Merge changes I1944666e,I30c789e0 into msm-4.9

* changes:
  Merge android-4.9.116 (52be322) into msm-4.9
  Merge android-4.9.115 (e6f9a8a) into msm-4.9
diff --git a/AndroidKernel.mk b/AndroidKernel.mk
index 26e5cb8..7233829 100644
--- a/AndroidKernel.mk
+++ b/AndroidKernel.mk
@@ -210,9 +210,11 @@
 			echo $(KERNEL_CONFIG_OVERRIDE) >> $(KERNEL_OUT)/.config; \
 			$(MAKE) -C $(TARGET_KERNEL_SOURCE) O=$(BUILD_ROOT_LOC)$(KERNEL_OUT) $(KERNEL_MAKE_ENV) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) oldconfig; fi
 
+.PHONY: kerneltags
 kerneltags: $(KERNEL_OUT) $(KERNEL_CONFIG)
 	$(MAKE) -C $(TARGET_KERNEL_SOURCE) O=$(BUILD_ROOT_LOC)$(KERNEL_OUT) $(KERNEL_MAKE_ENV) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) tags
 
+.PHONY: kernelconfig
 kernelconfig: $(KERNEL_OUT) $(KERNEL_CONFIG)
 	env KCONFIG_NOTIMESTAMP=true \
 	     $(MAKE) -C $(TARGET_KERNEL_SOURCE) O=$(BUILD_ROOT_LOC)$(KERNEL_OUT) $(KERNEL_MAKE_ENV) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) menuconfig
diff --git a/Documentation/devicetree/bindings/arm/msm/msm.txt b/Documentation/devicetree/bindings/arm/msm/msm.txt
index 0319e2f..ab58089 100644
--- a/Documentation/devicetree/bindings/arm/msm/msm.txt
+++ b/Documentation/devicetree/bindings/arm/msm/msm.txt
@@ -68,6 +68,9 @@
 - MSM8917
   compatible = "qcom,msm8917"
 
+- MSM8940
+  compatible = "qcom,msm8940"
+
 - MSM8936
   compatible = "qcom,msm8936"
 
@@ -279,6 +282,7 @@
 compatible = "qcom,msm8917-rumi"
 compatible = "qcom,msm8917-qrd"
 compatible = "qcom,msm8917-qrd-sku5"
+compatible = "qcom,msm8940-mtp"
 compatible = "qcom,msm8926-cdp"
 compatible = "qcom,msm8926-mtp"
 compatible = "qcom,msm8926-qrd"
diff --git a/Documentation/devicetree/bindings/drm/msm/mdss-dsi-panel.txt b/Documentation/devicetree/bindings/drm/msm/mdss-dsi-panel.txt
index c17970c..72c46f2 100644
--- a/Documentation/devicetree/bindings/drm/msm/mdss-dsi-panel.txt
+++ b/Documentation/devicetree/bindings/drm/msm/mdss-dsi-panel.txt
@@ -187,6 +187,9 @@
 					255 = default value.
 - qcom,mdss-brightness-max-level:	Specifies the max brightness level supported.
 					255 = default value.
+- qcom,bl-update-flag:			A string that specifies controls for backlight update of the panel.
+					"delay_until_first_frame" = Delay backlight update of the panel
+					until the first frame is received from the HW.
 - qcom,mdss-dsi-interleave-mode:	Specifies interleave mode.
 					0 = default value.
 - qcom,mdss-dsi-panel-type:		Specifies the panel operating mode.
@@ -599,6 +602,7 @@
 		qcom,mdss-dsi-bl-min-level = <1>;
 		qcom,mdss-dsi-bl-max-level = < 15>;
 		qcom,mdss-brightness-max-level = <255>;
+		qcom,bl-update-flag = "delay_until_first_frame";
 		qcom,mdss-dsi-interleave-mode = <0>;
 		qcom,mdss-dsi-panel-type = "dsi_video_mode";
 		qcom,mdss-dsi-te-check-enable;
diff --git a/Documentation/devicetree/bindings/power/supply/qcom/qpnp-qg.txt b/Documentation/devicetree/bindings/power/supply/qcom/qpnp-qg.txt
index 83f964d..1e49e96 100644
--- a/Documentation/devicetree/bindings/power/supply/qcom/qpnp-qg.txt
+++ b/Documentation/devicetree/bindings/power/supply/qcom/qpnp-qg.txt
@@ -308,6 +308,20 @@
 	Definition: Boolean property to support external-rsense based
 		    configuration.
 
+- qcom,shutdown-temp-diff
+	Usage:      optional
+	Value type: <u32>
+	Definition: The allowed battery temperature in deci-degree difference
+		    between shutdown and power-on to continue with the shutdown
+		    SOC. If not specified the default value is 6 degrees C (60).
+
+- qcom,shutdown-soc-threshold
+	Usage:      optional
+	Value type: <u32>
+	Definition: The SOC difference allowed between PON and SHUTDOWN SOC
+		    for the shutdown SOC to be used. If the difference is
+		    beyond this value the PON SOC is used.
+
 ==========================================================
 Second Level Nodes - Peripherals managed by QGAUGE driver
 ==========================================================
diff --git a/Documentation/devicetree/bindings/usb/msm-phy.txt b/Documentation/devicetree/bindings/usb/msm-phy.txt
index c28b05b..bcaa311 100644
--- a/Documentation/devicetree/bindings/usb/msm-phy.txt
+++ b/Documentation/devicetree/bindings/usb/msm-phy.txt
@@ -107,6 +107,9 @@
    microvolts or a value corresponding to voltage corner.
  - "pcs_clamp_enable_reg" : Clamps the phy data inputs and enables USB3
    autonomous mode.
+ - extcon : phandle to external connector devices which provide type-C based
+            "USB-HOST" cable events. This phandle is used for notifying number
+            of lanes used in case of USB+DP concurrent mode to driver.
 
 Example:
 	ssphy0: ssphy@f9b38000 {
diff --git a/arch/arm/boot/dts/qcom/sdxpoorwills-memory-256.dtsi b/arch/arm/boot/dts/qcom/sdxpoorwills-memory-256.dtsi
index 0c21814..6dc8354 100644
--- a/arch/arm/boot/dts/qcom/sdxpoorwills-memory-256.dtsi
+++ b/arch/arm/boot/dts/qcom/sdxpoorwills-memory-256.dtsi
@@ -15,5 +15,5 @@
 };
 
 &mss_mem {
-	reg = <0x87000000 0x8300000>;
+	reg = <0x86c00000 0x8300000>;
 };
diff --git a/arch/arm/boot/dts/qcom/sdxpoorwills-thermal.dtsi b/arch/arm/boot/dts/qcom/sdxpoorwills-thermal.dtsi
index 65467f9..0f2fe90 100644
--- a/arch/arm/boot/dts/qcom/sdxpoorwills-thermal.dtsi
+++ b/arch/arm/boot/dts/qcom/sdxpoorwills-thermal.dtsi
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -339,6 +339,35 @@
 		};
 	};
 
+	mdm-core-step {
+		polling-delay-passive = <0>;
+		polling-delay = <0>;
+		thermal-governor = "step_wise";
+		thermal-sensors = <&tsens0 4>;
+		trips {
+			mdm_step_trip0: mdm-step-trip-0 {
+				temperature = <95000>;
+				hysteresis = <5000>;
+				type = "passive";
+			};
+			mdm_step_trip1: mdm-step-trip-1 {
+				temperature = <105000>;
+				hysteresis = <5000>;
+				type = "passive";
+			};
+		};
+		cooling-maps {
+			modem_proc-lv11 {
+				trip = <&mdm_step_trip0>;
+				cooling-device = <&modem_proc 1 1>;
+			};
+			modem_proc_lvl3 {
+				trip = <&mdm_step_trip1>;
+				cooling-device = <&modem_proc 3 3>;
+			};
+		};
+	};
+
 	xo-therm-adc {
 		polling-delay-passive = <0>;
 		polling-delay = <0>;
diff --git a/arch/arm/boot/dts/qcom/sdxpoorwills-usb.dtsi b/arch/arm/boot/dts/qcom/sdxpoorwills-usb.dtsi
index a26aa71..8d3e8dc 100644
--- a/arch/arm/boot/dts/qcom/sdxpoorwills-usb.dtsi
+++ b/arch/arm/boot/dts/qcom/sdxpoorwills-usb.dtsi
@@ -73,6 +73,7 @@
 			interrupts = <0 133 0>;
 			usb-phy = <&usb2_phy>, <&usb3_qmp_phy>;
 			tx-fifo-resize;
+			snps,usb3-u1u2-disable;
 			linux,sysdev_is_parent;
 			snps,bus-suspend-enable;
 			snps,disable-clk-gating;
diff --git a/arch/arm/boot/dts/qcom/sdxpoorwills.dtsi b/arch/arm/boot/dts/qcom/sdxpoorwills.dtsi
index 1b1c430..cbd7e2e 100644
--- a/arch/arm/boot/dts/qcom/sdxpoorwills.dtsi
+++ b/arch/arm/boot/dts/qcom/sdxpoorwills.dtsi
@@ -65,7 +65,7 @@
 		mss_mem: mss_region@87400000 {
 			compatible = "removed-dma-pool";
 			no-map;
-			reg = <0x87000000 0x8700000>;
+			reg = <0x86c00000 0x8b00000>;
 			label = "mss_mem";
 		};
 
@@ -910,10 +910,10 @@
 	dcc: dcc_v2@10a2000 {
 		compatible = "qcom,dcc-v2";
 		reg = <0x10a2000 0x1000>,
-		      <0x10ae000 0x2000>;
+		      <0x10ae400 0x1c00>;
 		reg-names = "dcc-base", "dcc-ram-base";
 
-		dcc-ram-offset = <0x6000>;
+		dcc-ram-offset = <0x400>;
 	};
 
 	system_pm {
diff --git a/arch/arm/configs/msm8909-perf_defconfig b/arch/arm/configs/msm8909-perf_defconfig
index b64fade..d1640e0 100644
--- a/arch/arm/configs/msm8909-perf_defconfig
+++ b/arch/arm/configs/msm8909-perf_defconfig
@@ -25,6 +25,8 @@
 CONFIG_SCHED_TUNE=y
 CONFIG_DEFAULT_USE_ENERGY_AWARE=y
 CONFIG_BLK_DEV_INITRD=y
+# CONFIG_RD_BZIP2 is not set
+# CONFIG_RD_LZMA is not set
 # CONFIG_RD_XZ is not set
 # CONFIG_RD_LZO is not set
 # CONFIG_RD_LZ4 is not set
@@ -252,6 +254,9 @@
 CONFIG_KEYBOARD_GPIO=y
 CONFIG_INPUT_JOYSTICK=y
 CONFIG_INPUT_TOUCHSCREEN=y
+CONFIG_TOUCHSCREEN_GT9XX_v28=y
+CONFIG_TOUCHSCREEN_GT9XX_UPDATE=y
+CONFIG_TOUCHSCREEN_GT9XX_TOOL=y
 CONFIG_INPUT_MISC=y
 CONFIG_INPUT_QPNP_POWER_ON=y
 CONFIG_STMVL53L0X=y
@@ -263,6 +268,7 @@
 CONFIG_DIAG_CHAR=y
 CONFIG_DIAG_USES_SMD=y
 CONFIG_HW_RANDOM=y
+CONFIG_HW_RANDOM_MSM_LEGACY=y
 CONFIG_MSM_SMD_PKT=y
 CONFIG_MSM_ADSPRPC=y
 CONFIG_I2C_CHARDEV=y
@@ -279,6 +285,8 @@
 CONFIG_POWER_RESET=y
 CONFIG_POWER_RESET_QCOM=y
 CONFIG_QCOM_DLOAD_MODE=y
+CONFIG_POWER_RESET_SYSCON=y
+CONFIG_POWER_RESET_SYSCON_POWEROFF=y
 CONFIG_POWER_SUPPLY=y
 CONFIG_SMB1360_CHARGER_FG=y
 CONFIG_QPNP_VM_BMS=y
@@ -298,7 +306,6 @@
 CONFIG_REGULATOR_COOLING_DEVICE=y
 CONFIG_MFD_QCOM_RPM=y
 CONFIG_MFD_SPMI_PMIC=y
-CONFIG_MFD_SYSCON=y
 CONFIG_REGULATOR=y
 CONFIG_REGULATOR_FIXED_VOLTAGE=y
 CONFIG_REGULATOR_PROXY_CONSUMER=y
@@ -327,6 +334,10 @@
 CONFIG_MSM_ISPIF=y
 CONFIG_QCOM_KGSL=y
 CONFIG_FB=y
+CONFIG_FB_MSM=y
+CONFIG_FB_MSM_MDSS=y
+CONFIG_FB_MSM_MDSS_WRITEBACK=y
+CONFIG_FB_MSM_MDSS_MDP3=y
 CONFIG_BACKLIGHT_LCD_SUPPORT=y
 CONFIG_BACKLIGHT_CLASS_DEVICE=y
 CONFIG_SOUND=y
@@ -335,19 +346,14 @@
 CONFIG_SND_SOC=y
 CONFIG_UHID=y
 CONFIG_HID_A4TECH=y
-CONFIG_HID_APPLE=y
 CONFIG_HID_BELKIN=y
 CONFIG_HID_CHERRY=y
 CONFIG_HID_CHICONY=y
 CONFIG_HID_CYPRESS=y
-CONFIG_HID_ELECOM=y
 CONFIG_HID_EZKEY=y
 CONFIG_HID_KENSINGTON=y
 CONFIG_HID_LOGITECH=y
-CONFIG_HID_MAGICMOUSE=y
-CONFIG_HID_MICROSOFT=y
 CONFIG_HID_MONTEREY=y
-CONFIG_HID_MULTITOUCH=y
 CONFIG_USB=y
 CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
 CONFIG_USB_MON=y
@@ -383,7 +389,6 @@
 CONFIG_RTC_DRV_QPNP=y
 CONFIG_DMADEVICES=y
 CONFIG_QCOM_SPS_DMA=y
-CONFIG_SYNC_FILE=y
 CONFIG_UIO=y
 CONFIG_UIO_MSM_SHAREDMEM=y
 CONFIG_STAGING=y
@@ -395,6 +400,7 @@
 CONFIG_SPS_SUPPORT_NDP_BAM=y
 CONFIG_QPNP_REVID=y
 CONFIG_USB_BAM=y
+CONFIG_MSM_MDSS_PLL=y
 CONFIG_REMOTE_SPINLOCK_MSM=y
 CONFIG_MAILBOX=y
 CONFIG_ARM_SMMU=y
@@ -454,13 +460,15 @@
 CONFIG_PRINTK_TIME=y
 CONFIG_DEBUG_INFO=y
 CONFIG_FRAME_WARN=2048
+CONFIG_DEBUG_FS=y
 CONFIG_MAGIC_SYSRQ=y
 CONFIG_WQ_WATCHDOG=y
 CONFIG_PANIC_TIMEOUT=5
 CONFIG_PANIC_ON_SCHED_BUG=y
 CONFIG_PANIC_ON_RT_THROTTLING=y
 # CONFIG_DEBUG_PREEMPT is not set
-CONFIG_FUNCTION_TRACER=y
+CONFIG_STACKTRACE=y
+# CONFIG_FTRACE is not set
 CONFIG_DEBUG_SET_MODULE_RONX=y
 CONFIG_SECURITY_PERF_EVENTS_RESTRICT=y
 CONFIG_SECURITY=y
diff --git a/arch/arm/configs/msm8909_defconfig b/arch/arm/configs/msm8909_defconfig
index 17640c9..da3fc5f 100644
--- a/arch/arm/configs/msm8909_defconfig
+++ b/arch/arm/configs/msm8909_defconfig
@@ -271,6 +271,9 @@
 CONFIG_INPUT_JOYSTICK=y
 CONFIG_JOYSTICK_XPAD=y
 CONFIG_INPUT_TOUCHSCREEN=y
+CONFIG_TOUCHSCREEN_GT9XX_v28=y
+CONFIG_TOUCHSCREEN_GT9XX_UPDATE=y
+CONFIG_TOUCHSCREEN_GT9XX_TOOL=y
 CONFIG_INPUT_MISC=y
 CONFIG_INPUT_QPNP_POWER_ON=y
 CONFIG_STMVL53L0X=y
@@ -304,6 +307,8 @@
 CONFIG_POWER_RESET=y
 CONFIG_POWER_RESET_QCOM=y
 CONFIG_QCOM_DLOAD_MODE=y
+CONFIG_POWER_RESET_SYSCON=y
+CONFIG_POWER_RESET_SYSCON_POWEROFF=y
 CONFIG_POWER_SUPPLY=y
 CONFIG_SMB1360_CHARGER_FG=y
 CONFIG_QPNP_VM_BMS=y
@@ -324,7 +329,6 @@
 CONFIG_REGULATOR_COOLING_DEVICE=y
 CONFIG_MFD_QCOM_RPM=y
 CONFIG_MFD_SPMI_PMIC=y
-CONFIG_MFD_SYSCON=y
 CONFIG_REGULATOR=y
 CONFIG_REGULATOR_FIXED_VOLTAGE=y
 CONFIG_REGULATOR_PROXY_CONSUMER=y
@@ -354,6 +358,10 @@
 CONFIG_QCOM_KGSL=y
 CONFIG_FB=y
 CONFIG_FB_VIRTUAL=y
+CONFIG_FB_MSM=y
+CONFIG_FB_MSM_MDSS=y
+CONFIG_FB_MSM_MDSS_WRITEBACK=y
+CONFIG_FB_MSM_MDSS_MDP3=y
 CONFIG_BACKLIGHT_LCD_SUPPORT=y
 CONFIG_BACKLIGHT_CLASS_DEVICE=y
 CONFIG_LOGO=y
@@ -419,7 +427,6 @@
 CONFIG_RTC_DRV_QPNP=y
 CONFIG_DMADEVICES=y
 CONFIG_QCOM_SPS_DMA=y
-CONFIG_SYNC_FILE=y
 CONFIG_UIO=y
 CONFIG_UIO_MSM_SHAREDMEM=y
 CONFIG_STAGING=y
@@ -433,6 +440,7 @@
 CONFIG_SPS_SUPPORT_NDP_BAM=y
 CONFIG_QPNP_REVID=y
 CONFIG_USB_BAM=y
+CONFIG_MSM_MDSS_PLL=y
 CONFIG_REMOTE_SPINLOCK_MSM=y
 CONFIG_MAILBOX=y
 CONFIG_ARM_SMMU=y
diff --git a/arch/arm/configs/msm8937-perf_defconfig b/arch/arm/configs/msm8937-perf_defconfig
index df07ed8..e6e0b2a 100644
--- a/arch/arm/configs/msm8937-perf_defconfig
+++ b/arch/arm/configs/msm8937-perf_defconfig
@@ -58,6 +58,7 @@
 CONFIG_ARCH_QCOM=y
 CONFIG_ARCH_MSM8937=y
 CONFIG_ARCH_MSM8917=y
+CONFIG_ARCH_QM215=y
 CONFIG_ARCH_SDM439=y
 CONFIG_ARCH_SDM429=y
 # CONFIG_VDSO is not set
@@ -264,6 +265,7 @@
 CONFIG_BLK_DEV_DM=y
 CONFIG_DM_CRYPT=y
 CONFIG_DM_REQ_CRYPT=y
+CONFIG_DM_DEFAULT_KEY=y
 CONFIG_DM_UEVENT=y
 CONFIG_DM_VERITY=y
 CONFIG_DM_VERITY_FEC=y
diff --git a/arch/arm/configs/msm8937_defconfig b/arch/arm/configs/msm8937_defconfig
index abb8c6e..93d4d35 100644
--- a/arch/arm/configs/msm8937_defconfig
+++ b/arch/arm/configs/msm8937_defconfig
@@ -60,6 +60,7 @@
 CONFIG_ARCH_QCOM=y
 CONFIG_ARCH_MSM8937=y
 CONFIG_ARCH_MSM8917=y
+CONFIG_ARCH_QM215=y
 CONFIG_ARCH_SDM439=y
 CONFIG_ARCH_SDM429=y
 # CONFIG_VDSO is not set
@@ -268,6 +269,7 @@
 CONFIG_BLK_DEV_DM=y
 CONFIG_DM_CRYPT=y
 CONFIG_DM_REQ_CRYPT=y
+CONFIG_DM_DEFAULT_KEY=y
 CONFIG_DM_UEVENT=y
 CONFIG_DM_VERITY=y
 CONFIG_DM_VERITY_FEC=y
diff --git a/arch/arm/configs/msm8937go-perf_defconfig b/arch/arm/configs/msm8937go-perf_defconfig
index 3385173..3a38886 100644
--- a/arch/arm/configs/msm8937go-perf_defconfig
+++ b/arch/arm/configs/msm8937go-perf_defconfig
@@ -59,6 +59,7 @@
 CONFIG_ARCH_QCOM=y
 CONFIG_ARCH_MSM8937=y
 CONFIG_ARCH_MSM8917=y
+CONFIG_ARCH_QM215=y
 CONFIG_ARCH_SDM439=y
 CONFIG_ARCH_SDM429=y
 # CONFIG_VDSO is not set
@@ -357,10 +358,13 @@
 CONFIG_POWER_SUPPLY=y
 CONFIG_QPNP_FG=y
 CONFIG_SMB135X_CHARGER=y
+CONFIG_SMB1360_CHARGER_FG=y
 CONFIG_SMB1355_SLAVE_CHARGER=y
 CONFIG_SMB1351_USB_CHARGER=y
 CONFIG_QPNP_SMB5=y
 CONFIG_QPNP_SMBCHARGER=y
+CONFIG_QPNP_VM_BMS=y
+CONFIG_QPNP_LINEAR_CHARGER=y
 CONFIG_QPNP_TYPEC=y
 CONFIG_QPNP_QG=y
 CONFIG_MSM_APM=y
@@ -516,6 +520,7 @@
 CONFIG_LEDS_QPNP_WLED=y
 CONFIG_LEDS_QPNP_HAPTICS=y
 CONFIG_LEDS_QPNP_VIBRATOR_LDO=y
+CONFIG_LEDS_QPNP_VIBRATOR=y
 CONFIG_LEDS_TRIGGERS=y
 CONFIG_LEDS_TRIGGER_TIMER=y
 CONFIG_EDAC=y
diff --git a/arch/arm/configs/msm8937go_defconfig b/arch/arm/configs/msm8937go_defconfig
index 74af908..0f7c823 100644
--- a/arch/arm/configs/msm8937go_defconfig
+++ b/arch/arm/configs/msm8937go_defconfig
@@ -61,6 +61,7 @@
 CONFIG_ARCH_QCOM=y
 CONFIG_ARCH_MSM8937=y
 CONFIG_ARCH_MSM8917=y
+CONFIG_ARCH_QM215=y
 CONFIG_ARCH_SDM439=y
 CONFIG_ARCH_SDM429=y
 # CONFIG_VDSO is not set
@@ -363,10 +364,13 @@
 CONFIG_POWER_SUPPLY=y
 CONFIG_QPNP_FG=y
 CONFIG_SMB135X_CHARGER=y
+CONFIG_SMB1360_CHARGER_FG=y
 CONFIG_SMB1355_SLAVE_CHARGER=y
 CONFIG_SMB1351_USB_CHARGER=y
 CONFIG_QPNP_SMB5=y
 CONFIG_QPNP_SMBCHARGER=y
+CONFIG_QPNP_VM_BMS=y
+CONFIG_QPNP_LINEAR_CHARGER=y
 CONFIG_QPNP_TYPEC=y
 CONFIG_QPNP_QG=y
 CONFIG_MSM_APM=y
@@ -524,6 +528,7 @@
 CONFIG_LEDS_QPNP_WLED=y
 CONFIG_LEDS_QPNP_HAPTICS=y
 CONFIG_LEDS_QPNP_VIBRATOR_LDO=y
+CONFIG_LEDS_QPNP_VIBRATOR=y
 CONFIG_LEDS_TRIGGERS=y
 CONFIG_LEDS_TRIGGER_TIMER=y
 CONFIG_EDAC=y
diff --git a/arch/arm/configs/sdm670-perf_defconfig b/arch/arm/configs/sdm670-perf_defconfig
index e367824..5244452 100644
--- a/arch/arm/configs/sdm670-perf_defconfig
+++ b/arch/arm/configs/sdm670-perf_defconfig
@@ -505,7 +505,10 @@
 CONFIG_QMP_DEBUGFS_CLIENT=y
 CONFIG_MSM_REMOTEQDSS=y
 CONFIG_QCOM_BIMC_BWMON=y
+CONFIG_ARM_MEMLAT_MON=y
+CONFIG_DEVFREQ_GOV_QCOM_BW_HWMON=y
 CONFIG_DEVFREQ_GOV_QCOM_CACHE_HWMON=y
+CONFIG_DEVFREQ_GOV_MEMLAT=y
 CONFIG_QCOM_DEVFREQ_DEVBW=y
 CONFIG_EXTCON_USB_GPIO=y
 CONFIG_IIO=y
diff --git a/arch/arm/configs/sdm670_defconfig b/arch/arm/configs/sdm670_defconfig
index d905ae5..bffed7c 100644
--- a/arch/arm/configs/sdm670_defconfig
+++ b/arch/arm/configs/sdm670_defconfig
@@ -527,7 +527,10 @@
 CONFIG_QMP_DEBUGFS_CLIENT=y
 CONFIG_MSM_REMOTEQDSS=y
 CONFIG_QCOM_BIMC_BWMON=y
+CONFIG_ARM_MEMLAT_MON=y
+CONFIG_DEVFREQ_GOV_QCOM_BW_HWMON=y
 CONFIG_DEVFREQ_GOV_QCOM_CACHE_HWMON=y
+CONFIG_DEVFREQ_GOV_MEMLAT=y
 CONFIG_QCOM_DEVFREQ_DEVBW=y
 CONFIG_EXTCON_USB_GPIO=y
 CONFIG_IIO=y
diff --git a/arch/arm/configs/sdxpoorwills-auto-perf_defconfig b/arch/arm/configs/sdxpoorwills-auto-perf_defconfig
new file mode 100644
index 0000000..e1fed15
--- /dev/null
+++ b/arch/arm/configs/sdxpoorwills-auto-perf_defconfig
@@ -0,0 +1,441 @@
+CONFIG_AUDIT=y
+# CONFIG_AUDITSYSCALL is not set
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+CONFIG_CGROUPS=y
+CONFIG_CGROUP_DEBUG=y
+CONFIG_CGROUP_FREEZER=y
+CONFIG_CGROUP_CPUACCT=y
+CONFIG_CGROUP_SCHED=y
+# CONFIG_FAIR_GROUP_SCHED is not set
+CONFIG_RT_GROUP_SCHED=y
+CONFIG_NAMESPACES=y
+# CONFIG_UTS_NS is not set
+# CONFIG_PID_NS is not set
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_KALLSYMS_ALL=y
+CONFIG_EMBEDDED=y
+# CONFIG_SLUB_DEBUG is not set
+CONFIG_PROFILING=y
+CONFIG_CC_STACKPROTECTOR_REGULAR=y
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+CONFIG_MODULE_FORCE_UNLOAD=y
+CONFIG_PARTITION_ADVANCED=y
+CONFIG_ARCH_QCOM=y
+CONFIG_ARCH_SDXPOORWILLS=y
+CONFIG_PCI_MSM=y
+CONFIG_PREEMPT=y
+CONFIG_AEABI=y
+CONFIG_CMA=y
+CONFIG_BUILD_ARM_APPENDED_DTB_IMAGE=y
+CONFIG_CPU_FREQ=y
+CONFIG_CPU_FREQ_GOV_ONDEMAND=y
+CONFIG_CPU_FREQ_GOV_INTERACTIVE=y
+CONFIG_CPU_BOOST=y
+CONFIG_CPU_FREQ_MSM=y
+CONFIG_CPU_IDLE=y
+CONFIG_VFP=y
+CONFIG_NEON=y
+# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
+CONFIG_PM_AUTOSLEEP=y
+CONFIG_PM_WAKELOCKS=y
+CONFIG_PM_WAKELOCKS_LIMIT=0
+# CONFIG_PM_WAKELOCKS_GC is not set
+CONFIG_NET=y
+CONFIG_PACKET=y
+CONFIG_UNIX=y
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+CONFIG_IP_ADVANCED_ROUTER=y
+CONFIG_IP_MULTIPLE_TABLES=y
+CONFIG_NET_IPGRE_DEMUX=y
+CONFIG_NET_IPGRE=y
+CONFIG_IP_MROUTE=y
+CONFIG_IP_MROUTE_MULTIPLE_TABLES=y
+CONFIG_IP_PIMSM_V2=y
+CONFIG_IPV6_MIP6=y
+CONFIG_IPV6_GRE=y
+CONFIG_IPV6_MULTIPLE_TABLES=y
+CONFIG_IPV6_SUBTREES=y
+CONFIG_IPV6_MROUTE=y
+CONFIG_IPV6_MROUTE_MULTIPLE_TABLES=y
+CONFIG_IPV6_PIMSM_V2=y
+CONFIG_NETFILTER=y
+CONFIG_NETFILTER_DEBUG=y
+CONFIG_NF_CONNTRACK=y
+CONFIG_NF_CONNTRACK_SECMARK=y
+CONFIG_NF_CONNTRACK_EVENTS=y
+CONFIG_NF_CONNTRACK_TIMEOUT=y
+CONFIG_NF_CONNTRACK_TIMESTAMP=y
+CONFIG_NF_CT_PROTO_UDPLITE=y
+CONFIG_NF_CONNTRACK_AMANDA=y
+CONFIG_NF_CONNTRACK_FTP=y
+CONFIG_NF_CONNTRACK_H323=y
+CONFIG_NF_CONNTRACK_IRC=y
+CONFIG_NF_CONNTRACK_NETBIOS_NS=y
+CONFIG_NF_CONNTRACK_SNMP=y
+CONFIG_NF_CONNTRACK_PPTP=y
+CONFIG_NF_CONNTRACK_SIP=y
+CONFIG_NF_CONNTRACK_TFTP=y
+CONFIG_NF_CT_NETLINK=y
+CONFIG_NF_CT_NETLINK_TIMEOUT=y
+CONFIG_NF_CT_NETLINK_HELPER=y
+CONFIG_NETFILTER_NETLINK_GLUE_CT=y
+CONFIG_NETFILTER_XT_TARGET_CONNSECMARK=y
+CONFIG_NETFILTER_XT_TARGET_LOG=y
+CONFIG_NETFILTER_XT_TARGET_MARK=y
+CONFIG_NETFILTER_XT_TARGET_NFLOG=y
+CONFIG_NETFILTER_XT_TARGET_NFQUEUE=y
+CONFIG_NETFILTER_XT_TARGET_NOTRACK=y
+CONFIG_NETFILTER_XT_TARGET_TPROXY=y
+CONFIG_NETFILTER_XT_TARGET_TRACE=y
+CONFIG_NETFILTER_XT_TARGET_SECMARK=y
+CONFIG_NETFILTER_XT_TARGET_TCPMSS=y
+CONFIG_NETFILTER_XT_MATCH_ADDRTYPE=y
+CONFIG_NETFILTER_XT_MATCH_CONNLABEL=y
+CONFIG_NETFILTER_XT_MATCH_CONNLIMIT=y
+CONFIG_NETFILTER_XT_MATCH_CONNMARK=y
+CONFIG_NETFILTER_XT_MATCH_CONNTRACK=y
+CONFIG_NETFILTER_XT_MATCH_DSCP=y
+CONFIG_NETFILTER_XT_MATCH_ESP=y
+CONFIG_NETFILTER_XT_MATCH_IPRANGE=y
+CONFIG_NETFILTER_XT_MATCH_LIMIT=y
+CONFIG_NETFILTER_XT_MATCH_MULTIPORT=y
+CONFIG_NETFILTER_XT_MATCH_PHYSDEV=m
+CONFIG_NETFILTER_XT_MATCH_PKTTYPE=y
+CONFIG_NETFILTER_XT_MATCH_STATE=y
+CONFIG_IP_SET=y
+CONFIG_NF_CONNTRACK_IPV4=y
+CONFIG_IP_NF_IPTABLES=y
+CONFIG_IP_NF_MATCH_AH=y
+CONFIG_IP_NF_MATCH_ECN=y
+CONFIG_IP_NF_MATCH_TTL=y
+CONFIG_IP_NF_FILTER=y
+CONFIG_IP_NF_TARGET_REJECT=y
+CONFIG_IP_NF_NAT=y
+CONFIG_IP_NF_TARGET_MASQUERADE=y
+CONFIG_IP_NF_TARGET_NATTYPE_MODULE=y
+CONFIG_IP_NF_TARGET_NETMAP=y
+CONFIG_IP_NF_TARGET_REDIRECT=y
+CONFIG_IP_NF_MANGLE=y
+CONFIG_IP_NF_TARGET_ECN=y
+CONFIG_IP_NF_TARGET_TTL=y
+CONFIG_IP_NF_RAW=y
+CONFIG_IP_NF_SECURITY=y
+CONFIG_IP_NF_ARPTABLES=y
+CONFIG_IP_NF_ARPFILTER=y
+CONFIG_IP_NF_ARP_MANGLE=y
+CONFIG_NF_CONNTRACK_IPV6=y
+CONFIG_IP6_NF_IPTABLES=y
+CONFIG_IP6_NF_MATCH_AH=y
+CONFIG_IP6_NF_MATCH_FRAG=y
+CONFIG_IP6_NF_MATCH_OPTS=y
+CONFIG_IP6_NF_MATCH_HL=y
+CONFIG_IP6_NF_MATCH_IPV6HEADER=y
+CONFIG_IP6_NF_MATCH_MH=y
+CONFIG_IP6_NF_MATCH_RT=y
+CONFIG_IP6_NF_FILTER=y
+CONFIG_IP6_NF_TARGET_REJECT=y
+CONFIG_IP6_NF_MANGLE=y
+CONFIG_IP6_NF_RAW=y
+CONFIG_BRIDGE_NF_EBTABLES=y
+CONFIG_BRIDGE_EBT_BROUTE=y
+CONFIG_BRIDGE_EBT_T_FILTER=y
+CONFIG_BRIDGE_EBT_T_NAT=y
+CONFIG_BRIDGE_EBT_ARP=y
+CONFIG_BRIDGE_EBT_IP=y
+CONFIG_BRIDGE_EBT_IP6=y
+CONFIG_BRIDGE_EBT_ARPREPLY=y
+CONFIG_BRIDGE_EBT_DNAT=y
+CONFIG_BRIDGE_EBT_SNAT=y
+CONFIG_BRIDGE=y
+CONFIG_VLAN_8021Q=y
+CONFIG_NET_SCHED=y
+CONFIG_NET_SCH_PRIO=y
+CONFIG_RMNET_DATA=y
+CONFIG_RMNET_DATA_FC=y
+CONFIG_RMNET_DATA_DEBUG_PKT=y
+CONFIG_BT=y
+CONFIG_BT_RFCOMM=y
+CONFIG_BT_RFCOMM_TTY=y
+CONFIG_BT_BNEP=y
+CONFIG_BT_BNEP_MC_FILTER=y
+CONFIG_BT_BNEP_PROTO_FILTER=y
+CONFIG_BT_HIDP=y
+CONFIG_BT_HCIUART=y
+CONFIG_BT_HCIUART_H4=y
+CONFIG_MSM_BT_POWER=y
+CONFIG_CFG80211=y
+CONFIG_CFG80211_DEBUGFS=y
+CONFIG_CFG80211_INTERNAL_REGDB=y
+CONFIG_CFG80211_WEXT=y
+CONFIG_RFKILL=y
+CONFIG_IPC_ROUTER=y
+CONFIG_IPC_ROUTER_SECURITY=y
+CONFIG_DMA_CMA=y
+CONFIG_CMA_SIZE_MBYTES=12
+CONFIG_MTD=y
+CONFIG_MTD_TESTS=m
+CONFIG_MTD_CMDLINE_PARTS=y
+CONFIG_MTD_BLOCK=y
+CONFIG_MTD_MSM_QPIC_NAND=y
+CONFIG_MTD_UBI=y
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_RAM=y
+CONFIG_QSEECOM=y
+CONFIG_SCSI=y
+CONFIG_BLK_DEV_SD=y
+CONFIG_CHR_DEV_SG=y
+CONFIG_CHR_DEV_SCH=y
+CONFIG_SCSI_CONSTANTS=y
+CONFIG_SCSI_LOGGING=y
+CONFIG_SCSI_SCAN_ASYNC=y
+CONFIG_NETDEVICES=y
+CONFIG_TUN=y
+# CONFIG_NET_VENDOR_BROADCOM is not set
+# CONFIG_NET_VENDOR_CIRRUS is not set
+# CONFIG_NET_VENDOR_FARADAY is not set
+# CONFIG_NET_VENDOR_INTEL is not set
+CONFIG_KS8851=y
+# CONFIG_NET_VENDOR_MICROCHIP is not set
+# CONFIG_NET_VENDOR_NATSEMI is not set
+# CONFIG_NET_VENDOR_SEEQ is not set
+# CONFIG_NET_VENDOR_SMSC is not set
+# CONFIG_NET_VENDOR_STMICRO is not set
+CONFIG_AT803X_PHY=y
+CONFIG_PPP=y
+CONFIG_PPP_ASYNC=y
+CONFIG_USB_USBNET=y
+CONFIG_USB_NET_SMSC75XX=y
+CONFIG_USB_NET_SMSC95XX=y
+CONFIG_WCNSS_MEM_PRE_ALLOC=y
+CONFIG_CNSS=y
+CONFIG_CNSS_SDIO=y
+CONFIG_CNSS_PCI=y
+CONFIG_CLD_HL_SDIO_CORE=y
+CONFIG_CLD_LL_CORE=y
+CONFIG_CNSS_LOGGER=y
+# CONFIG_INPUT_MOUSEDEV is not set
+CONFIG_INPUT_EVDEV=y
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+CONFIG_INPUT_MISC=y
+CONFIG_INPUT_QPNP_POWER_ON=y
+CONFIG_INPUT_UINPUT=y
+CONFIG_INPUT_GPIO=m
+CONFIG_SERIO_LIBPS2=y
+# CONFIG_LEGACY_PTYS is not set
+CONFIG_SERIAL_MSM=y
+CONFIG_SERIAL_MSM_HS=y
+CONFIG_DIAG_CHAR=y
+CONFIG_HW_RANDOM=y
+CONFIG_HW_RANDOM_MSM_LEGACY=y
+CONFIG_I2C=y
+CONFIG_I2C_CHARDEV=y
+CONFIG_I2C_MSM_V2=y
+CONFIG_SPI=y
+CONFIG_SPI_QUP=y
+CONFIG_SPI_SPIDEV=m
+CONFIG_SPMI=y
+CONFIG_SPMI_MSM_PMIC_ARB_DEBUG=y
+CONFIG_PTP_1588_CLOCK=y
+CONFIG_PINCTRL_SDXPOORWILLS=y
+CONFIG_PINCTRL_QCOM_SPMI_PMIC=y
+CONFIG_DEBUG_GPIO=y
+CONFIG_GPIO_SYSFS=y
+CONFIG_POWER_RESET=y
+CONFIG_POWER_RESET_QCOM=y
+CONFIG_QCOM_DLOAD_MODE=y
+CONFIG_POWER_SUPPLY=y
+CONFIG_SMB1351_USB_CHARGER=y
+CONFIG_SMB138X_CHARGER=y
+CONFIG_SENSORS_QPNP_ADC_VOLTAGE=y
+CONFIG_THERMAL=y
+CONFIG_THERMAL_WRITABLE_TRIPS=y
+CONFIG_THERMAL_GOV_USER_SPACE=y
+CONFIG_THERMAL_GOV_LOW_LIMITS=y
+CONFIG_CPU_THERMAL=y
+CONFIG_THERMAL_QPNP=y
+CONFIG_THERMAL_TSENS=y
+CONFIG_QTI_AOP_REG_COOLING_DEVICE=y
+CONFIG_QTI_QMI_COOLING_DEVICE=y
+CONFIG_REGULATOR_COOLING_DEVICE=y
+CONFIG_MFD_I2C_PMIC=y
+CONFIG_MFD_SPMI_PMIC=y
+CONFIG_MFD_SYSCON=y
+CONFIG_REGULATOR=y
+CONFIG_REGULATOR_FIXED_VOLTAGE=y
+CONFIG_REGULATOR_QPNP=y
+CONFIG_REGULATOR_RPMH=y
+CONFIG_SOUND=y
+CONFIG_SND=y
+CONFIG_SND_DYNAMIC_MINORS=y
+CONFIG_SND_USB_AUDIO=y
+CONFIG_SND_USB_AUDIO_QMI=y
+CONFIG_SND_SOC=y
+CONFIG_UHID=y
+CONFIG_HID_APPLE=y
+CONFIG_HID_ELECOM=y
+CONFIG_HID_MAGICMOUSE=y
+CONFIG_HID_MICROSOFT=y
+CONFIG_HID_MULTITOUCH=y
+CONFIG_USB=y
+CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_ACM=y
+CONFIG_USB_STORAGE=y
+CONFIG_USB_STORAGE_DEBUG=y
+CONFIG_USB_STORAGE_DATAFAB=y
+CONFIG_USB_STORAGE_FREECOM=y
+CONFIG_USB_STORAGE_ISD200=y
+CONFIG_USB_STORAGE_USBAT=y
+CONFIG_USB_STORAGE_SDDR09=y
+CONFIG_USB_STORAGE_SDDR55=y
+CONFIG_USB_STORAGE_JUMPSHOT=y
+CONFIG_USB_STORAGE_ALAUDA=y
+CONFIG_USB_STORAGE_ONETOUCH=y
+CONFIG_USB_STORAGE_KARMA=y
+CONFIG_USB_STORAGE_CYPRESS_ATACB=y
+CONFIG_USB_DWC3=y
+CONFIG_USB_DWC3_MSM=y
+CONFIG_USB_EHSET_TEST_FIXTURE=y
+CONFIG_USB_LINK_LAYER_TEST=y
+CONFIG_NOP_USB_XCEIV=y
+CONFIG_USB_MSM_SSPHY_QMP=y
+CONFIG_MSM_HSUSB_PHY=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_DEBUG_FILES=y
+CONFIG_USB_GADGET_VBUS_DRAW=500
+CONFIG_USB_CONFIGFS=y
+CONFIG_USB_CONFIGFS_SERIAL=y
+CONFIG_USB_CONFIGFS_MASS_STORAGE=y
+CONFIG_USB_CONFIGFS_F_FS=y
+CONFIG_USB_CONFIGFS_UEVENT=y
+CONFIG_USB_CONFIGFS_F_UAC1=y
+CONFIG_USB_CONFIGFS_F_DIAG=y
+CONFIG_USB_CONFIGFS_F_CDEV=y
+CONFIG_USB_CONFIGFS_F_GSI=y
+CONFIG_USB_CONFIGFS_F_QDSS=y
+CONFIG_MMC=y
+CONFIG_MMC_PERF_PROFILING=y
+CONFIG_MMC_PARANOID_SD_INIT=y
+CONFIG_MMC_CLKGATE=y
+CONFIG_MMC_BLOCK_MINORS=32
+CONFIG_MMC_BLOCK_DEFERRED_RESUME=y
+CONFIG_MMC_TEST=m
+CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_PLTFM=y
+CONFIG_MMC_SDHCI_MSM=y
+CONFIG_RTC_CLASS=y
+CONFIG_RTC_DRV_QPNP=y
+CONFIG_DMADEVICES=y
+CONFIG_QCOM_SPS_DMA=y
+CONFIG_UIO=y
+CONFIG_STAGING=y
+CONFIG_ION=y
+CONFIG_ION_MSM=y
+CONFIG_GSI=y
+CONFIG_IPA3=y
+CONFIG_IPA_WDI_UNIFIED_API=y
+CONFIG_RMNET_IPA3=y
+CONFIG_ECM_IPA=y
+CONFIG_RNDIS_IPA=y
+CONFIG_IPA_UT=y
+CONFIG_SPS=y
+CONFIG_SPS_SUPPORT_NDP_BAM=y
+CONFIG_EP_PCIE=y
+CONFIG_EP_PCIE_HW=y
+CONFIG_QPNP_REVID=y
+CONFIG_MSM_MHI_DEV=y
+CONFIG_USB_BAM=y
+CONFIG_MSM_CLK_RPMH=y
+CONFIG_MSM_CLK_AOP_QMP=y
+CONFIG_MDM_GCC_SDXPOORWILLS=y
+CONFIG_MDM_CLOCK_CPU_SDXPOORWILLS=y
+CONFIG_MDM_DEBUGCC_SDXPOORWILLS=y
+CONFIG_REMOTE_SPINLOCK_MSM=y
+CONFIG_MSM_QMP=y
+CONFIG_IOMMU_IO_PGTABLE_FAST=y
+CONFIG_ARM_SMMU=y
+CONFIG_QCOM_LAZY_MAPPING=y
+CONFIG_IOMMU_DEBUG=y
+CONFIG_IOMMU_DEBUG_TRACKING=y
+CONFIG_IOMMU_TESTS=y
+CONFIG_QCOM_SCM=y
+CONFIG_MSM_BOOT_STATS=y
+CONFIG_QCOM_WATCHDOG_V2=y
+CONFIG_QCOM_MEMORY_DUMP_V2=y
+CONFIG_QCOM_BUS_SCALING=y
+CONFIG_QCOM_BUS_CONFIG_RPMH=y
+CONFIG_MSM_SMEM=y
+CONFIG_MSM_GLINK=y
+CONFIG_MSM_GLINK_LOOPBACK_SERVER=y
+CONFIG_MSM_GLINK_SMEM_NATIVE_XPRT=y
+CONFIG_TRACER_PKT=y
+CONFIG_QTI_RPMH_API=y
+CONFIG_MSM_SMP2P=y
+CONFIG_MSM_IPC_ROUTER_GLINK_XPRT=y
+CONFIG_MSM_QMI_INTERFACE=y
+CONFIG_MSM_GLINK_PKT=y
+CONFIG_MSM_SUBSYSTEM_RESTART=y
+CONFIG_MSM_PIL=y
+CONFIG_MSM_PIL_SSR_GENERIC=y
+CONFIG_QCOM_COMMAND_DB=y
+CONFIG_MSM_PM=y
+CONFIG_QCOM_DCC_V2=y
+CONFIG_QTI_RPM_STATS_LOG=y
+CONFIG_QCOM_FORCE_WDOG_BITE_ON_PANIC=y
+CONFIG_QMP_DEBUGFS_CLIENT=y
+CONFIG_ARM_MEMLAT_MON=y
+CONFIG_DEVFREQ_GOV_MEMLAT=y
+CONFIG_QCOM_DEVFREQ_DEVBW=y
+CONFIG_EXTCON_QCOM_SPMI_MISC=y
+CONFIG_IIO=y
+CONFIG_PWM=y
+CONFIG_PWM_QPNP=y
+CONFIG_QCOM_SHOW_RESUME_IRQ=y
+CONFIG_ANDROID=y
+CONFIG_EXT3_FS=y
+CONFIG_EXT4_FS_SECURITY=y
+CONFIG_VFAT_FS=y
+CONFIG_TMPFS=y
+CONFIG_UBIFS_FS=y
+CONFIG_UBIFS_FS_ADVANCED_COMPR=y
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_ASCII=y
+CONFIG_NLS_ISO8859_1=y
+CONFIG_PRINTK_TIME=y
+CONFIG_DEBUG_INFO=y
+CONFIG_MAGIC_SYSRQ=y
+CONFIG_PANIC_ON_RECURSIVE_FAULT=y
+CONFIG_PANIC_TIMEOUT=5
+# CONFIG_SCHED_DEBUG is not set
+CONFIG_SCHEDSTATS=y
+CONFIG_SCHED_STACK_END_CHECK=y
+# CONFIG_DEBUG_PREEMPT is not set
+CONFIG_IPC_LOGGING=y
+CONFIG_BLK_DEV_IO_TRACE=y
+CONFIG_DEBUG_SET_MODULE_RONX=y
+CONFIG_CORESIGHT=y
+CONFIG_CORESIGHT_REMOTE_ETM=y
+CONFIG_CORESIGHT_REMOTE_ETM_DEFAULT_ENABLE=0
+CONFIG_CORESIGHT_STM=y
+CONFIG_CORESIGHT_TPDA=y
+CONFIG_CORESIGHT_TPDM=y
+CONFIG_CORESIGHT_CTI=y
+CONFIG_CORESIGHT_EVENT=y
+CONFIG_CORESIGHT_HWEVENT=y
+CONFIG_SECURITY=y
+CONFIG_SECURITY_NETWORK=y
+CONFIG_HARDENED_USERCOPY=y
+CONFIG_SECURITY_SELINUX=y
+# CONFIG_SECURITY_SELINUX_AVC_STATS is not set
+CONFIG_CRYPTO_DEV_QCOM_MSM_QCE=y
+CONFIG_CRYPTO_DEV_QCRYPTO=y
+CONFIG_CRYPTO_DEV_QCEDEV=y
+CONFIG_QMI_ENCDEC=y
diff --git a/arch/arm/configs/sdxpoorwills-auto_defconfig b/arch/arm/configs/sdxpoorwills-auto_defconfig
new file mode 100644
index 0000000..54072cc
--- /dev/null
+++ b/arch/arm/configs/sdxpoorwills-auto_defconfig
@@ -0,0 +1,468 @@
+CONFIG_AUDIT=y
+# CONFIG_AUDITSYSCALL is not set
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+CONFIG_CGROUPS=y
+CONFIG_CGROUP_DEBUG=y
+CONFIG_CGROUP_FREEZER=y
+CONFIG_CGROUP_CPUACCT=y
+CONFIG_CGROUP_SCHED=y
+# CONFIG_FAIR_GROUP_SCHED is not set
+CONFIG_RT_GROUP_SCHED=y
+CONFIG_NAMESPACES=y
+# CONFIG_UTS_NS is not set
+# CONFIG_PID_NS is not set
+CONFIG_BLK_DEV_INITRD=y
+# CONFIG_RD_XZ is not set
+# CONFIG_RD_LZ4 is not set
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_KALLSYMS_ALL=y
+CONFIG_EMBEDDED=y
+CONFIG_PROFILING=y
+CONFIG_CC_STACKPROTECTOR_REGULAR=y
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+CONFIG_MODULE_FORCE_UNLOAD=y
+CONFIG_PARTITION_ADVANCED=y
+CONFIG_ARCH_QCOM=y
+CONFIG_ARCH_SDXPOORWILLS=y
+# CONFIG_VDSO is not set
+CONFIG_PCI_MSM=y
+CONFIG_PREEMPT=y
+CONFIG_AEABI=y
+CONFIG_CMA=y
+CONFIG_BUILD_ARM_APPENDED_DTB_IMAGE=y
+CONFIG_CPU_FREQ=y
+CONFIG_CPU_FREQ_GOV_ONDEMAND=y
+CONFIG_CPU_FREQ_GOV_INTERACTIVE=y
+CONFIG_CPU_BOOST=y
+CONFIG_CPU_FREQ_MSM=y
+CONFIG_CPU_IDLE=y
+CONFIG_VFP=y
+CONFIG_NEON=y
+# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
+CONFIG_PM_AUTOSLEEP=y
+CONFIG_PM_WAKELOCKS=y
+CONFIG_PM_WAKELOCKS_LIMIT=0
+# CONFIG_PM_WAKELOCKS_GC is not set
+CONFIG_NET=y
+CONFIG_PACKET=y
+CONFIG_UNIX=y
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+CONFIG_IP_ADVANCED_ROUTER=y
+CONFIG_IP_MULTIPLE_TABLES=y
+CONFIG_NET_IPGRE_DEMUX=y
+CONFIG_NET_IPGRE=y
+CONFIG_IP_MROUTE=y
+CONFIG_IP_MROUTE_MULTIPLE_TABLES=y
+CONFIG_IP_PIMSM_V2=y
+CONFIG_IPV6_MIP6=y
+CONFIG_IPV6_GRE=y
+CONFIG_IPV6_MULTIPLE_TABLES=y
+CONFIG_IPV6_SUBTREES=y
+CONFIG_IPV6_MROUTE=y
+CONFIG_IPV6_MROUTE_MULTIPLE_TABLES=y
+CONFIG_IPV6_PIMSM_V2=y
+CONFIG_NETFILTER=y
+CONFIG_NETFILTER_DEBUG=y
+CONFIG_NF_CONNTRACK=y
+CONFIG_NF_CONNTRACK_SECMARK=y
+CONFIG_NF_CONNTRACK_EVENTS=y
+CONFIG_NF_CONNTRACK_TIMEOUT=y
+CONFIG_NF_CONNTRACK_TIMESTAMP=y
+CONFIG_NF_CT_PROTO_UDPLITE=y
+CONFIG_NF_CONNTRACK_AMANDA=y
+CONFIG_NF_CONNTRACK_FTP=y
+CONFIG_NF_CONNTRACK_H323=y
+CONFIG_NF_CONNTRACK_IRC=y
+CONFIG_NF_CONNTRACK_NETBIOS_NS=y
+CONFIG_NF_CONNTRACK_SNMP=y
+CONFIG_NF_CONNTRACK_PPTP=y
+CONFIG_NF_CONNTRACK_SIP=y
+CONFIG_NF_CONNTRACK_TFTP=y
+CONFIG_NF_CT_NETLINK=y
+CONFIG_NF_CT_NETLINK_TIMEOUT=y
+CONFIG_NF_CT_NETLINK_HELPER=y
+CONFIG_NETFILTER_NETLINK_GLUE_CT=y
+CONFIG_NETFILTER_XT_TARGET_CONNSECMARK=y
+CONFIG_NETFILTER_XT_TARGET_LOG=y
+CONFIG_NETFILTER_XT_TARGET_MARK=y
+CONFIG_NETFILTER_XT_TARGET_NFLOG=y
+CONFIG_NETFILTER_XT_TARGET_NFQUEUE=y
+CONFIG_NETFILTER_XT_TARGET_NOTRACK=y
+CONFIG_NETFILTER_XT_TARGET_TPROXY=y
+CONFIG_NETFILTER_XT_TARGET_TRACE=y
+CONFIG_NETFILTER_XT_TARGET_SECMARK=y
+CONFIG_NETFILTER_XT_TARGET_TCPMSS=y
+CONFIG_NETFILTER_XT_MATCH_ADDRTYPE=y
+CONFIG_NETFILTER_XT_MATCH_CONNLABEL=y
+CONFIG_NETFILTER_XT_MATCH_CONNLIMIT=y
+CONFIG_NETFILTER_XT_MATCH_CONNMARK=y
+CONFIG_NETFILTER_XT_MATCH_CONNTRACK=y
+CONFIG_NETFILTER_XT_MATCH_DSCP=y
+CONFIG_NETFILTER_XT_MATCH_ESP=y
+CONFIG_NETFILTER_XT_MATCH_IPRANGE=y
+CONFIG_NETFILTER_XT_MATCH_LIMIT=y
+CONFIG_NETFILTER_XT_MATCH_MULTIPORT=y
+CONFIG_NETFILTER_XT_MATCH_PHYSDEV=m
+CONFIG_NETFILTER_XT_MATCH_PKTTYPE=y
+CONFIG_NETFILTER_XT_MATCH_STATE=y
+CONFIG_IP_SET=y
+CONFIG_NF_CONNTRACK_IPV4=y
+CONFIG_IP_NF_IPTABLES=y
+CONFIG_IP_NF_MATCH_AH=y
+CONFIG_IP_NF_MATCH_ECN=y
+CONFIG_IP_NF_MATCH_TTL=y
+CONFIG_IP_NF_FILTER=y
+CONFIG_IP_NF_TARGET_REJECT=y
+CONFIG_IP_NF_NAT=y
+CONFIG_IP_NF_TARGET_MASQUERADE=y
+CONFIG_IP_NF_TARGET_NATTYPE_MODULE=y
+CONFIG_IP_NF_TARGET_NETMAP=y
+CONFIG_IP_NF_TARGET_REDIRECT=y
+CONFIG_IP_NF_MANGLE=y
+CONFIG_IP_NF_TARGET_ECN=y
+CONFIG_IP_NF_TARGET_TTL=y
+CONFIG_IP_NF_RAW=y
+CONFIG_IP_NF_SECURITY=y
+CONFIG_IP_NF_ARPTABLES=y
+CONFIG_IP_NF_ARPFILTER=y
+CONFIG_IP_NF_ARP_MANGLE=y
+CONFIG_NF_CONNTRACK_IPV6=y
+CONFIG_IP6_NF_IPTABLES=y
+CONFIG_IP6_NF_MATCH_AH=y
+CONFIG_IP6_NF_MATCH_FRAG=y
+CONFIG_IP6_NF_MATCH_OPTS=y
+CONFIG_IP6_NF_MATCH_HL=y
+CONFIG_IP6_NF_MATCH_IPV6HEADER=y
+CONFIG_IP6_NF_MATCH_MH=y
+CONFIG_IP6_NF_MATCH_RT=y
+CONFIG_IP6_NF_FILTER=y
+CONFIG_IP6_NF_TARGET_REJECT=y
+CONFIG_IP6_NF_MANGLE=y
+CONFIG_IP6_NF_RAW=y
+CONFIG_BRIDGE_NF_EBTABLES=y
+CONFIG_BRIDGE_EBT_BROUTE=y
+CONFIG_BRIDGE_EBT_T_FILTER=y
+CONFIG_BRIDGE_EBT_T_NAT=y
+CONFIG_BRIDGE_EBT_ARP=y
+CONFIG_BRIDGE_EBT_IP=y
+CONFIG_BRIDGE_EBT_IP6=y
+CONFIG_BRIDGE_EBT_ARPREPLY=y
+CONFIG_BRIDGE_EBT_DNAT=y
+CONFIG_BRIDGE_EBT_SNAT=y
+CONFIG_BRIDGE=y
+CONFIG_VLAN_8021Q=y
+CONFIG_NET_SCHED=y
+CONFIG_NET_SCH_PRIO=y
+CONFIG_RMNET_DATA=y
+CONFIG_RMNET_DATA_FC=y
+CONFIG_RMNET_DATA_DEBUG_PKT=y
+CONFIG_BT=y
+CONFIG_MSM_BT_POWER=y
+CONFIG_CFG80211=y
+CONFIG_CFG80211_DEBUGFS=y
+CONFIG_CFG80211_INTERNAL_REGDB=y
+CONFIG_CFG80211_WEXT=y
+CONFIG_RFKILL=y
+CONFIG_IPC_ROUTER=y
+CONFIG_IPC_ROUTER_SECURITY=y
+CONFIG_DMA_CMA=y
+CONFIG_CMA_SIZE_MBYTES=12
+CONFIG_MTD=y
+CONFIG_MTD_TESTS=m
+CONFIG_MTD_CMDLINE_PARTS=y
+CONFIG_MTD_BLOCK=y
+CONFIG_MTD_MSM_QPIC_NAND=y
+CONFIG_MTD_UBI=y
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_RAM=y
+CONFIG_QSEECOM=y
+CONFIG_SCSI=y
+CONFIG_BLK_DEV_SD=y
+CONFIG_CHR_DEV_SG=y
+CONFIG_CHR_DEV_SCH=y
+CONFIG_SCSI_CONSTANTS=y
+CONFIG_SCSI_LOGGING=y
+CONFIG_SCSI_SCAN_ASYNC=y
+CONFIG_NETDEVICES=y
+CONFIG_TUN=y
+# CONFIG_NET_VENDOR_BROADCOM is not set
+# CONFIG_NET_VENDOR_CIRRUS is not set
+# CONFIG_NET_VENDOR_FARADAY is not set
+# CONFIG_NET_VENDOR_INTEL is not set
+CONFIG_KS8851=y
+# CONFIG_NET_VENDOR_MICROCHIP is not set
+# CONFIG_NET_VENDOR_NATSEMI is not set
+# CONFIG_NET_VENDOR_SEEQ is not set
+# CONFIG_NET_VENDOR_SMSC is not set
+# CONFIG_NET_VENDOR_STMICRO is not set
+CONFIG_AT803X_PHY=y
+CONFIG_PPP=y
+CONFIG_PPP_ASYNC=y
+CONFIG_USB_USBNET=y
+CONFIG_USB_NET_SMSC75XX=y
+CONFIG_USB_NET_SMSC95XX=y
+CONFIG_WCNSS_MEM_PRE_ALLOC=y
+CONFIG_CNSS=y
+CONFIG_CNSS_SDIO=y
+CONFIG_CNSS_PCI=y
+CONFIG_CLD_HL_SDIO_CORE=y
+CONFIG_CLD_LL_CORE=y
+CONFIG_CNSS_LOGGER=y
+# CONFIG_INPUT_MOUSEDEV is not set
+CONFIG_INPUT_EVDEV=y
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+CONFIG_INPUT_MISC=y
+CONFIG_INPUT_QPNP_POWER_ON=y
+CONFIG_INPUT_UINPUT=y
+CONFIG_INPUT_GPIO=m
+CONFIG_SERIO_LIBPS2=y
+# CONFIG_LEGACY_PTYS is not set
+CONFIG_SERIAL_MSM=y
+CONFIG_SERIAL_MSM_CONSOLE=y
+CONFIG_SERIAL_MSM_HS=y
+CONFIG_DIAG_CHAR=y
+CONFIG_HW_RANDOM=y
+CONFIG_HW_RANDOM_MSM_LEGACY=y
+CONFIG_I2C=y
+CONFIG_I2C_CHARDEV=y
+CONFIG_I2C_MSM_V2=y
+CONFIG_SPI=y
+CONFIG_SPI_QUP=y
+CONFIG_SPI_SPIDEV=m
+CONFIG_SPMI=y
+CONFIG_SPMI_MSM_PMIC_ARB_DEBUG=y
+CONFIG_PTP_1588_CLOCK=y
+CONFIG_PINCTRL_SDXPOORWILLS=y
+CONFIG_PINCTRL_QCOM_SPMI_PMIC=y
+CONFIG_POWER_RESET=y
+CONFIG_POWER_RESET_QCOM=y
+CONFIG_QCOM_DLOAD_MODE=y
+CONFIG_POWER_SUPPLY=y
+CONFIG_SMB1351_USB_CHARGER=y
+CONFIG_SMB138X_CHARGER=y
+CONFIG_SENSORS_QPNP_ADC_VOLTAGE=y
+CONFIG_THERMAL=y
+CONFIG_THERMAL_WRITABLE_TRIPS=y
+CONFIG_THERMAL_GOV_USER_SPACE=y
+CONFIG_THERMAL_GOV_LOW_LIMITS=y
+CONFIG_CPU_THERMAL=y
+CONFIG_THERMAL_QPNP=y
+CONFIG_THERMAL_TSENS=y
+CONFIG_QTI_AOP_REG_COOLING_DEVICE=y
+CONFIG_QTI_QMI_COOLING_DEVICE=y
+CONFIG_REGULATOR_COOLING_DEVICE=y
+CONFIG_MFD_I2C_PMIC=y
+CONFIG_MFD_SPMI_PMIC=y
+CONFIG_MFD_SYSCON=y
+CONFIG_MSM_CDC_PINCTRL=y
+CONFIG_MSM_CDC_SUPPLY=y
+CONFIG_REGULATOR=y
+CONFIG_REGULATOR_FIXED_VOLTAGE=y
+CONFIG_REGULATOR_QPNP=y
+CONFIG_REGULATOR_RPMH=y
+CONFIG_REGULATOR_STUB=y
+CONFIG_FB=y
+CONFIG_FB_MSM=y
+CONFIG_FB_MSM_MDP_NONE=y
+CONFIG_FB_MSM_QPIC_PANEL_DETECT=y
+CONFIG_SOUND=y
+CONFIG_SND=y
+CONFIG_SND_DYNAMIC_MINORS=y
+CONFIG_SND_USB_AUDIO=y
+CONFIG_SND_USB_AUDIO_QMI=y
+CONFIG_SND_SOC=y
+CONFIG_UHID=y
+CONFIG_HID_APPLE=y
+CONFIG_HID_ELECOM=y
+CONFIG_HID_MAGICMOUSE=y
+CONFIG_HID_MICROSOFT=y
+CONFIG_HID_MULTITOUCH=y
+CONFIG_USB=y
+CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_ACM=y
+CONFIG_USB_STORAGE=y
+CONFIG_USB_STORAGE_DEBUG=y
+CONFIG_USB_STORAGE_DATAFAB=y
+CONFIG_USB_STORAGE_FREECOM=y
+CONFIG_USB_STORAGE_ISD200=y
+CONFIG_USB_STORAGE_USBAT=y
+CONFIG_USB_STORAGE_SDDR09=y
+CONFIG_USB_STORAGE_SDDR55=y
+CONFIG_USB_STORAGE_JUMPSHOT=y
+CONFIG_USB_STORAGE_ALAUDA=y
+CONFIG_USB_STORAGE_ONETOUCH=y
+CONFIG_USB_STORAGE_KARMA=y
+CONFIG_USB_STORAGE_CYPRESS_ATACB=y
+CONFIG_USB_DWC3=y
+CONFIG_USB_DWC3_MSM=y
+CONFIG_USB_EHSET_TEST_FIXTURE=y
+CONFIG_USB_LINK_LAYER_TEST=y
+CONFIG_NOP_USB_XCEIV=y
+CONFIG_USB_MSM_SSPHY_QMP=y
+CONFIG_MSM_HSUSB_PHY=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_DEBUG_FILES=y
+CONFIG_USB_GADGET_DEBUG_FS=y
+CONFIG_USB_GADGET_VBUS_DRAW=500
+CONFIG_USB_CONFIGFS=y
+CONFIG_USB_CONFIGFS_SERIAL=y
+CONFIG_USB_CONFIGFS_MASS_STORAGE=y
+CONFIG_USB_CONFIGFS_F_FS=y
+CONFIG_USB_CONFIGFS_UEVENT=y
+CONFIG_USB_CONFIGFS_F_UAC1=y
+CONFIG_USB_CONFIGFS_F_DIAG=y
+CONFIG_USB_CONFIGFS_F_CDEV=y
+CONFIG_USB_CONFIGFS_F_GSI=y
+CONFIG_USB_CONFIGFS_F_QDSS=y
+CONFIG_MMC=y
+CONFIG_MMC_PERF_PROFILING=y
+CONFIG_MMC_RING_BUFFER=y
+CONFIG_MMC_PARANOID_SD_INIT=y
+CONFIG_MMC_CLKGATE=y
+CONFIG_MMC_BLOCK_MINORS=32
+CONFIG_MMC_BLOCK_DEFERRED_RESUME=y
+CONFIG_MMC_TEST=m
+CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_PLTFM=y
+CONFIG_MMC_SDHCI_MSM=y
+CONFIG_NEW_LEDS=y
+CONFIG_LEDS_CLASS=y
+CONFIG_LEDS_TRIGGERS=y
+CONFIG_RTC_CLASS=y
+CONFIG_RTC_DRV_QPNP=y
+CONFIG_DMADEVICES=y
+CONFIG_QCOM_SPS_DMA=y
+CONFIG_UIO=y
+CONFIG_STAGING=y
+CONFIG_ION=y
+CONFIG_ION_MSM=y
+CONFIG_GSI=y
+CONFIG_IPA3=y
+CONFIG_IPA_WDI_UNIFIED_API=y
+CONFIG_RMNET_IPA3=y
+CONFIG_ECM_IPA=y
+CONFIG_RNDIS_IPA=y
+CONFIG_IPA_UT=y
+CONFIG_SPS=y
+CONFIG_SPS_SUPPORT_NDP_BAM=y
+CONFIG_EP_PCIE=y
+CONFIG_EP_PCIE_HW=y
+CONFIG_QPNP_REVID=y
+CONFIG_MSM_MHI_DEV=y
+CONFIG_USB_BAM=y
+CONFIG_MSM_CLK_RPMH=y
+CONFIG_MSM_CLK_AOP_QMP=y
+CONFIG_MDM_GCC_SDXPOORWILLS=y
+CONFIG_MDM_CLOCK_CPU_SDXPOORWILLS=y
+CONFIG_MDM_DEBUGCC_SDXPOORWILLS=y
+CONFIG_REMOTE_SPINLOCK_MSM=y
+CONFIG_MSM_QMP=y
+CONFIG_IOMMU_IO_PGTABLE_FAST=y
+CONFIG_ARM_SMMU=y
+CONFIG_QCOM_LAZY_MAPPING=y
+CONFIG_IOMMU_DEBUG=y
+CONFIG_IOMMU_DEBUG_TRACKING=y
+CONFIG_IOMMU_TESTS=y
+CONFIG_QCOM_SCM=y
+CONFIG_MSM_BOOT_STATS=y
+CONFIG_QCOM_WATCHDOG_V2=y
+CONFIG_QCOM_MEMORY_DUMP_V2=y
+CONFIG_QCOM_BUS_SCALING=y
+CONFIG_QCOM_BUS_CONFIG_RPMH=y
+CONFIG_MSM_SMEM=y
+CONFIG_MSM_GLINK=y
+CONFIG_MSM_GLINK_LOOPBACK_SERVER=y
+CONFIG_MSM_GLINK_SMEM_NATIVE_XPRT=y
+CONFIG_TRACER_PKT=y
+CONFIG_QTI_RPMH_API=y
+CONFIG_MSM_SMP2P=y
+CONFIG_MSM_IPC_ROUTER_GLINK_XPRT=y
+CONFIG_MSM_QMI_INTERFACE=y
+CONFIG_MSM_GLINK_PKT=y
+CONFIG_MSM_SUBSYSTEM_RESTART=y
+CONFIG_MSM_PIL=y
+CONFIG_MSM_PIL_SSR_GENERIC=y
+CONFIG_QCOM_COMMAND_DB=y
+CONFIG_MSM_PM=y
+CONFIG_QCOM_DCC_V2=y
+CONFIG_QTI_RPM_STATS_LOG=y
+CONFIG_QCOM_FORCE_WDOG_BITE_ON_PANIC=y
+CONFIG_QMP_DEBUGFS_CLIENT=y
+CONFIG_ARM_MEMLAT_MON=y
+CONFIG_DEVFREQ_GOV_MEMLAT=y
+CONFIG_QCOM_DEVFREQ_DEVBW=y
+CONFIG_EXTCON_QCOM_SPMI_MISC=y
+CONFIG_IIO=y
+CONFIG_PWM=y
+CONFIG_PWM_QPNP=y
+CONFIG_QCOM_SHOW_RESUME_IRQ=y
+CONFIG_ANDROID=y
+CONFIG_EXT3_FS=y
+CONFIG_EXT4_FS_SECURITY=y
+CONFIG_VFAT_FS=y
+CONFIG_TMPFS=y
+CONFIG_UBIFS_FS=y
+CONFIG_UBIFS_FS_ADVANCED_COMPR=y
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_ASCII=y
+CONFIG_NLS_ISO8859_1=y
+CONFIG_PRINTK_TIME=y
+CONFIG_DYNAMIC_DEBUG=y
+CONFIG_DEBUG_INFO=y
+CONFIG_MAGIC_SYSRQ=y
+CONFIG_DEBUG_PAGEALLOC=y
+CONFIG_DEBUG_KMEMLEAK=y
+CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF=y
+CONFIG_DEBUG_STACK_USAGE=y
+CONFIG_DEBUG_MEMORY_INIT=y
+CONFIG_PANIC_ON_RECURSIVE_FAULT=y
+CONFIG_PANIC_TIMEOUT=5
+CONFIG_SCHEDSTATS=y
+CONFIG_SCHED_STACK_END_CHECK=y
+CONFIG_DEBUG_SPINLOCK=y
+CONFIG_DEBUG_MUTEXES=y
+CONFIG_DEBUG_ATOMIC_SLEEP=y
+CONFIG_DEBUG_LIST=y
+CONFIG_FAULT_INJECTION=y
+CONFIG_FAIL_PAGE_ALLOC=y
+CONFIG_FAULT_INJECTION_DEBUG_FS=y
+CONFIG_FAULT_INJECTION_STACKTRACE_FILTER=y
+CONFIG_IPC_LOGGING=y
+CONFIG_QCOM_RTB=y
+CONFIG_IRQSOFF_TRACER=y
+CONFIG_PREEMPT_TRACER=y
+CONFIG_BLK_DEV_IO_TRACE=y
+CONFIG_DEBUG_USER=y
+CONFIG_DEBUG_SET_MODULE_RONX=y
+CONFIG_CORESIGHT=y
+CONFIG_CORESIGHT_LINK_AND_SINK_TMC=y
+CONFIG_CORESIGHT_SOURCE_ETM3X=y
+CONFIG_CORESIGHT_REMOTE_ETM=y
+CONFIG_CORESIGHT_REMOTE_ETM_DEFAULT_ENABLE=0
+CONFIG_CORESIGHT_QCOM_REPLICATOR=y
+CONFIG_CORESIGHT_STM=y
+CONFIG_CORESIGHT_TPDA=y
+CONFIG_CORESIGHT_TPDM=y
+CONFIG_CORESIGHT_CTI=y
+CONFIG_CORESIGHT_EVENT=y
+CONFIG_CORESIGHT_TGU=y
+CONFIG_CORESIGHT_HWEVENT=y
+CONFIG_CORESIGHT_DUMMY=y
+CONFIG_SECURITY=y
+CONFIG_SECURITY_NETWORK=y
+CONFIG_HARDENED_USERCOPY=y
+CONFIG_SECURITY_SELINUX=y
+# CONFIG_SECURITY_SELINUX_AVC_STATS is not set
+CONFIG_CRYPTO_DEV_QCOM_MSM_QCE=y
+CONFIG_CRYPTO_DEV_QCRYPTO=y
+CONFIG_CRYPTO_DEV_QCEDEV=y
+CONFIG_XZ_DEC=y
+CONFIG_QMI_ENCDEC=y
diff --git a/arch/arm/mach-qcom/Kconfig b/arch/arm/mach-qcom/Kconfig
index 4e95a7b..89a4ca7 100644
--- a/arch/arm/mach-qcom/Kconfig
+++ b/arch/arm/mach-qcom/Kconfig
@@ -126,6 +126,47 @@
 	select HAVE_CLK_PREPARE
 	select COMMON_CLK_MSM
 
+config ARCH_QM215
+	bool "Enable support for QM215"
+	select CPU_V7
+	select HAVE_ARM_ARCH_TIMER
+	select PINCTRL
+	select QCOM_SCM if SMP
+	select PM_DEVFREQ
+	select CLKDEV_LOOKUP
+	select HAVE_CLK
+	select HAVE_CLK_PREPARE
+	select COMMON_CLK_MSM
+
+config ARCH_MSM8940
+	bool "MSM8940"
+	select MSM_CORTEX_A53
+	select ARCH_MSM_CORTEXMP
+	select CPU_V7
+	select HAVE_SMP
+	select ARM_GIC
+	select MSM_IRQ
+	select SPARSE_IRQ
+	select MULTI_IRQ_HANDLER
+	select HAVE_ARM_ARCH_TIMER
+	select MAY_HAVE_SPARSE_IRQ
+	select PINCTRL
+	select PINCTRL_MSM_TLMM
+	select USE_PINCTRL_IRQ
+	select MSM_PM if PM
+	select QMI_ENCDEC
+	select CPU_FREQ
+	select CPU_FREQ_MSM
+	select PM_DEVFREQ
+	select MSM_DEVFREQ_DEVBW
+	select DEVFREQ_SIMPLE_DEV
+	select DEVFREQ_GOV_MSM_BW_HWMON
+	select MSM_BIMC_BWMON
+	select MSM_QDSP6V2_CODECS
+	select MSM_AUDIO_QDSP6V2 if SND_SOC
+	select ARM_HAS_SG_CHAIN
+	select MSM_JTAGV8 if CORESIGHT_ETMV4
+
 config ARCH_SDM439
 	bool "Enable support for SDM439"
 	select CPU_V7
diff --git a/arch/arm/mach-qcom/Makefile b/arch/arm/mach-qcom/Makefile
index 3ef169f..f757ce0 100644
--- a/arch/arm/mach-qcom/Makefile
+++ b/arch/arm/mach-qcom/Makefile
@@ -6,6 +6,8 @@
 obj-$(CONFIG_ARCH_MSM8937) += board-msm8937.o
 obj-$(CONFIG_ARCH_MSM8909) += board-msm8909.o
 obj-$(CONFIG_ARCH_MSM8917) += board-msm8917.o
+obj-$(CONFIG_ARCH_QM215) += board-qm215.o
+obj-$(CONFIG_ARCH_MSM8940) += board-msm8940.o
 obj-$(CONFIG_ARCH_SDM429) += board-sdm429.o
 obj-$(CONFIG_ARCH_SDM439) += board-sdm439.o
 obj-$(CONFIG_ARCH_SDM450) += board-sdm450.o
diff --git a/arch/arm/mach-qcom/board-msm8940.c b/arch/arm/mach-qcom/board-msm8940.c
new file mode 100644
index 0000000..3e60902
--- /dev/null
+++ b/arch/arm/mach-qcom/board-msm8940.c
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2016, 2018, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/kernel.h>
+#include <asm/mach/arch.h>
+#include "board-dt.h"
+
+static const char *msm8940_dt_match[] __initconst = {
+	"qcom,msm8940",
+	NULL
+};
+
+static void __init msm8940_init(void)
+{
+	board_dt_populate(NULL);
+}
+
+DT_MACHINE_START(MSM8940_DT,
+	"Qualcomm Technologies, Inc. MSM8940-PMI8950 MTP")
+	.init_machine = msm8940_init,
+	.dt_compat = msm8940_dt_match,
+MACHINE_END
diff --git a/arch/arm/mach-qcom/board-qm215.c b/arch/arm/mach-qcom/board-qm215.c
new file mode 100644
index 0000000..62f9175
--- /dev/null
+++ b/arch/arm/mach-qcom/board-qm215.c
@@ -0,0 +1,32 @@
+/* Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/kernel.h>
+#include "board-dt.h"
+#include <asm/mach/map.h>
+#include <asm/mach/arch.h>
+
+static const char *qm215_dt_match[] __initconst = {
+	"qcom,qm215",
+	NULL
+};
+
+static void __init qm215_init(void)
+{
+	board_dt_populate(NULL);
+}
+
+DT_MACHINE_START(QM215_DT,
+	"Qualcomm Technologies, Inc. QM215")
+	.init_machine		= qm215_init,
+	.dt_compat		= qm215_dt_match,
+MACHINE_END
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 0fee77d0..d89d0d7 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -1862,7 +1862,7 @@
 	int ret = 0;
 	unsigned int count;
 	struct scatterlist *s;
-	int prot;
+	int prot = 0;
 
 	size = PAGE_ALIGN(size);
 	*handle = DMA_ERROR_CODE;
@@ -1871,6 +1871,11 @@
 	if (iova == DMA_ERROR_CODE)
 		return -ENOMEM;
 
+	/*
+	 * Check for coherency.
+	 */
+	prot |= is_coherent ? IOMMU_CACHE : 0;
+
 	for (count = 0, s = sg; count < (size >> PAGE_SHIFT); s = sg_next(s)) {
 		phys_addr_t phys = page_to_phys(sg_page(s));
 		unsigned int len = PAGE_ALIGN(s->offset + s->length);
@@ -1878,7 +1883,7 @@
 		if (!is_coherent && (attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
 			__dma_page_cpu_to_dev(sg_page(s), s->offset, s->length, dir);
 
-		prot = __dma_direction_to_prot(dir);
+		prot |= __dma_direction_to_prot(dir);
 
 		ret = iommu_map(mapping->domain, iova, phys, len, prot);
 		if (ret < 0)
@@ -1982,9 +1987,35 @@
 	dma_addr_t iova;
 	bool coherent;
 	int prot = __dma_direction_to_prot(dir);
+	int upstream_hint = 0;
+	/*
+	 * This is used to check if there are any unaligned offset/size
+	 * given in the scatter list.
+	 */
+	bool unaligned_offset_size = false;
 
-	for_each_sg(sg, s, nents, i)
+	for_each_sg(sg, s, nents, i) {
 		total_length += s->length;
+		if ((s->offset & ~PAGE_MASK) || (s->length & ~PAGE_MASK)) {
+			unaligned_offset_size = true;
+			break;
+		}
+	}
+
+	/*
+	 * Check for the upstream domain attribute just to catch
+	 * any abusive clients who expects the unaligned offset/size
+	 * support with out setting this attribute.
+	 * NOTE: on future kernels, we may not have this domain
+	 * attribute set where the check then will be based on just
+	 * offset/size.
+	 */
+	iommu_domain_get_attr(mapping->domain,
+			      DOMAIN_ATTR_UPSTREAM_IOVA_ALLOCATOR,
+			      &upstream_hint);
+	if (upstream_hint && unaligned_offset_size)
+		return __iommu_map_sg(dev, sg, nents, dir, attrs,
+				      is_dma_coherent(dev, attrs, false));
 
 	iova = __alloc_iova(mapping, total_length);
 	if (iova == DMA_ERROR_CODE)
diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms
index 4c013ad..a1ed16b 100644
--- a/arch/arm64/Kconfig.platforms
+++ b/arch/arm64/Kconfig.platforms
@@ -166,6 +166,15 @@
 	  This enables support for the MSM8937 chipset. If you do not
 	  wish to build a kernel that runs on this chipset, say 'N' here.
 
+config ARCH_MSM8940
+	bool "Enable Support for Qualcomm Technologies Inc. MSM8940"
+	depends on ARCH_QCOM
+	select CPU_FREQ_QCOM
+	select COMMON_CLK_MSM
+	help
+	  This enables support for the MSM8940 chipset. If you do not
+	  wish to build a kernel that runs on this chipset, say 'N' here.
+
 config ARCH_MSM8917
 	bool "Enable Support for Qualcomm Technologies Inc. MSM8917"
 	depends on ARCH_QCOM
@@ -175,6 +184,15 @@
 	  This enables support for the MSM8917 chipset. If you do not
 	  wish to build a kernel that runs on this chipset, say 'N' here.
 
+config ARCH_QM215
+	bool "Enable Support for Qualcomm Technologies Inc. QM215"
+	depends on ARCH_QCOM
+	select CPU_FREQ_QCOM
+	select COMMON_CLK_MSM
+	help
+	  This enables support for the QM215 chipset. If you do not
+	  wish to build a kernel that runs on this chipset, say 'N' here.
+
 config ARCH_SDM450
 	bool "Enable Support for Qualcomm Technologies Inc. SDM450"
 	depends on ARCH_QCOM
diff --git a/arch/arm64/boot/dts/qcom/Makefile b/arch/arm64/boot/dts/qcom/Makefile
index aae4f68..a5f8efc 100644
--- a/arch/arm64/boot/dts/qcom/Makefile
+++ b/arch/arm64/boot/dts/qcom/Makefile
@@ -344,8 +344,9 @@
 	msm8917-rcm-overlay.dtbo \
 	apq8017-mtp-overlay.dtbo \
 	apq8017-cdp-overlay.dtbo \
-	apq8017-cdp-wcd-rome-overlay.dtbo \
-	qm215-qrd-overlay.dtbo
+	apq8017-cdp-wcd-rome-overlay.dtbo
+
+dtbo-$(CONFIG_ARCH_QM215) +=qm215-qrd-overlay.dtbo
 
 dtbo-$(CONFIG_ARCH_MSM8953) += msm8953-mtp-overlay.dtbo \
 	msm8953-cdp-overlay.dtbo \
@@ -529,6 +530,10 @@
 	msm8937-interposer-sdm429-cdp.dtb \
 	msm8937-interposer-sdm429-mtp.dtb
 
+dtb-$(CONFIG_ARCH_MSM8940) += msm8940-pmi8937-mtp.dtb \
+	msm8940-pmi8950-mtp.dtb \
+	msm8940-pmi8940-mtp.dtb
+
 dtb-$(CONFIG_ARCH_MSM8917) += msm8917-pmi8950-mtp.dtb \
 	msm8917-pmi8950-cdp.dtb \
 	msm8917-pmi8950-rcm.dtb \
@@ -546,8 +551,9 @@
 	apq8017-pmi8937-cdp-wcd-rome.dtb \
 	msm8917-pmi8940-mtp.dtb \
 	msm8917-pmi8940-cdp.dtb \
-	msm8917-pmi8940-rcm.dtb \
-	qm215-qrd.dtb
+	msm8917-pmi8940-rcm.dtb
+
+dtb-$(CONFIG_ARCH_QM215) += qm215-qrd.dtb
 
 dtb-$(CONFIG_ARCH_MSM8909) += msm8909-pm8916-mtp.dtb \
 	sdw3100-msm8909w-wtp.dtb \
diff --git a/arch/arm64/boot/dts/qcom/apq8009-dragon.dts b/arch/arm64/boot/dts/qcom/apq8009-dragon.dts
index 314af11..1ac603e 100644
--- a/arch/arm64/boot/dts/qcom/apq8009-dragon.dts
+++ b/arch/arm64/boot/dts/qcom/apq8009-dragon.dts
@@ -361,3 +361,47 @@
 &blsp1_uart1 {
 	status = "disabled";
 };
+
+&i2c_5 {
+	status = "okay";
+	goodix_ts@5d {
+		compatible = "goodix,gt9xx";
+		status = "okay";
+		reg = <0x5d>;
+		vdd_ana-supply = <&pm8916_l17>;
+		vcc_i2c-supply = <&pm8916_l6>;
+		interrupt-parent = <&msm_gpio>;
+		interrupts = <13 0x2008>;
+		pinctrl-names = "gdix_ts_int_default", "gdix_ts_int_output_low",
+			"gdix_ts_int_output_high", "gdix_ts_int_input",
+			"gdix_ts_rst_default", "gdix_ts_rst_output_low",
+			"gdix_ts_rst_output_high", "gdix_ts_rst_input";
+		pinctrl-0 = <&ts_int_default>;
+		pinctrl-1 = <&ts_int_output_low>;
+		pinctrl-2 = <&ts_int_output_high>;
+		pinctrl-3 = <&ts_int_input>;
+		pinctrl-4 = <&ts_rst_default>;
+		pinctrl-5 = <&ts_rst_output_low>;
+		pinctrl-6 = <&ts_rst_output_high>;
+		pinctrl-7 = <&ts_rst_input>;
+		reset-gpios = <&msm_gpio 16 0x00>;
+		irq-gpios = <&msm_gpio 13 0x2008>;
+		irq-flags = <2>;
+		touchscreen-max-id = <5>;
+		touchscreen-size-x = <479>;
+		touchscreen-size-y = <853>;
+		touchscreen-max-w = <1024>;
+		touchscreen-max-p = <1024>;
+		goodix,type-a-report = <0>;
+		goodix,driver-send-cfg = <1>;
+		goodix,wakeup-with-reset = <0>;
+		goodix,resume-in-workqueue = <1>;
+		goodix,int-sync = <1>;
+		goodix,swap-x2y = <0>;
+		goodix,esd-protect = <1>;
+		goodix,pen-suppress-finger = <0>;
+		goodix,auto-update = <1>;
+		goodix,auto-update-cfg = <0>;
+		goodix,power-off-sleep = <0>;
+	};
+};
diff --git a/arch/arm64/boot/dts/qcom/apq8009-robot-pronto-refboard.dts b/arch/arm64/boot/dts/qcom/apq8009-robot-pronto-refboard.dts
index 875c878..648670b 100644
--- a/arch/arm64/boot/dts/qcom/apq8009-robot-pronto-refboard.dts
+++ b/arch/arm64/boot/dts/qcom/apq8009-robot-pronto-refboard.dts
@@ -18,7 +18,7 @@
 #include "apq8009-memory.dtsi"
 #include <dt-bindings/pinctrl/qcom,pmic-mpp.h>
 #include "msm8909-pm8916-camera.dtsi"
-#include "msm8909-pm8916-camera-sensor-robot.dtsi"
+#include "msm8909-pm8916-camera-sensor-robot-pronto.dtsi"
 
 / {
 	model = "Qualcomm Technologies, Inc. APQ8009 Robot-pronto RefBoard";
diff --git a/arch/arm64/boot/dts/qcom/apq8009-robot-rome-refboard.dts b/arch/arm64/boot/dts/qcom/apq8009-robot-rome-refboard.dts
index e00eb01..97123a6 100644
--- a/arch/arm64/boot/dts/qcom/apq8009-robot-rome-refboard.dts
+++ b/arch/arm64/boot/dts/qcom/apq8009-robot-rome-refboard.dts
@@ -18,7 +18,7 @@
 #include "apq8009-memory.dtsi"
 #include <dt-bindings/pinctrl/qcom,pmic-mpp.h>
 #include "msm8909-pm8916-camera.dtsi"
-#include "msm8909-pm8916-camera-sensor-robot.dtsi"
+#include "msm8909-pm8916-camera-sensor-robot-rome.dtsi"
 
 / {
 	model = "Qualcomm Technologies, Inc. APQ8009 Robot-rome RefBoard";
diff --git a/arch/arm64/boot/dts/qcom/dsi-panel-osd-disp-fwvga-video.dtsi b/arch/arm64/boot/dts/qcom/dsi-panel-osd-disp-fwvga-video.dtsi
new file mode 100644
index 0000000..0967a50
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/dsi-panel-osd-disp-fwvga-video.dtsi
@@ -0,0 +1,97 @@
+/* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+&mdss_mdp {
+	dsi_osd_disp_fwvga_video: qcom,mdss_dsi_osd_disp_fwvga_video {
+		qcom,mdss-dsi-panel-name =
+			"OSD Displays fwvga video mode dsi panel";
+		qcom,mdss-dsi-panel-controller = <&mdss_dsi0>;
+		qcom,mdss-dsi-panel-type = "dsi_video_mode";
+		qcom,mdss-dsi-panel-destination = "display_1";
+		qcom,mdss-dsi-panel-framerate = <60>;
+		qcom,mdss-dsi-virtual-channel-id = <0>;
+		qcom,mdss-dsi-stream = <0>;
+		qcom,mdss-dsi-panel-width = <480>;
+		qcom,mdss-dsi-panel-height = <854>;
+		qcom,mdss-dsi-h-front-porch = <70>;
+		qcom,mdss-dsi-h-back-porch = <70>;
+		qcom,mdss-dsi-h-pulse-width = <70>;
+		qcom,mdss-dsi-h-sync-skew = <0>;
+		qcom,mdss-dsi-v-back-porch = <10>;
+		qcom,mdss-dsi-v-front-porch = <10>;
+		qcom,mdss-dsi-v-pulse-width = <20>;
+		qcom,mdss-dsi-h-left-border = <0>;
+		qcom,mdss-dsi-h-right-border = <0>;
+		qcom,mdss-dsi-v-top-border = <0>;
+		qcom,mdss-dsi-v-bottom-border = <0>;
+		qcom,mdss-dsi-bpp = <24>;
+		qcom,mdss-dsi-color-order = <0>;
+		qcom,mdss-dsi-underflow-color = <0xff>;
+		qcom,mdss-dsi-border-color = <0>;
+		qcom,ulps-enabled;
+		qcom,mdss-dsi-on-command = [
+			39 01 00 00 01 00 04 BF 91 61 F2
+			39 01 00 00 01 00 03 B3 00 9B
+			39 01 00 00 01 00 03 B4 00 9B
+			39 01 00 00 01 00 02 C3 04
+			39 01 00 00 01 00 07 B8 00 6F 01 00 6F 01
+			39 01 00 00 01 00 04 BA 34 23 00
+			39 01 00 00 01 00 03 C4 30 6A
+			39 01 00 00 01 00 0A C7 00 01 32 05 65 2A 12 A5 A5
+			39 01 00 00 01 00 27 C8 7F 6A 5A 4E 49 39 3B 23 37
+				32 2F 49 35 3B 31 2B 1E 0F 00 7F 6A 5A 4E
+				49 39 3B 23 37 32 2F 49 35 3B 31 2B 1E 0F 00
+			39 01 00 00 01 00 11 D4 1E 1F 1F 1F 06 04 0A 08 00
+				02 1F 1F 1F 1F 1F 1F
+			39 01 00 00 01 00 11 D5 1E 1F 1F 1F 07 05 0B 09 01
+				03 1F 1F 1F 1F 1F 1F
+			39 01 00 00 01 00 11 D6 1F 1E 1F 1F 07 09 0B 05 03
+				01 1F 1F 1F 1F 1F 1F
+			39 01 00 00 01 00 11 D7 1F 1E 1F 1F 06 08 0A 04 02
+				00 1F 1F 1F 1F 1F 1F
+			39 01 00 00 01 00 15 D8 20 00 00 30 08 20 01 02 00
+				01 02 06 7B 00 00 72 0A 0E 49 08
+			39 01 00 00 01 00 14 D9 00 0A 0A 89 00 00 06 7B 00
+				00 00 3B 33 1F 00 00 00 03 7B
+			05 01 00 00 01 00 02 35 00
+			39 01 00 00 01 00 02 BE 01
+			39 01 00 00 01 00 02 C1 10
+			39 01 00 00 01 00 0B CC 34 20 38 60 11 91 00 40 00 00
+			39 01 00 00 01 00 02 BE 00
+			05 01 00 00 01 00 02 11 00
+			05 01 00 00 01 00 02 29 00];
+		qcom,mdss-dsi-off-command = [
+				05 01 00 00 01 00 02 28 00
+				05 01 00 00 01 00 02 10 00];
+		qcom,mdss-dsi-on-command-state = "dsi_lp_mode";
+		qcom,mdss-dsi-off-command-state = "dsi_hs_mode";
+		qcom,mdss-dsi-h-sync-pulse = <1>;
+		qcom,mdss-dsi-traffic-mode = "burst_mode";
+		qcom,mdss-dsi-bllp-eof-power-mode;
+		qcom,mdss-dsi-bllp-power-mode;
+		qcom,mdss-dsi-lane-0-state;
+		qcom,mdss-dsi-lane-1-state;
+		qcom,mdss-dsi-panel-timings =
+			[7F 1C 12 00 40 44 16 1E 17 03 04 00];
+		qcom,mdss-dsi-t-clk-post = <0x20>;
+		qcom,mdss-dsi-t-clk-pre = <0x2C>;
+		qcom,mdss-dsi-bl-min-level = <1>;
+		qcom,mdss-dsi-bl-max-level = <4095>;
+		qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_pwm";
+		qcom,mdss-dsi-bl-pmic-pwm-frequency = <100>;
+		qcom,mdss-dsi-bl-pmic-bank-select = <0>;
+		qcom,mdss-dsi-pwm-gpio = <&pm8916_mpps 4 0>;
+		qcom,mdss-dsi-dma-trigger = "trigger_sw";
+		qcom,mdss-dsi-mdp-trigger = "none";
+		qcom,mdss-dsi-reset-sequence = <1 20>, <0 20>, <1 20>;
+	};
+};
diff --git a/arch/arm64/boot/dts/qcom/msm-arm-smmu-8909.dtsi b/arch/arm64/boot/dts/qcom/msm-arm-smmu-8909.dtsi
index b506fb4..a6c7266 100644
--- a/arch/arm64/boot/dts/qcom/msm-arm-smmu-8909.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm-arm-smmu-8909.dtsi
@@ -36,13 +36,10 @@
 			<GIC_SPI 241 IRQ_TYPE_LEVEL_HIGH>,
 			<GIC_SPI 242 IRQ_TYPE_LEVEL_HIGH>,
 			<GIC_SPI 245 IRQ_TYPE_LEVEL_HIGH>;
-
-		vdd-supply = <&gdsc_oxili_gx>;
-		qcom,regulator-names = "vdd";
 		clocks =
-			<&clock_gcc clk_gcc_oxili_ahb_clk>,
-			<&clock_gcc clk_gcc_bimc_gfx_clk>;
-		clock-names = "gpu_ahb_clk", "gcc_bimc_gfx_clk";
+			<&clock_gcc clk_gcc_smmu_cfg_clk>,
+			<&clock_gcc clk_gcc_gfx_tcu_clk>;
+		clock-names = "iface_clk", "core_clk";
 	};
 
 	/* A test device to test the SMMU operation */
diff --git a/arch/arm64/boot/dts/qcom/msm-arm-smmu-sdm670.dtsi b/arch/arm64/boot/dts/qcom/msm-arm-smmu-sdm670.dtsi
index d4f2976..5664d3e 100644
--- a/arch/arm64/boot/dts/qcom/msm-arm-smmu-sdm670.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm-arm-smmu-sdm670.dtsi
@@ -25,6 +25,7 @@
 		#global-interrupts = <2>;
 		qcom,regulator-names = "vdd";
 		vdd-supply = <&gpu_cx_gdsc>;
+		qcom,deferred-regulator-disable-delay = <80>;
 		interrupts = <GIC_SPI 229 IRQ_TYPE_LEVEL_HIGH>,
 				<GIC_SPI 231 IRQ_TYPE_LEVEL_HIGH>,
 				<GIC_SPI 364 IRQ_TYPE_LEVEL_HIGH>,
diff --git a/arch/arm64/boot/dts/qcom/msm-arm-smmu-sdm845.dtsi b/arch/arm64/boot/dts/qcom/msm-arm-smmu-sdm845.dtsi
index 0ac9c2a..38dd747 100644
--- a/arch/arm64/boot/dts/qcom/msm-arm-smmu-sdm845.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm-arm-smmu-sdm845.dtsi
@@ -346,19 +346,11 @@
 };
 
 &apps_smmu {
-	qcom,actlr =	<0x0880 0x8 0x103>,
-			<0x0881 0x8 0x103>,
-			<0x0c80 0x8 0x103>,
-			<0x0c81 0x8 0x103>,
-			<0x1090 0x0 0x103>,
-			<0x1091 0x0 0x103>,
-			<0x10a0 0x8 0x103>,
-			<0x10b0 0x0 0x103>,
-			<0x10a1 0x8 0x103>,
-			<0x10a3 0x8 0x103>,
-			<0x10a4 0x8 0x103>,
-			<0x10b4 0x0 0x103>,
-			<0x10a5 0x8 0x103>;
+	qcom,actlr =
+		/* HF and SF TBUs: +3 deep PF */
+			<0x0800 0x7ff 0x103>,
+			<0x1000 0x3ff 0x103>;
+
 	qcom,mmu500-errata-1 =	<0x800 0x3ff>,
 				<0xc00 0x3ff>;
 };
diff --git a/arch/arm64/boot/dts/qcom/msm8909-pinctrl.dtsi b/arch/arm64/boot/dts/qcom/msm8909-pinctrl.dtsi
index c22259b..656385d 100644
--- a/arch/arm64/boot/dts/qcom/msm8909-pinctrl.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8909-pinctrl.dtsi
@@ -922,6 +922,103 @@
 			};
 		};
 
+		/* add pingrp for goodix touch */
+		ts_int_default: ts_int_default {
+			mux {
+				pins = "gpio13";
+				function = "gpio";
+			};
+			config {
+				pins = "gpio13";
+				drive-strength = <16>;
+				/*bias-pull-up;*/
+				input-enable;
+				bias-disable;
+			};
+		};
+
+		ts_int_output_high: ts_int_output_high {
+			mux {
+				pins = "gpio13";
+				function = "gpio";
+			};
+			config {
+				pins = "gpio13";
+				output-high;
+			};
+		};
+
+		ts_int_output_low: ts_int_output_low {
+			mux {
+				pins = "gpio13";
+				function = "gpio";
+			};
+			config {
+				pins = "gpio13";
+				output-low;
+			};
+		};
+
+		ts_int_input: ts_int_input {
+			mux {
+				pins = "gpio13";
+				function = "gpio";
+			};
+			config {
+				pins = "gpio13";
+				input-enable;
+				bias-disable;
+			};
+		};
+
+		ts_rst_default: ts_rst_default {
+			mux {
+				pins = "gpio16";
+				function = "gpio";
+			};
+			config {
+				pins = "gpio16";
+				drive-strength = <16>;
+				/*bias-pull-up;*/
+				input-enable;
+				bias-disable;
+			};
+		};
+
+		ts_rst_output_high: ts_rst_output_high {
+			mux {
+				pins = "gpio16";
+				function = "gpio";
+			};
+			config {
+				pins = "gpio16";
+				output-high;
+			};
+		};
+
+		ts_rst_output_low: ts_rst_output_low {
+			mux {
+				pins = "gpio16";
+				function = "gpio";
+			};
+			config {
+				pins = "gpio16";
+				output-low;
+			};
+		};
+
+		ts_rst_input: ts_rst_input {
+			mux {
+				pins = "gpio16";
+				function = "gpio";
+			};
+			config {
+				pins = "gpio16";
+				input-enable;
+				bias-disable;
+			};
+		};
+
 		/* add pingrp for touchscreen */
 		pmx_ts_int_active {
 			ts_int_active: ts_int_active {
diff --git a/arch/arm64/boot/dts/qcom/msm8909-pm8916-camera-sensor-robot-pronto.dtsi b/arch/arm64/boot/dts/qcom/msm8909-pm8916-camera-sensor-robot-pronto.dtsi
new file mode 100644
index 0000000..854965e
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/msm8909-pm8916-camera-sensor-robot-pronto.dtsi
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+&i2c_3 {
+	status = "ok";
+};
+
+&i2c_3 {
+
+	qcom,camera@1 {
+		cell-index = <1>;
+		compatible = "qcom,camera";
+		reg = <0x1>;
+		qcom,csiphy-sd-index = <0>;
+		qcom,csid-sd-index = <0>;
+		qcom,mount-angle = <90>;
+		cam_vana-supply = <&pm8916_l17>;
+		cam_vio-supply = <&pm8916_l6>;
+		qcom,cam-vreg-name = "cam_vio","cam_vana";
+		qcom,cam-vreg-min-voltage = <1800000 2850000>;
+		qcom,cam-vreg-max-voltage = <1800000 2850000>;
+		qcom,cam-vreg-op-mode = <0 80000>;
+		qcom,cam-vreg-type = <0 0>;
+		pinctrl-names = "cam_default", "cam_suspend";
+		pinctrl-0 = <&cam_sensor_mclk0_default
+				&cam_sensor_rear_default>;
+		pinctrl-1 = <&cam_sensor_mclk0_sleep &cam_sensor_rear_sleep>;
+		gpios = <&msm_gpio 26 0>,
+			<&msm_gpio 35 0>,
+			<&msm_gpio 34 0>;
+		qcom,gpio-reset = <1>;
+		qcom,gpio-standby = <2>;
+		qcom,gpio-req-tbl-num = <0 1 2>;
+		qcom,gpio-req-tbl-flags = <1 0 0>;
+		qcom,gpio-req-tbl-label = "CAMIF_MCLK",
+			"CAM_RESET",
+			"CAM_STANDBY";
+		qcom,sensor-position = <0>;
+		qcom,sensor-mode = <0>;
+		status = "ok";
+		clocks = <&clock_gcc clk_mclk0_clk_src>,
+				<&clock_gcc clk_gcc_camss_mclk0_clk>;
+		clock-names = "cam_src_clk", "cam_clk";
+		qcom,clock-rates = <24000000 0>;
+	};
+};
diff --git a/arch/arm64/boot/dts/qcom/msm8909-pm8916-camera-sensor-robot-rome.dtsi b/arch/arm64/boot/dts/qcom/msm8909-pm8916-camera-sensor-robot-rome.dtsi
new file mode 100644
index 0000000..cd720fd
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/msm8909-pm8916-camera-sensor-robot-rome.dtsi
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+&i2c_3 {
+	status = "ok";
+};
+
+&i2c_3 {
+	otp_eeprom: qcom,msm_eeprom@6e{
+		status = "ok";
+		cell-index = <0>;
+		reg = <0x6e>;
+		compatible = "msm_eeprom";
+		qcom,eeprom-name = "sunny_imx241_otp";
+		qcom,slave-addr = <0x6e>;
+		qcom,i2c-freq-mode = <1>;
+
+		cam_vdig-supply = <&pm8916_l2>;
+		cam_vio-supply = <&pm8916_l6>;
+		cam_vana-supply = <&pm8916_l17>;
+		qcom,cam-vreg-name = "cam_vdig", "cam_vio", "cam_vana";
+		qcom,cam-vreg-min-voltage = <1200000 1800000 2850000>;
+		qcom,cam-vreg-max-voltage = <1200000 1800000 2850000>;
+		qcom,cam-vreg-op-mode = <200000 0 80000>;
+		qcom,cam-vreg-type = <0 0 0>;
+		pinctrl-names = "cam_default", "cam_suspend";
+		pinctrl-0 = <&cam_sensor_mclk0_default
+					&cam_sensor_rear_default>;
+		pinctrl-1 = <&cam_sensor_mclk0_sleep
+					&cam_sensor_rear_sleep>;
+		gpios = <&msm_gpio 26 0>,
+				<&msm_gpio 35 0>;
+		qcom,gpio-reset = <1>;
+		qcom,gpio-req-tbl-num = <0 1>;
+		qcom,gpio-req-tbl-flags = <1 0>;
+		qcom,gpio-req-tbl-label = "CAMIF_MCLK", "CAM_RESET";
+
+		qcom,cam-power-seq-type = "sensor_vreg",
+						"sensor_vreg",
+						"sensor_vreg",
+						"sensor_gpio",
+						"sensor_clk",
+						"sensor_i2c_mux";
+		qcom,cam-power-seq-val =  "cam_vana",
+						"cam_vdig",
+						"cam_vio",
+						"sensor_gpio_reset",
+						"sensor_cam_mclk",
+						"none";
+		qcom,cam-power-seq-cfg-val = <2850000 1200000
+						1800000 1 24000000 0>;
+		qcom,cam-power-seq-delay =   <1 1 1 1 1 0>;
+
+		clocks = <&clock_gcc clk_mclk0_clk_src>,
+				<&clock_gcc clk_gcc_camss_mclk0_clk>;
+		clock-names = "cam_src_clk", "cam_clk";
+		qcom,clock-rates = <24000000 0>;
+
+		qcom,num-blocks = <12>;
+		qcom,page0 = <1 0x34C5 2 0x02 1 1>;
+		qcom,poll0 = <0 0x0 2 0 1 1>;
+		qcom,mem0 = <0 0x0 2 0 1 0>;
+		qcom,page1 = <1 0x34C9 2 0x02 1 10>;
+		qcom,poll1 = <0 0x0 2 0 1 1>;
+		qcom,mem1 = <8 0x3510 2 0 1 0>;
+		qcom,page2 = <1 0x34C5 2 0x03 1 1>;
+		qcom,poll2 = <0 0x0 2 0 1 1>;
+		qcom,mem2 = <0 0x0 2 0 1 0>;
+		qcom,page3 = <1 0x34C9 2 0x03 1 10>;
+		qcom,poll3 = <0 0x0 2 0 1 1>;
+		qcom,mem3 = <8 0x3518 2 0 1 0>;
+		qcom,page4 = <1 0x34C5 2 0x06 1 1>;
+		qcom,poll4 = <0 0x0 2 0 1 1>;
+		qcom,mem4 = <0 0x0 2 0 1 0>;
+		qcom,page5 = <1 0x34C9 2 0x06 1 10>;
+		qcom,poll5 = <0 0x0 2 0 1 1>;
+		qcom,mem5 = <8 0x3530 2 0 1 0>;
+		qcom,page6 = <1 0x34C5 2 0x07 1 1>;
+		qcom,poll6 = <0 0x0 2 0 1 1>;
+		qcom,mem6 = <0 0x0 2 0 1 0>;
+		qcom,page7 = <1 0x34C9 2 0x07 1 10>;
+		qcom,poll7 = <0 0x0 2 0 1 1>;
+		qcom,mem7 = <8 0x3538 2 0 1 0>;
+		qcom,page8 = <1 0x34C5 2 0x0A 1 1>;
+		qcom,poll8 = <0 0x0 2 0 1 1>;
+		qcom,mem8 = <0 0x0 2 0 1 0>;
+		qcom,page9 = <1 0x34C9 2 0x0A 1 10>;
+		qcom,poll9 = <0 0x0 2 0 1 1>;
+		qcom,mem9 = <8 0x3550 2 0 1 0>;
+		qcom,page10 = <1 0x34C5 2 0x0B 1 1>;
+		qcom,poll10 = <0 0x0 2 0 1 1>;
+		qcom,mem10 = <0 0x0 2 0 1 0>;
+		qcom,page11 = <1 0x34C9 2 0x0B 1 10>;
+		qcom,poll11 = <0 0x0 2 0 1 1>;
+		qcom,mem11 = <8 0x3558 2 0 1 0>;
+	};
+
+	qcom,camera@0 {
+		cell-index = <0>;
+		compatible = "qcom,camera";
+		reg = <0x2>;
+		qcom,csiphy-sd-index = <0>;
+		qcom,csid-sd-index = <0>;
+		qcom,mount-angle = <90>;
+		cam_vdig-supply = <&pm8916_l2>;
+		cam_vana-supply = <&pm8916_l17>;
+		cam_vio-supply = <&pm8916_l6>;
+		qcom,cam-vreg-type = <0 0 0>;
+		qcom,cam-vreg-name = "cam_vdig", "cam_vio", "cam_vana";
+		qcom,cam-vreg-min-voltage = <1200000 1800000 2850000>;
+		qcom,cam-vreg-max-voltage = <1200000 1800000 2850000>;
+		qcom,cam-vreg-op-mode = <200000 0 80000>;
+		pinctrl-names = "cam_default", "cam_suspend";
+		pinctrl-0 = <&cam_sensor_mclk0_default
+				&cam_sensor_rear_default>;
+		pinctrl-1 = <&cam_sensor_mclk0_sleep &cam_sensor_rear_sleep>;
+		gpios = <&msm_gpio 26 0>,
+			<&msm_gpio 35 0>,
+			<&msm_gpio 34 0>;
+		qcom,gpio-reset = <1>;
+		qcom,gpio-standby = <2>;
+		qcom,gpio-req-tbl-num = <0 1 2>;
+		qcom,gpio-req-tbl-flags = <1 0 0>;
+		qcom,gpio-req-tbl-label = "CAMIF_MCLK",
+			"CAM_RESET",
+			"CAM_STANDBY";
+		qcom,sensor-position = <0>;
+		qcom,sensor-mode = <0>;
+		qcom,eeprom-src = <&otp_eeprom>;
+		status = "ok";
+		clocks = <&clock_gcc clk_mclk0_clk_src>,
+				<&clock_gcc clk_gcc_camss_mclk0_clk>;
+		clock-names = "cam_src_clk", "cam_clk";
+		qcom,clock-rates = <24000000 0>;
+	};
+};
diff --git a/arch/arm64/boot/dts/qcom/msm8917-coresight.dtsi b/arch/arm64/boot/dts/qcom/msm8917-coresight.dtsi
index 87303c5..2ff64d6 100644
--- a/arch/arm64/boot/dts/qcom/msm8917-coresight.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8917-coresight.dtsi
@@ -11,1029 +11,34 @@
  * GNU General Public License for more details.
  */
 
+#include "msm8937-coresight.dtsi"
+
+&funnel_apss {
+	ports {
+		/delete-node/ port@1;
+		/delete-node/ port@2;
+		/delete-node/ port@3;
+		/delete-node/ port@4;
+	};
+};
+
+&funnel_mm {
+	ports {
+		/delete-node/ port@4;
+	};
+};
+
 &soc {
-	tmc_etr: tmc@6028000 {
-		compatible = "arm,primecell";
-		reg = <0x6028000 0x1000>,
-		      <0x6044000 0x15000>;
-		reg-names = "tmc-base", "bam-base";
+	/delete-node/ etm@619c000;
+	/delete-node/ etm@619d000;
+	/delete-node/ etm@619e000;
+	/delete-node/ etm@619f000;
+	/delete-node/ cti@6198000;
+	/delete-node/ cti@6199000;
+	/delete-node/ cti@619a000;
+	/delete-node/ cti@619b000;
+};
 
-		interrupts = <0 166 0>;
-		interrupt-names = "byte-cntr-irq";
-
-		arm,buffer-size = <0x100000>;
-		arm,sg-enable;
-		qcom,force-reg-dump;
-
-		coresight-name = "coresight-tmc-etr";
-		coresight-csr = <&csr>;
-		coresight-ctis = <&cti0 &cti8>;
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-
-		port {
-			tmc_etr_in_replicator: endpoint {
-				slave-mode;
-				remote-endpoint = <&replicator_out_tmc_etr>;
-			};
-		};
-	};
-
-	replicator: replicator@6026000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b909>;
-
-		reg = <0x6026000 0x1000>;
-		reg-names = "replicator-base";
-
-		coresight-name = "coresight-replicator";
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-		ports {
-			#address-cells = <1>;
-			#size-cells = <0>;
-
-			port@0 {
-				replicator_out_tmc_etr: endpoint {
-					remote-endpoint =
-						<&tmc_etr_in_replicator>;
-				};
-			};
-
-			port@1 {
-				reg = <0>;
-				replicator_in_tmc_etf: endpoint {
-					slave-mode;
-					remote-endpoint =
-						<&tmc_etf_out_replicator>;
-				};
-			};
-		};
-	};
-
-	tmc_etf: tmc@6027000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b961>;
-
-		reg = <0x6027000 0x1000>;
-		reg-names = "tmc-base";
-
-		coresight-name = "coresight-tmc-etf";
-		coresight-csr = <&csr>;
-
-		arm,default-sink;
-		qcom,force-reg-dump;
-
-		coresight-ctis = <&cti0 &cti8>;
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-
-		 ports {
-			#address-cells = <1>;
-			#size-cells = <0>;
-
-			port@0 {
-				tmc_etf_out_replicator:endpoint {
-					remote-endpoint =
-						<&replicator_in_tmc_etf>;
-				};
-			};
-
-			port@1 {
-				reg = <0>;
-				tmc_etf_in_funnel_in0: endpoint {
-					slave-mode;
-					remote-endpoint =
-						<&funnel_in0_out_tmc_etf>;
-				};
-			};
-		};
-	};
-
-	funnel_in0: funnel@6021000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b908>;
-
-		reg = <0x6021000 0x1000>;
-		reg-names = "funnel-base";
-
-		coresight-name = "coresight-funnel-in0";
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-
-		 ports {
-			#address-cells = <1>;
-			#size-cells = <0>;
-
-			port@0 {
-				funnel_in0_out_tmc_etf: endpoint {
-					remote-endpoint =
-						<&tmc_etf_in_funnel_in0>;
-				};
-			};
-
-			port@1 {
-				reg = <7>;
-				funnel_in0_in_stm: endpoint {
-					slave-mode;
-					remote-endpoint = <&stm_out_funnel_in0>;
-				};
-			};
-
-			port@2 {
-				reg = <6>;
-				funnel_in0_in_tpda: endpoint {
-					slave-mode;
-					remote-endpoint =
-						<&tpda_out_funnel_in0>;
-				};
-			};
-
-			port@3 {
-				reg = <3>;
-				funnel_in0_in_funnel_center: endpoint {
-					slave-mode;
-					remote-endpoint =
-						<&funnel_center_out_funnel_in0>;
-				};
-			};
-
-			port@4 {
-				reg = <4>;
-				funnel_in0_in_funnel_right: endpoint {
-					slave-mode;
-					remote-endpoint =
-						<&funnel_right_out_funnel_in0>;
-				};
-			};
-
-			port@5 {
-				reg = <5>;
-				funnel_in0_in_funnel_mm: endpoint {
-					slave-mode;
-					remote-endpoint =
-						<&funnel_mm_out_funnel_in0>;
-				};
-			};
-		};
-	};
-
-	funnel_mm: funnel@6130000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b908>;
-
-		reg = <0x6130000 0x1000>;
-		reg-names = "funnel-base";
-
-		coresight-name = "coresight-funnel-mm";
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-
-		ports {
-			#address-cells = <1>;
-			#size-cells = <0>;
-
-			port@0 {
-				funnel_mm_out_funnel_in0: endpoint {
-					remote-endpoint =
-						<&funnel_in0_in_funnel_mm>;
-				};
-			};
-
-			port@1 {
-				reg = <0>;
-				funnel_mm_in_wcn_etm0: endpoint {
-					slave-mode;
-					remote-endpoint =
-					<&wcn_etm0_out_funnel_mm>;
-				};
-			};
-
-			port@2 {
-				reg = <4>;
-				funnel_mm_in_funnel_cam: endpoint {
-					slave-mode;
-					remote-endpoint =
-						<&funnel_cam_out_funnel_mm>;
-				};
-			};
-
-			port@3 {
-				reg = <5>;
-				funnel_mm_in_audio_etm0: endpoint {
-					slave-mode;
-					remote-endpoint =
-						<&audio_etm0_out_funnel_mm>;
-				};
-			};
-		};
-	};
-
-	funnel_center: funnel@6100000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b908>;
-
-		reg = <0x6100000 0x1000>;
-		reg-names = "funnel-base";
-
-		coresight-name = "coresight-funnel-center";
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-
-		ports {
-			#address-cells = <1>;
-			#size-cells = <0>;
-
-			port@0 {
-				funnel_center_out_funnel_in0: endpoint {
-					remote-endpoint =
-						<&funnel_in0_in_funnel_center>;
-				};
-			};
-
-			port@1 {
-				reg = <0>;
-				funnel_center_in_rpm_etm0: endpoint {
-					slave-mode;
-					remote-endpoint =
-						<&rpm_etm0_out_funnel_center>;
-				};
-			};
-
-			port@2 {
-				reg = <2>;
-				funnel_center_in_dbgui: endpoint {
-					slave-mode;
-					remote-endpoint =
-						<&dbgui_out_funnel_center>;
-				};
-			};
-		};
-	};
-
-	funnel_right: funnel@6120000 {
-		compatible = "arm,primecell";
-
-		reg = <0x6120000 0x1000>;
-		reg-names = "funnel-base";
-
-		coresight-name = "coresight-funnel-right";
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-
-		ports {
-			#address-cells = <1>;
-			#size-cells = <0>;
-
-			port@0 {
-				funnel_right_out_funnel_in0: endpoint {
-					remote-endpoint =
-						<&funnel_in0_in_funnel_right>;
-				};
-			};
-
-			port@1 {
-				reg = <1>;
-				funnel_right_in_modem_etm0: endpoint {
-					slave-mode;
-					remote-endpoint =
-						<&modem_etm0_out_funnel_right>;
-				};
-			};
-
-			port@2 {
-				reg = <2>;
-				funnel_right_in_funnel_apss: endpoint {
-					slave-mode;
-					remote-endpoint =
-						<&funnel_apss_out_funnel_right>;
-				};
-			};
-		};
-	};
-
-	funnel_cam: funnel@6132000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b908>;
-
-		reg = <0x6132000 0x1000>;
-		reg-names = "funnel-base";
-
-		coresight-name = "coresight-funnel-cam";
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-
-		 port {
-			funnel_cam_out_funnel_mm: endpoint {
-				remote-endpoint = <&funnel_mm_in_funnel_cam>;
-			};
-		};
-	};
-
-	funnel_apss: funnel@61a1000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b908>;
-
-		reg = <0x61a1000 0x1000>;
-		reg-names = "funnel-base";
-
-		coresight-name = "coresight-funnel-apss";
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-
-		ports {
-			#address-cells = <1>;
-			#size-cells = <0>;
-
-			port@0 {
-				funnel_apss_out_funnel_right: endpoint {
-					remote-endpoint =
-						<&funnel_right_in_funnel_apss>;
-				};
-			};
-
-			port@1 {
-				reg = <0>;
-				funnel_apss0_in_etm0: endpoint {
-					slave-mode;
-					remote-endpoint =
-						<&etm0_out_funnel_apss0>;
-				};
-			};
-
-			port@2 {
-				reg = <1>;
-				funnel_apss0_in_etm1: endpoint {
-					slave-mode;
-					remote-endpoint =
-						<&etm1_out_funnel_apss0>;
-				};
-			};
-
-			port@3 {
-				reg = <2>;
-				funnel_apss0_in_etm2: endpoint {
-					slave-mode;
-					remote-endpoint =
-						<&etm2_out_funnel_apss0>;
-				};
-			};
-
-			port@4 {
-				reg = <3>;
-				funnel_apss0_in_etm3: endpoint {
-					slave-mode;
-					remote-endpoint =
-						<&etm3_out_funnel_apss0>;
-				};
-			};
-		};
-	};
-
-	etm0: etm@61bc000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x000bb95d>;
-
-		reg = <0x61bc000 0x1000>;
-		cpu = <&CPU0>;
-		reg-names = "etm-base";
-
-		coresight-name = "coresight-etm0";
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-		port {
-			etm0_out_funnel_apss0: endpoint {
-				remote-endpoint = <&funnel_apss0_in_etm0>;
-			};
-		};
-	};
-
-	etm1: etm@61bd000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x000bb95d>;
-
-		reg = <0x61bd000 0x1000>;
-		cpu = <&CPU1>;
-		coresight-name = "coresight-etm1";
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-
-		port {
-			etm1_out_funnel_apss0: endpoint {
-				remote-endpoint = <&funnel_apss0_in_etm1>;
-			};
-		};
-	};
-
-	etm2: etm@61be000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x000bb95d>;
-
-		reg = <0x61be000 0x1000>;
-		cpu = <&CPU2>;
-		coresight-name = "coresight-etm2";
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-
-		port {
-			etm2_out_funnel_apss0: endpoint {
-				remote-endpoint = <&funnel_apss0_in_etm2>;
-			};
-		};
-	};
-
-	etm3: etm@61bf000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x000bb95d>;
-
-		reg = <0x61bf000 0x1000>;
-		cpu = <&CPU3>;
-		coresight-name = "coresight-etm3";
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-
-		port {
-			etm3_out_funnel_apss0: endpoint {
-				remote-endpoint = <&funnel_apss0_in_etm3>;
-			};
-		};
-	};
-
-	stm: stm@6002000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b962>;
-
-		reg = <0x6002000 0x1000>,
-		      <0x9280000 0x180000>;
-		reg-names = "stm-base", "stm-data-base";
-
-		coresight-name = "coresight-stm";
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-
-		port {
-			stm_out_funnel_in0: endpoint {
-				remote-endpoint = <&funnel_in0_in_stm>;
-			};
-		};
-	};
-
-	cti0: cti@6010000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b966>;
-
-		reg = <0x6010000 0x1000>;
-		reg-names = "cti-base";
-
-		coresight-name = "coresight-cti0";
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-	};
-
-	cti1: cti@6011000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b966>;
-
-		reg = <0x6011000 0x1000>;
-		reg-names = "cti-base";
-
-		coresight-name = "coresight-cti1";
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-	};
-
-	cti2: cti@6012000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b966>;
-
-		reg = <0x6012000 0x1000>;
-		reg-names = "cti-base";
-
-		coresight-name = "coresight-cti2";
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-	};
-
-	cti3: cti@6013000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b966>;
-
-		reg = <0x6013000 0x1000>;
-		reg-names = "cti-base";
-
-		coresight-name = "coresight-cti3";
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-	};
-
-	cti4: cti@6014000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b966>;
-
-		reg = <0x6014000 0x1000>;
-		reg-names = "cti-base";
-
-		coresight-name = "coresight-cti4";
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-	};
-
-	cti5: cti@6015000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b966>;
-
-		reg = <0x6015000 0x1000>;
-		reg-names = "cti-base";
-
-		coresight-name = "coresight-cti5";
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-	};
-
-	cti6: cti@6016000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b966>;
-
-		reg = <0x6016000 0x1000>;
-		reg-names = "cti-base";
-
-		coresight-name = "coresight-cti6";
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-	};
-
-	cti7: cti@6017000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b966>;
-
-		reg = <0x6017000 0x1000>;
-		reg-names = "cti-base";
-
-		coresight-name = "coresight-cti7";
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-	};
-
-	cti8: cti@6018000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b966>;
-
-		reg = <0x6018000 0x1000>;
-		reg-names = "cti-base";
-
-		coresight-name = "coresight-cti8";
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-	};
-
-	cti9: cti@6019000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b966>;
-
-		reg = <0x6019000 0x1000>;
-		reg-names = "cti-base";
-
-		coresight-name = "coresight-cti9";
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-	};
-
-	cti10: cti@601a000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b966>;
-
-		reg = <0x601a000 0x1000>;
-		reg-names = "cti-base";
-
-		coresight-name = "coresight-cti10";
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-	};
-
-	cti11: cti@601b000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b966>;
-
-		reg = <0x601b000 0x1000>;
-		reg-names = "cti-base";
-
-		coresight-name = "coresight-cti11";
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-	};
-
-	cti12: cti@601c000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b966>;
-
-		reg = <0x601c000 0x1000>;
-		reg-names = "cti-base";
-
-		coresight-name = "coresight-cti12";
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-	};
-
-	cti13: cti@601d000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b966>;
-
-		reg = <0x601d000 0x1000>;
-		reg-names = "cti-base";
-
-		coresight-name = "coresight-cti13";
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-	};
-
-	cti14: cti@601e000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b966>;
-
-		reg = <0x601e000 0x1000>;
-		reg-names = "cti-base";
-
-		coresight-name = "coresight-cti14";
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-	};
-
-	cti15: cti@601f000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b966>;
-
-		reg = <0x601f000 0x1000>;
-		reg-names = "cti-base";
-
-		coresight-name = "coresight-cti15";
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-	};
-
-	cti_cpu0: cti@61b8000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b966>;
-
-		reg = <0x61b8000 0x1000>;
-		reg-names = "cti-base";
-
-		coresight-name = "coresight-cti-cpu0";
-		cpu = <&CPU0>;
-		qcom,cti-save;
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-	};
-
-	cti_cpu1: cti@61b9000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b966>;
-
-		reg = <0x61b9000 0x1000>;
-		reg-names = "cti-base";
-
-		coresight-name = "coresight-cti-cpu1";
-		cpu = <&CPU1>;
-		qcom,cti-save;
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-	};
-
-	cti_cpu2: cti@61ba000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b966>;
-
-		reg = <0x61ba000 0x1000>;
-		reg-names = "cti-base";
-
-		coresight-name = "coresight-cti-cpu2";
-		cpu = <&CPU2>;
-		qcom,cti-save;
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-	};
-
-	cti_cpu3: cti@61bb000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b966>;
-
-		reg = <0x61bb000 0x1000>;
-		reg-names = "cti-base";
-
-		coresight-name = "coresight-cti-cpu3";
-		cpu = <&CPU3>;
-		qcom,cti-save;
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-	};
-
-	cti_modem_cpu0: cti@6124000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b966>;
-
-		reg = <0x6124000 0x1000>;
-		reg-names = "cti-base";
-
-		coresight-name = "coresight-cti-modem-cpu0";
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-	};
-
-	/* Proto CTI */
-	cti_wcn_cpu0: cti@6139000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b966>;
-
-		reg = <0x6139000 0x1000>;
-		reg-names = "cti-base";
-
-		coresight-name = "coresight-cti-wcn-cpu0";
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-	};
-
-	/* Venus CTI */
-	cti_video_cpu0: cti@6134000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b966>;
-
-		reg = <0x6134000 0x1000>;
-		reg-names = "cti-base";
-
-		coresight-name = "coresight-cti-video-cpu0";
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-	};
-
-	/* LPASS CTI */
-	cti_audio_cpu0: cti@613c000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b966>;
-
-		reg = <0x613c000 0x1000>;
-		reg-names = "cti-base";
-
-		coresight-name = "coresight-cti-audio-cpu0";
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-	};
-
-	/* RPM CTI */
-	cti_rpm_cpu0: cti@610c000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b966>;
-
-		reg = <0x610c000 0x1000>;
-		reg-names = "cti-base";
-
-		coresight-name = "coresight-cti-rpm-cpu0";
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-	};
-
-	/* Proto ETM */
-	wcn_etm0 {
-		compatible = "qcom,coresight-remote-etm";
-		coresight-name = "coresight-wcn-etm0";
-		qcom,inst-id = <3>;
-
-		port {
-			wcn_etm0_out_funnel_mm: endpoint {
-				remote-endpoint = <&funnel_mm_in_wcn_etm0>;
-			};
-		};
-	};
-
-	rpm_etm0 {
-		compatible = "qcom,coresight-remote-etm";
-		coresight-name = "coresight-rpm-etm0";
-		qcom,inst-id = <4>;
-
-		port {
-			rpm_etm0_out_funnel_center: endpoint {
-				remote-endpoint = <&funnel_center_in_rpm_etm0>;
-			};
-		};
-	};
-
-	/* LPASS ETM */
-	audio_etm0 {
-		compatible = "qcom,coresight-remote-etm";
-		coresight-name = "coresight-audio-etm0";
-		qcom,inst-id = <5>;
-
-		port {
-			audio_etm0_out_funnel_mm: endpoint {
-				remote-endpoint = <&funnel_mm_in_audio_etm0>;
-			};
-		};
-	};
-
-	modem_etm0 {
-		compatible = "qcom,coresight-remote-etm";
-		coresight-name = "coresight-modem-etm0";
-		qcom,inst-id = <11>;
-
-		port {
-			modem_etm0_out_funnel_right: endpoint {
-				remote-endpoint = <&funnel_right_in_modem_etm0>;
-			};
-		};
-	};
-
-	csr: csr@6001000 {
-		compatible = "qcom,coresight-csr";
-		reg = <0x6001000 0x1000>;
-		reg-names = "csr-base";
-
-		coresight-name = "coresight-csr";
-
-		qcom,usb-bam-support;
-		qcom,hwctrl-set-support;
-		qcom,set-byte-cntr-support;
-
-		qcom,blk-size = <1>;
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-	};
-
-	dbgui: dbgui@6108000 {
-		compatible = "qcom,coresight-dbgui";
-		reg = <0x6108000 0x1000>;
-		reg-names = "dbgui-base";
-
-		coresight-name = "coresight-dbgui";
-
-		qcom,dbgui-addr-offset = <0x30>;
-		qcom,dbgui-data-offset = <0x130>;
-		qcom,dbgui-size = <32>;
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-
-		port {
-			dbgui_out_funnel_center: endpoint {
-				remote-endpoint = <&funnel_center_in_dbgui>;
-			};
-		};
-	};
-
-	tpda: tpda@6003000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b969>;
-
-		reg = <0x6003000 0x1000>;
-		reg-names = "tpda-base";
-
-		coresight-name = "coresight-tpda";
-
-		qcom,tpda-atid = <64>;
-		qcom,cmb-elem-size = <0 32>;
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-
-		ports {
-			#address-cells = <1>;
-			#size-cells = <0>;
-
-			port@0 {
-				tpda_out_funnel_in0: endpoint {
-					remote-endpoint = <&funnel_in0_in_tpda>;
-				};
-			};
-
-			port@1 {
-				reg = <0>;
-				tpda_in_tpdm_dcc: endpoint {
-					slave-mode;
-					remote-endpoint =
-						<&tpdm_dcc_out_tpda>;
-				};
-			};
-		};
-	};
-
-	tpdm_dcc: tpdm@6110000 {
-		compatible = "arm,primecell";
-		arm,primecell-periphid = <0x0003b968>;
-
-		reg = <0x6110000 0x1000>;
-		reg-names = "tpdm-base";
-
-		coresight-name = "coresight-tpdm-dcc";
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-
-		port {
-			tpdm_dcc_out_tpda: endpoint {
-				remote-endpoint = <&tpda_in_tpdm_dcc>;
-			};
-		};
-	};
-
-	hwevent: hwevent@6101000 {
-		compatible = "qcom,coresight-hwevent";
-		reg = <0x6101000 0x148>,
-		      <0x6101fb0 0x4>,
-		      <0x6121000 0x148>,
-		      <0x6121fb0 0x4>,
-		      <0x6131000 0x148>,
-		      <0x6131fb0 0x4>,
-		      <0x78c5010 0x4>,
-		      <0x7885010 0x4>;
-		reg-names = "center-wrapper-mux", "center-wrapper-lockaccess",
-			    "right-wrapper-mux", "right-wrapper-lockaccess",
-			    "mm-wrapper-mux", "mm-wrapper-lockaccess",
-			    "usbbam-mux", "blsp-mux";
-
-		coresight-name = "coresight-hwevent";
-		coresight-csr = <&csr>;
-
-		clocks = <&clock_gcc clk_qdss_clk>,
-			 <&clock_gcc clk_qdss_a_clk>;
-		clock-names = "apb_pclk";
-	};
+&dbgui {
+	qcom,dbgui-size = <32>;
 };
diff --git a/arch/arm64/boot/dts/qcom/msm8917-cpu.dtsi b/arch/arm64/boot/dts/qcom/msm8917-cpu.dtsi
index 5a242db..bf57e45 100644
--- a/arch/arm64/boot/dts/qcom/msm8917-cpu.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8917-cpu.dtsi
@@ -47,6 +47,8 @@
 			reg = <0x100>;
 			enable-method = "psci";
 			cpu-release-addr = <0x0 0x90000000>;
+			efficiency = <1024>;
+			sched-energy-costs = <&CPU_COST_0 &CLUSTER_COST_0>;
 			next-level-cache = <&L2_1>;
 			L2_1: l2-cache {
 			      compatible = "arm,arch-cache";
@@ -70,6 +72,8 @@
 			reg = <0x101>;
 			enable-method = "psci";
 			cpu-release-addr = <0x0 0x90000000>;
+			efficiency = <1024>;
+			sched-energy-costs = <&CPU_COST_0 &CLUSTER_COST_0>;
 			next-level-cache = <&L2_1>;
 			L1_I_101: l1-icache {
 				compatible = "arm,arch-cache";
@@ -87,6 +91,8 @@
 			reg = <0x102>;
 			enable-method = "psci";
 			cpu-release-addr = <0x0 0x90000000>;
+			efficiency = <1024>;
+			sched-energy-costs = <&CPU_COST_0 &CLUSTER_COST_0>;
 			next-level-cache = <&L2_1>;
 			L1_I_102: l1-icache {
 				compatible = "arm,arch-cache";
@@ -104,6 +110,8 @@
 			reg = <0x103>;
 			enable-method = "psci";
 			cpu-release-addr = <0x0 0x90000000>;
+			efficiency = <1024>;
+			sched-energy-costs = <&CPU_COST_0 &CLUSTER_COST_0>;
 			next-level-cache = <&L2_1>;
 			L1_I_103: l1-icache {
 				compatible = "arm,arch-cache";
@@ -116,6 +124,35 @@
 		};
 
 	};
+
+	energy_costs: energy-costs {
+		compatible = "sched-energy";
+
+		CPU_COST_0: core-cost0 {
+			busy-cost-data = <
+				 960000 159
+				1094000 207
+				1248000 256
+				1401000 327
+				1497600 343
+			>;
+			idle-cost-data = <
+				100 80 60 40
+			>;
+		};
+		CLUSTER_COST_0: cluster-cost0 {
+			busy-cost-data = <
+				 960000 53
+				1094000 61
+				1248000 71
+				1401000 85
+				1497600 88
+			>;
+			idle-cost-data = <
+				4 3 2 1
+			>;
+		};
+	};
 };
 
 &soc {
diff --git a/arch/arm64/boot/dts/qcom/msm8917.dtsi b/arch/arm64/boot/dts/qcom/msm8917.dtsi
index cb520bd..7d49ea1 100644
--- a/arch/arm64/boot/dts/qcom/msm8917.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8917.dtsi
@@ -490,6 +490,13 @@
 			< 1401000000 4>,
 			< 1497600000 5>;
 
+		qcom,speed3-bin-v0-c1 =
+			<          0 0>,
+			<  960000000 1>,
+			< 1094400000 2>,
+			< 1248000000 3>,
+			< 1305600000 4>;
+
 		#clock-cells = <1>;
 	};
 
@@ -506,6 +513,7 @@
 			 <  960000 >,
 			 < 1094400 >,
 			 < 1248000 >,
+			 < 1305600 >,
 			 < 1401000 >,
 			 < 1497600 >;
 	};
@@ -832,9 +840,9 @@
 			reg = <0x10 8>;
 		};
 
-		dload_type@18 {
+		dload_type@1c {
 			compatible = "qcom,msm-imem-dload-type";
-			reg = <0x18 4>;
+			reg = <0x1c 4>;
 		};
 
 		restart_reason@65c {
@@ -847,6 +855,11 @@
 			reg = <0x6b0 32>;
 		};
 
+		kaslr_offset@6d0 {
+			compatible = "qcom,msm-imem-kaslr_offset";
+			reg = <0x6d0 12>;
+		};
+
 		pil@94c {
 			compatible = "qcom,msm-imem-pil";
 			reg = <0x94c 200>;
@@ -1722,7 +1735,9 @@
 /* GPU overrides */
 &msm_gpu {
 
-	qcom,gpu-speed-bin = <0x6018 0x80000000 31>;
+	qcom,gpu-speed-bin-vectors =
+		<0x6018 0x80000000 31>,
+		<0x0164 0x00000400 9>;
 	/delete-node/qcom,gpu-pwrlevels;
 
 	qcom,gpu-pwrlevel-bins {
@@ -1854,5 +1869,49 @@
 				qcom,bus-max = <0>;
 			};
 		};
+
+		qcom,gpu-pwrlevels-2 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			qcom,speed-bin = <2>;
+			qcom,initial-pwrlevel = <1>;
+
+			/* NOM */
+			qcom,gpu-pwrlevel@0 {
+				reg = <0>;
+				qcom,gpu-freq = <465000000>;
+				qcom,bus-freq = <7>;
+				qcom,bus-min = <5>;
+				qcom,bus-max = <7>;
+			};
+
+			/* SVS+ */
+			qcom,gpu-pwrlevel@1 {
+				reg = <1>;
+				qcom,gpu-freq = <400000000>;
+				qcom,bus-freq = <4>;
+				qcom,bus-min = <3>;
+				qcom,bus-max = <5>;
+			};
+
+			/* SVS */
+			qcom,gpu-pwrlevel@2 {
+				reg = <2>;
+				qcom,gpu-freq = <270000000>;
+				qcom,bus-freq = <3>;
+				qcom,bus-min = <1>;
+				qcom,bus-max = <3>;
+			};
+
+			/* XO */
+			qcom,gpu-pwrlevel@3 {
+				reg = <3>;
+				qcom,gpu-freq = <19200000>;
+				qcom,bus-freq = <0>;
+				qcom,bus-min = <0>;
+				qcom,bus-max = <0>;
+			};
+		};
 	};
 };
diff --git a/arch/arm64/boot/dts/qcom/msm8937-coresight.dtsi b/arch/arm64/boot/dts/qcom/msm8937-coresight.dtsi
index e599b31..8c8f175 100644
--- a/arch/arm64/boot/dts/qcom/msm8937-coresight.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8937-coresight.dtsi
@@ -853,11 +853,11 @@
 		clock-names = "apb_pclk";
 	};
 
-	cti_cpu0: cti@6198000{
+	cti_cpu0: cti@61b8000{
 		compatible = "arm,primecell";
 		arm,primecell-periphid = <0x0003b966>;
 
-		reg = <0x6198000 0x1000>;
+		reg = <0x61b8000 0x1000>;
 		reg-names = "cti-base";
 		coresight-name = "coresight-cti-cpu0";
 		cpu = <&CPU0>;
@@ -868,11 +868,11 @@
 		clock-names = "apb_pclk";
 	};
 
-	cti_cpu1: cti@6199000{
+	cti_cpu1: cti@61b9000{
 		compatible = "arm,primecell";
 		arm,primecell-periphid = <0x0003b966>;
 
-		reg = <0x6199000 0x1000>;
+		reg = <0x61b9000 0x1000>;
 		reg-names = "cti-base";
 		coresight-name = "coresight-cti-cpu1";
 		cpu = <&CPU1>;
@@ -883,11 +883,11 @@
 		clock-names = "apb_pclk";
 	};
 
-	cti_cpu2: cti@619a000{
+	cti_cpu2: cti@61ba000{
 		compatible = "arm,primecell";
 		arm,primecell-periphid = <0x0003b966>;
 
-		reg = <0x619a000 0x1000>;
+		reg = <0x61ba000 0x1000>;
 		reg-names = "cti-base";
 		coresight-name = "coresight-cti-cpu2";
 		cpu = <&CPU2>;
@@ -898,11 +898,11 @@
 		clock-names = "apb_pclk";
 	};
 
-	cti_cpu3: cti@619b000{
+	cti_cpu3: cti@61bb000{
 		compatible = "arm,primecell";
 		arm,primecell-periphid = <0x0003b966>;
 
-		reg = <0x619b000 0x1000>;
+		reg = <0x61bb000 0x1000>;
 		reg-names = "cti-base";
 		coresight-name = "coresight-cti-cpu3";
 		cpu = <&CPU3>;
@@ -913,11 +913,11 @@
 		clock-names = "apb_pclk";
 	};
 
-	cti_cpu4: cti@61b8000{
+	cti_cpu4: cti@6198000{
 		compatible = "arm,primecell";
 		arm,primecell-periphid = <0x0003b966>;
 
-		reg = <0x61b8000 0x1000>;
+		reg = <0x6198000 0x1000>;
 		reg-names = "cti-base";
 		coresight-name = "coresight-cti-cpu4";
 		cpu = <&CPU4>;
@@ -928,11 +928,11 @@
 		clock-names = "apb_pclk";
 	};
 
-	cti_cpu5: cti@61b9000{
+	cti_cpu5: cti@6199000{
 		compatible = "arm,primecell";
 		arm,primecell-periphid = <0x0003b966>;
 
-		reg = <0x61b9000 0x1000>;
+		reg = <0x6199000 0x1000>;
 		reg-names = "cti-base";
 		coresight-name = "coresight-cti-cpu5";
 		cpu = <&CPU5>;
@@ -943,11 +943,11 @@
 		clock-names = "apb_pclk";
 	};
 
-	cti_cpu6: cti@61ba000{
+	cti_cpu6: cti@619a000{
 		compatible = "arm,primecell";
 		arm,primecell-periphid = <0x0003b966>;
 
-		reg = <0x61ba000 0x1000>;
+		reg = <0x619a000 0x1000>;
 		reg-names = "cti-base";
 		coresight-name = "coresight-cti-cpu6";
 		cpu = <&CPU6>;
@@ -958,11 +958,11 @@
 		clock-names = "apb_pclk";
 	};
 
-	cti_cpu7: cti@61bb000{
+	cti_cpu7: cti@619b000{
 		compatible = "arm,primecell";
 		arm,primecell-periphid = <0x0003b966>;
 
-		reg = <0x61bb000 0x1000>;
+		reg = <0x619b000 0x1000>;
 		reg-names = "cti-base";
 		coresight-name = "coresight-cti-cpu7";
 		cpu = <&CPU7>;
@@ -1195,7 +1195,7 @@
 		      <0x6121fb0 0x4>,
 		      <0x6131000 0x148>,
 		      <0x6131fb0 0x4>,
-		      <0x7105010 0x4>,
+		      <0x78c5010 0x4>,
 		      <0x7885010 0x4>;
 
 		reg-names = "center-wrapper-mux", "center-wrapper-lockaccess",
diff --git a/arch/arm64/boot/dts/qcom/msm8937-interposer-sdm429.dtsi b/arch/arm64/boot/dts/qcom/msm8937-interposer-sdm429.dtsi
index 433ed7c..29f008a 100644
--- a/arch/arm64/boot/dts/qcom/msm8937-interposer-sdm429.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8937-interposer-sdm429.dtsi
@@ -19,10 +19,10 @@
 	/delete-node/ etm@619d000;
 	/delete-node/ etm@619e000;
 	/delete-node/ etm@619f000;
-	/delete-node/ cti@61b8000;
-	/delete-node/ cti@61b9000;
-	/delete-node/ cti@61ba000;
-	/delete-node/ cti@61bb000;
+	/delete-node/ cti@6198000;
+	/delete-node/ cti@6199000;
+	/delete-node/ cti@619a000;
+	/delete-node/ cti@619b000;
 	/delete-node/ jtagmm@619c000;
 	/delete-node/ jtagmm@619d000;
 	/delete-node/ jtagmm@619e000;
diff --git a/arch/arm64/boot/dts/qcom/msm8937-mtp.dtsi b/arch/arm64/boot/dts/qcom/msm8937-mtp.dtsi
index 90685e9..b0cc91c 100644
--- a/arch/arm64/boot/dts/qcom/msm8937-mtp.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8937-mtp.dtsi
@@ -106,6 +106,8 @@
 &dsi_truly_1080_vid {
 	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
 	qcom,mdss-dsi-pan-enable-dynamic-fps;
+	qcom,mdss-dsi-min-refresh-rate = <48>;
+	qcom,mdss-dsi-max-refresh-rate = <60>;
 	qcom,mdss-dsi-pan-fps-update = "dfps_immediate_porch_mode_vfp";
 };
 
diff --git a/arch/arm64/boot/dts/qcom/msm8937.dtsi b/arch/arm64/boot/dts/qcom/msm8937.dtsi
index b440cb60..5006f28 100644
--- a/arch/arm64/boot/dts/qcom/msm8937.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8937.dtsi
@@ -1040,9 +1040,9 @@
 			reg = <0x10 8>;
 		};
 
-		dload_type@18 {
+		dload_type@1c {
 			compatible = "qcom,msm-imem-dload-type";
-			reg = <0x18 4>;
+			reg = <0x1c 4>;
 		};
 
 		restart_reason@65c {
diff --git a/arch/arm64/boot/dts/qcom/msm8940-mtp.dtsi b/arch/arm64/boot/dts/qcom/msm8940-mtp.dtsi
new file mode 100644
index 0000000..4414279
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/msm8940-mtp.dtsi
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2016, 2018, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include "msm8937-mtp.dtsi"
+#include "msm8940-pinctrl.dtsi"
+
+&soc {
+};
diff --git a/arch/arm64/boot/dts/qcom/msm8940-pinctrl.dtsi b/arch/arm64/boot/dts/qcom/msm8940-pinctrl.dtsi
new file mode 100644
index 0000000..55933b9
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/msm8940-pinctrl.dtsi
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2016, 2018, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include "msm8937-pinctrl.dtsi"
+
+&soc {
+};
diff --git a/arch/arm64/boot/dts/qcom/msm8940-pmi8937-mtp.dts b/arch/arm64/boot/dts/qcom/msm8940-pmi8937-mtp.dts
new file mode 100644
index 0000000..386badd
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/msm8940-pmi8937-mtp.dts
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2016, 2018, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+/dts-v1/;
+
+#include "msm8940.dtsi"
+#include "msm8940-pmi8937-mtp.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. MSM8940-PMI8937 MTP";
+	compatible = "qcom,msm8940-mtp", "qcom,msm8940", "qcom,mtp";
+	qcom,board-id= <8 0>;
+	qcom,pmic-id = <0x10019 0x020037 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/msm8940-pmi8937-mtp.dtsi b/arch/arm64/boot/dts/qcom/msm8940-pmi8937-mtp.dtsi
new file mode 100644
index 0000000..a1e7bcb
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/msm8940-pmi8937-mtp.dtsi
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2016, 2018, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include "pmi8937.dtsi"
+#include "msm8937-mtp.dtsi"
+#include "msm8940-mtp.dtsi"
+
+&soc {
+	led_flash0: qcom,camera-flash {
+		cell-index = <0>;
+		compatible = "qcom,camera-flash";
+		qcom,flash-type = <1>;
+		qcom,flash-source = <&pmi8937_flash0 &pmi8937_flash1>;
+		qcom,torch-source = <&pmi8937_torch0 &pmi8937_torch1>;
+		qcom,switch-source = <&pmi8937_switch>;
+	};
+};
+
+&vendor {
+	mtp_batterydata: qcom,battery-data {
+		qcom,batt-id-range-pct = <15>;
+		#include "batterydata-itech-3000mah.dtsi"
+		#include "batterydata-ascent-3450mAh.dtsi"
+	};
+};
+
+&qpnp_fg {
+	qcom,battery-data = <&mtp_batterydata>;
+};
+
+&qpnp_smbcharger {
+	qcom,battery-data = <&mtp_batterydata>;
+};
diff --git a/arch/arm64/boot/dts/qcom/msm8940-pmi8940-mtp.dts b/arch/arm64/boot/dts/qcom/msm8940-pmi8940-mtp.dts
new file mode 100644
index 0000000..51a34d4
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/msm8940-pmi8940-mtp.dts
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2016, 2018, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+/dts-v1/;
+
+#include "msm8940.dtsi"
+#include "msm8940-mtp.dtsi"
+#include "msm8940-pmi8940.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. MSM8940-PMI8940 MTP";
+	compatible = "qcom,msm8940-mtp", "qcom,msm8940", "qcom,mtp";
+	qcom,board-id= <8 0>;
+	qcom,pmic-id = <0x10019 0x020040 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/msm8940-pmi8940-mtp.dtsi b/arch/arm64/boot/dts/qcom/msm8940-pmi8940-mtp.dtsi
new file mode 100644
index 0000000..3cc12e3
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/msm8940-pmi8940-mtp.dtsi
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2016, 2018, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include "msm8937-pmi8940-mtp.dtsi"
+#include "msm8940-mtp.dtsi"
+
+&soc {
+};
diff --git a/arch/arm64/boot/dts/qcom/msm8940-pmi8940.dtsi b/arch/arm64/boot/dts/qcom/msm8940-pmi8940.dtsi
new file mode 100644
index 0000000..d9baeca
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/msm8940-pmi8940.dtsi
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#include "pmi8940.dtsi"
+
+&soc {
+	led_flash0: qcom,camera-flash {
+		cell-index = <0>;
+		compatible = "qcom,camera-flash";
+		qcom,flash-type = <1>;
+		qcom,flash-source = <&pmi8940_flash0 &pmi8940_flash1>;
+		qcom,torch-source = <&pmi8940_torch0 &pmi8940_torch1>;
+		qcom,switch-source = <&pmi8940_switch>;
+	};
+};
+
diff --git a/arch/arm64/boot/dts/qcom/msm8940-pmi8950-mtp.dts b/arch/arm64/boot/dts/qcom/msm8940-pmi8950-mtp.dts
new file mode 100644
index 0000000..ff6d208
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/msm8940-pmi8950-mtp.dts
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2016, 2018, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+/dts-v1/;
+
+#include "msm8940.dtsi"
+#include "msm8940-pmi8950-mtp.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. MSM8940-PMI8950 MTP";
+	compatible = "qcom,msm8940-mtp", "qcom,msm8940", "qcom,mtp";
+	qcom,board-id= <8 0>;
+	qcom,pmic-id = <0x10019 0x020011 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/msm8940-pmi8950-mtp.dtsi b/arch/arm64/boot/dts/qcom/msm8940-pmi8950-mtp.dtsi
new file mode 100644
index 0000000..5f3f3b7
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/msm8940-pmi8950-mtp.dtsi
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2016, 2018, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include "msm8937-pmi8950-mtp.dtsi"
+#include "msm8940-mtp.dtsi"
+
+&soc {
+};
diff --git a/arch/arm64/boot/dts/qcom/msm8940.dtsi b/arch/arm64/boot/dts/qcom/msm8940.dtsi
new file mode 100644
index 0000000..b7a5e02
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/msm8940.dtsi
@@ -0,0 +1,667 @@
+/*
+ * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include "skeleton64.dtsi"
+#include "msm8937.dtsi"
+
+/ {
+	model = "Qualcomm Technologies, Inc. MSM8940";
+	compatible = "qcom,msm8940";
+	qcom,msm-id = <313 0x0>;
+
+	soc: soc { };
+
+};
+
+&usb_otg {
+
+	/delete-property/ clocks;
+	clocks = <&clock_gcc clk_gcc_usb_hs_ahb_clk>,
+			 <&clock_gcc clk_gcc_usb_hs_system_clk>,
+			 <&clock_gcc clk_gcc_usb2a_phy_sleep_clk>,
+			 <&clock_gcc clk_bimc_usb_clk>,
+			 <&clock_gcc clk_snoc_usb_clk>,
+			 <&clock_gcc clk_pnoc_usb_clk>,
+			 <&clock_gcc clk_gcc_qusb2_phy_clk>,
+			 <&clock_gcc clk_gcc_usb2_hs_phy_only_clk>,
+			 <&clock_gcc clk_gcc_usb_hs_phy_cfg_ahb_clk>,
+			 <&clock_gcc clk_xo_otg_clk>;
+
+	qcom,usbbam@78c4000 {
+		/delete-property/ qcom,reset-bam-on-disconnect;
+		/delete-node/ qcom,pipe0;
+		qcom,pipe0 {
+			label = "hsusb-ipa-out-0";
+			qcom,usb-bam-mem-type = <1>;
+			qcom,dir = <0>;
+			qcom,pipe-num = <0>;
+			qcom,peer-bam = <1>;
+			qcom,src-bam-pipe-index = <1>;
+			qcom,data-fifo-size = <0x8000>;
+			qcom,descriptor-fifo-size = <0x2000>;
+		};
+		qcom,pipe1 {
+			label = "hsusb-ipa-in-0";
+			qcom,usb-bam-mem-type = <1>;
+			qcom,dir = <1>;
+			qcom,pipe-num = <0>;
+			qcom,peer-bam = <1>;
+			qcom,dst-bam-pipe-index = <0>;
+			qcom,data-fifo-size = <0x8000>;
+			qcom,descriptor-fifo-size = <0x2000>;
+		};
+		qcom,pipe2 {
+			label = "hsusb-qdss-in-0";
+			qcom,usb-bam-mem-type = <2>;
+			qcom,dir = <1>;
+			qcom,pipe-num = <0>;
+			qcom,peer-bam = <0>;
+			qcom,peer-bam-physical-address = <0x6044000>;
+			qcom,src-bam-pipe-index = <0>;
+			qcom,dst-bam-pipe-index = <2>;
+			qcom,data-fifo-offset = <0x0>;
+			qcom,data-fifo-size = <0xe00>;
+			qcom,descriptor-fifo-offset = <0xe00>;
+			qcom,descriptor-fifo-size = <0x200>;
+		};
+		qcom,pipe3 {
+			label = "hsusb-dpl-ipa-in-1";
+			qcom,usb-bam-mem-type = <1>;
+			qcom,dir = <1>;
+			qcom,pipe-num = <1>;
+			qcom,peer-bam = <1>;
+			qcom,dst-bam-pipe-index = <3>;
+			qcom,data-fifo-size = <0x8000>;
+			qcom,descriptor-fifo-size = <0x2000>;
+		};
+	};
+};
+
+&ad_hoc_bus {
+	mas_ipa: mas-ipa {
+		cell-id = <MSM_BUS_MASTER_IPA>;
+		label = "mas-ipa";
+		qcom,buswidth = <8>;
+		qcom,agg-ports = <1>;
+		qcom,ap-owned;
+		qcom,qport = <14>;
+		qcom,qos-mode = "fixed";
+		qcom,connections = <&snoc_int_1 &slv_snoc_bimc_1>;
+		qcom,prio1 = <0>;
+		qcom,prio0 = <0>;
+		qcom,bus-dev = <&fab_snoc>;
+		qcom,mas-rpm-id = <ICBID_MASTER_IPA>;
+	};
+};
+
+&soc {
+	devfreq_spdm_cpu {
+		compatible = "qcom,devfreq_spdm";
+		qcom,bw-dwnstep = <4000>;
+		qcom,max-vote = <4000>;
+	};
+};
+
+&clock_gcc {
+	compatible = "qcom,gcc-8940";
+};
+
+&clock_debug {
+	compatible = "qcom,cc-debug-8940";
+};
+
+&clock_gcc_mdss {
+	compatible = "qcom,gcc-mdss-8940";
+};
+
+&bam_dmux {
+	status = "disabled";
+};
+
+&soc {
+	ipa_hw: qcom,ipa@07900000 {
+		compatible = "qcom,ipa";
+		reg = <0x07900000 0x4effc>, <0x07904000 0x26934>;
+		reg-names = "ipa-base", "bam-base";
+		interrupts = <0 228 0>,
+				<0 230 0>;
+		interrupt-names = "ipa-irq", "bam-irq";
+		qcom,ipa-hw-ver = <6>; /* IPA core version = IPAv2.6L */
+		qcom,ipa-hw-mode = <0>; /* IPA hw type = Normal */
+		qcom,wan-rx-ring-size = <192>; /* IPA WAN-rx-ring-size*/
+		qcom,lan-rx-ring-size = <192>; /* IPA LAN-rx-ring-size*/
+		clock-names = "core_clk";
+		clocks = <&clock_gcc clk_ipa_clk>;
+		qcom,ee = <0>;
+		qcom,use-ipa-tethering-bridge;
+		qcom,modem-cfg-emb-pipe-flt;
+		qcom,msm-bus,name = "ipa";
+		qcom,msm-bus,num-cases = <3>;
+		qcom,msm-bus,num-paths = <1>;
+		qcom,msm-bus,vectors-KBps =
+		<90 512 0 0>, /* No BIMC vote (ab=0 Mbps, ib=0 Mbps ~ 0MHZ) */
+		<90 512 100000 800000>, /* SVS (ab=100, ib=800 ~ 50MHz) */
+		<90 512 100000 1200000>; /* PERF (ab=100, ib=1200 ~ 75MHz) */
+		qcom,bus-vector-names = "MIN", "SVS", "PERF";
+		qcom,rx-polling-sleep-ms = <2>; /* Polling sleep interval */
+		qcom,ipa-polling-iteration = <5>;	/* Polling Iteration */
+	};
+
+	qcom,rmnet-ipa {
+		compatible = "qcom,rmnet-ipa";
+		qcom,rmnet-ipa-ssr;
+		qcom,ipa-loaduC;
+		qcom,ipa-advertise-sg-support;
+	};
+
+	qcom,rmtfs_sharedmem@00000000 {
+		reg = <0x00000000 0x00180000>;
+	};
+
+	/* remove 8937 MEM ACC node */
+	/delete-node/ regulator@01946004;
+
+	mem_acc_vreg_corner: regulator@01946004 {
+		compatible = "qcom,mem-acc-regulator";
+		reg = <0xa4000 0x1000>;
+		reg-names = "efuse_addr";
+		regulator-name = "mem_acc_corner";
+		regulator-min-microvolt = <1>;
+		regulator-max-microvolt = <3>;
+
+		qcom,acc-reg-addr-list =
+			<0x01942138 0x01942130 0x01942120
+			 0x01942124 0x01942128>;
+
+		qcom,acc-init-reg-config = <1 0xfff>;
+
+		qcom,num-acc-corners = <3>;
+		qcom,boot-acc-corner = <2>;
+		qcom,corner1-reg-config =
+			/* SVS+ => SVS+ */
+			<(-1) (-1)>,     <(-1) (-1)>,   <(-1) (-1)>,
+			<(-1) (-1)>,     <(-1) (-1)>,   <(-1) (-1)>,
+			<(-1) (-1)>,
+			/* SVS+ => NOM */
+			<  2 0x555555>,  <  3  0x1041041>, <  4  0x1041041>,
+			<  5 0x0000041>, <(-1)      (-1)>, <(-1)      (-1)>,
+			<(-1)     (-1)>,
+			/* SVS+ => TURBO/NOM+ */
+			<  2 0x555555 >,  <  3  0x1041041>, <  4  0x1041041>,
+			<  5 0x0000041>,  <  3        0x0>, <  4        0x0>,
+			<  5       0x0>;
+
+		qcom,corner2-reg-config =
+			/* NOM => SVS+ */
+			<  2 0x555555>,  <  3  0x30C30C3>, <  4  0x30C30C3>,
+			<  5 0x00000C3>,
+			/* NOM => NOM */
+			<(-1) (-1)>,     <(-1) (-1)>,   <(-1) (-1)>,
+			<(-1) (-1)>,
+			/* NOM => TURBO/NOM+ */
+			<  2 0x555555>,       <  3  0x0>,    <  4  0x0>,
+			<  5	  0x0>;
+
+		qcom,corner3-reg-config =
+			/* TURBO/NOM+ => SVS+ */
+			<  2 0x555555>,  <  3  0x1041041>, <  4  0x1041041>,
+			<  5 0x0000041>, <  3  0x30C30C3>, <  4  0x30C30C3>,
+			<  5 0x00000C3>,
+			/* TURBO/NOM+ => NOM */
+			<  2 0x555555>,  <  3  0x1041041>, <  4  0x1041041>,
+			<  5 0x0000041>, <(-1)	    (-1)>, <(-1)      (-1)>,
+			<(-1)     (-1)>,
+			/* TURBO/NOM+ => TURBO/NOM+ */
+			<(-1) (-1)>,     <(-1) (-1)>,   <(-1) (-1)>,
+			<(-1) (-1)>,     <(-1) (-1)>,   <(-1) (-1)>,
+			<(-1)  (-1)>;
+
+		qcom,override-acc-range-fuse-list =
+			<37 40 3 0>,	/* foundry id */
+			<36 30 8 0>,	/* iddq apc on */
+			<67  0 6 0>;	/* turbo targ volt */
+
+		qcom,override-fuse-range-map =
+			<0 0>, <  0   0>, <49 63>,
+			<1 1>, <  0   0>, <50 63>,
+			<5 5>, <  0   0>, <51 63>,
+			<0 1>, < 95 255>, < 0 63>,
+			<5 5>, <100 255>, < 0 63>;
+
+		qcom,override-corner1-addr-val-map =
+			/* 1st fuse version tuple matched */
+			/* SVS+ => SVS+ */
+			<(-1) (-1)>,     <(-1) (-1)>,   <(-1) (-1)>,
+			<(-1) (-1)>,     <(-1) (-1)>,   <(-1) (-1)>,
+			<(-1) (-1)>,
+			/* SVS+ => NOM */
+			<  2 0x555555>,  <  3  0x1041041>, <  4  0x1041041>,
+			<  5 0x0000041>, <(-1)      (-1)>, <(-1)      (-1)>,
+			<(-1)     (-1)>,
+			/* SVS+ => TURBO/NOM+ */
+			<  2 0x555555 >,  <  3  0x1041041>, <  4  0x1041041>,
+			<  5 0x0000041>,  <  3        0x1>, <  4     0x1000>,
+			<  5       0x0>,
+
+			/* 2nd fuse version tuple matched */
+			/* SVS+ => SVS+ */
+			<(-1) (-1)>,     <(-1) (-1)>,   <(-1) (-1)>,
+			<(-1) (-1)>,     <(-1) (-1)>,   <(-1) (-1)>,
+			<(-1) (-1)>,
+			/* SVS+ => NOM */
+			<  2 0x555555>,  <  3  0x1041041>, <  4  0x1041041>,
+			<  5 0x0000041>, <(-1)      (-1)>, <(-1)      (-1)>,
+			<(-1)     (-1)>,
+			/* SVS+ => TURBO/NOM+ */
+			<  2 0x555555 >,  <  3  0x1041041>, <  4  0x1041041>,
+			<  5 0x0000041>,  <  3        0x1>, <  4     0x1000>,
+			<  5       0x0>,
+
+			/* 3rd fuse version tuple matched */
+			/* SVS+ => SVS+ */
+			<(-1) (-1)>,     <(-1) (-1)>,   <(-1) (-1)>,
+			<(-1) (-1)>,     <(-1) (-1)>,   <(-1) (-1)>,
+			<(-1) (-1)>,
+			/* SVS+ => NOM */
+			<  2 0x555555>,  <  3  0x1041041>, <  4  0x1041041>,
+			<  5 0x0000041>, <(-1)      (-1)>, <(-1)      (-1)>,
+			<(-1)     (-1)>,
+			/* SVS+ => TURBO/NOM+ */
+			<  2 0x555555 >,  <  3  0x1041041>, <  4  0x1041041>,
+			<  5 0x0000041>,  <  3        0x1>, <  4     0x1000>,
+			<  5       0x0>,
+
+			/* 4th fuse version tuple matched */
+			/* SVS+ => SVS+ */
+			<(-1) (-1)>,     <(-1) (-1)>,   <(-1) (-1)>,
+			<(-1) (-1)>,     <(-1) (-1)>,   <(-1) (-1)>,
+			<(-1) (-1)>,
+			/* SVS+ => NOM */
+			<  2 0x555555>,  <  3  0x1041041>, <  4  0x1041041>,
+			<  5 0x0000041>, <(-1)      (-1)>, <(-1)      (-1)>,
+			<(-1)     (-1)>,
+			/* SVS+ => TURBO/NOM+ */
+			<  2 0x555555 >,  <  3  0x1041041>, <  4  0x1041041>,
+			<  5 0x0000041>,  <  3        0x1>, <  4     0x1000>,
+			<  5       0x0>,
+
+			/* 5th fuse version tuple matched */
+			/* SVS+ => SVS+ */
+			<(-1) (-1)>,     <(-1) (-1)>,   <(-1) (-1)>,
+			<(-1) (-1)>,     <(-1) (-1)>,   <(-1) (-1)>,
+			<(-1) (-1)>,
+			/* SVS+ => NOM */
+			<  2 0x555555>,  <  3  0x1041041>, <  4  0x1041041>,
+			<  5 0x0000041>, <(-1)      (-1)>, <(-1)      (-1)>,
+			<(-1)     (-1)>,
+			/* SVS+ => TURBO/NOM+ */
+			<  2 0x555555 >,  <  3  0x1041041>, <  4  0x1041041>,
+			<  5 0x0000041>,  <  3        0x1>, <  4     0x1000>,
+			<  5       0x0>;
+
+		qcom,override-corner2-addr-val-map =
+			/* 1st fuse version tuple matched */
+			/* NOM => SVS+ */
+			<  2 0x555555>,  <  3  0x30C30C3>, <  4  0x30C30C3>,
+			<  5 0x00000C3>,
+			/* NOM => NOM */
+			<(-1) (-1)>,     <(-1) (-1)>,   <(-1) (-1)>,
+			<(-1) (-1)>,
+			/* NOM => TURBO/NOM+ */
+			<  2 0x555555>,       <  3  0x1>,    <  4  0x1000>,
+			<  5	  0x0>,
+
+			/* 2nd fuse version tuple matched */
+			/* NOM => SVS+ */
+			<  2 0x555555>,  <  3  0x30C30C3>, <  4  0x30C30C3>,
+			<  5 0x00000C3>,
+			/* NOM => NOM */
+			<(-1) (-1)>,     <(-1) (-1)>,   <(-1) (-1)>,
+			<(-1) (-1)>,
+			/* NOM => TURBO/NOM+ */
+			<  2 0x555555>,       <  3  0x1>,    <  4  0x1000>,
+			<  5	  0x0>,
+
+			/* 3rd fuse version tuple matched */
+			/* NOM => SVS+ */
+			<  2 0x555555>,  <  3  0x30C30C3>, <  4  0x30C30C3>,
+			<  5 0x00000C3>,
+			/* NOM => NOM */
+			<(-1) (-1)>,     <(-1) (-1)>,   <(-1) (-1)>,
+			<(-1) (-1)>,
+			/* NOM => TURBO/NOM+ */
+			<  2 0x555555>,       <  3  0x1>,    <  4  0x1000>,
+			<  5	  0x0>,
+
+			/* 4th fuse version tuple matched */
+			/* NOM => SVS+ */
+			<  2 0x555555>,  <  3  0x30C30C3>, <  4  0x30C30C3>,
+			<  5 0x00000C3>,
+			/* NOM => NOM */
+			<(-1) (-1)>,     <(-1) (-1)>,   <(-1) (-1)>,
+			<(-1) (-1)>,
+			/* NOM => TURBO/NOM+ */
+			<  2 0x555555>,       <  3  0x1>,    <  4  0x1000>,
+			<  5	  0x0>,
+
+			/* 5th fuse version tuple matched */
+			/* NOM => SVS+ */
+			<  2 0x555555>,  <  3  0x30C30C3>, <  4  0x30C30C3>,
+			<  5 0x00000C3>,
+			/* NOM => NOM */
+			<(-1) (-1)>,     <(-1) (-1)>,   <(-1) (-1)>,
+			<(-1) (-1)>,
+			/* NOM => TURBO/NOM+ */
+			<  2 0x555555>,       <  3  0x1>,    <  4  0x1000>,
+			<  5	  0x0>;
+
+		qcom,override-corner3-addr-val-map =
+			/* 1st fuse version tuple matched */
+			/* TURBO/NOM+ => SVS+ */
+			<  2 0x555555>,  <  3  0x1041041>, <  4  0x1041041>,
+			<  5 0x0000041>, <  3  0x30C30C3>, <  4  0x30C30C3>,
+			<  5 0x00000C3>,
+			/* TURBO/NOM+ => NOM */
+			<  2 0x555555>,  <  3  0x1041041>, <  4  0x1041041>,
+			<  5 0x0000041>, <(-1)	    (-1)>, <(-1)      (-1)>,
+			<(-1)     (-1)>,
+			/* TURBO/NOM+ => TURBO/NOM+ */
+			<(-1) (-1)>,     <(-1) (-1)>,   <(-1) (-1)>,
+			<(-1) (-1)>,     <(-1) (-1)>,   <(-1) (-1)>,
+			<(-1)  (-1)>,
+
+			/* 2nd fuse version tuple matched */
+			/* TURBO/NOM+ => SVS+ */
+			<  2 0x555555>,  <  3  0x1041041>, <  4  0x1041041>,
+			<  5 0x0000041>, <  3  0x30C30C3>, <  4  0x30C30C3>,
+			<  5 0x00000C3>,
+			/* TURBO/NOM+ => NOM */
+			<  2 0x555555>,  <  3  0x1041041>, <  4  0x1041041>,
+			<  5 0x0000041>, <(-1)	    (-1)>, <(-1)      (-1)>,
+			<(-1)     (-1)>,
+			/* TURBO/NOM+ => TURBO/NOM+ */
+			<(-1) (-1)>,     <(-1) (-1)>,   <(-1) (-1)>,
+			<(-1) (-1)>,     <(-1) (-1)>,   <(-1) (-1)>,
+			<(-1)  (-1)>,
+
+			/* 3rd fuse version tuple matched */
+			/* TURBO/NOM+ => SVS+ */
+			<  2 0x555555>,  <  3  0x1041041>, <  4  0x1041041>,
+			<  5 0x0000041>, <  3  0x30C30C3>, <  4  0x30C30C3>,
+			<  5 0x00000C3>,
+			/* TURBO/NOM+ => NOM */
+			<  2 0x555555>,  <  3  0x1041041>, <  4  0x1041041>,
+			<  5 0x0000041>, <(-1)	    (-1)>, <(-1)      (-1)>,
+			<(-1)     (-1)>,
+			/* TURBO/NOM+ => TURBO/NOM+ */
+			<(-1) (-1)>,     <(-1) (-1)>,   <(-1) (-1)>,
+			<(-1) (-1)>,     <(-1) (-1)>,   <(-1) (-1)>,
+			<(-1)  (-1)>,
+
+			/* 4th fuse version tuple matched */
+			/* TURBO/NOM+ => SVS+ */
+			<  2 0x555555>,  <  3  0x1041041>, <  4  0x1041041>,
+			<  5 0x0000041>, <  3  0x30C30C3>, <  4  0x30C30C3>,
+			<  5 0x00000C3>,
+			/* TURBO/NOM+ => NOM */
+			<  2 0x555555>,  <  3  0x1041041>, <  4  0x1041041>,
+			<  5 0x0000041>, <(-1)	    (-1)>, <(-1)      (-1)>,
+			<(-1)     (-1)>,
+			/* TURBO/NOM+ => TURBO/NOM+ */
+			<(-1) (-1)>,     <(-1) (-1)>,   <(-1) (-1)>,
+			<(-1) (-1)>,     <(-1) (-1)>,   <(-1) (-1)>,
+			<(-1)  (-1)>,
+
+			/* 5th fuse version tuple matched */
+			/* TURBO/NOM+ => SVS+ */
+			<  2 0x555555>,  <  3  0x1041041>, <  4  0x1041041>,
+			<  5 0x0000041>, <  3  0x30C30C3>, <  4  0x30C30C3>,
+			<  5 0x00000C3>,
+			/* TURBO/NOM+ => NOM */
+			<  2 0x555555>,  <  3  0x1041041>, <  4  0x1041041>,
+			<  5 0x0000041>, <(-1)	    (-1)>, <(-1)      (-1)>,
+			<(-1)     (-1)>,
+			/* TURBO/NOM+ => TURBO/NOM+ */
+			<(-1) (-1)>,     <(-1) (-1)>,   <(-1) (-1)>,
+			<(-1) (-1)>,     <(-1) (-1)>,   <(-1) (-1)>,
+			<(-1)  (-1)>;
+	};
+};
+
+&apc_vreg_corner {
+	/delete-property/ qcom,cpr-fuse-version-map;
+	/delete-property/ qcom,cpr-quotient-adjustment;
+	/delete-property/ qcom,cpr-init-voltage-adjustment;
+	/delete-property/ qcom,cpr-enable;
+
+	qcom,pvs-version-fuse-sel = <37 40 3 0>; /* foundry */
+	qcom,cpr-speed-bin-max-corners =
+		<0 (-1) 1 2 6>,
+		<1 (-1) 1 2 7>;
+
+	qcom,cpr-fuse-version-map =
+		<  0    0  (-1) (-1) (-1) (-1)>,
+		<  0    1  (-1) (-1) (-1) (-1)>,
+		<  0    5  (-1) (-1) (-1) (-1)>,
+		<  1    0  (-1) (-1) (-1) (-1)>,
+		<  1    1  (-1) (-1) (-1) (-1)>,
+		<  1    5  (-1) (-1) (-1) (-1)>;
+
+	qcom,cpr-init-voltage-adjustment =
+		<0    0     0>,
+		<0    0 20000>,
+		<0    0 20000>,
+		<0    0 20000>,
+		<0    0 20000>,
+		<0    0 25000>;
+
+	qcom,cpr-quotient-adjustment =
+		<0    0    0>,
+		<38   0   28>, /* SVSP(20mv); TURBO(15mv); KV(1.9) */
+		<0    0   28>, /* TURBO(15mv); KV(1.9) */
+		<0    0   28>, /* TURBO(15mv); KV(1.9) */
+		<38   0   28>, /* SVSP(20mv); TURBO(15mv); KV(1.9) */
+		<0    0   38>; /* TURBO(20mv); KV(1.9) */
+
+	qcom,cpr-enable;
+};
+
+&mdss_mdp {
+	qcom,vbif-settings = <0x0d0 0x00000020>;
+};
+
+&modem_mem {
+	reg = <0x0 0x86800000 0x0 0x6a00000>;
+};
+
+&adsp_fw_mem {
+	reg = <0x0 0x8d200000 0x0 0x1100000>;
+};
+
+&wcnss_fw_mem {
+	reg = <0x0 0x8e300000 0x0 0x700000>;
+};
+
+&pil_mss {
+	/delete-property/ qcom,qdsp6v56-1-8-inrush-current;
+	qcom,qdsp6v56-1-8;
+};
+
+/* GPU overrides */
+&msm_gpu {
+
+	qcom,restrict-pwrlevel = <1>;
+	/delete-property/qcom,gpu-speed-bin;
+	qcom,gpu-speed-bin = <0x0174 0x80000000 31>;
+
+	/delete-property/qcom,initial-pwrlevel;
+	/delete-node/qcom,gpu-pwrlevel-bins;
+	/delete-node/qcom,gpu-pwrlevels;
+
+	qcom,gpu-pwrlevel-bins {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		compatible="qcom,gpu-pwrlevel-bins";
+
+		/* Power levels */
+		qcom,gpu-pwrlevels-0 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			qcom,speed-bin = <0>;
+			qcom,initial-pwrlevel = <3>;
+
+			/* SUPER TURBO */
+			qcom,gpu-pwrlevel@0 {
+				reg = <0>;
+				qcom,gpu-freq = <475000000>;
+				qcom,bus-freq = <10>;
+				qcom,bus-min = <10>;
+				qcom,bus-max = <10>;
+			};
+
+			/* TURBO */
+			qcom,gpu-pwrlevel@1 {
+				reg = <1>;
+				qcom,gpu-freq = <450000000>;
+				qcom,bus-freq = <9>;
+				qcom,bus-min = <9>;
+				qcom,bus-max = <10>;
+			};
+
+			/* NOM+ */
+			qcom,gpu-pwrlevel@2 {
+				reg = <2>;
+				qcom,gpu-freq = <400000000>;
+				qcom,bus-freq = <7>;
+				qcom,bus-min = <6>;
+				qcom,bus-max = <9>;
+			};
+
+			/* NOM */
+			qcom,gpu-pwrlevel@3 {
+				reg = <3>;
+				qcom,gpu-freq = <375000000>;
+				qcom,bus-freq = <6>;
+				qcom,bus-min = <5>;
+				qcom,bus-max = <8>;
+			};
+
+			/* SVS+ */
+			qcom,gpu-pwrlevel@4 {
+				reg = <4>;
+				qcom,gpu-freq = <300000000>;
+				qcom,bus-freq = <5>;
+				qcom,bus-min = <4>;
+				qcom,bus-max = <7>;
+			};
+
+			/* SVS */
+			qcom,gpu-pwrlevel@5 {
+				reg = <5>;
+				qcom,gpu-freq = <216000000>;
+				qcom,bus-freq = <3>;
+				qcom,bus-min = <1>;
+				qcom,bus-max = <4>;
+			};
+
+			/* XO */
+			qcom,gpu-pwrlevel@6 {
+				reg = <6>;
+				qcom,gpu-freq = <19200000>;
+				qcom,bus-freq = <0>;
+				qcom,bus-min = <0>;
+				qcom,bus-max = <0>;
+			};
+		};
+
+		/* Power levels */
+		qcom,gpu-pwrlevels-1 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			qcom,speed-bin = <1>;
+			qcom,initial-pwrlevel = <3>;
+
+			/* SUPER TURBO */
+			qcom,gpu-pwrlevel@0 {
+				reg = <0>;
+				qcom,gpu-freq = <500000000>;
+				qcom,bus-freq = <10>;
+				qcom,bus-min = <10>;
+				qcom,bus-max = <10>;
+			};
+
+			/* TURBO */
+			qcom,gpu-pwrlevel@1 {
+				reg = <1>;
+				qcom,gpu-freq = <450000000>;
+				qcom,bus-freq = <9>;
+				qcom,bus-min = <9>;
+				qcom,bus-max = <10>;
+			};
+
+			/* NOM+ */
+			qcom,gpu-pwrlevel@2 {
+				reg = <2>;
+				qcom,gpu-freq = <400000000>;
+				qcom,bus-freq = <7>;
+				qcom,bus-min = <6>;
+				qcom,bus-max = <9>;
+			};
+
+			/* NOM */
+			qcom,gpu-pwrlevel@3 {
+				reg = <3>;
+				qcom,gpu-freq = <375000000>;
+				qcom,bus-freq = <6>;
+				qcom,bus-min = <5>;
+				qcom,bus-max = <8>;
+			};
+
+			/* SVS+ */
+			qcom,gpu-pwrlevel@4 {
+				reg = <4>;
+				qcom,gpu-freq = <300000000>;
+				qcom,bus-freq = <5>;
+				qcom,bus-min = <4>;
+				qcom,bus-max = <7>;
+			};
+
+			/* SVS */
+			qcom,gpu-pwrlevel@5 {
+				reg = <5>;
+				qcom,gpu-freq = <216000000>;
+				qcom,bus-freq = <3>;
+				qcom,bus-min = <1>;
+				qcom,bus-max = <4>;
+			};
+
+			/* XO */
+			qcom,gpu-pwrlevel@6 {
+				reg = <6>;
+				qcom,gpu-freq = <19200000>;
+				qcom,bus-freq = <0>;
+				qcom,bus-min = <0>;
+				qcom,bus-max = <0>;
+			};
+		};
+
+	};
+};
+
+&tsens0 {
+	qcom,temp1-offset = <0 (-2) (-5) (-3) (-1) (-1) (-1) 0 1 (-1) (-6)>;
+	qcom,temp2-offset = <1 1 (-7) 5 4 7 6 2 3 1 7>;
+};
diff --git a/arch/arm64/boot/dts/qcom/msm8953-cdp.dtsi b/arch/arm64/boot/dts/qcom/msm8953-cdp.dtsi
index 9b78253..b21983c 100644
--- a/arch/arm64/boot/dts/qcom/msm8953-cdp.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8953-cdp.dtsi
@@ -151,6 +151,8 @@
 &dsi_truly_1080_vid {
 	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
 	qcom,mdss-dsi-pan-enable-dynamic-fps;
+	qcom,mdss-dsi-min-refresh-rate = <48>;
+	qcom,mdss-dsi-max-refresh-rate = <60>;
 	qcom,mdss-dsi-pan-fps-update = "dfps_immediate_porch_mode_vfp";
 };
 
diff --git a/arch/arm64/boot/dts/qcom/msm8953-coresight.dtsi b/arch/arm64/boot/dts/qcom/msm8953-coresight.dtsi
index d3c2e26..87684a7 100644
--- a/arch/arm64/boot/dts/qcom/msm8953-coresight.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8953-coresight.dtsi
@@ -890,6 +890,7 @@
 		reg-names = "cti-base";
 		coresight-name = "coresight-cti-cpu0";
 		cpu = <&CPU0>;
+		qcom,cit-save;
 
 		clocks = <&clock_gcc clk_qdss_clk>,
 			 <&clock_gcc clk_qdss_a_clk>;
@@ -904,6 +905,7 @@
 		reg-names = "cti-base";
 		coresight-name = "coresight-cti-cpu1";
 		cpu = <&CPU1>;
+		qcom,cit-save;
 
 		clocks = <&clock_gcc clk_qdss_clk>,
 			 <&clock_gcc clk_qdss_a_clk>;
@@ -918,6 +920,7 @@
 		reg-names = "cti-base";
 		coresight-name = "coresight-cti-cpu2";
 		cpu = <&CPU2>;
+		qcom,cit-save;
 
 		clocks = <&clock_gcc clk_qdss_clk>,
 			 <&clock_gcc clk_qdss_a_clk>;
@@ -932,6 +935,7 @@
 		reg-names = "cti-base";
 		coresight-name = "coresight-cti-cpu3";
 		cpu = <&CPU3>;
+		qcom,cit-save;
 
 		clocks = <&clock_gcc clk_qdss_clk>,
 			 <&clock_gcc clk_qdss_a_clk>;
@@ -946,6 +950,7 @@
 		reg-names = "cti-base";
 		coresight-name = "coresight-cti-cpu4";
 		cpu = <&CPU4>;
+		qcom,cit-save;
 
 		clocks = <&clock_gcc clk_qdss_clk>,
 			 <&clock_gcc clk_qdss_a_clk>;
@@ -960,6 +965,7 @@
 		reg-names = "cti-base";
 		coresight-name = "coresight-cti-cpu5";
 		cpu = <&CPU5>;
+		qcom,cit-save;
 
 		clocks = <&clock_gcc clk_qdss_clk>,
 			 <&clock_gcc clk_qdss_a_clk>;
@@ -974,6 +980,7 @@
 		reg-names = "cti-base";
 		coresight-name = "coresight-cti-cpu6";
 		cpu = <&CPU6>;
+		qcom,cit-save;
 
 		clocks = <&clock_gcc clk_qdss_clk>,
 			 <&clock_gcc clk_qdss_a_clk>;
@@ -988,6 +995,7 @@
 		reg-names = "cti-base";
 		coresight-name = "coresight-cti-cpu7";
 		cpu = <&CPU7>;
+		qcom,cit-save;
 
 		clocks = <&clock_gcc clk_qdss_clk>,
 			 <&clock_gcc clk_qdss_a_clk>;
diff --git a/arch/arm64/boot/dts/qcom/msm8953-mtp.dtsi b/arch/arm64/boot/dts/qcom/msm8953-mtp.dtsi
index cc4bc7f..5655e94 100644
--- a/arch/arm64/boot/dts/qcom/msm8953-mtp.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8953-mtp.dtsi
@@ -150,6 +150,8 @@
 &dsi_truly_1080_vid {
 	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
 	qcom,mdss-dsi-pan-enable-dynamic-fps;
+	qcom,mdss-dsi-min-refresh-rate = <48>;
+	qcom,mdss-dsi-max-refresh-rate = <60>;
 	qcom,mdss-dsi-pan-fps-update = "dfps_immediate_porch_mode_vfp";
 };
 
diff --git a/arch/arm64/boot/dts/qcom/msm8953.dtsi b/arch/arm64/boot/dts/qcom/msm8953.dtsi
index b7d72b7..24701bf 100644
--- a/arch/arm64/boot/dts/qcom/msm8953.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8953.dtsi
@@ -1345,9 +1345,9 @@
 			reg = <0x10 8>;
 		};
 
-		dload_type@18 {
+		dload_type@1c {
 			compatible = "qcom,msm-imem-dload-type";
-			reg = <0x18 4>;
+			reg = <0x1c 4>;
 		};
 
 		restart_reason@65c {
diff --git a/arch/arm64/boot/dts/qcom/qcs605-lc-ipcamera.dtsi b/arch/arm64/boot/dts/qcom/qcs605-lc-ipcamera.dtsi
index fae58f0..0b36ffe 100644
--- a/arch/arm64/boot/dts/qcom/qcs605-lc-ipcamera.dtsi
+++ b/arch/arm64/boot/dts/qcom/qcs605-lc-ipcamera.dtsi
@@ -67,12 +67,26 @@
 			};
 	};
 
-	usb_vbus_det_default: usb_vbus_det_default {
-		config {
-			pins = "gpio26";
-			drive-strength = <2>;
-			bias-pull-up;
-			input-enable;
+	usb_det_default: usb_det_default {
+		usb_id_det_default: usb_id_det_default {
+			mux {
+				pins = "gpio131";
+				function = "gpio";
+			};
+			config {
+				pins = "gpio131";
+				drive-strength = <2>;
+				bias-pull-down;
+				output-enable;
+			};
+		};
+		usb_vbus_det_default: usb_vbus_det_default {
+			config {
+				pins = "gpio26";
+				drive-strength = <2>;
+				bias-pull-up;
+				input-enable;
+			};
 		};
 	};
 };
@@ -96,14 +110,16 @@
 	extcon_usb1: extcon_usb1 {
 		compatible = "linux,extcon-usb-gpio";
 		id-gpio = <&tlmm 26 0x1>;
+		trig-gpio = <&tlmm 131 0x0>;
+		gpio-names = "gpio131";
 
 		pinctrl-names = "default";
-		pinctrl-0 = <&usb_vbus_det_default>;
+		pinctrl-0 = <&usb_vbus_det_default &usb_id_det_default>;
 	};
 };
 
 &usb0 {
-	extcon = <&extcon_usb1 &extcon_usb1>;
+	extcon = <&extcon_usb1>;
 };
 
 &msm_sdw_codec {
@@ -174,14 +190,18 @@
 		"AIF4 VI", "MCLK",
 		"RX_BIAS", "MCLK",
 		"MADINPUT", "MCLK",
+		"AMIC1", "MIC BIAS1",
+		"MIC BIAS1", "Handset Mic",
+		"AMIC2", "MIC BIAS2",
+		"MIC BIAS2", "Headset Mic",
 		"DMIC0", "MIC BIAS1",
 		"MIC BIAS1", "Digital Mic0",
 		"DMIC1", "MIC BIAS1",
 		"MIC BIAS1", "Digital Mic1",
-		"DMIC2", "MIC BIAS3",
-		"MIC BIAS3", "Digital Mic2",
-		"DMIC3", "MIC BIAS3",
-		"MIC BIAS3", "Digital Mic3",
+		"DMIC2", "MIC BIAS1",
+		"MIC BIAS1", "Digital Mic2",
+		"DMIC3", "MIC BIAS1",
+		"MIC BIAS1", "Digital Mic3",
 		"SpkrLeft IN", "SPK1 OUT";
 	qcom,wsa-max-devs = <1>;
 	qcom,wsa-devs = <&wsa881x_0211>, <&wsa881x_0213>;
diff --git a/arch/arm64/boot/dts/qcom/qcs605-lc-pmic-overlay.dtsi b/arch/arm64/boot/dts/qcom/qcs605-lc-pmic-overlay.dtsi
index 1264e08..bbe3fb0 100644
--- a/arch/arm64/boot/dts/qcom/qcs605-lc-pmic-overlay.dtsi
+++ b/arch/arm64/boot/dts/qcom/qcs605-lc-pmic-overlay.dtsi
@@ -19,6 +19,8 @@
 
 		qcom,pmic-revid = <&pm660_revid>;
 
+		qcom,qcs605-ipc-wa;
+
 		io-channels = <&pm660_rradc 8>,
 			      <&pm660_rradc 10>,
 			      <&pm660_rradc 3>,
diff --git a/arch/arm64/boot/dts/qcom/qcs605.dtsi b/arch/arm64/boot/dts/qcom/qcs605.dtsi
index 7801775..cb46865 100644
--- a/arch/arm64/boot/dts/qcom/qcs605.dtsi
+++ b/arch/arm64/boot/dts/qcom/qcs605.dtsi
@@ -62,6 +62,10 @@
 	status = "disabled";
 };
 
+&qcom_seecom {
+	reg = <0x86d00000 0x800000>;
+};
+
 &sp_mem {
 	status = "disabled";
 };
diff --git a/arch/arm64/boot/dts/qcom/qm215-pm8916.dtsi b/arch/arm64/boot/dts/qcom/qm215-pm8916.dtsi
index bf47ea0..ed35f70 100644
--- a/arch/arm64/boot/dts/qcom/qm215-pm8916.dtsi
+++ b/arch/arm64/boot/dts/qcom/qm215-pm8916.dtsi
@@ -56,14 +56,20 @@
 		/delete-property/ vdd_cx-supply;
 		/delete-property/ vdd_mx-supply;
 		/delete-property/ vdd_pll-supply;
+		vdd_mss-supply = <&pm8916_s1_level>;
+		vdd_cx-supply = <&pm8916_s1_level>;
+		vdd_mx-supply = <&pm8916_l2_level_ao>;
+		vdd_pll-supply = <&pm8916_l7>;
 	};
 
 	qcom,lpass@c200000 {
 		/delete-property/ vdd_cx-supply;
+		vdd_cx-supply = <&pm8916_s1_level>;
 	};
 
 	qcom,pronto@a21b000 {
 		/delete-property/ vdd_pronto_pll-supply;
+		vdd_pronto_pll-supply = <&pm8916_l7>;
 	};
 
 	qcom,wcnss-wlan@a000000 {
@@ -114,9 +120,8 @@
 		backlight_pwm_en_default: backlight_pwm_en_default {
 			pins = "mpp4";
 			function = "digital";
-			qcom,dtest = <1>;
 			power-source = <0>;
-			output-low;
+			output-high;
 		};
 	};
 };
@@ -147,7 +152,7 @@
 };
 
 &mdss_dsi {
-	vdda-supply = <&disp_vdda_eldo1>;
+	vdda-supply = <&pm8916_l6>;
 	vddio-supply = <&pm8916_l6>;
 
 	qcom,phy-supply-entries {
@@ -163,4 +168,273 @@
 			qcom,supply-disable-load = <100>;
 		};
 	};
+
+	qcom,ctrl-supply-entries {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		qcom,ctrl-supply-entry@0 {
+			reg = <0>;
+			qcom,supply-name = "vdda";
+			qcom,supply-min-voltage = <1744000>;
+			qcom,supply-max-voltage = <1904000>;
+			qcom,supply-enable-load = <100000>;
+			qcom,supply-disable-load = <100>;
+		};
+	};
+};
+
+&clock_cpu {
+	vdd-c1-supply = <&apc_vreg_corner>;
+};
+
+&clock_gcc {
+	vdd_dig-supply = <&pm8916_s1_level>;
+	vdd_hf_dig-supply = <&pm8916_s1_level_ao>;
+	vdd_hf_pll-supply = <&pm8916_l7_ao>;
+};
+
+&pm8916_vadc {
+	chan@0 {
+		label = "usb_in";
+		reg = <0>;
+		qcom,decimation = <0>;
+		qcom,pre-div-channel-scaling = <7>;
+		qcom,calibration-type = "absolute";
+		qcom,scale-function = <0>;
+		qcom,hw-settle-time = <0>;
+		qcom,fast-avg-setup = <0>;
+	};
+
+	chan@2 {
+		label = "ireg_fb";
+		reg = <2>;
+		qcom,decimation = <0>;
+		qcom,pre-div-channel-scaling = <6>;
+		qcom,calibration-type = "absolute";
+		qcom,scale-function = <0>;
+		qcom,hw-settle-time = <0>;
+		qcom,fast-avg-setup = <0>;
+	};
+
+	chan@5 {
+		label = "vcoin";
+		reg = <5>;
+		qcom,decimation = <0>;
+		qcom,pre-div-channel-scaling = <1>;
+		qcom,calibration-type = "absolute";
+		qcom,scale-function = <0>;
+		qcom,hw-settle-time = <0>;
+		qcom,fast-avg-setup = <0>;
+	};
+
+	chan@6 {
+		label = "vbat_sns";
+		reg = <6>;
+		qcom,decimation = <0>;
+		qcom,pre-div-channel-scaling = <1>;
+		qcom,calibration-type = "absolute";
+		qcom,scale-function = <0>;
+		qcom,hw-settle-time = <0>;
+		qcom,fast-avg-setup = <0>;
+	};
+
+	chan@7 {
+		label = "vph_pwr";
+		reg = <7>;
+		qcom,decimation = <0>;
+		qcom,pre-div-channel-scaling = <1>;
+		qcom,calibration-type = "absolute";
+		qcom,scale-function = <0>;
+		qcom,hw-settle-time = <0>;
+		qcom,fast-avg-setup = <0>;
+	};
+
+	chan@b {
+		label = "chg_temp";
+		reg = <0xb>;
+		qcom,decimation = <0>;
+		qcom,pre-div-channel-scaling = <0>;
+		qcom,calibration-type = "absolute";
+		qcom,scale-function = <3>;
+		qcom,hw-settle-time = <0>;
+		qcom,fast-avg-setup = <0>;
+	};
+
+	chan@11 {
+		label = "skin_therm";
+		reg = <0x11>;
+		qcom,decimation = <0>;
+		qcom,pre-div-channel-scaling = <0>;
+		qcom,calibration-type = "ratiometric";
+		qcom,scale-function = <2>;
+		qcom,hw-settle-time = <2>;
+		qcom,fast-avg-setup = <0>;
+		qcom,vadc-thermal-node;
+	};
+
+	chan@30 {
+		label = "batt_therm";
+		reg = <0x30>;
+		qcom,decimation = <0>;
+		qcom,pre-div-channel-scaling = <0>;
+		qcom,calibration-type = "ratiometric";
+		qcom,scale-function = <22>;
+		qcom,hw-settle-time = <0xb>;
+		qcom,fast-avg-setup = <0>;
+	};
+
+	chan@31 {
+		label = "batt_id";
+		reg = <0x31>;
+		qcom,decimation = <0>;
+		qcom,pre-div-channel-scaling = <0>;
+		qcom,calibration-type = "ratiometric";
+		qcom,scale-function = <0>;
+		qcom,hw-settle-time = <0xb>;
+		qcom,fast-avg-setup = <0>;
+	};
+
+	chan@36 {
+		label = "pa_therm0";
+		reg = <0x36>;
+		qcom,decimation = <0>;
+		qcom,pre-div-channel-scaling = <0>;
+		qcom,calibration-type = "ratiometric";
+		qcom,scale-function = <2>;
+		qcom,hw-settle-time = <2>;
+		qcom,fast-avg-setup = <0>;
+		qcom,vadc-thermal-node;
+	};
+
+	chan@32 {
+		label = "xo_therm";
+		reg = <0x32>;
+		qcom,decimation = <0>;
+		qcom,pre-div-channel-scaling = <0>;
+		qcom,calibration-type = "ratiometric";
+		qcom,scale-function = <4>;
+		qcom,hw-settle-time = <2>;
+		qcom,fast-avg-setup = <0>;
+		qcom,vadc-thermal-node;
+	};
+
+	chan@3c {
+		label = "xo_therm_buf";
+		reg = <0x3c>;
+		qcom,decimation = <0>;
+		qcom,pre-div-channel-scaling = <0>;
+		qcom,calibration-type = "ratiometric";
+		qcom,scale-function = <4>;
+		qcom,hw-settle-time = <2>;
+		qcom,fast-avg-setup = <0>;
+		qcom,vadc-thermal-node;
+	};
+};
+
+&pm8916_adc_tm {
+	/* Channel Node */
+	chan@30 {
+		label = "batt_therm";
+		reg = <0x30>;
+		qcom,decimation = <0>;
+		qcom,pre-div-channel-scaling = <0>;
+		qcom,calibration-type = "ratiometric";
+		qcom,scale-function = <8>;
+		qcom,hw-settle-time = <0xb>;
+		qcom,fast-avg-setup = <0x2>;
+		qcom,btm-channel-number = <0x48>;
+	};
+
+	chan@6 {
+		label = "vbat_sns";
+		reg = <0x6>;
+		qcom,decimation = <0>;
+		qcom,pre-div-channel-scaling = <1>;
+		qcom,calibration-type = "absolute";
+		qcom,scale-function = <0>;
+		qcom,hw-settle-time = <0xb>;
+		qcom,fast-avg-setup = <0x2>;
+		qcom,btm-channel-number = <0x68>;
+	};
+};
+
+&soc {
+	thermal-zones {
+		xo-therm-buf-adc {
+			polling-delay-passive = <0>;
+			polling-delay = <0>;
+			thermal-sensors = <&pm8916_vadc 0x3c>;
+			thermal-governor = "user_space";
+
+			trips {
+				active-config0 {
+					temperature = <65000>;
+					hysteresis = <1000>;
+					type = "passive";
+				};
+			};
+		};
+
+		xo-therm-adc {
+			polling-delay-passive = <0>;
+			polling-delay = <0>;
+			thermal-sensors = <&pm8916_vadc 0x32>;
+			thermal-governor = "user_space";
+
+			trips {
+				active-config0 {
+					temperature = <65000>;
+					hysteresis = <1000>;
+					type = "passive";
+				};
+			};
+		};
+
+		pa-therm0-adc {
+			polling-delay-passive = <0>;
+			polling-delay = <0>;
+			thermal-sensors = <&pm8916_vadc 0x36>;
+			thermal-governor = "user_space";
+
+			trips {
+				active-config0 {
+					temperature = <65000>;
+					hysteresis = <1000>;
+					type = "passive";
+				};
+			};
+		};
+
+		skin-therm-adc {
+			polling-delay-passive = <0>;
+			polling-delay = <0>;
+			thermal-sensors = <&pm8916_vadc 0x11>;
+			thermal-governor = "user_space";
+
+			trips {
+				active-config0 {
+					temperature = <65000>;
+					hysteresis = <1000>;
+					type = "passive";
+				};
+			};
+		};
+	};
+};
+
+&soc {
+	usb_vdig_supply: usb_vdig_supply {
+		compatible = "regulator-fixed";
+		regulator-name = "usb_vdig_supply";
+		regulator-min-microvolt = <1200000>;
+		regulator-max-microvolt = <1200000>;
+	};
+};
+
+&usb_otg {
+	hsusb_vdd_dig-supply = <&usb_vdig_supply>;
+	HSUSB_1p8-supply = <&pm8916_l7>;
+	HSUSB_3p3-supply = <&pm8916_l13>;
+	extcon = <&pm8916_chg>;
 };
diff --git a/arch/arm64/boot/dts/qcom/qm215-qrd.dtsi b/arch/arm64/boot/dts/qcom/qm215-qrd.dtsi
index f5e1187..2708c40 100644
--- a/arch/arm64/boot/dts/qcom/qm215-qrd.dtsi
+++ b/arch/arm64/boot/dts/qcom/qm215-qrd.dtsi
@@ -48,23 +48,14 @@
 	};
 };
 
-/ {
-	qrd_batterydata: qcom,batterydata {
-		qcom,rpull-up-kohm = <100>;
-		qcom,vref-batt-therm = <1800000>;
-
-		#include "vbms-batterydata-mlp356477-2800mah.dtsi"
-	};
-};
-
 &mdss_dsi_active {
 	mux {
-		pins = "gpio61", "gpio93", "gpio94";
+		pins = "gpio60", "gpio93", "gpio94";
 		function = "gpio";
 	};
 
 	config {
-		pins = "gpio61", "gpio93", "gpio94";
+		pins = "gpio60", "gpio93", "gpio94";
 		drive-strength = <8>; /* 8 mA */
 		bias-disable = <0>; /* no pull */
 		output-high;
@@ -73,12 +64,12 @@
 
 &mdss_dsi_suspend {
 	mux {
-		pins = "gpio61", "gpio93", "gpio94";
+		pins = "gpio60", "gpio93", "gpio94";
 		function = "gpio";
 	};
 
 	config {
-		pins = "gpio61", "gpio93", "gpio94";
+		pins = "gpio60", "gpio93", "gpio94";
 		drive-strength = <2>; /* 2 mA */
 		bias-pull-down; /* pull down */
 	};
@@ -119,7 +110,7 @@
 	pinctrl-1 = <&mdss_dsi_suspend &mdss_te_suspend>;
 
 	qcom,platform-te-gpio = <&tlmm 24 0>;
-	qcom,platform-reset-gpio = <&tlmm 61 0>;
+	qcom,platform-reset-gpio = <&tlmm 60 0>;
 	qcom,platform-bklight-en-gpio = <&tlmm 93 0>;
 	qcom,platform-enable-gpio = <&tlmm 94 0>;
 };
diff --git a/arch/arm64/boot/dts/qcom/qm215.dts b/arch/arm64/boot/dts/qcom/qm215.dts
index 3fd0064..3f0b68e 100644
--- a/arch/arm64/boot/dts/qcom/qm215.dts
+++ b/arch/arm64/boot/dts/qcom/qm215.dts
@@ -17,6 +17,7 @@
 #include "qm215-pm8916.dtsi"
 
 / {
-	model = "Qualcomm Technologies, Inc. QM215 QRD";
+	model = "Qualcomm Technologies, Inc. QM215";
 	compatible = "qcom,qm215";
+	qcom,pmic-name = "PM8916";
 };
diff --git a/arch/arm64/boot/dts/qcom/qm215.dtsi b/arch/arm64/boot/dts/qcom/qm215.dtsi
index dc7ad4c..c16774b 100644
--- a/arch/arm64/boot/dts/qcom/qm215.dtsi
+++ b/arch/arm64/boot/dts/qcom/qm215.dtsi
@@ -16,6 +16,16 @@
 	model = "Qualcomm Technologies, Inc. QM215";
 	compatible = "qcom,qm215";
 	qcom,msm-id = <386 0x0>;
+	qcom,msm-name = "QM215";
+};
+
+/ {
+	qrd_batterydata: qcom,batterydata {
+		qcom,rpull-up-kohm = <100>;
+		qcom,vref-batt-therm = <1800000>;
+
+		#include "vbms-batterydata-mlp356477-2800mah.dtsi"
+	};
 };
 
 &soc {
diff --git a/arch/arm64/boot/dts/qcom/sdm429-cpu.dtsi b/arch/arm64/boot/dts/qcom/sdm429-cpu.dtsi
index 6c4ea9f..de0730d 100644
--- a/arch/arm64/boot/dts/qcom/sdm429-cpu.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm429-cpu.dtsi
@@ -134,6 +134,7 @@
 				1708800	327
 				1804800	343
 				1958400	445
+				2016000	470
 			>;
 			idle-cost-data = <
 				100 80 60 40
@@ -147,6 +148,7 @@
 				1708800	85
 				1804800	88
 				1958400	110
+				2016000	120
 			>;
 			idle-cost-data = <
 				4 3 2 1
diff --git a/arch/arm64/boot/dts/qcom/sdm429.dtsi b/arch/arm64/boot/dts/qcom/sdm429.dtsi
index 1e0cd24..8366032 100644
--- a/arch/arm64/boot/dts/qcom/sdm429.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm429.dtsi
@@ -24,10 +24,10 @@
 	/delete-node/ etm@619d000;
 	/delete-node/ etm@619e000;
 	/delete-node/ etm@619f000;
-	/delete-node/ cti@61b8000;
-	/delete-node/ cti@61b9000;
-	/delete-node/ cti@61ba000;
-	/delete-node/ cti@61bb000;
+	/delete-node/ cti@6198000;
+	/delete-node/ cti@6199000;
+	/delete-node/ cti@619a000;
+	/delete-node/ cti@619b000;
 	/delete-node/ jtagmm@619c000;
 	/delete-node/ jtagmm@619d000;
 	/delete-node/ jtagmm@619e000;
diff --git a/arch/arm64/boot/dts/qcom/sdm439-regulator.dtsi b/arch/arm64/boot/dts/qcom/sdm439-regulator.dtsi
index 42c3e83..750cedb 100644
--- a/arch/arm64/boot/dts/qcom/sdm439-regulator.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm439-regulator.dtsi
@@ -378,12 +378,12 @@
 			reg = <0x2000 0x100>;
 			regulator-name = "pm8953_s5";
 			regulator-min-microvolt = <490000>;
-			regulator-max-microvolt = <960000>;
+			regulator-max-microvolt = <980000>;
 
 			pm8953_s5_limit: avs-limit-regulator {
 				regulator-name = "pm8953_s5_avs_limit";
 				regulator-min-microvolt = <490000>;
-				regulator-max-microvolt = <960000>;
+				regulator-max-microvolt = <980000>;
 			};
 		};
 	};
@@ -418,14 +418,14 @@
 		interrupts = <0 15 0>;
 		regulator-name = "apc_corner";
 		regulator-min-microvolt = <1>;
-		regulator-max-microvolt = <5>;
+		regulator-max-microvolt = <6>;
 
 		qcom,cpr-fuse-corners = <3>;
-		qcom,cpr-voltage-ceiling = <810000 845000 960000>;
+		qcom,cpr-voltage-ceiling = <810000 845000 980000>;
 		qcom,cpr-voltage-floor =   <700000 700000 790000>;
 		vdd-apc-supply = <&pm8953_s5>;
 		mem-acc-supply = <&apc_mem_acc_vreg>;
-		qcom,mem-acc-corner-map = <1 1 1 1 2>;
+		qcom,mem-acc-corner-map = <1 1 1 1 2 2>;
 
 		qcom,cpr-ref-clk = <19200>;
 		qcom,cpr-timer-delay = <5000>;
@@ -455,15 +455,19 @@
 					<70 54 7 0>;
 		qcom,cpr-fuse-quot-offset-scale = <5 5 5>;
 		qcom,cpr-init-voltage-step = <10000>;
-		qcom,cpr-corner-map = <1 2 3 3 3>;
+		qcom,cpr-corner-map = <1 2 3 3 3 3>;
 		qcom,cpr-corner-frequency-map =
 				<1 1305600000>,
 				<2 1497600000>,
 				<3 1708800000>,
 				<4 1804800000>,
-				<5 1958400000>;
+				<5 1958400000>,
+				<6 2016000000>;
 		qcom,speed-bin-fuse-sel = <37 34 3 0>;
-		qcom,cpr-speed-bin-max-corners = <(-1) (-1) 1 2 5>;
+		qcom,cpr-speed-bin-max-corners =
+					<0 (-1) 1 2 5>,
+					<1 (-1) 1 2 5>,
+					<4 (-1) 1 2 6>;
 		qcom,cpr-fuse-revision = <69 39 3 0>;
 		qcom,cpr-quot-adjust-scaling-factor-max = <0 1400 1400>;
 		qcom,cpr-voltage-scaling-factor-max = <0 2000 2000>;
@@ -481,17 +485,17 @@
 			<0        0       0>;
 
 		qcom,cpr-floor-to-ceiling-max-range =
-			<50000 50000 65000 65000 65000>,
-			<50000 50000 65000 65000 65000>,
-			<50000 50000 65000 65000 65000>;
+			<50000 50000 65000 65000 65000 65000>,
+			<50000 50000 65000 65000 65000 65000>,
+			<50000 50000 65000 65000 65000 65000>;
 
 		qcom,cpr-voltage-ceiling-override =
-			<(-1) (-1) 810000 845000 885000 960000 960000>;
+			<(-1) (-1) 810000 845000 885000 980000 980000 980000>;
 
 		qcom,cpr-virtual-corner-quotient-adjustment =
-			<0  0    0   0   0>,
-			<0  0  (-22) 0   0>, /* NOMP: -10 mV */
-			<0  0    0   0   0>;
+			<0  0    0   0   0    0>,
+			<0  0  (-22) 0   0    0>, /* NOMP: -10 mV */
+			<0  0    0   0   0    0>;
 
 		qcom,cpr-enable;
 	};
diff --git a/arch/arm64/boot/dts/qcom/sdm439.dtsi b/arch/arm64/boot/dts/qcom/sdm439.dtsi
index ef22440..dc651d3 100644
--- a/arch/arm64/boot/dts/qcom/sdm439.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm439.dtsi
@@ -179,6 +179,7 @@
 				1708800	327
 				1804800	343
 				1958400	445
+				2016000	470
 			>;
 			idle-cost-data = <
 				100 80 60 40
@@ -204,6 +205,7 @@
 				1708800	85
 				1804800	88
 				1958400	110
+				2016000	120
 			>;
 			idle-cost-data = <
 				4 3 2 1
@@ -663,5 +665,5 @@
 };
 
 &usb_otg {
-	qcom,hsusb-otg-phy-init-seq = <0x06 0x82 0xffffffff>;
+	qcom,hsusb-otg-phy-init-seq = <0x43 0x80 0x06 0x82 0xffffffff>;
 };
diff --git a/arch/arm64/boot/dts/qcom/sdm632-coresight.dtsi b/arch/arm64/boot/dts/qcom/sdm632-coresight.dtsi
index 62eeb65..2e19b67 100644
--- a/arch/arm64/boot/dts/qcom/sdm632-coresight.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm632-coresight.dtsi
@@ -104,6 +104,7 @@
 		reg-names = "cti-base";
 		coresight-name = "coresight-cti-cpu4";
 		cpu = <&CPU4>;
+		qcom,cti-save;
 
 		clocks = <&clock_gcc clk_qdss_clk>,
 			 <&clock_gcc clk_qdss_a_clk>;
@@ -118,7 +119,7 @@
 		reg-names = "cti-base";
 		coresight-name = "coresight-cti-cpu5";
 		cpu = <&CPU5>;
-
+		qcom,cti-save;
 		clocks = <&clock_gcc clk_qdss_clk>,
 			 <&clock_gcc clk_qdss_a_clk>;
 		clock-names = "apb_pclk";
@@ -132,6 +133,7 @@
 		reg-names = "cti-base";
 		coresight-name = "coresight-cti-cpu6";
 		cpu = <&CPU6>;
+		qcom,cti-save;
 
 		clocks = <&clock_gcc clk_qdss_clk>,
 			 <&clock_gcc clk_qdss_a_clk>;
@@ -146,6 +148,7 @@
 		reg-names = "cti-base";
 		coresight-name = "coresight-cti-cpu7";
 		cpu = <&CPU7>;
+		qcom,cti-save;
 
 		clocks = <&clock_gcc clk_qdss_clk>,
 			 <&clock_gcc clk_qdss_a_clk>;
diff --git a/arch/arm64/boot/dts/qcom/sdm670-usb.dtsi b/arch/arm64/boot/dts/qcom/sdm670-usb.dtsi
index 1e84e2c..10fcc14 100644
--- a/arch/arm64/boot/dts/qcom/sdm670-usb.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm670-usb.dtsi
@@ -83,4 +83,5 @@
 &usb_qmp_dp_phy {
 	vdd-supply = <&pm660l_l1>; /* 0.88v */
 	core-supply = <&pm660_l1>; /* 1.2v */
+	extcon = <&pm660_pdphy>;
 };
diff --git a/arch/arm64/boot/dts/qcom/sdw3100-apq8009w-alpha.dts b/arch/arm64/boot/dts/qcom/sdw3100-apq8009w-alpha.dts
index 913cdc1..63638fc 100644
--- a/arch/arm64/boot/dts/qcom/sdw3100-apq8009w-alpha.dts
+++ b/arch/arm64/boot/dts/qcom/sdw3100-apq8009w-alpha.dts
@@ -117,6 +117,13 @@
 			qcom,glinkpkt-ch-name = "RSB_CTRL";
 			qcom,glinkpkt-dev-name = "glink_pkt_bg_rsb_ctrl";
 		};
+
+		qcom,glinkpkt-bg-sso-ctrl {
+			qcom,glinkpkt-transport = "bgcom";
+			qcom,glinkpkt-edge = "bg";
+			qcom,glinkpkt-ch-name = "sso-ctrl";
+			qcom,glinkpkt-dev-name = "glink_pkt_bg_sso_ctrl";
+		};
 	};
 
 	spi@78B8000 {  /* BLSP1 QUP4 */
diff --git a/arch/arm64/boot/dts/qcom/sdw3100-apq8009w-wtp.dts b/arch/arm64/boot/dts/qcom/sdw3100-apq8009w-wtp.dts
index eecf8b7..1938875 100644
--- a/arch/arm64/boot/dts/qcom/sdw3100-apq8009w-wtp.dts
+++ b/arch/arm64/boot/dts/qcom/sdw3100-apq8009w-wtp.dts
@@ -135,6 +135,13 @@
 			qcom,glinkpkt-ch-name = "RSB_CTRL";
 			qcom,glinkpkt-dev-name = "glink_pkt_bg_rsb_ctrl";
 		};
+
+		qcom,glinkpkt-bg-sso-ctrl {
+			qcom,glinkpkt-transport = "bgcom";
+			qcom,glinkpkt-edge = "bg";
+			qcom,glinkpkt-ch-name = "sso-ctrl";
+			qcom,glinkpkt-dev-name = "glink_pkt_bg_sso_ctrl";
+		};
 	};
 
 	spi@78B8000 {  /* BLSP1 QUP4 */
diff --git a/arch/arm64/boot/dts/qcom/sdw3100-msm8909w-1gb-wtp.dts b/arch/arm64/boot/dts/qcom/sdw3100-msm8909w-1gb-wtp.dts
index a66387e..b702ad0 100644
--- a/arch/arm64/boot/dts/qcom/sdw3100-msm8909w-1gb-wtp.dts
+++ b/arch/arm64/boot/dts/qcom/sdw3100-msm8909w-1gb-wtp.dts
@@ -137,6 +137,13 @@
 			qcom,glinkpkt-ch-name = "RSB_CTRL";
 			qcom,glinkpkt-dev-name = "glink_pkt_bg_rsb_ctrl";
 		};
+
+		qcom,glinkpkt-bg-sso-ctrl {
+			qcom,glinkpkt-transport = "bgcom";
+			qcom,glinkpkt-edge = "bg";
+			qcom,glinkpkt-ch-name = "sso-ctrl";
+			qcom,glinkpkt-dev-name = "glink_pkt_bg_sso_ctrl";
+		};
 	};
 
 	spi@78B8000 {  /* BLSP1 QUP4 */
diff --git a/arch/arm64/boot/dts/qcom/sdw3100-msm8909w-wtp.dts b/arch/arm64/boot/dts/qcom/sdw3100-msm8909w-wtp.dts
index 761879f..d51e6da 100644
--- a/arch/arm64/boot/dts/qcom/sdw3100-msm8909w-wtp.dts
+++ b/arch/arm64/boot/dts/qcom/sdw3100-msm8909w-wtp.dts
@@ -136,6 +136,13 @@
 			qcom,glinkpkt-ch-name = "RSB_CTRL";
 			qcom,glinkpkt-dev-name = "glink_pkt_bg_rsb_ctrl";
 		};
+
+		qcom,glinkpkt-bg-sso-ctrl {
+			qcom,glinkpkt-transport = "bgcom";
+			qcom,glinkpkt-edge = "bg";
+			qcom,glinkpkt-ch-name = "sso-ctrl";
+			qcom,glinkpkt-dev-name = "glink_pkt_bg_sso_ctrl";
+		};
 	};
 
 	spi@78B8000 {  /* BLSP1 QUP4 */
diff --git a/arch/arm64/configs/msm8937-perf_defconfig b/arch/arm64/configs/msm8937-perf_defconfig
index 5348cb4..40064cb 100644
--- a/arch/arm64/configs/msm8937-perf_defconfig
+++ b/arch/arm64/configs/msm8937-perf_defconfig
@@ -57,6 +57,7 @@
 CONFIG_ARCH_QCOM=y
 CONFIG_ARCH_MSM8937=y
 CONFIG_ARCH_MSM8917=y
+CONFIG_ARCH_QM215=y
 CONFIG_ARCH_SDM429=y
 CONFIG_ARCH_SDM439=y
 # CONFIG_ARM64_ERRATUM_1024718 is not set
@@ -263,6 +264,7 @@
 CONFIG_BLK_DEV_DM=y
 CONFIG_DM_CRYPT=y
 CONFIG_DM_REQ_CRYPT=y
+CONFIG_DM_DEFAULT_KEY=y
 CONFIG_DM_UEVENT=y
 CONFIG_DM_VERITY=y
 CONFIG_DM_VERITY_FEC=y
diff --git a/arch/arm64/configs/msm8937_defconfig b/arch/arm64/configs/msm8937_defconfig
index 0ff0ec1..fda1429 100644
--- a/arch/arm64/configs/msm8937_defconfig
+++ b/arch/arm64/configs/msm8937_defconfig
@@ -58,6 +58,7 @@
 CONFIG_ARCH_QCOM=y
 CONFIG_ARCH_MSM8937=y
 CONFIG_ARCH_MSM8917=y
+CONFIG_ARCH_QM215=y
 CONFIG_ARCH_SDM429=y
 CONFIG_ARCH_SDM439=y
 # CONFIG_ARM64_ERRATUM_1024718 is not set
@@ -269,6 +270,7 @@
 CONFIG_BLK_DEV_DM=y
 CONFIG_DM_CRYPT=y
 CONFIG_DM_REQ_CRYPT=y
+CONFIG_DM_DEFAULT_KEY=y
 CONFIG_DM_UEVENT=y
 CONFIG_DM_VERITY=y
 CONFIG_DM_VERITY_FEC=y
diff --git a/arch/arm64/configs/msm8953-perf_defconfig b/arch/arm64/configs/msm8953-perf_defconfig
index a66ea31..3039177 100644
--- a/arch/arm64/configs/msm8953-perf_defconfig
+++ b/arch/arm64/configs/msm8953-perf_defconfig
@@ -265,6 +265,7 @@
 CONFIG_BLK_DEV_DM=y
 CONFIG_DM_CRYPT=y
 CONFIG_DM_REQ_CRYPT=y
+CONFIG_DM_DEFAULT_KEY=y
 CONFIG_DM_UEVENT=y
 CONFIG_DM_VERITY=y
 CONFIG_DM_VERITY_FEC=y
diff --git a/arch/arm64/configs/msm8953_defconfig b/arch/arm64/configs/msm8953_defconfig
index 34d16db..4620bec 100644
--- a/arch/arm64/configs/msm8953_defconfig
+++ b/arch/arm64/configs/msm8953_defconfig
@@ -271,6 +271,7 @@
 CONFIG_BLK_DEV_DM=y
 CONFIG_DM_CRYPT=y
 CONFIG_DM_REQ_CRYPT=y
+CONFIG_DM_DEFAULT_KEY=y
 CONFIG_DM_UEVENT=y
 CONFIG_DM_VERITY=y
 CONFIG_DM_VERITY_FEC=y
diff --git a/block/bio.c b/block/bio.c
index a4c8c99..a44b525 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -568,8 +568,11 @@
 static inline void bio_clone_crypt_key(struct bio *dst, const struct bio *src)
 {
 #ifdef CONFIG_PFK
-	dst->bi_crypt_key = src->bi_crypt_key;
 	dst->bi_iter.bi_dun = src->bi_iter.bi_dun;
+#ifdef CONFIG_DM_DEFAULT_KEY
+	dst->bi_crypt_key = src->bi_crypt_key;
+	dst->bi_crypt_skip = src->bi_crypt_skip;
+#endif
 	dst->bi_dio_inode = src->bi_dio_inode;
 #endif
 }
diff --git a/drivers/char/adsprpc.c b/drivers/char/adsprpc.c
index 7776b08..67677ea 100644
--- a/drivers/char/adsprpc.c
+++ b/drivers/char/adsprpc.c
@@ -3434,7 +3434,7 @@
 	if (err)
 		return err;
 	snprintf(strpid, PID_SIZE, "%d", current->pid);
-	buf_size = strlen(current->comm) + strlen(strpid) + 1;
+	buf_size = strlen(current->comm) + strlen("_") + strlen(strpid) + 1;
 	fl->debug_buf = kzalloc(buf_size, GFP_KERNEL);
 	snprintf(fl->debug_buf, UL_SIZE, "%.10s%s%d",
 	current->comm, "_", current->pid);
diff --git a/drivers/char/diag/diagchar_core.c b/drivers/char/diag/diagchar_core.c
index 131a050..c613667 100644
--- a/drivers/char/diag/diagchar_core.c
+++ b/drivers/char/diag/diagchar_core.c
@@ -3227,13 +3227,13 @@
 	mutex_lock(&apps_data_mutex);
 	mutex_lock(&driver->hdlc_disable_mutex);
 	hdlc_disabled = driver->p_hdlc_disabled[APPS_DATA];
+	mutex_unlock(&driver->hdlc_disable_mutex);
 	if (hdlc_disabled)
 		ret = diag_process_apps_data_non_hdlc(user_space_data, len,
 						      pkt_type);
 	else
 		ret = diag_process_apps_data_hdlc(user_space_data, len,
 						  pkt_type);
-	mutex_unlock(&driver->hdlc_disable_mutex);
 	mutex_unlock(&apps_data_mutex);
 
 	diagmem_free(driver, user_space_data, mempool);
diff --git a/drivers/char/diag/diagfwd_cntl.c b/drivers/char/diag/diagfwd_cntl.c
index a6d5ca8..7a7d0fc 100644
--- a/drivers/char/diag/diagfwd_cntl.c
+++ b/drivers/char/diag/diagfwd_cntl.c
@@ -619,7 +619,12 @@
 	}
 	if (range->ssid_last >= mask->ssid_last) {
 		temp_range = range->ssid_last - mask->ssid_first + 1;
-		mask->ssid_last = range->ssid_last;
+		if (temp_range > MAX_SSID_PER_RANGE) {
+			temp_range = MAX_SSID_PER_RANGE;
+			mask->ssid_last = mask->ssid_first + temp_range - 1;
+		} else
+			mask->ssid_last = range->ssid_last;
+		mask->ssid_last_tools = mask->ssid_last;
 		mask->range = temp_range;
 	}
 
diff --git a/drivers/clk/msm/clock-gcc-8952.c b/drivers/clk/msm/clock-gcc-8952.c
index 47619f5..3c989eb 100644
--- a/drivers/clk/msm/clock-gcc-8952.c
+++ b/drivers/clk/msm/clock-gcc-8952.c
@@ -840,6 +840,7 @@
 	F_SLEW( 270000000, FIXED_CLK_SRC, gpll6_aux,	4,	0,	0),
 	F_SLEW( 320000000, FIXED_CLK_SRC, gpll0,	2.5,	0,	0),
 	F_SLEW( 400000000, FIXED_CLK_SRC, gpll0,	2,	0,	0),
+	F_SLEW( 465000000, 930000000,	  gpll3,	1,	0,	0),
 	F_SLEW( 484800000, 969600000,	  gpll3,	1,	0,	0),
 	F_SLEW( 523200000, 1046400000,	  gpll3,	1,	0,	0),
 	F_SLEW( 550000000, 1100000000,	  gpll3,	1,	0,	0),
@@ -860,6 +861,7 @@
 	F_SLEW( 270000000, FIXED_CLK_SRC, gpll6_aux,	4,	0,	0),
 	F_SLEW( 320000000, FIXED_CLK_SRC, gpll0,	2.5,	0,	0),
 	F_SLEW( 400000000, FIXED_CLK_SRC, gpll0,	2,	0,	0),
+	F_SLEW( 465000000, 930000000,	  gpll3,	1,	0,	0),
 	F_SLEW( 484800000, 969600000,	  gpll3,	1,	0,	0),
 	F_SLEW( 523200000, 1046400000,	  gpll3,	1,	0,	0),
 	F_SLEW( 550000000, 1100000000,	  gpll3,	1,	0,	0),
diff --git a/drivers/cpuidle/lpm-levels.c b/drivers/cpuidle/lpm-levels.c
index 3c75997..ae72206 100644
--- a/drivers/cpuidle/lpm-levels.c
+++ b/drivers/cpuidle/lpm-levels.c
@@ -1776,7 +1776,7 @@
 	md_entry.virt_addr = (uintptr_t)lpm_debug;
 	md_entry.phys_addr = lpm_debug_phys;
 	md_entry.size = size;
-	if (msm_minidump_add_region(&md_entry))
+	if (msm_minidump_add_region(&md_entry) < 0)
 		pr_info("Failed to add lpm_debug in Minidump\n");
 
 	return 0;
diff --git a/drivers/devfreq/governor_bw_hwmon.c b/drivers/devfreq/governor_bw_hwmon.c
index cb04014..d0be577 100644
--- a/drivers/devfreq/governor_bw_hwmon.c
+++ b/drivers/devfreq/governor_bw_hwmon.c
@@ -74,6 +74,7 @@
 	struct bw_hwmon *hw;
 	struct devfreq_governor *gov;
 	struct attribute_group *attr_grp;
+	struct mutex mon_lock;
 };
 
 #define UP_WAKE 1
@@ -511,8 +512,11 @@
 	if (!node)
 		return -ENODEV;
 
-	if (!node->mon_started)
+	mutex_lock(&node->mon_lock);
+	if (!node->mon_started) {
+		mutex_unlock(&node->mon_lock);
 		return -EBUSY;
+	}
 
 	dev_dbg(df->dev.parent, "Got update request\n");
 	devfreq_monitor_stop(df);
@@ -526,6 +530,7 @@
 
 	devfreq_monitor_start(df);
 
+	mutex_unlock(&node->mon_lock);
 	return 0;
 }
 
@@ -572,7 +577,9 @@
 	struct hwmon_node *node = df->data;
 	struct bw_hwmon *hw = node->hw;
 
+	mutex_lock(&node->mon_lock);
 	node->mon_started = false;
+	mutex_unlock(&node->mon_lock);
 
 	if (init) {
 		devfreq_monitor_stop(df);
@@ -932,6 +939,8 @@
 	node->mbps_zones[0] = 0;
 	node->hw = hwmon;
 
+	mutex_init(&node->mon_lock);
+
 	mutex_lock(&list_lock);
 	list_add_tail(&node->list, &hwmon_list);
 	mutex_unlock(&list_lock);
diff --git a/drivers/extcon/extcon-usb-gpio.c b/drivers/extcon/extcon-usb-gpio.c
index 2b108fa..a7a29fb 100644
--- a/drivers/extcon/extcon-usb-gpio.c
+++ b/drivers/extcon/extcon-usb-gpio.c
@@ -27,6 +27,7 @@
 #include <linux/slab.h>
 #include <linux/workqueue.h>
 #include <linux/acpi.h>
+#include <linux/delay.h>
 
 #define USB_GPIO_DEBOUNCE_MS	20	/* ms */
 
@@ -36,6 +37,7 @@
 
 	struct gpio_desc *id_gpiod;
 	struct gpio_desc *vbus_gpiod;
+	struct gpio_desc *trig_gpiod;
 	int id_irq;
 	int vbus_irq;
 
@@ -87,6 +89,12 @@
 
 	if (!id) {
 		extcon_set_state_sync(info->edev, EXTCON_USB_HOST, true);
+		if (info->trig_gpiod) {
+			gpiod_set_value(info->trig_gpiod, 1);
+			msleep(20);
+			gpiod_set_value(info->trig_gpiod, 0);
+			msleep(20);
+		}
 	} else {
 		if (vbus)
 			extcon_set_state_sync(info->edev, EXTCON_USB, true);
@@ -109,6 +117,7 @@
 	struct device_node *np = dev->of_node;
 	struct usb_extcon_info *info;
 	int ret;
+	const char *name = NULL;
 
 	if (!np && !ACPI_HANDLE(dev))
 		return -EINVAL;
@@ -121,6 +130,8 @@
 	info->id_gpiod = devm_gpiod_get_optional(&pdev->dev, "id", GPIOD_IN);
 	info->vbus_gpiod = devm_gpiod_get_optional(&pdev->dev, "vbus",
 						   GPIOD_IN);
+	info->trig_gpiod = devm_gpiod_get_optional(&pdev->dev, "trig",
+						   GPIOD_OUT_LOW);
 
 	if (!info->id_gpiod && !info->vbus_gpiod) {
 		dev_err(dev, "failed to get gpios\n");
@@ -133,6 +144,9 @@
 	if (IS_ERR(info->vbus_gpiod))
 		return PTR_ERR(info->vbus_gpiod);
 
+	if (IS_ERR(info->trig_gpiod))
+		return PTR_ERR(info->trig_gpiod);
+
 	info->edev = devm_extcon_dev_allocate(dev, usb_extcon_cable);
 	if (IS_ERR(info->edev)) {
 		dev_err(dev, "failed to allocate extcon device\n");
@@ -145,6 +159,25 @@
 		return ret;
 	}
 
+	if (info->trig_gpiod) {
+		ret = of_property_read_string_index(np, "gpio-names", 0, &name);
+		if (ret) {
+			dev_err(dev, "Could not get gpio name\n");
+			return ret;
+		}
+
+		ret = gpiod_export(info->trig_gpiod, 0);
+		if (ret) {
+			dev_err(dev, "failed to export gpio\n");
+			return ret;
+		}
+
+		ret = gpiod_export_link(dev, name, info->trig_gpiod);
+		if (ret) {
+		dev_err(dev, "failed to export gpio link\n");
+		return ret;
+		}
+	}
 	if (info->id_gpiod)
 		ret = gpiod_set_debounce(info->id_gpiod,
 					 USB_GPIO_DEBOUNCE_MS * 1000);
diff --git a/drivers/gpu/drm/msm/dsi-staging/dsi_panel.c b/drivers/gpu/drm/msm/dsi-staging/dsi_panel.c
index 2a70155..61c3fcb 100644
--- a/drivers/gpu/drm/msm/dsi-staging/dsi_panel.c
+++ b/drivers/gpu/drm/msm/dsi-staging/dsi_panel.c
@@ -1958,6 +1958,7 @@
 {
 	int rc = 0;
 	const char *bl_type;
+	const char *data;
 	u32 val = 0;
 
 	bl_type = of_get_property(of_node,
@@ -1977,6 +1978,17 @@
 		panel->bl_config.type = DSI_BACKLIGHT_UNKNOWN;
 	}
 
+	data = of_get_property(of_node, "qcom,bl-update-flag", NULL);
+	if (!data) {
+		panel->bl_config.bl_update = BL_UPDATE_NONE;
+	} else if (!strcmp(data, "delay_until_first_frame")) {
+		panel->bl_config.bl_update = BL_UPDATE_DELAY_UNTIL_FIRST_FRAME;
+	} else {
+		pr_debug("[%s] No valid bl-update-flag: %s\n",
+						panel->name, data);
+		panel->bl_config.bl_update = BL_UPDATE_NONE;
+	}
+
 	panel->bl_config.bl_scale = MAX_BL_SCALE_LEVEL;
 	panel->bl_config.bl_scale_ad = MAX_AD_BL_SCALE_LEVEL;
 
diff --git a/drivers/gpu/drm/msm/dsi-staging/dsi_panel.h b/drivers/gpu/drm/msm/dsi-staging/dsi_panel.h
index f6a9c60..fef7d3f 100644
--- a/drivers/gpu/drm/msm/dsi-staging/dsi_panel.h
+++ b/drivers/gpu/drm/msm/dsi-staging/dsi_panel.h
@@ -51,6 +51,11 @@
 	DSI_BACKLIGHT_MAX,
 };
 
+enum bl_update_flag {
+	BL_UPDATE_DELAY_UNTIL_FIRST_FRAME,
+	BL_UPDATE_NONE,
+};
+
 enum {
 	MODE_GPIO_NOT_VALID = 0,
 	MODE_SEL_DUAL_PORT,
@@ -85,6 +90,7 @@
 
 struct dsi_backlight_config {
 	enum dsi_backlight_type type;
+	enum bl_update_flag bl_update;
 
 	u32 bl_min_level;
 	u32 bl_max_level;
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 0f565d3..c564a09 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -201,62 +201,46 @@
 	return val;
 }
 
-struct vblank_event {
-	struct list_head node;
+struct vblank_work {
+	struct kthread_work work;
 	int crtc_id;
 	bool enable;
+	struct msm_drm_private *priv;
 };
 
 static void vblank_ctrl_worker(struct kthread_work *work)
 {
-	struct msm_vblank_ctrl *vbl_ctrl = container_of(work,
-						struct msm_vblank_ctrl, work);
-	struct msm_drm_private *priv = container_of(vbl_ctrl,
-					struct msm_drm_private, vblank_ctrl);
+	struct vblank_work *cur_work = container_of(work,
+					struct vblank_work, work);
+	struct msm_drm_private *priv = cur_work->priv;
 	struct msm_kms *kms = priv->kms;
-	struct vblank_event *vbl_ev, *tmp;
-	unsigned long flags;
-	LIST_HEAD(tmp_head);
 
-	spin_lock_irqsave(&vbl_ctrl->lock, flags);
-	list_for_each_entry_safe(vbl_ev, tmp, &vbl_ctrl->event_list, node) {
-		list_del(&vbl_ev->node);
-		list_add_tail(&vbl_ev->node, &tmp_head);
-	}
-	spin_unlock_irqrestore(&vbl_ctrl->lock, flags);
+	if (cur_work->enable)
+		kms->funcs->enable_vblank(kms, priv->crtcs[cur_work->crtc_id]);
+	else
+		kms->funcs->disable_vblank(kms, priv->crtcs[cur_work->crtc_id]);
 
-	list_for_each_entry_safe(vbl_ev, tmp, &tmp_head, node) {
-		if (vbl_ev->enable)
-			kms->funcs->enable_vblank(kms,
-						priv->crtcs[vbl_ev->crtc_id]);
-		else
-			kms->funcs->disable_vblank(kms,
-						priv->crtcs[vbl_ev->crtc_id]);
-
-		kfree(vbl_ev);
-	}
+	kfree(cur_work);
 }
 
 static int vblank_ctrl_queue_work(struct msm_drm_private *priv,
 					int crtc_id, bool enable)
 {
-	struct msm_vblank_ctrl *vbl_ctrl = &priv->vblank_ctrl;
-	struct vblank_event *vbl_ev;
-	unsigned long flags;
+	struct vblank_work *cur_work;
 
-	vbl_ev = kzalloc(sizeof(*vbl_ev), GFP_ATOMIC);
-	if (!vbl_ev)
+	if (!priv || crtc_id >= priv->num_crtcs)
+		return -EINVAL;
+
+	cur_work = kzalloc(sizeof(*cur_work), GFP_ATOMIC);
+	if (!cur_work)
 		return -ENOMEM;
 
-	vbl_ev->crtc_id = crtc_id;
-	vbl_ev->enable = enable;
+	kthread_init_work(&cur_work->work, vblank_ctrl_worker);
+	cur_work->crtc_id = crtc_id;
+	cur_work->enable = enable;
+	cur_work->priv = priv;
 
-	spin_lock_irqsave(&vbl_ctrl->lock, flags);
-	list_add_tail(&vbl_ev->node, &vbl_ctrl->event_list);
-	spin_unlock_irqrestore(&vbl_ctrl->lock, flags);
-
-	kthread_queue_work(&priv->disp_thread[crtc_id].worker,
-			&vbl_ctrl->work);
+	kthread_queue_work(&priv->disp_thread[crtc_id].worker, &cur_work->work);
 
 	return 0;
 }
@@ -268,20 +252,8 @@
 	struct msm_drm_private *priv = ddev->dev_private;
 	struct msm_kms *kms = priv->kms;
 	struct msm_gpu *gpu = priv->gpu;
-	struct msm_vblank_ctrl *vbl_ctrl = &priv->vblank_ctrl;
-	struct vblank_event *vbl_ev, *tmp;
 	int i;
 
-	/* We must cancel and cleanup any pending vblank enable/disable
-	 * work before drm_irq_uninstall() to avoid work re-enabling an
-	 * irq after uninstall has disabled it.
-	 */
-	kthread_flush_work(&vbl_ctrl->work);
-	list_for_each_entry_safe(vbl_ev, tmp, &vbl_ctrl->event_list, node) {
-		list_del(&vbl_ev->node);
-		kfree(vbl_ev);
-	}
-
 	/* clean up display commit/event worker threads */
 	for (i = 0; i < priv->num_crtcs; i++) {
 		if (priv->disp_thread[i].thread) {
@@ -522,9 +494,6 @@
 
 	INIT_LIST_HEAD(&priv->client_event_list);
 	INIT_LIST_HEAD(&priv->inactive_list);
-	INIT_LIST_HEAD(&priv->vblank_ctrl.event_list);
-	kthread_init_work(&priv->vblank_ctrl.work, vblank_ctrl_worker);
-	spin_lock_init(&priv->vblank_ctrl.lock);
 
 	ret = sde_power_resource_init(pdev, &priv->phandle);
 	if (ret) {
diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
index 978aba2..83e100c 100644
--- a/drivers/gpu/drm/msm/msm_drv.h
+++ b/drivers/gpu/drm/msm/msm_drv.h
@@ -198,12 +198,6 @@
 	CONNECTOR_PROP_COUNT
 };
 
-struct msm_vblank_ctrl {
-	struct kthread_work work;
-	struct list_head event_list;
-	spinlock_t lock;
-};
-
 #define MAX_H_TILES_PER_DISPLAY 2
 
 /**
@@ -615,8 +609,6 @@
 	struct notifier_block vmap_notifier;
 	struct shrinker shrinker;
 
-	struct msm_vblank_ctrl vblank_ctrl;
-
 	/* task holding struct_mutex.. currently only used in submit path
 	 * to detect and reject faults from copy_from_user() for submit
 	 * ioctl.
diff --git a/drivers/gpu/drm/msm/sde/sde_color_processing.c b/drivers/gpu/drm/msm/sde/sde_color_processing.c
index 8680449b..378847d 100644
--- a/drivers/gpu/drm/msm/sde/sde_color_processing.c
+++ b/drivers/gpu/drm/msm/sde/sde_color_processing.c
@@ -1862,24 +1862,29 @@
 
 	node = container_of(ad_irq, struct sde_crtc_irq_info, irq);
 
+	/* deregister AD irq */
 	if (!en) {
 		spin_lock_irqsave(&node->state_lock, flags);
 		if (node->state == IRQ_ENABLED) {
+			node->state = IRQ_DISABLING;
+			spin_unlock_irqrestore(&node->state_lock, flags);
 			ret = sde_core_irq_disable(kms, &irq_idx, 1);
-			if (ret)
+			spin_lock_irqsave(&node->state_lock, flags);
+			if (ret) {
 				DRM_ERROR("disable irq %d error %d\n",
 					irq_idx, ret);
-			else
-				node->state = IRQ_NOINIT;
-		} else {
-			node->state = IRQ_NOINIT;
+				node->state = IRQ_ENABLED;
+			} else {
+				node->state = IRQ_DISABLED;
+			}
 		}
 		spin_unlock_irqrestore(&node->state_lock, flags);
+
 		sde_core_irq_unregister_callback(kms, irq_idx, ad_irq);
-		ret = 0;
 		goto exit;
 	}
 
+	/* register AD irq */
 	ad_irq->arg = crtc;
 	ad_irq->func = sde_cp_ad_interrupt_cb;
 	ret = sde_core_irq_register_callback(kms, irq_idx, ad_irq);
@@ -1889,11 +1894,15 @@
 	}
 
 	spin_lock_irqsave(&node->state_lock, flags);
-	if (node->state == IRQ_DISABLED || node->state == IRQ_NOINIT) {
+	if (node->state == IRQ_DISABLED) {
+		node->state = IRQ_ENABLING;
+		spin_unlock_irqrestore(&node->state_lock, flags);
 		ret = sde_core_irq_enable(kms, &irq_idx, 1);
+		spin_lock_irqsave(&node->state_lock, flags);
 		if (ret) {
 			DRM_ERROR("enable irq %d error %d\n", irq_idx, ret);
 			sde_core_irq_unregister_callback(kms, irq_idx, ad_irq);
+			node->state = IRQ_DISABLED;
 		} else {
 			node->state = IRQ_ENABLED;
 		}
@@ -2138,15 +2147,10 @@
 					irq_idx, ret);
 				node->state = IRQ_ENABLED;
 			} else {
-				node->state = IRQ_NOINIT;
+				node->state = IRQ_DISABLED;
 			}
-			spin_unlock_irqrestore(&node->state_lock, flags);
-		} else if (node->state == IRQ_DISABLED) {
-			node->state = IRQ_NOINIT;
-			spin_unlock_irqrestore(&node->state_lock, flags);
-		} else {
-			spin_unlock_irqrestore(&node->state_lock, flags);
 		}
+		spin_unlock_irqrestore(&node->state_lock, flags);
 
 		sde_core_irq_unregister_callback(kms, irq_idx, hist_irq);
 		goto exit;
@@ -2162,12 +2166,16 @@
 	}
 
 	spin_lock_irqsave(&node->state_lock, flags);
-	if (node->state == IRQ_DISABLED || node->state == IRQ_NOINIT) {
+	if (node->state == IRQ_DISABLED) {
+		node->state = IRQ_ENABLING;
+		spin_unlock_irqrestore(&node->state_lock, flags);
 		ret = sde_core_irq_enable(kms, &irq_idx, 1);
+		spin_lock_irqsave(&node->state_lock, flags);
 		if (ret) {
 			DRM_ERROR("enable irq %d error %d\n", irq_idx, ret);
 			sde_core_irq_unregister_callback(kms,
 				irq_idx, hist_irq);
+			node->state = IRQ_DISABLED;
 		} else {
 			node->state = IRQ_ENABLED;
 		}
diff --git a/drivers/gpu/drm/msm/sde/sde_connector.c b/drivers/gpu/drm/msm/sde/sde_connector.c
index 9d7d1e0..04f16ca 100644
--- a/drivers/gpu/drm/msm/sde/sde_connector.c
+++ b/drivers/gpu/drm/msm/sde/sde_connector.c
@@ -89,12 +89,19 @@
 	if (!bl_lvl && brightness)
 		bl_lvl = 1;
 
+	if (display->panel->bl_config.bl_update ==
+		BL_UPDATE_DELAY_UNTIL_FIRST_FRAME && !c_conn->allow_bl_update) {
+		c_conn->unset_bl_level = bl_lvl;
+		return 0;
+	}
+
 	if (c_conn->ops.set_backlight) {
 		event.type = DRM_EVENT_SYS_BACKLIGHT;
 		event.length = sizeof(u32);
 		msm_mode_object_event_notify(&c_conn->base.base,
 				c_conn->base.dev, &event, (u8 *)&brightness);
 		rc = c_conn->ops.set_backlight(c_conn->display, bl_lvl);
+		c_conn->unset_bl_level = 0;
 	}
 
 	return rc;
@@ -519,6 +526,15 @@
 
 	bl_config = &dsi_display->panel->bl_config;
 
+	if (dsi_display->panel->bl_config.bl_update ==
+		BL_UPDATE_DELAY_UNTIL_FIRST_FRAME && !c_conn->allow_bl_update) {
+		c_conn->unset_bl_level = bl_config->bl_level;
+		return 0;
+	}
+
+	if (c_conn->unset_bl_level)
+		bl_config->bl_level = c_conn->unset_bl_level;
+
 	if (c_conn->bl_scale > MAX_BL_SCALE_LEVEL)
 		bl_config->bl_scale = MAX_BL_SCALE_LEVEL;
 	else
@@ -533,6 +549,7 @@
 		bl_config->bl_scale, bl_config->bl_scale_ad,
 		bl_config->bl_level);
 	rc = c_conn->ops.set_backlight(dsi_display, bl_config->bl_level);
+	c_conn->unset_bl_level = 0;
 
 	return rc;
 }
@@ -572,8 +589,11 @@
 		}
 	}
 
-	/* Special handling for postproc properties */
-	if (c_conn->bl_scale_dirty) {
+	/*
+	 * Special handling for postproc properties and
+	 * for updating backlight if any unset backlight level is present
+	 */
+	if (c_conn->bl_scale_dirty || c_conn->unset_bl_level) {
 		_sde_connector_update_bl_scale(c_conn);
 		c_conn->bl_scale_dirty = false;
 	}
@@ -639,29 +659,44 @@
 	sde_connector_schedule_status_work(connector, false);
 
 	c_conn = to_sde_connector(connector);
-	if (c_conn->panel_dead) {
+	if (c_conn->bl_device) {
 		c_conn->bl_device->props.power = FB_BLANK_POWERDOWN;
 		c_conn->bl_device->props.state |= BL_CORE_FBBLANK;
 		backlight_update_status(c_conn->bl_device);
 	}
+
+	c_conn->allow_bl_update = false;
 }
 
 void sde_connector_helper_bridge_enable(struct drm_connector *connector)
 {
 	struct sde_connector *c_conn = NULL;
+	struct dsi_display *display;
 
 	if (!connector)
 		return;
 
 	c_conn = to_sde_connector(connector);
+	display = (struct dsi_display *) c_conn->display;
 
-	/* Special handling for ESD recovery case */
-	if (c_conn->panel_dead) {
+	/*
+	 * Special handling for some panels which need atleast
+	 * one frame to be transferred to GRAM before enabling backlight.
+	 * So delay backlight update to these panels until the
+	 * first frame commit is received from the HW.
+	 */
+	if (display->panel->bl_config.bl_update ==
+				BL_UPDATE_DELAY_UNTIL_FIRST_FRAME)
+		sde_encoder_wait_for_event(c_conn->encoder,
+				MSM_ENC_TX_COMPLETE);
+	c_conn->allow_bl_update = true;
+
+	if (c_conn->bl_device) {
 		c_conn->bl_device->props.power = FB_BLANK_UNBLANK;
 		c_conn->bl_device->props.state &= ~BL_CORE_FBBLANK;
 		backlight_update_status(c_conn->bl_device);
-		c_conn->panel_dead = false;
 	}
+	c_conn->panel_dead = false;
 }
 
 int sde_connector_clk_ctrl(struct drm_connector *connector, bool enable)
diff --git a/drivers/gpu/drm/msm/sde/sde_connector.h b/drivers/gpu/drm/msm/sde/sde_connector.h
index 51dc92d..0ae6a91 100644
--- a/drivers/gpu/drm/msm/sde/sde_connector.h
+++ b/drivers/gpu/drm/msm/sde/sde_connector.h
@@ -329,7 +329,9 @@
  * @bl_scale_dirty: Flag to indicate PP BL scale value(s) is changed
  * @bl_scale: BL scale value for ABA feature
  * @bl_scale_ad: BL scale value for AD feature
- * last_cmd_tx_sts: status of the last command transfer
+ * @unset_bl_level: BL level that needs to be set later
+ * @allow_bl_update: Flag to indicate if BL update is allowed currently or not
+ * @last_cmd_tx_sts: status of the last command transfer
  */
 struct sde_connector {
 	struct drm_connector base;
@@ -373,6 +375,8 @@
 	bool bl_scale_dirty;
 	u32 bl_scale;
 	u32 bl_scale_ad;
+	u32 unset_bl_level;
+	bool allow_bl_update;
 
 	bool last_cmd_tx_sts;
 };
diff --git a/drivers/gpu/drm/msm/sde/sde_crtc.c b/drivers/gpu/drm/msm/sde/sde_crtc.c
index cb4e82d..73829da 100644
--- a/drivers/gpu/drm/msm/sde/sde_crtc.c
+++ b/drivers/gpu/drm/msm/sde/sde_crtc.c
@@ -6215,7 +6215,7 @@
 			INIT_LIST_HEAD(&node->list);
 			node->func = custom_events[i].func;
 			node->event = event;
-			node->state = IRQ_NOINIT;
+			node->state = IRQ_DISABLED;
 			spin_lock_init(&node->state_lock);
 			break;
 		}
diff --git a/drivers/gpu/drm/msm/sde/sde_crtc.h b/drivers/gpu/drm/msm/sde/sde_crtc.h
index 709a51f..4700a6c 100644
--- a/drivers/gpu/drm/msm/sde/sde_crtc.h
+++ b/drivers/gpu/drm/msm/sde/sde_crtc.h
@@ -430,7 +430,7 @@
 };
 
 enum sde_crtc_irq_state {
-	IRQ_NOINIT,
+	IRQ_ENABLING,
 	IRQ_ENABLED,
 	IRQ_DISABLING,
 	IRQ_DISABLED,
diff --git a/drivers/gpu/drm/msm/sde/sde_encoder.c b/drivers/gpu/drm/msm/sde/sde_encoder.c
index a1986db..0f5e127 100644
--- a/drivers/gpu/drm/msm/sde/sde_encoder.c
+++ b/drivers/gpu/drm/msm/sde/sde_encoder.c
@@ -1454,7 +1454,7 @@
 	struct msm_mode_info mode_info;
 	int i, rc = 0;
 
-	if (!sde_enc || !disp_info) {
+	if (!sde_enc || !sde_enc->cur_master || !disp_info) {
 		SDE_ERROR("invalid param sde_enc:%d or disp_info:%d\n",
 					sde_enc != NULL, disp_info != NULL);
 		return;
diff --git a/drivers/gpu/msm/adreno.c b/drivers/gpu/msm/adreno.c
index bf62087..f6927e9 100644
--- a/drivers/gpu/msm/adreno.c
+++ b/drivers/gpu/msm/adreno.c
@@ -1851,7 +1851,7 @@
 
 	status = kgsl_mmu_start(device);
 	if (status)
-		goto error_pwr_off;
+		goto error_boot_oob_clear;
 
 	_set_secvid(device);
 
@@ -2072,6 +2072,12 @@
 error_mmu_off:
 	kgsl_mmu_stop(&device->mmu);
 
+error_boot_oob_clear:
+	if (gpudev->oob_clear &&
+			ADRENO_QUIRK(adreno_dev, ADRENO_QUIRK_HFI_USE_REG))
+		gpudev->oob_clear(adreno_dev,
+				OOB_BOOT_SLUMBER_CLEAR_MASK);
+
 error_pwr_off:
 	/* set the state back to original state */
 	kgsl_pwrctrl_change_state(device, state);
diff --git a/drivers/gpu/msm/adreno_a3xx.c b/drivers/gpu/msm/adreno_a3xx.c
index 4f98912..e1f32e8 100644
--- a/drivers/gpu/msm/adreno_a3xx.c
+++ b/drivers/gpu/msm/adreno_a3xx.c
@@ -156,6 +156,12 @@
 	unsigned int speed_bin[3];
 	struct kgsl_device *device = &adreno_dev->dev;
 
+	if (of_get_property(device->pdev->dev.of_node,
+		"qcom,gpu-speed-bin-vectors", NULL)) {
+		adreno_efuse_speed_bin_array(adreno_dev);
+		return;
+	}
+
 	if (of_property_read_u32_array(device->pdev->dev.of_node,
 		"qcom,gpu-speed-bin", speed_bin, 3))
 		return;
diff --git a/drivers/gpu/msm/adreno_dispatch.c b/drivers/gpu/msm/adreno_dispatch.c
index a634d98..e7e0aae 100644
--- a/drivers/gpu/msm/adreno_dispatch.c
+++ b/drivers/gpu/msm/adreno_dispatch.c
@@ -1716,8 +1716,9 @@
 			ib2base, ib2sz, drawctxt->rb->id);
 
 		pr_fault(device, drawobj,
-			"gpu fault ctx %d ts %d status %8.8X rb %4.4x/%4.4x ib1 %16.16llX/%4.4x ib2 %16.16llX/%4.4x\n",
-			drawobj->context->id, drawobj->timestamp, status,
+			"gpu fault ctx %d ctx_type %s ts %d status %8.8X rb %4.4x/%4.4x ib1 %16.16llX/%4.4x ib2 %16.16llX/%4.4x\n",
+			drawobj->context->id, get_api_type_str(drawctxt->type),
+			drawobj->timestamp, status,
 			rptr, wptr, ib1base, ib1sz, ib2base, ib2sz);
 
 		if (rb != NULL)
diff --git a/drivers/gpu/msm/adreno_drawctxt.h b/drivers/gpu/msm/adreno_drawctxt.h
index eef506f..466d1e2 100644
--- a/drivers/gpu/msm/adreno_drawctxt.h
+++ b/drivers/gpu/msm/adreno_drawctxt.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2002,2007-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2002,2007-2018, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -139,4 +139,16 @@
 void adreno_drawctxt_dump(struct kgsl_device *device,
 		struct kgsl_context *context);
 
+static struct adreno_context_type ctxt_type_table[] = {KGSL_CONTEXT_TYPES};
+
+static inline const char *get_api_type_str(unsigned int type)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(ctxt_type_table) - 1; i++) {
+		if (ctxt_type_table[i].type == type)
+			return ctxt_type_table[i].str;
+	}
+	return "UNKNOWN";
+}
 #endif  /* __ADRENO_DRAWCTXT_H */
diff --git a/drivers/gpu/msm/adreno_profile.c b/drivers/gpu/msm/adreno_profile.c
index 2985f24..3b85129 100644
--- a/drivers/gpu/msm/adreno_profile.c
+++ b/drivers/gpu/msm/adreno_profile.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -77,19 +77,6 @@
 #define SIZE_PIPE_ENTRY(cnt) (50 + (cnt) * 62)
 #define SIZE_LOG_ENTRY(cnt) (6 + (cnt) * 5)
 
-static struct adreno_context_type ctxt_type_table[] = {KGSL_CONTEXT_TYPES};
-
-static const char *get_api_type_str(unsigned int type)
-{
-	int i;
-
-	for (i = 0; i < ARRAY_SIZE(ctxt_type_table) - 1; i++) {
-		if (ctxt_type_table[i].type == type)
-			return ctxt_type_table[i].str;
-	}
-	return "UNKNOWN";
-}
-
 static inline uint _ib_start(struct adreno_device *adreno_dev,
 			 unsigned int *cmds)
 {
diff --git a/drivers/gpu/msm/kgsl_device.h b/drivers/gpu/msm/kgsl_device.h
index 6f80011..6ae38a3 100644
--- a/drivers/gpu/msm/kgsl_device.h
+++ b/drivers/gpu/msm/kgsl_device.h
@@ -97,7 +97,8 @@
 	{ KGSL_CONTEXT_TYPE_GL, "GL" }, \
 	{ KGSL_CONTEXT_TYPE_CL, "CL" }, \
 	{ KGSL_CONTEXT_TYPE_C2D, "C2D" }, \
-	{ KGSL_CONTEXT_TYPE_RS, "RS" }
+	{ KGSL_CONTEXT_TYPE_RS, "RS" }, \
+	{ KGSL_CONTEXT_TYPE_VK, "VK" }
 
 #define KGSL_CONTEXT_ID(_context) \
 	((_context != NULL) ? (_context)->id : KGSL_MEMSTORE_GLOBAL)
diff --git a/drivers/gpu/msm/kgsl_iommu.c b/drivers/gpu/msm/kgsl_iommu.c
index 3539cda..4cf6250 100644
--- a/drivers/gpu/msm/kgsl_iommu.c
+++ b/drivers/gpu/msm/kgsl_iommu.c
@@ -836,11 +836,21 @@
 		no_page_fault_log = kgsl_mmu_log_fault_addr(mmu, ptbase, addr);
 
 	if (!no_page_fault_log && __ratelimit(&_rs)) {
+		const char *api_str;
+
+		if (context != NULL) {
+			struct adreno_context *drawctxt =
+					ADRENO_CONTEXT(context);
+
+			api_str = get_api_type_str(drawctxt->type);
+		} else
+			api_str = "UNKNOWN";
+
 		KGSL_MEM_CRIT(ctx->kgsldev,
 			"GPU PAGE FAULT: addr = %lX pid= %d\n", addr, ptname);
 		KGSL_MEM_CRIT(ctx->kgsldev,
-			"context=%s TTBR0=0x%llx CIDR=0x%x (%s %s fault)\n",
-			ctx->name, ptbase, contextidr,
+			"context=%s ctx_type=%s TTBR0=0x%llx CIDR=0x%x (%s %s fault)\n",
+			ctx->name, api_str, ptbase, contextidr,
 			write ? "write" : "read", fault_type);
 
 		if (gpudev->iommu_fault_block) {
diff --git a/drivers/gpu/msm/kgsl_pwrctrl.c b/drivers/gpu/msm/kgsl_pwrctrl.c
index 2a149ac..b2679b3 100644
--- a/drivers/gpu/msm/kgsl_pwrctrl.c
+++ b/drivers/gpu/msm/kgsl_pwrctrl.c
@@ -2760,6 +2760,12 @@
 		status = gmu_start(device);
 		break;
 	case KGSL_STATE_INIT:
+		/* if GMU already in FAULT */
+		if (kgsl_gmu_isenabled(device) &&
+			test_bit(GMU_FAULT, &gmu->flags)) {
+			status = -EINVAL;
+			break;
+		}
 		status = kgsl_pwrctrl_enable(device);
 		break;
 	/* The following 3 cases shouldn't occur, but don't panic. */
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index 5bcb6d2..95c3235 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -78,7 +78,7 @@
 
 obj-$(CONFIG_HID_PLANTRONICS)	+= hid-plantronics.o
 obj-$(CONFIG_HID_PRIMAX)	+= hid-primax.o
-obj-$(CONFIG_HID_QVR)		+= hid-qvr.o
+obj-$(CONFIG_HID_QVR)		+= hid-qvr.o hid-trace.o
 obj-$(CONFIG_HID_ROCCAT)	+= hid-roccat.o hid-roccat-common.o \
 	hid-roccat-arvo.o hid-roccat-isku.o hid-roccat-kone.o \
 	hid-roccat-koneplus.o hid-roccat-konepure.o hid-roccat-kovaplus.o \
diff --git a/drivers/hid/hid-qvr.c b/drivers/hid/hid-qvr.c
index 019dbaf..766b15d 100644
--- a/drivers/hid/hid-qvr.c
+++ b/drivers/hid/hid-qvr.c
@@ -36,6 +36,7 @@
 #include "../soc/qcom/smp2p_private.h"
 #include "hid-ids.h"
 #include "hid-qvr.h"
+#include "hid-trace.h"
 
 static struct ion_handle *handle;
 static struct ion_client *client;
@@ -142,6 +143,9 @@
 	data->my = imuData.my0;
 	data->mz = -imuData.mz0;
 
+	trace_qvr_recv_sensor("gyro", data->gts, data->gx, data->gy, data->gz);
+	trace_qvr_recv_sensor("accel", data->ats, data->ax, data->ay, data->az);
+
 	pr_debug("%s: gts= %llu, gx= %d, gy=%d, gz=%d", __func__,
 		data->gts, data->gx, data->gy, data->gz);
 	pr_debug("%s: ats= %llu, ax= %d, ay=%d, az=%d", __func__,
diff --git a/drivers/hid/hid-trace.c b/drivers/hid/hid-trace.c
new file mode 100644
index 0000000..b3afcb7
--- /dev/null
+++ b/drivers/hid/hid-trace.c
@@ -0,0 +1,17 @@
+/* Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+
+/* Instantiate tracepoints */
+#define CREATE_TRACE_POINTS
+#include "hid-trace.h"
diff --git a/drivers/hid/hid-trace.h b/drivers/hid/hid-trace.h
new file mode 100644
index 0000000..4415055
--- /dev/null
+++ b/drivers/hid/hid-trace.h
@@ -0,0 +1,56 @@
+/* Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#if !defined(_HID_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _HID_TRACE_H
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM hid
+#undef TRACE_INCLUDE_PATH
+#define TRACE_INCLUDE_PATH .
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_FILE hid-trace
+
+#include <linux/tracepoint.h>
+
+TRACE_EVENT(qvr_recv_sensor,
+	TP_PROTO(char *sensor, uint64_t ts, s32 x, s32 y, s32 z),
+	TP_ARGS(sensor, ts, x, y, z),
+	TP_STRUCT__entry(
+		__field(char *, sensor)
+		__field(uint64_t, ts)
+		__field(int, x)
+		__field(int, y)
+		__field(int, z)
+		),
+	TP_fast_assign(
+		__entry->sensor = sensor;
+		__entry->ts = ts;
+		__entry->x = x;
+		__entry->y = y;
+		__entry->z = z;
+		),
+	TP_printk(
+		"%s - ts=%llu x=%d y=%d z=%d",
+		__entry->sensor,
+		__entry->ts,
+		__entry->x,
+		__entry->y,
+		__entry->z
+		)
+	);
+
+#endif /* _HID_TRACE_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/hwmon/qpnp-adc-common.c b/drivers/hwmon/qpnp-adc-common.c
index b900f76..c5653fe 100644
--- a/drivers/hwmon/qpnp-adc-common.c
+++ b/drivers/hwmon/qpnp-adc-common.c
@@ -1263,6 +1263,19 @@
 		qpnp_adc_map_voltage_temp(adcmap_batt_therm_qrd,
 			ARRAY_SIZE(adcmap_batt_therm_qrd),
 			batt_thm_voltage, &adc_chan_result->physical);
+	} else {
+
+		qpnp_adc_scale_with_calib_param(adc_code,
+			adc_properties, chan_properties, &batt_thm_voltage);
+
+		adc_chan_result->measurement = batt_thm_voltage;
+
+		return qpnp_adc_map_voltage_temp(
+				adcmap_batt_therm_qrd,
+				ARRAY_SIZE(adcmap_batt_therm_qrd),
+				batt_thm_voltage,
+				&adc_chan_result->physical);
+
 	}
 	return 0;
 }
@@ -2152,6 +2165,64 @@
 }
 EXPORT_SYMBOL(qpnp_adc_qrd_skut1_btm_scaler);
 
+int32_t qpnp_adc_qrd_215_btm_scaler(struct qpnp_vadc_chip *chip,
+		struct qpnp_adc_tm_btm_param *param,
+		uint32_t *low_threshold, uint32_t *high_threshold)
+{
+	struct qpnp_vadc_linear_graph btm_param;
+	int64_t low_output = 0, high_output = 0;
+	int rc = 0;
+
+	if (param->adc_tm_hc) {
+		pr_debug("Update scaling for VADC_TM_HC\n");
+		return -EINVAL;
+	}
+
+	qpnp_get_vadc_gain_and_offset(chip, &btm_param, CALIB_RATIOMETRIC);
+
+	pr_debug("warm_temp:%d and cool_temp:%d\n", param->high_temp,
+				param->low_temp);
+	rc = qpnp_adc_map_voltage_temp(
+		adcmap_batt_therm_qrd,
+		ARRAY_SIZE(adcmap_batt_therm_qrd),
+		(param->low_temp),
+		&low_output);
+	if (rc) {
+		pr_debug("low_temp mapping failed with %d\n", rc);
+		return rc;
+	}
+
+	pr_debug("low_output:%lld\n", low_output);
+	low_output *= btm_param.dy;
+	low_output = div64_s64(low_output, btm_param.adc_vref);
+	low_output += btm_param.adc_gnd;
+
+	rc = qpnp_adc_map_voltage_temp(
+		adcmap_batt_therm_qrd,
+		ARRAY_SIZE(adcmap_batt_therm_qrd),
+		(param->high_temp),
+		&high_output);
+	if (rc) {
+		pr_debug("high temp mapping failed with %d\n", rc);
+		return rc;
+	}
+
+	pr_debug("high_output:%lld\n", high_output);
+	high_output *= btm_param.dy;
+	high_output = div64_s64(high_output, btm_param.adc_vref);
+	high_output += btm_param.adc_gnd;
+
+	/* btm low temperature correspondes to high voltage threshold */
+	*low_threshold = high_output;
+	/* btm high temperature correspondes to low voltage threshold */
+	*high_threshold = low_output;
+
+	pr_debug("high_volt:%d, low_volt:%d\n", *high_threshold,
+				*low_threshold);
+	return 0;
+}
+EXPORT_SYMBOL(qpnp_adc_qrd_215_btm_scaler);
+
 int32_t qpnp_adc_smb_btm_rscaler(struct qpnp_vadc_chip *chip,
 		struct qpnp_adc_tm_btm_param *param,
 		uint32_t *low_threshold, uint32_t *high_threshold)
diff --git a/drivers/hwtracing/coresight/coresight-cti.c b/drivers/hwtracing/coresight/coresight-cti.c
index 621e08f..066072a 100644
--- a/drivers/hwtracing/coresight/coresight-cti.c
+++ b/drivers/hwtracing/coresight/coresight-cti.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -166,14 +166,19 @@
 out:
 		spin_lock_irqsave(&drvdata->spinlock, flag);
 		drvdata->l2_off = true;
-		drvdata->state->cticontrol = cti_readl(drvdata, CTICONTROL);
-		drvdata->state->ctiappset = cti_readl(drvdata, CTIAPPSET);
-		drvdata->state->ctigate = cti_readl(drvdata, CTIGATE);
-		for (trig = 0; trig < CTI_MAX_TRIGGERS; trig++) {
-			drvdata->state->ctiinen[trig] =
-				cti_readl(drvdata, CTIINEN(trig));
-			drvdata->state->ctiouten[trig] =
-				cti_readl(drvdata, CTIOUTEN(trig));
+		if (drvdata->refcnt) {
+			drvdata->state->cticontrol =
+					cti_readl(drvdata, CTICONTROL);
+			drvdata->state->ctiappset =
+					cti_readl(drvdata, CTIAPPSET);
+			drvdata->state->ctigate =
+					cti_readl(drvdata, CTIGATE);
+			for (trig = 0; trig < CTI_MAX_TRIGGERS; trig++) {
+				drvdata->state->ctiinen[trig] =
+					cti_readl(drvdata, CTIINEN(trig));
+				drvdata->state->ctiouten[trig] =
+					cti_readl(drvdata, CTIOUTEN(trig));
+			}
 		}
 		spin_unlock_irqrestore(&drvdata->spinlock, flag);
 	}
@@ -209,17 +214,22 @@
 		continue;
 out:
 		spin_lock_irqsave(&drvdata->spinlock, flag);
-		CTI_UNLOCK(drvdata);
-		cti_writel(drvdata, drvdata->state->ctiappset, CTIAPPSET);
-		cti_writel(drvdata, drvdata->state->ctigate, CTIGATE);
-		for (trig = 0; trig < CTI_MAX_TRIGGERS; trig++) {
-			cti_writel(drvdata, drvdata->state->ctiinen[trig],
-				   CTIINEN(trig));
-			cti_writel(drvdata, drvdata->state->ctiouten[trig],
-				   CTIOUTEN(trig));
+		if (drvdata->refcnt) {
+			CTI_UNLOCK(drvdata);
+			cti_writel(drvdata, drvdata->state->ctiappset,
+				CTIAPPSET);
+			cti_writel(drvdata, drvdata->state->ctigate,
+				CTIGATE);
+			for (trig = 0; trig < CTI_MAX_TRIGGERS; trig++) {
+				cti_writel(drvdata,
+				drvdata->state->ctiinen[trig], CTIINEN(trig));
+				cti_writel(drvdata,
+				drvdata->state->ctiouten[trig], CTIOUTEN(trig));
+			}
+			cti_writel(drvdata, drvdata->state->cticontrol,
+				CTICONTROL);
+			CTI_LOCK(drvdata);
 		}
-		cti_writel(drvdata, drvdata->state->cticontrol, CTICONTROL);
-		CTI_LOCK(drvdata);
 		drvdata->l2_off = false;
 		spin_unlock_irqrestore(&drvdata->spinlock, flag);
 	}
@@ -380,8 +390,10 @@
 	 */
 	if (drvdata->refcnt == 0) {
 		ret = pm_runtime_get_sync(drvdata->dev);
-		if (ret)
+		if (ret < 0) {
+			pm_runtime_put(drvdata->dev);
 			goto err1;
+		}
 	}
 
 	spin_lock_irqsave(&drvdata->spinlock, flag);
@@ -464,8 +476,10 @@
 	 */
 	if (drvdata->refcnt == 0) {
 		ret = pm_runtime_get_sync(drvdata->dev);
-		if (ret)
+		if (ret < 0) {
+			pm_runtime_put(drvdata->dev);
 			goto err1;
+		}
 	}
 
 	spin_lock_irqsave(&drvdata->spinlock, flag);
@@ -1472,8 +1486,10 @@
 	}
 	if (drvdata->cti_save && !drvdata->cti_hwclk) {
 		ret = pm_runtime_get_sync(drvdata->dev);
-		if (ret)
+		if (ret < 0) {
+			pm_runtime_put(drvdata->dev);
 			return ret;
+		}
 	}
 
 	mutex_lock(&cti_lock);
diff --git a/drivers/i2c/busses/i2c-msm-v2.c b/drivers/i2c/busses/i2c-msm-v2.c
index 99e7c97..631169b 100644
--- a/drivers/i2c/busses/i2c-msm-v2.c
+++ b/drivers/i2c/busses/i2c-msm-v2.c
@@ -2321,6 +2321,12 @@
 	struct i2c_msm_ctrl      *ctrl = i2c_get_adapdata(adap);
 	struct i2c_msm_xfer      *xfer = &ctrl->xfer;
 
+	if (num < 1) {
+		dev_err(ctrl->dev,
+		"error on number of msgs(%d) received\n", num);
+		return -EINVAL;
+	}
+
 	if (IS_ERR_OR_NULL(msgs)) {
 		dev_err(ctrl->dev, " error on msgs Accessing invalid  pointer location\n");
 		return PTR_ERR(msgs);
diff --git a/drivers/iio/imu/inv_mpu/Kconfig b/drivers/iio/imu/inv_mpu/Kconfig
new file mode 100644
index 0000000..7505454
--- /dev/null
+++ b/drivers/iio/imu/inv_mpu/Kconfig
@@ -0,0 +1,63 @@
+#
+# inv-mpu-iio driver for Invensense MPU devices
+#
+
+config INV_MPU_IIO
+	tristate
+	select IIO_BUFFER
+	select IIO_KFIFO_BUF
+	select IIO_TRIGGER
+	select CRC32
+
+choice
+	prompt "Chip name"
+	depends on INV_MPU_IIO
+
+config INV_MPU_IIO_ICM20648
+	bool "ICM20648/ICM20948"
+	help
+	  Select this if you are using a ICM20648/ICM20948 chip.
+
+config INV_MPU_IIO_ICM20608D
+	bool "ICM20608D/ICM20609/ICM20689"
+	help
+	  Select this if you are using a ICM20608D/ICM20609/ICM20689 chip.
+
+config INV_MPU_IIO_ICM20602
+	bool "ICM20602"
+	help
+	  Select this if you are using a ICM20602 chip.
+
+config INV_MPU_IIO_ICM20690
+	bool "ICM20690"
+	help
+	  Select this if you are using a ICM20690 chip.
+
+config INV_MPU_IIO_IAM20680
+	bool "IAM20680"
+	help
+	  Select this if you are using a IAM20680 chip.
+
+endchoice
+
+config INV_MPU_IIO_I2C
+	tristate "Invensense ICM20xxx devices (I2C)"
+	depends on I2C && !INV_MPU6050_IIO
+	select INV_MPU_IIO
+	default n
+	help
+	  This driver supports Invensense ICM20xxx devices over I2C.
+	  This driver can be built as a module. The module will be called
+	  inv-mpu-iio-i2c.
+
+config INV_MPU_IIO_SPI
+	tristate "Invensense ICM20xxx devices (SPI)"
+	depends on SPI_MASTER && !INV_MPU6050_IIO
+	select INV_MPU_IIO
+	default n
+	help
+	  This driver supports Invensense ICM20xxx devices over SPI.
+	  This driver can be built as a module. The module will be called
+	  inv-mpu-iio-spi.
+
+source "drivers/iio/imu/inv_mpu/inv_test/Kconfig"
diff --git a/drivers/iio/imu/inv_mpu/Makefile b/drivers/iio/imu/inv_mpu/Makefile
new file mode 100644
index 0000000..dfc4c25
--- /dev/null
+++ b/drivers/iio/imu/inv_mpu/Makefile
@@ -0,0 +1,61 @@
+#
+# Makefile for Invensense inv-mpu-iio device.
+#
+
+obj-$(CONFIG_INV_MPU_IIO) += inv-mpu-iio.o
+
+inv-mpu-iio-objs += inv_mpu_common.o
+inv-mpu-iio-objs += inv_mpu_ring.o
+inv-mpu-iio-objs += inv_mpu_timestamp.o
+inv-mpu-iio-objs += inv_mpu_dts.o
+
+# chip support
+ifeq ($(CONFIG_INV_MPU_IIO_ICM20648), y)
+inv-mpu-iio-objs += icm20648/inv_mpu_init.o
+inv-mpu-iio-objs += icm20648/inv_mpu_core.o
+inv-mpu-iio-objs += icm20648/inv_mpu_parsing.o
+inv-mpu-iio-objs += icm20648/inv_mpu_setup.o
+inv-mpu-iio-objs += icm20648/inv_mpu_dmp_fifo.o
+inv-mpu-iio-objs += icm20648/inv_slave_compass.o
+inv-mpu-iio-objs += icm20648/inv_slave_pressure.o
+inv-mpu-iio-objs += icm20648/inv_slave_als.o
+inv-mpu-iio-objs += icm20648/inv_mpu_load_dmp.o
+inv-mpu-iio-objs += icm20648/inv_mpu_selftest.o
+inv-mpu-iio-objs += dmp_support/inv_mpu_misc.o
+else ifeq ($(CONFIG_INV_MPU_IIO_ICM20690), y)
+inv-mpu-iio-objs += icm20690/inv_mpu_init_20690.o
+inv-mpu-iio-objs += icm20690/inv_mpu_core_20690.o
+inv-mpu-iio-objs += icm20690/inv_mpu_parsing_20690.o
+inv-mpu-iio-objs += icm20690/inv_mpu_setup_20690.o
+inv-mpu-iio-objs += icm20690/inv_mpu_selftest_20690.o
+inv-mpu-iio-objs += icm20690/inv_slave_compass.o
+else ifeq ($(CONFIG_INV_MPU_IIO_ICM20602), y)
+inv-mpu-iio-objs += icm20602/inv_mpu_init_20602.o
+inv-mpu-iio-objs += icm20602/inv_mpu_core_20602.o
+inv-mpu-iio-objs += icm20602/inv_mpu_parsing_20602.o
+inv-mpu-iio-objs += icm20602/inv_mpu_setup_20602.o
+inv-mpu-iio-objs += icm20602/inv_mpu_selftest_20602.o
+else ifeq ($(CONFIG_INV_MPU_IIO_ICM20608D), y)
+inv-mpu-iio-objs += icm20608d/inv_mpu_init_20608.o
+inv-mpu-iio-objs += icm20608d/inv_mpu_core_20608.o
+inv-mpu-iio-objs += icm20608d/inv_mpu_parsing_20608.o
+inv-mpu-iio-objs += icm20608d/inv_mpu_setup_20608D.o
+inv-mpu-iio-objs += icm20608d/inv_mpu_dmp_fifo.o
+inv-mpu-iio-objs += icm20608d/inv_mpu_load_dmp.o
+inv-mpu-iio-objs += icm20608d/inv_mpu_selftest_20608.o
+inv-mpu-iio-objs += dmp_support/inv_mpu_misc.o
+else ifeq ($(CONFIG_INV_MPU_IIO_IAM20680), y)
+inv-mpu-iio-objs += iam20680/inv_mpu_init_20680.o
+inv-mpu-iio-objs += iam20680/inv_mpu_core_20680.o
+inv-mpu-iio-objs += iam20680/inv_mpu_parsing_20680.o
+inv-mpu-iio-objs += iam20680/inv_mpu_setup_20680.o
+inv-mpu-iio-objs += iam20680/inv_mpu_selftest_20680.o
+endif
+
+# Bus support
+obj-$(CONFIG_INV_MPU_IIO_I2C) += inv-mpu-iio-i2c.o
+inv-mpu-iio-i2c-objs := inv_mpu_i2c.o
+obj-$(CONFIG_INV_MPU_IIO_SPI) += inv-mpu-iio-spi.o
+inv-mpu-iio-spi-objs := inv_mpu_spi.o
+
+obj-y += inv_test/
diff --git a/drivers/iio/imu/inv_mpu/README b/drivers/iio/imu/inv_mpu/README
new file mode 100644
index 0000000..47ff502
--- /dev/null
+++ b/drivers/iio/imu/inv_mpu/README
@@ -0,0 +1,117 @@
+Kernel driver inv-mpu-iio
+Author: InvenSense, Inc.
+
+
+Table of Contents
+=================
+- Description
+- Integrating the Driver in the Linux Kernel
+- Dts file
+- Communicating with the Driver in Userspace
+
+
+Description
+===========
+This document describes how to install the Invensense device driver into a
+Linux kernel. The supported chips are listed in Kconfig and user selects an
+appropriate one from .e.g. menuconfig.
+
+
+Integrating the Driver in the Linux Kernel
+==========================================
+Please add the files as follows (kernel 3.10):
+- Copy mpu.h to <kernel_root>/include/linux/iio/imu/
+- Copy inv_mpu folder under <kernel_root>/drivers/iio/imu/
+
+In order to see the driver in menuconfig when building the kernel, please
+make modifications as shown below:
+
+    add "source "drivers/iio/imu/inv_mpu/Kconfig""
+      in <kernel_root>/drivers/iio/imu/Kconfig
+
+    add "obj-y += inv_mpu/"
+      in <kernel_root>/drivers/iio/imu/Makefile
+
+
+
+Dts file
+========
+In order to recognize the Invensense device on the I2C/SPI bus, dts(or dtsi)
+file must be modified.
+
+Example)
+ICM20648 + AK09911/BMP280/APDS9930 on AUX I2C
+
+    i2c@f9968000 {
+        /* Invensense */
+        mpu6515_acc@68 {
+            compatible = "inven,icm20648";
+            reg = <0x68>;
+            interrupt-parent = <&msmgpio>;
+            interrupts = <73 0x2>;
+            inven,vdd_ana-supply = <&pm8941_l17>;
+            inven,vcc_i2c-supply = <&pm8941_lvs1>;
+            inven,gpio_int1 = <&msmgpio 73 0x00>;
+            fs_range = <0x00>;
+            /* mount matrix */
+            axis_map_x = <1>;
+            axis_map_y = <0>;
+            axis_map_z = <2>;
+            negate_x = <0>;
+            negate_y = <0>;
+            negate_z = <1>;
+            poll_interval = <200>;
+            min_interval = <5>;
+            inven,secondary_reg = <0x0c>;
+            /* If no compass sensor,
+             * replace "compass" with "none"
+             */
+            inven,secondary_type = "compass";
+            inven,secondary_name = "ak09911";
+            inven,secondary_axis_map_x = <1>;
+            inven,secondary_axis_map_y = <0>;
+            inven,secondary_axis_map_z = <2>;
+            inven,secondary_negate_x = <1>;
+            inven,secondary_negate_y = <1>;
+            inven,secondary_negate_z = <1>;
+            /* If no pressure sensor,
+             * replace "pressure" with "none"
+             */
+            inven,aux_type = "pressure";
+            inven,aux_name = "bmp280";
+            inven,aux_reg = <0x76>;
+            /* If no ALS sensor
+             * replace "als" with "none"
+             */
+            inven,read_only_slave_type = "als";
+            inven,read_only_slave_name = "apds9930";
+            inven,read_only_slave_reg = <0x39>;
+        };
+    };
+
+
+Communicating with the Driver in Userspace
+==========================================
+The driver generates several files in sysfs upon installation.
+These files are used to communicate with the driver. The files can be found at:
+
+(I2C) /sys/devices/*.i2c/i2c-*/*-*/iio:device*
+(SPI) /sys/devices/*.spi/spi_master/spi*/spi*.*/iio:device*
+
+Group and Owner for all entries should be updated to system/system at
+boot time to allow userspace to access properly.
+
+
+License
+=======
+Copyright (C) 2018 InvenSense, Inc.
+
+This software is licensed under the terms of the GNU General Public
+License version 2, as published by the Free Software Foundation, and
+may be copied, distributed, and modified under those terms.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
diff --git a/drivers/iio/imu/inv_mpu/iam20680/inv_mpu_core_20680.c b/drivers/iio/imu/inv_mpu/iam20680/inv_mpu_core_20680.c
new file mode 100644
index 0000000..b429f57
--- /dev/null
+++ b/drivers/iio/imu/inv_mpu/iam20680/inv_mpu_core_20680.c
@@ -0,0 +1,1072 @@
+/*
+ * Copyright (C) 2017-2018 InvenSense, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#define pr_fmt(fmt) "inv_mpu: " fmt
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/err.h>
+#include <linux/delay.h>
+#include <linux/sysfs.h>
+#include <linux/jiffies.h>
+#include <linux/irq.h>
+#include <linux/interrupt.h>
+#include <linux/kfifo.h>
+#include <linux/poll.h>
+#include <linux/miscdevice.h>
+#include <linux/spinlock.h>
+#include <linux/spi/spi.h>
+#include <linux/i2c.h>
+
+#include "../inv_mpu_iio.h"
+
+static const struct inv_hw_s hw_info[INV_NUM_PARTS] = {
+	{128, "ICM20608D"},
+	{128, "ICM20690"},
+	{128, "ICM20602"},
+	{128, "IAM20680"},
+};
+
+#ifndef SUPPORT_ONLY_BASIC_FEATURES
+static char debug_reg_addr = 0x6;
+#endif
+
+const char sensor_l_info[][30] = {
+	"SENSOR_L_ACCEL",
+	"SENSOR_L_GYRO",
+	"SENSOR_L_MAG",
+	"SENSOR_L_ALS",
+	"SENSOR_L_SIXQ",
+	"SENSOR_L_THREEQ",
+	"SENSOR_L_NINEQ",
+	"SENSOR_L_PEDQ",
+	"SENSOR_L_GEOMAG",
+	"SENSOR_L_PRESSURE",
+	"SENSOR_L_GYRO_CAL",
+	"SENSOR_L_MAG_CAL",
+	"SENSOR_L_EIS_GYRO",
+	"SENSOR_L_ACCEL_WAKE",
+	"SENSOR_L_GYRO_WAKE",
+	"SENSOR_L_MAG_WAKE",
+	"SENSOR_L_ALS_WAKE",
+	"SENSOR_L_SIXQ_WAKE",
+	"SENSOR_L_NINEQ_WAKE",
+	"SENSOR_L_PEDQ_WAKE",
+	"SENSOR_L_GEOMAG_WAKE",
+	"SENSOR_L_PRESSURE_WAKE",
+	"SENSOR_L_GYRO_CAL_WAKE",
+	"SENSOR_L_MAG_CAL_WAKE",
+	"SENSOR_L_NUM_MAX",
+};
+
+static int inv_set_accel_bias_reg(struct inv_mpu_state *st,
+			int accel_bias, int axis)
+{
+	int accel_reg_bias;
+	u8 addr;
+	u8 d[2];
+	int result = 0;
+
+	switch (axis) {
+	case 0:
+		/* X */
+		addr = REG_XA_OFFS_H;
+		break;
+	case 1:
+		/* Y */
+		addr = REG_YA_OFFS_H;
+		break;
+	case 2:
+		/* Z* */
+		addr = REG_ZA_OFFS_H;
+		break;
+	default:
+		result = -EINVAL;
+		goto accel_bias_set_err;
+	}
+
+	result = inv_plat_read(st, addr, 2, d);
+	if (result)
+		goto accel_bias_set_err;
+	accel_reg_bias = ((int)d[0] << 8) | d[1];
+
+	/* accel_bias is 2g scaled by 1<<16.
+	 * Convert to 16g, and mask bit0 */
+	accel_reg_bias -= ((accel_bias / 8 / 65536) & ~1);
+
+	d[0] = (accel_reg_bias >> 8) & 0xff;
+	d[1] = (accel_reg_bias) & 0xff;
+	result = inv_plat_single_write(st, addr, d[0]);
+	if (result)
+		goto accel_bias_set_err;
+	result = inv_plat_single_write(st, addr + 1, d[1]);
+	if (result)
+		goto accel_bias_set_err;
+
+accel_bias_set_err:
+	return result;
+}
+
+static int inv_set_gyro_bias_reg(struct inv_mpu_state *st,
+			const int gyro_bias, int axis)
+{
+	int gyro_reg_bias;
+	u8 addr;
+	u8 d[2];
+	int result = 0;
+
+	switch (axis) {
+	case 0:
+		/* X */
+		addr = REG_XG_OFFS_USR_H;
+		break;
+	case 1:
+		/* Y */
+		addr = REG_YG_OFFS_USR_H;
+		break;
+	case 2:
+		/* Z */
+		addr = REG_ZG_OFFS_USR_H;
+		break;
+	default:
+		result = -EINVAL;
+		goto gyro_bias_set_err;
+	}
+
+	/* gyro_bias is 2000dps scaled by 1<<16.
+	 * Convert to 1000dps */
+	gyro_reg_bias = (-gyro_bias * 2 / 65536);
+
+	d[0] = (gyro_reg_bias >> 8) & 0xff;
+	d[1] = (gyro_reg_bias) & 0xff;
+	result = inv_plat_single_write(st, addr, d[0]);
+	if (result)
+		goto gyro_bias_set_err;
+	result = inv_plat_single_write(st, addr + 1, d[1]);
+	if (result)
+		goto gyro_bias_set_err;
+
+gyro_bias_set_err:
+	return result;
+}
+
+static int _bias_store(struct device *dev,
+			struct device_attribute *attr, const char *buf,
+			size_t count)
+{
+	struct iio_dev *indio_dev = dev_get_drvdata(dev);
+	struct inv_mpu_state *st = iio_priv(indio_dev);
+	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
+	int result, data;
+
+	result = inv_switch_power_in_lp(st, true);
+	if (result)
+		return result;
+
+	result = kstrtoint(buf, 10, &data);
+	if (result)
+		goto bias_store_fail;
+	switch (this_attr->address) {
+	case ATTR_ACCEL_X_OFFSET:
+		result = inv_set_accel_bias_reg(st, data, 0);
+		if (result)
+			goto bias_store_fail;
+		st->input_accel_bias[0] = data;
+		break;
+	case ATTR_ACCEL_Y_OFFSET:
+		result = inv_set_accel_bias_reg(st, data, 1);
+		if (result)
+			goto bias_store_fail;
+		st->input_accel_bias[1] = data;
+		break;
+	case ATTR_ACCEL_Z_OFFSET:
+		result = inv_set_accel_bias_reg(st, data, 2);
+		if (result)
+			goto bias_store_fail;
+		st->input_accel_bias[2] = data;
+		break;
+	case ATTR_GYRO_X_OFFSET:
+		result = inv_set_gyro_bias_reg(st, data, 0);
+		if (result)
+			goto bias_store_fail;
+		st->input_gyro_bias[0] = data;
+		break;
+	case ATTR_GYRO_Y_OFFSET:
+		result = inv_set_gyro_bias_reg(st, data, 1);
+		if (result)
+			goto bias_store_fail;
+		st->input_gyro_bias[1] = data;
+		break;
+	case ATTR_GYRO_Z_OFFSET:
+		result = inv_set_gyro_bias_reg(st, data, 2);
+		if (result)
+			goto bias_store_fail;
+		st->input_gyro_bias[2] = data;
+		break;
+	default:
+		break;
+	}
+
+bias_store_fail:
+	if (result)
+		return result;
+	result = inv_switch_power_in_lp(st, false);
+	if (result)
+		return result;
+
+	return count;
+}
+
+static ssize_t inv_bias_store(struct device *dev,
+			struct device_attribute *attr, const char *buf,
+			size_t count)
+{
+	struct iio_dev *indio_dev = dev_get_drvdata(dev);
+	int result;
+
+	mutex_lock(&indio_dev->mlock);
+	result = _bias_store(dev, attr, buf, count);
+	mutex_unlock(&indio_dev->mlock);
+
+	return result;
+}
+
+#ifndef SUPPORT_ONLY_BASIC_FEATURES
+static ssize_t inv_debug_store(struct device *dev,
+			struct device_attribute *attr, const char *buf,
+			size_t count)
+{
+	struct iio_dev *indio_dev = dev_get_drvdata(dev);
+	struct inv_mpu_state *st = iio_priv(indio_dev);
+	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
+	int result, data;
+
+	result = kstrtoint(buf, 10, &data);
+	if (result)
+		return result;
+	switch (this_attr->address) {
+	case ATTR_DMP_LP_EN_OFF:
+		st->chip_config.lp_en_mode_off = !!data;
+		inv_switch_power_in_lp(st, !!data);
+		break;
+	case ATTR_DMP_CLK_SEL:
+		st->chip_config.clk_sel = !!data;
+		inv_switch_power_in_lp(st, !!data);
+		break;
+	case ATTR_DEBUG_REG_ADDR:
+		debug_reg_addr = data;
+		break;
+	case ATTR_DEBUG_REG_WRITE:
+		inv_plat_single_write(st, debug_reg_addr, data);
+		break;
+	}
+	return count;
+}
+#endif
+
+static int _misc_attr_store(struct device *dev,
+			struct device_attribute *attr, const char *buf,
+			size_t count)
+{
+	struct iio_dev *indio_dev = dev_get_drvdata(dev);
+	struct inv_mpu_state *st = iio_priv(indio_dev);
+	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
+	int result, data;
+
+	result = inv_switch_power_in_lp(st, true);
+	if (result)
+		return result;
+	result = kstrtoint(buf, 10, &data);
+	if (result)
+		return result;
+	switch (this_attr->address) {
+	case ATTR_GYRO_SCALE:
+		if (data > 3)
+			return -EINVAL;
+		st->chip_config.fsr = data;
+		result = inv_set_gyro_sf(st);
+		return result;
+	case ATTR_ACCEL_SCALE:
+		if (data > 3)
+			return -EINVAL;
+		st->chip_config.accel_fs = data;
+		result = inv_set_accel_sf(st);
+		return result;
+	default:
+		return -EINVAL;
+	}
+	st->trigger_state = MISC_TRIGGER;
+	result = set_inv_enable(indio_dev);
+
+	return result;
+}
+
+/*
+ * inv_misc_attr_store() -  calling this function
+ */
+static ssize_t inv_misc_attr_store(struct device *dev,
+			struct device_attribute *attr, const char *buf,
+			size_t count)
+{
+	struct iio_dev *indio_dev = dev_get_drvdata(dev);
+	int result;
+
+	mutex_lock(&indio_dev->mlock);
+	result = _misc_attr_store(dev, attr, buf, count);
+	mutex_unlock(&indio_dev->mlock);
+	if (result)
+		return result;
+
+	return count;
+}
+
+static ssize_t inv_sensor_rate_show(struct device *dev,
+			struct device_attribute *attr, char *buf)
+{
+	struct iio_dev *indio_dev = dev_get_drvdata(dev);
+	struct inv_mpu_state *st = iio_priv(indio_dev);
+	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
+
+	return snprintf(buf, MAX_WR_SZ, "%d\n",
+					st->sensor_l[this_attr->address].rate);
+}
+
+static ssize_t inv_sensor_rate_store(struct device *dev,
+			struct device_attribute *attr, const char *buf,
+			size_t count)
+{
+	struct iio_dev *indio_dev = dev_get_drvdata(dev);
+	struct inv_mpu_state *st = iio_priv(indio_dev);
+	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
+	int data, rate, ind;
+	int result;
+
+	result = kstrtoint(buf, 10, &data);
+	if (result)
+		return -EINVAL;
+	if (data <= 0) {
+		pr_err("sensor_rate_store: invalid data=%d\n", data);
+		return -EINVAL;
+	}
+	ind = this_attr->address;
+	rate = inv_rate_convert(st, ind, data);
+
+	pr_debug("sensor [%s] requested  rate %d input [%d]\n",
+						sensor_l_info[ind], rate, data);
+
+	if (rate == st->sensor_l[ind].rate)
+		return count;
+	mutex_lock(&indio_dev->mlock);
+	st->sensor_l[ind].rate = rate;
+	st->trigger_state = DATA_TRIGGER;
+	inv_check_sensor_on(st);
+	result = set_inv_enable(indio_dev);
+	pr_debug("%s rate %d div %d\n", sensor_l_info[ind],
+				st->sensor_l[ind].rate, st->sensor_l[ind].div);
+	mutex_unlock(&indio_dev->mlock);
+
+	return count;
+}
+
+static ssize_t inv_sensor_on_show(struct device *dev,
+			struct device_attribute *attr, char *buf)
+{
+	struct iio_dev *indio_dev = dev_get_drvdata(dev);
+	struct inv_mpu_state *st = iio_priv(indio_dev);
+	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
+
+	return snprintf(buf, MAX_WR_SZ, "%d\n", st->sensor_l[this_attr->address].on);
+}
+
+static ssize_t inv_sensor_on_store(struct device *dev,
+			struct device_attribute *attr, const char *buf,
+			size_t count)
+{
+	struct iio_dev *indio_dev = dev_get_drvdata(dev);
+	struct inv_mpu_state *st = iio_priv(indio_dev);
+	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
+	int data, on, ind;
+	int result;
+
+	result = kstrtoint(buf, 10, &data);
+	if (result)
+		return -EINVAL;
+	if (data < 0) {
+		pr_err("sensor_on_store: invalid data=%d\n", data);
+		return -EINVAL;
+	}
+	ind = this_attr->address;
+	on = !!data;
+
+	pr_debug("sensor [%s] requested  %s, input [%d]\n",
+			sensor_l_info[ind], (on == 1) ? "On" : "Off", data);
+
+	if (on == st->sensor_l[ind].on) {
+		pr_debug("sensor [%s] is already %s, input [%d]\n",
+			sensor_l_info[ind], (on == 1) ? "On" : "Off", data);
+		return count;
+	}
+
+	mutex_lock(&indio_dev->mlock);
+	st->sensor_l[ind].on = on;
+	st->trigger_state = RATE_TRIGGER;
+	inv_check_sensor_on(st);
+	result = set_inv_enable(indio_dev);
+	mutex_unlock(&indio_dev->mlock);
+	if (result)
+		return result;
+
+	pr_debug("Sensor [%s] is %s by sysfs\n",
+				sensor_l_info[ind], (on == 1) ? "On" : "Off");
+	return count;
+}
+
+static int inv_check_l_step(struct inv_mpu_state *st)
+{
+	if (st->step_counter_l_on || st->step_counter_wake_l_on)
+		st->ped.on = true;
+	else
+		st->ped.on = false;
+
+	return 0;
+}
+
+static int _basic_attr_store(struct device *dev,
+			struct device_attribute *attr, const char *buf,
+			size_t count)
+{
+	struct iio_dev *indio_dev = dev_get_drvdata(dev);
+	struct inv_mpu_state *st = iio_priv(indio_dev);
+	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
+	int data;
+	int result;
+	u32 power_on_data;
+
+	result = kstrtoint(buf, 10, &data);
+	if (result || (data < 0))
+		return -EINVAL;
+
+	switch (this_attr->address) {
+	case ATTR_DMP_PED_ON:
+		if ((!!data) == st->ped.on)
+			return count;
+		st->ped.on = !!data;
+		break;
+	case ATTR_DMP_TILT_ENABLE:
+		if ((!!data) == st->chip_config.tilt_enable)
+			return count;
+		st->chip_config.tilt_enable = !!data;
+		pr_info("Tile %s\n",
+			st->chip_config.tilt_enable ==
+			1 ? "Enabled" : "Disabled");
+		break;
+	case ATTR_DMP_PICK_UP_ENABLE:
+		if ((!!data) == st->chip_config.pick_up_enable) {
+			pr_info("Pick_up enable already %s\n",
+				st->chip_config.pick_up_enable ==
+				1 ? "Enabled" : "Disabled");
+			return count;
+		}
+		st->chip_config.pick_up_enable = !!data;
+		pr_info("Pick up %s\n",
+			st->chip_config.pick_up_enable ==
+			1 ? "Enable" : "Disable");
+		break;
+	case ATTR_IN_POWER_ON:
+		{
+			u8 p0[2];
+			u8 p1[2];
+
+			power_on_data = (u32)data;
+			p0[0] = (power_on_data & 0xff);
+			p0[1] = ((power_on_data >> 8) & 0xff);
+			p1[0] = ((power_on_data >> 16) & 0xff);
+			p1[1] = ((power_on_data >> 24) & 0xff);
+
+			if (st->bus_type == BUS_SPI) {
+				struct spi_transfer power_on;
+				struct spi_message msg;
+
+				memset(&power_on, 0, sizeof(struct spi_transfer));
+
+				power_on.bits_per_word = 8;
+				power_on.len = 2;
+
+				power_on.tx_buf = p0;
+				power_on.rx_buf = p1;
+				spi_message_init(&msg);
+				spi_message_add_tail(&power_on, &msg);
+				spi_sync(to_spi_device(st->dev), &msg);
+
+			} else if (st->bus_type == BUS_I2C) {
+				struct i2c_msg msgs[2];
+
+				p0[0] &= 0x7f;
+
+				msgs[0].addr = st->i2c_addr;
+				msgs[0].flags = 0;	/* write */
+				msgs[0].buf = &p0[0];
+				msgs[0].len = 1;
+
+				msgs[1].addr = st->i2c_addr;
+				msgs[1].flags = I2C_M_RD;
+				msgs[1].buf = &p1[1];
+				msgs[1].len = 1;
+
+				result = i2c_transfer(st->sl_handle, msgs, 2);
+				if (result < 2)
+					return -EIO;
+			}
+			st->power_on_data = ((p0[0] << 24) | (p0[1] << 16) |
+							(p1[0] << 8) | p1[1]);
+			return count;
+		}
+	case ATTR_DMP_EIS_ENABLE:
+		if ((!!data) == st->chip_config.eis_enable)
+			return count;
+		st->chip_config.eis_enable = !!data;
+		pr_info("Eis %s\n",
+			st->chip_config.eis_enable == 1 ? "Enable" : "Disable");
+		break;
+	case ATTR_DMP_STEP_DETECTOR_ON:
+		st->step_detector_l_on = !!data;
+		break;
+	case ATTR_DMP_STEP_DETECTOR_WAKE_ON:
+		st->step_detector_wake_l_on = !!data;
+		break;
+	case ATTR_DMP_STEP_COUNTER_ON:
+		st->step_counter_l_on = !!data;
+		break;
+	case ATTR_DMP_STEP_COUNTER_WAKE_ON:
+		st->step_counter_wake_l_on = !!data;
+		break;
+	case ATTR_DMP_BATCHMODE_TIMEOUT:
+		if (data == st->batch.timeout)
+			return count;
+		st->batch.timeout = data;
+		break;
+	default:
+		return -EINVAL;
+	};
+	inv_check_l_step(st);
+	inv_check_sensor_on(st);
+
+	st->trigger_state = EVENT_TRIGGER;
+	result = set_inv_enable(indio_dev);
+	if (result)
+		return result;
+
+	return count;
+}
+
+/*
+ * inv_basic_attr_store()
+ */
+static ssize_t inv_basic_attr_store(struct device *dev,
+			struct device_attribute *attr, const char *buf,
+			size_t count)
+{
+	struct iio_dev *indio_dev = dev_get_drvdata(dev);
+	int result;
+
+	mutex_lock(&indio_dev->mlock);
+	result = _basic_attr_store(dev, attr, buf, count);
+
+	mutex_unlock(&indio_dev->mlock);
+
+	return result;
+}
+
+/*
+ * inv_attr_show()
+ */
+static ssize_t inv_attr_show(struct device *dev,
+			struct device_attribute *attr, char *buf)
+{
+	struct iio_dev *indio_dev = dev_get_drvdata(dev);
+	struct inv_mpu_state *st = iio_priv(indio_dev);
+	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
+	s8 *m;
+
+	switch (this_attr->address) {
+	case ATTR_GYRO_SCALE:
+		{
+			const s16 gyro_scale[] = { 250, 500, 1000, 2000 };
+
+			return snprintf(buf, MAX_WR_SZ, "%d\n",
+				gyro_scale[st->chip_config.fsr]);
+		}
+	case ATTR_ACCEL_SCALE:
+		{
+			const s16 accel_scale[] = { 2, 4, 8, 16 };
+			return snprintf(buf, MAX_WR_SZ, "%d\n",
+				accel_scale[st->chip_config.accel_fs]);
+		}
+	case ATTR_GYRO_ENABLE:
+		return snprintf(buf, MAX_WR_SZ, "%d\n", st->chip_config.gyro_enable);
+	case ATTR_ACCEL_ENABLE:
+		return snprintf(buf, MAX_WR_SZ, "%d\n", st->chip_config.accel_enable);
+	case ATTR_IN_POWER_ON:
+		return snprintf(buf, MAX_WR_SZ, "%d\n", st->power_on_data);
+	case ATTR_DMP_BATCHMODE_TIMEOUT:
+		return snprintf(buf, MAX_WR_SZ, "%d\n", st->batch.timeout);
+	case ATTR_DMP_PED_ON:
+		return snprintf(buf, MAX_WR_SZ, "%d\n", st->ped.on);
+	case ATTR_DMP_TILT_ENABLE:
+		return snprintf(buf, MAX_WR_SZ, "%d\n",
+			st->chip_config.tilt_enable);
+	case ATTR_DMP_PICK_UP_ENABLE:
+		return snprintf(buf, MAX_WR_SZ, "%d\n",
+			st->chip_config.pick_up_enable);
+	case ATTR_DMP_EIS_ENABLE:
+		return snprintf(buf, MAX_WR_SZ, "%d\n", st->chip_config.eis_enable);
+	case ATTR_DMP_LP_EN_OFF:
+		return snprintf(buf, MAX_WR_SZ, "%d\n",
+			st->chip_config.lp_en_mode_off);
+	case ATTR_DMP_STEP_COUNTER_ON:
+		return snprintf(buf, MAX_WR_SZ, "%d\n", st->step_counter_l_on);
+	case ATTR_DMP_STEP_COUNTER_WAKE_ON:
+		return snprintf(buf, MAX_WR_SZ, "%d\n", st->step_counter_wake_l_on);
+	case ATTR_DMP_STEP_DETECTOR_ON:
+		return snprintf(buf, MAX_WR_SZ, "%d\n", st->step_detector_l_on);
+	case ATTR_DMP_STEP_DETECTOR_WAKE_ON:
+		return snprintf(buf, MAX_WR_SZ, "%d\n", st->step_detector_wake_l_on);
+	case ATTR_GYRO_MATRIX:
+		m = st->plat_data.orientation;
+		return snprintf(buf, MAX_WR_SZ, "%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
+			m[0], m[1], m[2], m[3], m[4], m[5], m[6], m[7],
+			m[8]);
+	case ATTR_ACCEL_MATRIX:
+		m = st->plat_data.orientation;
+		return snprintf(buf, MAX_WR_SZ, "%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
+			m[0], m[1], m[2], m[3], m[4], m[5], m[6], m[7],
+			m[8]);
+	case ATTR_GYRO_SF:
+		return snprintf(buf, MAX_WR_SZ, "%d\n", st->gyro_sf);
+	case ATTR_ANGLVEL_X_ST_CALIBBIAS:
+		return snprintf(buf, MAX_WR_SZ, "%d\n", st->gyro_st_bias[0]);
+	case ATTR_ANGLVEL_Y_ST_CALIBBIAS:
+		return snprintf(buf, MAX_WR_SZ, "%d\n", st->gyro_st_bias[1]);
+	case ATTR_ANGLVEL_Z_ST_CALIBBIAS:
+		return snprintf(buf, MAX_WR_SZ, "%d\n", st->gyro_st_bias[2]);
+	case ATTR_ACCEL_X_ST_CALIBBIAS:
+		return snprintf(buf, MAX_WR_SZ, "%d\n", st->accel_st_bias[0]);
+	case ATTR_ACCEL_Y_ST_CALIBBIAS:
+		return snprintf(buf, MAX_WR_SZ, "%d\n", st->accel_st_bias[1]);
+	case ATTR_ACCEL_Z_ST_CALIBBIAS:
+		return snprintf(buf, MAX_WR_SZ, "%d\n", st->accel_st_bias[2]);
+	case ATTR_GYRO_X_OFFSET:
+		return snprintf(buf, MAX_WR_SZ, "%d\n", st->input_gyro_bias[0]);
+	case ATTR_GYRO_Y_OFFSET:
+		return snprintf(buf, MAX_WR_SZ, "%d\n", st->input_gyro_bias[1]);
+	case ATTR_GYRO_Z_OFFSET:
+		return snprintf(buf, MAX_WR_SZ, "%d\n", st->input_gyro_bias[2]);
+	case ATTR_ACCEL_X_OFFSET:
+		return snprintf(buf, MAX_WR_SZ, "%d\n", st->input_accel_bias[0]);
+	case ATTR_ACCEL_Y_OFFSET:
+		return snprintf(buf, MAX_WR_SZ, "%d\n", st->input_accel_bias[1]);
+	case ATTR_ACCEL_Z_OFFSET:
+		return snprintf(buf, MAX_WR_SZ, "%d\n", st->input_accel_bias[2]);
+	default:
+		return -EPERM;
+	}
+}
+
+static ssize_t inv_self_test(struct device *dev,
+			struct device_attribute *attr, char *buf)
+{
+	struct iio_dev *indio_dev = dev_get_drvdata(dev);
+	struct inv_mpu_state *st = iio_priv(indio_dev);
+	int res;
+
+	mutex_lock(&indio_dev->mlock);
+	res = inv_hw_self_test(st);
+	set_inv_enable(indio_dev);
+	mutex_unlock(&indio_dev->mlock);
+
+	return snprintf(buf, MAX_WR_SZ, "%d\n", res);
+}
+
+
+/*
+ *  inv_temperature_show() - Read temperature data directly from registers.
+ */
+static ssize_t inv_temperature_show(struct device *dev,
+			struct device_attribute *attr, char *buf)
+{
+	struct iio_dev *indio_dev = dev_get_drvdata(dev);
+	struct inv_mpu_state *st = iio_priv(indio_dev);
+
+	u8 data[2];
+	s32 temp;
+	int res;
+
+	mutex_lock(&indio_dev->mlock);
+	res = inv_plat_read(st, REG_RAW_TEMP, 2, data);
+	if (res)
+		return res;
+	mutex_unlock(&indio_dev->mlock);
+
+	temp = (s32)be16_to_cpup((__be16 *)(data)) * 10000;
+	temp = temp / TEMP_SENSITIVITY + TEMP_OFFSET;
+
+	return snprintf(buf, MAX_WR_SZ, "%d %lld\n", temp, get_time_ns());
+}
+
+/*
+ *  inv_reg_dump_show() - Register dump for testing.
+ */
+static ssize_t inv_reg_dump_show(struct device *dev,
+			struct device_attribute *attr, char *buf)
+{
+	int ii;
+	char data;
+	int bytes_printed = 0;
+	struct iio_dev *indio_dev = dev_get_drvdata(dev);
+	struct inv_mpu_state *st = iio_priv(indio_dev);
+
+	mutex_lock(&indio_dev->mlock);
+	bytes_printed += snprintf(buf + bytes_printed, MAX_WR_SZ, "bank 0\n");
+
+	for (ii = 0; ii < 0x7F; ii++) {
+		/* don't read fifo r/w register */
+		if ((ii == REG_MEM_R_W) || (ii == REG_FIFO_R_W))
+			data = 0;
+		else
+			inv_plat_read(st, ii, 1, &data);
+		bytes_printed += snprintf(buf + bytes_printed, MAX_WR_SZ,
+				"%#2x: %#2x\n", ii, data);
+	}
+	set_inv_enable(indio_dev);
+	mutex_unlock(&indio_dev->mlock);
+
+	return bytes_printed;
+}
+
+static ssize_t inv_flush_batch_store(struct device *dev,
+			struct device_attribute *attr, const char *buf,
+			size_t count)
+{
+	struct iio_dev *indio_dev = dev_get_drvdata(dev);
+	int result, data;
+
+	result = kstrtoint(buf, 10, &data);
+	if (result)
+		return result;
+
+	mutex_lock(&indio_dev->mlock);
+	result = inv_flush_batch_data(indio_dev, data);
+	mutex_unlock(&indio_dev->mlock);
+
+	return count;
+}
+
+static const struct iio_chan_spec inv_mpu_channels[] = {
+	IIO_CHAN_SOFT_TIMESTAMP(INV_MPU_SCAN_TIMESTAMP),
+};
+
+/* special run time sysfs entry, read only */
+static DEVICE_ATTR(debug_reg_dump, S_IRUGO | S_IWUSR, inv_reg_dump_show, NULL);
+static DEVICE_ATTR(out_temperature, S_IRUGO | S_IWUSR,
+			inv_temperature_show, NULL);
+static DEVICE_ATTR(misc_self_test, S_IRUGO | S_IWUSR, inv_self_test, NULL);
+
+static IIO_DEVICE_ATTR(info_anglvel_matrix, S_IRUGO, inv_attr_show, NULL,
+			ATTR_GYRO_MATRIX);
+static IIO_DEVICE_ATTR(info_accel_matrix, S_IRUGO, inv_attr_show, NULL,
+			ATTR_ACCEL_MATRIX);
+
+static IIO_DEVICE_ATTR(info_gyro_sf, S_IRUGO, inv_attr_show, NULL,
+			ATTR_GYRO_SF);
+/* write only sysfs */
+static DEVICE_ATTR(misc_flush_batch, S_IWUSR, NULL, inv_flush_batch_store);
+
+/* sensor on/off sysfs control */
+static IIO_DEVICE_ATTR(in_accel_enable, S_IRUGO | S_IWUSR,
+			inv_sensor_on_show, inv_sensor_on_store, SENSOR_L_ACCEL);
+static IIO_DEVICE_ATTR(in_anglvel_enable, S_IRUGO | S_IWUSR,
+			inv_sensor_on_show, inv_sensor_on_store, SENSOR_L_GYRO);
+#ifndef SUPPORT_ONLY_BASIC_FEATURES
+static IIO_DEVICE_ATTR(in_eis_enable, S_IRUGO | S_IWUSR,
+			inv_sensor_on_show, inv_sensor_on_store,
+			SENSOR_L_EIS_GYRO);
+#endif
+static IIO_DEVICE_ATTR(in_accel_wake_enable, S_IRUGO | S_IWUSR,
+			inv_sensor_on_show, inv_sensor_on_store,
+			SENSOR_L_ACCEL_WAKE);
+static IIO_DEVICE_ATTR(in_anglvel_wake_enable, S_IRUGO | S_IWUSR,
+			inv_sensor_on_show, inv_sensor_on_store,
+			SENSOR_L_GYRO_WAKE);
+
+/* sensor rate sysfs control */
+static IIO_DEVICE_ATTR(in_accel_rate, S_IRUGO | S_IWUSR,
+			inv_sensor_rate_show, inv_sensor_rate_store,
+			SENSOR_L_ACCEL);
+static IIO_DEVICE_ATTR(in_anglvel_rate, S_IRUGO | S_IWUSR, inv_sensor_rate_show,
+			inv_sensor_rate_store, SENSOR_L_GYRO);
+#ifndef SUPPORT_ONLY_BASIC_FEATURES
+static IIO_DEVICE_ATTR(in_eis_rate, S_IRUGO | S_IWUSR,
+			inv_sensor_rate_show, inv_sensor_rate_store,
+			SENSOR_L_EIS_GYRO);
+#endif
+static IIO_DEVICE_ATTR(in_accel_wake_rate, S_IRUGO | S_IWUSR,
+			inv_sensor_rate_show, inv_sensor_rate_store,
+			SENSOR_L_ACCEL_WAKE);
+static IIO_DEVICE_ATTR(in_anglvel_wake_rate, S_IRUGO | S_IWUSR,
+			inv_sensor_rate_show, inv_sensor_rate_store,
+			SENSOR_L_GYRO_WAKE);
+
+static IIO_DEVICE_ATTR(misc_batchmode_timeout, S_IRUGO | S_IWUSR,
+			inv_attr_show, inv_basic_attr_store,
+			ATTR_DMP_BATCHMODE_TIMEOUT);
+
+/* engine scale */
+static IIO_DEVICE_ATTR(in_accel_scale, S_IRUGO | S_IWUSR, inv_attr_show,
+			inv_misc_attr_store, ATTR_ACCEL_SCALE);
+static IIO_DEVICE_ATTR(in_anglvel_scale, S_IRUGO | S_IWUSR, inv_attr_show,
+			inv_misc_attr_store, ATTR_GYRO_SCALE);
+
+
+#ifndef SUPPORT_ONLY_BASIC_FEATURES
+static IIO_DEVICE_ATTR(debug_lp_en_off, S_IRUGO | S_IWUSR, inv_attr_show,
+			inv_debug_store, ATTR_DMP_LP_EN_OFF);
+static IIO_DEVICE_ATTR(debug_clock_sel, S_IRUGO | S_IWUSR, inv_attr_show,
+			inv_debug_store, ATTR_DMP_CLK_SEL);
+static IIO_DEVICE_ATTR(debug_reg_write, S_IRUGO | S_IWUSR, inv_attr_show,
+			inv_debug_store, ATTR_DEBUG_REG_WRITE);
+static IIO_DEVICE_ATTR(debug_reg_write_addr, S_IRUGO | S_IWUSR, inv_attr_show,
+			inv_debug_store, ATTR_DEBUG_REG_ADDR);
+#endif
+
+static IIO_DEVICE_ATTR(in_accel_x_st_calibbias, S_IRUGO | S_IWUSR,
+			inv_attr_show, NULL, ATTR_ACCEL_X_ST_CALIBBIAS);
+static IIO_DEVICE_ATTR(in_accel_y_st_calibbias, S_IRUGO | S_IWUSR,
+			inv_attr_show, NULL, ATTR_ACCEL_Y_ST_CALIBBIAS);
+static IIO_DEVICE_ATTR(in_accel_z_st_calibbias, S_IRUGO | S_IWUSR,
+			inv_attr_show, NULL, ATTR_ACCEL_Z_ST_CALIBBIAS);
+
+static IIO_DEVICE_ATTR(in_anglvel_x_st_calibbias, S_IRUGO | S_IWUSR,
+			inv_attr_show, NULL, ATTR_ANGLVEL_X_ST_CALIBBIAS);
+static IIO_DEVICE_ATTR(in_anglvel_y_st_calibbias, S_IRUGO | S_IWUSR,
+			inv_attr_show, NULL, ATTR_ANGLVEL_Y_ST_CALIBBIAS);
+static IIO_DEVICE_ATTR(in_anglvel_z_st_calibbias, S_IRUGO | S_IWUSR,
+			inv_attr_show, NULL, ATTR_ANGLVEL_Z_ST_CALIBBIAS);
+
+static IIO_DEVICE_ATTR(in_accel_x_offset, S_IRUGO | S_IWUSR,
+			inv_attr_show, inv_bias_store, ATTR_ACCEL_X_OFFSET);
+static IIO_DEVICE_ATTR(in_accel_y_offset, S_IRUGO | S_IWUSR,
+			inv_attr_show, inv_bias_store, ATTR_ACCEL_Y_OFFSET);
+static IIO_DEVICE_ATTR(in_accel_z_offset, S_IRUGO | S_IWUSR,
+			inv_attr_show, inv_bias_store, ATTR_ACCEL_Z_OFFSET);
+
+static IIO_DEVICE_ATTR(in_anglvel_x_offset, S_IRUGO | S_IWUSR,
+			inv_attr_show, inv_bias_store, ATTR_GYRO_X_OFFSET);
+static IIO_DEVICE_ATTR(in_anglvel_y_offset, S_IRUGO | S_IWUSR,
+			inv_attr_show, inv_bias_store, ATTR_GYRO_Y_OFFSET);
+static IIO_DEVICE_ATTR(in_anglvel_z_offset, S_IRUGO | S_IWUSR,
+			inv_attr_show, inv_bias_store, ATTR_GYRO_Z_OFFSET);
+
+#ifndef SUPPORT_ONLY_BASIC_FEATURES
+static IIO_DEVICE_ATTR(in_step_detector_enable, S_IRUGO | S_IWUSR,
+			inv_attr_show, inv_basic_attr_store,
+			ATTR_DMP_STEP_DETECTOR_ON);
+static IIO_DEVICE_ATTR(in_step_detector_wake_enable, S_IRUGO | S_IWUSR,
+			inv_attr_show, inv_basic_attr_store,
+			ATTR_DMP_STEP_DETECTOR_WAKE_ON);
+static IIO_DEVICE_ATTR(in_step_counter_enable, S_IRUGO | S_IWUSR, inv_attr_show,
+			inv_basic_attr_store, ATTR_DMP_STEP_COUNTER_ON);
+static IIO_DEVICE_ATTR(in_step_counter_wake_enable, S_IRUGO | S_IWUSR,
+			inv_attr_show, inv_basic_attr_store,
+			ATTR_DMP_STEP_COUNTER_WAKE_ON);
+
+static IIO_DEVICE_ATTR(event_tilt_enable, S_IRUGO | S_IWUSR,
+			inv_attr_show, inv_basic_attr_store,
+			ATTR_DMP_TILT_ENABLE);
+
+static IIO_DEVICE_ATTR(event_eis_enable, S_IRUGO | S_IWUSR,
+			inv_attr_show, inv_basic_attr_store,
+			ATTR_DMP_EIS_ENABLE);
+
+static IIO_DEVICE_ATTR(event_pick_up_enable, S_IRUGO | S_IWUSR,
+			inv_attr_show, inv_basic_attr_store,
+			ATTR_DMP_PICK_UP_ENABLE);
+
+static IIO_DEVICE_ATTR(in_power_on, S_IRUGO | S_IWUSR,
+			inv_attr_show, inv_basic_attr_store,
+			ATTR_IN_POWER_ON);
+#endif
+
+static const struct attribute *inv_raw_attributes[] = {
+	&dev_attr_debug_reg_dump.attr,
+	&dev_attr_out_temperature.attr,
+	&dev_attr_misc_flush_batch.attr,
+	&dev_attr_misc_self_test.attr,
+#ifndef SUPPORT_ONLY_BASIC_FEATURES
+	&iio_dev_attr_in_power_on.dev_attr.attr,
+#endif
+	&iio_dev_attr_in_accel_enable.dev_attr.attr,
+	&iio_dev_attr_in_accel_wake_enable.dev_attr.attr,
+	&iio_dev_attr_info_accel_matrix.dev_attr.attr,
+	&iio_dev_attr_in_accel_scale.dev_attr.attr,
+	&iio_dev_attr_misc_batchmode_timeout.dev_attr.attr,
+	&iio_dev_attr_in_accel_rate.dev_attr.attr,
+	&iio_dev_attr_in_accel_wake_rate.dev_attr.attr,
+};
+
+#ifndef SUPPORT_ONLY_BASIC_FEATURES
+static const struct attribute *inv_debug_attributes[] = {
+	&iio_dev_attr_debug_lp_en_off.dev_attr.attr,
+	&iio_dev_attr_debug_clock_sel.dev_attr.attr,
+	&iio_dev_attr_debug_reg_write.dev_attr.attr,
+	&iio_dev_attr_debug_reg_write_addr.dev_attr.attr,
+};
+#endif
+
+static const struct attribute *inv_gyro_attributes[] = {
+	&iio_dev_attr_info_anglvel_matrix.dev_attr.attr,
+	&iio_dev_attr_in_anglvel_enable.dev_attr.attr,
+	&iio_dev_attr_in_anglvel_rate.dev_attr.attr,
+#ifndef SUPPORT_ONLY_BASIC_FEATURES
+	&iio_dev_attr_in_eis_enable.dev_attr.attr,
+#endif
+	&iio_dev_attr_in_anglvel_wake_enable.dev_attr.attr,
+	&iio_dev_attr_in_anglvel_scale.dev_attr.attr,
+#ifndef SUPPORT_ONLY_BASIC_FEATURES
+	&iio_dev_attr_in_eis_rate.dev_attr.attr,
+#endif
+	&iio_dev_attr_in_anglvel_wake_rate.dev_attr.attr,
+	&iio_dev_attr_info_gyro_sf.dev_attr.attr,
+};
+
+static const struct attribute *inv_bias_attributes[] = {
+	&iio_dev_attr_in_accel_x_st_calibbias.dev_attr.attr,
+	&iio_dev_attr_in_accel_y_st_calibbias.dev_attr.attr,
+	&iio_dev_attr_in_accel_z_st_calibbias.dev_attr.attr,
+	&iio_dev_attr_in_accel_x_offset.dev_attr.attr,
+	&iio_dev_attr_in_accel_y_offset.dev_attr.attr,
+	&iio_dev_attr_in_accel_z_offset.dev_attr.attr,
+	&iio_dev_attr_in_anglvel_x_st_calibbias.dev_attr.attr,
+	&iio_dev_attr_in_anglvel_y_st_calibbias.dev_attr.attr,
+	&iio_dev_attr_in_anglvel_z_st_calibbias.dev_attr.attr,
+	&iio_dev_attr_in_anglvel_x_offset.dev_attr.attr,
+	&iio_dev_attr_in_anglvel_y_offset.dev_attr.attr,
+	&iio_dev_attr_in_anglvel_z_offset.dev_attr.attr,
+};
+
+#ifndef SUPPORT_ONLY_BASIC_FEATURES
+static const struct attribute *inv_pedometer_attributes[] = {
+	&iio_dev_attr_event_tilt_enable.dev_attr.attr,
+	&iio_dev_attr_event_eis_enable.dev_attr.attr,
+	&iio_dev_attr_event_pick_up_enable.dev_attr.attr,
+	&iio_dev_attr_in_step_counter_enable.dev_attr.attr,
+	&iio_dev_attr_in_step_counter_wake_enable.dev_attr.attr,
+	&iio_dev_attr_in_step_detector_enable.dev_attr.attr,
+	&iio_dev_attr_in_step_detector_wake_enable.dev_attr.attr,
+};
+#endif
+
+static struct attribute *inv_attributes[ARRAY_SIZE(inv_raw_attributes) +
+#ifndef SUPPORT_ONLY_BASIC_FEATURES
+					ARRAY_SIZE(inv_debug_attributes) +
+#endif
+					ARRAY_SIZE(inv_gyro_attributes) +
+					ARRAY_SIZE(inv_bias_attributes) +
+#ifndef SUPPORT_ONLY_BASIC_FEATURES
+					ARRAY_SIZE(inv_pedometer_attributes) +
+#endif
+					 + 1];
+
+static const struct attribute_group inv_attribute_group = {
+	.name = "mpu",
+	.attrs = inv_attributes
+};
+
+static const struct iio_info mpu_info = {
+	.driver_module = THIS_MODULE,
+	.attrs = &inv_attribute_group,
+};
+
+/*
+ *  inv_check_chip_type() - check and setup chip type.
+ */
+int inv_check_chip_type(struct iio_dev *indio_dev, const char *name)
+{
+	int result;
+	int t_ind;
+	struct inv_chip_config_s *conf;
+	struct mpu_platform_data *plat;
+	struct inv_mpu_state *st;
+
+	st = iio_priv(indio_dev);
+	conf = &st->chip_config;
+	plat = &st->plat_data;
+
+	if (!strcmp(name, "iam20680"))
+		st->chip_type = IAM20680;
+	else
+		return -EPERM;
+	st->chip_config.has_gyro = 1;
+
+	st->hw = &hw_info[st->chip_type];
+	result = inv_mpu_initialize(st);
+	if (result)
+		return result;
+
+	t_ind = 0;
+	memcpy(&inv_attributes[t_ind], inv_raw_attributes,
+				sizeof(inv_raw_attributes));
+	t_ind += ARRAY_SIZE(inv_raw_attributes);
+
+#ifndef SUPPORT_ONLY_BASIC_FEATURES
+	memcpy(&inv_attributes[t_ind], inv_pedometer_attributes,
+				sizeof(inv_pedometer_attributes));
+	t_ind += ARRAY_SIZE(inv_pedometer_attributes);
+#endif
+
+	memcpy(&inv_attributes[t_ind], inv_gyro_attributes,
+				sizeof(inv_gyro_attributes));
+	t_ind += ARRAY_SIZE(inv_gyro_attributes);
+
+	memcpy(&inv_attributes[t_ind], inv_bias_attributes,
+				sizeof(inv_bias_attributes));
+	t_ind += ARRAY_SIZE(inv_bias_attributes);
+
+#ifndef SUPPORT_ONLY_BASIC_FEATURES
+	memcpy(&inv_attributes[t_ind], inv_debug_attributes,
+				sizeof(inv_debug_attributes));
+	t_ind += ARRAY_SIZE(inv_debug_attributes);
+#endif
+
+	inv_attributes[t_ind] = NULL;
+
+	indio_dev->channels = inv_mpu_channels;
+	indio_dev->num_channels = ARRAY_SIZE(inv_mpu_channels);
+
+	indio_dev->info = &mpu_info;
+	indio_dev->modes = INDIO_DIRECT_MODE;
+	indio_dev->currentmode = INDIO_DIRECT_MODE;
+
+	return result;
+}
+EXPORT_SYMBOL_GPL(inv_check_chip_type);
+
+int inv_create_dmp_sysfs(struct iio_dev *ind)
+{
+	// dummy
+	return 0;
+}
+EXPORT_SYMBOL_GPL(inv_create_dmp_sysfs);
+
+MODULE_AUTHOR("Invensense Corporation");
+MODULE_DESCRIPTION("Invensense device ICM20xxx driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/iio/imu/inv_mpu/iam20680/inv_mpu_iio_reg_20680.h b/drivers/iio/imu/inv_mpu/iam20680/inv_mpu_iio_reg_20680.h
new file mode 100644
index 0000000..3f8ce71
--- /dev/null
+++ b/drivers/iio/imu/inv_mpu/iam20680/inv_mpu_iio_reg_20680.h
@@ -0,0 +1,236 @@
+/*
+ * Copyright (C) 2017-2018 InvenSense, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef _INV_MPU_IIO_REG_20680_H_
+#define _INV_MPU_IIO_REG_20680_H_
+
+/* Uncomment when HAL does not support the algorithm library
+ * for calibration and sensor fusion not to expose unused
+ * sysfs entries */
+#define SUPPORT_ONLY_BASIC_FEATURES
+
+/* Uncomment to read data registers for sensor data instead of FIFO */
+//#define SENSOR_DATA_FROM_REGISTERS
+
+/* Uncomment to enable timer based batching */
+#define TIMER_BASED_BATCHING
+
+/* Polling (batch mode) can be enabled only when FIFO read */
+#if defined(SENSOR_DATA_FROM_REGISTERS)
+#undef TIMER_BASED_BATCHING
+#endif
+
+/*register and associated bit definition*/
+#define REG_XA_OFFS_H		0x77
+#define REG_YA_OFFS_H		0x7A
+#define REG_ZA_OFFS_H           0x7D
+#define REG_XG_OFFS_USR_H        0x13
+#define REG_YG_OFFS_USR_H        0x15
+#define REG_ZG_OFFS_USR_H        0x17
+#define REG_SAMPLE_RATE_DIV     0x19
+
+#define REG_CONFIG              0x1A
+#define EXT_SYNC_SET                      8
+
+#define REG_GYRO_CONFIG		0x1B
+#define BITS_SELF_TEST_EN		0xE0
+#define SHIFT_GYRO_FS_SEL		0x03
+
+#define REG_ACCEL_CONFIG	0x1C
+#define SHIFT_ACCEL_FS			0x03
+
+#define REG_LP_MODE_CTRL	0x1E
+#define BIT_GYRO_CYCLE_EN               0x80
+
+#define REG_ACCEL_WOM_THR	0x1F
+#define REG_ACCEL_WOM_X_THR	0x20
+#define REG_ACCEL_WOM_Y_THR	0x21
+#define REG_ACCEL_WOM_Z_THR	0x22
+
+#define REG_ACCEL_MOT_THR       0x1F
+#define REG_ACCEL_MOT_DUR       0x20
+
+#define REG_ACCEL_CONFIG_2  0x1D
+#define BIT_ACCEL_FCHOCIE_B              0x08
+
+#define REG_FIFO_EN			0x23
+#define BITS_GYRO_FIFO_EN	0x70
+#define BIT_ACCEL_FIFO_EN	0x08
+
+#define REG_FSYNC_INT		0x36
+#define BIT_FSYNC_INT                   0x80
+
+#define REG_INT_PIN_CFG		0x37
+
+#define REG_INT_ENABLE		0x38
+#define BIT_WOM_X_INT_EN		0x80
+#define BIT_WOM_Y_INT_EN		0x40
+#define BIT_WOM_Z_INT_EN		0x20
+#define BIT_WOM_ALL_INT_EN		0xE0
+#define BIT_FSYNC_INT_EN		0x8
+#define BIT_DATA_RDY_EN		        0x1
+
+#define REG_INT_STATUS          0x3A
+#define BIT_WOM_X_INT                  0x80
+#define BIT_WOM_Y_INT                  0x40
+#define BIT_WOM_Z_INT                  0x20
+
+#define REG_RAW_ACCEL           0x3B
+#define REG_RAW_TEMP            0x41
+#define REG_RAW_GYRO            0x43
+#define REG_EXT_SENS_DATA_00    0x49
+#define REG_EXT_SENS_DATA_08    0x51
+#define REG_EXT_SENS_DATA_09    0x52
+
+#define REG_ACCEL_INTEL_CTRL 0x69
+#define BIT_ACCEL_INTEL_EN              0x80
+#define BIT_ACCEL_INTEL_MODE            0x40
+
+#define REG_USER_CTRL			0x6A
+#define BIT_COND_RST				0x01
+#define BIT_FIFO_RST				0x04
+#define BIT_FIFO_EN				0x40
+
+#define REG_PWR_MGMT_1			0x6B
+#define BIT_H_RESET				0x80
+#define BIT_SLEEP					0x40
+#define BIT_LP_EN                       	0x20
+#define BIT_CLK_PLL				0x01
+#define BIT_CLK_MASK				0x07
+
+#define REG_PWR_MGMT_2			0x6C
+#define BIT_PWR_ACCEL_STBY		0x38
+#define BIT_PWR_GYRO_STBY		0x07
+#define BIT_PWR_ALL_OFF			0x3F
+#define BIT_FIFO_LP_EN			0x80
+
+#define REG_MEM_BANK_SEL	0x6D
+#define REG_MEM_START_ADDR	0x6E
+#define REG_MEM_R_W		0x6F
+
+#define REG_FIFO_COUNT_H        0x72
+#define REG_FIFO_R_W            0x74
+#define REG_WHO_AM_I              0x75
+
+#define REG_6500_XG_ST_DATA     0x50
+#define REG_6500_XA_ST_DATA     0xD
+#define REG_6500_XA_OFFS_H      0x77
+#define REG_6500_YA_OFFS_H      0x7A
+#define REG_6500_ZA_OFFS_H      0x7D
+#define REG_6500_ACCEL_CONFIG2  0x1D
+#define BIT_ACCEL_FCHOCIE_B              0x08
+#define BIT_FIFO_SIZE_1K                 0x40
+
+#define REG_LP_MODE_CFG		0x1E
+
+#define REG_6500_LP_ACCEL_ODR   0x1E
+#define REG_6500_ACCEL_WOM_THR  0x1F
+
+/* data output control reg 2 */
+#define ACCEL_ACCURACY_SET  0x4000
+#define GYRO_ACCURACY_SET   0x2000
+#define CPASS_ACCURACY_SET  0x1000
+
+/* data definitions */
+#define ACCEL_COVARIANCE 0
+#define BYTES_PER_SENSOR         6
+#define BYTES_FOR_TEMP           2
+#define FIFO_COUNT_BYTE          2
+#define HARDWARE_FIFO_SIZE       512
+#define FIFO_SIZE                (HARDWARE_FIFO_SIZE * 7 / 10)
+#define POWER_UP_TIME            100
+#define REG_UP_TIME_USEC         100
+#define LEFT_OVER_BYTES          128
+#define IIO_BUFFER_BYTES         8
+#define BASE_SAMPLE_RATE         1000
+#define DRY_RUN_TIME             50
+#define INV_IAM20680_GYRO_START_TIME 35
+#define INV_IAM20680_ACCEL_START_TIME 30
+#define MODE_1K_INIT_SAMPLE      5
+#define FIRST_SAMPLE_BUF_MS      30
+
+#ifdef BIAS_CONFIDENCE_HIGH
+#define DEFAULT_ACCURACY         3
+#else
+#define DEFAULT_ACCURACY         1
+#endif
+
+/* temperature */
+#define TEMP_SENSITIVITY        32680   // 326.8 LSB/degC * 100
+#define TEMP_OFFSET             2500    // 25 degC * 100
+
+/* enum for sensor */
+enum INV_SENSORS {
+	SENSOR_ACCEL = 0,
+	SENSOR_TEMP,
+	SENSOR_GYRO,
+	SENSOR_COMPASS,
+	SENSOR_NUM_MAX,
+	SENSOR_INVALID,
+};
+
+enum inv_filter_e {
+	INV_FILTER_256HZ_NOLPF2 = 0,
+	INV_FILTER_188HZ,
+	INV_FILTER_98HZ,
+	INV_FILTER_42HZ,
+	INV_FILTER_20HZ,
+	INV_FILTER_10HZ,
+	INV_FILTER_5HZ,
+	INV_FILTER_2100HZ_NOLPF,
+	NUM_FILTER
+};
+
+#define MPU_DEFAULT_DMP_FREQ     200
+#define PEDOMETER_FREQ           (MPU_DEFAULT_DMP_FREQ >> 2)
+#define SENSOR_FUSION_MIN_RATE   100
+#define GESTURE_ACCEL_RATE       50
+#define ESI_GYRO_RATE            1000
+#define MAX_FIFO_PACKET_READ     6
+#define MAX_BATCH_FIFO_SIZE      FIFO_SIZE
+
+#define MIN_MST_ODR_CONFIG       4
+#define MAX_MST_ODR_CONFIG       5
+/* initial rate is important. For non-DMP mode, it is set as 4 1000/256*/
+#define MPU_INIT_SENSOR_RATE     4
+#define MAX_MST_NON_COMPASS_ODR_CONFIG 7
+#define THREE_AXES               3
+#define NINE_ELEM                (THREE_AXES * THREE_AXES)
+#define MPU_TEMP_SHIFT           16
+
+#define DMP_DIVIDER              (BASE_SAMPLE_RATE / MPU_DEFAULT_DMP_FREQ)
+#define DEFAULT_BATCH_RATE       400
+#define DEFAULT_BATCH_TIME    (MSEC_PER_SEC / DEFAULT_BATCH_RATE)
+
+#define TEMPERATURE_SCALE  3340827L
+#define TEMPERATURE_OFFSET 1376256L
+#define SECONDARY_INIT_WAIT 100
+#define MPU_SOFT_REV_ADDR               0x86
+#define MPU_SOFT_REV_MASK               0xf
+#define SW_REV_LP_EN_MODE               4
+
+/* data limit definitions */
+#define MIN_FIFO_RATE            4
+#define MAX_FIFO_RATE            MPU_DEFAULT_DMP_FREQ
+
+#define MAX_MPU_MEM              8192
+#define MAX_PRS_RATE             281
+
+enum inv_devices {
+	ICM20608D,
+	ICM20690,
+	ICM20602,
+	IAM20680,
+	INV_NUM_PARTS,
+};
+#endif
diff --git a/drivers/iio/imu/inv_mpu/iam20680/inv_mpu_init_20680.c b/drivers/iio/imu/inv_mpu/iam20680/inv_mpu_init_20680.c
new file mode 100644
index 0000000..58bd8d0
--- /dev/null
+++ b/drivers/iio/imu/inv_mpu/iam20680/inv_mpu_init_20680.c
@@ -0,0 +1,258 @@
+/*
+ * Copyright (C) 2017-2018 InvenSense, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#define pr_fmt(fmt) "inv_mpu: " fmt
+#include "../inv_mpu_iio.h"
+
+static int inv_calc_gyro_sf(s8 pll)
+{
+	int a, r;
+	int value, t;
+
+	t = 102870L + 81L * pll;
+	a = (1L << 30) / t;
+	r = (1L << 30) - a * t;
+	value = a * 797 * DMP_DIVIDER;
+	value += (s64) ((a * 1011387LL * DMP_DIVIDER) >> 20);
+	value += r * 797L * DMP_DIVIDER / t;
+	value += (s32) ((s64) ((r * 1011387LL * DMP_DIVIDER) >> 20)) / t;
+	value <<= 1;
+
+	return value;
+}
+
+static int inv_read_timebase(struct inv_mpu_state *st)
+{
+
+	inv_plat_single_write(st, REG_CONFIG, 3);
+
+	st->eng_info[ENGINE_ACCEL].base_time = NSEC_PER_SEC;
+	st->eng_info[ENGINE_ACCEL].base_time_1k = NSEC_PER_SEC;
+	/* talor expansion to calculate base time unit */
+	st->eng_info[ENGINE_GYRO].base_time = NSEC_PER_SEC;
+	st->eng_info[ENGINE_GYRO].base_time_1k = NSEC_PER_SEC;
+	st->eng_info[ENGINE_I2C].base_time = NSEC_PER_SEC;
+	st->eng_info[ENGINE_I2C].base_time_1k = NSEC_PER_SEC;
+
+	st->eng_info[ENGINE_ACCEL].orig_rate = BASE_SAMPLE_RATE;
+	st->eng_info[ENGINE_GYRO].orig_rate = BASE_SAMPLE_RATE;
+	st->eng_info[ENGINE_I2C].orig_rate = BASE_SAMPLE_RATE;
+
+	st->gyro_sf = inv_calc_gyro_sf(0);
+
+	return 0;
+}
+
+int inv_set_gyro_sf(struct inv_mpu_state *st)
+{
+	int result;
+
+	result = inv_plat_single_write(st, REG_GYRO_CONFIG,
+				   st->chip_config.fsr << SHIFT_GYRO_FS_SEL);
+
+	return result;
+}
+
+int inv_set_accel_sf(struct inv_mpu_state *st)
+{
+	int result;
+
+	result = inv_plat_single_write(st, REG_ACCEL_CONFIG,
+				st->chip_config.accel_fs << SHIFT_ACCEL_FS);
+	return result;
+}
+
+// dummy for 20602
+int inv_set_accel_intel(struct inv_mpu_state *st)
+{
+	return 0;
+}
+
+static void inv_init_sensor_struct(struct inv_mpu_state *st)
+{
+	int i;
+
+	for (i = 0; i < SENSOR_NUM_MAX; i++)
+		st->sensor[i].rate = MPU_INIT_SENSOR_RATE;
+
+	st->sensor[SENSOR_ACCEL].sample_size = BYTES_PER_SENSOR;
+	st->sensor[SENSOR_TEMP].sample_size = BYTES_FOR_TEMP;
+	st->sensor[SENSOR_GYRO].sample_size = BYTES_PER_SENSOR;
+
+	st->sensor_l[SENSOR_L_SIXQ].base = SENSOR_GYRO;
+	st->sensor_l[SENSOR_L_PEDQ].base = SENSOR_GYRO;
+
+	st->sensor_l[SENSOR_L_SIXQ_WAKE].base = SENSOR_GYRO;
+	st->sensor_l[SENSOR_L_PEDQ_WAKE].base = SENSOR_GYRO;
+
+	st->sensor[SENSOR_ACCEL].a_en = true;
+	st->sensor[SENSOR_GYRO].a_en = false;
+
+	st->sensor[SENSOR_ACCEL].g_en = false;
+	st->sensor[SENSOR_GYRO].g_en = true;
+
+	st->sensor[SENSOR_ACCEL].c_en = false;
+	st->sensor[SENSOR_GYRO].c_en = false;
+
+	st->sensor[SENSOR_ACCEL].p_en = false;
+	st->sensor[SENSOR_GYRO].p_en = false;
+
+	st->sensor[SENSOR_ACCEL].engine_base = ENGINE_ACCEL;
+	st->sensor[SENSOR_GYRO].engine_base = ENGINE_GYRO;
+
+	st->sensor_l[SENSOR_L_ACCEL].base = SENSOR_ACCEL;
+	st->sensor_l[SENSOR_L_GESTURE_ACCEL].base = SENSOR_ACCEL;
+	st->sensor_l[SENSOR_L_GYRO].base = SENSOR_GYRO;
+	st->sensor_l[SENSOR_L_GYRO_CAL].base = SENSOR_GYRO;
+	st->sensor_l[SENSOR_L_EIS_GYRO].base = SENSOR_GYRO;
+
+	st->sensor_l[SENSOR_L_ACCEL_WAKE].base = SENSOR_ACCEL;
+	st->sensor_l[SENSOR_L_GYRO_WAKE].base = SENSOR_GYRO;
+
+	st->sensor_l[SENSOR_L_GYRO_CAL_WAKE].base = SENSOR_GYRO;
+
+	st->sensor_l[SENSOR_L_ACCEL].header = ACCEL_HDR;
+	st->sensor_l[SENSOR_L_GESTURE_ACCEL].header = ACCEL_HDR;
+	st->sensor_l[SENSOR_L_GYRO].header = GYRO_HDR;
+	st->sensor_l[SENSOR_L_GYRO_CAL].header = GYRO_CALIB_HDR;
+
+	st->sensor_l[SENSOR_L_EIS_GYRO].header = EIS_GYRO_HDR;
+	st->sensor_l[SENSOR_L_SIXQ].header = SIXQUAT_HDR;
+	st->sensor_l[SENSOR_L_THREEQ].header = LPQ_HDR;
+	st->sensor_l[SENSOR_L_NINEQ].header = NINEQUAT_HDR;
+	st->sensor_l[SENSOR_L_PEDQ].header = PEDQUAT_HDR;
+
+	st->sensor_l[SENSOR_L_ACCEL_WAKE].header = ACCEL_WAKE_HDR;
+	st->sensor_l[SENSOR_L_GYRO_WAKE].header = GYRO_WAKE_HDR;
+	st->sensor_l[SENSOR_L_GYRO_CAL_WAKE].header = GYRO_CALIB_WAKE_HDR;
+	st->sensor_l[SENSOR_L_MAG_WAKE].header = COMPASS_WAKE_HDR;
+	st->sensor_l[SENSOR_L_MAG_CAL_WAKE].header = COMPASS_CALIB_WAKE_HDR;
+	st->sensor_l[SENSOR_L_SIXQ_WAKE].header = SIXQUAT_WAKE_HDR;
+	st->sensor_l[SENSOR_L_NINEQ_WAKE].header = NINEQUAT_WAKE_HDR;
+	st->sensor_l[SENSOR_L_PEDQ_WAKE].header = PEDQUAT_WAKE_HDR;
+
+	st->sensor_l[SENSOR_L_ACCEL].wake_on = false;
+	st->sensor_l[SENSOR_L_GYRO].wake_on = false;
+	st->sensor_l[SENSOR_L_GYRO_CAL].wake_on = false;
+	st->sensor_l[SENSOR_L_MAG].wake_on = false;
+	st->sensor_l[SENSOR_L_MAG_CAL].wake_on = false;
+	st->sensor_l[SENSOR_L_EIS_GYRO].wake_on = false;
+	st->sensor_l[SENSOR_L_SIXQ].wake_on = false;
+	st->sensor_l[SENSOR_L_NINEQ].wake_on = false;
+	st->sensor_l[SENSOR_L_PEDQ].wake_on = false;
+
+	st->sensor_l[SENSOR_L_ACCEL_WAKE].wake_on = true;
+	st->sensor_l[SENSOR_L_GYRO_WAKE].wake_on = true;
+	st->sensor_l[SENSOR_L_GYRO_CAL_WAKE].wake_on = true;
+	st->sensor_l[SENSOR_L_MAG_WAKE].wake_on = true;
+	st->sensor_l[SENSOR_L_SIXQ_WAKE].wake_on = true;
+	st->sensor_l[SENSOR_L_NINEQ_WAKE].wake_on = true;
+	st->sensor_l[SENSOR_L_PEDQ_WAKE].wake_on = true;
+}
+
+static int inv_init_config(struct inv_mpu_state *st)
+{
+	int res, i;
+
+	st->batch.overflow_on = 0;
+	st->chip_config.fsr = MPU_INIT_GYRO_SCALE;
+	st->chip_config.accel_fs = MPU_INIT_ACCEL_SCALE;
+	st->ped.int_thresh = MPU_INIT_PED_INT_THRESH;
+	st->ped.step_thresh = MPU_INIT_PED_STEP_THRESH;
+	st->chip_config.low_power_gyro_on = 1;
+	st->eis.count_precision = NSEC_PER_MSEC;
+	st->firmware = 0;
+	st->fifo_count_mode = BYTE_MODE;
+#ifdef TIMER_BASED_BATCHING
+	st->batch_timeout = 0;
+	st->is_batch_timer_running = false;
+#endif
+
+	st->eng_info[ENGINE_GYRO].base_time = NSEC_PER_SEC;
+	st->eng_info[ENGINE_ACCEL].base_time = NSEC_PER_SEC;
+
+	inv_init_sensor_struct(st);
+	res = inv_read_timebase(st);
+	if (res)
+		return res;
+
+	res = inv_set_gyro_sf(st);
+	if (res)
+		return res;
+	res = inv_set_accel_sf(st);
+	if (res)
+		return res;
+	res =  inv_set_accel_intel(st);
+	if (res)
+		return res;
+
+	for (i = 0; i < SENSOR_NUM_MAX; i++)
+		st->sensor[i].ts = 0;
+
+	for (i = 0; i < SENSOR_NUM_MAX; i++)
+		st->sensor[i].previous_ts = 0;
+
+	return res;
+}
+
+int inv_mpu_initialize(struct inv_mpu_state *st)
+{
+	u8 v;
+	int result;
+	struct inv_chip_config_s *conf;
+	struct mpu_platform_data *plat;
+
+	conf = &st->chip_config;
+	plat = &st->plat_data;
+
+	/* verify whoami */
+	result = inv_plat_read(st, REG_WHO_AM_I, 1, &v);
+	if (result)
+		return result;
+	pr_info("whoami= %x\n", v);
+	if (v == 0x00 || v == 0xff)
+		return -ENODEV;
+
+	/* reset to make sure previous state are not there */
+	result = inv_plat_single_write(st, REG_PWR_MGMT_1, BIT_H_RESET);
+	if (result)
+		return result;
+	usleep_range(REG_UP_TIME_USEC, REG_UP_TIME_USEC);
+	msleep(100);
+	/* toggle power state */
+	result = inv_set_power(st, false);
+	if (result)
+		return result;
+	result = inv_set_power(st, true);
+	if (result)
+		return result;
+
+	result = inv_plat_single_write(st, REG_USER_CTRL, st->i2c_dis);
+	if (result)
+		return result;
+	result = inv_init_config(st);
+	if (result)
+		return result;
+
+	result = mem_r(MPU_SOFT_REV_ADDR, 1, &v);
+	pr_info("sw_rev=%x, res=%d\n", v, result);
+	if (result)
+		return result;
+	st->chip_config.lp_en_mode_off = 0;
+
+	pr_info("%s: Mask %X, v = %X, lp mode = %d\n", __func__,
+		MPU_SOFT_REV_MASK, v, st->chip_config.lp_en_mode_off);
+	result = inv_set_power(st, false);
+
+	pr_info("%s: initialize result is %d....\n", __func__, result);
+	return 0;
+}
diff --git a/drivers/iio/imu/inv_mpu/iam20680/inv_mpu_parsing_20680.c b/drivers/iio/imu/inv_mpu/iam20680/inv_mpu_parsing_20680.c
new file mode 100644
index 0000000..0f17b6d
--- /dev/null
+++ b/drivers/iio/imu/inv_mpu/iam20680/inv_mpu_parsing_20680.c
@@ -0,0 +1,421 @@
+/*
+ * Copyright (C) 2017-2018 InvenSense, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#define pr_fmt(fmt) "inv_mpu: " fmt
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/err.h>
+#include <linux/delay.h>
+#include <linux/sysfs.h>
+#include <linux/jiffies.h>
+#include <linux/irq.h>
+#include <linux/interrupt.h>
+#include <linux/kfifo.h>
+#include <linux/poll.h>
+#include <linux/miscdevice.h>
+#include <linux/math64.h>
+
+#include "../inv_mpu_iio.h"
+
+static char iden[] = { 1, 0, 0, 0, 1, 0, 0, 0, 1 };
+
+static int inv_process_gyro(struct inv_mpu_state *st, u8 *d, u64 t)
+{
+	s16 raw[3];
+	s32 calib[3];
+	int i;
+#define BIAS_UNIT 2859
+
+	for (i = 0; i < 3; i++)
+		raw[i] = be16_to_cpup((__be16 *) (d + i * 2));
+
+	for (i = 0; i < 3; i++)
+		calib[i] = (raw[i] << 15);
+
+
+	inv_push_gyro_data(st, raw, calib, t);
+
+	return 0;
+}
+
+static int inv_check_fsync(struct inv_mpu_state *st, u8 fsync_status)
+{
+	u8 data[1];
+
+	if (!st->chip_config.eis_enable)
+		return 0;
+	inv_plat_read(st, REG_FSYNC_INT, 1, data);
+	if (data[0] & BIT_FSYNC_INT) {
+		pr_debug("fsync\n");
+		st->eis.eis_triggered = true;
+		st->eis.fsync_delay = 1;
+		st->eis.prev_state = 1;
+		st->eis.frame_count++;
+		st->eis.eis_frame = true;
+	}
+	st->header_count--;
+
+	return 0;
+}
+
+static int inv_push_sensor(struct inv_mpu_state *st, int ind, u64 t, u8 *d)
+{
+#ifdef ACCEL_BIAS_TEST
+	s16 acc[3], avg[3];
+#endif
+
+	switch (ind) {
+	case SENSOR_ACCEL:
+		inv_convert_and_push_8bytes(st, ind, d, t, iden);
+#ifdef ACCEL_BIAS_TEST
+		acc[0] = be16_to_cpup((__be16 *) (d));
+		acc[1] = be16_to_cpup((__be16 *) (d + 2));
+		acc[2] = be16_to_cpup((__be16 *) (d + 4));
+		if(inv_get_3axis_average(acc, avg, 0)){
+			pr_debug("accel 200 samples average = %5d, %5d, %5d\n", avg[0], avg[1], avg[2]);
+		}
+#endif
+		break;
+	case SENSOR_TEMP:
+		inv_check_fsync(st, d[1]);
+		break;
+	case SENSOR_GYRO:
+		inv_process_gyro(st, d, t);
+		break;
+	default:
+		break;
+	}
+
+	return 0;
+}
+
+static int inv_push_20680_data(struct inv_mpu_state *st, u8 *d)
+{
+	u8 *dptr;
+	int i;
+
+	dptr = d;
+
+	for (i = 0; i < SENSOR_NUM_MAX; i++) {
+		if (st->sensor[i].on) {
+			inv_get_dmp_ts(st, i);
+			if (st->sensor[i].send && (!st->ts_algo.first_sample)) {
+				st->sensor[i].sample_calib++;
+				inv_push_sensor(st, i, st->sensor[i].ts, dptr);
+			}
+			dptr += st->sensor[i].sample_size;
+		}
+	}
+	if (st->ts_algo.first_sample)
+		st->ts_algo.first_sample--;
+	st->header_count--;
+
+	return 0;
+}
+
+static int inv_process_20680_data(struct inv_mpu_state *st)
+{
+	int total_bytes, tmp, res, fifo_count, pk_size, i;
+	u8 *dptr, *d;
+	u8 data[14];
+	bool done_flag;
+	u8 v;
+#ifdef SENSOR_DATA_FROM_REGISTERS
+	u8 reg;
+	int len;
+#endif
+
+	if(st->gesture_only_on && (!st->batch.timeout)) {
+		res = inv_plat_read(st, REG_INT_STATUS, 1, data);
+		if (res)
+			return res;
+		pr_debug("ges cnt=%d, statu=%x\n",
+						st->gesture_int_count, data[0]);
+		if (data[0] & (BIT_WOM_ALL_INT_EN)) {
+			if (!st->gesture_int_count) {
+				inv_switch_power_in_lp(st, true);
+				res = inv_plat_single_write(st, REG_INT_ENABLE,
+					BIT_WOM_ALL_INT_EN | BIT_DATA_RDY_EN);
+				if (res)
+					return res;
+				v = 0;
+				if (st->chip_config.gyro_enable)
+					v |= BITS_GYRO_FIFO_EN;
+
+				if (st->chip_config.accel_enable)
+					v |= BIT_ACCEL_FIFO_EN;
+				res = inv_plat_single_write(st, REG_FIFO_EN, v);
+				if (res)
+					return res;
+				/* First time wake up from WOM.
+					We don't need data in the FIFO */
+				res = inv_reset_fifo(st, true);
+				if (res)
+					return res;
+				res = inv_switch_power_in_lp(st, false);
+				st->gesture_int_count = WOM_DELAY_THRESHOLD;
+
+				return res;
+			}
+			st->gesture_int_count = WOM_DELAY_THRESHOLD;
+		} else {
+			if (!st->gesture_int_count) {
+				inv_switch_power_in_lp(st, true);
+				res = inv_plat_single_write(st, REG_FIFO_EN, 0);
+				res = inv_plat_single_write(st, REG_INT_ENABLE,
+					BIT_WOM_ALL_INT_EN);
+				inv_switch_power_in_lp(st, false);
+
+				return res;
+			}
+			st->gesture_int_count--;
+		}
+	}
+
+	fifo_count = inv_get_last_run_time_non_dmp_record_mode(st);
+	pr_debug("fifc= %d\n", fifo_count);
+	if (!fifo_count) {
+		pr_debug("REG_FIFO_COUNT_H size is 0\n");
+		return 0;
+	}
+	pk_size = st->batch.pk_size;
+	if (!pk_size)
+		return -EINVAL;
+
+	if (fifo_count >= (HARDWARE_FIFO_SIZE / st->batch.pk_size)) {
+		pr_warn("fifo overflow pkt count=%d pkt sz=%d\n", fifo_count, st->batch.pk_size);
+		return -EOVERFLOW;
+	}
+
+	fifo_count *= st->batch.pk_size;
+	st->fifo_count = fifo_count;
+	d = st->fifo_data_store;
+	dptr = d;
+	total_bytes = fifo_count;
+
+#ifdef SENSOR_DATA_FROM_REGISTERS
+	len = 0;
+	if (st->sensor[SENSOR_GYRO].on) {
+		reg = REG_RAW_GYRO;
+		len += BYTES_PER_SENSOR;
+		if (st->sensor[SENSOR_ACCEL].on && !st->sensor[SENSOR_TEMP].on)
+			len += BYTES_FOR_TEMP;
+	}
+	if (st->sensor[SENSOR_TEMP].on) {
+		reg = REG_RAW_TEMP;
+		len += BYTES_FOR_TEMP;
+	}
+	if (st->sensor[SENSOR_ACCEL].on) {
+		reg = REG_RAW_ACCEL;
+		len += BYTES_PER_SENSOR;
+	}
+
+	if (len == 0) {
+		pr_debug("No sensor is enabled\n");
+		return 0;
+	}
+
+	/* read data registers */
+	res = inv_plat_read(st, reg, len, data);
+	if (res < 0) {
+		pr_err("read data registers is failed\n");
+		return res;
+	}
+
+	/* copy sensor data to buffer as FIFO data format */
+	tmp = 0;
+	if (st->sensor[SENSOR_ACCEL].on) {
+		for (i = 0; i < BYTES_PER_SENSOR; i++)
+			dptr[i] = data[tmp + i];
+		dptr += BYTES_PER_SENSOR;
+		tmp += BYTES_PER_SENSOR;
+	}
+
+	if (st->sensor[SENSOR_TEMP].on) {
+		for (i = 0; i < BYTES_FOR_TEMP; i++)
+			dptr[i] = data[tmp + i];
+		dptr += BYTES_FOR_TEMP;
+		tmp += BYTES_FOR_TEMP;
+	}
+
+	if (st->sensor[SENSOR_GYRO].on) {
+		if (st->sensor[SENSOR_ACCEL].on && !st->sensor[SENSOR_TEMP].on)
+			tmp += BYTES_FOR_TEMP;
+		for (i = 0; i < BYTES_PER_SENSOR; i++)
+			dptr[i] = data[tmp + i];
+	}
+#else
+	while (total_bytes > 0) {
+		if (total_bytes < pk_size * MAX_FIFO_PACKET_READ)
+			tmp = total_bytes;
+		else
+			tmp = pk_size * MAX_FIFO_PACKET_READ;
+		res = inv_plat_read(st, REG_FIFO_R_W, tmp, dptr);
+		if (res < 0) {
+			pr_err("read REG_FIFO_R_W is failed\n");
+			return res;
+		}
+		pr_debug("inside: %x, %x, %x, %x, %x, %x, %x, %x\n", dptr[0], dptr[1], dptr[2],
+						dptr[3], dptr[4], dptr[5], dptr[6], dptr[7]);
+		pr_debug("insid2: %x, %x, %x, %x, %x, %x, %x, %x\n", dptr[8], dptr[9], dptr[10],
+						dptr[11], dptr[12], dptr[13], dptr[14], dptr[15]);
+
+		dptr += tmp;
+		total_bytes -= tmp;
+	}
+#endif /* SENSOR_DATA_FROM_REGISTERS */
+	dptr = d;
+	pr_debug("dd: %x, %x, %x, %x, %x, %x, %x, %x\n", d[0], d[1], d[2],
+						d[3], d[4], d[5], d[6], d[7]);
+	pr_debug("dd2: %x, %x, %x, %x, %x, %x, %x, %x\n", d[8], d[9], d[10],
+					d[11], d[12], d[13], d[14], d[15]);
+	total_bytes = fifo_count;
+
+	for (i = 0; i < SENSOR_NUM_MAX; i++) {
+		if (st->sensor[i].on) {
+			st->sensor[i].count =  total_bytes / pk_size;
+		}
+	}
+	st->header_count = 0;
+	for (i = 0; i < SENSOR_NUM_MAX; i++) {
+		if (st->sensor[i].on)
+			st->header_count = max(st->header_count,
+							st->sensor[i].count);
+	}
+
+	st->ts_algo.calib_counter++;
+	inv_bound_timestamp(st);
+
+	dptr = d;
+	done_flag = false;
+
+	while (!done_flag) {
+		pr_debug("total%d, pk=%d\n", total_bytes, pk_size);
+		if (total_bytes >= pk_size) {
+			res = inv_push_20680_data(st, dptr);
+			if (res)
+				return res;
+			total_bytes -= pk_size;
+			dptr += pk_size;
+		} else {
+			done_flag = true;
+		}
+	}
+
+	return 0;
+}
+
+/*
+ *  _inv_read_fifo() - Transfer data from FIFO to ring buffer.
+ */
+static void _inv_read_fifo(struct inv_mpu_state *st)
+{
+	struct iio_dev *indio_dev = iio_priv_to_dev(st);
+	int result;
+
+	result = wait_event_interruptible_timeout(st->wait_queue,
+					st->resume_state, msecs_to_jiffies(300));
+	if (result <= 0)
+		return;
+	mutex_lock(&indio_dev->mlock);
+#ifdef TIMER_BASED_BATCHING
+	if (st->batch_timeout) {
+		if (inv_plat_single_write(st, REG_INT_ENABLE, st->int_en))
+			pr_err("REG_INT_ENABLE write error\n");
+	}
+#endif
+	st->wake_sensor_received = false;
+	result = inv_process_20680_data(st);
+	if (result)
+		goto err_reset_fifo;
+	mutex_unlock(&indio_dev->mlock);
+
+	if (st->wake_sensor_received)
+#ifdef CONFIG_HAS_WAKELOCK
+		wake_lock_timeout(&st->wake_lock, msecs_to_jiffies(200));
+#else
+		__pm_wakeup_event(&st->wake_lock, 200); /* 200 msecs */
+#endif
+	return;
+
+err_reset_fifo:
+	if ((!st->chip_config.gyro_enable) &&
+		(!st->chip_config.accel_enable) &&
+		(!st->chip_config.slave_enable) &&
+		(!st->chip_config.pressure_enable)) {
+		inv_switch_power_in_lp(st, false);
+		mutex_unlock(&indio_dev->mlock);
+
+		return;
+	}
+
+	pr_err("error to reset fifo\n");
+	inv_switch_power_in_lp(st, true);
+	inv_reset_fifo(st, true);
+	inv_switch_power_in_lp(st, false);
+	mutex_unlock(&indio_dev->mlock);
+
+	return;
+}
+
+irqreturn_t inv_read_fifo(int irq, void *dev_id)
+{
+	struct inv_mpu_state *st = (struct inv_mpu_state *)dev_id;
+
+	_inv_read_fifo(st);
+
+	return IRQ_HANDLED;
+}
+
+#ifdef TIMER_BASED_BATCHING
+void inv_batch_work(struct work_struct *work)
+{
+	struct inv_mpu_state *st =
+		container_of(work, struct inv_mpu_state, batch_work);
+	struct iio_dev *indio_dev = iio_priv_to_dev(st);
+
+	mutex_lock(&indio_dev->mlock);
+	if (inv_plat_single_write(st, REG_INT_ENABLE, st->int_en | BIT_DATA_RDY_EN))
+		pr_err("REG_INT_ENABLE write error\n");
+	mutex_unlock(&indio_dev->mlock);
+
+	return;
+}
+#endif
+
+int inv_flush_batch_data(struct iio_dev *indio_dev, int data)
+{
+	struct inv_mpu_state *st = iio_priv(indio_dev);
+
+#ifndef SENSOR_DATA_FROM_REGISTERS
+	if (st->chip_config.gyro_enable ||
+		st->chip_config.accel_enable ||
+		st->chip_config.slave_enable ||
+		st->chip_config.pressure_enable) {
+		st->wake_sensor_received = 0;
+		inv_process_20680_data(st);
+		if (st->wake_sensor_received)
+#ifdef CONFIG_HAS_WAKELOCK
+			wake_lock_timeout(&st->wake_lock, msecs_to_jiffies(200));
+#else
+			__pm_wakeup_event(&st->wake_lock, 200); /* 200 msecs */
+#endif
+		inv_switch_power_in_lp(st, false);
+	}
+#endif /* SENSOR_DATA_FROM_REGISTERS */
+	inv_push_marker_to_buffer(st, END_MARKER, data);
+
+	return 0;
+}
+
diff --git a/drivers/iio/imu/inv_mpu/iam20680/inv_mpu_selftest_20680.c b/drivers/iio/imu/inv_mpu/iam20680/inv_mpu_selftest_20680.c
new file mode 100644
index 0000000..7a90b4d
--- /dev/null
+++ b/drivers/iio/imu/inv_mpu/iam20680/inv_mpu_selftest_20680.c
@@ -0,0 +1,752 @@
+/*
+* Copyright (C) 2017-2018 InvenSense, Inc.
+*
+* This software is licensed under the terms of the GNU General Public
+* License version 2, as published by the Free Software Foundation, and
+* may be copied, distributed, and modified under those terms.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*/
+#define pr_fmt(fmt) "inv_mpu: " fmt
+
+#include "../inv_mpu_iio.h"
+
+/* register settings */
+#define DEF_SELFTEST_GYRO_SENS          (32768 / 250)
+/* wait time before collecting data */
+#define MAX_PACKETS                     20
+#define SELFTEST_WAIT_TIME              (MAX_PACKETS * 10)
+#define DEF_ST_STABLE_TIME              20
+#define DEF_GYRO_SCALE                  131
+#define DEF_ST_PRECISION                1000
+#define DEF_ST_ACCEL_FS_MG              2000UL
+#define DEF_ST_SCALE                    32768
+#define DEF_ST_TRY_TIMES                2
+#define DEF_ST_ACCEL_RESULT_SHIFT       1
+#define DEF_ST_SAMPLES                  200
+
+#define DEF_ACCEL_ST_SHIFT_DELTA_MIN    500
+#define DEF_ACCEL_ST_SHIFT_DELTA_MAX    1500
+#define DEF_GYRO_CT_SHIFT_DELTA         500
+
+#define SENSOR_UP_TIME	30
+#define REG_UP_TIME		2
+
+#define DEF_ST_ACCEL_FS_MG         2000UL
+#define DEF_ACCEL_ST_SHIFT_DELTA   500
+#define ACCEL_ST_AL_MIN ((DEF_ACCEL_ST_AL_MIN * DEF_ST_SCALE \
+				 / DEF_ST_ACCEL_FS_MG) * DEF_ST_PRECISION)
+#define ACCEL_ST_AL_MAX ((DEF_ACCEL_ST_AL_MAX * DEF_ST_SCALE \
+				 / DEF_ST_ACCEL_FS_MG) * DEF_ST_PRECISION)
+
+#define THREE_AXIS               3
+#define DEF_ST_MPU6500_ACCEL_LPF        2
+#define DEF_SELFTEST_SAMPLE_RATE        0  /* 1000Hz */
+#define DEF_SELFTEST_SAMPLE_RATE_LP     3  /*  250Hz */
+#define DEF_SELFTEST_SAMPLE_RATE_ACC_LP 10 /*  250Hz LPOSC_CLKSEL */
+#define INV_MPU_SAMPLE_RATE_CHANGE_STABLE 50
+#define DEF_SELFTEST_6500_ACCEL_FS      (0 << 3)
+#define DEF_SELFTEST_GYRO_FS            (0 << 3)
+#define DEF_ST_6500_STABLE_TIME         20
+#define BIT_ACCEL_OUT           0x08
+#define BITS_GYRO_OUT           0x70
+#define THREE_AXIS               3
+#define DEF_GYRO_WAIT_TIME              10
+#define DEF_GYRO_WAIT_TIME_LP           50
+
+/* Gyro Offset Max Value (dps) */
+#define DEF_GYRO_OFFSET_MAX             20
+/* Gyro Self Test Absolute Limits ST_AL (dps) */
+#define DEF_GYRO_ST_AL                  60
+/* Accel Self Test Absolute Limits ST_AL (mg) */
+#define DEF_ACCEL_ST_AL_MIN             225
+#define DEF_ACCEL_ST_AL_MAX             675
+
+struct recover_regs {
+	u8 int_enable;		/* REG_INT_ENABLE */
+	u8 fifo_en;			/* REG_FIFO_EN */
+	u8 user_ctrl;		/* REG_USER_CTRL */
+	u8 config;			/* REG_CONFIG */
+	u8 gyro_config;		/* REG_GYRO_CONFIG */
+	u8 accel_config;	/* REG_ACCEL_CONFIG */
+	u8 accel_config_2;	/* REG_ACCEL_CONFIG_2 */
+	u8 smplrt_div;		/* REG_SAMPLE_RATE_DIV */
+	u8 lp_mode;			/* REG_LP_MODE_CTRL */
+	u8 pwr_mgmt_1;		/* REG_PWR_MGMT_1 */
+	u8 pwr_mgmt_2;		/* REG_PWR_MGMT_2 */
+};
+
+static struct recover_regs saved_regs;
+
+static const u16 mpu_st_tb[256] = {
+	2620, 2646, 2672, 2699, 2726, 2753, 2781, 2808,
+	2837, 2865, 2894, 2923, 2952, 2981, 3011, 3041,
+	3072, 3102, 3133, 3165, 3196, 3228, 3261, 3293,
+	3326, 3359, 3393, 3427, 3461, 3496, 3531, 3566,
+	3602, 3638, 3674, 3711, 3748, 3786, 3823, 3862,
+	3900, 3939, 3979, 4019, 4059, 4099, 4140, 4182,
+	4224, 4266, 4308, 4352, 4395, 4439, 4483, 4528,
+	4574, 4619, 4665, 4712, 4759, 4807, 4855, 4903,
+	4953, 5002, 5052, 5103, 5154, 5205, 5257, 5310,
+	5363, 5417, 5471, 5525, 5581, 5636, 5693, 5750,
+	5807, 5865, 5924, 5983, 6043, 6104, 6165, 6226,
+	6289, 6351, 6415, 6479, 6544, 6609, 6675, 6742,
+	6810, 6878, 6946, 7016, 7086, 7157, 7229, 7301,
+	7374, 7448, 7522, 7597, 7673, 7750, 7828, 7906,
+	7985, 8065, 8145, 8227, 8309, 8392, 8476, 8561,
+	8647, 8733, 8820, 8909, 8998, 9088, 9178, 9270,
+	9363, 9457, 9551, 9647, 9743, 9841, 9939, 10038,
+	10139, 10240, 10343, 10446, 10550, 10656, 10763, 10870,
+	10979, 11089, 11200, 11312, 11425, 11539, 11654, 11771,
+	11889, 12008, 12128, 12249, 12371, 12495, 12620, 12746,
+	12874, 13002, 13132, 13264, 13396, 13530, 13666, 13802,
+	13940, 14080, 14221, 14363, 14506, 14652, 14798, 14946,
+	15096, 15247, 15399, 15553, 15709, 15866, 16024, 16184,
+	16346, 16510, 16675, 16842, 17010, 17180, 17352, 17526,
+	17701, 17878, 18057, 18237, 18420, 18604, 18790, 18978,
+	19167, 19359, 19553, 19748, 19946, 20145, 20347, 20550,
+	20756, 20963, 21173, 21385, 21598, 21814, 22033, 22253,
+	22475, 22700, 22927, 23156, 23388, 23622, 23858, 24097,
+	24338, 24581, 24827, 25075, 25326, 25579, 25835, 26093,
+	26354, 26618, 26884, 27153, 27424, 27699, 27976, 28255,
+	28538, 28823, 29112, 29403, 29697, 29994, 30294, 30597,
+	30903, 31212, 31524, 31839, 32157, 32479, 32804
+};
+
+static void inv_show_saved_setting(struct inv_mpu_state *st)
+{
+	pr_debug(" REG_INT_ENABLE      : 0x%02X\n", saved_regs.int_enable);
+	pr_debug(" REG_FIFO_EN         : 0x%02X\n", saved_regs.fifo_en);
+	pr_debug(" REG_USER_CTRL       : 0x%02X\n", saved_regs.user_ctrl);
+	pr_debug(" REG_CONFIG          : 0x%02X\n", saved_regs.config);
+	pr_debug(" REG_GYRO_CONFIG     : 0x%02X\n", saved_regs.gyro_config);
+	pr_debug(" REG_ACCEL_CONFIG    : 0x%02X\n", saved_regs.accel_config);
+	pr_debug(" REG_ACCEL_CONFIG_2  : 0x%02X\n", saved_regs.accel_config_2);
+	pr_debug(" REG_SAMPLE_RATE_DIV : 0x%02X\n", saved_regs.smplrt_div);
+	pr_debug(" REG_LP_MODE_CTRL    : 0x%02X\n", saved_regs.lp_mode);
+	pr_debug(" REG_PWR_MGMT_1      : 0x%02X\n", saved_regs.pwr_mgmt_1);
+	pr_debug(" REG_PWR_MGMT_2      : 0x%02X\n", saved_regs.pwr_mgmt_2);
+}
+
+static int inv_save_setting(struct inv_mpu_state *st)
+{
+	int result;
+
+	result = inv_plat_read(st, REG_PWR_MGMT_1, 1,
+			&saved_regs.pwr_mgmt_1);
+	if (result)
+		return result;
+
+	/* wake up */
+	result = inv_plat_single_write(st, REG_PWR_MGMT_1,
+			(saved_regs.pwr_mgmt_1 & ~BIT_SLEEP));
+	if (result)
+		return result;
+
+	result = inv_plat_read(st, REG_INT_ENABLE, 1,
+			&saved_regs.int_enable);
+	if (result)
+		return result;
+	result = inv_plat_read(st, REG_FIFO_EN, 1,
+			&saved_regs.fifo_en);
+	if (result)
+		return result;
+	result = inv_plat_read(st, REG_USER_CTRL, 1,
+			&saved_regs.user_ctrl);
+	if (result)
+		return result;
+	result = inv_plat_read(st, REG_CONFIG, 1,
+			&saved_regs.config);
+	if (result)
+		return result;
+	result = inv_plat_read(st, REG_GYRO_CONFIG, 1,
+			&saved_regs.gyro_config);
+	if (result)
+		return result;
+	result = inv_plat_read(st, REG_ACCEL_CONFIG, 1,
+			&saved_regs.accel_config);
+	if (result)
+		return result;
+	result = inv_plat_read(st, REG_ACCEL_CONFIG_2, 1,
+			&saved_regs.accel_config_2);
+	if (result)
+		return result;
+	result = inv_plat_read(st, REG_SAMPLE_RATE_DIV, 1,
+			&saved_regs.smplrt_div);
+	if (result)
+		return result;
+	result = inv_plat_read(st, REG_LP_MODE_CTRL, 1,
+			&saved_regs.lp_mode);
+	if (result)
+		return result;
+	result = inv_plat_read(st, REG_PWR_MGMT_2, 1,
+			&saved_regs.pwr_mgmt_2);
+	if (result)
+		return result;
+
+	inv_show_saved_setting(st);
+
+	return result;
+}
+
+static int inv_recover_setting(struct inv_mpu_state *st)
+{
+	int result;
+	/* Stop sensors */
+	result = inv_plat_single_write(st, REG_PWR_MGMT_2,
+			BIT_PWR_ACCEL_STBY | BIT_PWR_GYRO_STBY);
+	if (result)
+		return result;
+
+	/* Restore sensor configurations */
+	result = inv_plat_single_write(st, REG_INT_ENABLE,
+			saved_regs.int_enable);
+	if (result)
+		return result;
+	result = inv_plat_single_write(st, REG_FIFO_EN,
+			saved_regs.fifo_en);
+	if (result)
+		return result;
+	result = inv_plat_single_write(st, REG_USER_CTRL,
+			saved_regs.user_ctrl);
+	if (result)
+		return result;
+	result = inv_plat_single_write(st, REG_CONFIG,
+			saved_regs.config);
+	if (result)
+		return result;
+	result = inv_plat_single_write(st, REG_GYRO_CONFIG,
+			saved_regs.gyro_config);
+	if (result)
+		return result;
+	result = inv_plat_single_write(st, REG_ACCEL_CONFIG,
+			saved_regs.accel_config);
+	if (result)
+		return result;
+	result = inv_plat_single_write(st, REG_ACCEL_CONFIG_2,
+			saved_regs.accel_config_2);
+	if (result)
+		return result;
+	result = inv_plat_single_write(st, REG_SAMPLE_RATE_DIV,
+			saved_regs.smplrt_div);
+	if (result)
+		return result;
+	result = inv_plat_single_write(st, REG_LP_MODE_CTRL,
+			saved_regs.lp_mode);
+	if (result)
+		return result;
+	result = inv_plat_single_write(st, REG_PWR_MGMT_1,
+			saved_regs.pwr_mgmt_1);
+	if (result)
+		return result;
+
+	result = inv_plat_single_write(st, REG_PWR_MGMT_2,
+			saved_regs.pwr_mgmt_2);
+	if (result)
+		return result;
+
+	return result;
+}
+
+int inv_switch_engine(struct inv_mpu_state *st, bool en, u32 mask)
+{
+	u8 data, mgmt_1;
+	int result;
+
+	if (BIT_PWR_GYRO_STBY == mask) {
+		result = inv_plat_read(st, REG_PWR_MGMT_1, 1, &mgmt_1);
+		if (result)
+			return result;
+		mgmt_1 &= ~BIT_CLK_MASK;
+	}
+
+	if ((BIT_PWR_GYRO_STBY == mask) && (!en)) {
+		result = inv_plat_single_write(st, REG_PWR_MGMT_1, mgmt_1);
+		if (result)
+			return result;
+	}
+
+	result = inv_plat_read(st, REG_PWR_MGMT_2, 1, &data);
+	if (result)
+		return result;
+	if (en)
+		data &= (~mask);
+	else
+		data |= mask;
+	data |= BIT_FIFO_LP_EN;
+	result = inv_plat_single_write(st, REG_PWR_MGMT_2, data);
+	if (result)
+		return result;
+
+	if ((BIT_PWR_GYRO_STBY == mask) && en) {
+		/* only gyro on needs sensor up time */
+		msleep(SENSOR_UP_TIME);
+		/* after gyro is on & stable, switch internal clock to PLL */
+		mgmt_1 |= BIT_CLK_PLL;
+		result = inv_plat_single_write(st, REG_PWR_MGMT_1, mgmt_1);
+		if (result)
+			return result;
+	}
+	if ((BIT_PWR_ACCEL_STBY == mask) && en)
+		msleep(REG_UP_TIME);
+
+	return 0;
+}
+
+int inv_set_offset_reg(struct inv_mpu_state *st, int reg, int val)
+{
+	int result;
+	u8 d;
+
+	d = ((val >> 8) & 0xff);
+	result = inv_plat_single_write(st, reg, d);
+	if (result)
+		return result;
+
+	d = (val & 0xff);
+	result = inv_plat_single_write(st, reg + 1, d);
+
+	return result;
+}
+
+/**
+* inv_check_gyro_self_test() - check gyro self test. this function
+*                                   returns zero as success. A non-zero return
+*                                   value indicates failure in self test.
+*  @*st: main data structure.
+*  @*reg_avg: average value of normal test.
+*  @*st_avg:  average value of self test
+*/
+int inv_check_gyro_self_test(struct inv_mpu_state *st,
+						int *reg_avg, int *st_avg) {
+	u8 regs[3];
+	int ret_val, result;
+	int otp_value_zero = 0;
+	int st_shift_prod[3], st_shift_cust[3], i;
+
+	ret_val = 0;
+	result = inv_plat_read(st, REG_6500_XG_ST_DATA, 3, regs);
+	if (result)
+		return result;
+	pr_debug("%s self_test gyro shift_code - %02x %02x %02x\n",
+		st->hw->name, regs[0], regs[1], regs[2]);
+
+	for (i = 0; i < 3; i++) {
+		if (regs[i] != 0) {
+			st_shift_prod[i] = mpu_st_tb[regs[i] - 1];
+		} else {
+			st_shift_prod[i] = 0;
+			otp_value_zero = 1;
+		}
+	}
+	pr_debug("%s self_test gyro st_shift_prod - %+d %+d %+d\n",
+		st->hw->name, st_shift_prod[0], st_shift_prod[1],
+		st_shift_prod[2]);
+
+	for (i = 0; i < 3; i++) {
+		st_shift_cust[i] = st_avg[i] - reg_avg[i];
+		if (!otp_value_zero) {
+			/* Self Test Pass/Fail Criteria A */
+			if (st_shift_cust[i] < DEF_GYRO_CT_SHIFT_DELTA
+						* st_shift_prod[i])
+					ret_val = 1;
+		} else {
+			/* Self Test Pass/Fail Criteria B */
+			if (st_shift_cust[i] < DEF_GYRO_ST_AL *
+						DEF_SELFTEST_GYRO_SENS *
+						DEF_ST_PRECISION)
+				ret_val = 1;
+		}
+	}
+	pr_debug("%s self_test gyro st_shift_cust - %+d %+d %+d\n",
+		st->hw->name, st_shift_cust[0], st_shift_cust[1],
+		st_shift_cust[2]);
+
+	if (ret_val == 0) {
+		/* Self Test Pass/Fail Criteria C */
+		for (i = 0; i < 3; i++)
+			if (abs(reg_avg[i]) > DEF_GYRO_OFFSET_MAX *
+						DEF_SELFTEST_GYRO_SENS *
+						DEF_ST_PRECISION)
+				ret_val = 1;
+	}
+
+	return ret_val;
+}
+
+/**
+* inv_check_accel_self_test() - check 6500 accel self test. this function
+*                                   returns zero as success. A non-zero return
+*                                   value indicates failure in self test.
+*  @*st: main data structure.
+*  @*reg_avg: average value of normal test.
+*  @*st_avg:  average value of self test
+*/
+int inv_check_accel_self_test(struct inv_mpu_state *st,
+						int *reg_avg, int *st_avg) {
+	int ret_val, result;
+	int st_shift_prod[3], st_shift_cust[3], st_shift_ratio[3], i;
+	u8 regs[3];
+	int otp_value_zero = 0;
+
+	ret_val = 0;
+	result = inv_plat_read(st, REG_6500_XA_ST_DATA, 3, regs);
+	if (result)
+		return result;
+	pr_debug("%s self_test accel shift_code - %02x %02x %02x\n",
+		st->hw->name, regs[0], regs[1], regs[2]);
+
+	for (i = 0; i < 3; i++) {
+		if (regs[i] != 0) {
+			st_shift_prod[i] = mpu_st_tb[regs[i] - 1];
+		} else {
+			st_shift_prod[i] = 0;
+			otp_value_zero = 1;
+		}
+	}
+	pr_debug("%s self_test accel st_shift_prod - %+d %+d %+d\n",
+		st->hw->name, st_shift_prod[0], st_shift_prod[1],
+		st_shift_prod[2]);
+
+	if (!otp_value_zero) {
+		/* Self Test Pass/Fail Criteria A */
+		for (i = 0; i < 3; i++) {
+			st_shift_cust[i] = st_avg[i] - reg_avg[i];
+			st_shift_ratio[i] = abs(st_shift_cust[i] /
+					st_shift_prod[i] - DEF_ST_PRECISION);
+			if (st_shift_ratio[i] > DEF_ACCEL_ST_SHIFT_DELTA)
+				ret_val = 1;
+		}
+	} else {
+		/* Self Test Pass/Fail Criteria B */
+		for (i = 0; i < 3; i++) {
+			st_shift_cust[i] = abs(st_avg[i] - reg_avg[i]);
+			if (st_shift_cust[i] < ACCEL_ST_AL_MIN ||
+					st_shift_cust[i] > ACCEL_ST_AL_MAX)
+				ret_val = 1;
+		}
+	}
+	pr_debug("%s self_test accel st_shift_cust - %+d %+d %+d\n",
+		st->hw->name, st_shift_cust[0], st_shift_cust[1],
+		st_shift_cust[2]);
+
+	return ret_val;
+}
+
+/*
+ *  inv_do_test() - do the actual test of self testing
+ */
+int inv_do_test(struct inv_mpu_state *st, int self_test_flag,
+		int *gyro_result, int *accel_result, int lp_mode)
+{
+	int result, i, j, packet_size;
+	u8 data[BYTES_PER_SENSOR * 2], d, dd;
+	int fifo_count, packet_count, ind, s;
+
+	packet_size = BYTES_PER_SENSOR * 2;
+
+	/* disable interrupt */
+	result = inv_plat_single_write(st, REG_INT_ENABLE, 0);
+	if (result)
+		return result;
+	/* disable the sensor output to FIFO */
+	result = inv_plat_single_write(st, REG_FIFO_EN, 0);
+	if (result)
+		return result;
+	/* disable fifo reading */
+	result = inv_plat_single_write(st, REG_USER_CTRL, 0);
+	if (result)
+		return result;
+	/* clear FIFO */
+	result = inv_plat_single_write(st, REG_USER_CTRL, BIT_FIFO_RST);
+	if (result)
+		return result;
+	/* setup parameters */
+	result = inv_plat_single_write(st, REG_CONFIG, INV_FILTER_98HZ);
+	if (result)
+		return result;
+
+	/* gyro lp mode */
+	if (lp_mode == 1)
+		d = BIT_GYRO_CYCLE_EN;
+	else if (lp_mode == 2)
+		d = DEF_SELFTEST_SAMPLE_RATE_ACC_LP;
+	else
+		d = 0;
+	result = inv_plat_single_write(st, REG_LP_MODE_CTRL, d);
+	if (result)
+		return result;
+
+	/* config accel LPF register */
+	if (lp_mode == 2)
+		d = BIT_ACCEL_FCHOCIE_B;
+	else
+		d = DEF_ST_MPU6500_ACCEL_LPF;
+	result = inv_plat_single_write(st, REG_6500_ACCEL_CONFIG2, d);
+	if (result)
+		return result;
+
+	if (lp_mode) {
+		result = inv_plat_single_write(st, REG_SAMPLE_RATE_DIV,
+				DEF_SELFTEST_SAMPLE_RATE_LP);
+	} else {
+		result = inv_plat_single_write(st, REG_SAMPLE_RATE_DIV,
+				DEF_SELFTEST_SAMPLE_RATE);
+	}
+	if (result)
+		return result;
+	/* wait for the sampling rate change to stabilize */
+	mdelay(INV_MPU_SAMPLE_RATE_CHANGE_STABLE);
+	result = inv_plat_single_write(st, REG_GYRO_CONFIG,
+		self_test_flag | DEF_SELFTEST_GYRO_FS);
+	if (result)
+		return result;
+
+	d = DEF_SELFTEST_6500_ACCEL_FS;
+	d |= self_test_flag;
+	result = inv_plat_single_write(st, REG_ACCEL_CONFIG, d);
+	if (result)
+		return result;
+
+	/* wait for the output to get stable */
+	msleep(DEF_ST_6500_STABLE_TIME);
+
+	/* enable FIFO reading */
+	result = inv_plat_single_write(st, REG_USER_CTRL, BIT_FIFO_EN);
+	if (result)
+		return result;
+	/* enable sensor output to FIFO */
+	d = BITS_GYRO_OUT | BIT_ACCEL_OUT;
+	for (i = 0; i < THREE_AXIS; i++) {
+		gyro_result[i] = 0;
+		accel_result[i] = 0;
+	}
+	s = 0;
+	while (s < 200 /*st->self_test.samples*/) {
+		/* Stop FIFO */
+		result = inv_plat_single_write(st, REG_USER_CTRL, 0);
+		if (result)
+			return result;
+		/* clear FIFO */
+		result = inv_plat_single_write(st, REG_USER_CTRL, BIT_FIFO_RST);
+		if (result)
+			return result;
+		/* enable FIFO reading */
+		result = inv_plat_single_write(st, REG_USER_CTRL, BIT_FIFO_EN);
+		if (result)
+			return result;
+
+		/* accel lp mode */
+		dd = BIT_CLK_PLL;
+		if (lp_mode == 2)
+			dd |= BIT_LP_EN;
+		else
+			dd &= ~BIT_LP_EN;
+		result = inv_plat_single_write(st, REG_PWR_MGMT_1, dd);
+		if (result)
+			return result;
+
+		result = inv_plat_single_write(st, REG_FIFO_EN, d);
+		if (result)
+			return result;
+		if (lp_mode)
+			mdelay(DEF_GYRO_WAIT_TIME_LP);
+		else
+			mdelay(DEF_GYRO_WAIT_TIME);
+
+		result = inv_plat_single_write(st, REG_FIFO_EN, 0);
+		if (result)
+			return result;
+
+		result = inv_plat_read(st, REG_FIFO_COUNT_H,
+					FIFO_COUNT_BYTE, data);
+		if (result)
+			return result;
+		fifo_count = be16_to_cpup((__be16 *)(&data[0]));
+		pr_debug("%s self_test fifo_count - %d\n",
+			 st->hw->name, fifo_count);
+		packet_count = fifo_count / packet_size;
+		i = 0;
+		while ((i < packet_count) && (s < 200 /*st->self_test.samples*/)) {
+			short vals[3];
+			result = inv_plat_read(st, REG_FIFO_R_W,
+				packet_size, data);
+			if (result)
+				return result;
+			ind = 0;
+
+			for (j = 0; j < THREE_AXIS; j++) {
+				vals[j] = (short)be16_to_cpup(
+					(__be16 *)(&data[ind + 2 * j]));
+				accel_result[j] += vals[j];
+			}
+			ind += BYTES_PER_SENSOR;
+			pr_debug(
+				"%s self_test accel data - %d %+d %+d %+d",
+				st->hw->name, s, vals[0], vals[1], vals[2]);
+
+			for (j = 0; j < THREE_AXIS; j++) {
+				vals[j] = (short)be16_to_cpup(
+					(__be16 *)(&data[ind + 2 * j]));
+				gyro_result[j] += vals[j];
+			}
+			pr_debug("%s self_test gyro data - %d %+d %+d %+d",
+				st->hw->name, s, vals[0], vals[1], vals[2]);
+
+			s++;
+			i++;
+		}
+	}
+
+	for (j = 0; j < THREE_AXIS; j++) {
+		accel_result[j] = accel_result[j] / s;
+		accel_result[j] *= DEF_ST_PRECISION;
+	}
+	for (j = 0; j < THREE_AXIS; j++) {
+		gyro_result[j] = gyro_result[j] / s;
+		gyro_result[j] *= DEF_ST_PRECISION;
+	}
+
+	return 0;
+}
+
+
+int inv_power_up_self_test(struct inv_mpu_state *st)
+{
+	int result;
+
+	result = inv_switch_power_in_lp(st, true);
+
+	/* make sure no interrupts */
+	result = inv_plat_single_write(st, REG_INT_ENABLE, 0);
+	if (result)
+		return result;
+
+	if (result)
+		return result;
+	result = inv_switch_engine(st, true, BIT_PWR_ACCEL_STBY);
+	if (result)
+		return result;
+	result = inv_switch_engine(st, true, BIT_PWR_GYRO_STBY);
+	if (result)
+		return result;
+
+	return 0;
+}
+
+/*
+ *  inv_hw_self_test() - main function to do hardware self test
+ */
+int inv_hw_self_test(struct inv_mpu_state *st)
+{
+	int result;
+	int gyro_bias_st[THREE_AXIS], gyro_bias_regular[THREE_AXIS];
+	int accel_bias_st[THREE_AXIS], accel_bias_regular[THREE_AXIS];
+#if 0
+	int gyro_bias_regular_lp[THREE_AXIS];
+	int accel_bias_regular_lp[THREE_AXIS];
+	int dummy_bias_regular[THREE_AXIS];
+#endif
+	int test_times, i;
+	char accel_result, gyro_result;
+
+	result = inv_save_setting(st);
+	if (result)
+		return result;
+
+	result = inv_power_up_self_test(st);
+	if (result)
+		return result;
+	accel_result = 0;
+	gyro_result = 0;
+	test_times = DEF_ST_TRY_TIMES;
+	while (test_times > 0) {
+		result = inv_do_test(st, 0, gyro_bias_regular,
+			accel_bias_regular, 0);
+		if (result == -EAGAIN)
+			test_times--;
+		else
+			test_times = 0;
+	}
+	if (result)
+		goto test_fail;
+	pr_debug("%s self_test accel bias_regular - %+d %+d %+d\n",
+		st->hw->name, accel_bias_regular[0],
+		accel_bias_regular[1], accel_bias_regular[2]);
+	pr_debug("%s self_test gyro bias_regular - %+d %+d %+d\n",
+		st->hw->name, gyro_bias_regular[0], gyro_bias_regular[1],
+		gyro_bias_regular[2]);
+
+	test_times = DEF_ST_TRY_TIMES;
+	while (test_times > 0) {
+		result = inv_do_test(st, BITS_SELF_TEST_EN, gyro_bias_st,
+					accel_bias_st, 0);
+		if (result == -EAGAIN)
+			test_times--;
+		else
+			break;
+	}
+	if (result)
+		goto test_fail;
+	pr_debug("%s self_test accel bias_st - %+d %+d %+d\n",
+		st->hw->name, accel_bias_st[0], accel_bias_st[1],
+		accel_bias_st[2]);
+	pr_debug("%s self_test gyro bias_st - %+d %+d %+d\n",
+		st->hw->name, gyro_bias_st[0], gyro_bias_st[1],
+		gyro_bias_st[2]);
+
+#if 0
+	/* lp gyro mode */
+	test_times = DEF_ST_TRY_TIMES;
+	while (test_times > 0) {
+		result = inv_do_test(st, 0, gyro_bias_regular_lp,
+			dummy_bias_regular, 1);
+		if (result == -EAGAIN)
+			test_times--;
+		else
+			test_times = 0;
+	}
+	if (result)
+		goto test_fail;
+	pr_debug("%s self_test gyro bias_regular lp - %+d %+d %+d\n",
+		 st->hw->name, gyro_bias_regular_lp[0], gyro_bias_regular_lp[1],
+		 gyro_bias_regular_lp[2]);
+
+	/* lp accel mode */
+	test_times = DEF_ST_TRY_TIMES;
+	while (test_times > 0) {
+		result = inv_do_test(st, 0, dummy_bias_regular,
+			accel_bias_regular_lp, 2);
+		if (result == -EAGAIN)
+			test_times--;
+		else
+			test_times = 0;
+	}
+	if (result)
+		goto test_fail;
+	pr_debug("%s self_test accel bias_regular lp - %+d %+d %+d\n",
+		 st->hw->name, accel_bias_regular_lp[0],
+		 accel_bias_regular_lp[1], accel_bias_regular_lp[2]);
+#endif
+
+	/* copy bias */
+	for (i = 0; i < 3; i++) {
+		/* gyro : LN bias as LN is default mode */
+		st->gyro_st_bias[i] = gyro_bias_regular[i] / DEF_ST_PRECISION;
+		/* accel : LN bias as LN is default mode */
+		st->accel_st_bias[i] = accel_bias_regular[i] / DEF_ST_PRECISION;
+	}
+
+	/* Check is done on continuous mode data */
+	accel_result = !inv_check_accel_self_test(st,
+		accel_bias_regular, accel_bias_st);
+	gyro_result = !inv_check_gyro_self_test(st,
+		gyro_bias_regular, gyro_bias_st);
+
+test_fail:
+	inv_recover_setting(st);
+	return (accel_result << DEF_ST_ACCEL_RESULT_SHIFT) | gyro_result;
+}
diff --git a/drivers/iio/imu/inv_mpu/iam20680/inv_mpu_setup_20680.c b/drivers/iio/imu/inv_mpu/iam20680/inv_mpu_setup_20680.c
new file mode 100644
index 0000000..5e9cf89
--- /dev/null
+++ b/drivers/iio/imu/inv_mpu/iam20680/inv_mpu_setup_20680.c
@@ -0,0 +1,466 @@
+/*
+* Copyright (C) 2017-2018 InvenSense, Inc.
+*
+* This software is licensed under the terms of the GNU General Public
+* License version 2, as published by the Free Software Foundation, and
+* may be copied, distributed, and modified under those terms.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*/
+#define pr_fmt(fmt) "inv_mpu: " fmt
+#include "../inv_mpu_iio.h"
+
+/* set LN mode for gyro regardless of conditions */
+#define USE_GYRO_LN_MODE
+
+static int inv_calc_engine_dur(struct inv_engine_info *ei)
+{
+	if (!ei->running_rate)
+		return -EINVAL;
+	ei->dur = ei->base_time / ei->orig_rate;
+	ei->dur *= ei->divider;
+
+	return 0;
+}
+
+static int inv_turn_on_fifo(struct inv_mpu_state *st)
+{
+	u8 int_en, fifo_en, mode, user;
+	int r;
+
+	r = inv_plat_single_write(st, REG_FIFO_EN, 0);
+	if (r)
+		return r;
+	r = inv_plat_single_write(st, REG_USER_CTRL, BIT_FIFO_RST);
+	if (r)
+		return r;
+	fifo_en = 0;
+	int_en = 0;
+
+	if (st->gesture_only_on && (!st->batch.timeout)) {
+		st->gesture_int_count = WOM_DELAY_THRESHOLD;
+		int_en |= BIT_WOM_ALL_INT_EN;
+	}
+#ifdef TIMER_BASED_BATCHING
+	if (st->chip_config.eis_enable)
+		int_en |= BIT_FSYNC_INT_EN;
+	if (!st->batch_timeout) {
+		int_en |= BIT_DATA_RDY_EN;
+	}
+#else
+	if (st->batch.timeout) {
+		if(!st->batch.fifo_wm_th)
+			int_en = BIT_DATA_RDY_EN;
+	} else {
+		int_en = BIT_DATA_RDY_EN;
+		if (st->chip_config.eis_enable)
+			int_en |= BIT_FSYNC_INT_EN;
+	}
+#endif
+	if (st->sensor[SENSOR_GYRO].on)
+		fifo_en |= BITS_GYRO_FIFO_EN;
+
+	if (st->sensor[SENSOR_ACCEL].on)
+		fifo_en |= BIT_ACCEL_FIFO_EN;
+	r = inv_plat_single_write(st, REG_FIFO_EN, fifo_en);
+	if (r)
+		return r;
+	st->int_en = int_en;
+	r = inv_plat_single_write(st, REG_INT_ENABLE, int_en);
+	if (r)
+		return r;
+	if (st->gesture_only_on && (!st->batch.timeout)) {
+		mode = BIT_ACCEL_INTEL_EN | BIT_ACCEL_INTEL_MODE;
+	} else {
+		mode = 0;
+	}
+	r = inv_plat_single_write(st, REG_ACCEL_INTEL_CTRL, mode);
+#ifdef SENSOR_DATA_FROM_REGISTERS
+	user = 0;
+#else
+	user = BIT_FIFO_EN;
+#endif
+	r = inv_plat_single_write(st, REG_USER_CTRL, user | st->i2c_dis);
+#ifdef TIMER_BASED_BATCHING
+	if (fifo_en && st->batch_timeout) {
+		if (st->is_batch_timer_running)
+			hrtimer_cancel(&st ->hr_batch_timer);
+		st->is_batch_timer_running = true;
+		hrtimer_start(&st ->hr_batch_timer,
+			ns_to_ktime(st->batch_timeout), HRTIMER_MODE_REL);
+	} else {
+		if (st->is_batch_timer_running)
+			hrtimer_cancel(&st ->hr_batch_timer);
+		st->is_batch_timer_running = false;
+	}
+#endif
+
+	return r;
+}
+
+/*
+ *  inv_reset_fifo() - Reset FIFO related registers.
+ */
+int inv_reset_fifo(struct inv_mpu_state *st, bool turn_off)
+{
+	int r, i;
+	struct inv_timestamp_algo *ts_algo = &st->ts_algo;
+	int dur_ms;
+
+	r = inv_turn_on_fifo(st);
+	if (r)
+		return r;
+
+	ts_algo->last_run_time = get_time_ns();
+	ts_algo->reset_ts = ts_algo->last_run_time;
+	if (st->mode_1k_on)
+		ts_algo->first_sample = MODE_1K_INIT_SAMPLE;
+	else
+		ts_algo->first_sample = 1;
+
+	dur_ms = st->smplrt_div + 1;
+	if ((ts_algo->first_sample * dur_ms) < FIRST_SAMPLE_BUF_MS)
+		ts_algo->first_sample = FIRST_SAMPLE_BUF_MS / dur_ms;
+	if (ts_algo->first_sample == 0)
+		ts_algo->first_sample = 1;
+
+	st->last_temp_comp_time = ts_algo->last_run_time;
+	st->left_over_size = 0;
+	for (i = 0; i < SENSOR_NUM_MAX; i++) {
+		st->sensor[i].calib_flag = 0;
+		st->sensor[i].sample_calib = 0;
+		st->sensor[i].time_calib = ts_algo->last_run_time;
+	}
+
+	ts_algo->calib_counter = 0;
+
+	return 0;
+}
+
+static int inv_turn_on_engine(struct inv_mpu_state *st)
+{
+	u8 v, w;
+	int r;
+	unsigned int wait_ms;
+
+	if (st->chip_config.gyro_enable | st->chip_config.accel_enable) {
+		w = 0;
+		if (!st->chip_config.gyro_enable)
+			w |= BIT_PWR_GYRO_STBY;
+		if (!st->chip_config.accel_enable)
+			w |= BIT_PWR_ACCEL_STBY;
+	} else if (st->chip_config.compass_enable) {
+		w = BIT_PWR_GYRO_STBY;
+	} else {
+		w = (BIT_PWR_GYRO_STBY | BIT_PWR_ACCEL_STBY);
+	}
+
+	r = inv_plat_read(st, REG_PWR_MGMT_2, 1, &v);
+	if (r)
+		return r;
+	r = inv_plat_single_write(st, REG_PWR_MGMT_2, w);
+	if (r)
+		return r;
+
+	wait_ms = 0;
+	if (st->chip_config.gyro_enable
+		&& (v & BIT_PWR_GYRO_STBY)) {
+		wait_ms = INV_IAM20680_GYRO_START_TIME;
+	}
+	if (st->chip_config.accel_enable
+		&& (v & BIT_PWR_ACCEL_STBY)) {
+		if (INV_IAM20680_ACCEL_START_TIME > wait_ms)
+			wait_ms = INV_IAM20680_ACCEL_START_TIME;
+	}
+	if (wait_ms)
+		msleep(wait_ms);
+
+	if (st->chip_config.has_compass) {
+		if (st->chip_config.compass_enable)
+			r = st->slave_compass->resume(st);
+		else
+			r = st->slave_compass->suspend(st);
+		if (r)
+			return r;
+	}
+
+	return 0;
+}
+
+static int inv_setup_dmp_rate(struct inv_mpu_state *st)
+{
+	int i;
+
+	for (i = 0; i < SENSOR_NUM_MAX; i++) {
+		if (st->sensor[i].on) {
+			st->cntl |= st->sensor[i].output;
+			st->sensor[i].dur =
+				st->eng_info[st->sensor[i].engine_base].dur;
+			st->sensor[i].div = 1;
+		}
+	}
+
+	return 0;
+}
+
+/*
+ *  inv_set_lpf() - set low pass filer based on fifo rate.
+ */
+static int inv_set_lpf(struct inv_mpu_state *st, int rate)
+{
+	const short hz[] = {188, 98, 42, 20, 10, 5};
+	const int   d[] = {INV_FILTER_188HZ, INV_FILTER_98HZ,
+			INV_FILTER_42HZ, INV_FILTER_20HZ,
+			INV_FILTER_10HZ, INV_FILTER_5HZ};
+	int i, h, data, result;
+
+#ifdef USE_GYRO_LN_MODE
+	if (1) {
+#else
+	if (st->chip_config.eis_enable || st->ois.en || st->mode_1k_on) {
+#endif
+		h = (rate >> 1);
+		i = 0;
+		while ((h < hz[i]) && (i < ARRAY_SIZE(d) - 1))
+			i++;
+		data = d[i];
+		data |= EXT_SYNC_SET;
+		result = inv_plat_single_write(st, REG_CONFIG, data);
+		if (result)
+			return result;
+
+		st->chip_config.lpf = data;
+		result = inv_plat_single_write(st, REG_LP_MODE_CTRL, 0);
+	} else {
+		result = inv_plat_single_write(st, REG_LP_MODE_CTRL,
+							BIT_GYRO_CYCLE_EN);
+		if (result)
+			return result;
+		data = 0;
+		result = inv_plat_single_write(st, REG_CONFIG, data | 3);
+	}
+
+	return result;
+}
+
+static int inv_set_div(struct inv_mpu_state *st, int a_d, int g_d)
+{
+	int result, div;
+
+	if (st->chip_config.gyro_enable)
+		div = g_d;
+	else
+		div = a_d;
+	if (st->chip_config.eis_enable)
+		div = 0;
+
+	st->smplrt_div = div;
+	pr_debug("div= %d\n", div);
+	result = inv_plat_single_write(st, REG_SAMPLE_RATE_DIV, div);
+
+	return result;
+}
+
+// 20680 does not support batching
+static int inv_set_batch(struct inv_mpu_state *st)
+{
+#ifdef TIMER_BASED_BATCHING
+	u64 timeout;
+	int required_fifo_size;
+
+	if (st->batch.timeout) {
+		required_fifo_size = st->batch.timeout * st->eng_info[ENGINE_GYRO].running_rate
+					* st->batch.pk_size / 1000;
+		if (required_fifo_size > MAX_BATCH_FIFO_SIZE) {
+			required_fifo_size = MAX_BATCH_FIFO_SIZE;
+			timeout = (required_fifo_size / st->batch.pk_size) * (1000 / st->eng_info[ENGINE_GYRO].running_rate);
+		} else {
+			timeout = st->batch.timeout;
+		}
+	} else {
+		timeout = 1000 / st->eng_info[ENGINE_GYRO].running_rate;
+	}
+	if (timeout <= 1000 / st->eng_info[ENGINE_GYRO].running_rate)
+		st->batch_timeout = 0;
+	else
+		st->batch_timeout = timeout * 1000000; // ms to ns
+#endif
+	st->batch.fifo_wm_th = 0;
+
+	return 0;
+}
+
+static int inv_set_rate(struct inv_mpu_state *st)
+{
+	int g_d, a_d, result, i;
+
+	result = inv_setup_dmp_rate(st);
+	if (result)
+		return result;
+
+	g_d = st->eng_info[ENGINE_GYRO].divider - 1;
+	a_d = st->eng_info[ENGINE_ACCEL].divider - 1;
+	result = inv_set_div(st, a_d, g_d);
+	if (result)
+		return result;
+	result = inv_set_lpf(st, st->eng_info[ENGINE_GYRO].running_rate);
+	if (result)
+		return result;
+	// set ADLPF at this point not to change after accel is enabled
+	result = inv_set_accel_config2(st, false);
+	st->batch.pk_size = 0;
+	for (i = 0; i < SENSOR_NUM_MAX; i++) {
+		if (st->sensor[i].on)
+			st->batch.pk_size +=  st->sensor[i].sample_size;
+	}
+
+	inv_set_batch(st);
+
+	return result;
+}
+
+static int inv_determine_engine(struct inv_mpu_state *st)
+{
+	int i;
+	bool a_en, g_en;
+	int accel_rate, gyro_rate;
+
+	a_en = false;
+	g_en = false;
+	gyro_rate = MPU_INIT_SENSOR_RATE;
+	accel_rate = MPU_INIT_SENSOR_RATE;
+	/* loop the streaming sensors to see which engine needs to be turned on
+		*/
+	for (i = 0; i < SENSOR_NUM_MAX; i++) {
+		if (st->sensor[i].on) {
+			a_en |= st->sensor[i].a_en;
+			g_en |= st->sensor[i].g_en;
+		}
+	}
+
+	if (st->chip_config.eis_enable) {
+		g_en = true;
+		st->eis.frame_count = 0;
+		st->eis.fsync_delay = 0;
+		st->eis.gyro_counter = 0;
+		st->eis.voting_count = 0;
+		st->eis.voting_count_sub = 0;
+		gyro_rate = BASE_SAMPLE_RATE;
+	} else {
+		st->eis.eis_triggered = false;
+		st->eis.prev_state = false;
+	}
+
+	accel_rate = st->sensor[SENSOR_ACCEL].rate;
+	gyro_rate  = max(gyro_rate, st->sensor[SENSOR_GYRO].rate);
+
+	st->ts_algo.clock_base = ENGINE_ACCEL;
+
+	if (g_en) {
+		/* gyro engine needs to be fastest */
+		if (a_en)
+			gyro_rate = max(gyro_rate, accel_rate);
+		accel_rate = gyro_rate;
+		st->ts_algo.clock_base = ENGINE_GYRO;
+	} else if (a_en) {
+		/* accel engine needs to be fastest if gyro engine is off */
+		gyro_rate = accel_rate;
+		st->ts_algo.clock_base = ENGINE_ACCEL;
+	}
+
+	st->eng_info[ENGINE_GYRO].running_rate = gyro_rate;
+	st->eng_info[ENGINE_ACCEL].running_rate = accel_rate;
+	if ((gyro_rate >= BASE_SAMPLE_RATE) ||
+					(accel_rate >= BASE_SAMPLE_RATE))
+		st->mode_1k_on = true;
+	else
+		st->mode_1k_on = false;
+	/* engine divider for pressure and compass is set later */
+	if (st->chip_config.eis_enable || st->mode_1k_on) {
+		st->eng_info[ENGINE_GYRO].divider = 1;
+		st->eng_info[ENGINE_ACCEL].divider = 1;
+		// need to update rate and div for 1khz mode
+		for ( i = 0 ; i < SENSOR_L_NUM_MAX ; i++ ) {
+			if (st->sensor_l[i].on) {
+				st->sensor_l[i].counter = 0;
+				if (st->sensor_l[i].rate)
+					st->sensor_l[i].div =
+						BASE_SAMPLE_RATE
+						/ st->sensor_l[i].rate;
+				else
+					st->sensor_l[i].div = 0xffff;
+			}
+		}
+	} else {
+		st->eng_info[ENGINE_GYRO].divider = BASE_SAMPLE_RATE /
+			st->eng_info[ENGINE_GYRO].running_rate;
+		st->eng_info[ENGINE_ACCEL].divider = BASE_SAMPLE_RATE /
+			st->eng_info[ENGINE_ACCEL].running_rate;
+	}
+
+	for ( i = 0 ; i < SENSOR_L_NUM_MAX ; i++ )
+		st->sensor_l[i].counter = 0;
+
+	inv_calc_engine_dur(&st->eng_info[ENGINE_GYRO]);
+	inv_calc_engine_dur(&st->eng_info[ENGINE_ACCEL]);
+
+	pr_debug("gen: %d aen: %d grate: %d arate: %d\n",
+				g_en, a_en, gyro_rate, accel_rate);
+
+	st->chip_config.gyro_enable = g_en;
+	st->chip_config.accel_enable = a_en;
+
+	return 0;
+}
+
+/*
+ *  set_inv_enable() - enable function.
+ */
+int set_inv_enable(struct iio_dev *indio_dev)
+{
+	int result;
+	struct inv_mpu_state *st = iio_priv(indio_dev);
+
+	result = inv_switch_power_in_lp(st, true);
+	if (result)
+		return result;
+	inv_stop_interrupt(st);
+	inv_determine_engine(st);
+	result = inv_set_rate(st);
+	if (result) {
+		pr_err("inv_set_rate error\n");
+		return result;
+	}
+	result = inv_turn_on_engine(st);
+	if (result) {
+		pr_err("inv_turn_on_engine error\n");
+		return result;
+	}
+	result = inv_reset_fifo(st, false);
+	if (result)
+		return result;
+	result = inv_switch_power_in_lp(st, false);
+	if ((!st->chip_config.gyro_enable) &&
+		(!st->chip_config.accel_enable)) {
+		inv_set_power(st, false);
+		return 0;
+	}
+
+	return result;
+}
+/* dummy function for 20608D */
+int inv_enable_pedometer_interrupt(struct inv_mpu_state *st, bool en)
+{
+	return 0;
+}
+int inv_dmp_read(struct inv_mpu_state *st, int off, int size, u8 *buf)
+{
+	return 0;
+}
+int inv_firmware_load(struct inv_mpu_state *st)
+{
+	return 0;
+}
diff --git a/drivers/iio/imu/inv_mpu/inv_mpu_common.c b/drivers/iio/imu/inv_mpu/inv_mpu_common.c
new file mode 100644
index 0000000..33db034
--- /dev/null
+++ b/drivers/iio/imu/inv_mpu/inv_mpu_common.c
@@ -0,0 +1,988 @@
+/*
+ * Copyright (C) 2012-2017 InvenSense, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#define pr_fmt(fmt) "inv_mpu: " fmt
+#include "inv_mpu_iio.h"
+#ifdef CONFIG_RTC_INTF_ALARM
+#include <linux/android_alarm.h>
+#endif
+#include <linux/export.h>
+
+#ifdef CONFIG_RTC_INTF_ALARM
+s64 get_time_ns(void)
+{
+	struct timespec ts;
+
+	/* get_monotonic_boottime(&ts); */
+
+	/* Workaround for some platform on which monotonic clock and
+	 * Android SystemClock has a gap.
+	 * Use ktime_to_timespec(alarm_get_elapsed_realtime()) instead of
+	 * get_monotonic_boottime() for these platform
+	 */
+
+	ts = ktime_to_timespec(alarm_get_elapsed_realtime());
+
+	return timespec_to_ns(&ts);
+}
+#else
+s64 get_time_ns(void)
+{
+	struct timespec ts;
+
+	get_monotonic_boottime(&ts);
+
+	/* Workaround for some platform on which monotonic clock and
+	 * Android SystemClock has a gap.
+	 * Use ktime_to_timespec(alarm_get_elapsed_realtime()) instead of
+	 * get_monotonic_boottime() for these platform
+	 */
+	return timespec_to_ns(&ts);
+}
+
+#endif
+
+#ifdef ACCEL_BIAS_TEST
+int inv_get_3axis_average(s16 src[], s16 dst[], s16 reset)
+{
+#define BUFFER_SIZE 200
+	static s16 buffer[BUFFER_SIZE][3];
+	static s16 current_position = 0;
+	static s16 ready = 0;
+	int sum[3]= {0,};
+	int i;
+
+	if(reset){
+		current_position = 0;
+		ready = 0;
+	}
+	buffer[current_position][0] = src[0];
+	buffer[current_position][1] = src[1];
+	buffer[current_position][2] = src[2];
+	current_position++;
+	if(current_position == BUFFER_SIZE){
+		ready = 1;
+		current_position = 0;
+	}
+	if(ready){
+		for(i = 0 ; i < BUFFER_SIZE ; i++){
+			sum[0] += buffer[i][0];
+			sum[1] += buffer[i][1];
+			sum[2] += buffer[i][2];
+		}
+		dst[0] = sum[0]/BUFFER_SIZE;
+		dst[1] = sum[1]/BUFFER_SIZE;
+		dst[2] = sum[2]/BUFFER_SIZE;
+		return 1;
+	}
+	return 0;
+}
+#endif
+
+int inv_q30_mult(int a, int b)
+{
+#define DMP_MULTI_SHIFT                 30
+	u64 temp;
+	int result;
+
+	temp = ((u64)a) * b;
+	result = (int)(temp >> DMP_MULTI_SHIFT);
+
+	return result;
+}
+#if defined(CONFIG_INV_MPU_IIO_ICM20648) || \
+					defined(CONFIG_INV_MPU_IIO_ICM20690)
+/* inv_read_secondary(): set secondary registers for reading.
+   The chip must be set as bank 3 before calling.
+ */
+int inv_read_secondary(struct inv_mpu_state *st, int ind, int addr,
+		       int reg, int len)
+{
+	int result;
+
+	result = inv_plat_single_write(st, st->slv_reg[ind].addr,
+				       INV_MPU_BIT_I2C_READ | addr);
+	if (result)
+		return result;
+	result = inv_plat_single_write(st, st->slv_reg[ind].reg, reg);
+	if (result)
+		return result;
+	result = inv_plat_single_write(st, st->slv_reg[ind].ctrl,
+				       INV_MPU_BIT_SLV_EN | len);
+
+	return result;
+}
+
+int inv_execute_read_secondary(struct inv_mpu_state *st, int ind, int addr,
+			       int reg, int len, u8 *d)
+{
+	int result;
+
+	inv_set_bank(st, BANK_SEL_3);
+	result = inv_read_secondary(st, ind, addr, reg, len);
+	if (result)
+		return result;
+	inv_set_bank(st, BANK_SEL_0);
+	result = inv_plat_single_write(st, REG_USER_CTRL, st->i2c_dis |
+				       BIT_I2C_MST_EN);
+	msleep(SECONDARY_INIT_WAIT);
+	result = inv_plat_single_write(st, REG_USER_CTRL, st->i2c_dis);
+	if (result)
+		return result;
+	result = inv_plat_read(st, REG_EXT_SLV_SENS_DATA_00, len, d);
+
+	return result;
+}
+
+/* inv_write_secondary(): set secondary registers for writing.
+   The chip must be set as bank 3 before calling.
+ */
+int inv_write_secondary(struct inv_mpu_state *st, int ind, int addr,
+			int reg, int v)
+{
+	int result;
+
+	result = inv_plat_single_write(st, st->slv_reg[ind].addr, addr);
+	if (result)
+		return result;
+	result = inv_plat_single_write(st, st->slv_reg[ind].reg, reg);
+	if (result)
+		return result;
+	result = inv_plat_single_write(st, st->slv_reg[ind].ctrl,
+				       INV_MPU_BIT_SLV_EN | 1);
+
+	result = inv_plat_single_write(st, st->slv_reg[ind].d0, v);
+
+	return result;
+}
+
+int inv_execute_write_secondary(struct inv_mpu_state *st, int ind, int addr,
+				int reg, int v)
+{
+	int result;
+
+	inv_set_bank(st, BANK_SEL_3);
+	result = inv_write_secondary(st, ind, addr, reg, v);
+	if (result)
+		return result;
+	inv_set_bank(st, BANK_SEL_0);
+	result = inv_plat_single_write(st, REG_USER_CTRL, st->i2c_dis |
+				       BIT_I2C_MST_EN);
+	msleep(SECONDARY_INIT_WAIT);
+	result = inv_plat_single_write(st, REG_USER_CTRL, st->i2c_dis);
+
+	return result;
+}
+
+int inv_set_bank(struct inv_mpu_state *st, u8 bank)
+{
+#ifdef CONFIG_INV_MPU_IIO_ICM20648
+	int r;
+
+	r = inv_plat_single_write(st, REG_BANK_SEL, bank);
+
+	return r;
+#else
+	return 0;
+#endif
+}
+#endif
+
+#ifdef CONFIG_INV_MPU_IIO_ICM20648
+/**
+ *  inv_write_cntl() - Write control word to designated address.
+ *  @st:	Device driver instance.
+ *  @wd:        control word.
+ *  @en:	enable/disable.
+ *  @cntl:	control address to be written.
+ */
+int inv_write_cntl(struct inv_mpu_state *st, u16 wd, bool en, int cntl)
+{
+	int result;
+	u8 reg[2], d_out[2];
+
+	result = mem_r(cntl, 2, d_out);
+	if (result)
+		return result;
+	reg[0] = ((wd >> 8) & 0xff);
+	reg[1] = (wd & 0xff);
+	if (!en) {
+		d_out[0] &= ~reg[0];
+		d_out[1] &= ~reg[1];
+	} else {
+		d_out[0] |= reg[0];
+		d_out[1] |= reg[1];
+	}
+	result = mem_w(cntl, 2, d_out);
+
+	return result;
+}
+#endif
+
+int inv_set_power(struct inv_mpu_state *st, bool power_on)
+{
+	u8 d;
+	int r;
+
+	if ((!power_on) == st->chip_config.is_asleep)
+		return 0;
+
+	d = BIT_CLK_PLL;
+	if (!power_on)
+		d |= BIT_SLEEP;
+
+	r = inv_plat_single_write(st, REG_PWR_MGMT_1, d);
+	if (r)
+		return r;
+
+	if (power_on)
+		usleep_range(REG_UP_TIME_USEC, REG_UP_TIME_USEC);
+
+	st->chip_config.is_asleep = !power_on;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(inv_set_power);
+
+int inv_stop_interrupt(struct inv_mpu_state *st)
+{
+	int res;
+#if defined(CONFIG_INV_MPU_IIO_ICM20648)
+	/* disable_irq_wake alone should work already. However,
+	   it might need system configuration change. From driver side,
+	   we will disable IRQ altogether for non-wakeup sensors. */
+	res = inv_plat_read(st, REG_INT_ENABLE, 1, &st->int_en);
+	if (res)
+		return res;
+	res = inv_plat_read(st, REG_INT_ENABLE_2, 1, &st->int_en_2);
+	if (res)
+		return res;
+	res = inv_plat_single_write(st, REG_INT_ENABLE, 0);
+	if (res)
+		return res;
+	res = inv_plat_single_write(st, REG_INT_ENABLE_2, 0);
+	if (res)
+		return res;
+#endif
+#if defined(CONFIG_INV_MPU_IIO_ICM20608D)
+	res = inv_plat_read(st, REG_INT_ENABLE, 1, &st->int_en);
+	if (res)
+		return res;
+	res = inv_plat_single_write(st, REG_INT_ENABLE, 0);
+	if (res)
+		return res;
+#endif
+#if defined(CONFIG_INV_MPU_IIO_ICM20602) \
+	|| defined(CONFIG_INV_MPU_IIO_ICM20690) \
+	|| defined(CONFIG_INV_MPU_IIO_IAM20680)	
+	res = inv_plat_read(st, REG_INT_ENABLE, 1, &st->int_en);
+	if (res)
+		return res;
+	res = inv_plat_single_write(st, REG_INT_ENABLE, 0);
+	if (res)
+		return res;
+#endif
+	return 0;
+}
+int inv_reenable_interrupt(struct inv_mpu_state *st)
+{
+	int res = 0;
+#if defined(CONFIG_INV_MPU_IIO_ICM20648)
+	res = inv_plat_single_write(st, REG_INT_ENABLE, st->int_en);
+	if (res)
+		return res;
+	res = inv_plat_single_write(st, REG_INT_ENABLE_2, st->int_en_2);
+	if (res)
+		return res;
+#elif defined(CONFIG_INV_MPU_IIO_ICM20608D)
+	res = inv_plat_single_write(st, REG_INT_ENABLE, st->int_en);
+	if (res)
+		return res;
+#endif
+#if defined(CONFIG_INV_MPU_IIO_ICM20602) \
+	|| defined(CONFIG_INV_MPU_IIO_ICM20690) \
+	|| defined(CONFIG_INV_MPU_IIO_IAM20680)	
+	res = inv_plat_single_write(st, REG_INT_ENABLE, st->int_en);
+	if (res)
+		return res;
+#endif
+	return res;
+}
+
+static int inv_lp_en_off_mode(struct inv_mpu_state *st, bool on)
+{
+	int r;
+
+	if (!st->chip_config.is_asleep)
+		return 0;
+
+	r = inv_plat_single_write(st, REG_PWR_MGMT_1, BIT_CLK_PLL);
+	st->chip_config.is_asleep = 0;
+
+	return r;
+}
+#ifdef CONFIG_INV_MPU_IIO_ICM20648
+static int inv_lp_en_on_mode(struct inv_mpu_state *st, bool on)
+{
+	int r = 0;
+	u8 w;
+
+	if ((!st->chip_config.is_asleep) &&
+	    ((!on) == st->chip_config.lp_en_set))
+		return 0;
+
+	w = BIT_CLK_PLL;
+	if ((!on) && (!st->eis.eis_triggered))
+		w |= BIT_LP_EN;
+	r = inv_plat_single_write(st, REG_PWR_MGMT_1, w);
+	st->chip_config.is_asleep = 0;
+	st->chip_config.lp_en_set = (!on);
+	return r;
+}
+#endif
+#if defined(CONFIG_INV_MPU_IIO_ICM20602) \
+	|| defined(CONFIG_INV_MPU_IIO_ICM20690) \
+	|| defined(CONFIG_INV_MPU_IIO_IAM20680)	
+int inv_set_accel_config2(struct inv_mpu_state *st, bool cycle_mode)
+{
+	int cycle_freq[] = {275, 192, 111, 59};
+	int cont_freq[] = {219, 219, 99, 45, 22, 11, 6};
+	int i, r, rate;
+	u8 v;
+
+	v = 0;
+#ifdef CONFIG_INV_MPU_IIO_ICM20690
+	v |= BIT_FIFO_SIZE_1K;
+#endif
+	if (cycle_mode) {
+		rate = (st->eng_info[ENGINE_ACCEL].running_rate << 1);
+		i = ARRAY_SIZE(cycle_freq) - 1;
+		while (i > 0) {
+			if (rate < cycle_freq[i]) {
+				break;
+			}
+			i--;
+		}
+		r = inv_plat_single_write(st, REG_ACCEL_CONFIG_2, v |
+								(i << 4) | 7);
+		if (r)
+			return r;
+	} else {
+		rate = (st->eng_info[ENGINE_ACCEL].running_rate >> 1);
+		for (i = 1; i < ARRAY_SIZE(cont_freq); i++) {
+			if (rate >= cont_freq[i])
+				break;
+		}
+		if (i > 6)
+			i = 6;
+		r = inv_plat_single_write(st, REG_ACCEL_CONFIG_2, v | i);
+		if (r)
+			return r;
+	}
+
+	return 0;
+}
+static int inv_lp_en_on_mode(struct inv_mpu_state *st, bool on)
+{
+	int r = 0;
+	u8 w;
+	bool cond_check;
+
+	if ((!st->chip_config.is_asleep) &&
+					((!on) == st->chip_config.lp_en_set))
+		return 0;
+	cond_check = (!on) && st->cycle_on;
+
+	w = BIT_CLK_PLL;
+	r = inv_plat_single_write(st, REG_PWR_MGMT_1, w);
+	if (cond_check) {
+		w |= BIT_LP_EN;
+		inv_set_accel_config2(st, true);
+		st->chip_config.lp_en_set = true;
+		r = inv_plat_single_write(st, REG_PWR_MGMT_1, w);
+	} else {
+		inv_set_accel_config2(st, false);
+#ifdef CONFIG_INV_MPU_IIO_ICM20690
+		r = inv_plat_single_write(st, REG_PWR_MGMT_1, w | BIT_SLEEP);
+		if (r)
+			return r;
+#endif
+		st->chip_config.lp_en_set = false;
+		r = inv_plat_single_write(st, REG_PWR_MGMT_1, w);
+		msleep(10);
+	}
+	st->chip_config.is_asleep = 0;
+
+	return r;
+}
+#endif
+#ifdef CONFIG_INV_MPU_IIO_ICM20608D
+static int inv_set_accel_config2(struct inv_mpu_state *st)
+{
+	int cont_freq[] = {219, 219, 99, 45, 22, 11, 6};
+	int dec2_cfg = 0;
+	int i, r, rate;
+
+	rate = (st->eng_info[ENGINE_ACCEL].running_rate << 1);
+	i = 0;
+	if (!st->chip_config.eis_enable){
+		while ((rate < cont_freq[i]) && (i < ARRAY_SIZE(cont_freq) - 1))
+			i++;
+		dec2_cfg = 2<<4; //4x
+	}
+	r = inv_plat_single_write(st, REG_ACCEL_CONFIG_2, i | dec2_cfg);
+	if (r)
+		return r;
+	return 0;
+}
+static int inv_lp_en_on_mode(struct inv_mpu_state *st, bool on)
+{
+	int r = 0;
+	u8 w;
+
+	w = BIT_CLK_PLL;
+	if ((!on) && (!st->chip_config.eis_enable))
+		w |= BIT_LP_EN;
+	inv_set_accel_config2(st);
+	r = inv_plat_single_write(st, REG_PWR_MGMT_1, w);
+
+	return r;
+}
+#endif
+int inv_switch_power_in_lp(struct inv_mpu_state *st, bool on)
+{
+	int r;
+
+	if (st->chip_config.lp_en_mode_off)
+		r = inv_lp_en_off_mode(st, on);
+	else
+		r = inv_lp_en_on_mode(st, on);
+
+	return r;
+}
+EXPORT_SYMBOL_GPL(inv_switch_power_in_lp);
+
+int write_be16_to_mem(struct inv_mpu_state *st, u16 data, int addr)
+{
+	u8 d[2];
+
+	d[0] = (data >> 8) & 0xff;
+	d[1] = data & 0xff;
+
+	return mem_w(addr, sizeof(d), d);
+}
+
+int write_be32_to_mem(struct inv_mpu_state *st, u32 data, int addr)
+{
+	cpu_to_be32s(&data);
+	return mem_w(addr, sizeof(data), (u8 *)&data);
+}
+
+int read_be16_from_mem(struct inv_mpu_state *st, u16 *o, int addr)
+{
+	int result;
+	u8 d[2];
+
+	result = mem_r(addr, 2, (u8 *) &d);
+	*o = d[0] << 8 | d[1];
+
+	return result;
+}
+
+int read_be32_from_mem(struct inv_mpu_state *st, u32 *o, int addr)
+{
+	int result;
+	u32 d = 0;
+
+	result = mem_r(addr, 4, (u8 *) &d);
+	*o = be32_to_cpup((__be32 *)(&d));
+
+	return result;
+}
+
+int be32_to_int(u8 *d)
+{
+	return (d[0] << 24) | (d[1] << 16) | (d[2] << 8) | d[3];
+}
+
+u32 inv_get_cntr_diff(u32 curr_counter, u32 prev)
+{
+	u32 diff;
+
+	if (curr_counter > prev)
+		diff = curr_counter - prev;
+	else
+		diff = 0xffffffff - prev + curr_counter + 1;
+
+	return diff;
+}
+
+int inv_write_2bytes(struct inv_mpu_state *st, int addr, int data)
+{
+	u8 d[2];
+
+	if (data < 0 || data > USHRT_MAX)
+		return -EINVAL;
+
+	d[0] = (u8) ((data >> 8) & 0xff);
+	d[1] = (u8) (data & 0xff);
+
+	return mem_w(addr, ARRAY_SIZE(d), d);
+}
+
+
+
+int inv_process_eis(struct inv_mpu_state *st, u16 delay)
+{
+	int tmp1, tmp2, tmp3;
+
+	switch (st->eis.voting_state) {
+	case 0:
+		st->eis.gyro_counter_s[0] = st->eis.gyro_counter;
+		st->eis.fsync_delay_s[0] = delay - st->eis.fsync_delay;
+		st->eis.voting_count = 1;
+		st->eis.voting_count_sub = 0;
+		st->eis.voting_state = 1;
+		break;
+	case 1:
+		if (abs(st->eis.gyro_counter_s[0] -
+						st->eis.gyro_counter) <= 1) {
+			st->eis.voting_count++;
+		} else {
+			st->eis.gyro_counter_s[2] = st->eis.gyro_counter;
+			st->eis.voting_count_sub++;
+			st->eis.voting_state = 2;
+		}
+		if (st->eis.voting_count > 5)
+			st->eis.voting_state = 3;
+		break;
+	case 2:
+		tmp1 = abs(st->eis.gyro_counter_s[0] - st->eis.gyro_counter);
+		tmp2 = abs(st->eis.gyro_counter_s[2] - st->eis.gyro_counter);
+
+		if ((tmp1 < tmp2) && (tmp1 <= 1))
+			st->eis.voting_count++;
+		else
+			st->eis.voting_count_sub++;
+		if (st->eis.voting_count > 5) {
+			st->eis.voting_state = 3;
+			st->eis.voting_count = 0;
+			st->eis.voting_count_sub = 0;
+		}
+
+		if (st->eis.voting_count_sub > 5) {
+			st->eis.gyro_counter_s[0] = st->eis.gyro_counter;
+			st->eis.fsync_delay_s[0] = delay - st->eis.fsync_delay;
+			st->eis.voting_state = 1;
+			st->eis.voting_count = 1;
+			st->eis.voting_count_sub = 0;
+		}
+		break;
+	case 3:
+		tmp1 = abs(st->eis.gyro_counter_s[0] - st->eis.gyro_counter);
+		if (tmp1 == 1) {
+			st->eis.gyro_counter_s[1] = st->eis.gyro_counter;
+			st->eis.fsync_delay_s[1] = delay - st->eis.fsync_delay;
+			st->eis.voting_state = 4;
+			st->eis.voting_count_sub = 1;
+			st->eis.voting_count = 1;
+		}
+		break;
+	case 4:
+		if (st->eis.gyro_counter == st->eis.gyro_counter_s[0]) {
+			tmp1 = delay - st->eis.fsync_delay;
+			tmp2 = abs(tmp1 - st->eis.fsync_delay_s[0]);
+			if (tmp2 < 3) {
+				st->eis.voting_count++;
+			} else {
+				st->eis.fsync_delay_s[2] = tmp1;
+				st->eis.voting_count_sub = 1;
+				st->eis.voting_state = 5;
+			}
+			if (st->eis.voting_count > 5) {
+				st->eis.voting_count = 1;
+				st->eis.voting_state = 6;
+			}
+		}
+		break;
+	case 5:
+		if (st->eis.gyro_counter == st->eis.gyro_counter_s[0]) {
+			tmp1 = delay - st->eis.fsync_delay;
+
+			tmp2 = abs(tmp1 - st->eis.fsync_delay_s[0]);
+			tmp3 = abs(tmp1 - st->eis.fsync_delay_s[2]);
+			if ((tmp2 < tmp3) && (tmp2 < 3))
+				st->eis.voting_count++;
+			else
+				st->eis.voting_count_sub++;
+			if ((st->eis.voting_count > 5) &&
+					(st->eis.voting_count_sub
+					< st->eis.voting_count)) {
+				st->eis.voting_state = 6;
+				st->eis.voting_count = 1;
+			} else if (st->eis.voting_count_sub > 5) {
+				st->eis.fsync_delay_s[0] = tmp1;
+				st->eis.voting_state = 4;
+				st->eis.voting_count = 1;
+			}
+
+		}
+		break;
+	case 6:
+		if (st->eis.gyro_counter == st->eis.gyro_counter_s[1]) {
+			tmp1 = delay - st->eis.fsync_delay;
+			tmp2 = abs(tmp1 - st->eis.fsync_delay_s[1]);
+			if (tmp2 < 3) {
+				st->eis.voting_count++;
+			} else {
+				st->eis.fsync_delay_s[2] = tmp1;
+				st->eis.voting_count_sub = 1;
+				st->eis.voting_count = 1;
+				st->eis.voting_state = 7;
+			}
+			if (st->eis.voting_count > 5)
+				st->eis.voting_state = 8;
+		}
+		break;
+	case 7:
+		if (st->eis.gyro_counter == st->eis.gyro_counter_s[1]) {
+			tmp1 = delay - st->eis.fsync_delay;
+
+			tmp2 = abs(tmp1 - st->eis.fsync_delay_s[1]);
+			tmp3 = abs(tmp1 - st->eis.fsync_delay_s[2]);
+			if ((tmp2 < tmp3) && (tmp2 < 3))
+				st->eis.voting_count++;
+			else
+				st->eis.voting_count_sub++;
+			if ((st->eis.voting_count > 5) &&
+					(st->eis.voting_count_sub
+					< st->eis.voting_count)) {
+				st->eis.voting_state = 8;
+			} else if (st->eis.voting_count_sub > 5) {
+				st->eis.fsync_delay_s[1] = tmp1;
+				st->eis.voting_state = 6;
+				st->eis.voting_count = 1;
+			}
+
+		}
+		break;
+	default:
+		break;
+	}
+
+	pr_debug("de= %d gc= %d\n", delay, st->eis.gyro_counter);
+	st->eis.fsync_delay = delay;
+	st->eis.gyro_counter = 0;
+
+	pr_debug("state=%d g1= %d d1= %d g2= %d d2= %d\n",
+			st->eis.voting_state,
+			st->eis.gyro_counter_s[0],
+			st->eis.fsync_delay_s[0],
+			st->eis.gyro_counter_s[1],
+			st->eis.fsync_delay_s[1]);
+
+	return 0;
+}
+
+int inv_rate_convert(struct inv_mpu_state *st, int ind, int data)
+{
+	int t, out, out1, out2;
+	int base_freq;
+
+	if (data <= MPU_DEFAULT_DMP_FREQ)
+		base_freq = MPU_DEFAULT_DMP_FREQ;
+	else
+		base_freq = BASE_SAMPLE_RATE;
+
+	t = base_freq / data;
+	if (!t)
+		t = 1;
+	out1 = base_freq / (t + 1);
+	out2 = base_freq / t;
+	if ((data - out1) * INV_ODR_BUFFER_MULTI < data)
+		out = out1;
+	else
+		out = out2;
+
+	return out;
+}
+
+static void inv_check_wake_non_wake(struct inv_mpu_state *st,
+			enum SENSOR_L wake, enum SENSOR_L non_wake)
+{
+	int tmp_rate;
+
+	if (!st->sensor_l[wake].on && !st->sensor_l[non_wake].on)
+		return;
+
+	tmp_rate = MPU_INIT_SENSOR_RATE;
+	if (st->sensor_l[wake].on)
+		tmp_rate = st->sensor_l[wake].rate;
+	if (st->sensor_l[non_wake].on)
+		tmp_rate = max(tmp_rate, st->sensor_l[non_wake].rate);
+	st->sensor_l[wake].rate = tmp_rate;
+	st->sensor_l[non_wake].rate = tmp_rate;
+}
+
+static void inv_check_wake_non_wake_divider(struct inv_mpu_state *st,
+			enum SENSOR_L wake, enum SENSOR_L non_wake)
+{
+	if (st->sensor_l[wake].on && st->sensor_l[non_wake].on)
+		st->sensor_l[non_wake].div = 0xffff;
+
+}
+
+#if defined(CONFIG_INV_MPU_IIO_ICM20602) \
+	|| defined(CONFIG_INV_MPU_IIO_ICM20690) \
+	|| defined(CONFIG_INV_MPU_IIO_IAM20680)	
+int inv_check_sensor_on(struct inv_mpu_state *st)
+{
+	int i, max_rate;
+	enum SENSOR_L wake[] = {SENSOR_L_GYRO_WAKE, SENSOR_L_ACCEL_WAKE,
+					SENSOR_L_MAG_WAKE};
+	enum SENSOR_L non_wake[] = {SENSOR_L_GYRO, SENSOR_L_ACCEL,
+					SENSOR_L_MAG};
+
+	st->sensor_l[SENSOR_L_GESTURE_ACCEL].rate = GESTURE_ACCEL_RATE;
+	for (i = 0; i < SENSOR_NUM_MAX; i++)
+		st->sensor[i].on = false;
+	for (i = 0; i < SENSOR_NUM_MAX; i++)
+		st->sensor[i].rate = MPU_INIT_SENSOR_RATE;
+
+	if ((st->step_detector_l_on
+			|| st->step_detector_wake_l_on
+			|| st->step_counter_l_on
+			|| st->step_counter_wake_l_on
+			|| st->chip_config.pick_up_enable
+			|| st->chip_config.tilt_enable)
+			&& (!st->sensor_l[SENSOR_L_ACCEL].on)
+			&& (!st->sensor_l[SENSOR_L_ACCEL_WAKE].on))
+		st->sensor_l[SENSOR_L_GESTURE_ACCEL].on = true;
+	else
+		st->sensor_l[SENSOR_L_GESTURE_ACCEL].on = false;
+
+
+	st->chip_config.wake_on = false;
+	for (i = 0; i < SENSOR_L_NUM_MAX; i++) {
+		if (st->sensor_l[i].on && st->sensor_l[i].rate) {
+			st->sensor[st->sensor_l[i].base].on = true;
+			st->chip_config.wake_on |= st->sensor_l[i].wake_on;
+		}
+	}
+	if (st->sensor_l[SENSOR_L_GESTURE_ACCEL].on &&
+				(!st->sensor[SENSOR_GYRO].on) &&
+				(!st->sensor[SENSOR_COMPASS].on))
+		st->gesture_only_on = true;
+	else
+		st->gesture_only_on = false;
+
+	for (i = 0; i < SENSOR_L_NUM_MAX; i++) {
+		if (st->sensor_l[i].on) {
+			st->sensor[st->sensor_l[i].base].rate =
+			    max(st->sensor[st->sensor_l[i].base].rate,
+							st->sensor_l[i].rate);
+		}
+	}
+	max_rate = MPU_INIT_SENSOR_RATE;
+	if (st->chip_config.eis_enable) {
+		max_rate = ESI_GYRO_RATE;
+		st->sensor_l[SENSOR_L_EIS_GYRO].rate = ESI_GYRO_RATE;
+	}
+
+	for (i = 0; i < SENSOR_NUM_MAX; i++) {
+		if (st->sensor[i].on) {
+			max_rate = max(max_rate, st->sensor[i].rate);
+		}
+	}
+	for (i = 0; i < SENSOR_NUM_MAX; i++) {
+		if (st->sensor[i].on) {
+			st->sensor[i].rate = max_rate;
+		}
+	}
+	for (i = 0; i < ARRAY_SIZE(wake); i++)
+		inv_check_wake_non_wake(st, wake[i], non_wake[i]);
+
+	for (i = 0; i < SENSOR_L_NUM_MAX; i++) {
+		if (st->sensor_l[i].on) {
+			if (st->sensor_l[i].rate)
+				st->sensor_l[i].div =
+				    st->sensor[st->sensor_l[i].base].rate
+							/ st->sensor_l[i].rate;
+			else
+				st->sensor_l[i].div = 0xffff;
+			pr_debug("sensor= %d, div= %d\n",
+						i, st->sensor_l[i].div);
+		}
+	}
+	for (i = 0; i < ARRAY_SIZE(wake); i++)
+		inv_check_wake_non_wake_divider(st, wake[i], non_wake[i]);
+
+	if (st->step_detector_wake_l_on ||
+			st->step_counter_wake_l_on ||
+			st->chip_config.pick_up_enable ||
+			st->chip_config.tilt_enable)
+		st->chip_config.wake_on = true;
+
+	return 0;
+}
+#else
+static void inv_do_check_sensor_on(struct inv_mpu_state *st,
+				enum SENSOR_L *wake,
+				enum SENSOR_L *non_wake, int sensor_size)
+{
+	int i;
+
+	for (i = 0; i < SENSOR_NUM_MAX; i++)
+		st->sensor[i].on = false;
+
+	for (i = 0; i < SENSOR_NUM_MAX; i++)
+		st->sensor[i].rate = MPU_INIT_SENSOR_RATE;
+
+	st->chip_config.wake_on = false;
+	for (i = 0; i < SENSOR_L_NUM_MAX; i++) {
+		if (st->sensor_l[i].on && st->sensor_l[i].rate) {
+			st->sensor[st->sensor_l[i].base].on = true;
+			st->chip_config.wake_on |= st->sensor_l[i].wake_on;
+		}
+	}
+
+	for (i = 0; i < SENSOR_L_NUM_MAX; i++) {
+		if (st->sensor_l[i].on) {
+			st->sensor[st->sensor_l[i].base].rate =
+			    max(st->sensor[st->sensor_l[i].base].rate,
+				st->sensor_l[i].rate);
+		}
+	}
+	for (i = 0; i < sensor_size; i++)
+		inv_check_wake_non_wake(st, wake[i], non_wake[i]);
+
+	for (i = 0; i < SENSOR_L_NUM_MAX; i++) {
+		if (st->sensor_l[i].on) {
+			if (st->sensor_l[i].rate)
+				st->sensor_l[i].div =
+				    st->sensor[st->sensor_l[i].base].rate
+				    / st->sensor_l[i].rate;
+			else
+				st->sensor_l[i].div = 0xffff;
+		}
+	}
+	for (i = 0; i < sensor_size; i++)
+		inv_check_wake_non_wake_divider(st, wake[i], non_wake[i]);
+
+	if (st->step_detector_wake_l_on ||
+			st->step_counter_wake_l_on ||
+			st->chip_config.pick_up_enable ||
+			st->chip_config.tilt_enable ||
+			st->smd.on)
+		st->chip_config.wake_on = true;
+
+}
+#endif
+
+#if defined(CONFIG_INV_MPU_IIO_ICM20608D)
+int inv_check_sensor_on(struct inv_mpu_state *st)
+{
+	enum SENSOR_L wake[] = {SENSOR_L_GYRO_WAKE, SENSOR_L_ACCEL_WAKE,
+				SENSOR_L_SIXQ_WAKE, SENSOR_L_PEDQ_WAKE,
+				SENSOR_L_GYRO_CAL_WAKE};
+	enum SENSOR_L non_wake[] = {SENSOR_L_GYRO, SENSOR_L_ACCEL,
+				SENSOR_L_SIXQ, SENSOR_L_PEDQ,
+				SENSOR_L_GYRO_CAL};
+
+	inv_do_check_sensor_on(st, wake, non_wake, ARRAY_SIZE(wake));
+
+	return 0;
+}
+#endif
+
+#if defined(CONFIG_INV_MPU_IIO_ICM20648)
+int inv_check_sensor_on(struct inv_mpu_state *st)
+{
+	enum SENSOR_L wake[] = {SENSOR_L_GYRO_WAKE, SENSOR_L_ACCEL_WAKE,
+				SENSOR_L_MAG_WAKE, SENSOR_L_ALS_WAKE,
+				SENSOR_L_SIXQ_WAKE, SENSOR_L_PEDQ_WAKE,
+				SENSOR_L_NINEQ_WAKE, SENSOR_L_GEOMAG_WAKE,
+				SENSOR_L_PRESSURE_WAKE,
+				SENSOR_L_GYRO_CAL_WAKE,
+				SENSOR_L_MAG_CAL_WAKE};
+	enum SENSOR_L non_wake[] = {SENSOR_L_GYRO, SENSOR_L_ACCEL,
+					SENSOR_L_MAG, SENSOR_L_ALS,
+					SENSOR_L_SIXQ, SENSOR_L_PEDQ,
+					SENSOR_L_NINEQ, SENSOR_L_GEOMAG,
+					SENSOR_L_PRESSURE,
+					SENSOR_L_GYRO_CAL,
+					SENSOR_L_MAG_CAL};
+
+	inv_do_check_sensor_on(st, wake, non_wake, ARRAY_SIZE(wake));
+
+	return 0;
+}
+#endif
+
+#ifdef CONFIG_PM_SLEEP
+int inv_mpu_suspend(struct iio_dev *indio_dev)
+{
+	struct inv_mpu_state *st = iio_priv(indio_dev);
+
+	/* add code according to different request Start */
+	dev_info(st->dev, "%s suspend\n", st->hw->name);
+	mutex_lock(&indio_dev->mlock);
+
+	st->resume_state = false;
+	if (st->chip_config.wake_on) {
+		enable_irq_wake(st->irq);
+	} else {
+		inv_stop_interrupt(st);
+	}
+
+	mutex_unlock(&indio_dev->mlock);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(inv_mpu_suspend);
+
+/*
+ * inv_mpu_complete(): complete method for this driver.
+ *    This method can be modified according to the request of different
+ *    customers. It basically undo everything suspend is doing
+ *    and recover the chip to what it was before suspend. We use complete to
+ *    make sure that alarm clock resume is finished. If we use resume, the
+ *    alarm clock may not resume yet and get incorrect clock reading.
+ */
+void inv_mpu_complete(struct iio_dev *indio_dev)
+{
+	struct inv_mpu_state *st = iio_priv(indio_dev);
+
+	dev_info(st->dev, "%s resume\n", st->hw->name);
+	if (st->resume_state)
+		return;
+
+	mutex_lock(&indio_dev->mlock);
+
+	if (!st->chip_config.wake_on) {
+		inv_reenable_interrupt(st);
+	} else {
+		disable_irq_wake(st->irq);
+	}
+	/*	resume state is used to synchronize read_fifo such that it won't
+		proceed unless resume is finished. */
+	st->resume_state = true;
+	/*	resume flag is indicating that current clock reading is from resume,
+		it has up to 1 second drift and should do proper processing */
+	st->ts_algo.resume_flag  = true;
+	mutex_unlock(&indio_dev->mlock);
+	wake_up_interruptible(&st->wait_queue);
+
+	return;
+}
+EXPORT_SYMBOL_GPL(inv_mpu_complete);
+#endif
diff --git a/drivers/iio/imu/inv_mpu/inv_mpu_dts.c b/drivers/iio/imu/inv_mpu/inv_mpu_dts.c
new file mode 100644
index 0000000..0b8b3fc
--- /dev/null
+++ b/drivers/iio/imu/inv_mpu/inv_mpu_dts.c
@@ -0,0 +1,343 @@
+/*
+ * Copyright (C) 2012-2017 InvenSense, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/of_gpio.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/regulator/consumer.h>
+#include <linux/export.h>
+
+#include <linux/iio/imu/mpu.h>
+#include "inv_mpu_dts.h"
+#include "inv_mpu_iio.h"
+
+#ifdef CONFIG_OF
+
+static int inv_mpu_power_on(struct mpu_platform_data *pdata)
+{
+	int err;
+
+	if (!IS_ERR(pdata->vdd_ana)) {
+		err = regulator_enable(pdata->vdd_ana);
+		if (err)
+			return err;
+	}
+	if (!IS_ERR(pdata->vdd_i2c)) {
+		err = regulator_enable(pdata->vdd_i2c);
+		if (err)
+			goto error_disable_vdd_ana;
+	}
+
+	return 0;
+
+error_disable_vdd_ana:
+	regulator_disable(pdata->vdd_ana);
+	return err;
+}
+
+static int inv_mpu_power_off(struct mpu_platform_data *pdata)
+{
+	if (!IS_ERR(pdata->vdd_ana))
+		regulator_disable(pdata->vdd_ana);
+	if (!IS_ERR(pdata->vdd_i2c))
+		regulator_disable(pdata->vdd_i2c);
+
+	return 0;
+}
+
+static int inv_parse_orientation_matrix(struct device *dev, s8 *orient)
+{
+	int rc, i;
+	struct device_node *np = dev->of_node;
+	u32 temp_val, temp_val2;
+
+	for (i = 0; i < 9; i++)
+		orient[i] = 0;
+
+	/* parsing axis x orientation matrix */
+	rc = of_property_read_u32(np, "axis_map_x", &temp_val);
+	if (rc) {
+		dev_err(dev, "Unable to read axis_map_x\n");
+		return rc;
+	}
+	rc = of_property_read_u32(np, "negate_x", &temp_val2);
+	if (rc) {
+		dev_err(dev, "Unable to read negate_x\n");
+		return rc;
+	}
+	if (temp_val2)
+		orient[temp_val] = -1;
+	else
+		orient[temp_val] = 1;
+
+	/* parsing axis y orientation matrix */
+	rc = of_property_read_u32(np, "axis_map_y", &temp_val);
+	if (rc) {
+		dev_err(dev, "Unable to read axis_map_y\n");
+		return rc;
+	}
+	rc = of_property_read_u32(np, "negate_y", &temp_val2);
+	if (rc) {
+		dev_err(dev, "Unable to read negate_y\n");
+		return rc;
+	}
+	if (temp_val2)
+		orient[3 + temp_val] = -1;
+	else
+		orient[3 + temp_val] = 1;
+
+	/* parsing axis z orientation matrix */
+	rc = of_property_read_u32(np, "axis_map_z", &temp_val);
+	if (rc) {
+		dev_err(dev, "Unable to read axis_map_z\n");
+		return rc;
+	}
+	rc = of_property_read_u32(np, "negate_z", &temp_val2);
+	if (rc) {
+		dev_err(dev, "Unable to read negate_z\n");
+		return rc;
+	}
+	if (temp_val2)
+		orient[6 + temp_val] = -1;
+	else
+		orient[6 + temp_val] = 1;
+
+	return 0;
+}
+
+static int inv_parse_secondary_orientation_matrix(struct device *dev,
+						  s8 *orient)
+{
+	int rc, i;
+	struct device_node *np = dev->of_node;
+	u32 temp_val, temp_val2;
+
+	for (i = 0; i < 9; i++)
+		orient[i] = 0;
+
+	/* parsing axis x orientation matrix */
+	rc = of_property_read_u32(np, "inven,secondary_axis_map_x", &temp_val);
+	if (rc) {
+		dev_err(dev, "Unable to read secondary axis_map_x\n");
+		return rc;
+	}
+	rc = of_property_read_u32(np, "inven,secondary_negate_x", &temp_val2);
+	if (rc) {
+		dev_err(dev, "Unable to read secondary negate_x\n");
+		return rc;
+	}
+	if (temp_val2)
+		orient[temp_val] = -1;
+	else
+		orient[temp_val] = 1;
+
+	/* parsing axis y orientation matrix */
+	rc = of_property_read_u32(np, "inven,secondary_axis_map_y", &temp_val);
+	if (rc) {
+		dev_err(dev, "Unable to read secondary axis_map_y\n");
+		return rc;
+	}
+	rc = of_property_read_u32(np, "inven,secondary_negate_y", &temp_val2);
+	if (rc) {
+		dev_err(dev, "Unable to read secondary negate_y\n");
+		return rc;
+	}
+	if (temp_val2)
+		orient[3 + temp_val] = -1;
+	else
+		orient[3 + temp_val] = 1;
+
+	/* parsing axis z orientation matrix */
+	rc = of_property_read_u32(np, "inven,secondary_axis_map_z", &temp_val);
+	if (rc) {
+		dev_err(dev, "Unable to read secondary axis_map_z\n");
+		return rc;
+	}
+	rc = of_property_read_u32(np, "inven,secondary_negate_z", &temp_val2);
+	if (rc) {
+		dev_err(dev, "Unable to read secondary negate_z\n");
+		return rc;
+	}
+	if (temp_val2)
+		orient[6 + temp_val] = -1;
+	else
+		orient[6 + temp_val] = 1;
+
+	return 0;
+}
+
+static int inv_parse_secondary(struct device *dev,
+			       struct mpu_platform_data *pdata)
+{
+	int rc;
+	struct device_node *np = dev->of_node;
+	u32 temp_val;
+	const char *name;
+
+	if (of_property_read_string(np, "inven,secondary_type", &name)) {
+		dev_err(dev, "Missing secondary type.\n");
+		return -EINVAL;
+	}
+	if (!strcmp(name, "compass")) {
+		pdata->sec_slave_type = SECONDARY_SLAVE_TYPE_COMPASS;
+	} else if (!strcmp(name, "none")) {
+		pdata->sec_slave_type = SECONDARY_SLAVE_TYPE_NONE;
+		return 0;
+	} else {
+		return -EINVAL;
+	}
+
+	if (of_property_read_string(np, "inven,secondary_name", &name)) {
+		dev_err(dev, "Missing secondary name.\n");
+		return -EINVAL;
+	}
+	if (!strcmp(name, "ak8963"))
+		pdata->sec_slave_id = COMPASS_ID_AK8963;
+	else if (!strcmp(name, "ak8975"))
+		pdata->sec_slave_id = COMPASS_ID_AK8975;
+	else if (!strcmp(name, "ak8972"))
+		pdata->sec_slave_id = COMPASS_ID_AK8972;
+	else if (!strcmp(name, "ak09911"))
+		pdata->sec_slave_id = COMPASS_ID_AK09911;
+	else if (!strcmp(name, "ak09912"))
+		pdata->sec_slave_id = COMPASS_ID_AK09912;
+	else if (!strcmp(name, "ak09916"))
+		pdata->sec_slave_id = COMPASS_ID_AK09916;
+	else
+		return -EINVAL;
+	rc = of_property_read_u32(np, "inven,secondary_reg", &temp_val);
+	if (rc) {
+		dev_err(dev, "Unable to read secondary register\n");
+		return rc;
+	}
+	pdata->secondary_i2c_addr = temp_val;
+	rc = inv_parse_secondary_orientation_matrix(dev,
+						    pdata->
+						    secondary_orientation);
+
+	return rc;
+}
+
+static int inv_parse_aux(struct device *dev, struct mpu_platform_data *pdata)
+{
+	int rc;
+	struct device_node *np = dev->of_node;
+	u32 temp_val;
+	const char *name;
+
+	if (of_property_read_string(np, "inven,aux_type", &name)) {
+		dev_err(dev, "Missing aux type.\n");
+		return -EINVAL;
+	}
+	if (!strcmp(name, "pressure")) {
+		pdata->aux_slave_type = SECONDARY_SLAVE_TYPE_PRESSURE;
+	} else if (!strcmp(name, "none")) {
+		pdata->aux_slave_type = SECONDARY_SLAVE_TYPE_NONE;
+		return 0;
+	} else {
+		return -EINVAL;
+	}
+
+	if (of_property_read_string(np, "inven,aux_name", &name)) {
+		dev_err(dev, "Missing aux name.\n");
+		return -EINVAL;
+	}
+	if (!strcmp(name, "bmp280"))
+		pdata->aux_slave_id = PRESSURE_ID_BMP280;
+	else
+		return -EINVAL;
+
+	rc = of_property_read_u32(np, "inven,aux_reg", &temp_val);
+	if (rc) {
+		dev_err(dev, "Unable to read aux register\n");
+		return rc;
+	}
+	pdata->aux_i2c_addr = temp_val;
+
+	return 0;
+}
+
+static int inv_parse_readonly_secondary(struct device *dev,
+				 	struct mpu_platform_data *pdata)
+{
+	int rc;
+	struct device_node *np = dev->of_node;
+	u32 temp_val;
+	const char *name;
+
+	if (of_property_read_string(np, "inven,read_only_slave_type", &name)) {
+		dev_err(dev, "Missing read only slave type type.\n");
+		return -EINVAL;
+	}
+	if (!strcmp(name, "als")) {
+		pdata->read_only_slave_type = SECONDARY_SLAVE_TYPE_ALS;
+	} else if (!strcmp(name, "none")) {
+		pdata->read_only_slave_type = SECONDARY_SLAVE_TYPE_NONE;
+		return 0;
+	} else {
+		return -EINVAL;
+	}
+
+	if (of_property_read_string(np, "inven,read_only_slave_name", &name)) {
+		dev_err(dev, "Missing read only slave type name.\n");
+		return -EINVAL;
+	}
+	if (!strcmp(name, "apds9930"))
+		pdata->read_only_slave_id = ALS_ID_APDS_9930;
+	else
+		return -EINVAL;
+
+	rc = of_property_read_u32(np, "inven,read_only_slave_reg", &temp_val);
+	if (rc) {
+		dev_err(dev, "Unable to read read only slave reg register\n");
+		return rc;
+	}
+	pdata->read_only_i2c_addr = temp_val;
+
+	return 0;
+}
+
+int invensense_mpu_parse_dt(struct device *dev, struct mpu_platform_data *pdata)
+{
+	int rc;
+
+	rc = inv_parse_orientation_matrix(dev, pdata->orientation);
+	if (rc)
+		return rc;
+	rc = inv_parse_secondary(dev, pdata);
+	if (rc)
+		return rc;
+	inv_parse_aux(dev, pdata);
+
+	inv_parse_readonly_secondary(dev, pdata);
+
+	pdata->vdd_ana = regulator_get(dev, "inven,vdd_ana");
+	if (IS_ERR(pdata->vdd_ana)) {
+		rc = PTR_ERR(pdata->vdd_ana);
+		dev_warn(dev, "regulator get failed vdd_ana-supply rc=%d\n", rc);
+	}
+	pdata->vdd_i2c = regulator_get(dev, "inven,vcc_i2c");
+	if (IS_ERR(pdata->vdd_i2c)) {
+		rc = PTR_ERR(pdata->vdd_i2c);
+		dev_warn(dev, "regulator get failed vcc-i2c-supply rc=%d\n", rc);
+	}
+	pdata->power_on = inv_mpu_power_on;
+	pdata->power_off = inv_mpu_power_off;
+	dev_dbg(dev, "parse dt complete\n");
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(invensense_mpu_parse_dt);
+
+#endif /* CONFIG_OF */
diff --git a/drivers/iio/imu/inv_mpu/inv_mpu_dts.h b/drivers/iio/imu/inv_mpu/inv_mpu_dts.h
new file mode 100644
index 0000000..90966fe
--- /dev/null
+++ b/drivers/iio/imu/inv_mpu/inv_mpu_dts.h
@@ -0,0 +1,25 @@
+/*
+* Copyright (C) 2012-2017 InvenSense, Inc.
+*
+* This software is licensed under the terms of the GNU General Public
+* License version 2, as published by the Free Software Foundation, and
+* may be copied, distributed, and modified under those terms.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*/
+
+#ifndef _INV_MPU_DTS_H_
+#define _INV_MPU_DTS_H_
+
+#include <linux/kernel.h>
+#include <linux/iio/imu/mpu.h>
+
+#ifdef CONFIG_OF
+int invensense_mpu_parse_dt(struct device *dev,
+			    struct mpu_platform_data *pdata);
+#endif
+
+#endif /* #ifndef _INV_MPU_DTS_H_ */
diff --git a/drivers/iio/imu/inv_mpu/inv_mpu_i2c.c b/drivers/iio/imu/inv_mpu/inv_mpu_i2c.c
new file mode 100644
index 0000000..e7838fc
--- /dev/null
+++ b/drivers/iio/imu/inv_mpu/inv_mpu_i2c.c
@@ -0,0 +1,556 @@
+/*
+* Copyright (C) 2012-2018 InvenSense, Inc.
+*
+* This software is licensed under the terms of the GNU General Public
+* License version 2, as published by the Free Software Foundation, and
+* may be copied, distributed, and modified under those terms.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*/
+#define pr_fmt(fmt) "inv_mpu: " fmt
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/i2c.h>
+#include <linux/err.h>
+#include <linux/delay.h>
+#include <linux/sysfs.h>
+#include <linux/jiffies.h>
+#include <linux/irq.h>
+#include <linux/interrupt.h>
+#include <linux/kfifo.h>
+#include <linux/poll.h>
+#include <linux/miscdevice.h>
+#include <linux/spinlock.h>
+
+#include "inv_mpu_iio.h"
+#include "inv_mpu_dts.h"
+
+#define CONFIG_DYNAMIC_DEBUG_I2C 0
+
+/**
+ *  inv_i2c_read_base() - Read one or more bytes from the device registers.
+ *  @st:	Device driver instance.
+ *  @i2c_addr:  i2c address of device.
+ *  @reg:	First device register to be read from.
+ *  @length:	Number of bytes to read.
+ *  @data:	Data read from device.
+ *  NOTE:This is not re-implementation of i2c_smbus_read because i2c
+ *       address could be specified in this case. We could have two different
+ *       i2c address due to secondary i2c interface.
+ */
+int inv_i2c_read_base(struct inv_mpu_state *st, u16 i2c_addr,
+						u8 reg, u16 length, u8 *data)
+{
+	struct i2c_msg msgs[2];
+	int res;
+
+	if (!data)
+		return -EINVAL;
+
+	msgs[0].addr = i2c_addr;
+	msgs[0].flags = 0;	/* write */
+	msgs[0].buf = &reg;
+	msgs[0].len = 1;
+
+	msgs[1].addr = i2c_addr;
+	msgs[1].flags = I2C_M_RD;
+	msgs[1].buf = data;
+	msgs[1].len = length;
+
+	res = i2c_transfer(st->sl_handle, msgs, 2);
+
+	if (res < 2) {
+		if (res >= 0)
+			res = -EIO;
+	} else
+		res = 0;
+	INV_I2C_INC_MPUWRITE(3);
+	INV_I2C_INC_MPUREAD(length);
+
+	return res;
+}
+
+/**
+ *  inv_i2c_single_write_base() - Write a byte to a device register.
+ *  @st:	Device driver instance.
+ *  @i2c_addr:  I2C address of the device.
+ *  @reg:	Device register to be written to.
+ *  @data:	Byte to write to device.
+ *  NOTE:This is not re-implementation of i2c_smbus_write because i2c
+ *       address could be specified in this case. We could have two different
+ *       i2c address due to secondary i2c interface.
+ */
+int inv_i2c_single_write_base(struct inv_mpu_state *st,
+						u16 i2c_addr, u8 reg, u8 data)
+{
+	u8 tmp[2];
+	struct i2c_msg msg;
+	int res;
+
+	tmp[0] = reg;
+	tmp[1] = data;
+
+	msg.addr = i2c_addr;
+	msg.flags = 0;		/* write */
+	msg.buf = tmp;
+	msg.len = 2;
+
+	INV_I2C_INC_MPUWRITE(3);
+
+	res = i2c_transfer(st->sl_handle, &msg, 1);
+	if (res < 1) {
+		if (res == 0)
+			res = -EIO;
+		return res;
+	} else
+		return 0;
+}
+
+static int inv_i2c_single_write(struct inv_mpu_state *st, u8 reg, u8 data)
+{
+	return inv_i2c_single_write_base(st, st->i2c_addr, reg, data);
+}
+
+static int inv_i2c_read(struct inv_mpu_state *st, u8 reg, int len, u8 *data)
+{
+	return inv_i2c_read_base(st, st->i2c_addr, reg, len, data);
+}
+
+static int _memory_write(struct inv_mpu_state *st, u8 mpu_addr, u16 mem_addr,
+						u32 len, u8 const *data)
+{
+	u8 bank[2];
+	u8 addr[2];
+	u8 buf[513];
+
+	struct i2c_msg msgs[3];
+	int res;
+
+	if (!data || !st)
+		return -EINVAL;
+
+	if (len >= (sizeof(buf) - 1))
+		return -ENOMEM;
+
+	bank[0] = REG_MEM_BANK_SEL;
+	bank[1] = mem_addr >> 8;
+
+	addr[0] = REG_MEM_START_ADDR;
+	addr[1] = mem_addr & 0xFF;
+
+	buf[0] = REG_MEM_R_W;
+	memcpy(buf + 1, data, len);
+
+	/* write message */
+	msgs[0].addr = mpu_addr;
+	msgs[0].flags = 0;
+	msgs[0].buf = bank;
+	msgs[0].len = sizeof(bank);
+
+	msgs[1].addr = mpu_addr;
+	msgs[1].flags = 0;
+	msgs[1].buf = addr;
+	msgs[1].len = sizeof(addr);
+
+	msgs[2].addr = mpu_addr;
+	msgs[2].flags = 0;
+	msgs[2].buf = (u8 *) buf;
+	msgs[2].len = len + 1;
+
+	INV_I2C_INC_MPUWRITE(3 + 3 + (2 + len));
+
+#if CONFIG_DYNAMIC_DEBUG_I2C
+	{
+		char *write = 0;
+		pr_debug("%s WM%02X%02X%02X%s%s - %d\n", st->hw->name,
+			mpu_addr, bank[1], addr[1],
+			wr_pr_debug_begin(data, len, write),
+			wr_pr_debug_end(write), len);
+	}
+#endif
+
+	res = i2c_transfer(st->sl_handle, msgs, 3);
+	if (res != 3) {
+		if (res >= 0)
+			res = -EIO;
+		return res;
+	} else {
+		return 0;
+	}
+}
+
+static int inv_i2c_mem_write(struct inv_mpu_state *st, u8 mpu_addr, u16 mem_addr,
+						u32 len, u8 const *data)
+{
+	int r, i, j;
+#define DMP_MEM_CMP_SIZE 16
+	u8 w[DMP_MEM_CMP_SIZE];
+	bool retry;
+
+	j = 0;
+	retry = true;
+	while ((j < 3) && retry) {
+		retry = false;
+		r = _memory_write(st, mpu_addr, mem_addr, len, data);
+		if (len < DMP_MEM_CMP_SIZE) {
+			r = mem_r(mem_addr, len, w);
+			for (i = 0; i < len; i++) {
+				if (data[i] != w[i]) {
+					pr_debug
+				("error write=%x, len=%d,data=%x, w=%x, i=%d\n",
+					mem_addr, len, data[i], w[i], i);
+					retry = true;
+				}
+			}
+		}
+		j++;
+	}
+
+	return r;
+}
+
+static int inv_i2c_mem_read(struct inv_mpu_state *st, u8 mpu_addr, u16 mem_addr,
+						u32 len, u8 *data)
+{
+	u8 bank[2];
+	u8 addr[2];
+	u8 buf;
+
+	struct i2c_msg msgs[4];
+	int res;
+
+	if (!data || !st)
+		return -EINVAL;
+
+	bank[0] = REG_MEM_BANK_SEL;
+	bank[1] = mem_addr >> 8;
+
+	addr[0] = REG_MEM_START_ADDR;
+	addr[1] = mem_addr & 0xFF;
+
+	buf = REG_MEM_R_W;
+
+	/* write message */
+	msgs[0].addr = mpu_addr;
+	msgs[0].flags = 0;
+	msgs[0].buf = bank;
+	msgs[0].len = sizeof(bank);
+
+	msgs[1].addr = mpu_addr;
+	msgs[1].flags = 0;
+	msgs[1].buf = addr;
+	msgs[1].len = sizeof(addr);
+
+	msgs[2].addr = mpu_addr;
+	msgs[2].flags = 0;
+	msgs[2].buf = &buf;
+	msgs[2].len = 1;
+
+	msgs[3].addr = mpu_addr;
+	msgs[3].flags = I2C_M_RD;
+	msgs[3].buf = data;
+	msgs[3].len = len;
+
+	res = i2c_transfer(st->sl_handle, msgs, 4);
+	if (res != 4) {
+		if (res >= 0)
+			res = -EIO;
+	} else
+		res = 0;
+	INV_I2C_INC_MPUWRITE(3 + 3 + 3);
+	INV_I2C_INC_MPUREAD(len);
+
+#if CONFIG_DYNAMIC_DEBUG_I2C
+	{
+		char *read = 0;
+		pr_debug("%s RM%02X%02X%02X%02X - %s%s\n", st->hw->name,
+			mpu_addr, bank[1], addr[1], len,
+			wr_pr_debug_begin(data, len, read),
+			wr_pr_debug_end(read));
+	}
+#endif
+
+	return res;
+}
+
+/*
+ *  inv_mpu_probe() - probe function.
+ */
+static int inv_mpu_probe(struct i2c_client *client,
+			const struct i2c_device_id *id)
+{
+	struct inv_mpu_state *st;
+	struct iio_dev *indio_dev;
+	int result;
+
+	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
+		result = -ENOSYS;
+		pr_err("I2c function error\n");
+		goto out_no_free;
+	}
+
+#ifdef KERNEL_VERSION_4_X
+	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*st));
+	if (indio_dev == NULL) {
+		pr_err("memory allocation failed\n");
+		result = -ENOMEM;
+		goto out_no_free;
+	}
+#else
+	indio_dev = iio_device_alloc(sizeof(*st));
+	if (indio_dev == NULL) {
+		pr_err("memory allocation failed\n");
+		result = -ENOMEM;
+		goto out_no_free;
+	}
+#endif
+	st = iio_priv(indio_dev);
+	st->client = client;
+	st->sl_handle = client->adapter;
+	st->i2c_addr = client->addr;
+	st->write = inv_i2c_single_write;
+	st->read = inv_i2c_read;
+	st->mem_write = inv_i2c_mem_write;
+	st->mem_read = inv_i2c_mem_read;
+	st->dev = &client->dev;
+	st->bus_type = BUS_I2C;
+#ifdef CONFIG_OF
+	result = invensense_mpu_parse_dt(st->dev, &st->plat_data);
+	if (result)
+#  ifdef KERNEL_VERSION_4_X
+		return -ENODEV;
+#  else
+		goto out_free;
+#  endif
+
+	/* Power on device */
+	if (st->plat_data.power_on) {
+		result = st->plat_data.power_on(&st->plat_data);
+		if (result < 0) {
+			dev_err(st->dev, "power_on failed: %d\n", result);
+#  ifdef KERNEL_VERSION_4_X
+			return -ENODEV;
+#  else
+			goto out_free;
+#  endif
+		}
+		pr_info("%s: power on here.\n", __func__);
+	}
+	pr_info("%s: power on.\n", __func__);
+
+	msleep(100);
+#else
+	if (dev_get_platdata(st->dev) == NULL)
+#  ifdef KERNEL_VERSION_4_X
+		return -ENODEV;
+#  else
+		goto out_free;
+#  endif
+	st->plat_data = *(struct mpu_platform_data *)dev_get_platdata(st->dev);
+#endif
+
+	/* power is turned on inside check chip type */
+	result = inv_check_chip_type(indio_dev, id->name);
+	if (result)
+#ifdef KERNEL_VERSION_4_X
+		return -ENODEV;
+#else
+		goto out_free;
+#endif
+
+	/* Make state variables available to all _show and _store functions. */
+	i2c_set_clientdata(client, indio_dev);
+	indio_dev->dev.parent = st->dev;
+	indio_dev->name = id->name;
+
+	st->irq = client->irq;
+
+	result = inv_mpu_configure_ring(indio_dev);
+	if (result) {
+		pr_err("configure ring buffer fail\n");
+		goto out_free;
+	}
+#ifdef KERNEL_VERSION_4_X
+	INV_I2C_SETIRQ(IRQ_MPU, st->irq);
+	result = devm_iio_device_register(st->dev, indio_dev);
+	if (result) {
+		pr_err("IIO device register fail\n");
+		goto out_unreg_ring;
+	}
+#else
+	result = iio_buffer_register(indio_dev, indio_dev->channels,
+				     indio_dev->num_channels);
+	if (result) {
+		pr_err("ring buffer register fail\n");
+		goto out_unreg_ring;
+	}
+	INV_I2C_SETIRQ(IRQ_MPU, client->irq);
+	result = iio_device_register(indio_dev);
+	if (result) {
+		pr_err("IIO device register fail\n");
+		goto out_remove_ring;
+	}
+#endif
+
+	result = inv_create_dmp_sysfs(indio_dev);
+	if (result) {
+		pr_err("create dmp sysfs failed\n");
+		goto out_unreg_iio;
+	}
+	init_waitqueue_head(&st->wait_queue);
+	st->resume_state = true;
+#ifdef CONFIG_HAS_WAKELOCK
+	wake_lock_init(&st->wake_lock, WAKE_LOCK_SUSPEND, "inv_mpu");
+#else
+	wakeup_source_init(&st->wake_lock, "inv_mpu");
+#endif
+	dev_info(st->dev, "%s ma-kernel-%s is ready to go!\n",
+				indio_dev->name, INVENSENSE_DRIVER_VERSION);
+
+#ifdef SENSOR_DATA_FROM_REGISTERS
+	pr_info("Data read from registers\n");
+#else
+	pr_info("Data read from FIFO\n");
+#endif
+#ifdef TIMER_BASED_BATCHING
+	pr_info("Timer based batching\n");
+#endif
+
+	return 0;
+#ifdef KERNEL_VERSION_4_X
+out_unreg_iio:
+	devm_iio_device_unregister(st->dev, indio_dev);
+out_unreg_ring:
+	inv_mpu_unconfigure_ring(indio_dev);
+out_free:
+	devm_iio_device_free(st->dev, indio_dev);
+out_no_free:
+#else
+out_unreg_iio:
+	iio_device_unregister(indio_dev);
+out_remove_ring:
+	iio_buffer_unregister(indio_dev);
+out_unreg_ring:
+	inv_mpu_unconfigure_ring(indio_dev);
+out_free:
+	iio_device_free(indio_dev);
+out_no_free:
+#endif
+	dev_err(st->dev, "%s failed %d\n", __func__, result);
+
+	return -EIO;
+}
+
+static void inv_mpu_shutdown(struct i2c_client *client)
+{
+	struct iio_dev *indio_dev = i2c_get_clientdata(client);
+	struct inv_mpu_state *st = iio_priv(indio_dev);
+	int result;
+
+	mutex_lock(&indio_dev->mlock);
+	inv_switch_power_in_lp(st, true);
+	dev_dbg(st->dev, "Shutting down %s...\n", st->hw->name);
+
+	/* reset to make sure previous state are not there */
+	result = inv_plat_single_write(st, REG_PWR_MGMT_1, BIT_H_RESET);
+	if (result)
+		dev_err(st->dev, "Failed to reset %s\n",
+			st->hw->name);
+	msleep(POWER_UP_TIME);
+	/* turn off power to ensure gyro engine is off */
+	result = inv_set_power(st, false);
+	if (result)
+		dev_err(st->dev, "Failed to turn off %s\n",
+			st->hw->name);
+	inv_switch_power_in_lp(st, false);
+	mutex_unlock(&indio_dev->mlock);
+}
+
+/*
+ *  inv_mpu_remove() - remove function.
+ */
+static int inv_mpu_remove(struct i2c_client *client)
+{
+	struct iio_dev *indio_dev = i2c_get_clientdata(client);
+	struct inv_mpu_state *st = iio_priv(indio_dev);
+
+#ifdef KERNEL_VERSION_4_X
+	devm_iio_device_unregister(st->dev, indio_dev);
+#else
+	iio_device_unregister(indio_dev);
+	iio_buffer_unregister(indio_dev);
+#endif
+	inv_mpu_unconfigure_ring(indio_dev);
+#ifdef KERNEL_VERSION_4_X
+	devm_iio_device_free(st->dev, indio_dev);
+#else
+	iio_device_free(indio_dev);
+#endif
+	dev_info(st->dev, "inv-mpu-iio module removed.\n");
+
+	return 0;
+}
+
+#ifdef CONFIG_PM_SLEEP
+static int inv_mpu_i2c_suspend(struct device *dev)
+{
+	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
+
+	return inv_mpu_suspend(indio_dev);
+}
+
+static void inv_mpu_i2c_complete(struct device *dev)
+{
+	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
+
+	inv_mpu_complete(indio_dev);
+}
+#endif
+
+static const struct dev_pm_ops inv_mpu_i2c_pmops = {
+#ifdef CONFIG_PM_SLEEP
+	.suspend = inv_mpu_i2c_suspend,
+	.complete = inv_mpu_i2c_complete,
+#endif
+};
+
+/* device id table is used to identify what device can be
+ * supported by this driver
+ */
+static const struct i2c_device_id inv_mpu_id[] = {
+#ifdef CONFIG_INV_MPU_IIO_ICM20648
+	{"icm20645", ICM20645},
+	{"icm10340", ICM10340},
+	{"icm20648", ICM20648},
+#else
+	{"icm20608d", ICM20608D},
+	{"icm20690", ICM20690},
+	{"icm20602", ICM20602},
+	{"iam20680", IAM20680},
+#endif
+	{}
+};
+
+MODULE_DEVICE_TABLE(i2c, inv_mpu_id);
+
+static struct i2c_driver inv_mpu_driver = {
+	.probe = inv_mpu_probe,
+	.remove = inv_mpu_remove,
+	.shutdown = inv_mpu_shutdown,
+	.id_table = inv_mpu_id,
+	.driver = {
+		.owner = THIS_MODULE,
+		.name = "inv-mpu-iio-i2c",
+		.pm = &inv_mpu_i2c_pmops,
+	},
+};
+module_i2c_driver(inv_mpu_driver);
+
+MODULE_AUTHOR("Invensense Corporation");
+MODULE_DESCRIPTION("Invensense I2C device driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/iio/imu/inv_mpu/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu/inv_mpu_iio.h
new file mode 100644
index 0000000..9e73165
--- /dev/null
+++ b/drivers/iio/imu/inv_mpu/inv_mpu_iio.h
@@ -0,0 +1,1138 @@
+/*
+ * Copyright (C) 2012-2018 InvenSense, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef _INV_MPU_IIO_H_
+#define _INV_MPU_IIO_H_
+
+#include <linux/version.h>
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0))
+#define KERNEL_VERSION_4_X
+#endif
+
+#include <linux/i2c.h>
+#include <linux/kfifo.h>
+#include <linux/miscdevice.h>
+#include <linux/spinlock.h>
+#include <linux/delay.h>
+#include <linux/iio/imu/mpu.h>
+#include <linux/interrupt.h>
+#include <linux/semaphore.h>
+#ifdef CONFIG_HAS_WAKELOCK
+#include <linux/wakelock.h>
+#else
+#include <linux/pm_wakeup.h>
+#endif
+#include <linux/wait.h>
+
+#include <linux/iio/sysfs.h>
+#include <linux/iio/iio.h>
+#include <linux/iio/kfifo_buf.h>
+
+#ifdef CONFIG_INV_MPU_IIO_ICM20648
+#include "icm20648/dmp3Default.h"
+#endif
+#ifdef CONFIG_INV_MPU_IIO_ICM20608D
+#include "icm20608d/dmp3Default_20608D.h"
+#endif
+
+#include "inv_test/inv_counters.h"
+
+#if defined(CONFIG_INV_MPU_IIO_ICM20648)
+#include "icm20648/inv_mpu_iio_reg_20648.h"
+#elif defined(CONFIG_INV_MPU_IIO_ICM20602)
+#include "icm20602/inv_mpu_iio_reg_20602.h"
+#elif defined(CONFIG_INV_MPU_IIO_ICM20608D)
+#include "icm20608d/inv_mpu_iio_reg_20608.h"
+#elif defined(CONFIG_INV_MPU_IIO_ICM20690)
+#include "icm20690/inv_mpu_iio_reg_20690.h"
+#elif defined(CONFIG_INV_MPU_IIO_IAM20680)
+#include "iam20680/inv_mpu_iio_reg_20680.h"
+#endif
+
+#define INVENSENSE_DRIVER_VERSION		"8.1.2-simple-test1"
+
+/* #define DEBUG */
+
+/* #define ACCEL_BIAS_TEST */
+
+/* #define BIAS_CONFIDENCE_HIGH 1 */
+
+#define MAX_FIFO_READ_SIZE       128
+#define MAX_DMP_READ_SIZE        16
+
+/* data header defines */
+#define WAKE_HDR                 0x8000
+
+#define ACCEL_HDR                1
+#define GYRO_HDR                 2
+#define COMPASS_HDR              3
+#define ALS_HDR                  4
+#define SIXQUAT_HDR              5
+#define NINEQUAT_HDR             6
+#define PEDQUAT_HDR              7
+#define GEOMAG_HDR               8
+#define PRESSURE_HDR             9
+#define GYRO_CALIB_HDR           10
+#define COMPASS_CALIB_HDR        11
+#define STEP_COUNTER_HDR         12
+#define STEP_DETECTOR_HDR        13
+#define STEP_COUNT_HDR           14
+#define ACTIVITY_HDR             15
+#define PICK_UP_HDR              16
+#define EMPTY_MARKER             17
+#define END_MARKER               18
+#define COMPASS_ACCURACY_HDR     19
+#define ACCEL_ACCURACY_HDR       20
+#define GYRO_ACCURACY_HDR        21
+#define EIS_GYRO_HDR             36
+#define EIS_CALIB_HDR            37
+#define LPQ_HDR                  38
+
+#define ACCEL_WAKE_HDR           (ACCEL_HDR | WAKE_HDR)
+#define GYRO_WAKE_HDR            (GYRO_HDR | WAKE_HDR)
+#define COMPASS_WAKE_HDR         (COMPASS_HDR | WAKE_HDR)
+#define ALS_WAKE_HDR             (ALS_HDR | WAKE_HDR)
+#define SIXQUAT_WAKE_HDR         (SIXQUAT_HDR | WAKE_HDR)
+#define NINEQUAT_WAKE_HDR        (NINEQUAT_HDR | WAKE_HDR)
+#define PEDQUAT_WAKE_HDR         (PEDQUAT_HDR | WAKE_HDR)
+#define GEOMAG_WAKE_HDR          (GEOMAG_HDR | WAKE_HDR)
+#define PRESSURE_WAKE_HDR        (PRESSURE_HDR | WAKE_HDR)
+#define GYRO_CALIB_WAKE_HDR      (GYRO_CALIB_HDR | WAKE_HDR)
+#define COMPASS_CALIB_WAKE_HDR   (COMPASS_CALIB_HDR | WAKE_HDR)
+#define STEP_COUNTER_WAKE_HDR    (STEP_COUNTER_HDR | WAKE_HDR)
+#define STEP_DETECTOR_WAKE_HDR   (STEP_DETECTOR_HDR | WAKE_HDR)
+
+/* init parameters */
+#define MPU_INIT_SMD_THLD        1500
+#define MPU_INIT_GYRO_SCALE      3
+#define MPU_INIT_ACCEL_SCALE     2
+#define MPU_INIT_PED_INT_THRESH  2
+#define MPU_INIT_PED_STEP_THRESH 6
+#define MPU_4X_TS_GYRO_SHIFT      (3160000 / 2)
+#define DMP_START_ADDR_20645     0x900
+#define DMP_START_ADDR_20648     0x1000
+#define DMP_START_ADDR_10340     0x0a60
+#define DMP_START_ADDR_20608D    0x4B0
+#define MAX_WR_SZ                  100
+#define WOM_DELAY_THRESHOLD      200
+#define INV_ODR_BUFFER_MULTI     20
+#define INV_ODR_OVER_FACTOR      20
+
+#define COVARIANCE_SIZE          14
+#define ACCEL_COVARIANCE_SIZE  (COVARIANCE_SIZE * sizeof(int))
+
+enum inv_bus_type {
+	BUS_I2C = 0,
+	BUS_SPI,
+};
+
+struct inv_mpu_state;
+
+enum INV_ENGINE {
+	ENGINE_GYRO = 0,
+	ENGINE_ACCEL,
+	ENGINE_PRESSURE,
+	ENGINE_I2C,
+	ENGINE_NUM_MAX,
+};
+
+/**
+ *  struct inv_hw_s - Other important hardware information.
+ *  @num_reg:	Number of registers on device.
+ *  @name:      name of the chip
+ */
+struct inv_hw_s {
+	u8 num_reg;
+	u8 *name;
+};
+
+/**
+ *  struct inv_sensor - information for each sensor.
+ *  @ts: this sensors timestamp.
+ *  @ts_adj: sensor timestamp adjustment.
+ *  @previous_ts: previous timestamp for this sensor.
+ *  @dur: duration between samples in ns.
+ *  @rate:  sensor data rate.
+ *  @sample_size: number of bytes for the sensor.
+ *  @odr_addr: output data rate address in DMP.
+ *  @counter_addr: output counter address in DMP.
+ *  @output: output on/off control word.
+ *  @time_calib: calibrate timestamp.
+ *  @sample_calib: calibrate bytes accumulated.
+ *  @div:         divider in DMP mode.
+ *  @calib_flag:  calibrate flag used to improve the accuracy of estimation.
+ *  @on:    sensor on/off.
+ *  @a_en:  accel engine requirement.
+ *  @g_en:  gyro engine requirement.
+ *  @c_en:  compass_engine requirement.
+ *  @p_en:  pressure engine requirement.
+ *  @engine_base: engine base for this sensor.
+ *  @count: number of samples in one session.
+ *  @send: decide whether to send this sample or not.
+ */
+struct inv_sensor {
+	u64 ts;
+	s64 ts_adj;
+	u64 previous_ts;
+	int dur;
+	int rate;
+	u8 sample_size;
+	int odr_addr;
+	int counter_addr;
+	u16 output;
+	u64 time_calib;
+	u32 sample_calib;
+	int div;
+	bool calib_flag;
+	bool on;
+	bool a_en;
+	bool g_en;
+	bool c_en;
+	bool p_en;
+	enum INV_ENGINE engine_base;
+	int count;
+	bool send;
+};
+
+/**
+ *  struct inv_sensor - information for each sensor.
+ *  @sample_size: number of bytes for the sensor.
+ *  @output: output on/off control word.
+ *  @on:    sensor on/off.
+ *  @header: accuracy header for communicate with HAL
+ *dd  @count: number of samples in one session.
+ */
+struct inv_sensor_accuracy {
+	u16 output;
+	u8 sample_size;
+	bool on;
+	u16 header;
+};
+
+enum SENSOR_ACCURACY {
+	SENSOR_ACCEL_ACCURACY = 0,
+	SENSOR_GYRO_ACCURACY,
+	SENSOR_COMPASS_ACCURACY,
+	SENSOR_ACCURACY_NUM_MAX,
+};
+
+enum SENSOR_L {
+	SENSOR_L_ACCEL = 0,
+	SENSOR_L_GYRO,
+	SENSOR_L_MAG,
+	SENSOR_L_ALS,
+	SENSOR_L_SIXQ,
+	SENSOR_L_THREEQ,
+	SENSOR_L_NINEQ,
+	SENSOR_L_PEDQ,
+	SENSOR_L_GEOMAG,
+	SENSOR_L_PRESSURE,
+	SENSOR_L_GYRO_CAL,
+	SENSOR_L_MAG_CAL,
+	SENSOR_L_EIS_GYRO,
+	/*wake sensors */
+	SENSOR_L_ACCEL_WAKE = 13,
+	SENSOR_L_GYRO_WAKE,
+	SENSOR_L_MAG_WAKE,
+	SENSOR_L_ALS_WAKE,
+	SENSOR_L_SIXQ_WAKE,
+	SENSOR_L_NINEQ_WAKE,
+	SENSOR_L_PEDQ_WAKE,
+	SENSOR_L_GEOMAG_WAKE,
+	SENSOR_L_PRESSURE_WAKE,
+	SENSOR_L_GYRO_CAL_WAKE,
+	SENSOR_L_MAG_CAL_WAKE,
+	SENSOR_L_GESTURE_ACCEL,
+	SENSOR_L_NUM_MAX,
+};
+
+/**
+ *  struct android_l_sensor - information for each android sensor.
+ *  @ts: this sensors timestamp.
+ *  @base: android sensor based on invensense sensor.
+ *  @rate: output rate.
+ *  @on:  sensor on/off.
+ *  @wake_on: wake on sensor is on/off.
+ *  @div: divider for the output.
+ *  @counter: counter works with the divider.
+ *  @header: header for the output.
+ */
+struct android_l_sensor {
+	u64 ts;
+	enum INV_SENSORS base;
+	int rate;
+	bool on;
+	bool wake_on;
+	int div;
+	int counter;
+	u16 header;
+};
+
+/**
+ *  struct inv_batch - information for batchmode.
+ *  @on: normal batch mode on.
+ *  @default_on: default batch on. This is optimization option.
+ *  @overflow_on: overflow mode for batchmode.
+ *  @wake_fifo_on: overflow for suspend mode.
+ *  @step_only: mean only step detector data is batched.
+ *  @post_isr_run: mean post isr has runned once.
+ *  @counter: counter for batch mode.
+ *  @timeout: nominal timeout value for batchmode in milliseconds.
+ *  @max_rate: max rate for all batched sensors.
+ *  @pk_size: packet size;
+ *  @engine_base: engine base batch mode should stick to.
+ */
+struct inv_batch {
+	bool on;
+	bool default_on;
+	bool overflow_on;
+	bool wake_fifo_on;
+	bool step_only;
+	bool post_isr_run;
+	u32 counter;
+	u32 timeout;
+	u32 max_rate;
+	u32 pk_size;
+	u32 fifo_wm_th;
+	enum INV_ENGINE engine_base;
+};
+
+/**
+ *  struct inv_chip_config_s - Cached chip configuration data.
+ *  @fsr:		Full scale range.
+ *  @lpf:		Digital low pass filter frequency.
+ *  @accel_fs:		accel full scale range.
+ *  @accel_enable:	enable accel functionality
+ *  @gyro_enable:	enable gyro functionality
+ *  @compass_enable:    enable compass functinality.
+ *  @geomag_enable:     enable geomag sensor functions.
+ *  @als_enable:        enable ALS functionality.
+ *  @pressure_enable:   eanble pressure functionality.
+ *  @secondary_enable:  secondary I2C bus enabled or not.
+ *  @has_gyro:	has gyro or not.
+ *  @has_compass:	has secondary I2C compass or not.
+ *  @has_pressure:      has secondary I2C pressure or not.
+ *  @has_als:           has secondary I2C als or not.
+ *  @slave_enable:      secondary I2C interface enabled or not.
+ *  @normal_compass_measure: discard first compass data after reset.
+ *  @is_asleep:		1 if chip is powered down.
+ *  @lp_en_set:         1 if LP_EN bit is set;
+ *  @lp_en_mode_off:    debug mode that turns off LP_EN mode off.
+ *  @clk_sel:           debug_mode that turns on/off clock selection.
+ *  @dmp_on:		dmp is on/off.
+ *  @dmp_event_int_on:  dmp event interrupt on/off.
+ *  @wom_on:        WOM interrupt on. This is an internal variable.
+ *  @step_indicator_on: step indicate bit added to the sensor or not.
+ *  @tilt_enable: tilt enable.
+ *  @pick_up_enable: pick up gesture enable.
+ *  @step_detector_on:  step detector on or not.
+ *  @activity_on: turn on/off activity.
+ *  @activity_eng_on: activity engine on/off.
+ *  @firmware_loaded:	flag indicate firmware loaded or not.
+ *  @low_power_gyro_on: flag indicating low power gyro on/off.
+ *  @wake_on: any wake on sensor is on/off.
+ *  @compass_rate:    compass engine rate. Determined by underlying data.
+ */
+struct inv_chip_config_s {
+	u32 fsr:2;
+	u32 lpf:3;
+	u32 accel_fs:2;
+	u32 accel_enable:1;
+	u32 gyro_enable:1;
+	u32 compass_enable:1;
+	u32 geomag_enable:1;
+	u32 als_enable:1;
+	u32 prox_enable:1;
+	u32 pressure_enable:1;
+	u32 has_gyro:1;
+	u32 has_compass:1;
+	u32 has_pressure:1;
+	u32 has_als:1;
+	u32 slave_enable:1;
+	u32 normal_compass_measure:1;
+	u32 is_asleep:1;
+	u32 lp_en_set:1;
+	u32 lp_en_mode_off:1;
+	u32 clk_sel:1;
+	u32 dmp_on:1;
+	u32 dmp_event_int_on:1;
+	u32 wom_on:1;
+	u32 step_indicator_on:1;
+	u32 tilt_enable:1;
+	u32 pick_up_enable:1;
+	u32 eis_enable:1;
+	u32 step_detector_on:1;
+	u32 activity_on:1;
+	u32 activity_eng_on:1;
+	u32 firmware_loaded:1;
+	u32 low_power_gyro_on:1;
+	u32 wake_on:1;
+	int compass_rate;
+};
+
+/**
+ *  struct inv_temp_comp - temperature compensation structure.
+ *  @t_lo:    raw temperature in low temperature.
+ *  @t_hi:    raw temperature in high temperature.
+ *  @b_lo:    gyro bias in low temperature.
+ *  @b_hi:    gyro bias in high temperature.
+ *  @has_low:    flag indicate low temperature parameters is updated.
+ *  @has_high:   flag indicates high temperature parameters is updated.
+ *  @slope:      slope for temperature compensation.
+ */
+struct inv_temp_comp {
+	int t_lo;
+	int t_hi;
+	int b_lo[3];
+	int b_hi[3];
+	bool has_low;
+	bool has_high;
+	int slope[3];
+};
+
+/**
+ *  struct inv_chip_info_s - Chip related information.
+ *  @product_id:	Product id.
+ *  @product_revision:	Product revision.
+ *  @silicon_revision:	Silicon revision.
+ *  @software_revision:	software revision.
+ *  @compass_sens:	compass sensitivity.
+ *  @gyro_sens_trim:	Gyro sensitivity trim factor.
+ *  @accel_sens_trim:    accel sensitivity trim factor.
+ */
+struct inv_chip_info_s {
+	u8 product_id;
+	u8 product_revision;
+	u8 silicon_revision;
+	u8 software_revision;
+	u8 compass_sens[3];
+	u32 gyro_sens_trim;
+	u32 accel_sens_trim;
+};
+
+/**
+ * struct inv_smd significant motion detection structure.
+ * @threshold: accel threshold for motion detection.
+ * @delay: delay time to confirm 2nd motion.
+ * @delay2: delay window parameter.
+ * @on: smd on/off.
+ */
+struct inv_smd {
+	u32 threshold;
+	u32 delay;
+	u32 delay2;
+	bool on;
+};
+
+/**
+ * struct inv_ped pedometer related data structure.
+ * @step: steps taken.
+ * @time: time taken during the period.
+ * @last_step_time: last time the step is taken.
+ * @step_thresh: step threshold to show steps.
+ * @int_thresh: step threshold to generate interrupt.
+ * @int_on:   pedometer interrupt enable/disable.
+ * @on:  pedometer on/off.
+ * @engine_on: pedometer engine on/off.
+ */
+struct inv_ped {
+	u64 step;
+	u64 time;
+	u64 last_step_time;
+	u16 step_thresh;
+	u16 int_thresh;
+	bool int_on;
+	bool on;
+	bool engine_on;
+};
+
+/**
+ * struct inv_eis EIS related data structure.
+ * @prev_gyro: latest gyro data just before FSYNC triggerd
+ * @prev_timestamp: latest gyro timestamp just before FSYNC triggered
+ * @current_gyro: gyro data just after FSYNC triggerd
+ * @current_timestamp: gyro timestamp just after FSYNC triggered
+ * @fsync_timestamp: timestamp of FSYNC event
+ * @fsync_delay: delay time of FSYNC and Gyro data. DMP data of FSYNC event
+ * @eis_triggered: check fsync event is triggered or not.
+ * @eis_frame: current frame is eis frame;
+ * @current_sync: current frame contains fsync counter.
+ * @frame_count: frame count for synchronization.
+ */
+struct inv_eis {
+	int prev_gyro[3];
+	u64 prev_timestamp;
+	int current_gyro[3];
+	u64 current_timestamp;
+	u32 frame_dur;
+	u64 slope[3];
+	u64 fsync_timestamp;
+	u64 last_fsync_timestamp;
+	u16 fsync_delay;
+	bool eis_triggered;
+	bool eis_frame;
+	bool current_sync;
+	bool prev_state;
+	u32 frame_count;
+	int gyro_counter;
+	int gyro_counter_s[3];
+	int fsync_delay_s[3];
+	int voting_count;
+	int voting_count_sub;
+	int voting_state;
+	int count_precision;
+};
+
+enum TRIGGER_STATE {
+	DATA_TRIGGER = 0,
+	RATE_TRIGGER,
+	EVENT_TRIGGER,
+	MISC_TRIGGER,
+	DEBUG_TRIGGER,
+};
+
+enum inv_fifo_count_mode {
+	BYTE_MODE,
+	RECORD_MODE
+};
+
+/**
+ *  struct inv_secondary_reg - secondary registers data structure.
+ *  @addr:       address of the slave.
+ *  @reg: register address of slave.
+ *  @ctrl: control register.
+ *  @d0: data out register.
+ */
+struct inv_secondary_reg {
+	u8 addr;
+	u8 reg;
+	u8 ctrl;
+	u8 d0;
+};
+
+struct inv_secondary_set {
+	u8 delay_enable;
+	u8 delay_time;
+	u8 odr_config;
+};
+/**
+ *  struct inv_engine_info - data structure for engines.
+ *  @base_time: base time for each engine.
+ *  @base_time_1k: base time when chip is running at 1K;
+ *  @divider: divider used to downsample engine rate from original rate.
+ *  @running_rate: the actually running rate of engine.
+ *  @orig_rate: original rate for each engine before downsample.
+ *  @dur: duration for one tick.
+ *  @last_update_time: last update time.
+ */
+struct inv_engine_info {
+	u32 base_time;
+	u32 base_time_1k;
+	u32 divider;
+	u32 running_rate;
+	u32 orig_rate;
+	u32 dur;
+	u64 last_update_time;
+};
+
+struct inv_ois {
+	int gyro_fs;
+	int accel_fs;
+	bool en;
+};
+
+/**
+ *  struct inv_timestamp_algo - timestamp algorithm .
+ *  @last_run_time: last time the post ISR runs.
+ *  @ts_for_calib: ts storage for calibration.
+ *  @reset_ts: reset time.
+ *  @dmp_ticks: dmp ticks storage for calibration.
+ *  @start_dmp_counter: dmp counter when start a new session.
+ *  @calib_counter: calibration counter for timestamp.
+ *  @resume_flag: flag to indicate this is the first time after resume. time
+                 could have up to 1 seconds difference.
+ *  @clock_base: clock base to calculate the timestamp.
+ *  @gyro_ts_shift: 9 K counter for EIS.
+ *  @first_sample: first of 1K running should be dropped it affects timing
+ */
+struct inv_timestamp_algo {
+	u64 last_run_time;
+	u64 ts_for_calib;
+	u64 reset_ts;
+	u32 dmp_ticks;
+	u32 start_dmp_counter;
+	int calib_counter;
+	bool resume_flag;
+	enum INV_ENGINE clock_base;
+	u32 gyro_ts_shift;
+	u32 first_sample;
+};
+
+struct inv_mpu_slave;
+/**
+ *  struct inv_mpu_state - Driver state variables.
+ *  @dev:               device address of the current bus, i2c or spi.
+ *  @chip_config:	Cached attribute information.
+ *  @chip_info:		Chip information from read-only registers.
+ *  @smd:               SMD data structure.
+ *  @ped:               pedometer data structure.
+ *  @batch:             batchmode data structure.
+ *  @temp_comp:         gyro temperature compensation structure.
+ *  @slave_compass:     slave compass.
+ *  @slave_pressure:    slave pressure.
+ *  @slave_als:         slave als.
+ *  @slv_reg: slave register data structure.
+ *  @ts_algo: timestamp algorithm data structure.
+ *  @sec_set: slave register odr config.
+ *  @eng_info: information for each engine.
+ *  @hw:		Other hardware-specific information.
+ *  @chip_type:		chip type.
+ *  @suspend_resume_sema: semaphore for suspend/resume.
+ *  @wake_lock: wake lock of the system.
+ *  @client:		i2c client handle.
+ *  @plat_data:		platform data.
+ *  @sl_handle:         Handle to I2C port.
+ *  @sensor{SENSOR_NUM_MAX]: sensor individual properties.
+ *  @sensor_l[SENSOR_L_NUM_MAX]: android L sensors properties.
+ *  @sensor_accuracy[SENSOR_ACCURACY_NUM_MAX]: sensor accuracy.
+ *  @sensor_acurracy_flag: flag indiciate whether to check output accuracy.
+ *  @irq:               irq number store.
+ *  @accel_bias:        accel bias store.
+ *  @gyro_bias:         gyro bias store.
+ *  @accel_st_bias:     accel bias store, result of self-test.
+ *  @gyro_st_bias:      gyro bias store, result of self-test.
+ *  @gyro_ois_st_bias:  gyro bias store from ois self test result.
+ *  @input_accel_dmp_bias[3]: accel bias for dmp.
+ *  @input_gyro_dmp_bias[3]: gyro bias for dmp.
+ *  @input_compass_dmp_bias[3]: compass bias for dmp.
+ *  @input_accel_bias[3]: accel bias for offset register.
+ *  @input_gyro_bias[3]: gyro bias for offset register.
+ *  @fifo_data[8]: fifo data storage.
+ *  @i2c_addr:          i2c address.
+ *  @header_count:      header count in current FIFO.
+ *  @step_det_count:    number of step detectors in one batch.
+ *  @gyro_sf: gyro scale factor.
+ *  @left_over[LEFT_OVER_BYTES]: left over bytes storage.
+ *  @left_over_size: left over size.
+ *  @fifo_count: current fifo_count;
+ *  @wake_sensor_received: wake up sensor received.
+ *  @accel_cal_enable:  accel calibration on/off
+ *  @gyro_cal_enable:   gyro calibration on/off
+ *  @calib_compass_on: calibrate compass on.
+ *  @debug_determine_engine_on: determine engine on/off.
+ *  @poke_mode_on: poke mode on/off.
+ *  @mode_1k_on: indicate 1K Hz mode is on.
+ *  @poke_ts: time stamp for poke feature.
+ *  @step_detector_base_ts: base time stamp for step detector calculation.
+ *  @last_temp_comp_time: last time temperature compensation is done.
+ *  @i2c_dis: disable I2C interface or not.
+ *  @name: name for the chip.
+ *  @gyro_st_data: gyro self test data.
+ *  @accel_st_data: accel self test data.
+ *  @secondary_name: name for the slave device in the secondary I2C.
+ *  @compass_var: compass variance from DMP.
+ *  @current_compass_matrix: matrix compass data multiplied to before soft iron.
+ *  @final_compass_matrix: matrix compass data multiplied to before soft iron.
+ *  @trigger_state: information that which part triggers set_inv_enable.
+ *  @firmware: firmware data pointer.
+ *  @accel_calib_threshold: accel calibration threshold;
+ *  @accel_calib_rate: divider for accel calibration rate.
+ *  @accel_covariance[COVARIANCE_SIZE]: accel covariance data;
+ *  @kf: kfifo for activity store.
+ *  @activity_size: size for activity.
+ *  @cntl: control word for sensor enable.
+ *  @cntl2: control word for sensor extension.
+ *  @motion_event_cntl: control word for events.
+ *  @dmp_image_size: dmp image size.
+ *  @dmp_start_address: start address of dmp.
+ *  @step_counter_l_on: step counter android L sensor on/off.
+ *  @step_counter_wake_l_on: step counter android L sensor wake on/off .
+ *  @step_detector_l_on: step detector android L sensor on/off.
+ *  @step_detector_wake_l_on: step detector android L sensor wake on/off .
+ *  @gesture_only_on: indicate it is gesture only.
+ *  @mag_divider: mag divider when gyro/accel is faster than mag maximum rate.
+ *  @special_mag_mode: for 20690, there is special mag mode need to be handled.
+ *  @mag_start_flag: when mag divider is non zero, need to check the start.
+ *  @prev_steps: previous steps sent to the user.
+ *  @aut_key_in: authentication key input.
+ *  @aut_key_out: authentication key output.
+ *  @suspend_state: state variable to indicate that we are in suspend state.
+ *  @secondary_gyro_on: DMP out signal to turn on gyro.
+ *  @secondary_mag_on:  DMP out signal to turn on mag.
+ *  @secondary_prox_on: DMP out signal to turn on proximity.
+ *  @secondary_switch: showing this setup is triggerred by secondary switch.
+ *  @send_calib_gyro:       flag to indicate to send calibrated gyro.
+ *  @send_raw_compass: flag to send raw compass.
+ *  @resume_state: flag to synchronize the processing of inv_read_fifo()
+ *  @cycle_on: variable indicate accel cycle mode is on.
+ *  @secondary_switch_data: secondary switch data for activity.
+ *  @raw_gyro_data[6]:    save raw gyro data.
+ *  @raw_compass_data[3]: save raw compass data.
+ *  @wait_queue: wait queue to wake up inv_read_fifo()
+ *  @bac_drive_conf: bac drive configuration.
+ *  @bac_walk_conf: bac walk configuration.
+ *  @bac_smd_conf: bac smd configuration.
+ *  @bac_bike_conf: bac bike configuration.
+ *  @bac_run_conf: bac run configuration.
+ *  @bac_still_conf: back still configuration.
+ *  @power_on_data: power on data.
+ *  @fifo_data_store: store of FIFO data.
+ *  @int_en: store interrupt enable register data.
+ *  @int_en2: store interrupt enable register 2 data.
+ *  @gesture_int_count: interrupt count for gesture only mode.
+ *  @smplrt_div: SMPLRT_DIV register value.
+ */
+struct inv_mpu_state {
+	struct device *dev;
+	int (*write)(struct inv_mpu_state *st, u8 reg, u8 data);
+	int (*read)(struct inv_mpu_state *st, u8 reg, int len, u8 *data);
+	int (*mem_write)(struct inv_mpu_state *st, u8 mpu_addr, u16 mem_addr,
+	                 u32 len, u8 const *data);
+	int (*mem_read)(struct inv_mpu_state *st, u8 mpu_addr, u16 mem_addr,
+	                u32 len, u8 *data);
+	struct inv_chip_config_s chip_config;
+	struct inv_chip_info_s chip_info;
+	struct inv_smd smd;
+	struct inv_ped ped;
+	struct inv_eis eis;
+	struct inv_batch batch;
+	struct inv_temp_comp temp_comp;
+	struct inv_mpu_slave *slave_compass;
+	struct inv_mpu_slave *slave_pressure;
+	struct inv_mpu_slave *slave_als;
+	struct inv_secondary_reg slv_reg[4];
+	struct inv_timestamp_algo ts_algo;
+	struct inv_secondary_set sec_set;
+	struct inv_engine_info eng_info[ENGINE_NUM_MAX];
+	const struct inv_hw_s *hw;
+	enum inv_devices chip_type;
+	enum inv_bus_type bus_type;
+	enum inv_fifo_count_mode fifo_count_mode;
+#ifdef CONFIG_HAS_WAKELOCK
+	struct wake_lock wake_lock;
+#else
+	struct wakeup_source wake_lock;
+#endif
+#ifdef TIMER_BASED_BATCHING
+	struct hrtimer hr_batch_timer;
+	u64 batch_timeout;
+	bool is_batch_timer_running;
+	struct work_struct batch_work;
+#endif
+	struct i2c_client *client;
+	struct mpu_platform_data plat_data;
+	void *sl_handle;
+	struct inv_sensor sensor[SENSOR_NUM_MAX];
+	struct android_l_sensor sensor_l[SENSOR_L_NUM_MAX];
+	struct inv_sensor_accuracy sensor_accuracy[SENSOR_ACCURACY_NUM_MAX];
+	struct inv_ois ois;
+	bool sensor_acurracy_flag[SENSOR_ACCURACY_NUM_MAX];
+	short irq;
+	int accel_bias[3];
+	int gyro_bias[3];
+	int accel_st_bias[3];
+	int accel_ois_st_bias[3];
+	int gyro_st_bias[3];
+	int gyro_ois_st_bias[3];
+	int input_accel_dmp_bias[3];
+	int input_gyro_dmp_bias[3];
+	int input_compass_dmp_bias[3];
+	int input_accel_bias[3];
+	int input_gyro_bias[3];
+	u8 fifo_data[8];
+	u8 i2c_addr;
+	int header_count;
+	int step_det_count;
+	s32 gyro_sf;
+	u8 left_over[LEFT_OVER_BYTES];
+	u32 left_over_size;
+	u32 fifo_count;
+	bool wake_sensor_received;
+	bool accel_cal_enable;
+	bool gyro_cal_enable;
+	bool calib_compass_on;
+	bool debug_determine_engine_on;
+	bool poke_mode_on;
+	bool mode_1k_on;
+	u64 poke_ts;
+	u64 step_detector_base_ts;
+	u64 last_temp_comp_time;
+	u8 i2c_dis;
+	u8 name[20];
+	u8 gyro_st_data[3];
+	u8 accel_st_data[3];
+	u8 secondary_name[20];
+	s32 compass_var;
+	int current_compass_matrix[9];
+	int final_compass_matrix[9];
+	enum TRIGGER_STATE trigger_state;
+	u8 *firmware;
+	int accel_calib_threshold;
+	int accel_calib_rate;
+	u32 accel_covariance[COVARIANCE_SIZE];
+	 DECLARE_KFIFO(kf, u8, 128);
+	u32 activity_size;
+	int wom_thld;
+	u16 cntl;
+	u16 cntl2;
+	u16 motion_event_cntl;
+	int dmp_image_size;
+	int dmp_start_address;
+	bool step_counter_l_on;
+	bool step_counter_wake_l_on;
+	bool step_detector_l_on;
+	bool step_detector_wake_l_on;
+	bool gesture_only_on;
+	bool mag_start_flag;
+	int mag_divider;
+	bool special_mag_mode;
+	int prev_steps;
+	u32 curr_steps;
+	int aut_key_in;
+	int aut_key_out;
+	bool secondary_gyro_on;
+	bool secondary_mag_on;
+	bool secondary_prox_on;
+	bool secondary_switch;
+	bool send_calib_gyro;
+	bool send_raw_compass;
+	bool send_raw_gyro;
+	bool resume_state;
+	bool cycle_on;
+	int secondary_switch_data;
+	u8 raw_gyro_data[6];
+	u32 raw_compass_data[3];
+	wait_queue_head_t wait_queue;
+	u32 bac_drive_conf;
+	u32 bac_walk_conf;
+	u32 bac_smd_conf;
+	u32 bac_bike_conf;
+	u32 bac_run_conf;
+	u32 bac_still_conf;
+	u32 power_on_data;
+	u8 fifo_data_store[HARDWARE_FIFO_SIZE + LEFT_OVER_BYTES];
+	u8 int_en;
+	u8 int_en_2;
+	u8 gesture_int_count;
+	u8 smplrt_div;
+};
+
+/**
+ *  struct inv_mpu_slave - MPU slave structure.
+ *  @st_upper:  compass self test upper limit.
+ *  @st_lower:  compass self test lower limit.
+ *  @scale: compass scale.
+ *  @rate_scale: decide how fast a compass can read.
+ *  @min_read_time: minimum time between each reading.
+ *  @self_test: self test method of the slave.
+ *  @set_scale: set scale of slave
+ *  @get_scale: read scale back of the slave.
+ *  @suspend:		suspend operation.
+ *  @resume:		resume operation.
+ *  @setup:		setup chip. initialization.
+ *  @combine_data:	combine raw data into meaningful data.
+ *  @read_data:        read external sensor and output
+ *  @get_mode:		get current chip mode.
+ *  @set_lpf:            set low pass filter.
+ *  @set_fs:             set full scale
+ *  @prev_ts: last time it is read.
+ */
+struct inv_mpu_slave {
+	const short *st_upper;
+	const short *st_lower;
+	int scale;
+	int rate_scale;
+	int min_read_time;
+	int (*self_test) (struct inv_mpu_state *);
+	int (*set_scale) (struct inv_mpu_state *, int scale);
+	int (*get_scale) (struct inv_mpu_state *, int *val);
+	int (*suspend) (struct inv_mpu_state *);
+	int (*resume) (struct inv_mpu_state *);
+	int (*setup) (struct inv_mpu_state *);
+	int (*combine_data) (u8 *in, short *out);
+	int (*read_data) (struct inv_mpu_state *, short *out);
+	int (*get_mode) (void);
+	int (*set_lpf) (struct inv_mpu_state *, int rate);
+	int (*set_fs) (struct inv_mpu_state *, int fs);
+	u64 prev_ts;
+};
+
+/* scan element definition */
+enum inv_mpu_scan {
+	INV_MPU_SCAN_TIMESTAMP,
+};
+
+/* IIO attribute address */
+enum MPU_IIO_ATTR_ADDR {
+	ATTR_DMP_GYRO_X_DMP_BIAS,
+	ATTR_DMP_GYRO_Y_DMP_BIAS,
+	ATTR_DMP_GYRO_Z_DMP_BIAS,
+	ATTR_DMP_GYRO_CAL_ENABLE,
+	ATTR_DMP_ACCEL_X_DMP_BIAS,
+	ATTR_DMP_ACCEL_Y_DMP_BIAS,
+	ATTR_DMP_ACCEL_Z_DMP_BIAS,
+	ATTR_DMP_MAGN_X_DMP_BIAS,
+	ATTR_DMP_MAGN_Y_DMP_BIAS,
+	ATTR_DMP_MAGN_Z_DMP_BIAS,
+	ATTR_DMP_MAGN_ACCURACY,
+	ATTR_GYRO_X_OFFSET,
+	ATTR_GYRO_Y_OFFSET,
+	ATTR_GYRO_Z_OFFSET,
+	ATTR_ACCEL_X_OFFSET,
+	ATTR_ACCEL_Y_OFFSET,
+	ATTR_ACCEL_Z_OFFSET,
+	ATTR_DMP_SC_AUTH,
+	ATTR_DMP_EIS_AUTH,
+	ATTR_DMP_ACCEL_CAL_ENABLE,
+	ATTR_DMP_PED_INT_ON,
+	ATTR_DMP_PED_STEP_THRESH,
+	ATTR_DMP_PED_INT_THRESH,
+	ATTR_DMP_PED_ON,
+	ATTR_DMP_SMD_ENABLE,
+	ATTR_DMP_TILT_ENABLE,
+	ATTR_DMP_PICK_UP_ENABLE,
+	ATTR_DMP_EIS_ENABLE,
+	ATTR_DMP_PEDOMETER_STEPS,
+	ATTR_DMP_PEDOMETER_TIME,
+	ATTR_DMP_PEDOMETER_COUNTER,
+	ATTR_DMP_LOW_POWER_GYRO_ON,
+	ATTR_DMP_LP_EN_OFF,
+	ATTR_DMP_CLK_SEL,
+	ATTR_DMP_DEBUG_MEM_READ,
+	ATTR_DMP_DEBUG_MEM_WRITE,
+	ATTR_DEBUG_REG_WRITE,
+	ATTR_DEBUG_WRITE_CFG,
+	ATTR_DEBUG_REG_ADDR,
+	ATTR_WOM_THLD,
+	/* *****above this line, are DMP features, power needs on/off */
+	/* *****below this line, are DMP features, no power needed */
+	ATTR_IN_POWER_ON,
+	ATTR_DMP_ON,
+	ATTR_DMP_EVENT_INT_ON,
+	ATTR_DMP_STEP_COUNTER_ON,
+	ATTR_DMP_STEP_COUNTER_WAKE_ON,
+	ATTR_DMP_BATCHMODE_TIMEOUT,
+	ATTR_DMP_BATCHMODE_WAKE_FIFO_FULL,
+	ATTR_DMP_STEP_DETECTOR_ON,
+	ATTR_DMP_STEP_DETECTOR_WAKE_ON,
+	ATTR_DMP_ACTIVITY_ON,
+	ATTR_DMP_IN_ANGLVEL_ACCURACY_ENABLE,
+	ATTR_DMP_IN_ACCEL_ACCURACY_ENABLE,
+	ATTR_DMP_DEBUG_DETERMINE_ENGINE_ON,
+	ATTR_DMP_MISC_GYRO_RECALIBRATION,
+	ATTR_DMP_MISC_ACCEL_RECALIBRATION,
+	ATTR_DMP_PARAMS_ACCEL_CALIBRATION_THRESHOLD,
+	ATTR_DMP_PARAMS_ACCEL_CALIBRATION_RATE,
+	ATTR_GYRO_SCALE,
+	ATTR_ACCEL_SCALE,
+	ATTR_COMPASS_SCALE,
+	ATTR_COMPASS_SENSITIVITY_X,
+	ATTR_COMPASS_SENSITIVITY_Y,
+	ATTR_COMPASS_SENSITIVITY_Z,
+	ATTR_GYRO_ENABLE,
+	ATTR_ACCEL_ENABLE,
+	ATTR_COMPASS_ENABLE,
+	ATTR_FIRMWARE_LOADED,
+	ATTR_POKE_MODE,
+	ATTR_ANGLVEL_X_CALIBBIAS,
+	ATTR_ANGLVEL_Y_CALIBBIAS,
+	ATTR_ANGLVEL_Z_CALIBBIAS,
+	ATTR_ACCEL_X_CALIBBIAS,
+	ATTR_ACCEL_Y_CALIBBIAS,
+	ATTR_ACCEL_Z_CALIBBIAS,
+	ATTR_ANGLVEL_X_ST_CALIBBIAS,
+	ATTR_ANGLVEL_Y_ST_CALIBBIAS,
+	ATTR_ANGLVEL_Z_ST_CALIBBIAS,
+	ATTR_ANGLVEL_X_OIS_ST_CALIBBIAS,
+	ATTR_ANGLVEL_Y_OIS_ST_CALIBBIAS,
+	ATTR_ANGLVEL_Z_OIS_ST_CALIBBIAS,
+	ATTR_ACCEL_X_ST_CALIBBIAS,
+	ATTR_ACCEL_Y_ST_CALIBBIAS,
+	ATTR_ACCEL_Z_ST_CALIBBIAS,
+	ATTR_ACCEL_X_OIS_ST_CALIBBIAS,
+	ATTR_ACCEL_Y_OIS_ST_CALIBBIAS,
+	ATTR_ACCEL_Z_OIS_ST_CALIBBIAS,
+	ATTR_GYRO_MATRIX,
+	ATTR_ACCEL_MATRIX,
+	ATTR_COMPASS_MATRIX,
+	ATTR_FSYNC_FRAME_COUNT,
+	ATTR_SECONDARY_NAME,
+	ATTR_GYRO_SF,
+	ATTR_BAC_DRIVE_CONFIDENCE,
+	ATTR_BAC_WALK_CONFIDENCE,
+	ATTR_BAC_SMD_CONFIDENCE,
+	ATTR_BAC_BIKE_CONFIDENCE,
+	ATTR_BAC_STILL_CONFIDENCE,
+	ATTR_BAC_RUN_CONFIDENCE,
+	IN_OIS_ACCEL_FS,
+	IN_OIS_GYRO_FS,
+	IN_OIS_ENABLE,
+};
+
+int inv_mpu_configure_ring(struct iio_dev *indio_dev);
+int inv_mpu_probe_trigger(struct iio_dev *indio_dev);
+void inv_mpu_unconfigure_ring(struct iio_dev *indio_dev);
+void inv_mpu_remove_trigger(struct iio_dev *indio_dev);
+#ifdef CONFIG_PM_SLEEP
+int inv_mpu_suspend(struct iio_dev *indio_dev);
+void inv_mpu_complete(struct iio_dev *indio_dev);
+#endif
+
+int inv_get_pedometer_steps(struct inv_mpu_state *st, int *ped);
+int inv_get_pedometer_time(struct inv_mpu_state *st, int *ped);
+int inv_read_pedometer_counter(struct inv_mpu_state *st);
+
+int inv_dmp_read(struct inv_mpu_state *st, int off, int size, u8 *buf);
+int inv_firmware_load(struct inv_mpu_state *st);
+
+int set_inv_enable(struct iio_dev *indio_dev);
+
+int inv_mpu_setup_compass_slave(struct inv_mpu_state *st);
+int inv_mpu_setup_pressure_slave(struct inv_mpu_state *st);
+int inv_mpu_setup_als_slave(struct inv_mpu_state *st);
+int inv_mpu_initialize(struct inv_mpu_state *st);
+int inv_set_accel_sf(struct inv_mpu_state *st);
+int inv_set_gyro_sf(struct inv_mpu_state *st);
+s64 get_time_ns(void);
+int inv_i2c_read_base(struct inv_mpu_state *st, u16 i, u8 r, u16 l, u8 *d);
+int inv_i2c_single_write_base(struct inv_mpu_state *st, u16 i, u8 r, u8 d);
+int write_be32_to_mem(struct inv_mpu_state *st, u32 data, int addr);
+int write_be16_to_mem(struct inv_mpu_state *st, u16 data, int addr);
+int read_be32_from_mem(struct inv_mpu_state *st, u32 *o, int addr);
+int read_be16_from_mem(struct inv_mpu_state *st, u16 *o, int addr);
+u32 inv_get_cntr_diff(u32 curr_counter, u32 prev);
+int inv_write_2bytes(struct inv_mpu_state *st, int k, int data);
+int inv_set_bank(struct inv_mpu_state *st, u8 bank);
+int inv_set_power(struct inv_mpu_state *st, bool power_on);
+int inv_switch_power_in_lp(struct inv_mpu_state *st, bool on);
+#ifndef CONFIG_INV_MPU_IIO_ICM20608D
+int inv_set_accel_config2(struct inv_mpu_state *st, bool cycle_mode);
+#endif
+int inv_stop_dmp(struct inv_mpu_state *st);
+int inv_reset_fifo(struct inv_mpu_state *st, bool turn_off);
+int inv_create_dmp_sysfs(struct iio_dev *ind);
+int inv_check_chip_type(struct iio_dev *indio_dev, const char *name);
+int inv_write_compass_matrix(struct inv_mpu_state *st, int *adj);
+irqreturn_t inv_read_fifo(int irq, void *dev_id);
+#ifdef TIMER_BASED_BATCHING
+void inv_batch_work(struct work_struct *work);
+#endif
+int inv_flush_batch_data(struct iio_dev *indio_dev, int data);
+static inline int mpu_memory_write(struct inv_mpu_state *st, u8 mpu_addr,
+                                   u16 mem_addr, u32 len, u8 const *data)
+{
+	int ret = -1;
+
+	if (st->mem_write)
+		ret = st->mem_write(st, mpu_addr, mem_addr, len, data);
+
+	return ret;
+}
+static inline int mpu_memory_read(struct inv_mpu_state *st, u8 mpu_addr,
+                                  u16 mem_addr, u32 len, u8 *data)
+{
+	int ret = -1;
+
+	if (st->mem_read)
+		ret = st->mem_read(st, mpu_addr, mem_addr, len, data);
+
+	return ret;
+}
+int inv_read_secondary(struct inv_mpu_state *st, int ind, int addr,
+			int reg, int len);
+int inv_write_secondary(struct inv_mpu_state *st, int ind, int addr,
+			int reg, int v);
+int inv_execute_write_secondary(struct inv_mpu_state *st, int ind, int addr,
+				int reg, int v);
+int inv_execute_read_secondary(struct inv_mpu_state *st, int ind, int addr,
+			       int reg, int len, u8 *d);
+
+int inv_push_16bytes_buffer(struct inv_mpu_state *st, u16 hdr,
+						u64 t, int *q, s16 accur);
+int inv_push_gyro_data(struct inv_mpu_state *st, s16 *raw, s32 *calib, u64 t);
+int inv_push_8bytes_buffer(struct inv_mpu_state *st, u16 hdr, u64 t, s16 *d);
+int inv_push_8bytes_kf(struct inv_mpu_state *st, u16 hdr, u64 t, s16 *d);
+
+void inv_push_step_indicator(struct inv_mpu_state *st, u64 t);
+int inv_send_steps(struct inv_mpu_state *st, int step, u64 t);
+int inv_push_marker_to_buffer(struct inv_mpu_state *st, u16 hdr, int data);
+
+int inv_check_sensor_on(struct inv_mpu_state *st);
+int inv_write_cntl(struct inv_mpu_state *st, u16 wd, bool en, int cntl);
+
+int inv_get_packet_size(struct inv_mpu_state *st, u16 hdr,
+						u32 *pk_size, u8 *dptr);
+int inv_parse_packet(struct inv_mpu_state *st, u16 hdr, u8 *dptr);
+int inv_pre_parse_packet(struct inv_mpu_state *st, u16 hdr, u8 *dptr);
+int inv_process_dmp_data(struct inv_mpu_state *st);
+
+int be32_to_int(u8 *d);
+void inv_convert_and_push_16bytes(struct inv_mpu_state *st, u16 hdr,
+							u8 *d, u64 t, s8 *m);
+void inv_convert_and_push_8bytes(struct inv_mpu_state *st, u16 hdr,
+						u8 *d, u64 t, s8 *m);
+int inv_get_dmp_ts(struct inv_mpu_state *st, int i);
+int inv_process_step_det(struct inv_mpu_state *st, u8 *dptr);
+int inv_process_eis(struct inv_mpu_state *st, u16 delay);
+int inv_rate_convert(struct inv_mpu_state *st, int ind, int data);
+
+int inv_setup_dmp_firmware(struct inv_mpu_state *st);
+/* used to print i2c data using pr_debug */
+char *wr_pr_debug_begin(u8 const *data, u32 len, char *string);
+char *wr_pr_debug_end(char *string);
+
+int inv_hw_self_test(struct inv_mpu_state *st);
+int inv_q30_mult(int a, int b);
+#ifdef ACCEL_BIAS_TEST
+int inv_get_3axis_average(s16 src[], s16 dst[], s16 reset);
+#endif
+
+static inline int inv_plat_single_write(struct inv_mpu_state *st,
+							u8 reg, u8 data)
+{
+	int ret = -1;
+
+	if (st->write)
+		ret = st->write(st, reg, data);
+
+	return ret;
+}
+static inline int inv_plat_read(struct inv_mpu_state *st, u8 reg,
+							int len, u8 *data)
+{
+	int ret = -1;
+
+	if (st->read)
+		ret = st->read(st, reg, len, data);
+
+	return ret;
+}
+irqreturn_t inv_read_fifo(int , void *);
+
+int inv_stop_interrupt(struct inv_mpu_state *st);
+int inv_reenable_interrupt(struct inv_mpu_state *st);
+
+int inv_enable_pedometer_interrupt(struct inv_mpu_state *st, bool en);
+int inv_dataout_control1(struct inv_mpu_state *st, u16 cntl1);
+int inv_dataout_control2(struct inv_mpu_state *st, u16 cntl2);
+int inv_motion_interrupt_control(struct inv_mpu_state *st,
+						u16 motion_event_cntl);
+
+int inv_bound_timestamp(struct inv_mpu_state *st);
+int inv_update_dmp_ts(struct inv_mpu_state *st, int ind);
+int inv_get_last_run_time_non_dmp_record_mode(struct inv_mpu_state *st);
+
+#define mem_w(a, b, c) mpu_memory_write(st, st->i2c_addr, a, b, c)
+#define mem_r(a, b, c) mpu_memory_read(st, st->i2c_addr, a, b, c)
+
+#endif /* #ifndef _INV_MPU_IIO_H_ */
diff --git a/drivers/iio/imu/inv_mpu/inv_mpu_ring.c b/drivers/iio/imu/inv_mpu/inv_mpu_ring.c
new file mode 100644
index 0000000..3e5bccbe
--- /dev/null
+++ b/drivers/iio/imu/inv_mpu/inv_mpu_ring.c
@@ -0,0 +1,643 @@
+/*
+* Copyright (C) 2012-2018 InvenSense, Inc.
+*
+* This software is licensed under the terms of the GNU General Public
+* License version 2, as published by the Free Software Foundation, and
+* may be copied, distributed, and modified under those terms.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*/
+#define pr_fmt(fmt) "inv_mpu: " fmt
+
+#include <linux/export.h>
+#include <linux/kernel.h>
+#include <linux/device.h>
+#include <linux/slab.h>
+#include <linux/err.h>
+#include <linux/delay.h>
+#include <linux/sysfs.h>
+#include <linux/jiffies.h>
+#include <linux/irq.h>
+#include <linux/interrupt.h>
+#include <linux/kfifo.h>
+#include <linux/poll.h>
+#include <linux/math64.h>
+#include <linux/miscdevice.h>
+
+#include "inv_mpu_iio.h"
+
+static void inv_push_timestamp(struct iio_dev *indio_dev, u64 t)
+{
+	u8 buf[IIO_BUFFER_BYTES];
+	struct inv_mpu_state *st;
+
+	st = iio_priv(indio_dev);
+	if (st->poke_mode_on)
+		memcpy(buf, &st->poke_ts, sizeof(t));
+	else
+		memcpy(buf, &t, sizeof(t));
+	iio_push_to_buffers(indio_dev, buf);
+}
+
+int inv_push_marker_to_buffer(struct inv_mpu_state *st, u16 hdr, int data)
+{
+	struct iio_dev *indio_dev = iio_priv_to_dev(st);
+	u8 buf[IIO_BUFFER_BYTES];
+
+	memcpy(buf, &hdr, sizeof(hdr));
+	memcpy(&buf[4], &data, sizeof(data));
+	iio_push_to_buffers(indio_dev, buf);
+
+	return 0;
+}
+static int inv_calc_precision(struct inv_mpu_state *st)
+{
+	int diff;
+	int init;
+
+	if (st->eis.voting_state != 8)
+		return 0;
+	diff = abs(st->eis.fsync_delay_s[1] - st->eis.fsync_delay_s[0]);
+	init = 0;
+	if (diff)
+		init = st->sensor[SENSOR_GYRO].dur / diff;
+
+	if (abs(init - NSEC_PER_USEC) < (NSEC_PER_USEC >> 3))
+		 st->eis.count_precision = init;
+	else
+		st->eis.voting_state = 0;
+
+	pr_debug("dur= %d prc= %d\n", st->sensor[SENSOR_GYRO].dur,
+						st->eis.count_precision);
+
+	return 0;
+}
+
+static s64 calc_frame_ave(struct inv_mpu_state *st, int delay)
+{
+	s64 ts;
+
+	ts = st->eis.current_timestamp - delay;
+#if defined(CONFIG_INV_MPU_IIO_ICM20648) | defined(CONFIG_INV_MPU_IIO_ICM20690)
+	ts -= st->ts_algo.gyro_ts_shift;
+#endif
+	pr_debug("shift= %d ts = %lld\n", st->ts_algo.gyro_ts_shift, ts);
+
+	return ts;
+}
+
+static void inv_push_eis_ring(struct inv_mpu_state *st, int *q, bool sync,
+								s64 t)
+{
+	struct iio_dev *indio_dev = iio_priv_to_dev(st);
+	struct inv_eis *eis = &st->eis;
+	u8 buf[IIO_BUFFER_BYTES];
+	int tmp, ii;
+
+	buf[0] = (EIS_GYRO_HDR & 0xff);
+	buf[1] = (EIS_GYRO_HDR >> 8);
+	memcpy(buf + 4, &q[0], sizeof(q[0]));
+	iio_push_to_buffers(indio_dev, buf);
+	for (ii = 0; ii < 2; ii++)
+		memcpy(buf + 4 * ii, &q[ii + 1], sizeof(q[ii]));
+	iio_push_to_buffers(indio_dev, buf);
+	tmp = eis->frame_count;
+	if (sync)
+		tmp |= 0x80000000;
+	memcpy(buf, &tmp, sizeof(tmp));
+	iio_push_to_buffers(indio_dev, buf);
+	inv_push_timestamp(indio_dev, t);
+}
+static int inv_do_interpolation_gyro(struct inv_mpu_state *st, int *prev,
+	s64 prev_t, int *curr, s64 curr_t, s64 t, bool trigger)
+{
+	int i;
+	int out[3];
+#if defined(CONFIG_INV_MPU_IIO_ICM20648) | defined(CONFIG_INV_MPU_IIO_ICM20690)
+	prev_t -= st->ts_algo.gyro_ts_shift;
+	prev_t += MPU_4X_TS_GYRO_SHIFT;
+	curr_t -= st->ts_algo.gyro_ts_shift;
+	curr_t += MPU_4X_TS_GYRO_SHIFT;
+#endif
+	if ((t > prev_t) && (t < curr_t)) {
+		for (i = 0; i < 3; i++)
+			out[i] = (int)div_s64((s64)(curr[i] - prev[i]) *
+				(s64)(t - prev_t), curr_t - prev_t) + prev[i];
+	} else if (t < prev_t) {
+		for (i = 0; i < 3; i++)
+			out[i] = prev[i];
+	} else {
+		for (i = 0; i < 3; i++)
+			out[i] = curr[i];
+	}
+	pr_debug("prev= %lld t = %lld curr= %lld\n", prev_t, t, curr_t);
+	pr_debug("prev = %d, %d, %d\n", prev[0], prev[1], prev[2]);
+	pr_debug("curr = %d, %d, %d\n", curr[0], curr[1], curr[2]);
+	pr_debug("out = %d, %d, %d\n", out[0], out[1], out[2]);
+	inv_push_eis_ring(st, out, trigger, t);
+
+	return 0;
+}
+#if defined(CONFIG_INV_MPU_IIO_ICM20648) | defined(CONFIG_INV_MPU_IIO_ICM20690)
+static void inv_handle_triggered_eis(struct inv_mpu_state *st)
+{
+	struct inv_eis *eis = &st->eis;
+	int delay;
+
+	if (st->eis.eis_frame) {
+		inv_calc_precision(st);
+		delay = ((int)st->eis.fsync_delay) * st->eis.count_precision;
+		eis->fsync_timestamp = calc_frame_ave(st, delay);
+		inv_do_interpolation_gyro(st,
+			st->eis.prev_gyro,    st->eis.prev_timestamp,
+			st->eis.current_gyro, st->eis.current_timestamp,
+			eis->fsync_timestamp, true);
+		pr_debug("fsync=%lld, curr=%lld, delay=%d\n",
+			eis->fsync_timestamp, eis->current_timestamp, delay);
+		inv_push_eis_ring(st, st->eis.current_gyro, false,
+			st->eis.current_timestamp - st->ts_algo.gyro_ts_shift
+						+ MPU_4X_TS_GYRO_SHIFT);
+		eis->last_fsync_timestamp = eis->fsync_timestamp;
+	} else {
+		pr_debug("cur= %lld\n", st->eis.current_timestamp);
+		inv_push_eis_ring(st, st->eis.current_gyro, false,
+			st->eis.current_timestamp - st->ts_algo.gyro_ts_shift
+						+ MPU_4X_TS_GYRO_SHIFT);
+	}
+}
+#else
+static void inv_handle_triggered_eis(struct inv_mpu_state *st)
+{
+	struct inv_eis *eis = &st->eis;
+	int delay;
+
+	if ((st->eis.eis_frame && (st->eis.fsync_delay != 5)) ||
+		(st->eis.eis_frame && (st->eis.fsync_delay == 5) &&
+		(!st->eis.current_sync))
+		) {
+		inv_calc_precision(st);
+		delay = ((int)st->eis.fsync_delay) * st->eis.count_precision;
+		eis->fsync_timestamp = calc_frame_ave(st, delay);
+		inv_do_interpolation_gyro(st,
+			st->eis.prev_gyro,    st->eis.prev_timestamp,
+			st->eis.current_gyro, st->eis.current_timestamp,
+			eis->fsync_timestamp, true);
+		pr_debug("fsync=%lld, curr=%lld, delay=%d\n",
+			eis->fsync_timestamp, eis->current_timestamp, delay);
+		inv_push_eis_ring(st, st->eis.current_gyro, false,
+				st->eis.current_timestamp);
+		eis->last_fsync_timestamp = eis->fsync_timestamp;
+		st->eis.eis_frame = false;
+	} else {
+		st->eis.current_sync = false;
+		pr_debug("cur= %lld\n", st->eis.current_timestamp);
+		inv_push_eis_ring(st, st->eis.current_gyro, false,
+				st->eis.current_timestamp);
+	}
+}
+#endif
+static void inv_push_eis_buffer(struct inv_mpu_state *st, u64 t, int *q)
+{
+	int ii;
+
+	if (st->eis.eis_triggered) {
+		for (ii = 0; ii < 3; ii++)
+			st->eis.prev_gyro[ii] = st->eis.current_gyro[ii];
+		st->eis.prev_timestamp = st->eis.current_timestamp;
+
+		for (ii = 0; ii < 3; ii++)
+			st->eis.current_gyro[ii] = q[ii];
+		st->eis.current_timestamp = t;
+		inv_handle_triggered_eis(st);
+	} else {
+		for (ii = 0; ii < 3; ii++)
+			st->eis.current_gyro[ii] = q[ii];
+		st->eis.current_timestamp = t;
+	}
+}
+static int inv_push_16bytes_final(struct inv_mpu_state *st, int j,
+						s32 *q, u64 t, s16 accur)
+{
+	struct iio_dev *indio_dev = iio_priv_to_dev(st);
+	u8 buf[IIO_BUFFER_BYTES];
+	int ii;
+
+	memcpy(buf, &st->sensor_l[j].header, sizeof(st->sensor_l[j].header));
+	memcpy(buf + 2, &accur, sizeof(accur));
+	memcpy(buf + 4, &q[0], sizeof(q[0]));
+	iio_push_to_buffers(indio_dev, buf);
+	for (ii = 0; ii < 2; ii++)
+		memcpy(buf + 4 * ii, &q[ii + 1], sizeof(q[ii]));
+	iio_push_to_buffers(indio_dev, buf);
+	inv_push_timestamp(indio_dev, t);
+	st->sensor_l[j].counter = 0;
+	if (st->sensor_l[j].wake_on)
+		st->wake_sensor_received = true;
+
+	return 0;
+}
+int inv_push_16bytes_buffer(struct inv_mpu_state *st, u16 sensor,
+				    u64 t, int *q, s16 accur)
+{
+	int j;
+
+	for (j = 0; j < SENSOR_L_NUM_MAX; j++) {
+		if (st->sensor_l[j].on && (st->sensor_l[j].base == sensor)) {
+			st->sensor_l[j].counter++;
+			if ((st->sensor_l[j].div != 0xffff) &&
+				(st->sensor_l[j].counter >=
+						st->sensor_l[j].div)) {
+				pr_debug(
+	"Sensor_l = %d sensor = %d header [%04X] div [%d] ts [%lld] %d %d %d\n",
+					j, sensor,
+					st->sensor_l[j].header,
+					st->sensor_l[j].div,
+					t, q[0], q[1], q[2]);
+				inv_push_16bytes_final(st, j, q, t, accur);
+			}
+		}
+	}
+	return 0;
+}
+
+void inv_convert_and_push_16bytes(struct inv_mpu_state *st, u16 hdr,
+							u8 *d, u64 t, s8 *m)
+{
+	int i, j;
+	s32 in[3], out[3];
+
+	for (i = 0; i < 3; i++)
+		in[i] = be32_to_int(d + i * 4);
+	/* multiply with orientation matrix can be optimized like this */
+	for (i = 0; i < 3; i++)
+		for (j = 0; j < 3; j++)
+			if (m[i * 3 + j])
+				out[i] = in[j] * m[i * 3 + j];
+
+	inv_push_16bytes_buffer(st, hdr, t, out, 0);
+}
+
+void inv_convert_and_push_8bytes(struct inv_mpu_state *st, u16 hdr,
+						u8 *d, u64 t, s8 *m)
+{
+	int i, j;
+	s16 in[3], out[3];
+
+	for (i = 0; i < 3; i++)
+		in[i] = be16_to_cpup((__be16 *) (d + i * 2));
+
+	/* multiply with orientation matrix can be optimized like this */
+	for (i = 0; i < 3; i++)
+		for (j = 0; j < 3; j++)
+			if (m[i * 3 + j])
+				out[i] = in[j] * m[i * 3 + j];
+
+	inv_push_8bytes_buffer(st, hdr, t, out);
+}
+
+int inv_push_special_8bytes_buffer(struct inv_mpu_state *st,
+				   u16 hdr, u64 t, s16 *d)
+{
+	struct iio_dev *indio_dev = iio_priv_to_dev(st);
+	u8 buf[IIO_BUFFER_BYTES];
+	int j;
+
+	memcpy(buf, &hdr, sizeof(hdr));
+	memcpy(&buf[2], &d[0], sizeof(d[0]));
+	for (j = 0; j < 2; j++)
+		memcpy(&buf[4 + j * 2], &d[j + 1], sizeof(d[j]));
+	iio_push_to_buffers(indio_dev, buf);
+	inv_push_timestamp(indio_dev, t);
+
+	return 0;
+}
+
+static int inv_s16_gyro_push(struct inv_mpu_state *st, int i, s16 *raw, u64 t)
+{
+	if (st->sensor_l[i].on) {
+		st->sensor_l[i].counter++;
+		if ((st->sensor_l[i].div != 0xffff) &&
+			(st->sensor_l[i].counter >= st->sensor_l[i].div)) {
+			inv_push_special_8bytes_buffer(st,
+					st->sensor_l[i].header, t, raw);
+			st->sensor_l[i].counter = 0;
+			if (st->sensor_l[i].wake_on)
+				st->wake_sensor_received = true;
+		}
+	}
+
+	return 0;
+}
+
+static int inv_s32_gyro_push(struct inv_mpu_state *st, int i, s32 *calib, u64 t)
+{
+	if (st->sensor_l[i].on) {
+		st->sensor_l[i].counter++;
+		if ((st->sensor_l[i].div != 0xffff) &&
+			(st->sensor_l[i].counter >= st->sensor_l[i].div)) {
+			inv_push_16bytes_final(st, i, calib, t, 0);
+			st->sensor_l[i].counter = 0;
+			if (st->sensor_l[i].wake_on)
+				st->wake_sensor_received = true;
+		}
+	}
+
+	return 0;
+}
+
+int inv_push_gyro_data(struct inv_mpu_state *st, s16 *raw, s32 *calib, u64 t)
+{
+	int gyro_data[] = {SENSOR_L_GYRO, SENSOR_L_GYRO_WAKE};
+	int calib_data[] = {SENSOR_L_GYRO_CAL, SENSOR_L_GYRO_CAL_WAKE};
+	int i;
+
+	if (st->sensor_l[SENSOR_L_EIS_GYRO].on)
+		inv_push_eis_buffer(st, t, calib);
+
+	for (i = 0; i < 2; i++)
+		inv_s16_gyro_push(st, gyro_data[i], raw, t);
+	for (i = 0; i < 2; i++)
+		inv_s32_gyro_push(st, calib_data[i], calib, t);
+
+	return 0;
+}
+int inv_push_8bytes_buffer(struct inv_mpu_state *st, u16 sensor, u64 t, s16 *d)
+{
+	struct iio_dev *indio_dev = iio_priv_to_dev(st);
+	u8 buf[IIO_BUFFER_BYTES];
+	int ii, j;
+
+	if ((sensor == STEP_DETECTOR_HDR) ||
+					(sensor == STEP_DETECTOR_WAKE_HDR)) {
+		memcpy(buf, &sensor, sizeof(sensor));
+		memcpy(&buf[2], &d[0], sizeof(d[0]));
+		for (j = 0; j < 2; j++)
+			memcpy(&buf[4 + j * 2], &d[j + 1], sizeof(d[j]));
+		iio_push_to_buffers(indio_dev, buf);
+		inv_push_timestamp(indio_dev, t);
+		if (sensor == STEP_DETECTOR_WAKE_HDR)
+			st->wake_sensor_received = true;
+		return 0;
+	}
+	for (ii = 0; ii < SENSOR_L_NUM_MAX; ii++) {
+		if (st->sensor_l[ii].on &&
+		    (st->sensor_l[ii].base == sensor) &&
+		    (st->sensor_l[ii].div != 0xffff)) {
+			st->sensor_l[ii].counter++;
+			if (st->sensor_l[ii].counter >= st->sensor_l[ii].div) {
+				pr_debug(
+	"Sensor_l = %d sensor = %d header [%04X] div [%d] ts [%lld] %d %d %d\n",
+	ii, sensor, st->sensor_l[ii].header,
+	st->sensor_l[ii].div, t, d[0], d[1], d[2]);
+
+				memcpy(buf, &st->sensor_l[ii].header,
+				       sizeof(st->sensor_l[ii].header));
+				memcpy(&buf[2], &d[0], sizeof(d[0]));
+				for (j = 0; j < 2; j++)
+					memcpy(&buf[4 + j * 2], &d[j + 1],
+					       sizeof(d[j]));
+
+				iio_push_to_buffers(indio_dev, buf);
+				inv_push_timestamp(indio_dev, t);
+				st->sensor_l[ii].counter = 0;
+				if (st->sensor_l[ii].wake_on)
+					st->wake_sensor_received = true;
+			}
+		}
+	}
+
+	return 0;
+}
+#ifdef CONFIG_INV_MPU_IIO_ICM20648
+/* Implemented activity to string function for BAC test */
+#define TILT_DETECTED  0x1000
+#define NONE 0x00
+#define DRIVE 0x01
+#define WALK 0x02
+#define RUN 0x04
+#define BIKE 0x08
+#define TILT 0x10
+#define STILL 0x20
+#define DRIVE_WALK (DRIVE | WALK)
+#define DRIVE_RUN (DRIVE | RUN)
+
+char *act_string(s16 data)
+{
+	data &= (~TILT);
+	switch (data) {
+	case NONE:
+		return "None";
+	case DRIVE:
+		return "Drive";
+	case WALK:
+		return "Walk";
+	case RUN:
+		return "Run";
+	case BIKE:
+		return "Bike";
+	case STILL:
+		return "Still";
+	case DRIVE_WALK:
+		return "drive and walk";
+	case DRIVE_RUN:
+		return "drive and run";
+	default:
+		return "Unknown";
+	}
+	return "Unknown";
+}
+
+char *inv_tilt_check(s16 data)
+{
+	if (data & TILT)
+		return "Tilt";
+	else
+		return "None";
+}
+
+int inv_push_8bytes_kf(struct inv_mpu_state *st, u16 hdr, u64 t, s16 *d)
+{
+	struct iio_dev *indio_dev = iio_priv_to_dev(st);
+	u8 buf[IIO_BUFFER_BYTES];
+	int i;
+
+	if (st->chip_config.activity_on) {
+		memcpy(buf, &hdr, sizeof(hdr));
+		for (i = 0; i < 3; i++)
+			memcpy(&buf[2 + i * 2], &d[i], sizeof(d[i]));
+
+		kfifo_in(&st->kf, buf, IIO_BUFFER_BYTES);
+		memcpy(buf, &t, sizeof(t));
+		kfifo_in(&st->kf, buf, IIO_BUFFER_BYTES);
+		st->activity_size += IIO_BUFFER_BYTES * 2;
+	}
+	if (st->chip_config.tilt_enable) {
+		pr_debug("d[0] = %04X,  [%X : %s] to [%X : %s]",
+		d[0], d[0] & 0x00FF,
+		inv_tilt_check(d[0] & 0x00FF),
+		(d[0] & 0xFF00) >> 8,  inv_tilt_check((d[0] & 0xFF00) >> 8));
+		sysfs_notify(&indio_dev->dev.kobj, NULL, "poll_tilt");
+	}
+
+	pr_debug("d[0] = %04X,  [%X : %s] to [%X : %s]", d[0], d[0] & 0x00FF,
+		act_string(d[0] & 0x00FF),
+		(d[0] & 0xFF00) >> 8,  act_string((d[0] & 0xFF00) >> 8));
+
+	read_be32_from_mem(st, &st->bac_drive_conf, BAC_DRIVE_CONFIDENCE);
+	read_be32_from_mem(st, &st->bac_walk_conf, BAC_WALK_CONFIDENCE);
+	read_be32_from_mem(st, &st->bac_smd_conf, BAC_SMD_CONFIDENCE);
+	read_be32_from_mem(st, &st->bac_bike_conf, BAC_BIKE_CONFIDENCE);
+	read_be32_from_mem(st, &st->bac_still_conf, BAC_STILL_CONFIDENCE);
+	read_be32_from_mem(st, &st->bac_run_conf, BAC_RUN_CONFIDENCE);
+
+	return 0;
+}
+#endif
+
+int inv_send_steps(struct inv_mpu_state *st, int step, u64 ts)
+{
+	s16 s[3];
+
+	s[0] = 0;
+	s[1] = (s16) (step & 0xffff);
+	s[2] = (s16) ((step >> 16) & 0xffff);
+	if (st->step_counter_l_on)
+		inv_push_special_8bytes_buffer(st, STEP_COUNTER_HDR, ts, s);
+	if (st->step_counter_wake_l_on) {
+		inv_push_special_8bytes_buffer(st, STEP_COUNTER_WAKE_HDR,
+					       ts, s);
+		st->wake_sensor_received = true;
+	}
+	return 0;
+}
+
+void inv_push_step_indicator(struct inv_mpu_state *st, u64 t)
+{
+	s16 sen[3];
+#define STEP_INDICATOR_HEADER 0x0001
+
+	sen[0] = 0;
+	sen[1] = 0;
+	sen[2] = 0;
+	inv_push_8bytes_buffer(st, STEP_INDICATOR_HEADER, t, sen);
+}
+
+/*
+ *  inv_irq_handler() - Cache a timestamp at each data ready interrupt.
+ */
+static irqreturn_t inv_irq_handler(int irq, void *dev_id)
+{
+	return IRQ_WAKE_THREAD;
+}
+
+#ifdef TIMER_BASED_BATCHING
+static enum hrtimer_restart inv_batch_timer_handler(struct hrtimer *timer)
+{
+	struct inv_mpu_state *st =
+		container_of(timer, struct inv_mpu_state, hr_batch_timer);
+
+	if (st->chip_config.gyro_enable || st->chip_config.accel_enable) {
+		hrtimer_forward_now(&st->hr_batch_timer,
+			ns_to_ktime(st->batch_timeout));
+		schedule_work(&st->batch_work);
+		return HRTIMER_RESTART;
+	}
+	st->is_batch_timer_running = 0;
+	return HRTIMER_NORESTART;
+}
+#endif
+
+void inv_mpu_unconfigure_ring(struct iio_dev *indio_dev)
+{
+	struct inv_mpu_state *st = iio_priv(indio_dev);
+#ifdef KERNEL_VERSION_4_X
+	devm_free_irq(st->dev, st->irq, st);
+	devm_iio_kfifo_free(st->dev, indio_dev->buffer);
+#else
+	free_irq(st->irq, st);
+	iio_kfifo_free(indio_dev->buffer);
+#endif
+};
+EXPORT_SYMBOL_GPL(inv_mpu_unconfigure_ring);
+
+#ifndef KERNEL_VERSION_4_X
+static int inv_predisable(struct iio_dev *indio_dev)
+{
+	return 0;
+}
+
+static int inv_preenable(struct iio_dev *indio_dev)
+{
+	return 0;
+}
+
+static const struct iio_buffer_setup_ops inv_mpu_ring_setup_ops = {
+	.preenable = &inv_preenable,
+	.predisable = &inv_predisable,
+};
+#endif
+
+int inv_mpu_configure_ring(struct iio_dev *indio_dev)
+{
+	int ret;
+	struct inv_mpu_state *st = iio_priv(indio_dev);
+	struct iio_buffer *ring;
+
+#ifdef TIMER_BASED_BATCHING
+	/* configure hrtimer */
+	hrtimer_init(&st->hr_batch_timer, CLOCK_BOOTTIME, HRTIMER_MODE_REL);
+	st->hr_batch_timer.function = inv_batch_timer_handler;
+	INIT_WORK(&st->batch_work, inv_batch_work);
+#endif
+#ifdef KERNEL_VERSION_4_X
+	ring = devm_iio_kfifo_allocate(st->dev);
+	if (!ring)
+		return -ENOMEM;
+	ring->scan_timestamp = true;
+	iio_device_attach_buffer(indio_dev, ring);
+	ret = devm_request_threaded_irq(st->dev,
+		st->irq,
+		inv_irq_handler,
+		inv_read_fifo,
+		IRQF_TRIGGER_RISING | IRQF_SHARED,
+		"inv_irq",
+		st);
+	if (ret) {
+		devm_iio_kfifo_free(st->dev, ring);
+		return ret;
+	}
+
+	// this mode does not use ops
+	indio_dev->modes = INDIO_ALL_BUFFER_MODES;
+
+	return ret;
+#else
+	ring = iio_kfifo_allocate(indio_dev);
+	if (!ring)
+		return -ENOMEM;
+	indio_dev->buffer = ring;
+	/* setup ring buffer */
+	ring->scan_timestamp = true;
+	indio_dev->setup_ops = &inv_mpu_ring_setup_ops;
+	ret = request_threaded_irq(st->irq,
+			inv_irq_handler,
+			inv_read_fifo,
+			IRQF_TRIGGER_RISING | IRQF_SHARED,
+			"inv_irq",
+			st);
+	if (ret)
+		goto error_iio_sw_rb_free;
+
+	indio_dev->modes |= INDIO_BUFFER_HARDWARE;
+
+	return 0;
+error_iio_sw_rb_free:
+	iio_kfifo_free(indio_dev->buffer);
+
+	return ret;
+#endif
+}
+EXPORT_SYMBOL_GPL(inv_mpu_configure_ring);
diff --git a/drivers/iio/imu/inv_mpu/inv_mpu_spi.c b/drivers/iio/imu/inv_mpu/inv_mpu_spi.c
new file mode 100644
index 0000000..fb91678
--- /dev/null
+++ b/drivers/iio/imu/inv_mpu/inv_mpu_spi.c
@@ -0,0 +1,410 @@
+/*
+* Copyright (C) 2012-2018 InvenSense, Inc.
+*
+* This software is licensed under the terms of the GNU General Public
+* License version 2, as published by the Free Software Foundation, and
+* may be copied, distributed, and modified under those terms.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*/
+#define pr_fmt(fmt) "inv_mpu: " fmt
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/spi/spi.h>
+#include <linux/err.h>
+#include <linux/delay.h>
+#include <linux/sysfs.h>
+#include <linux/jiffies.h>
+#include <linux/irq.h>
+#include <linux/interrupt.h>
+#include <linux/kfifo.h>
+#include <linux/poll.h>
+#include <linux/miscdevice.h>
+#include <linux/spinlock.h>
+
+#include "inv_mpu_iio.h"
+#include "inv_mpu_dts.h"
+
+#define INV_SPI_READ 0x80
+
+static int inv_spi_single_write(struct inv_mpu_state *st, u8 reg, u8 data)
+{
+	struct spi_message msg;
+	int res;
+	u8 d[2];
+	struct spi_transfer xfers = {
+		.tx_buf = d,
+		.bits_per_word = 8,
+		.len = 2,
+	};
+
+	pr_debug("reg_write: reg=0x%x data=0x%x\n", reg, data);
+	d[0] = reg;
+	d[1] = data;
+	spi_message_init(&msg);
+	spi_message_add_tail(&xfers, &msg);
+	res = spi_sync(to_spi_device(st->dev), &msg);
+
+	return res;
+}
+
+static int inv_spi_read(struct inv_mpu_state *st, u8 reg, int len, u8 *data)
+{
+	struct spi_message msg;
+	int res;
+	u8 d[1];
+	struct spi_transfer xfers[] = {
+		{
+		 .tx_buf = d,
+		 .bits_per_word = 8,
+		 .len = 1,
+		 },
+		{
+		 .rx_buf = data,
+		 .bits_per_word = 8,
+		 .len = len,
+		 }
+	};
+
+	if (!data)
+		return -EINVAL;
+
+	d[0] = (reg | INV_SPI_READ);
+
+	spi_message_init(&msg);
+	spi_message_add_tail(&xfers[0], &msg);
+	spi_message_add_tail(&xfers[1], &msg);
+	res = spi_sync(to_spi_device(st->dev), &msg);
+
+	if (len ==1)
+		pr_debug("reg_read: reg=0x%x length=%d data=0x%x\n",
+							reg, len, data[0]);
+	else
+		pr_debug("reg_read: reg=0x%x length=%d d0=0x%x d1=0x%x\n",
+					reg, len, data[0], data[1]);
+
+	return res;
+
+}
+
+static int inv_spi_mem_write(struct inv_mpu_state *st, u8 mpu_addr, u16 mem_addr,
+		     u32 len, u8 const *data)
+{
+	struct spi_message msg;
+	u8 buf[258];
+	int res;
+
+	struct spi_transfer xfers = {
+		.tx_buf = buf,
+		.bits_per_word = 8,
+		.len = len + 1,
+	};
+
+	if (!data || !st)
+		return -EINVAL;
+
+	if (len > (sizeof(buf) - 1))
+		return -ENOMEM;
+
+	inv_plat_single_write(st, REG_MEM_BANK_SEL, mem_addr >> 8);
+	inv_plat_single_write(st, REG_MEM_START_ADDR, mem_addr & 0xFF);
+
+	buf[0] = REG_MEM_R_W;
+	memcpy(buf + 1, data, len);
+	spi_message_init(&msg);
+	spi_message_add_tail(&xfers, &msg);
+	res = spi_sync(to_spi_device(st->dev), &msg);
+
+	return res;
+}
+
+static int inv_spi_mem_read(struct inv_mpu_state *st, u8 mpu_addr, u16 mem_addr,
+		    u32 len, u8 *data)
+{
+	int res;
+
+	if (!data || !st)
+		return -EINVAL;
+
+	if (len > 256)
+		return -EINVAL;
+
+	res = inv_plat_single_write(st, REG_MEM_BANK_SEL, mem_addr >> 8);
+	res = inv_plat_single_write(st, REG_MEM_START_ADDR, mem_addr & 0xFF);
+	res = inv_plat_read(st, REG_MEM_R_W, len, data);
+
+	return res;
+}
+
+/*
+ *  inv_mpu_probe() - probe function.
+ */
+static int inv_mpu_probe(struct spi_device *spi)
+{
+	const struct spi_device_id *id = spi_get_device_id(spi);
+	struct inv_mpu_state *st;
+	struct iio_dev *indio_dev;
+	int result;
+
+#ifdef KERNEL_VERSION_4_X
+	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
+	if (indio_dev == NULL) {
+		pr_err("memory allocation failed\n");
+		result = -ENOMEM;
+		goto out_no_free;
+	}
+#else
+	indio_dev = iio_device_alloc(sizeof(*st));
+	if (indio_dev == NULL) {
+		pr_err("memory allocation failed\n");
+		result = -ENOMEM;
+		goto out_no_free;
+	}
+#endif
+	st = iio_priv(indio_dev);
+	st->write = inv_spi_single_write;
+	st->read = inv_spi_read;
+	st->mem_write = inv_spi_mem_write;
+	st->mem_read = inv_spi_mem_read;
+	st->dev = &spi->dev;
+	st->irq = spi->irq;
+#if !defined(CONFIG_INV_MPU_IIO_ICM20602) \
+	&& !defined(CONFIG_INV_MPU_IIO_IAM20680)
+	st->i2c_dis = BIT_I2C_IF_DIS;
+#endif
+	st->bus_type = BUS_SPI;
+	spi_set_drvdata(spi, indio_dev);
+	indio_dev->dev.parent = &spi->dev;
+	indio_dev->name = id->name;
+
+#ifdef CONFIG_OF
+	result = invensense_mpu_parse_dt(st->dev, &st->plat_data);
+	if (result)
+#  ifdef KERNEL_VERSION_4_X
+		return -ENODEV;
+#  else
+		goto out_free;
+#  endif
+	/* Power on device */
+	if (st->plat_data.power_on) {
+		result = st->plat_data.power_on(&st->plat_data);
+		if (result < 0) {
+			dev_err(st->dev, "power_on failed: %d\n", result);
+#  ifdef KERNEL_VERSION_4_X
+			return -ENODEV;
+#  else
+			goto out_free;
+#  endif
+		}
+		pr_info("%s: power on here.\n", __func__);
+	}
+	pr_info("%s: power on.\n", __func__);
+
+	msleep(100);
+#else
+	if (dev_get_platdata(st->dev) == NULL)
+#  ifdef KERNEL_VERSION_4_X
+		return -ENODEV;
+#  else
+		goto out_free;
+#  endif
+	st->plat_data = *(struct mpu_platform_data *)dev_get_platdata(st->dev);
+#endif
+
+	/* power is turned on inside check chip type */
+	result = inv_check_chip_type(indio_dev, id->name);
+	if (result)
+#ifdef KERNEL_VERSION_4_X
+		return -ENODEV;
+#else
+		goto out_free;
+#endif
+
+	result = inv_mpu_configure_ring(indio_dev);
+	if (result) {
+		pr_err("configure ring buffer fail\n");
+		goto out_free;
+	}
+#ifdef KERNEL_VERSION_4_X
+	result = devm_iio_device_register(st->dev, indio_dev);
+	if (result) {
+		pr_err("IIO device register fail\n");
+		goto out_unreg_ring;
+	}
+#else
+	result = iio_buffer_register(indio_dev, indio_dev->channels,
+				     indio_dev->num_channels);
+	if (result) {
+		pr_err("ring buffer register fail\n");
+		goto out_unreg_ring;
+	}
+
+	result = iio_device_register(indio_dev);
+	if (result) {
+		pr_err("IIO device register fail\n");
+		goto out_remove_ring;
+	}
+#endif
+
+	result = inv_create_dmp_sysfs(indio_dev);
+	if (result) {
+		pr_err("create dmp sysfs failed\n");
+		goto out_unreg_iio;
+	}
+	init_waitqueue_head(&st->wait_queue);
+	st->resume_state = true;
+#ifdef CONFIG_HAS_WAKELOCK
+	wake_lock_init(&st->wake_lock, WAKE_LOCK_SUSPEND, "inv_mpu");
+#else
+	wakeup_source_init(&st->wake_lock, "inv_mpu");
+#endif
+	dev_info(st->dev, "%s ma-kernel-%s is ready to go!\n",
+	         indio_dev->name, INVENSENSE_DRIVER_VERSION);
+
+#ifdef SENSOR_DATA_FROM_REGISTERS
+	pr_info("Data read from registers\n");
+#else
+	pr_info("Data read from FIFO\n");
+#endif
+#ifdef TIMER_BASED_BATCHING
+	pr_info("Timer based batching\n");
+#endif
+
+	return 0;
+#ifdef KERNEL_VERSION_4_X
+out_unreg_iio:
+	devm_iio_device_unregister(st->dev, indio_dev);
+out_unreg_ring:
+	inv_mpu_unconfigure_ring(indio_dev);
+out_free:
+	devm_iio_device_free(st->dev, indio_dev);
+out_no_free:
+#else
+out_unreg_iio:
+	iio_device_unregister(indio_dev);
+out_remove_ring:
+	iio_buffer_unregister(indio_dev);
+out_unreg_ring:
+	inv_mpu_unconfigure_ring(indio_dev);
+out_free:
+	iio_device_free(indio_dev);
+out_no_free:
+#endif
+	dev_err(st->dev, "%s failed %d\n", __func__, result);
+
+	return -EIO;
+}
+
+static void inv_mpu_shutdown(struct spi_device *spi)
+{
+	struct iio_dev *indio_dev = spi_get_drvdata(spi);
+	struct inv_mpu_state *st = iio_priv(indio_dev);
+	int result;
+
+	mutex_lock(&indio_dev->mlock);
+	inv_switch_power_in_lp(st, true);
+	dev_dbg(st->dev, "Shutting down %s...\n", st->hw->name);
+
+	/* reset to make sure previous state are not there */
+	result = inv_plat_single_write(st, REG_PWR_MGMT_1, BIT_H_RESET);
+	if (result)
+		dev_err(st->dev, "Failed to reset %s\n",
+			st->hw->name);
+	msleep(POWER_UP_TIME);
+	/* turn off power to ensure gyro engine is off */
+	result = inv_set_power(st, false);
+	if (result)
+		dev_err(st->dev, "Failed to turn off %s\n",
+			st->hw->name);
+	inv_switch_power_in_lp(st, false);
+	mutex_unlock(&indio_dev->mlock);
+}
+
+/*
+ *  inv_mpu_remove() - remove function.
+ */
+static int inv_mpu_remove(struct spi_device *spi)
+{
+	struct iio_dev *indio_dev = spi_get_drvdata(spi);
+	struct inv_mpu_state *st = iio_priv(indio_dev);
+
+#ifdef KERNEL_VERSION_4_X
+	devm_iio_device_unregister(st->dev, indio_dev);
+#else
+	iio_device_unregister(indio_dev);
+	iio_buffer_unregister(indio_dev);
+#endif
+	inv_mpu_unconfigure_ring(indio_dev);
+#ifdef KERNEL_VERSION_4_X
+	devm_iio_device_free(st->dev, indio_dev);
+#else
+	iio_device_free(indio_dev);
+#endif
+	dev_info(st->dev, "inv-mpu-iio module removed.\n");
+
+	return 0;
+}
+
+#ifdef CONFIG_PM_SLEEP
+static int inv_mpu_spi_suspend(struct device *dev)
+{
+	struct iio_dev *indio_dev = spi_get_drvdata(to_spi_device(dev));
+
+	return inv_mpu_suspend(indio_dev);
+}
+
+static void inv_mpu_spi_complete(struct device *dev)
+{
+	struct iio_dev *indio_dev = spi_get_drvdata(to_spi_device(dev));
+
+	inv_mpu_complete(indio_dev);
+}
+#endif
+
+static const struct dev_pm_ops inv_mpu_spi_pmops = {
+#ifdef CONFIG_PM_SLEEP
+	.suspend = inv_mpu_spi_suspend,
+	.complete = inv_mpu_spi_complete,
+#endif
+};
+
+/* device id table is used to identify what device can be
+ * supported by this driver
+ */
+static const struct spi_device_id inv_mpu_id[] = {
+#ifdef CONFIG_INV_MPU_IIO_ICM20648
+	{"icm20645", ICM20645},
+	{"icm10340", ICM10340},
+	{"icm20648", ICM20648},
+#else
+	{"icm20608d", ICM20608D},
+	{"icm20690", ICM20690},
+	{"icm20602", ICM20602},
+	{"iam20680", IAM20680},
+#endif
+	{}
+};
+
+MODULE_DEVICE_TABLE(spi, inv_mpu_id);
+
+static struct spi_driver inv_mpu_driver = {
+	.probe = inv_mpu_probe,
+	.remove = inv_mpu_remove,
+	.shutdown = inv_mpu_shutdown,
+	.id_table = inv_mpu_id,
+	.driver = {
+		.owner = THIS_MODULE,
+		.name = "inv-mpu-iio-spi",
+		.pm = &inv_mpu_spi_pmops,
+	},
+};
+module_spi_driver(inv_mpu_driver);
+
+MODULE_AUTHOR("Invensense Corporation");
+MODULE_DESCRIPTION("Invensense SPI device driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/iio/imu/inv_mpu/inv_mpu_timestamp.c b/drivers/iio/imu/inv_mpu/inv_mpu_timestamp.c
new file mode 100644
index 0000000..2cc721b
--- /dev/null
+++ b/drivers/iio/imu/inv_mpu/inv_mpu_timestamp.c
@@ -0,0 +1,280 @@
+/*
+ * Copyright (C) 2012-2018 InvenSense, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#define pr_fmt(fmt) "inv_mpu: " fmt
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/err.h>
+#include <linux/delay.h>
+#include <linux/sysfs.h>
+#include <linux/jiffies.h>
+#include <linux/irq.h>
+#include <linux/interrupt.h>
+#include <linux/kfifo.h>
+#include <linux/poll.h>
+#include <linux/miscdevice.h>
+#include <linux/math64.h>
+
+#include "inv_mpu_iio.h"
+
+#define INV_TIME_CALIB_THRESHOLD_1 2
+
+#define MIN_DELAY (3 * NSEC_PER_MSEC)
+#define JITTER_THRESH ( 1 * NSEC_PER_MSEC)
+
+int inv_update_dmp_ts(struct inv_mpu_state *st, int ind)
+{
+	int i;
+	u32 counter;
+	u64 ts;
+	enum INV_ENGINE en_ind;
+	struct inv_timestamp_algo *ts_algo = &st->ts_algo;
+	u32 base_time;
+	u64 cal_period;
+
+	if (st->mode_1k_on)
+		cal_period = (NSEC_PER_SEC >> 2);
+	else
+		cal_period = 2 * NSEC_PER_SEC;
+
+	ts = ts_algo->last_run_time - st->sensor[ind].time_calib;
+	counter = st->sensor[ind].sample_calib;
+	en_ind = st->sensor[ind].engine_base;
+	if (en_ind != ts_algo->clock_base)
+		return 0;
+	/* we average over 2 seconds period to do the timestamp calculation */
+	if (ts < cal_period)
+		return 0;
+	/* this is the first time we do timestamp averaging, return */
+	/* after resume from suspend, the clock of linux has up to 1 seconds
+	   drift. We should start from the resume clock instead of using clock
+	   before resume */
+	if ((!st->sensor[ind].calib_flag) || ts_algo->resume_flag) {
+		st->sensor[ind].sample_calib = 0;
+		st->sensor[ind].time_calib = ts_algo->last_run_time;
+		st->sensor[ind].calib_flag = 1;
+		ts_algo->resume_flag = false;
+
+		return 0;
+	}
+	/* if the sample number in current FIFO is not zero and between now and
+		last update time is more than 2 seconds, we do calculation */
+	if ((counter > 0) &&
+		(ts_algo->last_run_time - st->eng_info[en_ind].last_update_time >
+		 cal_period)) {
+		/* duration for each sensor */
+		st->sensor[ind].dur = (u32) div_u64(ts, counter);
+		/* engine duration derived from each sensor */
+		if (st->sensor[ind].div)
+			st->eng_info[en_ind].dur = st->sensor[ind].dur /
+							st->sensor[ind].div;
+		else
+			pr_err("sensor %d divider zero!\n", ind);
+		/* update base time for each sensor */
+		if (st->eng_info[en_ind].divider) {
+			base_time = (st->eng_info[en_ind].dur /
+					st->eng_info[en_ind].divider) *
+					st->eng_info[en_ind].orig_rate;
+			if (st->mode_1k_on)
+				st->eng_info[en_ind].base_time_1k = base_time;
+			else
+				st->eng_info[en_ind].base_time = base_time;
+		} else {
+			pr_err("engine %d divider zero!\n", en_ind);
+		}
+
+		st->eng_info[en_ind].last_update_time = ts_algo->last_run_time;
+		/* update all the sensors duration based on the same engine */
+		for (i = 0; i < SENSOR_NUM_MAX; i++) {
+			if (st->sensor[i].on &&
+			    (st->sensor[i].engine_base == en_ind))
+				st->sensor[i].dur = st->sensor[i].div *
+				    st->eng_info[en_ind].dur;
+		}
+
+	}
+	st->sensor[ind].sample_calib = 0;
+	st->sensor[ind].time_calib = ts_algo->last_run_time;
+
+	return 0;
+}
+/**
+ *     int inv_get_last_run_time_non_dmp_record_mode(struct inv_mpu_state *st)
+ *     This is the function to get last run time in non dmp and record mode.
+ *     This function will update the last_run_time, which is important parameter
+ *     in overall timestamp algorithm.
+ *     return value: this function returns fifo count value.
+*/
+int inv_get_last_run_time_non_dmp_record_mode(struct inv_mpu_state *st)
+{
+	long long t_pre, t_post, dur;
+	int fifo_count;
+#ifndef SENSOR_DATA_FROM_REGISTERS
+	int res;
+	u8 data[2];
+#endif
+
+	t_pre = get_time_ns();
+#ifndef SENSOR_DATA_FROM_REGISTERS
+	res = inv_plat_read(st, REG_FIFO_COUNT_H, FIFO_COUNT_BYTE, data);
+	if (res) {
+		pr_info("read REG_FIFO_COUNT_H failed= %d\n", res);
+		return 0;
+	}
+#endif
+	t_post = get_time_ns();
+
+#ifdef SENSOR_DATA_FROM_REGISTERS
+	if (st->fifo_count_mode == BYTE_MODE)
+		fifo_count = st->batch.pk_size;
+	else
+		fifo_count = 1;
+#else
+	fifo_count = be16_to_cpup((__be16 *) (data));
+#endif
+	pr_debug("fifc=%d\n", fifo_count);
+	if (!fifo_count)
+		return 0;
+	if (st->special_mag_mode && (fifo_count == 2)) {
+		pr_debug("special trigger\n");
+		fifo_count = 1;
+	}
+
+	/* In non DMP mode, either gyro or accel duration is the duration
+           for each sample */
+	if (st->chip_config.gyro_enable)
+		dur = st->eng_info[ENGINE_GYRO].dur;
+	else
+		dur = st->eng_info[ENGINE_ACCEL].dur;
+
+	if (st->fifo_count_mode == BYTE_MODE) {
+		fifo_count /= st->batch.pk_size;
+	}
+
+	/* In record mode, each number in fifo_count is 1 record or 1 sample */
+	st->ts_algo.last_run_time += dur * fifo_count;
+	if (st->ts_algo.last_run_time < t_pre)
+		st->ts_algo.last_run_time = t_pre;
+	if (st->ts_algo.last_run_time > t_post)
+		st->ts_algo.last_run_time = t_post;
+
+	return fifo_count;
+}
+
+int inv_get_dmp_ts(struct inv_mpu_state *st, int i)
+{
+	u64 current_time;
+	int expected_lower_duration, expected_upper_duration;
+
+	current_time = get_time_ns();
+
+	st->sensor[i].ts += st->sensor[i].dur + st->sensor[i].ts_adj;
+
+	if (st->sensor[i].ts < st->sensor[i].previous_ts)
+		st->sensor[i].ts = st->sensor[i].previous_ts + st->sensor[i].dur;
+
+	//hifi sensor limits ts jitter to +/- 2%
+	expected_upper_duration = st->eng_info[st->sensor[i].engine_base].divider * 1020000;
+	expected_lower_duration = st->eng_info[st->sensor[i].engine_base].divider * 980000;
+#if defined(CONFIG_INV_MPU_IIO_ICM20602) || defined(CONFIG_INV_MPU_IIO_ICM20690) || defined(CONFIG_INV_MPU_IIO_IAM20680)
+	if (st->sensor[i].ts < st->sensor[i].previous_ts + expected_lower_duration)
+		st->sensor[i].ts = st->sensor[i].previous_ts + expected_lower_duration;
+	if (st->sensor[i].ts > st->sensor[i].previous_ts + expected_upper_duration)
+		st->sensor[i].ts = st->sensor[i].previous_ts + expected_upper_duration;
+#endif
+	if (st->sensor[i].ts > current_time )
+		st->sensor[i].ts = current_time;
+
+	st->sensor[i].previous_ts = st->sensor[i].ts;
+
+	pr_debug("ts=%lld, reset=%lld\n", st->sensor[i].ts, st->ts_algo.reset_ts);
+	if (st->sensor[i].ts < st->ts_algo.reset_ts) {
+		pr_debug("less than reset\n");
+		st->sensor[i].send = false;
+	} else {
+		st->sensor[i].send = true;
+	}
+
+	if (st->header_count == 1)
+		inv_update_dmp_ts(st, i);
+
+	return 0;
+}
+
+static void process_sensor_bounding(struct inv_mpu_state *st, int i)
+{
+	s64 elaps_time, thresh1, thresh2;
+	struct inv_timestamp_algo *ts_algo = &st->ts_algo;
+	u32 dur;
+
+	elaps_time = ((u64) (st->sensor[i].dur)) * st->sensor[i].count;
+	thresh1 = ts_algo->last_run_time - elaps_time;
+
+	dur = max(st->sensor[i].dur, (int)MIN_DELAY);
+	thresh2 = thresh1 - dur;
+	if (thresh1 < 0)
+		thresh1 = 0;
+	if (thresh2 < 0)
+		thresh2 = 0;
+	st->sensor[i].ts_adj = 0;
+	if ((ts_algo->calib_counter >= INV_TIME_CALIB_THRESHOLD_1) &&
+						(!ts_algo->resume_flag)) {
+		if (st->sensor[i].ts < thresh2)
+			st->sensor[i].ts_adj = thresh2 - st->sensor[i].ts;
+	} else if ((ts_algo->calib_counter >=
+		INV_TIME_CALIB_THRESHOLD_1) && ts_algo->resume_flag) {
+		if (st->sensor[i].ts < thresh2)
+			st->sensor[i].ts = ts_algo->last_run_time -
+						elaps_time - JITTER_THRESH;
+	} else {
+		st->sensor[i].ts = ts_algo->last_run_time - elaps_time -
+							JITTER_THRESH;
+		st->sensor[i].previous_ts = st->sensor[i].ts;
+	}
+
+	if (st->sensor[i].ts > thresh1)
+		st->sensor[i].ts_adj = thresh1 - st->sensor[i].ts;
+	pr_debug("cali=%d\n", st->ts_algo.calib_counter);
+	pr_debug("adj= %lld\n", st->sensor[i].ts_adj);
+	pr_debug("dur= %d count= %d last= %lld\n", st->sensor[i].dur,
+				st->sensor[i].count, ts_algo->last_run_time);
+	if (st->sensor[i].ts_adj && (st->sensor[i].count > 1))
+		st->sensor[i].ts_adj = div_s64(st->sensor[i].ts_adj,
+							st->sensor[i].count);
+}
+/* inv_bound_timestamp (struct inv_mpu_state *st)
+	The purpose this function is to give a generic bound to each
+	sensor timestamp. The timestamp cannot exceed current time.
+	The timestamp cannot backwards one sample time either, otherwise, there
+	would be another sample in between. Using this principle, we can bound
+	the sensor samples */
+int inv_bound_timestamp(struct inv_mpu_state *st)
+{
+	int i;
+	struct inv_timestamp_algo *ts_algo = &st->ts_algo;
+
+	for (i = 0; i < SENSOR_NUM_MAX; i++) {
+		if (st->sensor[i].on) {
+			if (st->sensor[i].count) {
+				process_sensor_bounding(st, i);
+			} else if (ts_algo->calib_counter <
+				   INV_TIME_CALIB_THRESHOLD_1) {
+				st->sensor[i].ts = ts_algo->reset_ts;
+				st->sensor[i].previous_ts = st->sensor[i].ts;
+			}
+		}
+	}
+
+	return 0;
+}
diff --git a/drivers/iio/imu/inv_mpu/inv_test/Kconfig b/drivers/iio/imu/inv_mpu/inv_test/Kconfig
new file mode 100644
index 0000000..a4dfd95
--- /dev/null
+++ b/drivers/iio/imu/inv_mpu/inv_test/Kconfig
@@ -0,0 +1,13 @@
+#
+# Kconfig for Invensense IIO testing hooks
+#
+
+config INV_TESTING
+	boolean "Invensense IIO testing hooks"
+	depends on INV_MPU_IIO || INV_AMI306_IIO || INV_YAS530 || INV_HUB_IIO
+	default n
+	help
+	  This flag enables display of additional testing information from the
+	  Invensense IIO drivers
+	  It also enables the I2C counters facility to perform IO profiling.
+	  Some additional sysfs entries will appear when this flag is enabled.
diff --git a/drivers/iio/imu/inv_mpu/inv_test/Makefile b/drivers/iio/imu/inv_mpu/inv_test/Makefile
new file mode 100644
index 0000000..4f0edd3
--- /dev/null
+++ b/drivers/iio/imu/inv_mpu/inv_test/Makefile
@@ -0,0 +1,6 @@
+#
+# Makefile for Invensense IIO testing hooks.
+#
+
+obj-$(CONFIG_INV_TESTING) += inv_counters.o
+
diff --git a/drivers/iio/imu/inv_mpu/inv_test/inv_counters.c b/drivers/iio/imu/inv_mpu/inv_test/inv_counters.c
new file mode 100644
index 0000000..f60337c
--- /dev/null
+++ b/drivers/iio/imu/inv_mpu/inv_test/inv_counters.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright (C) 2012-2017 InvenSense, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/miscdevice.h>
+#include <linux/err.h>
+#include <linux/sysfs.h>
+#include <linux/kdev_t.h>
+#include <linux/string.h>
+#include <linux/jiffies.h>
+#include <linux/spinlock.h>
+#include <linux/kernel_stat.h>
+
+#include "inv_counters.h"
+
+static int mpu_irq;
+static int accel_irq;
+static int compass_irq;
+
+struct inv_counters {
+	uint32_t i2c_tempreads;
+	uint32_t i2c_mpureads;
+	uint32_t i2c_mpuwrites;
+	uint32_t i2c_accelreads;
+	uint32_t i2c_accelwrites;
+	uint32_t i2c_compassreads;
+	uint32_t i2c_compasswrites;
+	uint32_t i2c_compassirq;
+	uint32_t i2c_accelirq;
+};
+
+static struct inv_counters Counters;
+
+static ssize_t i2c_counters_show(struct class *cls,
+			struct class_attribute *attr, char *buf)
+{
+	return scnprintf(buf, PAGE_SIZE,
+		"%ld.%03ld %u %u %u %u %u %u %u %u %u %u\n",
+		jiffies / HZ, ((jiffies % HZ) * (1024 / HZ)),
+		mpu_irq ? kstat_irqs(mpu_irq) : 0,
+		Counters.i2c_tempreads,
+		Counters.i2c_mpureads, Counters.i2c_mpuwrites,
+		accel_irq ? kstat_irqs(accel_irq) : Counters.i2c_accelirq,
+		Counters.i2c_accelreads, Counters.i2c_accelwrites,
+		compass_irq ? kstat_irqs(compass_irq) : Counters.i2c_compassirq,
+		Counters.i2c_compassreads, Counters.i2c_compasswrites);
+}
+
+void inv_iio_counters_set_i2cirq(enum irqtype type, int irq)
+{
+	switch (type) {
+	case IRQ_MPU:
+		mpu_irq = irq;
+		break;
+	case IRQ_ACCEL:
+		accel_irq = irq;
+		break;
+	case IRQ_COMPASS:
+		compass_irq = irq;
+		break;
+	}
+}
+EXPORT_SYMBOL_GPL(inv_iio_counters_set_i2cirq);
+
+void inv_iio_counters_tempread(int count)
+{
+	Counters.i2c_tempreads += count;
+}
+EXPORT_SYMBOL_GPL(inv_iio_counters_tempread);
+
+void inv_iio_counters_mpuread(int count)
+{
+	Counters.i2c_mpureads += count;
+}
+EXPORT_SYMBOL_GPL(inv_iio_counters_mpuread);
+
+void inv_iio_counters_mpuwrite(int count)
+{
+	Counters.i2c_mpuwrites += count;
+}
+EXPORT_SYMBOL_GPL(inv_iio_counters_mpuwrite);
+
+void inv_iio_counters_accelread(int count)
+{
+	Counters.i2c_accelreads += count;
+}
+EXPORT_SYMBOL_GPL(inv_iio_counters_accelread);
+
+void inv_iio_counters_accelwrite(int count)
+{
+	Counters.i2c_accelwrites += count;
+}
+EXPORT_SYMBOL_GPL(inv_iio_counters_accelwrite);
+
+void inv_iio_counters_compassread(int count)
+{
+	Counters.i2c_compassreads += count;
+}
+EXPORT_SYMBOL_GPL(inv_iio_counters_compassread);
+
+void inv_iio_counters_compasswrite(int count)
+{
+	Counters.i2c_compasswrites += count;
+}
+EXPORT_SYMBOL_GPL(inv_iio_counters_compasswrite);
+
+void inv_iio_counters_compassirq(void)
+{
+	Counters.i2c_compassirq++;
+}
+EXPORT_SYMBOL_GPL(inv_iio_counters_compassirq);
+
+void inv_iio_counters_accelirq(void)
+{
+	Counters.i2c_accelirq++;
+}
+EXPORT_SYMBOL_GPL(inv_iio_counters_accelirq);
+
+static struct class_attribute inv_class_attr[] = {
+	__ATTR(i2c_counter, S_IRUGO, i2c_counters_show, NULL),
+	__ATTR_NULL
+};
+
+static struct class inv_counters_class = {
+	.name = "inv_counters",
+	.owner = THIS_MODULE,
+	.class_attrs = (struct class_attribute *) &inv_class_attr
+};
+
+static int __init inv_counters_init(void)
+{
+	memset(&Counters, 0, sizeof(Counters));
+
+	return class_register(&inv_counters_class);
+}
+
+static void __exit inv_counters_exit(void)
+{
+	class_unregister(&inv_counters_class);
+}
+
+module_init(inv_counters_init);
+module_exit(inv_counters_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("GESL");
+MODULE_DESCRIPTION("inv_counters debug support");
+
diff --git a/drivers/iio/imu/inv_mpu/inv_test/inv_counters.h b/drivers/iio/imu/inv_mpu/inv_test/inv_counters.h
new file mode 100644
index 0000000..62f7627
--- /dev/null
+++ b/drivers/iio/imu/inv_mpu/inv_test/inv_counters.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2012-2017 InvenSense, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#ifndef _INV_COUNTERS_H_
+#define _INV_COUNTERS_H_
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/err.h>
+#include <linux/sysfs.h>
+#include <linux/string.h>
+#include <linux/jiffies.h>
+#include <linux/spinlock.h>
+
+#ifdef CONFIG_INV_TESTING
+
+enum irqtype {
+	IRQ_MPU,
+	IRQ_ACCEL,
+	IRQ_COMPASS
+};
+
+#define INV_I2C_INC_MPUREAD(x)		inv_iio_counters_mpuread(x)
+#define INV_I2C_INC_MPUWRITE(x)		inv_iio_counters_mpuwrite(x)
+#define INV_I2C_INC_ACCELREAD(x)	inv_iio_counters_accelread(x)
+#define INV_I2C_INC_ACCELWRITE(x)	inv_iio_counters_accelwrite(x)
+#define INV_I2C_INC_COMPASSREAD(x)	inv_iio_counters_compassread(x)
+#define INV_I2C_INC_COMPASSWRITE(x)	inv_iio_counters_compasswrite(x)
+
+#define INV_I2C_INC_TEMPREAD(x)		inv_iio_counters_tempread(x)
+
+#define INV_I2C_SETIRQ(type, irq)	inv_iio_counters_set_i2cirq(type, irq)
+#define INV_I2C_INC_COMPASSIRQ()	inv_iio_counters_compassirq()
+#define INV_I2C_INC_ACCELIRQ()		inv_iio_counters_accelirq()
+
+void inv_iio_counters_mpuread(int count);
+void inv_iio_counters_mpuwrite(int count);
+void inv_iio_counters_accelread(int count);
+void inv_iio_counters_accelwrite(int count);
+void inv_iio_counters_compassread(int count);
+void inv_iio_counters_compasswrite(int count);
+
+void inv_iio_counters_tempread(int count);
+
+void inv_iio_counters_set_i2cirq(enum irqtype type, int irq);
+void inv_iio_counters_compassirq(void);
+void inv_iio_counters_accelirq(void);
+
+#else
+
+#define INV_I2C_INC_MPUREAD(x)
+#define INV_I2C_INC_MPUWRITE(x)
+#define INV_I2C_INC_ACCELREAD(x)
+#define INV_I2C_INC_ACCELWRITE(x)
+#define INV_I2C_INC_COMPASSREAD(x)
+#define INV_I2C_INC_COMPASSWRITE(x)
+
+#define INV_I2C_INC_TEMPREAD(x)
+
+#define INV_I2C_SETIRQ(type, irq)
+#define INV_I2C_INC_COMPASSIRQ()
+#define INV_I2C_INC_ACCELIRQ()
+
+#endif /* CONFIG_INV_TESTING */
+
+#endif /* _INV_COUNTERS_H_ */
+
diff --git a/drivers/iio/imu/st_asm330lhh/Kconfig b/drivers/iio/imu/st_asm330lhh/Kconfig
new file mode 100644
index 0000000..092cc48
--- /dev/null
+++ b/drivers/iio/imu/st_asm330lhh/Kconfig
@@ -0,0 +1,23 @@
+
+config IIO_ST_ASM330LHH
+	tristate "STMicroelectronics ASM330LHH sensor"
+	depends on (I2C || SPI)
+	select IIO_BUFFER
+	select IIO_KFIFO_BUF
+	select IIO_ST_ASM330LHH_I2C if (I2C)
+	select IIO_ST_ASM330LHH_SPI if (SPI_MASTER)
+	help
+	  Say yes here to build support for STMicroelectronics ASM330LHH imu
+	  sensor.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called st_asm330lhh.
+
+config IIO_ST_ASM330LHH_I2C
+	tristate
+	depends on IIO_ST_ASM330LHH
+
+config IIO_ST_ASM330LHH_SPI
+	tristate
+	depends on IIO_ST_ASM330LHH
+
diff --git a/drivers/iio/imu/st_asm330lhh/Makefile b/drivers/iio/imu/st_asm330lhh/Makefile
new file mode 100644
index 0000000..7af80de
--- /dev/null
+++ b/drivers/iio/imu/st_asm330lhh/Makefile
@@ -0,0 +1,5 @@
+st_asm330lhh-y := st_asm330lhh_core.o st_asm330lhh_buffer.o
+
+obj-$(CONFIG_IIO_ST_ASM330LHH) += st_asm330lhh.o
+obj-$(CONFIG_IIO_ST_ASM330LHH_I2C) += st_asm330lhh_i2c.o
+obj-$(CONFIG_IIO_ST_ASM330LHH_SPI) += st_asm330lhh_spi.o
diff --git a/drivers/iio/imu/st_asm330lhh/README.md b/drivers/iio/imu/st_asm330lhh/README.md
new file mode 100644
index 0000000..f06afd3
--- /dev/null
+++ b/drivers/iio/imu/st_asm330lhh/README.md
@@ -0,0 +1,201 @@
+Index
+=======
+	* Introduction
+	* Driver Integration details
+	* Android SensorHAL integration
+	* Linux SensorHAL integration
+	* More information
+	* Copyright
+
+
+Introduction
+==============
+This repository contains asm330lhh IMU STMicroelectronics MEMS sensor linux driver support for kernel version 3.18, 4.4 and 4.9.
+
+Data collected by asm330lhh STM sensor are pushed to userland through the kernel buffers of Linux IIO framework. User space applications can get sensor events by reading the related IIO devices created in the /dev directory (*/dev/iio{x}*). Please see [IIO][1] for more information.
+
+Asm330lhh IMU STM MEMS sensor support *I2C/SPI* digital interface. Please refer to [I2C][2] and [SPI][3] for detailed documentation.
+
+The STM Hardware Abstraction Layer (*HAL*) defines a standard interface for STM sensors allowing Android to be agnostic about low level driver implementation. The HAL library is packaged into modules (.so) file and loaded by the Android or Linux system at the appropriate time. For more information see [AOSP HAL Interface](https://source.android.com/devices/sensors/hal-interface.html) 
+
+STM Sensor HAL is leaning on [Linux IIO framework](https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/iio) to gather data from sensor device drivers and to forward samples to the Android Framework
+
+Driver Integration details
+=====================
+
+In order to explain how to integrate Asm330lhh IMU STM sensor into the kernel, please consider the following example
+
+### Source code integration
+
+> * Copy driver source code into your linux kernel target directory (e.g. *drivers/iio/imu*)
+> * Edit related Kconfig (e.g. *drivers/iio/imu/Kconfig*) adding *ASM330LHH* support:
+
+>         source "drivers/iio/imu/st_asm330lhh/Kconfig"
+
+> * Edit related Makefile (e.g. *drivers/iio/imu/Makefile*) adding the following line:
+
+>         obj-y += st_asm330lhh/
+
+### Device Tree configuration
+
+> To enable driver probing, add the asm330lhh node to the platform device tree as described below.
+
+> **Required properties:**
+
+> *- compatible*: "st,asm330lhh"
+
+> *- reg*: the I2C address or SPI chip select the device will respond to
+
+> *- interrupt-parent*: phandle to the parent interrupt controller as documented in [interrupts][4]
+
+> *- interrupts*: interrupt mapping for IRQ as documented in [interrupts][4]
+> 
+>**Recommended properties for SPI bus usage:**
+
+> *- spi-max-frequency*: maximum SPI bus frequency as documented in [SPI][3]
+> 
+> **Optional properties:**
+
+> *- st,drdy-int-pin*: MEMS sensor interrupt line to use (default 1)
+
+> I2C example (based on Raspberry PI 3):
+
+>		&i2c0 {
+>			status = "ok";
+>			#address-cells = <0x1>;
+>			#size-cells = <0x0>;
+>			asm330lhh@6b {
+>				compatible = "st,asm330lhh";
+>				reg = <0x6b>;
+>				interrupt-parent = <&gpio>;
+>				interrupts = <26 IRQ_TYPE_EDGE_RISING>;
+>		};
+
+> SPI example (based on Raspberry PI 3):
+
+>		&spi0 {
+>			status = "ok";
+>			#address-cells = <0x1>;
+>			#size-cells = <0x0>;
+>			asm330lhh@0 {
+>				spi-max-frequency = <500000>;
+>				compatible = "st,asm330lhh";
+>				reg = <0>;
+>				interrupt-parent = <&gpio>;
+>				interrupts = <26 IRQ_TYPE_EDGE_RISING>;
+>			};
+
+### Kernel configuration
+
+Configure kernel with *make menuconfig* (alternatively use *make xconfig* or *make qconfig*)
+ 
+>		Device Drivers  --->
+>			<M> Industrial I/O support  --->
+>				Inertial measurement units  --->
+>				<M>   STMicroelectronics ASM330LHH sensor  --->
+
+
+Android SensorHAL integration
+==============
+
+STM Sensor HAL is written in *C++* language using object-oriented design. For each hw sensor there is a custom class file (*Accelerometer.cpp*, *Gyroscope.cpp*) which extends the common base class (*SensorBase.cpp*).
+
+Copy the HAL source code into *<AOSP_DIR\>/hardware/STMicroelectronics/SensorHAL_IIO* folder. During building process Android will include automatically the SensorHAL Android.mk.
+In *<AOSP_DIR\>/device/<vendor\>/<board\>/device.mk* add package build information:
+
+	PRODUCT_PACKAGES += sensors.{TARGET_BOARD_PLATFORM}
+
+	Note: device.mk can not read $(TARGET_BOARD_PLATFORM) variable, read and replace the value from your BoardConfig.mk (e.g. PRODUCT_PACKAGES += sensors.msm8974 for Nexus 5)
+
+To compile the SensorHAL_IIO just build AOSP source code from *$TOP* folder
+
+	$ cd <AOSP_DIR>
+	$ source build/envsetup.sh
+	$ lunch <select target platform>
+	$ make V=99
+
+The compiled library will be placed in *<AOSP_DIR\>/out/target/product/<board\>/system/vendor/lib/hw/sensor.{TARGET_BOARD_PLATFORM}.so*
+
+To configure sensor the Sensor HAL IIO use mm utility from HAL root folder
+
+    since Android 7
+	$mm sensors-defconfig (default configuration)
+	$mm sensors-menuconfig
+
+    after Android 7
+    make -f Makefile_config sensors-defconfig (default configuration)
+    make -f Makefile_config sensors-menuconfig
+    
+Linux SensorHAL integration
+==============
+
+Linux Sensor HAL share the same source code of Android Sensor HAL. Before compiling the Linux Sensor HAL IIO
+you need to follow the same procedure listed in previous chapter "Android SensorHAL integration"
+To cross compile Linux Sensor HAL must export the following shell variables 
+
+>   export AOSP_DIR=<AOSP_DIR>
+>   export ARCH=<your target architecture>
+>   export CROSS_COMPILE=<toolchain for your target>
+
+then in *<AOSP_DIR\>/hardware/STMicroelectronics/SensorHAL_IIO* folder type
+>   make
+
+it will produce a SensorHAL.so file containing the library. 
+In relative pat Documentation/LinuxHal/ there are some examples explaining how to use Linux Sensor HAL
+
+Copyright
+========
+Copyright (C) 2017 STMicroelectronics
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+
+More Information
+=================
+[http://st.com](http://st.com)
+
+[https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/iio](https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/input)
+
+[https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/i2c](https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/i2c)
+
+[https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/spi](https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/spi)
+
+[https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bings/interrupt-controller/interrupts.txt](https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/interrupt-controller/interrupts.txt)
+
+
+Copyright Driver
+===========
+Copyright (C) 2017 STMicroelectronics
+
+This software is distributed under the GNU General Public License - see the accompanying COPYING file for more details.
+
+[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/iio/iio_configfs.txt "IIO"
+[2]: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/i2c "I2C"
+[3]: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/spi "SPI"
+[4]: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/interrupt-controller/interrupts.txt "interrupts"
+
+Copyright SensorHAL
+========
+Copyright (C) 2017 STMicroelectronics
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
diff --git a/drivers/iio/imu/st_asm330lhh/st_asm330lhh.h b/drivers/iio/imu/st_asm330lhh/st_asm330lhh.h
new file mode 100644
index 0000000..52b293f
--- /dev/null
+++ b/drivers/iio/imu/st_asm330lhh/st_asm330lhh.h
@@ -0,0 +1,238 @@
+/*
+ * STMicroelectronics st_asm330lhh sensor driver
+ *
+ * Copyright 2018 STMicroelectronics Inc.
+ *
+ * Lorenzo Bianconi <lorenzo.bianconi@st.com>
+ *
+ * Licensed under the GPL-2.
+ */
+
+#ifndef ST_ASM330LHH_H
+#define ST_ASM330LHH_H
+
+#include <linux/device.h>
+#include <linux/iio/iio.h>
+
+#define ST_ASM330LHH_REVISION		"2.0.1"
+#define ST_ASM330LHH_PATCH		"1"
+
+#define ST_ASM330LHH_VERSION		"v"	\
+	ST_ASM330LHH_REVISION			\
+	"-"					\
+	ST_ASM330LHH_PATCH
+
+#define ST_ASM330LHH_DEV_NAME		"asm330lhh"
+
+#define ST_ASM330LHH_SAMPLE_SIZE	6
+#define ST_ASM330LHH_TS_SAMPLE_SIZE	4
+#define ST_ASM330LHH_TAG_SIZE		1
+#define ST_ASM330LHH_FIFO_SAMPLE_SIZE	(ST_ASM330LHH_SAMPLE_SIZE + \
+					 ST_ASM330LHH_TAG_SIZE)
+#define ST_ASM330LHH_MAX_FIFO_DEPTH	416
+
+#define ST_ASM330LHH_REG_FIFO_BATCH_ADDR	0x09
+#define ST_ASM330LHH_REG_FIFO_CTRL4_ADDR	0x0a
+#define ST_ASM330LHH_REG_STATUS_ADDR		0x1e
+#define ST_ASM330LHH_REG_STATUS_TDA		BIT(2)
+#define ST_ASM330LHH_REG_OUT_TEMP_L_ADDR	0x20
+#define ST_ASM330LHH_REG_OUT_TEMP_H_ADDR	0x21
+
+#define ST_ASM330LHH_MAX_ODR			416
+
+/* Define Custom events for FIFO flush */
+#define CUSTOM_IIO_EV_DIR_FIFO_EMPTY (IIO_EV_DIR_NONE + 1)
+#define CUSTOM_IIO_EV_DIR_FIFO_DATA (IIO_EV_DIR_NONE + 2)
+#define CUSTOM_IIO_EV_TYPE_FIFO_FLUSH (IIO_EV_TYPE_CHANGE + 1)
+
+#define ST_ASM330LHH_CHANNEL(chan_type, addr, mod, ch2, scan_idx,	\
+			   rb, sb, sg)					\
+{									\
+	.type = chan_type,						\
+	.address = addr,						\
+	.modified = mod,						\
+	.channel2 = ch2,						\
+	.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |			\
+			      BIT(IIO_CHAN_INFO_SCALE),			\
+	.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),	\
+	.scan_index = scan_idx,						\
+	.scan_type = {							\
+		.sign = sg,						\
+		.realbits = rb,						\
+		.storagebits = sb,					\
+		.endianness = IIO_LE,					\
+	},								\
+}
+
+static const struct iio_event_spec st_asm330lhh_flush_event = {
+	.type = CUSTOM_IIO_EV_TYPE_FIFO_FLUSH,
+	.dir = IIO_EV_DIR_EITHER,
+};
+
+#define ST_ASM330LHH_FLUSH_CHANNEL(dtype)		\
+{							\
+	.type = dtype,					\
+	.modified = 0,					\
+	.scan_index = -1,				\
+	.indexed = -1,					\
+	.event_spec = &st_asm330lhh_flush_event,	\
+	.num_event_specs = 1,				\
+}
+
+#define ST_ASM330LHH_RX_MAX_LENGTH	8
+#define ST_ASM330LHH_TX_MAX_LENGTH	8
+
+struct st_asm330lhh_transfer_buffer {
+	u8 rx_buf[ST_ASM330LHH_RX_MAX_LENGTH];
+	u8 tx_buf[ST_ASM330LHH_TX_MAX_LENGTH] ____cacheline_aligned;
+};
+
+struct st_asm330lhh_transfer_function {
+	int (*read)(struct device *dev, u8 addr, int len, u8 *data);
+	int (*write)(struct device *dev, u8 addr, int len, u8 *data);
+};
+
+struct st_asm330lhh_reg {
+	u8 addr;
+	u8 mask;
+};
+
+struct st_asm330lhh_odr {
+	u16 hz;
+	u8 val;
+};
+
+#define ST_ASM330LHH_ODR_LIST_SIZE	7
+struct st_asm330lhh_odr_table_entry {
+	struct st_asm330lhh_reg reg;
+	struct st_asm330lhh_odr odr_avl[ST_ASM330LHH_ODR_LIST_SIZE];
+};
+
+struct st_asm330lhh_fs {
+	u32 gain;
+	u8 val;
+};
+
+#define ST_ASM330LHH_FS_ACC_LIST_SIZE		4
+#define ST_ASM330LHH_FS_GYRO_LIST_SIZE		6
+#define ST_ASM330LHH_FS_TEMP_LIST_SIZE		1
+#define ST_ASM330LHH_FS_LIST_SIZE		6
+struct st_asm330lhh_fs_table_entry {
+	u32 size;
+	struct st_asm330lhh_reg reg;
+	struct st_asm330lhh_fs fs_avl[ST_ASM330LHH_FS_LIST_SIZE];
+};
+
+enum st_asm330lhh_sensor_id {
+	ST_ASM330LHH_ID_ACC,
+	ST_ASM330LHH_ID_GYRO,
+	ST_ASM330LHH_ID_TEMP,
+	ST_ASM330LHH_ID_MAX,
+};
+
+enum st_asm330lhh_fifo_mode {
+	ST_ASM330LHH_FIFO_BYPASS = 0x0,
+	ST_ASM330LHH_FIFO_CONT = 0x6,
+};
+
+enum {
+	ST_ASM330LHH_HW_FLUSH,
+	ST_ASM330LHH_HW_OPERATIONAL,
+};
+
+/**
+ * struct st_asm330lhh_sensor - ST IMU sensor instance
+ * @id: Sensor identifier.
+ * @hw: Pointer to instance of struct st_asm330lhh_hw.
+ * @gain: Configured sensor sensitivity.
+ * @odr: Output data rate of the sensor [Hz].
+ * @watermark: Sensor watermark level.
+ * @batch_mask: Sensor mask for FIFO batching register
+ */
+struct st_asm330lhh_sensor {
+	enum st_asm330lhh_sensor_id id;
+	struct st_asm330lhh_hw *hw;
+
+	u32 gain;
+	u16 odr;
+	u32 offset;
+
+	__le16 old_data;
+
+	u8 std_samples;
+	u8 std_level;
+
+	u16 watermark;
+	u8 batch_mask;
+	u8 batch_addr;
+};
+
+/**
+ * struct st_asm330lhh_hw - ST IMU MEMS hw instance
+ * @dev: Pointer to instance of struct device (I2C or SPI).
+ * @irq: Device interrupt line (I2C or SPI).
+ * @lock: Mutex to protect read and write operations.
+ * @fifo_lock: Mutex to prevent concurrent access to the hw FIFO.
+ * @fifo_mode: FIFO operating mode supported by the device.
+ * @state: hw operational state.
+ * @enable_mask: Enabled sensor bitmask.
+ * @ts_offset: Hw timestamp offset.
+ * @hw_ts: Latest hw timestamp from the sensor.
+ * @ts: Latest timestamp from irq handler.
+ * @delta_ts: Delta time between two consecutive interrupts.
+ * @iio_devs: Pointers to acc/gyro iio_dev instances.
+ * @tf: Transfer function structure used by I/O operations.
+ * @tb: Transfer buffers used by SPI I/O operations.
+ */
+struct st_asm330lhh_hw {
+	struct device *dev;
+	int irq;
+
+	struct mutex lock;
+	struct mutex fifo_lock;
+
+	enum st_asm330lhh_fifo_mode fifo_mode;
+	unsigned long state;
+	u8 enable_mask;
+
+	s64 ts_offset;
+	s64 hw_ts;
+	s64 delta_ts;
+	s64 ts;
+	s64 tsample;
+	s64 hw_ts_old;
+	s64 delta_hw_ts;
+
+	/* Timestamp sample ODR */
+	u16 odr;
+
+	struct iio_dev *iio_devs[ST_ASM330LHH_ID_MAX];
+
+	const struct st_asm330lhh_transfer_function *tf;
+	struct st_asm330lhh_transfer_buffer tb;
+};
+
+extern const struct dev_pm_ops st_asm330lhh_pm_ops;
+
+int st_asm330lhh_probe(struct device *dev, int irq,
+		       const struct st_asm330lhh_transfer_function *tf_ops);
+int st_asm330lhh_sensor_set_enable(struct st_asm330lhh_sensor *sensor,
+				   bool enable);
+int st_asm330lhh_fifo_setup(struct st_asm330lhh_hw *hw);
+int st_asm330lhh_write_with_mask(struct st_asm330lhh_hw *hw, u8 addr, u8 mask,
+				 u8 val);
+int st_asm330lhh_get_odr_val(enum st_asm330lhh_sensor_id id, u16 odr, u8 *val);
+ssize_t st_asm330lhh_flush_fifo(struct device *dev,
+				struct device_attribute *attr,
+				const char *buf, size_t size);
+ssize_t st_asm330lhh_get_max_watermark(struct device *dev,
+				       struct device_attribute *attr, char *buf);
+ssize_t st_asm330lhh_get_watermark(struct device *dev,
+				   struct device_attribute *attr, char *buf);
+ssize_t st_asm330lhh_set_watermark(struct device *dev,
+				   struct device_attribute *attr,
+				   const char *buf, size_t size);
+int st_asm330lhh_set_fifo_mode(struct st_asm330lhh_hw *hw,
+			       enum st_asm330lhh_fifo_mode fifo_mode);
+int st_asm330lhh_suspend_fifo(struct st_asm330lhh_hw *hw);
+#endif /* ST_ASM330LHH_H */
diff --git a/drivers/iio/imu/st_asm330lhh/st_asm330lhh_buffer.c b/drivers/iio/imu/st_asm330lhh/st_asm330lhh_buffer.c
new file mode 100644
index 0000000..af8c5ba
--- /dev/null
+++ b/drivers/iio/imu/st_asm330lhh/st_asm330lhh_buffer.c
@@ -0,0 +1,531 @@
+/*
+ * STMicroelectronics st_asm330lhh FIFO buffer library driver
+ *
+ * Copyright 2018 STMicroelectronics Inc.
+ *
+ * Lorenzo Bianconi <lorenzo.bianconi@st.com>
+ *
+ * Licensed under the GPL-2.
+ */
+#include <linux/module.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/iio/kfifo_buf.h>
+#include <linux/iio/events.h>
+#include <asm/unaligned.h>
+#include <linux/of.h>
+
+#include "st_asm330lhh.h"
+
+#define ST_ASM330LHH_REG_FIFO_THL_ADDR		0x07
+#define ST_ASM330LHH_REG_FIFO_LEN_MASK		GENMASK(8, 0)
+#define ST_ASM330LHH_REG_FIFO_MODE_MASK		GENMASK(2, 0)
+#define ST_ASM330LHH_REG_DEC_TS_MASK		GENMASK(7, 6)
+#define ST_ASM330LHH_REG_HLACTIVE_ADDR		0x12
+#define ST_ASM330LHH_REG_HLACTIVE_MASK		BIT(5)
+#define ST_ASM330LHH_REG_PP_OD_ADDR		0x12
+#define ST_ASM330LHH_REG_PP_OD_MASK		BIT(4)
+#define ST_ASM330LHH_REG_FIFO_DIFFL_ADDR	0x3a
+#define ST_ASM330LHH_REG_TS0_ADDR		0x40
+#define ST_ASM330LHH_REG_TS2_ADDR		0x42
+#define ST_ASM330LHH_REG_FIFO_OUT_TAG_ADDR	0x78
+#define ST_ASM330LHH_GYRO_TAG			0x01
+#define ST_ASM330LHH_ACC_TAG			0x02
+#define ST_ASM330LHH_TS_TAG			0x04
+
+#define ST_ASM330LHH_TS_DELTA_NS		25000ULL /* 25us/LSB */
+
+static inline s64 st_asm330lhh_get_time_ns(void)
+{
+	struct timespec ts;
+
+	get_monotonic_boottime(&ts);
+	return timespec_to_ns(&ts);
+}
+
+#define ST_ASM330LHH_EWMA_LEVEL			120
+#define ST_ASM330LHH_EWMA_DIV			128
+static inline s64 st_asm330lhh_ewma(s64 old, s64 new, int weight)
+{
+	s64 diff, incr;
+
+	diff = new - old;
+	incr = div_s64((ST_ASM330LHH_EWMA_DIV - weight) * diff,
+		       ST_ASM330LHH_EWMA_DIV);
+
+	return old + incr;
+}
+
+static inline int st_asm330lhh_reset_hwts(struct st_asm330lhh_hw *hw)
+{
+	u8 data = 0xaa;
+
+	hw->ts = st_asm330lhh_get_time_ns();
+	hw->ts_offset = hw->ts;
+	hw->hw_ts_old = 0ull;
+	hw->tsample = 0ull;
+
+	return hw->tf->write(hw->dev, ST_ASM330LHH_REG_TS2_ADDR, sizeof(data),
+			     &data);
+}
+
+int st_asm330lhh_set_fifo_mode(struct st_asm330lhh_hw *hw,
+			       enum st_asm330lhh_fifo_mode fifo_mode)
+{
+	int err;
+
+	err = st_asm330lhh_write_with_mask(hw, ST_ASM330LHH_REG_FIFO_CTRL4_ADDR,
+					   ST_ASM330LHH_REG_FIFO_MODE_MASK,
+					   fifo_mode);
+	if (err < 0)
+		return err;
+
+	hw->fifo_mode = fifo_mode;
+
+	return 0;
+}
+
+static int st_asm330lhh_set_sensor_batching_odr(struct st_asm330lhh_sensor *sensor,
+						bool enable)
+{
+	struct st_asm330lhh_hw *hw = sensor->hw;
+	u8 data = 0;
+	int err;
+
+	if (enable) {
+		err = st_asm330lhh_get_odr_val(sensor->id, sensor->odr, &data);
+		if (err < 0)
+			return err;
+	}
+
+	return st_asm330lhh_write_with_mask(hw,
+					    sensor->batch_addr,
+					    sensor->batch_mask, data);
+}
+
+static u16 st_asm330lhh_ts_odr(struct st_asm330lhh_hw *hw)
+{
+	struct st_asm330lhh_sensor *sensor;
+	u16 odr = 0;
+	u8 i;
+
+	for (i = 0; i < ST_ASM330LHH_ID_MAX; i++) {
+		if (!hw->iio_devs[i])
+			continue;
+
+		sensor = iio_priv(hw->iio_devs[i]);
+		if (hw->enable_mask & BIT(sensor->id))
+			odr = max_t(u16, odr, sensor->odr);
+	}
+
+	return odr;
+}
+
+static int st_asm330lhh_update_watermark(struct st_asm330lhh_sensor *sensor,
+					 u16 watermark)
+{
+	u16 fifo_watermark = ST_ASM330LHH_MAX_FIFO_DEPTH, cur_watermark = 0;
+	struct st_asm330lhh_hw *hw = sensor->hw;
+	struct st_asm330lhh_sensor *cur_sensor;
+	__le16 wdata;
+	int i, err;
+	u8 data;
+
+	for (i = 0; i < ST_ASM330LHH_ID_MAX; i++) {
+		cur_sensor = iio_priv(hw->iio_devs[i]);
+
+		if (!(hw->enable_mask & BIT(cur_sensor->id)))
+			continue;
+
+		cur_watermark = (cur_sensor == sensor) ? watermark
+						       : cur_sensor->watermark;
+
+		fifo_watermark = min_t(u16, fifo_watermark, cur_watermark);
+	}
+
+	fifo_watermark = max_t(u16, fifo_watermark, 2);
+	mutex_lock(&hw->lock);
+
+	err = hw->tf->read(hw->dev, ST_ASM330LHH_REG_FIFO_THL_ADDR + 1,
+			   sizeof(data), &data);
+	if (err < 0)
+		goto out;
+
+	fifo_watermark = ((data << 8) & ~ST_ASM330LHH_REG_FIFO_LEN_MASK) |
+			 (fifo_watermark & ST_ASM330LHH_REG_FIFO_LEN_MASK);
+	wdata = cpu_to_le16(fifo_watermark);
+	err = hw->tf->write(hw->dev, ST_ASM330LHH_REG_FIFO_THL_ADDR,
+			    sizeof(wdata), (u8 *)&wdata);
+
+out:
+	mutex_unlock(&hw->lock);
+
+	return err < 0 ? err : 0;
+}
+
+static inline void st_asm330lhh_sync_hw_ts(struct st_asm330lhh_hw *hw, s64 ts)
+{
+	s64 delta = ts - hw->hw_ts;
+
+	hw->ts_offset = st_asm330lhh_ewma(hw->ts_offset, delta,
+					  ST_ASM330LHH_EWMA_LEVEL);
+}
+
+static struct iio_dev *st_asm330lhh_get_iiodev_from_tag(struct st_asm330lhh_hw *hw,
+							u8 tag)
+{
+	struct iio_dev *iio_dev;
+
+	switch (tag) {
+	case ST_ASM330LHH_GYRO_TAG:
+		iio_dev = hw->iio_devs[ST_ASM330LHH_ID_GYRO];
+		break;
+	case ST_ASM330LHH_ACC_TAG:
+		iio_dev = hw->iio_devs[ST_ASM330LHH_ID_ACC];
+		break;
+	default:
+		iio_dev = NULL;
+		break;
+	}
+
+	return iio_dev;
+}
+
+static int st_asm330lhh_read_fifo(struct st_asm330lhh_hw *hw)
+{
+	u8 iio_buf[ALIGN(ST_ASM330LHH_SAMPLE_SIZE, sizeof(s64)) + sizeof(s64)];
+	u8 buf[6 * ST_ASM330LHH_FIFO_SAMPLE_SIZE], tag, *ptr;
+	s64 ts_delta_hw_ts = 0, ts_irq;
+	s64 ts_delta_offs;
+	int i, err, read_len, word_len, fifo_len;
+	struct st_asm330lhh_sensor *sensor;
+	struct iio_dev *iio_dev;
+	__le16 fifo_status;
+	u16 fifo_depth;
+	u32 val;
+	int ts_processed = 0;
+	s64 hw_ts = 0ull, delta_hw_ts, cpu_timestamp;
+
+	ts_irq = hw->ts - hw->delta_ts;
+
+	do
+	{
+		err = hw->tf->read(hw->dev, ST_ASM330LHH_REG_FIFO_DIFFL_ADDR,
+				   sizeof(fifo_status), (u8 *)&fifo_status);
+		if (err < 0)
+			return err;
+
+		fifo_depth = le16_to_cpu(fifo_status) & ST_ASM330LHH_REG_FIFO_LEN_MASK;
+		if (!fifo_depth)
+			return 0;
+
+		read_len = 0;
+		fifo_len = fifo_depth * ST_ASM330LHH_FIFO_SAMPLE_SIZE;
+		while (read_len < fifo_len) {
+			word_len = min_t(int, fifo_len - read_len, sizeof(buf));
+			err = hw->tf->read(hw->dev,
+					   ST_ASM330LHH_REG_FIFO_OUT_TAG_ADDR,
+					   word_len, buf);
+			if (err < 0)
+				return err;
+
+			for (i = 0; i < word_len; i += ST_ASM330LHH_FIFO_SAMPLE_SIZE) {
+				ptr = &buf[i + ST_ASM330LHH_TAG_SIZE];
+				tag = buf[i] >> 3;
+
+				if (tag == ST_ASM330LHH_TS_TAG) {
+					val = get_unaligned_le32(ptr);
+					hw->hw_ts = val * ST_ASM330LHH_TS_DELTA_NS;
+					ts_delta_hw_ts = hw->hw_ts - hw->hw_ts_old;
+					hw_ts += ts_delta_hw_ts;
+					ts_delta_offs =
+						div_s64(hw->delta_hw_ts * ST_ASM330LHH_MAX_ODR, hw->odr);
+
+					hw->ts_offset = st_asm330lhh_ewma(hw->ts_offset, ts_irq -
+						hw->hw_ts + ts_delta_offs, ST_ASM330LHH_EWMA_LEVEL);
+
+					ts_irq += (hw->hw_ts + ts_delta_offs);
+					hw->hw_ts_old = hw->hw_ts;
+					ts_processed++;
+
+					if (!hw->tsample)
+						hw->tsample =
+							hw->ts_offset + (hw->hw_ts + ts_delta_offs);
+					else
+						hw->tsample =
+							hw->tsample + (ts_delta_hw_ts + ts_delta_offs);
+				} else {
+					iio_dev = st_asm330lhh_get_iiodev_from_tag(hw, tag);
+					if (!iio_dev)
+						continue;
+
+					sensor = iio_priv(iio_dev);
+					if (sensor->std_samples < sensor->std_level) {
+						sensor->std_samples++;
+						continue;
+					}
+
+					sensor = iio_priv(iio_dev);
+
+					/* Check if timestamp is in the future. */
+					cpu_timestamp = st_asm330lhh_get_time_ns();
+
+					/* Avoid samples in the future. */
+					if (hw->tsample > cpu_timestamp)
+						hw->tsample = cpu_timestamp;
+
+					memcpy(iio_buf, ptr, ST_ASM330LHH_SAMPLE_SIZE);
+					iio_push_to_buffers_with_timestamp(iio_dev,
+									   iio_buf,
+									   hw->tsample);
+				}
+			}
+			read_len += word_len;
+		}
+
+		delta_hw_ts = div_s64(hw->delta_ts - hw_ts, ts_processed);
+		delta_hw_ts = div_s64(delta_hw_ts * hw->odr, ST_ASM330LHH_MAX_ODR);
+		hw->delta_hw_ts = st_asm330lhh_ewma(hw->delta_hw_ts,
+							delta_hw_ts,
+							ST_ASM330LHH_EWMA_LEVEL);
+	} while(read_len);
+
+	return read_len;
+}
+
+ssize_t st_asm330lhh_get_max_watermark(struct device *dev,
+				       struct device_attribute *attr, char *buf)
+{
+	return sprintf(buf, "%d\n", ST_ASM330LHH_MAX_FIFO_DEPTH);
+}
+
+ssize_t st_asm330lhh_get_watermark(struct device *dev,
+				   struct device_attribute *attr, char *buf)
+{
+	struct iio_dev *iio_dev = dev_get_drvdata(dev);
+	struct st_asm330lhh_sensor *sensor = iio_priv(iio_dev);
+
+	return sprintf(buf, "%d\n", sensor->watermark);
+}
+
+ssize_t st_asm330lhh_set_watermark(struct device *dev,
+				   struct device_attribute *attr,
+				   const char *buf, size_t size)
+{
+	struct iio_dev *iio_dev = dev_get_drvdata(dev);
+	struct st_asm330lhh_sensor *sensor = iio_priv(iio_dev);
+	int err, val;
+
+	mutex_lock(&iio_dev->mlock);
+	if (iio_buffer_enabled(iio_dev)) {
+		err = -EBUSY;
+		goto out;
+	}
+
+	err = kstrtoint(buf, 10, &val);
+	if (err < 0)
+		goto out;
+
+	err = st_asm330lhh_update_watermark(sensor, val);
+	if (err < 0)
+		goto out;
+
+	sensor->watermark = val;
+
+out:
+	mutex_unlock(&iio_dev->mlock);
+
+	return err < 0 ? err : size;
+}
+
+ssize_t st_asm330lhh_flush_fifo(struct device *dev,
+				struct device_attribute *attr,
+				const char *buf, size_t size)
+{
+	struct iio_dev *iio_dev = dev_get_drvdata(dev);
+	struct st_asm330lhh_sensor *sensor = iio_priv(iio_dev);
+	struct st_asm330lhh_hw *hw = sensor->hw;
+	s64 type, event;
+	int count;
+	s64 ts;
+
+	mutex_lock(&hw->fifo_lock);
+	ts = st_asm330lhh_get_time_ns();
+	hw->delta_ts = ts - hw->ts;
+	hw->ts = ts;
+	set_bit(ST_ASM330LHH_HW_FLUSH, &hw->state);
+
+	count = st_asm330lhh_read_fifo(hw);
+
+	mutex_unlock(&hw->fifo_lock);
+
+	type = count > 0 ? CUSTOM_IIO_EV_DIR_FIFO_DATA : CUSTOM_IIO_EV_DIR_FIFO_EMPTY;
+	event = IIO_UNMOD_EVENT_CODE(iio_dev->channels[0].type, -1,
+				     CUSTOM_IIO_EV_TYPE_FIFO_FLUSH, type);
+	iio_push_event(iio_dev, event, st_asm330lhh_get_time_ns());
+
+	return size;
+}
+
+int st_asm330lhh_suspend_fifo(struct st_asm330lhh_hw *hw)
+{
+	int err;
+
+	mutex_lock(&hw->fifo_lock);
+
+	st_asm330lhh_read_fifo(hw);
+	err = st_asm330lhh_set_fifo_mode(hw, ST_ASM330LHH_FIFO_BYPASS);
+
+	mutex_unlock(&hw->fifo_lock);
+
+	return err;
+}
+
+static int st_asm330lhh_update_fifo(struct iio_dev *iio_dev, bool enable)
+{
+	struct st_asm330lhh_sensor *sensor = iio_priv(iio_dev);
+	struct st_asm330lhh_hw *hw = sensor->hw;
+	int err;
+
+	mutex_lock(&hw->fifo_lock);
+
+	err = st_asm330lhh_sensor_set_enable(sensor, enable);
+	if (err < 0)
+		goto out;
+
+	err = st_asm330lhh_set_sensor_batching_odr(sensor, enable);
+	if (err < 0)
+		goto out;
+
+	err = st_asm330lhh_update_watermark(sensor, sensor->watermark);
+	if (err < 0)
+		goto out;
+
+	hw->odr = st_asm330lhh_ts_odr(hw);
+
+	if (enable && hw->fifo_mode == ST_ASM330LHH_FIFO_BYPASS) {
+		st_asm330lhh_reset_hwts(hw);
+		err = st_asm330lhh_set_fifo_mode(hw, ST_ASM330LHH_FIFO_CONT);
+	} else if (!hw->enable_mask) {
+		err = st_asm330lhh_set_fifo_mode(hw, ST_ASM330LHH_FIFO_BYPASS);
+	}
+
+out:
+	mutex_unlock(&hw->fifo_lock);
+
+	return err;
+}
+
+static irqreturn_t st_asm330lhh_handler_irq(int irq, void *private)
+{
+	struct st_asm330lhh_hw *hw = (struct st_asm330lhh_hw *)private;
+	s64 ts = st_asm330lhh_get_time_ns();
+
+	hw->delta_ts = ts - hw->ts;
+	hw->ts = ts;
+
+	return IRQ_WAKE_THREAD;
+}
+
+static irqreturn_t st_asm330lhh_handler_thread(int irq, void *private)
+{
+	struct st_asm330lhh_hw *hw = (struct st_asm330lhh_hw *)private;
+
+	mutex_lock(&hw->fifo_lock);
+
+	st_asm330lhh_read_fifo(hw);
+	clear_bit(ST_ASM330LHH_HW_FLUSH, &hw->state);
+
+	mutex_unlock(&hw->fifo_lock);
+
+	return IRQ_HANDLED;
+}
+
+static int st_asm330lhh_buffer_preenable(struct iio_dev *iio_dev)
+{
+	return st_asm330lhh_update_fifo(iio_dev, true);
+}
+
+static int st_asm330lhh_buffer_postdisable(struct iio_dev *iio_dev)
+{
+	return st_asm330lhh_update_fifo(iio_dev, false);
+}
+
+static const struct iio_buffer_setup_ops st_asm330lhh_buffer_ops = {
+	.preenable = st_asm330lhh_buffer_preenable,
+	.postdisable = st_asm330lhh_buffer_postdisable,
+};
+
+static int st_asm330lhh_fifo_init(struct st_asm330lhh_hw *hw)
+{
+	return st_asm330lhh_write_with_mask(hw, ST_ASM330LHH_REG_FIFO_CTRL4_ADDR,
+					    ST_ASM330LHH_REG_DEC_TS_MASK, 1);
+}
+
+int st_asm330lhh_fifo_setup(struct st_asm330lhh_hw *hw)
+{
+	struct device_node *np = hw->dev->of_node;
+	struct iio_buffer *buffer;
+	unsigned long irq_type;
+	bool irq_active_low;
+	int i, err;
+
+	irq_type = irqd_get_trigger_type(irq_get_irq_data(hw->irq));
+
+	switch (irq_type) {
+	case IRQF_TRIGGER_HIGH:
+	case IRQF_TRIGGER_RISING:
+		irq_active_low = false;
+		break;
+	case IRQF_TRIGGER_LOW:
+	case IRQF_TRIGGER_FALLING:
+		irq_active_low = true;
+		break;
+	default:
+		dev_info(hw->dev, "mode %lx unsupported\n", irq_type);
+		return -EINVAL;
+	}
+
+	err = st_asm330lhh_write_with_mask(hw, ST_ASM330LHH_REG_HLACTIVE_ADDR,
+					   ST_ASM330LHH_REG_HLACTIVE_MASK,
+					   irq_active_low);
+	if (err < 0)
+		return err;
+
+	if (np && of_property_read_bool(np, "drive-open-drain")) {
+		err = st_asm330lhh_write_with_mask(hw,
+					ST_ASM330LHH_REG_PP_OD_ADDR,
+					ST_ASM330LHH_REG_PP_OD_MASK, 1);
+		if (err < 0)
+			return err;
+
+		irq_type |= IRQF_SHARED;
+	}
+
+	err = devm_request_threaded_irq(hw->dev, hw->irq,
+					st_asm330lhh_handler_irq,
+					st_asm330lhh_handler_thread,
+					irq_type | IRQF_ONESHOT,
+					"asm330lhh", hw);
+	if (err) {
+		dev_err(hw->dev, "failed to request trigger irq %d\n",
+			hw->irq);
+		return err;
+	}
+
+	for (i = ST_ASM330LHH_ID_ACC; i < ST_ASM330LHH_ID_MAX; i++) {
+		if (!hw->iio_devs[i])
+			continue;
+
+		buffer = devm_iio_kfifo_allocate(hw->dev);
+		if (!buffer)
+			return -ENOMEM;
+
+		iio_device_attach_buffer(hw->iio_devs[i], buffer);
+		hw->iio_devs[i]->modes |= INDIO_BUFFER_SOFTWARE;
+		hw->iio_devs[i]->setup_ops = &st_asm330lhh_buffer_ops;
+	}
+
+	return st_asm330lhh_fifo_init(hw);
+}
+
diff --git a/drivers/iio/imu/st_asm330lhh/st_asm330lhh_core.c b/drivers/iio/imu/st_asm330lhh/st_asm330lhh_core.c
new file mode 100644
index 0000000..9d9ee20
--- /dev/null
+++ b/drivers/iio/imu/st_asm330lhh/st_asm330lhh_core.c
@@ -0,0 +1,824 @@
+/*
+ * STMicroelectronics st_asm330lhh sensor driver
+ *
+ * Copyright 2018 STMicroelectronics Inc.
+ *
+ * Lorenzo Bianconi <lorenzo.bianconi@st.com>
+ *
+ * Licensed under the GPL-2.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/delay.h>
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/pm.h>
+#include <linux/version.h>
+#include <linux/of.h>
+
+#include <linux/platform_data/st_sensors_pdata.h>
+
+#include "st_asm330lhh.h"
+
+#define ST_ASM330LHH_REG_INT1_ADDR		0x0d
+#define ST_ASM330LHH_REG_INT2_ADDR		0x0e
+#define ST_ASM330LHH_REG_FIFO_CTRL4_ADDR	0x0a
+#define ST_ASM330LHH_REG_FIFO_FTH_IRQ_MASK	BIT(3)
+#define ST_ASM330LHH_REG_WHOAMI_ADDR		0x0f
+#define ST_ASM330LHH_WHOAMI_VAL			0x6b
+#define ST_ASM330LHH_REG_CTRL1_XL_ADDR		0x10
+#define ST_ASM330LHH_REG_CTRL2_G_ADDR		0x11
+#define ST_ASM330LHH_REG_RESET_ADDR		0x12
+#define ST_ASM330LHH_REG_RESET_MASK		BIT(0)
+#define ST_ASM330LHH_REG_BDU_ADDR		0x12
+#define ST_ASM330LHH_REG_BDU_MASK		BIT(6)
+#define ST_ASM330LHH_REG_INT2_ON_INT1_ADDR	0x13
+#define ST_ASM330LHH_REG_INT2_ON_INT1_MASK	BIT(5)
+#define ST_ASM330LHH_REG_ROUNDING_ADDR		0x14
+#define ST_ASM330LHH_REG_ROUNDING_MASK		GENMASK(6, 5)
+#define ST_ASM330LHH_REG_TIMESTAMP_EN_ADDR	0x19
+#define ST_ASM330LHH_REG_TIMESTAMP_EN_MASK	BIT(5)
+
+#define ST_ASM330LHH_REG_GYRO_OUT_X_L_ADDR	0x22
+#define ST_ASM330LHH_REG_GYRO_OUT_Y_L_ADDR	0x24
+#define ST_ASM330LHH_REG_GYRO_OUT_Z_L_ADDR	0x26
+
+#define ST_ASM330LHH_REG_ACC_OUT_X_L_ADDR	0x28
+#define ST_ASM330LHH_REG_ACC_OUT_Y_L_ADDR	0x2a
+#define ST_ASM330LHH_REG_ACC_OUT_Z_L_ADDR	0x2c
+
+#define ST_ASM330LHH_REG_LIR_ADDR		0x56
+#define ST_ASM330LHH_REG_LIR_MASK		BIT(0)
+
+#define ST_ASM330LHH_ACC_FS_2G_GAIN		IIO_G_TO_M_S_2(61)
+#define ST_ASM330LHH_ACC_FS_4G_GAIN		IIO_G_TO_M_S_2(122)
+#define ST_ASM330LHH_ACC_FS_8G_GAIN		IIO_G_TO_M_S_2(244)
+#define ST_ASM330LHH_ACC_FS_16G_GAIN		IIO_G_TO_M_S_2(488)
+
+#define ST_ASM330LHH_GYRO_FS_125_GAIN		IIO_DEGREE_TO_RAD(4375)
+#define ST_ASM330LHH_GYRO_FS_250_GAIN		IIO_DEGREE_TO_RAD(8750)
+#define ST_ASM330LHH_GYRO_FS_500_GAIN		IIO_DEGREE_TO_RAD(17500)
+#define ST_ASM330LHH_GYRO_FS_1000_GAIN		IIO_DEGREE_TO_RAD(35000)
+#define ST_ASM330LHH_GYRO_FS_2000_GAIN		IIO_DEGREE_TO_RAD(70000)
+#define ST_ASM330LHH_GYRO_FS_4000_GAIN		IIO_DEGREE_TO_RAD(140000)
+
+/* Temperature in uC */
+#define ST_ASM330LHH_TEMP_GAIN			256
+#define ST_ASM330LHH_TEMP_FS_GAIN		(1000000 / ST_ASM330LHH_TEMP_GAIN)
+#define ST_ASM330LHH_OFFSET			(6400)
+
+struct st_asm330lhh_std_entry {
+	u16 odr;
+	u8 val;
+};
+
+/* Minimal number of sample to be discarded */
+struct st_asm330lhh_std_entry st_asm330lhh_std_table[] = {
+	{  13,  2 },
+	{  26,  3 },
+	{  52,  4 },
+	{ 104,  6 },
+	{ 208,  8 },
+	{ 416, 18 },
+};
+
+static const struct st_asm330lhh_odr_table_entry st_asm330lhh_odr_table[] = {
+	[ST_ASM330LHH_ID_ACC] = {
+		.reg = {
+			.addr = ST_ASM330LHH_REG_CTRL1_XL_ADDR,
+			.mask = GENMASK(7, 4),
+		},
+		.odr_avl[0] = {   0, 0x00 },
+		.odr_avl[1] = {  13, 0x01 },
+		.odr_avl[2] = {  26, 0x02 },
+		.odr_avl[3] = {  52, 0x03 },
+		.odr_avl[4] = { 104, 0x04 },
+		.odr_avl[5] = { 208, 0x05 },
+		.odr_avl[6] = { 416, 0x06 },
+	},
+	[ST_ASM330LHH_ID_GYRO] = {
+		.reg = {
+			.addr = ST_ASM330LHH_REG_CTRL2_G_ADDR,
+			.mask = GENMASK(7, 4),
+		},
+		.odr_avl[0] = {   0, 0x00 },
+		.odr_avl[1] = {  13, 0x01 },
+		.odr_avl[2] = {  26, 0x02 },
+		.odr_avl[3] = {  52, 0x03 },
+		.odr_avl[4] = { 104, 0x04 },
+		.odr_avl[5] = { 208, 0x05 },
+		.odr_avl[6] = { 416, 0x06 },
+	},
+	[ST_ASM330LHH_ID_TEMP] = {
+		.odr_avl[0] = {   0, 0x00 },
+		.odr_avl[1] = {  52, 0x01 },
+	}
+};
+
+static const struct st_asm330lhh_fs_table_entry st_asm330lhh_fs_table[] = {
+	[ST_ASM330LHH_ID_ACC] = {
+		.reg = {
+			.addr = ST_ASM330LHH_REG_CTRL1_XL_ADDR,
+			.mask = GENMASK(3, 2),
+		},
+		.size = ST_ASM330LHH_FS_ACC_LIST_SIZE,
+		.fs_avl[0] = {  ST_ASM330LHH_ACC_FS_2G_GAIN, 0x0 },
+		.fs_avl[1] = {  ST_ASM330LHH_ACC_FS_4G_GAIN, 0x2 },
+		.fs_avl[2] = {  ST_ASM330LHH_ACC_FS_8G_GAIN, 0x3 },
+		.fs_avl[3] = { ST_ASM330LHH_ACC_FS_16G_GAIN, 0x1 },
+	},
+	[ST_ASM330LHH_ID_GYRO] = {
+		.reg = {
+			.addr = ST_ASM330LHH_REG_CTRL2_G_ADDR,
+			.mask = GENMASK(3, 0),
+		},
+		.size = ST_ASM330LHH_FS_GYRO_LIST_SIZE,
+		.fs_avl[0] = {  ST_ASM330LHH_GYRO_FS_125_GAIN, 0x2 },
+		.fs_avl[1] = {  ST_ASM330LHH_GYRO_FS_250_GAIN, 0x0 },
+		.fs_avl[2] = {  ST_ASM330LHH_GYRO_FS_500_GAIN, 0x4 },
+		.fs_avl[3] = { ST_ASM330LHH_GYRO_FS_1000_GAIN, 0x8 },
+		.fs_avl[4] = { ST_ASM330LHH_GYRO_FS_2000_GAIN, 0xC },
+		.fs_avl[5] = { ST_ASM330LHH_GYRO_FS_4000_GAIN, 0x1 },
+	},
+	[ST_ASM330LHH_ID_TEMP] = {
+		.size = ST_ASM330LHH_FS_TEMP_LIST_SIZE,
+		.fs_avl[0] = {  ST_ASM330LHH_TEMP_FS_GAIN, 0x0 },
+	}
+};
+
+static const struct iio_chan_spec st_asm330lhh_acc_channels[] = {
+	ST_ASM330LHH_CHANNEL(IIO_ACCEL, ST_ASM330LHH_REG_ACC_OUT_X_L_ADDR,
+			   1, IIO_MOD_X, 0, 16, 16, 's'),
+	ST_ASM330LHH_CHANNEL(IIO_ACCEL, ST_ASM330LHH_REG_ACC_OUT_Y_L_ADDR,
+			   1, IIO_MOD_Y, 1, 16, 16, 's'),
+	ST_ASM330LHH_CHANNEL(IIO_ACCEL, ST_ASM330LHH_REG_ACC_OUT_Z_L_ADDR,
+			   1, IIO_MOD_Z, 2, 16, 16, 's'),
+	ST_ASM330LHH_FLUSH_CHANNEL(IIO_ACCEL),
+	IIO_CHAN_SOFT_TIMESTAMP(3),
+};
+
+static const struct iio_chan_spec st_asm330lhh_gyro_channels[] = {
+	ST_ASM330LHH_CHANNEL(IIO_ANGL_VEL, ST_ASM330LHH_REG_GYRO_OUT_X_L_ADDR,
+			   1, IIO_MOD_X, 0, 16, 16, 's'),
+	ST_ASM330LHH_CHANNEL(IIO_ANGL_VEL, ST_ASM330LHH_REG_GYRO_OUT_Y_L_ADDR,
+			   1, IIO_MOD_Y, 1, 16, 16, 's'),
+	ST_ASM330LHH_CHANNEL(IIO_ANGL_VEL, ST_ASM330LHH_REG_GYRO_OUT_Z_L_ADDR,
+			   1, IIO_MOD_Z, 2, 16, 16, 's'),
+	ST_ASM330LHH_FLUSH_CHANNEL(IIO_ANGL_VEL),
+	IIO_CHAN_SOFT_TIMESTAMP(3),
+};
+
+static const struct iio_chan_spec st_asm330lhh_temp_channels[] = {
+	{
+		.type = IIO_TEMP,
+		.address = ST_ASM330LHH_REG_OUT_TEMP_L_ADDR,
+		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW)
+				| BIT(IIO_CHAN_INFO_OFFSET)
+				| BIT(IIO_CHAN_INFO_SCALE),
+		.scan_index = -1,
+	},
+};
+
+int st_asm330lhh_write_with_mask(struct st_asm330lhh_hw *hw, u8 addr, u8 mask,
+				 u8 val)
+{
+	u8 data;
+	int err;
+
+	mutex_lock(&hw->lock);
+
+	err = hw->tf->read(hw->dev, addr, sizeof(data), &data);
+	if (err < 0) {
+		dev_err(hw->dev, "failed to read %02x register\n", addr);
+		goto out;
+	}
+
+	data = (data & ~mask) | ((val << __ffs(mask)) & mask);
+
+	err = hw->tf->write(hw->dev, addr, sizeof(data), &data);
+	if (err < 0)
+		dev_err(hw->dev, "failed to write %02x register\n", addr);
+
+out:
+	mutex_unlock(&hw->lock);
+
+	return err;
+}
+
+static int st_asm330lhh_check_whoami(struct st_asm330lhh_hw *hw)
+{
+	int err;
+	u8 data;
+
+	err = hw->tf->read(hw->dev, ST_ASM330LHH_REG_WHOAMI_ADDR, sizeof(data),
+			   &data);
+	if (err < 0) {
+		dev_err(hw->dev, "failed to read whoami register\n");
+		return err;
+	}
+
+	if (data != ST_ASM330LHH_WHOAMI_VAL) {
+		dev_err(hw->dev, "unsupported whoami [%02x]\n", data);
+		return -ENODEV;
+	}
+
+	return 0;
+}
+
+static int st_asm330lhh_set_full_scale(struct st_asm330lhh_sensor *sensor,
+				       u32 gain)
+{
+	enum st_asm330lhh_sensor_id id = sensor->id;
+	int i, err;
+	u8 val;
+
+	for (i = 0; i < st_asm330lhh_fs_table[id].size; i++)
+		if (st_asm330lhh_fs_table[id].fs_avl[i].gain == gain)
+			break;
+
+	if (i == st_asm330lhh_fs_table[id].size)
+		return -EINVAL;
+
+	val = st_asm330lhh_fs_table[id].fs_avl[i].val;
+	err = st_asm330lhh_write_with_mask(sensor->hw,
+					st_asm330lhh_fs_table[id].reg.addr,
+					st_asm330lhh_fs_table[id].reg.mask,
+					val);
+	if (err < 0)
+		return err;
+
+	sensor->gain = gain;
+
+	return 0;
+}
+
+int st_asm330lhh_get_odr_val(enum st_asm330lhh_sensor_id id, u16 odr, u8 *val)
+{
+	int i;
+
+	for (i = 0; i < ST_ASM330LHH_ODR_LIST_SIZE; i++)
+		if (st_asm330lhh_odr_table[id].odr_avl[i].hz >= odr)
+			break;
+
+	if (i == ST_ASM330LHH_ODR_LIST_SIZE)
+		return -EINVAL;
+
+	*val = st_asm330lhh_odr_table[id].odr_avl[i].val;
+
+	return 0;
+}
+
+static int st_asm330lhh_set_std_level(struct st_asm330lhh_sensor *sensor,
+			u16 odr)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(st_asm330lhh_std_table); i++)
+		if (st_asm330lhh_std_table[i].odr == odr)
+			break;
+
+	if (i == ARRAY_SIZE(st_asm330lhh_std_table))
+		return -EINVAL;
+
+	sensor->std_level = st_asm330lhh_std_table[i].val;
+	sensor->std_samples = 0;
+
+	return 0;
+}
+
+static int st_asm330lhh_set_odr(struct st_asm330lhh_sensor *sensor, u16 odr)
+{
+	struct st_asm330lhh_hw *hw = sensor->hw;
+	u8 val;
+
+	if (st_asm330lhh_get_odr_val(sensor->id, odr, &val) < 0)
+		return -EINVAL;
+
+	return st_asm330lhh_write_with_mask(hw,
+				st_asm330lhh_odr_table[sensor->id].reg.addr,
+				st_asm330lhh_odr_table[sensor->id].reg.mask, val);
+}
+
+int st_asm330lhh_sensor_set_enable(struct st_asm330lhh_sensor *sensor,
+				   bool enable)
+{
+	u16 odr = enable ? sensor->odr : 0;
+	int err;
+
+	if (sensor->id != ST_ASM330LHH_ID_TEMP) {
+		err = st_asm330lhh_set_odr(sensor, odr);
+		if (err < 0)
+			return err;
+	}
+
+	if (enable)
+		sensor->hw->enable_mask |= BIT(sensor->id);
+	else
+		sensor->hw->enable_mask &= ~BIT(sensor->id);
+
+	return 0;
+}
+
+static int st_asm330lhh_read_oneshot(struct st_asm330lhh_sensor *sensor,
+				     u8 addr, int *val)
+{
+	int err, delay;
+	__le16 data;
+
+	if (sensor->id == ST_ASM330LHH_ID_TEMP) {
+		u8 status;
+
+		mutex_lock(&sensor->hw->fifo_lock);
+		err = sensor->hw->tf->read(sensor->hw->dev,
+					   ST_ASM330LHH_REG_STATUS_ADDR, sizeof(status), &status);
+		if (err < 0)
+			goto unlock;
+
+		if (status & ST_ASM330LHH_REG_STATUS_TDA) {
+			err = sensor->hw->tf->read(sensor->hw->dev, addr, sizeof(data),
+					   (u8 *)&data);
+			if (err < 0)
+				goto unlock;
+
+			sensor->old_data = data;
+		} else
+			data = sensor->old_data;
+unlock:
+		mutex_unlock(&sensor->hw->fifo_lock);
+
+	} else {
+		err = st_asm330lhh_sensor_set_enable(sensor, true);
+		if (err < 0)
+			return err;
+
+		delay = 1000000 / sensor->odr;
+		usleep_range(delay, 2 * delay);
+
+		err = sensor->hw->tf->read(sensor->hw->dev, addr, sizeof(data),
+					   (u8 *)&data);
+		if (err < 0)
+			return err;
+
+		st_asm330lhh_sensor_set_enable(sensor, false);
+	}
+
+	*val = (s16)data;
+
+	return IIO_VAL_INT;
+}
+
+static int st_asm330lhh_read_raw(struct iio_dev *iio_dev,
+				 struct iio_chan_spec const *ch,
+				 int *val, int *val2, long mask)
+{
+	struct st_asm330lhh_sensor *sensor = iio_priv(iio_dev);
+	int ret;
+
+	switch (mask) {
+	case IIO_CHAN_INFO_RAW:
+		mutex_lock(&iio_dev->mlock);
+		if (iio_buffer_enabled(iio_dev)) {
+			ret = -EBUSY;
+			mutex_unlock(&iio_dev->mlock);
+			break;
+		}
+		ret = st_asm330lhh_read_oneshot(sensor, ch->address, val);
+		mutex_unlock(&iio_dev->mlock);
+		break;
+	case IIO_CHAN_INFO_OFFSET:
+		switch (ch->type) {
+		case IIO_TEMP:
+			*val = sensor->offset;
+			ret = IIO_VAL_INT;
+			break;
+		default:
+			return -EINVAL;
+		}
+		break;
+	case IIO_CHAN_INFO_SAMP_FREQ:
+		*val = sensor->odr;
+		ret = IIO_VAL_INT;
+		break;
+	case IIO_CHAN_INFO_SCALE:
+		switch (ch->type) {
+		case IIO_TEMP:
+			*val = 1;
+			*val2 = ST_ASM330LHH_TEMP_GAIN;
+			ret = IIO_VAL_FRACTIONAL;
+			break;
+		case IIO_ACCEL:
+		case IIO_ANGL_VEL:
+			*val = 0;
+			*val2 = sensor->gain;
+			ret = IIO_VAL_INT_PLUS_MICRO;
+			break;
+		default:
+			return -EINVAL;
+		}
+		break;
+	default:
+		ret = -EINVAL;
+		break;
+	}
+
+	return ret;
+}
+
+static int st_asm330lhh_write_raw(struct iio_dev *iio_dev,
+				  struct iio_chan_spec const *chan,
+				  int val, int val2, long mask)
+{
+	struct st_asm330lhh_sensor *sensor = iio_priv(iio_dev);
+	int err;
+
+	mutex_lock(&iio_dev->mlock);
+
+	switch (mask) {
+	case IIO_CHAN_INFO_SCALE:
+		err = st_asm330lhh_set_full_scale(sensor, val2);
+		break;
+	case IIO_CHAN_INFO_SAMP_FREQ: {
+		u8 data;
+
+		err = st_asm330lhh_set_std_level(sensor, val);
+		if (err < 0)
+			break;
+
+		err = st_asm330lhh_get_odr_val(sensor->id, val, &data);
+		if (!err)
+			sensor->odr = val;
+
+		err = st_asm330lhh_set_odr(sensor, sensor->odr);
+		break;
+	}
+	default:
+		err = -EINVAL;
+		break;
+	}
+
+	mutex_unlock(&iio_dev->mlock);
+
+	return err;
+}
+
+static ssize_t
+st_asm330lhh_sysfs_sampling_frequency_avail(struct device *dev,
+					    struct device_attribute *attr,
+					    char *buf)
+{
+	struct st_asm330lhh_sensor *sensor = iio_priv(dev_get_drvdata(dev));
+	enum st_asm330lhh_sensor_id id = sensor->id;
+	int i, len = 0;
+
+	for (i = 1; i < ST_ASM330LHH_ODR_LIST_SIZE; i++)
+		len += scnprintf(buf + len, PAGE_SIZE - len, "%d ",
+				 st_asm330lhh_odr_table[id].odr_avl[i].hz);
+	buf[len - 1] = '\n';
+
+	return len;
+}
+
+static ssize_t st_asm330lhh_sysfs_scale_avail(struct device *dev,
+					      struct device_attribute *attr,
+					      char *buf)
+{
+	struct st_asm330lhh_sensor *sensor = iio_priv(dev_get_drvdata(dev));
+	enum st_asm330lhh_sensor_id id = sensor->id;
+	int i, len = 0;
+
+	for (i = 0; i < st_asm330lhh_fs_table[id].size; i++)
+		len += scnprintf(buf + len, PAGE_SIZE - len, "0.%06u ",
+				 st_asm330lhh_fs_table[id].fs_avl[i].gain);
+	buf[len - 1] = '\n';
+
+	return len;
+}
+
+static IIO_DEV_ATTR_SAMP_FREQ_AVAIL(st_asm330lhh_sysfs_sampling_frequency_avail);
+static IIO_DEVICE_ATTR(in_accel_scale_available, 0444,
+		       st_asm330lhh_sysfs_scale_avail, NULL, 0);
+static IIO_DEVICE_ATTR(in_anglvel_scale_available, 0444,
+		       st_asm330lhh_sysfs_scale_avail, NULL, 0);
+static IIO_DEVICE_ATTR(in_temp_scale_available, 0444,
+		       st_asm330lhh_sysfs_scale_avail, NULL, 0);
+static IIO_DEVICE_ATTR(hwfifo_watermark_max, 0444,
+		       st_asm330lhh_get_max_watermark, NULL, 0);
+static IIO_DEVICE_ATTR(hwfifo_flush, 0200, NULL, st_asm330lhh_flush_fifo, 0);
+static IIO_DEVICE_ATTR(hwfifo_watermark, 0644, st_asm330lhh_get_watermark,
+		       st_asm330lhh_set_watermark, 0);
+
+static struct attribute *st_asm330lhh_acc_attributes[] = {
+	&iio_dev_attr_sampling_frequency_available.dev_attr.attr,
+	&iio_dev_attr_in_accel_scale_available.dev_attr.attr,
+	&iio_dev_attr_hwfifo_watermark_max.dev_attr.attr,
+	&iio_dev_attr_hwfifo_watermark.dev_attr.attr,
+	&iio_dev_attr_hwfifo_flush.dev_attr.attr,
+	NULL,
+};
+
+static const struct attribute_group st_asm330lhh_acc_attribute_group = {
+	.attrs = st_asm330lhh_acc_attributes,
+};
+
+static const struct iio_info st_asm330lhh_acc_info = {
+	.driver_module = THIS_MODULE,
+	.attrs = &st_asm330lhh_acc_attribute_group,
+	.read_raw = st_asm330lhh_read_raw,
+	.write_raw = st_asm330lhh_write_raw,
+};
+
+static struct attribute *st_asm330lhh_gyro_attributes[] = {
+	&iio_dev_attr_sampling_frequency_available.dev_attr.attr,
+	&iio_dev_attr_in_anglvel_scale_available.dev_attr.attr,
+	&iio_dev_attr_hwfifo_watermark_max.dev_attr.attr,
+	&iio_dev_attr_hwfifo_watermark.dev_attr.attr,
+	&iio_dev_attr_hwfifo_flush.dev_attr.attr,
+	NULL,
+};
+
+static const struct attribute_group st_asm330lhh_gyro_attribute_group = {
+	.attrs = st_asm330lhh_gyro_attributes,
+};
+
+static const struct iio_info st_asm330lhh_gyro_info = {
+	.driver_module = THIS_MODULE,
+	.attrs = &st_asm330lhh_gyro_attribute_group,
+	.read_raw = st_asm330lhh_read_raw,
+	.write_raw = st_asm330lhh_write_raw,
+};
+
+static struct attribute *st_asm330lhh_temp_attributes[] = {
+	&iio_dev_attr_sampling_frequency_available.dev_attr.attr,
+	&iio_dev_attr_in_temp_scale_available.dev_attr.attr,
+	&iio_dev_attr_hwfifo_watermark_max.dev_attr.attr,
+	&iio_dev_attr_hwfifo_watermark.dev_attr.attr,
+	&iio_dev_attr_hwfifo_flush.dev_attr.attr,
+	NULL,
+};
+
+static const struct attribute_group st_asm330lhh_temp_attribute_group = {
+	.attrs = st_asm330lhh_temp_attributes,
+};
+
+static const struct iio_info st_asm330lhh_temp_info = {
+	.driver_module = THIS_MODULE,
+	.attrs = &st_asm330lhh_temp_attribute_group,
+	.read_raw = st_asm330lhh_read_raw,
+	.write_raw = st_asm330lhh_write_raw,
+};
+
+static const unsigned long st_asm330lhh_available_scan_masks[] = { 0x7, 0x0 };
+
+static int st_asm330lhh_of_get_drdy_pin(struct st_asm330lhh_hw *hw, int *drdy_pin)
+{
+	struct device_node *np = hw->dev->of_node;
+
+	if (!np)
+		return -EINVAL;
+
+	return of_property_read_u32(np, "st,drdy-int-pin", drdy_pin);
+}
+
+static int st_asm330lhh_get_drdy_reg(struct st_asm330lhh_hw *hw, u8 *drdy_reg)
+{
+	int err = 0, drdy_pin;
+
+	if (st_asm330lhh_of_get_drdy_pin(hw, &drdy_pin) < 0) {
+		struct st_sensors_platform_data *pdata;
+		struct device *dev = hw->dev;
+
+		pdata = (struct st_sensors_platform_data *)dev->platform_data;
+		drdy_pin = pdata ? pdata->drdy_int_pin : 1;
+	}
+
+	switch (drdy_pin) {
+	case 1:
+		*drdy_reg = ST_ASM330LHH_REG_INT1_ADDR;
+		break;
+	case 2:
+		*drdy_reg = ST_ASM330LHH_REG_INT2_ADDR;
+		break;
+	default:
+		dev_err(hw->dev, "unsupported data ready pin\n");
+		err = -EINVAL;
+		break;
+	}
+
+	return err;
+}
+
+static int st_asm330lhh_init_device(struct st_asm330lhh_hw *hw)
+{
+	u8 drdy_int_reg;
+	int err;
+
+	err = st_asm330lhh_write_with_mask(hw, ST_ASM330LHH_REG_RESET_ADDR,
+					   ST_ASM330LHH_REG_RESET_MASK, 1);
+	if (err < 0)
+		return err;
+
+	msleep(200);
+
+	/* latch interrupts */
+	err = st_asm330lhh_write_with_mask(hw, ST_ASM330LHH_REG_LIR_ADDR,
+					   ST_ASM330LHH_REG_LIR_MASK, 1);
+	if (err < 0)
+		return err;
+
+	/* enable Block Data Update */
+	err = st_asm330lhh_write_with_mask(hw, ST_ASM330LHH_REG_BDU_ADDR,
+					   ST_ASM330LHH_REG_BDU_MASK, 1);
+	if (err < 0)
+		return err;
+
+	err = st_asm330lhh_write_with_mask(hw, ST_ASM330LHH_REG_ROUNDING_ADDR,
+					   ST_ASM330LHH_REG_ROUNDING_MASK, 3);
+	if (err < 0)
+		return err;
+
+	/* init timestamp engine */
+	err = st_asm330lhh_write_with_mask(hw, ST_ASM330LHH_REG_TIMESTAMP_EN_ADDR,
+					   ST_ASM330LHH_REG_TIMESTAMP_EN_MASK, 1);
+	if (err < 0)
+		return err;
+
+	/* enable FIFO watermak interrupt */
+	err = st_asm330lhh_get_drdy_reg(hw, &drdy_int_reg);
+	if (err < 0)
+		return err;
+
+	return st_asm330lhh_write_with_mask(hw, drdy_int_reg,
+					    ST_ASM330LHH_REG_FIFO_FTH_IRQ_MASK, 1);
+}
+
+static struct iio_dev *st_asm330lhh_alloc_iiodev(struct st_asm330lhh_hw *hw,
+						 enum st_asm330lhh_sensor_id id)
+{
+	struct st_asm330lhh_sensor *sensor;
+	struct iio_dev *iio_dev;
+
+	iio_dev = devm_iio_device_alloc(hw->dev, sizeof(*sensor));
+	if (!iio_dev)
+		return NULL;
+
+	iio_dev->modes = INDIO_DIRECT_MODE;
+	iio_dev->dev.parent = hw->dev;
+	iio_dev->available_scan_masks = st_asm330lhh_available_scan_masks;
+
+	sensor = iio_priv(iio_dev);
+	sensor->id = id;
+	sensor->hw = hw;
+	sensor->odr = st_asm330lhh_odr_table[id].odr_avl[1].hz;
+	sensor->gain = st_asm330lhh_fs_table[id].fs_avl[0].gain;
+	sensor->watermark = 1;
+	sensor->old_data = 0;
+
+	switch (id) {
+	case ST_ASM330LHH_ID_ACC:
+		iio_dev->channels = st_asm330lhh_acc_channels;
+		iio_dev->num_channels = ARRAY_SIZE(st_asm330lhh_acc_channels);
+		iio_dev->name = "asm330lhh_accel";
+		iio_dev->info = &st_asm330lhh_acc_info;
+		sensor->batch_addr = ST_ASM330LHH_REG_FIFO_BATCH_ADDR;
+		sensor->batch_mask = GENMASK(3, 0);
+		sensor->offset = 0;
+		break;
+	case ST_ASM330LHH_ID_GYRO:
+		iio_dev->channels = st_asm330lhh_gyro_channels;
+		iio_dev->num_channels = ARRAY_SIZE(st_asm330lhh_gyro_channels);
+		iio_dev->name = "asm330lhh_gyro";
+		iio_dev->info = &st_asm330lhh_gyro_info;
+		sensor->batch_addr = ST_ASM330LHH_REG_FIFO_BATCH_ADDR;
+		sensor->batch_mask = GENMASK(7, 4);
+		sensor->offset = 0;
+		break;
+	case ST_ASM330LHH_ID_TEMP:
+		iio_dev->channels = st_asm330lhh_temp_channels;
+		iio_dev->num_channels = ARRAY_SIZE(st_asm330lhh_temp_channels);
+		iio_dev->name = "asm330lhh_temp";
+		iio_dev->info = &st_asm330lhh_temp_info;
+		sensor->offset = ST_ASM330LHH_OFFSET;
+		break;
+	default:
+		return NULL;
+	}
+
+	return iio_dev;
+}
+
+int st_asm330lhh_probe(struct device *dev, int irq,
+		       const struct st_asm330lhh_transfer_function *tf_ops)
+{
+	struct st_asm330lhh_hw *hw;
+	int i, err;
+
+	hw = devm_kzalloc(dev, sizeof(*hw), GFP_KERNEL);
+	if (!hw)
+		return -ENOMEM;
+
+	dev_set_drvdata(dev, (void *)hw);
+
+	mutex_init(&hw->lock);
+	mutex_init(&hw->fifo_lock);
+
+	hw->dev = dev;
+	hw->irq = irq;
+	hw->tf = tf_ops;
+
+	dev_info(hw->dev, "Ver: %s\n", ST_ASM330LHH_VERSION);
+	err = st_asm330lhh_check_whoami(hw);
+	if (err < 0)
+		return err;
+
+	err = st_asm330lhh_init_device(hw);
+	if (err < 0)
+		return err;
+
+	for (i = 0; i < ST_ASM330LHH_ID_MAX; i++) {
+		hw->iio_devs[i] = st_asm330lhh_alloc_iiodev(hw, i);
+		if (!hw->iio_devs[i])
+			return -ENOMEM;
+	}
+
+	if (hw->irq > 0) {
+		err = st_asm330lhh_fifo_setup(hw);
+		if (err < 0)
+			return err;
+	}
+
+	for (i = 0; i < ST_ASM330LHH_ID_MAX; i++) {
+		if (!hw->iio_devs[i])
+			continue;
+
+		err = devm_iio_device_register(hw->dev, hw->iio_devs[i]);
+		if (err)
+			return err;
+	}
+
+	dev_info(hw->dev, "probe ok\n");
+
+	return 0;
+}
+EXPORT_SYMBOL(st_asm330lhh_probe);
+
+static int __maybe_unused st_asm330lhh_suspend(struct device *dev)
+{
+	struct st_asm330lhh_hw *hw = dev_get_drvdata(dev);
+	struct st_asm330lhh_sensor *sensor;
+	int i, err = 0;
+
+	for (i = 0; i < ST_ASM330LHH_ID_MAX; i++) {
+		if (!hw->iio_devs[i])
+			continue;
+
+		sensor = iio_priv(hw->iio_devs[i]);
+
+		if (!(hw->enable_mask & BIT(sensor->id)))
+			continue;
+
+		err = st_asm330lhh_set_odr(sensor, 0);
+		if (err < 0)
+			return err;
+	}
+
+	if (hw->enable_mask)
+		err = st_asm330lhh_suspend_fifo(hw);
+
+	return err;
+}
+
+static int __maybe_unused st_asm330lhh_resume(struct device *dev)
+{
+	struct st_asm330lhh_hw *hw = dev_get_drvdata(dev);
+	struct st_asm330lhh_sensor *sensor;
+	int i, err = 0;
+
+	for (i = 0; i < ST_ASM330LHH_ID_MAX; i++) {
+		if (!hw->iio_devs[i])
+			continue;
+
+		sensor = iio_priv(hw->iio_devs[i]);
+		if (!(hw->enable_mask & BIT(sensor->id)))
+			continue;
+
+		err = st_asm330lhh_set_odr(sensor, sensor->odr);
+		if (err < 0)
+			return err;
+	}
+
+	if (hw->enable_mask)
+		err = st_asm330lhh_set_fifo_mode(hw, ST_ASM330LHH_FIFO_CONT);
+
+	return err;
+}
+
+const struct dev_pm_ops st_asm330lhh_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(st_asm330lhh_suspend, st_asm330lhh_resume)
+};
+EXPORT_SYMBOL(st_asm330lhh_pm_ops);
+
+MODULE_AUTHOR("Lorenzo Bianconi <lorenzo.bianconi@st.com>");
+MODULE_DESCRIPTION("STMicroelectronics st_asm330lhh driver");
+MODULE_LICENSE("GPL v2");
+MODULE_VERSION(ST_ASM330LHH_VERSION);
diff --git a/drivers/iio/imu/st_asm330lhh/st_asm330lhh_i2c.c b/drivers/iio/imu/st_asm330lhh/st_asm330lhh_i2c.c
new file mode 100644
index 0000000..4875097
--- /dev/null
+++ b/drivers/iio/imu/st_asm330lhh/st_asm330lhh_i2c.c
@@ -0,0 +1,94 @@
+/*
+ * STMicroelectronics st_asm330lhh i2c driver
+ *
+ * Copyright 2018 STMicroelectronics Inc.
+ *
+ * Lorenzo Bianconi <lorenzo.bianconi@st.com>
+ *
+ * Licensed under the GPL-2.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/i2c.h>
+#include <linux/slab.h>
+#include <linux/of.h>
+
+#include "st_asm330lhh.h"
+
+static int st_asm330lhh_i2c_read(struct device *dev, u8 addr, int len, u8 *data)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct i2c_msg msg[2];
+
+	msg[0].addr = client->addr;
+	msg[0].flags = client->flags;
+	msg[0].len = 1;
+	msg[0].buf = &addr;
+
+	msg[1].addr = client->addr;
+	msg[1].flags = client->flags | I2C_M_RD;
+	msg[1].len = len;
+	msg[1].buf = data;
+
+	return i2c_transfer(client->adapter, msg, 2);
+}
+
+static int st_asm330lhh_i2c_write(struct device *dev, u8 addr, int len, u8 *data)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct i2c_msg msg;
+	u8 send[len + 1];
+
+	send[0] = addr;
+	memcpy(&send[1], data, len * sizeof(u8));
+
+	msg.addr = client->addr;
+	msg.flags = client->flags;
+	msg.len = len + 1;
+	msg.buf = send;
+
+	return i2c_transfer(client->adapter, &msg, 1);
+}
+
+static const struct st_asm330lhh_transfer_function st_asm330lhh_transfer_fn = {
+	.read = st_asm330lhh_i2c_read,
+	.write = st_asm330lhh_i2c_write,
+};
+
+static int st_asm330lhh_i2c_probe(struct i2c_client *client,
+				const struct i2c_device_id *id)
+{
+	return st_asm330lhh_probe(&client->dev, client->irq,
+				&st_asm330lhh_transfer_fn);
+}
+
+static const struct of_device_id st_asm330lhh_i2c_of_match[] = {
+	{
+		.compatible = "st,asm330lhh",
+	},
+	{},
+};
+MODULE_DEVICE_TABLE(of, st_asm330lhh_i2c_of_match);
+
+static const struct i2c_device_id st_asm330lhh_i2c_id_table[] = {
+	{ ST_ASM330LHH_DEV_NAME },
+	{},
+};
+MODULE_DEVICE_TABLE(i2c, st_asm330lhh_i2c_id_table);
+
+static struct i2c_driver st_asm330lhh_driver = {
+	.driver = {
+		.name = "st_asm330lhh_i2c",
+		.pm = &st_asm330lhh_pm_ops,
+		.of_match_table = of_match_ptr(st_asm330lhh_i2c_of_match),
+	},
+	.probe = st_asm330lhh_i2c_probe,
+	.id_table = st_asm330lhh_i2c_id_table,
+};
+module_i2c_driver(st_asm330lhh_driver);
+
+MODULE_AUTHOR("Lorenzo Bianconi <lorenzo.bianconi@st.com>");
+MODULE_DESCRIPTION("STMicroelectronics st_asm330lhh i2c driver");
+MODULE_LICENSE("GPL v2");
+MODULE_VERSION(ST_ASM330LHH_VERSION);
diff --git a/drivers/iio/imu/st_asm330lhh/st_asm330lhh_spi.c b/drivers/iio/imu/st_asm330lhh/st_asm330lhh_spi.c
new file mode 100644
index 0000000..07b8400
--- /dev/null
+++ b/drivers/iio/imu/st_asm330lhh/st_asm330lhh_spi.c
@@ -0,0 +1,109 @@
+/*
+ * STMicroelectronics st_asm330lhh spi driver
+ *
+ * Copyright 2018 STMicroelectronics Inc.
+ *
+ * Lorenzo Bianconi <lorenzo.bianconi@st.com>
+ *
+ * Licensed under the GPL-2.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/spi/spi.h>
+#include <linux/slab.h>
+#include <linux/of.h>
+
+#include "st_asm330lhh.h"
+
+#define SENSORS_SPI_READ	BIT(7)
+
+static int st_asm330lhh_spi_read(struct device *dev, u8 addr, int len,
+			       u8 *data)
+{
+	struct spi_device *spi = to_spi_device(dev);
+	struct st_asm330lhh_hw *hw = spi_get_drvdata(spi);
+	int err;
+
+	struct spi_transfer xfers[] = {
+		{
+			.tx_buf = hw->tb.tx_buf,
+			.bits_per_word = 8,
+			.len = 1,
+		},
+		{
+			.rx_buf = hw->tb.rx_buf,
+			.bits_per_word = 8,
+			.len = len,
+		}
+	};
+
+	hw->tb.tx_buf[0] = addr | SENSORS_SPI_READ;
+
+	err = spi_sync_transfer(spi, xfers,  ARRAY_SIZE(xfers));
+	if (err < 0)
+		return err;
+
+	memcpy(data, hw->tb.rx_buf, len * sizeof(u8));
+
+	return len;
+}
+
+static int st_asm330lhh_spi_write(struct device *dev, u8 addr, int len,
+				u8 *data)
+{
+	struct st_asm330lhh_hw *hw;
+	struct spi_device *spi;
+
+	if (len >= ST_ASM330LHH_TX_MAX_LENGTH)
+		return -ENOMEM;
+
+	spi = to_spi_device(dev);
+	hw = spi_get_drvdata(spi);
+
+	hw->tb.tx_buf[0] = addr;
+	memcpy(&hw->tb.tx_buf[1], data, len);
+
+	return spi_write(spi, hw->tb.tx_buf, len + 1);
+}
+
+static const struct st_asm330lhh_transfer_function st_asm330lhh_transfer_fn = {
+	.read = st_asm330lhh_spi_read,
+	.write = st_asm330lhh_spi_write,
+};
+
+static int st_asm330lhh_spi_probe(struct spi_device *spi)
+{
+	return st_asm330lhh_probe(&spi->dev, spi->irq,
+				&st_asm330lhh_transfer_fn);
+}
+
+static const struct of_device_id st_asm330lhh_spi_of_match[] = {
+	{
+		.compatible = "st,asm330lhh",
+	},
+	{},
+};
+MODULE_DEVICE_TABLE(of, st_asm330lhh_spi_of_match);
+
+static const struct spi_device_id st_asm330lhh_spi_id_table[] = {
+	{ ST_ASM330LHH_DEV_NAME },
+	{},
+};
+MODULE_DEVICE_TABLE(spi, st_asm330lhh_spi_id_table);
+
+static struct spi_driver st_asm330lhh_driver = {
+	.driver = {
+		.name = "st_asm330lhh_spi",
+		.pm = &st_asm330lhh_pm_ops,
+		.of_match_table = of_match_ptr(st_asm330lhh_spi_of_match),
+	},
+	.probe = st_asm330lhh_spi_probe,
+	.id_table = st_asm330lhh_spi_id_table,
+};
+module_spi_driver(st_asm330lhh_driver);
+
+MODULE_AUTHOR("Lorenzo Bianconi <lorenzo.bianconi@st.com>");
+MODULE_DESCRIPTION("STMicroelectronics st_asm330lhh spi driver");
+MODULE_LICENSE("GPL v2");
+MODULE_VERSION(ST_ASM330LHH_VERSION);
diff --git a/drivers/input/sensors/bmi160/Kconfig b/drivers/input/sensors/bmi160/Kconfig
new file mode 100644
index 0000000..0b1feda
--- /dev/null
+++ b/drivers/input/sensors/bmi160/Kconfig
@@ -0,0 +1,121 @@
+#
+# Makefile for Bosch sensors driver.
+#
+config BOSCH_DRIVER_LOG_FUNC
+	tristate "Bosch Sensortec driver smart log function support"
+	depends on (I2C || SPI_MASTER) && SYSFS
+	help
+	 If you say yes here, you get support for smart log function in Bosch Sensortec driver.
+
+config SENSORS_BMA2X2
+	tristate "BMA2x2 acceleration sensor support"
+	depends on I2C
+	help
+	  If you say yes here, you get support for Bosch Sensortec's
+	  acceleration sensors BMA255/BMA254/BMA355/BMA250E/BMA222E/BMA280.
+
+config SENSORS_BMA2X2_ENABLE_INT1
+	tristate "BMA2X2 acceleration sensor interrupt INT1 support"
+	depends on SENSORS_BMA2X2
+	help
+	 If you say yes here, you get INT1 support for Bosch Sensortec
+	 acceleration sensors BMA255/BMA250E/BMA222E/BMA280.
+	 Select it will disable interrupt INT2 support
+
+config SENSORS_BMA2X2_ENABLE_INT2
+	tristate "BMA2X2 acceleration sensor interrupt INT2 support"
+	depends on SENSORS_BMA2X2 && !SENSORS_BMA2X2_ENABLE_INT1
+	help
+	 If you say yes here, you get INT2 support for Bosch Sensortec
+	 acceleration sensors BMA255/BMA250E/BMA222E/BMA280.
+	 Can only open if you do NOT open interrupt INT1 support
+
+config SIG_MOTION
+	tristate "support significant motion sensor function"
+	depends on SENSORS_BMA2X2  && ( SENSORS_BMA2X2_ENABLE_INT1 || SENSORS_BMA2X2_ENABLE_INT2)
+	help
+	 If you say yes here, if you want to support Bosch significant motion sensor function
+
+config DOUBLE_TAP
+	tristate "support double tap sensor function"
+	depends on SENSORS_BMA2X2  && ( SENSORS_BMA2X2_ENABLE_INT1 || SENSORS_BMA2X2_ENABLE_INT2)
+	help
+	 If you say yes here, you get support Bosch double tap sensor function
+
+config SENSORS_BMG
+	tristate "Bosch Gyroscope Sensor Driver"
+	depends on I2C
+	help
+	 If you say yes here, you get support for Bosch Sensortec's
+	 gyroscope sensor drivers of BMG160/BMI055/BMI058 e.t.c.
+
+config SENSORS_BMG_FIFO
+	tristate "Bosch Gyroscope FIFO Support"
+	depends on SENSORS_BMG
+	help
+	 If you say yes here, you get support for Gyroscope sensor FIFO operations.
+	 Please check whether the chip supports fifo feature to open it.
+
+config SENSORS_BMI058
+	tristate "BMI058 Sensor Support"
+	depends on (SENSORS_BMG || SENSORS_BMA2X2)
+	help
+	 If you say yes here, you get support for Bosch Sensortec's
+	 sensor driver of BMI058.
+
+config SENSORS_YAS537
+	tristate "YAS537 Magnetic Sensor Driver"
+	depends on I2C
+	help
+	 If you say yes here, you get support for YAMAHA
+	 sensor YAS537 Magnetic Sensor
+
+config SENSORS_BMM050
+	tristate "BMM050 Magnetic Sensor Driver"
+	depends on I2C
+	help
+	 If you say yes here, you get support for Bosch Sensortec's
+	 sensor BMM050 Magnetic Sensor
+
+config SENSORS_AKM09911
+	tristate "AKM09911 Mag Sensor Driver"
+	depends on I2C
+	help
+	 If you say yes here, you get support AKM09911 Sensor support.
+
+config SENSORS_AKM09912
+	tristate "AKM09912 Mag Sensor Driver"
+	depends on I2C
+	help
+	 If you say yes here, you get support AKM09912 Sensor support.
+
+config SENSORS_BMA420
+	tristate "BMA4XY Sensor Support"
+	depends on I2C || SPI_MASTER
+	help
+	If you say yes here, you get support for Bosch Sensortec's sensor driver of BMA420.
+config SENSORS_BMA421
+	tristate "BMA4XY Sensor Support"
+	depends on I2C || SPI_MASTER
+	help
+	If you say yes here, you get support for Bosch Sensortec's sensor driver of BMA421.
+config SENSORS_BMA422
+	tristate "BMA4XY Sensor Support"
+	depends on I2C || SPI_MASTER
+	help
+	If you say yes here, you get support for Bosch Sensortec's sensor driver of BMA422.
+config SENSORS_BMA455
+	tristate "BMA4XY Sensor Support"
+	depends on I2C || SPI_MASTER
+	help
+	If you say yes here, you get support for Bosch Sensortec's sensor driver of BMA455.
+
+config BMA4XY_MAG_INTERFACE_SUPPORT
+tristate "BMA4XY Sensor mag interface support"
+depends on SENSORS_BMA4XY
+	help
+	 If you say yes here, you get support for Bosch Sensortec's
+	 sensor driver of BMA4XY with mag sensor support.
+
+
+
diff --git a/drivers/input/sensors/bmi160/Makefile b/drivers/input/sensors/bmi160/Makefile
new file mode 100644
index 0000000..0a9bb56
--- /dev/null
+++ b/drivers/input/sensors/bmi160/Makefile
@@ -0,0 +1,41 @@
+#
+# Makefile for Bosch sensor driver.
+#
+
+obj-$(CONFIG_BOSCH_DRIVER_LOG_FUNC) += bs_log.o
+obj-y += bstclass.o
+ifeq ($(CONFIG_BOSCH_DRIVER_LOG_FUNC),y)
+	EXTRA_CFLAGS += -DBOSCH_DRIVER_LOG_FUNC
+endif
+
+#obj-y   += bma2x2.o
+
+ifeq ($(CONFIG_SENSORS_BMA2X2_ENABLE_INT1),y)
+	EXTRA_CFLAGS += -DBMA2X2_ENABLE_INT1
+endif
+
+ifeq ($(CONFIG_BOSCH_BMA2X2_ENABLE_INT2),y)
+	EXTRA_CFLAGS += -DBMA2X2_ENABLE_INT2
+endif
+
+#obj-y    += bmg160_driver.o bmg160.o
+EXTRA_CFLAGS += -DBMG_USE_BASIC_I2C_FUNC
+
+obj-y    += bmi160_driver.o bmi160.o
+ifeq ($(CONFIG_BMI160_MAG_INTERFACE_SUPPORT),y)
+		EXTRA_CFLAGS += -DBMI160_MAG_INTERFACE_SUPPORT
+endif
+ifeq ($(CONFIG_SENSORS_BMI160_ENABLE_INT1),y)
+		EXTRA_CFLAGS += -DBMI160_ENABLE_INT1
+endif
+
+ifeq ($(CONFIG_SENSORS_BMI160_ENABLE_INT2),y)
+		EXTRA_CFLAGS += -DBMI160_ENABLE_INT2
+endif
+
+obj-y  += bmi160_i2c.o
+
+EXTRA_CFLAGS += -DBMI_USE_BASIC_I2C_FUNC
+
+obj-$(CONFIG_SENSORS_BMI160_SPI)  += bmi160_spi.o
+
diff --git a/drivers/input/sensors/bmi160/bmi160.c b/drivers/input/sensors/bmi160/bmi160.c
new file mode 100644
index 0000000..071f7e3
--- /dev/null
+++ b/drivers/input/sensors/bmi160/bmi160.c
@@ -0,0 +1,18753 @@
+/*
+* @section LICENSE
+* (C) Copyright 2011~2018 Bosch Sensortec GmbH All Rights Reserved
+*
+* This software program is licensed subject to the GNU General
+* Public License (GPL).Version 2,June 1991,
+* available at http://www.fsf.org/copyleft/gpl.html
+
+*
+* @filename bmi160.c
+* @Date: 2015/04/02
+* @id       836294d
+* @Revision: 2.0.9 $
+*
+* Usage: Sensor Driver for BMI160 sensor
+*
+****************************************************************************
+* \section Disclaimer
+*
+* Common:
+* Bosch Sensortec products are developed for the consumer goods industry.
+* They may only be used within the parameters of the respective valid
+* product data sheet.  Bosch Sensortec products are provided with the
+* express understanding that there is no warranty of fitness for a
+* particular purpose.They are not fit for use in life-sustaining,
+* safety or security sensitive systems or any system or device
+* that may lead to bodily harm or property damage if the system
+* or device malfunctions. In addition,Bosch Sensortec products are
+* not fit for use in products which interact with motor vehicle systems.
+* The resale and or use of products are at the purchasers own risk and
+* his own responsibility. The examination of fitness for the intended use
+* is the sole responsibility of the Purchaser.
+*
+* The purchaser shall indemnify Bosch Sensortec from all third party
+* claims, including any claims for incidental, or consequential damages,
+* arising from any product use not covered by the parameters of
+* the respective valid product data sheet or not approved by
+* Bosch Sensortec and reimburse Bosch Sensortec for all costs in
+* connection with such claims.
+*
+* The purchaser must monitor the market for the purchased products,
+* particularly with regard to product safety and inform Bosch Sensortec
+* without delay of all security relevant incidents.
+*
+* Engineering Samples are marked with an asterisk (*) or (e).
+* Samples may vary from the valid technical specifications of the product
+* series. They are therefore not intended or fit for resale to third
+* parties or for use in end products. Their sole purpose is internal
+* client testing. The testing of an engineering sample may in no way
+* replace the testing of a product series. Bosch Sensortec assumes
+* no liability for the use of engineering samples.
+* By accepting the engineering samples, the Purchaser agrees to indemnify
+* Bosch Sensortec from all claims arising from the use of engineering
+* samples.
+*
+* Special:
+* This software module (hereinafter called "Software") and any information
+* on application-sheets (hereinafter called "Information") is provided
+* free of charge for the sole purpose to support your application work.
+* The Software and Information is subject to the following
+* terms and conditions:
+*
+* The Software is specifically designed for the exclusive use for
+* Bosch Sensortec products by personnel who have special experience
+* and training. Do not use this Software if you do not have the
+* proper experience or training.
+*
+* This Software package is provided `` as is `` and without any expressed
+* or implied warranties,including without limitation, the implied warranties
+* of merchantability and fitness for a particular purpose.
+*
+* Bosch Sensortec and their representatives and agents deny any liability
+* for the functional impairment
+* of this Software in terms of fitness, performance and safety.
+* Bosch Sensortec and their representatives and agents shall not be liable
+* for any direct or indirect damages or injury, except as
+* otherwise stipulated in mandatory applicable law.
+*
+* The Information provided is believed to be accurate and reliable.
+* Bosch Sensortec assumes no responsibility for the consequences of use
+* of such Information nor for any infringement of patents or
+* other rights of third parties which may result from its use.
+* No license is granted by implication or otherwise under any patent or
+* patent rights of Bosch. Specifications mentioned in the Information are
+* subject to change without notice.
+**************************************************************************/
+/*! file <BMI160 >
+    brief <Sensor driver for BMI160> */
+#include "bmi160.h"
+#include <linux/kernel.h>
+
+/* user defined code to be added here ... */
+struct bmi160_t *p_bmi160;
+/* used for reading the mag trim values for compensation*/
+struct trim_data_t mag_trim;
+/* the following variable used for avoiding the selecting of auto mode
+when it is running in the manual mode of BMM150 mag interface*/
+u8 V_bmm150_maual_auto_condition_u8 = BMI160_INIT_VALUE;
+/* used for reading the AKM compensating data */
+struct bst_akm_sensitivity_data_t akm_asa_data;
+/* Assign the fifo time */
+u32 V_fifo_time_U32 = BMI160_INIT_VALUE;
+
+/* FIFO data read for 1024 bytes of data */
+u8 v_fifo_data_u8[FIFO_FRAME] = {BMI160_INIT_VALUE};
+/* YAMAHA-YAS532*/
+/* value of coeff*/
+static const int yas532_version_ac_coef[] = {YAS532_VERSION_AC_COEF_X,
+YAS532_VERSION_AC_COEF_Y1, YAS532_VERSION_AC_COEF_Y2};
+/* used for reading the yas532 calibration data*/
+struct yas532_t yas532_data;
+/* used for reading the yas537 calibration data*/
+struct yas537_t yas537_data;
+/*!
+ *	@brief
+ *	This function is used for initialize
+ *	bus read and bus write functions
+ *	assign the chip id and device address
+ *	chip id is read in the register 0x00 bit from 0 to 7
+ *
+ *	@param bmi160 : structure pointer
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *	@note
+ *	While changing the parameter of the bmi160_t
+ *	consider the following point:
+ *	Changing the reference value of the parameter
+ *	will changes the local copy or local reference
+ *	make sure your changes will not
+ *	affect the reference value of the parameter
+ *	(Better case don't change the reference value of the parameter)
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_init(struct bmi160_t *bmi160)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	u8 v_pmu_data_u8 = BMI160_INIT_VALUE;
+	/* assign bmi160 ptr */
+	p_bmi160 = bmi160;
+	com_rslt =
+	p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+	BMI160_USER_CHIP_ID__REG,
+	&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	/* read Chip Id */
+	p_bmi160->chip_id = v_data_u8;
+	/* To avoid gyro wakeup it is required to write 0x00 to 0x6C*/
+	com_rslt += bmi160_write_reg(BMI160_USER_PMU_TRIGGER_ADDR,
+	&v_pmu_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	return com_rslt;
+}
+/*!
+ * @brief
+ *	This API write the data to
+ *	the given register
+ *
+ *
+ *	@param v_addr_u8 -> Address of the register
+ *	@param v_data_u8 -> The data from the register
+ *	@param v_len_u8 -> no of bytes to read
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_write_reg(u8 v_addr_u8,
+u8 *v_data_u8, u8 v_len_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* write data from register*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->dev_addr,
+			v_addr_u8, v_data_u8, v_len_u8);
+		}
+	return com_rslt;
+}
+/*!
+ * @brief
+ *	This API reads the data from
+ *	the given register
+ *
+ *
+ *	@param v_addr_u8 -> Address of the register
+ *	@param v_data_u8 -> The data from the register
+ *	@param v_len_u8 -> no of bytes to read
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_reg(u8 v_addr_u8,
+u8 *v_data_u8, u8 v_len_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* Read data from register*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			v_addr_u8, v_data_u8, v_len_u8);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API used to reads the fatal error
+ *	from the Register 0x02 bit 0
+ *	This flag will be reset only by power-on-reset and soft reset
+ *
+ *
+ *  @param v_fatal_err_u8 : The status of fatal error
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_fatal_err(u8
+*v_fatal_err_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* reading the fatal error status*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_FATAL_ERR__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_fatal_err_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_FATAL_ERR);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API used to read the error code
+ *	from register 0x02 bit 1 to 4
+ *
+ *
+ *  @param v_err_code_u8 : The status of error codes
+ *	error_code  |    description
+ *  ------------|---------------
+ *	0x00        |no error
+ *	0x01        |ACC_CONF error (accel ODR and bandwidth not compatible)
+ *	0x02        |GYR_CONF error (Gyroscope ODR and bandwidth not compatible)
+ *	0x03        |Under sampling mode and interrupt uses pre filtered data
+ *	0x04        |reserved
+ *	0x05        |Selected trigger-readout offset in
+ *    -         |MAG_IF greater than selected ODR
+ *	0x06        |FIFO configuration error for header less mode
+ *	0x07        |Under sampling mode and pre filtered data as FIFO source
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_err_code(u8
+*v_err_code_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_ERR_CODE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_err_code_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_ERR_CODE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API Reads the i2c error code from the
+ *	Register 0x02 bit 5.
+ *	This error occurred in I2C master detected
+ *
+ *  @param v_i2c_err_code_u8 : The status of i2c fail error
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_i2c_fail_err(u8
+*v_i2c_err_code_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_I2C_FAIL_ERR__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_i2c_err_code_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_I2C_FAIL_ERR);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API Reads the dropped command error
+ *	from the register 0x02 bit 6
+ *
+ *
+ *  @param v_drop_cmd_err_u8 : The status of drop command error
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_drop_cmd_err(u8
+*v_drop_cmd_err_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_DROP_CMD_ERR__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_drop_cmd_err_u8 = BMI160_GET_BITSLICE(
+			v_data_u8,
+			BMI160_USER_DROP_CMD_ERR);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the magnetometer data ready
+ *	interrupt not active.
+ *	It reads from the error register 0x0x2 bit 7
+ *
+ *
+ *
+ *
+ *  @param v_mag_data_rdy_err_u8 : The status of mag data ready interrupt
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_dada_rdy_err(
+u8 *v_mag_data_rdy_err_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_MAG_DADA_RDY_ERR__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_mag_data_rdy_err_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_MAG_DADA_RDY_ERR);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the error status
+ *	from the error register 0x02 bit 0 to 7
+ *
+ *  @param v_mag_data_rdy_err_u8 : The status of mag data ready interrupt
+ *  @param v_fatal_er_u8r : The status of fatal error
+ *  @param v_err_code_u8 : The status of error code
+ *  @param v_i2c_fail_err_u8 : The status of I2C fail error
+ *  @param v_drop_cmd_err_u8 : The status of drop command error
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_error_status(u8 *v_fatal_er_u8r,
+u8 *v_err_code_u8, u8 *v_i2c_fail_err_u8,
+u8 *v_drop_cmd_err_u8, u8 *v_mag_data_rdy_err_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the error codes*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_ERR_STAT__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			/* fatal error*/
+			*v_fatal_er_u8r =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_FATAL_ERR);
+			/* user error*/
+			*v_err_code_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_ERR_CODE);
+			/* i2c fail error*/
+			*v_i2c_fail_err_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_I2C_FAIL_ERR);
+			/* drop command error*/
+			*v_drop_cmd_err_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_DROP_CMD_ERR);
+			/* mag data ready error*/
+			*v_mag_data_rdy_err_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_MAG_DADA_RDY_ERR);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the magnetometer power mode from
+ *	PMU status register 0x03 bit 0 and 1
+ *
+ *  @param v_mag_power_mode_stat_u8 : The value of mag power mode
+ *	mag_powermode    |   value
+ * ------------------|----------
+ *    SUSPEND        |   0x00
+ *    NORMAL         |   0x01
+ *   LOW POWER       |   0x02
+ *
+ *
+ * @note The power mode of mag set by the 0x7E command register
+ * @note using the function "bmi160_set_command_register()"
+ *  value    |   mode
+ *  ---------|----------------
+ *   0x18    | MAG_MODE_SUSPEND
+ *   0x19    | MAG_MODE_NORMAL
+ *   0x1A    | MAG_MODE_LOWPOWER
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_power_mode_stat(u8
+*v_mag_power_mode_stat_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_MAG_POWER_MODE_STAT__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_mag_power_mode_stat_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_MAG_POWER_MODE_STAT);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the gyroscope power mode from
+ *	PMU status register 0x03 bit 2 and 3
+ *
+ *  @param v_gyro_power_mode_stat_u8 :	The value of gyro power mode
+ *	gyro_powermode   |   value
+ * ------------------|----------
+ *    SUSPEND        |   0x00
+ *    NORMAL         |   0x01
+ *   FAST POWER UP   |   0x03
+ *
+ * @note The power mode of gyro set by the 0x7E command register
+ * @note using the function "bmi160_set_command_register()"
+ *  value    |   mode
+ *  ---------|----------------
+ *   0x14    | GYRO_MODE_SUSPEND
+ *   0x15    | GYRO_MODE_NORMAL
+ *   0x17    | GYRO_MODE_FASTSTARTUP
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_power_mode_stat(u8
+*v_gyro_power_mode_stat_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_GYRO_POWER_MODE_STAT__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_gyro_power_mode_stat_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_GYRO_POWER_MODE_STAT);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the accelerometer power mode from
+ *	PMU status register 0x03 bit 4 and 5
+ *
+ *
+ *  @param v_accel_power_mode_stat_u8 :	The value of accel power mode
+ *	accel_powermode  |   value
+ * ------------------|----------
+ *    SUSPEND        |   0x00
+ *    NORMAL         |   0x01
+ *  LOW POWER        |   0x02
+ *
+ * @note The power mode of accel set by the 0x7E command register
+ * @note using the function "bmi160_set_command_register()"
+ *  value    |   mode
+ *  ---------|----------------
+ *   0x11    | ACCEL_MODE_NORMAL
+ *   0x12    | ACCEL_LOWPOWER
+ *   0x10    | ACCEL_SUSPEND
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_power_mode_stat(u8
+*v_accel_power_mode_stat_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_ACCEL_POWER_MODE_STAT__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_accel_power_mode_stat_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_ACCEL_POWER_MODE_STAT);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API switch mag interface to normal mode
+ *	and confirm whether the mode switching done successfully or not
+*
+ *	@return results of bus communication function and current MAG_PMU result
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_interface_normal(void)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = BMI160_INIT_VALUE;
+	/* aim to check the result of switching mag normal */
+	u8 v_try_times_u8 = BMI160_MAG_NOAMRL_SWITCH_TIMES;
+	u8 v_mag_pum_status_u8 = BMI160_INIT_VALUE;
+
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	com_rslt = bmi160_set_command_register(MAG_MODE_NORMAL);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	while (v_try_times_u8) {
+		com_rslt = bmi160_get_mag_power_mode_stat(&v_mag_pum_status_u8);
+		if (v_mag_pum_status_u8 == MAG_INTERFACE_PMU_ENABLE)
+			break;
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		v_try_times_u8--;
+	}
+	if (v_mag_pum_status_u8 == MAG_INTERFACE_PMU_ENABLE)
+		com_rslt += SUCCESS;
+	else
+		com_rslt += E_BMI160_COMM_RES;
+
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads magnetometer data X values
+ *	from the register 0x04 and 0x05
+ *	@brief The mag sensor data read form auxiliary mag
+ *
+ *  @param v_mag_x_s16 : The value of mag x
+ *  @param v_sensor_select_u8 : Mag selection value
+ *  value    |   sensor
+ *  ---------|----------------
+ *   0       | BMM150
+ *   1       | AKM09911 or AKM09912
+ *
+ *	@note For mag data output rate configuration use the following function
+ *	@note bmi160_set_mag_output_data_rate()
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_x(s16 *v_mag_x_s16,
+u8 v_sensor_select_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* Array contains the mag X lSB and MSB data
+		v_data_u8[0] - LSB
+		v_data_u8[1] - MSB*/
+	u8 v_data_u8[BMI160_MAG_X_DATA_SIZE] = {BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE};
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		switch (v_sensor_select_u8) {
+		case BST_BMM:
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_DATA_MAG_X_LSB__REG,
+			v_data_u8, BMI160_MAG_X_DATA_LENGTH);
+			/* X axis*/
+			v_data_u8[BMI160_MAG_X_LSB_BYTE] =
+			BMI160_GET_BITSLICE(v_data_u8[BMI160_MAG_X_LSB_BYTE],
+			BMI160_USER_DATA_MAG_X_LSB);
+			*v_mag_x_s16 = (s16)
+			((((s32)((s8)v_data_u8[BMI160_MAG_X_MSB_BYTE]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_05_BITS) |
+			(v_data_u8[BMI160_MAG_X_LSB_BYTE]));
+		break;
+		case BST_AKM:
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_DATA_0_MAG_X_LSB__REG,
+			v_data_u8, BMI160_MAG_X_DATA_LENGTH);
+			*v_mag_x_s16 = (s16)
+			((((s32)((s8)v_data_u8[BMI160_MAG_X_MSB_BYTE]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS) |
+			(v_data_u8[BMI160_MAG_X_LSB_BYTE]));
+		break;
+		default:
+			com_rslt = E_BMI160_OUT_OF_RANGE;
+		break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads magnetometer data Y values
+ *	from the register 0x06 and 0x07
+ *	@brief The mag sensor data read form auxiliary mag
+ *
+ *  @param v_mag_y_s16 : The value of mag y
+ *  @param v_sensor_select_u8 : Mag selection value
+ *  value    |   sensor
+ *  ---------|----------------
+ *   0       | BMM150
+ *   1       | AKM09911 or AKM09912
+ *
+ *	@note For mag data output rate configuration use the following function
+ *	@note bmi160_set_mag_output_data_rate()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_y(s16 *v_mag_y_s16,
+u8 v_sensor_select_u8)
+{
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_OUT_OF_RANGE;
+	/* Array contains the mag Y lSB and MSB data
+		v_data_u8[0] - LSB
+		v_data_u8[1] - MSB*/
+	u8 v_data_u8[BMI160_MAG_Y_DATA_SIZE] = {BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE};
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		switch (v_sensor_select_u8) {
+		case BST_BMM:
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_DATA_MAG_Y_LSB__REG,
+			v_data_u8, BMI160_MAG_Y_DATA_LENGTH);
+			/*Y-axis lsb value shifting*/
+			v_data_u8[BMI160_MAG_Y_LSB_BYTE] =
+			BMI160_GET_BITSLICE(v_data_u8[BMI160_MAG_Y_LSB_BYTE],
+			BMI160_USER_DATA_MAG_Y_LSB);
+			*v_mag_y_s16 = (s16)
+			((((s32)((s8)v_data_u8[BMI160_MAG_Y_MSB_BYTE]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_05_BITS) |
+			(v_data_u8[BMI160_MAG_Y_LSB_BYTE]));
+		break;
+		case BST_AKM:
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_DATA_2_MAG_Y_LSB__REG,
+			v_data_u8, BMI160_MAG_Y_DATA_LENGTH);
+			*v_mag_y_s16 = (s16)
+			((((s32)((s8)v_data_u8[BMI160_MAG_Y_MSB_BYTE]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS) |
+			(v_data_u8[BMI160_MAG_Y_LSB_BYTE]));
+		break;
+		default:
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads magnetometer data Z values
+ *	from the register 0x08 and 0x09
+ *	@brief The mag sensor data read form auxiliary mag
+ *
+ *  @param v_mag_z_s16 : The value of mag z
+ *  @param v_sensor_select_u8 : Mag selection value
+ *  value    |   sensor
+ *  ---------|----------------
+ *   0       | BMM150
+ *   1       | AKM09911 or AKM09912
+ *
+ *	@note For mag data output rate configuration use the following function
+ *	@note bmi160_set_mag_output_data_rate()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_z(s16 *v_mag_z_s16,
+u8 v_sensor_select_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* Array contains the mag Z lSB and MSB data
+		v_data_u8[0] - LSB
+		v_data_u8[1] - MSB*/
+	u8 v_data_u8[BMI160_MAG_Z_DATA_SIZE] = {BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE};
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		switch (v_sensor_select_u8) {
+		case BST_BMM:
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_DATA_MAG_Z_LSB__REG,
+			v_data_u8, BMI160_MAG_Z_DATA_LENGTH);
+			/*Z-axis lsb value shifting*/
+			v_data_u8[BMI160_MAG_Z_LSB_BYTE] =
+			BMI160_GET_BITSLICE(v_data_u8[BMI160_MAG_Z_LSB_BYTE],
+			BMI160_USER_DATA_MAG_Z_LSB);
+			*v_mag_z_s16 = (s16)
+			((((s32)((s8)v_data_u8[BMI160_MAG_Z_MSB_BYTE]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_07_BITS) |
+			(v_data_u8[BMI160_MAG_Z_LSB_BYTE]));
+		break;
+		case BST_AKM:
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_DATA_4_MAG_Z_LSB__REG,
+			v_data_u8, BMI160_MAG_Z_DATA_LENGTH);
+			*v_mag_z_s16 = (s16)
+			((((s32)((s8)v_data_u8[BMI160_MAG_Z_MSB_BYTE]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS) | (
+			v_data_u8[BMI160_MAG_Z_LSB_BYTE]));
+		break;
+		default:
+			com_rslt = E_BMI160_OUT_OF_RANGE;
+		break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads magnetometer data RHALL values
+ *	from the register 0x0A and 0x0B
+ *
+ *
+ *  @param v_mag_r_s16 : The value of BMM150 r data
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_r(s16 *v_mag_r_s16)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* Array contains the mag R lSB and MSB data
+		v_data_u8[0] - LSB
+		v_data_u8[1] - MSB*/
+	u8 v_data_u8[BMI160_MAG_R_DATA_SIZE] = {BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE};
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_DATA_6_RHALL_LSB__REG,
+			v_data_u8, BMI160_MAG_R_DATA_LENGTH);
+			/*R-axis lsb value shifting*/
+			v_data_u8[BMI160_MAG_R_LSB_BYTE] =
+			BMI160_GET_BITSLICE(v_data_u8[BMI160_MAG_R_LSB_BYTE],
+			BMI160_USER_DATA_MAG_R_LSB);
+			*v_mag_r_s16 = (s16)
+			((((s32)((s8)v_data_u8[BMI160_MAG_R_MSB_BYTE]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_06_BITS) |
+			(v_data_u8[BMI160_MAG_R_LSB_BYTE]));
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads magnetometer data X,Y,Z values
+ *	from the register 0x04 to 0x09
+ *
+ *	@brief The mag sensor data read form auxiliary mag
+ *
+ *  @param mag : The value of mag xyz data
+ *  @param v_sensor_select_u8 : Mag selection value
+ *  value    |   sensor
+ *  ---------|----------------
+ *   0       | BMM150
+ *   1       | AKM09911 or AKM09912
+ *
+ *	@note For mag data output rate configuration use the following function
+ *	@note bmi160_set_mag_output_data_rate()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_xyz(
+struct bmi160_mag_t *mag, u8 v_sensor_select_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* Array contains the mag XYZ lSB and MSB data
+		v_data_u8[0] - X-LSB
+		v_data_u8[1] - X-MSB
+		v_data_u8[0] - Y-LSB
+		v_data_u8[1] - Y-MSB
+		v_data_u8[0] - Z-LSB
+		v_data_u8[1] - Z-MSB
+		*/
+	u8 v_data_u8[BMI160_MAG_XYZ_DATA_SIZE] = {
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE};
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		switch (v_sensor_select_u8) {
+		case BST_BMM:
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_DATA_MAG_X_LSB__REG,
+			v_data_u8, BMI160_MAG_XYZ_DATA_LENGTH);
+			/*X-axis lsb value shifting*/
+			v_data_u8[BMI160_DATA_FRAME_MAG_X_LSB_BYTE] =
+			BMI160_GET_BITSLICE(
+			v_data_u8[BMI160_DATA_FRAME_MAG_X_LSB_BYTE],
+			BMI160_USER_DATA_MAG_X_LSB);
+			/* Data X */
+			mag->x = (s16)
+			((((s32)((s8)v_data_u8[
+			BMI160_DATA_FRAME_MAG_X_MSB_BYTE]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_05_BITS) |
+			(v_data_u8[BMI160_DATA_FRAME_MAG_X_LSB_BYTE]));
+			/* Data Y */
+			/*Y-axis lsb value shifting*/
+			v_data_u8[BMI160_DATA_FRAME_MAG_Y_LSB_BYTE] =
+			BMI160_GET_BITSLICE(
+			v_data_u8[BMI160_DATA_FRAME_MAG_Y_LSB_BYTE],
+			BMI160_USER_DATA_MAG_Y_LSB);
+			mag->y = (s16)
+			((((s32)((s8)v_data_u8[
+			BMI160_DATA_FRAME_MAG_Y_MSB_BYTE]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_05_BITS) |
+			(v_data_u8[BMI160_DATA_FRAME_MAG_Y_LSB_BYTE]));
+
+			/* Data Z */
+			/*Z-axis lsb value shifting*/
+			v_data_u8[BMI160_DATA_FRAME_MAG_Z_LSB_BYTE]
+			= BMI160_GET_BITSLICE(
+			v_data_u8[BMI160_DATA_FRAME_MAG_Z_LSB_BYTE],
+			BMI160_USER_DATA_MAG_Z_LSB);
+			mag->z = (s16)
+			((((s32)((s8)v_data_u8[
+			BMI160_DATA_FRAME_MAG_Z_MSB_BYTE]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_07_BITS) |
+			(v_data_u8[BMI160_DATA_FRAME_MAG_Z_LSB_BYTE]));
+		break;
+		case BST_AKM:
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_DATA_0_MAG_X_LSB__REG,
+			v_data_u8, BMI160_MAG_XYZ_DATA_LENGTH);
+			/* Data X */
+			mag->x = (s16)
+			((((s32)((s8)v_data_u8[
+			BMI160_DATA_FRAME_MAG_X_MSB_BYTE]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS) |
+			(v_data_u8[BMI160_DATA_FRAME_MAG_X_LSB_BYTE]));
+			/* Data Y */
+			mag->y  = ((((s32)((s8)v_data_u8[
+			BMI160_DATA_FRAME_MAG_Y_MSB_BYTE]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS) |
+			(v_data_u8[BMI160_DATA_FRAME_MAG_Y_LSB_BYTE]));
+			/* Data Z */
+			mag->z = (s16)
+			((((s32)((s8)v_data_u8[
+			BMI160_DATA_FRAME_MAG_Z_MSB_BYTE]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS) |
+			(v_data_u8[BMI160_DATA_FRAME_MAG_Z_LSB_BYTE]));
+		break;
+		default:
+			com_rslt = E_BMI160_OUT_OF_RANGE;
+		break;
+		}
+	}
+	return com_rslt;
+}
+ /*!*
+ *	@brief This API reads magnetometer data X,Y,Z,r
+ *	values from the register 0x04 to 0x0B
+ *
+ *	@brief The mag sensor data read form auxiliary mag
+ *
+ *  @param mag : The value of mag-BMM150 xyzr data
+ *
+ *	@note For mag data output rate configuration use the following function
+ *	@note bmi160_set_mag_output_data_rate()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_xyzr(
+struct bmi160_mag_xyzr_t *mag)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8[BMI160_MAG_XYZR_DATA_SIZE] = {
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE};
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_DATA_MAG_X_LSB__REG,
+			v_data_u8, BMI160_MAG_XYZR_DATA_LENGTH);
+
+			/* Data X */
+			/*X-axis lsb value shifting*/
+			v_data_u8[BMI160_DATA_FRAME_MAG_X_LSB_BYTE]
+			= BMI160_GET_BITSLICE(
+			v_data_u8[BMI160_DATA_FRAME_MAG_X_LSB_BYTE],
+			BMI160_USER_DATA_MAG_X_LSB);
+			mag->x = (s16)
+			((((s32)((s8)v_data_u8[
+			BMI160_DATA_FRAME_MAG_X_MSB_BYTE]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_05_BITS)
+			| (v_data_u8[BMI160_DATA_FRAME_MAG_X_LSB_BYTE]));
+			/* Data Y */
+			/*Y-axis lsb value shifting*/
+			v_data_u8[BMI160_DATA_FRAME_MAG_Y_LSB_BYTE]
+			= BMI160_GET_BITSLICE(
+			v_data_u8[BMI160_DATA_FRAME_MAG_Y_LSB_BYTE],
+			BMI160_USER_DATA_MAG_Y_LSB);
+			mag->y = (s16)
+			((((s32)((s8)v_data_u8[
+			BMI160_DATA_FRAME_MAG_Y_MSB_BYTE]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_05_BITS)
+			| (v_data_u8[
+			BMI160_DATA_FRAME_MAG_Y_LSB_BYTE]));
+
+			/* Data Z */
+			/*Z-axis lsb value shifting*/
+			v_data_u8[BMI160_DATA_FRAME_MAG_Z_LSB_BYTE]
+			= BMI160_GET_BITSLICE(
+			v_data_u8[BMI160_DATA_FRAME_MAG_Z_LSB_BYTE],
+			BMI160_USER_DATA_MAG_Z_LSB);
+			mag->z = (s16)
+			((((s32)((s8)v_data_u8[
+			BMI160_DATA_FRAME_MAG_Z_MSB_BYTE]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_07_BITS)
+			| (v_data_u8[BMI160_DATA_FRAME_MAG_Z_LSB_BYTE]));
+
+			/* RHall */
+			/*R-axis lsb value shifting*/
+			v_data_u8[BMI160_DATA_FRAME_MAG_R_LSB_BYTE]
+			= BMI160_GET_BITSLICE(
+			v_data_u8[BMI160_DATA_FRAME_MAG_R_LSB_BYTE],
+			BMI160_USER_DATA_MAG_R_LSB);
+			mag->r = (s16)
+			((((s32)((s8)v_data_u8[
+			BMI160_DATA_FRAME_MAG_R_MSB_BYTE]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_06_BITS)
+			| (v_data_u8[BMI160_DATA_FRAME_MAG_R_LSB_BYTE]));
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads gyro data X values
+ *	form the register 0x0C and 0x0D
+ *
+ *
+ *
+ *
+ *  @param v_gyro_x_s16 : The value of gyro x data
+ *
+ *	@note Gyro Configuration use the following function
+ *	@note bmi160_set_gyro_output_data_rate()
+ *	@note bmi160_set_gyro_bw()
+ *	@note bmi160_set_gyro_range()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_gyro_x(s16 *v_gyro_x_s16)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* Array contains the gyro X lSB and MSB data
+		v_data_u8[0] - LSB
+		v_data_u8[MSB_ONE] - MSB*/
+	u8 v_data_u8[BMI160_GYRO_X_DATA_SIZE] = {BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE};
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_DATA_8_GYRO_X_LSB__REG,
+			v_data_u8, BMI160_GYRO_DATA_LENGTH);
+
+			*v_gyro_x_s16 = (s16)
+			((((s32)((s8)v_data_u8[BMI160_GYRO_X_MSB_BYTE]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
+			| (v_data_u8[BMI160_GYRO_X_LSB_BYTE]));
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads gyro data Y values
+ *	form the register 0x0E and 0x0F
+ *
+ *
+ *
+ *
+ *  @param v_gyro_y_s16 : The value of gyro y data
+ *
+ *	@note Gyro Configuration use the following function
+ *	@note bmi160_set_gyro_output_data_rate()
+ *	@note bmi160_set_gyro_bw()
+ *	@note bmi160_set_gyro_range()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error result of communication routines
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_gyro_y(s16 *v_gyro_y_s16)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* Array contains the gyro Y lSB and MSB data
+		v_data_u8[LSB_ZERO] - LSB
+		v_data_u8[MSB_ONE] - MSB*/
+	u8 v_data_u8[BMI160_GYRO_Y_DATA_SIZE] = {BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE};
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read gyro y data*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_DATA_10_GYRO_Y_LSB__REG,
+			v_data_u8, BMI160_GYRO_DATA_LENGTH);
+
+			*v_gyro_y_s16 = (s16)
+			((((s32)((s8)v_data_u8[BMI160_GYRO_Y_MSB_BYTE]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
+			| (v_data_u8[BMI160_GYRO_Y_LSB_BYTE]));
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads gyro data Z values
+ *	form the register 0x10 and 0x11
+ *
+ *
+ *
+ *
+ *  @param v_gyro_z_s16 : The value of gyro z data
+ *
+ *	@note Gyro Configuration use the following function
+ *	@note bmi160_set_gyro_output_data_rate()
+ *	@note bmi160_set_gyro_bw()
+ *	@note bmi160_set_gyro_range()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_gyro_z(s16 *v_gyro_z_s16)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* Array contains the gyro Z lSB and MSB data
+		v_data_u8[LSB_ZERO] - LSB
+		v_data_u8[MSB_ONE] - MSB*/
+	u8 v_data_u8[BMI160_GYRO_Z_DATA_SIZE] = {BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE};
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read gyro z data */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_DATA_12_GYRO_Z_LSB__REG,
+			v_data_u8, BMI160_GYRO_DATA_LENGTH);
+
+			*v_gyro_z_s16 = (s16)
+			((((s32)((s8)v_data_u8[BMI160_GYRO_Z_MSB_BYTE]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
+			| (v_data_u8[BMI160_GYRO_Z_LSB_BYTE]));
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads gyro data X,Y,Z values
+ *	from the register 0x0C to 0x11
+ *
+ *
+ *
+ *
+ *  @param gyro : The value of gyro xyz
+ *
+ *	@note Gyro Configuration use the following function
+ *	@note bmi160_set_gyro_output_data_rate()
+ *	@note bmi160_set_gyro_bw()
+ *	@note bmi160_set_gyro_range()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_gyro_xyz(struct bmi160_gyro_t *gyro)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* Array contains the mag XYZ lSB and MSB data
+		v_data_u8[0] - X-LSB
+		v_data_u8[1] - X-MSB
+		v_data_u8[0] - Y-LSB
+		v_data_u8[1] - Y-MSB
+		v_data_u8[0] - Z-LSB
+		v_data_u8[1] - Z-MSB
+		*/
+	u8 v_data_u8[BMI160_GYRO_XYZ_DATA_SIZE] = {
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE};
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the gyro xyz data*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_DATA_8_GYRO_X_LSB__REG,
+			v_data_u8, BMI160_GYRO_XYZ_DATA_LENGTH);
+
+			/* Data X */
+			gyro->x = (s16)
+			((((s32)((s8)v_data_u8[
+			BMI160_DATA_FRAME_GYRO_X_MSB_BYTE]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
+			| (v_data_u8[BMI160_DATA_FRAME_GYRO_X_LSB_BYTE]));
+			/* Data Y */
+			gyro->y = (s16)
+			((((s32)((s8)v_data_u8[
+			BMI160_DATA_FRAME_GYRO_Y_MSB_BYTE]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
+			| (v_data_u8[BMI160_DATA_FRAME_GYRO_Y_LSB_BYTE]));
+
+			/* Data Z */
+			gyro->z = (s16)
+			((((s32)((s8)v_data_u8[
+			BMI160_DATA_FRAME_GYRO_Z_MSB_BYTE]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
+			| (v_data_u8[BMI160_DATA_FRAME_GYRO_Z_LSB_BYTE]));
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads accelerometer data X values
+ *	form the register 0x12 and 0x13
+ *
+ *
+ *
+ *
+ *  @param v_accel_x_s16 : The value of accel x
+ *
+ *	@note For accel configuration use the following functions
+ *	@note bmi160_set_accel_output_data_rate()
+ *	@note bmi160_set_accel_bw()
+ *	@note bmi160_set_accel_under_sampling_parameter()
+ *	@note bmi160_set_accel_range()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_accel_x(s16 *v_accel_x_s16)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* Array contains the accel X lSB and MSB data
+		v_data_u8[0] - LSB
+		v_data_u8[1] - MSB*/
+	u8 v_data_u8[BMI160_ACCEL_X_DATA_SIZE] = {BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE};
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_DATA_14_ACCEL_X_LSB__REG,
+			v_data_u8, BMI160_ACCEL_DATA_LENGTH);
+
+			*v_accel_x_s16 = (s16)
+			((((s32)((s8)v_data_u8[BMI160_ACCEL_X_MSB_BYTE]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
+			| (v_data_u8[BMI160_ACCEL_X_LSB_BYTE]));
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads accelerometer data Y values
+ *	form the register 0x14 and 0x15
+ *
+ *
+ *
+ *
+ *  @param v_accel_y_s16 : The value of accel y
+ *
+ *	@note For accel configuration use the following functions
+ *	@note bmi160_set_accel_output_data_rate()
+ *	@note bmi160_set_accel_bw()
+ *	@note bmi160_set_accel_under_sampling_parameter()
+ *	@note bmi160_set_accel_range()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_accel_y(s16 *v_accel_y_s16)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* Array contains the accel Y lSB and MSB data
+		v_data_u8[0] - LSB
+		v_data_u8[1] - MSB*/
+	u8 v_data_u8[BMI160_ACCEL_Y_DATA_SIZE] = {BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE};
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_DATA_16_ACCEL_Y_LSB__REG,
+			v_data_u8, BMI160_ACCEL_DATA_LENGTH);
+
+			*v_accel_y_s16 = (s16)
+			((((s32)((s8)v_data_u8[BMI160_ACCEL_Y_MSB_BYTE]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
+			| (v_data_u8[BMI160_ACCEL_Y_LSB_BYTE]));
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads accelerometer data Z values
+ *	form the register 0x16 and 0x17
+ *
+ *
+ *
+ *
+ *  @param v_accel_z_s16 : The value of accel z
+ *
+ *	@note For accel configuration use the following functions
+ *	@note bmi160_set_accel_output_data_rate()
+ *	@note bmi160_set_accel_bw()
+ *	@note bmi160_set_accel_under_sampling_parameter()
+ *	@note bmi160_set_accel_range()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_accel_z(s16 *v_accel_z_s16)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* Array contains the accel Z lSB and MSB data
+		a_data_u8r[LSB_ZERO] - LSB
+		a_data_u8r[MSB_ONE] - MSB*/
+	u8 a_data_u8r[BMI160_ACCEL_Z_DATA_SIZE] = {
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE};
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_DATA_18_ACCEL_Z_LSB__REG,
+			a_data_u8r, BMI160_ACCEL_DATA_LENGTH);
+
+			*v_accel_z_s16 = (s16)
+			((((s32)((s8)a_data_u8r[BMI160_ACCEL_Z_MSB_BYTE]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
+			| (a_data_u8r[BMI160_ACCEL_Z_LSB_BYTE]));
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads accelerometer data X,Y,Z values
+ *	from the register 0x12 to 0x17
+ *
+ *
+ *
+ *
+ *  @param accel :The value of accel xyz
+ *
+ *	@note For accel configuration use the following functions
+ *	@note bmi160_set_accel_output_data_rate()
+ *	@note bmi160_set_accel_bw()
+ *	@note bmi160_set_accel_under_sampling_parameter()
+ *	@note bmi160_set_accel_range()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_accel_xyz(
+struct bmi160_accel_t *accel)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* Array contains the accel XYZ lSB and MSB data
+	a_data_u8r[0] - X-LSB
+	a_data_u8r[1] - X-MSB
+	a_data_u8r[0] - Y-LSB
+	a_data_u8r[1] - Y-MSB
+	a_data_u8r[0] - Z-LSB
+	a_data_u8r[1] - Z-MSB
+	*/
+	u8 a_data_u8r[BMI160_ACCEL_XYZ_DATA_SIZE] = {
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE};
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_DATA_14_ACCEL_X_LSB__REG,
+			a_data_u8r, BMI160_ACCEL_XYZ_DATA_LENGTH);
+
+			/* Data X */
+			accel->x = (s16)
+			((((s32)((s8)a_data_u8r[
+			BMI160_DATA_FRAME_ACCEL_X_MSB_BYTE]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
+			| (a_data_u8r[BMI160_DATA_FRAME_ACCEL_X_LSB_BYTE]));
+			/* Data Y */
+			accel->y = (s16)
+			((((s32)((s8)a_data_u8r[
+			BMI160_DATA_FRAME_ACCEL_Y_MSB_BYTE]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
+			| (a_data_u8r[BMI160_DATA_FRAME_ACCEL_Y_LSB_BYTE]));
+
+			/* Data Z */
+			accel->z = (s16)
+			((((s32)((s8)a_data_u8r[
+			BMI160_DATA_FRAME_ACCEL_Z_MSB_BYTE]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
+			| (a_data_u8r[BMI160_DATA_FRAME_ACCEL_Z_LSB_BYTE]));
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads sensor_time from the register
+ *	0x18 to 0x1A
+ *
+ *
+ *  @param v_sensor_time_u32 : The value of sensor time
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_sensor_time(u32 *v_sensor_time_u32)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* Array contains the sensor time it is 32 bit data
+	a_data_u8r[0] - sensor time
+	a_data_u8r[1] - sensor time
+	a_data_u8r[0] - sensor time
+	*/
+	u8 a_data_u8r[BMI160_SENSOR_TIME_DATA_SIZE] = {BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE};
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_SENSORTIME_0_SENSOR_TIME_LSB__REG,
+			a_data_u8r, BMI160_SENSOR_TIME_LENGTH);
+
+			*v_sensor_time_u32 = (u32)
+			((((u32)a_data_u8r[BMI160_SENSOR_TIME_MSB_BYTE])
+			<< BMI160_SHIFT_BIT_POSITION_BY_16_BITS)
+			|(((u32)a_data_u8r[BMI160_SENSOR_TIME_XLSB_BYTE])
+			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
+			| (a_data_u8r[BMI160_SENSOR_TIME_LSB_BYTE]));
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the Gyroscope self test
+ *	status from the register 0x1B bit 1
+ *
+ *
+ *  @param v_gyro_selftest_u8 : The value of gyro self test status
+ *  value    |   status
+ *  ---------|----------------
+ *   0       | Gyroscope self test is running or failed
+ *   1       | Gyroscope self test completed successfully
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_selftest(u8
+*v_gyro_selftest_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_STAT_GYRO_SELFTEST_OK__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_gyro_selftest_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_STAT_GYRO_SELFTEST_OK);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the status of
+ *	mag manual interface operation form the register 0x1B bit 2
+ *
+ *
+ *
+ *  @param v_mag_manual_stat_u8 : The value of mag manual operation status
+ *  value    |   status
+ *  ---------|----------------
+ *   0       | Indicates no manual magnetometer
+ *   -       | interface operation is ongoing
+ *   1       | Indicates manual magnetometer
+ *   -       | interface operation is ongoing
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_manual_operation_stat(u8
+*v_mag_manual_stat_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read manual operation*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_STAT_MAG_MANUAL_OPERATION__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_mag_manual_stat_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_STAT_MAG_MANUAL_OPERATION);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the fast offset compensation
+ *	status form the register 0x1B bit 3
+ *
+ *
+ *  @param v_foc_rdy_u8 : The status of fast compensation
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_foc_rdy(u8
+*v_foc_rdy_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the FOC status*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_STAT_FOC_RDY__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_foc_rdy_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_STAT_FOC_RDY);
+		}
+	return com_rslt;
+}
+/*!
+ * @brief This API Reads the nvm_rdy status from the
+ *	resister 0x1B bit 4
+ *
+ *
+ *  @param v_nvm_rdy_u8 : The value of NVM ready status
+ *  value    |   status
+ *  ---------|----------------
+ *   0       | NVM write operation in progress
+ *   1       | NVM is ready to accept a new write trigger
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_nvm_rdy(u8
+*v_nvm_rdy_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the nvm ready status*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_STAT_NVM_RDY__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_nvm_rdy_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_STAT_NVM_RDY);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the status of mag data ready
+ *	from the register 0x1B bit 5
+ *	The status get reset when one mag data register is read out
+ *
+ *  @param v_data_rdy_u8 : The value of mag data ready status
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_data_rdy_mag(u8
+*v_data_rdy_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_STAT_DATA_RDY_MAG__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_data_rdy_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_STAT_DATA_RDY_MAG);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the status of gyro data ready form the
+ *	register 0x1B bit 6
+ *	The status get reset when gyro data register read out
+ *
+ *
+ *	@param v_data_rdy_u8 :	The value of gyro data ready
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_data_rdy(u8
+*v_data_rdy_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_STAT_DATA_RDY_GYRO__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_data_rdy_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_STAT_DATA_RDY_GYRO);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the status of accel data ready form the
+ *	register 0x1B bit 7
+ *	The status get reset when accel data register read out
+ *
+ *
+ *	@param v_data_rdy_u8 :	The value of accel data ready status
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_data_rdy(u8
+*v_data_rdy_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/*reads the status of accel data ready*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_STAT_DATA_RDY_ACCEL__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_data_rdy_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_STAT_DATA_RDY_ACCEL);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the step detector interrupt status
+ *	from the register 0x1C bit 0
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the single tab interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt
+ *	signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_step_intr_u8 : The status of step detector interrupt
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_step_intr(u8
+*v_step_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_INTR_STAT_0_STEP_INTR__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_step_intr_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_STAT_0_STEP_INTR);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the
+ *	significant motion interrupt status
+ *	from the register 0x1C bit 1
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the single tab interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt
+ *	signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *
+ *  @param v_significant_intr_u8 : The status of step
+ *	motion interrupt
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_significant_intr(u8
+*v_significant_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_INTR_STAT_0_SIGNIFICANT_INTR__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_significant_intr_u8  = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_STAT_0_SIGNIFICANT_INTR);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API reads the any motion interrupt status
+ *	from the register 0x1C bit 2
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the single tab interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt
+ *	signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *  @param v_any_motion_intr_u8 : The status of any-motion interrupt
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_any_motion_intr(u8
+*v_any_motion_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_INTR_STAT_0_ANY_MOTION__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_any_motion_intr_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_STAT_0_ANY_MOTION);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the power mode trigger interrupt status
+ *	from the register 0x1C bit 3
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the single tab interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt
+ *	signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *
+ *  @param v_pmu_trigger_intr_u8 : The status of power mode trigger interrupt
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_pmu_trigger_intr(u8
+*v_pmu_trigger_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_INTR_STAT_0_PMU_TRIGGER__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_pmu_trigger_intr_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_STAT_0_PMU_TRIGGER);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the double tab status
+ *	from the register 0x1C bit 4
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the single tab interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt
+ *	signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_double_tap_intr_u8 :The status of double tab interrupt
+ *
+ *	@note Double tap interrupt can be configured by the following functions
+ *	@note INTERRUPT MAPPING
+ *	@note bmi160_set_intr_double_tap()
+ *	@note AXIS MAPPING
+ *	@note bmi160_get_stat2_tap_first_x()
+ *	@note bmi160_get_stat2_tap_first_y()
+ *	@note bmi160_get_stat2_tap_first_z()
+ *	@note DURATION
+ *	@note bmi160_set_intr_tap_durn()
+ *	@note THRESHOLD
+ *	@note bmi160_set_intr_tap_thres()
+ *	@note TAP QUIET
+ *	@note bmi160_set_intr_tap_quiet()
+ *	@note TAP SHOCK
+ *	@note bmi160_set_intr_tap_shock()
+ *	@note TAP SOURCE
+ *	@note bmi160_set_intr_tap_source()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_double_tap_intr(u8
+*v_double_tap_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_INTR_STAT_0_DOUBLE_TAP_INTR__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_double_tap_intr_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_STAT_0_DOUBLE_TAP_INTR);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the single tab status
+ *	from the register 0x1C bit 5
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the single tab interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt
+ *	signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_single_tap_intr_u8 :The status of single tap interrupt
+ *
+ *	@note Single tap interrupt can be configured by the following functions
+ *	@note INTERRUPT MAPPING
+ *	@note bmi160_set_intr_single_tap()
+ *	@note AXIS MAPPING
+ *	@note bmi160_get_stat2_tap_first_x()
+ *	@note bmi160_get_stat2_tap_first_y()
+ *	@note bmi160_get_stat2_tap_first_z()
+ *	@note DURATION
+ *	@note bmi160_set_intr_tap_durn()
+ *	@note THRESHOLD
+ *	@note bmi160_set_intr_tap_thres()
+ *	@note TAP QUIET
+ *	@note bmi160_set_intr_tap_quiet()
+ *	@note TAP SHOCK
+ *	@note bmi160_set_intr_tap_shock()
+ *	@note TAP SOURCE
+ *	@note bmi160_set_intr_tap_source()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_single_tap_intr(u8
+*v_single_tap_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_INTR_STAT_0_SINGLE_TAP_INTR__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_single_tap_intr_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_STAT_0_SINGLE_TAP_INTR);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the orient status
+ *	from the register 0x1C bit 6
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the orient interrupt triggers. The
+ *	setting of INT_LATCH controls if the
+ *	interrupt signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_orient_intr_u8 : The status of orient interrupt
+ *
+ *	@note For orient interrupt configuration use the following functions
+ *	@note STATUS
+ *	@note bmi160_get_stat0_orient_intr()
+ *	@note AXIS MAPPING
+ *	@note bmi160_get_stat3_orient_xy()
+ *	@note bmi160_get_stat3_orient_z()
+ *	@note bmi160_set_intr_orient_axes_enable()
+ *	@note INTERRUPT MAPPING
+ *	@note bmi160_set_intr_orient()
+ *	@note INTERRUPT OUTPUT
+ *	@note bmi160_set_intr_orient_ud_enable()
+ *	@note THETA
+ *	@note bmi160_set_intr_orient_theta()
+ *	@note HYSTERESIS
+ *	@note bmi160_set_intr_orient_hyst()
+ *	@note BLOCKING
+ *	@note bmi160_set_intr_orient_blocking()
+ *	@note MODE
+ *	@note bmi160_set_intr_orient_mode()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_orient_intr(u8
+*v_orient_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_INTR_STAT_0_ORIENT__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_orient_intr_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_STAT_0_ORIENT);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the flat interrupt status
+ *	from the register 0x1C bit 7
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the flat interrupt triggers. The
+ *	setting of INT_LATCH controls if the
+ *	interrupt signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_flat_intr_u8 : The status of  flat interrupt
+ *
+ *	@note For flat configuration use the following functions
+ *	@note STATS
+ *	@note bmi160_get_stat0_flat_intr()
+ *	@note bmi160_get_stat3_flat()
+ *	@note INTERRUPT MAPPING
+ *	@note bmi160_set_intr_flat()
+ *	@note THETA
+ *	@note bmi160_set_intr_flat_theta()
+ *	@note HOLD TIME
+ *	@note bmi160_set_intr_flat_hold()
+ *	@note HYSTERESIS
+ *	@note bmi160_set_intr_flat_hyst()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_flat_intr(u8
+*v_flat_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_INTR_STAT_0_FLAT__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_flat_intr_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_STAT_0_FLAT);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the high_g interrupt status
+ *	from the register 0x1D bit 2
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the high g  interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt signal and hence the
+ *	respective interrupt flag will be permanently
+ *	latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_high_g_intr_u8 : The status of high_g interrupt
+ *
+ *	@note High_g interrupt configured by following functions
+ *	@note STATUS
+ *	@note bmi160_get_stat1_high_g_intr()
+ *	@note AXIS MAPPING
+ *	@note bmi160_get_stat3_high_g_first_x()
+ *	@note bmi160_get_stat3_high_g_first_y()
+ *	@note bmi160_get_stat3_high_g_first_z()
+ *	@note SIGN MAPPING
+ *	@note bmi160_get_stat3_high_g_first_sign()
+ *	@note INTERRUPT MAPPING
+ *	@note bmi160_set_intr_high_g()
+  *	@note HYSTERESIS
+ *	@note bmi160_set_intr_high_g_hyst()
+ *	@note DURATION
+ *	@note bmi160_set_intr_high_g_durn()
+ *	@note THRESHOLD
+ *	@note bmi160_set_intr_high_g_thres()
+ *	@note SOURCE
+ *	@note bmi160_set_intr_low_high_source()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat1_high_g_intr(u8
+*v_high_g_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_INTR_STAT_1_HIGH_G_INTR__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_high_g_intr_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_STAT_1_HIGH_G_INTR);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the low g interrupt status
+ *	from the register 0x1D bit 3
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the low g  interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_low_g_intr_u8 : The status of low_g interrupt
+ *
+ *	@note Low_g interrupt configured by following functions
+ *	@note STATUS
+ *	@note bmi160_get_stat1_low_g_intr()
+ *	@note INTERRUPT MAPPING
+ *	@note bmi160_set_intr_low_g()
+ *	@note SOURCE
+ *	@note bmi160_set_intr_low_high_source()
+ *	@note DURATION
+ *	@note bmi160_set_intr_low_g_durn()
+ *	@note THRESHOLD
+ *	@note bmi160_set_intr_low_g_thres()
+ *	@note HYSTERESIS
+ *	@note bmi160_set_intr_low_g_hyst()
+ *	@note MODE
+ *	@note bmi160_set_intr_low_g_mode()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat1_low_g_intr(u8
+*v_low_g_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_INTR_STAT_1_LOW_G_INTR__REG, &v_data_u8,
+			 BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_low_g_intr_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_STAT_1_LOW_G_INTR);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads data ready interrupt status
+ *	from the register 0x1D bit 4
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the  data ready  interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_data_rdy_intr_u8 : The status of data ready interrupt
+ *
+ *	@note Data ready interrupt configured by following functions
+ *	@note STATUS
+ *	@note bmi160_get_stat1_data_rdy_intr()
+ *	@note INTERRUPT MAPPING
+ *	@note bmi160_set_intr_data_rdy()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat1_data_rdy_intr(u8
+*v_data_rdy_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_INTR_STAT_1_DATA_RDY_INTR__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_data_rdy_intr_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_STAT_1_DATA_RDY_INTR);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads data ready FIFO full interrupt status
+ *	from the register 0x1D bit 5
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the FIFO full interrupt triggers. The
+ *	setting of INT_LATCH controls if the
+ *	interrupt signal and hence the
+ *	respective interrupt flag will
+ *	be permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_fifo_full_intr_u8 : The status of fifo full interrupt
+ *
+ *	@note FIFO full interrupt can be configured by following functions
+ *	@note bmi160_set_intr_fifo_full()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat1_fifo_full_intr(u8
+*v_fifo_full_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_INTR_STAT_1_FIFO_FULL_INTR__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_fifo_full_intr_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_STAT_1_FIFO_FULL_INTR);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads data
+ *	 ready FIFO watermark interrupt status
+ *	from the register 0x1D bit 6
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the FIFO watermark interrupt triggers. The
+ *	setting of INT_LATCH controls if the
+ *	interrupt signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_fifo_wm_intr_u8 : The status of fifo water mark interrupt
+ *
+ *	@note FIFO full interrupt can be configured by following functions
+ *	@note bmi160_set_intr_fifo_wm()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat1_fifo_wm_intr(u8
+*v_fifo_wm_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_INTR_STAT_1_FIFO_WM_INTR__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_fifo_wm_intr_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_STAT_1_FIFO_WM_INTR);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads data ready no motion interrupt status
+ *	from the register 0x1D bit 7
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the no motion  interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt signal and hence the
+ *	respective interrupt flag will be permanently
+ *	latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_nomotion_intr_u8 : The status of no motion interrupt
+ *
+ *	@note No motion interrupt can be configured by following function
+ *	@note STATUS
+ *	@note bmi160_get_stat1_nomotion_intr()
+ *	@note INTERRUPT MAPPING
+ *	@note bmi160_set_intr_nomotion()
+ *	@note DURATION
+ *	@note bmi160_set_intr_slow_no_motion_durn()
+ *	@note THRESHOLD
+ *	@note bmi160_set_intr_slow_no_motion_thres()
+ *	@note SLOW/NO MOTION SELECT
+ *	@note bmi160_set_intr_slow_no_motion_select()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat1_nomotion_intr(u8
+*v_nomotion_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the no motion interrupt*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_INTR_STAT_1_NOMOTION_INTR__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_nomotion_intr_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_STAT_1_NOMOTION_INTR);
+		}
+	return com_rslt;
+}
+/*!
+ *@brief This API reads the status of any motion first x
+ *	from the register 0x1E bit 0
+ *
+ *
+ *@param v_anymotion_first_x_u8 : The status of any motion first x interrupt
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by x axis
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_any_motion_first_x(u8
+*v_anymotion_first_x_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the any motion first x interrupt*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_X__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_anymotion_first_x_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_X);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the status of any motion first y interrupt
+ *	from the register 0x1E bit 1
+ *
+ *
+ *
+ *@param v_any_motion_first_y_u8 : The status of any motion first y interrupt
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by y axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_any_motion_first_y(u8
+*v_any_motion_first_y_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the any motion first y interrupt*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Y__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_any_motion_first_y_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Y);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the status of any motion first z interrupt
+ *	from the register 0x1E bit 2
+ *
+ *
+ *
+ *
+ *@param v_any_motion_first_z_u8 : The status of any motion first z interrupt
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by y axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_any_motion_first_z(u8
+*v_any_motion_first_z_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the any motion first z interrupt*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Z__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_any_motion_first_z_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Z);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the any motion sign status from the
+ *	register 0x1E bit 3
+ *
+ *
+ *
+ *
+ *  @param v_anymotion_sign_u8 : The status of any motion sign
+ *  value     |  sign
+ * -----------|-------------
+ *   0        | positive
+ *   1        | negative
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_any_motion_sign(u8
+*v_anymotion_sign_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read any motion sign interrupt status */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_INTR_STAT_2_ANY_MOTION_SIGN__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_anymotion_sign_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_STAT_2_ANY_MOTION_SIGN);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the any motion tap first x status from the
+ *	register 0x1E bit 4
+ *
+ *
+ *
+ *
+ *  @param v_tap_first_x_u8 :The status of any motion tap first x
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by x axis
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_tap_first_x(u8
+*v_tap_first_x_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read tap first x interrupt status */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_INTR_STAT_2_TAP_FIRST_X__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_tap_first_x_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_STAT_2_TAP_FIRST_X);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the tap first y interrupt status from the
+ *	register 0x1E bit 5
+ *
+ *
+ *
+ *
+ *  @param v_tap_first_y_u8 :The status of tap first y interrupt
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by y axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_tap_first_y(u8
+*v_tap_first_y_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read tap first y interrupt status */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_INTR_STAT_2_TAP_FIRST_Y__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_tap_first_y_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_STAT_2_TAP_FIRST_Y);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the tap first z interrupt status  from the
+ *	register 0x1E bit 6
+ *
+ *
+ *
+ *
+ *  @param v_tap_first_z_u8 :The status of tap first z interrupt
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by z axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_tap_first_z(u8
+*v_tap_first_z_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read tap first z interrupt status */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_INTR_STAT_2_TAP_FIRST_Z__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_tap_first_z_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_STAT_2_TAP_FIRST_Z);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the tap sign status from the
+ *	register 0x1E bit 7
+ *
+ *
+ *
+ *
+ *  @param v_tap_sign_u8 : The status of tap sign
+ *  value     |  sign
+ * -----------|-------------
+ *   0        | positive
+ *   1        | negative
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_tap_sign(u8
+*v_tap_sign_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read tap_sign interrupt status */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_INTR_STAT_2_TAP_SIGN__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_tap_sign_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_STAT_2_TAP_SIGN);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the high_g first x status from the
+ *	register 0x1F bit 0
+ *
+ *
+ *
+ *
+ *  @param v_high_g_first_x_u8 :The status of high_g first x
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by x axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_high_g_first_x(u8
+*v_high_g_first_x_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read highg_x interrupt status */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_X__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_high_g_first_x_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_X);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the high_g first y status from the
+ *	register 0x1F bit 1
+ *
+ *
+ *
+ *
+ *  @param v_high_g_first_y_u8 : The status of high_g first y
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by y axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_high_g_first_y(u8
+*v_high_g_first_y_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read highg_y interrupt status */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Y__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_high_g_first_y_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Y);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the high_g first z status from the
+ *	register 0x1F bit 3
+ *
+ *
+ *
+ *
+ *  @param v_high_g_first_z_u8 : The status of high_g first z
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by z axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_high_g_first_z(u8
+*v_high_g_first_z_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read highg_z interrupt status */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Z__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_high_g_first_z_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Z);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the high sign status from the
+ *	register 0x1F bit 3
+ *
+ *
+ *
+ *
+ *  @param v_high_g_sign_u8 :The status of high sign
+ *  value     |  sign
+ * -----------|-------------
+ *   0        | positive
+ *   1        | negative
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_high_g_sign(u8
+*v_high_g_sign_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read highg_sign interrupt status */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_INTR_STAT_3_HIGH_G_SIGN__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_high_g_sign_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_STAT_3_HIGH_G_SIGN);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the status of orient_xy plane
+ *	from the register 0x1F bit 4 and 5
+ *
+ *
+ *  @param v_orient_xy_u8 :The status of orient_xy plane
+ *  value     |  status
+ * -----------|-------------
+ *   0x00     | portrait upright
+ *   0x01     | portrait upside down
+ *   0x02     | landscape left
+ *   0x03     | landscape right
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_orient_xy(u8
+*v_orient_xy_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read orient plane xy interrupt status */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_INTR_STAT_3_ORIENT_XY__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_orient_xy_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_STAT_3_ORIENT_XY);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the status of orient z plane
+ *	from the register 0x1F bit 6
+ *
+ *
+ *  @param v_orient_z_u8 :The status of orient z
+ *  value     |  status
+ * -----------|-------------
+ *   0x00     | upward looking
+ *   0x01     | downward looking
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_orient_z(u8
+*v_orient_z_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read orient z plane interrupt status */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_INTR_STAT_3_ORIENT_Z__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_orient_z_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_STAT_3_ORIENT_Z);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the flat status from the register
+ *	0x1F bit 7
+ *
+ *
+ *  @param v_flat_u8 : The status of flat interrupt
+ *  value     |  status
+ * -----------|-------------
+ *   0x00     | non flat
+ *   0x01     | flat position
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_flat(u8
+*v_flat_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read flat interrupt status */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_INTR_STAT_3_FLAT__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_flat_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_STAT_3_FLAT);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the temperature of the sensor
+ *	from the register 0x21 bit 0 to 7
+ *
+ *
+ *
+ *  @param v_temp_s16 : The value of temperature
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_temp(s16
+*v_temp_s16)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* Array contains the temperature lSB and MSB data
+	v_data_u8[0] - LSB
+	v_data_u8[1] - MSB*/
+	u8 v_data_u8[BMI160_TEMP_DATA_SIZE] = {BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE};
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read temperature data */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_TEMP_LSB_VALUE__REG, v_data_u8,
+			BMI160_TEMP_DATA_LENGTH);
+			*v_temp_s16 =
+			(s16)(((s32)((s8) (v_data_u8[BMI160_TEMP_MSB_BYTE]) <<
+			BMI160_SHIFT_BIT_POSITION_BY_08_BITS))
+			| v_data_u8[BMI160_TEMP_LSB_BYTE]);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the  of the sensor
+ *	form the register 0x23 and 0x24 bit 0 to 7 and 0 to 2
+ *	@brief this byte counter is updated each time a complete frame
+ *	was read or writtern
+ *
+ *
+ *  @param v_fifo_length_u32 : The value of fifo byte counter
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_fifo_length(u32 *v_fifo_length_u32)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* Array contains the fifo length data
+	v_data_u8[0] - fifo length
+	v_data_u8[1] - fifo length*/
+	u8 a_data_u8r[BMI160_FIFO_DATA_SIZE] = {BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE};
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read fifo length*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_FIFO_BYTE_COUNTER_LSB__REG, a_data_u8r,
+			 BMI160_FIFO_DATA_LENGTH);
+
+			a_data_u8r[BMI160_FIFO_LENGTH_MSB_BYTE] =
+			BMI160_GET_BITSLICE(
+			a_data_u8r[BMI160_FIFO_LENGTH_MSB_BYTE],
+			BMI160_USER_FIFO_BYTE_COUNTER_MSB);
+
+			*v_fifo_length_u32 =
+			(u32)(((u32)((u8) (
+			a_data_u8r[BMI160_FIFO_LENGTH_MSB_BYTE]) <<
+			BMI160_SHIFT_BIT_POSITION_BY_08_BITS))
+			| a_data_u8r[BMI160_FIFO_LENGTH_LSB_BYTE]);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the fifo data of the sensor
+ *	from the register 0x24
+ *	@brief Data format depends on the setting of register FIFO_CONFIG
+ *
+ *
+ *
+ *  @param v_fifodata_u8 : Pointer holding the fifo data
+ *  @param fifo_length_u16 : The value of fifo length maximum
+ *	1024
+ *
+ *	@note For reading FIFO data use the following functions
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_fifo_data(
+u8 *v_fifodata_u8, u16 v_fifo_length_u16)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read fifo data*/
+			com_rslt =
+			p_bmi160->BMI160_BURST_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_FIFO_DATA__REG,
+			v_fifodata_u8, v_fifo_length_u16);
+
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to get the
+ *	accel output date rate form the register 0x40 bit 0 to 3
+ *
+ *
+ *  @param  v_output_data_rate_u8 :The value of accel output date rate
+ *  value |  output data rate
+ * -------|--------------------------
+ *	 0    |	BMI160_ACCEL_OUTPUT_DATA_RATE_RESERVED
+ *	 1	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_0_78HZ
+ *	 2	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_1_56HZ
+ *	 3    |	BMI160_ACCEL_OUTPUT_DATA_RATE_3_12HZ
+ *	 4    | BMI160_ACCEL_OUTPUT_DATA_RATE_6_25HZ
+ *	 5	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_12_5HZ
+ *	 6	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_25HZ
+ *	 7	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_50HZ
+ *	 8	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_100HZ
+ *	 9	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_200HZ
+ *	 10	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_400HZ
+ *	 11	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_800HZ
+ *	 12	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_1600HZ
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_output_data_rate(
+u8 *v_output_data_rate_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the accel output data rate*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_output_data_rate_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set the
+ *	accel output date rate form the register 0x40 bit 0 to 3
+ *
+ *
+ *  @param  v_output_data_rate_u8 :The value of accel output date rate
+ *  value |  output data rate
+ * -------|--------------------------
+ *	 0    |	BMI160_ACCEL_OUTPUT_DATA_RATE_RESERVED
+ *	 1	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_0_78HZ
+ *	 2	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_1_56HZ
+ *	 3    |	BMI160_ACCEL_OUTPUT_DATA_RATE_3_12HZ
+ *	 4    | BMI160_ACCEL_OUTPUT_DATA_RATE_6_25HZ
+ *	 5	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_12_5HZ
+ *	 6	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_25HZ
+ *	 7	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_50HZ
+ *	 8	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_100HZ
+ *	 9	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_200HZ
+ *	 10	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_400HZ
+ *	 11	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_800HZ
+ *	 12	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_1600HZ
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_output_data_rate(
+u8 v_output_data_rate_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		/* accel output data rate selection */
+		if ((v_output_data_rate_u8 != BMI160_INIT_VALUE) &&
+		(v_output_data_rate_u8 <= BMI160_MAX_ACCEL_OUTPUT_DATA_RATE)) {
+			/* write accel output data rate */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE,
+				v_output_data_rate_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to get the
+ *	accel bandwidth from the register 0x40 bit 4 to 6
+ *	@brief bandwidth parameter determines filter configuration(acc_us=0)
+ *	and averaging for under sampling mode(acc_us=1)
+ *
+ *
+ *  @param  v_bw_u8 : The value of accel bandwidth
+ *
+ *	@note accel bandwidth depends on under sampling parameter
+ *	@note under sampling parameter cab be set by the function
+ *	"BMI160_SET_ACCEL_UNDER_SAMPLING_PARAMETER"
+ *
+ *	@note Filter configuration
+ *  accel_us  | Filter configuration
+ * -----------|---------------------
+ *    0x00    |  OSR4 mode
+ *    0x01    |  OSR2 mode
+ *    0x02    |  normal mode
+ *    0x03    |  CIC mode
+ *    0x04    |  Reserved
+ *    0x05    |  Reserved
+ *    0x06    |  Reserved
+ *    0x07    |  Reserved
+ *
+ *	@note accel under sampling mode
+ *  accel_us  | Under sampling mode
+ * -----------|---------------------
+ *    0x00    |  no averaging
+ *    0x01    |  average 2 samples
+ *    0x02    |  average 4 samples
+ *    0x03    |  average 8 samples
+ *    0x04    |  average 16 samples
+ *    0x05    |  average 32 samples
+ *    0x06    |  average 64 samples
+ *    0x07    |  average 128 samples
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_bw(u8 *v_bw_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the accel bandwidth */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_ACCEL_CONFIG_ACCEL_BW__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_bw_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_ACCEL_CONFIG_ACCEL_BW);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set the
+ *	accel bandwidth from the register 0x40 bit 4 to 6
+ *	@brief bandwidth parameter determines filter configuration(acc_us=0)
+ *	and averaging for under sampling mode(acc_us=1)
+ *
+ *
+ *  @param  v_bw_u8 : The value of accel bandwidth
+ *
+ *	@note accel bandwidth depends on under sampling parameter
+ *	@note under sampling parameter cab be set by the function
+ *	"BMI160_SET_ACCEL_UNDER_SAMPLING_PARAMETER"
+ *
+ *	@note Filter configuration
+ *  accel_us  | Filter configuration
+ * -----------|---------------------
+ *    0x00    |  OSR4 mode
+ *    0x01    |  OSR2 mode
+ *    0x02    |  normal mode
+ *    0x03    |  CIC mode
+ *    0x04    |  Reserved
+ *    0x05    |  Reserved
+ *    0x06    |  Reserved
+ *    0x07    |  Reserved
+ *
+ *	@note accel under sampling mode
+ *  accel_us  | Under sampling mode
+ * -----------|---------------------
+ *    0x00    |  no averaging
+ *    0x01    |  average 2 samples
+ *    0x02    |  average 4 samples
+ *    0x03    |  average 8 samples
+ *    0x04    |  average 16 samples
+ *    0x05    |  average 32 samples
+ *    0x06    |  average 64 samples
+ *    0x07    |  average 128 samples
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_bw(u8 v_bw_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		/* select accel bandwidth*/
+		if (v_bw_u8 <= BMI160_MAX_ACCEL_BW) {
+			/* write accel bandwidth*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_ACCEL_CONFIG_ACCEL_BW__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_ACCEL_CONFIG_ACCEL_BW,
+				v_bw_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_ACCEL_CONFIG_ACCEL_BW__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to get the accel
+ *	under sampling parameter form the register 0x40 bit 7
+ *
+ *
+ *
+ *
+ *	@param  v_accel_under_sampling_u8 : The value of accel under sampling
+ *	value    | under_sampling
+ * ----------|---------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_under_sampling_parameter(
+u8 *v_accel_under_sampling_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the accel under sampling parameter */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_accel_under_sampling_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set the accel
+ *	under sampling parameter form the register 0x40 bit 7
+ *
+ *
+ *
+ *
+ *	@param  v_accel_under_sampling_u8 : The value of accel under sampling
+ *	value    | under_sampling
+ * ----------|---------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_under_sampling_parameter(
+u8 v_accel_under_sampling_u8)
+{
+/* variable used for return the status of communication result*/
+BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+	if (v_accel_under_sampling_u8 <= BMI160_MAX_UNDER_SAMPLING) {
+		com_rslt =
+		p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+		BMI160_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			/* write the accel under sampling parameter */
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING,
+			v_accel_under_sampling_u8);
+			com_rslt +=
+			p_bmi160->BMI160_BUS_WRITE_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	} else {
+	com_rslt = E_BMI160_OUT_OF_RANGE;
+	}
+}
+return com_rslt;
+}
+/*!
+ *	@brief This API is used to get the ranges
+ *	(g values) of the accel from the register 0x41 bit 0 to 3
+ *
+ *
+ *
+ *
+ *  @param v_range_u8 : The value of accel g range
+ *	value    | g_range
+ * ----------|-----------
+ *   0x03    | BMI160_ACCEL_RANGE_2G
+ *   0x05    | BMI160_ACCEL_RANGE_4G
+ *   0x08    | BMI160_ACCEL_RANGE_8G
+ *   0x0C    | BMI160_ACCEL_RANGE_16G
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_range(
+u8 *v_range_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the accel range*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_ACCEL_RANGE__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_range_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_ACCEL_RANGE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set the ranges
+ *	(g values) of the accel from the register 0x41 bit 0 to 3
+ *
+ *
+ *
+ *
+ *  @param v_range_u8 : The value of accel g range
+ *	value    | g_range
+ * ----------|-----------
+ *   0x03    | BMI160_ACCEL_RANGE_2G
+ *   0x05    | BMI160_ACCEL_RANGE_4G
+ *   0x08    | BMI160_ACCEL_RANGE_8G
+ *   0x0C    | BMI160_ACCEL_RANGE_16G
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_range(u8 v_range_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if ((v_range_u8 == BMI160_ACCEL_RANGE0) ||
+			(v_range_u8 == BMI160_ACCEL_RANGE1) ||
+			(v_range_u8 == BMI160_ACCEL_RANGE3) ||
+			(v_range_u8 == BMI160_ACCEL_RANGE4)) {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_ACCEL_RANGE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8  = BMI160_SET_BITSLICE(
+				v_data_u8, BMI160_USER_ACCEL_RANGE,
+				v_range_u8);
+				/* write the accel range*/
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_ACCEL_RANGE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to get the
+ *	gyroscope output data rate from the register 0x42 bit 0 to 3
+ *
+ *
+ *
+ *
+ *  @param  v_output_data_rate_u8 :The value of gyro output data rate
+ *  value     |      gyro output data rate
+ * -----------|-----------------------------
+ *   0x00     | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x01     | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x02     | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x03     | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x04     | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x05     | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x06     | BMI160_GYRO_OUTPUT_DATA_RATE_25HZ
+ *   0x07     | BMI160_GYRO_OUTPUT_DATA_RATE_50HZ
+ *   0x08     | BMI160_GYRO_OUTPUT_DATA_RATE_100HZ
+ *   0x09     | BMI160_GYRO_OUTPUT_DATA_RATE_200HZ
+ *   0x0A     | BMI160_GYRO_OUTPUT_DATA_RATE_400HZ
+ *   0x0B     | BMI160_GYRO_OUTPUT_DATA_RATE_800HZ
+ *   0x0C     | BMI160_GYRO_OUTPUT_DATA_RATE_1600HZ
+ *   0x0D     | BMI160_GYRO_OUTPUT_DATA_RATE_3200HZ
+ *   0x0E     | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x0F     | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_output_data_rate(
+u8 *v_output_data_rate_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the gyro output data rate*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_GYRO_CONFIG_OUTPUT_DATA_RATE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_output_data_rate_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_GYRO_CONFIG_OUTPUT_DATA_RATE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set the
+ *	gyroscope output data rate from the register 0x42 bit 0 to 3
+ *
+ *
+ *
+ *
+ *  @param  v_output_data_rate_u8 :The value of gyro output data rate
+ *  value     |      gyro output data rate
+ * -----------|-----------------------------
+ *   0x00     | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x01     | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x02     | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x03     | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x04     | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x05     | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x06     | BMI160_GYRO_OUTPUT_DATA_RATE_25HZ
+ *   0x07     | BMI160_GYRO_OUTPUT_DATA_RATE_50HZ
+ *   0x08     | BMI160_GYRO_OUTPUT_DATA_RATE_100HZ
+ *   0x09     | BMI160_GYRO_OUTPUT_DATA_RATE_200HZ
+ *   0x0A     | BMI160_GYRO_OUTPUT_DATA_RATE_400HZ
+ *   0x0B     | BMI160_GYRO_OUTPUT_DATA_RATE_800HZ
+ *   0x0C     | BMI160_GYRO_OUTPUT_DATA_RATE_1600HZ
+ *   0x0D     | BMI160_GYRO_OUTPUT_DATA_RATE_3200HZ
+ *   0x0E     | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x0F     | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_output_data_rate(
+u8 v_output_data_rate_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		/* select the gyro output data rate*/
+		if ((v_output_data_rate_u8 <  BMI160_OUTPUT_DATA_RATE6) &&
+		(v_output_data_rate_u8 != BMI160_INIT_VALUE)
+		&& (v_output_data_rate_u8 !=  BMI160_OUTPUT_DATA_RATE1)
+		&& (v_output_data_rate_u8 !=  BMI160_OUTPUT_DATA_RATE2)
+		&& (v_output_data_rate_u8 !=  BMI160_OUTPUT_DATA_RATE3)
+		&& (v_output_data_rate_u8 !=  BMI160_OUTPUT_DATA_RATE4)
+		&& (v_output_data_rate_u8 !=  BMI160_OUTPUT_DATA_RATE5)
+		&& (v_output_data_rate_u8 !=  BMI160_OUTPUT_DATA_RATE6)
+		&& (v_output_data_rate_u8 !=  BMI160_OUTPUT_DATA_RATE7)) {
+			/* write the gyro output data rate */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_GYRO_CONFIG_OUTPUT_DATA_RATE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_GYRO_CONFIG_OUTPUT_DATA_RATE,
+				v_output_data_rate_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
+				(p_bmi160->dev_addr,
+				BMI160_USER_GYRO_CONFIG_OUTPUT_DATA_RATE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to get the
+ *	data of gyro from the register 0x42 bit 4 to 5
+ *
+ *
+ *
+ *
+ *  @param  v_bw_u8 : The value of gyro bandwidth
+ *  value     | gyro bandwidth
+ *  ----------|----------------
+ *   0x00     | BMI160_GYRO_OSR4_MODE
+ *   0x01     | BMI160_GYRO_OSR2_MODE
+ *   0x02     | BMI160_GYRO_NORMAL_MODE
+ *   0x03     | BMI160_GYRO_CIC_MODE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_bw(u8 *v_bw_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read gyro bandwidth*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_GYRO_CONFIG_BW__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_bw_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_GYRO_CONFIG_BW);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set the
+ *	data of gyro from the register 0x42 bit 4 to 5
+ *
+ *
+ *
+ *
+ *  @param  v_bw_u8 : The value of gyro bandwidth
+ *  value     | gyro bandwidth
+ *  ----------|----------------
+ *   0x00     | BMI160_GYRO_OSR4_MODE
+ *   0x01     | BMI160_GYRO_OSR2_MODE
+ *   0x02     | BMI160_GYRO_NORMAL_MODE
+ *   0x03     | BMI160_GYRO_CIC_MODE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_bw(u8 v_bw_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_bw_u8 <= BMI160_MAX_GYRO_BW) {
+			/* write the gyro bandwidth*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_GYRO_CONFIG_BW__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_GYRO_CONFIG_BW, v_bw_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_GYRO_CONFIG_BW__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the range
+ *	of gyro from the register 0x43 bit 0 to 2
+ *
+ *  @param  v_range_u8 : The value of gyro range
+ *   value    |    range
+ *  ----------|-------------------------------
+ *    0x00    | BMI160_GYRO_RANGE_2000_DEG_SEC
+ *    0x01    | BMI160_GYRO_RANGE_1000_DEG_SEC
+ *    0x02    | BMI160_GYRO_RANGE_500_DEG_SEC
+ *    0x03    | BMI160_GYRO_RANGE_250_DEG_SEC
+ *    0x04    | BMI160_GYRO_RANGE_125_DEG_SEC
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_range(u8 *v_range_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the gyro range */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_GYRO_RANGE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_range_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_GYRO_RANGE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API set the range
+ *	of gyro from the register 0x43 bit 0 to 2
+ *
+ *  @param  v_range_u8 : The value of gyro range
+ *   value    |    range
+ *  ----------|-------------------------------
+ *    0x00    | BMI160_GYRO_RANGE_2000_DEG_SEC
+ *    0x01    | BMI160_GYRO_RANGE_1000_DEG_SEC
+ *    0x02    | BMI160_GYRO_RANGE_500_DEG_SEC
+ *    0x03    | BMI160_GYRO_RANGE_250_DEG_SEC
+ *    0x04    | BMI160_GYRO_RANGE_125_DEG_SEC
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_range(u8 v_range_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_range_u8 <= BMI160_MAX_GYRO_RANGE) {
+			/* write the gyro range value */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_GYRO_RANGE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_GYRO_RANGE,
+				v_range_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
+				(p_bmi160->dev_addr,
+				BMI160_USER_GYRO_RANGE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to get the
+ *	output data rate of magnetometer from the register 0x44 bit 0 to 3
+ *
+ *
+ *
+ *
+ *  @param  v_output_data_rat_u8e : The value of mag output data rate
+ *  value   |    mag output data rate
+ * ---------|---------------------------
+ *  0x00    |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED
+ *  0x01    |BMI160_MAG_OUTPUT_DATA_RATE_0_78HZ
+ *  0x02    |BMI160_MAG_OUTPUT_DATA_RATE_1_56HZ
+ *  0x03    |BMI160_MAG_OUTPUT_DATA_RATE_3_12HZ
+ *  0x04    |BMI160_MAG_OUTPUT_DATA_RATE_6_25HZ
+ *  0x05    |BMI160_MAG_OUTPUT_DATA_RATE_12_5HZ
+ *  0x06    |BMI160_MAG_OUTPUT_DATA_RATE_25HZ
+ *  0x07    |BMI160_MAG_OUTPUT_DATA_RATE_50HZ
+ *  0x08    |BMI160_MAG_OUTPUT_DATA_RATE_100HZ
+ *  0x09    |BMI160_MAG_OUTPUT_DATA_RATE_200HZ
+ *  0x0A    |BMI160_MAG_OUTPUT_DATA_RATE_400HZ
+ *  0x0B    |BMI160_MAG_OUTPUT_DATA_RATE_800HZ
+ *  0x0C    |BMI160_MAG_OUTPUT_DATA_RATE_1600HZ
+ *  0x0D    |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED0
+ *  0x0E    |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED1
+ *  0x0F    |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED2
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_output_data_rate(
+u8 *v_output_data_rat_u8e)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the mag data output rate*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_MAG_CONFIG_OUTPUT_DATA_RATE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_output_data_rat_u8e = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_MAG_CONFIG_OUTPUT_DATA_RATE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set the
+ *	output data rate of magnetometer from the register 0x44 bit 0 to 3
+ *
+ *
+ *
+ *
+ *  @param  v_output_data_rat_u8e : The value of mag output data rate
+ *  value   |    mag output data rate
+ * ---------|---------------------------
+ *  0x00    |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED
+ *  0x01    |BMI160_MAG_OUTPUT_DATA_RATE_0_78HZ
+ *  0x02    |BMI160_MAG_OUTPUT_DATA_RATE_1_56HZ
+ *  0x03    |BMI160_MAG_OUTPUT_DATA_RATE_3_12HZ
+ *  0x04    |BMI160_MAG_OUTPUT_DATA_RATE_6_25HZ
+ *  0x05    |BMI160_MAG_OUTPUT_DATA_RATE_12_5HZ
+ *  0x06    |BMI160_MAG_OUTPUT_DATA_RATE_25HZ
+ *  0x07    |BMI160_MAG_OUTPUT_DATA_RATE_50HZ
+ *  0x08    |BMI160_MAG_OUTPUT_DATA_RATE_100HZ
+ *  0x09    |BMI160_MAG_OUTPUT_DATA_RATE_200HZ
+ *  0x0A    |BMI160_MAG_OUTPUT_DATA_RATE_400HZ
+ *  0x0B    |BMI160_MAG_OUTPUT_DATA_RATE_800HZ
+ *  0x0C    |BMI160_MAG_OUTPUT_DATA_RATE_1600HZ
+ *  0x0D    |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED0
+ *  0x0E    |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED1
+ *  0x0F    |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED2
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_output_data_rate(
+u8 v_output_data_rat_u8e)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		/* select the mag data output rate*/
+		if ((v_output_data_rat_u8e
+		<= BMI160_MAX_ACCEL_OUTPUT_DATA_RATE)
+		&& (v_output_data_rat_u8e
+		!= BMI160_OUTPUT_DATA_RATE0)
+		&& (v_output_data_rat_u8e
+		!=  BMI160_OUTPUT_DATA_RATE6)
+		&& (v_output_data_rat_u8e
+		!=  BMI160_OUTPUT_DATA_RATE7)) {
+			/* write the mag data output rate*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_MAG_CONFIG_OUTPUT_DATA_RATE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_MAG_CONFIG_OUTPUT_DATA_RATE,
+				v_output_data_rat_u8e);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_MAG_CONFIG_OUTPUT_DATA_RATE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API is used to read Down sampling
+ *	for gyro (2**downs_gyro) in the register 0x45 bit 0 to 2
+ *
+ *
+ *
+ *
+ *  @param v_fifo_down_gyro_u8 :The value of gyro fifo down
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_down_gyro(
+u8 *v_fifo_down_gyro_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the gyro fifo down*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_FIFO_DOWN_GYRO__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_fifo_down_gyro_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_FIFO_DOWN_GYRO);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API is used to set Down sampling
+ *	for gyro (2**downs_gyro) in the register 0x45 bit 0 to 2
+ *
+ *
+ *
+ *
+ *  @param v_fifo_down_gyro_u8 :The value of gyro fifo down
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_down_gyro(
+u8 v_fifo_down_gyro_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* write the gyro fifo down*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_FIFO_DOWN_GYRO__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(
+				v_data_u8,
+				BMI160_USER_FIFO_DOWN_GYRO,
+				v_fifo_down_gyro_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_FIFO_DOWN_GYRO__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to read gyro fifo filter data
+ *	from the register 0x45 bit 3
+ *
+ *
+ *
+ *  @param v_gyro_fifo_filter_data_u8 :The value of gyro filter data
+ *  value      |  gyro_fifo_filter_data
+ * ------------|-------------------------
+ *    0x00     |  Unfiltered data
+ *    0x01     |  Filtered data
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_fifo_filter_data(
+u8 *v_gyro_fifo_filter_data_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the gyro fifo filter data */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_FIFO_FILTER_GYRO__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_gyro_fifo_filter_data_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_FIFO_FILTER_GYRO);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set gyro fifo filter data
+ *	from the register 0x45 bit 3
+ *
+ *
+ *
+ *  @param v_gyro_fifo_filter_data_u8 :The value of gyro filter data
+ *  value      |  gyro_fifo_filter_data
+ * ------------|-------------------------
+ *    0x00     |  Unfiltered data
+ *    0x01     |  Filtered data
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_fifo_filter_data(
+u8 v_gyro_fifo_filter_data_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_gyro_fifo_filter_data_u8
+		<= BMI160_MAX_VALUE_FIFO_FILTER) {
+			/* write the gyro fifo filter data */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_FIFO_FILTER_GYRO__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(
+				v_data_u8,
+				BMI160_USER_FIFO_FILTER_GYRO,
+				v_gyro_fifo_filter_data_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_FIFO_FILTER_GYRO__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to read Down sampling
+ *	for accel (2*downs_accel) from the register 0x45 bit 4 to 6
+ *
+ *
+ *
+ *
+ *  @param v_fifo_down_u8 :The value of accel fifo down
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_down_accel(
+u8 *v_fifo_down_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the accel fifo down data */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_FIFO_DOWN_ACCEL__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_fifo_down_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_FIFO_DOWN_ACCEL);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API is used to set Down sampling
+ *	for accel (2*downs_accel) from the register 0x45 bit 4 to 6
+ *
+ *
+ *
+ *
+ *  @param v_fifo_down_u8 :The value of accel fifo down
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_down_accel(
+u8 v_fifo_down_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* write the accel fifo down data */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_FIFO_DOWN_ACCEL__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_FIFO_DOWN_ACCEL, v_fifo_down_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_FIFO_DOWN_ACCEL__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to read accel fifo filter data
+ *	from the register 0x45 bit 7
+ *
+ *
+ *
+ *  @param v_accel_fifo_filter_u8 :The value of accel filter data
+ *  value      |  accel_fifo_filter_data
+ * ------------|-------------------------
+ *    0x00     |  Unfiltered data
+ *    0x01     |  Filtered data
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_fifo_filter_data(
+u8 *v_accel_fifo_filter_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the accel fifo filter data */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_FIFO_FILTER_ACCEL__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_accel_fifo_filter_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_FIFO_FILTER_ACCEL);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set accel fifo filter data
+ *	from the register 0x45 bit 7
+ *
+ *
+ *
+ *  @param v_accel_fifo_filter_u8 :The value of accel filter data
+ *  value      |  accel_fifo_filter_data
+ * ------------|-------------------------
+ *    0x00     |  Unfiltered data
+ *    0x01     |  Filtered data
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_fifo_filter_data(
+u8 v_accel_fifo_filter_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_accel_fifo_filter_u8 <= BMI160_MAX_VALUE_FIFO_FILTER) {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_FIFO_FILTER_ACCEL__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				/* write accel fifo filter data */
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_FIFO_FILTER_ACCEL,
+				v_accel_fifo_filter_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_FIFO_FILTER_ACCEL__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to Trigger an interrupt
+ *	when FIFO contains water mark level from the register 0x46 bit 0 to 7
+ *
+ *
+ *
+ *  @param  v_fifo_wm_u8 : The value of fifo water mark level
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_wm(
+u8 *v_fifo_wm_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the fifo water mark level*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_FIFO_WM__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_fifo_wm_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_FIFO_WM);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to Trigger an interrupt
+ *	when FIFO contains water mark level from the register 0x46 bit 0 to 7
+ *
+ *
+ *
+ *  @param  v_fifo_wm_u8 : The value of fifo water mark level
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_wm(
+u8 v_fifo_wm_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* write the fifo water mark level*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_FIFO_WM__REG,
+			&v_fifo_wm_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads fifo sensor time
+ *	frame after the last valid data frame form the register  0x47 bit 1
+ *
+ *
+ *
+ *
+ *  @param v_fifo_time_enable_u8 : The value of sensor time
+ *  value      |  fifo sensor time
+ * ------------|-------------------------
+ *    0x00     |  do not return sensortime frame
+ *    0x01     |  return sensortime frame
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_time_enable(
+u8 *v_fifo_time_enable_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the fifo sensor time*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_FIFO_TIME_ENABLE__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_fifo_time_enable_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_FIFO_TIME_ENABLE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API set fifo sensor time
+ *	frame after the last valid data frame form the register  0x47 bit 1
+ *
+ *
+ *
+ *
+ *  @param v_fifo_time_enable_u8 : The value of sensor time
+ *  value      |  fifo sensor time
+ * ------------|-------------------------
+ *    0x00     |  do not return sensortime frame
+ *    0x01     |  return sensortime frame
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_time_enable(
+u8 v_fifo_time_enable_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_fifo_time_enable_u8 <= BMI160_MAX_VALUE_FIFO_TIME) {
+			/* write the fifo sensor time*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_FIFO_TIME_ENABLE__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_FIFO_TIME_ENABLE,
+				v_fifo_time_enable_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_FIFO_TIME_ENABLE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads FIFO tag interrupt2 enable status
+ *	from the resister 0x47 bit 2
+ *
+ *  @param v_fifo_tag_intr2_u8 : The value of fifo tag interrupt
+ *	value    | fifo tag interrupt
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_tag_intr2_enable(
+u8 *v_fifo_tag_intr2_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the fifo tag interrupt2*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_FIFO_TAG_INTR2_ENABLE__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_fifo_tag_intr2_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_FIFO_TAG_INTR2_ENABLE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API set FIFO tag interrupt2 enable status
+ *	from the resister 0x47 bit 2
+ *
+ *  @param v_fifo_tag_intr2_u8 : The value of fifo tag interrupt
+ *	value    | fifo tag interrupt
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_tag_intr2_enable(
+u8 v_fifo_tag_intr2_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_fifo_tag_intr2_u8 <= BMI160_MAX_VALUE_FIFO_INTR) {
+			/* write the fifo tag interrupt2*/
+			com_rslt = bmi160_set_input_enable(1,
+			v_fifo_tag_intr2_u8);
+			com_rslt +=
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_FIFO_TAG_INTR2_ENABLE__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_FIFO_TAG_INTR2_ENABLE,
+				v_fifo_tag_intr2_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_FIFO_TAG_INTR2_ENABLE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API get FIFO tag interrupt1 enable status
+ *	from the resister 0x47 bit 3
+ *
+ *  @param v_fifo_tag_intr1_u8 :The value of fifo tag interrupt1
+ *	value    | fifo tag interrupt
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_tag_intr1_enable(
+u8 *v_fifo_tag_intr1_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read fifo tag interrupt*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_FIFO_TAG_INTR1_ENABLE__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_fifo_tag_intr1_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_FIFO_TAG_INTR1_ENABLE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API set FIFO tag interrupt1 enable status
+ *	from the resister 0x47 bit 3
+ *
+ *  @param v_fifo_tag_intr1_u8 :The value of fifo tag interrupt1
+ *	value    | fifo tag interrupt
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_tag_intr1_enable(
+u8 v_fifo_tag_intr1_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_fifo_tag_intr1_u8 <= BMI160_MAX_VALUE_FIFO_INTR) {
+			/* write the fifo tag interrupt*/
+			com_rslt = bmi160_set_input_enable(BMI160_INIT_VALUE,
+			v_fifo_tag_intr1_u8);
+			com_rslt +=
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_FIFO_TAG_INTR1_ENABLE__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_FIFO_TAG_INTR1_ENABLE,
+				v_fifo_tag_intr1_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_FIFO_TAG_INTR1_ENABLE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads FIFO frame
+ *	header enable from the register 0x47 bit 4
+ *
+ *  @param v_fifo_header_u8 :The value of fifo header
+ *	value    | fifo header
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_header_enable(
+u8 *v_fifo_header_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read fifo header */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_FIFO_HEADER_ENABLE__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_fifo_header_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_FIFO_HEADER_ENABLE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API set FIFO frame
+ *	header enable from the register 0x47 bit 4
+ *
+ *  @param v_fifo_header_u8 :The value of fifo header
+ *	value    | fifo header
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_header_enable(
+u8 v_fifo_header_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_fifo_header_u8 <= BMI160_MAX_VALUE_FIFO_HEADER) {
+			/* write the fifo header */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_FIFO_HEADER_ENABLE__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_FIFO_HEADER_ENABLE,
+				v_fifo_header_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_FIFO_HEADER_ENABLE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to read stored
+ *	magnetometer data in FIFO (all 3 axes) from the register 0x47 bit 5
+ *
+ *  @param v_fifo_mag_u8 : The value of fifo mag enble
+ *	value    | fifo mag
+ * ----------|-------------------
+ *  0x00     |  no magnetometer data is stored
+ *  0x01     |  magnetometer data is stored
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_mag_enable(
+u8 *v_fifo_mag_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the fifo mag enable*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_FIFO_MAG_ENABLE__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_fifo_mag_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_FIFO_MAG_ENABLE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set stored
+ *	magnetometer data in FIFO (all 3 axes) from the register 0x47 bit 5
+ *
+ *  @param v_fifo_mag_u8 : The value of fifo mag enble
+ *	value    | fifo mag
+ * ----------|-------------------
+ *  0x00     |  no magnetometer data is stored
+ *  0x01     |  magnetometer data is stored
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_mag_enable(
+u8 v_fifo_mag_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			if (v_fifo_mag_u8 <= BMI160_MAX_VALUE_FIFO_MAG) {
+				/* write the fifo mag enable*/
+				com_rslt =
+				p_bmi160->BMI160_BUS_READ_FUNC
+				(p_bmi160->dev_addr,
+				BMI160_USER_FIFO_MAG_ENABLE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+				if (com_rslt == SUCCESS) {
+					v_data_u8 =
+					BMI160_SET_BITSLICE(v_data_u8,
+					BMI160_USER_FIFO_MAG_ENABLE,
+					v_fifo_mag_u8);
+					com_rslt +=
+					p_bmi160->BMI160_BUS_WRITE_FUNC
+					(p_bmi160->dev_addr,
+					BMI160_USER_FIFO_MAG_ENABLE__REG,
+					&v_data_u8,
+					BMI160_GEN_READ_WRITE_DATA_LENGTH);
+				}
+			} else {
+			com_rslt = E_BMI160_OUT_OF_RANGE;
+			}
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to read stored
+ *	accel data in FIFO (all 3 axes) from the register 0x47 bit 6
+ *
+ *  @param v_fifo_accel_u8 : The value of fifo accel enble
+ *	value    | fifo accel
+ * ----------|-------------------
+ *  0x00     |  no accel data is stored
+ *  0x01     |  accel data is stored
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_accel_enable(
+u8 *v_fifo_accel_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the accel fifo enable*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_FIFO_ACCEL_ENABLE__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_fifo_accel_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_FIFO_ACCEL_ENABLE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set stored
+ *	accel data in FIFO (all 3 axes) from the register 0x47 bit 6
+ *
+ *  @param v_fifo_accel_u8 : The value of fifo accel enble
+ *	value    | fifo accel
+ * ----------|-------------------
+ *  0x00     |  no accel data is stored
+ *  0x01     |  accel data is stored
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_accel_enable(
+u8 v_fifo_accel_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_fifo_accel_u8 <= BMI160_MAX_VALUE_FIFO_ACCEL) {
+			/* write the fifo mag enables*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_FIFO_ACCEL_ENABLE__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_FIFO_ACCEL_ENABLE, v_fifo_accel_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_FIFO_ACCEL_ENABLE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to read stored
+ *	 gyro data in FIFO (all 3 axes) from the resister 0x47 bit 7
+ *
+ *
+ *  @param v_fifo_gyro_u8 : The value of fifo gyro enble
+ *	value    | fifo gyro
+ * ----------|-------------------
+ *  0x00     |  no gyro data is stored
+ *  0x01     |  gyro data is stored
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_gyro_enable(
+u8 *v_fifo_gyro_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read fifo gyro enable */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_FIFO_GYRO_ENABLE__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_fifo_gyro_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_FIFO_GYRO_ENABLE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set stored
+ *	gyro data in FIFO (all 3 axes) from the resister 0x47 bit 7
+ *
+ *
+ *  @param v_fifo_gyro_u8 : The value of fifo gyro enble
+ *	value    | fifo gyro
+ * ----------|-------------------
+ *  0x00     |  no gyro data is stored
+ *  0x01     |  gyro data is stored
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_gyro_enable(
+u8 v_fifo_gyro_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_fifo_gyro_u8 <= BMI160_MAX_VALUE_FIFO_GYRO) {
+			/* write fifo gyro enable*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_FIFO_GYRO_ENABLE__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_FIFO_GYRO_ENABLE, v_fifo_gyro_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_FIFO_GYRO_ENABLE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to read
+ *	I2C device address of auxiliary mag from the register 0x4B bit 1 to 7
+ *
+ *
+ *
+ *
+ *  @param v_i2c_device_addr_u8 : The value of mag I2C device address
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_i2c_device_addr(
+u8 *v_i2c_device_addr_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the mag I2C device address*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_I2C_DEVICE_ADDR__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_i2c_device_addr_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_I2C_DEVICE_ADDR);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set
+ *	I2C device address of auxiliary mag from the register 0x4B bit 1 to 7
+ *
+ *
+ *
+ *
+ *  @param v_i2c_device_addr_u8 : The value of mag I2C device address
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_i2c_device_addr(
+u8 v_i2c_device_addr_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* write the mag I2C device address*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_I2C_DEVICE_ADDR__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_I2C_DEVICE_ADDR,
+				v_i2c_device_addr_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_I2C_DEVICE_ADDR__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to read
+ *	Burst data length (1,2,6,8 byte) from the register 0x4C bit 0 to 1
+ *
+ *
+ *
+ *
+ *  @param v_mag_burst_u8 : The data of mag burst read lenth
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_burst(
+u8 *v_mag_burst_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read mag burst mode length*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_MAG_BURST__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_mag_burst_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_MAG_BURST);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set
+ *	Burst data length (1,2,6,8 byte) from the register 0x4C bit 0 to 1
+ *
+ *
+ *
+ *
+ *  @param v_mag_burst_u8 : The data of mag burst read lenth
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_burst(
+u8 v_mag_burst_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* write mag burst mode length*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_MAG_BURST__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 =
+				BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_MAG_BURST, v_mag_burst_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_MAG_BURST__REG, &v_data_u8,
+				BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to read
+ *	trigger-readout offset in units of 2.5 ms. If set to zero,
+ *	the offset is maximum, i.e. after readout a trigger
+ *	is issued immediately. from the register 0x4C bit 2 to 5
+ *
+ *
+ *
+ *
+ *  @param v_mag_offset_u8 : The value of mag offset
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_offset(
+u8 *v_mag_offset_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_MAG_OFFSET__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_mag_offset_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_MAG_OFFSET);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set
+ *	trigger-readout offset in units of 2.5 ms. If set to zero,
+ *	the offset is maximum, i.e. after readout a trigger
+ *	is issued immediately. from the register 0x4C bit 2 to 5
+ *
+ *
+ *
+ *
+ *  @param v_mag_offset_u8 : The value of mag offset
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_offset(
+u8 v_mag_offset_u8)
+{
+/* variable used for return the status of communication result*/
+BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+		com_rslt =
+		p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+		BMI160_USER_MAG_OFFSET__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 =
+			BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_MAG_OFFSET, v_mag_offset_u8);
+			com_rslt +=
+			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_MAG_OFFSET__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	}
+return com_rslt;
+}
+/*!
+ *	@brief This API is used to read
+ *	Enable register access on MAG_IF[2] or MAG_IF[3] writes.
+ *	This implies that the DATA registers are not updated with
+ *	magnetometer values. Accessing magnetometer requires
+ *	the magnetometer in normal mode in PMU_STATUS.
+ *	from the register 0x4C bit 7
+ *
+ *
+ *
+ *  @param v_mag_manual_u8 : The value of mag manual enable
+ *	value    | mag manual
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_manual_enable(
+u8 *v_mag_manual_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read mag manual */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_MAG_MANUAL_ENABLE__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_mag_manual_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_MAG_MANUAL_ENABLE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set
+ *	Enable register access on MAG_IF[2] or MAG_IF[3] writes.
+ *	This implies that the DATA registers are not updated with
+ *	magnetometer values. Accessing magnetometer requires
+ *	the magnetometer in normal mode in PMU_STATUS.
+ *	from the register 0x4C bit 7
+ *
+ *
+ *
+ *  @param v_mag_manual_u8 : The value of mag manual enable
+ *	value    | mag manual
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_manual_enable(
+u8 v_mag_manual_u8)
+{
+/* variable used for return the status of communication result*/
+BMI160_RETURN_FUNCTION_TYPE com_rslt = BMI160_INIT_VALUE;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+		/* write the mag manual*/
+		com_rslt =
+		p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+		BMI160_USER_MAG_MANUAL_ENABLE__REG, &v_data_u8,
+		BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		if (com_rslt == SUCCESS) {
+			/* set the bit of mag manual enable*/
+			v_data_u8 =
+			BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_MAG_MANUAL_ENABLE, v_mag_manual_u8);
+			com_rslt +=
+			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_MAG_MANUAL_ENABLE__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		if (com_rslt == SUCCESS)
+			p_bmi160->mag_manual_enable = v_mag_manual_u8;
+		else
+			p_bmi160->mag_manual_enable = E_BMI160_COMM_RES;
+	}
+return com_rslt;
+}
+/*!
+ *	@brief This API is used to read data
+ *	magnetometer address to read from the register 0x4D bit 0 to 7
+ *	@brief It used to provide mag read address of auxiliary mag
+ *
+ *
+ *
+ *
+ *  @param  v_mag_read_addr_u8 : The value of address need to be read
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_read_addr(
+u8 *v_mag_read_addr_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the written address*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_READ_ADDR__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_mag_read_addr_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_READ_ADDR);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set
+ *	magnetometer write address from the register 0x4D bit 0 to 7
+ *	@brief mag write address writes the address of auxiliary mag to write
+ *
+ *
+ *
+ *  @param v_mag_read_addr_u8:
+ *	The data of auxiliary mag address to write data
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_read_addr(
+u8 v_mag_read_addr_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* write the mag read address*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_READ_ADDR__REG, &v_mag_read_addr_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to read
+ *	magnetometer write address from the register 0x4E bit 0 to 7
+ *	@brief mag write address writes the address of auxiliary mag to write
+ *
+ *
+ *
+ *  @param  v_mag_write_addr_u8:
+ *	The data of auxiliary mag address to write data
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_write_addr(
+u8 *v_mag_write_addr_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the address of last written */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_WRITE_ADDR__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_mag_write_addr_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_WRITE_ADDR);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set
+ *	magnetometer write address from the register 0x4E bit 0 to 7
+ *	@brief mag write address writes the address of auxiliary mag to write
+ *
+ *
+ *
+ *  @param  v_mag_write_addr_u8:
+ *	The data of auxiliary mag address to write data
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_write_addr(
+u8 v_mag_write_addr_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* write the data of mag address to write data */
+			com_rslt =
+			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_WRITE_ADDR__REG, &v_mag_write_addr_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to read magnetometer write data
+ *	form the resister 0x4F bit 0 to 7
+ *	@brief This writes the data will be wrote to mag
+ *
+ *
+ *
+ *  @param  v_mag_write_data_u8: The value of mag data
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_write_data(
+u8 *v_mag_write_data_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_WRITE_DATA__REG, &v_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_mag_write_data_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_WRITE_DATA);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set magnetometer write data
+ *	form the resister 0x4F bit 0 to 7
+ *	@brief This writes the data will be wrote to mag
+ *
+ *
+ *
+ *  @param  v_mag_write_data_u8: The value of mag data
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_write_data(
+u8 v_mag_write_data_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt =
+			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_WRITE_DATA__REG, &v_mag_write_data_u8,
+			BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief  This API is used to read
+ *	interrupt enable from the register 0x50 bit 0 to 7
+ *
+ *
+ *
+ *
+ *	@param v_enable_u8 : Value to decided to select interrupt
+ *   v_enable_u8   |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_ANY_MOTION_X_ENABLE
+ *       1         | BMI160_ANY_MOTION_Y_ENABLE
+ *       2         | BMI160_ANY_MOTION_Z_ENABLE
+ *       3         | BMI160_DOUBLE_TAP_ENABLE
+ *       4         | BMI160_SINGLE_TAP_ENABLE
+ *       5         | BMI160_ORIENT_ENABLE
+ *       6         | BMI160_FLAT_ENABLE
+ *
+ *	@param v_intr_enable_zero_u8 : The interrupt enable value
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_enable_0(
+u8 v_enable_u8, u8 *v_intr_enable_zero_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		/* select interrupt to read*/
+		switch (v_enable_u8) {
+		case BMI160_ANY_MOTION_X_ENABLE:
+			/* read the any motion interrupt x data */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr,
+			BMI160_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_zero_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE);
+		break;
+		case BMI160_ANY_MOTION_Y_ENABLE:
+			/* read the any motion interrupt y data */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr,
+			BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_zero_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE);
+		break;
+		case BMI160_ANY_MOTION_Z_ENABLE:
+			/* read the any motion interrupt z data */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr,
+			BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_zero_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE);
+		break;
+		case BMI160_DOUBLE_TAP_ENABLE:
+			/* read the double tap interrupt data */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr,
+			BMI160_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_zero_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE);
+		break;
+		case BMI160_SINGLE_TAP_ENABLE:
+			/* read the single tap interrupt data */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr,
+			BMI160_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_zero_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE);
+		break;
+		case BMI160_ORIENT_ENABLE:
+			/* read the orient interrupt data */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_ENABLE_0_ORIENT_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_zero_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_ENABLE_0_ORIENT_ENABLE);
+		break;
+		case BMI160_FLAT_ENABLE:
+			/* read the flat interrupt data */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_ENABLE_0_FLAT_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_zero_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_ENABLE_0_FLAT_ENABLE);
+		break;
+		default:
+			com_rslt = E_BMI160_OUT_OF_RANGE;
+		break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief  This API is used to set
+ *	interrupt enable from the register 0x50 bit 0 to 7
+ *
+ *
+ *
+ *
+ *	@param v_enable_u8 : Value to decided to select interrupt
+ *   v_enable_u8   |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_ANY_MOTION_X_ENABLE
+ *       1         | BMI160_ANY_MOTION_Y_ENABLE
+ *       2         | BMI160_ANY_MOTION_Z_ENABLE
+ *       3         | BMI160_DOUBLE_TAP_ENABLE
+ *       4         | BMI160_SINGLE_TAP_ENABLE
+ *       5         | BMI160_ORIENT_ENABLE
+ *       6         | BMI160_FLAT_ENABLE
+ *
+ *	@param v_intr_enable_zero_u8 : The interrupt enable value
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_enable_0(
+u8 v_enable_u8, u8 v_intr_enable_zero_u8)
+{
+/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+	switch (v_enable_u8) {
+	case BMI160_ANY_MOTION_X_ENABLE:
+		/* write any motion x*/
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+		dev_addr, BMI160_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE,
+			v_intr_enable_zero_u8);
+			com_rslt +=
+			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+			dev_addr,
+			BMI160_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	case BMI160_ANY_MOTION_Y_ENABLE:
+		/* write any motion y*/
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+		dev_addr, BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE,
+			v_intr_enable_zero_u8);
+			com_rslt +=
+			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+			dev_addr,
+			BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	case BMI160_ANY_MOTION_Z_ENABLE:
+		/* write any motion z*/
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+		dev_addr, BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE,
+			v_intr_enable_zero_u8);
+			com_rslt +=
+			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+			dev_addr,
+			BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	case BMI160_DOUBLE_TAP_ENABLE:
+		/* write double tap*/
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+		dev_addr, BMI160_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE,
+			v_intr_enable_zero_u8);
+			com_rslt +=
+			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+			dev_addr,
+			BMI160_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	case BMI160_SINGLE_TAP_ENABLE:
+		/* write single tap */
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+		dev_addr, BMI160_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE,
+			v_intr_enable_zero_u8);
+			com_rslt +=
+			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+			dev_addr,
+			BMI160_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	case BMI160_ORIENT_ENABLE:
+		/* write orient interrupt*/
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+		dev_addr, BMI160_USER_INTR_ENABLE_0_ORIENT_ENABLE__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_ENABLE_0_ORIENT_ENABLE,
+			v_intr_enable_zero_u8);
+			com_rslt +=
+			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+			dev_addr,
+			BMI160_USER_INTR_ENABLE_0_ORIENT_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	case BMI160_FLAT_ENABLE:
+		/* write flat interrupt*/
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+		dev_addr, BMI160_USER_INTR_ENABLE_0_FLAT_ENABLE__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_ENABLE_0_FLAT_ENABLE,
+			v_intr_enable_zero_u8);
+			com_rslt +=
+			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+			dev_addr,
+			BMI160_USER_INTR_ENABLE_0_FLAT_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	default:
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		break;
+	}
+}
+return com_rslt;
+}
+/*!
+ *	@brief  This API is used to read
+ *	interrupt enable byte1 from the register 0x51 bit 0 to 6
+ *	@brief It read the high_g_x,high_g_y,high_g_z,low_g_enable
+ *	data ready, fifo full and fifo water mark.
+ *
+ *
+ *
+ *  @param  v_enable_u8 :  The value of interrupt enable
+ *	@param v_enable_u8 : Value to decided to select interrupt
+ *   v_enable_u8   |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_HIGH_G_X_ENABLE
+ *       1         | BMI160_HIGH_G_Y_ENABLE
+ *       2         | BMI160_HIGH_G_Z_ENABLE
+ *       3         | BMI160_LOW_G_ENABLE
+ *       4         | BMI160_DATA_RDY_ENABLE
+ *       5         | BMI160_FIFO_FULL_ENABLE
+ *       6         | BMI160_FIFO_WM_ENABLE
+ *
+ *	@param v_intr_enable_1_u8 : The interrupt enable value
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_enable_1(
+u8 v_enable_u8, u8 *v_intr_enable_1_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		switch (v_enable_u8) {
+		case BMI160_HIGH_G_X_ENABLE:
+			/* read high_g_x interrupt*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr,
+			BMI160_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_1_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE);
+			break;
+		case BMI160_HIGH_G_Y_ENABLE:
+			/* read high_g_y interrupt*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr,
+			BMI160_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_1_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE);
+			break;
+		case BMI160_HIGH_G_Z_ENABLE:
+			/* read high_g_z interrupt*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr,
+			BMI160_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_1_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE);
+			break;
+		case BMI160_LOW_G_ENABLE:
+			/* read low_g interrupt */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_1_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE);
+			break;
+		case BMI160_DATA_RDY_ENABLE:
+			/* read data ready interrupt */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr,
+			BMI160_USER_INTR_ENABLE_1_DATA_RDY_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_1_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_ENABLE_1_DATA_RDY_ENABLE);
+			break;
+		case BMI160_FIFO_FULL_ENABLE:
+			/* read fifo full interrupt */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr,
+			BMI160_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_1_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE);
+			break;
+		case BMI160_FIFO_WM_ENABLE:
+			/* read fifo water mark interrupt */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr,
+			BMI160_USER_INTR_ENABLE_1_FIFO_WM_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_1_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_ENABLE_1_FIFO_WM_ENABLE);
+			break;
+		default:
+			com_rslt = E_BMI160_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief  This API is used to set
+ *	interrupt enable byte1 from the register 0x51 bit 0 to 6
+ *	@brief It read the high_g_x,high_g_y,high_g_z,low_g_enable
+ *	data ready, fifo full and fifo water mark.
+ *
+ *
+ *
+ *  @param  v_enable_u8 :  The value of interrupt enable
+ *	@param v_enable_u8 : Value to decided to select interrupt
+ *   v_enable_u8   |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_HIGH_G_X_ENABLE
+ *       1         | BMI160_HIGH_G_Y_ENABLE
+ *       2         | BMI160_HIGH_G_Z_ENABLE
+ *       3         | BMI160_LOW_G_ENABLE
+ *       4         | BMI160_DATA_RDY_ENABLE
+ *       5         | BMI160_FIFO_FULL_ENABLE
+ *       6         | BMI160_FIFO_WM_ENABLE
+ *
+ *	@param v_intr_enable_1_u8 : The interrupt enable value
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_enable_1(
+u8 v_enable_u8, u8 v_intr_enable_1_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		switch (v_enable_u8) {
+		case BMI160_HIGH_G_X_ENABLE:
+			/* write high_g_x interrupt*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr,
+			BMI160_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE,
+				v_intr_enable_1_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+				dev_addr,
+				BMI160_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		break;
+		case BMI160_HIGH_G_Y_ENABLE:
+			/* write high_g_y interrupt*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr,
+			BMI160_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE,
+				v_intr_enable_1_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+				dev_addr,
+				BMI160_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		break;
+		case BMI160_HIGH_G_Z_ENABLE:
+			/* write high_g_z interrupt*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr,
+			BMI160_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE,
+				v_intr_enable_1_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+				dev_addr,
+				BMI160_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		break;
+		case BMI160_LOW_G_ENABLE:
+			/* write low_g interrupt*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr,
+			BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE,
+				v_intr_enable_1_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+				dev_addr,
+				BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		break;
+		case BMI160_DATA_RDY_ENABLE:
+			/* write data ready interrupt*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr,
+			BMI160_USER_INTR_ENABLE_1_DATA_RDY_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR_ENABLE_1_DATA_RDY_ENABLE,
+				v_intr_enable_1_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+				dev_addr,
+				BMI160_USER_INTR_ENABLE_1_DATA_RDY_ENABLE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		break;
+		case BMI160_FIFO_FULL_ENABLE:
+			/* write fifo full interrupt*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr,
+			BMI160_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE,
+				v_intr_enable_1_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+				dev_addr,
+				BMI160_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		break;
+		case BMI160_FIFO_WM_ENABLE:
+			/* write fifo water mark interrupt*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_ENABLE_1_FIFO_WM_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR_ENABLE_1_FIFO_WM_ENABLE,
+				v_intr_enable_1_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+				dev_addr,
+				BMI160_USER_INTR_ENABLE_1_FIFO_WM_ENABLE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		break;
+		default:
+			com_rslt = E_BMI160_OUT_OF_RANGE;
+		break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief  This API is used to read
+ *	interrupt enable byte2 from the register bit 0x52 bit 0 to 3
+ *	@brief It reads no motion x,y and z
+ *
+ *
+ *
+ *	@param v_enable_u8: The value of interrupt enable
+ *   v_enable_u8   |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_NOMOTION_X_ENABLE
+ *       1         | BMI160_NOMOTION_Y_ENABLE
+ *       2         | BMI160_NOMOTION_Z_ENABLE
+ *
+ *	@param v_intr_enable_2_u8 : The interrupt enable value
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_enable_2(
+u8 v_enable_u8, u8 *v_intr_enable_2_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		switch (v_enable_u8) {
+		case BMI160_NOMOTION_X_ENABLE:
+			/* read no motion x */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr,
+			BMI160_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_2_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE);
+			break;
+		case BMI160_NOMOTION_Y_ENABLE:
+			/* read no motion y */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr,
+			BMI160_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_2_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE);
+			break;
+		case BMI160_NOMOTION_Z_ENABLE:
+			/* read no motion z */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr,
+			BMI160_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_2_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE);
+			break;
+		default:
+			com_rslt = E_BMI160_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief  This API is used to set
+ *	interrupt enable byte2 from the register bit 0x52 bit 0 to 3
+ *	@brief It reads no motion x,y and z
+ *
+ *
+ *
+ *	@param v_enable_u8: The value of interrupt enable
+ *   v_enable_u8   |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_NOMOTION_X_ENABLE
+ *       1         | BMI160_NOMOTION_Y_ENABLE
+ *       2         | BMI160_NOMOTION_Z_ENABLE
+ *
+ *	@param v_intr_enable_2_u8 : The interrupt enable value
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_enable_2(
+u8 v_enable_u8, u8 v_intr_enable_2_u8)
+{
+/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+	switch (v_enable_u8) {
+	case BMI160_NOMOTION_X_ENABLE:
+		/* write no motion x */
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+		dev_addr,
+		BMI160_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE,
+			v_intr_enable_2_u8);
+			com_rslt +=
+			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+			dev_addr,
+			BMI160_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	case BMI160_NOMOTION_Y_ENABLE:
+		/* write no motion y */
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+		dev_addr,
+		BMI160_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE,
+			v_intr_enable_2_u8);
+			com_rslt +=
+			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+			dev_addr,
+			BMI160_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	case BMI160_NOMOTION_Z_ENABLE:
+		/* write no motion z */
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+		dev_addr,
+		BMI160_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE,
+			v_intr_enable_2_u8);
+			com_rslt +=
+			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+			dev_addr,
+			BMI160_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	default:
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		break;
+	}
+}
+return com_rslt;
+}
+ /*!
+ *	@brief This API is used to read
+ *	interrupt enable step detector interrupt from
+ *	the register bit 0x52 bit 3
+ *
+ *
+ *
+ *
+ *	@param v_step_intr_u8 : The value of step detector interrupt enable
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_step_detector_enable(
+u8 *v_step_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the step detector interrupt*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr,
+			BMI160_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_step_intr_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API is used to set
+ *	interrupt enable step detector interrupt from
+ *	the register bit 0x52 bit 3
+ *
+ *
+ *
+ *
+ *	@param v_step_intr_u8 : The value of step detector interrupt enable
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_step_detector_enable(
+u8 v_step_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+		dev_addr,
+		BMI160_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE,
+			v_step_intr_u8);
+			com_rslt +=
+			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+			dev_addr,
+			BMI160_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief  Configure trigger condition of interrupt1
+ *	and interrupt2 pin from the register 0x53
+ *	@brief interrupt1 - bit 0
+ *	@brief interrupt2 - bit 4
+ *
+ *  @param v_channel_u8: The value of edge trigger selection
+ *   v_channel_u8  |   Edge trigger
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_EDGE_CTRL
+ *       1         | BMI160_INTR2_EDGE_CTRL
+ *
+ *	@param v_intr_edge_ctrl_u8 : The value of edge trigger enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_EDGE
+ *  0x00     |  BMI160_LEVEL
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_edge_ctrl(
+u8 v_channel_u8, u8 *v_intr_edge_ctrl_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		case BMI160_INTR1_EDGE_CTRL:
+			/* read the edge trigger interrupt1*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR1_EDGE_CTRL__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_edge_ctrl_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR1_EDGE_CTRL);
+			break;
+		case BMI160_INTR2_EDGE_CTRL:
+			/* read the edge trigger interrupt2*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR2_EDGE_CTRL__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_edge_ctrl_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR2_EDGE_CTRL);
+			break;
+		default:
+			com_rslt = E_BMI160_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief  Configure trigger condition of interrupt1
+ *	and interrupt2 pin from the register 0x53
+ *	@brief interrupt1 - bit 0
+ *	@brief interrupt2 - bit 4
+ *
+ *  @param v_channel_u8: The value of edge trigger selection
+ *   v_channel_u8  |   Edge trigger
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_EDGE_CTRL
+ *       1         | BMI160_INTR2_EDGE_CTRL
+ *
+ *	@param v_intr_edge_ctrl_u8 : The value of edge trigger enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_EDGE
+ *  0x00     |  BMI160_LEVEL
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_edge_ctrl(
+u8 v_channel_u8, u8 v_intr_edge_ctrl_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		case BMI160_INTR1_EDGE_CTRL:
+			/* write the edge trigger interrupt1*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR1_EDGE_CTRL__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR1_EDGE_CTRL,
+				v_intr_edge_ctrl_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+				dev_addr, BMI160_USER_INTR1_EDGE_CTRL__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+			break;
+		case BMI160_INTR2_EDGE_CTRL:
+			/* write the edge trigger interrupt2*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR2_EDGE_CTRL__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR2_EDGE_CTRL,
+				v_intr_edge_ctrl_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+				dev_addr, BMI160_USER_INTR2_EDGE_CTRL__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+			break;
+		default:
+			com_rslt = E_BMI160_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief  API used for get the Configure level condition of interrupt1
+ *	and interrupt2 pin form the register 0x53
+ *	@brief interrupt1 - bit 1
+ *	@brief interrupt2 - bit 5
+ *
+ *  @param v_channel_u8: The value of level condition selection
+ *   v_channel_u8  |   level selection
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_LEVEL
+ *       1         | BMI160_INTR2_LEVEL
+ *
+ *	@param v_intr_level_u8 : The value of level of interrupt enable
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x01     |  BMI160_LEVEL_HIGH
+ *  0x00     |  BMI160_LEVEL_LOW
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_level(
+u8 v_channel_u8, u8 *v_intr_level_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		case BMI160_INTR1_LEVEL:
+			/* read the interrupt1 level*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR1_LEVEL__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_level_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR1_LEVEL);
+			break;
+		case BMI160_INTR2_LEVEL:
+			/* read the interrupt2 level*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR2_LEVEL__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_level_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR2_LEVEL);
+			break;
+		default:
+			com_rslt = E_BMI160_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief  API used for set the Configure level condition of interrupt1
+ *	and interrupt2 pin form the register 0x53
+ *	@brief interrupt1 - bit 1
+ *	@brief interrupt2 - bit 5
+ *
+ *  @param v_channel_u8: The value of level condition selection
+ *   v_channel_u8  |   level selection
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_LEVEL
+ *       1         | BMI160_INTR2_LEVEL
+ *
+ *	@param v_intr_level_u8 : The value of level of interrupt enable
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x01     |  BMI160_LEVEL_HIGH
+ *  0x00     |  BMI160_LEVEL_LOW
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_level(
+u8 v_channel_u8, u8 v_intr_level_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		case BMI160_INTR1_LEVEL:
+			/* write the interrupt1 level*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR1_LEVEL__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR1_LEVEL, v_intr_level_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+				dev_addr, BMI160_USER_INTR1_LEVEL__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+			break;
+		case BMI160_INTR2_LEVEL:
+			/* write the interrupt2 level*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR2_LEVEL__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR2_LEVEL, v_intr_level_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+				dev_addr, BMI160_USER_INTR2_LEVEL__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+			break;
+		default:
+			com_rslt = E_BMI160_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief  API used to get configured output enable of interrupt1
+ *	and interrupt2 from the register 0x53
+ *	@brief interrupt1 - bit 2
+ *	@brief interrupt2 - bit 6
+ *
+ *
+ *  @param v_channel_u8: The value of output type enable selection
+ *   v_channel_u8  |   level selection
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_OUTPUT_TYPE
+ *       1         | BMI160_INTR2_OUTPUT_TYPE
+ *
+ *	@param v_intr_output_type_u8 :
+ *	The value of output type of interrupt enable
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x01     |  BMI160_OPEN_DRAIN
+ *  0x00     |  BMI160_PUSH_PULL
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_output_type(
+u8 v_channel_u8, u8 *v_intr_output_type_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		case BMI160_INTR1_OUTPUT_TYPE:
+			/* read the output type of interrupt1*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR1_OUTPUT_TYPE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_output_type_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR1_OUTPUT_TYPE);
+			break;
+		case BMI160_INTR2_OUTPUT_TYPE:
+			/* read the output type of interrupt2*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR2_OUTPUT_TYPE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_output_type_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR2_OUTPUT_TYPE);
+			break;
+		default:
+			com_rslt = E_BMI160_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief  API used to set output enable of interrupt1
+ *	and interrupt2 from the register 0x53
+ *	@brief interrupt1 - bit 2
+ *	@brief interrupt2 - bit 6
+ *
+ *
+ *  @param v_channel_u8: The value of output type enable selection
+ *   v_channel_u8  |   level selection
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_OUTPUT_TYPE
+ *       1         | BMI160_INTR2_OUTPUT_TYPE
+ *
+ *	@param v_intr_output_type_u8 :
+ *	The value of output type of interrupt enable
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x01     |  BMI160_OPEN_DRAIN
+ *  0x00     |  BMI160_PUSH_PULL
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_output_type(
+u8 v_channel_u8, u8 v_intr_output_type_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		case BMI160_INTR1_OUTPUT_TYPE:
+			/* write the output type of interrupt1*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR1_OUTPUT_TYPE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR1_OUTPUT_TYPE,
+				v_intr_output_type_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+				dev_addr, BMI160_USER_INTR1_OUTPUT_TYPE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+			break;
+		case BMI160_INTR2_OUTPUT_TYPE:
+			/* write the output type of interrupt2*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR2_OUTPUT_TYPE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR2_OUTPUT_TYPE,
+				v_intr_output_type_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+				dev_addr, BMI160_USER_INTR2_OUTPUT_TYPE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+			break;
+		default:
+			com_rslt = E_BMI160_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+ /*!
+ *	@brief API used to get the Output enable for interrupt1
+ *	and interrupt1 pin from the register 0x53
+ *	@brief interrupt1 - bit 3
+ *	@brief interrupt2 - bit 7
+ *
+ *  @param v_channel_u8: The value of output enable selection
+ *   v_channel_u8  |   level selection
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_OUTPUT_TYPE
+ *       1         | BMI160_INTR2_OUTPUT_TYPE
+ *
+ *	@param v_output_enable_u8 :
+ *	The value of output enable of interrupt enable
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x01     |  BMI160_INPUT
+ *  0x00     |  BMI160_OUTPUT
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_output_enable(
+u8 v_channel_u8, u8 *v_output_enable_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		case BMI160_INTR1_OUTPUT_ENABLE:
+			/* read the output enable of interrupt1*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR1_OUTPUT_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_output_enable_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR1_OUTPUT_ENABLE);
+			break;
+		case BMI160_INTR2_OUTPUT_ENABLE:
+			/* read the output enable of interrupt2*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR2_OUTPUT_EN__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_output_enable_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR2_OUTPUT_EN);
+			break;
+		default:
+			com_rslt = E_BMI160_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+ /*!
+ *	@brief API used to set the Output enable for interrupt1
+ *	and interrupt1 pin from the register 0x53
+ *	@brief interrupt1 - bit 3
+ *	@brief interrupt2 - bit 7
+ *
+ *  @param v_channel_u8: The value of output enable selection
+ *   v_channel_u8  |   level selection
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_OUTPUT_TYPE
+ *       1         | BMI160_INTR2_OUTPUT_TYPE
+ *
+ *	@param v_output_enable_u8 :
+ *	The value of output enable of interrupt enable
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x01     |  BMI160_INPUT
+ *  0x00     |  BMI160_OUTPUT
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_output_enable(
+u8 v_channel_u8, u8 v_output_enable_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		case BMI160_INTR1_OUTPUT_ENABLE:
+			/* write the output enable of interrupt1*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR1_OUTPUT_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR1_OUTPUT_ENABLE,
+				v_output_enable_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+				dev_addr, BMI160_USER_INTR1_OUTPUT_ENABLE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		break;
+		case BMI160_INTR2_OUTPUT_ENABLE:
+			/* write the output enable of interrupt2*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR2_OUTPUT_EN__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR2_OUTPUT_EN,
+				v_output_enable_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+				dev_addr, BMI160_USER_INTR2_OUTPUT_EN__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		break;
+		default:
+			com_rslt = E_BMI160_OUT_OF_RANGE;
+		break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+*	@brief This API is used to get the latch duration
+*	from the register 0x54 bit 0 to 3
+*	@brief This latch selection is not applicable for data ready,
+*	orientation and flat interrupts.
+*
+*
+*
+*  @param v_latch_intr_u8 : The value of latch duration
+*	Latch Duration                      |     value
+* --------------------------------------|------------------
+*    BMI160_LATCH_DUR_NONE              |      0x00
+*    BMI160_LATCH_DUR_312_5_MICRO_SEC   |      0x01
+*    BMI160_LATCH_DUR_625_MICRO_SEC     |      0x02
+*    BMI160_LATCH_DUR_1_25_MILLI_SEC    |      0x03
+*    BMI160_LATCH_DUR_2_5_MILLI_SEC     |      0x04
+*    BMI160_LATCH_DUR_5_MILLI_SEC       |      0x05
+*    BMI160_LATCH_DUR_10_MILLI_SEC      |      0x06
+*    BMI160_LATCH_DUR_20_MILLI_SEC      |      0x07
+*    BMI160_LATCH_DUR_40_MILLI_SEC      |      0x08
+*    BMI160_LATCH_DUR_80_MILLI_SEC      |      0x09
+*    BMI160_LATCH_DUR_160_MILLI_SEC     |      0x0A
+*    BMI160_LATCH_DUR_320_MILLI_SEC     |      0x0B
+*    BMI160_LATCH_DUR_640_MILLI_SEC     |      0x0C
+*    BMI160_LATCH_DUR_1_28_SEC          |      0x0D
+*    BMI160_LATCH_DUR_2_56_SEC          |      0x0E
+*    BMI160_LATCHED                     |      0x0F
+*
+*
+*
+*	@return results of bus communication function
+*	@retval 0 -> Success
+*	@retval -1 -> Error
+*
+*
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_latch_intr(
+u8 *v_latch_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the latch duration value */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_LATCH__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_latch_intr_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_LATCH);
+		}
+	return com_rslt;
+}
+/*!
+*	@brief This API is used to set the latch duration
+*	from the register 0x54 bit 0 to 3
+*	@brief This latch selection is not applicable for data ready,
+*	orientation and flat interrupts.
+*
+*
+*
+*  @param v_latch_intr_u8 : The value of latch duration
+*	Latch Duration                      |     value
+* --------------------------------------|------------------
+*    BMI160_LATCH_DUR_NONE              |      0x00
+*    BMI160_LATCH_DUR_312_5_MICRO_SEC   |      0x01
+*    BMI160_LATCH_DUR_625_MICRO_SEC     |      0x02
+*    BMI160_LATCH_DUR_1_25_MILLI_SEC    |      0x03
+*    BMI160_LATCH_DUR_2_5_MILLI_SEC     |      0x04
+*    BMI160_LATCH_DUR_5_MILLI_SEC       |      0x05
+*    BMI160_LATCH_DUR_10_MILLI_SEC      |      0x06
+*    BMI160_LATCH_DUR_20_MILLI_SEC      |      0x07
+*    BMI160_LATCH_DUR_40_MILLI_SEC      |      0x08
+*    BMI160_LATCH_DUR_80_MILLI_SEC      |      0x09
+*    BMI160_LATCH_DUR_160_MILLI_SEC     |      0x0A
+*    BMI160_LATCH_DUR_320_MILLI_SEC     |      0x0B
+*    BMI160_LATCH_DUR_640_MILLI_SEC     |      0x0C
+*    BMI160_LATCH_DUR_1_28_SEC          |      0x0D
+*    BMI160_LATCH_DUR_2_56_SEC          |      0x0E
+*    BMI160_LATCHED                     |      0x0F
+*
+*
+*
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+*
+*
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_latch_intr(u8 v_latch_intr_u8)
+{
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_latch_intr_u8 <= BMI160_MAX_LATCH_INTR) {
+			/* write the latch duration value */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_LATCH__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR_LATCH, v_latch_intr_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+				dev_addr, BMI160_USER_INTR_LATCH__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief API used to get input enable for interrupt1
+ *	and interrupt2 pin from the register 0x54
+ *	@brief interrupt1 - bit 4
+ *	@brief interrupt2 - bit 5
+ *
+ *  @param v_channel_u8: The value of input enable selection
+ *   v_channel_u8  |   input selection
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_INPUT_ENABLE
+ *       1         | BMI160_INTR2_INPUT_ENABLE
+ *
+ *	@param v_input_en_u8 :
+ *	The value of input enable of interrupt enable
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x01     |  BMI160_INPUT
+ *  0x00     |  BMI160_OUTPUT
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_input_enable(
+u8 v_channel_u8, u8 *v_input_en_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		/* read input enable of interrup1 and interrupt2*/
+		case BMI160_INTR1_INPUT_ENABLE:
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR1_INPUT_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_input_en_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR1_INPUT_ENABLE);
+			break;
+		case BMI160_INTR2_INPUT_ENABLE:
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR2_INPUT_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_input_en_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR2_INPUT_ENABLE);
+			break;
+		default:
+			com_rslt = E_BMI160_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief API used to set input enable for interrupt1
+ *	and interrupt2 pin from the register 0x54
+ *	@brief interrupt1 - bit 4
+ *	@brief interrupt2 - bit 5
+ *
+ *  @param v_channel_u8: The value of input enable selection
+ *   v_channel_u8  |   input selection
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_INPUT_ENABLE
+ *       1         | BMI160_INTR2_INPUT_ENABLE
+ *
+ *	@param v_input_en_u8 :
+ *	The value of input enable of interrupt enable
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x01     |  BMI160_INPUT
+ *  0x00     |  BMI160_OUTPUT
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_input_enable(
+u8 v_channel_u8, u8 v_input_en_u8)
+{
+/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+	switch (v_channel_u8) {
+	/* write input enable of interrup1 and interrupt2*/
+	case BMI160_INTR1_INPUT_ENABLE:
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+		dev_addr, BMI160_USER_INTR1_INPUT_ENABLE__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR1_INPUT_ENABLE, v_input_en_u8);
+			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR1_INPUT_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	break;
+	case BMI160_INTR2_INPUT_ENABLE:
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+		dev_addr, BMI160_USER_INTR2_INPUT_ENABLE__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR2_INPUT_ENABLE, v_input_en_u8);
+			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR2_INPUT_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	break;
+	default:
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+	break;
+	}
+}
+return com_rslt;
+}
+ /*!
+ *	@brief reads the Low g interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 0 in the register 0x55
+ *	@brief interrupt2 bit 0 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of low_g selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_LOW_G
+ *       1         | BMI160_INTR2_MAP_LOW_G
+ *
+ *	@param v_intr_low_g_u8 : The value of low_g enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_g(
+u8 v_channel_u8, u8 *v_intr_low_g_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		/* read the low_g interrupt */
+		case BMI160_INTR1_MAP_LOW_G:
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_0_INTR1_LOW_G__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_low_g_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_0_INTR1_LOW_G);
+			break;
+		case BMI160_INTR2_MAP_LOW_G:
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_2_INTR2_LOW_G__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_low_g_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_2_INTR2_LOW_G);
+			break;
+		default:
+			com_rslt = E_BMI160_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+ /*!
+ *	@brief set the Low g interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 0 in the register 0x55
+ *	@brief interrupt2 bit 0 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of low_g selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_LOW_G
+ *       1         | BMI160_INTR2_MAP_LOW_G
+ *
+ *	@param v_intr_low_g_u8 : The value of low_g enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_g(
+u8 v_channel_u8, u8 v_intr_low_g_u8)
+{
+/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+u8 v_step_cnt_stat_u8 = BMI160_INIT_VALUE;
+u8 v_step_det_stat_u8 = BMI160_INIT_VALUE;
+
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+	/* check the step detector interrupt enable status*/
+	com_rslt = bmi160_get_step_detector_enable(&v_step_det_stat_u8);
+	/* disable the step detector interrupt */
+	if (v_step_det_stat_u8 != BMI160_INIT_VALUE)
+		com_rslt += bmi160_set_step_detector_enable(BMI160_INIT_VALUE);
+	/* check the step counter interrupt enable status*/
+	com_rslt += bmi160_get_step_counter_enable(&v_step_cnt_stat_u8);
+	/* disable the step counter interrupt */
+	if (v_step_cnt_stat_u8 != BMI160_INIT_VALUE)
+			com_rslt += bmi160_set_step_counter_enable(
+			BMI160_INIT_VALUE);
+	switch (v_channel_u8) {
+	/* write the low_g interrupt*/
+	case BMI160_INTR1_MAP_LOW_G:
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+		dev_addr, BMI160_USER_INTR_MAP_0_INTR1_LOW_G__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_0_INTR1_LOW_G, v_intr_low_g_u8);
+			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_0_INTR1_LOW_G__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	case BMI160_INTR2_MAP_LOW_G:
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+		dev_addr, BMI160_USER_INTR_MAP_2_INTR2_LOW_G__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_2_INTR2_LOW_G, v_intr_low_g_u8);
+			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_2_INTR2_LOW_G__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	default:
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		break;
+	}
+}
+return com_rslt;
+}
+/*!
+ *	@brief Reads the HIGH g interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 1 in the register 0x55
+ *	@brief interrupt2 bit 1 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of high_g selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_HIGH_G
+ *       1         | BMI160_INTR2_MAP_HIGH_G
+ *
+ *	@param v_intr_high_g_u8 : The value of high_g enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_high_g(
+u8 v_channel_u8, u8 *v_intr_high_g_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		/* read the high_g interrupt*/
+		switch (v_channel_u8) {
+		case BMI160_INTR1_MAP_HIGH_G:
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_0_INTR1_HIGH_G__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_high_g_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_0_INTR1_HIGH_G);
+		break;
+		case BMI160_INTR2_MAP_HIGH_G:
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_2_INTR2_HIGH_G__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_high_g_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_2_INTR2_HIGH_G);
+		break;
+		default:
+			com_rslt = E_BMI160_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief Write the HIGH g interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 1 in the register 0x55
+ *	@brief interrupt2 bit 1 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of high_g selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_HIGH_G
+ *       1         | BMI160_INTR2_MAP_HIGH_G
+ *
+ *	@param v_intr_high_g_u8 : The value of high_g enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_high_g(
+u8 v_channel_u8, u8 v_intr_high_g_u8)
+{
+/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+	switch (v_channel_u8) {
+	/* write the high_g interrupt*/
+	case BMI160_INTR1_MAP_HIGH_G:
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+		dev_addr, BMI160_USER_INTR_MAP_0_INTR1_HIGH_G__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_0_INTR1_HIGH_G, v_intr_high_g_u8);
+			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_0_INTR1_HIGH_G__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	break;
+	case BMI160_INTR2_MAP_HIGH_G:
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+		dev_addr, BMI160_USER_INTR_MAP_2_INTR2_HIGH_G__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_2_INTR2_HIGH_G, v_intr_high_g_u8);
+			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_2_INTR2_HIGH_G__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	break;
+	default:
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+	break;
+	}
+}
+return com_rslt;
+}
+/*!
+ *	@brief Reads the Any motion interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 2 in the register 0x55
+ *	@brief interrupt2 bit 2 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of any motion selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_ANY_MOTION
+ *       1         | BMI160_INTR2_MAP_ANY_MOTION
+ *
+ *	@param v_intr_any_motion_u8 : The value of any motion enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_any_motion(
+u8 v_channel_u8, u8 *v_intr_any_motion_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		/* read the any motion interrupt */
+		case BMI160_INTR1_MAP_ANY_MOTION:
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_any_motion_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION);
+		break;
+		case BMI160_INTR2_MAP_ANY_MOTION:
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_any_motion_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION);
+		break;
+		default:
+			com_rslt = E_BMI160_OUT_OF_RANGE;
+		break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief Write the Any motion interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 2 in the register 0x55
+ *	@brief interrupt2 bit 2 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of any motion selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_ANY_MOTION
+ *       1         | BMI160_INTR2_MAP_ANY_MOTION
+ *
+ *	@param v_intr_any_motion_u8 : The value of any motion enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_any_motion(
+u8 v_channel_u8, u8 v_intr_any_motion_u8)
+{
+/* variable used for return the status of communication result*/
+BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+u8 sig_mot_stat = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+	/* read the status of significant motion interrupt */
+	com_rslt = bmi160_get_intr_significant_motion_select(&sig_mot_stat);
+	/* disable the significant motion interrupt */
+	if (sig_mot_stat != BMI160_INIT_VALUE)
+		com_rslt += bmi160_set_intr_significant_motion_select(
+		BMI160_INIT_VALUE);
+	switch (v_channel_u8) {
+	/* write the any motion interrupt */
+	case BMI160_INTR1_MAP_ANY_MOTION:
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+		dev_addr, BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION,
+			v_intr_any_motion_u8);
+			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	break;
+	case BMI160_INTR2_MAP_ANY_MOTION:
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+		dev_addr, BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION,
+			v_intr_any_motion_u8);
+			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	break;
+	default:
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+	break;
+	}
+}
+return com_rslt;
+}
+/*!
+ *	@brief Reads the No motion interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 3 in the register 0x55
+ *	@brief interrupt2 bit 3 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of no motion selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_NOMO
+ *       1         | BMI160_INTR2_MAP_NOMO
+ *
+ *	@param v_intr_nomotion_u8 : The value of no motion enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_nomotion(
+u8 v_channel_u8, u8 *v_intr_nomotion_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		/* read the no motion interrupt*/
+		case BMI160_INTR1_MAP_NOMO:
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_0_INTR1_NOMOTION__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_nomotion_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_0_INTR1_NOMOTION);
+			break;
+		case BMI160_INTR2_MAP_NOMO:
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_2_INTR2_NOMOTION__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_nomotion_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_2_INTR2_NOMOTION);
+			break;
+		default:
+			com_rslt = E_BMI160_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief Write the No motion interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 3 in the register 0x55
+ *	@brief interrupt2 bit 3 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of no motion selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_NOMO
+ *       1         | BMI160_INTR2_MAP_NOMO
+ *
+ *	@param v_intr_nomotion_u8 : The value of no motion enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_nomotion(
+u8 v_channel_u8, u8 v_intr_nomotion_u8)
+{
+/* variable used for return the status of communication result*/
+BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+	switch (v_channel_u8) {
+	/* write the no motion interrupt*/
+	case BMI160_INTR1_MAP_NOMO:
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+		dev_addr, BMI160_USER_INTR_MAP_0_INTR1_NOMOTION__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_0_INTR1_NOMOTION,
+			v_intr_nomotion_u8);
+			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_0_INTR1_NOMOTION__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	case BMI160_INTR2_MAP_NOMO:
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+		dev_addr, BMI160_USER_INTR_MAP_2_INTR2_NOMOTION__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_2_INTR2_NOMOTION,
+			v_intr_nomotion_u8);
+			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_2_INTR2_NOMOTION__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	default:
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		break;
+	}
+}
+return com_rslt;
+}
+/*!
+ *	@brief Reads the Double Tap interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 4 in the register 0x55
+ *	@brief interrupt2 bit 4 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of double tap interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_DOUBLE_TAP
+ *       1         | BMI160_INTR2_MAP_DOUBLE_TAP
+ *
+ *	@param v_intr_double_tap_u8 : The value of double tap enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_double_tap(
+u8 v_channel_u8, u8 *v_intr_double_tap_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		case BMI160_INTR1_MAP_DOUBLE_TAP:
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_0_INTR1_DOUBLE_TAP__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_double_tap_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_0_INTR1_DOUBLE_TAP);
+			break;
+		case BMI160_INTR2_MAP_DOUBLE_TAP:
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_2_INTR2_DOUBLE_TAP__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_double_tap_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_2_INTR2_DOUBLE_TAP);
+			break;
+		default:
+			com_rslt = E_BMI160_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief Write the Double Tap interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 4 in the register 0x55
+ *	@brief interrupt2 bit 4 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of double tap interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_DOUBLE_TAP
+ *       1         | BMI160_INTR2_MAP_DOUBLE_TAP
+ *
+ *	@param v_intr_double_tap_u8 : The value of double tap enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_double_tap(
+u8 v_channel_u8, u8 v_intr_double_tap_u8)
+{
+/* variable used for return the status of communication result*/
+BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+	switch (v_channel_u8) {
+	/* set the double tap interrupt */
+	case BMI160_INTR1_MAP_DOUBLE_TAP:
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+		dev_addr, BMI160_USER_INTR_MAP_0_INTR1_DOUBLE_TAP__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_0_INTR1_DOUBLE_TAP,
+			v_intr_double_tap_u8);
+			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_0_INTR1_DOUBLE_TAP__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	case BMI160_INTR2_MAP_DOUBLE_TAP:
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+		dev_addr, BMI160_USER_INTR_MAP_2_INTR2_DOUBLE_TAP__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_2_INTR2_DOUBLE_TAP,
+			v_intr_double_tap_u8);
+			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_2_INTR2_DOUBLE_TAP__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	default:
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		break;
+	}
+}
+return com_rslt;
+}
+/*!
+ *	@brief Reads the Single Tap interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 5 in the register 0x55
+ *	@brief interrupt2 bit 5 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of single tap interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_SINGLE_TAP
+ *       1         | BMI160_INTR2_MAP_SINGLE_TAP
+ *
+ *	@param v_intr_single_tap_u8 : The value of single tap  enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_single_tap(
+u8 v_channel_u8, u8 *v_intr_single_tap_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		/* reads the single tap interrupt*/
+		case BMI160_INTR1_MAP_SINGLE_TAP:
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_0_INTR1_SINGLE_TAP__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_single_tap_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_0_INTR1_SINGLE_TAP);
+			break;
+		case BMI160_INTR2_MAP_SINGLE_TAP:
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_2_INTR2_SINGLE_TAP__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_single_tap_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_2_INTR2_SINGLE_TAP);
+			break;
+		default:
+			com_rslt = E_BMI160_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief Write the Single Tap interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 5 in the register 0x55
+ *	@brief interrupt2 bit 5 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of single tap interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_SINGLE_TAP
+ *       1         | BMI160_INTR2_MAP_SINGLE_TAP
+ *
+ *	@param v_intr_single_tap_u8 : The value of single tap  enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_single_tap(
+u8 v_channel_u8, u8 v_intr_single_tap_u8)
+{
+/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+	switch (v_channel_u8) {
+	/* write the single tap interrupt */
+	case BMI160_INTR1_MAP_SINGLE_TAP:
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+		dev_addr, BMI160_USER_INTR_MAP_0_INTR1_SINGLE_TAP__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_0_INTR1_SINGLE_TAP,
+			v_intr_single_tap_u8);
+			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_0_INTR1_SINGLE_TAP__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	case BMI160_INTR2_MAP_SINGLE_TAP:
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+		dev_addr, BMI160_USER_INTR_MAP_2_INTR2_SINGLE_TAP__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_2_INTR2_SINGLE_TAP,
+			v_intr_single_tap_u8);
+			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_2_INTR2_SINGLE_TAP__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	default:
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		break;
+	}
+}
+return com_rslt;
+}
+/*!
+ *	@brief Reads the Orient interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 6 in the register 0x55
+ *	@brief interrupt2 bit 6 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of orient interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_ORIENT
+ *       1         | BMI160_INTR2_MAP_ORIENT
+ *
+ *	@param v_intr_orient_u8 : The value of orient enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient(
+u8 v_channel_u8, u8 *v_intr_orient_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		/* read the orientation interrupt*/
+		case BMI160_INTR1_MAP_ORIENT:
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_0_INTR1_ORIENT__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_orient_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_0_INTR1_ORIENT);
+			break;
+		case BMI160_INTR2_MAP_ORIENT:
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_2_INTR2_ORIENT__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_orient_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_2_INTR2_ORIENT);
+			break;
+		default:
+			com_rslt = E_BMI160_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief Write the Orient interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 6 in the register 0x55
+ *	@brief interrupt2 bit 6 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of orient interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_ORIENT
+ *       1         | BMI160_INTR2_MAP_ORIENT
+ *
+ *	@param v_intr_orient_u8 : The value of orient enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient(
+u8 v_channel_u8, u8 v_intr_orient_u8)
+{
+/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+	switch (v_channel_u8) {
+	/* write the orientation interrupt*/
+	case BMI160_INTR1_MAP_ORIENT:
+		com_rslt =
+		p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+		dev_addr, BMI160_USER_INTR_MAP_0_INTR1_ORIENT__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_0_INTR1_ORIENT, v_intr_orient_u8);
+			com_rslt +=
+			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_0_INTR1_ORIENT__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	case BMI160_INTR2_MAP_ORIENT:
+		com_rslt =
+		p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+		dev_addr, BMI160_USER_INTR_MAP_2_INTR2_ORIENT__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 =
+			BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_2_INTR2_ORIENT, v_intr_orient_u8);
+			com_rslt +=
+			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_2_INTR2_ORIENT__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	default:
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		break;
+	}
+}
+return com_rslt;
+}
+ /*!
+ *	@brief Reads the Flat interrupt
+ *	mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 7 in the register 0x55
+ *	@brief interrupt2 bit 7 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of flat interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_FLAT
+ *       1         | BMI160_INTR2_MAP_FLAT
+ *
+ *	@param v_intr_flat_u8 : The value of flat enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_flat(
+u8 v_channel_u8, u8 *v_intr_flat_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		/* read the flat interrupt*/
+		case BMI160_INTR1_MAP_FLAT:
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_0_INTR1_FLAT__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_flat_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_0_INTR1_FLAT);
+			break;
+		case BMI160_INTR2_MAP_FLAT:
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_2_INTR2_FLAT__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_flat_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_2_INTR2_FLAT);
+			break;
+		default:
+			com_rslt = E_BMI160_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+ /*!
+ *	@brief Write the Flat interrupt
+ *	mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 7 in the register 0x55
+ *	@brief interrupt2 bit 7 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of flat interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_FLAT
+ *       1         | BMI160_INTR2_MAP_FLAT
+ *
+ *	@param v_intr_flat_u8 : The value of flat enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_flat(
+u8 v_channel_u8, u8 v_intr_flat_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		/* write the flat interrupt */
+		case BMI160_INTR1_MAP_FLAT:
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_0_INTR1_FLAT__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 =
+				BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR_MAP_0_INTR1_FLAT,
+				v_intr_flat_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+				dev_addr,
+				BMI160_USER_INTR_MAP_0_INTR1_FLAT__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+			break;
+		case BMI160_INTR2_MAP_FLAT:
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_2_INTR2_FLAT__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR_MAP_2_INTR2_FLAT,
+				v_intr_flat_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+				dev_addr,
+				BMI160_USER_INTR_MAP_2_INTR2_FLAT__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+			break;
+		default:
+			com_rslt = E_BMI160_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief Reads PMU trigger interrupt mapped to interrupt1
+ *	and interrupt2 form the register 0x56 bit 0 and 4
+ *	@brief interrupt1 bit 0 in the register 0x56
+ *	@brief interrupt2 bit 4 in the register 0x56
+ *
+ *
+ *	@param v_channel_u8: The value of pmu trigger selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_PMUTRIG
+ *       1         | BMI160_INTR2_MAP_PMUTRIG
+ *
+ *	@param v_intr_pmu_trig_u8 : The value of pmu trigger enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_pmu_trig(
+u8 v_channel_u8, u8 *v_intr_pmu_trig_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		/* read the pmu trigger interrupt*/
+		case BMI160_INTR1_MAP_PMUTRIG:
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_1_INTR1_PMU_TRIG__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_pmu_trig_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_1_INTR1_PMU_TRIG);
+			break;
+		case BMI160_INTR2_MAP_PMUTRIG:
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_1_INTR2_PMU_TRIG__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_pmu_trig_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_1_INTR2_PMU_TRIG);
+			break;
+		default:
+			com_rslt = E_BMI160_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief Write PMU trigger interrupt mapped to interrupt1
+ *	and interrupt2 form the register 0x56 bit 0 and 4
+ *	@brief interrupt1 bit 0 in the register 0x56
+ *	@brief interrupt2 bit 4 in the register 0x56
+ *
+ *
+ *	@param v_channel_u8: The value of pmu trigger selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_PMUTRIG
+ *       1         | BMI160_INTR2_MAP_PMUTRIG
+ *
+ *	@param v_intr_pmu_trig_u8 : The value of pmu trigger enable
+ *	value    | trigger enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_pmu_trig(
+u8 v_channel_u8, u8 v_intr_pmu_trig_u8)
+{
+/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+	switch (v_channel_u8) {
+	/* write the pmu trigger interrupt */
+	case BMI160_INTR1_MAP_PMUTRIG:
+		com_rslt =
+		p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+		dev_addr, BMI160_USER_INTR_MAP_1_INTR1_PMU_TRIG__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 =
+			BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_1_INTR1_PMU_TRIG,
+			v_intr_pmu_trig_u8);
+			com_rslt +=
+			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_1_INTR1_PMU_TRIG__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	break;
+	case BMI160_INTR2_MAP_PMUTRIG:
+		com_rslt =
+		p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+		dev_addr, BMI160_USER_INTR_MAP_1_INTR2_PMU_TRIG__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 =
+			BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_1_INTR2_PMU_TRIG,
+			v_intr_pmu_trig_u8);
+			com_rslt +=
+			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_1_INTR2_PMU_TRIG__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	break;
+	default:
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+	break;
+	}
+}
+return com_rslt;
+}
+/*!
+ *	@brief Reads FIFO Full interrupt mapped to interrupt1
+ *	and interrupt2 form the register 0x56 bit 5 and 1
+ *	@brief interrupt1 bit 5 in the register 0x56
+ *	@brief interrupt2 bit 1 in the register 0x56
+ *
+ *
+ *	@param v_channel_u8: The value of fifo full interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_FIFO_FULL
+ *       1         | BMI160_INTR2_MAP_FIFO_FULL
+ *
+ *	@param v_intr_fifo_full_u8 : The value of fifo full interrupt enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_fifo_full(
+u8 v_channel_u8, u8 *v_intr_fifo_full_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		/* read the fifo full interrupt */
+		case BMI160_INTR1_MAP_FIFO_FULL:
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_1_INTR1_FIFO_FULL__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_fifo_full_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_1_INTR1_FIFO_FULL);
+		break;
+		case BMI160_INTR2_MAP_FIFO_FULL:
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_1_INTR2_FIFO_FULL__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_fifo_full_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_1_INTR2_FIFO_FULL);
+		break;
+		default:
+			com_rslt = E_BMI160_OUT_OF_RANGE;
+		break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief Write FIFO Full interrupt mapped to interrupt1
+ *	and interrupt2 form the register 0x56 bit 5 and 1
+ *	@brief interrupt1 bit 5 in the register 0x56
+ *	@brief interrupt2 bit 1 in the register 0x56
+ *
+ *
+ *	@param v_channel_u8: The value of fifo full interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_FIFO_FULL
+ *       1         | BMI160_INTR2_MAP_FIFO_FULL
+ *
+ *	@param v_intr_fifo_full_u8 : The value of fifo full interrupt enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_fifo_full(
+u8 v_channel_u8, u8 v_intr_fifo_full_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		/* write the fifo full interrupt */
+		case BMI160_INTR1_MAP_FIFO_FULL:
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_1_INTR1_FIFO_FULL__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 =
+				BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR_MAP_1_INTR1_FIFO_FULL,
+				v_intr_fifo_full_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+				dev_addr,
+				BMI160_USER_INTR_MAP_1_INTR1_FIFO_FULL__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		break;
+		case BMI160_INTR2_MAP_FIFO_FULL:
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_1_INTR2_FIFO_FULL__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 =
+				BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR_MAP_1_INTR2_FIFO_FULL,
+				v_intr_fifo_full_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+				dev_addr,
+				BMI160_USER_INTR_MAP_1_INTR2_FIFO_FULL__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		break;
+		default:
+			com_rslt = E_BMI160_OUT_OF_RANGE;
+		break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief Reads FIFO Watermark interrupt mapped to interrupt1
+ *	and interrupt2 form the register 0x56 bit 6 and 2
+ *	@brief interrupt1 bit 6 in the register 0x56
+ *	@brief interrupt2 bit 2 in the register 0x56
+ *
+ *
+ *	@param v_channel_u8: The value of fifo Watermark interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_FIFO_WM
+ *       1         | BMI160_INTR2_MAP_FIFO_WM
+ *
+ *	@param v_intr_fifo_wm_u8 : The value of fifo Watermark interrupt enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_fifo_wm(
+u8 v_channel_u8, u8 *v_intr_fifo_wm_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		/* read the fifo water mark interrupt */
+		case BMI160_INTR1_MAP_FIFO_WM:
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_1_INTR1_FIFO_WM__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_fifo_wm_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_1_INTR1_FIFO_WM);
+			break;
+		case BMI160_INTR2_MAP_FIFO_WM:
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_1_INTR2_FIFO_WM__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_fifo_wm_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_1_INTR2_FIFO_WM);
+			break;
+		default:
+			com_rslt = E_BMI160_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief Write FIFO Watermark interrupt mapped to interrupt1
+ *	and interrupt2 form the register 0x56 bit 6 and 2
+ *	@brief interrupt1 bit 6 in the register 0x56
+ *	@brief interrupt2 bit 2 in the register 0x56
+ *
+ *
+ *	@param v_channel_u8: The value of fifo Watermark interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_FIFO_WM
+ *       1         | BMI160_INTR2_MAP_FIFO_WM
+ *
+ *	@param v_intr_fifo_wm_u8 : The value of fifo Watermark interrupt enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_fifo_wm(
+u8 v_channel_u8, u8 v_intr_fifo_wm_u8)
+{
+/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		/* write the fifo water mark interrupt */
+		case BMI160_INTR1_MAP_FIFO_WM:
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_1_INTR1_FIFO_WM__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR_MAP_1_INTR1_FIFO_WM,
+				v_intr_fifo_wm_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+				dev_addr,
+				BMI160_USER_INTR_MAP_1_INTR1_FIFO_WM__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+			break;
+		case BMI160_INTR2_MAP_FIFO_WM:
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_1_INTR2_FIFO_WM__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR_MAP_1_INTR2_FIFO_WM,
+				v_intr_fifo_wm_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+				dev_addr,
+				BMI160_USER_INTR_MAP_1_INTR2_FIFO_WM__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+			break;
+		default:
+			com_rslt = E_BMI160_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief Reads Data Ready interrupt mapped to interrupt1
+ *	and interrupt2 form the register 0x56
+ *	@brief interrupt1 bit 7 in the register 0x56
+ *	@brief interrupt2 bit 3 in the register 0x56
+ *
+ *
+ *	@param v_channel_u8: The value of data ready interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_DATA_RDY
+ *       1         | BMI160_INTR2_MAP_DATA_RDY
+ *
+ *	@param v_intr_data_rdy_u8 : The value of data ready interrupt enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_data_rdy(
+u8 v_channel_u8, u8 *v_intr_data_rdy_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		/*Read Data Ready interrupt*/
+		case BMI160_INTR1_MAP_DATA_RDY:
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_1_INTR1_DATA_RDY__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_data_rdy_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_1_INTR1_DATA_RDY);
+			break;
+		case BMI160_INTR2_MAP_DATA_RDY:
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_1_INTR2_DATA_RDY__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_data_rdy_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_1_INTR2_DATA_RDY);
+			break;
+		default:
+			com_rslt = E_BMI160_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief Write Data Ready interrupt mapped to interrupt1
+ *	and interrupt2 form the register 0x56
+ *	@brief interrupt1 bit 7 in the register 0x56
+ *	@brief interrupt2 bit 3 in the register 0x56
+ *
+ *
+ *	@param v_channel_u8: The value of data ready interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_DATA_RDY
+ *       1         | BMI160_INTR2_MAP_DATA_RDY
+ *
+ *	@param v_intr_data_rdy_u8 : The value of data ready interrupt enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_data_rdy(
+u8 v_channel_u8, u8 v_intr_data_rdy_u8)
+{
+/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+	switch (v_channel_u8) {
+	/*Write Data Ready interrupt*/
+	case BMI160_INTR1_MAP_DATA_RDY:
+		com_rslt =
+		p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+		dev_addr, BMI160_USER_INTR_MAP_1_INTR1_DATA_RDY__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_1_INTR1_DATA_RDY,
+			v_intr_data_rdy_u8);
+			com_rslt +=
+			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_1_INTR1_DATA_RDY__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	break;
+	case BMI160_INTR2_MAP_DATA_RDY:
+		com_rslt =
+		p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+		dev_addr, BMI160_USER_INTR_MAP_1_INTR2_DATA_RDY__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MAP_1_INTR2_DATA_RDY,
+			v_intr_data_rdy_u8);
+			com_rslt +=
+			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+			dev_addr, BMI160_USER_INTR_MAP_1_INTR2_DATA_RDY__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	break;
+	default:
+	com_rslt = E_BMI160_OUT_OF_RANGE;
+	break;
+	}
+}
+return com_rslt;
+}
+ /*!
+ *	@brief This API reads data source for the interrupt
+ *	engine for the single and double tap interrupts from the register
+ *	0x58 bit 3
+ *
+ *
+ *  @param v_tap_source_u8 : The value of the tap source
+ *	value    | Description
+ * ----------|-------------------
+ *  0x01     |  UNFILTER_DATA
+ *  0x00     |  FILTER_DATA
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_tap_source(u8 *v_tap_source_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the tap source interrupt */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_INTR_DATA_0_INTR_TAP_SOURCE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_tap_source_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_DATA_0_INTR_TAP_SOURCE);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write data source for the interrupt
+ *	engine for the single and double tap interrupts from the register
+ *	0x58 bit 3
+ *
+ *
+ *  @param v_tap_source_u8 : The value of the tap source
+ *	value    | Description
+ * ----------|-------------------
+ *  0x01     |  UNFILTER_DATA
+ *  0x00     |  FILTER_DATA
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_tap_source(
+u8 v_tap_source_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_tap_source_u8 <= BMI160_MAX_VALUE_SOURCE_INTR) {
+			/* write the tap source interrupt */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_INTR_DATA_0_INTR_TAP_SOURCE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR_DATA_0_INTR_TAP_SOURCE,
+				v_tap_source_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
+				(p_bmi160->dev_addr,
+				BMI160_USER_INTR_DATA_0_INTR_TAP_SOURCE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API Reads Data source for the
+ *	interrupt engine for the low and high g interrupts
+ *	from the register 0x58 bit 7
+ *
+ *  @param v_low_high_source_u8 : The value of the tap source
+ *	value    | Description
+ * ----------|-------------------
+ *  0x01     |  UNFILTER_DATA
+ *  0x00     |  FILTER_DATA
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_high_source(
+u8 *v_low_high_source_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the high_low_g source interrupt */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_low_high_source_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write Data source for the
+ *	interrupt engine for the low and high g interrupts
+ *	from the register 0x58 bit 7
+ *
+ *  @param v_low_high_source_u8 : The value of the tap source
+ *	value    | Description
+ * ----------|-------------------
+ *  0x01     |  UNFILTER_DATA
+ *  0x00     |  FILTER_DATA
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_high_source(
+u8 v_low_high_source_u8)
+{
+/* variable used for return the status of communication result*/
+BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+	if (v_low_high_source_u8 <= BMI160_MAX_VALUE_SOURCE_INTR) {
+		/* write the high_low_g source interrupt */
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+		(p_bmi160->dev_addr,
+		BMI160_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE,
+			v_low_high_source_u8);
+			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	} else {
+	com_rslt = E_BMI160_OUT_OF_RANGE;
+	}
+}
+return com_rslt;
+}
+ /*!
+ *	@brief This API reads Data source for the
+ *	interrupt engine for the nomotion and anymotion interrupts
+ *	from the register 0x59 bit 7
+ *
+ *  @param v_motion_source_u8 :
+ *	The value of the any/no motion interrupt source
+ *	value    | Description
+ * ----------|-------------------
+ *  0x01     |  UNFILTER_DATA
+ *  0x00     |  FILTER_DATA
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_motion_source(
+u8 *v_motion_source_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the any/no motion interrupt  */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_INTR_DATA_1_INTR_MOTION_SOURCE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_motion_source_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_DATA_1_INTR_MOTION_SOURCE);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write Data source for the
+ *	interrupt engine for the nomotion and anymotion interrupts
+ *	from the register 0x59 bit 7
+ *
+ *  @param v_motion_source_u8 :
+ *	The value of the any/no motion interrupt source
+ *	value    | Description
+ * ----------|-------------------
+ *  0x01     |  UNFILTER_DATA
+ *  0x00     |  FILTER_DATA
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_motion_source(
+u8 v_motion_source_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_motion_source_u8 <= BMI160_MAX_VALUE_SOURCE_INTR) {
+			/* write the any/no motion interrupt  */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_INTR_DATA_1_INTR_MOTION_SOURCE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR_DATA_1_INTR_MOTION_SOURCE,
+				v_motion_source_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_INTR_DATA_1_INTR_MOTION_SOURCE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API is used to read the low_g duration from register
+ *	0x5A bit 0 to 7
+ *
+ *
+ *
+ *
+ *  @param v_low_g_durn_u8 : The value of low_g duration
+ *
+ *	@note Low_g duration trigger trigger delay according to
+ *	"(v_low_g_durn_u8 * 2.5)ms" in a range from 2.5ms to 640ms.
+ *	the default corresponds delay is 20ms
+ *	@note When low_g data source of interrupt is unfiltered
+ *	the sensor must not be in low power mode
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_g_durn(
+u8 *v_low_g_durn_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the low_g interrupt */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_INTR_LOWHIGH_0_INTR_LOW_DURN__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_low_g_durn_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_LOWHIGH_0_INTR_LOW_DURN);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API is used to write the low_g duration from register
+ *	0x5A bit 0 to 7
+ *
+ *
+ *
+ *
+ *  @param v_low_g_durn_u8 : The value of low_g duration
+ *
+ *	@note Low_g duration trigger trigger delay according to
+ *	"(v_low_g_durn_u8 * 2.5)ms" in a range from 2.5ms to 640ms.
+ *	the default corresponds delay is 20ms
+ *	@note When low_g data source of interrupt is unfiltered
+ *	the sensor must not be in low power mode
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_g_durn(u8 v_low_g_durn_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* write the low_g interrupt */
+			com_rslt = p_bmi160->BMI160_BUS_WRITE_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_INTR_LOWHIGH_0_INTR_LOW_DURN__REG,
+			&v_low_g_durn_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to read Threshold
+ *	definition for the low-g interrupt from the register 0x5B bit 0 to 7
+ *
+ *
+ *
+ *
+ *  @param v_low_g_thres_u8 : The value of low_g threshold
+ *
+ *	@note Low_g interrupt trigger threshold according to
+ *	(v_low_g_thres_u8 * 7.81)mg for v_low_g_thres_u8 > 0
+ *	3.91 mg for v_low_g_thres_u8 = 0
+ *	The threshold range is form 3.91mg to 2.000mg
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_g_thres(
+u8 *v_low_g_thres_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read low_g threshold */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_INTR_LOWHIGH_1_INTR_LOW_THRES__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_low_g_thres_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_LOWHIGH_1_INTR_LOW_THRES);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to write Threshold
+ *	definition for the low-g interrupt from the register 0x5B bit 0 to 7
+ *
+ *
+ *
+ *
+ *  @param v_low_g_thres_u8 : The value of low_g threshold
+ *
+ *	@note Low_g interrupt trigger threshold according to
+ *	(v_low_g_thres_u8 * 7.81)mg for v_low_g_thres_u8 > 0
+ *	3.91 mg for v_low_g_thres_u8 = 0
+ *	The threshold range is form 3.91mg to 2.000mg
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_g_thres(
+u8 v_low_g_thres_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* write low_g threshold */
+			com_rslt = p_bmi160->BMI160_BUS_WRITE_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_INTR_LOWHIGH_1_INTR_LOW_THRES__REG,
+			&v_low_g_thres_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API Reads Low-g interrupt hysteresis
+ *	from the register 0x5C bit 0 to 1
+ *
+ *  @param v_low_hyst_u8 :The value of low_g hysteresis
+ *
+ *	@note Low_g hysteresis calculated by v_low_hyst_u8*125 mg
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_g_hyst(
+u8 *v_low_hyst_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read low_g hysteresis*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_low_hyst_u8 = BMI160_GET_BITSLICE(
+			v_data_u8,
+			BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write Low-g interrupt hysteresis
+ *	from the register 0x5C bit 0 to 1
+ *
+ *  @param v_low_hyst_u8 :The value of low_g hysteresis
+ *
+ *	@note Low_g hysteresis calculated by v_low_hyst_u8*125 mg
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_g_hyst(
+u8 v_low_hyst_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* write low_g hysteresis*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST,
+				v_low_hyst_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads Low-g interrupt mode
+ *	from the register 0x5C bit 2
+ *
+ *  @param v_low_g_mode_u8 : The value of low_g mode
+ *	Value    |  Description
+ * ----------|-----------------
+ *	   0     | single-axis
+ *     1     | axis-summing
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_g_mode(u8 *v_low_g_mode_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/*read Low-g interrupt mode*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_low_g_mode_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write Low-g interrupt mode
+ *	from the register 0x5C bit 2
+ *
+ *  @param v_low_g_mode_u8 : The value of low_g mode
+ *	Value    |  Description
+ * ----------|-----------------
+ *	   0     | single-axis
+ *     1     | axis-summing
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_g_mode(
+u8 v_low_g_mode_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_low_g_mode_u8 <= BMI160_MAX_VALUE_LOW_G_MODE) {
+			/*write Low-g interrupt mode*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE,
+				v_low_g_mode_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads High-g interrupt hysteresis
+ *	from the register 0x5C bit 6 and 7
+ *
+ *  @param v_high_g_hyst_u8 : The value of high hysteresis
+ *
+ *	@note High_g hysteresis changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | high_g hysteresis
+ *  ----------------|---------------------
+ *      2g          |  high_hy*125 mg
+ *      4g          |  high_hy*250 mg
+ *      8g          |  high_hy*500 mg
+ *      16g         |  high_hy*1000 mg
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_high_g_hyst(
+u8 *v_high_g_hyst_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read high_g hysteresis*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_high_g_hyst_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write High-g interrupt hysteresis
+ *	from the register 0x5C bit 6 and 7
+ *
+ *  @param v_high_g_hyst_u8 : The value of high hysteresis
+ *
+ *	@note High_g hysteresis changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | high_g hysteresis
+ *  ----------------|---------------------
+ *      2g          |  high_hy*125 mg
+ *      4g          |  high_hy*250 mg
+ *      8g          |  high_hy*500 mg
+ *      16g         |  high_hy*1000 mg
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_high_g_hyst(
+u8 v_high_g_hyst_u8)
+{
+/* variable used for return the status of communication result*/
+BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+		/* write high_g hysteresis*/
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+		p_bmi160->dev_addr,
+		BMI160_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST,
+			v_high_g_hyst_u8);
+			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	}
+return com_rslt;
+}
+/*!
+ *	@brief This API is used to read Delay
+ *	time definition for the high-g interrupt from the register
+ *	0x5D bit 0 to 7
+ *
+ *
+ *
+ *  @param  v_high_g_durn_u8 :  The value of high duration
+ *
+ *	@note High_g interrupt delay triggered according to
+ *	v_high_g_durn_u8 * 2.5ms in a range from 2.5ms to 640ms
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_high_g_durn(
+u8 *v_high_g_durn_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read high_g duration*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_INTR_LOWHIGH_3_INTR_HIGH_G_DURN__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_high_g_durn_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_LOWHIGH_3_INTR_HIGH_G_DURN);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to write Delay
+ *	time definition for the high-g interrupt from the register
+ *	0x5D bit 0 to 7
+ *
+ *
+ *
+ *  @param  v_high_g_durn_u8 :  The value of high duration
+ *
+ *	@note High_g interrupt delay triggered according to
+ *	v_high_g_durn_u8 * 2.5ms in a range from 2.5ms to 640ms
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_high_g_durn(
+u8 v_high_g_durn_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* write high_g duration*/
+			com_rslt = p_bmi160->BMI160_BUS_WRITE_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_INTR_LOWHIGH_3_INTR_HIGH_G_DURN__REG,
+			&v_high_g_durn_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to read Threshold
+ *	definition for the high-g interrupt from the register 0x5E 0 to 7
+ *
+ *
+ *
+ *
+ *  @param  v_high_g_thres_u8 : Pointer holding the value of Threshold
+ *	@note High_g threshold changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | high_g threshold
+ *  ----------------|---------------------
+ *      2g          |  v_high_g_thres_u8*7.81 mg
+ *      4g          |  v_high_g_thres_u8*15.63 mg
+ *      8g          |  v_high_g_thres_u8*31.25 mg
+ *      16g         |  v_high_g_thres_u8*62.5 mg
+ *	@note when v_high_g_thres_u8 = 0
+ *   accel_range    | high_g threshold
+ *  ----------------|---------------------
+ *      2g          |  3.91 mg
+ *      4g          |  7.81 mg
+ *      8g          |  15.63 mg
+ *      16g         |  31.25 mg
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_high_g_thres(
+u8 *v_high_g_thres_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_INTR_LOWHIGH_4_INTR_HIGH_THRES__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_high_g_thres_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_LOWHIGH_4_INTR_HIGH_THRES);
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to write Threshold
+ *	definition for the high-g interrupt from the register 0x5E 0 to 7
+ *
+ *
+ *
+ *
+ *  @param  v_high_g_thres_u8 : Pointer holding the value of Threshold
+ *	@note High_g threshold changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | high_g threshold
+ *  ----------------|---------------------
+ *      2g          |  v_high_g_thres_u8*7.81 mg
+ *      4g          |  v_high_g_thres_u8*15.63 mg
+ *      8g          |  v_high_g_thres_u8*31.25 mg
+ *      16g         |  v_high_g_thres_u8*62.5 mg
+ *	@note when v_high_g_thres_u8 = 0
+ *   accel_range    | high_g threshold
+ *  ----------------|---------------------
+ *      2g          |  3.91 mg
+ *      4g          |  7.81 mg
+ *      8g          |  15.63 mg
+ *      16g         |  31.25 mg
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_high_g_thres(
+u8 v_high_g_thres_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		com_rslt = p_bmi160->BMI160_BUS_WRITE_FUNC(
+		p_bmi160->dev_addr,
+		BMI160_USER_INTR_LOWHIGH_4_INTR_HIGH_THRES__REG,
+		&v_high_g_thres_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads any motion duration
+ *	from the register 0x5F bit 0 and 1
+ *
+ *  @param v_any_motion_durn_u8 : The value of any motion duration
+ *
+ *	@note Any motion duration can be calculated by "v_any_motion_durn_u8 + 1"
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_any_motion_durn(
+u8 *v_any_motion_durn_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		/* read any motion duration*/
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+		(p_bmi160->dev_addr,
+		BMI160_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		*v_any_motion_durn_u8 = BMI160_GET_BITSLICE
+		(v_data_u8,
+		BMI160_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN);
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write any motion duration
+ *	from the register 0x5F bit 0 and 1
+ *
+ *  @param v_any_motion_durn_u8 : The value of any motion duration
+ *
+ *	@note Any motion duration can be calculated by "v_any_motion_durn_u8 + 1"
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_any_motion_durn(
+u8 v_any_motion_durn_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		/* write any motion duration*/
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+		(p_bmi160->dev_addr,
+		BMI160_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN,
+			v_any_motion_durn_u8);
+			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API read Slow/no-motion
+ *	interrupt trigger delay duration from the register 0x5F bit 2 to 7
+ *
+ *  @param v_slow_no_motion_u8 :The value of slow no motion duration
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *	@note
+ *	@note v_slow_no_motion_u8(5:4)=0b00 ->
+ *	[v_slow_no_motion_u8(3:0) + 1] * 1.28s (1.28s-20.48s)
+ *	@note v_slow_no_motion_u8(5:4)=1 ->
+ *	[v_slow_no_motion_u8(3:0)+5] * 5.12s (25.6s-102.4s)
+ *	@note v_slow_no_motion_u8(5)='1' ->
+ *	[(v_slow_no_motion_u8:0)+11] * 10.24s (112.64s-430.08s);
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_slow_no_motion_durn(
+u8 *v_slow_no_motion_u8)
+{
+/* variable used for return the status of communication result*/
+BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+		/* read slow no motion duration*/
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+		(p_bmi160->dev_addr,
+		BMI160_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		*v_slow_no_motion_u8 = BMI160_GET_BITSLICE
+		(v_data_u8,
+		BMI160_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN);
+	}
+return com_rslt;
+}
+ /*!
+ *	@brief This API write Slow/no-motion
+ *	interrupt trigger delay duration from the register 0x5F bit 2 to 7
+ *
+ *  @param v_slow_no_motion_u8 :The value of slow no motion duration
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *	@note
+ *	@note v_slow_no_motion_u8(5:4)=0b00 ->
+ *	[v_slow_no_motion_u8(3:0) + 1] * 1.28s (1.28s-20.48s)
+ *	@note v_slow_no_motion_u8(5:4)=1 ->
+ *	[v_slow_no_motion_u8(3:0)+5] * 5.12s (25.6s-102.4s)
+ *	@note v_slow_no_motion_u8(5)='1' ->
+ *	[(v_slow_no_motion_u8:0)+11] * 10.24s (112.64s-430.08s);
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_slow_no_motion_durn(
+u8 v_slow_no_motion_u8)
+{
+/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+	/* write slow no motion duration*/
+	com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+	(p_bmi160->dev_addr,
+	BMI160_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN__REG,
+	&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	if (com_rslt == SUCCESS) {
+		v_data_u8 = BMI160_SET_BITSLICE
+		(v_data_u8,
+		BMI160_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN,
+		v_slow_no_motion_u8);
+		com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
+		(p_bmi160->dev_addr,
+		BMI160_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	}
+}
+return com_rslt;
+}
+/*!
+ *	@brief This API is used to read threshold
+ *	definition for the any-motion interrupt
+ *	from the register 0x60 bit 0 to 7
+ *
+ *
+ *  @param  v_any_motion_thres_u8 : The value of any motion threshold
+ *
+ *	@note any motion threshold changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | any motion threshold
+ *  ----------------|---------------------
+ *      2g          |  v_any_motion_thres_u8*3.91 mg
+ *      4g          |  v_any_motion_thres_u8*7.81 mg
+ *      8g          |  v_any_motion_thres_u8*15.63 mg
+ *      16g         |  v_any_motion_thres_u8*31.25 mg
+ *	@note when v_any_motion_thres_u8 = 0
+ *   accel_range    | any motion threshold
+ *  ----------------|---------------------
+ *      2g          |  1.95 mg
+ *      4g          |  3.91 mg
+ *      8g          |  7.81 mg
+ *      16g         |  15.63 mg
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_any_motion_thres(
+u8 *v_any_motion_thres_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read any motion threshold*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_INTR_MOTION_1_INTR_ANY_MOTION_THRES__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_any_motion_thres_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_MOTION_1_INTR_ANY_MOTION_THRES);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to write threshold
+ *	definition for the any-motion interrupt
+ *	from the register 0x60 bit 0 to 7
+ *
+ *
+ *  @param  v_any_motion_thres_u8 : The value of any motion threshold
+ *
+ *	@note any motion threshold changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | any motion threshold
+ *  ----------------|---------------------
+ *      2g          |  v_any_motion_thres_u8*3.91 mg
+ *      4g          |  v_any_motion_thres_u8*7.81 mg
+ *      8g          |  v_any_motion_thres_u8*15.63 mg
+ *      16g         |  v_any_motion_thres_u8*31.25 mg
+ *	@note when v_any_motion_thres_u8 = 0
+ *   accel_range    | any motion threshold
+ *  ----------------|---------------------
+ *      2g          |  1.95 mg
+ *      4g          |  3.91 mg
+ *      8g          |  7.81 mg
+ *      16g         |  15.63 mg
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_any_motion_thres(
+u8 v_any_motion_thres_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		/* write any motion threshold*/
+		com_rslt = p_bmi160->BMI160_BUS_WRITE_FUNC
+		(p_bmi160->dev_addr,
+		BMI160_USER_INTR_MOTION_1_INTR_ANY_MOTION_THRES__REG,
+		&v_any_motion_thres_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API is used to read threshold
+ *	for the slow/no-motion interrupt
+ *	from the register 0x61 bit 0 to 7
+ *
+ *
+ *
+ *
+ *  @param v_slow_no_motion_thres_u8 : The value of slow no motion threshold
+ *	@note slow no motion threshold changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | slow no motion threshold
+ *  ----------------|---------------------
+ *      2g          |  v_slow_no_motion_thres_u8*3.91 mg
+ *      4g          |  v_slow_no_motion_thres_u8*7.81 mg
+ *      8g          |  v_slow_no_motion_thres_u8*15.63 mg
+ *      16g         |  v_slow_no_motion_thres_u8*31.25 mg
+ *	@note when v_slow_no_motion_thres_u8 = 0
+ *   accel_range    | slow no motion threshold
+ *  ----------------|---------------------
+ *      2g          |  1.95 mg
+ *      4g          |  3.91 mg
+ *      8g          |  7.81 mg
+ *      16g         |  15.63 mg
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_slow_no_motion_thres(
+u8 *v_slow_no_motion_thres_u8)
+{
+BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+		/* read slow no motion threshold*/
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+		(p_bmi160->dev_addr,
+		BMI160_USER_INTR_MOTION_2_INTR_SLOW_NO_MOTION_THRES__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		*v_slow_no_motion_thres_u8 =
+		BMI160_GET_BITSLICE(v_data_u8,
+		BMI160_USER_INTR_MOTION_2_INTR_SLOW_NO_MOTION_THRES);
+	}
+return com_rslt;
+}
+ /*!
+ *	@brief This API is used to write threshold
+ *	for the slow/no-motion interrupt
+ *	from the register 0x61 bit 0 to 7
+ *
+ *
+ *
+ *
+ *  @param v_slow_no_motion_thres_u8 : The value of slow no motion threshold
+ *	@note slow no motion threshold changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | slow no motion threshold
+ *  ----------------|---------------------
+ *      2g          |  v_slow_no_motion_thres_u8*3.91 mg
+ *      4g          |  v_slow_no_motion_thres_u8*7.81 mg
+ *      8g          |  v_slow_no_motion_thres_u8*15.63 mg
+ *      16g         |  v_slow_no_motion_thres_u8*31.25 mg
+ *	@note when v_slow_no_motion_thres_u8 = 0
+ *   accel_range    | slow no motion threshold
+ *  ----------------|---------------------
+ *      2g          |  1.95 mg
+ *      4g          |  3.91 mg
+ *      8g          |  7.81 mg
+ *      16g         |  15.63 mg
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_slow_no_motion_thres(
+u8 v_slow_no_motion_thres_u8)
+{
+BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+		/* write slow no motion threshold*/
+		com_rslt = p_bmi160->BMI160_BUS_WRITE_FUNC(
+		p_bmi160->dev_addr,
+		BMI160_USER_INTR_MOTION_2_INTR_SLOW_NO_MOTION_THRES__REG,
+		&v_slow_no_motion_thres_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	}
+return com_rslt;
+}
+ /*!
+ *	@brief This API is used to read
+ *	the slow/no-motion selection from the register 0x62 bit 0
+ *
+ *
+ *
+ *
+ *  @param  v_intr_slow_no_motion_select_u8 :
+ *	The value of slow/no-motion select
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     |  SLOW_MOTION
+ *  0x01     |  NO_MOTION
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_slow_no_motion_select(
+u8 *v_intr_slow_no_motion_select_u8)
+{
+BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+		/* read slow no motion select*/
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+		p_bmi160->dev_addr,
+		BMI160_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		*v_intr_slow_no_motion_select_u8 =
+		BMI160_GET_BITSLICE(v_data_u8,
+		BMI160_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT);
+	}
+return com_rslt;
+}
+ /*!
+ *	@brief This API is used to write
+ *	the slow/no-motion selection from the register 0x62 bit 0
+ *
+ *
+ *
+ *
+ *  @param  v_intr_slow_no_motion_select_u8 :
+ *	The value of slow/no-motion select
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     |  SLOW_MOTION
+ *  0x01     |  NO_MOTION
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_slow_no_motion_select(
+u8 v_intr_slow_no_motion_select_u8)
+{
+/* variable used for return the status of communication result*/
+BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+} else {
+if (v_intr_slow_no_motion_select_u8 <= BMI160_MAX_VALUE_NO_MOTION) {
+	/* write slow no motion select*/
+	com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+	(p_bmi160->dev_addr,
+	BMI160_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT__REG,
+	&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	if (com_rslt == SUCCESS) {
+		v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+		BMI160_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT,
+		v_intr_slow_no_motion_select_u8);
+		com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
+		(p_bmi160->dev_addr,
+		BMI160_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	}
+} else {
+com_rslt = E_BMI160_OUT_OF_RANGE;
+}
+}
+return com_rslt;
+}
+ /*!
+ *	@brief This API is used to select
+ *	the significant or any motion interrupt from the register 0x62 bit 1
+ *
+ *
+ *
+ *
+ *  @param  v_intr_significant_motion_select_u8 :
+ *	the value of significant or any motion interrupt selection
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     |  ANY_MOTION
+ *  0x01     |  SIGNIFICANT_MOTION
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_significant_motion_select(
+u8 *v_intr_significant_motion_select_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the significant or any motion interrupt*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_INTR_SIGNIFICATION_MOTION_SELECT__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_significant_motion_select_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_SIGNIFICATION_MOTION_SELECT);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API is used to write, select
+ *	the significant or any motion interrupt from the register 0x62 bit 1
+ *
+ *
+ *
+ *
+ *  @param  v_intr_significant_motion_select_u8 :
+ *	the value of significant or any motion interrupt selection
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     |  ANY_MOTION
+ *  0x01     |  SIGNIFICANT_MOTION
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_significant_motion_select(
+u8 v_intr_significant_motion_select_u8)
+{
+/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+	if (v_intr_significant_motion_select_u8 <=
+	BMI160_MAX_VALUE_SIGNIFICANT_MOTION) {
+		/* write the significant or any motion interrupt*/
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+		(p_bmi160->dev_addr,
+		BMI160_USER_INTR_SIGNIFICATION_MOTION_SELECT__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_SIGNIFICATION_MOTION_SELECT,
+			v_intr_significant_motion_select_u8);
+			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_INTR_SIGNIFICATION_MOTION_SELECT__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	} else {
+	com_rslt = E_BMI160_OUT_OF_RANGE;
+	}
+}
+return com_rslt;
+}
+ /*!
+ *	@brief This API is used to read
+ *	the significant skip time from the register 0x62 bit  2 and 3
+ *
+ *
+ *
+ *
+ *  @param  v_int_sig_mot_skip_u8 : the value of significant skip time
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     |  skip time 1.5 seconds
+ *  0x01     |  skip time 3 seconds
+ *  0x02     |  skip time 6 seconds
+ *  0x03     |  skip time 12 seconds
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_significant_motion_skip(
+u8 *v_int_sig_mot_skip_u8)
+{
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read significant skip time*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_INTR_SIGNIFICANT_MOTION_SKIP__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_int_sig_mot_skip_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_SIGNIFICANT_MOTION_SKIP);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API is used to write
+ *	the significant skip time from the register 0x62 bit  2 and 3
+ *
+ *
+ *
+ *
+ *  @param  v_int_sig_mot_skip_u8 : the value of significant skip time
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     |  skip time 1.5 seconds
+ *  0x01     |  skip time 3 seconds
+ *  0x02     |  skip time 6 seconds
+ *  0x03     |  skip time 12 seconds
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_significant_motion_skip(
+u8 v_int_sig_mot_skip_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_int_sig_mot_skip_u8 <= BMI160_MAX_UNDER_SIG_MOTION) {
+			/* write significant skip time*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_INTR_SIGNIFICANT_MOTION_SKIP__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR_SIGNIFICANT_MOTION_SKIP,
+				v_int_sig_mot_skip_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
+				(p_bmi160->dev_addr,
+				BMI160_USER_INTR_SIGNIFICANT_MOTION_SKIP__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API is used to read
+ *	the significant proof time from the register 0x62 bit  4 and 5
+ *
+ *
+ *
+ *
+ *  @param  v_significant_motion_proof_u8 :
+ *	the value of significant proof time
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     |  proof time 0.25 seconds
+ *  0x01     |  proof time 0.5 seconds
+ *  0x02     |  proof time 1 seconds
+ *  0x03     |  proof time 2 seconds
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_significant_motion_proof(
+u8 *v_significant_motion_proof_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read significant proof time */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_INTR_SIGNIFICANT_MOTION_PROOF__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_significant_motion_proof_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_SIGNIFICANT_MOTION_PROOF);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API is used to write
+ *	the significant proof time from the register 0x62 bit  4 and 5
+ *
+ *
+ *
+ *
+ *  @param  v_significant_motion_proof_u8 :
+ *	the value of significant proof time
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     |  proof time 0.25 seconds
+ *  0x01     |  proof time 0.5 seconds
+ *  0x02     |  proof time 1 seconds
+ *  0x03     |  proof time 2 seconds
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_significant_motion_proof(
+u8 v_significant_motion_proof_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_significant_motion_proof_u8
+		<= BMI160_MAX_UNDER_SIG_MOTION) {
+			/* write significant proof time */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_INTR_SIGNIFICANT_MOTION_PROOF__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR_SIGNIFICANT_MOTION_PROOF,
+				v_significant_motion_proof_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
+				(p_bmi160->dev_addr,
+				BMI160_USER_INTR_SIGNIFICANT_MOTION_PROOF__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to get the tap duration
+ *	from the register 0x63 bit 0 to 2
+ *
+ *
+ *
+ *  @param v_tap_durn_u8 : The value of tap duration
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | BMI160_TAP_DURN_50MS
+ *  0x01     | BMI160_TAP_DURN_100MS
+ *  0x03     | BMI160_TAP_DURN_150MS
+ *  0x04     | BMI160_TAP_DURN_200MS
+ *  0x05     | BMI160_TAP_DURN_250MS
+ *  0x06     | BMI160_TAP_DURN_375MS
+ *  0x07     | BMI160_TAP_DURN_700MS
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_tap_durn(
+u8 *v_tap_durn_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read tap duration*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_INTR_TAP_0_INTR_TAP_DURN__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_tap_durn_u8 = BMI160_GET_BITSLICE(
+			v_data_u8,
+			BMI160_USER_INTR_TAP_0_INTR_TAP_DURN);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to write the tap duration
+ *	from the register 0x63 bit 0 to 2
+ *
+ *
+ *
+ *  @param v_tap_durn_u8 : The value of tap duration
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | BMI160_TAP_DURN_50MS
+ *  0x01     | BMI160_TAP_DURN_100MS
+ *  0x03     | BMI160_TAP_DURN_150MS
+ *  0x04     | BMI160_TAP_DURN_200MS
+ *  0x05     | BMI160_TAP_DURN_250MS
+ *  0x06     | BMI160_TAP_DURN_375MS
+ *  0x07     | BMI160_TAP_DURN_700MS
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_tap_durn(
+u8 v_tap_durn_u8)
+{
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_tap_durn_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_tap_durn_u8 <= BMI160_MAX_TAP_TURN) {
+			switch (v_tap_durn_u8) {
+			case BMI160_TAP_DURN_50MS:
+				v_data_tap_durn_u8 = BMI160_TAP_DURN_50MS;
+				break;
+			case BMI160_TAP_DURN_100MS:
+				v_data_tap_durn_u8 = BMI160_TAP_DURN_100MS;
+				break;
+			case BMI160_TAP_DURN_150MS:
+				v_data_tap_durn_u8 = BMI160_TAP_DURN_150MS;
+				break;
+			case BMI160_TAP_DURN_200MS:
+				v_data_tap_durn_u8 = BMI160_TAP_DURN_200MS;
+				break;
+			case BMI160_TAP_DURN_250MS:
+				v_data_tap_durn_u8 = BMI160_TAP_DURN_250MS;
+				break;
+			case BMI160_TAP_DURN_375MS:
+				v_data_tap_durn_u8 = BMI160_TAP_DURN_375MS;
+				break;
+			case BMI160_TAP_DURN_500MS:
+				v_data_tap_durn_u8 = BMI160_TAP_DURN_500MS;
+				break;
+			case BMI160_TAP_DURN_700MS:
+				v_data_tap_durn_u8 = BMI160_TAP_DURN_700MS;
+				break;
+			default:
+				break;
+			}
+			/* write tap duration*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_INTR_TAP_0_INTR_TAP_DURN__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR_TAP_0_INTR_TAP_DURN,
+				v_data_tap_durn_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
+				(p_bmi160->dev_addr,
+				BMI160_USER_INTR_TAP_0_INTR_TAP_DURN__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API read the
+ *	tap shock duration from the register 0x63 bit 2
+ *
+ *  @param v_tap_shock_u8 :The value of tap shock
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | BMI160_TAP_SHOCK_50MS
+ *  0x01     | BMI160_TAP_SHOCK_75MS
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_tap_shock(
+u8 *v_tap_shock_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read tap shock duration*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_INTR_TAP_0_INTR_TAP_SHOCK__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_tap_shock_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_TAP_0_INTR_TAP_SHOCK);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write the
+ *	tap shock duration from the register 0x63 bit 2
+ *
+ *  @param v_tap_shock_u8 :The value of tap shock
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | BMI160_TAP_SHOCK_50MS
+ *  0x01     | BMI160_TAP_SHOCK_75MS
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_tap_shock(u8 v_tap_shock_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_tap_shock_u8 <= BMI160_MAX_VALUE_TAP_SHOCK) {
+			/* write tap shock duration*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_INTR_TAP_0_INTR_TAP_SHOCK__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR_TAP_0_INTR_TAP_SHOCK,
+				v_tap_shock_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
+				(p_bmi160->dev_addr,
+				BMI160_USER_INTR_TAP_0_INTR_TAP_SHOCK__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read
+ *	tap quiet duration from the register 0x63 bit 7
+ *
+ *
+ *  @param v_tap_quiet_u8 : The value of tap quiet
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | BMI160_TAP_QUIET_30MS
+ *  0x01     | BMI160_TAP_QUIET_20MS
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_tap_quiet(
+u8 *v_tap_quiet_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read tap quiet duration*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_INTR_TAP_0_INTR_TAP_QUIET__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_tap_quiet_u8 = BMI160_GET_BITSLICE(
+			v_data_u8,
+			BMI160_USER_INTR_TAP_0_INTR_TAP_QUIET);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write
+ *	tap quiet duration from the register 0x63 bit 7
+ *
+ *
+ *  @param v_tap_quiet_u8 : The value of tap quiet
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | BMI160_TAP_QUIET_30MS
+ *  0x01     | BMI160_TAP_QUIET_20MS
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_tap_quiet(u8 v_tap_quiet_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_tap_quiet_u8 <= BMI160_MAX_VALUE_TAP_QUIET) {
+			/* write tap quiet duration*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_INTR_TAP_0_INTR_TAP_QUIET__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR_TAP_0_INTR_TAP_QUIET,
+				v_tap_quiet_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
+				(p_bmi160->dev_addr,
+				BMI160_USER_INTR_TAP_0_INTR_TAP_QUIET__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API read Threshold of the
+ *	single/double tap interrupt from the register 0x64 bit 0 to 4
+ *
+ *
+ *	@param v_tap_thres_u8 : The value of single/double tap threshold
+ *
+ *	@note single/double tap threshold changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | single/double tap threshold
+ *  ----------------|---------------------
+ *      2g          |  ((v_tap_thres_u8 + 1) * 62.5)mg
+ *      4g          |  ((v_tap_thres_u8 + 1) * 125)mg
+ *      8g          |  ((v_tap_thres_u8 + 1) * 250)mg
+ *      16g         |  ((v_tap_thres_u8 + 1) * 500)mg
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_tap_thres(
+u8 *v_tap_thres_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read tap threshold*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_INTR_TAP_1_INTR_TAP_THRES__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_tap_thres_u8 = BMI160_GET_BITSLICE
+			(v_data_u8,
+			BMI160_USER_INTR_TAP_1_INTR_TAP_THRES);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write Threshold of the
+ *	single/double tap interrupt from the register 0x64 bit 0 to 4
+ *
+ *
+ *	@param v_tap_thres_u8 : The value of single/double tap threshold
+ *
+ *	@note single/double tap threshold changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | single/double tap threshold
+ *  ----------------|---------------------
+ *      2g          |  ((v_tap_thres_u8 + 1) * 62.5)mg
+ *      4g          |  ((v_tap_thres_u8 + 1) * 125)mg
+ *      8g          |  ((v_tap_thres_u8 + 1) * 250)mg
+ *      16g         |  ((v_tap_thres_u8 + 1) * 500)mg
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_tap_thres(
+u8 v_tap_thres_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* write tap threshold*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_INTR_TAP_1_INTR_TAP_THRES__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR_TAP_1_INTR_TAP_THRES,
+				v_tap_thres_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
+				(p_bmi160->dev_addr,
+				BMI160_USER_INTR_TAP_1_INTR_TAP_THRES__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API read the threshold for orientation interrupt
+ *	from the register 0x65 bit 0 and 1
+ *
+ *  @param v_orient_mode_u8 : The value of threshold for orientation
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | symmetrical
+ *  0x01     | high-asymmetrical
+ *  0x02     | low-asymmetrical
+ *  0x03     | symmetrical
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_mode(
+u8 *v_orient_mode_u8)
+{
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read orientation threshold*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_MODE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_orient_mode_u8 = BMI160_GET_BITSLICE
+			(v_data_u8,
+			BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_MODE);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write the threshold for orientation interrupt
+ *	from the register 0x65 bit 0 and 1
+ *
+ *  @param v_orient_mode_u8 : The value of threshold for orientation
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | symmetrical
+ *  0x01     | high-asymmetrical
+ *  0x02     | low-asymmetrical
+ *  0x03     | symmetrical
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_mode(
+u8 v_orient_mode_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_orient_mode_u8 <= BMI160_MAX_ORIENT_MODE) {
+			/* write orientation threshold*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_MODE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_MODE,
+				v_orient_mode_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
+				(p_bmi160->dev_addr,
+				BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_MODE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read the orient blocking mode
+ *	that is used for the generation of the orientation interrupt.
+ *	from the register 0x65 bit 2 and 3
+ *
+ *  @param v_orient_blocking_u8 : The value of orient blocking mode
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | No blocking
+ *  0x01     | Theta blocking or acceleration in any axis > 1.5g
+ *  0x02     | Theta blocking or acceleration slope in any axis >
+ *   -       | 0.2g or acceleration in any axis > 1.5g
+ *  0x03     | Theta blocking or acceleration slope in any axis >
+ *   -       | 0.4g or acceleration in any axis >
+ *   -       | 1.5g and value of orient is not stable
+ *   -       | for at least 100 ms
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_blocking(
+u8 *v_orient_blocking_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read orient blocking mode*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_orient_blocking_u8 = BMI160_GET_BITSLICE
+			(v_data_u8,
+			BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write the orient blocking mode
+ *	that is used for the generation of the orientation interrupt.
+ *	from the register 0x65 bit 2 and 3
+ *
+ *  @param v_orient_blocking_u8 : The value of orient blocking mode
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | No blocking
+ *  0x01     | Theta blocking or acceleration in any axis > 1.5g
+ *  0x02     | Theta blocking or acceleration slope in any axis >
+ *   -       | 0.2g or acceleration in any axis > 1.5g
+ *  0x03     | Theta blocking or acceleration slope in any axis >
+ *   -       | 0.4g or acceleration in any axis >
+ *   -       | 1.5g and value of orient is not stable
+ *   -       | for at least 100 ms
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_blocking(
+u8 v_orient_blocking_u8)
+{
+/* variable used for return the status of communication result*/
+BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+	if (v_orient_blocking_u8 <= BMI160_MAX_ORIENT_BLOCKING) {
+		/* write orient blocking mode*/
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+		(p_bmi160->dev_addr,
+		BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING,
+			v_orient_blocking_u8);
+			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	} else {
+	com_rslt = E_BMI160_OUT_OF_RANGE;
+	}
+}
+return com_rslt;
+}
+/*!
+ *	@brief This API read Orient interrupt
+ *	hysteresis, from the register 0x64 bit 4 to 7
+ *
+ *
+ *
+ *  @param v_orient_hyst_u8 : The value of orient hysteresis
+ *
+ *	@note 1 LSB corresponds to 62.5 mg,
+ *	irrespective of the selected accel range
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_hyst(
+u8 *v_orient_hyst_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read orient hysteresis*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_HYST__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_orient_hyst_u8 = BMI160_GET_BITSLICE
+			(v_data_u8,
+			BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_HYST);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write Orient interrupt
+ *	hysteresis, from the register 0x64 bit 4 to 7
+ *
+ *
+ *
+ *  @param v_orient_hyst_u8 : The value of orient hysteresis
+ *
+ *	@note 1 LSB corresponds to 62.5 mg,
+ *	irrespective of the selected accel range
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_hyst(
+u8 v_orient_hyst_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* write orient hysteresis*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_HYST__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_HYST,
+				v_orient_hyst_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
+				(p_bmi160->dev_addr,
+				BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_HYST__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API read Orient
+ *	blocking angle (0 to 44.8) from the register 0x66 bit 0 to 5
+ *
+ *  @param v_orient_theta_u8 : The value of Orient blocking angle
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_theta(
+u8 *v_orient_theta_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read Orient blocking angle*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_THETA__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_orient_theta_u8 = BMI160_GET_BITSLICE
+			(v_data_u8,
+			BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_THETA);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write Orient
+ *	blocking angle (0 to 44.8) from the register 0x66 bit 0 to 5
+ *
+ *  @param v_orient_theta_u8 : The value of Orient blocking angle
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_theta(
+u8 v_orient_theta_u8)
+{
+/* variable used for return the status of communication result*/
+BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+	if (v_orient_theta_u8 <= BMI160_MAX_ORIENT_THETA) {
+		/* write Orient blocking angle*/
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+		(p_bmi160->dev_addr,
+		BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_THETA__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_THETA,
+			v_orient_theta_u8);
+			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_THETA__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	} else {
+	com_rslt = E_BMI160_OUT_OF_RANGE;
+	}
+}
+return com_rslt;
+}
+/*!
+ *	@brief This API read orient change
+ *	of up/down bit from the register 0x66 bit 6
+ *
+ *  @param v_orient_ud_u8 : The value of orient change of up/down
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | Is ignored
+ *  0x01     | Generates orientation interrupt
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_ud_enable(
+u8 *v_orient_ud_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read orient up/down enable*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_orient_ud_u8 = BMI160_GET_BITSLICE
+			(v_data_u8,
+			BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write orient change
+ *	of up/down bit from the register 0x66 bit 6
+ *
+ *  @param v_orient_ud_u8 : The value of orient change of up/down
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | Is ignored
+ *  0x01     | Generates orientation interrupt
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_ud_enable(
+u8 v_orient_ud_u8)
+{
+/* variable used for return the status of communication result*/
+BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+	if (v_orient_ud_u8 <= BMI160_MAX_VALUE_ORIENT_UD) {
+		/* write orient up/down enable */
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+		(p_bmi160->dev_addr,
+		BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE,
+			v_orient_ud_u8);
+			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	} else {
+	com_rslt = E_BMI160_OUT_OF_RANGE;
+	}
+}
+return com_rslt;
+}
+ /*!
+ *	@brief This API read orientation axes changes
+ *	from the register 0x66 bit 7
+ *
+ *  @param v_orient_axes_u8 : The value of orient axes assignment
+ *	value    |       Behaviour    | Name
+ * ----------|--------------------|------
+ *  0x00     | x = x, y = y, z = z|orient_ax_noex
+ *  0x01     | x = y, y = z, z = x|orient_ax_ex
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_axes_enable(
+u8 *v_orient_axes_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read orientation axes changes  */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_orient_axes_u8 = BMI160_GET_BITSLICE
+			(v_data_u8,
+			BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write orientation axes changes
+ *	from the register 0x66 bit 7
+ *
+ *  @param v_orient_axes_u8 : The value of orient axes assignment
+ *	value    |       Behaviour    | Name
+ * ----------|--------------------|------
+ *  0x00     | x = x, y = y, z = z|orient_ax_noex
+ *  0x01     | x = y, y = z, z = x|orient_ax_ex
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_axes_enable(
+u8 v_orient_axes_u8)
+{
+/* variable used for return the status of communication result*/
+BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+	if (v_orient_axes_u8 <= BMI160_MAX_VALUE_ORIENT_AXES) {
+		/*write orientation axes changes  */
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+		(p_bmi160->dev_addr,
+		BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX,
+			v_orient_axes_u8);
+			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	} else {
+	com_rslt = E_BMI160_OUT_OF_RANGE;
+	}
+}
+return com_rslt;
+}
+ /*!
+ *	@brief This API read Flat angle (0 to 44.8) for flat interrupt
+ *	from the register 0x67 bit 0 to 5
+ *
+ *  @param v_flat_theta_u8 : The value of flat angle
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_flat_theta(
+u8 *v_flat_theta_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read Flat angle*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_INTR_FLAT_0_INTR_FLAT_THETA__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_flat_theta_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_FLAT_0_INTR_FLAT_THETA);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write Flat angle (0 to 44.8) for flat interrupt
+ *	from the register 0x67 bit 0 to 5
+ *
+ *  @param v_flat_theta_u8 : The value of flat angle
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_flat_theta(
+u8 v_flat_theta_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_flat_theta_u8 <= BMI160_MAX_FLAT_THETA) {
+			/* write Flat angle */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_INTR_FLAT_0_INTR_FLAT_THETA__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR_FLAT_0_INTR_FLAT_THETA,
+				v_flat_theta_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
+				(p_bmi160->dev_addr,
+				BMI160_USER_INTR_FLAT_0_INTR_FLAT_THETA__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read Flat interrupt hold time;
+ *	from the register 0x68 bit 4 and 5
+ *
+ *  @param v_flat_hold_u8 : The value of flat hold time
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | 0ms
+ *  0x01     | 512ms
+ *  0x01     | 1024ms
+ *  0x01     | 2048ms
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_flat_hold(
+u8 *v_flat_hold_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read flat hold time*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_INTR_FLAT_1_INTR_FLAT_HOLD__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_flat_hold_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_INTR_FLAT_1_INTR_FLAT_HOLD);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write Flat interrupt hold time;
+ *	from the register 0x68 bit 4 and 5
+ *
+ *  @param v_flat_hold_u8 : The value of flat hold time
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | 0ms
+ *  0x01     | 512ms
+ *  0x01     | 1024ms
+ *  0x01     | 2048ms
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_flat_hold(
+u8 v_flat_hold_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_flat_hold_u8 <= BMI160_MAX_FLAT_HOLD) {
+			/* write flat hold time*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_INTR_FLAT_1_INTR_FLAT_HOLD__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR_FLAT_1_INTR_FLAT_HOLD,
+				v_flat_hold_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
+				(p_bmi160->dev_addr,
+				BMI160_USER_INTR_FLAT_1_INTR_FLAT_HOLD__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read flat interrupt hysteresis
+ *	from the register 0x68 bit 0 to 3
+ *
+ *  @param v_flat_hyst_u8 : The value of flat hysteresis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_flat_hyst(
+u8 *v_flat_hyst_u8)
+{
+	/* variable used to return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the flat hysteresis*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_INTR_FLAT_1_INTR_FLAT_HYST__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_flat_hyst_u8 = BMI160_GET_BITSLICE(
+			v_data_u8,
+			BMI160_USER_INTR_FLAT_1_INTR_FLAT_HYST);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write flat interrupt hysteresis
+ *	from the register 0x68 bit 0 to 3
+ *
+ *  @param v_flat_hyst_u8 : The value of flat hysteresis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_flat_hyst(
+u8 v_flat_hyst_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_flat_hyst_u8 <= BMI160_MAX_FLAT_HYST) {
+			/* read the flat hysteresis*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_INTR_FLAT_1_INTR_FLAT_HYST__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_INTR_FLAT_1_INTR_FLAT_HYST,
+				v_flat_hyst_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
+				(p_bmi160->dev_addr,
+				BMI160_USER_INTR_FLAT_1_INTR_FLAT_HYST__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API read accel offset compensation
+ *	target value for z-axis from the register 0x69 bit 0 and 1
+ *
+ *  @param v_foc_accel_z_u8 : the value of accel offset compensation z axis
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_foc_accel_z(u8 *v_foc_accel_z_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the accel offset compensation for z axis*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_FOC_ACCEL_Z__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_foc_accel_z_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_FOC_ACCEL_Z);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write accel offset compensation
+ *	target value for z-axis from the register 0x69 bit 0 and 1
+ *
+ *  @param v_foc_accel_z_u8 : the value of accel offset compensation z axis
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_foc_accel_z(
+u8 v_foc_accel_z_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* write the accel offset compensation for z axis*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_FOC_ACCEL_Z__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_FOC_ACCEL_Z,
+				v_foc_accel_z_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
+				(p_bmi160->dev_addr,
+				BMI160_USER_FOC_ACCEL_Z__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read accel offset compensation
+ *	target value for y-axis
+ *	from the register 0x69 bit 2 and 3
+ *
+ *  @param v_foc_accel_y_u8 : the value of accel offset compensation y axis
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_foc_accel_y(u8 *v_foc_accel_y_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the accel offset compensation for y axis*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_FOC_ACCEL_Y__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_foc_accel_y_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_FOC_ACCEL_Y);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write accel offset compensation
+ *	target value for y-axis
+ *	from the register 0x69 bit 2 and 3
+ *
+ *  @param v_foc_accel_y_u8 : the value of accel offset compensation y axis
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x02     | -1g
+ *  0x03     | 0g
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_foc_accel_y(u8 v_foc_accel_y_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_foc_accel_y_u8 <= BMI160_MAX_ACCEL_FOC) {
+			/* write the accel offset compensation for y axis*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_FOC_ACCEL_Y__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_FOC_ACCEL_Y,
+				v_foc_accel_y_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
+				(p_bmi160->dev_addr,
+				BMI160_USER_FOC_ACCEL_Y__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read accel offset compensation
+ *	target value for x-axis is
+ *	from the register 0x69 bit 4 and 5
+ *
+ *  @param v_foc_accel_x_u8 : the value of accel offset compensation x axis
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x02     | -1g
+ *  0x03     | 0g
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_foc_accel_x(u8 *v_foc_accel_x_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		/* read the accel offset compensation for x axis*/
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+		p_bmi160->dev_addr,
+		BMI160_USER_FOC_ACCEL_X__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		*v_foc_accel_x_u8 = BMI160_GET_BITSLICE(v_data_u8,
+		BMI160_USER_FOC_ACCEL_X);
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write accel offset compensation
+ *	target value for x-axis is
+ *	from the register 0x69 bit 4 and 5
+ *
+ *  @param v_foc_accel_x_u8 : the value of accel offset compensation x axis
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_foc_accel_x(u8 v_foc_accel_x_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_foc_accel_x_u8 <= BMI160_MAX_ACCEL_FOC) {
+			/* write the accel offset compensation for x axis*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_FOC_ACCEL_X__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_FOC_ACCEL_X,
+				v_foc_accel_x_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_FOC_ACCEL_X__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API writes accel fast offset compensation
+ *	from the register 0x69 bit 0 to 5
+ *	@brief This API writes each axis individually
+ *	FOC_X_AXIS - bit 4 and 5
+ *	FOC_Y_AXIS - bit 2 and 3
+ *	FOC_Z_AXIS - bit 0 and 1
+ *
+ *  @param  v_foc_accel_u8: The value of accel offset compensation
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *  @param  v_axis_u8: The value of accel offset axis selection
+  *	value    | axis
+ * ----------|-------------------
+ *  0        | FOC_X_AXIS
+ *  1        | FOC_Y_AXIS
+ *  2        | FOC_Z_AXIS
+ *
+ *	@param v_accel_offset_s8: The accel offset value
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_foc_trigger(u8 v_axis_u8,
+u8 v_foc_accel_u8, s8 *v_accel_offset_s8)
+{
+/* variable used for return the status of communication result*/
+BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+s8 v_status_s8 = SUCCESS;
+u8 v_timeout_u8 = BMI160_INIT_VALUE;
+s8 v_foc_accel_offset_x_s8  = BMI160_INIT_VALUE;
+s8 v_foc_accel_offset_y_s8 =  BMI160_INIT_VALUE;
+s8 v_foc_accel_offset_z_s8 =  BMI160_INIT_VALUE;
+u8 focstatus = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+} else {
+	v_status_s8 = bmi160_set_accel_offset_enable(
+	ACCEL_OFFSET_ENABLE);
+	if (v_status_s8 == SUCCESS) {
+		switch (v_axis_u8) {
+		case FOC_X_AXIS:
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_FOC_ACCEL_X__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 =
+				BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_FOC_ACCEL_X,
+				v_foc_accel_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_FOC_ACCEL_X__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+
+			/* trigger the
+			FOC need to write
+			0x03 in the register 0x7e*/
+			com_rslt +=
+			bmi160_set_command_register(
+			START_FOC_ACCEL_GYRO);
+
+			com_rslt +=
+			bmi160_get_foc_rdy(&focstatus);
+			if ((com_rslt != SUCCESS) ||
+			(focstatus != BMI160_FOC_STAT_HIGH)) {
+				while ((com_rslt != SUCCESS) ||
+				(focstatus != BMI160_FOC_STAT_HIGH
+				&& v_timeout_u8 <
+				BMI160_MAXIMUM_TIMEOUT)) {
+					p_bmi160->delay_msec(
+					BMI160_DELAY_SETTLING_TIME);
+					com_rslt = bmi160_get_foc_rdy(
+					&focstatus);
+					v_timeout_u8++;
+				}
+			}
+			if ((com_rslt == SUCCESS) &&
+				(focstatus == BMI160_FOC_STAT_HIGH)) {
+				com_rslt +=
+				bmi160_get_accel_offset_compensation_xaxis(
+				&v_foc_accel_offset_x_s8);
+				*v_accel_offset_s8 =
+				v_foc_accel_offset_x_s8;
+			}
+		break;
+		case FOC_Y_AXIS:
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_FOC_ACCEL_Y__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 =
+				BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_FOC_ACCEL_Y,
+				v_foc_accel_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_FOC_ACCEL_Y__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+
+			/* trigger the FOC
+			need to write 0x03
+			in the register 0x7e*/
+			com_rslt +=
+			bmi160_set_command_register(
+			START_FOC_ACCEL_GYRO);
+
+			com_rslt +=
+			bmi160_get_foc_rdy(&focstatus);
+			if ((com_rslt != SUCCESS) ||
+			(focstatus != BMI160_FOC_STAT_HIGH)) {
+				while ((com_rslt != SUCCESS) ||
+				(focstatus != BMI160_FOC_STAT_HIGH
+				&& v_timeout_u8 <
+				BMI160_MAXIMUM_TIMEOUT)) {
+					p_bmi160->delay_msec(
+					BMI160_DELAY_SETTLING_TIME);
+					com_rslt = bmi160_get_foc_rdy(
+					&focstatus);
+					v_timeout_u8++;
+				}
+			}
+			if ((com_rslt == SUCCESS) &&
+			(focstatus == BMI160_FOC_STAT_HIGH)) {
+				com_rslt +=
+				bmi160_get_accel_offset_compensation_yaxis(
+				&v_foc_accel_offset_y_s8);
+				*v_accel_offset_s8 =
+				v_foc_accel_offset_y_s8;
+			}
+		break;
+		case FOC_Z_AXIS:
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_FOC_ACCEL_Z__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 =
+				BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_FOC_ACCEL_Z,
+				v_foc_accel_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_FOC_ACCEL_Z__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+
+			/* trigger the FOC need to write
+			0x03 in the register 0x7e*/
+			com_rslt +=
+			bmi160_set_command_register(
+			START_FOC_ACCEL_GYRO);
+
+			com_rslt +=
+			bmi160_get_foc_rdy(&focstatus);
+			if ((com_rslt != SUCCESS) ||
+			(focstatus != BMI160_FOC_STAT_HIGH)) {
+				while ((com_rslt != SUCCESS) ||
+				(focstatus != BMI160_FOC_STAT_HIGH
+				&& v_timeout_u8 <
+				BMI160_MAXIMUM_TIMEOUT)) {
+					p_bmi160->delay_msec(
+					BMI160_DELAY_SETTLING_TIME);
+					com_rslt = bmi160_get_foc_rdy(
+					&focstatus);
+					v_timeout_u8++;
+				}
+			}
+			if ((com_rslt == SUCCESS) &&
+			(focstatus == BMI160_FOC_STAT_HIGH)) {
+				com_rslt +=
+				bmi160_get_accel_offset_compensation_zaxis(
+				&v_foc_accel_offset_z_s8);
+				*v_accel_offset_s8 =
+				v_foc_accel_offset_z_s8;
+			}
+		break;
+		default:
+		break;
+		}
+	} else {
+	com_rslt =  ERROR;
+	}
+}
+return com_rslt;
+}
+/*!
+ *	@brief This API write fast accel offset compensation
+ *	it writes all axis together.To the register 0x69 bit 0 to 5
+ *	FOC_X_AXIS - bit 4 and 5
+ *	FOC_Y_AXIS - bit 2 and 3
+ *	FOC_Z_AXIS - bit 0 and 1
+ *
+ *  @param  v_foc_accel_x_u8: The value of accel offset x compensation
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *  @param  v_foc_accel_y_u8: The value of accel offset y compensation
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *  @param  v_foc_accel_z_u8: The value of accel offset z compensation
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *  @param  v_accel_off_x_s8: The value of accel offset x axis
+ *  @param  v_accel_off_y_s8: The value of accel offset y axis
+ *  @param  v_accel_off_z_s8: The value of accel offset z axis
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_accel_foc_trigger_xyz(u8 v_foc_accel_x_u8,
+u8 v_foc_accel_y_u8, u8 v_foc_accel_z_u8, s8 *v_accel_off_x_s8,
+s8 *v_accel_off_y_s8, s8 *v_accel_off_z_s8)
+{
+/* variable used for return the status of communication result*/
+BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 focx = BMI160_INIT_VALUE;
+u8 focy = BMI160_INIT_VALUE;
+u8 focz = BMI160_INIT_VALUE;
+s8 v_foc_accel_offset_x_s8 = BMI160_INIT_VALUE;
+s8 v_foc_accel_offset_y_s8 = BMI160_INIT_VALUE;
+s8 v_foc_accel_offset_z_s8 = BMI160_INIT_VALUE;
+u8 v_status_s8 = SUCCESS;
+u8 v_timeout_u8 = BMI160_INIT_VALUE;
+u8 focstatus = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+		v_status_s8 = bmi160_set_accel_offset_enable(
+		ACCEL_OFFSET_ENABLE);
+		if (v_status_s8 == SUCCESS) {
+			/* foc x axis*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_FOC_ACCEL_X__REG,
+			&focx, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				focx = BMI160_SET_BITSLICE(focx,
+				BMI160_USER_FOC_ACCEL_X,
+				v_foc_accel_x_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_FOC_ACCEL_X__REG,
+				&focx, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+
+			/* foc y axis*/
+			com_rslt +=
+			p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_FOC_ACCEL_Y__REG,
+			&focy, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				focy = BMI160_SET_BITSLICE(focy,
+				BMI160_USER_FOC_ACCEL_Y,
+				v_foc_accel_y_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_FOC_ACCEL_Y__REG,
+				&focy, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+
+			/* foc z axis*/
+			com_rslt +=
+			p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_FOC_ACCEL_Z__REG,
+			&focz, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				focz = BMI160_SET_BITSLICE(focz,
+				BMI160_USER_FOC_ACCEL_Z,
+				v_foc_accel_z_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_FOC_ACCEL_Z__REG,
+				&focz, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+
+			/* trigger the FOC need to
+			write 0x03 in the register 0x7e*/
+			com_rslt += bmi160_set_command_register(
+			START_FOC_ACCEL_GYRO);
+
+			com_rslt += bmi160_get_foc_rdy(
+			&focstatus);
+			if ((com_rslt != SUCCESS) ||
+			(focstatus != BMI160_FOC_STAT_HIGH)) {
+				while ((com_rslt != SUCCESS) ||
+				(focstatus != BMI160_FOC_STAT_HIGH
+				&& v_timeout_u8 <
+				BMI160_MAXIMUM_TIMEOUT)) {
+					p_bmi160->delay_msec(
+					BMI160_DELAY_SETTLING_TIME);
+					com_rslt = bmi160_get_foc_rdy(
+					&focstatus);
+					v_timeout_u8++;
+				}
+			}
+			if ((com_rslt == SUCCESS) &&
+			(focstatus == BMI160_GEN_READ_WRITE_DATA_LENGTH)) {
+				com_rslt +=
+				bmi160_get_accel_offset_compensation_xaxis(
+				&v_foc_accel_offset_x_s8);
+				*v_accel_off_x_s8 =
+				v_foc_accel_offset_x_s8;
+				com_rslt +=
+				bmi160_get_accel_offset_compensation_yaxis(
+				&v_foc_accel_offset_y_s8);
+				*v_accel_off_y_s8 =
+				v_foc_accel_offset_y_s8;
+				com_rslt +=
+				bmi160_get_accel_offset_compensation_zaxis(
+				&v_foc_accel_offset_z_s8);
+				*v_accel_off_z_s8 =
+				v_foc_accel_offset_z_s8;
+			}
+		} else {
+		com_rslt =  ERROR;
+		}
+	}
+return com_rslt;
+}
+/*!
+ *	@brief This API read gyro fast offset enable
+ *	from the register 0x69 bit 6
+ *
+ *  @param v_foc_gyro_u8 : The value of gyro fast offset enable
+ *  value    |  Description
+ * ----------|-------------
+ *    0      | fast offset compensation disabled
+ *    1      |  fast offset compensation enabled
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_foc_gyro_enable(
+u8 *v_foc_gyro_u8)
+{
+	/* used for return the status of bus communication */
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the gyro fast offset enable*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_FOC_GYRO_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_foc_gyro_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_FOC_GYRO_ENABLE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write gyro fast offset enable
+ *	from the register 0x69 bit 6
+ *
+ *  @param v_foc_gyro_u8 : The value of gyro fast offset enable
+ *  value    |  Description
+ * ----------|-------------
+ *    0      | fast offset compensation disabled
+ *    1      |  fast offset compensation enabled
+ *
+ *	@param v_gyro_off_x_s16 : The value of gyro fast offset x axis data
+ *	@param v_gyro_off_y_s16 : The value of gyro fast offset y axis data
+ *	@param v_gyro_off_z_s16 : The value of gyro fast offset z axis data
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_foc_gyro_enable(
+u8 v_foc_gyro_u8, s16 *v_gyro_off_x_s16,
+s16 *v_gyro_off_y_s16, s16 *v_gyro_off_z_s16)
+{
+/* variable used for return the status of communication result*/
+BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+u8 v_status_s8 = SUCCESS;
+u8 v_timeout_u8 = BMI160_INIT_VALUE;
+s16 offsetx = BMI160_INIT_VALUE;
+s16 offsety = BMI160_INIT_VALUE;
+s16 offsetz = BMI160_INIT_VALUE;
+u8 focstatus = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+		v_status_s8 = bmi160_set_gyro_offset_enable(
+		GYRO_OFFSET_ENABLE);
+		if (v_status_s8 == SUCCESS) {
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_FOC_GYRO_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 =
+				BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_FOC_GYRO_ENABLE,
+				v_foc_gyro_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC
+				(p_bmi160->dev_addr,
+				BMI160_USER_FOC_GYRO_ENABLE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+
+			/* trigger the FOC need to write 0x03
+			in the register 0x7e*/
+			com_rslt += bmi160_set_command_register
+			(START_FOC_ACCEL_GYRO);
+
+			com_rslt += bmi160_get_foc_rdy(&focstatus);
+			if ((com_rslt != SUCCESS) ||
+			(focstatus != BMI160_FOC_STAT_HIGH)) {
+				while ((com_rslt != SUCCESS) ||
+				(focstatus != BMI160_FOC_STAT_HIGH
+				&& v_timeout_u8 <
+				BMI160_MAXIMUM_TIMEOUT)) {
+					p_bmi160->delay_msec(
+					BMI160_DELAY_SETTLING_TIME);
+					com_rslt = bmi160_get_foc_rdy(
+					&focstatus);
+					v_timeout_u8++;
+				}
+			}
+			if ((com_rslt == SUCCESS) &&
+			(focstatus == BMI160_FOC_STAT_HIGH)) {
+				com_rslt +=
+				bmi160_get_gyro_offset_compensation_xaxis
+				(&offsetx);
+				*v_gyro_off_x_s16 = offsetx;
+
+				com_rslt +=
+				bmi160_get_gyro_offset_compensation_yaxis
+				(&offsety);
+				*v_gyro_off_y_s16 = offsety;
+
+				com_rslt +=
+				bmi160_get_gyro_offset_compensation_zaxis(
+				&offsetz);
+				*v_gyro_off_z_s16 = offsetz;
+			}
+		} else {
+		com_rslt = ERROR;
+		}
+	}
+return com_rslt;
+}
+ /*!
+ *	@brief This API read NVM program enable
+ *	from the register 0x6A bit 1
+ *
+ *  @param v_nvm_prog_u8 : The value of NVM program enable
+ *  Value  |  Description
+ * --------|-------------
+ *   0     |  DISABLE
+ *   1     |  ENABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_nvm_prog_enable(
+u8 *v_nvm_prog_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read NVM program*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_CONFIG_NVM_PROG_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_nvm_prog_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_CONFIG_NVM_PROG_ENABLE);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write NVM program enable
+ *	from the register 0x6A bit 1
+ *
+ *  @param v_nvm_prog_u8 : The value of NVM program enable
+ *  Value  |  Description
+ * --------|-------------
+ *   0     |  DISABLE
+ *   1     |  ENABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_nvm_prog_enable(
+u8 v_nvm_prog_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_nvm_prog_u8 <= BMI160_MAX_VALUE_NVM_PROG) {
+			/* write the NVM program*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_CONFIG_NVM_PROG_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_CONFIG_NVM_PROG_ENABLE,
+				v_nvm_prog_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_CONFIG_NVM_PROG_ENABLE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ * @brief This API read to configure SPI
+ * Interface Mode for primary and OIS interface
+ * from the register 0x6B bit 0
+ *
+ *  @param v_spi3_u8 : The value of SPI mode selection
+ *  Value  |  Description
+ * --------|-------------
+ *   0     |  SPI 4-wire mode
+ *   1     |  SPI 3-wire mode
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_spi3(
+u8 *v_spi3_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read SPI mode*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_IF_CONFIG_SPI3__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_spi3_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_IF_CONFIG_SPI3);
+		}
+	return com_rslt;
+}
+/*!
+ * @brief This API write to configure SPI
+ * Interface Mode for primary and OIS interface
+ * from the register 0x6B bit 0
+ *
+ *  @param v_spi3_u8 : The value of SPI mode selection
+ *  Value  |  Description
+ * --------|-------------
+ *   0     |  SPI 4-wire mode
+ *   1     |  SPI 3-wire mode
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_spi3(
+u8 v_spi3_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_spi3_u8 <= BMI160_MAX_VALUE_SPI3) {
+			/* write SPI mode*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_IF_CONFIG_SPI3__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_IF_CONFIG_SPI3,
+				v_spi3_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_IF_CONFIG_SPI3__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read I2C Watchdog timer
+ *	from the register 0x70 bit 1
+ *
+ *  @param v_i2c_wdt_u8 : The value of I2C watch dog timer
+ *  Value  |  Description
+ * --------|-------------
+ *   0     |  I2C watchdog v_timeout_u8 after 1 ms
+ *   1     |  I2C watchdog v_timeout_u8 after 50 ms
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_i2c_wdt_select(
+u8 *v_i2c_wdt_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read I2C watch dog timer */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_IF_CONFIG_I2C_WDT_SELECT__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_i2c_wdt_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_IF_CONFIG_I2C_WDT_SELECT);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write I2C Watchdog timer
+ *	from the register 0x70 bit 1
+ *
+ *  @param v_i2c_wdt_u8 : The value of I2C watch dog timer
+ *  Value  |  Description
+ * --------|-------------
+ *   0     |  I2C watchdog v_timeout_u8 after 1 ms
+ *   1     |  I2C watchdog v_timeout_u8 after 50 ms
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_i2c_wdt_select(
+u8 v_i2c_wdt_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_i2c_wdt_u8 <= BMI160_MAX_VALUE_I2C_WDT) {
+			/* write I2C watch dog timer */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_IF_CONFIG_I2C_WDT_SELECT__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_IF_CONFIG_I2C_WDT_SELECT,
+				v_i2c_wdt_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_IF_CONFIG_I2C_WDT_SELECT__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read I2C watchdog enable
+ *	from the register 0x70 bit 2
+ *
+ *  @param v_i2c_wdt_u8 : The value of I2C watchdog enable
+ *  Value  |  Description
+ * --------|-------------
+ *   0     |  DISABLE
+ *   1     |  ENABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_i2c_wdt_enable(
+u8 *v_i2c_wdt_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read i2c watch dog eneble */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_IF_CONFIG_I2C_WDT_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_i2c_wdt_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_IF_CONFIG_I2C_WDT_ENABLE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write I2C watchdog enable
+ *	from the register 0x70 bit 2
+ *
+ *  @param v_i2c_wdt_u8 : The value of I2C watchdog enable
+ *  Value  |  Description
+ * --------|-------------
+ *   0     |  DISABLE
+ *   1     |  ENABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_i2c_wdt_enable(
+u8 v_i2c_wdt_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_i2c_wdt_u8 <= BMI160_MAX_VALUE_I2C_WDT) {
+			/* write i2c watch dog eneble */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_IF_CONFIG_I2C_WDT_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_IF_CONFIG_I2C_WDT_ENABLE,
+				v_i2c_wdt_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_IF_CONFIG_I2C_WDT_ENABLE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ * @brief This API read I2C interface configuration(if) moe
+ * from the register 0x6B bit 4 and 5
+ *
+ *  @param  v_if_mode_u8 : The value of interface configuration mode
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  |  Primary interface:autoconfig / secondary interface:off
+ *   0x01  |  Primary interface:I2C / secondary interface:OIS
+ *   0x02  |  Primary interface:autoconfig/secondary interface:Magnetometer
+ *   0x03  |   Reserved
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_if_mode(
+u8 *v_if_mode_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read if mode*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_IF_CONFIG_IF_MODE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_if_mode_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_IF_CONFIG_IF_MODE);
+		}
+	return com_rslt;
+}
+/*!
+ * @brief This API write I2C interface configuration(if) moe
+ * from the register 0x6B bit 4 and 5
+ *
+ *  @param  v_if_mode_u8 : The value of interface configuration mode
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  |  Primary interface:autoconfig / secondary interface:off
+ *   0x01  |  Primary interface:I2C / secondary interface:OIS
+ *   0x02  |  Primary interface:autoconfig/secondary interface:Magnetometer
+ *   0x03  |   Reserved
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_if_mode(
+u8 v_if_mode_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_if_mode_u8 <= BMI160_MAX_IF_MODE) {
+			/* write if mode*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_IF_CONFIG_IF_MODE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_IF_CONFIG_IF_MODE,
+				v_if_mode_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_IF_CONFIG_IF_MODE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read gyro sleep trigger
+ *	from the register 0x6C bit 0 to 2
+ *
+ *  @param v_gyro_sleep_trigger_u8 : The value of gyro sleep trigger
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | nomotion: no / Not INT1 pin: no / INT2 pin: no
+ *   0x01  | nomotion: no / Not INT1 pin: no / INT2 pin: yes
+ *   0x02  | nomotion: no / Not INT1 pin: yes / INT2 pin: no
+ *   0x03  | nomotion: no / Not INT1 pin: yes / INT2 pin: yes
+ *   0x04  | nomotion: yes / Not INT1 pin: no / INT2 pin: no
+ *   0x05  | anymotion: yes / Not INT1 pin: no / INT2 pin: yes
+ *   0x06  | anymotion: yes / Not INT1 pin: yes / INT2 pin: no
+ *   0x07  | anymotion: yes / Not INT1 pin: yes / INT2 pin: yes
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_sleep_trigger(
+u8 *v_gyro_sleep_trigger_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read gyro sleep trigger */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_GYRO_SLEEP_TRIGGER__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_gyro_sleep_trigger_u8 =
+			BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_GYRO_SLEEP_TRIGGER);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write gyro sleep trigger
+ *	from the register 0x6C bit 0 to 2
+ *
+ *  @param v_gyro_sleep_trigger_u8 : The value of gyro sleep trigger
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | nomotion: no / Not INT1 pin: no / INT2 pin: no
+ *   0x01  | nomotion: no / Not INT1 pin: no / INT2 pin: yes
+ *   0x02  | nomotion: no / Not INT1 pin: yes / INT2 pin: no
+ *   0x03  | nomotion: no / Not INT1 pin: yes / INT2 pin: yes
+ *   0x04  | nomotion: yes / Not INT1 pin: no / INT2 pin: no
+ *   0x05  | anymotion: yes / Not INT1 pin: no / INT2 pin: yes
+ *   0x06  | anymotion: yes / Not INT1 pin: yes / INT2 pin: no
+ *   0x07  | anymotion: yes / Not INT1 pin: yes / INT2 pin: yes
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_sleep_trigger(
+u8 v_gyro_sleep_trigger_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_gyro_sleep_trigger_u8 <= BMI160_MAX_GYRO_SLEEP_TIGGER) {
+			/* write gyro sleep trigger */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_GYRO_SLEEP_TRIGGER__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_GYRO_SLEEP_TRIGGER,
+				v_gyro_sleep_trigger_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_GYRO_SLEEP_TRIGGER__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read gyro wakeup trigger
+ *	from the register 0x6C bit 3 and 4
+ *
+ *  @param v_gyro_wakeup_trigger_u8 : The value of gyro wakeup trigger
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | anymotion: no / INT1 pin: no
+ *   0x01  | anymotion: no / INT1 pin: yes
+ *   0x02  | anymotion: yes / INT1 pin: no
+ *   0x03  | anymotion: yes / INT1 pin: yes
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_wakeup_trigger(
+u8 *v_gyro_wakeup_trigger_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read gyro wakeup trigger */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_GYRO_WAKEUP_TRIGGER__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_gyro_wakeup_trigger_u8 = BMI160_GET_BITSLICE(
+			v_data_u8,
+			BMI160_USER_GYRO_WAKEUP_TRIGGER);
+	  }
+	return com_rslt;
+}
+/*!
+ *	@brief This API write gyro wakeup trigger
+ *	from the register 0x6C bit 3 and 4
+ *
+ *  @param v_gyro_wakeup_trigger_u8 : The value of gyro wakeup trigger
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | anymotion: no / INT1 pin: no
+ *   0x01  | anymotion: no / INT1 pin: yes
+ *   0x02  | anymotion: yes / INT1 pin: no
+ *   0x03  | anymotion: yes / INT1 pin: yes
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_wakeup_trigger(
+u8 v_gyro_wakeup_trigger_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_gyro_wakeup_trigger_u8
+		<= BMI160_MAX_GYRO_WAKEUP_TRIGGER) {
+			/* write gyro wakeup trigger */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_GYRO_WAKEUP_TRIGGER__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_GYRO_WAKEUP_TRIGGER,
+				v_gyro_wakeup_trigger_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_GYRO_WAKEUP_TRIGGER__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read Target state for gyro sleep mode
+ *	from the register 0x6C bit 5
+ *
+ *  @param v_gyro_sleep_state_u8 : The value of gyro sleep mode
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | Sleep transition to fast wake up state
+ *   0x01  | Sleep transition to suspend state
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_sleep_state(
+u8 *v_gyro_sleep_state_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read gyro sleep state*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_GYRO_SLEEP_STATE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_gyro_sleep_state_u8 = BMI160_GET_BITSLICE(
+			v_data_u8,
+			BMI160_USER_GYRO_SLEEP_STATE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write Target state for gyro sleep mode
+ *	from the register 0x6C bit 5
+ *
+ *  @param v_gyro_sleep_state_u8 : The value of gyro sleep mode
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | Sleep transition to fast wake up state
+ *   0x01  | Sleep transition to suspend state
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_sleep_state(
+u8 v_gyro_sleep_state_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_gyro_sleep_state_u8 <= BMI160_MAX_VALUE_SLEEP_STATE) {
+			/* write gyro sleep state*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_GYRO_SLEEP_STATE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_GYRO_SLEEP_STATE,
+				v_gyro_sleep_state_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_GYRO_SLEEP_STATE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read gyro wakeup interrupt
+ *	from the register 0x6C bit 6
+ *
+ *  @param v_gyro_wakeup_intr_u8 : The valeu of gyro wakeup interrupt
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | DISABLE
+ *   0x01  | ENABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_wakeup_intr(
+u8 *v_gyro_wakeup_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read gyro wakeup interrupt */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_GYRO_WAKEUP_INTR__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_gyro_wakeup_intr_u8 = BMI160_GET_BITSLICE(
+			v_data_u8,
+			BMI160_USER_GYRO_WAKEUP_INTR);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write gyro wakeup interrupt
+ *	from the register 0x6C bit 6
+ *
+ *  @param v_gyro_wakeup_intr_u8 : The valeu of gyro wakeup interrupt
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | DISABLE
+ *   0x01  | ENABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_wakeup_intr(
+u8 v_gyro_wakeup_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_gyro_wakeup_intr_u8 <= BMI160_MAX_VALUE_WAKEUP_INTR) {
+			/* write gyro wakeup interrupt */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_GYRO_WAKEUP_INTR__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_GYRO_WAKEUP_INTR,
+				v_gyro_wakeup_intr_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_GYRO_WAKEUP_INTR__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ * @brief This API read accel select axis to be self-test
+ *
+ *  @param v_accel_selftest_axis_u8 :
+ *	The value of accel self test axis selection
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | disabled
+ *   0x01  | x-axis
+ *   0x02  | y-axis
+ *   0x03  | z-axis
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_selftest_axis(
+u8 *v_accel_selftest_axis_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read accel self test axis*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_ACCEL_SELFTEST_AXIS__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_accel_selftest_axis_u8 = BMI160_GET_BITSLICE(
+			v_data_u8,
+			BMI160_USER_ACCEL_SELFTEST_AXIS);
+		}
+	return com_rslt;
+}
+/*!
+ * @brief This API write accel select axis to be self-test
+ *
+ *  @param v_accel_selftest_axis_u8 :
+ *	The value of accel self test axis selection
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | disabled
+ *   0x01  | x-axis
+ *   0x02  | y-axis
+ *   0x03  | z-axis
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_selftest_axis(
+u8 v_accel_selftest_axis_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_accel_selftest_axis_u8
+		<= BMI160_MAX_ACCEL_SELFTEST_AXIS) {
+			/* write accel self test axis*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_ACCEL_SELFTEST_AXIS__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_ACCEL_SELFTEST_AXIS,
+				v_accel_selftest_axis_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_ACCEL_SELFTEST_AXIS__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read accel self test axis sign
+ *	from the register 0x6D bit 2
+ *
+ *  @param v_accel_selftest_sign_u8: The value of accel self test axis sign
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | negative
+ *   0x01  | positive
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_selftest_sign(
+u8 *v_accel_selftest_sign_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read accel self test axis sign*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_ACCEL_SELFTEST_SIGN__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_accel_selftest_sign_u8 = BMI160_GET_BITSLICE(
+			v_data_u8,
+			BMI160_USER_ACCEL_SELFTEST_SIGN);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write accel self test axis sign
+ *	from the register 0x6D bit 2
+ *
+ *  @param v_accel_selftest_sign_u8: The value of accel self test axis sign
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | negative
+ *   0x01  | positive
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_selftest_sign(
+u8 v_accel_selftest_sign_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_accel_selftest_sign_u8 <=
+		BMI160_MAX_VALUE_SELFTEST_SIGN) {
+			/* write accel self test axis sign*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_ACCEL_SELFTEST_SIGN__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_ACCEL_SELFTEST_SIGN,
+				v_accel_selftest_sign_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_ACCEL_SELFTEST_SIGN__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+			com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read accel self test amplitude
+ *	from the register 0x6D bit 3
+ *        select amplitude of the selftest deflection:
+ *
+ *  @param v_accel_selftest_amp_u8 : The value of accel self test amplitude
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | LOW
+ *   0x01  | HIGH
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_selftest_amp(
+u8 *v_accel_selftest_amp_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read  self test amplitude*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_SELFTEST_AMP__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_accel_selftest_amp_u8 = BMI160_GET_BITSLICE(
+			v_data_u8,
+			BMI160_USER_SELFTEST_AMP);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write accel self test amplitude
+ *	from the register 0x6D bit 3
+ *        select amplitude of the selftest deflection:
+ *
+ *  @param v_accel_selftest_amp_u8 : The value of accel self test amplitude
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | LOW
+ *   0x01  | HIGH
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_selftest_amp(
+u8 v_accel_selftest_amp_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_accel_selftest_amp_u8 <=
+		BMI160_MAX_VALUE_SELFTEST_AMP) {
+			/* write  self test amplitude*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_SELFTEST_AMP__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_SELFTEST_AMP,
+				v_accel_selftest_amp_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_SELFTEST_AMP__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read gyro self test trigger
+ *
+ *	@param v_gyro_selftest_start_u8: The value of gyro self test start
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_selftest_start(
+u8 *v_gyro_selftest_start_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read gyro self test start */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_GYRO_SELFTEST_START__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_gyro_selftest_start_u8 = BMI160_GET_BITSLICE(
+			v_data_u8,
+			BMI160_USER_GYRO_SELFTEST_START);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write gyro self test trigger
+ *
+ *	@param v_gyro_selftest_start_u8: The value of gyro self test start
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_selftest_start(
+u8 v_gyro_selftest_start_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_gyro_selftest_start_u8 <=
+		BMI160_MAX_VALUE_SELFTEST_START) {
+			/* write gyro self test start */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_GYRO_SELFTEST_START__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_GYRO_SELFTEST_START,
+				v_gyro_selftest_start_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_GYRO_SELFTEST_START__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+ /*!
+ * @brief This API read primary interface selection I2C or SPI
+ *	from the register 0x70 bit 0
+ *
+ *  @param v_spi_enable_u8: The value of Interface selection
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | I2C Enable
+ *   0x01  | I2C DISBALE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_spi_enable(u8 *v_spi_enable_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read interface section*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_NV_CONFIG_SPI_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_spi_enable_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_NV_CONFIG_SPI_ENABLE);
+		}
+	return com_rslt;
+}
+ /*!
+ * @brief This API write primary interface selection I2C or SPI
+ *	from the register 0x70 bit 0
+ *
+ *  @param v_spi_enable_u8: The value of Interface selection
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | I2C Enable
+ *   0x01  | I2C DISBALE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_spi_enable(u8 v_spi_enable_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* write interface section*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_NV_CONFIG_SPI_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_NV_CONFIG_SPI_ENABLE,
+				v_spi_enable_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
+				(p_bmi160->dev_addr,
+				BMI160_USER_NV_CONFIG_SPI_ENABLE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API read the spare zero
+ *	form register 0x70 bit 3
+ *
+ *
+ *  @param v_spare0_trim_u8: The value of spare zero
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_spare0_trim(u8 *v_spare0_trim_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read spare zero*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_NV_CONFIG_SPARE0__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_spare0_trim_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_NV_CONFIG_SPARE0);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write the spare zero
+ *	form register 0x70 bit 3
+ *
+ *
+ *  @param v_spare0_trim_u8: The value of spare zero
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_spare0_trim(u8 v_spare0_trim_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* write  spare zero*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_NV_CONFIG_SPARE0__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_NV_CONFIG_SPARE0,
+				v_spare0_trim_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_NV_CONFIG_SPARE0__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API read the NVM counter
+ *	form register 0x70 bit 4 to 7
+ *
+ *
+ *  @param v_nvm_counter_u8: The value of NVM counter
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_nvm_counter(u8 *v_nvm_counter_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read NVM counter*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_NV_CONFIG_NVM_COUNTER__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_nvm_counter_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_NV_CONFIG_NVM_COUNTER);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write the NVM counter
+ *	form register 0x70 bit 4 to 7
+ *
+ *
+ *  @param v_nvm_counter_u8: The value of NVM counter
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_nvm_counter(
+u8 v_nvm_counter_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* write NVM counter*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_NV_CONFIG_NVM_COUNTER__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_NV_CONFIG_NVM_COUNTER,
+				v_nvm_counter_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_NV_CONFIG_NVM_COUNTER__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read accel manual offset compensation of x axis
+ *	from the register 0x71 bit 0 to 7
+ *
+ *
+ *
+ *  @param v_accel_off_x_s8:
+ *	The value of accel manual offset compensation of x axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_offset_compensation_xaxis(
+s8 *v_accel_off_x_s8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read accel manual offset compensation of x axis*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_OFFSET_0_ACCEL_OFF_X__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_accel_off_x_s8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_OFFSET_0_ACCEL_OFF_X);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write accel manual offset compensation of x axis
+ *	from the register 0x71 bit 0 to 7
+ *
+ *
+ *
+ *  @param v_accel_off_x_s8:
+ *	The value of accel manual offset compensation of x axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_offset_compensation_xaxis(
+s8 v_accel_off_x_s8)
+{
+/* variable used for return the status of communication result*/
+BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+u8 v_status_s8 = SUCCESS;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+		/* enable accel offset */
+		v_status_s8 = bmi160_set_accel_offset_enable(
+		ACCEL_OFFSET_ENABLE);
+		if (v_status_s8 == SUCCESS) {
+			/* write accel manual offset compensation of x axis*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_OFFSET_0_ACCEL_OFF_X__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 =
+				BMI160_SET_BITSLICE(
+				v_data_u8,
+				BMI160_USER_OFFSET_0_ACCEL_OFF_X,
+				v_accel_off_x_s8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_OFFSET_0_ACCEL_OFF_X__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt =  ERROR;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read accel manual offset compensation of y axis
+ *	from the register 0x72 bit 0 to 7
+ *
+ *
+ *
+ *  @param v_accel_off_y_s8:
+ *	The value of accel manual offset compensation of y axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_offset_compensation_yaxis(
+s8 *v_accel_off_y_s8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read accel manual offset compensation of y axis*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_OFFSET_1_ACCEL_OFF_Y__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_accel_off_y_s8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_OFFSET_1_ACCEL_OFF_Y);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write accel manual offset compensation of y axis
+ *	from the register 0x72 bit 0 to 7
+ *
+ *
+ *
+ *  @param v_accel_off_y_s8:
+ *	The value of accel manual offset compensation of y axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_offset_compensation_yaxis(
+s8 v_accel_off_y_s8)
+{
+/* variable used for return the status of communication result*/
+BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+u8 v_status_s8 = SUCCESS;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+		/* enable accel offset */
+		v_status_s8 = bmi160_set_accel_offset_enable(
+		ACCEL_OFFSET_ENABLE);
+		if (v_status_s8 == SUCCESS) {
+			/* write accel manual offset compensation of y axis*/
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_OFFSET_1_ACCEL_OFF_Y__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 =
+				BMI160_SET_BITSLICE(
+				v_data_u8,
+				BMI160_USER_OFFSET_1_ACCEL_OFF_Y,
+				v_accel_off_y_s8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_OFFSET_1_ACCEL_OFF_Y__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = ERROR;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read accel manual offset compensation of z axis
+ *	from the register 0x73 bit 0 to 7
+ *
+ *
+ *
+ *  @param v_accel_off_z_s8:
+ *	The value of accel manual offset compensation of z axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_offset_compensation_zaxis(
+s8 *v_accel_off_z_s8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read accel manual offset compensation of z axis*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_OFFSET_2_ACCEL_OFF_Z__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_accel_off_z_s8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_OFFSET_2_ACCEL_OFF_Z);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write accel manual offset compensation of z axis
+ *	from the register 0x73 bit 0 to 7
+ *
+ *
+ *
+ *  @param v_accel_off_z_s8:
+ *	The value of accel manual offset compensation of z axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_offset_compensation_zaxis(
+s8 v_accel_off_z_s8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	u8 v_status_s8 = SUCCESS;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* enable accel offset */
+			v_status_s8 = bmi160_set_accel_offset_enable(
+			ACCEL_OFFSET_ENABLE);
+			if (v_status_s8 == SUCCESS) {
+				/* write accel manual offset
+				compensation of z axis*/
+				com_rslt =
+				p_bmi160->BMI160_BUS_READ_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_OFFSET_2_ACCEL_OFF_Z__REG,
+				&v_data_u8,
+				BMI160_GEN_READ_WRITE_DATA_LENGTH);
+				if (com_rslt == SUCCESS) {
+					v_data_u8 =
+					BMI160_SET_BITSLICE(v_data_u8,
+					BMI160_USER_OFFSET_2_ACCEL_OFF_Z,
+					v_accel_off_z_s8);
+					com_rslt +=
+					p_bmi160->BMI160_BUS_WRITE_FUNC(
+					p_bmi160->dev_addr,
+					BMI160_USER_OFFSET_2_ACCEL_OFF_Z__REG,
+					&v_data_u8,
+					BMI160_GEN_READ_WRITE_DATA_LENGTH);
+				}
+			} else {
+			com_rslt = ERROR;
+			}
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read gyro manual offset compensation of x axis
+ *	from the register 0x74 bit 0 to 7 and 0x77 bit 0 and 1
+ *
+ *
+ *
+ *  @param v_gyro_off_x_s16:
+ *	The value of gyro manual offset compensation of x axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_offset_compensation_xaxis(
+s16 *v_gyro_off_x_s16)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data1_u8r = BMI160_INIT_VALUE;
+	u8 v_data2_u8r = BMI160_INIT_VALUE;
+	s16 v_data3_u8r, v_data4_u8r = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read gyro offset x*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_OFFSET_3_GYRO_OFF_X__REG,
+			&v_data1_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			v_data1_u8r = BMI160_GET_BITSLICE(v_data1_u8r,
+			BMI160_USER_OFFSET_3_GYRO_OFF_X);
+			com_rslt += p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_OFFSET_6_GYRO_OFF_X__REG,
+			&v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			v_data2_u8r = BMI160_GET_BITSLICE(v_data2_u8r,
+			BMI160_USER_OFFSET_6_GYRO_OFF_X);
+			v_data3_u8r = v_data2_u8r
+			<< BMI160_SHIFT_BIT_POSITION_BY_14_BITS;
+			v_data4_u8r =  v_data1_u8r
+			<< BMI160_SHIFT_BIT_POSITION_BY_06_BITS;
+			v_data3_u8r = v_data3_u8r | v_data4_u8r;
+			*v_gyro_off_x_s16 = v_data3_u8r
+			>> BMI160_SHIFT_BIT_POSITION_BY_06_BITS;
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write gyro manual offset compensation of x axis
+ *	from the register 0x74 bit 0 to 7 and 0x77 bit 0 and 1
+ *
+ *
+ *
+ *  @param v_gyro_off_x_s16:
+ *	The value of gyro manual offset compensation of x axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_offset_compensation_xaxis(
+s16 v_gyro_off_x_s16)
+{
+/* variable used for return the status of communication result*/
+BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data1_u8r, v_data2_u8r = BMI160_INIT_VALUE;
+u16 v_data3_u8r = BMI160_INIT_VALUE;
+u8 v_status_s8 = SUCCESS;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+		/* write gyro offset x*/
+		v_status_s8 = bmi160_set_gyro_offset_enable(
+		GYRO_OFFSET_ENABLE);
+		if (v_status_s8 == SUCCESS) {
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_OFFSET_3_GYRO_OFF_X__REG,
+			&v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data1_u8r =
+				((s8) (v_gyro_off_x_s16 &
+				BMI160_GYRO_MANUAL_OFFSET_0_7));
+				v_data2_u8r = BMI160_SET_BITSLICE(
+				v_data2_u8r,
+				BMI160_USER_OFFSET_3_GYRO_OFF_X,
+				v_data1_u8r);
+				/* write 0x74 bit 0 to 7*/
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_OFFSET_3_GYRO_OFF_X__REG,
+				&v_data2_u8r,
+				BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+
+			com_rslt += p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_OFFSET_6_GYRO_OFF_X__REG,
+			&v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data3_u8r =
+				(u16) (v_gyro_off_x_s16 &
+				BMI160_GYRO_MANUAL_OFFSET_8_9);
+				v_data1_u8r = (u8)(v_data3_u8r
+				>> BMI160_SHIFT_BIT_POSITION_BY_08_BITS);
+				v_data2_u8r = BMI160_SET_BITSLICE(
+				v_data2_u8r,
+				BMI160_USER_OFFSET_6_GYRO_OFF_X,
+				v_data1_u8r);
+				/* write 0x77 bit 0 and 1*/
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_OFFSET_6_GYRO_OFF_X__REG,
+				&v_data2_u8r,
+				BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		return ERROR;
+		}
+	}
+return com_rslt;
+}
+/*!
+ *	@brief This API read gyro manual offset compensation of y axis
+ *	from the register 0x75 bit 0 to 7 and 0x77 bit 2 and 3
+ *
+ *
+ *
+ *  @param v_gyro_off_y_s16:
+ *	The value of gyro manual offset compensation of y axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_offset_compensation_yaxis(
+s16 *v_gyro_off_y_s16)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data1_u8r = BMI160_INIT_VALUE;
+	u8 v_data2_u8r = BMI160_INIT_VALUE;
+	s16 v_data3_u8r, v_data4_u8r = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read gyro offset y*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_OFFSET_4_GYRO_OFF_Y__REG,
+			&v_data1_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			v_data1_u8r = BMI160_GET_BITSLICE(v_data1_u8r,
+			BMI160_USER_OFFSET_4_GYRO_OFF_Y);
+			com_rslt += p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_OFFSET_6_GYRO_OFF_Y__REG,
+			&v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			v_data2_u8r = BMI160_GET_BITSLICE(v_data2_u8r,
+			BMI160_USER_OFFSET_6_GYRO_OFF_Y);
+			v_data3_u8r = v_data2_u8r
+			<< BMI160_SHIFT_BIT_POSITION_BY_14_BITS;
+			v_data4_u8r =  v_data1_u8r
+			<< BMI160_SHIFT_BIT_POSITION_BY_06_BITS;
+			v_data3_u8r = v_data3_u8r | v_data4_u8r;
+			*v_gyro_off_y_s16 = v_data3_u8r
+			>> BMI160_SHIFT_BIT_POSITION_BY_06_BITS;
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write gyro manual offset compensation of y axis
+ *	from the register 0x75 bit 0 to 7 and 0x77 bit 2 and 3
+ *
+ *
+ *
+ *  @param v_gyro_off_y_s16:
+ *	The value of gyro manual offset compensation of y axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_offset_compensation_yaxis(
+s16 v_gyro_off_y_s16)
+{
+/* variable used for return the status of communication result*/
+BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data1_u8r, v_data2_u8r = BMI160_INIT_VALUE;
+u16 v_data3_u8r = BMI160_INIT_VALUE;
+u8 v_status_s8 = SUCCESS;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+		/* enable gyro offset bit */
+		v_status_s8 = bmi160_set_gyro_offset_enable(
+		GYRO_OFFSET_ENABLE);
+		/* write gyro offset y*/
+		if (v_status_s8 == SUCCESS) {
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_OFFSET_4_GYRO_OFF_Y__REG,
+			&v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data1_u8r =
+				((s8) (v_gyro_off_y_s16 &
+				BMI160_GYRO_MANUAL_OFFSET_0_7));
+				v_data2_u8r = BMI160_SET_BITSLICE(
+				v_data2_u8r,
+				BMI160_USER_OFFSET_4_GYRO_OFF_Y,
+				v_data1_u8r);
+				/* write 0x75 bit 0 to 7*/
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC
+				(p_bmi160->dev_addr,
+				BMI160_USER_OFFSET_4_GYRO_OFF_Y__REG,
+				&v_data2_u8r,
+				BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+
+			com_rslt += p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_OFFSET_6_GYRO_OFF_Y__REG,
+			&v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data3_u8r =
+				(u16) (v_gyro_off_y_s16 &
+				BMI160_GYRO_MANUAL_OFFSET_8_9);
+				v_data1_u8r = (u8)(v_data3_u8r
+				>> BMI160_SHIFT_BIT_POSITION_BY_08_BITS);
+				v_data2_u8r = BMI160_SET_BITSLICE(
+				v_data2_u8r,
+				BMI160_USER_OFFSET_6_GYRO_OFF_Y,
+				v_data1_u8r);
+				/* write 0x77 bit 2 and 3*/
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC
+				(p_bmi160->dev_addr,
+				BMI160_USER_OFFSET_6_GYRO_OFF_Y__REG,
+				&v_data2_u8r,
+				BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		return ERROR;
+		}
+	}
+return com_rslt;
+}
+/*!
+ *	@brief This API read gyro manual offset compensation of z axis
+ *	from the register 0x76 bit 0 to 7 and 0x77 bit 4 and 5
+ *
+ *
+ *
+ *  @param v_gyro_off_z_s16:
+ *	The value of gyro manual offset compensation of z axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_offset_compensation_zaxis(
+s16 *v_gyro_off_z_s16)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data1_u8r = BMI160_INIT_VALUE;
+	u8 v_data2_u8r = BMI160_INIT_VALUE;
+	s16 v_data3_u8r, v_data4_u8r = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read gyro manual offset z axis*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_OFFSET_5_GYRO_OFF_Z__REG,
+			&v_data1_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			v_data1_u8r = BMI160_GET_BITSLICE
+			(v_data1_u8r,
+			BMI160_USER_OFFSET_5_GYRO_OFF_Z);
+			com_rslt +=
+			p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_OFFSET_6_GYRO_OFF_Z__REG,
+			&v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			v_data2_u8r = BMI160_GET_BITSLICE(
+			v_data2_u8r,
+			BMI160_USER_OFFSET_6_GYRO_OFF_Z);
+			v_data3_u8r = v_data2_u8r
+			<< BMI160_SHIFT_BIT_POSITION_BY_14_BITS;
+			v_data4_u8r =  v_data1_u8r
+			<< BMI160_SHIFT_BIT_POSITION_BY_06_BITS;
+			v_data3_u8r = v_data3_u8r | v_data4_u8r;
+			*v_gyro_off_z_s16 = v_data3_u8r
+			>> BMI160_SHIFT_BIT_POSITION_BY_06_BITS;
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write gyro manual offset compensation of z axis
+ *	from the register 0x76 bit 0 to 7 and 0x77 bit 4 and 5
+ *
+ *
+ *
+ *  @param v_gyro_off_z_s16:
+ *	The value of gyro manual offset compensation of z axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_offset_compensation_zaxis(
+s16 v_gyro_off_z_s16)
+{
+/* variable used for return the status of communication result*/
+BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data1_u8r, v_data2_u8r = BMI160_INIT_VALUE;
+u16 v_data3_u8r = BMI160_INIT_VALUE;
+u8 v_status_s8 = SUCCESS;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+	} else {
+		/* enable gyro offset*/
+		v_status_s8 = bmi160_set_gyro_offset_enable(
+		GYRO_OFFSET_ENABLE);
+		/* write gyro manual offset z axis*/
+		if (v_status_s8 == SUCCESS) {
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_OFFSET_5_GYRO_OFF_Z__REG,
+			&v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data1_u8r =
+				((u8) (v_gyro_off_z_s16 &
+				BMI160_GYRO_MANUAL_OFFSET_0_7));
+				v_data2_u8r = BMI160_SET_BITSLICE(
+				v_data2_u8r,
+				BMI160_USER_OFFSET_5_GYRO_OFF_Z,
+				v_data1_u8r);
+				/* write 0x76 bit 0 to 7*/
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC
+				(p_bmi160->dev_addr,
+				BMI160_USER_OFFSET_5_GYRO_OFF_Z__REG,
+				&v_data2_u8r,
+				BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+
+			com_rslt += p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_OFFSET_6_GYRO_OFF_Z__REG,
+			&v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data3_u8r =
+				(u16) (v_gyro_off_z_s16 &
+				BMI160_GYRO_MANUAL_OFFSET_8_9);
+				v_data1_u8r = (u8)(v_data3_u8r
+				>> BMI160_SHIFT_BIT_POSITION_BY_08_BITS);
+				v_data2_u8r = BMI160_SET_BITSLICE(
+				v_data2_u8r,
+				BMI160_USER_OFFSET_6_GYRO_OFF_Z,
+				v_data1_u8r);
+				/* write 0x77 bit 4 and 5*/
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC
+				(p_bmi160->dev_addr,
+				BMI160_USER_OFFSET_6_GYRO_OFF_Z__REG,
+				&v_data2_u8r,
+				BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		return ERROR;
+		}
+	}
+return com_rslt;
+}
+/*!
+ *	@brief This API read the accel offset enable bit
+ *	from the register 0x77 bit 6
+ *
+ *
+ *
+ *  @param v_accel_off_enable_u8: The value of accel offset enable
+ *  value    |  Description
+ * ----------|--------------
+ *   0x01    | ENABLE
+ *   0x00    | DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_offset_enable(
+u8 *v_accel_off_enable_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read accel offset enable */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_OFFSET_6_ACCEL_OFF_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_accel_off_enable_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_OFFSET_6_ACCEL_OFF_ENABLE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write the accel offset enable bit
+ *	from the register 0x77 bit 6
+ *
+ *
+ *
+ *  @param v_accel_off_enable_u8: The value of accel offset enable
+ *  value    |  Description
+ * ----------|--------------
+ *   0x01    | ENABLE
+ *   0x00    | DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_offset_enable(
+u8 v_accel_off_enable_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+			} else {
+			/* write accel offset enable */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_OFFSET_6_ACCEL_OFF_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_OFFSET_6_ACCEL_OFF_ENABLE,
+				v_accel_off_enable_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_OFFSET_6_ACCEL_OFF_ENABLE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read the accel offset enable bit
+ *	from the register 0x77 bit 7
+ *
+ *
+ *
+ *  @param v_gyro_off_enable_u8: The value of gyro offset enable
+ *  value    |  Description
+ * ----------|--------------
+ *   0x01    | ENABLE
+ *   0x00    | DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_offset_enable(
+u8 *v_gyro_off_enable_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read gyro offset*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_OFFSET_6_GYRO_OFF_EN__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_gyro_off_enable_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_OFFSET_6_GYRO_OFF_EN);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write the accel offset enable bit
+ *	from the register 0x77 bit 7
+ *
+ *
+ *
+ *  @param v_gyro_off_enable_u8: The value of gyro offset enable
+ *  value    |  Description
+ * ----------|--------------
+ *   0x01    | ENABLE
+ *   0x00    | DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_offset_enable(
+u8 v_gyro_off_enable_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* write gyro offset*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_OFFSET_6_GYRO_OFF_EN__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_USER_OFFSET_6_GYRO_OFF_EN,
+				v_gyro_off_enable_u8);
+				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
+				p_bmi160->dev_addr,
+				BMI160_USER_OFFSET_6_GYRO_OFF_EN__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads step counter value
+ *	form the register 0x78 and 0x79
+ *
+ *
+ *
+ *
+ *  @param v_step_cnt_s16 : The value of step counter
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_step_count(u16 *v_step_cnt_s16)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* array having the step counter LSB and MSB data
+	v_data_u8[0] - LSB
+	v_data_u8[1] - MSB*/
+	u8 a_data_u8r[BMI160_STEP_COUNT_DATA_SIZE] = {BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE};
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read step counter */
+			com_rslt =
+			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+			BMI160_USER_STEP_COUNT_LSB__REG,
+			a_data_u8r, BMI160_STEP_COUNTER_LENGTH);
+
+			*v_step_cnt_s16 = (s16)
+			((((s32)((s8)a_data_u8r[BMI160_STEP_COUNT_MSB_BYTE]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
+			| (a_data_u8r[BMI160_STEP_COUNT_LSB_BYTE]));
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API Reads
+ *	step counter configuration
+ *	from the register 0x7A bit 0 to 7
+ *	and from the register 0x7B bit 0 to 2 and 4 to 7
+ *
+ *
+ *  @param v_step_config_u16 : The value of step configuration
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_step_config(
+u16 *v_step_config_u16)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data1_u8r = BMI160_INIT_VALUE;
+	u8 v_data2_u8r = BMI160_INIT_VALUE;
+	u16 v_data3_u8r = BMI160_INIT_VALUE;
+	/* Read the 0 to 7 bit*/
+	com_rslt =
+	p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+	BMI160_USER_STEP_CONFIG_ZERO__REG,
+	&v_data1_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	/* Read the 8 to 10 bit*/
+	com_rslt +=
+	p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+	BMI160_USER_STEP_CONFIG_ONE_CNF1__REG,
+	&v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	v_data2_u8r = BMI160_GET_BITSLICE(v_data2_u8r,
+	BMI160_USER_STEP_CONFIG_ONE_CNF1);
+	v_data3_u8r = ((u16)((((u32)
+	((u8)v_data2_u8r))
+	<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS) | (v_data1_u8r)));
+	/* Read the 11 to 14 bit*/
+	com_rslt +=
+	p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+	BMI160_USER_STEP_CONFIG_ONE_CNF2__REG,
+	&v_data1_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	v_data1_u8r = BMI160_GET_BITSLICE(v_data1_u8r,
+	BMI160_USER_STEP_CONFIG_ONE_CNF2);
+	*v_step_config_u16 = ((u16)((((u32)
+	((u8)v_data1_u8r))
+	<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS) | (v_data3_u8r)));
+
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write
+ *	step counter configuration
+ *	from the register 0x7A bit 0 to 7
+ *	and from the register 0x7B bit 0 to 2 and 4 to 7
+ *
+ *
+ *  @param v_step_config_u16   :
+ *	the value of  Enable step configuration
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_step_config(
+u16 v_step_config_u16)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data1_u8r = BMI160_INIT_VALUE;
+	u8 v_data2_u8r = BMI160_INIT_VALUE;
+	u16 v_data3_u16 = BMI160_INIT_VALUE;
+
+	/* write the 0 to 7 bit*/
+	v_data1_u8r = (u8)(v_step_config_u16 &
+	BMI160_STEP_CONFIG_0_7);
+	p_bmi160->BMI160_BUS_WRITE_FUNC
+	(p_bmi160->dev_addr,
+	BMI160_USER_STEP_CONFIG_ZERO__REG,
+	&v_data1_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	/* write the 8 to 10 bit*/
+	com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+	(p_bmi160->dev_addr,
+	BMI160_USER_STEP_CONFIG_ONE_CNF1__REG,
+	&v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	if (com_rslt == SUCCESS) {
+		v_data3_u16 = (u16) (v_step_config_u16 &
+		BMI160_STEP_CONFIG_8_10);
+		v_data1_u8r = (u8)(v_data3_u16
+		>> BMI160_SHIFT_BIT_POSITION_BY_08_BITS);
+		v_data2_u8r = BMI160_SET_BITSLICE(v_data2_u8r,
+		BMI160_USER_STEP_CONFIG_ONE_CNF1, v_data1_u8r);
+		p_bmi160->BMI160_BUS_WRITE_FUNC
+		(p_bmi160->dev_addr,
+		BMI160_USER_STEP_CONFIG_ONE_CNF1__REG,
+		&v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	}
+	/* write the 11 to 14 bit*/
+	com_rslt += p_bmi160->BMI160_BUS_READ_FUNC
+	(p_bmi160->dev_addr,
+	BMI160_USER_STEP_CONFIG_ONE_CNF2__REG,
+	&v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	if (com_rslt == SUCCESS) {
+		v_data3_u16 = (u16) (v_step_config_u16 &
+		BMI160_STEP_CONFIG_11_14);
+		v_data1_u8r = (u8)(v_data3_u16
+		>> BMI160_SHIFT_BIT_POSITION_BY_12_BITS);
+		v_data2_u8r = BMI160_SET_BITSLICE(v_data2_u8r,
+		BMI160_USER_STEP_CONFIG_ONE_CNF2, v_data1_u8r);
+		p_bmi160->BMI160_BUS_WRITE_FUNC
+		(p_bmi160->dev_addr,
+		BMI160_USER_STEP_CONFIG_ONE_CNF2__REG,
+		&v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	}
+
+	return com_rslt;
+}
+ /*!
+ *	@brief This API read enable step counter
+ *	from the register 0x7B bit 3
+ *
+ *
+ *  @param v_step_counter_u8 : The value of step counter enable
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_step_counter_enable(
+u8 *v_step_counter_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the step counter */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_step_counter_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write enable step counter
+ *	from the register 0x7B bit 3
+ *
+ *
+ *  @param v_step_counter_u8 : The value of step counter enable
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_step_counter_enable(u8 v_step_counter_u8)
+{
+/* variable used for return the status of communication result*/
+BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+	return E_BMI160_NULL_PTR;
+} else {
+	if (v_step_counter_u8 <= BMI160_MAX_GYRO_STEP_COUNTER) {
+		/* write the step counter */
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+		(p_bmi160->dev_addr,
+		BMI160_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 =
+			BMI160_SET_BITSLICE(v_data_u8,
+			BMI160_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE,
+			v_step_counter_u8);
+			com_rslt +=
+			p_bmi160->BMI160_BUS_WRITE_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	} else {
+	com_rslt = E_BMI160_OUT_OF_RANGE;
+	}
+}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API set Step counter modes
+ *
+ *
+ *  @param  v_step_mode_u8 : The value of step counter mode
+ *  value    |   mode
+ * ----------|-----------
+ *   0       | BMI160_STEP_NORMAL_MODE
+ *   1       | BMI160_STEP_SENSITIVE_MODE
+ *   2       | BMI160_STEP_ROBUST_MODE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_step_mode(u8 v_step_mode_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+
+	switch (v_step_mode_u8) {
+	case BMI160_STEP_NORMAL_MODE:
+		com_rslt = bmi160_set_step_config(
+		STEP_CONFIG_NORMAL);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	break;
+	case BMI160_STEP_SENSITIVE_MODE:
+		com_rslt = bmi160_set_step_config(
+		STEP_CONFIG_SENSITIVE);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	break;
+	case BMI160_STEP_ROBUST_MODE:
+		com_rslt = bmi160_set_step_config(
+		STEP_CONFIG_ROBUST);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	break;
+	default:
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+	break;
+	}
+
+	return com_rslt;
+}
+/*!
+ *	@brief This API used to trigger the  signification motion
+ *	interrupt
+ *
+ *
+ *  @param  v_significant_u8 : The value of interrupt selection
+ *  value    |  interrupt
+ * ----------|-----------
+ *   0       |  BMI160_MAP_INTR1
+ *   1       |  BMI160_MAP_INTR2
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_map_significant_motion_intr(
+u8 v_significant_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_sig_motion_u8 = BMI160_INIT_VALUE;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	u8 v_any_motion_intr1_stat_u8 = BMI160_ENABLE_ANY_MOTION_INTR1;
+	u8 v_any_motion_intr2_stat_u8 = BMI160_ENABLE_ANY_MOTION_INTR2;
+	u8 v_any_motion_axis_stat_u8 = BMI160_ENABLE_ANY_MOTION_AXIS;
+	/* enable the significant motion interrupt */
+	com_rslt = bmi160_get_intr_significant_motion_select(&v_sig_motion_u8);
+	if (v_sig_motion_u8 != BMI160_SIG_MOTION_STAT_HIGH)
+		com_rslt += bmi160_set_intr_significant_motion_select(
+		BMI160_SIG_MOTION_INTR_ENABLE);
+	switch (v_significant_u8) {
+	case BMI160_MAP_INTR1:
+		/* interrupt */
+		com_rslt += bmi160_read_reg(
+		BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		v_data_u8 |= v_any_motion_intr1_stat_u8;
+		/* map the signification interrupt to any-motion interrupt1*/
+		com_rslt += bmi160_write_reg(
+		BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		/* axis*/
+		com_rslt = bmi160_read_reg(BMI160_USER_INTR_ENABLE_0_ADDR,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		v_data_u8 |= v_any_motion_axis_stat_u8;
+		com_rslt += bmi160_write_reg(
+		BMI160_USER_INTR_ENABLE_0_ADDR,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	break;
+
+	case BMI160_MAP_INTR2:
+		/* map the signification interrupt to any-motion interrupt2*/
+		com_rslt += bmi160_read_reg(
+		BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		v_data_u8 |= v_any_motion_intr2_stat_u8;
+		com_rslt += bmi160_write_reg(
+		BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		/* axis*/
+		com_rslt = bmi160_read_reg(BMI160_USER_INTR_ENABLE_0_ADDR,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		v_data_u8 |= v_any_motion_axis_stat_u8;
+		com_rslt += bmi160_write_reg(
+		BMI160_USER_INTR_ENABLE_0_ADDR,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	break;
+
+	default:
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+	break;
+
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API used to trigger the step detector
+ *	interrupt
+ *
+ *
+ *  @param  v_step_detector_u8 : The value of interrupt selection
+ *  value    |  interrupt
+ * ----------|-----------
+ *   0       |  BMI160_MAP_INTR1
+ *   1       |  BMI160_MAP_INTR2
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_map_step_detector_intr(
+u8 v_step_detector_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_step_det_u8 = BMI160_INIT_VALUE;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	u8 v_low_g_intr_u81_stat_u8 = BMI160_LOW_G_INTR_STAT;
+	u8 v_low_g_intr_u82_stat_u8 = BMI160_LOW_G_INTR_STAT;
+	u8 v_low_g_enable_u8 = BMI160_ENABLE_LOW_G;
+	/* read the v_status_s8 of step detector interrupt*/
+	com_rslt = bmi160_get_step_detector_enable(&v_step_det_u8);
+	if (v_step_det_u8 != BMI160_STEP_DET_STAT_HIGH)
+		com_rslt += bmi160_set_step_detector_enable(
+		BMI160_STEP_DETECT_INTR_ENABLE);
+	switch (v_step_detector_u8) {
+	case BMI160_MAP_INTR1:
+		com_rslt += bmi160_read_reg(
+		BMI160_USER_INTR_MAP_0_INTR1_LOW_G__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		v_data_u8 |= v_low_g_intr_u81_stat_u8;
+		/* map the step detector interrupt
+		to Low-g interrupt 1*/
+		com_rslt += bmi160_write_reg(
+		BMI160_USER_INTR_MAP_0_INTR1_LOW_G__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		/* Enable the Low-g interrupt*/
+		com_rslt = bmi160_read_reg(
+		BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		v_data_u8 |= v_low_g_enable_u8;
+		com_rslt += bmi160_write_reg(
+		BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	break;
+	case BMI160_MAP_INTR2:
+		/* map the step detector interrupt
+		to Low-g interrupt 1*/
+		com_rslt += bmi160_read_reg(
+		BMI160_USER_INTR_MAP_2_INTR2_LOW_G__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		v_data_u8 |= v_low_g_intr_u82_stat_u8;
+
+		com_rslt += bmi160_write_reg(
+		BMI160_USER_INTR_MAP_2_INTR2_LOW_G__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		/* Enable the Low-g interrupt*/
+		com_rslt = bmi160_read_reg(
+		BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		v_data_u8 |= v_low_g_enable_u8;
+		com_rslt += bmi160_write_reg(
+		BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	break;
+	default:
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+	break;
+	}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API used to clear the step counter interrupt
+ *	interrupt
+ *
+ *
+ *  @param  : None
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_clear_step_counter(void)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* clear the step counter*/
+	com_rslt = bmi160_set_command_register(RESET_STEP_COUNTER);
+	p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+
+	return com_rslt;
+
+}
+ /*!
+ *	@brief This API writes value to the register 0x7E bit 0 to 7
+ *
+ *
+ *  @param  v_command_reg_u8 : The value to write command register
+ *  value   |  Description
+ * ---------|--------------------------------------------------------
+ *	0x00	|	Reserved
+ *  0x03	|	Starts fast offset calibration for the accel and gyro
+ *	0x10	|	Sets the PMU mode for the Accelerometer to suspend
+ *	0x11	|	Sets the PMU mode for the Accelerometer to normal
+ *	0x12	|	Sets the PMU mode for the Accelerometer Lowpower
+ *  0x14	|	Sets the PMU mode for the Gyroscope to suspend
+ *	0x15	|	Sets the PMU mode for the Gyroscope to normal
+ *	0x16	|	Reserved
+ *	0x17	|	Sets the PMU mode for the Gyroscope to fast start-up
+ *  0x18	|	Sets the PMU mode for the Magnetometer to suspend
+ *	0x19	|	Sets the PMU mode for the Magnetometer to normal
+ *	0x1A	|	Sets the PMU mode for the Magnetometer to Lowpower
+ *	0xB0	|	Clears all data in the FIFO
+ *  0xB1	|	Resets the interrupt engine
+ *	0xB2	|	step_cnt_clr Clears the step counter
+ *	0xB6	|	Triggers a reset
+ *	0x37	|	See extmode_en_last
+ *	0x9A	|	See extmode_en_last
+ *	0xC0	|	Enable the extended mode
+ *  0xC4	|	Erase NVM cell
+ *	0xC8	|	Load NVM cell
+ *	0xF0	|	Reset acceleration data path
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_command_register(u8 v_command_reg_u8)
+{
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* write command register */
+			com_rslt = p_bmi160->BMI160_BUS_WRITE_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_CMD_COMMANDS__REG,
+			&v_command_reg_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API read target page from the register 0x7F bit 4 and 5
+ *
+ *  @param v_target_page_u8: The value of target page
+ *  value   |  page
+ * ---------|-----------
+ *   0      |  User data/configure page
+ *   1      |  Chip level trim/test page
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_target_page(u8 *v_target_page_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* read the page*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+			p_bmi160->dev_addr,
+			BMI160_CMD_TARGET_PAGE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			*v_target_page_u8 = BMI160_GET_BITSLICE(v_data_u8,
+			BMI160_CMD_TARGET_PAGE);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write target page from the register 0x7F bit 4 and 5
+ *
+ *  @param v_target_page_u8: The value of target page
+ *  value   |  page
+ * ---------|-----------
+ *   0      |  User data/configure page
+ *   1      |  Chip level trim/test page
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_target_page(u8 v_target_page_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_target_page_u8 <= BMI160_MAX_TARGET_PAGE) {
+			/* write the page*/
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_CMD_TARGET_PAGE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 =
+				BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_CMD_TARGET_PAGE,
+				v_target_page_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC
+				(p_bmi160->dev_addr,
+				BMI160_CMD_TARGET_PAGE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API read page enable from the register 0x7F bit 7
+ *
+ *
+ *
+ *  @param v_page_enable_u8: The value of page enable
+ *  value   |  page
+ * ---------|-----------
+ *   0      |  DISABLE
+ *   1      |  ENABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_paging_enable(u8 *v_page_enable_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		/* read the page enable */
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+		p_bmi160->dev_addr,
+		BMI160_CMD_PAGING_EN__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		*v_page_enable_u8 = BMI160_GET_BITSLICE(v_data_u8,
+		BMI160_CMD_PAGING_EN);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write page enable from the register 0x7F bit 7
+ *
+ *
+ *
+ *  @param v_page_enable_u8: The value of page enable
+ *  value   |  page
+ * ---------|-----------
+ *   0      |  DISABLE
+ *   1      |  ENABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_paging_enable(
+u8 v_page_enable_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		if (v_page_enable_u8 <= BMI160_MAX_VALUE_PAGE) {
+			/* write the page enable */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_CMD_PAGING_EN__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 =
+				BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_CMD_PAGING_EN,
+				v_page_enable_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC
+				(p_bmi160->dev_addr,
+				BMI160_CMD_PAGING_EN__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API read
+ *	pull up configuration from the register 0X85 bit 4 an 5
+ *
+ *
+ *
+ *  @param v_control_pullup_u8: The value of pull up register
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_pullup_configuration(
+u8 *v_control_pullup_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		/* read pull up value */
+		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
+		p_bmi160->dev_addr,
+		BMI160_COM_C_TRIM_FIVE__REG,
+		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		*v_control_pullup_u8 = BMI160_GET_BITSLICE(v_data_u8,
+		BMI160_COM_C_TRIM_FIVE);
+		}
+	return com_rslt;
+
+}
+ /*!
+ *	@brief This API write
+ *	pull up configuration from the register 0X85 bit 4 an 5
+ *
+ *
+ *
+ *  @param v_control_pullup_u8: The value of pull up register
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_pullup_configuration(
+u8 v_control_pullup_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+			/* write  pull up value */
+			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+			(p_bmi160->dev_addr,
+			BMI160_COM_C_TRIM_FIVE__REG,
+			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 =
+				BMI160_SET_BITSLICE(v_data_u8,
+				BMI160_COM_C_TRIM_FIVE,
+				v_control_pullup_u8);
+				com_rslt +=
+				p_bmi160->BMI160_BUS_WRITE_FUNC
+				(p_bmi160->dev_addr,
+				BMI160_COM_C_TRIM_FIVE__REG,
+				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		}
+	return com_rslt;
+}
+
+/*!
+ *	@brief This function used for read the compensated value of mag
+ *	Before start reading the mag compensated data's
+ *	make sure the following two points are addressed
+ *	@note
+ *	1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note
+ *	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_bmm150_mag_compensate_xyz(
+struct bmi160_mag_xyz_s32_t *mag_comp_xyz)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	struct bmi160_mag_xyzr_t mag_xyzr;
+	com_rslt = bmi160_read_mag_xyzr(&mag_xyzr);
+	if (com_rslt)
+		return com_rslt;
+	/* Compensation for X axis */
+	mag_comp_xyz->x = bmi160_bmm150_mag_compensate_X(
+	mag_xyzr.x, mag_xyzr.r);
+
+	/* Compensation for Y axis */
+	mag_comp_xyz->y = bmi160_bmm150_mag_compensate_Y(
+	mag_xyzr.y, mag_xyzr.r);
+
+	/* Compensation for Z axis */
+	mag_comp_xyz->z = bmi160_bmm150_mag_compensate_Z(
+	mag_xyzr.z, mag_xyzr.r);
+
+	return com_rslt;
+}
+
+/*!
+ *	@brief This function used for read the compensated value of mag
+ *	Before start reading the mag compensated data's
+ *	make sure the following two points are addressed
+ *	@note
+ *	1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note
+ *	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_bmm150_mag_compensate_xyz_raw(
+struct bmi160_mag_xyz_s32_t *mag_comp_xyz, struct bmi160_mag_xyzr_t mag_xyzr)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+
+	/* Compensation for X axis */
+	mag_comp_xyz->x = bmi160_bmm150_mag_compensate_X(
+	mag_xyzr.x, mag_xyzr.r);
+
+	/* Compensation for Y axis */
+	mag_comp_xyz->y = bmi160_bmm150_mag_compensate_Y(
+	mag_xyzr.y, mag_xyzr.r);
+
+	/* Compensation for Z axis */
+	mag_comp_xyz->z = bmi160_bmm150_mag_compensate_Z(
+	mag_xyzr.z, mag_xyzr.r);
+
+	return com_rslt;
+}
+/*!
+ *	@brief This API used to get the compensated BMM150-X data
+ *	the out put of X as s32
+ *	Before start reading the mag compensated X data
+ *	make sure the following two points are addressed
+ *	@note
+ *	1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note
+ *	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+ *
+ *
+ *
+ *  @param  v_mag_data_x_s16 : The value of mag raw X data
+ *  @param  v_data_r_u16 : The value of mag R data
+ *
+ *	@return results of compensated X data value output as s32
+ *
+ */
+s32 bmi160_bmm150_mag_compensate_X(s16 v_mag_data_x_s16, u16 v_data_r_u16)
+{
+s32 inter_retval = BMI160_INIT_VALUE;
+/* no overflow */
+if (v_mag_data_x_s16 != BMI160_MAG_FLIP_OVERFLOW_ADCVAL) {
+	if ((v_data_r_u16 != 0)
+	&& (mag_trim.dig_xyz1 != 0)) {
+		inter_retval = ((s32)(((u16)
+		((((s32)mag_trim.dig_xyz1)
+		<< BMI160_SHIFT_BIT_POSITION_BY_14_BITS)/
+		 (v_data_r_u16 != 0 ?
+		 v_data_r_u16 : mag_trim.dig_xyz1))) -
+		((u16)0x4000)));
+	} else {
+		inter_retval = BMI160_MAG_OVERFLOW_OUTPUT;
+		return inter_retval;
+	}
+	inter_retval = ((s32)((((s32)v_mag_data_x_s16) *
+			((((((((s32)mag_trim.dig_xy2) *
+			((((s32)inter_retval) *
+			((s32)inter_retval))
+			>> BMI160_SHIFT_BIT_POSITION_BY_07_BITS)) +
+			 (((s32)inter_retval) *
+			  ((s32)(((s16)mag_trim.dig_xy1)
+			  << BMI160_SHIFT_BIT_POSITION_BY_07_BITS))))
+			  >> BMI160_SHIFT_BIT_POSITION_BY_09_BITS) +
+		   ((s32)0x100000)) *
+		  ((s32)(((s16)mag_trim.dig_x2) +
+		  ((s16)0xA0))))
+		  >> BMI160_SHIFT_BIT_POSITION_BY_12_BITS))
+		  >> BMI160_SHIFT_BIT_POSITION_BY_13_BITS)) +
+		(((s16)mag_trim.dig_x1)
+		<< BMI160_SHIFT_BIT_POSITION_BY_03_BITS);
+	/* check the overflow output */
+	if (inter_retval == (s32)BMI160_MAG_OVERFLOW_OUTPUT)
+		inter_retval = BMI160_MAG_OVERFLOW_OUTPUT_S32;
+} else {
+	/* overflow */
+	inter_retval = BMI160_MAG_OVERFLOW_OUTPUT;
+}
+return inter_retval;
+}
+/*!
+ *	@brief This API used to get the compensated BMM150-Y data
+ *	the out put of Y as s32
+ *	Before start reading the mag compensated Y data
+ *	make sure the following two points are addressed
+ *	@note
+ *	1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note
+ *	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+ *
+ *
+ *
+ *  @param  v_mag_data_y_s16 : The value of mag raw Y data
+ *  @param  v_data_r_u16 : The value of mag R data
+ *
+ *	@return results of compensated Y data value output as s32
+ */
+s32 bmi160_bmm150_mag_compensate_Y(s16 v_mag_data_y_s16, u16 v_data_r_u16)
+{
+s32 inter_retval = BMI160_INIT_VALUE;
+/* no overflow */
+if (v_mag_data_y_s16 != BMI160_MAG_FLIP_OVERFLOW_ADCVAL) {
+	if ((v_data_r_u16 != 0)
+	&& (mag_trim.dig_xyz1 != 0)) {
+		inter_retval = ((s32)(((u16)(((
+		(s32)mag_trim.dig_xyz1)
+		<< BMI160_SHIFT_BIT_POSITION_BY_14_BITS) /
+		(v_data_r_u16 != 0 ?
+		 v_data_r_u16 : mag_trim.dig_xyz1))) -
+		((u16)0x4000)));
+		} else {
+			inter_retval = BMI160_MAG_OVERFLOW_OUTPUT;
+			return inter_retval;
+		}
+	inter_retval = ((s32)((((s32)v_mag_data_y_s16) * ((((((((s32)
+		mag_trim.dig_xy2) * ((((s32) inter_retval) *
+		((s32)inter_retval)) >> BMI160_SHIFT_BIT_POSITION_BY_07_BITS))
+		+ (((s32)inter_retval) *
+		((s32)(((s16)mag_trim.dig_xy1)
+		<< BMI160_SHIFT_BIT_POSITION_BY_07_BITS))))
+		>> BMI160_SHIFT_BIT_POSITION_BY_09_BITS) +
+		((s32)0x100000))
+		* ((s32)(((s16)mag_trim.dig_y2)
+		+ ((s16)0xA0))))
+		>> BMI160_SHIFT_BIT_POSITION_BY_12_BITS))
+		>> BMI160_SHIFT_BIT_POSITION_BY_13_BITS)) +
+		(((s16)mag_trim.dig_y1)
+		<< BMI160_SHIFT_BIT_POSITION_BY_03_BITS);
+	/* check the overflow output */
+	if (inter_retval == (s32)BMI160_MAG_OVERFLOW_OUTPUT)
+		inter_retval = BMI160_MAG_OVERFLOW_OUTPUT_S32;
+} else {
+	/* overflow */
+	inter_retval = BMI160_MAG_OVERFLOW_OUTPUT;
+}
+return inter_retval;
+}
+/*!
+ *	@brief This API used to get the compensated BMM150-Z data
+ *	the out put of Z as s32
+ *	Before start reading the mag compensated Z data
+ *	make sure the following two points are addressed
+ *	@note
+ *	1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note
+ *	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+ *
+ *
+ *
+ *  @param  v_mag_data_z_s16 : The value of mag raw Z data
+ *  @param  v_data_r_u16 : The value of mag R data
+ *
+ *	@return results of compensated Z data value output as s32
+ */
+s32 bmi160_bmm150_mag_compensate_Z(s16 v_mag_data_z_s16, u16 v_data_r_u16)
+{
+	s32 retval = BMI160_INIT_VALUE;
+
+	if (v_mag_data_z_s16 != BMI160_MAG_HALL_OVERFLOW_ADCVAL) {
+		if ((v_data_r_u16 != 0)
+		   && (mag_trim.dig_z2 != 0)
+		/*   && (mag_trim.dig_z3 != 0)*/
+		   && (mag_trim.dig_z1 != 0)
+		   && (mag_trim.dig_xyz1 != 0)) {
+			retval = (((((s32)(v_mag_data_z_s16 - mag_trim.dig_z4))
+			<< BMI160_SHIFT_BIT_POSITION_BY_15_BITS) -
+			((((s32)mag_trim.dig_z3) *
+			((s32)(((s16)v_data_r_u16) -
+			((s16)mag_trim.dig_xyz1))))
+			>> BMI160_SHIFT_BIT_POSITION_BY_02_BITS))/
+			(mag_trim.dig_z2 +
+			((s16)(((((s32)mag_trim.dig_z1) *
+			((((s16)v_data_r_u16)
+			<< BMI160_SHIFT_BIT_POSITION_BY_01_BIT))) +
+			(1 << BMI160_SHIFT_BIT_POSITION_BY_15_BITS))
+			>> BMI160_SHIFT_BIT_POSITION_BY_16_BITS))));
+		}
+	} else {
+		retval = BMI160_MAG_OVERFLOW_OUTPUT;
+	}
+		return retval;
+}
+ /*!
+ *	@brief This function used for initialize the bmm150 sensor
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_bmm150_mag_interface_init(void)
+{
+	/* This variable used for provide the communication
+	results*/
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = BMI160_INIT_VALUE;
+	u8 v_pull_value_u8 = BMI160_INIT_VALUE;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	/* accel operation mode to normal*/
+	com_rslt = bmi160_set_command_register(ACCEL_MODE_NORMAL);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* write the mag power mode as NORMAL*/
+	com_rslt += bmi160_set_mag_interface_normal();
+
+	/* register 0x7E write the 0x37, 0x9A and 0x30*/
+	com_rslt += bmi160_set_command_register(BMI160_COMMAND_REG_ONE);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	com_rslt += bmi160_set_command_register(BMI160_COMMAND_REG_TWO);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	com_rslt += bmi160_set_command_register(BMI160_COMMAND_REG_THREE);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/*switch the page1*/
+	com_rslt += bmi160_set_target_page(BMI160_WRITE_TARGET_PAGE1);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	bmi160_get_target_page(&v_data_u8);
+	com_rslt += bmi160_set_paging_enable(BMI160_WRITE_ENABLE_PAGE1);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	bmi160_get_paging_enable(&v_data_u8);
+	/* enable the pullup configuration from
+	the register 0x05 bit 4 and 5 as 10*/
+	bmi160_get_pullup_configuration(&v_pull_value_u8);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	v_pull_value_u8 = v_pull_value_u8 | BMI160_PULL_UP_DATA;
+	com_rslt += bmi160_set_pullup_configuration(v_pull_value_u8);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/*switch the page0*/
+	com_rslt += bmi160_set_target_page(BMI160_WRITE_TARGET_PAGE0);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	bmi160_get_target_page(&v_data_u8);
+	/* Write the BMM150 i2c address*/
+	com_rslt += bmi160_set_i2c_device_addr(BMI160_AUX_BMM150_I2C_ADDRESS);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* enable the mag interface to manual mode*/
+	com_rslt += bmi160_set_mag_manual_enable(BMI160_MANUAL_ENABLE);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	bmi160_get_mag_manual_enable(&v_data_u8);
+	/*Enable the MAG interface */
+	com_rslt += bmi160_set_if_mode(BMI160_ENABLE_MAG_IF_MODE);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	bmi160_get_if_mode(&v_data_u8);
+	/* Mag normal mode*/
+	com_rslt += bmi160_bmm150_mag_wakeup();
+	printk(KERN_INFO "com_rslt:%d, <%s><%d>\n",
+		com_rslt, __func__, __LINE__);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* Read the BMM150 device id is 0x32*/
+	/*com_rslt += bmi160_set_mag_read_addr(BMI160_BMM150_CHIP_ID);*/
+	/*p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);*/
+	/*com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);*/
+	/**v_chip_id_u8 = v_data_u8;*/
+	/*p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);*/
+	/* write the power mode register*/
+	com_rslt += bmi160_set_mag_write_data(BMI160_BMM_POWER_MODE_REG);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/*write 0x4C register to write set power mode to normal*/
+	com_rslt += bmi160_set_mag_write_addr(
+	BMI160_BMM150_POWE_MODE_REG);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* read the mag trim values*/
+	com_rslt += bmi160_read_bmm150_mag_trim();
+	printk(KERN_INFO "com_rslt:%d, <%s><%d>\n",
+		com_rslt, __func__, __LINE__);
+	/* To avoid the auto mode enable when manual mode operation running*/
+	V_bmm150_maual_auto_condition_u8 = BMI160_MANUAL_ENABLE;
+	/* write the XY and Z repetitions*/
+	com_rslt += bmi160_set_bmm150_mag_presetmode(
+	BMI160_MAG_PRESETMODE_REGULAR);
+	printk(KERN_INFO "com_rslt:%d, <%s><%d>\n",
+		com_rslt, __func__, __LINE__);
+	/* To avoid the auto mode enable when manual mode operation running*/
+	V_bmm150_maual_auto_condition_u8 = BMI160_MANUAL_DISABLE;
+	/* Set the power mode of mag as force mode*/
+	/* The data have to write for the register
+	It write the value in the register 0x4F */
+	com_rslt += bmi160_set_mag_write_data(BMI160_BMM150_FORCE_MODE);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	printk(KERN_INFO "com_rslt:%d, <%s><%d>\n",
+		com_rslt, __func__, __LINE__);
+	/* write into power mode register*/
+	com_rslt += bmi160_set_mag_write_addr(
+	BMI160_BMM150_POWE_MODE_REG);
+	/* write the mag v_data_bw_u8 as 25Hz*/
+	com_rslt += bmi160_set_mag_output_data_rate(
+	BMI160_MAG_OUTPUT_DATA_RATE_25HZ);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+
+	/* When mag interface is auto mode - The mag read address
+	starts the register 0x42*/
+	com_rslt += bmi160_set_mag_read_addr(
+	BMI160_BMM150_DATA_REG);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* enable mag interface to auto mode*/
+	com_rslt += bmi160_set_mag_manual_enable(BMI160_MANUAL_DISABLE);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	bmi160_get_mag_manual_enable(&v_data_u8);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+
+	return com_rslt;
+}
+ /*!
+ *	@brief This function used for set the mag power control
+ *	bit enable
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_bmm150_mag_wakeup(void)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = BMI160_INIT_VALUE;
+	u8 v_try_times_u8 = BMI160_BMM150_MAX_RETRY_WAKEUP;
+	u8 v_power_control_bit_u8 = BMI160_INIT_VALUE;
+	u8 i = BMI160_INIT_VALUE;
+
+	for (i = BMI160_INIT_VALUE; i < v_try_times_u8; i++) {
+		com_rslt = bmi160_set_mag_write_data(BMI160_BMM150_POWER_ON);
+		p_bmi160->delay_msec(BMI160_BMM150_WAKEUP_DELAY1);
+		/*write 0x4B register to enable power control bit*/
+		com_rslt += bmi160_set_mag_write_addr(
+		BMI160_BMM150_POWE_CONTROL_REG);
+		p_bmi160->delay_msec(BMI160_BMM150_WAKEUP_DELAY2);
+		com_rslt += bmi160_set_mag_read_addr(
+		BMI160_BMM150_POWE_CONTROL_REG);
+		/* 0x04 is secondary read mag x lsb register */
+		p_bmi160->delay_msec(BMI160_BMM150_WAKEUP_DELAY3);
+		com_rslt += bmi160_read_reg(BMI160_USER_DATA_0_ADDR,
+		&v_power_control_bit_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+		v_power_control_bit_u8 = BMI160_BMM150_SET_POWER_CONTROL
+		& v_power_control_bit_u8;
+		if (v_power_control_bit_u8 == BMI160_BMM150_POWER_ON)
+			break;
+	}
+	com_rslt = (i >= v_try_times_u8) ?
+	BMI160_BMM150_POWER_ON_FAIL : BMI160_BMM150_POWER_ON_SUCCESS;
+	return com_rslt;
+}
+ /*!
+ *	@brief This function used for set the magnetometer
+ *	power mode.
+ *	@note
+ *	Before set the mag power mode
+ *	make sure the following two point is addressed
+ *		Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *
+ *	@param v_mag_sec_if_pow_mode_u8 : The value of mag power mode
+ *  value    |  mode
+ * ----------|------------
+ *   0       | BMI160_MAG_FORCE_MODE
+ *   1       | BMI160_MAG_SUSPEND_MODE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_bmm150_mag_and_secondary_if_power_mode(
+u8 v_mag_sec_if_pow_mode_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = BMI160_INIT_VALUE;
+	/* set the accel power mode to NORMAL*/
+	com_rslt = bmi160_set_command_register(ACCEL_MODE_NORMAL);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	printk(KERN_INFO "com_rslt:%d, manual:%d, <%s><%d>\n",
+		com_rslt, p_bmi160->mag_manual_enable, __func__, __LINE__);
+	/* set mag interface manual mode*/
+	if (p_bmi160->mag_manual_enable != BMI160_MANUAL_ENABLE)	{
+		com_rslt += bmi160_set_mag_manual_enable(
+		BMI160_MANUAL_ENABLE);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	}
+	printk(KERN_INFO "com_rslt:%d, manual:%d, <%s><%d>\n",
+	com_rslt, p_bmi160->mag_manual_enable, __func__, __LINE__);
+
+	switch (v_mag_sec_if_pow_mode_u8) {
+	case BMI160_MAG_FORCE_MODE:
+		/* set the secondary mag power mode as NORMAL*/
+		com_rslt += bmi160_set_mag_interface_normal();
+		printk(KERN_INFO "com_rslt:%d, manual:%d, <%s><%d>\n",
+		com_rslt, p_bmi160->mag_manual_enable, __func__, __LINE__);
+		/* set the mag power mode as FORCE mode*/
+		com_rslt += bmi160_bmm150_mag_set_power_mode(FORCE_MODE);
+		printk(KERN_INFO "com_rslt:%d, manual:%d, <%s><%d>\n",
+		com_rslt, p_bmi160->mag_manual_enable, __func__, __LINE__);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	break;
+	case BMI160_MAG_SUSPEND_MODE:
+		/* set the mag power mode as SUSPEND mode*/
+		printk(KERN_INFO "com_rslt:%d, manual:%d, <%s><%d>\n",
+		com_rslt, p_bmi160->mag_manual_enable, __func__, __LINE__);
+		com_rslt += bmi160_bmm150_mag_set_power_mode(SUSPEND_MODE);
+		printk(KERN_INFO "com_rslt:%d, manual:%d, <%s><%d>\n",
+		com_rslt, p_bmi160->mag_manual_enable, __func__, __LINE__);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		/* set the secondary mag power mode as SUSPEND*/
+		com_rslt += bmi160_set_command_register(MAG_MODE_SUSPEND);
+		printk(KERN_INFO "com_rslt:%d, manual:%d, <%s><%d>\n",
+		com_rslt, p_bmi160->mag_manual_enable, __func__, __LINE__);
+		p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	break;
+	default:
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+	break;
+	}
+	if (p_bmi160->mag_manual_enable == BMI160_MANUAL_ENABLE) {
+		/* set mag interface auto mode*/
+		com_rslt += bmi160_set_mag_manual_enable(
+		BMI160_MANUAL_DISABLE);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	}
+	printk(KERN_INFO "com_rslt:%d, manual:%d, <%s><%d>\n",
+	com_rslt, p_bmi160->mag_manual_enable, __func__, __LINE__);
+	return com_rslt;
+}
+/*!
+ *	@brief This function used for set the magnetometer
+ *	power mode.
+ *	@note
+ *	Before set the mag power mode
+ *	make sure the following two points are addressed
+ *	@note
+ *	1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note
+ *	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+ *
+ *	@param v_mag_pow_mode_u8 : The value of mag power mode
+ *  value    |  mode
+ * ----------|------------
+ *   0       | FORCE_MODE
+ *   1       | SUSPEND_MODE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_bmm150_mag_set_power_mode(
+u8 v_mag_pow_mode_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = BMI160_INIT_VALUE;
+	u8 manual_enable_status = 0;
+	/* set mag interface manual mode*/
+	if (p_bmi160->mag_manual_enable != BMI160_MANUAL_ENABLE) {
+		com_rslt = bmi160_set_mag_manual_enable(
+		BMI160_MANUAL_ENABLE);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		com_rslt += bmi160_get_mag_manual_enable(&manual_enable_status);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		printk(KERN_INFO "1com_rslt:%d, manual:%d, manual_read:%d\n",
+		com_rslt, p_bmi160->mag_manual_enable, manual_enable_status);
+	}
+	printk(KERN_INFO "2com_rslt:%d, manual:%d, manual_read:%d\n",
+	com_rslt, p_bmi160->mag_manual_enable, manual_enable_status);
+
+	switch (v_mag_pow_mode_u8) {
+	case FORCE_MODE:
+		/* Set the power control bit enabled */
+		com_rslt = bmi160_bmm150_mag_wakeup();
+		/* write the mag power mode as FORCE mode*/
+		com_rslt += bmi160_set_mag_write_data(
+		BMI160_BMM150_FORCE_MODE);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		com_rslt += bmi160_set_mag_write_addr(
+		BMI160_BMM150_POWE_MODE_REG);
+		p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+		/* To avoid the auto mode enable when manual
+		mode operation running*/
+		V_bmm150_maual_auto_condition_u8 = BMI160_MANUAL_ENABLE;
+		/* set the preset mode */
+		com_rslt += bmi160_set_bmm150_mag_presetmode(
+		BMI160_MAG_PRESETMODE_REGULAR);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		/* To avoid the auto mode enable when manual
+		mode operation running*/
+		V_bmm150_maual_auto_condition_u8 = BMI160_MANUAL_DISABLE;
+		/* set the mag read address to data registers*/
+		com_rslt += bmi160_set_mag_read_addr(
+		BMI160_BMM150_DATA_REG);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	break;
+	case SUSPEND_MODE:
+		printk(KERN_INFO "3com_rslt:%d, manual:%d, read_manual:%d\n",
+		com_rslt, p_bmi160->mag_manual_enable, manual_enable_status);
+		/* Set the power mode of mag as suspend mode*/
+		com_rslt += bmi160_set_mag_write_data(
+		BMI160_BMM150_POWER_OFF);
+		printk(KERN_INFO "com_rslt:%d, manual:%d, <%s><%d>\n",
+		com_rslt, p_bmi160->mag_manual_enable, __func__, __LINE__);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		com_rslt += bmi160_set_mag_write_addr(
+		BMI160_BMM150_POWE_CONTROL_REG);
+		printk(KERN_INFO "com_rslt:%d, manual:%d, <%s><%d>\n",
+		com_rslt, p_bmi160->mag_manual_enable, __func__, __LINE__);
+		p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	break;
+	default:
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+	break;
+	}
+	printk(KERN_INFO "4com_rslt:%d, manual:%d, manual_read:%d\n",
+	com_rslt, p_bmi160->mag_manual_enable, manual_enable_status);
+	/* set mag interface auto mode*/
+	if (p_bmi160->mag_manual_enable == BMI160_MANUAL_ENABLE) {
+		com_rslt += bmi160_set_mag_manual_enable(
+		BMI160_MANUAL_DISABLE);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		com_rslt += bmi160_get_mag_manual_enable(&manual_enable_status);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	}
+	printk(KERN_INFO "5com_rslt:%d, manual:%d, manual_read:%d\n",
+	com_rslt, p_bmi160->mag_manual_enable, manual_enable_status);
+	return com_rslt;
+}
+/*!
+ *	@brief This API used to set the pre-set modes of bmm150
+ *	The pre-set mode setting is depend on data rate and xy and z repetitions
+ *
+ *	@note
+ *	Before set the mag preset mode
+ *	make sure the following two points are addressed
+ *	@note
+ *	1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note
+ *	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+ *
+ *
+ *  @param  v_mode_u8: The value of pre-set mode selection value
+ *  value    |  pre_set mode
+ * ----------|------------
+ *   1       | BMI160_MAG_PRESETMODE_LOWPOWER
+ *   2       | BMI160_MAG_PRESETMODE_REGULAR
+ *   3       | BMI160_MAG_PRESETMODE_HIGHACCURACY
+ *   4       | BMI160_MAG_PRESETMODE_ENHANCED
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_bmm150_mag_presetmode(u8 v_mode_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	switch (v_mode_u8) {
+	case BMI160_MAG_PRESETMODE_LOWPOWER:
+		/* write the XY and Z repetitions*/
+		/* The v_data_u8 have to write for the register
+		It write the value in the register 0x4F*/
+		com_rslt = bmi160_set_mag_write_data(
+		BMI160_MAG_LOWPOWER_REPXY);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		com_rslt += bmi160_set_mag_write_addr(
+		BMI160_BMM150_XY_REP);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		/* write the Z repetitions*/
+		/* The v_data_u8 have to write for the register
+		It write the value in the register 0x4F*/
+		com_rslt += bmi160_set_mag_write_data(
+		BMI160_MAG_LOWPOWER_REPZ);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		com_rslt += bmi160_set_mag_write_addr(
+		BMI160_BMM150_Z_REP);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		/* set the mag v_data_u8 rate as 10 to the register 0x4C*/
+		com_rslt += bmi160_set_mag_write_data(
+		BMI160_MAG_LOWPOWER_DR);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		com_rslt += bmi160_set_mag_write_addr(
+		BMI160_BMM150_POWE_MODE_REG);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	break;
+	case BMI160_MAG_PRESETMODE_REGULAR:
+		/* write the XY and Z repetitions*/
+		/* The v_data_u8 have to write for the register
+		It write the value in the register 0x4F*/
+		com_rslt = bmi160_set_mag_write_data(
+		BMI160_MAG_REGULAR_REPXY);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		com_rslt += bmi160_set_mag_write_addr(
+		BMI160_BMM150_XY_REP);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		/* write the Z repetitions*/
+		/* The v_data_u8 have to write for the register
+		It write the value in the register 0x4F*/
+		com_rslt += bmi160_set_mag_write_data(
+		BMI160_MAG_REGULAR_REPZ);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		com_rslt += bmi160_set_mag_write_addr(
+		BMI160_BMM150_Z_REP);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		/* set the mag v_data_u8 rate as 10 to the register 0x4C*/
+		com_rslt += bmi160_set_mag_write_data(
+		BMI160_MAG_REGULAR_DR);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		com_rslt += bmi160_set_mag_write_addr(
+		BMI160_BMM150_POWE_MODE_REG);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	break;
+	case BMI160_MAG_PRESETMODE_HIGHACCURACY:
+		/* write the XY and Z repetitions*/
+		/* The v_data_u8 have to write for the register
+		It write the value in the register 0x4F*/
+		com_rslt = bmi160_set_mag_write_data(
+		BMI160_MAG_HIGHACCURACY_REPXY);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		com_rslt += bmi160_set_mag_write_addr(
+		BMI160_BMM150_XY_REP);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		/* write the Z repetitions*/
+		/* The v_data_u8 have to write for the register
+		It write the value in the register 0x4F*/
+		com_rslt += bmi160_set_mag_write_data(
+		BMI160_MAG_HIGHACCURACY_REPZ);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		com_rslt += bmi160_set_mag_write_addr(
+		BMI160_BMM150_Z_REP);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		/* set the mag v_data_u8 rate as 20 to the register 0x4C*/
+		com_rslt += bmi160_set_mag_write_data(
+		BMI160_MAG_HIGHACCURACY_DR);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		com_rslt += bmi160_set_mag_write_addr(
+		BMI160_BMM150_POWE_MODE_REG);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	break;
+	case BMI160_MAG_PRESETMODE_ENHANCED:
+		/* write the XY and Z repetitions*/
+		/* The v_data_u8 have to write for the register
+		It write the value in the register 0x4F*/
+		com_rslt = bmi160_set_mag_write_data(
+		BMI160_MAG_ENHANCED_REPXY);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		com_rslt += bmi160_set_mag_write_addr(
+		BMI160_BMM150_XY_REP);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		/* write the Z repetitions*/
+		/* The v_data_u8 have to write for the register
+		It write the value in the register 0x4F*/
+		com_rslt += bmi160_set_mag_write_data(
+		BMI160_MAG_ENHANCED_REPZ);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		com_rslt += bmi160_set_mag_write_addr(
+		BMI160_BMM150_Z_REP);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		/* set the mag v_data_u8 rate as 10 to the register 0x4C*/
+		com_rslt += bmi160_set_mag_write_data(
+		BMI160_MAG_ENHANCED_DR);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		com_rslt += bmi160_set_mag_write_addr(
+		BMI160_BMM150_POWE_MODE_REG);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	break;
+	default:
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+	break;
+	}
+
+	return com_rslt;
+}
+ /*!
+ *	@brief This function used for read the trim values of magnetometer
+ *
+ *	@note
+ *	Before reading the mag trimming values
+ *	make sure the following two points are addressed
+ *	@note
+ *	1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note
+ *	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_bmm150_mag_trim(void)
+{
+	/* This variable used for provide the communication
+	results*/
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* Array holding the bmm150 trim data
+	*/
+	u8 v_data_u8[BMI160_MAG_TRIM_DATA_SIZE] = {
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE};
+	/* read dig_x1 value */
+	com_rslt = bmi160_set_mag_read_addr(
+	BMI160_MAG_DIG_X1);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8[BMI160_BMM150_DIG_X1],
+	BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	mag_trim.dig_x1 = v_data_u8[BMI160_BMM150_DIG_X1];
+	/* read dig_y1 value */
+	com_rslt += bmi160_set_mag_read_addr(
+	BMI160_MAG_DIG_Y1);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8[BMI160_BMM150_DIG_Y1],
+	BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	mag_trim.dig_y1 = v_data_u8[BMI160_BMM150_DIG_Y1];
+
+	/* read dig_x2 value */
+	com_rslt += bmi160_set_mag_read_addr(
+	BMI160_MAG_DIG_X2);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8[BMI160_BMM150_DIG_X2],
+	BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	mag_trim.dig_x2 = v_data_u8[BMI160_BMM150_DIG_X2];
+	/* read dig_y2 value */
+	com_rslt += bmi160_set_mag_read_addr(
+	BMI160_MAG_DIG_Y2);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8[BMI160_BMM150_DIG_Y3],
+	BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	mag_trim.dig_y2 = v_data_u8[BMI160_BMM150_DIG_Y3];
+
+	/* read dig_xy1 value */
+	com_rslt += bmi160_set_mag_read_addr(
+	BMI160_MAG_DIG_XY1);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8[BMI160_BMM150_DIG_XY1],
+	BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	mag_trim.dig_xy1 = v_data_u8[BMI160_BMM150_DIG_XY1];
+	/* read dig_xy2 value */
+	com_rslt += bmi160_set_mag_read_addr(
+	BMI160_MAG_DIG_XY2);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* 0x04 is v_mag_x_s16 ls register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8[BMI160_BMM150_DIG_XY2],
+	BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	mag_trim.dig_xy2 = v_data_u8[BMI160_BMM150_DIG_XY2];
+
+	/* read dig_z1 lsb value */
+	com_rslt += bmi160_set_mag_read_addr(
+	BMI160_MAG_DIG_Z1_LSB);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8[BMI160_BMM150_DIG_Z1_LSB],
+	BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* read dig_z1 msb value */
+	com_rslt += bmi160_set_mag_read_addr(BMI160_MAG_DIG_Z1_MSB);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* 0x04 is v_mag_x_s16 msb register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8[BMI160_BMM150_DIG_Z1_MSB],
+	BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	mag_trim.dig_z1 =
+	(u16)((((u32)((u8)v_data_u8[BMI160_BMM150_DIG_Z1_MSB]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS) |
+			(v_data_u8[BMI160_BMM150_DIG_Z1_LSB]));
+
+	/* read dig_z2 lsb value */
+	com_rslt += bmi160_set_mag_read_addr(BMI160_MAG_DIG_Z2_LSB);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8[BMI160_BMM150_DIG_Z2_LSB],
+	BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* read dig_z2 msb value */
+	com_rslt += bmi160_set_mag_read_addr(BMI160_MAG_DIG_Z2_MSB);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* 0x04 is v_mag_x_s16 msb register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8[BMI160_BMM150_DIG_Z2_MSB],
+	BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	mag_trim.dig_z2 =
+	(s16)((((s32)((s8)v_data_u8[BMI160_BMM150_DIG_Z2_MSB]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS) |
+			(v_data_u8[BMI160_BMM150_DIG_Z2_LSB]));
+
+	/* read dig_z3 lsb value */
+	com_rslt += bmi160_set_mag_read_addr(BMI160_MAG_DIG_Z3_LSB);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8[BMI160_BMM150_DIG_DIG_Z3_LSB],
+	BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* read dig_z3 msb value */
+	com_rslt += bmi160_set_mag_read_addr(BMI160_MAG_DIG_Z3_MSB);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* 0x04 is v_mag_x_s16 msb register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8[BMI160_BMM150_DIG_DIG_Z3_MSB],
+	BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	mag_trim.dig_z3 =
+	(s16)((((s32)((s8)v_data_u8[BMI160_BMM150_DIG_DIG_Z3_MSB]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS) |
+			(v_data_u8[BMI160_BMM150_DIG_DIG_Z3_LSB]));
+
+	/* read dig_z4 lsb value */
+	com_rslt += bmi160_set_mag_read_addr(BMI160_MAG_DIG_Z4_LSB);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8[BMI160_BMM150_DIG_DIG_Z4_LSB],
+	BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* read dig_z4 msb value */
+	com_rslt += bmi160_set_mag_read_addr(BMI160_MAG_DIG_Z4_MSB);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* 0x04 is v_mag_x_s16 msb register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8[BMI160_BMM150_DIG_DIG_Z4_MSB],
+	BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	mag_trim.dig_z4 =
+	(s16)((((s32)((s8)v_data_u8[BMI160_BMM150_DIG_DIG_Z4_MSB]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS) |
+			(v_data_u8[BMI160_BMM150_DIG_DIG_Z4_LSB]));
+
+	/* read dig_xyz1 lsb value */
+	com_rslt += bmi160_set_mag_read_addr(BMI160_MAG_DIG_XYZ1_LSB);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8[BMI160_BMM150_DIG_DIG_XYZ1_LSB],
+	BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* read dig_xyz1 msb value */
+	com_rslt += bmi160_set_mag_read_addr(BMI160_MAG_DIG_XYZ1_MSB);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* 0x04 is v_mag_x_s16 msb register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8[BMI160_BMM150_DIG_DIG_XYZ1_MSB],
+	BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	mag_trim.dig_xyz1 =
+	(u16)((((u32)((u8)v_data_u8[BMI160_BMM150_DIG_DIG_XYZ1_MSB]))
+			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS) |
+			(v_data_u8[BMI160_BMM150_DIG_DIG_XYZ1_LSB]));
+
+	return com_rslt;
+}
+ /*!
+ *	@brief This function used for initialize
+ *	the AKM09911 and AKM09912 sensor
+ *
+ *
+ *	@param v_akm_i2c_address_u8: The value of device address
+ *	AKM sensor   |  Slave address
+ * --------------|---------------------
+ *  AKM09911     |  AKM09911_I2C_ADDR_1
+ *     -         |  and AKM09911_I2C_ADDR_2
+ *  AKM09912     |  AKM09912_I2C_ADDR_1
+ *     -         |  AKM09912_I2C_ADDR_2
+ *     -         |  AKM09912_I2C_ADDR_3
+ *     -         |  AKM09912_I2C_ADDR_4
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_akm_mag_interface_init(
+u8 v_akm_i2c_address_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_pull_value_u8 = BMI160_INIT_VALUE;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	u8 v_akm_chip_id_u8 = BMI160_INIT_VALUE;
+	/* accel operation mode to normal*/
+	com_rslt = bmi160_set_command_register(ACCEL_MODE_NORMAL);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	com_rslt += bmi160_set_command_register(MAG_MODE_NORMAL);
+	p_bmi160->delay_msec(BMI160_AKM_INIT_DELAY);
+	bmi160_get_mag_power_mode_stat(&v_data_u8);
+	/* register 0x7E write the 0x37, 0x9A and 0x30*/
+	com_rslt += bmi160_set_command_register(BMI160_COMMAND_REG_ONE);
+	p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	com_rslt += bmi160_set_command_register(BMI160_COMMAND_REG_TWO);
+	p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	com_rslt += bmi160_set_command_register(BMI160_COMMAND_REG_THREE);
+	p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	/*switch the page1*/
+	com_rslt += bmi160_set_target_page(BMI160_WRITE_TARGET_PAGE1);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	bmi160_get_target_page(&v_data_u8);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	com_rslt += bmi160_set_paging_enable(BMI160_WRITE_ENABLE_PAGE1);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	bmi160_get_paging_enable(&v_data_u8);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* enable the pullup configuration from
+	the register 0x05 bit 4 and 5  to 10*/
+	bmi160_get_pullup_configuration(&v_pull_value_u8);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	v_pull_value_u8 = v_pull_value_u8 | BMI160_PULL_UP_DATA;
+	com_rslt += bmi160_set_pullup_configuration(v_pull_value_u8);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+
+	/*switch the page0*/
+	com_rslt += bmi160_set_target_page(BMI160_WRITE_TARGET_PAGE0);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	bmi160_get_target_page(&v_data_u8);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* Write the AKM09911 0r AKM09912 i2c address*/
+	com_rslt += bmi160_set_i2c_device_addr(v_akm_i2c_address_u8);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* enable the mag interface to manual mode*/
+	com_rslt += bmi160_set_mag_manual_enable(BMI160_MANUAL_ENABLE);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	bmi160_get_mag_manual_enable(&v_data_u8);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/*Enable the MAG interface */
+	com_rslt += bmi160_set_if_mode(BMI160_ENABLE_MAG_IF_MODE);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	bmi160_get_if_mode(&v_data_u8);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+
+	/* Set the AKM Fuse ROM mode */
+	/* Set value for fuse ROM mode*/
+	com_rslt += bmi160_set_mag_write_data(AKM_FUSE_ROM_MODE);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* AKM mode address is 0x31*/
+	com_rslt += bmi160_set_mag_write_addr(AKM_POWER_MODE_REG);
+	p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	/* Read the Fuse ROM v_data_u8 from registers
+	0x60,0x61 and 0x62*/
+	/* ASAX v_data_u8 */
+	com_rslt += bmi160_read_bst_akm_sensitivity_data();
+	p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	/* read the device id of the AKM sensor
+	if device id is 0x05 - AKM09911
+	if device id is 0x04 - AKM09912*/
+	com_rslt += bmi160_set_mag_read_addr(AKM09912_CHIP_ID_REG);
+	/* 0x04 is mag_x lsb register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_akm_chip_id_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	printk(KERN_INFO "bmi160,addr:0x%x, akm_chip_id:0x%x",
+	v_akm_i2c_address_u8, v_akm_chip_id_u8);
+	/* Set value power down mode mode*/
+	com_rslt += bmi160_set_mag_write_data(AKM_POWER_DOWN_MODE_DATA);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* AKM mode address is 0x31*/
+	com_rslt += bmi160_set_mag_write_addr(AKM_POWER_MODE_REG);
+	p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	/* Set AKM Force mode*/
+	com_rslt += bmi160_set_mag_write_data(
+	AKM_SINGLE_MEASUREMENT_MODE);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* AKM mode address is 0x31*/
+	com_rslt += bmi160_set_mag_write_addr(AKM_POWER_MODE_REG);
+	p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	/* Set the AKM read xyz v_data_u8 address*/
+	com_rslt += bmi160_set_mag_read_addr(AKM_DATA_REGISTER);
+	/* write the mag v_data_bw_u8 as 25Hz*/
+	com_rslt += bmi160_set_mag_output_data_rate(
+	BMI160_MAG_OUTPUT_DATA_RATE_25HZ);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* Enable mag interface to auto mode*/
+	com_rslt += bmi160_set_mag_manual_enable(BMI160_MANUAL_DISABLE);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	bmi160_get_mag_manual_enable(&v_data_u8);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+
+	return com_rslt;
+}
+ /*!
+ *	@brief This function used for read the sensitivity data of
+ *	AKM09911 and AKM09912
+ *
+ *	@note Before reading the mag sensitivity values
+ *	make sure the following two points are addressed
+ *	@note	1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_bst_akm_sensitivity_data(void)
+{
+	/* This variable used for provide the communication
+	results*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* Array holding the sensitivity ax,ay and az data*/
+	u8 v_data_u8[BMI160_AKM_SENSITIVITY_DATA_SIZE] = {
+	BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE};
+	/* read asax value */
+	com_rslt = bmi160_set_mag_read_addr(BMI160_BST_AKM_ASAX);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8[AKM_ASAX],
+	BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	akm_asa_data.asax = v_data_u8[AKM_ASAX];
+	/* read asay value */
+	com_rslt += bmi160_set_mag_read_addr(BMI160_BST_AKM_ASAY);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8[AKM_ASAY],
+	BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	akm_asa_data.asay = v_data_u8[AKM_ASAY];
+	/* read asaz value */
+	com_rslt += bmi160_set_mag_read_addr(BMI160_BST_AKM_ASAZ);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8[AKM_ASAZ],
+	BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	akm_asa_data.asaz = v_data_u8[AKM_ASAZ];
+
+	return com_rslt;
+}
+/*!
+ *	@brief This API used to get the compensated X data
+ *	of AKM09911 the out put of X as s32
+ *	@note	Before start reading the mag compensated X data
+ *			make sure the following two points are addressed
+ *	@note 1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note 2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+ *
+ *
+ *  @param v_bst_akm_x_s16 : The value of X data
+ *
+ *	@return results of compensated X data value output as s32
+ *
+ */
+s32 bmi160_bst_akm09911_compensate_X(s16 v_bst_akm_x_s16)
+{
+	/*Return value of AKM x compensated v_data_u8*/
+	s32 retval = BMI160_INIT_VALUE;
+	/* Convert raw v_data_u8 into compensated v_data_u8*/
+	retval = (v_bst_akm_x_s16 *
+	((akm_asa_data.asax/AKM09911_SENSITIVITY_DIV) +
+	BMI160_GEN_READ_WRITE_DATA_LENGTH));
+	return retval;
+}
+/*!
+ *	@brief This API used to get the compensated Y data
+ *	of AKM09911 the out put of Y as s32
+ *	@note	Before start reading the mag compensated Y data
+ *			make sure the following two points are addressed
+ *	@note 1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note 2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+ *
+ *
+ *  @param v_bst_akm_y_s16 : The value of Y data
+ *
+ *	@return results of compensated Y data value output as s32
+ *
+ */
+s32 bmi160_bst_akm09911_compensate_Y(s16 v_bst_akm_y_s16)
+{
+	/*Return value of AKM y compensated v_data_u8*/
+	s32 retval = BMI160_INIT_VALUE;
+	/* Convert raw v_data_u8 into compensated v_data_u8*/
+	retval = (v_bst_akm_y_s16 *
+	((akm_asa_data.asay/AKM09911_SENSITIVITY_DIV) +
+	BMI160_GEN_READ_WRITE_DATA_LENGTH));
+	return retval;
+}
+/*!
+ *	@brief This API used to get the compensated Z data
+ *	of AKM09911 the out put of Z as s32
+ *	@note	Before start reading the mag compensated Z data
+ *			make sure the following two points are addressed
+ *	@note 1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note 2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+ *
+ *
+ *  @param v_bst_akm_z_s16 : The value of Z data
+ *
+ *	@return results of compensated Z data value output as s32
+ *
+ */
+s32 bmi160_bst_akm09911_compensate_Z(s16 v_bst_akm_z_s16)
+{
+	/*Return value of AKM z compensated v_data_u8*/
+	s32 retval = BMI160_INIT_VALUE;
+	/* Convert raw v_data_u8 into compensated v_data_u8*/
+	retval = (v_bst_akm_z_s16 *
+	((akm_asa_data.asaz/AKM09911_SENSITIVITY_DIV) +
+	BMI160_GEN_READ_WRITE_DATA_LENGTH));
+	return retval;
+}
+/*!
+ *	@brief This API used to get the compensated X data
+ *	of AKM09912 the out put of X as s32
+ *	@note	Before start reading the mag compensated X data
+ *			make sure the following two points are addressed
+ *	@note 1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note 2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+ *
+ *
+ *  @param v_bst_akm_x_s16 : The value of X data
+ *
+ *	@return results of compensated X data value output as s32
+ *
+ */
+s32 bmi160_bst_akm09912_compensate_X(s16 v_bst_akm_x_s16)
+{
+	/*Return value of AKM x compensated data*/
+	s32 retval = BMI160_INIT_VALUE;
+	/* Convert raw data into compensated data*/
+	retval = v_bst_akm_x_s16 *
+	(akm_asa_data.asax + AKM09912_SENSITIVITY)
+	/ AKM09912_SENSITIVITY_DIV;
+	return retval;
+}
+/*!
+ *	@brief This API used to get the compensated Y data
+ *	of AKM09912 the out put of Y as s32
+ *	@note	Before start reading the mag compensated Y data
+ *			make sure the following two points are addressed
+ *	@note 1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note 2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+ *
+ *
+ *  @param v_bst_akm_y_s16 : The value of Y data
+ *
+ *	@return results of compensated Y data value output as s32
+ *
+ */
+s32 bmi160_bst_akm09912_compensate_Y(s16 v_bst_akm_y_s16)
+{
+	/*Return value of AKM y compensated data*/
+	s32 retval = BMI160_INIT_VALUE;
+	/* Convert raw data into compensated data*/
+	retval = v_bst_akm_y_s16 *
+	(akm_asa_data.asax + AKM09912_SENSITIVITY)
+	/ AKM09912_SENSITIVITY_DIV;
+	return retval;
+}
+/*!
+ *	@brief This API used to get the compensated Z data
+ *	of AKM09912 the out put of Z as s32
+ *	@note	Before start reading the mag compensated Z data
+ *			make sure the following two points are addressed
+ *	@note 1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note 2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+ *
+ *
+ *  @param v_bst_akm_z_s16 : The value of Z data
+ *
+ *	@return results of compensated Z data value output as s32
+ *
+ */
+s32 bmi160_bst_akm09912_compensate_Z(s16 v_bst_akm_z_s16)
+{
+	/*Return value of AKM z compensated data*/
+	s32 retval = BMI160_INIT_VALUE;
+	/* Convert raw data into compensated data*/
+	retval = v_bst_akm_z_s16 *
+	(akm_asa_data.asax + AKM09912_SENSITIVITY)
+	/ AKM09912_SENSITIVITY_DIV;
+	return retval;
+}
+ /*!
+ *	@brief This function used for read the compensated value of
+ *	AKM09911
+ *	@note Before start reading the mag compensated data's
+ *	make sure the following two points are addressed
+ *	@note	1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_akm09911_compensate_xyz(
+struct bmi160_mag_xyz_s32_t *bst_akm_xyz)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	struct bmi160_mag_t mag_xyz;
+
+	com_rslt = bmi160_read_mag_xyz(&mag_xyz, BST_AKM);
+	/* Compensation for X axis */
+	bst_akm_xyz->x = bmi160_bst_akm09911_compensate_X(mag_xyz.x);
+
+	/* Compensation for Y axis */
+	bst_akm_xyz->y = bmi160_bst_akm09911_compensate_Y(mag_xyz.y);
+
+	/* Compensation for Z axis */
+	bst_akm_xyz->z = bmi160_bst_akm09911_compensate_Z(mag_xyz.z);
+
+	return com_rslt;
+}
+ /*!
+ *	@brief This function used for read the compensated value of
+ *	AKM09912
+ *	@note Before start reading the mag compensated data's
+ *	make sure the following two points are addressed
+ *	@note	1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_akm09912_compensate_xyz(
+struct bmi160_mag_xyz_s32_t *bst_akm_xyz)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	struct bmi160_mag_t mag_xyz;
+
+	com_rslt = bmi160_read_mag_xyz(&mag_xyz, BST_AKM);
+	printk(KERN_INFO "akm09912_raw_x:%d, %d, %d, <%s>,<%d>",
+	mag_xyz.x, mag_xyz.y, mag_xyz.z, __func__, __LINE__);
+	/* Compensation for X axis */
+	bst_akm_xyz->x = bmi160_bst_akm09912_compensate_X(mag_xyz.x);
+
+	/* Compensation for Y axis */
+	bst_akm_xyz->y = bmi160_bst_akm09912_compensate_Y(mag_xyz.y);
+
+	/* Compensation for Z axis */
+	bst_akm_xyz->z = bmi160_bst_akm09912_compensate_Z(mag_xyz.z);
+	return com_rslt;
+}
+ /*!
+ *	@brief This function used for read the compensated value of
+ *	AKM09912
+ *	@note Before start reading the mag compensated data's
+ *	make sure the following two points are addressed
+ *	@note	1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_akm09912_compensate_xyz_raw(
+struct bmi160_mag_xyz_s32_t *bst_akm_xyz)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* Compensation for X axis */
+	bst_akm_xyz->x = bmi160_bst_akm09912_compensate_X(bst_akm_xyz->x);
+
+	/* Compensation for Y axis */
+	bst_akm_xyz->y = bmi160_bst_akm09912_compensate_Y(bst_akm_xyz->y);
+
+	/* Compensation for Z axis */
+	bst_akm_xyz->z = bmi160_bst_akm09912_compensate_Z(bst_akm_xyz->z);
+
+	return com_rslt;
+}
+/*!
+ *	@brief This function used for set the AKM09911 and AKM09912
+ *	power mode.
+ *	@note Before set the AKM power mode
+ *	make sure the following two points are addressed
+ *	@note	1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+ *
+ *	@param v_akm_pow_mode_u8 : The value of akm power mode
+ *  value   |    Description
+ * ---------|--------------------
+ *    0     |  AKM_POWER_DOWN_MODE
+ *    1     |  AKM_SINGLE_MEAS_MODE
+ *    2     |  FUSE_ROM_MODE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_akm_set_powermode(
+u8 v_akm_pow_mode_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = BMI160_INIT_VALUE;
+	/* set mag interface manual mode*/
+	if (p_bmi160->mag_manual_enable != BMI160_MANUAL_ENABLE) {
+		com_rslt = bmi160_set_mag_manual_enable(
+		BMI160_MANUAL_ENABLE);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	}
+	printk(KERN_INFO "com_rslt:%d, manual:%d, <%s>\n",
+	com_rslt, p_bmi160->mag_manual_enable, __func__);
+	switch (v_akm_pow_mode_u8) {
+	case AKM_POWER_DOWN_MODE:
+		/* Set the power mode of AKM as power down mode*/
+		com_rslt += bmi160_set_mag_write_data(AKM_POWER_DOWN_MODE_DATA);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		com_rslt += bmi160_set_mag_write_addr(AKM_POWER_MODE_REG);
+		p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	break;
+	case AKM_SINGLE_MEAS_MODE:
+		/* Set the power mode of AKM as
+		single measurement mode*/
+		com_rslt += bmi160_set_mag_write_data
+		(AKM_SINGLE_MEASUREMENT_MODE);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		com_rslt += bmi160_set_mag_write_addr(AKM_POWER_MODE_REG);
+		p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+		com_rslt += bmi160_set_mag_read_addr(AKM_DATA_REGISTER);
+	break;
+	case FUSE_ROM_MODE:
+		/* Set the power mode of AKM as
+		Fuse ROM mode*/
+		com_rslt += bmi160_set_mag_write_data(AKM_FUSE_ROM_MODE);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		com_rslt += bmi160_set_mag_write_addr(AKM_POWER_MODE_REG);
+		p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+		/* Sensitivity v_data_u8 */
+		com_rslt += bmi160_read_bst_akm_sensitivity_data();
+		p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+		/* power down mode*/
+		com_rslt += bmi160_set_mag_write_data(AKM_POWER_DOWN_MODE);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		com_rslt += bmi160_set_mag_write_addr(AKM_POWER_MODE_REG);
+		p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	break;
+	default:
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+	break;
+	}
+	/* set mag interface auto mode*/
+	if (p_bmi160->mag_manual_enable == BMI160_MANUAL_ENABLE) {
+		com_rslt += bmi160_set_mag_manual_enable(
+		BMI160_MANUAL_DISABLE);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	}
+	printk(KERN_INFO "com_rslt:%d, manual:%d, <%s><%d>\n",
+	com_rslt, p_bmi160->mag_manual_enable, __func__, __LINE__);
+	return com_rslt;
+}
+ /*!
+ *	@brief This function used for set the magnetometer
+ *	power mode of AKM09911 and AKM09912
+ *	@note Before set the mag power mode
+ *	make sure the following two point is addressed
+ *		Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *
+ *	@param v_mag_sec_if_pow_mode_u8 : The value of secondary if power mode
+ *  value   |    Description
+ * ---------|--------------------
+ *    0     |  BMI160_MAG_FORCE_MODE
+ *    1     |  BMI160_MAG_SUSPEND_MODE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_bst_akm_and_secondary_if_powermode(
+u8 v_mag_sec_if_pow_mode_u8)
+{
+	/* variable used for return the status of communication result*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* accel operation mode to normal*/
+	com_rslt = bmi160_set_command_register(ACCEL_MODE_NORMAL);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* set mag interface manual mode*/
+	if (p_bmi160->mag_manual_enable != BMI160_MANUAL_ENABLE) {
+		com_rslt = bmi160_set_mag_manual_enable(
+		BMI160_MANUAL_ENABLE);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	}
+	printk(KERN_ERR "com_rslt:%d, manual:%d,after setacc normal mode\n",
+	com_rslt, p_bmi160->mag_manual_enable);
+	switch (v_mag_sec_if_pow_mode_u8) {
+	case BMI160_MAG_FORCE_MODE:
+		/* set the secondary mag power mode as NORMAL*/
+		com_rslt += bmi160_set_mag_interface_normal();
+		/* set the akm power mode as single measurement mode*/
+		com_rslt += bmi160_bst_akm_set_powermode(AKM_SINGLE_MEAS_MODE);
+		p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+		com_rslt += bmi160_set_mag_read_addr(AKM_DATA_REGISTER);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	break;
+	case BMI160_MAG_SUSPEND_MODE:
+		/* set the akm power mode as power down mode*/
+		com_rslt += bmi160_bst_akm_set_powermode(AKM_POWER_DOWN_MODE);
+		p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+		/* set the secondary mag power mode as SUSPEND*/
+		com_rslt += bmi160_set_command_register(MAG_MODE_SUSPEND);
+		p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	break;
+	default:
+		com_rslt = E_BMI160_OUT_OF_RANGE;
+	break;
+	}
+	/* set mag interface auto mode*/
+	if (p_bmi160->mag_manual_enable == BMI160_MANUAL_ENABLE)
+		com_rslt += bmi160_set_mag_manual_enable(
+		BMI160_MANUAL_DISABLE);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	return com_rslt;
+}
+/*!
+ *	@brief This function used for read the YAMAH-YAS532 init
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas532_mag_interface_init(
+void)
+{
+	/* This variable used for provide the communication
+	results*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	u8 v_pull_value_u8 = BMI160_INIT_VALUE;
+	u8 v_data_u8 = BMI160_INIT_VALUE;
+	u8 i = BMI160_INIT_VALUE;
+	/* accel operation mode to normal*/
+	com_rslt = bmi160_set_command_register(ACCEL_MODE_NORMAL);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* write mag power mode as NORMAL*/
+	com_rslt += bmi160_set_mag_interface_normal();
+	/* register 0x7E write the 0x37, 0x9A and 0x30*/
+	com_rslt += bmi160_set_command_register(BMI160_COMMAND_REG_ONE);
+	p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	com_rslt += bmi160_set_command_register(BMI160_COMMAND_REG_TWO);
+	p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	com_rslt += bmi160_set_command_register(BMI160_COMMAND_REG_THREE);
+	p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	/*switch the page1*/
+	com_rslt += bmi160_set_target_page(BMI160_WRITE_TARGET_PAGE1);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	bmi160_get_target_page(&v_data_u8);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	com_rslt += bmi160_set_paging_enable(BMI160_WRITE_ENABLE_PAGE1);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	bmi160_get_paging_enable(&v_data_u8);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* enable the pullup configuration from
+	the register 0x05 bit 4 and 5 as 10*/
+	bmi160_get_pullup_configuration(&v_pull_value_u8);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	v_pull_value_u8 = v_pull_value_u8 | BMI160_PULL_UP_DATA;
+	com_rslt += bmi160_set_pullup_configuration(v_pull_value_u8);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/*switch the page0*/
+	com_rslt += bmi160_set_target_page(BMI160_WRITE_TARGET_PAGE0);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	bmi160_get_target_page(&v_data_u8);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* Write the YAS532 i2c address*/
+	com_rslt += bmi160_set_i2c_device_addr(BMI160_AUX_YAS532_I2C_ADDRESS);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* enable the mag interface to manual mode*/
+	com_rslt += bmi160_set_mag_manual_enable(BMI160_MANUAL_ENABLE);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	bmi160_get_mag_manual_enable(&v_data_u8);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/*Enable the MAG interface */
+	com_rslt += bmi160_set_if_mode(BMI160_ENABLE_MAG_IF_MODE);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	bmi160_get_if_mode(&v_data_u8);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	v_data_u8 = BMI160_MANUAL_DISABLE;
+	/* Read the YAS532 device id is 0x02*/
+	com_rslt += bmi160_set_mag_read_addr(BMI160_YAS_DEVICE_ID_REG);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* Read the YAS532 calibration data*/
+	com_rslt += bmi160_bst_yamaha_yas532_calib_values();
+	p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	/* Assign the data acquisition mode*/
+	yas532_data.measure_state = YAS532_MAG_STATE_INIT_COIL;
+	/* Set the default offset as invalid offset*/
+	set_vector(yas532_data.v_hard_offset_s8, INVALID_OFFSET);
+	/* set the transform to zero */
+	yas532_data.transform = BMI160_NULL;
+	/* Assign overflow as zero*/
+	yas532_data.overflow = 0;
+	#if YAS532_MAG_LOG < YAS532_MAG_TEMPERATURE_LOG
+		yas532_data.temp_data.num =
+		yas532_data.temp_data.idx = 0;
+	#endif
+	/* Assign the coef value*/
+	for (i = 0; i < 3; i++) {
+		yas532_data.coef[i] = yas532_version_ac_coef[i];
+		yas532_data.last_raw[i] = 0;
+	}
+	yas532_data.last_raw[3] = 0;
+	/* Set the initial values of yas532*/
+	com_rslt += bmi160_bst_yas532_set_initial_values();
+	/* write the mag v_data_bw_u8 as 25Hz*/
+	com_rslt += bmi160_set_mag_output_data_rate(
+	BMI160_MAG_OUTPUT_DATA_RATE_25HZ);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* Enable mag interface to auto mode*/
+	com_rslt += bmi160_set_mag_manual_enable(
+	BMI160_MANUAL_DISABLE);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	bmi160_get_mag_manual_enable(&v_data_u8);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+
+	return com_rslt;
+}
+/*!
+ *	@brief This function used to set the YAS532 initial values
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_set_initial_values(void)
+{
+/* This variable used for provide the communication
+	results*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* write testr1 as 0x00*/
+	com_rslt = bmi160_set_mag_write_data(
+	BMI160_YAS532_WRITE_TESTR1);
+	p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	com_rslt += bmi160_set_mag_write_addr(BMI160_YAS532_TESTR1);
+	p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	/* write testr2 as 0x00*/
+	com_rslt += bmi160_set_mag_write_data(
+	BMI160_YAS532_WRITE_TESTR2);
+	p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	com_rslt += bmi160_set_mag_write_addr(BMI160_YAS532_TESTR2);
+	p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	/* write Rcoil as 0x00*/
+	com_rslt += bmi160_set_mag_write_data(
+	BMI160_YAS532_WRITE_RCOIL);
+	p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	com_rslt += bmi160_set_mag_write_addr(BMI160_YAS532_RCOIL);
+	p_bmi160->delay_msec(BMI160_YAS532_SET_INITIAL_VALUE_DELAY);
+	/* check the valid offset*/
+	if (is_valid_offset(yas532_data.v_hard_offset_s8)) {
+		com_rslt += bmi160_bst_yas532_set_offset(
+		yas532_data.v_hard_offset_s8);
+		yas532_data.measure_state = YAS532_MAG_STATE_NORMAL;
+	} else {
+		/* set the default offset as invalid offset*/
+		set_vector(yas532_data.v_hard_offset_s8, INVALID_OFFSET);
+		/*Set the default measure state for offset correction*/
+		yas532_data.measure_state = YAS532_MAG_STATE_MEASURE_OFFSET;
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This function used for YAS532 offset correction
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_magnetic_measure_set_offset(
+void)
+{
+	/* This variable used for provide the communication
+	results*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* used for offset value set to the offset register*/
+	s8 v_hard_offset_s8[BMI160_HARD_OFFSET_DATA_SIZE] = {
+	BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE};
+	/* offset correction factors*/
+	static const u8 v_correct_u8[BMI160_YAS_CORRECT_DATA_SIZE] = {
+	16, 8, 4, 2, 1};
+	/* used for the temperature */
+	u16 v_temp_u16 = BMI160_INIT_VALUE;
+	/* used for the xy1y2 read*/
+	u16 v_xy1y2_u16[BMI160_YAS_XY1Y2_DATA_SIZE] = {BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE};
+	/* local flag for assign the values*/
+	s32 v_flag_s32[BMI160_YAS_FLAG_DATA_SIZE] = {BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE};
+	u8 i, j, v_busy_u8, v_overflow_u8 = BMI160_INIT_VALUE;
+
+	for (i = 0; i < 5; i++) {
+		/* set the offset values*/
+		com_rslt = bmi160_bst_yas532_set_offset(v_hard_offset_s8);
+		/* read the sensor data*/
+		com_rslt += bmi160_bst_yas532_normal_measurement_data(
+		BMI160_YAS532_ACQ_START, &v_busy_u8, &v_temp_u16,
+		v_xy1y2_u16, &v_overflow_u8);
+		/* check the sensor busy status*/
+		if (v_busy_u8)
+			return E_BMI160_BUSY;
+		/* calculate the magnetic correction with
+		offset and assign the values
+		to the offset register */
+		for (j = 0; j < 3; j++) {
+			if (YAS532_DATA_CENTER == v_xy1y2_u16[j])
+				v_flag_s32[j] = 0;
+			if (YAS532_DATA_CENTER < v_xy1y2_u16[j])
+				v_flag_s32[j] = 1;
+			if (v_xy1y2_u16[j] < YAS532_DATA_CENTER)
+				v_flag_s32[j] = -1;
+		}
+		for (j = 0; j < 3; j++) {
+			if (v_flag_s32[j])
+				v_hard_offset_s8[j] = (s8)(v_hard_offset_s8[j]
+				+ v_flag_s32[j] * v_correct_u8[i]);
+		}
+	}
+	/* set the offset */
+	com_rslt += bmi160_bst_yas532_set_offset(v_hard_offset_s8);
+	return com_rslt;
+}
+/*!
+ *	@brief This function used for read the
+ *	YAMAHA YAS532 calibration data
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas532_calib_values(void)
+{
+	/* This variable used for provide the communication
+	results*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* Array holding the YAS532 calibration values */
+	u8 v_data_u8[BMI160_YAS532_CALIB_DATA_SIZE] = {
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE};
+	/* Read the DX value */
+	com_rslt = bmi160_set_mag_read_addr(BMI160_YAS532_CALIB_CX);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8[0], BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	yas532_data.calib_yas532.cx = (s32)((v_data_u8[0]
+	* 10) - 1280);
+	/* Read the DY1 value */
+	com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB_CY1);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8[1], BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	yas532_data.calib_yas532.cy1 =
+	(s32)((v_data_u8[1] * 10) - 1280);
+	/* Read the DY2 value */
+	com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB_CY2);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8[2], BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	yas532_data.calib_yas532.cy2 =
+	(s32)((v_data_u8[2] * 10) - 1280);
+	/* Read the D2 and D3 value */
+	com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB1);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8[3], BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	yas532_data.calib_yas532.a2 =
+	(s32)(((v_data_u8[3] >>
+	BMI160_SHIFT_BIT_POSITION_BY_02_BITS)
+	& 0x03F) - 32);
+	/* Read the D3 and D4 value */
+	com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB2);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8[4], BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	/* calculate a3*/
+	yas532_data.calib_yas532.a3 = (s32)((((v_data_u8[3] <<
+	BMI160_SHIFT_BIT_POSITION_BY_02_BITS) & 0x0C) |
+	((v_data_u8[4]
+	>> BMI160_SHIFT_BIT_POSITION_BY_06_BITS)
+	& 0x03)) - 8);
+	/* calculate a4*/
+	yas532_data.calib_yas532.a4 = (s32)((v_data_u8[4]
+	& 0x3F) - 32);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+    /* Read the D5 and D6 value */
+	com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB3);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8[5], BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	/* calculate a5*/
+	yas532_data.calib_yas532.a5 =
+	(s32)(((v_data_u8[5]
+	>> BMI160_SHIFT_BIT_POSITION_BY_02_BITS)
+	& 0x3F) + 38);
+	/* Read the D6 and D7 value */
+	com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB4);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8[6], BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	/* calculate a6*/
+	yas532_data.calib_yas532.a6 =
+	(s32)((((v_data_u8[5]
+	<< BMI160_SHIFT_BIT_POSITION_BY_04_BITS)
+	& 0x30) | ((v_data_u8[6] >>
+	 BMI160_SHIFT_BIT_POSITION_BY_04_BITS)
+	 & 0x0F)) - 32);
+	 /* Read the D7 and D8 value */
+	com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB5);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8[7], BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	/* calculate a7*/
+	yas532_data.calib_yas532.a7 = (s32)((((v_data_u8[6]
+	<< BMI160_SHIFT_BIT_POSITION_BY_03_BITS)
+	& 0x78) |
+	((v_data_u8[7]
+	>> BMI160_SHIFT_BIT_POSITION_BY_05_BITS) &
+	0x07)) - 64);
+	/* Read the D8 and D9 value */
+	com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CLAIB6);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8[8], BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	/* calculate a8*/
+	yas532_data.calib_yas532.a8 = (s32)((((v_data_u8[7] <<
+	BMI160_GEN_READ_WRITE_DATA_LENGTH) & 0x3E) |
+	((v_data_u8[8] >>
+	BMI160_SHIFT_BIT_POSITION_BY_07_BITS) & 0x01)) -
+	32);
+
+	/* Read the D8 and D9 value */
+	com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB7);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8[9], BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	/* calculate a9*/
+	yas532_data.calib_yas532.a9 = (s32)(((v_data_u8[8] <<
+	BMI160_GEN_READ_WRITE_DATA_LENGTH) & 0xFE) |
+	 ((v_data_u8[9] >>
+	 BMI160_SHIFT_BIT_POSITION_BY_07_BITS) & 0x01));
+	/* calculate k*/
+	yas532_data.calib_yas532.k = (s32)((v_data_u8[9] >>
+	BMI160_SHIFT_BIT_POSITION_BY_02_BITS) & 0x1F);
+	/* Read the  value from register 0x9A*/
+	com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB8);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8[10],
+	BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	/* Read the  value from register 0x9B*/
+	com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIIB9);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8[11],
+	BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	/* Read the  value from register 0x9C*/
+	com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB10);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8[12],
+	BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	/* Read the  value from register 0x9D*/
+	com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB11);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+	&v_data_u8[13],
+	BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	/* Calculate the fxy1y2 and rxy1y1*/
+	yas532_data.calib_yas532.fxy1y2[0] =
+	(u8)(((v_data_u8[10]
+	& 0x01)
+	<< BMI160_SHIFT_BIT_POSITION_BY_01_BIT)
+	| ((v_data_u8[11] >>
+	BMI160_SHIFT_BIT_POSITION_BY_07_BITS) & 0x01));
+	yas532_data.calib_yas532.rxy1y2[0] =
+	((s8)(((v_data_u8[10]
+	>> BMI160_SHIFT_BIT_POSITION_BY_01_BIT) & 0x3F)
+	<< BMI160_SHIFT_BIT_POSITION_BY_02_BITS))
+	>> BMI160_SHIFT_BIT_POSITION_BY_02_BITS;
+	yas532_data.calib_yas532.fxy1y2[1] =
+	(u8)(((v_data_u8[11] & 0x01)
+	<< BMI160_SHIFT_BIT_POSITION_BY_01_BIT)
+	 | ((v_data_u8[12] >>
+	 BMI160_SHIFT_BIT_POSITION_BY_07_BITS) & 0x01));
+	yas532_data.calib_yas532.rxy1y2[1] =
+	((s8)(((v_data_u8[11]
+	>> BMI160_SHIFT_BIT_POSITION_BY_01_BIT) & 0x3F)
+	<< BMI160_SHIFT_BIT_POSITION_BY_02_BITS))
+	>> BMI160_SHIFT_BIT_POSITION_BY_02_BITS;
+	yas532_data.calib_yas532.fxy1y2[2] =
+	(u8)(((v_data_u8[12] & 0x01)
+	<< BMI160_SHIFT_BIT_POSITION_BY_01_BIT)
+	| ((v_data_u8[13]
+	>> BMI160_SHIFT_BIT_POSITION_BY_07_BITS) & 0x01));
+	yas532_data.calib_yas532.rxy1y2[2] =
+	((s8)(((v_data_u8[12]
+	>> BMI160_SHIFT_BIT_POSITION_BY_01_BIT) & 0x3F)
+	 << BMI160_SHIFT_BIT_POSITION_BY_02_BITS))
+	 >> BMI160_SHIFT_BIT_POSITION_BY_02_BITS;
+
+	return com_rslt;
+}
+/*!
+ *	@brief This function used for calculate the
+ *	YAS532 read the linear data
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_xy1y2_to_linear(
+u16 *v_xy1y2_u16, s32 *xy1y2_linear)
+{
+	/* This variable used for provide the communication
+	results*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = SUCCESS;
+	static const u16 v_calib_data[] = {
+	3721, 3971, 4221, 4471};
+	u8 i = BMI160_INIT_VALUE;
+
+	for (i = 0; i < 3; i++)
+		xy1y2_linear[i] = v_xy1y2_u16[i] -
+		 v_calib_data[yas532_data.calib_yas532.fxy1y2[i]]
+			+ (yas532_data.v_hard_offset_s8[i] -
+			yas532_data.calib_yas532.rxy1y2[i])
+			* yas532_data.coef[i];
+	return com_rslt;
+}
+/*!
+ *	@brief This function used for read the YAS532 sensor data
+ *	@param	v_acquisition_command_u8: used to set the data acquisition
+ *	acquisition_command  |   operation
+ *  ---------------------|-------------------------
+ *         0x17          | turn on the acquisition coil
+ *         -             | set direction of the coil
+ *         _             | (x and y as minus(-))
+ *         _             | Deferred acquisition mode
+ *        0x07           | turn on the acquisition coil
+ *         _             | set direction of the coil
+ *         _             | (x and y as minus(-))
+ *         _             | Normal acquisition mode
+ *        0x11           | turn OFF the acquisition coil
+ *         _             | set direction of the coil
+ *         _             | (x and y as plus(+))
+ *         _             | Deferred acquisition mode
+ *       0x01            | turn OFF the acquisition coil
+ *        _              | set direction of the coil
+ *        _              | (x and y as plus(+))
+ *        _              | Normal acquisition mode
+ *
+ *	@param	v_busy_u8 : used to get the busy flay for sensor data read
+ *	@param	v_temp_u16 : used to get the temperature data
+ *	@param	v_xy1y2_u16 : used to get the sensor xy1y2 data
+ *	@param	v_overflow_u8 : used to get the overflow data
+ *
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_normal_measurement_data(
+u8 v_acquisition_command_u8, u8 *v_busy_u8,
+u16 *v_temp_u16, u16 *v_xy1y2_u16, u8 *v_overflow_u8)
+{
+	/* This variable used for provide the communication
+	results*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = BMI160_INIT_VALUE;
+	/* Array holding the YAS532 xyy1 data*/
+	u8 v_data_u8[BMI160_YAS_XY1Y2T_DATA_SIZE] = {
+	BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE};
+	u8 i = BMI160_INIT_VALUE;
+	/* check the p_bmi160 structure as NULL*/
+	if (p_bmi160 == BMI160_NULL) {
+		return E_BMI160_NULL_PTR;
+		} else {
+		/* read the sensor data */
+		com_rslt = bmi160_bst_yas532_acquisition_command_register(
+		v_acquisition_command_u8);
+		com_rslt +=
+		p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+		BMI160_USER_DATA_MAG_X_LSB__REG,
+		v_data_u8, BMI160_MAG_YAS_DATA_LENGTH);
+		/* read the xyy1 data*/
+		*v_busy_u8 =
+		((v_data_u8[0]
+		>> BMI160_SHIFT_BIT_POSITION_BY_07_BITS) & 0x01);
+		*v_temp_u16 =
+		(u16)((((s32)v_data_u8[0]
+		<< BMI160_SHIFT_BIT_POSITION_BY_03_BITS)
+		& 0x3F8) | ((v_data_u8[1]
+		>> BMI160_SHIFT_BIT_POSITION_BY_05_BITS) & 0x07));
+		v_xy1y2_u16[0] =
+		(u16)((((s32)v_data_u8[2]
+		<< BMI160_SHIFT_BIT_POSITION_BY_06_BITS) & 0x1FC0)
+		| ((v_data_u8[3] >>
+		BMI160_SHIFT_BIT_POSITION_BY_02_BITS) & 0x3F));
+		v_xy1y2_u16[1] =
+		(u16)((((s32)v_data_u8[4]
+		<< BMI160_SHIFT_BIT_POSITION_BY_06_BITS)
+		& 0x1FC0)
+		| ((v_data_u8[5]
+		>> BMI160_SHIFT_BIT_POSITION_BY_02_BITS) & 0x3F));
+		v_xy1y2_u16[2] =
+		(u16)((((s32)v_data_u8[6]
+		<< BMI160_SHIFT_BIT_POSITION_BY_06_BITS)
+		& 0x1FC0)
+		| ((v_data_u8[7]
+		>> BMI160_SHIFT_BIT_POSITION_BY_02_BITS) & 0x3F));
+		*v_overflow_u8 = 0;
+		for (i = 0; i < 3; i++) {
+			if (v_xy1y2_u16[i] == YAS532_DATA_OVERFLOW)
+				*v_overflow_u8 |= (1 << (i * 2));
+			if (v_xy1y2_u16[i] == YAS532_DATA_UNDERFLOW)
+				*v_overflow_u8 |= (1 << (i * 2 + 1));
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This function used for YAS532 sensor data
+ *	@param	v_acquisition_command_u8	:	the value of CMDR
+ *	acquisition_command  |   operation
+ *  ---------------------|-------------------------
+ *         0x17          | turn on the acquisition coil
+ *         -             | set direction of the coil
+ *         _             | (x and y as minus(-))
+ *         _             | Deferred acquisition mode
+ *        0x07           | turn on the acquisition coil
+ *         _             | set direction of the coil
+ *         _             | (x and y as minus(-))
+ *         _             | Normal acquisition mode
+ *        0x11           | turn OFF the acquisition coil
+ *         _             | set direction of the coil
+ *         _             | (x and y as plus(+))
+ *         _             | Deferred acquisition mode
+ *       0x01            | turn OFF the acquisition coil
+ *        _              | set direction of the coil
+ *        _              | (x and y as plus(+))
+ *        _              | Normal acquisition mode
+ *
+ * @param xyz_data : the vector xyz output
+ * @param v_overflow_s8 : the value of overflow
+ * @param v_temp_correction_u8 : the value of temperate correction enable
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_measurement_xyz_data(
+struct yas532_vector *xyz_data, u8 *v_overflow_s8, u8 v_temp_correction_u8,
+u8 v_acquisition_command_u8)
+{
+	/* This variable used for provide the communication
+	results*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = BMI160_INIT_VALUE;
+	/* Array holding the linear calculation output*/
+	s32 v_xy1y2_linear_s32[BMI160_YAS_XY1Y2_DATA_SIZE] = {
+	BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE};
+	/* Array holding the temperature data */
+	s32 v_xyz_tmp_s32[BMI160_YAS_TEMP_DATA_SIZE] = {BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE};
+	s32 tmp = BMI160_INIT_VALUE;
+	s32 sx, sy1, sy2, sy, sz = BMI160_INIT_VALUE;
+	u8 i, v_busy_u8 = BMI160_INIT_VALUE;
+	u16 v_temp_u16 = BMI160_INIT_VALUE;
+	/* Array holding the xyy1 sensor raw data*/
+	u16 v_xy1y2_u16[BMI160_YAS_XY1Y2_DATA_SIZE] = {BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE};
+	#if YAS532_MAG_LOG < YAS532_MAG_TEMPERATURE_LOG
+	s32 sum = BMI160_INIT_VALUE;
+	#endif
+	*v_overflow_s8 = BMI160_INIT_VALUE;
+	switch (yas532_data.measure_state) {
+	case YAS532_MAG_STATE_INIT_COIL:
+		if (p_bmi160->mag_manual_enable != BMI160_MANUAL_ENABLE)
+			com_rslt = bmi160_set_mag_manual_enable(
+			BMI160_MANUAL_ENABLE);
+		/* write Rcoil*/
+		com_rslt += bmi160_set_mag_write_data(
+		BMI160_YAS_DISABLE_RCOIL);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		com_rslt += bmi160_set_mag_write_addr(BMI160_YAS532_RCOIL);
+		p_bmi160->delay_msec(BMI160_YAS532_MEASUREMENT_DELAY);
+		if (!yas532_data.overflow && is_valid_offset(
+		yas532_data.v_hard_offset_s8))
+			yas532_data.measure_state = 0;
+	break;
+	case YAS532_MAG_STATE_MEASURE_OFFSET:
+		com_rslt = bmi160_bst_yas532_magnetic_measure_set_offset();
+		yas532_data.measure_state = 0;
+	break;
+	default:
+	break;
+	}
+	/* Read sensor data*/
+	com_rslt += bmi160_bst_yas532_normal_measurement_data(
+	v_acquisition_command_u8, &v_busy_u8, &v_temp_u16,
+	v_xy1y2_u16, v_overflow_s8);
+	/* Calculate the linear data*/
+	com_rslt += bmi160_bst_yas532_xy1y2_to_linear(v_xy1y2_u16,
+	v_xy1y2_linear_s32);
+	/* Calculate temperature correction */
+	#if YAS532_MAG_LOG < YAS532_MAG_TEMPERATURE_LOG
+		yas532_data.temp_data.log[yas532_data.temp_data.idx++] =
+		v_temp_u16;
+	if (YAS532_MAG_TEMPERATURE_LOG <= yas532_data.temp_data.idx)
+		yas532_data.temp_data.idx = 0;
+		yas532_data.temp_data.num++;
+	if (YAS532_MAG_TEMPERATURE_LOG <= yas532_data.temp_data.num)
+		yas532_data.temp_data.num = YAS532_MAG_TEMPERATURE_LOG;
+	for (i = 0; i < yas532_data.temp_data.num; i++)
+		sum += yas532_data.temp_data.log[i];
+		tmp = sum * 10 / yas532_data.temp_data.num
+		- YAS532_TEMP20DEGREE_TYPICAL * 10;
+	#else
+		tmp = (v_temp_u16 - YAS532_TEMP20DEGREE_TYPICAL)
+		* 10;
+	#endif
+	sx  = v_xy1y2_linear_s32[0];
+	sy1 = v_xy1y2_linear_s32[1];
+	sy2 = v_xy1y2_linear_s32[2];
+	/* Temperature correction */
+	if (v_temp_correction_u8) {
+		sx  -= (yas532_data.calib_yas532.cx  * tmp)
+		/ 1000;
+		sy1 -= (yas532_data.calib_yas532.cy1 * tmp)
+		/ 1000;
+		sy2 -= (yas532_data.calib_yas532.cy2 * tmp)
+		/ 1000;
+	}
+	sy = sy1 - sy2;
+	sz = -sy1 - sy2;
+
+	xyz_data->yas532_vector_xyz[0] = yas532_data.calib_yas532.k *
+	((100 * sx + yas532_data.calib_yas532.a2 * sy +
+	yas532_data.calib_yas532.a3 * sz) / 10);
+	xyz_data->yas532_vector_xyz[1] = yas532_data.calib_yas532.k *
+	((yas532_data.calib_yas532.a4 * sx + yas532_data.calib_yas532.a5 * sy +
+	yas532_data.calib_yas532.a6 * sz) / 10);
+	xyz_data->yas532_vector_xyz[2] = yas532_data.calib_yas532.k *
+	((yas532_data.calib_yas532.a7 * sx + yas532_data.calib_yas532.a8 * sy +
+	yas532_data.calib_yas532.a9 * sz) / 10);
+	if (yas532_data.transform != BMI160_NULL) {
+		for (i = 0; i < 3; i++) {
+				v_xyz_tmp_s32[i] = yas532_data.transform[i
+				* 3] *
+				xyz_data->yas532_vector_xyz[0]
+				+ yas532_data.transform[i * 3 + 1] *
+				xyz_data->yas532_vector_xyz[1]
+				+ yas532_data.transform[i * 3 + 2] *
+				xyz_data->yas532_vector_xyz[2];
+		}
+		set_vector(xyz_data->yas532_vector_xyz, v_xyz_tmp_s32);
+	}
+	for (i = 0; i < 3; i++) {
+		xyz_data->yas532_vector_xyz[i] -=
+		xyz_data->yas532_vector_xyz[i] % 10;
+		if (*v_overflow_s8 & (1
+		<< (i * 2)))
+			xyz_data->yas532_vector_xyz[i] +=
+			1; /* set overflow */
+		if (*v_overflow_s8 & (1 <<
+		(i * 2 + 1)))
+			xyz_data->yas532_vector_xyz[i] += 2; /* set underflow */
+	}
+
+
+if (v_busy_u8)
+		return com_rslt;
+	if (0 < *v_overflow_s8) {
+		if (!yas532_data.overflow)
+			yas532_data.overflow = 1;
+		yas532_data.measure_state = YAS532_MAG_STATE_INIT_COIL;
+	} else
+		yas532_data.overflow = 0;
+	for (i = 0; i < 3; i++)
+		yas532_data.last_raw[i] = v_xy1y2_u16[i];
+	  yas532_data.last_raw[i] = v_temp_u16;
+	return com_rslt;
+}
+/*!
+ *	@brief This function used for YAS532 write data acquisition
+ *	command register write
+ *	@param	v_command_reg_data_u8	:	the value of data acquisition
+ *	acquisition_command  |   operation
+ *  ---------------------|-------------------------
+ *         0x17          | turn on the acquisition coil
+ *         -             | set direction of the coil
+ *         _             | (x and y as minus(-))
+ *         _             | Deferred acquisition mode
+ *        0x07           | turn on the acquisition coil
+ *         _             | set direction of the coil
+ *         _             | (x and y as minus(-))
+ *         _             | Normal acquisition mode
+ *        0x11           | turn OFF the acquisition coil
+ *         _             | set direction of the coil
+ *         _             | (x and y as plus(+))
+ *         _             | Deferred acquisition mode
+ *       0x01            | turn OFF the acquisition coil
+ *        _              | set direction of the coil
+ *        _              | (x and y as plus(+))
+ *        _              | Normal acquisition mode
+ *
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_acquisition_command_register(
+u8 v_command_reg_data_u8)
+{
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+
+	if (p_bmi160->mag_manual_enable != BMI160_MANUAL_ENABLE)
+			com_rslt = bmi160_set_mag_manual_enable(
+			BMI160_MANUAL_ENABLE);
+
+		com_rslt = bmi160_set_mag_write_data(v_command_reg_data_u8);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		/* YAMAHA YAS532-0x82*/
+		com_rslt += bmi160_set_mag_write_addr(
+		BMI160_YAS532_COMMAND_REGISTER);
+		p_bmi160->delay_msec(BMI160_YAS_ACQ_COMMAND_DELAY);
+		com_rslt += bmi160_set_mag_read_addr(
+		BMI160_YAS532_DATA_REGISTER);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+
+	if (p_bmi160->mag_manual_enable == BMI160_MANUAL_ENABLE)
+		com_rslt += bmi160_set_mag_manual_enable(BMI160_MANUAL_DISABLE);
+
+	return com_rslt;
+
+}
+/*!
+ *	@brief This function used write offset of YAS532
+ *
+ *	@param	p_offset_s8	: The value of offset to write
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_set_offset(
+const s8 *p_offset_s8)
+{
+	/* This variable used for provide the communication
+	results*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+
+	if (p_bmi160->mag_manual_enable != BMI160_MANUAL_ENABLE)
+		com_rslt = bmi160_set_mag_manual_enable(BMI160_MANUAL_ENABLE);
+		p_bmi160->delay_msec(BMI160_YAS532_OFFSET_DELAY);
+
+	    /* Write offset X data*/
+		com_rslt = bmi160_set_mag_write_data(p_offset_s8[0]);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		/* YAS532 offset x write*/
+		com_rslt += bmi160_set_mag_write_addr(BMI160_YAS532_OFFSET_X);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+
+		/* Write offset Y data*/
+		com_rslt = bmi160_set_mag_write_data(p_offset_s8[1]);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		/* YAS532 offset y write*/
+		com_rslt += bmi160_set_mag_write_addr(BMI160_YAS532_OFFSET_Y);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+
+		/* Write offset Z data*/
+		com_rslt = bmi160_set_mag_write_data(p_offset_s8[2]);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		/* YAS532 offset z write*/
+		com_rslt += bmi160_set_mag_write_addr(BMI160_YAS532_OFFSET_Z);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		set_vector(yas532_data.v_hard_offset_s8, p_offset_s8);
+
+	if (p_bmi160->mag_manual_enable == BMI160_MANUAL_ENABLE)
+		com_rslt = bmi160_set_mag_manual_enable(BMI160_MANUAL_DISABLE);
+	return com_rslt;
+}
+/*!
+ *	@brief This function used to init the YAMAH-YAS537
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas537_mag_interface_init(
+void)
+{
+/* This variable used for provide the communication
+results*/
+BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_pull_value_u8 = BMI160_INIT_VALUE;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+u8 i = BMI160_INIT_VALUE;
+/* accel operation mode to normal*/
+com_rslt = bmi160_set_command_register(ACCEL_MODE_NORMAL);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+/* write mag power mode as NORMAL*/
+com_rslt += bmi160_set_mag_interface_normal();
+/* register 0x7E write the 0x37, 0x9A and 0x30*/
+com_rslt += bmi160_set_command_register(BMI160_COMMAND_REG_ONE);
+p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+com_rslt += bmi160_set_command_register(BMI160_COMMAND_REG_TWO);
+p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+com_rslt += bmi160_set_command_register(BMI160_COMMAND_REG_THREE);
+p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+/*switch the page1*/
+com_rslt += bmi160_set_target_page(BMI160_WRITE_TARGET_PAGE1);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+bmi160_get_target_page(&v_data_u8);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+com_rslt += bmi160_set_paging_enable(BMI160_WRITE_ENABLE_PAGE1);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+bmi160_get_paging_enable(&v_data_u8);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+/* enable the pullup configuration from
+the register 0x05 bit 4 and 5 as 10*/
+bmi160_get_pullup_configuration(&v_pull_value_u8);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+v_pull_value_u8 = v_pull_value_u8 | BMI160_PULL_UP_DATA;
+com_rslt += bmi160_set_pullup_configuration(v_pull_value_u8);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+/*switch the page0*/
+com_rslt += bmi160_set_target_page(BMI160_WRITE_TARGET_PAGE0);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+bmi160_get_target_page(&v_data_u8);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+/* Write the YAS532 i2c address*/
+com_rslt += bmi160_set_i2c_device_addr(BMI160_YAS537_I2C_ADDRESS);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+/* enable the mag interface to manual mode*/
+com_rslt += bmi160_set_mag_manual_enable(BMI160_MANUAL_ENABLE);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+bmi160_get_mag_manual_enable(&v_data_u8);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+/*Enable the MAG interface */
+com_rslt += bmi160_set_if_mode(BMI160_ENABLE_MAG_IF_MODE);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+bmi160_get_if_mode(&v_data_u8);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+v_data_u8 = BMI160_MANUAL_DISABLE;
+/* Read the YAS537 device id*/
+com_rslt += bmi160_set_mag_read_addr(BMI160_YAS_DEVICE_ID_REG);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+yas537_data.dev_id = v_data_u8;
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+/* Read the YAS532 calibration data*/
+com_rslt +=
+bmi160_bst_yamaha_yas537_calib_values(
+BMI160_GEN_READ_WRITE_DATA_LENGTH);
+p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+/* set the mode to NORMAL*/
+yas537_data.measure_state = YAS537_MAG_STATE_NORMAL;
+/* set the transform to zero */
+yas537_data.transform = BMI160_NULL;
+yas537_data.average = 32;
+for (i = 0; i < 3; i++) {
+	yas537_data.hard_offset[i] = -128;
+	yas537_data.last_after_rcoil[i] = 0;
+}
+for (i = 0; i < 4; i++)
+	yas537_data.last_raw[i] = 0;
+/* write the mag bandwidth as 25Hz*/
+com_rslt += bmi160_set_mag_output_data_rate(
+BMI160_MAG_OUTPUT_DATA_RATE_25HZ);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+/* Enable mag interface to auto mode*/
+com_rslt += bmi160_set_mag_manual_enable(
+BMI160_MANUAL_DISABLE);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+bmi160_get_mag_manual_enable(&v_data_u8);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+return com_rslt;
+}
+/*!
+*	@brief This function used for read the
+*	YAMAHA YAS537 calibration data
+*
+*
+*	@param v_rcoil_u8 : The value of r coil
+*
+*
+*	@return results of bus communication function
+*	@retval 0 -> Success
+*	@retval -1 -> Error
+*
+*
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas537_calib_values(
+u8 v_rcoil_u8)
+{
+/* This variable used for provide the communication
+results*/
+BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+/* Array holding the YAS532 calibration values */
+u8 a_data_u8[BMI160_YAS537_CALIB_DATA_SIZE] = {
+BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+};
+static const u8 v_avrr_u8[] = {0x50, 0x60, 0x70};
+u8 v_cal_valid_u8 = BMI160_INIT_VALUE, i;
+/* write soft reset as 0x02*/
+com_rslt = bmi160_set_mag_write_data(
+YAS537_SRSTR_DATA);
+p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+com_rslt += bmi160_set_mag_write_addr(YAS537_REG_SRSTR);
+p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+/* Read the DX value */
+com_rslt = bmi160_set_mag_read_addr(YAS537_REG_CALR_C0);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+&a_data_u8[0], BMI160_GEN_READ_WRITE_DATA_LENGTH);
+/* Read the DY1 value */
+com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_C1);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+&a_data_u8[1], BMI160_GEN_READ_WRITE_DATA_LENGTH);
+/* Read the DY2 value */
+com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_C2);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+&a_data_u8[2], BMI160_GEN_READ_WRITE_DATA_LENGTH);
+/* Read the D2 value */
+com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_C3);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+&a_data_u8[3], BMI160_GEN_READ_WRITE_DATA_LENGTH);
+/* Read the D3 value */
+com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_C4);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+&a_data_u8[4], BMI160_GEN_READ_WRITE_DATA_LENGTH);
+/* Read the D4 value */
+com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_C5);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+&a_data_u8[5], BMI160_GEN_READ_WRITE_DATA_LENGTH);
+/* Read the D5 value */
+com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_C6);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+&a_data_u8[6], BMI160_GEN_READ_WRITE_DATA_LENGTH);
+/* Read the D6 value */
+com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_C7);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+&a_data_u8[7], BMI160_GEN_READ_WRITE_DATA_LENGTH);
+/* Read the D7 value */
+com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_C8);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+&a_data_u8[8], BMI160_GEN_READ_WRITE_DATA_LENGTH);
+/* Read the D8 value */
+com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_C9);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+&a_data_u8[9], BMI160_GEN_READ_WRITE_DATA_LENGTH);
+/* Read the D9 value */
+com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_CA);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+&a_data_u8[10], BMI160_GEN_READ_WRITE_DATA_LENGTH);
+/* Read the RX value */
+com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_CB);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+&a_data_u8[11], BMI160_GEN_READ_WRITE_DATA_LENGTH);
+/* Read the RY1 value */
+com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_CC);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+&a_data_u8[12], BMI160_GEN_READ_WRITE_DATA_LENGTH);
+/* Read the RY2 value */
+com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_CD);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+&a_data_u8[13], BMI160_GEN_READ_WRITE_DATA_LENGTH);
+/* Read the RY2 value */
+com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_CE);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+&a_data_u8[14], BMI160_GEN_READ_WRITE_DATA_LENGTH);
+/* Read the CHF value */
+com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_CF);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+&a_data_u8[15], BMI160_GEN_READ_WRITE_DATA_LENGTH);
+/* Read the VER value */
+com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_DO);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
+&a_data_u8[16], BMI160_GEN_READ_WRITE_DATA_LENGTH);
+/* get the calib ver*/
+yas537_data.calib_yas537.ver =
+(a_data_u8[16] >> BMI160_SHIFT_BIT_POSITION_BY_06_BITS);
+for (i = 0; i < 17; i++) {
+	if (((i < 16 && a_data_u8[i]) != 0))
+		v_cal_valid_u8 = 1;
+	if ((i < 16 &&
+	(a_data_u8[i] & 0x3F)) != 0)
+		v_cal_valid_u8 = 1;
+}
+if (!v_cal_valid_u8)
+	return ERROR;
+if (yas537_data.calib_yas537.ver == 0) {
+	for (i = 0; i < 17; i++) {
+		if (i < 12) {
+			/* write offset*/
+			com_rslt += bmi160_set_mag_write_data(
+			a_data_u8[i]);
+			p_bmi160->delay_msec(
+			BMI160_GEN_READ_WRITE_DELAY);
+			com_rslt += bmi160_set_mag_write_addr(
+			YAS537_REG_MTCR + i);
+			p_bmi160->delay_msec(
+			BMI160_GEN_READ_WRITE_DELAY);
+		} else if (i < 15) {
+			/* write offset correction*/
+			com_rslt += bmi160_set_mag_write_data(
+			a_data_u8[i]);
+			p_bmi160->delay_msec(
+			BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+			com_rslt += bmi160_set_mag_write_addr((
+			(YAS537_REG_OXR + i) - 12));
+			p_bmi160->delay_msec(
+			BMI160_GEN_READ_WRITE_DELAY);
+			yas537_data.hard_offset[i - 12]
+			= a_data_u8[i];
+		} else {
+			/* write offset correction*/
+			com_rslt += bmi160_set_mag_write_data(
+			a_data_u8[i]);
+			p_bmi160->delay_msec(
+			BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+			com_rslt += bmi160_set_mag_write_addr((
+			(YAS537_REG_OXR + i) - 11));
+			p_bmi160->delay_msec(
+			BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+		}
+
+}
+} else if (yas537_data.calib_yas537.ver == 1) {
+	for (i = 0; i < 3; i++) {
+		/* write offset*/
+		com_rslt += bmi160_set_mag_write_data(
+		a_data_u8[i]);
+		p_bmi160->delay_msec(
+		BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+		com_rslt += bmi160_set_mag_write_addr(
+		YAS537_REG_MTCR + i);
+		p_bmi160->delay_msec(
+		BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+		if (com_rslt == SUCCESS) {
+			/* write offset*/
+			com_rslt += bmi160_set_mag_write_data(
+			a_data_u8[i + 12]);
+			p_bmi160->delay_msec(
+			BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+			com_rslt += bmi160_set_mag_write_addr(
+			YAS537_REG_OXR + i);
+			p_bmi160->delay_msec(
+			BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+			yas537_data.hard_offset[i] =
+			a_data_u8[i + 12];
+		} else {
+			com_rslt = ERROR;
+		}
+	}
+	/* write offset*/
+	com_rslt += bmi160_set_mag_write_data(
+	((a_data_u8[i] & 0xE0) | 0x10));
+	p_bmi160->delay_msec(
+	BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	com_rslt += bmi160_set_mag_write_addr(
+	YAS537_REG_MTCR + i);
+	p_bmi160->delay_msec(
+	BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	/* write offset*/
+	com_rslt += bmi160_set_mag_write_data(
+	((a_data_u8[15]
+	>> BMI160_SHIFT_BIT_POSITION_BY_03_BITS)
+	& 0x1E));
+	p_bmi160->delay_msec(
+	BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	com_rslt += bmi160_set_mag_write_addr(YAS537_REG_HCKR);
+	p_bmi160->delay_msec(
+	BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	/* write offset*/
+	com_rslt += bmi160_set_mag_write_data(
+	((a_data_u8[15] << 1) & 0x1E));
+	p_bmi160->delay_msec(
+	BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	com_rslt += bmi160_set_mag_write_addr(YAS537_REG_LCKR);
+	p_bmi160->delay_msec(
+	BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	/* write offset*/
+	com_rslt += bmi160_set_mag_write_data(
+	(a_data_u8[16] & 0x3F));
+	p_bmi160->delay_msec(
+	BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	com_rslt += bmi160_set_mag_write_addr(YAS537_REG_OCR);
+	p_bmi160->delay_msec(
+	BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+
+	/* Assign the calibration values*/
+	/* a2 */
+	yas537_data.calib_yas537.a2 =
+	((((a_data_u8[3]
+	<< BMI160_SHIFT_BIT_POSITION_BY_02_BITS)
+	& 0x7C)
+	| (a_data_u8[4]
+	>> BMI160_SHIFT_BIT_POSITION_BY_06_BITS)) - 64);
+	/* a3 */
+	yas537_data.calib_yas537.a3 =
+	((((a_data_u8[4] << BMI160_SHIFT_BIT_POSITION_BY_01_BIT)
+	& 0x7E)
+	| (a_data_u8[5]
+	>> BMI160_SHIFT_BIT_POSITION_BY_07_BITS)) - 64);
+	/* a4 */
+	yas537_data.calib_yas537.a4 =
+	((((a_data_u8[5]
+	<< BMI160_SHIFT_BIT_POSITION_BY_01_BIT)
+	& 0xFE)
+	| (a_data_u8[6]
+	>> BMI160_SHIFT_BIT_POSITION_BY_07_BITS))
+	- 128);
+	/* a5 */
+	yas537_data.calib_yas537.a5 =
+	((((a_data_u8[6]
+	<< BMI160_SHIFT_BIT_POSITION_BY_02_BITS)
+	& 0x1FC)
+	| (a_data_u8[7]
+	>> BMI160_SHIFT_BIT_POSITION_BY_06_BITS))
+	- 112);
+	/* a6 */
+	yas537_data.calib_yas537.a6 =
+	((((a_data_u8[7]
+	<< BMI160_SHIFT_BIT_POSITION_BY_01_BIT)
+	& 0x7E)
+	| (a_data_u8[8]
+	>> BMI160_SHIFT_BIT_POSITION_BY_07_BITS)) - 64);
+	/* a7 */
+	yas537_data.calib_yas537.a7 =
+	((((a_data_u8[8]
+	<< BMI160_SHIFT_BIT_POSITION_BY_01_BIT)
+	& 0xFE)
+	| (a_data_u8[9]
+	>> BMI160_SHIFT_BIT_POSITION_BY_07_BITS))
+	- 128);
+	/* a8 */
+	yas537_data.calib_yas537.a8 = ((a_data_u8[9] &
+	0x7F) - 64);
+	/* a9 */
+	yas537_data.calib_yas537.a9 = ((((a_data_u8[10]
+	<< BMI160_SHIFT_BIT_POSITION_BY_01_BIT) & 0x1FE)
+	| (a_data_u8[11]
+	>> BMI160_SHIFT_BIT_POSITION_BY_07_BITS))
+	- 112);
+	/* k */
+	yas537_data.calib_yas537.k = (
+	a_data_u8[11] & 0x7F);
+	} else {
+		return ERROR;
+	}
+/* write A/D converter*/
+com_rslt += bmi160_set_mag_write_data(
+YAS537_WRITE_A_D_CONVERTER);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+com_rslt += bmi160_set_mag_write_addr(YAS537_REG_ADCCALR);
+p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+/* write A/D converter second register*/
+com_rslt += bmi160_set_mag_write_data(
+YAS537_WRITE_A_D_CONVERTER2);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+com_rslt += bmi160_set_mag_write_addr(YAS537_REG_ADCCALR_ONE);
+p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+/* write temperature calibration register*/
+com_rslt += bmi160_set_mag_write_data(YAS537_WRITE_TEMP_CALIB);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+com_rslt += bmi160_set_mag_write_addr(YAS537_REG_TRMR);
+p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+/* write average filter register*/
+com_rslt += bmi160_set_mag_write_data(
+v_avrr_u8[yas537_data.average]);
+p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+com_rslt += bmi160_set_mag_write_addr(YAS537_REG_AVRR);
+p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+if (v_rcoil_u8) {
+	/* write average; filter register*/
+	com_rslt += bmi160_set_mag_write_data(
+	YAS537_WRITE_FILTER);
+	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	com_rslt += bmi160_set_mag_write_addr(YAS537_REG_CONFR);
+	p_bmi160->delay_msec(
+	BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+}
+
+return com_rslt;
+
+}
+/*!
+ *	@brief This function used for YAS537 write data acquisition
+ *	command register write
+ *	@param	v_command_reg_data_u8	:	the value of data acquisition
+ *	acquisition_command  |   operation
+ *  ---------------------|-------------------------
+ *         0x17          | turn on the acquisition coil
+ *         -             | set direction of the coil
+ *         _             | (x and y as minus(-))
+ *         _             | Deferred acquisition mode
+ *        0x07           | turn on the acquisition coil
+ *         _             | set direction of the coil
+ *         _             | (x and y as minus(-))
+ *         _             | Normal acquisition mode
+ *        0x11           | turn OFF the acquisition coil
+ *         _             | set direction of the coil
+ *         _             | (x and y as plus(+))
+ *         _             | Deferred acquisition mode
+ *       0x01            | turn OFF the acquisition coil
+ *        _              | set direction of the coil
+ *        _              | (x and y as plus(+))
+ *        _              | Normal acquisition mode
+ *
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas537_acquisition_command_register(
+u8 v_command_reg_data_u8)
+{
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+
+	if (p_bmi160->mag_manual_enable != BMI160_MANUAL_ENABLE)
+			com_rslt = bmi160_set_mag_manual_enable(
+			BMI160_MANUAL_ENABLE);
+			p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+
+		com_rslt = bmi160_set_mag_write_data(v_command_reg_data_u8);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		/* YAMAHA YAS532-0x82*/
+		com_rslt += bmi160_set_mag_write_addr(
+		BMI160_REG_YAS537_CMDR);
+		/* set the mode to RECORD*/
+		yas537_data.measure_state = YAS537_MAG_STATE_RECORD_DATA;
+		p_bmi160->delay_msec(BMI160_YAS_ACQ_COMMAND_DELAY);
+		com_rslt += bmi160_set_mag_read_addr(
+		YAS537_REG_TEMPERATURE_0);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+
+	if (p_bmi160->mag_manual_enable == BMI160_MANUAL_ENABLE)
+		com_rslt += bmi160_set_mag_manual_enable(
+		BMI160_MANUAL_DISABLE);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+
+	return com_rslt;
+
+}
+/*!
+ *	@brief This function used for read the
+ *	YAMAHA YAS537 xy1y2 data
+ *
+ *	@param xy1y2: The value of raw xy1y2 data
+ *	@param xyz: The value of  xyz data
+ *
+ *
+ *	@return None
+ *
+ *
+ */
+static void xy1y2_to_xyz(u16 *xy1y2, s32 *xyz)
+{
+	xyz[0] = ((xy1y2[0] - 8192)
+	* 300);
+	xyz[1] = (((xy1y2[1] - xy1y2[2])
+	* 1732) / 10);
+	xyz[2] = (((-xy1y2[2] - xy1y2[2])
+	+ 16384) * 300);
+}
+/*!
+ *	@brief This function used for read the
+ *	YAMAHA YAS537 xy1y2 data
+ *
+ *	@param v_coil_stat_u8: The value of R coil status
+ *	@param v_busy_u8: The value of busy status
+ *	@param v_temperature_u16: The value of temperature
+ *	@param xy1y2: The value of raw xy1y2 data
+ *	@param v_ouflow_u8: The value of overflow
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas537_read_xy1y2_data(
+u8 *v_coil_stat_u8, u8 *v_busy_u8,
+u16 *v_temperature_u16, u16 *xy1y2, u8 *v_ouflow_u8)
+{
+	/* This variable used for provide the communication
+	results*/
+	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	/* Array holding the YAS532 calibration values */
+	u8 a_data_u8[BMI160_YAS_XY1Y2T_DATA_SIZE] = {
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+	};
+	u8 i = BMI160_INIT_VALUE;
+	s32 a_h_s32[BMI160_YAS_H_DATA_SIZE] = {
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE};
+	s32 a_s_s32[BMI160_YAS_S_DATA_SIZE] = {
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE};
+	/* set command register*/
+	com_rslt = bmi160_bst_yas537_acquisition_command_register(
+	YAS537_SET_COMMAND_REGISTER);
+	/* read the yas537 sensor data of xy1y2*/
+	com_rslt +=
+	p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+	BMI160_USER_DATA_MAG_X_LSB__REG,
+	a_data_u8, BMI160_MAG_YAS_DATA_LENGTH);
+	/* read the busy flag*/
+	*v_busy_u8 = a_data_u8[2]
+	>> BMI160_SHIFT_BIT_POSITION_BY_07_BITS;
+	/* read the coil status*/
+	*v_coil_stat_u8 =
+	((a_data_u8[2] >>
+	BMI160_SHIFT_BIT_POSITION_BY_06_BITS) & 0X01);
+	/* read temperature data*/
+	*v_temperature_u16 = (u16)((a_data_u8[0]
+	<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS) | a_data_u8[1]);
+	/* read x data*/
+	xy1y2[0] = (u16)(((a_data_u8[2] &
+	0x3F)
+	<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
+	| (a_data_u8[3]));
+	/* read y1 data*/
+	xy1y2[1] = (u16)((a_data_u8[4]
+	<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
+	| a_data_u8[5]);
+	/* read y2 data*/
+	xy1y2[2] = (u16)((a_data_u8[6]
+	<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
+	| a_data_u8[7]);
+	for (i = 0; i < 3; i++)
+		yas537_data.last_raw[i] = xy1y2[i];
+	yas537_data.last_raw[i] = *v_temperature_u16;
+	if (yas537_data.calib_yas537.ver == 1) {
+		for (i = 0; i < 3; i++)
+			a_s_s32[i] = xy1y2[i] - 8192;
+		/* read hx*/
+		a_h_s32[0] = ((yas537_data.calib_yas537.k * (
+		(128 * a_s_s32[0]) +
+		(yas537_data.calib_yas537.a2 * a_s_s32[1]) +
+		(yas537_data.calib_yas537.a3 * a_s_s32[2])))
+		/ (8192));
+		/* read hy1*/
+		a_h_s32[1] = ((yas537_data.calib_yas537.k * (
+		(yas537_data.calib_yas537.a4 * a_s_s32[0]) +
+		(yas537_data.calib_yas537.a5 * a_s_s32[1]) +
+		(yas537_data.calib_yas537.a6 * a_s_s32[2])))
+		/ (8192));
+		/* read hy2*/
+		a_h_s32[2] = ((yas537_data.calib_yas537.k * (
+		(yas537_data.calib_yas537.a7 * a_s_s32[0]) +
+		(yas537_data.calib_yas537.a8 * a_s_s32[1]) +
+		(yas537_data.calib_yas537.a9 * a_s_s32[2])))
+		/ (8192));
+
+		for (i = 0; i < 3; i++) {
+			if (a_h_s32[i] < -8192)
+				a_h_s32[i] = -8192;
+
+			if (8192 < a_h_s32[i])
+				a_h_s32[i] = 8192;
+
+			xy1y2[i] = a_h_s32[i] + 8192;
+
+		}
+	}
+	*v_ouflow_u8 = 0;
+	for (i = 0; i < 3; i++) {
+		if (YAS537_DATA_OVERFLOW <= xy1y2[i])
+			*v_ouflow_u8 |= (1 << (i * 2));
+		if (xy1y2[i] == YAS537_DATA_UNDERFLOW)
+			*v_ouflow_u8 |= (1 << (i * 2 + 1));
+	}
+
+	return com_rslt;
+
+}
+/*!
+ *	@brief This function used for read the
+ *	YAMAHA YAS537 xy1y2 data
+ *
+ *	@param v_ouflow_u8: The value of overflow
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+static BMI160_RETURN_FUNCTION_TYPE invalid_magnetic_field(
+u16 *v_cur_u16, u16 *v_last_u16)
+{
+	s16 invalid_thresh[] = {1500, 1500, 1500};
+	u8 i = BMI160_INIT_VALUE;
+
+	for (i = 0; i < 3; i++)
+		if (invalid_thresh[i] < ABS(v_cur_u16[i] - v_last_u16[i]))
+			return 1;
+	return 0;
+}
+/*!
+ *	@brief This function used for read the
+ *	YAMAHA YAS537 xy1y2 data
+ *
+ *	@param v_ouflow_u8: The value of overflow
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas537_measure_xyz_data(
+u8 *v_ouflow_u8, struct yas_vector *vector_xyz)
+{
+	s32 a_xyz_tmp_s32[BMI160_YAS_TEMP_DATA_SIZE] = {
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE};
+	u8 i = BMI160_INIT_VALUE;
+	s8 com_rslt = BMI160_INIT_VALUE;
+	u8 v_busy_u8 = BMI160_INIT_VALUE;
+	u8 v_rcoil_u8 = BMI160_INIT_VALUE;
+	u16 v_temperature_u16 = BMI160_INIT_VALUE;
+	u16 a_xy1y2_u16[BMI160_YAS_XY1Y2_DATA_SIZE] = {
+	BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE};
+	*v_ouflow_u8 = 0;
+	/* read the yas537 xy1y2 data*/
+	com_rslt = bmi160_bst_yamaha_yas537_read_xy1y2_data(
+	&v_rcoil_u8, &v_busy_u8,
+	&v_temperature_u16, a_xy1y2_u16, v_ouflow_u8);
+	/* linear calculation*/
+	xy1y2_to_xyz(a_xy1y2_u16, vector_xyz->yas537_vector_xyz);
+	if (yas537_data.transform != BMI160_NULL) {
+		for (i = 0; i < 3; i++) {
+			a_xyz_tmp_s32[i] = ((
+			yas537_data.transform[i + 3]
+			* vector_xyz->yas537_vector_xyz[0])
+			+ (yas537_data.transform[
+			i * 3 + 1]
+			* vector_xyz->yas537_vector_xyz[1])
+			+ (yas537_data.transform[
+			i * 3 + 2]
+			* vector_xyz->yas537_vector_xyz[2]));
+		}
+		yas537_set_vector(
+		vector_xyz->yas537_vector_xyz, a_xyz_tmp_s32);
+	}
+	for (i = 0; i < 3; i++) {
+		vector_xyz->yas537_vector_xyz[i] -=
+		vector_xyz->yas537_vector_xyz[i] % 10;
+		if (*v_ouflow_u8 & (1 <<
+		(i * 2)))
+			vector_xyz->yas537_vector_xyz[i] +=
+			1; /* set overflow */
+		if (*v_ouflow_u8 & (1 << (i * 2 + 1)))
+			/* set underflow */
+			vector_xyz->yas537_vector_xyz[i] += 2;
+	}
+	if (v_busy_u8)
+		return ERROR;
+	switch (yas537_data.measure_state) {
+	case YAS537_MAG_STATE_INIT_COIL:
+		if (p_bmi160->mag_manual_enable != BMI160_MANUAL_ENABLE)
+			com_rslt = bmi160_set_mag_manual_enable(
+			BMI160_MANUAL_ENABLE);
+		com_rslt += bmi160_set_mag_write_data(YAS537_WRITE_CONFR);
+		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		com_rslt += bmi160_set_mag_write_addr(YAS537_REG_CONFR);
+		p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+		yas537_data.measure_state = YAS537_MAG_STATE_RECORD_DATA;
+		if (p_bmi160->mag_manual_enable == BMI160_MANUAL_ENABLE)
+			com_rslt = bmi160_set_mag_manual_enable(
+			BMI160_MANUAL_DISABLE);
+	break;
+	case YAS537_MAG_STATE_RECORD_DATA:
+		if (v_rcoil_u8)
+			break;
+		yas537_set_vector(yas537_data.last_after_rcoil, a_xy1y2_u16);
+		yas537_data.measure_state = YAS537_MAG_STATE_NORMAL;
+	break;
+	case YAS537_MAG_STATE_NORMAL:
+		if (BMI160_INIT_VALUE < v_ouflow_u8
+		|| invalid_magnetic_field(a_xy1y2_u16,
+		yas537_data.last_after_rcoil)) {
+			yas537_data.measure_state = YAS537_MAG_STATE_INIT_COIL;
+			for (i = 0; i < 3; i++) {
+				if (!*v_ouflow_u8)
+					vector_xyz->yas537_vector_xyz[i] += 3;
+			}
+		}
+	break;
+	}
+
+	return com_rslt;
+}
+/*!
+ *	@brief This function used for reading
+ *	bmi160_t structure
+ *
+ *  @return the reference and values of bmi160_t
+ *
+ *
+*/
+struct bmi160_t *bmi160_get_ptr(void)
+{
+	return  p_bmi160;
+}
diff --git a/drivers/input/sensors/bmi160/bmi160.h b/drivers/input/sensors/bmi160/bmi160.h
new file mode 100644
index 0000000..bc94a35
--- /dev/null
+++ b/drivers/input/sensors/bmi160/bmi160.h
@@ -0,0 +1,11814 @@
+/*
+****************************************************************************
+* Copyright (C) 2014 Bosch Sensortec GmbH
+*
+* bmi160.h
+* Date : 2015/04/02
+* @id       836294d
+* Revision : 2.0.9 $
+* @brief
+* The head file of BMI160API
+*
+****************************************************************************
+*
+* \section Disclaimer
+*
+* Common:
+* Bosch Sensortec products are developed for the consumer goods industry.
+* They may only be used within the parameters of the respective valid
+* product data sheet.  Bosch Sensortec products are provided with the
+* express understanding that there is no warranty of fitness for a
+* particular purpose.They are not fit for use in life-sustaining,
+* safety or security sensitive systems or any system or device
+* that may lead to bodily harm or property damage if the system
+* or device malfunctions. In addition,Bosch Sensortec products are
+* not fit for use in products which interact with motor vehicle systems.
+* The resale and or use of products are at the purchasers own risk and
+* his own responsibility. The examination of fitness for the intended use
+* is the sole responsibility of the Purchaser.
+*
+* The purchaser shall indemnify Bosch Sensortec from all third party
+* claims, including any claims for incidental, or consequential damages,
+* arising from any product use not covered by the parameters of
+* the respective valid product data sheet or not approved by
+* Bosch Sensortec and reimburse Bosch Sensortec for all costs in
+* connection with such claims.
+*
+* The purchaser must monitor the market for the purchased products,
+* particularly with regard to product safety and inform Bosch Sensortec
+* without delay of all security relevant incidents.
+*
+* Engineering Samples are marked with an asterisk (*) or (e).
+* Samples may vary from the valid technical specifications of the product
+* series. They are therefore not intended or fit for resale to third
+* parties or for use in end products. Their sole purpose is internal
+* client testing. The testing of an engineering sample may in no way
+* replace the testing of a product series. Bosch Sensortec assumes
+* no liability for the use of engineering samples.
+* By accepting the engineering samples, the Purchaser agrees to indemnify
+* Bosch Sensortec from all claims arising from the use of engineering
+* samples.
+*
+* Special:
+* This software module (hereinafter called "Software") and any information
+* on application-sheets (hereinafter called "Information") is provided
+* free of charge for the sole purpose to support your application work.
+* The Software and Information is subject to the following
+* terms and conditions:
+*
+* The Software is specifically designed for the exclusive use for
+* Bosch Sensortec products by personnel who have special experience
+* and training. Do not use this Software if you do not have the
+* proper experience or training.
+*
+* This Software package is provided `` as is `` and without any expressed
+* or implied warranties,including without limitation, the implied warranties
+* of merchantability and fitness for a particular purpose.
+*
+* Bosch Sensortec and their representatives and agents deny any liability
+* for the functional impairment
+* of this Software in terms of fitness, performance and safety.
+* Bosch Sensortec and their representatives and agents shall not be liable
+* for any direct or indirect damages or injury, except as
+* otherwise stipulated in mandatory applicable law.
+*
+* The Information provided is believed to be accurate and reliable.
+* Bosch Sensortec assumes no responsibility for the consequences of use
+* of such Information nor for any infringement of patents or
+* other rights of third parties which may result from its use.
+* No license is granted by implication or otherwise under any patent or
+* patent rights of Bosch. Specifications mentioned in the Information are
+* subject to change without notice.
+**************************************************************************/
+/*! \file bmi160.h
+    \brief BMI160 Sensor Driver Support Header File */
+/* user defined code to be added here ... */
+#ifndef __BMI160_H__
+#define __BMI160_H__
+
+/*!
+* @brief The following definition uses for define the data types
+*
+* @note While porting the API please consider the following
+* @note Please check the version of C standard
+* @note Are you using Linux platform
+*/
+
+/*!
+* @brief For the Linux platform support
+* Please use the types.h for your data types definitions
+*/
+#ifdef	__KERNEL__
+
+#include <linux/types.h>
+
+#else /* ! __KERNEL__ */
+/**********************************************************
+* These definition uses for define the C
+* standard version data types
+***********************************************************/
+# if !defined(__STDC_VERSION__)
+
+/************************************************
+ * compiler is C11 C standard
+************************************************/
+#if (__STDC_VERSION__ == 201112L)
+
+/************************************************/
+#include <stdint.h>
+/************************************************/
+
+/*unsigned integer types*/
+#define	u8	uint8_t
+#define	u16	uint16_t
+#define	u32	uint32_t
+#define	u64	uint64_t
+
+/*signed integer types*/
+#define	s8	int8_t
+#define	s16	int16_t
+#define	s32	int32_t
+#define	s64	int64_t
+/************************************************
+ * compiler is C99 C standard
+************************************************/
+
+#elif (__STDC_VERSION__ == 199901L)
+
+/* stdint.h is a C99 supported c library.
+which is used to fixed the integer size*/
+/************************************************/
+#include <stdint.h>
+/************************************************/
+
+/*unsigned integer types*/
+#define	u8	uint8_t
+#define	u16	uint16_t
+#define	u32	uint32_t
+#define	u64	uint64_t
+
+/*signed integer types*/
+#define s8	int8_t
+#define	s16	int16_t
+#define	s32	int32_t
+#define	s64	int64_t
+/************************************************
+ * compiler is C89 or other C standard
+************************************************/
+#else /*  !defined(__STDC_VERSION__) */
+/*	By default it is defined as 32 bit machine configuration*/
+/*	define the definition based on your machine configuration*/
+/*	define the data types based on your
+	machine/compiler/controller configuration*/
+#define  MACHINE_32_BIT
+
+/* If your machine support 16 bit
+define the MACHINE_16_BIT*/
+#ifdef MACHINE_16_BIT
+#include <limits.h>
+/*signed integer types*/
+#define	s8	signed char
+#define	s16	signed short int
+#define	s32	signed long int
+
+#if defined(LONG_MAX) && LONG_MAX == 0x7fffffffffffffffL
+#define s64 long int
+#define u64 unsigned long int
+#elif defined(LLONG_MAX) && (LLONG_MAX == 0x7fffffffffffffffLL)
+#define s64 long long int
+#define u64 unsigned long long int
+#else
+#warning Either the correct data type for signed 64 bit integer \
+could not be found, or 64 bit integers are not supported in your environment.
+#warning If 64 bit integers are supported on your platform, \
+please set s64 manually.
+#endif
+
+/*unsigned integer types*/
+#define	u8	unsigned char
+#define	u16	unsigned short int
+#define	u32	unsigned long int
+
+/* If your machine support 32 bit
+define the MACHINE_32_BIT*/
+#elif defined MACHINE_32_BIT
+/*signed integer types*/
+#define	s8	signed char
+#define	s16	signed short int
+#define	s32	signed int
+#define	s64	signed long long int
+
+/*unsigned integer types*/
+#define	u8	unsigned char
+#define	u16	unsigned short int
+#define	u32	unsigned int
+#define	u64	unsigned long long int
+
+/* If your machine support 64 bit
+define the MACHINE_64_BIT*/
+#elif defined MACHINE_64_BIT
+/*signed integer types*/
+#define	s8	signed char
+#define	s16	signed short int
+#define	s32	signed int
+#define	s64	signed long int
+
+/*unsigned integer types*/
+#define	u8	unsigned char
+#define	u16	unsigned short int
+#define	u32	unsigned int
+#define	u64	unsigned long int
+
+#else
+#warning The data types defined above which not supported \
+define the data types manually
+#endif
+#endif
+
+/*** This else will execute for the compilers
+ *	which are not supported the C standards
+ *	Like C89/C99/C11***/
+#else
+/*	By default it is defined as 32 bit machine configuration*/
+/*	define the definition based on your machine configuration*/
+/*	define the data types based on your
+	machine/compiler/controller configuration*/
+#define  MACHINE_32_BIT
+
+/* If your machine support 16 bit
+define the MACHINE_16_BIT*/
+#ifdef MACHINE_16_BIT
+#include <limits.h>
+/*signed integer types*/
+#define	s8	signed char
+#define	s16	signed short int
+#define	s32	signed long int
+
+#if defined(LONG_MAX) && LONG_MAX == 0x7fffffffffffffffL
+#define s64 long int
+#define u64 unsigned long int
+#elif defined(LLONG_MAX) && (LLONG_MAX == 0x7fffffffffffffffLL)
+#define s64 long long int
+#define u64 unsigned long long int
+#else
+#warning Either the correct data type for signed 64 bit integer \
+could not be found, or 64 bit integers are not supported in your environment.
+#warning If 64 bit integers are supported on your platform, \
+please set s64 manually.
+#endif
+
+/*unsigned integer types*/
+#define	u8	unsigned char
+#define	u16	unsigned short int
+#define	u32	unsigned long int
+
+/* If your machine support 32 bit
+define the MACHINE_32_BIT*/
+#elif defined MACHINE_32_BIT
+/*signed integer types*/
+#define	s8	signed char
+#define	s16	signed short int
+#define	s32	signed int
+#define	s64	signed long long int
+
+/*unsigned integer types*/
+#define	u8	unsigned char
+#define	u16	unsigned short int
+#define	u32	unsigned int
+#define	u64	unsigned long long int
+
+/* If your machine support 64 bit
+define the MACHINE_64_BIT*/
+#elif defined  MACHINE_64_BIT
+/*signed integer types*/
+#define	s8	signed char
+#define	s16	signed short int
+#define	s32	signed int
+#define	s64	signed long int
+
+/*unsigned integer types*/
+#define	u8	unsigned char
+#define	u16	unsigned short int
+#define	u32	unsigned int
+#define	u64	unsigned long int
+
+#else
+#warning The data types defined above which not supported \
+define the data types manually
+#endif
+#endif
+#endif
+/***************************************************************/
+/**\name	BUS READ AND WRITE FUNCTION POINTERS        */
+/***************************************************************/
+/*!
+	@brief Define the calling convention of YOUR bus communication routine.
+	@note This includes types of parameters. This example shows the
+	configuration for an SPI bus link.
+
+    If your communication function looks like this:
+
+    write_my_bus_xy(u8 device_addr, u8 register_addr,
+    u8 * data, u8 length);
+
+    The BMI160_WR_FUNC_PTR would equal:
+
+    BMI160_WR_FUNC_PTR s8 (* bus_write)(u8,
+    u8, u8 *, u8)
+
+    Parameters can be mixed as needed refer to the
+    @ref BMI160_BUS_WRITE_FUNC  macro.
+
+
+*/
+#define BMI160_WR_FUNC_PTR s8 (*bus_write)(u8, u8,\
+u8 *, u8)
+/**< link macro between API function calls and bus write function
+	@note The bus write function can change since this is a
+	system dependant issue.
+
+    If the bus_write parameter calling order is like: reg_addr,
+    reg_data, wr_len it would be as it is here.
+
+    If the parameters are differently ordered or your communication
+    function like I2C need to know the device address,
+    you can change this macro accordingly.
+
+
+    BMI160_BUS_WRITE_FUNC(dev_addr, reg_addr, reg_data, wr_len)\
+    bus_write(dev_addr, reg_addr, reg_data, wr_len)
+
+    This macro lets all API functions call YOUR communication routine in a
+    way that equals your definition in the
+    @ref BMI160_WR_FUNC_PTR definition.
+
+*/
+#define BMI160_BUS_WRITE_FUNC(dev_addr, reg_addr, reg_data, wr_len)\
+				bus_write(dev_addr, reg_addr, reg_data, wr_len)
+
+/**< Define the calling convention of YOUR bus communication routine.
+	@note This includes types of parameters. This example shows the
+	configuration for an SPI bus link.
+
+    If your communication function looks like this:
+
+    read_my_bus_xy(u8 device_addr, u8 register_addr,
+    u8 * data, u8 length);
+
+    The BMI160_RD_FUNC_PTR would equal:
+
+    BMI160_RD_FUNC_PTR s8 (* bus_read)(u8,
+    u8, u8 *, u8)
+
+    Parameters can be mixed as needed refer to the
+    refer BMI160_BUS_READ_FUNC  macro.
+
+*/
+#define BMI160_SPI_RD_MASK (0x80)   /* for spi read transactions on SPI the
+			MSB has to be set */
+#define BMI160_RD_FUNC_PTR s8 (*bus_read)(u8,\
+			u8, u8 *, u8)
+
+#define BMI160_BRD_FUNC_PTR s8 \
+(*burst_read)(u8, u8, u8 *, u32)
+
+/**< link macro between API function calls and bus read function
+	@note The bus write function can change since this is a
+	system dependant issue.
+
+    If the bus_read parameter calling order is like: reg_addr,
+    reg_data, wr_len it would be as it is here.
+
+    If the parameters are differently ordered or your communication
+    function like I2C need to know the device address,
+    you can change this macro accordingly.
+
+
+    BMI160_BUS_READ_FUNC(dev_addr, reg_addr, reg_data, wr_len)\
+    bus_read(dev_addr, reg_addr, reg_data, wr_len)
+
+    This macro lets all API functions call YOUR communication routine in a
+    way that equals your definition in the
+    refer BMI160_WR_FUNC_PTR definition.
+
+    @note: this macro also includes the "MSB='1'
+    for reading BMI160 addresses.
+
+*/
+#define BMI160_BUS_READ_FUNC(dev_addr, reg_addr, reg_data, r_len)\
+				bus_read(dev_addr, reg_addr, reg_data, r_len)
+
+#define BMI160_BURST_READ_FUNC(device_addr, \
+register_addr, register_data, rd_len)\
+burst_read(device_addr, register_addr, register_data, rd_len)
+
+
+#define BMI160_MDELAY_DATA_TYPE                 u32
+
+/***************************************************************/
+/**\name	BUS READ AND WRITE FUNCTION POINTERS        */
+/***************************************************************/
+#define BMI160_I2C_ADDR1	0x68 /**< I2C Address needs to be changed */
+#define BMI160_I2C_ADDR2    0x69 /**< I2C Address needs to be changed */
+#define BMI160_AUX_BMM150_I2C_ADDRESS       (0x10)
+#define BMI160_AUX_YAS532_I2C_ADDRESS       (0x2E)
+/**< I2C address of YAS532*/
+#define BMI160_AKM09911_I2C_ADDRESS   0x0C/**< I2C address of AKM09911*/
+/**< I2C address of AKM09911*/
+#define	BMI160_AUX_AKM09911_I2C_ADDR_2		(0x0D)
+/**< I2C address of AKM09911*/
+#define	BMI160_AUX_AKM09912_I2C_ADDR_1		(0x0C)
+/**< I2C address of AKM09912*/
+#define	BMI160_AUX_AKM09912_I2C_ADDR_2		(0x0D)
+/**< I2C address of AKM09912*/
+#define	BMI160_AUX_AKM09912_I2C_ADDR_3		(0x0E)
+/**< I2C address of AKM09912*/
+#define BMI160_AKM09912_I2C_ADDRESS   0x0F/**< I2C address of akm09912*/
+
+#define BMI160_YAS532_I2C_ADDRESS	0x2E/**< I2C address of YAS532*/
+/*******************************************/
+/**\name	CONSTANTS        */
+/******************************************/
+#define  BMI160_INIT_VALUE					(0)
+#define  BMI160_GEN_READ_WRITE_DATA_LENGTH	(1)
+#define  BMI160_MAXIMUM_TIMEOUT             (10)
+/* output data rate condition check*/
+#define  BMI160_OUTPUT_DATA_RATE0	(0)
+#define  BMI160_OUTPUT_DATA_RATE1	(1)
+#define  BMI160_OUTPUT_DATA_RATE2	(2)
+#define  BMI160_OUTPUT_DATA_RATE3	(3)
+#define  BMI160_OUTPUT_DATA_RATE4	(4)
+#define  BMI160_OUTPUT_DATA_RATE5	(5)
+#define  BMI160_OUTPUT_DATA_RATE6	(14)
+#define  BMI160_OUTPUT_DATA_RATE7	(15)
+/* accel range check*/
+#define BMI160_ACCEL_RANGE0  (3)
+#define BMI160_ACCEL_RANGE1  (5)
+#define BMI160_ACCEL_RANGE3  (8)
+#define BMI160_ACCEL_RANGE4  (12)
+/* check the status of registers*/
+#define  BMI160_FOC_STAT_HIGH			(1)
+#define  BMI160_SIG_MOTION_STAT_HIGH	(1)
+#define  BMI160_STEP_DET_STAT_HIGH		(1)
+
+/*condition check for reading and writing data*/
+#define	BMI160_MAX_VALUE_SIGNIFICANT_MOTION      (1)
+#define	BMI160_MAX_VALUE_FIFO_FILTER    (1)
+#define	BMI160_MAX_VALUE_FIFO_TIME      (1)
+#define	BMI160_MAX_VALUE_FIFO_INTR      (1)
+#define	BMI160_MAX_VALUE_FIFO_HEADER    (1)
+#define	BMI160_MAX_VALUE_FIFO_MAG       (1)
+#define	BMI160_MAX_VALUE_FIFO_ACCEL     (1)
+#define	BMI160_MAX_VALUE_FIFO_GYRO      (1)
+#define	BMI160_MAX_VALUE_SOURCE_INTR    (1)
+#define	BMI160_MAX_VALUE_LOW_G_MODE     (1)
+#define	BMI160_MAX_VALUE_NO_MOTION      (1)
+#define	BMI160_MAX_VALUE_TAP_SHOCK      (1)
+#define	BMI160_MAX_VALUE_TAP_QUIET      (1)
+#define	BMI160_MAX_VALUE_ORIENT_UD      (1)
+#define	BMI160_MAX_VALUE_ORIENT_AXES    (1)
+#define	BMI160_MAX_VALUE_NVM_PROG       (1)
+#define	BMI160_MAX_VALUE_SPI3           (1)
+#define	BMI160_MAX_VALUE_PAGE           (1)
+#define	BMI160_MAX_VALUE_I2C_WDT        (1)
+#define	BMI160_MAX_VALUE_SLEEP_STATE    (1)
+#define	BMI160_MAX_VALUE_WAKEUP_INTR    (1)
+#define	BMI160_MAX_VALUE_SELFTEST_SIGN  (1)
+#define	BMI160_MAX_VALUE_SELFTEST_AMP   (1)
+#define	BMI160_MAX_VALUE_SELFTEST_START (1)
+#define BMI160_MAX_GYRO_WAKEUP_TRIGGER		(3)
+#define BMI160_MAX_ACCEL_SELFTEST_AXIS	    (3)
+#define BMI160_MAX_GYRO_STEP_COUNTER        (1)
+#define BMI160_MAX_GYRO_BW                  (3)
+#define BMI160_MAX_ACCEL_BW                 (7)
+#define BMI160_MAX_ORIENT_MODE              (3)
+#define BMI160_MAX_ORIENT_BLOCKING          (3)
+#define BMI160_MAX_FLAT_HOLD                (3)
+#define BMI160_MAX_ACCEL_FOC                (3)
+#define BMI160_MAX_IF_MODE                  (3)
+#define BMI160_MAX_TARGET_PAGE              (3)
+#define BMI160_MAX_GYRO_RANGE               (4)
+#define BMI160_MAX_GYRO_SLEEP_TIGGER        (7)
+#define BMI160_MAX_TAP_TURN                 (7)
+#define BMI160_MAX_UNDER_SAMPLING           (1)
+#define BMI160_MAX_UNDER_SIG_MOTION         (3)
+#define BMI160_MAX_ACCEL_OUTPUT_DATA_RATE   (12)
+#define BMI160_MAX_LATCH_INTR               (15)
+#define BMI160_MAX_FLAT_HYST                (15)
+#define BMI160_MAX_ORIENT_THETA             (63)
+#define BMI160_MAX_FLAT_THETA               (63)
+
+/* FIFO index definitions*/
+#define BMI160_FIFO_X_LSB_DATA			(0)
+#define BMI160_FIFO_X_MSB_DATA			(1)
+#define BMI160_FIFO_Y_LSB_DATA			(2)
+#define BMI160_FIFO_Y_MSB_DATA			(3)
+#define BMI160_FIFO_Z_LSB_DATA			(4)
+#define BMI160_FIFO_Z_MSB_DATA			(5)
+#define BMI160_FIFO_R_LSB_DATA			(6)
+#define BMI160_FIFO_R_MSB_DATA			(7)
+/* FIFO gyro definition*/
+#define BMI160_GA_FIFO_G_X_LSB		(0)
+#define BMI160_GA_FIFO_G_X_MSB		(1)
+#define BMI160_GA_FIFO_G_Y_LSB		(2)
+#define BMI160_GA_FIFO_G_Y_MSB		(3)
+#define BMI160_GA_FIFO_G_Z_LSB		(4)
+#define BMI160_GA_FIFO_G_Z_MSB		(5)
+#define BMI160_GA_FIFO_A_X_LSB		(6)
+#define BMI160_GA_FIFO_A_X_MSB		(7)
+#define BMI160_GA_FIFO_A_Y_LSB		(8)
+#define BMI160_GA_FIFO_A_Y_MSB		(9)
+#define BMI160_GA_FIFO_A_Z_LSB		(10)
+#define BMI160_GA_FIFO_A_Z_MSB		(11)
+/* FIFO mag/gyro/accel definition*/
+#define BMI160_MGA_FIFO_M_X_LSB		(0)
+#define BMI160_MGA_FIFO_M_X_MSB		(1)
+#define BMI160_MGA_FIFO_M_Y_LSB		(2)
+#define BMI160_MGA_FIFO_M_Y_MSB		(3)
+#define BMI160_MGA_FIFO_M_Z_LSB		(4)
+#define BMI160_MGA_FIFO_M_Z_MSB		(5)
+#define BMI160_MGA_FIFO_M_R_LSB		(6)
+#define BMI160_MGA_FIFO_M_R_MSB		(7)
+#define BMI160_MGA_FIFO_G_X_LSB		(8)
+#define BMI160_MGA_FIFO_G_X_MSB		(9)
+#define BMI160_MGA_FIFO_G_Y_LSB		(10)
+#define BMI160_MGA_FIFO_G_Y_MSB		(11)
+#define BMI160_MGA_FIFO_G_Z_LSB		(12)
+#define BMI160_MGA_FIFO_G_Z_MSB		(13)
+#define BMI160_MGA_FIFO_A_X_LSB		(14)
+#define BMI160_MGA_FIFO_A_X_MSB		(15)
+#define BMI160_MGA_FIFO_A_Y_LSB		(16)
+#define BMI160_MGA_FIFO_A_Y_MSB		(17)
+#define BMI160_MGA_FIFO_A_Z_LSB		(18)
+#define BMI160_MGA_FIFO_A_Z_MSB		(19)
+/* FIFO mag definition*/
+#define BMI160_MA_FIFO_M_X_LSB		(0)
+#define BMI160_MA_FIFO_M_X_MSB		(1)
+#define BMI160_MA_FIFO_M_Y_LSB		(2)
+#define BMI160_MA_FIFO_M_Y_MSB		(3)
+#define BMI160_MA_FIFO_M_Z_LSB		(4)
+#define BMI160_MA_FIFO_M_Z_MSB		(5)
+#define BMI160_MA_FIFO_M_R_LSB		(6)
+#define BMI160_MA_FIFO_M_R_MSB		(7)
+#define BMI160_MA_FIFO_A_X_LSB		(8)
+#define BMI160_MA_FIFO_A_X_MSB		(9)
+#define BMI160_MA_FIFO_A_Y_LSB		(10)
+#define BMI160_MA_FIFO_A_Y_MSB		(11)
+#define BMI160_MA_FIFO_A_Z_LSB		(12)
+#define BMI160_MA_FIFO_A_Z_MSB		(13)
+/* FIFO mag/gyro definition*/
+#define BMI160_MG_FIFO_M_X_LSB		(0)
+#define BMI160_MG_FIFO_M_X_MSB		(1)
+#define BMI160_MG_FIFO_M_Y_LSB		(2)
+#define BMI160_MG_FIFO_M_Y_MSB		(3)
+#define BMI160_MG_FIFO_M_Z_LSB		(4)
+#define BMI160_MG_FIFO_M_Z_MSB		(5)
+#define BMI160_MG_FIFO_M_R_LSB		(6)
+#define BMI160_MG_FIFO_M_R_MSB		(7)
+#define BMI160_MG_FIFO_G_X_LSB		(8)
+#define BMI160_MG_FIFO_G_X_MSB		(9)
+#define BMI160_MG_FIFO_G_Y_LSB		(10)
+#define BMI160_MG_FIFO_G_Y_MSB		(11)
+#define BMI160_MG_FIFO_G_Z_LSB		(12)
+#define BMI160_MG_FIFO_G_Z_MSB		(13)
+/* FIFO length definitions*/
+#define BMI160_FIFO_SENSOR_TIME_LSB     (0)
+#define BMI160_FIFO_SENSOR_TIME_XLSB    (1)
+#define BMI160_FIFO_SENSOR_TIME_MSB     (2)
+#define BMI160_FIFO_SENSOR_TIME_LENGTH  (3)
+#define BMI160_FIFO_A_LENGTH            (6)
+#define BMI160_FIFO_G_LENGTH            (6)
+#define BMI160_FIFO_M_LENGTH            (8)
+#define BMI160_FIFO_AG_LENGTH           (12)
+#define BMI160_FIFO_AMG_LENGTH          (20)
+#define BMI160_FIFO_MA_OR_MG_LENGTH     (14)
+
+/* bus read and write length for mag, accel and gyro*/
+#define BMI160_MAG_X_DATA_LENGTH     (2)
+#define BMI160_MAG_Y_DATA_LENGTH     (2)
+#define BMI160_MAG_Z_DATA_LENGTH     (2)
+#define BMI160_MAG_R_DATA_LENGTH     (2)
+#define BMI160_MAG_XYZ_DATA_LENGTH	 (6)
+#define BMI160_MAG_XYZR_DATA_LENGTH	 (8)
+#define BMI160_MAG_YAS_DATA_LENGTH	 (8)
+#define BMI160_GYRO_DATA_LENGTH		 (2)
+#define BMI160_GYRO_XYZ_DATA_LENGTH	 (6)
+#define BMI160_ACCEL_DATA_LENGTH	 (2)
+#define BMI160_ACCEL_XYZ_DATA_LENGTH (6)
+#define BMI160_TEMP_DATA_LENGTH		 (2)
+#define BMI160_FIFO_DATA_LENGTH		 (2)
+#define BMI160_STEP_COUNTER_LENGTH	 (2)
+#define BMI160_SENSOR_TIME_LENGTH	 (3)
+
+/* Delay definitions*/
+#define BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY    (5)
+#define BMI160_BMM150_WAKEUP_DELAY1                  (2)
+#define BMI160_BMM150_WAKEUP_DELAY2                  (3)
+#define BMI160_BMM150_WAKEUP_DELAY3                  (1)
+#define BMI160_YAS532_OFFSET_DELAY                   (2)
+#define BMI160_GEN_READ_WRITE_DELAY                  (1)
+#define BMI160_YAS532_MEASUREMENT_DELAY              (25)
+#define BMI160_YAS_ACQ_COMMAND_DELAY                 (50)
+#define BMI160_YAS532_SET_INITIAL_VALUE_DELAY        (200)
+#define BMI160_AKM_INIT_DELAY                        (60)
+/****************************************************/
+/**\name	ARRAY SIZE DEFINITIONS      */
+/***************************************************/
+#define	BMI160_ACCEL_X_DATA_SIZE   (2)
+#define	BMI160_ACCEL_Y_DATA_SIZE   (2)
+#define	BMI160_ACCEL_Z_DATA_SIZE   (2)
+#define	BMI160_ACCEL_XYZ_DATA_SIZE (6)
+
+#define	BMI160_GYRO_X_DATA_SIZE    (2)
+#define	BMI160_GYRO_Y_DATA_SIZE    (2)
+#define	BMI160_GYRO_Z_DATA_SIZE    (2)
+#define	BMI160_GYRO_XYZ_DATA_SIZE  (6)
+
+#define	BMI160_MAG_X_DATA_SIZE      (2)
+#define	BMI160_MAG_Y_DATA_SIZE      (2)
+#define	BMI160_MAG_Z_DATA_SIZE      (2)
+#define	BMI160_MAG_R_DATA_SIZE      (2)
+#define	BMI160_MAG_XYZ_DATA_SIZE    (6)
+#define	BMI160_MAG_XYZR_DATA_SIZE   (8)
+#define	BMI160_MAG_TRIM_DATA_SIZE   (16)
+
+
+#define	BMI160_TEMP_DATA_SIZE       (2)
+#define	BMI160_FIFO_DATA_SIZE       (2)
+#define	BMI160_STEP_COUNT_DATA_SIZE (2)
+
+#define	BMI160_SENSOR_TIME_DATA_SIZE      (3)
+#define	BMI160_AKM_SENSITIVITY_DATA_SIZE  (3)
+#define	BMI160_HARD_OFFSET_DATA_SIZE      (3)
+#define	BMI160_YAS_XY1Y2_DATA_SIZE        (3)
+#define	BMI160_YAS_FLAG_DATA_SIZE         (3)
+#define	BMI160_YAS_TEMP_DATA_SIZE         (3)
+#define	BMI160_YAS_H_DATA_SIZE            (3)
+#define	BMI160_YAS_S_DATA_SIZE            (3)
+#define BMI160_YAS_CORRECT_DATA_SIZE      (5)
+#define BMI160_YAS_XY1Y2T_DATA_SIZE       (8)
+#define BMI160_YAS537_CALIB_DATA_SIZE     (17)
+#define BMI160_YAS532_CALIB_DATA_SIZE     (14)
+/****************************************************/
+/**\name	ARRAY PARAMETER DEFINITIONS      */
+/***************************************************/
+#define BMI160_SENSOR_TIME_MSB_BYTE   (2)
+#define BMI160_SENSOR_TIME_XLSB_BYTE  (1)
+#define BMI160_SENSOR_TIME_LSB_BYTE   (0)
+
+#define BMI160_MAG_X_LSB_BYTE	          (0)
+#define BMI160_MAG_X_MSB_BYTE              (1)
+#define BMI160_MAG_Y_LSB_BYTE	           (0)
+#define BMI160_MAG_Y_MSB_BYTE              (1)
+#define BMI160_MAG_Z_LSB_BYTE	           (0)
+#define BMI160_MAG_Z_MSB_BYTE              (1)
+#define BMI160_MAG_R_LSB_BYTE	           (0)
+#define BMI160_MAG_R_MSB_BYTE              (1)
+#define BMI160_DATA_FRAME_MAG_X_LSB_BYTE   (0)
+#define BMI160_DATA_FRAME_MAG_X_MSB_BYTE   (1)
+#define BMI160_DATA_FRAME_MAG_Y_LSB_BYTE   (2)
+#define BMI160_DATA_FRAME_MAG_Y_MSB_BYTE   (3)
+#define BMI160_DATA_FRAME_MAG_Z_LSB_BYTE   (4)
+#define BMI160_DATA_FRAME_MAG_Z_MSB_BYTE   (5)
+#define BMI160_DATA_FRAME_MAG_R_LSB_BYTE   (6)
+#define BMI160_DATA_FRAME_MAG_R_MSB_BYTE   (7)
+
+#define BMI160_GYRO_X_LSB_BYTE              (0)
+#define BMI160_GYRO_X_MSB_BYTE              (1)
+#define BMI160_GYRO_Y_LSB_BYTE              (0)
+#define BMI160_GYRO_Y_MSB_BYTE              (1)
+#define BMI160_GYRO_Z_LSB_BYTE              (0)
+#define BMI160_GYRO_Z_MSB_BYTE              (1)
+#define BMI160_DATA_FRAME_GYRO_X_LSB_BYTE   (0)
+#define BMI160_DATA_FRAME_GYRO_X_MSB_BYTE   (1)
+#define BMI160_DATA_FRAME_GYRO_Y_LSB_BYTE   (2)
+#define BMI160_DATA_FRAME_GYRO_Y_MSB_BYTE   (3)
+#define BMI160_DATA_FRAME_GYRO_Z_LSB_BYTE   (4)
+#define BMI160_DATA_FRAME_GYRO_Z_MSB_BYTE   (5)
+
+#define BMI160_ACCEL_X_LSB_BYTE              (0)
+#define BMI160_ACCEL_X_MSB_BYTE              (1)
+#define BMI160_ACCEL_Y_LSB_BYTE              (0)
+#define BMI160_ACCEL_Y_MSB_BYTE              (1)
+#define BMI160_ACCEL_Z_LSB_BYTE              (0)
+#define BMI160_ACCEL_Z_MSB_BYTE              (1)
+#define BMI160_DATA_FRAME_ACCEL_X_LSB_BYTE   (0)
+#define BMI160_DATA_FRAME_ACCEL_X_MSB_BYTE   (1)
+#define BMI160_DATA_FRAME_ACCEL_Y_LSB_BYTE   (2)
+#define BMI160_DATA_FRAME_ACCEL_Y_MSB_BYTE   (3)
+#define BMI160_DATA_FRAME_ACCEL_Z_LSB_BYTE   (4)
+#define BMI160_DATA_FRAME_ACCEL_Z_MSB_BYTE   (5)
+
+#define	BMI160_TEMP_LSB_BYTE    (0)
+#define	BMI160_TEMP_MSB_BYTE    (1)
+
+#define	BMI160_FIFO_LENGTH_LSB_BYTE    (0)
+#define	BMI160_FIFO_LENGTH_MSB_BYTE    (1)
+
+#define	BMI160_STEP_COUNT_LSB_BYTE    (0)
+#define	BMI160_STEP_COUNT_MSB_BYTE    (1)
+/****************************************************/
+/**\name	ERROR CODES       */
+/***************************************************/
+
+#define E_BMI160_NULL_PTR			((s8)-127)
+#define E_BMI160_COMM_RES			((s8)-1)
+#define E_BMI160_OUT_OF_RANGE		((s8)-2)
+#define E_BMI160_BUSY				((s8)-3)
+#define	SUCCESS						((u8)0)
+#define	ERROR						((s8)-1)
+
+/* Constants */
+#define BMI160_NULL						(0)
+#define BMI160_DELAY_SETTLING_TIME		(5)
+/*This refers BMI160 return type as s8 */
+#define BMI160_RETURN_FUNCTION_TYPE        s8
+/****************************************************/
+/**\name	REGISTER DEFINITIONS       */
+/***************************************************/
+/*******************/
+/**\name CHIP ID */
+/*******************/
+#define BMI160_USER_CHIP_ID_ADDR				(0x00)
+/*******************/
+/**\name ERROR STATUS */
+/*******************/
+#define BMI160_USER_ERROR_ADDR					(0X02)
+/*******************/
+/**\name POWER MODE STATUS */
+/*******************/
+#define BMI160_USER_PMU_STAT_ADDR				(0X03)
+/*******************/
+/**\name MAG DATA REGISTERS */
+/*******************/
+#define BMI160_USER_DATA_0_ADDR					(0X04)
+#define BMI160_USER_DATA_1_ADDR					(0X05)
+#define BMI160_USER_DATA_2_ADDR					(0X06)
+#define BMI160_USER_DATA_3_ADDR					(0X07)
+#define BMI160_USER_DATA_4_ADDR					(0X08)
+#define BMI160_USER_DATA_5_ADDR					(0X09)
+#define BMI160_USER_DATA_6_ADDR					(0X0A)
+#define BMI160_USER_DATA_7_ADDR					(0X0B)
+/*******************/
+/**\name GYRO DATA REGISTERS */
+/*******************/
+#define BMI160_USER_DATA_8_ADDR					(0X0C)
+#define BMI160_USER_DATA_9_ADDR					(0X0D)
+#define BMI160_USER_DATA_10_ADDR				(0X0E)
+#define BMI160_USER_DATA_11_ADDR				(0X0F)
+#define BMI160_USER_DATA_12_ADDR				(0X10)
+#define BMI160_USER_DATA_13_ADDR				(0X11)
+#define BMI160_USER_DATA_14_ADDR				(0X12)
+#define BMI160_USER_DATA_15_ADDR				(0X13)
+/*******************/
+/**\name ACCEL DATA REGISTERS */
+/*******************/
+#define BMI160_USER_DATA_16_ADDR				(0X14)
+#define BMI160_USER_DATA_17_ADDR				(0X15)
+#define BMI160_USER_DATA_18_ADDR				(0X16)
+#define BMI160_USER_DATA_19_ADDR				(0X17)
+/*******************/
+/**\name SENSOR TIME REGISTERS */
+/*******************/
+#define BMI160_USER_SENSORTIME_0_ADDR			(0X18)
+#define BMI160_USER_SENSORTIME_1_ADDR			(0X19)
+#define BMI160_USER_SENSORTIME_2_ADDR			(0X1A)
+/*******************/
+/**\name STATUS REGISTER FOR SENSOR STATUS FLAG */
+/*******************/
+#define BMI160_USER_STAT_ADDR					(0X1B)
+/*******************/
+/**\name INTERRUPY STATUS REGISTERS */
+/*******************/
+#define BMI160_USER_INTR_STAT_0_ADDR			(0X1C)
+#define BMI160_USER_INTR_STAT_1_ADDR			(0X1D)
+#define BMI160_USER_INTR_STAT_2_ADDR			(0X1E)
+#define BMI160_USER_INTR_STAT_3_ADDR			(0X1F)
+/*******************/
+/**\name TEMPERATURE REGISTERS */
+/*******************/
+#define BMI160_USER_TEMPERATURE_0_ADDR			(0X20)
+#define BMI160_USER_TEMPERATURE_1_ADDR			(0X21)
+/*******************/
+/**\name FIFO REGISTERS */
+/*******************/
+#define BMI160_USER_FIFO_LENGTH_0_ADDR			(0X22)
+#define BMI160_USER_FIFO_LENGTH_1_ADDR			(0X23)
+#define BMI160_USER_FIFO_DATA_ADDR				(0X24)
+/***************************************************/
+/**\name ACCEL CONFIG REGISTERS  FOR ODR, BANDWIDTH AND UNDERSAMPLING*/
+/******************************************************/
+#define BMI160_USER_ACCEL_CONFIG_ADDR			(0X40)
+/*******************/
+/**\name ACCEL RANGE */
+/*******************/
+#define BMI160_USER_ACCEL_RANGE_ADDR            (0X41)
+/***************************************************/
+/**\name GYRO CONFIG REGISTERS  FOR ODR AND BANDWIDTH */
+/******************************************************/
+#define BMI160_USER_GYRO_CONFIG_ADDR            (0X42)
+/*******************/
+/**\name GYRO RANGE */
+/*******************/
+#define BMI160_USER_GYRO_RANGE_ADDR             (0X43)
+/***************************************************/
+/**\name MAG CONFIG REGISTERS  FOR ODR*/
+/******************************************************/
+#define BMI160_USER_MAG_CONFIG_ADDR				(0X44)
+/***************************************************/
+/**\name REGISTER FOR GYRO AND ACCEL DOWNSAMPLING RATES FOR FIFO*/
+/******************************************************/
+#define BMI160_USER_FIFO_DOWN_ADDR              (0X45)
+/***************************************************/
+/**\name FIFO CONFIG REGISTERS*/
+/******************************************************/
+#define BMI160_USER_FIFO_CONFIG_0_ADDR          (0X46)
+#define BMI160_USER_FIFO_CONFIG_1_ADDR          (0X47)
+/***************************************************/
+/**\name MAG INTERFACE REGISTERS*/
+/******************************************************/
+#define BMI160_USER_MAG_IF_0_ADDR				(0X4B)
+#define BMI160_USER_MAG_IF_1_ADDR				(0X4C)
+#define BMI160_USER_MAG_IF_2_ADDR				(0X4D)
+#define BMI160_USER_MAG_IF_3_ADDR				(0X4E)
+#define BMI160_USER_MAG_IF_4_ADDR				(0X4F)
+/***************************************************/
+/**\name INTERRUPT ENABLE REGISTERS*/
+/******************************************************/
+#define BMI160_USER_INTR_ENABLE_0_ADDR			(0X50)
+#define BMI160_USER_INTR_ENABLE_1_ADDR			(0X51)
+#define BMI160_USER_INTR_ENABLE_2_ADDR			(0X52)
+#define BMI160_USER_INTR_OUT_CTRL_ADDR			(0X53)
+/***************************************************/
+/**\name LATCH DURATION REGISTERS*/
+/******************************************************/
+#define BMI160_USER_INTR_LATCH_ADDR				(0X54)
+/***************************************************/
+/**\name MAP INTERRUPT 1 and 2 REGISTERS*/
+/******************************************************/
+#define BMI160_USER_INTR_MAP_0_ADDR				(0X55)
+#define BMI160_USER_INTR_MAP_1_ADDR				(0X56)
+#define BMI160_USER_INTR_MAP_2_ADDR				(0X57)
+/***************************************************/
+/**\name DATA SOURCE REGISTERS*/
+/******************************************************/
+#define BMI160_USER_INTR_DATA_0_ADDR			(0X58)
+#define BMI160_USER_INTR_DATA_1_ADDR			(0X59)
+/***************************************************/
+/**\name
+INTERRUPT THRESHOLD, HYSTERESIS, DURATION, MODE CONFIGURATION REGISTERS*/
+/******************************************************/
+#define BMI160_USER_INTR_LOWHIGH_0_ADDR			(0X5A)
+#define BMI160_USER_INTR_LOWHIGH_1_ADDR			(0X5B)
+#define BMI160_USER_INTR_LOWHIGH_2_ADDR			(0X5C)
+#define BMI160_USER_INTR_LOWHIGH_3_ADDR			(0X5D)
+#define BMI160_USER_INTR_LOWHIGH_4_ADDR			(0X5E)
+#define BMI160_USER_INTR_MOTION_0_ADDR			(0X5F)
+#define BMI160_USER_INTR_MOTION_1_ADDR			(0X60)
+#define BMI160_USER_INTR_MOTION_2_ADDR			(0X61)
+#define BMI160_USER_INTR_MOTION_3_ADDR			(0X62)
+#define BMI160_USER_INTR_TAP_0_ADDR				(0X63)
+#define BMI160_USER_INTR_TAP_1_ADDR				(0X64)
+#define BMI160_USER_INTR_ORIENT_0_ADDR			(0X65)
+#define BMI160_USER_INTR_ORIENT_1_ADDR			(0X66)
+#define BMI160_USER_INTR_FLAT_0_ADDR			(0X67)
+#define BMI160_USER_INTR_FLAT_1_ADDR			(0X68)
+/***************************************************/
+/**\name FAST OFFSET CONFIGURATION REGISTER*/
+/******************************************************/
+#define BMI160_USER_FOC_CONFIG_ADDR				(0X69)
+/***************************************************/
+/**\name MISCELLANEOUS CONFIGURATION REGISTER*/
+/******************************************************/
+#define BMI160_USER_CONFIG_ADDR					(0X6A)
+/***************************************************/
+/**\name SERIAL INTERFACE SETTINGS REGISTER*/
+/******************************************************/
+#define BMI160_USER_IF_CONFIG_ADDR				(0X6B)
+/***************************************************/
+/**\name GYRO POWER MODE TRIGGER REGISTER */
+/******************************************************/
+#define BMI160_USER_PMU_TRIGGER_ADDR			(0X6C)
+/***************************************************/
+/**\name SELF_TEST REGISTER*/
+/******************************************************/
+#define BMI160_USER_SELF_TEST_ADDR				(0X6D)
+/***************************************************/
+/**\name SPI,I2C SELECTION REGISTER*/
+/******************************************************/
+#define BMI160_USER_NV_CONFIG_ADDR				(0x70)
+/***************************************************/
+/**\name ACCEL AND GYRO OFFSET REGISTERS*/
+/******************************************************/
+#define BMI160_USER_OFFSET_0_ADDR				(0X71)
+#define BMI160_USER_OFFSET_1_ADDR				(0X72)
+#define BMI160_USER_OFFSET_2_ADDR				(0X73)
+#define BMI160_USER_OFFSET_3_ADDR				(0X74)
+#define BMI160_USER_OFFSET_4_ADDR				(0X75)
+#define BMI160_USER_OFFSET_5_ADDR				(0X76)
+#define BMI160_USER_OFFSET_6_ADDR				(0X77)
+/***************************************************/
+/**\name STEP COUNTER INTERRUPT REGISTERS*/
+/******************************************************/
+#define BMI160_USER_STEP_COUNT_0_ADDR			(0X78)
+#define BMI160_USER_STEP_COUNT_1_ADDR			(0X79)
+/***************************************************/
+/**\name STEP COUNTER CONFIGURATION REGISTERS*/
+/******************************************************/
+#define BMI160_USER_STEP_CONFIG_0_ADDR			(0X7A)
+#define BMI160_USER_STEP_CONFIG_1_ADDR			(0X7B)
+/***************************************************/
+/**\name COMMAND REGISTER*/
+/******************************************************/
+#define BMI160_CMD_COMMANDS_ADDR				(0X7E)
+/***************************************************/
+/**\name PAGE REGISTERS*/
+/******************************************************/
+#define BMI160_CMD_EXT_MODE_ADDR				(0X7F)
+#define BMI160_COM_C_TRIM_FIVE_ADDR				(0X05)
+
+/****************************************************/
+/**\name	SHIFT VALUE DEFINITION       */
+/***************************************************/
+#define BMI160_SHIFT_BIT_POSITION_BY_01_BIT      (1)
+#define BMI160_SHIFT_BIT_POSITION_BY_02_BITS     (2)
+#define BMI160_SHIFT_BIT_POSITION_BY_03_BITS     (3)
+#define BMI160_SHIFT_BIT_POSITION_BY_04_BITS     (4)
+#define BMI160_SHIFT_BIT_POSITION_BY_05_BITS     (5)
+#define BMI160_SHIFT_BIT_POSITION_BY_06_BITS     (6)
+#define BMI160_SHIFT_BIT_POSITION_BY_07_BITS     (7)
+#define BMI160_SHIFT_BIT_POSITION_BY_08_BITS     (8)
+#define BMI160_SHIFT_BIT_POSITION_BY_09_BITS     (9)
+#define BMI160_SHIFT_BIT_POSITION_BY_12_BITS     (12)
+#define BMI160_SHIFT_BIT_POSITION_BY_13_BITS     (13)
+#define BMI160_SHIFT_BIT_POSITION_BY_14_BITS     (14)
+#define BMI160_SHIFT_BIT_POSITION_BY_15_BITS     (15)
+#define BMI160_SHIFT_BIT_POSITION_BY_16_BITS     (16)
+
+/****************************************************/
+/**\name	 DEFINITIONS USED FOR YAMAHA-YAS532 */
+/***************************************************/
+#define YAS532_MAG_STATE_NORMAL				(0)
+#define YAS532_MAG_STATE_INIT_COIL			(1)
+#define YAS532_MAG_STATE_MEASURE_OFFSET		(2)
+#define YAS532_MAG_INITCOIL_TIMEOUT			(1000)
+#define YAS532_MAG_NOTRANS_POSITION			(3)
+#define YAS532_DEFAULT_SENSOR_DELAY			(50)
+#define YAS532_DATA_OVERFLOW				(8190)
+#define YAS532_DATA_UNDERFLOW				(0)
+#define YAS532_MAG_LOG				(20)
+#define YAS532_MAG_TEMPERATURE_LOG			(10)
+#define YAS532_TEMP20DEGREE_TYPICAL			(390)
+#define YAS532_VERSION_AC_COEF_X			(850)
+#define YAS532_VERSION_AC_COEF_Y1			(750)
+#define YAS532_VERSION_AC_COEF_Y2			(750)
+#define YAS532_DATA_CENTER					(4096)
+/****************************************************/
+/**\name	YAMAHA-YAS532 OFFSET DEFINITION */
+/***************************************************/
+static const s8 INVALID_OFFSET[] = {0x7f, 0x7f, 0x7f};
+#define set_vector(to, from) \
+	{int _l; for (_l = 0; _l < 3; _l++) (to)[_l] = (from)[_l]; }
+#define is_valid_offset(a) \
+	(((a)[0] <= 31) && ((a)[1] <= 31) && ((a)[2] <= 31) \
+		&& (-31 <= (a)[0]) && (-31 <= (a)[1]) && (-31 <= (a)[2]))
+
+/**************************************************/
+/**\name	YAS532 CALIB DATA DEFINITIONS  */
+/*************************************************/
+
+
+/* register address of YAS532*/
+#define BMI160_YAS532_TESTR1			(0x88)
+#define BMI160_YAS532_TESTR2			(0x89)
+#define BMI160_YAS532_RCOIL				(0x81)
+#define BMI160_YAS532_COMMAND_REGISTER	(0x82)
+#define BMI160_YAS532_DATA_REGISTER		(0xB0)
+/* calib data register definition*/
+#define BMI160_YAS532_CALIB_CX	        (0x90)
+#define BMI160_YAS532_CALIB_CY1	        (0x91)
+#define BMI160_YAS532_CALIB_CY2	        (0x92)
+#define BMI160_YAS532_CALIB1	        (0x93)
+#define BMI160_YAS532_CALIB2	        (0x94)
+#define BMI160_YAS532_CALIB3	        (0x95)
+#define BMI160_YAS532_CALIB4	        (0x96)
+#define BMI160_YAS532_CALIB5	        (0x97)
+#define BMI160_YAS532_CLAIB6	        (0x98)
+#define BMI160_YAS532_CALIB7	        (0x99)
+#define BMI160_YAS532_CALIB8	        (0x9A)
+#define BMI160_YAS532_CALIIB9	        (0x9B)
+#define BMI160_YAS532_CALIB10	        (0x9C)
+#define BMI160_YAS532_CALIB11	        (0x9D)
+/* offset definition */
+#define BMI160_YAS532_OFFSET_X	        (0x85)
+#define BMI160_YAS532_OFFSET_Y	        (0x86)
+#define BMI160_YAS532_OFFSET_Z	        (0x87)
+/* data to write register for yas532*/
+#define BMI160_YAS532_WRITE_TESTR1	    (0x00)
+#define BMI160_YAS532_WRITE_TESTR2	    (0x00)
+#define BMI160_YAS532_WRITE_RCOIL       (0x00)
+/**************************************************/
+/**\name	YAS537 DEFINITION  */
+/*************************************************/
+
+#define	YAS537_SRSTR_DATA		        (0x02)
+#define	YAS537_WRITE_A_D_CONVERTER		(0x03)
+#define	YAS537_WRITE_A_D_CONVERTER2		(0xF8)
+#define	YAS537_WRITE_FILTER             (0x08)
+#define	YAS537_WRITE_CONFR              (0x08)
+#define	YAS537_WRITE_TEMP_CALIB         (0xFF)
+#define	YAS537_SET_COMMAND_REGISTER     (0x01)
+
+/**************************************************/
+/**\name	YAS537 REGISTER DEFINITION  */
+/*************************************************/
+#define	YAS537_REG_SRSTR				(0x90)
+#define	YAS537_REG_CALR_C0				(0xC0)
+#define	YAS537_REG_CALR_C1				(0xC1)
+#define	YAS537_REG_CALR_C2				(0xC2)
+#define	YAS537_REG_CALR_C3				(0xC3)
+#define	YAS537_REG_CALR_C4				(0xC4)
+#define	YAS537_REG_CALR_C5				(0xC5)
+#define	YAS537_REG_CALR_C6				(0xC6)
+#define	YAS537_REG_CALR_C7				(0xC7)
+#define	YAS537_REG_CALR_C8				(0xC8)
+#define	YAS537_REG_CALR_C9				(0xC9)
+#define	YAS537_REG_CALR_CA				(0xCA)
+#define	YAS537_REG_CALR_CB				(0xCB)
+#define	YAS537_REG_CALR_CC				(0xCC)
+#define	YAS537_REG_CALR_CD				(0xCD)
+#define	YAS537_REG_CALR_CE				(0xCE)
+#define	YAS537_REG_CALR_CF				(0xCF)
+#define	YAS537_REG_CALR_DO				(0xD0)
+#define	YAS537_REG_MTCR					(0x93)
+#define	YAS537_REG_CONFR				(0x82)
+#define	BMI160_REG_YAS537_CMDR			(0x81)
+#define	YAS537_REG_OXR					(0x84)
+#define	YAS537_REG_AVRR					(0x87)
+#define	YAS537_REG_HCKR					(0x88)
+#define	YAS537_REG_LCKR					(0x89)
+#define	YAS537_REG_ADCCALR				(0x91)
+#define	YAS537_REG_ADCCALR_ONE			(0x92)
+#define	YAS537_REG_OCR					(0x9E)
+#define	YAS537_REG_TRMR			        (0x9F)
+#define	YAS537_REG_TEMPERATURE_0		(0xB0)
+#define	YAS537_REG_TEMPERATURE_1		(0xB1)
+#define	YAS537_REG_DATA_X_0				(0xB2)
+#define	YAS537_REG_DATA_X_1				(0xB3)
+#define	YAS537_REG_DATA_Y1_0			(0xB4)
+#define	YAS537_REG_DATA_Y1_1			(0xB5)
+#define	YAS537_REG_DATA_Y2_0			(0xB6)
+#define	YAS537_REG_DATA_Y2_1			(0xB7)
+#define YAS537_MAG_STATE_NORMAL			(0)
+#define YAS537_MAG_STATE_INIT_COIL		(1)
+#define YAS537_MAG_STATE_RECORD_DATA	(2)
+#define YAS537_DATA_UNDERFLOW			(0)
+#define YAS537_DATA_OVERFLOW			(16383)
+/****************************************************/
+/**\name	YAS537_set vector */
+/***************************************************/
+#define yas537_set_vector(to, from) \
+	{int _l; for (_l = 0; _l < 3; _l++) (to)[_l] = (from)[_l]; }
+
+#ifndef ABS
+#define ABS(a)		((a) > 0 ? (a) : -(a)) /*!< Absolute value */
+#endif
+/****************************************************/
+/**\name	AKM09911 AND AKM09912 DEFINITION */
+/***************************************************/
+#define AKM09912_SENSITIVITY_DIV	(256)
+#define AKM09912_SENSITIVITY		(128)
+#define AKM09911_SENSITIVITY_DIV	(128)
+#define AKM_ASAX	(0)
+#define AKM_ASAY	(1)
+#define AKM_ASAZ	(2)
+#define AKM_POWER_DOWN_MODE_DATA		(0x00)
+#define AKM_FUSE_ROM_MODE				(0x1F)
+#define AKM_POWER_MODE_REG				(0x31)
+#define	AKM_SINGLE_MEASUREMENT_MODE		(0x01)
+#define AKM_DATA_REGISTER				(0x11)
+/*! AKM09912 Register definition */
+#define AKM09912_CHIP_ID_REG			(0x01)
+/****************************************************/
+/**\name	BMM150 DEFINITION */
+/***************************************************/
+#define BMI160_BMM150_SET_POWER_CONTROL	(0x01)
+#define BMI160_BMM150_MAX_RETRY_WAKEUP	(5)
+#define BMI160_BMM150_POWER_ON			(0x01)
+#define BMI160_BMM150_POWER_OFF			(0x00)
+#define BMI160_BMM150_FORCE_MODE		(0x02)
+#define BMI160_BMM150_POWER_ON_SUCCESS	(0)
+#define BMI160_BMM150_POWER_ON_FAIL		((s8)-1)
+
+#define	BMI160_BMM150_DIG_X1			(0)
+#define	BMI160_BMM150_DIG_Y1			(1)
+#define	BMI160_BMM150_DIG_X2			(2)
+#define	BMI160_BMM150_DIG_Y3			(3)
+#define	BMI160_BMM150_DIG_XY1			(4)
+#define	BMI160_BMM150_DIG_XY2			(5)
+#define	BMI160_BMM150_DIG_Z1_LSB		(6)
+#define	BMI160_BMM150_DIG_Z1_MSB		(7)
+#define	BMI160_BMM150_DIG_Z2_LSB		(8)
+#define	BMI160_BMM150_DIG_Z2_MSB		(9)
+#define	BMI160_BMM150_DIG_DIG_Z3_LSB	(10)
+#define	BMI160_BMM150_DIG_DIG_Z3_MSB	(11)
+#define	BMI160_BMM150_DIG_DIG_Z4_LSB	(12)
+#define	BMI160_BMM150_DIG_DIG_Z4_MSB	(13)
+#define	BMI160_BMM150_DIG_DIG_XYZ1_LSB	(14)
+#define	BMI160_BMM150_DIG_DIG_XYZ1_MSB	(15)
+
+/**************************************************************/
+/**\name	STRUCTURE DEFINITIONS                         */
+/**************************************************************/
+/*!
+*	@brief bmi160 structure
+*	This structure holds all relevant information about bmi160
+*/
+struct bmi160_t {
+u8 chip_id;/**< chip id of BMI160 */
+u8 dev_addr;/**< device address of BMI160 */
+s8 mag_manual_enable;/**< used for check the mag manual/auto mode status */
+BMI160_WR_FUNC_PTR;/**< bus write function pointer */
+BMI160_RD_FUNC_PTR;/**< bus read function pointer */
+BMI160_BRD_FUNC_PTR;/**< burst write function pointer */
+void (*delay_msec)(BMI160_MDELAY_DATA_TYPE);/**< delay function pointer */
+};
+/*!
+ * @brief Structure containing bmm150 and akm09911
+ *	magnetometer values for x,y and
+ *	z-axis in s16
+ */
+struct bmi160_mag_t {
+s16 x;/**< BMM150 and AKM09911 and AKM09912 X raw data*/
+s16 y;/**< BMM150 and AKM09911 and AKM09912 Y raw data*/
+s16 z;/**< BMM150 and AKM09911 and AKM09912 Z raw data*/
+};
+/*!
+ * @brief Structure containing bmm150 xyz data and temperature
+ */
+struct bmi160_mag_xyzr_t {
+s16 x;/**< BMM150 X raw data*/
+s16 y;/**< BMM150 Y raw data*/
+s16 z;/**<BMM150 Z raw data*/
+u16 r;/**<BMM150 R raw data*/
+};
+/*!
+ * @brief Structure containing gyro xyz data
+ */
+struct bmi160_gyro_t {
+s16 x;/**<gyro X  data*/
+s16 y;/**<gyro Y  data*/
+s16 z;/**<gyro Z  data*/
+};
+/*!
+ * @brief Structure containing accel xyz data
+ */
+struct bmi160_accel_t {
+s16 x;/**<accel X  data*/
+s16 y;/**<accel Y  data*/
+s16 z;/**<accel Z  data*/
+};
+/*!
+ * @brief Structure bmm150 mag compensated data with s32 output
+ */
+struct bmi160_mag_xyz_s32_t {
+s16 x;/**<BMM150 X compensated data*/
+s16 y;/**<BMM150 Y compensated data*/
+s16 z;/**<BMM150 Z compensated data*/
+};
+/*!
+ * @brief Structure bmm150 mag trim data
+ */
+struct trim_data_t {
+s8 dig_x1;/**<BMM150 trim x1 data*/
+s8 dig_y1;/**<BMM150 trim y1 data*/
+
+s8 dig_x2;/**<BMM150 trim x2 data*/
+s8 dig_y2;/**<BMM150 trim y2 data*/
+
+u16 dig_z1;/**<BMM150 trim z1 data*/
+s16 dig_z2;/**<BMM150 trim z2 data*/
+s16 dig_z3;/**<BMM150 trim z3 data*/
+s16 dig_z4;/**<BMM150 trim z4 data*/
+
+u8 dig_xy1;/**<BMM150 trim xy1 data*/
+s8 dig_xy2;/**<BMM150 trim xy2 data*/
+
+u16 dig_xyz1;/**<BMM150 trim xyz1 data*/
+};
+
+/*!
+*	@brief Structure for reading AKM compensating data
+*/
+struct bst_akm_sensitivity_data_t {
+u8 asax;/**<AKM09911 and AKM09912 X sensitivity data*/
+u8 asay;/**<AKM09911 and AKM09912 Y sensitivity data*/
+u8 asaz;/**<AKM09911 and AKM09912 Z sensitivity data*/
+};
+/*!
+* @brief YAMAHA-YAS532 struct
+* Calibration YAS532 data struct
+*/
+struct bst_yas532_calib_data_t {
+s32 cx;/**<YAS532 calib cx data */
+s32 cy1;/**<YAS532 calib cy1 data */
+s32 cy2;/**<YAS532 calib cy2 data */
+s32 a2;/**<YAS532 calib a2 data */
+s32 a3;/**<YAS532 calib a3 data */
+s32 a4;/**<YAS532 calib a4 data */
+s32 a5;/**<YAS532 calib a5 data */
+s32 a6;/**<YAS532 calib a6 data */
+s32 a7;/**<YAS532 calib a7 data */
+s32 a8;/**<YAS532 calib a8 data */
+s32 a9;/**<YAS532 calib a9 data */
+s32 k;/**<YAS532 calib k data */
+s8 rxy1y2[3];/**<YAS532 calib rxy1y2 data */
+u8 fxy1y2[3];/**<YAS532 calib fxy1y2 data */
+};
+/*!
+* @brief YAS532 Temperature structure
+*/
+#if YAS532_MAG_LOG < YAS532_MAG_TEMPERATURE_LOG
+struct yas_temp_filter_t {
+u16 log[YAS532_MAG_TEMPERATURE_LOG];/**<YAS532 temp log array */
+u8 num;/**< used for increment the index */
+u8 idx;/**< used for increment the index */
+};
+#endif
+/*!
+* @brief YAS532 sensor initialization
+*/
+struct yas532_t {
+struct bst_yas532_calib_data_t calib_yas532;/**< calib data */
+s8 measure_state;/**< update measure state */
+s8 v_hard_offset_s8[3];/**< offset write array*/
+s32 coef[3];/**< co efficient data */
+s8 overflow;/**< over flow condition check */
+u8 dev_id;/**< device id information */
+const s8 *transform;/**< transform condition check  */
+#if YAS532_MAG_LOG < YAS532_MAG_TEMPERATURE_LOG
+struct yas_temp_filter_t temp_data;/**< temp data */
+#endif
+u16 last_raw[4];/**< raw data */
+};
+/*!
+* @brief Used for reading the YAS532 XYZ data
+*/
+struct yas532_vector {
+s32 yas532_vector_xyz[3];/**< YAS532 compensated xyz data*/
+};
+/**
+ * @struct yas_vector
+ * @brief Stores the sensor data
+ */
+struct yas_vector {
+	s32 yas537_vector_xyz[3]; /*!< vector data */
+};
+/*!
+* @brief YAMAHA-YAS532 struct
+* Calibration YAS532 data struct
+*/
+struct bst_yas537_calib_data_t {
+s8 a2;/**<YAS532 calib a2 data */
+s8 a3;/**<YAS532 calib a3 data */
+s8 a4;/**<YAS532 calib a4 data */
+s16 a5;/**<YAS532 calib a5 data */
+s8 a6;/**<YAS532 calib a6 data */
+s8 a7;/**<YAS532 calib a7 data */
+s8 a8;/**<YAS532 calib a8 data */
+s16 a9;/**<YAS532 calib a9 data */
+u8 k;/**<YAS532 calib k data */
+u8 ver;/**<YAS532 calib ver data*/
+};
+/*!
+* @brief YAS537 sensor initialization
+*/
+struct yas537_t {
+struct bst_yas537_calib_data_t calib_yas537;/**< calib data */
+s8 measure_state;/**< update measure state */
+s8 hard_offset[3];/**< offset write array*/
+u16 last_after_rcoil[3];/**< rcoil write array*/
+s32 coef[3];/**< co efficient data */
+s8 overflow;/**< over flow condition check */
+u8 dev_id;/**< device id information */
+u8 average;/**<average selection for offset configuration*/
+const s8 *transform;/**< transform condition check  */
+u16 last_raw[4];/**< raw data */
+struct yas_vector xyz; /*!< X, Y, Z measurement data of the sensor */
+};
+/**************************************************************/
+/**\name	USER DATA REGISTERS DEFINITION START    */
+/**************************************************************/
+
+/**************************************************************/
+/**\name	CHIP ID LENGTH, POSITION AND MASK    */
+/**************************************************************/
+/* Chip ID Description - Reg Addr --> (0x00), Bit --> 0...7 */
+#define BMI160_USER_CHIP_ID__POS             (0)
+#define BMI160_USER_CHIP_ID__MSK            (0xFF)
+#define BMI160_USER_CHIP_ID__LEN             (8)
+#define BMI160_USER_CHIP_ID__REG             (BMI160_USER_CHIP_ID_ADDR)
+/**************************************************************/
+/**\name	ERROR STATUS LENGTH, POSITION AND MASK    */
+/**************************************************************/
+/* Error Description - Reg Addr --> (0x02), Bit --> 0 */
+#define BMI160_USER_ERR_STAT__POS               (0)
+#define BMI160_USER_ERR_STAT__LEN               (8)
+#define BMI160_USER_ERR_STAT__MSK               (0xFF)
+#define BMI160_USER_ERR_STAT__REG               (BMI160_USER_ERROR_ADDR)
+
+#define BMI160_USER_FATAL_ERR__POS               (0)
+#define BMI160_USER_FATAL_ERR__LEN               (1)
+#define BMI160_USER_FATAL_ERR__MSK               (0x01)
+#define BMI160_USER_FATAL_ERR__REG               (BMI160_USER_ERROR_ADDR)
+
+/* Error Description - Reg Addr --> (0x02), Bit --> 1...4 */
+#define BMI160_USER_ERR_CODE__POS               (1)
+#define BMI160_USER_ERR_CODE__LEN               (4)
+#define BMI160_USER_ERR_CODE__MSK               (0x1E)
+#define BMI160_USER_ERR_CODE__REG               (BMI160_USER_ERROR_ADDR)
+
+/* Error Description - Reg Addr --> (0x02), Bit --> 5 */
+#define BMI160_USER_I2C_FAIL_ERR__POS               (5)
+#define BMI160_USER_I2C_FAIL_ERR__LEN               (1)
+#define BMI160_USER_I2C_FAIL_ERR__MSK               (0x20)
+#define BMI160_USER_I2C_FAIL_ERR__REG               (BMI160_USER_ERROR_ADDR)
+
+/* Error Description - Reg Addr --> (0x02), Bit --> 6 */
+#define BMI160_USER_DROP_CMD_ERR__POS              (6)
+#define BMI160_USER_DROP_CMD_ERR__LEN              (1)
+#define BMI160_USER_DROP_CMD_ERR__MSK              (0x40)
+#define BMI160_USER_DROP_CMD_ERR__REG              (BMI160_USER_ERROR_ADDR)
+/**************************************************************/
+/**\name	MAG DATA READY LENGTH, POSITION AND MASK    */
+/**************************************************************/
+/* Error Description - Reg Addr --> (0x02), Bit --> 7 */
+#define BMI160_USER_MAG_DADA_RDY_ERR__POS               (7)
+#define BMI160_USER_MAG_DADA_RDY_ERR__LEN               (1)
+#define BMI160_USER_MAG_DADA_RDY_ERR__MSK               (0x80)
+#define BMI160_USER_MAG_DADA_RDY_ERR__REG               (BMI160_USER_ERROR_ADDR)
+/**************************************************************/
+/**\name	MAG POWER MODE LENGTH, POSITION AND MASK    */
+/**************************************************************/
+/* PMU_Status Description of MAG - Reg Addr --> (0x03), Bit --> 1..0 */
+#define BMI160_USER_MAG_POWER_MODE_STAT__POS		(0)
+#define BMI160_USER_MAG_POWER_MODE_STAT__LEN		(2)
+#define BMI160_USER_MAG_POWER_MODE_STAT__MSK		(0x03)
+#define BMI160_USER_MAG_POWER_MODE_STAT__REG		\
+(BMI160_USER_PMU_STAT_ADDR)
+/**************************************************************/
+/**\name	GYRO POWER MODE LENGTH, POSITION AND MASK    */
+/**************************************************************/
+/* PMU_Status Description of GYRO - Reg Addr --> (0x03), Bit --> 3...2 */
+#define BMI160_USER_GYRO_POWER_MODE_STAT__POS               (2)
+#define BMI160_USER_GYRO_POWER_MODE_STAT__LEN               (2)
+#define BMI160_USER_GYRO_POWER_MODE_STAT__MSK               (0x0C)
+#define BMI160_USER_GYRO_POWER_MODE_STAT__REG		      \
+(BMI160_USER_PMU_STAT_ADDR)
+/**************************************************************/
+/**\name	ACCEL POWER MODE LENGTH, POSITION AND MASK    */
+/**************************************************************/
+/* PMU_Status Description of ACCEL - Reg Addr --> (0x03), Bit --> 5...4 */
+#define BMI160_USER_ACCEL_POWER_MODE_STAT__POS               (4)
+#define BMI160_USER_ACCEL_POWER_MODE_STAT__LEN               (2)
+#define BMI160_USER_ACCEL_POWER_MODE_STAT__MSK               (0x30)
+#define BMI160_USER_ACCEL_POWER_MODE_STAT__REG		    \
+(BMI160_USER_PMU_STAT_ADDR)
+/**************************************************************/
+/**\name	MAG DATA XYZ LENGTH, POSITION AND MASK    */
+/**************************************************************/
+/* Mag_X(LSB) Description - Reg Addr --> (0x04), Bit --> 0...7 */
+#define BMI160_USER_DATA_0_MAG_X_LSB__POS           (0)
+#define BMI160_USER_DATA_0_MAG_X_LSB__LEN           (8)
+#define BMI160_USER_DATA_0_MAG_X_LSB__MSK          (0xFF)
+#define BMI160_USER_DATA_0_MAG_X_LSB__REG          (BMI160_USER_DATA_0_ADDR)
+
+/* Mag_X(LSB) Description - Reg Addr --> (0x04), Bit --> 3...7 */
+#define BMI160_USER_DATA_MAG_X_LSB__POS           (3)
+#define BMI160_USER_DATA_MAG_X_LSB__LEN           (5)
+#define BMI160_USER_DATA_MAG_X_LSB__MSK          (0xF8)
+#define BMI160_USER_DATA_MAG_X_LSB__REG          (BMI160_USER_DATA_0_ADDR)
+
+/* Mag_X(MSB) Description - Reg Addr --> (0x05), Bit --> 0...7 */
+#define BMI160_USER_DATA_1_MAG_X_MSB__POS           (0)
+#define BMI160_USER_DATA_1_MAG_X_MSB__LEN           (8)
+#define BMI160_USER_DATA_1_MAG_X_MSB__MSK          (0xFF)
+#define BMI160_USER_DATA_1_MAG_X_MSB__REG          (BMI160_USER_DATA_1_ADDR)
+
+/* Mag_Y(LSB) Description - Reg Addr --> (0x06), Bit --> 0...7 */
+#define BMI160_USER_DATA_2_MAG_Y_LSB__POS           (0)
+#define BMI160_USER_DATA_2_MAG_Y_LSB__LEN           (8)
+#define BMI160_USER_DATA_2_MAG_Y_LSB__MSK          (0xFF)
+#define BMI160_USER_DATA_2_MAG_Y_LSB__REG          (BMI160_USER_DATA_2_ADDR)
+
+/* Mag_Y(LSB) Description - Reg Addr --> (0x06), Bit --> 3...7 */
+#define BMI160_USER_DATA_MAG_Y_LSB__POS           (3)
+#define BMI160_USER_DATA_MAG_Y_LSB__LEN           (5)
+#define BMI160_USER_DATA_MAG_Y_LSB__MSK          (0xF8)
+#define BMI160_USER_DATA_MAG_Y_LSB__REG          (BMI160_USER_DATA_2_ADDR)
+
+/* Mag_Y(MSB) Description - Reg Addr --> (0x07), Bit --> 0...7 */
+#define BMI160_USER_DATA_3_MAG_Y_MSB__POS           (0)
+#define BMI160_USER_DATA_3_MAG_Y_MSB__LEN           (8)
+#define BMI160_USER_DATA_3_MAG_Y_MSB__MSK          (0xFF)
+#define BMI160_USER_DATA_3_MAG_Y_MSB__REG          (BMI160_USER_DATA_3_ADDR)
+
+/* Mag_Z(LSB) Description - Reg Addr --> (0x08), Bit --> 0...7 */
+#define BMI160_USER_DATA_4_MAG_Z_LSB__POS           (0)
+#define BMI160_USER_DATA_4_MAG_Z_LSB__LEN           (8)
+#define BMI160_USER_DATA_4_MAG_Z_LSB__MSK          (0xFF)
+#define BMI160_USER_DATA_4_MAG_Z_LSB__REG          (BMI160_USER_DATA_4_ADDR)
+
+/* Mag_X(LSB) Description - Reg Addr --> (0x08), Bit --> 3...7 */
+#define BMI160_USER_DATA_MAG_Z_LSB__POS           (1)
+#define BMI160_USER_DATA_MAG_Z_LSB__LEN           (7)
+#define BMI160_USER_DATA_MAG_Z_LSB__MSK          (0xFE)
+#define BMI160_USER_DATA_MAG_Z_LSB__REG          (BMI160_USER_DATA_4_ADDR)
+
+/* Mag_Z(MSB) Description - Reg Addr --> (0x09), Bit --> 0...7 */
+#define BMI160_USER_DATA_5_MAG_Z_MSB__POS           (0)
+#define BMI160_USER_DATA_5_MAG_Z_MSB__LEN           (8)
+#define BMI160_USER_DATA_5_MAG_Z_MSB__MSK          (0xFF)
+#define BMI160_USER_DATA_5_MAG_Z_MSB__REG          (BMI160_USER_DATA_5_ADDR)
+
+/* RHALL(LSB) Description - Reg Addr --> (0x0A), Bit --> 0...7 */
+#define BMI160_USER_DATA_6_RHALL_LSB__POS           (0)
+#define BMI160_USER_DATA_6_RHALL_LSB__LEN           (8)
+#define BMI160_USER_DATA_6_RHALL_LSB__MSK          (0xFF)
+#define BMI160_USER_DATA_6_RHALL_LSB__REG          (BMI160_USER_DATA_6_ADDR)
+
+/* Mag_R(LSB) Description - Reg Addr --> (0x0A), Bit --> 3...7 */
+#define BMI160_USER_DATA_MAG_R_LSB__POS           (2)
+#define BMI160_USER_DATA_MAG_R_LSB__LEN           (6)
+#define BMI160_USER_DATA_MAG_R_LSB__MSK          (0xFC)
+#define BMI160_USER_DATA_MAG_R_LSB__REG          (BMI160_USER_DATA_6_ADDR)
+
+/* RHALL(MSB) Description - Reg Addr --> (0x0B), Bit --> 0...7 */
+#define BMI160_USER_DATA_7_RHALL_MSB__POS           (0)
+#define BMI160_USER_DATA_7_RHALL_MSB__LEN           (8)
+#define BMI160_USER_DATA_7_RHALL_MSB__MSK          (0xFF)
+#define BMI160_USER_DATA_7_RHALL_MSB__REG          (BMI160_USER_DATA_7_ADDR)
+/**************************************************************/
+/**\name	GYRO DATA XYZ LENGTH, POSITION AND MASK    */
+/**************************************************************/
+/* GYR_X (LSB) Description - Reg Addr --> (0x0C), Bit --> 0...7 */
+#define BMI160_USER_DATA_8_GYRO_X_LSB__POS           (0)
+#define BMI160_USER_DATA_8_GYRO_X_LSB__LEN           (8)
+#define BMI160_USER_DATA_8_GYRO_X_LSB__MSK          (0xFF)
+#define BMI160_USER_DATA_8_GYRO_X_LSB__REG          (BMI160_USER_DATA_8_ADDR)
+
+/* GYR_X (MSB) Description - Reg Addr --> (0x0D), Bit --> 0...7 */
+#define BMI160_USER_DATA_9_GYRO_X_MSB__POS           (0)
+#define BMI160_USER_DATA_9_GYRO_X_MSB__LEN           (8)
+#define BMI160_USER_DATA_9_GYRO_X_MSB__MSK          (0xFF)
+#define BMI160_USER_DATA_9_GYRO_X_MSB__REG          (BMI160_USER_DATA_9_ADDR)
+
+/* GYR_Y (LSB) Description - Reg Addr --> 0x0E, Bit --> 0...7 */
+#define BMI160_USER_DATA_10_GYRO_Y_LSB__POS           (0)
+#define BMI160_USER_DATA_10_GYRO_Y_LSB__LEN           (8)
+#define BMI160_USER_DATA_10_GYRO_Y_LSB__MSK          (0xFF)
+#define BMI160_USER_DATA_10_GYRO_Y_LSB__REG          (BMI160_USER_DATA_10_ADDR)
+
+/* GYR_Y (MSB) Description - Reg Addr --> (0x0F), Bit --> 0...7 */
+#define BMI160_USER_DATA_11_GYRO_Y_MSB__POS           (0)
+#define BMI160_USER_DATA_11_GYRO_Y_MSB__LEN           (8)
+#define BMI160_USER_DATA_11_GYRO_Y_MSB__MSK          (0xFF)
+#define BMI160_USER_DATA_11_GYRO_Y_MSB__REG          (BMI160_USER_DATA_11_ADDR)
+
+/* GYR_Z (LSB) Description - Reg Addr --> (0x10), Bit --> 0...7 */
+#define BMI160_USER_DATA_12_GYRO_Z_LSB__POS           (0)
+#define BMI160_USER_DATA_12_GYRO_Z_LSB__LEN           (8)
+#define BMI160_USER_DATA_12_GYRO_Z_LSB__MSK          (0xFF)
+#define BMI160_USER_DATA_12_GYRO_Z_LSB__REG          (BMI160_USER_DATA_12_ADDR)
+
+/* GYR_Z (MSB) Description - Reg Addr --> (0x11), Bit --> 0...7 */
+#define BMI160_USER_DATA_13_GYRO_Z_MSB__POS           (0)
+#define BMI160_USER_DATA_13_GYRO_Z_MSB__LEN           (8)
+#define BMI160_USER_DATA_13_GYRO_Z_MSB__MSK          (0xFF)
+#define BMI160_USER_DATA_13_GYRO_Z_MSB__REG          (BMI160_USER_DATA_13_ADDR)
+/**************************************************************/
+/**\name	ACCEL DATA XYZ LENGTH, POSITION AND MASK    */
+/**************************************************************/
+/* ACC_X (LSB) Description - Reg Addr --> (0x12), Bit --> 0...7 */
+#define BMI160_USER_DATA_14_ACCEL_X_LSB__POS           (0)
+#define BMI160_USER_DATA_14_ACCEL_X_LSB__LEN           (8)
+#define BMI160_USER_DATA_14_ACCEL_X_LSB__MSK          (0xFF)
+#define BMI160_USER_DATA_14_ACCEL_X_LSB__REG          (BMI160_USER_DATA_14_ADDR)
+
+/* ACC_X (MSB) Description - Reg Addr --> 0x13, Bit --> 0...7 */
+#define BMI160_USER_DATA_15_ACCEL_X_MSB__POS           (0)
+#define BMI160_USER_DATA_15_ACCEL_X_MSB__LEN           (8)
+#define BMI160_USER_DATA_15_ACCEL_X_MSB__MSK          (0xFF)
+#define BMI160_USER_DATA_15_ACCEL_X_MSB__REG          (BMI160_USER_DATA_15_ADDR)
+
+/* ACC_Y (LSB) Description - Reg Addr --> (0x14), Bit --> 0...7 */
+#define BMI160_USER_DATA_16_ACCEL_Y_LSB__POS           (0)
+#define BMI160_USER_DATA_16_ACCEL_Y_LSB__LEN           (8)
+#define BMI160_USER_DATA_16_ACCEL_Y_LSB__MSK          (0xFF)
+#define BMI160_USER_DATA_16_ACCEL_Y_LSB__REG          (BMI160_USER_DATA_16_ADDR)
+
+/* ACC_Y (MSB) Description - Reg Addr --> (0x15), Bit --> 0...7 */
+#define BMI160_USER_DATA_17_ACCEL_Y_MSB__POS           (0)
+#define BMI160_USER_DATA_17_ACCEL_Y_MSB__LEN           (8)
+#define BMI160_USER_DATA_17_ACCEL_Y_MSB__MSK          (0xFF)
+#define BMI160_USER_DATA_17_ACCEL_Y_MSB__REG          (BMI160_USER_DATA_17_ADDR)
+
+/* ACC_Z (LSB) Description - Reg Addr --> 0x16, Bit --> 0...7 */
+#define BMI160_USER_DATA_18_ACCEL_Z_LSB__POS           (0)
+#define BMI160_USER_DATA_18_ACCEL_Z_LSB__LEN           (8)
+#define BMI160_USER_DATA_18_ACCEL_Z_LSB__MSK          (0xFF)
+#define BMI160_USER_DATA_18_ACCEL_Z_LSB__REG          (BMI160_USER_DATA_18_ADDR)
+
+/* ACC_Z (MSB) Description - Reg Addr --> (0x17), Bit --> 0...7 */
+#define BMI160_USER_DATA_19_ACCEL_Z_MSB__POS           (0)
+#define BMI160_USER_DATA_19_ACCEL_Z_MSB__LEN           (8)
+#define BMI160_USER_DATA_19_ACCEL_Z_MSB__MSK          (0xFF)
+#define BMI160_USER_DATA_19_ACCEL_Z_MSB__REG          (BMI160_USER_DATA_19_ADDR)
+/**************************************************************/
+/**\name	SENSOR TIME LENGTH, POSITION AND MASK    */
+/**************************************************************/
+/* SENSORTIME_0 (LSB) Description - Reg Addr --> (0x18), Bit --> 0...7 */
+#define BMI160_USER_SENSORTIME_0_SENSOR_TIME_LSB__POS           (0)
+#define BMI160_USER_SENSORTIME_0_SENSOR_TIME_LSB__LEN           (8)
+#define BMI160_USER_SENSORTIME_0_SENSOR_TIME_LSB__MSK          (0xFF)
+#define BMI160_USER_SENSORTIME_0_SENSOR_TIME_LSB__REG          \
+		(BMI160_USER_SENSORTIME_0_ADDR)
+
+/* SENSORTIME_1 (MSB) Description - Reg Addr --> (0x19), Bit --> 0...7 */
+#define BMI160_USER_SENSORTIME_1_SENSOR_TIME_MSB__POS           (0)
+#define BMI160_USER_SENSORTIME_1_SENSOR_TIME_MSB__LEN           (8)
+#define BMI160_USER_SENSORTIME_1_SENSOR_TIME_MSB__MSK          (0xFF)
+#define BMI160_USER_SENSORTIME_1_SENSOR_TIME_MSB__REG          \
+		(BMI160_USER_SENSORTIME_1_ADDR)
+
+/* SENSORTIME_2 (MSB) Description - Reg Addr --> (0x1A), Bit --> 0...7 */
+#define BMI160_USER_SENSORTIME_2_SENSOR_TIME_MSB__POS           (0)
+#define BMI160_USER_SENSORTIME_2_SENSOR_TIME_MSB__LEN           (8)
+#define BMI160_USER_SENSORTIME_2_SENSOR_TIME_MSB__MSK          (0xFF)
+#define BMI160_USER_SENSORTIME_2_SENSOR_TIME_MSB__REG          \
+		(BMI160_USER_SENSORTIME_2_ADDR)
+/**************************************************************/
+/**\name	GYRO SELF TEST LENGTH, POSITION AND MASK    */
+/**************************************************************/
+/* Status Description - Reg Addr --> 0x1B, Bit --> 1 */
+#define BMI160_USER_STAT_GYRO_SELFTEST_OK__POS          (1)
+#define BMI160_USER_STAT_GYRO_SELFTEST_OK__LEN          (1)
+#define BMI160_USER_STAT_GYRO_SELFTEST_OK__MSK          (0x02)
+#define BMI160_USER_STAT_GYRO_SELFTEST_OK__REG         \
+		(BMI160_USER_STAT_ADDR)
+/**************************************************************/
+/**\name	MAG MANUAL OPERATION LENGTH, POSITION AND MASK    */
+/**************************************************************/
+/* Status Description - Reg Addr --> 0x1B, Bit --> 2 */
+#define BMI160_USER_STAT_MAG_MANUAL_OPERATION__POS          (2)
+#define BMI160_USER_STAT_MAG_MANUAL_OPERATION__LEN          (1)
+#define BMI160_USER_STAT_MAG_MANUAL_OPERATION__MSK          (0x04)
+#define BMI160_USER_STAT_MAG_MANUAL_OPERATION__REG          \
+		(BMI160_USER_STAT_ADDR)
+/**************************************************************/
+/**\name	FOC STATUS LENGTH, POSITION AND MASK    */
+/**************************************************************/
+/* Status Description - Reg Addr --> 0x1B, Bit --> 3 */
+#define BMI160_USER_STAT_FOC_RDY__POS          (3)
+#define BMI160_USER_STAT_FOC_RDY__LEN          (1)
+#define BMI160_USER_STAT_FOC_RDY__MSK          (0x08)
+#define BMI160_USER_STAT_FOC_RDY__REG          (BMI160_USER_STAT_ADDR)
+/**************************************************************/
+/**\name	NVM READY LENGTH, POSITION AND MASK    */
+/**************************************************************/
+/* Status Description - Reg Addr --> 0x1B, Bit --> 4 */
+#define BMI160_USER_STAT_NVM_RDY__POS           (4)
+#define BMI160_USER_STAT_NVM_RDY__LEN           (1)
+#define BMI160_USER_STAT_NVM_RDY__MSK           (0x10)
+#define BMI160_USER_STAT_NVM_RDY__REG           (BMI160_USER_STAT_ADDR)
+/**************************************************************/
+/**\name	DATA READY LENGTH, POSITION AND MASK FOR ACCEL, MAG AND GYRO*/
+/**************************************************************/
+/* Status Description - Reg Addr --> 0x1B, Bit --> 5 */
+#define BMI160_USER_STAT_DATA_RDY_MAG__POS           (5)
+#define BMI160_USER_STAT_DATA_RDY_MAG__LEN           (1)
+#define BMI160_USER_STAT_DATA_RDY_MAG__MSK           (0x20)
+#define BMI160_USER_STAT_DATA_RDY_MAG__REG           (BMI160_USER_STAT_ADDR)
+
+/* Status Description - Reg Addr --> 0x1B, Bit --> 6 */
+#define BMI160_USER_STAT_DATA_RDY_GYRO__POS           (6)
+#define BMI160_USER_STAT_DATA_RDY_GYRO__LEN           (1)
+#define BMI160_USER_STAT_DATA_RDY_GYRO__MSK           (0x40)
+#define BMI160_USER_STAT_DATA_RDY_GYRO__REG           (BMI160_USER_STAT_ADDR)
+
+/* Status Description - Reg Addr --> 0x1B, Bit --> 7 */
+#define BMI160_USER_STAT_DATA_RDY_ACCEL__POS           (7)
+#define BMI160_USER_STAT_DATA_RDY_ACCEL__LEN           (1)
+#define BMI160_USER_STAT_DATA_RDY_ACCEL__MSK           (0x80)
+#define BMI160_USER_STAT_DATA_RDY_ACCEL__REG           (BMI160_USER_STAT_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT STATUS LENGTH, POSITION AND MASK    */
+/**************************************************************/
+/* Int_Status_0 Description - Reg Addr --> 0x1C, Bit --> 0 */
+#define BMI160_USER_INTR_STAT_0_STEP_INTR__POS           (0)
+#define BMI160_USER_INTR_STAT_0_STEP_INTR__LEN           (1)
+#define BMI160_USER_INTR_STAT_0_STEP_INTR__MSK          (0x01)
+#define BMI160_USER_INTR_STAT_0_STEP_INTR__REG          \
+		(BMI160_USER_INTR_STAT_0_ADDR)
+/**************************************************************/
+/**\name	SIGNIFICANT INTERRUPT STATUS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_0 Description - Reg Addr --> 0x1C, Bit --> 1 */
+#define BMI160_USER_INTR_STAT_0_SIGNIFICANT_INTR__POS		(1)
+#define BMI160_USER_INTR_STAT_0_SIGNIFICANT_INTR__LEN		(1)
+#define BMI160_USER_INTR_STAT_0_SIGNIFICANT_INTR__MSK		(0x02)
+#define BMI160_USER_INTR_STAT_0_SIGNIFICANT_INTR__REG       \
+		(BMI160_USER_INTR_STAT_0_ADDR)
+/**************************************************************/
+/**\name	ANY_MOTION INTERRUPT STATUS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_0 Description - Reg Addr --> 0x1C, Bit --> 2 */
+#define BMI160_USER_INTR_STAT_0_ANY_MOTION__POS           (2)
+#define BMI160_USER_INTR_STAT_0_ANY_MOTION__LEN           (1)
+#define BMI160_USER_INTR_STAT_0_ANY_MOTION__MSK          (0x04)
+#define BMI160_USER_INTR_STAT_0_ANY_MOTION__REG          \
+		(BMI160_USER_INTR_STAT_0_ADDR)
+/**************************************************************/
+/**\name	PMU TRIGGER INTERRUPT STATUS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_0 Description - Reg Addr --> 0x1C, Bit --> 3 */
+#define BMI160_USER_INTR_STAT_0_PMU_TRIGGER__POS           3
+#define BMI160_USER_INTR_STAT_0_PMU_TRIGGER__LEN           (1)
+#define BMI160_USER_INTR_STAT_0_PMU_TRIGGER__MSK          (0x08)
+#define BMI160_USER_INTR_STAT_0_PMU_TRIGGER__REG          \
+		(BMI160_USER_INTR_STAT_0_ADDR)
+/**************************************************************/
+/**\name	DOUBLE TAP INTERRUPT STATUS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_0 Description - Reg Addr --> 0x1C, Bit --> 4 */
+#define BMI160_USER_INTR_STAT_0_DOUBLE_TAP_INTR__POS           4
+#define BMI160_USER_INTR_STAT_0_DOUBLE_TAP_INTR__LEN           (1)
+#define BMI160_USER_INTR_STAT_0_DOUBLE_TAP_INTR__MSK          (0x10)
+#define BMI160_USER_INTR_STAT_0_DOUBLE_TAP_INTR__REG          \
+		(BMI160_USER_INTR_STAT_0_ADDR)
+/**************************************************************/
+/**\name	SINGLE TAP INTERRUPT STATUS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_0 Description - Reg Addr --> 0x1C, Bit --> 5 */
+#define BMI160_USER_INTR_STAT_0_SINGLE_TAP_INTR__POS           5
+#define BMI160_USER_INTR_STAT_0_SINGLE_TAP_INTR__LEN           (1)
+#define BMI160_USER_INTR_STAT_0_SINGLE_TAP_INTR__MSK          (0x20)
+#define BMI160_USER_INTR_STAT_0_SINGLE_TAP_INTR__REG          \
+		(BMI160_USER_INTR_STAT_0_ADDR)
+/**************************************************************/
+/**\name	ORIENT INTERRUPT STATUS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_0 Description - Reg Addr --> 0x1C, Bit --> 6 */
+#define BMI160_USER_INTR_STAT_0_ORIENT__POS           (6)
+#define BMI160_USER_INTR_STAT_0_ORIENT__LEN           (1)
+#define BMI160_USER_INTR_STAT_0_ORIENT__MSK          (0x40)
+#define BMI160_USER_INTR_STAT_0_ORIENT__REG          \
+		(BMI160_USER_INTR_STAT_0_ADDR)
+/**************************************************************/
+/**\name	FLAT INTERRUPT STATUS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_0 Description - Reg Addr --> 0x1C, Bit --> 7 */
+#define BMI160_USER_INTR_STAT_0_FLAT__POS           (7)
+#define BMI160_USER_INTR_STAT_0_FLAT__LEN           (1)
+#define BMI160_USER_INTR_STAT_0_FLAT__MSK          (0x80)
+#define BMI160_USER_INTR_STAT_0_FLAT__REG          \
+		(BMI160_USER_INTR_STAT_0_ADDR)
+/**************************************************************/
+/**\name	HIGH_G INTERRUPT STATUS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_1 Description - Reg Addr --> 0x1D, Bit --> 2 */
+#define BMI160_USER_INTR_STAT_1_HIGH_G_INTR__POS               (2)
+#define BMI160_USER_INTR_STAT_1_HIGH_G_INTR__LEN               (1)
+#define BMI160_USER_INTR_STAT_1_HIGH_G_INTR__MSK              (0x04)
+#define BMI160_USER_INTR_STAT_1_HIGH_G_INTR__REG              \
+		(BMI160_USER_INTR_STAT_1_ADDR)
+/**************************************************************/
+/**\name	LOW_G INTERRUPT STATUS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_1 Description - Reg Addr --> 0x1D, Bit --> 3 */
+#define BMI160_USER_INTR_STAT_1_LOW_G_INTR__POS               (3)
+#define BMI160_USER_INTR_STAT_1_LOW_G_INTR__LEN               (1)
+#define BMI160_USER_INTR_STAT_1_LOW_G_INTR__MSK              (0x08)
+#define BMI160_USER_INTR_STAT_1_LOW_G_INTR__REG              \
+		(BMI160_USER_INTR_STAT_1_ADDR)
+/**************************************************************/
+/**\name	DATA READY INTERRUPT STATUS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_1 Description - Reg Addr --> 0x1D, Bit --> 4 */
+#define BMI160_USER_INTR_STAT_1_DATA_RDY_INTR__POS               (4)
+#define BMI160_USER_INTR_STAT_1_DATA_RDY_INTR__LEN               (1)
+#define BMI160_USER_INTR_STAT_1_DATA_RDY_INTR__MSK               (0x10)
+#define BMI160_USER_INTR_STAT_1_DATA_RDY_INTR__REG               \
+		(BMI160_USER_INTR_STAT_1_ADDR)
+/**************************************************************/
+/**\name	FIFO FULL INTERRUPT STATUS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_1 Description - Reg Addr --> 0x1D, Bit --> 5 */
+#define BMI160_USER_INTR_STAT_1_FIFO_FULL_INTR__POS               (5)
+#define BMI160_USER_INTR_STAT_1_FIFO_FULL_INTR__LEN               (1)
+#define BMI160_USER_INTR_STAT_1_FIFO_FULL_INTR__MSK               (0x20)
+#define BMI160_USER_INTR_STAT_1_FIFO_FULL_INTR__REG               \
+		(BMI160_USER_INTR_STAT_1_ADDR)
+/**************************************************************/
+/**\name FIFO WATERMARK INTERRUPT STATUS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_1 Description - Reg Addr --> 0x1D, Bit --> 6 */
+#define BMI160_USER_INTR_STAT_1_FIFO_WM_INTR__POS               (6)
+#define BMI160_USER_INTR_STAT_1_FIFO_WM_INTR__LEN               (1)
+#define BMI160_USER_INTR_STAT_1_FIFO_WM_INTR__MSK               (0x40)
+#define BMI160_USER_INTR_STAT_1_FIFO_WM_INTR__REG               \
+		(BMI160_USER_INTR_STAT_1_ADDR)
+/**************************************************************/
+/**\name	NO MOTION INTERRUPT STATUS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_1 Description - Reg Addr --> 0x1D, Bit --> 7 */
+#define BMI160_USER_INTR_STAT_1_NOMOTION_INTR__POS               (7)
+#define BMI160_USER_INTR_STAT_1_NOMOTION_INTR__LEN               (1)
+#define BMI160_USER_INTR_STAT_1_NOMOTION_INTR__MSK               (0x80)
+#define BMI160_USER_INTR_STAT_1_NOMOTION_INTR__REG               \
+		(BMI160_USER_INTR_STAT_1_ADDR)
+/**************************************************************/
+/**\name	ANY MOTION-XYZ AXIS INTERRUPT STATUS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 0 */
+#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_X__POS               (0)
+#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_X__LEN               (1)
+#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_X__MSK               (0x01)
+#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_X__REG               \
+		(BMI160_USER_INTR_STAT_2_ADDR)
+
+/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 1 */
+#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Y__POS               (1)
+#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Y__LEN               (1)
+#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Y__MSK               (0x02)
+#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Y__REG               \
+		(BMI160_USER_INTR_STAT_2_ADDR)
+
+/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 2 */
+#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Z__POS               (2)
+#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Z__LEN               (1)
+#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Z__MSK               (0x04)
+#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Z__REG               \
+		(BMI160_USER_INTR_STAT_2_ADDR)
+/**************************************************************/
+/**\name	ANY MOTION SIGN LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 3 */
+#define BMI160_USER_INTR_STAT_2_ANY_MOTION_SIGN__POS               (3)
+#define BMI160_USER_INTR_STAT_2_ANY_MOTION_SIGN__LEN               (1)
+#define BMI160_USER_INTR_STAT_2_ANY_MOTION_SIGN__MSK               (0x08)
+#define BMI160_USER_INTR_STAT_2_ANY_MOTION_SIGN__REG               \
+		(BMI160_USER_INTR_STAT_2_ADDR)
+/**************************************************************/
+/**\name	TAP_XYZ AND SIGN LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 4 */
+#define BMI160_USER_INTR_STAT_2_TAP_FIRST_X__POS               (4)
+#define BMI160_USER_INTR_STAT_2_TAP_FIRST_X__LEN               (1)
+#define BMI160_USER_INTR_STAT_2_TAP_FIRST_X__MSK               (0x10)
+#define BMI160_USER_INTR_STAT_2_TAP_FIRST_X__REG               \
+		(BMI160_USER_INTR_STAT_2_ADDR)
+
+/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 5 */
+#define BMI160_USER_INTR_STAT_2_TAP_FIRST_Y__POS               (5)
+#define BMI160_USER_INTR_STAT_2_TAP_FIRST_Y__LEN               (1)
+#define BMI160_USER_INTR_STAT_2_TAP_FIRST_Y__MSK               (0x20)
+#define BMI160_USER_INTR_STAT_2_TAP_FIRST_Y__REG               \
+		(BMI160_USER_INTR_STAT_2_ADDR)
+
+/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 6 */
+#define BMI160_USER_INTR_STAT_2_TAP_FIRST_Z__POS               (6)
+#define BMI160_USER_INTR_STAT_2_TAP_FIRST_Z__LEN               (1)
+#define BMI160_USER_INTR_STAT_2_TAP_FIRST_Z__MSK               (0x40)
+#define BMI160_USER_INTR_STAT_2_TAP_FIRST_Z__REG               \
+		(BMI160_USER_INTR_STAT_2_ADDR)
+
+/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 7 */
+#define BMI160_USER_INTR_STAT_2_TAP_SIGN__POS               (7)
+#define BMI160_USER_INTR_STAT_2_TAP_SIGN__LEN               (1)
+#define BMI160_USER_INTR_STAT_2_TAP_SIGN__MSK               (0x80)
+#define BMI160_USER_INTR_STAT_2_TAP_SIGN__REG               \
+		(BMI160_USER_INTR_STAT_2_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT SATAUS FOR WHOLE 0x1E LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 0...7 */
+#define BMI160_USER_INTR_STAT_2__POS               (0)
+#define BMI160_USER_INTR_STAT_2__LEN               (8)
+#define BMI160_USER_INTR_STAT_2__MSK               (0xFF)
+#define BMI160_USER_INTR_STAT_2__REG               \
+		(BMI160_USER_INTR_STAT_2_ADDR)
+/**************************************************************/
+/**\name	HIGH_G-XYZ AND SIGN LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_3 Description - Reg Addr --> (0x1F), Bit --> 0 */
+#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_X__POS               (0)
+#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_X__LEN               (1)
+#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_X__MSK               (0x01)
+#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_X__REG               \
+		(BMI160_USER_INTR_STAT_3_ADDR)
+
+/* Int_Status_3 Description - Reg Addr --> 0x1E, Bit --> 1 */
+#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Y__POS               (1)
+#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Y__LEN               (1)
+#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Y__MSK               (0x02)
+#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Y__REG               \
+		(BMI160_USER_INTR_STAT_3_ADDR)
+
+/* Int_Status_3 Description - Reg Addr --> (0x1F), Bit --> 2 */
+#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Z__POS               (2)
+#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Z__LEN               (1)
+#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Z__MSK               (0x04)
+#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Z__REG               \
+		(BMI160_USER_INTR_STAT_3_ADDR)
+
+/* Int_Status_3 Description - Reg Addr --> (0x1F), Bit --> 3 */
+#define BMI160_USER_INTR_STAT_3_HIGH_G_SIGN__POS               (3)
+#define BMI160_USER_INTR_STAT_3_HIGH_G_SIGN__LEN               (1)
+#define BMI160_USER_INTR_STAT_3_HIGH_G_SIGN__MSK               (0x08)
+#define BMI160_USER_INTR_STAT_3_HIGH_G_SIGN__REG               \
+		(BMI160_USER_INTR_STAT_3_ADDR)
+/**************************************************************/
+/**\name	ORIENT XY and Z AXIS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_3 Description - Reg Addr --> (0x1F), Bit --> 4...5 */
+#define BMI160_USER_INTR_STAT_3_ORIENT_XY__POS               (4)
+#define BMI160_USER_INTR_STAT_3_ORIENT_XY__LEN               (2)
+#define BMI160_USER_INTR_STAT_3_ORIENT_XY__MSK               (0x30)
+#define BMI160_USER_INTR_STAT_3_ORIENT_XY__REG               \
+		(BMI160_USER_INTR_STAT_3_ADDR)
+
+/* Int_Status_3 Description - Reg Addr --> (0x1F), Bit --> 6 */
+#define BMI160_USER_INTR_STAT_3_ORIENT_Z__POS               (6)
+#define BMI160_USER_INTR_STAT_3_ORIENT_Z__LEN               (1)
+#define BMI160_USER_INTR_STAT_3_ORIENT_Z__MSK               (0x40)
+#define BMI160_USER_INTR_STAT_3_ORIENT_Z__REG               \
+		(BMI160_USER_INTR_STAT_3_ADDR)
+/**************************************************************/
+/**\name	FLAT LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_3 Description - Reg Addr --> (0x1F), Bit --> 7 */
+#define BMI160_USER_INTR_STAT_3_FLAT__POS               (7)
+#define BMI160_USER_INTR_STAT_3_FLAT__LEN               (1)
+#define BMI160_USER_INTR_STAT_3_FLAT__MSK               (0x80)
+#define BMI160_USER_INTR_STAT_3_FLAT__REG               \
+		(BMI160_USER_INTR_STAT_3_ADDR)
+/**************************************************************/
+/**\name	(0x1F) LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_3 Description - Reg Addr --> (0x1F), Bit --> 0...7 */
+#define BMI160_USER_INTR_STAT_3__POS               (0)
+#define BMI160_USER_INTR_STAT_3__LEN               (8)
+#define BMI160_USER_INTR_STAT_3__MSK               (0xFF)
+#define BMI160_USER_INTR_STAT_3__REG               \
+		(BMI160_USER_INTR_STAT_3_ADDR)
+/**************************************************************/
+/**\name	TEMPERATURE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Temperature Description - LSB Reg Addr --> (0x20), Bit --> 0...7 */
+#define BMI160_USER_TEMP_LSB_VALUE__POS               (0)
+#define BMI160_USER_TEMP_LSB_VALUE__LEN               (8)
+#define BMI160_USER_TEMP_LSB_VALUE__MSK               (0xFF)
+#define BMI160_USER_TEMP_LSB_VALUE__REG               \
+		(BMI160_USER_TEMPERATURE_0_ADDR)
+
+/* Temperature Description - LSB Reg Addr --> 0x21, Bit --> 0...7 */
+#define BMI160_USER_TEMP_MSB_VALUE__POS               (0)
+#define BMI160_USER_TEMP_MSB_VALUE__LEN               (8)
+#define BMI160_USER_TEMP_MSB_VALUE__MSK               (0xFF)
+#define BMI160_USER_TEMP_MSB_VALUE__REG               \
+		(BMI160_USER_TEMPERATURE_1_ADDR)
+/**************************************************************/
+/**\name	FIFO BYTE COUNTER LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Fifo_Length0 Description - Reg Addr --> 0x22, Bit --> 0...7 */
+#define BMI160_USER_FIFO_BYTE_COUNTER_LSB__POS           (0)
+#define BMI160_USER_FIFO_BYTE_COUNTER_LSB__LEN           (8)
+#define BMI160_USER_FIFO_BYTE_COUNTER_LSB__MSK          (0xFF)
+#define BMI160_USER_FIFO_BYTE_COUNTER_LSB__REG          \
+		(BMI160_USER_FIFO_LENGTH_0_ADDR)
+
+/*Fifo_Length1 Description - Reg Addr --> 0x23, Bit --> 0...2 */
+#define BMI160_USER_FIFO_BYTE_COUNTER_MSB__POS           (0)
+#define BMI160_USER_FIFO_BYTE_COUNTER_MSB__LEN           3
+#define BMI160_USER_FIFO_BYTE_COUNTER_MSB__MSK          (0x07)
+#define BMI160_USER_FIFO_BYTE_COUNTER_MSB__REG          \
+		(BMI160_USER_FIFO_LENGTH_1_ADDR)
+
+/**************************************************************/
+/**\name	FIFO DATA LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Fifo_Data Description - Reg Addr --> 0x24, Bit --> 0...7 */
+#define BMI160_USER_FIFO_DATA__POS           (0)
+#define BMI160_USER_FIFO_DATA__LEN           (8)
+#define BMI160_USER_FIFO_DATA__MSK          (0xFF)
+#define BMI160_USER_FIFO_DATA__REG          (BMI160_USER_FIFO_DATA_ADDR)
+
+/**************************************************************/
+/**\name	ACCEL CONFIGURATION LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Acc_Conf Description - Reg Addr --> (0x40), Bit --> 0...3 */
+#define BMI160_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE__POS               (0)
+#define BMI160_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE__LEN               (4)
+#define BMI160_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE__MSK               (0x0F)
+#define BMI160_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE__REG		       \
+(BMI160_USER_ACCEL_CONFIG_ADDR)
+
+/* Acc_Conf Description - Reg Addr --> (0x40), Bit --> 4...6 */
+#define BMI160_USER_ACCEL_CONFIG_ACCEL_BW__POS               (4)
+#define BMI160_USER_ACCEL_CONFIG_ACCEL_BW__LEN               (3)
+#define BMI160_USER_ACCEL_CONFIG_ACCEL_BW__MSK               (0x70)
+#define BMI160_USER_ACCEL_CONFIG_ACCEL_BW__REG	(BMI160_USER_ACCEL_CONFIG_ADDR)
+
+/* Acc_Conf Description - Reg Addr --> (0x40), Bit --> 7 */
+#define BMI160_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING__POS           (7)
+#define BMI160_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING__LEN           (1)
+#define BMI160_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING__MSK           (0x80)
+#define BMI160_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING__REG	\
+(BMI160_USER_ACCEL_CONFIG_ADDR)
+
+/* Acc_Range Description - Reg Addr --> 0x41, Bit --> 0...3 */
+#define BMI160_USER_ACCEL_RANGE__POS               (0)
+#define BMI160_USER_ACCEL_RANGE__LEN               (4)
+#define BMI160_USER_ACCEL_RANGE__MSK               (0x0F)
+#define BMI160_USER_ACCEL_RANGE__REG              \
+(BMI160_USER_ACCEL_RANGE_ADDR)
+/**************************************************************/
+/**\name	GYRO CONFIGURATION LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Gyro_Conf Description - Reg Addr --> (0x42), Bit --> 0...3 */
+#define BMI160_USER_GYRO_CONFIG_OUTPUT_DATA_RATE__POS               (0)
+#define BMI160_USER_GYRO_CONFIG_OUTPUT_DATA_RATE__LEN               (4)
+#define BMI160_USER_GYRO_CONFIG_OUTPUT_DATA_RATE__MSK               (0x0F)
+#define BMI160_USER_GYRO_CONFIG_OUTPUT_DATA_RATE__REG               \
+(BMI160_USER_GYRO_CONFIG_ADDR)
+
+/* Gyro_Conf Description - Reg Addr --> (0x42), Bit --> 4...5 */
+#define BMI160_USER_GYRO_CONFIG_BW__POS               (4)
+#define BMI160_USER_GYRO_CONFIG_BW__LEN               (2)
+#define BMI160_USER_GYRO_CONFIG_BW__MSK               (0x30)
+#define BMI160_USER_GYRO_CONFIG_BW__REG               \
+(BMI160_USER_GYRO_CONFIG_ADDR)
+
+/* Gyr_Range Description - Reg Addr --> 0x43, Bit --> 0...2 */
+#define BMI160_USER_GYRO_RANGE__POS               (0)
+#define BMI160_USER_GYRO_RANGE__LEN               (3)
+#define BMI160_USER_GYRO_RANGE__MSK               (0x07)
+#define BMI160_USER_GYRO_RANGE__REG               (BMI160_USER_GYRO_RANGE_ADDR)
+/**************************************************************/
+/**\name	MAG CONFIGURATION LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Mag_Conf Description - Reg Addr --> (0x44), Bit --> 0...3 */
+#define BMI160_USER_MAG_CONFIG_OUTPUT_DATA_RATE__POS               (0)
+#define BMI160_USER_MAG_CONFIG_OUTPUT_DATA_RATE__LEN               (4)
+#define BMI160_USER_MAG_CONFIG_OUTPUT_DATA_RATE__MSK               (0x0F)
+#define BMI160_USER_MAG_CONFIG_OUTPUT_DATA_RATE__REG               \
+(BMI160_USER_MAG_CONFIG_ADDR)
+/**************************************************************/
+/**\name	FIFO DOWNS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Fifo_Downs Description - Reg Addr --> 0x45, Bit --> 0...2 */
+#define BMI160_USER_FIFO_DOWN_GYRO__POS               (0)
+#define BMI160_USER_FIFO_DOWN_GYRO__LEN               (3)
+#define BMI160_USER_FIFO_DOWN_GYRO__MSK               (0x07)
+#define BMI160_USER_FIFO_DOWN_GYRO__REG	(BMI160_USER_FIFO_DOWN_ADDR)
+/**************************************************************/
+/**\name	FIFO FILTER FOR ACCEL AND GYRO LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Fifo_filt Description - Reg Addr --> 0x45, Bit --> 3 */
+#define BMI160_USER_FIFO_FILTER_GYRO__POS               (3)
+#define BMI160_USER_FIFO_FILTER_GYRO__LEN               (1)
+#define BMI160_USER_FIFO_FILTER_GYRO__MSK               (0x08)
+#define BMI160_USER_FIFO_FILTER_GYRO__REG	  (BMI160_USER_FIFO_DOWN_ADDR)
+
+/* Fifo_Downs Description - Reg Addr --> 0x45, Bit --> 4...6 */
+#define BMI160_USER_FIFO_DOWN_ACCEL__POS               (4)
+#define BMI160_USER_FIFO_DOWN_ACCEL__LEN               (3)
+#define BMI160_USER_FIFO_DOWN_ACCEL__MSK               (0x70)
+#define BMI160_USER_FIFO_DOWN_ACCEL__REG	(BMI160_USER_FIFO_DOWN_ADDR)
+
+/* Fifo_FILT Description - Reg Addr --> 0x45, Bit --> 7 */
+#define BMI160_USER_FIFO_FILTER_ACCEL__POS               (7)
+#define BMI160_USER_FIFO_FILTER_ACCEL__LEN               (1)
+#define BMI160_USER_FIFO_FILTER_ACCEL__MSK               (0x80)
+#define BMI160_USER_FIFO_FILTER_ACCEL__REG	(BMI160_USER_FIFO_DOWN_ADDR)
+/**************************************************************/
+/**\name	FIFO WATER MARK LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Fifo_Config_0 Description - Reg Addr --> 0x46, Bit --> 0...7 */
+#define BMI160_USER_FIFO_WM__POS               (0)
+#define BMI160_USER_FIFO_WM__LEN               (8)
+#define BMI160_USER_FIFO_WM__MSK               (0xFF)
+#define BMI160_USER_FIFO_WM__REG	(BMI160_USER_FIFO_CONFIG_0_ADDR)
+/**************************************************************/
+/**\name	FIFO TIME LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Fifo_Config_1 Description - Reg Addr --> 0x47, Bit --> 1 */
+#define BMI160_USER_FIFO_TIME_ENABLE__POS               (1)
+#define BMI160_USER_FIFO_TIME_ENABLE__LEN               (1)
+#define BMI160_USER_FIFO_TIME_ENABLE__MSK               (0x02)
+#define BMI160_USER_FIFO_TIME_ENABLE__REG	(BMI160_USER_FIFO_CONFIG_1_ADDR)
+/**************************************************************/
+/**\name	FIFO TAG INTERRUPT LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Fifo_Config_1 Description - Reg Addr --> 0x47, Bit --> 2 */
+#define BMI160_USER_FIFO_TAG_INTR2_ENABLE__POS               (2)
+#define BMI160_USER_FIFO_TAG_INTR2_ENABLE__LEN               (1)
+#define BMI160_USER_FIFO_TAG_INTR2_ENABLE__MSK               (0x04)
+#define BMI160_USER_FIFO_TAG_INTR2_ENABLE__REG	(BMI160_USER_FIFO_CONFIG_1_ADDR)
+
+/* Fifo_Config_1 Description - Reg Addr --> 0x47, Bit --> 3 */
+#define BMI160_USER_FIFO_TAG_INTR1_ENABLE__POS               (3)
+#define BMI160_USER_FIFO_TAG_INTR1_ENABLE__LEN               (1)
+#define BMI160_USER_FIFO_TAG_INTR1_ENABLE__MSK               (0x08)
+#define BMI160_USER_FIFO_TAG_INTR1_ENABLE__REG	(BMI160_USER_FIFO_CONFIG_1_ADDR)
+/**************************************************************/
+/**\name	FIFO HEADER LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Fifo_Config_1 Description - Reg Addr --> 0x47, Bit --> 4 */
+#define BMI160_USER_FIFO_HEADER_ENABLE__POS               (4)
+#define BMI160_USER_FIFO_HEADER_ENABLE__LEN               (1)
+#define BMI160_USER_FIFO_HEADER_ENABLE__MSK               (0x10)
+#define BMI160_USER_FIFO_HEADER_ENABLE__REG		         \
+(BMI160_USER_FIFO_CONFIG_1_ADDR)
+/**************************************************************/
+/**\name	FIFO MAG ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Fifo_Config_1 Description - Reg Addr --> 0x47, Bit --> 5 */
+#define BMI160_USER_FIFO_MAG_ENABLE__POS               (5)
+#define BMI160_USER_FIFO_MAG_ENABLE__LEN               (1)
+#define BMI160_USER_FIFO_MAG_ENABLE__MSK               (0x20)
+#define BMI160_USER_FIFO_MAG_ENABLE__REG		     \
+(BMI160_USER_FIFO_CONFIG_1_ADDR)
+/**************************************************************/
+/**\name	FIFO ACCEL ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Fifo_Config_1 Description - Reg Addr --> 0x47, Bit --> 6 */
+#define BMI160_USER_FIFO_ACCEL_ENABLE__POS               (6)
+#define BMI160_USER_FIFO_ACCEL_ENABLE__LEN               (1)
+#define BMI160_USER_FIFO_ACCEL_ENABLE__MSK               (0x40)
+#define BMI160_USER_FIFO_ACCEL_ENABLE__REG		        \
+(BMI160_USER_FIFO_CONFIG_1_ADDR)
+/**************************************************************/
+/**\name	FIFO GYRO ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Fifo_Config_1 Description - Reg Addr --> 0x47, Bit --> 7 */
+#define BMI160_USER_FIFO_GYRO_ENABLE__POS               (7)
+#define BMI160_USER_FIFO_GYRO_ENABLE__LEN               (1)
+#define BMI160_USER_FIFO_GYRO_ENABLE__MSK               (0x80)
+#define BMI160_USER_FIFO_GYRO_ENABLE__REG		       \
+(BMI160_USER_FIFO_CONFIG_1_ADDR)
+
+/**************************************************************/
+/**\name	MAG I2C ADDRESS SELECTION LENGTH, POSITION AND MASK*/
+/**************************************************************/
+
+/* Mag_IF_0 Description - Reg Addr --> 0x4b, Bit --> 1...7 */
+#define BMI160_USER_I2C_DEVICE_ADDR__POS               (1)
+#define BMI160_USER_I2C_DEVICE_ADDR__LEN               (7)
+#define BMI160_USER_I2C_DEVICE_ADDR__MSK               (0xFE)
+#define BMI160_USER_I2C_DEVICE_ADDR__REG	(BMI160_USER_MAG_IF_0_ADDR)
+/**************************************************************/
+/**\name MAG CONFIGURATION FOR SECONDARY
+	INTERFACE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Mag_IF_1 Description - Reg Addr --> 0x4c, Bit --> 0...1 */
+#define BMI160_USER_MAG_BURST__POS               (0)
+#define BMI160_USER_MAG_BURST__LEN               (2)
+#define BMI160_USER_MAG_BURST__MSK               (0x03)
+#define BMI160_USER_MAG_BURST__REG               (BMI160_USER_MAG_IF_1_ADDR)
+
+/* Mag_IF_1 Description - Reg Addr --> 0x4c, Bit --> 2...5 */
+#define BMI160_USER_MAG_OFFSET__POS               (2)
+#define BMI160_USER_MAG_OFFSET__LEN               (4)
+#define BMI160_USER_MAG_OFFSET__MSK               (0x3C)
+#define BMI160_USER_MAG_OFFSET__REG               (BMI160_USER_MAG_IF_1_ADDR)
+
+/* Mag_IF_1 Description - Reg Addr --> 0x4c, Bit --> 7 */
+#define BMI160_USER_MAG_MANUAL_ENABLE__POS               (7)
+#define BMI160_USER_MAG_MANUAL_ENABLE__LEN               (1)
+#define BMI160_USER_MAG_MANUAL_ENABLE__MSK               (0x80)
+#define BMI160_USER_MAG_MANUAL_ENABLE__REG               \
+(BMI160_USER_MAG_IF_1_ADDR)
+
+/* Mag_IF_2 Description - Reg Addr --> 0x4d, Bit -->0... 7 */
+#define BMI160_USER_READ_ADDR__POS               (0)
+#define BMI160_USER_READ_ADDR__LEN               (8)
+#define BMI160_USER_READ_ADDR__MSK               (0xFF)
+#define BMI160_USER_READ_ADDR__REG               (BMI160_USER_MAG_IF_2_ADDR)
+
+/* Mag_IF_3 Description - Reg Addr --> 0x4e, Bit -->0... 7 */
+#define BMI160_USER_WRITE_ADDR__POS               (0)
+#define BMI160_USER_WRITE_ADDR__LEN               (8)
+#define BMI160_USER_WRITE_ADDR__MSK               (0xFF)
+#define BMI160_USER_WRITE_ADDR__REG               (BMI160_USER_MAG_IF_3_ADDR)
+
+/* Mag_IF_4 Description - Reg Addr --> 0x4f, Bit -->0... 7 */
+#define BMI160_USER_WRITE_DATA__POS               (0)
+#define BMI160_USER_WRITE_DATA__LEN               (8)
+#define BMI160_USER_WRITE_DATA__MSK               (0xFF)
+#define BMI160_USER_WRITE_DATA__REG               (BMI160_USER_MAG_IF_4_ADDR)
+/**************************************************************/
+/**\name	ANY MOTION XYZ AXIS ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_En_0 Description - Reg Addr --> 0x50, Bit -->0 */
+#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE__POS               (0)
+#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE__LEN               (1)
+#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE__MSK               (0x01)
+#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE__REG	              \
+(BMI160_USER_INTR_ENABLE_0_ADDR)
+
+/* Int_En_0 Description - Reg Addr --> 0x50, Bit -->1 */
+#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE__POS               (1)
+#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE__LEN               (1)
+#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE__MSK               (0x02)
+#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE__REG	          \
+(BMI160_USER_INTR_ENABLE_0_ADDR)
+
+/* Int_En_0 Description - Reg Addr --> 0x50, Bit -->2 */
+#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE__POS               (2)
+#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE__LEN               (1)
+#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE__MSK               (0x04)
+#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE__REG	            \
+(BMI160_USER_INTR_ENABLE_0_ADDR)
+/**************************************************************/
+/**\name	DOUBLE TAP ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_En_0 Description - Reg Addr --> 0x50, Bit -->4 */
+#define BMI160_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE__POS               (4)
+#define BMI160_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE__LEN               (1)
+#define BMI160_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE__MSK               (0x10)
+#define BMI160_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE__REG	        \
+(BMI160_USER_INTR_ENABLE_0_ADDR)
+/**************************************************************/
+/**\name	SINGLE TAP ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_En_0 Description - Reg Addr --> 0x50, Bit -->5 */
+#define BMI160_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE__POS               (5)
+#define BMI160_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE__LEN               (1)
+#define BMI160_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE__MSK               (0x20)
+#define BMI160_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE__REG	       \
+(BMI160_USER_INTR_ENABLE_0_ADDR)
+/**************************************************************/
+/**\name	ORIENT ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_En_0 Description - Reg Addr --> 0x50, Bit -->6 */
+#define BMI160_USER_INTR_ENABLE_0_ORIENT_ENABLE__POS               (6)
+#define BMI160_USER_INTR_ENABLE_0_ORIENT_ENABLE__LEN               (1)
+#define BMI160_USER_INTR_ENABLE_0_ORIENT_ENABLE__MSK               (0x40)
+#define BMI160_USER_INTR_ENABLE_0_ORIENT_ENABLE__REG	           \
+(BMI160_USER_INTR_ENABLE_0_ADDR)
+/**************************************************************/
+/**\name	FLAT ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_En_0 Description - Reg Addr --> 0x50, Bit -->7 */
+#define BMI160_USER_INTR_ENABLE_0_FLAT_ENABLE__POS               (7)
+#define BMI160_USER_INTR_ENABLE_0_FLAT_ENABLE__LEN               (1)
+#define BMI160_USER_INTR_ENABLE_0_FLAT_ENABLE__MSK               (0x80)
+#define BMI160_USER_INTR_ENABLE_0_FLAT_ENABLE__REG	           \
+(BMI160_USER_INTR_ENABLE_0_ADDR)
+/**************************************************************/
+/**\name	HIGH_G XYZ ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_En_1 Description - Reg Addr --> (0x51), Bit -->0 */
+#define BMI160_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE__POS               (0)
+#define BMI160_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE__LEN               (1)
+#define BMI160_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE__MSK               (0x01)
+#define BMI160_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE__REG	           \
+(BMI160_USER_INTR_ENABLE_1_ADDR)
+
+/* Int_En_1 Description - Reg Addr --> (0x51), Bit -->1 */
+#define BMI160_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE__POS               (1)
+#define BMI160_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE__LEN               (1)
+#define BMI160_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE__MSK               (0x02)
+#define BMI160_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE__REG	           \
+(BMI160_USER_INTR_ENABLE_1_ADDR)
+
+/* Int_En_1 Description - Reg Addr --> (0x51), Bit -->2 */
+#define BMI160_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE__POS               (2)
+#define BMI160_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE__LEN               (1)
+#define BMI160_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE__MSK               (0x04)
+#define BMI160_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE__REG	           \
+(BMI160_USER_INTR_ENABLE_1_ADDR)
+/**************************************************************/
+/**\name	LOW_G ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_En_1 Description - Reg Addr --> (0x51), Bit -->3 */
+#define BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE__POS               (3)
+#define BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE__LEN               (1)
+#define BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE__MSK               (0x08)
+#define BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE__REG	          \
+(BMI160_USER_INTR_ENABLE_1_ADDR)
+/**************************************************************/
+/**\name	DATA READY ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_En_1 Description - Reg Addr --> (0x51), Bit -->4 */
+#define BMI160_USER_INTR_ENABLE_1_DATA_RDY_ENABLE__POS               (4)
+#define BMI160_USER_INTR_ENABLE_1_DATA_RDY_ENABLE__LEN               (1)
+#define BMI160_USER_INTR_ENABLE_1_DATA_RDY_ENABLE__MSK               (0x10)
+#define BMI160_USER_INTR_ENABLE_1_DATA_RDY_ENABLE__REG	            \
+(BMI160_USER_INTR_ENABLE_1_ADDR)
+/**************************************************************/
+/**\name	FIFO FULL AND WATER MARK ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_En_1 Description - Reg Addr --> (0x51), Bit -->5 */
+#define BMI160_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE__POS               (5)
+#define BMI160_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE__LEN               (1)
+#define BMI160_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE__MSK               (0x20)
+#define BMI160_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE__REG	              \
+(BMI160_USER_INTR_ENABLE_1_ADDR)
+
+/* Int_En_1 Description - Reg Addr --> (0x51), Bit -->6 */
+#define BMI160_USER_INTR_ENABLE_1_FIFO_WM_ENABLE__POS               (6)
+#define BMI160_USER_INTR_ENABLE_1_FIFO_WM_ENABLE__LEN               (1)
+#define BMI160_USER_INTR_ENABLE_1_FIFO_WM_ENABLE__MSK               (0x40)
+#define BMI160_USER_INTR_ENABLE_1_FIFO_WM_ENABLE__REG	           \
+(BMI160_USER_INTR_ENABLE_1_ADDR)
+/**************************************************************/
+/**\name	NO MOTION XYZ ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_En_2 Description - Reg Addr --> (0x52), Bit -->0 */
+#define BMI160_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE__POS               (0)
+#define BMI160_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE__LEN               (1)
+#define BMI160_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE__MSK               (0x01)
+#define BMI160_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE__REG	  \
+(BMI160_USER_INTR_ENABLE_2_ADDR)
+
+/* Int_En_2 Description - Reg Addr --> (0x52), Bit -->1 */
+#define BMI160_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE__POS               (1)
+#define BMI160_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE__LEN               (1)
+#define BMI160_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE__MSK               (0x02)
+#define BMI160_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE__REG	  \
+(BMI160_USER_INTR_ENABLE_2_ADDR)
+
+/* Int_En_2 Description - Reg Addr --> (0x52), Bit -->2 */
+#define BMI160_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE__POS               (2)
+#define BMI160_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE__LEN               (1)
+#define BMI160_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE__MSK               (0x04)
+#define BMI160_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE__REG	  \
+(BMI160_USER_INTR_ENABLE_2_ADDR)
+/**************************************************************/
+/**\name	STEP DETECTOR ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_En_2 Description - Reg Addr --> (0x52), Bit -->3 */
+#define BMI160_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE__POS               (3)
+#define BMI160_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE__LEN               (1)
+#define BMI160_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE__MSK               (0x08)
+#define BMI160_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE__REG	  \
+(BMI160_USER_INTR_ENABLE_2_ADDR)
+/**************************************************************/
+/**\name	EDGE CONTROL ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Out_Ctrl Description - Reg Addr --> 0x53, Bit -->0 */
+#define BMI160_USER_INTR1_EDGE_CTRL__POS               (0)
+#define BMI160_USER_INTR1_EDGE_CTRL__LEN               (1)
+#define BMI160_USER_INTR1_EDGE_CTRL__MSK               (0x01)
+#define BMI160_USER_INTR1_EDGE_CTRL__REG		\
+(BMI160_USER_INTR_OUT_CTRL_ADDR)
+/**************************************************************/
+/**\name	LEVEL CONTROL ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Out_Ctrl Description - Reg Addr --> 0x53, Bit -->1 */
+#define BMI160_USER_INTR1_LEVEL__POS               (1)
+#define BMI160_USER_INTR1_LEVEL__LEN               (1)
+#define BMI160_USER_INTR1_LEVEL__MSK               (0x02)
+#define BMI160_USER_INTR1_LEVEL__REG               \
+(BMI160_USER_INTR_OUT_CTRL_ADDR)
+/**************************************************************/
+/**\name	OUTPUT TYPE ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Out_Ctrl Description - Reg Addr --> 0x53, Bit -->2 */
+#define BMI160_USER_INTR1_OUTPUT_TYPE__POS               (2)
+#define BMI160_USER_INTR1_OUTPUT_TYPE__LEN               (1)
+#define BMI160_USER_INTR1_OUTPUT_TYPE__MSK               (0x04)
+#define BMI160_USER_INTR1_OUTPUT_TYPE__REG               \
+(BMI160_USER_INTR_OUT_CTRL_ADDR)
+/**************************************************************/
+/**\name	OUTPUT TYPE ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Out_Ctrl Description - Reg Addr --> 0x53, Bit -->3 */
+#define BMI160_USER_INTR1_OUTPUT_ENABLE__POS               (3)
+#define BMI160_USER_INTR1_OUTPUT_ENABLE__LEN               (1)
+#define BMI160_USER_INTR1_OUTPUT_ENABLE__MSK               (0x08)
+#define BMI160_USER_INTR1_OUTPUT_ENABLE__REG		\
+(BMI160_USER_INTR_OUT_CTRL_ADDR)
+/**************************************************************/
+/**\name	EDGE CONTROL ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Out_Ctrl Description - Reg Addr --> 0x53, Bit -->4 */
+#define BMI160_USER_INTR2_EDGE_CTRL__POS               (4)
+#define BMI160_USER_INTR2_EDGE_CTRL__LEN               (1)
+#define BMI160_USER_INTR2_EDGE_CTRL__MSK               (0x10)
+#define BMI160_USER_INTR2_EDGE_CTRL__REG		\
+(BMI160_USER_INTR_OUT_CTRL_ADDR)
+/**************************************************************/
+/**\name	LEVEL CONTROL ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Out_Ctrl Description - Reg Addr --> 0x53, Bit -->5 */
+#define BMI160_USER_INTR2_LEVEL__POS               (5)
+#define BMI160_USER_INTR2_LEVEL__LEN               (1)
+#define BMI160_USER_INTR2_LEVEL__MSK               (0x20)
+#define BMI160_USER_INTR2_LEVEL__REG               \
+(BMI160_USER_INTR_OUT_CTRL_ADDR)
+/**************************************************************/
+/**\name	OUTPUT TYPE ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Out_Ctrl Description - Reg Addr --> 0x53, Bit -->6 */
+#define BMI160_USER_INTR2_OUTPUT_TYPE__POS               (6)
+#define BMI160_USER_INTR2_OUTPUT_TYPE__LEN               (1)
+#define BMI160_USER_INTR2_OUTPUT_TYPE__MSK               (0x40)
+#define BMI160_USER_INTR2_OUTPUT_TYPE__REG               \
+(BMI160_USER_INTR_OUT_CTRL_ADDR)
+
+/* Int_Out_Ctrl Description - Reg Addr --> 0x53, Bit -->7 */
+#define BMI160_USER_INTR2_OUTPUT_EN__POS               (7)
+#define BMI160_USER_INTR2_OUTPUT_EN__LEN               (1)
+#define BMI160_USER_INTR2_OUTPUT_EN__MSK               (0x80)
+#define BMI160_USER_INTR2_OUTPUT_EN__REG		\
+(BMI160_USER_INTR_OUT_CTRL_ADDR)
+/**************************************************************/
+/**\name	LATCH INTERRUPT LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Latch Description - Reg Addr --> 0x54, Bit -->0...3 */
+#define BMI160_USER_INTR_LATCH__POS               (0)
+#define BMI160_USER_INTR_LATCH__LEN               (4)
+#define BMI160_USER_INTR_LATCH__MSK               (0x0F)
+#define BMI160_USER_INTR_LATCH__REG               (BMI160_USER_INTR_LATCH_ADDR)
+/**************************************************************/
+/**\name	INPUT ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Latch Description - Reg Addr --> 0x54, Bit -->4 */
+#define BMI160_USER_INTR1_INPUT_ENABLE__POS               (4)
+#define BMI160_USER_INTR1_INPUT_ENABLE__LEN               (1)
+#define BMI160_USER_INTR1_INPUT_ENABLE__MSK               (0x10)
+#define BMI160_USER_INTR1_INPUT_ENABLE__REG               \
+(BMI160_USER_INTR_LATCH_ADDR)
+
+/* Int_Latch Description - Reg Addr --> 0x54, Bit -->5*/
+#define BMI160_USER_INTR2_INPUT_ENABLE__POS               (5)
+#define BMI160_USER_INTR2_INPUT_ENABLE__LEN               (1)
+#define BMI160_USER_INTR2_INPUT_ENABLE__MSK               (0x20)
+#define BMI160_USER_INTR2_INPUT_ENABLE__REG              \
+(BMI160_USER_INTR_LATCH_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT1 MAPPIONG OF LOW_G LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_0 Description - Reg Addr --> 0x55, Bit -->0 */
+#define BMI160_USER_INTR_MAP_0_INTR1_LOW_G__POS               (0)
+#define BMI160_USER_INTR_MAP_0_INTR1_LOW_G__LEN               (1)
+#define BMI160_USER_INTR_MAP_0_INTR1_LOW_G__MSK               (0x01)
+#define BMI160_USER_INTR_MAP_0_INTR1_LOW_G__REG	(BMI160_USER_INTR_MAP_0_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT1 MAPPIONG OF HIGH_G LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_0 Description - Reg Addr --> 0x55, Bit -->1 */
+#define BMI160_USER_INTR_MAP_0_INTR1_HIGH_G__POS               (1)
+#define BMI160_USER_INTR_MAP_0_INTR1_HIGH_G__LEN               (1)
+#define BMI160_USER_INTR_MAP_0_INTR1_HIGH_G__MSK               (0x02)
+#define BMI160_USER_INTR_MAP_0_INTR1_HIGH_G__REG	\
+(BMI160_USER_INTR_MAP_0_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT MAPPIONG OF ANY MOTION_G LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_0 Description - Reg Addr --> 0x55, Bit -->2 */
+#define BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION__POS               (2)
+#define BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION__LEN               (1)
+#define BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION__MSK               (0x04)
+#define BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION__REG            \
+(BMI160_USER_INTR_MAP_0_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT1 MAPPIONG OF NO MOTION LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_0 Description - Reg Addr --> 0x55, Bit -->3 */
+#define BMI160_USER_INTR_MAP_0_INTR1_NOMOTION__POS               (3)
+#define BMI160_USER_INTR_MAP_0_INTR1_NOMOTION__LEN               (1)
+#define BMI160_USER_INTR_MAP_0_INTR1_NOMOTION__MSK               (0x08)
+#define BMI160_USER_INTR_MAP_0_INTR1_NOMOTION__REG (BMI160_USER_INTR_MAP_0_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT1 MAPPIONG OF DOUBLE TAP LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_0 Description - Reg Addr --> 0x55, Bit -->4 */
+#define BMI160_USER_INTR_MAP_0_INTR1_DOUBLE_TAP__POS               (4)
+#define BMI160_USER_INTR_MAP_0_INTR1_DOUBLE_TAP__LEN               (1)
+#define BMI160_USER_INTR_MAP_0_INTR1_DOUBLE_TAP__MSK               (0x10)
+#define BMI160_USER_INTR_MAP_0_INTR1_DOUBLE_TAP__REG	\
+(BMI160_USER_INTR_MAP_0_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT1 MAPPIONG OF SINGLE TAP LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_0 Description - Reg Addr --> 0x55, Bit -->5 */
+#define BMI160_USER_INTR_MAP_0_INTR1_SINGLE_TAP__POS               (5)
+#define BMI160_USER_INTR_MAP_0_INTR1_SINGLE_TAP__LEN               (1)
+#define BMI160_USER_INTR_MAP_0_INTR1_SINGLE_TAP__MSK               (0x20)
+#define BMI160_USER_INTR_MAP_0_INTR1_SINGLE_TAP__REG	      \
+(BMI160_USER_INTR_MAP_0_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT1 MAPPIONG OF ORIENT LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_0 Description - Reg Addr --> 0x55, Bit -->6 */
+#define BMI160_USER_INTR_MAP_0_INTR1_ORIENT__POS               (6)
+#define BMI160_USER_INTR_MAP_0_INTR1_ORIENT__LEN               (1)
+#define BMI160_USER_INTR_MAP_0_INTR1_ORIENT__MSK               (0x40)
+#define BMI160_USER_INTR_MAP_0_INTR1_ORIENT__REG	          \
+(BMI160_USER_INTR_MAP_0_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT MAPPIONG OF FLAT LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_0 Description - Reg Addr --> 0x56, Bit -->7 */
+#define BMI160_USER_INTR_MAP_0_INTR1_FLAT__POS               (7)
+#define BMI160_USER_INTR_MAP_0_INTR1_FLAT__LEN               (1)
+#define BMI160_USER_INTR_MAP_0_INTR1_FLAT__MSK               (0x80)
+#define BMI160_USER_INTR_MAP_0_INTR1_FLAT__REG	(BMI160_USER_INTR_MAP_0_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT1 MAPPIONG OF PMU TRIGGER LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_1 Description - Reg Addr --> 0x56, Bit -->0 */
+#define BMI160_USER_INTR_MAP_1_INTR2_PMU_TRIG__POS               (0)
+#define BMI160_USER_INTR_MAP_1_INTR2_PMU_TRIG__LEN               (1)
+#define BMI160_USER_INTR_MAP_1_INTR2_PMU_TRIG__MSK               (0x01)
+#define BMI160_USER_INTR_MAP_1_INTR2_PMU_TRIG__REG (BMI160_USER_INTR_MAP_1_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT1 MAPPIONG OF FIFO FULL AND
+	WATER MARK LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_1 Description - Reg Addr --> 0x56, Bit -->1 */
+#define BMI160_USER_INTR_MAP_1_INTR2_FIFO_FULL__POS               (1)
+#define BMI160_USER_INTR_MAP_1_INTR2_FIFO_FULL__LEN               (1)
+#define BMI160_USER_INTR_MAP_1_INTR2_FIFO_FULL__MSK               (0x02)
+#define BMI160_USER_INTR_MAP_1_INTR2_FIFO_FULL__REG	         \
+(BMI160_USER_INTR_MAP_1_ADDR)
+
+/* Int_Map_1 Description - Reg Addr --> 0x56, Bit -->2 */
+#define BMI160_USER_INTR_MAP_1_INTR2_FIFO_WM__POS               (2)
+#define BMI160_USER_INTR_MAP_1_INTR2_FIFO_WM__LEN               (1)
+#define BMI160_USER_INTR_MAP_1_INTR2_FIFO_WM__MSK               (0x04)
+#define BMI160_USER_INTR_MAP_1_INTR2_FIFO_WM__REG	         \
+(BMI160_USER_INTR_MAP_1_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT1 MAPPIONG OF DATA READY LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_1 Description - Reg Addr --> 0x56, Bit -->3 */
+#define BMI160_USER_INTR_MAP_1_INTR2_DATA_RDY__POS               (3)
+#define BMI160_USER_INTR_MAP_1_INTR2_DATA_RDY__LEN               (1)
+#define BMI160_USER_INTR_MAP_1_INTR2_DATA_RDY__MSK               (0x08)
+#define BMI160_USER_INTR_MAP_1_INTR2_DATA_RDY__REG	      \
+(BMI160_USER_INTR_MAP_1_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT1 MAPPIONG OF PMU TRIGGER LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_1 Description - Reg Addr --> 0x56, Bit -->4 */
+#define BMI160_USER_INTR_MAP_1_INTR1_PMU_TRIG__POS               (4)
+#define BMI160_USER_INTR_MAP_1_INTR1_PMU_TRIG__LEN               (1)
+#define BMI160_USER_INTR_MAP_1_INTR1_PMU_TRIG__MSK               (0x10)
+#define BMI160_USER_INTR_MAP_1_INTR1_PMU_TRIG__REG (BMI160_USER_INTR_MAP_1_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT1 MAPPIONG OF FIFO FULL AND
+	WATER MARK LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_1 Description - Reg Addr --> 0x56, Bit -->5 */
+#define BMI160_USER_INTR_MAP_1_INTR1_FIFO_FULL__POS               (5)
+#define BMI160_USER_INTR_MAP_1_INTR1_FIFO_FULL__LEN               (1)
+#define BMI160_USER_INTR_MAP_1_INTR1_FIFO_FULL__MSK               (0x20)
+#define BMI160_USER_INTR_MAP_1_INTR1_FIFO_FULL__REG	       \
+(BMI160_USER_INTR_MAP_1_ADDR)
+
+/* Int_Map_1 Description - Reg Addr --> 0x56, Bit -->6 */
+#define BMI160_USER_INTR_MAP_1_INTR1_FIFO_WM__POS               (6)
+#define BMI160_USER_INTR_MAP_1_INTR1_FIFO_WM__LEN               (1)
+#define BMI160_USER_INTR_MAP_1_INTR1_FIFO_WM__MSK               (0x40)
+#define BMI160_USER_INTR_MAP_1_INTR1_FIFO_WM__REG	\
+(BMI160_USER_INTR_MAP_1_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT1 MAPPIONG OF DATA READY LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_1 Description - Reg Addr --> 0x56, Bit -->7 */
+#define BMI160_USER_INTR_MAP_1_INTR1_DATA_RDY__POS               (7)
+#define BMI160_USER_INTR_MAP_1_INTR1_DATA_RDY__LEN               (1)
+#define BMI160_USER_INTR_MAP_1_INTR1_DATA_RDY__MSK               (0x80)
+#define BMI160_USER_INTR_MAP_1_INTR1_DATA_RDY__REG	\
+(BMI160_USER_INTR_MAP_1_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT2 MAPPIONG OF LOW_G LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_2 Description - Reg Addr --> 0x57, Bit -->0 */
+#define BMI160_USER_INTR_MAP_2_INTR2_LOW_G__POS               (0)
+#define BMI160_USER_INTR_MAP_2_INTR2_LOW_G__LEN               (1)
+#define BMI160_USER_INTR_MAP_2_INTR2_LOW_G__MSK               (0x01)
+#define BMI160_USER_INTR_MAP_2_INTR2_LOW_G__REG	(BMI160_USER_INTR_MAP_2_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT2 MAPPIONG OF HIGH_G LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_2 Description - Reg Addr --> 0x57, Bit -->1 */
+#define BMI160_USER_INTR_MAP_2_INTR2_HIGH_G__POS               (1)
+#define BMI160_USER_INTR_MAP_2_INTR2_HIGH_G__LEN               (1)
+#define BMI160_USER_INTR_MAP_2_INTR2_HIGH_G__MSK               (0x02)
+#define BMI160_USER_INTR_MAP_2_INTR2_HIGH_G__REG	\
+(BMI160_USER_INTR_MAP_2_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT2 MAPPIONG OF ANY MOTION LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_2 Description - Reg Addr --> 0x57, Bit -->2 */
+#define BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION__POS      (2)
+#define BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION__LEN      (1)
+#define BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION__MSK     (0x04)
+#define BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION__REG     \
+(BMI160_USER_INTR_MAP_2_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT2 MAPPIONG OF NO MOTION LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_2 Description - Reg Addr --> 0x57, Bit -->3 */
+#define BMI160_USER_INTR_MAP_2_INTR2_NOMOTION__POS               (3)
+#define BMI160_USER_INTR_MAP_2_INTR2_NOMOTION__LEN               (1)
+#define BMI160_USER_INTR_MAP_2_INTR2_NOMOTION__MSK               (0x08)
+#define BMI160_USER_INTR_MAP_2_INTR2_NOMOTION__REG (BMI160_USER_INTR_MAP_2_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT2 MAPPIONG OF DOUBLE TAP LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_2 Description - Reg Addr --> 0x57, Bit -->4 */
+#define BMI160_USER_INTR_MAP_2_INTR2_DOUBLE_TAP__POS               (4)
+#define BMI160_USER_INTR_MAP_2_INTR2_DOUBLE_TAP__LEN               (1)
+#define BMI160_USER_INTR_MAP_2_INTR2_DOUBLE_TAP__MSK               (0x10)
+#define BMI160_USER_INTR_MAP_2_INTR2_DOUBLE_TAP__REG	\
+(BMI160_USER_INTR_MAP_2_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT2 MAPPIONG OF SINGLE TAP LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_2 Description - Reg Addr --> 0x57, Bit -->5 */
+#define BMI160_USER_INTR_MAP_2_INTR2_SINGLE_TAP__POS               (5)
+#define BMI160_USER_INTR_MAP_2_INTR2_SINGLE_TAP__LEN               (1)
+#define BMI160_USER_INTR_MAP_2_INTR2_SINGLE_TAP__MSK               (0x20)
+#define BMI160_USER_INTR_MAP_2_INTR2_SINGLE_TAP__REG	\
+(BMI160_USER_INTR_MAP_2_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT2 MAPPIONG OF ORIENT LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_2 Description - Reg Addr --> 0x57, Bit -->6 */
+#define BMI160_USER_INTR_MAP_2_INTR2_ORIENT__POS               (6)
+#define BMI160_USER_INTR_MAP_2_INTR2_ORIENT__LEN               (1)
+#define BMI160_USER_INTR_MAP_2_INTR2_ORIENT__MSK               (0x40)
+#define BMI160_USER_INTR_MAP_2_INTR2_ORIENT__REG	\
+(BMI160_USER_INTR_MAP_2_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT2 MAPPIONG OF FLAT LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_2 Description - Reg Addr --> 0x57, Bit -->7 */
+#define BMI160_USER_INTR_MAP_2_INTR2_FLAT__POS               (7)
+#define BMI160_USER_INTR_MAP_2_INTR2_FLAT__LEN               (1)
+#define BMI160_USER_INTR_MAP_2_INTR2_FLAT__MSK               (0x80)
+#define BMI160_USER_INTR_MAP_2_INTR2_FLAT__REG	(BMI160_USER_INTR_MAP_2_ADDR)
+
+/**************************************************************/
+/**\name	TAP SOURCE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Data_0 Description - Reg Addr --> 0x58, Bit --> 3 */
+#define BMI160_USER_INTR_DATA_0_INTR_TAP_SOURCE__POS               (3)
+#define BMI160_USER_INTR_DATA_0_INTR_TAP_SOURCE__LEN               (1)
+#define BMI160_USER_INTR_DATA_0_INTR_TAP_SOURCE__MSK               (0x08)
+#define BMI160_USER_INTR_DATA_0_INTR_TAP_SOURCE__REG	           \
+(BMI160_USER_INTR_DATA_0_ADDR)
+
+/**************************************************************/
+/**\name	HIGH SOURCE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Data_0 Description - Reg Addr --> 0x58, Bit --> 7 */
+#define BMI160_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE__POS           (7)
+#define BMI160_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE__LEN           (1)
+#define BMI160_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE__MSK           (0x80)
+#define BMI160_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE__REG            \
+(BMI160_USER_INTR_DATA_0_ADDR)
+
+/**************************************************************/
+/**\name	MOTION SOURCE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Data_1 Description - Reg Addr --> 0x59, Bit --> 7 */
+#define BMI160_USER_INTR_DATA_1_INTR_MOTION_SOURCE__POS               (7)
+#define BMI160_USER_INTR_DATA_1_INTR_MOTION_SOURCE__LEN               (1)
+#define BMI160_USER_INTR_DATA_1_INTR_MOTION_SOURCE__MSK               (0x80)
+#define BMI160_USER_INTR_DATA_1_INTR_MOTION_SOURCE__REG               \
+		(BMI160_USER_INTR_DATA_1_ADDR)
+/**************************************************************/
+/**\name	LOW HIGH DURATION LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_LowHigh_0 Description - Reg Addr --> 0x5a, Bit --> 0...7 */
+#define BMI160_USER_INTR_LOWHIGH_0_INTR_LOW_DURN__POS               (0)
+#define BMI160_USER_INTR_LOWHIGH_0_INTR_LOW_DURN__LEN               (8)
+#define BMI160_USER_INTR_LOWHIGH_0_INTR_LOW_DURN__MSK               (0xFF)
+#define BMI160_USER_INTR_LOWHIGH_0_INTR_LOW_DURN__REG               \
+		(BMI160_USER_INTR_LOWHIGH_0_ADDR)
+/**************************************************************/
+/**\name	LOW THRESHOLD LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_LowHigh_1 Description - Reg Addr --> 0x5b, Bit --> 0...7 */
+#define BMI160_USER_INTR_LOWHIGH_1_INTR_LOW_THRES__POS               (0)
+#define BMI160_USER_INTR_LOWHIGH_1_INTR_LOW_THRES__LEN               (8)
+#define BMI160_USER_INTR_LOWHIGH_1_INTR_LOW_THRES__MSK               (0xFF)
+#define BMI160_USER_INTR_LOWHIGH_1_INTR_LOW_THRES__REG               \
+		(BMI160_USER_INTR_LOWHIGH_1_ADDR)
+/**************************************************************/
+/**\name	LOW HYSTERESIS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_LowHigh_2 Description - Reg Addr --> 0x5c, Bit --> 0...1 */
+#define BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST__POS               (0)
+#define BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST__LEN               (2)
+#define BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST__MSK               (0x03)
+#define BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST__REG               \
+		(BMI160_USER_INTR_LOWHIGH_2_ADDR)
+/**************************************************************/
+/**\name	LOW MODE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_LowHigh_2 Description - Reg Addr --> 0x5c, Bit --> 2 */
+#define BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE__POS               (2)
+#define BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE__LEN               (1)
+#define BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE__MSK               (0x04)
+#define BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE__REG               \
+		(BMI160_USER_INTR_LOWHIGH_2_ADDR)
+/**************************************************************/
+/**\name	HIGH_G HYSTERESIS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_LowHigh_2 Description - Reg Addr --> 0x5c, Bit --> 6...7 */
+#define BMI160_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST__POS               (6)
+#define BMI160_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST__LEN               (2)
+#define BMI160_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST__MSK               (0xC0)
+#define BMI160_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST__REG               \
+		(BMI160_USER_INTR_LOWHIGH_2_ADDR)
+/**************************************************************/
+/**\name	HIGH_G DURATION LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_LowHigh_3 Description - Reg Addr --> 0x5d, Bit --> 0...7 */
+#define BMI160_USER_INTR_LOWHIGH_3_INTR_HIGH_G_DURN__POS               (0)
+#define BMI160_USER_INTR_LOWHIGH_3_INTR_HIGH_G_DURN__LEN               (8)
+#define BMI160_USER_INTR_LOWHIGH_3_INTR_HIGH_G_DURN__MSK               (0xFF)
+#define BMI160_USER_INTR_LOWHIGH_3_INTR_HIGH_G_DURN__REG               \
+		(BMI160_USER_INTR_LOWHIGH_3_ADDR)
+/**************************************************************/
+/**\name	HIGH_G THRESHOLD LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_LowHigh_4 Description - Reg Addr --> 0x5e, Bit --> 0...7 */
+#define BMI160_USER_INTR_LOWHIGH_4_INTR_HIGH_THRES__POS               (0)
+#define BMI160_USER_INTR_LOWHIGH_4_INTR_HIGH_THRES__LEN               (8)
+#define BMI160_USER_INTR_LOWHIGH_4_INTR_HIGH_THRES__MSK               (0xFF)
+#define BMI160_USER_INTR_LOWHIGH_4_INTR_HIGH_THRES__REG               \
+		(BMI160_USER_INTR_LOWHIGH_4_ADDR)
+/**************************************************************/
+/**\name	ANY MOTION DURATION LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Motion_0 Description - Reg Addr --> 0x5f, Bit --> 0...1 */
+#define BMI160_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN__POS               (0)
+#define BMI160_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN__LEN               (2)
+#define BMI160_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN__MSK               (0x03)
+#define BMI160_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN__REG               \
+		(BMI160_USER_INTR_MOTION_0_ADDR)
+/**************************************************************/
+/**\name	SLOW/NO MOTION DURATION LENGTH, POSITION AND MASK*/
+/**************************************************************/
+	/* Int_Motion_0 Description - Reg Addr --> 0x5f, Bit --> 2...7 */
+#define BMI160_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN__POS      (2)
+#define BMI160_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN__LEN      (6)
+#define BMI160_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN__MSK      (0xFC)
+#define BMI160_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN__REG       \
+		(BMI160_USER_INTR_MOTION_0_ADDR)
+/**************************************************************/
+/**\name	ANY MOTION THRESHOLD LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Motion_1 Description - Reg Addr --> (0x60), Bit --> 0...7 */
+#define BMI160_USER_INTR_MOTION_1_INTR_ANY_MOTION_THRES__POS      (0)
+#define BMI160_USER_INTR_MOTION_1_INTR_ANY_MOTION_THRES__LEN      (8)
+#define BMI160_USER_INTR_MOTION_1_INTR_ANY_MOTION_THRES__MSK      (0xFF)
+#define BMI160_USER_INTR_MOTION_1_INTR_ANY_MOTION_THRES__REG               \
+		(BMI160_USER_INTR_MOTION_1_ADDR)
+/**************************************************************/
+/**\name	SLOW/NO MOTION THRESHOLD LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Motion_2 Description - Reg Addr --> 0x61, Bit --> 0...7 */
+#define BMI160_USER_INTR_MOTION_2_INTR_SLOW_NO_MOTION_THRES__POS       (0)
+#define BMI160_USER_INTR_MOTION_2_INTR_SLOW_NO_MOTION_THRES__LEN       (8)
+#define BMI160_USER_INTR_MOTION_2_INTR_SLOW_NO_MOTION_THRES__MSK       (0xFF)
+#define BMI160_USER_INTR_MOTION_2_INTR_SLOW_NO_MOTION_THRES__REG       \
+		(BMI160_USER_INTR_MOTION_2_ADDR)
+/**************************************************************/
+/**\name	SLOW/NO MOTION SELECT LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Motion_3 Description - Reg Addr --> (0x62), Bit --> 0 */
+#define BMI160_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT__POS	(0)
+#define BMI160_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT__LEN	(1)
+#define BMI160_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT__MSK	(0x01)
+#define BMI160_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT__REG   \
+(BMI160_USER_INTR_MOTION_3_ADDR)
+/**************************************************************/
+/**\name	SIGNIFICANT MOTION SELECT LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Motion_3 Description - Reg Addr --> (0x62), Bit --> 1 */
+#define BMI160_USER_INTR_SIGNIFICATION_MOTION_SELECT__POS		(1)
+#define BMI160_USER_INTR_SIGNIFICATION_MOTION_SELECT__LEN		(1)
+#define BMI160_USER_INTR_SIGNIFICATION_MOTION_SELECT__MSK		(0x02)
+#define BMI160_USER_INTR_SIGNIFICATION_MOTION_SELECT__REG		\
+		(BMI160_USER_INTR_MOTION_3_ADDR)
+
+/* Int_Motion_3 Description - Reg Addr --> (0x62), Bit --> 3..2 */
+#define BMI160_USER_INTR_SIGNIFICANT_MOTION_SKIP__POS		(2)
+#define BMI160_USER_INTR_SIGNIFICANT_MOTION_SKIP__LEN		(2)
+#define BMI160_USER_INTR_SIGNIFICANT_MOTION_SKIP__MSK		(0x0C)
+#define BMI160_USER_INTR_SIGNIFICANT_MOTION_SKIP__REG		\
+		(BMI160_USER_INTR_MOTION_3_ADDR)
+
+/* Int_Motion_3 Description - Reg Addr --> (0x62), Bit --> 5..4 */
+#define BMI160_USER_INTR_SIGNIFICANT_MOTION_PROOF__POS		(4)
+#define BMI160_USER_INTR_SIGNIFICANT_MOTION_PROOF__LEN		(2)
+#define BMI160_USER_INTR_SIGNIFICANT_MOTION_PROOF__MSK		(0x30)
+#define BMI160_USER_INTR_SIGNIFICANT_MOTION_PROOF__REG		\
+		(BMI160_USER_INTR_MOTION_3_ADDR)
+/**************************************************************/
+/**\name	TAP DURATION LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* INT_TAP_0 Description - Reg Addr --> (0x63), Bit --> 0..2*/
+#define BMI160_USER_INTR_TAP_0_INTR_TAP_DURN__POS               (0)
+#define BMI160_USER_INTR_TAP_0_INTR_TAP_DURN__LEN               (3)
+#define BMI160_USER_INTR_TAP_0_INTR_TAP_DURN__MSK               (0x07)
+#define BMI160_USER_INTR_TAP_0_INTR_TAP_DURN__REG	\
+(BMI160_USER_INTR_TAP_0_ADDR)
+/**************************************************************/
+/**\name	TAP SHOCK LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Tap_0 Description - Reg Addr --> (0x63), Bit --> 6 */
+#define BMI160_USER_INTR_TAP_0_INTR_TAP_SHOCK__POS               (6)
+#define BMI160_USER_INTR_TAP_0_INTR_TAP_SHOCK__LEN               (1)
+#define BMI160_USER_INTR_TAP_0_INTR_TAP_SHOCK__MSK               (0x40)
+#define BMI160_USER_INTR_TAP_0_INTR_TAP_SHOCK__REG (BMI160_USER_INTR_TAP_0_ADDR)
+/**************************************************************/
+/**\name	TAP QUIET LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Tap_0 Description - Reg Addr --> (0x63), Bit --> 7 */
+#define BMI160_USER_INTR_TAP_0_INTR_TAP_QUIET__POS               (7)
+#define BMI160_USER_INTR_TAP_0_INTR_TAP_QUIET__LEN               (1)
+#define BMI160_USER_INTR_TAP_0_INTR_TAP_QUIET__MSK               (0x80)
+#define BMI160_USER_INTR_TAP_0_INTR_TAP_QUIET__REG (BMI160_USER_INTR_TAP_0_ADDR)
+/**************************************************************/
+/**\name	TAP THRESHOLD LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Tap_1 Description - Reg Addr --> (0x64), Bit --> 0...4 */
+#define BMI160_USER_INTR_TAP_1_INTR_TAP_THRES__POS               (0)
+#define BMI160_USER_INTR_TAP_1_INTR_TAP_THRES__LEN               (5)
+#define BMI160_USER_INTR_TAP_1_INTR_TAP_THRES__MSK               (0x1F)
+#define BMI160_USER_INTR_TAP_1_INTR_TAP_THRES__REG (BMI160_USER_INTR_TAP_1_ADDR)
+/**************************************************************/
+/**\name	ORIENT MODE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Orient_0 Description - Reg Addr --> (0x65), Bit --> 0...1 */
+#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_MODE__POS               (0)
+#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_MODE__LEN               (2)
+#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_MODE__MSK               (0x03)
+#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_MODE__REG               \
+		(BMI160_USER_INTR_ORIENT_0_ADDR)
+/**************************************************************/
+/**\name	ORIENT BLOCKING LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Orient_0 Description - Reg Addr --> (0x65), Bit --> 2...3 */
+#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING__POS               (2)
+#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING__LEN               (2)
+#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING__MSK               (0x0C)
+#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING__REG               \
+		(BMI160_USER_INTR_ORIENT_0_ADDR)
+/**************************************************************/
+/**\name	ORIENT HYSTERESIS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Orient_0 Description - Reg Addr --> (0x65), Bit --> 4...7 */
+#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_HYST__POS               (4)
+#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_HYST__LEN               (4)
+#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_HYST__MSK               (0xF0)
+#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_HYST__REG               \
+		(BMI160_USER_INTR_ORIENT_0_ADDR)
+/**************************************************************/
+/**\name	ORIENT THETA LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Orient_1 Description - Reg Addr --> 0x66, Bit --> 0...5 */
+#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_THETA__POS               (0)
+#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_THETA__LEN               (6)
+#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_THETA__MSK               (0x3F)
+#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_THETA__REG               \
+		(BMI160_USER_INTR_ORIENT_1_ADDR)
+/**************************************************************/
+/**\name	ORIENT UD LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Orient_1 Description - Reg Addr --> 0x66, Bit --> 6 */
+#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE__POS         (6)
+#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE__LEN         (1)
+#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE__MSK         (0x40)
+#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE__REG          \
+		(BMI160_USER_INTR_ORIENT_1_ADDR)
+/**************************************************************/
+/**\name	ORIENT AXIS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Orient_1 Description - Reg Addr --> 0x66, Bit --> 7 */
+#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX__POS               (7)
+#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX__LEN               (1)
+#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX__MSK               (0x80)
+#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX__REG               \
+		(BMI160_USER_INTR_ORIENT_1_ADDR)
+/**************************************************************/
+/**\name	FLAT THETA LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Flat_0 Description - Reg Addr --> 0x67, Bit --> 0...5 */
+#define BMI160_USER_INTR_FLAT_0_INTR_FLAT_THETA__POS               (0)
+#define BMI160_USER_INTR_FLAT_0_INTR_FLAT_THETA__LEN               (6)
+#define BMI160_USER_INTR_FLAT_0_INTR_FLAT_THETA__MSK               (0x3F)
+#define BMI160_USER_INTR_FLAT_0_INTR_FLAT_THETA__REG  \
+		(BMI160_USER_INTR_FLAT_0_ADDR)
+/**************************************************************/
+/**\name	FLAT HYSTERESIS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Flat_1 Description - Reg Addr --> (0x68), Bit --> 0...3 */
+#define BMI160_USER_INTR_FLAT_1_INTR_FLAT_HYST__POS		(0)
+#define BMI160_USER_INTR_FLAT_1_INTR_FLAT_HYST__LEN		(4)
+#define BMI160_USER_INTR_FLAT_1_INTR_FLAT_HYST__MSK		(0x0F)
+#define BMI160_USER_INTR_FLAT_1_INTR_FLAT_HYST__REG	 \
+(BMI160_USER_INTR_FLAT_1_ADDR)
+/**************************************************************/
+/**\name	FLAT HOLD LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Flat_1 Description - Reg Addr --> (0x68), Bit --> 4...5 */
+#define BMI160_USER_INTR_FLAT_1_INTR_FLAT_HOLD__POS                (4)
+#define BMI160_USER_INTR_FLAT_1_INTR_FLAT_HOLD__LEN                (2)
+#define BMI160_USER_INTR_FLAT_1_INTR_FLAT_HOLD__MSK                (0x30)
+#define BMI160_USER_INTR_FLAT_1_INTR_FLAT_HOLD__REG  \
+(BMI160_USER_INTR_FLAT_1_ADDR)
+/**************************************************************/
+/**\name	FOC ACCEL XYZ LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Foc_Conf Description - Reg Addr --> (0x69), Bit --> 0...1 */
+#define BMI160_USER_FOC_ACCEL_Z__POS               (0)
+#define BMI160_USER_FOC_ACCEL_Z__LEN               (2)
+#define BMI160_USER_FOC_ACCEL_Z__MSK               (0x03)
+#define BMI160_USER_FOC_ACCEL_Z__REG               (BMI160_USER_FOC_CONFIG_ADDR)
+
+/* Foc_Conf Description - Reg Addr --> (0x69), Bit --> 2...3 */
+#define BMI160_USER_FOC_ACCEL_Y__POS               (2)
+#define BMI160_USER_FOC_ACCEL_Y__LEN               (2)
+#define BMI160_USER_FOC_ACCEL_Y__MSK               (0x0C)
+#define BMI160_USER_FOC_ACCEL_Y__REG               (BMI160_USER_FOC_CONFIG_ADDR)
+
+/* Foc_Conf Description - Reg Addr --> (0x69), Bit --> 4...5 */
+#define BMI160_USER_FOC_ACCEL_X__POS               (4)
+#define BMI160_USER_FOC_ACCEL_X__LEN               (2)
+#define BMI160_USER_FOC_ACCEL_X__MSK               (0x30)
+#define BMI160_USER_FOC_ACCEL_X__REG               (BMI160_USER_FOC_CONFIG_ADDR)
+/**************************************************************/
+/**\name	FOC GYRO LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Foc_Conf Description - Reg Addr --> (0x69), Bit --> 6 */
+#define BMI160_USER_FOC_GYRO_ENABLE__POS               (6)
+#define BMI160_USER_FOC_GYRO_ENABLE__LEN               (1)
+#define BMI160_USER_FOC_GYRO_ENABLE__MSK               (0x40)
+#define BMI160_USER_FOC_GYRO_ENABLE__REG               \
+(BMI160_USER_FOC_CONFIG_ADDR)
+/**************************************************************/
+/**\name	NVM PROGRAM LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* CONF Description - Reg Addr --> (0x6A), Bit --> 1 */
+#define BMI160_USER_CONFIG_NVM_PROG_ENABLE__POS               (1)
+#define BMI160_USER_CONFIG_NVM_PROG_ENABLE__LEN               (1)
+#define BMI160_USER_CONFIG_NVM_PROG_ENABLE__MSK               (0x02)
+#define BMI160_USER_CONFIG_NVM_PROG_ENABLE__REG               \
+(BMI160_USER_CONFIG_ADDR)
+
+/*IF_CONF Description - Reg Addr --> (0x6B), Bit --> 0 */
+
+#define BMI160_USER_IF_CONFIG_SPI3__POS               (0)
+#define BMI160_USER_IF_CONFIG_SPI3__LEN               (1)
+#define BMI160_USER_IF_CONFIG_SPI3__MSK               (0x01)
+#define BMI160_USER_IF_CONFIG_SPI3__REG               \
+(BMI160_USER_IF_CONFIG_ADDR)
+
+/*IF_CONF Description - Reg Addr --> (0x6B), Bit --> 5..4 */
+#define BMI160_USER_IF_CONFIG_IF_MODE__POS               (4)
+#define BMI160_USER_IF_CONFIG_IF_MODE__LEN               (2)
+#define BMI160_USER_IF_CONFIG_IF_MODE__MSK               (0x30)
+#define BMI160_USER_IF_CONFIG_IF_MODE__REG		\
+(BMI160_USER_IF_CONFIG_ADDR)
+/**************************************************************/
+/**\name	GYRO SLEEP CONFIGURATION LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Pmu_Trigger Description - Reg Addr --> 0x6c, Bit --> 0...2 */
+#define BMI160_USER_GYRO_SLEEP_TRIGGER__POS               (0)
+#define BMI160_USER_GYRO_SLEEP_TRIGGER__LEN               (3)
+#define BMI160_USER_GYRO_SLEEP_TRIGGER__MSK               (0x07)
+#define BMI160_USER_GYRO_SLEEP_TRIGGER__REG	(BMI160_USER_PMU_TRIGGER_ADDR)
+
+/* Pmu_Trigger Description - Reg Addr --> 0x6c, Bit --> 3...4 */
+#define BMI160_USER_GYRO_WAKEUP_TRIGGER__POS               (3)
+#define BMI160_USER_GYRO_WAKEUP_TRIGGER__LEN               (2)
+#define BMI160_USER_GYRO_WAKEUP_TRIGGER__MSK               (0x18)
+#define BMI160_USER_GYRO_WAKEUP_TRIGGER__REG	(BMI160_USER_PMU_TRIGGER_ADDR)
+
+/* Pmu_Trigger Description - Reg Addr --> 0x6c, Bit --> 5 */
+#define BMI160_USER_GYRO_SLEEP_STATE__POS               (5)
+#define BMI160_USER_GYRO_SLEEP_STATE__LEN               (1)
+#define BMI160_USER_GYRO_SLEEP_STATE__MSK               (0x20)
+#define BMI160_USER_GYRO_SLEEP_STATE__REG	(BMI160_USER_PMU_TRIGGER_ADDR)
+
+/* Pmu_Trigger Description - Reg Addr --> 0x6c, Bit --> 6 */
+#define BMI160_USER_GYRO_WAKEUP_INTR__POS               (6)
+#define BMI160_USER_GYRO_WAKEUP_INTR__LEN               (1)
+#define BMI160_USER_GYRO_WAKEUP_INTR__MSK               (0x40)
+#define BMI160_USER_GYRO_WAKEUP_INTR__REG	(BMI160_USER_PMU_TRIGGER_ADDR)
+/**************************************************************/
+/**\name	ACCEL SELF TEST LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Self_Test Description - Reg Addr --> 0x6d, Bit --> 0...1 */
+#define BMI160_USER_ACCEL_SELFTEST_AXIS__POS               (0)
+#define BMI160_USER_ACCEL_SELFTEST_AXIS__LEN               (2)
+#define BMI160_USER_ACCEL_SELFTEST_AXIS__MSK               (0x03)
+#define BMI160_USER_ACCEL_SELFTEST_AXIS__REG	(BMI160_USER_SELF_TEST_ADDR)
+
+/* Self_Test Description - Reg Addr --> 0x6d, Bit --> 2 */
+#define BMI160_USER_ACCEL_SELFTEST_SIGN__POS               (2)
+#define BMI160_USER_ACCEL_SELFTEST_SIGN__LEN               (1)
+#define BMI160_USER_ACCEL_SELFTEST_SIGN__MSK               (0x04)
+#define BMI160_USER_ACCEL_SELFTEST_SIGN__REG	(BMI160_USER_SELF_TEST_ADDR)
+
+/* Self_Test Description - Reg Addr --> 0x6d, Bit --> 3 */
+#define BMI160_USER_SELFTEST_AMP__POS               (3)
+#define BMI160_USER_SELFTEST_AMP__LEN               (1)
+#define BMI160_USER_SELFTEST_AMP__MSK               (0x08)
+#define BMI160_USER_SELFTEST_AMP__REG		(BMI160_USER_SELF_TEST_ADDR)
+/**************************************************************/
+/**\name	GYRO SELF TEST LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Self_Test Description - Reg Addr --> 0x6d, Bit --> 4 */
+#define BMI160_USER_GYRO_SELFTEST_START__POS               (4)
+#define BMI160_USER_GYRO_SELFTEST_START__LEN               (1)
+#define BMI160_USER_GYRO_SELFTEST_START__MSK               (0x10)
+#define BMI160_USER_GYRO_SELFTEST_START__REG		    \
+(BMI160_USER_SELF_TEST_ADDR)
+/**************************************************************/
+/**\name	NV_CONFIG LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* NV_CONF Description - Reg Addr --> (0x70), Bit --> 0 */
+#define BMI160_USER_NV_CONFIG_SPI_ENABLE__POS               (0)
+#define BMI160_USER_NV_CONFIG_SPI_ENABLE__LEN               (1)
+#define BMI160_USER_NV_CONFIG_SPI_ENABLE__MSK               (0x01)
+#define BMI160_USER_NV_CONFIG_SPI_ENABLE__REG	 (BMI160_USER_NV_CONFIG_ADDR)
+
+/*IF_CONF Description - Reg Addr --> (0x70), Bit --> 1 */
+#define BMI160_USER_IF_CONFIG_I2C_WDT_SELECT__POS               (1)
+#define BMI160_USER_IF_CONFIG_I2C_WDT_SELECT__LEN               (1)
+#define BMI160_USER_IF_CONFIG_I2C_WDT_SELECT__MSK               (0x02)
+#define BMI160_USER_IF_CONFIG_I2C_WDT_SELECT__REG		\
+(BMI160_USER_NV_CONFIG_ADDR)
+
+/*IF_CONF Description - Reg Addr --> (0x70), Bit --> 2 */
+#define BMI160_USER_IF_CONFIG_I2C_WDT_ENABLE__POS               (2)
+#define BMI160_USER_IF_CONFIG_I2C_WDT_ENABLE__LEN               (1)
+#define BMI160_USER_IF_CONFIG_I2C_WDT_ENABLE__MSK               (0x04)
+#define BMI160_USER_IF_CONFIG_I2C_WDT_ENABLE__REG		\
+(BMI160_USER_NV_CONFIG_ADDR)
+
+/* NV_CONF Description - Reg Addr --> (0x70), Bit --> 3 */
+#define BMI160_USER_NV_CONFIG_SPARE0__POS               (3)
+#define BMI160_USER_NV_CONFIG_SPARE0__LEN               (1)
+#define BMI160_USER_NV_CONFIG_SPARE0__MSK               (0x08)
+#define BMI160_USER_NV_CONFIG_SPARE0__REG	(BMI160_USER_NV_CONFIG_ADDR)
+
+/* NV_CONF Description - Reg Addr --> (0x70), Bit --> 4...7 */
+#define BMI160_USER_NV_CONFIG_NVM_COUNTER__POS               (4)
+#define BMI160_USER_NV_CONFIG_NVM_COUNTER__LEN               (4)
+#define BMI160_USER_NV_CONFIG_NVM_COUNTER__MSK               (0xF0)
+#define BMI160_USER_NV_CONFIG_NVM_COUNTER__REG	(BMI160_USER_NV_CONFIG_ADDR)
+/**************************************************************/
+/**\name	ACCEL MANUAL OFFSET LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Offset_0 Description - Reg Addr --> (0x71), Bit --> 0...7 */
+#define BMI160_USER_OFFSET_0_ACCEL_OFF_X__POS               (0)
+#define BMI160_USER_OFFSET_0_ACCEL_OFF_X__LEN               (8)
+#define BMI160_USER_OFFSET_0_ACCEL_OFF_X__MSK               (0xFF)
+#define BMI160_USER_OFFSET_0_ACCEL_OFF_X__REG	(BMI160_USER_OFFSET_0_ADDR)
+
+/* Offset_1 Description - Reg Addr --> 0x72, Bit --> 0...7 */
+#define BMI160_USER_OFFSET_1_ACCEL_OFF_Y__POS               (0)
+#define BMI160_USER_OFFSET_1_ACCEL_OFF_Y__LEN               (8)
+#define BMI160_USER_OFFSET_1_ACCEL_OFF_Y__MSK               (0xFF)
+#define BMI160_USER_OFFSET_1_ACCEL_OFF_Y__REG	(BMI160_USER_OFFSET_1_ADDR)
+
+/* Offset_2 Description - Reg Addr --> 0x73, Bit --> 0...7 */
+#define BMI160_USER_OFFSET_2_ACCEL_OFF_Z__POS               (0)
+#define BMI160_USER_OFFSET_2_ACCEL_OFF_Z__LEN               (8)
+#define BMI160_USER_OFFSET_2_ACCEL_OFF_Z__MSK               (0xFF)
+#define BMI160_USER_OFFSET_2_ACCEL_OFF_Z__REG	(BMI160_USER_OFFSET_2_ADDR)
+/**************************************************************/
+/**\name	GYRO MANUAL OFFSET LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Offset_3 Description - Reg Addr --> 0x74, Bit --> 0...7 */
+#define BMI160_USER_OFFSET_3_GYRO_OFF_X__POS               (0)
+#define BMI160_USER_OFFSET_3_GYRO_OFF_X__LEN               (8)
+#define BMI160_USER_OFFSET_3_GYRO_OFF_X__MSK               (0xFF)
+#define BMI160_USER_OFFSET_3_GYRO_OFF_X__REG	(BMI160_USER_OFFSET_3_ADDR)
+
+/* Offset_4 Description - Reg Addr --> 0x75, Bit --> 0...7 */
+#define BMI160_USER_OFFSET_4_GYRO_OFF_Y__POS               (0)
+#define BMI160_USER_OFFSET_4_GYRO_OFF_Y__LEN               (8)
+#define BMI160_USER_OFFSET_4_GYRO_OFF_Y__MSK               (0xFF)
+#define BMI160_USER_OFFSET_4_GYRO_OFF_Y__REG	(BMI160_USER_OFFSET_4_ADDR)
+
+/* Offset_5 Description - Reg Addr --> 0x76, Bit --> 0...7 */
+#define BMI160_USER_OFFSET_5_GYRO_OFF_Z__POS               (0)
+#define BMI160_USER_OFFSET_5_GYRO_OFF_Z__LEN               (8)
+#define BMI160_USER_OFFSET_5_GYRO_OFF_Z__MSK               (0xFF)
+#define BMI160_USER_OFFSET_5_GYRO_OFF_Z__REG	(BMI160_USER_OFFSET_5_ADDR)
+
+
+/* Offset_6 Description - Reg Addr --> 0x77, Bit --> 0..1 */
+#define BMI160_USER_OFFSET_6_GYRO_OFF_X__POS               (0)
+#define BMI160_USER_OFFSET_6_GYRO_OFF_X__LEN               (2)
+#define BMI160_USER_OFFSET_6_GYRO_OFF_X__MSK               (0x03)
+#define BMI160_USER_OFFSET_6_GYRO_OFF_X__REG	(BMI160_USER_OFFSET_6_ADDR)
+
+/* Offset_6 Description - Reg Addr --> 0x77, Bit --> 2...3 */
+#define BMI160_USER_OFFSET_6_GYRO_OFF_Y__POS               (2)
+#define BMI160_USER_OFFSET_6_GYRO_OFF_Y__LEN               (2)
+#define BMI160_USER_OFFSET_6_GYRO_OFF_Y__MSK               (0x0C)
+#define BMI160_USER_OFFSET_6_GYRO_OFF_Y__REG	(BMI160_USER_OFFSET_6_ADDR)
+
+/* Offset_6 Description - Reg Addr --> 0x77, Bit --> 4...5 */
+#define BMI160_USER_OFFSET_6_GYRO_OFF_Z__POS               (4)
+#define BMI160_USER_OFFSET_6_GYRO_OFF_Z__LEN               (2)
+#define BMI160_USER_OFFSET_6_GYRO_OFF_Z__MSK               (0x30)
+#define BMI160_USER_OFFSET_6_GYRO_OFF_Z__REG	 (BMI160_USER_OFFSET_6_ADDR)
+/**************************************************************/
+/**\name	ACCEL OFFSET  ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Offset_6 Description - Reg Addr --> 0x77, Bit --> 6 */
+#define BMI160_USER_OFFSET_6_ACCEL_OFF_ENABLE__POS               (6)
+#define BMI160_USER_OFFSET_6_ACCEL_OFF_ENABLE__LEN               (1)
+#define BMI160_USER_OFFSET_6_ACCEL_OFF_ENABLE__MSK               (0x40)
+#define BMI160_USER_OFFSET_6_ACCEL_OFF_ENABLE__REG	 \
+(BMI160_USER_OFFSET_6_ADDR)
+/**************************************************************/
+/**\name	GYRO OFFSET  ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Offset_6 Description - Reg Addr --> 0x77, Bit -->  7 */
+#define BMI160_USER_OFFSET_6_GYRO_OFF_EN__POS               (7)
+#define BMI160_USER_OFFSET_6_GYRO_OFF_EN__LEN               (1)
+#define BMI160_USER_OFFSET_6_GYRO_OFF_EN__MSK               (0x80)
+#define BMI160_USER_OFFSET_6_GYRO_OFF_EN__REG	 (BMI160_USER_OFFSET_6_ADDR)
+/**************************************************************/
+/**\name	STEP COUNTER LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* STEP_CNT_0  Description - Reg Addr --> 0x78, Bit -->  0 to 7 */
+#define BMI160_USER_STEP_COUNT_LSB__POS               (0)
+#define BMI160_USER_STEP_COUNT_LSB__LEN               (7)
+#define BMI160_USER_STEP_COUNT_LSB__MSK               (0xFF)
+#define BMI160_USER_STEP_COUNT_LSB__REG	 (BMI160_USER_STEP_COUNT_0_ADDR)
+
+/* STEP_CNT_1  Description - Reg Addr --> 0x79, Bit -->  0 to 7 */
+#define BMI160_USER_STEP_COUNT_MSB__POS               (0)
+#define BMI160_USER_STEP_COUNT_MSB__LEN               (7)
+#define BMI160_USER_STEP_COUNT_MSB__MSK               (0xFF)
+#define BMI160_USER_STEP_COUNT_MSB__REG	 (BMI160_USER_STEP_COUNT_1_ADDR)
+/**************************************************************/
+/**\name	STEP COUNTER CONFIGURATION LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* STEP_CONFIG_0  Description - Reg Addr --> 0x7A, Bit -->  0 to 7 */
+#define BMI160_USER_STEP_CONFIG_ZERO__POS               (0)
+#define BMI160_USER_STEP_CONFIG_ZERO__LEN               (7)
+#define BMI160_USER_STEP_CONFIG_ZERO__MSK               (0xFF)
+#define BMI160_USER_STEP_CONFIG_ZERO__REG	 \
+(BMI160_USER_STEP_CONFIG_0_ADDR)
+
+
+/* STEP_CONFIG_1  Description - Reg Addr --> 0x7B, Bit -->  0 to 2 and
+4 to 7 */
+#define BMI160_USER_STEP_CONFIG_ONE_CNF1__POS               (0)
+#define BMI160_USER_STEP_CONFIG_ONE_CNF1__LEN               (3)
+#define BMI160_USER_STEP_CONFIG_ONE_CNF1__MSK               (0x07)
+#define BMI160_USER_STEP_CONFIG_ONE_CNF1__REG	 \
+(BMI160_USER_STEP_CONFIG_1_ADDR)
+
+#define BMI160_USER_STEP_CONFIG_ONE_CNF2__POS               (4)
+#define BMI160_USER_STEP_CONFIG_ONE_CNF2__LEN               (4)
+#define BMI160_USER_STEP_CONFIG_ONE_CNF2__MSK               (0xF0)
+#define BMI160_USER_STEP_CONFIG_ONE_CNF2__REG	 \
+(BMI160_USER_STEP_CONFIG_1_ADDR)
+/**************************************************************/
+/**\name	STEP COUNTER ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* STEP_CONFIG_1  Description - Reg Addr --> 0x7B, Bit -->  0 to 2 */
+#define BMI160_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE__POS		(3)
+#define BMI160_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE__LEN		(1)
+#define BMI160_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE__MSK		(0x08)
+#define BMI160_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE__REG	\
+(BMI160_USER_STEP_CONFIG_1_ADDR)
+
+/* USER REGISTERS DEFINITION END */
+/**************************************************************************/
+/* CMD REGISTERS DEFINITION START */
+/**************************************************************/
+/**\name	COMMAND REGISTER LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Command description address - Reg Addr --> 0x7E, Bit -->  0....7 */
+#define BMI160_CMD_COMMANDS__POS              (0)
+#define BMI160_CMD_COMMANDS__LEN              (8)
+#define BMI160_CMD_COMMANDS__MSK              (0xFF)
+#define BMI160_CMD_COMMANDS__REG	 (BMI160_CMD_COMMANDS_ADDR)
+/**************************************************************/
+/**\name	PAGE ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Target page address - Reg Addr --> 0x7F, Bit -->  4....5 */
+#define BMI160_CMD_TARGET_PAGE__POS           (4)
+#define BMI160_CMD_TARGET_PAGE__LEN           (2)
+#define BMI160_CMD_TARGET_PAGE__MSK           (0x30)
+#define BMI160_CMD_TARGET_PAGE__REG	 (BMI160_CMD_EXT_MODE_ADDR)
+
+/* Target page address - Reg Addr --> 0x7F, Bit -->  4....5 */
+#define BMI160_CMD_PAGING_EN__POS           (7)
+#define BMI160_CMD_PAGING_EN__LEN           (1)
+#define BMI160_CMD_PAGING_EN__MSK           (0x80)
+#define BMI160_CMD_PAGING_EN__REG		(BMI160_CMD_EXT_MODE_ADDR)
+
+/* Target page address - Reg Addr --> 0x7F, Bit -->  4....5 */
+#define BMI160_COM_C_TRIM_FIVE__POS           (0)
+#define BMI160_COM_C_TRIM_FIVE__LEN           (8)
+#define BMI160_COM_C_TRIM_FIVE__MSK           (0xFF)
+#define BMI160_COM_C_TRIM_FIVE__REG		(BMI160_COM_C_TRIM_FIVE_ADDR)
+
+/**************************************************************************/
+/* CMD REGISTERS DEFINITION END */
+
+/**************************************************/
+/**\name	FIFO FRAME COUNT DEFINITION           */
+/*************************************************/
+#define FIFO_FRAME				(1024)
+#define FIFO_CONFIG_CHECK1		(0x00)
+#define FIFO_CONFIG_CHECK2		(0x80)
+/**************************************************/
+/**\name	MAG SENSOR SELECT          */
+/*************************************************/
+#define BST_BMM		(0)
+#define BST_AKM		(1)
+#define BMI160_YAS537_I2C_ADDRESS	(0x2E)
+/**************************************************/
+/**\name	ACCEL RANGE          */
+/*************************************************/
+#define BMI160_ACCEL_RANGE_2G           (0X03)
+#define BMI160_ACCEL_RANGE_4G           (0X05)
+#define BMI160_ACCEL_RANGE_8G           (0X08)
+#define BMI160_ACCEL_RANGE_16G          (0X0C)
+/**************************************************/
+/**\name	ACCEL ODR          */
+/*************************************************/
+#define BMI160_ACCEL_OUTPUT_DATA_RATE_RESERVED       (0x00)
+#define BMI160_ACCEL_OUTPUT_DATA_RATE_0_78HZ         (0x01)
+#define BMI160_ACCEL_OUTPUT_DATA_RATE_1_56HZ         (0x02)
+#define BMI160_ACCEL_OUTPUT_DATA_RATE_3_12HZ         (0x03)
+#define BMI160_ACCEL_OUTPUT_DATA_RATE_6_25HZ         (0x04)
+#define BMI160_ACCEL_OUTPUT_DATA_RATE_12_5HZ         (0x05)
+#define BMI160_ACCEL_OUTPUT_DATA_RATE_25HZ           (0x06)
+#define BMI160_ACCEL_OUTPUT_DATA_RATE_50HZ           (0x07)
+#define BMI160_ACCEL_OUTPUT_DATA_RATE_100HZ          (0x08)
+#define BMI160_ACCEL_OUTPUT_DATA_RATE_200HZ          (0x09)
+#define BMI160_ACCEL_OUTPUT_DATA_RATE_400HZ          (0x0A)
+#define BMI160_ACCEL_OUTPUT_DATA_RATE_800HZ          (0x0B)
+#define BMI160_ACCEL_OUTPUT_DATA_RATE_1600HZ         (0x0C)
+#define BMI160_ACCEL_OUTPUT_DATA_RATE_RESERVED0      (0x0D)
+#define BMI160_ACCEL_OUTPUT_DATA_RATE_RESERVED1      (0x0E)
+#define BMI160_ACCEL_OUTPUT_DATA_RATE_RESERVED2      (0x0F)
+/**************************************************/
+/**\name	ACCEL BANDWIDTH PARAMETER         */
+/*************************************************/
+#define BMI160_ACCEL_OSR4_AVG1			(0x00)
+#define BMI160_ACCEL_OSR2_AVG2			(0x01)
+#define BMI160_ACCEL_NORMAL_AVG4		(0x02)
+#define BMI160_ACCEL_CIC_AVG8			(0x03)
+#define BMI160_ACCEL_RES_AVG16			(0x04)
+#define BMI160_ACCEL_RES_AVG32			(0x05)
+#define BMI160_ACCEL_RES_AVG64			(0x06)
+#define BMI160_ACCEL_RES_AVG128			(0x07)
+/**************************************************/
+/**\name	GYRO ODR         */
+/*************************************************/
+#define BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED		(0x00)
+#define BMI160_GYRO_OUTPUT_DATA_RATE_25HZ			(0x06)
+#define BMI160_GYRO_OUTPUT_DATA_RATE_50HZ			(0x07)
+#define BMI160_GYRO_OUTPUT_DATA_RATE_100HZ			(0x08)
+#define BMI160_GYRO_OUTPUT_DATA_RATE_200HZ			(0x09)
+#define BMI160_GYRO_OUTPUT_DATA_RATE_400HZ			(0x0A)
+#define BMI160_GYRO_OUTPUT_DATA_RATE_800HZ			(0x0B)
+#define BMI160_GYRO_OUTPUT_DATA_RATE_1600HZ			(0x0C)
+#define BMI160_GYRO_OUTPUT_DATA_RATE_3200HZ			(0x0D)
+/**************************************************/
+/**\name	GYRO BANDWIDTH PARAMETER         */
+/*************************************************/
+#define BMI160_GYRO_OSR4_MODE		(0x00)
+#define BMI160_GYRO_OSR2_MODE		(0x01)
+#define BMI160_GYRO_NORMAL_MODE		(0x02)
+#define BMI160_GYRO_CIC_MODE		(0x03)
+/**************************************************/
+/**\name	GYROSCOPE RANGE PARAMETER         */
+/*************************************************/
+#define BMI160_GYRO_RANGE_2000_DEG_SEC	(0x00)
+#define BMI160_GYRO_RANGE_1000_DEG_SEC	(0x01)
+#define BMI160_GYRO_RANGE_500_DEG_SEC	(0x02)
+#define BMI160_GYRO_RANGE_250_DEG_SEC	(0x03)
+#define BMI160_GYRO_RANGE_125_DEG_SEC	(0x04)
+/**************************************************/
+/**\name	MAG ODR         */
+/*************************************************/
+#define BMI160_MAG_OUTPUT_DATA_RATE_RESERVED       (0x00)
+#define BMI160_MAG_OUTPUT_DATA_RATE_0_78HZ         (0x01)
+#define BMI160_MAG_OUTPUT_DATA_RATE_1_56HZ         (0x02)
+#define BMI160_MAG_OUTPUT_DATA_RATE_3_12HZ         (0x03)
+#define BMI160_MAG_OUTPUT_DATA_RATE_6_25HZ         (0x04)
+#define BMI160_MAG_OUTPUT_DATA_RATE_12_5HZ         (0x05)
+#define BMI160_MAG_OUTPUT_DATA_RATE_25HZ           (0x06)
+#define BMI160_MAG_OUTPUT_DATA_RATE_50HZ           (0x07)
+#define BMI160_MAG_OUTPUT_DATA_RATE_100HZ          (0x08)
+#define BMI160_MAG_OUTPUT_DATA_RATE_200HZ          (0x09)
+#define BMI160_MAG_OUTPUT_DATA_RATE_400HZ          (0x0A)
+#define BMI160_MAG_OUTPUT_DATA_RATE_800HZ          (0x0B)
+#define BMI160_MAG_OUTPUT_DATA_RATE_1600HZ         (0x0C)
+#define BMI160_MAG_OUTPUT_DATA_RATE_RESERVED0      (0x0D)
+#define BMI160_MAG_OUTPUT_DATA_RATE_RESERVED1      (0x0E)
+#define BMI160_MAG_OUTPUT_DATA_RATE_RESERVED2      (0x0F)
+
+/**************************************************/
+/**\name	ENABLE/DISABLE SELECTIONS        */
+/*************************************************/
+
+/* Enable accel and gyro offset */
+#define ACCEL_OFFSET_ENABLE		(0x01)
+#define GYRO_OFFSET_ENABLE		(0x01)
+
+/* command register definition */
+#define START_FOC_ACCEL_GYRO	(0X03)
+
+ /* INT ENABLE 1 */
+#define BMI160_ANY_MOTION_X_ENABLE       (0)
+#define BMI160_ANY_MOTION_Y_ENABLE       (1)
+#define BMI160_ANY_MOTION_Z_ENABLE       (2)
+#define BMI160_DOUBLE_TAP_ENABLE         (4)
+#define BMI160_SINGLE_TAP_ENABLE         (5)
+#define BMI160_ORIENT_ENABLE             (6)
+#define BMI160_FLAT_ENABLE               (7)
+
+/* INT ENABLE 1 */
+#define BMI160_HIGH_G_X_ENABLE       (0)
+#define BMI160_HIGH_G_Y_ENABLE       (1)
+#define BMI160_HIGH_G_Z_ENABLE       (2)
+#define BMI160_LOW_G_ENABLE          (3)
+#define BMI160_DATA_RDY_ENABLE       (4)
+#define BMI160_FIFO_FULL_ENABLE      (5)
+#define BMI160_FIFO_WM_ENABLE        (6)
+
+/* INT ENABLE 2 */
+#define  BMI160_NOMOTION_X_ENABLE	(0)
+#define  BMI160_NOMOTION_Y_ENABLE	(1)
+#define  BMI160_NOMOTION_Z_ENABLE	(2)
+#define  BMI160_STEP_DETECTOR_EN	(3)
+
+/* FOC axis selection for accel*/
+#define	FOC_X_AXIS		(0)
+#define	FOC_Y_AXIS		(1)
+#define	FOC_Z_AXIS		(2)
+
+/* IN OUT CONTROL */
+#define BMI160_INTR1_EDGE_CTRL			(0)
+#define BMI160_INTR2_EDGE_CTRL			(1)
+#define BMI160_INTR1_LEVEL				(0)
+#define BMI160_INTR2_LEVEL				(1)
+#define BMI160_INTR1_OUTPUT_TYPE		(0)
+#define BMI160_INTR2_OUTPUT_TYPE		(1)
+#define BMI160_INTR1_OUTPUT_ENABLE		(0)
+#define BMI160_INTR2_OUTPUT_ENABLE		(1)
+
+#define BMI160_INTR1_INPUT_ENABLE	(0)
+#define BMI160_INTR2_INPUT_ENABLE	(1)
+
+/*  INTERRUPT MAPS    */
+#define BMI160_INTR1_MAP_LOW_G			(0)
+#define BMI160_INTR2_MAP_LOW_G			(1)
+#define BMI160_INTR1_MAP_HIGH_G			(0)
+#define BMI160_INTR2_MAP_HIGH_G			(1)
+#define BMI160_INTR1_MAP_ANY_MOTION		(0)
+#define BMI160_INTR2_MAP_ANY_MOTION		(1)
+#define BMI160_INTR1_MAP_NOMO			(0)
+#define BMI160_INTR2_MAP_NOMO			(1)
+#define BMI160_INTR1_MAP_DOUBLE_TAP		(0)
+#define BMI160_INTR2_MAP_DOUBLE_TAP		(1)
+#define BMI160_INTR1_MAP_SINGLE_TAP		(0)
+#define BMI160_INTR2_MAP_SINGLE_TAP		(1)
+#define BMI160_INTR1_MAP_ORIENT			(0)
+#define BMI160_INTR2_MAP_ORIENT			(1)
+#define BMI160_INTR1_MAP_FLAT			(0)
+#define BMI160_INTR2_MAP_FLAT			(1)
+#define BMI160_INTR1_MAP_DATA_RDY		(0)
+#define BMI160_INTR2_MAP_DATA_RDY		(1)
+#define BMI160_INTR1_MAP_FIFO_WM		(0)
+#define BMI160_INTR2_MAP_FIFO_WM		(1)
+#define BMI160_INTR1_MAP_FIFO_FULL      (0)
+#define BMI160_INTR2_MAP_FIFO_FULL      (1)
+#define BMI160_INTR1_MAP_PMUTRIG        (0)
+#define BMI160_INTR2_MAP_PMUTRIG		(1)
+
+/* Interrupt mapping*/
+#define	BMI160_MAP_INTR1		(0)
+#define	BMI160_MAP_INTR2		(1)
+/**************************************************/
+/**\name	 TAP DURATION         */
+/*************************************************/
+#define BMI160_TAP_DURN_50MS     (0x00)
+#define BMI160_TAP_DURN_100MS    (0x01)
+#define BMI160_TAP_DURN_150MS    (0x02)
+#define BMI160_TAP_DURN_200MS    (0x03)
+#define BMI160_TAP_DURN_250MS    (0x04)
+#define BMI160_TAP_DURN_375MS    (0x05)
+#define BMI160_TAP_DURN_500MS    (0x06)
+#define BMI160_TAP_DURN_700MS    (0x07)
+/**************************************************/
+/**\name	TAP SHOCK         */
+/*************************************************/
+#define BMI160_TAP_SHOCK_50MS	(0x00)
+#define BMI160_TAP_SHOCK_75MS	(0x01)
+/**************************************************/
+/**\name	TAP QUIET        */
+/*************************************************/
+#define BMI160_TAP_QUIET_30MS	(0x00)
+#define BMI160_TAP_QUIET_20MS	(0x01)
+/**************************************************/
+/**\name	STEP DETECTION SELECTION MODES      */
+/*************************************************/
+#define	BMI160_STEP_NORMAL_MODE			(0)
+#define	BMI160_STEP_SENSITIVE_MODE		(1)
+#define	BMI160_STEP_ROBUST_MODE			(2)
+/**************************************************/
+/**\name	STEP CONFIGURATION SELECT MODE    */
+/*************************************************/
+#define	STEP_CONFIG_NORMAL		(0X315)
+#define	STEP_CONFIG_SENSITIVE	(0X2D)
+#define	STEP_CONFIG_ROBUST		(0X71D)
+/**************************************************/
+/**\name	BMM150 TRIM DATA DEFINITIONS      */
+/*************************************************/
+#define BMI160_MAG_DIG_X1                      (0x5D)
+#define BMI160_MAG_DIG_Y1                      (0x5E)
+#define BMI160_MAG_DIG_Z4_LSB                  (0x62)
+#define BMI160_MAG_DIG_Z4_MSB                  (0x63)
+#define BMI160_MAG_DIG_X2                      (0x64)
+#define BMI160_MAG_DIG_Y2                      (0x65)
+#define BMI160_MAG_DIG_Z2_LSB                  (0x68)
+#define BMI160_MAG_DIG_Z2_MSB                  (0x69)
+#define BMI160_MAG_DIG_Z1_LSB                  (0x6A)
+#define BMI160_MAG_DIG_Z1_MSB                  (0x6B)
+#define BMI160_MAG_DIG_XYZ1_LSB                (0x6C)
+#define BMI160_MAG_DIG_XYZ1_MSB                (0x6D)
+#define BMI160_MAG_DIG_Z3_LSB                  (0x6E)
+#define BMI160_MAG_DIG_Z3_MSB                  (0x6F)
+#define BMI160_MAG_DIG_XY2                     (0x70)
+#define BMI160_MAG_DIG_XY1                     (0x71)
+/**************************************************/
+/**\name	BMM150 PRE-SET MODE DEFINITIONS     */
+/*************************************************/
+#define BMI160_MAG_PRESETMODE_LOWPOWER                 (1)
+#define BMI160_MAG_PRESETMODE_REGULAR                  (2)
+#define BMI160_MAG_PRESETMODE_HIGHACCURACY             (3)
+#define BMI160_MAG_PRESETMODE_ENHANCED                 (4)
+/**************************************************/
+/**\name	BMM150 PRESET MODES - DATA RATES    */
+/*************************************************/
+#define BMI160_MAG_LOWPOWER_DR                       (0x02)
+#define BMI160_MAG_REGULAR_DR                        (0x02)
+#define BMI160_MAG_HIGHACCURACY_DR                   (0x2A)
+#define BMI160_MAG_ENHANCED_DR                       (0x02)
+/**************************************************/
+/**\name	BMM150 PRESET MODES - REPETITIONS-XY RATES */
+/*************************************************/
+#define BMI160_MAG_LOWPOWER_REPXY                    (1)
+#define BMI160_MAG_REGULAR_REPXY                     (4)
+#define BMI160_MAG_HIGHACCURACY_REPXY                (23)
+#define BMI160_MAG_ENHANCED_REPXY                    (7)
+/**************************************************/
+/**\name	BMM150 PRESET MODES - REPETITIONS-Z RATES */
+/*************************************************/
+#define BMI160_MAG_LOWPOWER_REPZ                     (2)
+#define BMI160_MAG_REGULAR_REPZ                      (14)
+#define BMI160_MAG_HIGHACCURACY_REPZ                 (82)
+#define BMI160_MAG_ENHANCED_REPZ                     (26)
+#define BMI160_MAG_NOAMRL_SWITCH_TIMES               (5)
+#define MAG_INTERFACE_PMU_ENABLE                     (1)
+#define MAG_INTERFACE_PMU_DISABLE                    (0)
+/**************************************************/
+/**\name	USED FOR MAG OVERFLOW CHECK FOR BMM150  */
+/*************************************************/
+#define BMI160_MAG_OVERFLOW_OUTPUT			((s16)-32768)
+#define BMI160_MAG_OVERFLOW_OUTPUT_S32		((s32)(-2147483647-1))
+#define BMI160_MAG_NEGATIVE_SATURATION_Z   ((s16)-32767)
+#define BMI160_MAG_POSITIVE_SATURATION_Z   ((u16)32767)
+#define BMI160_MAG_FLIP_OVERFLOW_ADCVAL		((s16)-4096)
+#define BMI160_MAG_HALL_OVERFLOW_ADCVAL		((s16)-16384)
+/**************************************************/
+/**\name	BMM150 REGISTER DEFINITION */
+/*************************************************/
+#define BMI160_BMM150_CHIP_ID           (0x40)
+#define BMI160_BMM150_POWE_CONTROL_REG	(0x4B)
+#define BMI160_BMM150_POWE_MODE_REG		(0x4C)
+#define BMI160_BMM150_DATA_REG			(0x42)
+#define BMI160_BMM150_XY_REP			(0x51)
+#define BMI160_BMM150_Z_REP				(0x52)
+/**************************************************/
+/**\name	AKM COMPENSATING DATA REGISTERS     */
+/*************************************************/
+#define BMI160_BST_AKM_ASAX		(0x60)
+#define BMI160_BST_AKM_ASAY		(0x61)
+#define BMI160_BST_AKM_ASAZ		(0x62)
+/**************************************************/
+/**\name	AKM POWER MODE SELECTION     */
+/*************************************************/
+#define AKM_POWER_DOWN_MODE			(0)
+#define AKM_SINGLE_MEAS_MODE		(1)
+#define FUSE_ROM_MODE				(2)
+/**************************************************/
+/**\name	SECONDARY_MAG POWER MODE SELECTION    */
+/*************************************************/
+#define BMI160_MAG_FORCE_MODE		(0)
+#define BMI160_MAG_SUSPEND_MODE		(1)
+/**************************************************/
+/**\name	MAG POWER MODE SELECTION    */
+/*************************************************/
+#define	FORCE_MODE		(0)
+#define	SUSPEND_MODE	(1)
+#define	NORMAL_MODE		(2)
+#define MAG_SUSPEND_MODE (1)
+/**************************************************/
+/**\name	FIFO CONFIGURATIONS    */
+/*************************************************/
+#define FIFO_HEADER_ENABLE			(0x01)
+#define FIFO_MAG_ENABLE				(0x01)
+#define FIFO_ACCEL_ENABLE			(0x01)
+#define FIFO_GYRO_ENABLE			(0x01)
+#define FIFO_TIME_ENABLE			(0x01)
+#define FIFO_STOPONFULL_ENABLE		(0x01)
+#define FIFO_WM_INTERRUPT_ENABLE	(0x01)
+#define	BMI160_FIFO_INDEX_LENGTH	(1)
+#define	BMI160_FIFO_TAG_INTR_MASK	(0xFC)
+
+/**************************************************/
+/**\name	ACCEL POWER MODE    */
+/*************************************************/
+#define ACCEL_MODE_NORMAL	(0x11)
+#define	ACCEL_LOWPOWER		(0X12)
+#define	ACCEL_SUSPEND		(0X10)
+/**************************************************/
+/**\name	GYRO POWER MODE    */
+/*************************************************/
+#define GYRO_MODE_SUSPEND		(0x14)
+#define GYRO_MODE_NORMAL		(0x15)
+#define GYRO_MODE_FASTSTARTUP	(0x17)
+/**************************************************/
+/**\name	MAG POWER MODE    */
+/*************************************************/
+#define MAG_MODE_SUSPEND	(0x18)
+#define MAG_MODE_NORMAL		(0x19)
+#define MAG_MODE_LOWPOWER	(0x1A)
+/**************************************************/
+/**\name	ENABLE/DISABLE BIT VALUES    */
+/*************************************************/
+#define BMI160_ENABLE	(0x01)
+#define BMI160_DISABLE	(0x00)
+/**************************************************/
+/**\name	INTERRUPT EDGE TRIGGER ENABLE    */
+/*************************************************/
+#define BMI160_EDGE		(0x01)
+#define BMI160_LEVEL	(0x00)
+/**************************************************/
+/**\name	INTERRUPT LEVEL ENABLE    */
+/*************************************************/
+#define BMI160_LEVEL_LOW		(0x00)
+#define BMI160_LEVEL_HIGH		(0x01)
+/**************************************************/
+/**\name	INTERRUPT OUTPUT ENABLE    */
+/*************************************************/
+#define BMI160_OPEN_DRAIN	(0x01)
+#define BMI160_PUSH_PULL	(0x00)
+
+/* interrupt output enable*/
+#define BMI160_INPUT	(0x01)
+#define BMI160_OUTPUT	(0x00)
+
+/**************************************************/
+/**\name	INTERRUPT TAP SOURCE ENABLE    */
+/*************************************************/
+#define FILTER_DATA		(0x00)
+#define UNFILTER_DATA	(0x01)
+/**************************************************/
+/**\name	SLOW MOTION/ NO MOTION SELECT   */
+/*************************************************/
+#define SLOW_MOTION		(0x00)
+#define NO_MOTION		(0x01)
+/**************************************************/
+/**\name	SIGNIFICANT MOTION SELECTION   */
+/*************************************************/
+#define ANY_MOTION			(0x00)
+#define SIGNIFICANT_MOTION	(0x01)
+/**************************************************/
+/**\name	LATCH DURATION   */
+/*************************************************/
+#define BMI160_LATCH_DUR_NONE				(0x00)
+#define BMI160_LATCH_DUR_312_5_MICRO_SEC	(0x01)
+#define BMI160_LATCH_DUR_625_MICRO_SEC		(0x02)
+#define BMI160_LATCH_DUR_1_25_MILLI_SEC		(0x03)
+#define BMI160_LATCH_DUR_2_5_MILLI_SEC		(0x04)
+#define BMI160_LATCH_DUR_5_MILLI_SEC		(0x05)
+#define BMI160_LATCH_DUR_10_MILLI_SEC		(0x06)
+#define BMI160_LATCH_DUR_20_MILLI_SEC		(0x07)
+#define BMI160_LATCH_DUR_40_MILLI_SEC		(0x08)
+#define BMI160_LATCH_DUR_80_MILLI_SEC		(0x09)
+#define BMI160_LATCH_DUR_160_MILLI_SEC		(0x0A)
+#define BMI160_LATCH_DUR_320_MILLI_SEC		(0x0B)
+#define BMI160_LATCH_DUR_640_MILLI_SEC		(0x0C)
+#define BMI160_LATCH_DUR_1_28_SEC			(0x0D)
+#define BMI160_LATCH_DUR_2_56_SEC			(0x0E)
+#define BMI160_LATCHED						(0x0F)
+/**************************************************/
+/**\name	GYRO OFFSET MASK DEFINITION   */
+/*************************************************/
+#define BMI160_GYRO_MANUAL_OFFSET_0_7	(0x00FF)
+#define BMI160_GYRO_MANUAL_OFFSET_8_9	(0x0300)
+/**************************************************/
+/**\name	STEP CONFIGURATION MASK DEFINITION   */
+/*************************************************/
+#define BMI160_STEP_CONFIG_0_7		(0x00FF)
+#define BMI160_STEP_CONFIG_8_10		(0x0700)
+#define BMI160_STEP_CONFIG_11_14	(0xF000)
+/**************************************************/
+/**\name	DEFINITION USED FOR DIFFERENT WRITE   */
+/*************************************************/
+#define	BMI160_WRITE_TARGET_PAGE0	(0x00)
+#define	BMI160_WRITE_TARGET_PAGE1	(0x01)
+#define	BMI160_WRITE_ENABLE_PAGE1	(0x01)
+#define	BMI160_MANUAL_DISABLE	    (0x00)
+#define	BMI160_MANUAL_ENABLE	    (0x01)
+#define	BMI160_YAS_DISABLE_RCOIL	(0x00)
+#define	BMI160_ENABLE_MAG_IF_MODE	(0x02)
+#define	BMI160_ENABLE_ANY_MOTION_INTR1	(0x04)
+#define	BMI160_ENABLE_ANY_MOTION_INTR2	(0x04)
+#define	BMI160_MAG_DATA_READ_REG        (0x04)
+#define BMI160_BMM_POWER_MODE_REG		(0x06)
+#define	BMI160_ENABLE_ANY_MOTION_AXIS	(0x07)
+#define	BMI160_ENABLE_LOW_G             (0x08)
+#define	BMI160_YAS532_ACQ_START         (0x11)
+#define	BMI160_YAS_DEVICE_ID_REG        (0x80)
+#define	BMI160_FIFO_GYRO_ENABLE         (0x80)
+#define	BMI160_SIG_MOTION_INTR_ENABLE   (0x01)
+#define	BMI160_STEP_DETECT_INTR_ENABLE  (0x01)
+#define	BMI160_LOW_G_INTR_STAT          (0x01)
+#define BMI160_PULL_UP_DATA             (0x30)
+#define BMI160_FIFO_M_G_A_ENABLE        (0xE0)
+#define BMI160_FIFO_M_G_ENABLE          (0xA0)
+#define BMI160_FIFO_M_A_ENABLE          (0x60)
+#define BMI160_FIFO_G_A_ENABLE          (0xC0)
+#define BMI160_FIFO_A_ENABLE            (0x40)
+#define BMI160_FIFO_M_ENABLE            (0x20)
+/**************************************************/
+/**\name	MAG INIT DEFINITION  */
+/*************************************************/
+#define BMI160_COMMAND_REG_ONE		(0x37)
+#define BMI160_COMMAND_REG_TWO		(0x9A)
+#define BMI160_COMMAND_REG_THREE	(0xC0)
+#define	RESET_STEP_COUNTER			(0xB2)
+/**************************************************/
+/**\name	BIT SLICE GET AND SET FUNCTIONS  */
+/*************************************************/
+#define BMI160_GET_BITSLICE(regvar, bitname)\
+		((regvar & bitname##__MSK) >> bitname##__POS)
+
+
+#define BMI160_SET_BITSLICE(regvar, bitname, val)\
+		((regvar & ~bitname##__MSK) | \
+		((val<<bitname##__POS)&bitname##__MSK))
+
+/**************************************************/
+/**\name	 FUNCTION DECLARATIONS  */
+/*************************************************/
+/**************************************************/
+/**\name	 FUNCTION FOR BMI160 INITIALIZE  */
+/*************************************************/
+/*!
+ *	@brief
+ *	This function is used for initialize
+ *	bus read and bus write functions
+ *	assign the chip id and device address
+ *	chip id is read in the register 0x00 bit from 0 to 7
+ *
+ *	@param bmi160 : structure pointer
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *	@note
+ *	While changing the parameter of the bmi160_t
+ *	consider the following point:
+ *	Changing the reference value of the parameter
+ *	will changes the local copy or local reference
+ *	make sure your changes will not
+ *	affect the reference value of the parameter
+ *	(Better case don't change the reference value of the parameter)
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_init(struct bmi160_t *bmi160);
+/**************************************************/
+/**\name	 FUNCTION FOR READ AND WRITE REGISTERS  */
+/*************************************************/
+/*!
+ * @brief
+ *	This API write the data to
+ *	the given register
+ *
+ *
+ *	@param v_addr_u8 -> Address of the register
+ *	@param v_data_u8 -> The data from the register
+ *	@param v_len_u8 -> no of bytes to read
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_write_reg(u8 v_addr_u8,
+u8 *v_data_u8, u8 v_len_u8);
+/*!
+ * @brief
+ *	This API reads the data from
+ *	the given register
+ *
+ *
+ *	@param v_addr_u8 -> Address of the register
+ *	@param v_data_u8 -> The data from the register
+ *	@param v_len_u8 -> no of bytes to read
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_reg(u8 v_addr_u8,
+u8 *v_data_u8, u8 v_len_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR ERROR CODES  */
+/*************************************************/
+/*!
+ *	@brief This API used to reads the fatal error
+ *	from the Register 0x02 bit 0
+ *	This flag will be reset only by power-on-reset and soft reset
+ *
+ *
+ *  @param v_fatal_err_u8 : The status of fatal error
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_fatal_err(u8
+*v_fatal_err_u8);
+/*!
+ *	@brief This API used to read the error code
+ *	from register 0x02 bit 1 to 4
+ *
+ *
+ *  @param v_err_code_u8 : The status of error codes
+ *	error_code  |    description
+ *  ------------|---------------
+ *	0x00        |no error
+ *	0x01        |ACC_CONF error (accel ODR and bandwidth not compatible)
+ *	0x02        |GYR_CONF error (Gyroscope ODR and bandwidth not compatible)
+ *	0x03        |Under sampling mode and interrupt uses pre filtered data
+ *	0x04        |reserved
+ *	0x05        |Selected trigger-readout offset in
+ *    -         |MAG_IF greater than selected ODR
+ *	0x06        |FIFO configuration error for header less mode
+ *	0x07        |Under sampling mode and pre filtered data as FIFO source
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_err_code(u8
+*v_error_code_u8);
+/*!
+ *	@brief This API Reads the i2c error code from the
+ *	Register 0x02 bit 5.
+ *	This error occurred in I2C master detected
+ *
+ *  @param v_i2c_err_code_u8 : The status of i2c fail error
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_i2c_fail_err(u8
+*v_i2c_error_code_u8);
+ /*!
+ *	@brief This API Reads the dropped command error
+ *	from the register 0x02 bit 6
+ *
+ *
+ *  @param v_drop_cmd_err_u8 : The status of drop command error
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_drop_cmd_err(u8
+*v_drop_cmd_err_u8);
+/*!
+ *	@brief This API reads the magnetometer data ready
+ *	interrupt not active.
+ *	It reads from the error register 0x0x2 bit 7
+ *
+ *
+ *
+ *
+ *  @param v_mag_data_rdy_err_u8 : The status of mag data ready interrupt
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_dada_rdy_err(u8
+*v_mag_data_rdy_err_u8);
+/*!
+ *	@brief This API reads the error status
+ *	from the error register 0x02 bit 0 to 7
+ *
+ *  @param v_mag_data_rdy_err_u8 : The status of mag data ready interrupt
+ *  @param v_fatal_er_u8r : The status of fatal error
+ *  @param v_err_code_u8 : The status of error code
+ *  @param v_i2c_fail_err_u8 : The status of I2C fail error
+ *  @param v_drop_cmd_err_u8 : The status of drop command error
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_error_status(u8 *v_fatal_er_u8r,
+u8 *v_err_code_u8, u8 *v_i2c_fail_err_u8,
+u8 *v_drop_cmd_err_u8, u8 *v_mag_data_rdy_err_u8);
+/******************************************************************/
+/**\name	 FUNCTIONS FOR MAG,ACCEL AND GYRO POWER MODE STATUS  */
+/*****************************************************************/
+/*!
+ *	@brief This API reads the magnetometer power mode from
+ *	PMU status register 0x03 bit 0 and 1
+ *
+ *  @param v_mag_power_mode_stat_u8 : The value of mag power mode
+ *	mag_powermode    |   value
+ * ------------------|----------
+ *    SUSPEND        |   0x00
+ *    NORMAL         |   0x01
+ *   LOW POWER       |   0x02
+ *
+ *
+ * @note The power mode of mag set by the 0x7E command register
+ * @note using the function "bmi160_set_command_register()"
+ *  value    |   mode
+ *  ---------|----------------
+ *   0x18    | MAG_MODE_SUSPEND
+ *   0x19    | MAG_MODE_NORMAL
+ *   0x1A    | MAG_MODE_LOWPOWER
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_power_mode_stat(u8
+*v_mag_power_mode_stat_u8);
+/*!
+ *	@brief This API reads the gyroscope power mode from
+ *	PMU status register 0x03 bit 2 and 3
+ *
+ *  @param v_gyro_power_mode_stat_u8 :	The value of gyro power mode
+ *	gyro_powermode   |   value
+ * ------------------|----------
+ *    SUSPEND        |   0x00
+ *    NORMAL         |   0x01
+ *   FAST POWER UP   |   0x03
+ *
+ * @note The power mode of gyro set by the 0x7E command register
+ * @note using the function "bmi160_set_command_register()"
+ *  value    |   mode
+ *  ---------|----------------
+ *   0x14    | GYRO_MODE_SUSPEND
+ *   0x15    | GYRO_MODE_NORMAL
+ *   0x17    | GYRO_MODE_FASTSTARTUP
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_power_mode_stat(u8
+*v_gyro_power_mode_stat_u8);
+/*!
+ *	@brief This API reads the accelerometer power mode from
+ *	PMU status register 0x03 bit 4 and 5
+ *
+ *
+ *  @param v_accel_power_mode_stat_u8 :	The value of accel power mode
+ *	accel_powermode  |   value
+ * ------------------|----------
+ *    SUSPEND        |   0x00
+ *    NORMAL         |   0x01
+ *  LOW POWER        |   0x03
+ *
+ * @note The power mode of accel set by the 0x7E command register
+ * @note using the function "bmi160_set_command_register()"
+ *  value    |   mode
+ *  ---------|----------------
+ *   0x11    | ACCEL_MODE_NORMAL
+ *   0x12    | ACCEL_LOWPOWER
+ *   0x10    | ACCEL_SUSPEND
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_power_mode_stat(u8
+*v_accel_power_mode_stat_u8);
+/*!
+ *	@brief This API switch mag interface to normal mode
+ *	and confirm whether the mode switching done successfully or not
+*
+ *	@return results of bus communication function and current MAG_PMU result
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_interface_normal(void);
+/**************************************************/
+/**\name	 FUNCTION FOR Mag XYZ data read */
+/*************************************************/
+/*!
+ *	@brief This API reads magnetometer data X values
+ *	from the register 0x04 and 0x05
+ *	@brief The mag sensor data read form auxiliary mag
+ *
+ *  @param v_mag_x_s16 : The value of mag x
+ *  @param v_sensor_select_u8 : Mag selection value
+ *  value    |   sensor
+ *  ---------|----------------
+ *   0       | BMM150
+ *   1       | AKM09911 or AKM09912
+ *
+ *	@note For mag data output rate configuration use the following function
+ *	@note bmi160_set_mag_output_data_rate()
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_x(s16 *v_mag_x_s16,
+u8 v_sensor_select_u8);
+/*!
+ *	@brief This API reads magnetometer data Y values
+ *	from the register 0x06 and 0x07
+ *	@brief The mag sensor data read form auxiliary mag
+ *
+ *  @param v_mag_y_s16 : The value of mag y
+ *  @param v_sensor_select_u8 : Mag selection value
+ *  value    |   sensor
+ *  ---------|----------------
+ *   0       | BMM150
+ *   1       | AKM09911 or AKM09912
+ *
+ *	@note For mag data output rate configuration use the following function
+ *	@note bmi160_set_mag_output_data_rate()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_y(s16 *v_mag_y_s16,
+u8 v_sensor_select_u8);
+/*!
+ *	@brief This API reads magnetometer data Z values
+ *	from the register 0x08 and 0x09
+ *	@brief The mag sensor data read form auxiliary mag
+ *
+ *  @param v_mag_z_s16 : The value of mag z
+ *  @param v_sensor_select_u8 : Mag selection value
+ *  value    |   sensor
+ *  ---------|----------------
+ *   0       | BMM150
+ *   1       | AKM09911 or AKM09912
+ *
+ *	@note For mag data output rate configuration use the following function
+ *	@note bmi160_set_mag_output_data_rate()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_z(s16 *v_mag_z_s16,
+u8 v_sensor_select_u8);
+/*!
+ *	@brief This API reads magnetometer data RHALL values
+ *	from the register 0x0A and 0x0B
+ *
+ *
+ *  @param v_mag_r_s16 : The value of BMM150 r data
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_r(
+s16 *v_mag_r_s16);
+/*!
+ *	@brief This API reads magnetometer data X,Y,Z values
+ *	from the register 0x04 to 0x09
+ *
+ *	@brief The mag sensor data read form auxiliary mag
+ *
+ *  @param mag : The value of mag xyz data
+ *  @param v_sensor_select_u8 : Mag selection value
+ *  value    |   sensor
+ *  ---------|----------------
+ *   0       | BMM150
+ *   1       | AKM09911 or AKM09912
+ *
+ *	@note For mag data output rate configuration use the following function
+ *	@note bmi160_set_mag_output_data_rate()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_xyz(
+struct bmi160_mag_t *mag, u8 v_sensor_select_u8);
+ /*!*
+ *	@brief This API reads magnetometer data X,Y,Z,r
+ *	values from the register 0x04 to 0x0B
+ *
+ *	@brief The mag sensor data read form auxiliary mag
+ *
+ *  @param mag : The value of mag-BMM150 xyzr data
+ *
+ *	@note For mag data output rate configuration use the following function
+ *	@note bmi160_set_mag_output_data_rate()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_xyzr(
+struct bmi160_mag_xyzr_t *mag);
+/**************************************************/
+/**\name	 FUNCTION FOR GYRO XYZ DATA READ  */
+/*************************************************/
+/*!
+ *	@brief This API reads gyro data X values
+ *	form the register 0x0C and 0x0D
+ *
+ *
+ *
+ *
+ *  @param v_gyro_x_s16 : The value of gyro x data
+ *
+ *	@note Gyro Configuration use the following function
+ *	@note bmi160_set_gyro_output_data_rate()
+ *	@note bmi160_set_gyro_bw()
+ *	@note bmi160_set_gyro_range()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_gyro_x(
+s16 *v_gyro_x_s16);
+/*!
+ *	@brief This API reads gyro data Y values
+ *	form the register 0x0E and 0x0F
+ *
+ *
+ *
+ *
+ *  @param v_gyro_y_s16 : The value of gyro y data
+ *
+ *	@note Gyro Configuration use the following function
+ *	@note bmi160_set_gyro_output_data_rate()
+ *	@note bmi160_set_gyro_bw()
+ *	@note bmi160_set_gyro_range()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error result of communication routines
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_gyro_y(
+s16 *v_gyro_y_s16);
+/*!
+ *	@brief This API reads gyro data Z values
+ *	form the register 0x10 and 0x11
+ *
+ *
+ *
+ *
+ *  @param v_gyro_z_s16 : The value of gyro z data
+ *
+ *	@note Gyro Configuration use the following function
+ *	@note bmi160_set_gyro_output_data_rate()
+ *	@note bmi160_set_gyro_bw()
+ *	@note bmi160_set_gyro_range()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_gyro_z(
+s16 *v_gyro_z_s16);
+/*!
+ *	@brief This API reads gyro data X,Y,Z values
+ *	from the register 0x0C to 0x11
+ *
+ *
+ *
+ *
+ *  @param gyro : The value of gyro xyz
+ *
+ *	@note Gyro Configuration use the following function
+ *	@note bmi160_set_gyro_output_data_rate()
+ *	@note bmi160_set_gyro_bw()
+ *	@note bmi160_set_gyro_range()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_gyro_xyz(
+struct bmi160_gyro_t *gyro);
+/**************************************************/
+/**\name	 FUNCTION FOR ACCEL XYZ DATA READ  */
+/*************************************************/
+/*!
+ *	@brief This API reads accelerometer data X values
+ *	form the register 0x12 and 0x13
+ *
+ *
+ *
+ *
+ *  @param v_accel_x_s16 : The value of accel x
+ *
+ *	@note For accel configuration use the following functions
+ *	@note bmi160_set_accel_output_data_rate()
+ *	@note bmi160_set_accel_bw()
+ *	@note bmi160_set_accel_under_sampling_parameter()
+ *	@note bmi160_set_accel_range()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_accel_x(
+s16 *v_accel_x_s16);
+/*!
+ *	@brief This API reads accelerometer data Y values
+ *	form the register 0x14 and 0x15
+ *
+ *
+ *
+ *
+ *  @param v_accel_y_s16 : The value of accel y
+ *
+ *	@note For accel configuration use the following functions
+ *	@note bmi160_set_accel_output_data_rate()
+ *	@note bmi160_set_accel_bw()
+ *	@note bmi160_set_accel_under_sampling_parameter()
+ *	@note bmi160_set_accel_range()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_accel_y(
+s16 *v_accel_y_s16);
+/*!
+ *	@brief This API reads accelerometer data Z values
+ *	form the register 0x16 and 0x17
+ *
+ *
+ *
+ *
+ *  @param v_accel_z_s16 : The value of accel z
+ *
+ *	@note For accel configuration use the following functions
+ *	@note bmi160_set_accel_output_data_rate()
+ *	@note bmi160_set_accel_bw()
+ *	@note bmi160_set_accel_under_sampling_parameter()
+ *	@note bmi160_set_accel_range()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_accel_z(
+s16 *v_accel_z_s16);
+/*!
+ *	@brief This API reads accelerometer data X,Y,Z values
+ *	from the register 0x12 to 0x17
+ *
+ *
+ *
+ *
+ *  @param accel :The value of accel xyz
+ *
+ *	@note For accel configuration use the following functions
+ *	@note bmi160_set_accel_output_data_rate()
+ *	@note bmi160_set_accel_bw()
+ *	@note bmi160_set_accel_under_sampling_parameter()
+ *	@note bmi160_set_accel_range()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_accel_xyz(
+struct bmi160_accel_t *accel);
+/**************************************************/
+/**\name	 FUNCTION FOR SENSOR TIME */
+/*************************************************/
+/*!
+ *	@brief This API reads sensor_time from the register
+ *	0x18 to 0x1A
+ *
+ *
+ *  @param v_sensor_time_u32 : The value of sensor time
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_sensor_time(
+u32 *v_sensor_time_u32);
+/**************************************************/
+/**\name	 FUNCTION FOR GYRO SLEF TEST  */
+/*************************************************/
+/*!
+ *	@brief This API reads the Gyroscope self test
+ *	status from the register 0x1B bit 1
+ *
+ *
+ *  @param v_gyro_selftest_u8 : The value of gyro self test status
+ *  value    |   status
+ *  ---------|----------------
+ *   0       | Gyroscope self test is running or failed
+ *   1       | Gyroscope self test completed successfully
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_selftest(u8
+*v_gyro_selftest_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR MANUAL INTERFACE  */
+/*************************************************/
+/*!
+ *	@brief This API reads the status of
+ *	mag manual interface operation form the register 0x1B bit 2
+ *
+ *
+ *
+ *  @param v_mag_manual_stat_u8 : The value of mag manual operation status
+ *  value    |   status
+ *  ---------|----------------
+ *   0       | Indicates no manual magnetometer
+ *   -       | interface operation is ongoing
+ *   1       | Indicates manual magnetometer
+ *   -       | interface operation is ongoing
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_manual_operation_stat(u8
+*v_mag_manual_stat_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR FAST OFFSET READY  */
+/*************************************************/
+/*!
+ *	@brief This API reads the fast offset compensation
+ *	status form the register 0x1B bit 3
+ *
+ *
+ *  @param v_foc_rdy_u8 : The status of fast compensation
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_foc_rdy(u8
+*v_foc_rdy_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR NVM READY  */
+/*************************************************/
+/*!
+ * @brief This API Reads the nvm_rdy status from the
+ *	resister 0x1B bit 4
+ *
+ *
+ *  @param v_nvm_rdy_u8 : The value of NVM ready status
+ *  value    |   status
+ *  ---------|----------------
+ *   0       | NVM write operation in progress
+ *   1       | NVM is ready to accept a new write trigger
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_nvm_rdy(u8
+*v_nvm_rdy_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR DATA READY FOR MAG, GYRO, AND ACCEL */
+/*************************************************/
+/*!
+ *	@brief This API reads the status of mag data ready
+ *	from the register 0x1B bit 5
+ *	The status get reset when one mag data register is read out
+ *
+ *  @param v_data_rdy_u8 : The value of mag data ready status
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_data_rdy_mag(u8
+*v_data_rdy_u8);
+/*!
+ *	@brief This API reads the status of gyro data ready form the
+ *	register 0x1B bit 6
+ *	The status get reset when gyro data register read out
+ *
+ *
+ *	@param v_data_rdy_u8 :	The value of gyro data ready
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_data_rdy(u8
+*v_data_rdy_u8);
+/*!
+ *	@brief This API reads the status of accel data ready form the
+ *	register 0x1B bit 7
+ *	The status get reset when accel data register read out
+ *
+ *
+ *	@param v_data_rdy_u8 :	The value of accel data ready status
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_data_rdy(u8
+*drdy_acc);
+/**************************************************/
+/**\name	 FUNCTION FOR STEP INTERRUPT STATUS  */
+/*************************************************/
+/*!
+ *	@brief This API reads the step detector interrupt status
+ *	from the register 0x1C bit 0
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the single tab interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt
+ *	signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_step_intr_u8 : The status of step detector interrupt
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_step_intr(u8
+*v_step_intr_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR SIGNIFICANT INTERRUPT STATUS  */
+/*************************************************/
+/*!
+ *	@brief This API reads the
+ *	significant motion interrupt status
+ *	from the register 0x1C bit 1
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the single tab interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt
+ *	signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *
+ *  @param v_significant_intr_u8 : The status of step
+ *	motion interrupt
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_significant_intr(u8
+*sigmot_intr);
+/**************************************************/
+/**\name	 FUNCTION FOR ANY MOTION INTERRUPT STATUS  */
+/*************************************************/
+ /*!
+ *	@brief This API reads the any motion interrupt status
+ *	from the register 0x1C bit 2
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the single tab interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt
+ *	signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *  @param v_any_motion_intr_u8 : The status of any-motion interrupt
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_any_motion_intr(u8
+*v_any_motion_intr_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR PMU TRIGGER INTERRUPT STATUS  */
+/*************************************************/
+/*!
+ *	@brief This API reads the power mode trigger interrupt status
+ *	from the register 0x1C bit 3
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the single tab interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt
+ *	signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *
+ *  @param v_pmu_trigger_intr_u8 : The status of power mode trigger interrupt
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_pmu_trigger_intr(u8
+*v_pmu_trigger_intr_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR DOUBLE TAB STATUS  */
+/*************************************************/
+/*!
+ *	@brief This API reads the double tab status
+ *	from the register 0x1C bit 4
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the single tab interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt
+ *	signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_double_tap_intr_u8 :The status of double tab interrupt
+ *
+ *	@note Double tap interrupt can be configured by the following functions
+ *	@note INTERRUPT MAPPING
+ *	@note bmi160_set_intr_double_tap()
+ *	@note AXIS MAPPING
+ *	@note bmi160_get_stat2_tap_first_x()
+ *	@note bmi160_get_stat2_tap_first_y()
+ *	@note bmi160_get_stat2_tap_first_z()
+ *	@note DURATION
+ *	@note bmi160_set_intr_tap_durn()
+ *	@note THRESHOLD
+ *	@note bmi160_set_intr_tap_thres()
+ *	@note TAP QUIET
+ *	@note bmi160_set_intr_tap_quiet()
+ *	@note TAP SHOCK
+ *	@note bmi160_set_intr_tap_shock()
+ *	@note TAP SOURCE
+ *	@note bmi160_set_intr_tap_source()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_double_tap_intr(u8
+*v_double_tap_intr_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR SINGLE TAB STATUS  */
+/*************************************************/
+/*!
+ *	@brief This API reads the single tab status
+ *	from the register 0x1C bit 5
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the single tab interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt
+ *	signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_single_tap_intr_u8 :The status of single tap interrupt
+ *
+ *	@note Single tap interrupt can be configured by the following functions
+ *	@note INTERRUPT MAPPING
+ *	@note bmi160_set_intr_single_tap()
+ *	@note AXIS MAPPING
+ *	@note bmi160_get_stat2_tap_first_x()
+ *	@note bmi160_get_stat2_tap_first_y()
+ *	@note bmi160_get_stat2_tap_first_z()
+ *	@note DURATION
+ *	@note bmi160_set_intr_tap_durn()
+ *	@note THRESHOLD
+ *	@note bmi160_set_intr_tap_thres()
+ *	@note TAP QUIET
+ *	@note bmi160_set_intr_tap_quiet()
+ *	@note TAP SHOCK
+ *	@note bmi160_set_intr_tap_shock()
+ *	@note TAP SOURCE
+ *	@note bmi160_set_intr_tap_source()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_single_tap_intr(u8
+*v_single_tap_intr_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR ORIENT INTERRUPT STATUS  */
+/*************************************************/
+/*!
+ *	@brief This API reads the orient status
+ *	from the register 0x1C bit 6
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the orient interrupt triggers. The
+ *	setting of INT_LATCH controls if the
+ *	interrupt signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_orient_intr_u8 : The status of orient interrupt
+ *
+ *	@note For orient interrupt configuration use the following functions
+ *	@note STATUS
+ *	@note bmi160_get_stat0_orient_intr()
+ *	@note AXIS MAPPING
+ *	@note bmi160_get_stat3_orient_xy()
+ *	@note bmi160_get_stat3_orient_z()
+ *	@note bmi160_set_intr_orient_axes_enable()
+ *	@note INTERRUPT MAPPING
+ *	@note bmi160_set_intr_orient()
+ *	@note INTERRUPT OUTPUT
+ *	@note bmi160_set_intr_orient_ud_enable()
+ *	@note THETA
+ *	@note bmi160_set_intr_orient_theta()
+ *	@note HYSTERESIS
+ *	@note bmi160_set_intr_orient_hyst()
+ *	@note BLOCKING
+ *	@note bmi160_set_intr_orient_blocking()
+ *	@note MODE
+ *	@note bmi160_set_intr_orient_mode()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_orient_intr(u8
+*v_orient_intr_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR FLAT INTERRUPT STATUS  */
+/*************************************************/
+/*!
+ *	@brief This API reads the flat interrupt status
+ *	from the register 0x1C bit 7
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the flat interrupt triggers. The
+ *	setting of INT_LATCH controls if the
+ *	interrupt signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_flat_intr_u8 : The status of  flat interrupt
+ *
+ *	@note For flat configuration use the following functions
+ *	@note STATS
+ *	@note bmi160_get_stat0_flat_intr()
+ *	@note bmi160_get_stat3_flat()
+ *	@note INTERRUPT MAPPING
+ *	@note bmi160_set_intr_flat()
+ *	@note THETA
+ *	@note bmi160_set_intr_flat_theta()
+ *	@note HOLD TIME
+ *	@note bmi160_set_intr_flat_hold()
+ *	@note HYSTERESIS
+ *	@note bmi160_set_intr_flat_hyst()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_flat_intr(u8
+*v_flat_intr_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR HIGH_G INTERRUPT STATUS  */
+/*************************************************/
+/*!
+ *	@brief This API reads the high_g interrupt status
+ *	from the register 0x1D bit 2
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the high g  interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt signal and hence the
+ *	respective interrupt flag will be permanently
+ *	latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_high_g_intr_u8 : The status of high_g interrupt
+ *
+ *	@note High_g interrupt configured by following functions
+ *	@note STATUS
+ *	@note bmi160_get_stat1_high_g_intr()
+ *	@note AXIS MAPPING
+ *	@note bmi160_get_stat3_high_g_first_x()
+ *	@note bmi160_get_stat3_high_g_first_y()
+ *	@note bmi160_get_stat3_high_g_first_z()
+ *	@note SIGN MAPPING
+ *	@note bmi160_get_stat3_high_g_first_sign()
+ *	@note INTERRUPT MAPPING
+ *	@note bmi160_set_intr_high_g()
+  *	@note HYSTERESIS
+ *	@note bmi160_set_intr_high_g_hyst()
+ *	@note DURATION
+ *	@note bmi160_set_intr_high_g_durn()
+ *	@note THRESHOLD
+ *	@note bmi160_set_intr_high_g_thres()
+ *	@note SOURCE
+ *	@note bmi160_set_intr_low_high_source()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat1_high_g_intr(u8
+*v_high_g_intr_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR LOW_G INTERRUPT STATUS  */
+/*************************************************/
+/*!
+ *	@brief This API reads the low g interrupt status
+ *	from the register 0x1D bit 3
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the low g  interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_low_g_intr_u8 : The status of low_g interrupt
+ *
+ *	@note Low_g interrupt configured by following functions
+ *	@note STATUS
+ *	@note bmi160_get_stat1_low_g_intr()
+ *	@note INTERRUPT MAPPING
+ *	@note bmi160_set_intr_low_g()
+ *	@note SOURCE
+ *	@note bmi160_set_intr_low_high_source()
+ *	@note DURATION
+ *	@note bmi160_set_intr_low_g_durn()
+ *	@note THRESHOLD
+ *	@note bmi160_set_intr_low_g_thres()
+ *	@note HYSTERESIS
+ *	@note bmi160_set_intr_low_g_hyst()
+ *	@note MODE
+ *	@note bmi160_set_intr_low_g_mode()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat1_low_g_intr(u8
+*v_low_g_intr_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR DATA READY INTERRUPT STATUS  */
+/*************************************************/
+/*!
+ *	@brief This API reads data ready interrupt status
+ *	from the register 0x1D bit 4
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the  data ready  interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_data_rdy_intr_u8 : The status of data ready interrupt
+ *
+ *	@note Data ready interrupt configured by following functions
+ *	@note STATUS
+ *	@note bmi160_get_stat1_data_rdy_intr()
+ *	@note INTERRUPT MAPPING
+ *	@note bmi160_set_intr_data_rdy()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat1_data_rdy_intr(u8
+*v_data_rdy_intr_u8);
+/**************************************************/
+/**\name	 FUNCTIONS FOR FIFO FULL AND WATER MARK INTERRUPT STATUS*/
+/*************************************************/
+/*!
+ *	@brief This API reads data ready FIFO full interrupt status
+ *	from the register 0x1D bit 5
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the FIFO full interrupt triggers. The
+ *	setting of INT_LATCH controls if the
+ *	interrupt signal and hence the
+ *	respective interrupt flag will
+ *	be permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_fifo_full_intr_u8 : The status of fifo full interrupt
+ *
+ *	@note FIFO full interrupt can be configured by following functions
+ *	@note bmi160_set_intr_fifo_full()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat1_fifo_full_intr(u8
+*v_fifo_full_intr_u8);
+/*!
+ *	@brief This API reads data
+ *	 ready FIFO watermark interrupt status
+ *	from the register 0x1D bit 6
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the FIFO watermark interrupt triggers. The
+ *	setting of INT_LATCH controls if the
+ *	interrupt signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_fifo_wm_intr_u8 : The status of fifo water mark interrupt
+ *
+ *	@note FIFO full interrupt can be configured by following functions
+ *	@note bmi160_set_intr_fifo_wm()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat1_fifo_wm_intr(u8
+*v_fifo_wm_intr_u8);
+/**************************************************/
+/**\name	 FUNCTIONS FOR NO MOTION INTERRUPT STATUS*/
+/*************************************************/
+/*!
+ *	@brief This API reads data ready no motion interrupt status
+ *	from the register 0x1D bit 7
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the no motion  interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt signal and hence the
+ *	respective interrupt flag will be permanently
+ *	latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_nomotion_intr_u8 : The status of no motion interrupt
+ *
+ *	@note No motion interrupt can be configured by following function
+ *	@note STATUS
+ *	@note bmi160_get_stat1_nomotion_intr()
+ *	@note INTERRUPT MAPPING
+ *	@note bmi160_set_intr_nomotion()
+ *	@note DURATION
+ *	@note bmi160_set_intr_slow_no_motion_durn()
+ *	@note THRESHOLD
+ *	@note bmi160_set_intr_slow_no_motion_thres()
+ *	@note SLOW/NO MOTION SELECT
+ *	@note bmi160_set_intr_slow_no_motion_select()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat1_nomotion_intr(u8
+*nomo_intr);
+/**************************************************/
+/**\name	 FUNCTIONS FOR ANY MOTION FIRST XYZ AND SIGN INTERRUPT STATUS*/
+/*************************************************/
+/*!
+ *	@brief This API reads the status of any motion first x
+ *	from the register 0x1E bit 0
+ *
+ *
+ *  @param v_anymotion_first_x_u8 : The status of any motion first x interrupt
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by x axis
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_any_motion_first_x(u8
+*v_anymotion_first_x_u8);
+/*!
+ *	@brief This API reads the status of any motion first y interrupt
+ *	from the register 0x1E bit 1
+ *
+ *
+ *
+ *@param v_any_motion_first_y_u8 : The status of any motion first y interrupt
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by y axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_any_motion_first_y(u8
+*v_any_motion_first_y_u8);
+/*!
+ *	@brief This API reads the status of any motion first z interrupt
+ *	from the register 0x1E bit 2
+ *
+ *
+ *
+ *
+ *@param v_any_motion_first_z_u8 : The status of any motion first z interrupt
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by y axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_any_motion_first_z(u8
+*v_any_motion_first_z_u8);
+/*!
+ *	@brief This API reads the any motion sign status from the
+ *	register 0x1E bit 3
+ *
+ *
+ *
+ *
+ *  @param v_anymotion_sign_u8 : The status of any motion sign
+ *  value     |  sign
+ * -----------|-------------
+ *   0        | positive
+ *   1        | negative
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_any_motion_sign(u8
+*v_anymotion_sign_u8);
+/**************************************************/
+/**\name	 FUNCTIONS FOR TAP FIRST XYZ AND SIGN INTERRUPT STATUS*/
+/*************************************************/
+/*!
+ *	@brief This API reads the any motion tap first x status from the
+ *	register 0x1E bit 4
+ *
+ *
+ *
+ *
+ *  @param v_tap_first_x_u8 :The status of any motion tap first x
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by x axis
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_tap_first_x(u8
+*v_tap_first_x_u8);
+/*!
+ *	@brief This API reads the tap first y interrupt status from the
+ *	register 0x1E bit 5
+ *
+ *
+ *
+ *
+ *  @param v_tap_first_y_u8 :The status of tap first y interrupt
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by y axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_tap_first_y(u8
+*v_tap_first_y_u8);
+/*!
+ *	@brief This API reads the tap first z interrupt status  from the
+ *	register 0x1E bit 6
+ *
+ *
+ *
+ *
+ *  @param v_tap_first_z_u8 :The status of tap first z interrupt
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by z axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_tap_first_z(u8
+*v_tap_first_z_u8);
+/*!
+ *	@brief This API reads the tap sign status from the
+ *	register 0x1E bit 7
+ *
+ *
+ *
+ *
+ *  @param v_tap_sign_u8 : The status of tap sign
+ *  value     |  sign
+ * -----------|-------------
+ *   0        | positive
+ *   1        | negative
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_tap_sign(u8
+*tap_sign);
+/**************************************************/
+/**\name	 FUNCTIONS FOR HIGH_G FIRST XYZ AND SIGN INTERRUPT STATUS*/
+/*************************************************/
+/*!
+ *	@brief This API reads the high_g first x status from the
+ *	register 0x1F bit 0
+ *
+ *
+ *
+ *
+ *  @param v_high_g_first_x_u8 :The status of high_g first x
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by x axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_high_g_first_x(u8
+*v_high_g_first_x_u8);
+/*!
+ *	@brief This API reads the high_g first y status from the
+ *	register 0x1F bit 1
+ *
+ *
+ *
+ *
+ *  @param v_high_g_first_y_u8 : The status of high_g first y
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by y axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_high_g_first_y(u8
+*v_high_g_first_y_u8);
+/*!
+ *	@brief This API reads the high_g first z status from the
+ *	register 0x1F bit 3
+ *
+ *
+ *
+ *
+ *  @param v_high_g_first_z_u8 : The status of high_g first z
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by z axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_high_g_first_z(u8
+*v_high_g_first_z_u8);
+/*!
+ *	@brief This API reads the high sign status from the
+ *	register 0x1F bit 3
+ *
+ *
+ *
+ *
+ *  @param v_high_g_sign_u8 :The status of high sign
+ *  value     |  sign
+ * -----------|-------------
+ *   0        | positive
+ *   1        | negative
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_high_g_sign(u8
+*v_high_g_sign_u8);
+/**************************************************/
+/**\name	 FUNCTIONS FOR ORIENT XY AND Z INTERRUPT STATUS*/
+/*************************************************/
+/*!
+ *	@brief This API reads the status of orient_xy plane
+ *	from the register 0x1F bit 4 and 5
+ *
+ *
+ *  @param v_orient_xy_u8 :The status of orient_xy plane
+ *  value     |  status
+ * -----------|-------------
+ *   0x00     | portrait upright
+ *   0x01     | portrait upside down
+ *   0x02     | landscape left
+ *   0x03     | landscape right
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_orient_xy(u8
+*v_orient_xy_u8);
+/*!
+ *	@brief This API reads the status of orient z plane
+ *	from the register 0x1F bit 6
+ *
+ *
+ *  @param v_orient_z_u8 :The status of orient z
+ *  value     |  status
+ * -----------|-------------
+ *   0x00     | upward looking
+ *   0x01     | downward looking
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_orient_z(u8
+*v_orient_z_u8);
+/**************************************************/
+/**\name	 FUNCTIONS FOR FLAT INTERRUPT STATUS*/
+/*************************************************/
+/*!
+ *	@brief This API reads the flat status from the register
+ *	0x1F bit 7
+ *
+ *
+ *  @param v_flat_u8 : The status of flat interrupt
+ *  value     |  status
+ * -----------|-------------
+ *   0x00     | non flat
+ *   0x01     | flat position
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_flat(u8
+*flat);
+/**************************************************/
+/**\name	 FUNCTION FOR TEMPERATUE READ */
+/*************************************************/
+/*!
+ *	@brief This API reads the temperature of the sensor
+ *	from the register 0x21 bit 0 to 7
+ *
+ *
+ *
+ *  @param v_temp_s16 : The value of temperature
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_temp(s16
+*v_temp_s16);
+/**************************************************/
+/**\name	 FUNCTION FOR FIFO LENGTH AND FIFO DATA READ */
+/*************************************************/
+/*!
+ *	@brief This API reads the  of the sensor
+ *	form the register 0x23 and 0x24 bit 0 to 7 and 0 to 2
+ *	@brief this byte counter is updated each time a complete frame
+ *	was read or writtern
+ *
+ *
+ *  @param v_fifo_length_u32 : The value of fifo byte counter
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_fifo_length(
+u32 *v_fifo_length_u32);
+/*!
+ *	@brief This API reads the fifo data of the sensor
+ *	from the register 0x24
+ *	@brief Data format depends on the setting of register FIFO_CONFIG
+ *
+ *
+ *
+ *  @param v_fifodata_u8 : Pointer holding the fifo data
+ *
+ *	@note For reading FIFO data use the following functions
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_fifo_data(
+u8 *v_fifodata_u8, u16 v_fifo_length_u16);
+/**************************************************/
+/**\name	 FUNCTION FOR ACCEL CONFIGURATIONS */
+/*************************************************/
+/*!
+ *	@brief This API is used to get the
+ *	accel output date rate form the register 0x40 bit 0 to 3
+ *
+ *
+ *  @param  v_output_data_rate_u8 :The value of accel output date rate
+ *  value |  output data rate
+ * -------|--------------------------
+ *	 0    |	BMI160_ACCEL_OUTPUT_DATA_RATE_RESERVED
+ *	 1	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_0_78HZ
+ *	 2	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_1_56HZ
+ *	 3    |	BMI160_ACCEL_OUTPUT_DATA_RATE_3_12HZ
+ *	 4    | BMI160_ACCEL_OUTPUT_DATA_RATE_6_25HZ
+ *	 5	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_12_5HZ
+ *	 6	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_25HZ
+ *	 7	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_50HZ
+ *	 8	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_100HZ
+ *	 9	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_200HZ
+ *	 10	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_400HZ
+ *	 11	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_800HZ
+ *	 12	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_1600HZ
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_output_data_rate(
+u8 *v_output_data_rate_u8);
+/*!
+ *	@brief This API is used to set the
+ *	accel output date rate form the register 0x40 bit 0 to 3
+ *
+ *
+ *  @param  v_output_data_rate_u8 :The value of accel output date rate
+ *  value |  output data rate
+ * -------|--------------------------
+ *	 0    |	BMI160_ACCEL_OUTPUT_DATA_RATE_RESERVED
+ *	 1	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_0_78HZ
+ *	 2	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_1_56HZ
+ *	 3    |	BMI160_ACCEL_OUTPUT_DATA_RATE_3_12HZ
+ *	 4    | BMI160_ACCEL_OUTPUT_DATA_RATE_6_25HZ
+ *	 5	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_12_5HZ
+ *	 6	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_25HZ
+ *	 7	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_50HZ
+ *	 8	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_100HZ
+ *	 9	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_200HZ
+ *	 10	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_400HZ
+ *	 11	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_800HZ
+ *	 12	  |	BMI160_ACCEL_OUTPUT_DATA_RATE_1600HZ
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_output_data_rate(u8 odr);
+/*!
+ *	@brief This API is used to get the
+ *	accel bandwidth from the register 0x40 bit 4 to 6
+ *	@brief bandwidth parameter determines filter configuration(acc_us=0)
+ *	and averaging for under sampling mode(acc_us=1)
+ *
+ *
+ *  @param  v_bw_u8 : The value of accel bandwidth
+ *
+ *	@note accel bandwidth depends on under sampling parameter
+ *	@note under sampling parameter cab be set by the function
+ *	"BMI160_SET_ACCEL_UNDER_SAMPLING_PARAMETER"
+ *
+ *	@note Filter configuration
+ *  accel_us  | Filter configuration
+ * -----------|---------------------
+ *    0x00    |  OSR4 mode
+ *    0x01    |  OSR2 mode
+ *    0x02    |  normal mode
+ *    0x03    |  CIC mode
+ *    0x04    |  Reserved
+ *    0x05    |  Reserved
+ *    0x06    |  Reserved
+ *    0x07    |  Reserved
+ *
+ *	@note accel under sampling mode
+ *  accel_us  | Under sampling mode
+ * -----------|---------------------
+ *    0x00    |  no averaging
+ *    0x01    |  average 2 samples
+ *    0x02    |  average 4 samples
+ *    0x03    |  average 8 samples
+ *    0x04    |  average 16 samples
+ *    0x05    |  average 32 samples
+ *    0x06    |  average 64 samples
+ *    0x07    |  average 128 samples
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_bw(u8 *v_bw_u8);
+/*!
+ *	@brief This API is used to set the
+ *	accel bandwidth from the register 0x40 bit 4 to 6
+ *	@brief bandwidth parameter determines filter configuration(acc_us=0)
+ *	and averaging for under sampling mode(acc_us=1)
+ *
+ *
+ *  @param  v_bw_u8 : The value of accel bandwidth
+ *
+ *	@note accel bandwidth depends on under sampling parameter
+ *	@note under sampling parameter cab be set by the function
+ *	"BMI160_SET_ACCEL_UNDER_SAMPLING_PARAMETER"
+ *
+ *	@note Filter configuration
+ *  accel_us  | Filter configuration
+ * -----------|---------------------
+ *    0x00    |  OSR4 mode
+ *    0x01    |  OSR2 mode
+ *    0x02    |  normal mode
+ *    0x03    |  CIC mode
+ *    0x04    |  Reserved
+ *    0x05    |  Reserved
+ *    0x06    |  Reserved
+ *    0x07    |  Reserved
+ *
+ *	@note accel under sampling mode
+ *  accel_us  | Under sampling mode
+ * -----------|---------------------
+ *    0x00    |  no averaging
+ *    0x01    |  average 2 samples
+ *    0x02    |  average 4 samples
+ *    0x03    |  average 8 samples
+ *    0x04    |  average 16 samples
+ *    0x05    |  average 32 samples
+ *    0x06    |  average 64 samples
+ *    0x07    |  average 128 samples
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_bw(u8 v_bw_u8);
+/*!
+ *	@brief This API is used to get the accel
+ *	under sampling parameter form the register 0x40 bit 7
+ *
+ *
+ *
+ *
+ *	@param  v_accel_under_sampling_u8 : The value of accel under sampling
+ *	value    | under_sampling
+ * ----------|---------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_under_sampling_parameter(
+u8 *v_accel_under_sampling_u8);
+/*!
+ *	@brief This API is used to set the accel
+ *	under sampling parameter form the register 0x40 bit 7
+ *
+ *
+ *
+ *
+ *	@param  v_accel_under_sampling_u8 : The value of accel under sampling
+ *	value    | under_sampling
+ * ----------|---------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_under_sampling_parameter(
+u8 v_accel_under_sampling_u8);
+/*!
+ *	@brief This API is used to get the ranges
+ *	(g values) of the accel from the register 0x41 bit 0 to 3
+ *
+ *
+ *
+ *
+ *  @param v_range_u8 : The value of accel g range
+ *	value    | g_range
+ * ----------|-----------
+ *   0x03    | BMI160_ACCEL_RANGE_2G
+ *   0x05    | BMI160_ACCEL_RANGE_4G
+ *   0x08    | BMI160_ACCEL_RANGE_8G
+ *   0x0C    | BMI160_ACCEL_RANGE_16G
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_range(
+u8 *v_range_u8);
+/*!
+ *	@brief This API is used to set the ranges
+ *	(g values) of the accel from the register 0x41 bit 0 to 3
+ *
+ *
+ *
+ *
+ *  @param v_range_u8 : The value of accel g range
+ *	value    | g_range
+ * ----------|-----------
+ *   0x03    | BMI160_ACCEL_RANGE_2G
+ *   0x05    | BMI160_ACCEL_RANGE_4G
+ *   0x08    | BMI160_ACCEL_RANGE_8G
+ *   0x0C    | BMI160_ACCEL_RANGE_16G
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_range(
+u8 v_range_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR GYRO CONFIGURATIONS */
+/*************************************************/
+/*!
+ *	@brief This API is used to get the
+ *	gyroscope output data rate from the register 0x42 bit 0 to 3
+ *
+ *
+ *
+ *
+ *  @param  v_output_data_rate_u8 :The value of gyro output data rate
+ *  value     |      gyro output data rate
+ * -----------|-----------------------------
+ *   0x00     | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x01     | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x02     | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x03     | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x04     | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x05     | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x06     | BMI160_GYRO_OUTPUT_DATA_RATE_25HZ
+ *   0x07     | BMI160_GYRO_OUTPUT_DATA_RATE_50HZ
+ *   0x08     | BMI160_GYRO_OUTPUT_DATA_RATE_100HZ
+ *   0x09     | BMI160_GYRO_OUTPUT_DATA_RATE_200HZ
+ *   0x0A     | BMI160_GYRO_OUTPUT_DATA_RATE_400HZ
+ *   0x0B     | BMI160_GYRO_OUTPUT_DATA_RATE_800HZ
+ *   0x0C     | BMI160_GYRO_OUTPUT_DATA_RATE_1600HZ
+ *   0x0D     | BMI160_GYRO_OUTPUT_DATA_RATE_3200HZ
+ *   0x0E     | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x0F     | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_output_data_rate(
+u8 *gyro_output_typer);
+/*!
+ *	@brief This API is used to set the
+ *	gyroscope output data rate from the register 0x42 bit 0 to 3
+ *
+ *
+ *
+ *
+ *  @param  v_output_data_rate_u8 :The value of gyro output data rate
+ *  value     |      gyro output data rate
+ * -----------|-----------------------------
+ *   0x00     | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x01     | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x02     | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x03     | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x04     | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x05     | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x06     | BMI160_GYRO_OUTPUT_DATA_RATE_25HZ
+ *   0x07     | BMI160_GYRO_OUTPUT_DATA_RATE_50HZ
+ *   0x08     | BMI160_GYRO_OUTPUT_DATA_RATE_100HZ
+ *   0x09     | BMI160_GYRO_OUTPUT_DATA_RATE_200HZ
+ *   0x0A     | BMI160_GYRO_OUTPUT_DATA_RATE_400HZ
+ *   0x0B     | BMI160_GYRO_OUTPUT_DATA_RATE_800HZ
+ *   0x0C     | BMI160_GYRO_OUTPUT_DATA_RATE_1600HZ
+ *   0x0D     | BMI160_GYRO_OUTPUT_DATA_RATE_3200HZ
+ *   0x0E     | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x0F     | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_output_data_rate(
+u8 gyro_output_typer);
+/*!
+ *	@brief This API is used to get the
+ *	data of gyro from the register 0x42 bit 4 to 5
+ *
+ *
+ *
+ *
+ *  @param  v_bw_u8 : The value of gyro bandwidth
+ *  value     | gyro bandwidth
+ *  ----------|----------------
+ *   0x00     | BMI160_GYRO_OSR4_MODE
+ *   0x01     | BMI160_GYRO_OSR2_MODE
+ *   0x02     | BMI160_GYRO_NORMAL_MODE
+ *   0x03     | BMI160_GYRO_CIC_MODE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_bw(u8 *v_bw_u8);
+/*!
+ *	@brief This API is used to set the
+ *	data of gyro from the register 0x42 bit 4 to 5
+ *
+ *
+ *
+ *
+ *  @param  v_bw_u8 : The value of gyro bandwidth
+ *  value     | gyro bandwidth
+ *  ----------|----------------
+ *   0x00     | BMI160_GYRO_OSR4_MODE
+ *   0x01     | BMI160_GYRO_OSR2_MODE
+ *   0x02     | BMI160_GYRO_NORMAL_MODE
+ *   0x03     | BMI160_GYRO_CIC_MODE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_bw(u8 v_bw_u8);
+/*!
+ *	@brief This API reads the range
+ *	of gyro from the register 0x43 bit 0 to 2
+ *
+ *  @param  v_range_u8 : The value of gyro range
+ *   value    |    range
+ *  ----------|-------------------------------
+ *    0x00    | BMI160_GYRO_RANGE_2000_DEG_SEC
+ *    0x01    | BMI160_GYRO_RANGE_1000_DEG_SEC
+ *    0x02    | BMI160_GYRO_RANGE_500_DEG_SEC
+ *    0x03    | BMI160_GYRO_RANGE_250_DEG_SEC
+ *    0x04    | BMI160_GYRO_RANGE_125_DEG_SEC
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_range(
+u8 *v_range_u8);
+/*!
+ *	@brief This API set the range
+ *	of gyro from the register 0x43 bit 0 to 2
+ *
+ *  @param  v_range_u8 : The value of gyro range
+ *   value    |    range
+ *  ----------|-------------------------------
+ *    0x00    | BMI160_GYRO_RANGE_2000_DEG_SEC
+ *    0x01    | BMI160_GYRO_RANGE_1000_DEG_SEC
+ *    0x02    | BMI160_GYRO_RANGE_500_DEG_SEC
+ *    0x03    | BMI160_GYRO_RANGE_250_DEG_SEC
+ *    0x04    | BMI160_GYRO_RANGE_125_DEG_SEC
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_range(
+u8 v_range_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR MAG CONFIGURATIONS */
+/*************************************************/
+/*!
+ *	@brief This API is used to get the
+ *	output data rate of magnetometer from the register 0x44 bit 0 to 3
+ *
+ *
+ *
+ *
+ *  @param  v_output_data_rat_u8e : The value of mag output data rate
+ *  value   |    mag output data rate
+ * ---------|---------------------------
+ *  0x00    |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED
+ *  0x01    |BMI160_MAG_OUTPUT_DATA_RATE_0_78HZ
+ *  0x02    |BMI160_MAG_OUTPUT_DATA_RATE_1_56HZ
+ *  0x03    |BMI160_MAG_OUTPUT_DATA_RATE_3_12HZ
+ *  0x04    |BMI160_MAG_OUTPUT_DATA_RATE_6_25HZ
+ *  0x05    |BMI160_MAG_OUTPUT_DATA_RATE_12_5HZ
+ *  0x06    |BMI160_MAG_OUTPUT_DATA_RATE_25HZ
+ *  0x07    |BMI160_MAG_OUTPUT_DATA_RATE_50HZ
+ *  0x08    |BMI160_MAG_OUTPUT_DATA_RATE_100HZ
+ *  0x09    |BMI160_MAG_OUTPUT_DATA_RATE_200HZ
+ *  0x0A    |BMI160_MAG_OUTPUT_DATA_RATE_400HZ
+ *  0x0B    |BMI160_MAG_OUTPUT_DATA_RATE_800HZ
+ *  0x0C    |BMI160_MAG_OUTPUT_DATA_RATE_1600HZ
+ *  0x0D    |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED0
+ *  0x0E    |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED1
+ *  0x0F    |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED2
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_output_data_rate(u8 *odr);
+/*!
+ *	@brief This API is used to set the
+ *	output data rate of magnetometer from the register 0x44 bit 0 to 3
+ *
+ *
+ *
+ *
+ *  @param  v_output_data_rat_u8e : The value of mag output data rate
+ *  value   |    mag output data rate
+ * ---------|---------------------------
+ *  0x00    |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED
+ *  0x01    |BMI160_MAG_OUTPUT_DATA_RATE_0_78HZ
+ *  0x02    |BMI160_MAG_OUTPUT_DATA_RATE_1_56HZ
+ *  0x03    |BMI160_MAG_OUTPUT_DATA_RATE_3_12HZ
+ *  0x04    |BMI160_MAG_OUTPUT_DATA_RATE_6_25HZ
+ *  0x05    |BMI160_MAG_OUTPUT_DATA_RATE_12_5HZ
+ *  0x06    |BMI160_MAG_OUTPUT_DATA_RATE_25HZ
+ *  0x07    |BMI160_MAG_OUTPUT_DATA_RATE_50HZ
+ *  0x08    |BMI160_MAG_OUTPUT_DATA_RATE_100HZ
+ *  0x09    |BMI160_MAG_OUTPUT_DATA_RATE_200HZ
+ *  0x0A    |BMI160_MAG_OUTPUT_DATA_RATE_400HZ
+ *  0x0B    |BMI160_MAG_OUTPUT_DATA_RATE_800HZ
+ *  0x0C    |BMI160_MAG_OUTPUT_DATA_RATE_1600HZ
+ *  0x0D    |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED0
+ *  0x0E    |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED1
+ *  0x0F    |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED2
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_output_data_rate(u8 odr);
+/**************************************************/
+/**\name	 FUNCTION FOR FIFO CONFIGURATIONS */
+/*************************************************/
+ /*!
+ *	@brief This API is used to read Down sampling
+ *	for gyro (2**downs_gyro) in the register 0x45 bit 0 to 2
+ *
+ *
+ *
+ *
+ *  @param v_fifo_down_gyro_u8 :The value of gyro fifo down
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_down_gyro(
+u8 *v_fifo_down_gyro_u8);
+ /*!
+ *	@brief This API is used to set Down sampling
+ *	for gyro (2**downs_gyro) in the register 0x45 bit 0 to 2
+ *
+ *
+ *
+ *
+ *  @param v_fifo_down_gyro_u8 :The value of gyro fifo down
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_down_gyro(
+u8 v_fifo_down_gyro_u8);
+/*!
+ *	@brief This API is used to read gyro fifo filter data
+ *	from the register 0x45 bit 3
+ *
+ *
+ *
+ *  @param v_gyro_fifo_filter_data_u8 :The value of gyro filter data
+ *  value      |  gyro_fifo_filter_data
+ * ------------|-------------------------
+ *    0x00     |  Unfiltered data
+ *    0x01     |  Filtered data
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_fifo_filter_data(
+u8 *v_gyro_fifo_filter_data_u8);
+/*!
+ *	@brief This API is used to set gyro fifo filter data
+ *	from the register 0x45 bit 3
+ *
+ *
+ *
+ *  @param v_gyro_fifo_filter_data_u8 :The value of gyro filter data
+ *  value      |  gyro_fifo_filter_data
+ * ------------|-------------------------
+ *    0x00     |  Unfiltered data
+ *    0x01     |  Filtered data
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_fifo_filter_data(
+u8 v_gyro_fifo_filter_data_u8);
+/*!
+ *	@brief This API is used to read Down sampling
+ *	for accel (2*downs_accel) from the register 0x45 bit 4 to 6
+ *
+ *
+ *
+ *
+ *  @param v_fifo_down_u8 :The value of accel fifo down
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_down_accel(
+u8 *v_fifo_down_u8);
+ /*!
+ *	@brief This API is used to set Down sampling
+ *	for accel (2*downs_accel) from the register 0x45 bit 4 to 6
+ *
+ *
+ *
+ *
+ *  @param v_fifo_down_u8 :The value of accel fifo down
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_down_accel(
+u8 v_fifo_down_u8);
+/*!
+ *	@brief This API is used to read accel fifo filter data
+ *	from the register 0x45 bit 7
+ *
+ *
+ *
+ *  @param v_accel_fifo_filter_u8 :The value of accel filter data
+ *  value      |  accel_fifo_filter_data
+ * ------------|-------------------------
+ *    0x00     |  Unfiltered data
+ *    0x01     |  Filtered data
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_fifo_filter_data(
+u8 *v_accel_fifo_filter_u8);
+/*!
+ *	@brief This API is used to set accel fifo filter data
+ *	from the register 0x45 bit 7
+ *
+ *
+ *
+ *  @param v_accel_fifo_filter_u8 :The value of accel filter data
+ *  value      |  accel_fifo_filter_data
+ * ------------|-------------------------
+ *    0x00     |  Unfiltered data
+ *    0x01     |  Filtered data
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_fifo_filter_data(
+u8 v_accel_fifo_filter_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR FIFO WATER MARK ENABLE */
+/*************************************************/
+/*!
+ *	@brief This API is used to Trigger an interrupt
+ *	when FIFO contains water mark level from the register 0x46 bit 0 to 7
+ *
+ *
+ *
+ *  @param  v_fifo_wm_u8 : The value of fifo water mark level
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_wm(
+u8 *v_fifo_wm_u8);
+/*!
+ *	@brief This API is used to Trigger an interrupt
+ *	when FIFO contains water mark level from the register 0x46 bit 0 to 7
+ *
+ *
+ *
+ *  @param  v_fifo_wm_u8 : The value of fifo water mark level
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_wm(
+u8 v_fifo_wm_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR FIFO CONFIGURATIONS */
+/*************************************************/
+/*!
+ *	@brief This API reads fifo sensor time
+ *	frame after the last valid data frame form the register  0x47 bit 1
+ *
+ *
+ *
+ *
+ *  @param v_fifo_time_enable_u8 : The value of sensor time
+ *  value      |  fifo sensor time
+ * ------------|-------------------------
+ *    0x00     |  do not return sensortime frame
+ *    0x01     |  return sensortime frame
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_time_enable(
+u8 *v_fifo_time_enable_u8);
+/*!
+ *	@brief This API set fifo sensor time
+ *	frame after the last valid data frame form the register  0x47 bit 1
+ *
+ *
+ *
+ *
+ *  @param v_fifo_time_enable_u8 : The value of sensor time
+ *  value      |  fifo sensor time
+ * ------------|-------------------------
+ *    0x00     |  do not return sensortime frame
+ *    0x01     |  return sensortime frame
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_time_enable(
+u8 v_fifo_time_enable_u8);
+/*!
+ *	@brief This API reads FIFO tag interrupt2 enable status
+ *	from the resister 0x47 bit 2
+ *
+ *  @param v_fifo_tag_intr2_u8 : The value of fifo tag interrupt
+ *	value    | fifo tag interrupt
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_tag_intr2_enable(
+u8 *v_fifo_tag_intr2_u8);
+/*!
+ *	@brief This API set FIFO tag interrupt2 enable status
+ *	from the resister 0x47 bit 2
+ *
+ *  @param v_fifo_tag_intr2_u8 : The value of fifo tag interrupt
+ *	value    | fifo tag interrupt
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_tag_intr2_enable(
+u8 v_fifo_tag_intr2_u8);
+/*!
+ *	@brief This API get FIFO tag interrupt1 enable status
+ *	from the resister 0x47 bit 3
+ *
+ *  @param v_fifo_tag_intr1_u8 :The value of fifo tag interrupt1
+ *	value    | fifo tag interrupt
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_tag_intr1_enable(
+u8 *v_fifo_tag_intr1_u8);
+/*!
+ *	@brief This API set FIFO tag interrupt1 enable status
+ *	from the resister 0x47 bit 3
+ *
+ *  @param v_fifo_tag_intr1_u8 :The value of fifo tag interrupt1
+ *	value    | fifo tag interrupt
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_tag_intr1_enable(
+u8 v_fifo_tag_intr1_u8);
+/*!
+ *	@brief This API reads FIFO frame
+ *	header enable from the register 0x47 bit 4
+ *
+ *  @param v_fifo_header_u8 :The value of fifo header
+ *	value    | fifo header
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_header_enable(
+u8 *v_fifo_header_u8);
+/*!
+ *	@brief This API set FIFO frame
+ *	header enable from the register 0x47 bit 4
+ *
+ *  @param v_fifo_header_u8 :The value of fifo header
+ *	value    | fifo header
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_header_enable(
+u8 v_fifo_header_u8);
+/*!
+ *	@brief This API is used to read stored
+ *	magnetometer data in FIFO (all 3 axes) from the register 0x47 bit 5
+ *
+ *  @param v_fifo_mag_u8 : The value of fifo mag enble
+ *	value    | fifo mag
+ * ----------|-------------------
+ *  0x00     |  no magnetometer data is stored
+ *  0x01     |  magnetometer data is stored
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_mag_enable(
+u8 *v_fifo_mag_u8);
+/*!
+ *	@brief This API is used to set stored
+ *	magnetometer data in FIFO (all 3 axes) from the register 0x47 bit 5
+ *
+ *  @param v_fifo_mag_u8 : The value of fifo mag enble
+ *	value    | fifo mag
+ * ----------|-------------------
+ *  0x00     |  no magnetometer data is stored
+ *  0x01     |  magnetometer data is stored
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_mag_enable(
+u8 v_fifo_mag_u8);
+/*!
+ *	@brief This API is used to read stored
+ *	accel data in FIFO (all 3 axes) from the register 0x47 bit 6
+ *
+ *  @param v_fifo_accel_u8 : The value of fifo accel enble
+ *	value    | fifo accel
+ * ----------|-------------------
+ *  0x00     |  no accel data is stored
+ *  0x01     |  accel data is stored
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_accel_enable(
+u8 *v_fifo_accel_u8);
+/*!
+ *	@brief This API is used to set stored
+ *	accel data in FIFO (all 3 axes) from the register 0x47 bit 6
+ *
+ *  @param v_fifo_accel_u8 : The value of fifo accel enble
+ *	value    | fifo accel
+ * ----------|-------------------
+ *  0x00     |  no accel data is stored
+ *  0x01     |  accel data is stored
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_accel_enable(
+u8 v_fifo_accel_u8);
+/*!
+ *	@brief This API is used to read stored
+ *	 gyro data in FIFO (all 3 axes) from the resister 0x47 bit 7
+ *
+ *
+ *  @param v_fifo_gyro_u8 : The value of fifo gyro enble
+ *	value    | fifo gyro
+ * ----------|-------------------
+ *  0x00     |  no gyro data is stored
+ *  0x01     |  gyro data is stored
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_gyro_enable(
+u8 *v_fifo_gyro_u8);
+/*!
+ *	@brief This API is used to set stored
+ *	gyro data in FIFO (all 3 axes) from the resister 0x47 bit 7
+ *
+ *
+ *  @param v_fifo_gyro_u8 : The value of fifo gyro enble
+ *	value    | fifo gyro
+ * ----------|-------------------
+ *  0x00     |  no gyro data is stored
+ *  0x01     |  gyro data is stored
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_gyro_enable(
+u8 v_fifo_gyro_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR MAG I2C ADDRESS SELECTION          */
+/***************************************************************/
+/*!
+ *	@brief This API is used to read
+ *	I2C device address of auxiliary mag from the register 0x4B bit 1 to 7
+ *
+ *
+ *
+ *
+ *  @param v_i2c_device_addr_u8 : The value of mag I2C device address
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_i2c_device_addr(
+u8 *v_i2c_device_addr_u8);
+/*!
+ *	@brief This API is used to set
+ *	I2C device address of auxiliary mag from the register 0x4B bit 1 to 7
+ *
+ *
+ *
+ *
+ *  @param v_i2c_device_addr_u8 : The value of mag I2C device address
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_i2c_device_addr(
+u8 v_i2c_device_addr_u8);
+/*!
+ *	@brief This API is used to read
+ *	Burst data length (1,2,6,8 byte) from the register 0x4C bit 0 to 1
+ *
+ *
+ *
+ *
+ *  @param v_mag_burst_u8 : The data of mag burst read lenth
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_burst(
+u8 *v_mag_burst_u8);
+/*!
+ *	@brief This API is used to set
+ *	Burst data length (1,2,6,8 byte) from the register 0x4C bit 0 to 1
+ *
+ *
+ *
+ *
+ *  @param v_mag_burst_u8 : The data of mag burst read lenth
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_burst(
+u8 v_mag_burst_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR MAG OFFSET         */
+/***************************************************************/
+/*!
+ *	@brief This API is used to read
+ *	trigger-readout offset in units of 2.5 ms. If set to zero,
+ *	the offset is maximum, i.e. after readout a trigger
+ *	is issued immediately. from the register 0x4C bit 2 to 5
+ *
+ *
+ *
+ *
+ *  @param v_mag_offset_u8 : The value of mag offset
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_offset(
+u8 *v_mag_offset_u8);
+/*!
+ *	@brief This API is used to set
+ *	trigger-readout offset in units of 2.5 ms. If set to zero,
+ *	the offset is maximum, i.e. after readout a trigger
+ *	is issued immediately. from the register 0x4C bit 2 to 5
+ *
+ *
+ *
+ *
+ *  @param v_mag_offset_u8 : The value of mag offset
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_offset(
+u8 v_mag_offset_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR MAG MANUAL/AUTO MODE SELECTION          */
+/***************************************************************/
+/*!
+ *	@brief This API is used to read
+ *	Enable register access on MAG_IF[2] or MAG_IF[3] writes.
+ *	This implies that the DATA registers are not updated with
+ *	magnetometer values. Accessing magnetometer requires
+ *	the magnetometer in normal mode in PMU_STATUS.
+ *	from the register 0x4C bit 7
+ *
+ *
+ *
+ *  @param v_mag_manual_u8 : The value of mag manual enable
+ *	value    | mag manual
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_manual_enable(
+u8 *v_mag_manual_u8);
+/*!
+ *	@brief This API is used to set
+ *	Enable register access on MAG_IF[2] or MAG_IF[3] writes.
+ *	This implies that the DATA registers are not updated with
+ *	magnetometer values. Accessing magnetometer requires
+ *	the magnetometer in normal mode in PMU_STATUS.
+ *	from the register 0x4C bit 7
+ *
+ *
+ *
+ *  @param v_mag_manual_u8 : The value of mag manual enable
+ *	value    | mag manual
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_manual_enable(
+u8 v_mag_manual_u8);
+/***************************************************************/
+/**\name	FUNCTIONS FOR MAG READ, WRITE AND WRITE DATA ADDRESS  */
+/***************************************************************/
+/*!
+ *	@brief This API is used to read data
+ *	magnetometer address to read from the register 0x4D bit 0 to 7
+ *	@brief It used to provide mag read address of auxiliary mag
+ *
+ *
+ *
+ *
+ *  @param  v_mag_read_addr_u8 : The value of address need to be read
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_read_addr(
+u8 *v_mag_read_addr_u8);
+/*!
+ *	@brief This API is used to set
+ *	magnetometer write address from the register 0x4D bit 0 to 7
+ *	@brief mag write address writes the address of auxiliary mag to write
+ *
+ *
+ *
+ *  @param v_mag_read_addr_u8:
+ *	The data of auxiliary mag address to write data
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_read_addr(
+u8 v_mag_read_addr_u8);
+/*!
+ *	@brief This API is used to read
+ *	magnetometer write address from the register 0x4E bit 0 to 7
+ *	@brief mag write address writes the address of auxiliary mag to write
+ *
+ *
+ *
+ *  @param  v_mag_write_addr_u8:
+ *	The data of auxiliary mag address to write data
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_write_addr(
+u8 *v_mag_write_addr_u8);
+/*!
+ *	@brief This API is used to set
+ *	magnetometer write address from the register 0x4E bit 0 to 7
+ *	@brief mag write address writes the address of auxiliary mag to write
+ *
+ *
+ *
+ *  @param  v_mag_write_addr_u8:
+ *	The data of auxiliary mag address to write data
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_write_addr(
+u8 v_mag_write_addr_u8);
+/*!
+ *	@brief This API is used to read magnetometer write data
+ *	form the resister 0x4F bit 0 to 7
+ *	@brief This writes the data will be wrote to mag
+ *
+ *
+ *
+ *  @param  v_mag_write_data_u8: The value of mag data
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_write_data(
+u8 *v_mag_write_data_u8);
+/*!
+ *	@brief This API is used to set magnetometer write data
+ *	form the resister 0x4F bit 0 to 7
+ *	@brief This writes the data will be wrote to mag
+ *
+ *
+ *
+ *  @param  v_mag_write_data_u8: The value of mag data
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_write_data(
+u8 v_mag_write_data_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR INTERRUPT ENABLE OF
+ANY-MOTION XYZ, DOUBLE AND SINGLE TAP, ORIENT AND FLAT         */
+/***************************************************************/
+/*!
+ *	@brief  This API is used to read
+ *	interrupt enable from the register 0x50 bit 0 to 7
+ *
+ *
+ *
+ *
+ *	@param v_enable_u8 : Value to decided to select interrupt
+ *   v_enable_u8   |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_ANY_MOTION_X_ENABLE
+ *       1         | BMI160_ANY_MOTION_Y_ENABLE
+ *       2         | BMI160_ANY_MOTION_Z_ENABLE
+ *       3         | BMI160_DOUBLE_TAP_ENABLE
+ *       4         | BMI160_SINGLE_TAP_ENABLE
+ *       5         | BMI160_ORIENT_ENABLE
+ *       6         | BMI160_FLAT_ENABLE
+ *
+ *	@param v_intr_enable_zero_u8 : The interrupt enable value
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_enable_0(
+u8 enable, u8 *v_intr_enable_zero_u8);
+/*!
+ *	@brief  This API is used to set
+ *	interrupt enable from the register 0x50 bit 0 to 7
+ *
+ *
+ *
+ *
+ *	@param v_enable_u8 : Value to decided to select interrupt
+ *   v_enable_u8   |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_ANY_MOTION_X_ENABLE
+ *       1         | BMI160_ANY_MOTION_Y_ENABLE
+ *       2         | BMI160_ANY_MOTION_Z_ENABLE
+ *       3         | BMI160_DOUBLE_TAP_ENABLE
+ *       4         | BMI160_SINGLE_TAP_ENABLE
+ *       5         | BMI160_ORIENT_ENABLE
+ *       6         | BMI160_FLAT_ENABLE
+ *
+ *	@param v_intr_enable_zero_u8 : The interrupt enable value
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_enable_0(
+u8 enable, u8 v_intr_enable_zero_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR INTERRUPT ENABLE OF
+HIGH_G XYZ, LOW_G, DATA READY, FIFO FULL AND FIFO WATER MARK  */
+/***************************************************************/
+/*!
+ *	@brief  This API is used to read
+ *	interrupt enable byte1 from the register 0x51 bit 0 to 6
+ *	@brief It read the high_g_x,high_g_y,high_g_z,low_g_enable
+ *	data ready, fifo full and fifo water mark.
+ *
+ *
+ *
+ *  @param  v_enable_u8 :  The value of interrupt enable
+ *	@param v_enable_u8 : Value to decided to select interrupt
+ *   v_enable_u8   |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_HIGH_G_X_ENABLE
+ *       1         | BMI160_HIGH_G_Y_ENABLE
+ *       2         | BMI160_HIGH_G_Z_ENABLE
+ *       3         | BMI160_LOW_G_ENABLE
+ *       4         | BMI160_DATA_RDY_ENABLE
+ *       5         | BMI160_FIFO_FULL_ENABLE
+ *       6         | BMI160_FIFO_WM_ENABLE
+ *
+ *	@param v_intr_enable_1_u8 : The interrupt enable value
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_enable_1(
+u8 enable, u8 *v_intr_enable_1_u8);
+/*!
+ *	@brief  This API is used to set
+ *	interrupt enable byte1 from the register 0x51 bit 0 to 6
+ *	@brief It read the high_g_x,high_g_y,high_g_z,low_g_enable
+ *	data ready, fifo full and fifo water mark.
+ *
+ *
+ *
+ *  @param  v_enable_u8 :  The value of interrupt enable
+ *	@param v_enable_u8 : Value to decided to select interrupt
+ *   v_enable_u8   |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_HIGH_G_X_ENABLE
+ *       1         | BMI160_HIGH_G_Y_ENABLE
+ *       2         | BMI160_HIGH_G_Z_ENABLE
+ *       3         | BMI160_LOW_G_ENABLE
+ *       4         | BMI160_DATA_RDY_ENABLE
+ *       5         | BMI160_FIFO_FULL_ENABLE
+ *       6         | BMI160_FIFO_WM_ENABLE
+ *
+ *	@param v_intr_enable_1_u8 : The interrupt enable value
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_enable_1(
+u8 enable, u8 v_intr_enable_1_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR INTERRUPT ENABLE OF
+NO MOTION XYZ  */
+/***************************************************************/
+/*!
+ *	@brief  This API is used to read
+ *	interrupt enable byte2 from the register bit 0x52 bit 0 to 3
+ *	@brief It reads no motion x,y and z
+ *
+ *
+ *
+ *	@param v_enable_u8: The value of interrupt enable
+ *   v_enable_u8   |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_NOMOTION_X_ENABLE
+ *       1         | BMI160_NOMOTION_Y_ENABLE
+ *       2         | BMI160_NOMOTION_Z_ENABLE
+ *
+ *	@param v_intr_enable_2_u8 : The interrupt enable value
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_enable_2(
+u8 enable, u8 *v_intr_enable_2_u8);
+/*!
+ *	@brief  This API is used to set
+ *	interrupt enable byte2 from the register bit 0x52 bit 0 to 3
+ *	@brief It reads no motion x,y and z
+ *
+ *
+ *
+ *	@param v_enable_u8: The value of interrupt enable
+ *   v_enable_u8   |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_NOMOTION_X_ENABLE
+ *       1         | BMI160_NOMOTION_Y_ENABLE
+ *       2         | BMI160_NOMOTION_Z_ENABLE
+ *
+ *	@param v_intr_enable_2_u8 : The interrupt enable value
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_enable_2(
+u8 enable, u8 v_intr_enable_2_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR INTERRUPT ENABLE OF
+  STEP DETECTOR */
+/***************************************************************/
+ /*!
+ *	@brief This API is used to read
+ *	interrupt enable step detector interrupt from
+ *	the register bit 0x52 bit 3
+ *
+ *
+ *
+ *
+ *	@param v_step_intr_u8 : The value of step detector interrupt enable
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_step_detector_enable(
+u8 *v_step_intr_u8);
+ /*!
+ *	@brief This API is used to set
+ *	interrupt enable step detector interrupt from
+ *	the register bit 0x52 bit 3
+ *
+ *
+ *
+ *
+ *	@param v_step_intr_u8 : The value of step detector interrupt enable
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_step_detector_enable(
+u8 v_step_intr_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR INTERRUPT CONTROL */
+/***************************************************************/
+/*!
+ *	@brief  Configure trigger condition of interrupt1
+ *	and interrupt2 pin from the register 0x53
+ *	@brief interrupt1 - bit 0
+ *	@brief interrupt2 - bit 4
+ *
+ *  @param v_channel_u8: The value of edge trigger selection
+ *   v_channel_u8  |   Edge trigger
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_EDGE_CTRL
+ *       1         | BMI160_INTR2_EDGE_CTRL
+ *
+ *	@param v_intr_edge_ctrl_u8 : The value of edge trigger enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_EDGE
+ *  0x00     |  BMI160_LEVEL
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_edge_ctrl(
+u8 v_channel_u8, u8 *v_intr_edge_ctrl_u8);
+/*!
+ *	@brief  Configure trigger condition of interrupt1
+ *	and interrupt2 pin from the register 0x53
+ *	@brief interrupt1 - bit 0
+ *	@brief interrupt2 - bit 4
+ *
+ *  @param v_channel_u8: The value of edge trigger selection
+ *   v_channel_u8  |   Edge trigger
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_EDGE_CTRL
+ *       1         | BMI160_INTR2_EDGE_CTRL
+ *
+ *	@param v_intr_edge_ctrl_u8 : The value of edge trigger enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_EDGE
+ *  0x00     |  BMI160_LEVEL
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_edge_ctrl(
+u8 v_channel_u8, u8 v_intr_edge_ctrl_u8);
+/*!
+ *	@brief  API used for get the Configure level condition of interrupt1
+ *	and interrupt2 pin form the register 0x53
+ *	@brief interrupt1 - bit 1
+ *	@brief interrupt2 - bit 5
+ *
+ *  @param v_channel_u8: The value of level condition selection
+ *   v_channel_u8  |   level selection
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_LEVEL
+ *       1         | BMI160_INTR2_LEVEL
+ *
+ *	@param v_intr_level_u8 : The value of level of interrupt enable
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x01     |  BMI160_LEVEL_HIGH
+ *  0x00     |  BMI160_LEVEL_LOW
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_level(
+u8 v_channel_u8, u8 *v_intr_level_u8);
+/*!
+ *	@brief  API used for set the Configure level condition of interrupt1
+ *	and interrupt2 pin form the register 0x53
+ *	@brief interrupt1 - bit 1
+ *	@brief interrupt2 - bit 5
+ *
+ *  @param v_channel_u8: The value of level condition selection
+ *   v_channel_u8  |   level selection
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_LEVEL
+ *       1         | BMI160_INTR2_LEVEL
+ *
+ *	@param v_intr_level_u8 : The value of level of interrupt enable
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x01     |  BMI160_LEVEL_HIGH
+ *  0x00     |  BMI160_LEVEL_LOW
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_level(
+u8 v_channel_u8, u8 v_intr_level_u8);
+/*!
+ *	@brief  API used to get configured output enable of interrupt1
+ *	and interrupt2 from the register 0x53
+ *	@brief interrupt1 - bit 2
+ *	@brief interrupt2 - bit 6
+ *
+ *
+ *  @param v_channel_u8: The value of output type enable selection
+ *   v_channel_u8  |   level selection
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_OUTPUT_TYPE
+ *       1         | BMI160_INTR2_OUTPUT_TYPE
+ *
+ *	@param v_intr_output_type_u8 :
+ *	The value of output type of interrupt enable
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x01     |  BMI160_OPEN_DRAIN
+ *  0x00     |  BMI160_PUSH_PULL
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_output_type(
+u8 v_channel_u8, u8 *v_intr_output_type_u8);
+/*!
+ *	@brief  API used to set output enable of interrupt1
+ *	and interrupt2 from the register 0x53
+ *	@brief interrupt1 - bit 2
+ *	@brief interrupt2 - bit 6
+ *
+ *
+ *  @param v_channel_u8: The value of output type enable selection
+ *   v_channel_u8  |   level selection
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_OUTPUT_TYPE
+ *       1         | BMI160_INTR2_OUTPUT_TYPE
+ *
+ *	@param v_intr_output_type_u8 :
+ *	The value of output type of interrupt enable
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x01     |  BMI160_OPEN_DRAIN
+ *  0x00     |  BMI160_PUSH_PULL
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_output_type(
+u8 v_channel_u8, u8 v_intr_output_type_u8);
+ /*!
+ *	@brief API used to get the Output enable for interrupt1
+ *	and interrupt1 pin from the register 0x53
+ *	@brief interrupt1 - bit 3
+ *	@brief interrupt2 - bit 7
+ *
+ *  @param v_channel_u8: The value of output enable selection
+ *   v_channel_u8  |   level selection
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_OUTPUT_TYPE
+ *       1         | BMI160_INTR2_OUTPUT_TYPE
+ *
+ *	@param v_output_enable_u8 :
+ *	The value of output enable of interrupt enable
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x01     |  BMI160_INPUT
+ *  0x00     |  BMI160_OUTPUT
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_output_enable(
+u8 v_channel_u8, u8 *v_output_enable_u8);
+ /*!
+ *	@brief API used to set the Output enable for interrupt1
+ *	and interrupt1 pin from the register 0x53
+ *	@brief interrupt1 - bit 3
+ *	@brief interrupt2 - bit 7
+ *
+ *  @param v_channel_u8: The value of output enable selection
+ *   v_channel_u8  |   level selection
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_OUTPUT_TYPE
+ *       1         | BMI160_INTR2_OUTPUT_TYPE
+ *
+ *	@param v_output_enable_u8 :
+ *	The value of output enable of interrupt enable
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x01     |  BMI160_INPUT
+ *  0x00     |  BMI160_OUTPUT
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_output_enable(
+u8 v_channel_u8, u8 v_output_enable_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR INTERRUPT LATCH INTERRUPT  */
+/***************************************************************/
+/*!
+*	@brief This API is used to get the latch duration
+*	from the register 0x54 bit 0 to 3
+*	@brief This latch selection is not applicable for data ready,
+*	orientation and flat interrupts.
+*
+*
+*
+*  @param v_latch_intr_u8 : The value of latch duration
+*	Latch Duration                      |     value
+* --------------------------------------|------------------
+*    BMI160_LATCH_DUR_NONE              |      0x00
+*    BMI160_LATCH_DUR_312_5_MICRO_SEC   |      0x01
+*    BMI160_LATCH_DUR_625_MICRO_SEC     |      0x02
+*    BMI160_LATCH_DUR_1_25_MILLI_SEC    |      0x03
+*    BMI160_LATCH_DUR_2_5_MILLI_SEC     |      0x04
+*    BMI160_LATCH_DUR_5_MILLI_SEC       |      0x05
+*    BMI160_LATCH_DUR_10_MILLI_SEC      |      0x06
+*    BMI160_LATCH_DUR_20_MILLI_SEC      |      0x07
+*    BMI160_LATCH_DUR_40_MILLI_SEC      |      0x08
+*    BMI160_LATCH_DUR_80_MILLI_SEC      |      0x09
+*    BMI160_LATCH_DUR_160_MILLI_SEC     |      0x0A
+*    BMI160_LATCH_DUR_320_MILLI_SEC     |      0x0B
+*    BMI160_LATCH_DUR_640_MILLI_SEC     |      0x0C
+*    BMI160_LATCH_DUR_1_28_SEC          |      0x0D
+*    BMI160_LATCH_DUR_2_56_SEC          |      0x0E
+*    BMI160_LATCHED                     |      0x0F
+*
+*
+*
+*	@return results of bus communication function
+*	@retval 0 -> Success
+*	@retval -1 -> Error
+*
+*
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_latch_intr(
+u8 *v_latch_intr_u8);
+/*!
+*	@brief This API is used to set the latch duration
+*	from the register 0x54 bit 0 to 3
+*	@brief This latch selection is not applicable for data ready,
+*	orientation and flat interrupts.
+*
+*
+*
+*  @param v_latch_intr_u8 : The value of latch duration
+*	Latch Duration                      |     value
+* --------------------------------------|------------------
+*    BMI160_LATCH_DUR_NONE              |      0x00
+*    BMI160_LATCH_DUR_312_5_MICRO_SEC   |      0x01
+*    BMI160_LATCH_DUR_625_MICRO_SEC     |      0x02
+*    BMI160_LATCH_DUR_1_25_MILLI_SEC    |      0x03
+*    BMI160_LATCH_DUR_2_5_MILLI_SEC     |      0x04
+*    BMI160_LATCH_DUR_5_MILLI_SEC       |      0x05
+*    BMI160_LATCH_DUR_10_MILLI_SEC      |      0x06
+*    BMI160_LATCH_DUR_20_MILLI_SEC      |      0x07
+*    BMI160_LATCH_DUR_40_MILLI_SEC      |      0x08
+*    BMI160_LATCH_DUR_80_MILLI_SEC      |      0x09
+*    BMI160_LATCH_DUR_160_MILLI_SEC     |      0x0A
+*    BMI160_LATCH_DUR_320_MILLI_SEC     |      0x0B
+*    BMI160_LATCH_DUR_640_MILLI_SEC     |      0x0C
+*    BMI160_LATCH_DUR_1_28_SEC          |      0x0D
+*    BMI160_LATCH_DUR_2_56_SEC          |      0x0E
+*    BMI160_LATCHED                     |      0x0F
+*
+*
+*
+*	@return results of bus communication function
+*	@retval 0 -> Success
+*	@retval -1 -> Error
+*
+*
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_latch_intr(
+u8 v_latch_intr_u8);
+/*!
+ *	@brief API used to get input enable for interrupt1
+ *	and interrupt2 pin from the register 0x54
+ *	@brief interrupt1 - bit 4
+ *	@brief interrupt2 - bit 5
+ *
+ *  @param v_channel_u8: The value of input enable selection
+ *   v_channel_u8  |   input selection
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_INPUT_ENABLE
+ *       1         | BMI160_INTR2_INPUT_ENABLE
+ *
+ *	@param v_input_en_u8 :
+ *	The value of input enable of interrupt enable
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x01     |  BMI160_INPUT
+ *  0x00     |  BMI160_OUTPUT
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_input_enable(
+u8 v_channel_u8, u8 *v_input_en_u8);
+/*!
+ *	@brief API used to set input enable for interrupt1
+ *	and interrupt2 pin from the register 0x54
+ *	@brief interrupt1 - bit 4
+ *	@brief interrupt2 - bit 5
+ *
+ *  @param v_channel_u8: The value of input enable selection
+ *   v_channel_u8  |   input selection
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_INPUT_ENABLE
+ *       1         | BMI160_INTR2_INPUT_ENABLE
+ *
+ *	@param v_input_en_u8 :
+ *	The value of input enable of interrupt enable
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x01     |  BMI160_INPUT
+ *  0x00     |  BMI160_OUTPUT
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_input_enable(
+u8 v_channel_u8, u8 v_input_en_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR INTERRUPT1 AND INTERRUPT2 MAPPING */
+/***************************************************************/
+ /*!
+ *	@brief reads the Low g interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 0 in the register 0x55
+ *	@brief interrupt2 bit 0 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of low_g selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_LOW_G
+ *       1         | BMI160_INTR2_MAP_LOW_G
+ *
+ *	@param v_intr_low_g_u8 : The value of low_g enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_g(
+u8 v_channel_u8, u8 *v_intr_low_g_u8);
+ /*!
+ *	@brief set the Low g interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 0 in the register 0x55
+ *	@brief interrupt2 bit 0 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of low_g selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_LOW_G
+ *       1         | BMI160_INTR2_MAP_LOW_G
+ *
+ *	@param v_intr_low_g_u8 : The value of low_g enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_g(
+u8 v_channel_u8, u8 v_intr_low_g_u8);
+/*!
+ *	@brief Reads the HIGH g interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 1 in the register 0x55
+ *	@brief interrupt2 bit 1 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of high_g selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_HIGH_G
+ *       1         | BMI160_INTR2_MAP_HIGH_G
+ *
+ *	@param v_intr_high_g_u8 : The value of high_g enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_high_g(
+u8 v_channel_u8, u8 *v_intr_high_g_u8);
+/*!
+ *	@brief Write the HIGH g interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 1 in the register 0x55
+ *	@brief interrupt2 bit 1 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of high_g selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_HIGH_G
+ *       1         | BMI160_INTR2_MAP_HIGH_G
+ *
+ *	@param v_intr_high_g_u8 : The value of high_g enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_high_g(
+u8 v_channel_u8, u8 v_intr_high_g_u8);
+/*!
+ *	@brief Reads the Any motion interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 2 in the register 0x55
+ *	@brief interrupt2 bit 2 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of any motion selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_ANY_MOTION
+ *       1         | BMI160_INTR2_MAP_ANY_MOTION
+ *
+ *	@param v_intr_any_motion_u8 : The value of any motion enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_any_motion(
+u8 v_channel_u8, u8 *v_intr_any_motion_u8);
+/*!
+ *	@brief Write the Any motion interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 2 in the register 0x55
+ *	@brief interrupt2 bit 2 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of any motion selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_ANY_MOTION
+ *       1         | BMI160_INTR2_MAP_ANY_MOTION
+ *
+ *	@param v_intr_any_motion_u8 : The value of any motion enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_any_motion(
+u8 v_channel_u8, u8 v_intr_any_motion_u8);
+/*!
+ *	@brief Reads the No motion interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 3 in the register 0x55
+ *	@brief interrupt2 bit 3 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of no motion selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_NOMO
+ *       1         | BMI160_INTR2_MAP_NOMO
+ *
+ *	@param v_intr_nomotion_u8 : The value of no motion enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_nomotion(
+u8 v_channel_u8, u8 *v_intr_nomotion_u8);
+/*!
+ *	@brief Write the No motion interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 3 in the register 0x55
+ *	@brief interrupt2 bit 3 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of no motion selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_NOMO
+ *       1         | BMI160_INTR2_MAP_NOMO
+ *
+ *	@param v_intr_nomotion_u8 : The value of no motion enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_nomotion(
+u8 v_channel_u8, u8 v_intr_nomotion_u8);
+/*!
+ *	@brief Reads the Double Tap interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 4 in the register 0x55
+ *	@brief interrupt2 bit 4 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of double tap interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_DOUBLE_TAP
+ *       1         | BMI160_INTR2_MAP_DOUBLE_TAP
+ *
+ *	@param v_intr_double_tap_u8 : The value of double tap enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_double_tap(
+u8 v_channel_u8, u8 *v_intr_double_tap_u8);
+/*!
+ *	@brief Write the Double Tap interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 4 in the register 0x55
+ *	@brief interrupt2 bit 4 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of double tap interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_DOUBLE_TAP
+ *       1         | BMI160_INTR2_MAP_DOUBLE_TAP
+ *
+ *	@param v_intr_double_tap_u8 : The value of double tap enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_double_tap(
+u8 v_channel_u8, u8 v_intr_double_tap_u8);
+/*!
+ *	@brief Reads the Single Tap interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 5 in the register 0x55
+ *	@brief interrupt2 bit 5 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of single tap interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_SINGLE_TAP
+ *       1         | BMI160_INTR2_MAP_SINGLE_TAP
+ *
+ *	@param v_intr_single_tap_u8 : The value of single tap  enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_single_tap(
+u8 v_channel_u8, u8 *v_intr_single_tap_u8);
+/*!
+ *	@brief Write the Single Tap interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 5 in the register 0x55
+ *	@brief interrupt2 bit 5 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of single tap interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_SINGLE_TAP
+ *       1         | BMI160_INTR2_MAP_SINGLE_TAP
+ *
+ *	@param v_intr_single_tap_u8 : The value of single tap  enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_single_tap(
+u8 v_channel_u8, u8 v_intr_single_tap_u8);
+/*!
+ *	@brief Reads the Orient interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 6 in the register 0x55
+ *	@brief interrupt2 bit 6 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of orient interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_ORIENT
+ *       1         | BMI160_INTR2_MAP_ORIENT
+ *
+ *	@param v_intr_orient_u8 : The value of orient enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient(
+u8 v_channel_u8, u8 *v_intr_orient_u8);
+/*!
+ *	@brief Write the Orient interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 6 in the register 0x55
+ *	@brief interrupt2 bit 6 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of orient interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_ORIENT
+ *       1         | BMI160_INTR2_MAP_ORIENT
+ *
+ *	@param v_intr_orient_u8 : The value of orient enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient(
+u8 v_channel_u8, u8 v_intr_orient_u8);
+ /*!
+ *	@brief Reads the Flat interrupt
+ *	mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 7 in the register 0x55
+ *	@brief interrupt2 bit 7 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of flat interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_FLAT
+ *       1         | BMI160_INTR2_MAP_FLAT
+ *
+ *	@param v_intr_flat_u8 : The value of flat enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_flat(
+u8 v_channel_u8, u8 *v_intr_flat_u8);
+ /*!
+ *	@brief Write the Flat interrupt
+ *	mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 7 in the register 0x55
+ *	@brief interrupt2 bit 7 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of flat interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_FLAT
+ *       1         | BMI160_INTR2_MAP_FLAT
+ *
+ *	@param v_intr_flat_u8 : The value of flat enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_flat(
+u8 v_channel_u8, u8 v_intr_flat_u8);
+/*!
+ *	@brief Reads PMU trigger interrupt mapped to interrupt1
+ *	and interrupt2 form the register 0x56 bit 0 and 4
+ *	@brief interrupt1 bit 0 in the register 0x56
+ *	@brief interrupt2 bit 4 in the register 0x56
+ *
+ *
+ *	@param v_channel_u8: The value of pmu trigger selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_PMUTRIG
+ *       1         | BMI160_INTR2_MAP_PMUTRIG
+ *
+ *	@param v_intr_pmu_trig_u8 : The value of pmu trigger enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_pmu_trig(
+u8 v_channel_u8, u8 *v_intr_pmu_trig_u8);
+/*!
+ *	@brief Write PMU trigger interrupt mapped to interrupt1
+ *	and interrupt2 form the register 0x56 bit 0 and 4
+ *	@brief interrupt1 bit 0 in the register 0x56
+ *	@brief interrupt2 bit 4 in the register 0x56
+ *
+ *
+ *	@param v_channel_u8: The value of pmu trigger selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_PMUTRIG
+ *       1         | BMI160_INTR2_MAP_PMUTRIG
+ *
+ *	@param v_intr_pmu_trig_u8 : The value of pmu trigger enable
+ *	value    | trigger enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_pmu_trig(
+u8 v_channel_u8, u8 v_intr_pmu_trig_u8);
+/*!
+ *	@brief Reads FIFO Full interrupt mapped to interrupt1
+ *	and interrupt2 form the register 0x56 bit 5 and 1
+ *	@brief interrupt1 bit 5 in the register 0x56
+ *	@brief interrupt2 bit 1 in the register 0x56
+ *
+ *
+ *	@param v_channel_u8: The value of fifo full interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_FIFO_FULL
+ *       1         | BMI160_INTR2_MAP_FIFO_FULL
+ *
+ *	@param v_intr_fifo_full_u8 : The value of fifo full interrupt enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_fifo_full(
+u8 v_channel_u8, u8 *v_intr_fifo_full_u8);
+/*!
+ *	@brief Write FIFO Full interrupt mapped to interrupt1
+ *	and interrupt2 form the register 0x56 bit 5 and 1
+ *	@brief interrupt1 bit 5 in the register 0x56
+ *	@brief interrupt2 bit 1 in the register 0x56
+ *
+ *
+ *	@param v_channel_u8: The value of fifo full interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_FIFO_FULL
+ *       1         | BMI160_INTR2_MAP_FIFO_FULL
+ *
+ *	@param v_intr_fifo_full_u8 : The value of fifo full interrupt enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_fifo_full(
+u8 v_channel_u8, u8 v_intr_fifo_full_u8);
+/*!
+ *	@brief Reads FIFO Watermark interrupt mapped to interrupt1
+ *	and interrupt2 form the register 0x56 bit 6 and 2
+ *	@brief interrupt1 bit 6 in the register 0x56
+ *	@brief interrupt2 bit 2 in the register 0x56
+ *
+ *
+ *	@param v_channel_u8: The value of fifo Watermark interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_FIFO_WM
+ *       1         | BMI160_INTR2_MAP_FIFO_WM
+ *
+ *	@param v_intr_fifo_wm_u8 : The value of fifo Watermark interrupt enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_fifo_wm(
+u8 v_channel_u8, u8 *v_intr_fifo_wm_u8);
+/*!
+ *	@brief Write FIFO Watermark interrupt mapped to interrupt1
+ *	and interrupt2 form the register 0x56 bit 6 and 2
+ *	@brief interrupt1 bit 6 in the register 0x56
+ *	@brief interrupt2 bit 2 in the register 0x56
+ *
+ *
+ *	@param v_channel_u8: The value of fifo Watermark interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_FIFO_WM
+ *       1         | BMI160_INTR2_MAP_FIFO_WM
+ *
+ *	@param v_intr_fifo_wm_u8 : The value of fifo Watermark interrupt enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_fifo_wm(
+u8 v_channel_u8, u8 v_intr_fifo_wm_u8);
+/*!
+ *	@brief Reads Data Ready interrupt mapped to interrupt1
+ *	and interrupt2 form the register 0x56
+ *	@brief interrupt1 bit 7 in the register 0x56
+ *	@brief interrupt2 bit 3 in the register 0x56
+ *
+ *
+ *	@param v_channel_u8: The value of data ready interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_DATA_RDY
+ *       1         | BMI160_INTR2_MAP_DATA_RDY
+ *
+ *	@param v_intr_data_rdy_u8 : The value of data ready interrupt enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_data_rdy(
+u8 v_channel_u8, u8 *v_intr_data_rdy_u8);
+/*!
+ *	@brief Write Data Ready interrupt mapped to interrupt1
+ *	and interrupt2 form the register 0x56
+ *	@brief interrupt1 bit 7 in the register 0x56
+ *	@brief interrupt2 bit 3 in the register 0x56
+ *
+ *
+ *	@param v_channel_u8: The value of data ready interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | BMI160_INTR1_MAP_DATA_RDY
+ *       1         | BMI160_INTR2_MAP_DATA_RDY
+ *
+ *	@param v_intr_data_rdy_u8 : The value of data ready interrupt enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  BMI160_ENABLE
+ *  0x00     |  BMI160_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_data_rdy(
+u8 v_channel_u8, u8 v_intr_data_rdy_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR TAP SOURCE CONFIGURATION          */
+/***************************************************************/
+ /*!
+ *	@brief This API reads data source for the interrupt
+ *	engine for the single and double tap interrupts from the register
+ *	0x58 bit 3
+ *
+ *
+ *  @param v_tap_source_u8 : The value of the tap source
+ *	value    | Description
+ * ----------|-------------------
+ *  0x01     |  UNFILTER_DATA
+ *  0x00     |  FILTER_DATA
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_tap_source(
+u8 *v_tap_source_u8);
+ /*!
+ *	@brief This API write data source for the interrupt
+ *	engine for the single and double tap interrupts from the register
+ *	0x58 bit 3
+ *
+ *
+ *  @param v_tap_source_u8 : The value of the tap source
+ *	value    | Description
+ * ----------|-------------------
+ *  0x01     |  UNFILTER_DATA
+ *  0x00     |  FILTER_DATA
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_tap_source(
+u8 v_tap_source_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR LOW_G AND HIGH_G SOURCE CONFIGURATION */
+/***************************************************************/
+ /*!
+ *	@brief This API Reads Data source for the
+ *	interrupt engine for the low and high g interrupts
+ *	from the register 0x58 bit 7
+ *
+ *  @param v_low_high_source_u8 : The value of the tap source
+ *	value    | Description
+ * ----------|-------------------
+ *  0x01     |  UNFILTER_DATA
+ *  0x00     |  FILTER_DATA
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_high_source(
+u8 *v_low_high_source_u8);
+ /*!
+ *	@brief This API write Data source for the
+ *	interrupt engine for the low and high g interrupts
+ *	from the register 0x58 bit 7
+ *
+ *  @param v_low_high_source_u8 : The value of the tap source
+ *	value    | Description
+ * ----------|-------------------
+ *  0x01     |  UNFILTER_DATA
+ *  0x00     |  FILTER_DATA
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_high_source(
+u8 v_low_high_source_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR MOTION SOURCE CONFIGURATION          */
+/***************************************************************/
+ /*!
+ *	@brief This API reads Data source for the
+ *	interrupt engine for the nomotion and anymotion interrupts
+ *	from the register 0x59 bit 7
+ *
+ *  @param v_motion_source_u8 :
+ *	The value of the any/no motion interrupt source
+ *	value    | Description
+ * ----------|-------------------
+ *  0x01     |  UNFILTER_DATA
+ *  0x00     |  FILTER_DATA
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_motion_source(
+u8 *v_motion_source_u8);
+ /*!
+ *	@brief This API write Data source for the
+ *	interrupt engine for the nomotion and anymotion interrupts
+ *	from the register 0x59 bit 7
+ *
+ *  @param v_motion_source_u8 :
+ *	The value of the any/no motion interrupt source
+ *	value    | Description
+ * ----------|-------------------
+ *  0x01     |  UNFILTER_DATA
+ *  0x00     |  FILTER_DATA
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_motion_source(
+u8 v_motion_source_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR LOW_G DURATION CONFIGURATION          */
+/***************************************************************/
+/*!
+ *	@brief This API is used to read the low_g duration from register
+ *	0x5A bit 0 to 7
+ *
+ *
+ *
+ *
+ *  @param v_low_g_durn_u8 : The value of low_g duration
+ *
+ *	@note Low_g duration trigger trigger delay according to
+ *	"(v_low_g_durn_u8 * 2.5)ms" in a range from 2.5ms to 640ms.
+ *	the default corresponds delay is 20ms
+ *	@note When low_g data source of interrupt is unfiltered
+ *	the sensor must not be in low power mode
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_g_durn(
+u8 *v_low_durn_u8);
+ /*!
+ *	@brief This API is used to write the low_g duration from register
+ *	0x5A bit 0 to 7
+ *
+ *
+ *
+ *
+ *  @param v_low_g_durn_u8 : The value of low_g duration
+ *
+ *	@note Low_g duration trigger trigger delay according to
+ *	"(v_low_g_durn_u8 * 2.5)ms" in a range from 2.5ms to 640ms.
+ *	the default corresponds delay is 20ms
+ *	@note When low_g data source of interrupt is unfiltered
+ *	the sensor must not be in low power mode
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_g_durn(
+u8 v_low_durn_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR LOW_G THRESH CONFIGURATION          */
+/***************************************************************/
+/*!
+ *	@brief This API is used to read Threshold
+ *	definition for the low-g interrupt from the register 0x5B bit 0 to 7
+ *
+ *
+ *
+ *
+ *  @param v_low_g_thres_u8 : The value of low_g threshold
+ *
+ *	@note Low_g interrupt trigger threshold according to
+ *	(v_low_g_thres_u8 * 7.81)mg for v_low_g_thres_u8 > 0
+ *	3.91 mg for v_low_g_thres_u8 = 0
+ *	The threshold range is form 3.91mg to 2.000mg
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_g_thres(
+u8 *v_low_g_thres_u8);
+/*!
+ *	@brief This API is used to write Threshold
+ *	definition for the low-g interrupt from the register 0x5B bit 0 to 7
+ *
+ *
+ *
+ *
+ *  @param v_low_g_thres_u8 : The value of low_g threshold
+ *
+ *	@note Low_g interrupt trigger threshold according to
+ *	(v_low_g_thres_u8 * 7.81)mg for v_low_g_thres_u8 > 0
+ *	3.91 mg for v_low_g_thres_u8 = 0
+ *	The threshold range is form 3.91mg to 2.000mg
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_g_thres(
+u8 v_low_g_thres_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR LOW_G HYSTERESIS CONFIGURATION     */
+/***************************************************************/
+ /*!
+ *	@brief This API Reads Low-g interrupt hysteresis
+ *	from the register 0x5C bit 0 to 1
+ *
+ *  @param v_low_hyst_u8 :The value of low_g hysteresis
+ *
+ *	@note Low_g hysteresis calculated by v_low_hyst_u8*125 mg
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_g_hyst(
+u8 *v_low_hyst_u8);
+ /*!
+ *	@brief This API write Low-g interrupt hysteresis
+ *	from the register 0x5C bit 0 to 1
+ *
+ *  @param v_low_hyst_u8 :The value of low_g hysteresis
+ *
+ *	@note Low_g hysteresis calculated by v_low_hyst_u8*125 mg
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_g_hyst(
+u8 v_low_hyst_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR LOW_G MODE CONFIGURATION     */
+/***************************************************************/
+/*!
+ *	@brief This API reads Low-g interrupt mode
+ *	from the register 0x5C bit 2
+ *
+ *  @param v_low_g_mode_u8 : The value of low_g mode
+ *	Value    |  Description
+ * ----------|-----------------
+ *	   0     | single-axis
+ *     1     | axis-summing
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_g_mode(
+u8 *v_low_g_mode_u8);
+/*!
+ *	@brief This API write Low-g interrupt mode
+ *	from the register 0x5C bit 2
+ *
+ *  @param v_low_g_mode_u8 : The value of low_g mode
+ *	Value    |  Description
+ * ----------|-----------------
+ *	   0     | single-axis
+ *     1     | axis-summing
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_g_mode(
+u8 v_low_g_mode_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR HIGH_G HYST CONFIGURATION     */
+/***************************************************************/
+/*!
+ *	@brief This API reads High-g interrupt hysteresis
+ *	from the register 0x5C bit 6 and 7
+ *
+ *  @param v_high_g_hyst_u8 : The value of high hysteresis
+ *
+ *	@note High_g hysteresis changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | high_g hysteresis
+ *  ----------------|---------------------
+ *      2g          |  high_hy*125 mg
+ *      4g          |  high_hy*250 mg
+ *      8g          |  high_hy*500 mg
+ *      16g         |  high_hy*1000 mg
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_high_g_hyst(
+u8 *v_high_g_hyst_u8);
+/*!
+ *	@brief This API write High-g interrupt hysteresis
+ *	from the register 0x5C bit 6 and 7
+ *
+ *  @param v_high_g_hyst_u8 : The value of high hysteresis
+ *
+ *	@note High_g hysteresis changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | high_g hysteresis
+ *  ----------------|---------------------
+ *      2g          |  high_hy*125 mg
+ *      4g          |  high_hy*250 mg
+ *      8g          |  high_hy*500 mg
+ *      16g         |  high_hy*1000 mg
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_high_g_hyst(
+u8 v_high_g_hyst_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR HIGH_G DURATION CONFIGURATION     */
+/***************************************************************/
+/*!
+ *	@brief This API is used to read Delay
+ *	time definition for the high-g interrupt from the register
+ *	0x5D bit 0 to 7
+ *
+ *
+ *
+ *  @param  v_high_g_durn_u8 :  The value of high duration
+ *
+ *	@note High_g interrupt delay triggered according to
+ *	v_high_g_durn_u8 * 2.5ms in a range from 2.5ms to 640ms
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_high_g_durn(
+u8 *v_high_g_durn_u8);
+/*!
+ *	@brief This API is used to write Delay
+ *	time definition for the high-g interrupt from the register
+ *	0x5D bit 0 to 7
+ *
+ *
+ *
+ *  @param  v_high_g_durn_u8 :  The value of high duration
+ *
+ *	@note High_g interrupt delay triggered according to
+ *	v_high_g_durn_u8 * 2.5ms in a range from 2.5ms to 640ms
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_high_g_durn(
+u8 v_high_g_durn_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR HIGH_G THRESHOLD CONFIGURATION     */
+/***************************************************************/
+/*!
+ *	@brief This API is used to read Threshold
+ *	definition for the high-g interrupt from the register 0x5E 0 to 7
+ *
+ *
+ *
+ *
+ *  @param  v_high_g_thres_u8 : Pointer holding the value of Threshold
+ *	@note High_g threshold changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | high_g threshold
+ *  ----------------|---------------------
+ *      2g          |  v_high_g_thres_u8*7.81 mg
+ *      4g          |  v_high_g_thres_u8*15.63 mg
+ *      8g          |  v_high_g_thres_u8*31.25 mg
+ *      16g         |  v_high_g_thres_u8*62.5 mg
+ *	@note when v_high_g_thres_u8 = 0
+ *   accel_range    | high_g threshold
+ *  ----------------|---------------------
+ *      2g          |  3.91 mg
+ *      4g          |  7.81 mg
+ *      8g          |  15.63 mg
+ *      16g         |  31.25 mg
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_high_g_thres(
+u8 *v_high_g_thres_u8);
+/*!
+ *	@brief This API is used to write Threshold
+ *	definition for the high-g interrupt from the register 0x5E 0 to 7
+ *
+ *
+ *
+ *
+ *  @param  v_high_g_thres_u8 : Pointer holding the value of Threshold
+ *	@note High_g threshold changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | high_g threshold
+ *  ----------------|---------------------
+ *      2g          |  v_high_g_thres_u8*7.81 mg
+ *      4g          |  v_high_g_thres_u8*15.63 mg
+ *      8g          |  v_high_g_thres_u8*31.25 mg
+ *      16g         |  v_high_g_thres_u8*62.5 mg
+ *	@note when v_high_g_thres_u8 = 0
+ *   accel_range    | high_g threshold
+ *  ----------------|---------------------
+ *      2g          |  3.91 mg
+ *      4g          |  7.81 mg
+ *      8g          |  15.63 mg
+ *      16g         |  31.25 mg
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_high_g_thres(
+u8 v_high_g_thres_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR ANY MOTION DURATION CONFIGURATION     */
+/***************************************************************/
+/*!
+ *	@brief This API reads any motion duration
+ *	from the register 0x5F bit 0 and 1
+ *
+ *  @param v_any_motion_durn_u8 : The value of any motion duration
+ *
+ *	@note Any motion duration can be calculated by "v_any_motion_durn_u8 + 1"
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_any_motion_durn(
+u8 *v_any_motion_durn_u8);
+/*!
+ *	@brief This API write any motion duration
+ *	from the register 0x5F bit 0 and 1
+ *
+ *  @param v_any_motion_durn_u8 : The value of any motion duration
+ *
+ *	@note Any motion duration can be calculated by "v_any_motion_durn_u8 + 1"
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_any_motion_durn(
+u8 nomotion);
+/***************************************************************/
+/**\name	FUNCTION FOR SLOW NO MOTION DURATION CONFIGURATION  */
+/***************************************************************/
+ /*!
+ *	@brief This API read Slow/no-motion
+ *	interrupt trigger delay duration from the register 0x5F bit 2 to 7
+ *
+ *  @param v_slow_no_motion_u8 :The value of slow no motion duration
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *	@note
+ *	@note v_slow_no_motion_u8(5:4)=0b00 ->
+ *	[v_slow_no_motion_u8(3:0) + 1] * 1.28s (1.28s-20.48s)
+ *	@note v_slow_no_motion_u8(5:4)=1 ->
+ *	[v_slow_no_motion_u8(3:0)+5] * 5.12s (25.6s-102.4s)
+ *	@note v_slow_no_motion_u8(5)='1' ->
+ *	[(v_slow_no_motion_u8:0)+11] * 10.24s (112.64s-430.08s);
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_slow_no_motion_durn(
+u8 *v_slow_no_motion_u8);
+ /*!
+ *	@brief This API write Slow/no-motion
+ *	interrupt trigger delay duration from the register 0x5F bit 2 to 7
+ *
+ *  @param v_slow_no_motion_u8 :The value of slow no motion duration
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *	@note
+ *	@note v_slow_no_motion_u8(5:4)=0b00 ->
+ *	[v_slow_no_motion_u8(3:0) + 1] * 1.28s (1.28s-20.48s)
+ *	@note v_slow_no_motion_u8(5:4)=1 ->
+ *	[v_slow_no_motion_u8(3:0)+5] * 5.12s (25.6s-102.4s)
+ *	@note v_slow_no_motion_u8(5)='1' ->
+ *	[(v_slow_no_motion_u8:0)+11] * 10.24s (112.64s-430.08s);
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_slow_no_motion_durn(
+u8 v_slow_no_motion_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR ANY MOTION THRESHOLD CONFIGURATION  */
+/***************************************************************/
+/*!
+ *	@brief This API is used to read threshold
+ *	definition for the any-motion interrupt
+ *	from the register 0x60 bit 0 to 7
+ *
+ *
+ *  @param  v_any_motion_thres_u8 : The value of any motion threshold
+ *
+ *	@note any motion threshold changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | any motion threshold
+ *  ----------------|---------------------
+ *      2g          |  v_any_motion_thres_u8*3.91 mg
+ *      4g          |  v_any_motion_thres_u8*7.81 mg
+ *      8g          |  v_any_motion_thres_u8*15.63 mg
+ *      16g         |  v_any_motion_thres_u8*31.25 mg
+ *	@note when v_any_motion_thres_u8 = 0
+ *   accel_range    | any motion threshold
+ *  ----------------|---------------------
+ *      2g          |  1.95 mg
+ *      4g          |  3.91 mg
+ *      8g          |  7.81 mg
+ *      16g         |  15.63 mg
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_any_motion_thres(
+u8 *v_any_motion_thres_u8);
+/*!
+ *	@brief This API is used to write threshold
+ *	definition for the any-motion interrupt
+ *	from the register 0x60 bit 0 to 7
+ *
+ *
+ *  @param  v_any_motion_thres_u8 : The value of any motion threshold
+ *
+ *	@note any motion threshold changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | any motion threshold
+ *  ----------------|---------------------
+ *      2g          |  v_any_motion_thres_u8*3.91 mg
+ *      4g          |  v_any_motion_thres_u8*7.81 mg
+ *      8g          |  v_any_motion_thres_u8*15.63 mg
+ *      16g         |  v_any_motion_thres_u8*31.25 mg
+ *	@note when v_any_motion_thres_u8 = 0
+ *   accel_range    | any motion threshold
+ *  ----------------|---------------------
+ *      2g          |  1.95 mg
+ *      4g          |  3.91 mg
+ *      8g          |  7.81 mg
+ *      16g         |  15.63 mg
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_any_motion_thres(
+u8 v_any_motion_thres_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR SLO/NO MOTION THRESHOLD CONFIGURATION  */
+/***************************************************************/
+ /*!
+ *	@brief This API is used to read threshold
+ *	for the slow/no-motion interrupt
+ *	from the register 0x61 bit 0 to 7
+ *
+ *
+ *
+ *
+ *  @param v_slow_no_motion_thres_u8 : The value of slow no motion threshold
+ *	@note slow no motion threshold changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | slow no motion threshold
+ *  ----------------|---------------------
+ *      2g          |  v_slow_no_motion_thres_u8*3.91 mg
+ *      4g          |  v_slow_no_motion_thres_u8*7.81 mg
+ *      8g          |  v_slow_no_motion_thres_u8*15.63 mg
+ *      16g         |  v_slow_no_motion_thres_u8*31.25 mg
+ *	@note when v_slow_no_motion_thres_u8 = 0
+ *   accel_range    | slow no motion threshold
+ *  ----------------|---------------------
+ *      2g          |  1.95 mg
+ *      4g          |  3.91 mg
+ *      8g          |  7.81 mg
+ *      16g         |  15.63 mg
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_slow_no_motion_thres(
+u8 *v_slow_no_motion_thres_u8);
+ /*!
+ *	@brief This API is used to write threshold
+ *	for the slow/no-motion interrupt
+ *	from the register 0x61 bit 0 to 7
+ *
+ *
+ *
+ *
+ *  @param v_slow_no_motion_thres_u8 : The value of slow no motion threshold
+ *	@note slow no motion threshold changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | slow no motion threshold
+ *  ----------------|---------------------
+ *      2g          |  v_slow_no_motion_thres_u8*3.91 mg
+ *      4g          |  v_slow_no_motion_thres_u8*7.81 mg
+ *      8g          |  v_slow_no_motion_thres_u8*15.63 mg
+ *      16g         |  v_slow_no_motion_thres_u8*31.25 mg
+ *	@note when v_slow_no_motion_thres_u8 = 0
+ *   accel_range    | slow no motion threshold
+ *  ----------------|---------------------
+ *      2g          |  1.95 mg
+ *      4g          |  3.91 mg
+ *      8g          |  7.81 mg
+ *      16g         |  15.63 mg
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_slow_no_motion_thres(
+u8 v_slow_no_motion_thres_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR SLO/NO MOTION SELECT CONFIGURATION  */
+/***************************************************************/
+ /*!
+ *	@brief This API is used to read
+ *	the slow/no-motion selection from the register 0x62 bit 0
+ *
+ *
+ *
+ *
+ *  @param  v_intr_slow_no_motion_select_u8 :
+ *	The value of slow/no-motion select
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     |  SLOW_MOTION
+ *  0x01     |  NO_MOTION
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_slow_no_motion_select(
+u8 *v_intr_slow_no_motion_select_u8);
+ /*!
+ *	@brief This API is used to write
+ *	the slow/no-motion selection from the register 0x62 bit 0
+ *
+ *
+ *
+ *
+ *  @param  v_intr_slow_no_motion_select_u8 :
+ *	The value of slow/no-motion select
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     |  SLOW_MOTION
+ *  0x01     |  NO_MOTION
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_slow_no_motion_select(
+u8 v_intr_slow_no_motion_select_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR SIGNIFICANT MOTION SELECT CONFIGURATION*/
+/***************************************************************/
+ /*!
+ *	@brief This API is used to select
+ *	the significant or any motion interrupt from the register 0x62 bit 1
+ *
+ *
+ *
+ *
+ *  @param  v_intr_significant_motion_select_u8 :
+ *	the value of significant or any motion interrupt selection
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     |  ANY_MOTION
+ *  0x01     |  SIGNIFICANT_MOTION
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_significant_motion_select(
+u8 *int_sig_mot_sel);
+ /*!
+ *	@brief This API is used to write, select
+ *	the significant or any motion interrupt from the register 0x62 bit 1
+ *
+ *
+ *
+ *
+ *  @param  v_intr_significant_motion_select_u8 :
+ *	the value of significant or any motion interrupt selection
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     |  ANY_MOTION
+ *  0x01     |  SIGNIFICANT_MOTION
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_significant_motion_select(
+u8 int_sig_mot_sel);
+ /*!
+ *	@brief This API is used to read
+ *	the significant skip time from the register 0x62 bit  2 and 3
+ *
+ *
+ *
+ *
+ *  @param  v_int_sig_mot_skip_u8 : the value of significant skip time
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     |  skip time 1.5 seconds
+ *  0x01     |  skip time 3 seconds
+ *  0x02     |  skip time 6 seconds
+ *  0x03     |  skip time 12 seconds
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_significant_motion_skip(
+u8 *v_int_sig_mot_skip_u8);
+ /*!
+ *	@brief This API is used to write
+ *	the significant skip time from the register 0x62 bit  2 and 3
+ *
+ *
+ *
+ *
+ *  @param  v_int_sig_mot_skip_u8 : the value of significant skip time
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     |  skip time 1.5 seconds
+ *  0x01     |  skip time 3 seconds
+ *  0x02     |  skip time 6 seconds
+ *  0x03     |  skip time 12 seconds
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_significant_motion_skip(
+u8 v_int_sig_mot_skip_u8);
+ /*!
+ *	@brief This API is used to read
+ *	the significant proof time from the register 0x62 bit  4 and 5
+ *
+ *
+ *
+ *
+ *  @param  v_significant_motion_proof_u8 :
+ *	the value of significant proof time
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     |  proof time 0.25 seconds
+ *  0x01     |  proof time 0.5 seconds
+ *  0x02     |  proof time 1 seconds
+ *  0x03     |  proof time 2 seconds
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_significant_motion_proof(
+u8 *int_sig_mot_proof);
+ /*!
+ *	@brief This API is used to write
+ *	the significant proof time from the register 0x62 bit  4 and 5
+ *
+ *
+ *
+ *
+ *  @param  v_significant_motion_proof_u8 :
+ *	the value of significant proof time
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     |  proof time 0.25 seconds
+ *  0x01     |  proof time 0.5 seconds
+ *  0x02     |  proof time 1 seconds
+ *  0x03     |  proof time 2 seconds
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_significant_motion_proof(
+u8 int_sig_mot_proof);
+/***************************************************************/
+/**\name	FUNCTION FOR TAP DURATION CONFIGURATION*/
+/***************************************************************/
+/*!
+ *	@brief This API is used to get the tap duration
+ *	from the register 0x63 bit 0 to 2
+ *
+ *
+ *
+ *  @param v_tap_durn_u8 : The value of tap duration
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | BMI160_TAP_DURN_50MS
+ *  0x01     | BMI160_TAP_DURN_100MS
+ *  0x03     | BMI160_TAP_DURN_150MS
+ *  0x04     | BMI160_TAP_DURN_200MS
+ *  0x05     | BMI160_TAP_DURN_250MS
+ *  0x06     | BMI160_TAP_DURN_375MS
+ *  0x07     | BMI160_TAP_DURN_700MS
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_tap_durn(
+u8 *v_tap_durn_u8);
+/*!
+ *	@brief This API is used to write the tap duration
+ *	from the register 0x63 bit 0 to 2
+ *
+ *
+ *
+ *  @param v_tap_durn_u8 : The value of tap duration
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | BMI160_TAP_DURN_50MS
+ *  0x01     | BMI160_TAP_DURN_100MS
+ *  0x03     | BMI160_TAP_DURN_150MS
+ *  0x04     | BMI160_TAP_DURN_200MS
+ *  0x05     | BMI160_TAP_DURN_250MS
+ *  0x06     | BMI160_TAP_DURN_375MS
+ *  0x07     | BMI160_TAP_DURN_700MS
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_tap_durn(
+u8 v_tap_durn_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR TAP SHOCK CONFIGURATION*/
+/***************************************************************/
+ /*!
+ *	@brief This API read the
+ *	tap shock duration from the register 0x63 bit 2
+ *
+ *  @param v_tap_shock_u8 :The value of tap shock
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | BMI160_TAP_SHOCK_50MS
+ *  0x01     | BMI160_TAP_SHOCK_75MS
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_tap_shock(
+u8 *v_tap_shock_u8);
+ /*!
+ *	@brief This API write the
+ *	tap shock duration from the register 0x63 bit 2
+ *
+ *  @param v_tap_shock_u8 :The value of tap shock
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | BMI160_TAP_SHOCK_50MS
+ *  0x01     | BMI160_TAP_SHOCK_75MS
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_tap_shock(
+u8 v_tap_shock_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR TAP QUIET CONFIGURATION*/
+/***************************************************************/
+/*!
+ *	@brief This API read
+ *	tap quiet duration from the register 0x63 bit 7
+ *
+ *
+ *  @param v_tap_quiet_u8 : The value of tap quiet
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | BMI160_TAP_QUIET_30MS
+ *  0x01     | BMI160_TAP_QUIET_20MS
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_tap_quiet(
+u8 *v_tap_quiet_u8);
+/*!
+ *	@brief This API write
+ *	tap quiet duration from the register 0x63 bit 7
+ *
+ *
+ *  @param v_tap_quiet_u8 : The value of tap quiet
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | BMI160_TAP_QUIET_30MS
+ *  0x01     | BMI160_TAP_QUIET_20MS
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_tap_quiet(
+u8 v_tap_quiet_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR TAP THRESHOLD CONFIGURATION*/
+/***************************************************************/
+ /*!
+ *	@brief This API read Threshold of the
+ *	single/double tap interrupt from the register 0x64 bit 0 to 4
+ *
+ *
+ *	@param v_tap_thres_u8 : The value of single/double tap threshold
+ *
+ *	@note single/double tap threshold changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | single/double tap threshold
+ *  ----------------|---------------------
+ *      2g          |  ((v_tap_thres_u8 + 1) * 62.5)mg
+ *      4g          |  ((v_tap_thres_u8 + 1) * 125)mg
+ *      8g          |  ((v_tap_thres_u8 + 1) * 250)mg
+ *      16g         |  ((v_tap_thres_u8 + 1) * 500)mg
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_tap_thres(
+u8 *v_tap_thres_u8);
+ /*!
+ *	@brief This API write Threshold of the
+ *	single/double tap interrupt from the register 0x64 bit 0 to 4
+ *
+ *
+ *	@param v_tap_thres_u8 : The value of single/double tap threshold
+ *
+ *	@note single/double tap threshold changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | single/double tap threshold
+ *  ----------------|---------------------
+ *      2g          |  ((v_tap_thres_u8 + 1) * 62.5)mg
+ *      4g          |  ((v_tap_thres_u8 + 1) * 125)mg
+ *      8g          |  ((v_tap_thres_u8 + 1) * 250)mg
+ *      16g         |  ((v_tap_thres_u8 + 1) * 500)mg
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_tap_thres(
+u8 v_tap_thres_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR ORIENT MODE CONFIGURATION*/
+/***************************************************************/
+ /*!
+ *	@brief This API read the threshold for orientation interrupt
+ *	from the register 0x65 bit 0 and 1
+ *
+ *  @param v_orient_mode_u8 : The value of threshold for orientation
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | symmetrical
+ *  0x01     | high-asymmetrical
+ *  0x02     | low-asymmetrical
+ *  0x03     | symmetrical
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_mode(
+u8 *v_orient_mode_u8);
+ /*!
+ *	@brief This API write the threshold for orientation interrupt
+ *	from the register 0x65 bit 0 and 1
+ *
+ *  @param v_orient_mode_u8 : The value of threshold for orientation
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | symmetrical
+ *  0x01     | high-asymmetrical
+ *  0x02     | low-asymmetrical
+ *  0x03     | symmetrical
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_mode(
+u8 v_orient_mode_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR ORIENT BLOCKING CONFIGURATION*/
+/***************************************************************/
+/*!
+ *	@brief This API read the orient blocking mode
+ *	that is used for the generation of the orientation interrupt.
+ *	from the register 0x65 bit 2 and 3
+ *
+ *  @param v_orient_blocking_u8 : The value of orient blocking mode
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | No blocking
+ *  0x01     | Theta blocking or acceleration in any axis > 1.5g
+ *  0x02     | Theta blocking or acceleration slope in any axis >
+ *   -       | 0.2g or acceleration in any axis > 1.5g
+ *  0x03     | Theta blocking or acceleration slope in any axis >
+ *   -       | 0.4g or acceleration in any axis >
+ *   -       | 1.5g and value of orient is not stable
+ *   -       | for at least 100 ms
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_blocking(
+u8 *v_orient_blocking_u8);
+/*!
+ *	@brief This API write the orient blocking mode
+ *	that is used for the generation of the orientation interrupt.
+ *	from the register 0x65 bit 2 and 3
+ *
+ *  @param v_orient_blocking_u8 : The value of orient blocking mode
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | No blocking
+ *  0x01     | Theta blocking or acceleration in any axis > 1.5g
+ *  0x02     | Theta blocking or acceleration slope in any axis >
+ *   -       | 0.2g or acceleration in any axis > 1.5g
+ *  0x03     | Theta blocking or acceleration slope in any axis >
+ *   -       | 0.4g or acceleration in any axis >
+ *   -       | 1.5g and value of orient is not stable
+ *   -       | for at least 100 ms
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_blocking(
+u8 v_orient_blocking_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR ORIENT HYSTERESIS CONFIGURATION*/
+/***************************************************************/
+/*!
+ *	@brief This API read Orient interrupt
+ *	hysteresis, from the register 0x64 bit 4 to 7
+ *
+ *
+ *
+ *  @param v_orient_hyst_u8 : The value of orient hysteresis
+ *
+ *	@note 1 LSB corresponds to 62.5 mg,
+ *	irrespective of the selected accel range
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_hyst(
+u8 *v_orient_hyst_u8);
+/*!
+ *	@brief This API write Orient interrupt
+ *	hysteresis, from the register 0x64 bit 4 to 7
+ *
+ *
+ *
+ *  @param v_orient_hyst_u8 : The value of orient hysteresis
+ *
+ *	@note 1 LSB corresponds to 62.5 mg,
+ *	irrespective of the selected accel range
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_hyst(
+u8 v_orient_hyst_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR ORIENT THETA CONFIGURATION*/
+/***************************************************************/
+ /*!
+ *	@brief This API read Orient
+ *	blocking angle (0 to 44.8) from the register 0x66 bit 0 to 5
+ *
+ *  @param v_orient_theta_u8 : The value of Orient blocking angle
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_theta(
+u8 *v_orient_theta_u8);
+ /*!
+ *	@brief This API write Orient
+ *	blocking angle (0 to 44.8) from the register 0x66 bit 0 to 5
+ *
+ *  @param v_orient_theta_u8 : The value of Orient blocking angle
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_theta(
+u8 v_orient_theta_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR ORIENT OUTPUT ENABLE CONFIGURATION*/
+/***************************************************************/
+/*!
+ *	@brief This API read orient change
+ *	of up/down bit from the register 0x66 bit 6
+ *
+ *  @param v_orient_ud_u8 : The value of orient change of up/down
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | Is ignored
+ *  0x01     | Generates orientation interrupt
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_ud_enable(
+u8 *v_orient_ud_u8);
+/*!
+ *	@brief This API write orient change
+ *	of up/down bit from the register 0x66 bit 6
+ *
+ *  @param v_orient_ud_u8 : The value of orient change of up/down
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | Is ignored
+ *  0x01     | Generates orientation interrupt
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_ud_enable(
+u8 v_orient_ud_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR ORIENT AXIS ENABLE CONFIGURATION*/
+/***************************************************************/
+ /*!
+ *	@brief This API read orientation axes changes
+ *	from the register 0x66 bit 7
+ *
+ *  @param v_orient_axes_u8 : The value of orient axes assignment
+ *	value    |       Behaviour    | Name
+ * ----------|--------------------|------
+ *  0x00     | x = x, y = y, z = z|orient_ax_noex
+ *  0x01     | x = y, y = z, z = x|orient_ax_ex
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_axes_enable(
+u8 *v_orient_axes_u8);
+ /*!
+ *	@brief This API write orientation axes changes
+ *	from the register 0x66 bit 7
+ *
+ *  @param v_orient_axes_u8 : The value of orient axes assignment
+ *	value    |       Behaviour    | Name
+ * ----------|--------------------|------
+ *  0x00     | x = x, y = y, z = z|orient_ax_noex
+ *  0x01     | x = y, y = z, z = x|orient_ax_ex
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_axes_enable(
+u8 v_orient_axes_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR FLAT THETA CONFIGURATION*/
+/***************************************************************/
+ /*!
+ *	@brief This API read Flat angle (0 to 44.8) for flat interrupt
+ *	from the register 0x67 bit 0 to 5
+ *
+ *  @param v_flat_theta_u8 : The value of flat angle
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_flat_theta(
+u8 *v_flat_theta_u8);
+ /*!
+ *	@brief This API write Flat angle (0 to 44.8) for flat interrupt
+ *	from the register 0x67 bit 0 to 5
+ *
+ *  @param v_flat_theta_u8 : The value of flat angle
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_flat_theta(
+u8 v_flat_theta_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR FLAT HOLD CONFIGURATION*/
+/***************************************************************/
+/*!
+ *	@brief This API read Flat interrupt hold time;
+ *	from the register 0x68 bit 4 and 5
+ *
+ *  @param v_flat_hold_u8 : The value of flat hold time
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | 0ms
+ *  0x01     | 512ms
+ *  0x01     | 1024ms
+ *  0x01     | 2048ms
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_flat_hold(
+u8 *v_flat_hold_u8);
+/*!
+ *	@brief This API write Flat interrupt hold time;
+ *	from the register 0x68 bit 4 and 5
+ *
+ *  @param v_flat_hold_u8 : The value of flat hold time
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | 0ms
+ *  0x01     | 512ms
+ *  0x01     | 1024ms
+ *  0x01     | 2048ms
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_flat_hold(
+u8 v_flat_hold_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR FLAT HYSTERESIS CONFIGURATION*/
+/***************************************************************/
+/*!
+ *	@brief This API read flat interrupt hysteresis
+ *	from the register 0x68 bit 0 to 3
+ *
+ *  @param v_flat_hyst_u8 : The value of flat hysteresis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_flat_hyst(
+u8 *v_flat_hyst_u8);
+/*!
+ *	@brief This API write flat interrupt hysteresis
+ *	from the register 0x68 bit 0 to 3
+ *
+ *  @param v_flat_hyst_u8 : The value of flat hysteresis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_flat_hyst(
+u8 v_flat_hyst_u8);
+/***************************************************************/
+/**\name	FUNCTION FAST OFFSET COMPENSATION FOR ACCEL */
+/***************************************************************/
+ /*!
+ *	@brief This API read accel offset compensation
+ *	target value for z-axis from the register 0x69 bit 0 and 1
+ *
+ *  @param v_foc_accel_z_u8 : the value of accel offset compensation z axis
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_foc_accel_z(
+u8 *v_foc_accel_z_u8);
+ /*!
+ *	@brief This API write accel offset compensation
+ *	target value for z-axis from the register 0x69 bit 0 and 1
+ *
+ *  @param v_foc_accel_z_u8 : the value of accel offset compensation z axis
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_foc_accel_z(
+u8 v_foc_accel_z_u8);
+/*!
+ *	@brief This API read accel offset compensation
+ *	target value for y-axis
+ *	from the register 0x69 bit 2 and 3
+ *
+ *  @param v_foc_accel_y_u8 : the value of accel offset compensation y axis
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_foc_accel_y(
+u8 *v_foc_accel_y_u8);
+/*!
+ *	@brief This API write accel offset compensation
+ *	target value for y-axis
+ *	from the register 0x69 bit 2 and 3
+ *
+ *  @param v_foc_accel_y_u8 : the value of accel offset compensation y axis
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_foc_accel_y(
+u8 v_foc_accel_y_u8);
+/*!
+ *	@brief This API read accel offset compensation
+ *	target value for x-axis is
+ *	from the register 0x69 bit 4 and 5
+ *
+ *  @param v_foc_accel_x_u8 : the value of accel offset compensation x axis
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_foc_accel_x(
+u8 *v_foc_accel_x_u8);
+/*!
+ *	@brief This API write accel offset compensation
+ *	target value for x-axis is
+ *	from the register 0x69 bit 4 and 5
+ *
+ *  @param v_foc_accel_x_u8 : the value of accel offset compensation x axis
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_foc_accel_x(
+u8 v_foc_accel_x_u8);
+/***************************************************************/
+/**\name	FUNCTION FAST OFFSET COMPENSATION FOR GYRO */
+/***************************************************************/
+/*!
+ *	@brief This API write gyro fast offset enable
+ *	from the register 0x69 bit 6
+ *
+ *  @param v_foc_gyro_u8 : The value of gyro fast offset enable
+ *  value    |  Description
+ * ----------|-------------
+ *    0      | fast offset compensation disabled
+ *    1      |  fast offset compensation enabled
+ *
+ *	@param v_gyro_off_x_s16 : The value of gyro fast offset x axis data
+ *	@param v_gyro_off_y_s16 : The value of gyro fast offset y axis data
+ *	@param v_gyro_off_z_s16 : The value of gyro fast offset z axis data
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_foc_gyro_enable(
+u8 v_foc_gyro_u8, s16 *v_gyro_off_x_s16,
+s16 *v_gyro_off_y_s16, s16 *v_gyro_off_z_s16);
+/***************************************************/
+/**\name	FUNCTION FOR NVM*/
+/***************************************************/
+ /*!
+ *	@brief This API read NVM program enable
+ *	from the register 0x6A bit 1
+ *
+ *  @param v_nvm_prog_u8 : The value of NVM program enable
+ *  Value  |  Description
+ * --------|-------------
+ *   0     |  DISABLE
+ *   1     |  ENABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_nvm_prog_enable(
+u8 *v_nvm_prog_u8);
+ /*!
+ *	@brief This API write NVM program enable
+ *	from the register 0x6A bit 1
+ *
+ *  @param v_nvm_prog_u8 : The value of NVM program enable
+ *  Value  |  Description
+ * --------|-------------
+ *   0     |  DISABLE
+ *   1     |  ENABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_nvm_prog_enable(
+u8 v_nvm_prog_u8);
+/***************************************************/
+/**\name	FUNCTION FOR SPI MODE*/
+/***************************************************/
+/*!
+ * @brief This API read to configure SPI
+ * Interface Mode for primary and OIS interface
+ * from the register 0x6B bit 0
+ *
+ *  @param v_spi3_u8 : The value of SPI mode selection
+ *  Value  |  Description
+ * --------|-------------
+ *   0     |  SPI 4-wire mode
+ *   1     |  SPI 3-wire mode
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_spi3(
+u8 *v_spi3_u8);
+/*!
+ * @brief This API write to configure SPI
+ * Interface Mode for primary and OIS interface
+ * from the register 0x6B bit 0
+ *
+ *  @param v_spi3_u8 : The value of SPI mode selection
+ *  Value  |  Description
+ * --------|-------------
+ *   0     |  SPI 4-wire mode
+ *   1     |  SPI 3-wire mode
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_spi3(
+u8 v_spi3_u8);
+/***************************************************/
+/**\name	FUNCTION FOR FOC GYRO */
+/***************************************************/
+/*!
+ *	@brief This API read gyro fast offset enable
+ *	from the register 0x69 bit 6
+ *
+ *  @param v_foc_gyro_u8 : The value of gyro fast offset enable
+ *  value    |  Description
+ * ----------|-------------
+ *    0      | fast offset compensation disabled
+ *    1      |  fast offset compensation enabled
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_foc_gyro_enable(
+u8 *v_foc_gyro_u8);
+/***************************************************/
+/**\name	FUNCTION FOR I2C WATCHDOG TIMBER */
+/***************************************************/
+/*!
+ *	@brief This API read I2C Watchdog timer
+ *	from the register 0x70 bit 1
+ *
+ *  @param v_i2c_wdt_u8 : The value of I2C watch dog timer
+ *  Value  |  Description
+ * --------|-------------
+ *   0     |  I2C watchdog v_timeout_u8 after 1 ms
+ *   1     |  I2C watchdog v_timeout_u8 after 50 ms
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_i2c_wdt_select(
+u8 *v_i2c_wdt_u8);
+/*!
+ *	@brief This API write I2C Watchdog timer
+ *	from the register 0x70 bit 1
+ *
+ *  @param v_i2c_wdt_u8 : The value of I2C watch dog timer
+ *  Value  |  Description
+ * --------|-------------
+ *   0     |  I2C watchdog v_timeout_u8 after 1 ms
+ *   1     |  I2C watchdog v_timeout_u8 after 50 ms
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE
+bmi160_set_i2c_wdt_select(u8 v_i2c_wdt_u8);
+/*!
+ *	@brief This API read I2C watchdog enable
+ *	from the register 0x70 bit 2
+ *
+ *  @param v_i2c_wdt_u8 : The value of I2C watchdog enable
+ *  Value  |  Description
+ * --------|-------------
+ *   0     |  DISABLE
+ *   1     |  ENABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_i2c_wdt_enable(
+u8 *v_i2c_wdt_u8);
+/*!
+ *	@brief This API write I2C watchdog enable
+ *	from the register 0x70 bit 2
+ *
+ *  @param v_i2c_wdt_u8 : The value of I2C watchdog enable
+ *  Value  |  Description
+ * --------|-------------
+ *   0     |  DISABLE
+ *   1     |  ENABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_i2c_wdt_enable(
+u8 v_i2c_wdt_u8);
+/***************************************************/
+/**\name	FUNCTION FOR IF MODE*/
+/***************************************************/
+/*!
+ * @brief This API read I2C interface configuration(if) moe
+ * from the register 0x6B bit 4 and 5
+ *
+ *  @param  v_if_mode_u8 : The value of interface configuration mode
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  |  Primary interface:autoconfig / secondary interface:off
+ *   0x01  |  Primary interface:I2C / secondary interface:OIS
+ *   0x02  |  Primary interface:autoconfig/secondary interface:Magnetometer
+ *   0x03  |   Reserved
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_if_mode(
+u8 *v_if_mode_u8);
+/*!
+ * @brief This API write I2C interface configuration(if) moe
+ * from the register 0x6B bit 4 and 5
+ *
+ *  @param  v_if_mode_u8 : The value of interface configuration mode
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  |  Primary interface:autoconfig / secondary interface:off
+ *   0x01  |  Primary interface:I2C / secondary interface:OIS
+ *   0x02  |  Primary interface:autoconfig/secondary interface:Magnetometer
+ *   0x03  |   Reserved
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_if_mode(
+u8 v_if_mode_u8);
+/***************************************************/
+/**\name	FUNCTION FOR GYRO SLEEP TRIGGER INTERRUPT CONFIGURATION*/
+/***************************************************/
+/*!
+ *	@brief This API read gyro sleep trigger
+ *	from the register 0x6C bit 0 to 2
+ *
+ *  @param v_gyro_sleep_trigger_u8 : The value of gyro sleep trigger
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | nomotion: no / Not INT1 pin: no / INT2 pin: no
+ *   0x01  | nomotion: no / Not INT1 pin: no / INT2 pin: yes
+ *   0x02  | nomotion: no / Not INT1 pin: yes / INT2 pin: no
+ *   0x03  | nomotion: no / Not INT1 pin: yes / INT2 pin: yes
+ *   0x04  | nomotion: yes / Not INT1 pin: no / INT2 pin: no
+ *   0x05  | anymotion: yes / Not INT1 pin: no / INT2 pin: yes
+ *   0x06  | anymotion: yes / Not INT1 pin: yes / INT2 pin: no
+ *   0x07  | anymotion: yes / Not INT1 pin: yes / INT2 pin: yes
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_sleep_trigger(
+u8 *v_gyro_sleep_trigger_u8);
+/*!
+ *	@brief This API write gyro sleep trigger
+ *	from the register 0x6C bit 0 to 2
+ *
+ *  @param v_gyro_sleep_trigger_u8 : The value of gyro sleep trigger
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | nomotion: no / Not INT1 pin: no / INT2 pin: no
+ *   0x01  | nomotion: no / Not INT1 pin: no / INT2 pin: yes
+ *   0x02  | nomotion: no / Not INT1 pin: yes / INT2 pin: no
+ *   0x03  | nomotion: no / Not INT1 pin: yes / INT2 pin: yes
+ *   0x04  | nomotion: yes / Not INT1 pin: no / INT2 pin: no
+ *   0x05  | anymotion: yes / Not INT1 pin: no / INT2 pin: yes
+ *   0x06  | anymotion: yes / Not INT1 pin: yes / INT2 pin: no
+ *   0x07  | anymotion: yes / Not INT1 pin: yes / INT2 pin: yes
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_sleep_trigger(
+u8 v_gyro_sleep_trigger_u8);
+/*!
+ *	@brief This API read gyro wakeup trigger
+ *	from the register 0x6C bit 3 and 4
+ *
+ *  @param v_gyro_wakeup_trigger_u8 : The value of gyro wakeup trigger
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | anymotion: no / INT1 pin: no
+ *   0x01  | anymotion: no / INT1 pin: yes
+ *   0x02  | anymotion: yes / INT1 pin: no
+ *   0x03  | anymotion: yes / INT1 pin: yes
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_wakeup_trigger(
+u8 *v_gyro_wakeup_trigger_u8);
+/*!
+ *	@brief This API write gyro wakeup trigger
+ *	from the register 0x6C bit 3 and 4
+ *
+ *  @param v_gyro_wakeup_trigger_u8 : The value of gyro wakeup trigger
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | anymotion: no / INT1 pin: no
+ *   0x01  | anymotion: no / INT1 pin: yes
+ *   0x02  | anymotion: yes / INT1 pin: no
+ *   0x03  | anymotion: yes / INT1 pin: yes
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_wakeup_trigger(
+u8 v_gyro_wakeup_trigger_u8);
+/*!
+ *	@brief This API read Target state for gyro sleep mode
+ *	from the register 0x6C bit 5
+ *
+ *  @param v_gyro_sleep_state_u8 : The value of gyro sleep mode
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | Sleep transition to fast wake up state
+ *   0x01  | Sleep transition to suspend state
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_sleep_state(
+u8 *v_gyro_sleep_state_u8);
+/*!
+ *	@brief This API write Target state for gyro sleep mode
+ *	from the register 0x6C bit 5
+ *
+ *  @param v_gyro_sleep_state_u8 : The value of gyro sleep mode
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | Sleep transition to fast wake up state
+ *   0x01  | Sleep transition to suspend state
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_sleep_state(
+u8 v_gyro_sleep_state_u8);
+/*!
+ *	@brief This API read gyro wakeup interrupt
+ *	from the register 0x6C bit 6
+ *
+ *  @param v_gyro_wakeup_intr_u8 : The valeu of gyro wakeup interrupt
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | DISABLE
+ *   0x01  | ENABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_wakeup_intr(
+u8 *v_gyro_wakeup_intr_u8);
+/*!
+ *	@brief This API write gyro wakeup interrupt
+ *	from the register 0x6C bit 6
+ *
+ *  @param v_gyro_wakeup_intr_u8 : The valeu of gyro wakeup interrupt
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | DISABLE
+ *   0x01  | ENABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_wakeup_intr(
+u8 v_gyro_wakeup_intr_u8);
+/***************************************************/
+/**\name	FUNCTION FOR ACCEL SELF TEST */
+/***************************************************/
+/*!
+ * @brief This API read accel select axis to be self-test
+ *
+ *  @param v_accel_selftest_axis_u8 :
+ *	The value of accel self test axis selection
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | disabled
+ *   0x01  | x-axis
+ *   0x02  | y-axis
+ *   0x03  | z-axis
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_selftest_axis(
+u8 *acc_selftest_axis);
+/*!
+ * @brief This API write accel select axis to be self-test
+ *
+ *  @param v_accel_selftest_axis_u8 :
+ *	The value of accel self test axis selection
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | disabled
+ *   0x01  | x-axis
+ *   0x02  | y-axis
+ *   0x03  | z-axis
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_selftest_axis(
+u8 acc_selftest_axis);
+/*!
+ *	@brief This API read accel self test axis sign
+ *	from the register 0x6D bit 2
+ *
+ *  @param v_accel_selftest_sign_u8: The value of accel self test axis sign
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | negative
+ *   0x01  | positive
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_selftest_sign(
+u8 *acc_selftest_sign);
+/*!
+ *	@brief This API write accel self test axis sign
+ *	from the register 0x6D bit 2
+ *
+ *  @param v_accel_selftest_sign_u8: The value of accel self test axis sign
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | negative
+ *   0x01  | positive
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_selftest_sign(
+u8 acc_selftest_sign);
+/*!
+ *	@brief This API read accel self test amplitude
+ *	from the register 0x6D bit 3
+ *        select amplitude of the selftest deflection:
+ *
+ *  @param v_accel_selftest_amp_u8 : The value of accel self test amplitude
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | LOW
+ *   0x01  | HIGH
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_selftest_amp(
+u8 *acc_selftest_amp);
+/*!
+ *	@brief This API write accel self test amplitude
+ *	from the register 0x6D bit 3
+ *        select amplitude of the selftest deflection:
+ *
+ *  @param v_accel_selftest_amp_u8 : The value of accel self test amplitude
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | LOW
+ *   0x01  | HIGH
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_selftest_amp(
+u8 acc_selftest_amp);
+/***************************************************/
+/**\name	FUNCTION FOR GYRO SELF TEST */
+/***************************************************/
+/*!
+ *	@brief This API read gyro self test trigger
+ *
+ *	@param v_gyro_selftest_start_u8: The value of gyro self test start
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_selftest_start(
+u8 *v_gyro_selftest_start_u8);
+/*!
+ *	@brief This API write gyro self test trigger
+ *
+ *	@param v_gyro_selftest_start_u8: The value of gyro self test start
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_selftest_start(
+u8 v_gyro_selftest_start_u8);
+/***************************************************/
+/**\name	FUNCTION FOR SPI/I2C ENABLE */
+/***************************************************/
+ /*!
+ * @brief This API read primary interface selection I2C or SPI
+ *	from the register 0x70 bit 0
+ *
+ *  @param v_spi_enable_u8: The value of Interface selection
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | I2C Enable
+ *   0x01  | I2C DISBALE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_spi_enable(
+u8 *v_spi_enable_u8);
+ /*!
+ * @brief This API write primary interface selection I2C or SPI
+ *	from the register 0x70 bit 0
+ *
+ *  @param v_spi_enable_u8: The value of Interface selection
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | I2C Enable
+ *   0x01  | I2C DISBALE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_spi_enable(
+u8 v_spi_enable_u8);
+ /*!
+ *	@brief This API read the spare zero
+ *	form register 0x70 bit 3
+ *
+ *
+ *  @param v_spare0_trim_u8: The value of spare zero
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_spare0_trim
+(u8 *v_spare0_trim_u8);
+ /*!
+ *	@brief This API write the spare zero
+ *	form register 0x70 bit 3
+ *
+ *
+ *  @param v_spare0_trim_u8: The value of spare zero
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_spare0_trim
+(u8 v_spare0_trim_u8);
+/***************************************************/
+/**\name	FUNCTION FOR NVM COUNTER */
+/***************************************************/
+ /*!
+ *	@brief This API read the NVM counter
+ *	form register 0x70 bit 4 to 7
+ *
+ *
+ *  @param v_nvm_counter_u8: The value of NVM counter
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_nvm_counter(
+u8 *v_nvm_counter_u8);
+ /*!
+ *	@brief This API write the NVM counter
+ *	form register 0x70 bit 4 to 7
+ *
+ *
+ *  @param v_nvm_counter_u8: The value of NVM counter
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_nvm_counter(
+u8 v_nvm_counter_u8);
+/***************************************************/
+/**\name	FUNCTION FOR ACCEL MANUAL OFFSET COMPENSATION */
+/***************************************************/
+/*!
+ *	@brief This API read accel manual offset compensation of x axis
+ *	from the register 0x71 bit 0 to 7
+ *
+ *
+ *
+ *  @param v_accel_off_x_s8:
+ *	The value of accel manual offset compensation of x axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_offset_compensation_xaxis(
+s8 *v_accel_off_x_s8);
+/*!
+ *	@brief This API write accel manual offset compensation of x axis
+ *	from the register 0x71 bit 0 to 7
+ *
+ *
+ *
+ *  @param v_accel_off_x_s8:
+ *	The value of accel manual offset compensation of x axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_offset_compensation_xaxis(
+s8 v_accel_off_x_s8);
+/*!
+ *	@brief This API read accel manual offset compensation of y axis
+ *	from the register 0x72 bit 0 to 7
+ *
+ *
+ *
+ *  @param v_accel_off_y_s8:
+ *	The value of accel manual offset compensation of y axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_offset_compensation_yaxis(
+s8 *v_accel_off_y_s8);
+/*!
+ *	@brief This API write accel manual offset compensation of y axis
+ *	from the register 0x72 bit 0 to 7
+ *
+ *
+ *
+ *  @param v_accel_off_y_s8:
+ *	The value of accel manual offset compensation of y axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_offset_compensation_yaxis(
+s8 v_accel_off_y_s8);
+/*!
+ *	@brief This API read accel manual offset compensation of z axis
+ *	from the register 0x73 bit 0 to 7
+ *
+ *
+ *
+ *  @param v_accel_off_z_s8:
+ *	The value of accel manual offset compensation of z axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_offset_compensation_zaxis(
+s8 *v_accel_off_z_s8);
+/*!
+ *	@brief This API write accel manual offset compensation of z axis
+ *	from the register 0x73 bit 0 to 7
+ *
+ *
+ *
+ *  @param v_accel_off_z_s8:
+ *	The value of accel manual offset compensation of z axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_offset_compensation_zaxis(
+s8 v_accel_off_z_s8);
+/***************************************************/
+/**\name	FUNCTION FOR GYRO MANUAL OFFSET COMPENSATION */
+/***************************************************/
+/*!
+ *	@brief This API read gyro manual offset compensation of x axis
+ *	from the register 0x74 bit 0 to 7 and 0x77 bit 0 and 1
+ *
+ *
+ *
+ *  @param v_gyro_off_x_s16:
+ *	The value of gyro manual offset compensation of x axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_offset_compensation_xaxis(
+s16 *v_gyro_off_x_s16);
+/*!
+ *	@brief This API write gyro manual offset compensation of x axis
+ *	from the register 0x74 bit 0 to 7 and 0x77 bit 0 and 1
+ *
+ *
+ *
+ *  @param v_gyro_off_x_s16:
+ *	The value of gyro manual offset compensation of x axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_offset_compensation_xaxis(
+s16 v_gyro_off_x_s16);
+/*!
+ *	@brief This API read gyro manual offset compensation of y axis
+ *	from the register 0x75 bit 0 to 7 and 0x77 bit 2 and 3
+ *
+ *
+ *
+ *  @param v_gyro_off_y_s16:
+ *	The value of gyro manual offset compensation of y axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_offset_compensation_yaxis(
+s16 *v_gyro_off_y_s16);
+/*!
+ *	@brief This API write gyro manual offset compensation of y axis
+ *	from the register 0x75 bit 0 to 7 and 0x77 bit 2 and 3
+ *
+ *
+ *
+ *  @param v_gyro_off_y_s16:
+ *	The value of gyro manual offset compensation of y axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_offset_compensation_yaxis(
+s16 v_gyro_off_y_s16);
+/*!
+ *	@brief This API read gyro manual offset compensation of z axis
+ *	from the register 0x76 bit 0 to 7 and 0x77 bit 4 and 5
+ *
+ *
+ *
+ *  @param v_gyro_off_z_s16:
+ *	The value of gyro manual offset compensation of z axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_offset_compensation_zaxis(
+s16 *v_gyro_off_z_s16);
+/*!
+ *	@brief This API write gyro manual offset compensation of z axis
+ *	from the register 0x76 bit 0 to 7 and 0x77 bit 4 and 5
+ *
+ *
+ *
+ *  @param v_gyro_off_z_s16:
+ *	The value of gyro manual offset compensation of z axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_offset_compensation_zaxis(
+s16 v_gyro_off_z_s16);
+/*!
+ *	@brief This API writes accel fast offset compensation
+ *	from the register 0x69 bit 0 to 5
+ *	@brief This API writes each axis individually
+ *	FOC_X_AXIS - bit 4 and 5
+ *	FOC_Y_AXIS - bit 2 and 3
+ *	FOC_Z_AXIS - bit 0 and 1
+ *
+ *  @param  v_foc_accel_u8: The value of accel offset compensation
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *  @param  v_axis_u8: The value of accel offset axis selection
+  *	value    | axis
+ * ----------|-------------------
+ *  0        | FOC_X_AXIS
+ *  1        | FOC_Y_AXIS
+ *  2        | FOC_Z_AXIS
+ *
+ *	@param v_accel_offset_s8: The accel offset value
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_foc_trigger(u8 axis,
+u8 foc_acc, s8 *accel_offset);
+/*!
+ *	@brief This API write fast accel offset compensation
+ *	it writes all axis together.To the register 0x69 bit 0 to 5
+ *	FOC_X_AXIS - bit 4 and 5
+ *	FOC_Y_AXIS - bit 2 and 3
+ *	FOC_Z_AXIS - bit 0 and 1
+ *
+ *  @param  v_foc_accel_x_u8: The value of accel offset x compensation
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *  @param  v_foc_accel_y_u8: The value of accel offset y compensation
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *  @param  v_foc_accel_z_u8: The value of accel offset z compensation
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *  @param  v_accel_off_x_s8: The value of accel offset x axis
+ *  @param  v_accel_off_y_s8: The value of accel offset y axis
+ *  @param  v_accel_off_z_s8: The value of accel offset z axis
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_accel_foc_trigger_xyz(u8 v_foc_accel_x_u8,
+u8 v_foc_accel_y_u8, u8 v_foc_accel_z_u8,
+s8 *acc_off_x, s8 *acc_off_y, s8 *acc_off_z);
+/***************************************************/
+/**\name	FUNCTION FOR ACEL AND GYRO OFFSET ENABLE */
+/***************************************************/
+/*!
+ *	@brief This API read the accel offset enable bit
+ *	from the register 0x77 bit 6
+ *
+ *
+ *
+ *  @param v_accel_off_enable_u8: The value of accel offset enable
+ *  value    |  Description
+ * ----------|--------------
+ *   0x01    | ENABLE
+ *   0x00    | DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_offset_enable(
+u8 *acc_off_en);
+/*!
+ *	@brief This API write the accel offset enable bit
+ *	from the register 0x77 bit 6
+ *
+ *
+ *
+ *  @param v_accel_off_enable_u8: The value of accel offset enable
+ *  value    |  Description
+ * ----------|--------------
+ *   0x01    | ENABLE
+ *   0x00    | DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_offset_enable(
+u8 acc_off_en);
+/*!
+ *	@brief This API read the accel offset enable bit
+ *	from the register 0x77 bit 7
+ *
+ *
+ *
+ *  @param v_gyro_off_enable_u8: The value of gyro offset enable
+ *  value    |  Description
+ * ----------|--------------
+ *   0x01    | ENABLE
+ *   0x00    | DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_offset_enable(
+u8 *v_gyro_off_enable_u8);
+/*!
+ *	@brief This API write the accel offset enable bit
+ *	from the register 0x77 bit 7
+ *
+ *
+ *
+ *  @param v_gyro_off_enable_u8: The value of gyro offset enable
+ *  value    |  Description
+ * ----------|--------------
+ *   0x01    | ENABLE
+ *   0x00    | DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_offset_enable(
+u8 v_gyro_off_enable_u8);
+/***************************************************/
+/**\name	FUNCTION FOR STEP COUNTER INTERRUPT */
+/***************************************************/
+/*!
+ *	@brief This API reads step counter value
+ *	form the register 0x78 and 0x79
+ *
+ *
+ *
+ *
+ *  @param v_step_cnt_s16 : The value of step counter
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_step_count(u16 *v_step_cnt_s16);
+ /*!
+ *	@brief This API Reads
+ *	step counter configuration
+ *	from the register 0x7A bit 0 to 7
+ *	and from the register 0x7B bit 0 to 2 and 4 to 7
+ *
+ *
+ *  @param v_step_config_u16 : The value of step configuration
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_step_config(
+u16 *v_step_config_u16);
+ /*!
+ *	@brief This API write
+ *	step counter configuration
+ *	from the register 0x7A bit 0 to 7
+ *	and from the register 0x7B bit 0 to 2 and 4 to 7
+ *
+ *
+ *  @param v_step_config_u16   :
+ *	the value of  Enable step configuration
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_step_config(
+u16 v_step_config_u16);
+ /*!
+ *	@brief This API read enable step counter
+ *	from the register 0x7B bit 3
+ *
+ *
+ *  @param v_step_counter_u8 : The value of step counter enable
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_step_counter_enable(
+u8 *v_step_counter_u8);
+ /*!
+ *	@brief This API write enable step counter
+ *	from the register 0x7B bit 3
+ *
+ *
+ *  @param v_step_counter_u8 : The value of step counter enable
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_step_counter_enable(
+u8 v_step_counter_u8);
+ /*!
+ *	@brief This API set Step counter modes
+ *
+ *
+ *  @param  v_step_mode_u8 : The value of step counter mode
+ *  value    |   mode
+ * ----------|-----------
+ *   0       | BMI160_STEP_NORMAL_MODE
+ *   1       | BMI160_STEP_SENSITIVE_MODE
+ *   2       | BMI160_STEP_ROBUST_MODE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_step_mode(u8 v_step_mode_u8);
+/*!
+ *	@brief This API used to trigger the  signification motion
+ *	interrupt
+ *
+ *
+ *  @param  v_significant_u8 : The value of interrupt selection
+ *  value    |  interrupt
+ * ----------|-----------
+ *   0       |  BMI160_MAP_INTR1
+ *   1       |  BMI160_MAP_INTR2
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_map_significant_motion_intr(
+u8 v_significant_u8);
+/*!
+ *	@brief This API used to trigger the step detector
+ *	interrupt
+ *
+ *
+ *  @param  v_step_detector_u8 : The value of interrupt selection
+ *  value    |  interrupt
+ * ----------|-----------
+ *   0       |  BMI160_MAP_INTR1
+ *   1       |  BMI160_MAP_INTR2
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_map_step_detector_intr(
+u8 v_step_detector_u8);
+ /*!
+ *	@brief This API used to clear the step counter interrupt
+ *	interrupt
+ *
+ *
+ *  @param  : None
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_clear_step_counter(void);
+/***************************************************/
+/**\name	FUNCTION FOR STEP COMMAND REGISTER WRITE */
+/***************************************************/
+ /*!
+ *	@brief This API writes value to the register 0x7E bit 0 to 7
+ *
+ *
+ *  @param  v_command_reg_u8 : The value to write command register
+ *  value   |  Description
+ * ---------|--------------------------------------------------------
+ *	0x00	|	Reserved
+ *  0x03	|	Starts fast offset calibration for the accel and gyro
+ *	0x10	|	Sets the PMU mode for the Accelerometer to suspend
+ *	0x11	|	Sets the PMU mode for the Accelerometer to normal
+ *	0x12	|	Sets the PMU mode for the Accelerometer Lowpower
+ *  0x14	|	Sets the PMU mode for the Gyroscope to suspend
+ *	0x15	|	Sets the PMU mode for the Gyroscope to normal
+ *	0x16	|	Reserved
+ *	0x17	|	Sets the PMU mode for the Gyroscope to fast start-up
+ *  0x18	|	Sets the PMU mode for the Magnetometer to suspend
+ *	0x19	|	Sets the PMU mode for the Magnetometer to normal
+ *	0x1A	|	Sets the PMU mode for the Magnetometer to Lowpower
+ *	0xB0	|	Clears all data in the FIFO
+ *  0xB1	|	Resets the interrupt engine
+ *	0xB2	|	step_cnt_clr Clears the step counter
+ *	0xB6	|	Triggers a reset
+ *	0x37	|	See extmode_en_last
+ *	0x9A	|	See extmode_en_last
+ *	0xC0	|	Enable the extended mode
+ *  0xC4	|	Erase NVM cell
+ *	0xC8	|	Load NVM cell
+ *	0xF0	|	Reset acceleration data path
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_command_register(
+u8 v_command_reg_u8);
+/***************************************************/
+/**\name	FUNCTION FOR PAGE ENABLE */
+/***************************************************/
+ /*!
+ *	@brief This API read target page from the register 0x7F bit 4 and 5
+ *
+ *  @param v_target_page_u8: The value of target page
+ *  value   |  page
+ * ---------|-----------
+ *   0      |  User data/configure page
+ *   1      |  Chip level trim/test page
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_target_page(
+u8 *v_target_page_u8);
+ /*!
+ *	@brief This API write target page from the register 0x7F bit 4 and 5
+ *
+ *  @param v_target_page_u8: The value of target page
+ *  value   |  page
+ * ---------|-----------
+ *   0      |  User data/configure page
+ *   1      |  Chip level trim/test page
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_target_page(
+u8 v_target_page_u8);
+ /*!
+ *	@brief This API read page enable from the register 0x7F bit 7
+ *
+ *
+ *
+ *  @param v_page_enable_u8: The value of page enable
+ *  value   |  page
+ * ---------|-----------
+ *   0      |  DISABLE
+ *   1      |  ENABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_paging_enable(
+u8 *v_page_enable_u8);
+ /*!
+ *	@brief This API write page enable from the register 0x7F bit 7
+ *
+ *
+ *
+ *  @param v_page_enable_u8: The value of page enable
+ *  value   |  page
+ * ---------|-----------
+ *   0      |  DISABLE
+ *   1      |  ENABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_paging_enable(
+u8 v_page_enable_u8);
+ /*!
+ *	@brief This API read
+ *	pull up configuration from the register 0X85 bit 4 an 5
+ *
+ *
+ *
+ *  @param v_control_pullup_u8: The value of pull up register
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_pullup_configuration(
+u8 *v_control_pullup_u8);
+ /*!
+ *	@brief This API write
+ *	pull up configuration from the register 0X85 bit 4 an 5
+ *
+ *
+ *
+ *  @param v_control_pullup_u8: The value of pull up register
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_pullup_configuration(
+u8 v_control_pullup_u8);
+/***************************************************/
+/**\name	FUNCTION FOR BMM150 */
+/***************************************************/
+ /*!
+ *	@brief This function used for initialize the bmm150 sensor
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_bmm150_mag_interface_init(void);
+ /*!
+ *	@brief This function used for set the mag power control
+ *	bit enable
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_bmm150_mag_wakeup(void);
+ /*!
+ *	@brief This function used for read the trim values of magnetometer
+ *
+ *	@note
+ *	Before reading the mag trimming values
+ *	make sure the following two points are addressed
+ *	@note
+ *	1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note
+ *	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_bmm150_mag_trim(void);
+ /*!
+ *	@brief This function used for read the compensated value of mag
+ *	Before start reading the mag compensated data's
+ *	make sure the following two points are addressed
+ *	@note
+ *	1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note
+ *	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_bmm150_mag_compensate_xyz(
+struct bmi160_mag_xyz_s32_t *mag_comp_xyz);
+BMI160_RETURN_FUNCTION_TYPE bmi160_bmm150_mag_compensate_xyz_raw(
+struct bmi160_mag_xyz_s32_t *mag_comp_xyz, struct bmi160_mag_xyzr_t mag_xyzr);
+
+/*!
+ *	@brief This API used to get the compensated BMM150-X data
+ *	the out put of X as s32
+ *	Before start reading the mag compensated X data
+ *	make sure the following two points are addressed
+ *	@note
+ *	1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note
+ *	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+ *
+ *
+ *
+ *  @param  v_mag_data_x_s16 : The value of mag raw X data
+ *  @param  v_data_r_u16 : The value of mag R data
+ *
+ *	@return results of compensated X data value output as s32
+ *
+ */
+s32 bmi160_bmm150_mag_compensate_X(s16 v_mag_data_x_s16, u16 v_data_r_u16);
+/*!
+ *	@brief This API used to get the compensated BMM150-Y data
+ *	the out put of Y as s32
+ *	Before start reading the mag compensated Y data
+ *	make sure the following two points are addressed
+ *	@note
+ *	1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note
+ *	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+ *
+ *
+ *
+ *  @param  v_mag_data_y_s16 : The value of mag raw Y data
+ *  @param  v_data_r_u16 : The value of mag R data
+ *
+ *	@return results of compensated Y data value output as s32
+ */
+s32 bmi160_bmm150_mag_compensate_Y(s16 v_mag_data_y_s16, u16 v_data_r_u16);
+/*!
+ *	@brief This API used to get the compensated BMM150-Z data
+ *	the out put of Z as s32
+ *	Before start reading the mag compensated Z data
+ *	make sure the following two points are addressed
+ *	@note
+ *	1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note
+ *	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+ *
+ *
+ *
+ *  @param  v_mag_data_z_s16 : The value of mag raw Z data
+ *  @param  v_data_r_u16 : The value of mag R data
+ *
+ *	@return results of compensated Z data value output as s32
+ */
+s32 bmi160_bmm150_mag_compensate_Z(s16 v_mag_data_z_s16, u16 v_data_r_u16);
+/*!
+ *	@brief This API used to set the pre-set modes of bmm150
+ *	The pre-set mode setting is depend on data rate and xy and z repetitions
+ *
+ *	@note
+ *	Before set the mag preset mode
+ *	make sure the following two points are addressed
+ *	@note
+ *	1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note
+ *	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+ *
+ *
+ *  @param  v_mode_u8: The value of pre-set mode selection value
+ *  value    |  pre_set mode
+ * ----------|------------
+ *   1       | BMI160_MAG_PRESETMODE_LOWPOWER
+ *   2       | BMI160_MAG_PRESETMODE_REGULAR
+ *   3       | BMI160_MAG_PRESETMODE_HIGHACCURACY
+ *   4       | BMI160_MAG_PRESETMODE_ENHANCED
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_bmm150_mag_presetmode(u8 mode);
+/*!
+ *	@brief This function used for set the magnetometer
+ *	power mode.
+ *	@note
+ *	Before set the mag power mode
+ *	make sure the following two points are addressed
+ *	@note
+ *	1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note
+ *	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+ *
+ *	@param v_mag_pow_mode_u8 : The value of mag power mode
+ *  value    |  mode
+ * ----------|------------
+ *   0       | FORCE_MODE
+ *   1       | SUSPEND_MODE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_bmm150_mag_set_power_mode(u8 mag_pow_mode);
+ /*!
+ *	@brief This function used for set the magnetometer
+ *	power mode.
+ *	@note
+ *	Before set the mag power mode
+ *	make sure the following two point is addressed
+ *		Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *
+ *	@param v_mag_sec_if_pow_mode_u8 : The value of mag power mode
+ *  value    |  mode
+ * ----------|------------
+ *   0       | BMI160_MAG_FORCE_MODE
+ *   1       | BMI160_MAG_SUSPEND_MODE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_bmm150_mag_and_secondary_if_power_mode(
+u8 v_mag_sec_if_pow_mode_u8);
+/***************************************************/
+/**\name	FUNCTIONS FOR AKM09911 AND AKM09912*/
+/***************************************************/
+ /*!
+ *	@brief This function used for initialize
+ *	the AKM09911 and AKM09912 sensor
+ *
+ *
+ *	@param v_akm_i2c_address_u8: The value of device address
+ *	AKM sensor   |  Slave address
+ * --------------|---------------------
+ *  AKM09911     |  AKM09911_I2C_ADDR_1
+ *     -         |  and AKM09911_I2C_ADDR_2
+ *  AKM09912     |  AKM09912_I2C_ADDR_1
+ *     -         |  AKM09912_I2C_ADDR_2
+ *     -         |  AKM09912_I2C_ADDR_3
+ *     -         |  AKM09912_I2C_ADDR_4
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_akm_mag_interface_init(
+u8 v_akm_i2c_address_u8);
+ /*!
+ *	@brief This function used for read the sensitivity data of
+ *	AKM09911 and AKM09912
+ *
+ *	@note Before reading the mag sensitivity values
+ *	make sure the following two points are addressed
+ *	@note	1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_bst_akm_sensitivity_data(void);
+/*!
+ *	@brief This API used to get the compensated X data
+ *	of AKM09911 the out put of X as s32
+ *	@note	Before start reading the mag compensated X data
+ *			make sure the following two points are addressed
+ *	@note 1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note 2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+ *
+ *
+ *  @param v_bst_akm_x_s16 : The value of X data
+ *
+ *	@return results of compensated X data value output as s32
+ *
+ */
+s32 bmi160_bst_akm09911_compensate_X(s16 v_bst_akm_x_s16);
+/*!
+ *	@brief This API used to get the compensated Y data
+ *	of AKM09911 the out put of Y as s32
+ *	@note	Before start reading the mag compensated Y data
+ *			make sure the following two points are addressed
+ *	@note 1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note 2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+ *
+ *
+ *  @param v_bst_akm_y_s16 : The value of Y data
+ *
+ *	@return results of compensated Y data value output as s32
+ *
+ */
+s32 bmi160_bst_akm09911_compensate_Y(s16 v_bst_akm_y_s16);
+/*!
+ *	@brief This API used to get the compensated Z data
+ *	of AKM09911 the out put of Z as s32
+ *	@note	Before start reading the mag compensated Z data
+ *			make sure the following two points are addressed
+ *	@note 1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note 2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+ *
+ *
+ *  @param v_bst_akm_z_s16 : The value of Z data
+ *
+ *	@return results of compensated Z data value output as s32
+ *
+ */
+s32 bmi160_bst_akm09911_compensate_Z(s16 v_bst_akm_z_s16);
+/*!
+ *	@brief This API used to get the compensated X data
+ *	of AKM09912 the out put of X as s32
+ *	@note	Before start reading the mag compensated X data
+ *			make sure the following two points are addressed
+ *	@note 1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note 2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+ *
+ *
+ *  @param v_bst_akm_x_s16 : The value of X data
+ *
+ *	@return results of compensated X data value output as s32
+ *
+ */
+s32 bmi160_bst_akm09912_compensate_X(s16 v_bst_akm_x_s16);
+/*!
+ *	@brief This API used to get the compensated Y data
+ *	of AKM09912 the out put of Y as s32
+ *	@note	Before start reading the mag compensated Y data
+ *			make sure the following two points are addressed
+ *	@note 1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note 2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+ *
+ *
+ *  @param v_bst_akm_y_s16 : The value of Y data
+ *
+ *	@return results of compensated Y data value output as s32
+ *
+ */
+s32 bmi160_bst_akm09912_compensate_Y(s16 v_bst_akm_y_s16);
+/*!
+ *	@brief This API used to get the compensated Z data
+ *	of AKM09912 the out put of Z as s32
+ *	@note	Before start reading the mag compensated Z data
+ *			make sure the following two points are addressed
+ *	@note 1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note 2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+ *
+ *
+ *  @param v_bst_akm_z_s16 : The value of Z data
+ *
+ *	@return results of compensated Z data value output as s32
+ *
+ */
+s32 bmi160_bst_akm09912_compensate_Z(s16 v_bst_akm_z_s16);
+ /*!
+ *	@brief This function used for read the compensated value of
+ *	AKM09911
+ *	@note Before start reading the mag compensated data's
+ *	make sure the following two points are addressed
+ *	@note	1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_akm09911_compensate_xyz(
+struct bmi160_mag_xyz_s32_t *bst_akm_xyz);
+ /*!
+ *	@brief This function used for read the compensated value of
+ *	AKM09912
+ *	@note Before start reading the mag compensated data's
+ *	make sure the following two points are addressed
+ *	@note	1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_akm09912_compensate_xyz(
+struct bmi160_mag_xyz_s32_t *bst_akm_xyz);
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_akm09912_compensate_xyz_raw(
+struct bmi160_mag_xyz_s32_t *bst_akm_xyz);
+/*!
+ *	@brief This function used for set the AKM09911 and AKM09912
+ *	power mode.
+ *	@note Before set the AKM power mode
+ *	make sure the following two points are addressed
+ *	@note	1.	Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *	@note	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function bmi160_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		bmi160_set_command_register(0x19) function.
+ *
+ *	@param v_akm_pow_mode_u8 : The value of akm power mode
+ *  value   |    Description
+ * ---------|--------------------
+ *    0     |  AKM_POWER_DOWN_MODE
+ *    1     |  AKM_SINGLE_MEAS_MODE
+ *    2     |  FUSE_ROM_MODE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_akm_set_powermode(u8 v_akm_pow_mode_u8);
+ /*!
+ *	@brief This function used for set the magnetometer
+ *	power mode of AKM09911 and AKM09912
+ *	@note Before set the mag power mode
+ *	make sure the following two point is addressed
+ *		Make sure the mag interface is enabled or not,
+ *		by using the bmi160_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function bmi160_get_if_mode(0x02)
+ *
+ *	@param v_mag_sec_if_pow_mode_u8 : The value of secondary if power mode
+ *  value   |    Description
+ * ---------|--------------------
+ *    0     |  BMI160_MAG_FORCE_MODE
+ *    1     |  BMI160_MAG_SUSPEND_MODE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_bst_akm_and_secondary_if_powermode(
+u8 v_mag_sec_if_pow_mode_u8);
+/***************************************************/
+/**\name	FUNCTIONS FOR YAMAH-YAS532 */
+/***************************************************/
+/*!
+ *	@brief This function used for read the YAMAH-YAS532 init
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas532_mag_interface_init(
+void);
+/*!
+ *	@brief This function used to set the YAS532 initial values
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_set_initial_values(void);
+/*!
+ *	@brief This function used for YAS532 offset correction
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_magnetic_measure_set_offset(
+void);
+/*!
+ *	@brief This function used for read the
+ *	YAMAHA YAS532 calibration data
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas532_calib_values(void);
+/*!
+ *	@brief This function used for calculate the
+ *	YAS532 read the linear data
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_xy1y2_to_linear(
+u16 *v_xy1y2_u16, s32 *xy1y2_linear);
+/*!
+ *	@brief This function used for read the YAS532 sensor data
+ *	@param	v_acquisition_command_u8: used to set the data acquisition
+ *	acquisition_command  |   operation
+ *  ---------------------|-------------------------
+ *         0x17          | turn on the acquisition coil
+ *         -             | set direction of the coil
+ *         _             | (x and y as minus(-))
+ *         _             | Deferred acquisition mode
+ *        0x07           | turn on the acquisition coil
+ *         _             | set direction of the coil
+ *         _             | (x and y as minus(-))
+ *         _             | Normal acquisition mode
+ *        0x11           | turn OFF the acquisition coil
+ *         _             | set direction of the coil
+ *         _             | (x and y as plus(+))
+ *         _             | Deferred acquisition mode
+ *       0x01            | turn OFF the acquisition coil
+ *        _              | set direction of the coil
+ *        _              | (x and y as plus(+))
+ *        _              | Normal acquisition mode
+ *
+ *	@param	v_busy_u8 : used to get the busy flay for sensor data read
+ *	@param	v_temp_u16 : used to get the temperature data
+ *	@param	v_xy1y2_u16 : used to get the sensor xy1y2 data
+ *	@param	v_overflow_u8 : used to get the overflow data
+ *
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_normal_measurement_data(
+u8 v_acquisition_command_u8, u8 *v_busy_u8,
+u16 *v_temp_u16, u16 *v_xy1y2_u16, u8 *v_overflow_u8);
+/*!
+ *	@brief This function used for YAS532 sensor data
+ *	@param	v_acquisition_command_u8	:	the value of CMDR
+ *	acquisition_command  |   operation
+ *  ---------------------|-------------------------
+ *         0x17          | turn on the acquisition coil
+ *         -             | set direction of the coil
+ *         _             | (x and y as minus(-))
+ *         _             | Deferred acquisition mode
+ *        0x07           | turn on the acquisition coil
+ *         _             | set direction of the coil
+ *         _             | (x and y as minus(-))
+ *         _             | Normal acquisition mode
+ *        0x11           | turn OFF the acquisition coil
+ *         _             | set direction of the coil
+ *         _             | (x and y as plus(+))
+ *         _             | Deferred acquisition mode
+ *       0x01            | turn OFF the acquisition coil
+ *        _              | set direction of the coil
+ *        _              | (x and y as plus(+))
+ *        _              | Normal acquisition mode
+ *
+ * @param xyz_data : the vector xyz output
+ * @param v_overflow_s8 : the value of overflow
+ * @param v_temp_correction_u8 : the value of temperate correction enable
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_measurement_xyz_data(
+struct yas532_vector *xyz_data, u8 *v_overflow_s8, u8 v_temp_correction_u8,
+u8 v_acquisition_command_u8);
+/*!
+ *	@brief This function used for YAS532 write data acquisition
+ *	command register write
+ *	@param	v_command_reg_data_u8	:	the value of data acquisition
+ *	acquisition_command  |   operation
+ *  ---------------------|-------------------------
+ *         0x17          | turn on the acquisition coil
+ *         -             | set direction of the coil
+ *         _             | (x and y as minus(-))
+ *         _             | Deferred acquisition mode
+ *        0x07           | turn on the acquisition coil
+ *         _             | set direction of the coil
+ *         _             | (x and y as minus(-))
+ *         _             | Normal acquisition mode
+ *        0x11           | turn OFF the acquisition coil
+ *         _             | set direction of the coil
+ *         _             | (x and y as plus(+))
+ *         _             | Deferred acquisition mode
+ *       0x01            | turn OFF the acquisition coil
+ *        _              | set direction of the coil
+ *        _              | (x and y as plus(+))
+ *        _              | Normal acquisition mode
+ *
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_acquisition_command_register(
+u8 v_command_reg_data_u8);
+/*!
+ *	@brief This function used write offset of YAS532
+ *
+ *	@param	p_offset_s8	: The value of offset to write
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_set_offset(
+const s8 *p_offset_s8);
+/*!
+ *	@brief This function used to init the YAMAH-YAS537
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas537_mag_interface_init(
+void);
+/*!
+ *	@brief This function used for read the
+ *	YAMAHA YAS537 calibration data
+ *
+ *
+ *	@param v_rcoil_u8 : The value of r coil
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas537_calib_values(
+u8 v_rcoil_u8);
+/*!
+ *	@brief This function used for YAS537 write data acquisition
+ *	command register write
+ *	@param	v_command_reg_data_u8	:	the value of data acquisition
+ *	acquisition_command  |   operation
+ *  ---------------------|-------------------------
+ *         0x17          | turn on the acquisition coil
+ *         -             | set direction of the coil
+ *         _             | (x and y as minus(-))
+ *         _             | Deferred acquisition mode
+ *        0x07           | turn on the acquisition coil
+ *         _             | set direction of the coil
+ *         _             | (x and y as minus(-))
+ *         _             | Normal acquisition mode
+ *        0x11           | turn OFF the acquisition coil
+ *         _             | set direction of the coil
+ *         _             | (x and y as plus(+))
+ *         _             | Deferred acquisition mode
+ *       0x01            | turn OFF the acquisition coil
+ *        _              | set direction of the coil
+ *        _              | (x and y as plus(+))
+ *        _              | Normal acquisition mode
+ *
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas537_acquisition_command_register(
+u8 v_command_reg_data_u8);
+
+/*!
+ *	@brief This function used for read the
+ *	YAMAHA YAS537 xy1y2 data
+ *
+ *	@param v_coil_stat_u8: The value of R coil status
+ *	@param v_busy_u8: The value of busy status
+ *	@param v_temperature_u16: The value of temperature
+ *	@param xy1y2: The value of raw xy1y2 data
+ *	@param v_ouflow_u8: The value of overflow
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas537_read_xy1y2_data(
+u8 *v_coil_stat_u8, u8 *v_busy_u8,
+u16 *v_temperature_u16, u16 *xy1y2, u8 *v_ouflow_u8);
+/*!
+ *	@brief This function used for read the
+ *	YAMAHA YAS537 xy1y2 data
+ *
+ *	@param v_ouflow_u8: The value of overflow
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas537_measure_xyz_data(
+u8 *v_ouflow_u8, struct yas_vector *vector_xyz);
+
+/***************************************************/
+/**\name	FUNCTIONS FOR FIFO DATA READ */
+/***************************************************/
+/*!
+ *	@brief This function used for reading the
+ *	fifo data of  header less mode
+ *
+ *
+ *
+ *	@note Configure the below functions for FIFO header less mode
+ *	@note 1. bmi160_set_fifo_down_gyro
+ *	@note 2. bmi160_set_gyro_fifo_filter_data
+ *	@note 3. bmi160_set_fifo_down_accel
+ *	@note 4. bmi160_set_accel_fifo_filter_dat
+ *	@note 5. bmi160_set_fifo_mag_enable
+ *	@note 6. bmi160_set_fifo_accel_enable
+ *	@note 7. bmi160_set_fifo_gyro_enable
+ *	@note For interrupt configuration
+ *	@note 1. bmi160_set_intr_fifo_full
+ *	@note 2. bmi160_set_intr_fifo_wm
+ *	@note 3. bmi160_set_fifo_tag_intr2_enable
+ *	@note 4. bmi160_set_fifo_tag_intr1_enable
+ *
+ *	@note The fifo reads the whole 1024 bytes
+ *	and processing the data
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_fifo_headerless_mode(
+void);
+/*!
+ *	@brief This function used for reading the
+ *	fifo data of  header less mode for using user defined length
+ *
+ *
+ *	@param v_fifo_user_length_u16: The value of length of fifo read data
+ *
+ *	@note Configure the below functions for FIFO header less mode
+ *	@note 1. bmi160_set_fifo_down_gyro
+ *	@note 2. bmi160_set_gyro_fifo_filter_data
+ *	@note 3. bmi160_set_fifo_down_accel
+ *	@note 4. bmi160_set_accel_fifo_filter_dat
+ *	@note 5. bmi160_set_fifo_mag_enable
+ *	@note 6. bmi160_set_fifo_accel_enable
+ *	@note 7. bmi160_set_fifo_gyro_enable
+ *	@note For interrupt configuration
+ *	@note 1. bmi160_set_intr_fifo_full
+ *	@note 2. bmi160_set_intr_fifo_wm
+ *	@note 3. bmi160_set_fifo_tag_intr2_enable
+ *	@note 4. bmi160_set_fifo_tag_intr1_enable
+ *
+ *	@note The fifo reads the whole 1024 bytes
+ *	and processing the data
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE
+bmi160_read_fifo_headerless_mode_user_defined_length(
+u16 v_fifo_user_length_u16);
+/*!
+ *	@brief This function used for reading the
+ *	fifo data of  header mode
+ *
+ *
+ *	@note Configure the below functions for FIFO header mode
+ *	@note 1. bmi160_set_fifo_down_gyro()
+ *	@note 2. bmi160_set_gyro_fifo_filter_data()
+ *	@note 3. bmi160_set_fifo_down_accel()
+ *	@note 4. bmi160_set_accel_fifo_filter_dat()
+ *	@note 5. bmi160_set_fifo_mag_enable()
+ *	@note 6. bmi160_set_fifo_accel_enable()
+ *	@note 7. bmi160_set_fifo_gyro_enable()
+ *	@note 8. bmi160_set_fifo_header_enable()
+ *	@note For interrupt configuration
+ *	@note 1. bmi160_set_intr_fifo_full()
+ *	@note 2. bmi160_set_intr_fifo_wm()
+ *	@note 3. bmi160_set_fifo_tag_intr2_enable()
+ *	@note 4. bmi160_set_fifo_tag_intr1_enable()
+ *
+ *	@note The fifo reads the whole 1024 bytes
+ *	and processing the data
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_fifo_header_data(
+void);
+/*!
+ *	@brief This function used for reading the
+ *	fifo data of  header mode for using user defined length
+ *
+ *
+ *	@note Configure the below functions for FIFO header mode
+ *	@note 1. bmi160_set_fifo_down_gyro()
+ *	@note 2. bmi160_set_gyro_fifo_filter_data()
+ *	@note 3. bmi160_set_fifo_down_accel()
+ *	@note 4. bmi160_set_accel_fifo_filter_dat()
+ *	@note 5. bmi160_set_fifo_mag_enable()
+ *	@note 6. bmi160_set_fifo_accel_enable()
+ *	@note 7. bmi160_set_fifo_gyro_enable()
+ *	@note 8. bmi160_set_fifo_header_enable()
+ *	@note For interrupt configuration
+ *	@note 1. bmi160_set_intr_fifo_full()
+ *	@note 2. bmi160_set_intr_fifo_wm()
+ *	@note 3. bmi160_set_fifo_tag_intr2_enable()
+ *	@note 4. bmi160_set_fifo_tag_intr1_enable()
+ *
+ *	@note The fifo reads the whole 1024 bytes
+ *	and processing the data
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_fifo_header_data_user_defined_length(
+u16 v_fifo_user_length_u16);
+/*!
+ *	@brief This function used for reading
+ *	bmi160_t structure
+ *
+ *  @return the reference and values of bmi160_t
+ *
+ *
+*/
+struct bmi160_t *bmi160_get_ptr(void);
+
+#endif
+
diff --git a/drivers/input/sensors/bmi160/bmi160_driver.c b/drivers/input/sensors/bmi160/bmi160_driver.c
new file mode 100644
index 0000000..66d2248
--- /dev/null
+++ b/drivers/input/sensors/bmi160/bmi160_driver.c
@@ -0,0 +1,4021 @@
+/*!
+ * @section LICENSE
+ * (C) Copyright 2011~2016 Bosch Sensortec GmbH All Rights Reserved
+ *
+ * This software program is licensed subject to the GNU General
+ * Public License (GPL).Version 2,June 1991,
+ * available at http://www.fsf.org/copyleft/gpl.html
+ *
+ * @filename bmi160_driver.c
+ * @date     2016/08/01 14:40
+ * @id       "b5ff23a"
+ * @version  1.3
+ *
+ * @brief
+ * The core code of BMI160 device driver
+ *
+ * @detail
+ * This file implements the core code of BMI160 device driver,
+ * which includes hardware related functions, input device register,
+ * device attribute files, etc.
+*/
+
+#include "bmi160.h"
+#include "bmi160_driver.h"
+#include <linux/device.h>
+#include <linux/gpio.h>
+#include <linux/of_gpio.h>
+#include <linux/of_irq.h>
+
+
+#define DRIVER_VERSION "0.0.53.0"
+#define I2C_BURST_READ_MAX_LEN      (256)
+#define BMI160_STORE_COUNT  (6000)
+#define LMADA     (1)
+uint64_t g_current_apts_us;
+
+
+enum BMI_SENSOR_INT_T {
+	/* Interrupt enable0*/
+	BMI_ANYMO_X_INT = 0,
+	BMI_ANYMO_Y_INT,
+	BMI_ANYMO_Z_INT,
+	BMI_D_TAP_INT,
+	BMI_S_TAP_INT,
+	BMI_ORIENT_INT,
+	BMI_FLAT_INT,
+	/* Interrupt enable1*/
+	BMI_HIGH_X_INT,
+	BMI_HIGH_Y_INT,
+	BMI_HIGH_Z_INT,
+	BMI_LOW_INT,
+	BMI_DRDY_INT,
+	BMI_FFULL_INT,
+	BMI_FWM_INT,
+	/* Interrupt enable2 */
+	BMI_NOMOTION_X_INT,
+	BMI_NOMOTION_Y_INT,
+	BMI_NOMOTION_Z_INT,
+	BMI_STEP_DETECTOR_INT,
+	INT_TYPE_MAX
+};
+
+/*bmi fifo sensor type combination*/
+enum BMI_SENSOR_FIFO_COMBINATION {
+	BMI_FIFO_A = 0,
+	BMI_FIFO_G,
+	BMI_FIFO_M,
+	BMI_FIFO_G_A,
+	BMI_FIFO_M_A,
+	BMI_FIFO_M_G,
+	BMI_FIFO_M_G_A,
+	BMI_FIFO_COM_MAX
+};
+
+/*bmi fifo analyse return err status*/
+enum BMI_FIFO_ANALYSE_RETURN_T {
+	FIFO_OVER_READ_RETURN = -10,
+	FIFO_SENSORTIME_RETURN = -9,
+	FIFO_SKIP_OVER_LEN = -8,
+	FIFO_M_G_A_OVER_LEN = -7,
+	FIFO_M_G_OVER_LEN = -6,
+	FIFO_M_A_OVER_LEN = -5,
+	FIFO_G_A_OVER_LEN = -4,
+	FIFO_M_OVER_LEN = -3,
+	FIFO_G_OVER_LEN = -2,
+	FIFO_A_OVER_LEN = -1
+};
+
+/*!bmi sensor generic power mode enum */
+enum BMI_DEV_OP_MODE {
+	SENSOR_PM_NORMAL = 0,
+	SENSOR_PM_LP1,
+	SENSOR_PM_SUSPEND,
+	SENSOR_PM_LP2
+};
+
+/*! bmi acc sensor power mode enum */
+enum BMI_ACC_PM_TYPE {
+	BMI_ACC_PM_NORMAL = 0,
+	BMI_ACC_PM_LP1,
+	BMI_ACC_PM_SUSPEND,
+	BMI_ACC_PM_LP2,
+	BMI_ACC_PM_MAX
+};
+
+/*! bmi gyro sensor power mode enum */
+enum BMI_GYRO_PM_TYPE {
+	BMI_GYRO_PM_NORMAL = 0,
+	BMI_GYRO_PM_FAST_START,
+	BMI_GYRO_PM_SUSPEND,
+	BMI_GYRO_PM_MAX
+};
+
+/*! bmi mag sensor power mode enum */
+enum BMI_MAG_PM_TYPE {
+	BMI_MAG_PM_NORMAL = 0,
+	BMI_MAG_PM_LP1,
+	BMI_MAG_PM_SUSPEND,
+	BMI_MAG_PM_LP2,
+	BMI_MAG_PM_MAX
+};
+
+
+/*! bmi sensor support type*/
+enum BMI_SENSOR_TYPE {
+	BMI_ACC_SENSOR,
+	BMI_GYRO_SENSOR,
+	BMI_MAG_SENSOR,
+	BMI_SENSOR_TYPE_MAX
+};
+
+/*!bmi sensor generic power mode enum */
+enum BMI_AXIS_TYPE {
+	X_AXIS = 0,
+	Y_AXIS,
+	Z_AXIS,
+	AXIS_MAX
+};
+
+/*!bmi sensor generic intterrupt enum */
+enum BMI_INT_TYPE {
+	BMI160_INT0 = 0,
+	BMI160_INT1,
+	BMI160_INT_MAX
+};
+
+/*! bmi sensor time resolution definition*/
+enum BMI_SENSOR_TIME_RS_TYPE {
+	TS_0_78_HZ = 1,/*0.78HZ*/
+	TS_1_56_HZ,/*1.56HZ*/
+	TS_3_125_HZ,/*3.125HZ*/
+	TS_6_25_HZ,/*6.25HZ*/
+	TS_12_5_HZ,/*12.5HZ*/
+	TS_25_HZ,/*25HZ, odr=6*/
+	TS_50_HZ,/*50HZ*/
+	TS_100_HZ,/*100HZ*/
+	TS_200_HZ,/*200HZ*/
+	TS_400_HZ,/*400HZ*/
+	TS_800_HZ,/*800HZ*/
+	TS_1600_HZ,/*1600HZ*/
+	TS_MAX_HZ
+};
+
+/*! bmi sensor interface mode */
+enum BMI_SENSOR_IF_MODE_TYPE {
+	/*primary interface:autoconfig/secondary interface off*/
+	P_AUTO_S_OFF = 0,
+	/*primary interface:I2C/secondary interface:OIS*/
+	P_I2C_S_OIS,
+	/*primary interface:autoconfig/secondary interface:Magnetometer*/
+	P_AUTO_S_MAG,
+	/*interface mode reseved*/
+	IF_MODE_RESEVED
+
+};
+
+/*! bmi160 acc/gyro calibration status in H/W layer */
+enum BMI_CALIBRATION_STATUS_TYPE {
+	/*BMI FAST Calibration ready x/y/z status*/
+	BMI_ACC_X_FAST_CALI_RDY = 0,
+	BMI_ACC_Y_FAST_CALI_RDY,
+	BMI_ACC_Z_FAST_CALI_RDY
+};
+
+unsigned int reg_op_addr;
+
+static const int bmi_pmu_cmd_acc_arr[BMI_ACC_PM_MAX] = {
+	/*!bmi pmu for acc normal, low power1,
+	 * suspend, low power2 mode command */
+	CMD_PMU_ACC_NORMAL,
+	CMD_PMU_ACC_LP1,
+	CMD_PMU_ACC_SUSPEND,
+	CMD_PMU_ACC_LP2
+};
+
+static const int bmi_pmu_cmd_gyro_arr[BMI_GYRO_PM_MAX] = {
+	/*!bmi pmu for gyro normal, fast startup,
+	 * suspend mode command */
+	CMD_PMU_GYRO_NORMAL,
+	CMD_PMU_GYRO_FASTSTART,
+	CMD_PMU_GYRO_SUSPEND
+};
+
+static const int bmi_pmu_cmd_mag_arr[BMI_MAG_PM_MAX] = {
+	/*!bmi pmu for mag normal, low power1,
+	 * suspend, low power2 mode command */
+	CMD_PMU_MAG_NORMAL,
+	CMD_PMU_MAG_LP1,
+	CMD_PMU_MAG_SUSPEND,
+	CMD_PMU_MAG_LP2
+};
+
+static const char *bmi_axis_name[AXIS_MAX] = {"x", "y", "z"};
+
+static const int bmi_interrupt_type[] = {
+	/*!bmi interrupt type */
+	/* Interrupt enable0 , index=0~6*/
+	BMI160_ANY_MOTION_X_ENABLE,
+	BMI160_ANY_MOTION_Y_ENABLE,
+	BMI160_ANY_MOTION_Z_ENABLE,
+	BMI160_DOUBLE_TAP_ENABLE,
+	BMI160_SINGLE_TAP_ENABLE,
+	BMI160_ORIENT_ENABLE,
+	BMI160_FLAT_ENABLE,
+	/* Interrupt enable1, index=7~13*/
+	BMI160_HIGH_G_X_ENABLE,
+	BMI160_HIGH_G_Y_ENABLE,
+	BMI160_HIGH_G_Z_ENABLE,
+	BMI160_LOW_G_ENABLE,
+	BMI160_DATA_RDY_ENABLE,
+	BMI160_FIFO_FULL_ENABLE,
+	BMI160_FIFO_WM_ENABLE,
+	/* Interrupt enable2, index = 14~17*/
+	BMI160_NOMOTION_X_ENABLE,
+	BMI160_NOMOTION_Y_ENABLE,
+	BMI160_NOMOTION_Z_ENABLE,
+	BMI160_STEP_DETECTOR_EN
+};
+
+/*! bmi sensor time depend on ODR*/
+struct bmi_sensor_time_odr_tbl {
+	u32 ts_duration_lsb;
+	u32 ts_duration_us;
+	u32 ts_delat;/*sub current delat fifo_time*/
+};
+
+struct bmi160_axis_data_t {
+	s16 x;
+	s16 y;
+	s16 z;
+};
+
+struct bmi160_type_mapping_type {
+
+	/*! bmi16x sensor chip id */
+	uint16_t chip_id;
+
+	/*! bmi16x chip revision code */
+	uint16_t revision_id;
+
+	/*! bma2x2 sensor name */
+	const char *sensor_name;
+};
+
+struct bmi160_store_info_t {
+	uint8_t current_frm_cnt;
+	uint64_t current_apts_us[2];
+	uint8_t fifo_ts_total_frmcnt;
+	uint64_t fifo_time;
+};
+
+uint64_t get_current_timestamp(void)
+{
+	uint64_t ts_ap;
+	struct timespec tmp_time;
+	get_monotonic_boottime(&tmp_time);
+	ts_ap = (uint64_t)tmp_time.tv_sec * 1000000000 + tmp_time.tv_nsec;
+	return ts_ap;
+
+}
+
+/*! sensor support type map */
+static const struct bmi160_type_mapping_type sensor_type_map[] = {
+
+	{SENSOR_CHIP_ID_BMI, SENSOR_CHIP_REV_ID_BMI, "BMI160/162AB"},
+	{SENSOR_CHIP_ID_BMI_C2, SENSOR_CHIP_REV_ID_BMI, "BMI160C2"},
+	{SENSOR_CHIP_ID_BMI_C3, SENSOR_CHIP_REV_ID_BMI, "BMI160C3"},
+
+};
+
+/*!bmi160 sensor time depends on ODR */
+static const struct bmi_sensor_time_odr_tbl
+		sensortime_duration_tbl[TS_MAX_HZ] = {
+	{0x010000, 2560000, 0x00ffff},/*2560ms, 0.39hz, odr=resver*/
+	{0x008000, 1280000, 0x007fff},/*1280ms, 0.78hz, odr_acc=1*/
+	{0x004000, 640000, 0x003fff},/*640ms, 1.56hz, odr_acc=2*/
+	{0x002000, 320000, 0x001fff},/*320ms, 3.125hz, odr_acc=3*/
+	{0x001000, 160000, 0x000fff},/*160ms, 6.25hz, odr_acc=4*/
+	{0x000800, 80000,  0x0007ff},/*80ms, 12.5hz*/
+	{0x000400, 40000, 0x0003ff},/*40ms, 25hz, odr_acc = odr_gyro =6*/
+	{0x000200, 20000, 0x0001ff},/*20ms, 50hz, odr = 7*/
+	{0x000100, 10000, 0x0000ff},/*10ms, 100hz, odr=8*/
+	{0x000080, 5000, 0x00007f},/*5ms, 200hz, odr=9*/
+	{0x000040, 2500, 0x00003f},/*2.5ms, 400hz, odr=10*/
+	{0x000020, 1250, 0x00001f},/*1.25ms, 800hz, odr=11*/
+	{0x000010, 625, 0x00000f},/*0.625ms, 1600hz, odr=12*/
+
+};
+
+#if defined(CONFIG_USE_QUALCOMM_HAL)
+#define POLL_INTERVAL_MIN_MS	10
+#define POLL_INTERVAL_MAX_MS	4000
+#define POLL_DEFAULT_INTERVAL_MS 200
+#define BMI160_ACCEL_MIN_VALUE	-32768
+#define BMI160_ACCEL_MAX_VALUE	32767
+#define BMI160_GYRO_MIN_VALUE	-32768
+#define BMI160_GYRO_MAX_VALUE	32767
+#define BMI160_ACCEL_DEFAULT_POLL_INTERVAL_MS	200
+#define BMI160_GYRO_DEFAULT_POLL_INTERVAL_MS	200
+#define BMI160_ACCEL_MIN_POLL_INTERVAL_MS	10
+#define BMI160_ACCEL_MAX_POLL_INTERVAL_MS	5000
+#define BMI160_GYRO_MIN_POLL_INTERVAL_MS	10
+#define BMI160_GYRO_MAX_POLL_INTERVAL_MS	5000
+static struct sensors_classdev bmi160_accel_cdev = {
+		.name = "bmi160-accel",
+		.vendor = "bosch",
+		.version = 1,
+		.handle = SENSORS_ACCELERATION_HANDLE,
+		.type = SENSOR_TYPE_ACCELEROMETER,
+		.max_range = "156.8",	/* 16g */
+		.resolution = "0.153125",	/* 15.6mg */
+		.sensor_power = "0.13",	/* typical value */
+		.min_delay = POLL_INTERVAL_MIN_MS * 1000, /* in microseconds */
+		.max_delay = POLL_INTERVAL_MAX_MS,
+		.delay_msec = POLL_DEFAULT_INTERVAL_MS, /* in millisecond */
+		.fifo_reserved_event_count = 0,
+		.fifo_max_event_count = 0,
+		.enabled = 0,
+		.max_latency = 0,
+		.flags = 0,
+		.sensors_enable = NULL,
+		.sensors_poll_delay = NULL,
+		.sensors_set_latency = NULL,
+		.sensors_flush = NULL,
+		.sensors_self_test = NULL,
+};
+static struct sensors_classdev bmi160_gyro_cdev = {
+	.name = "bmi160-gyro",
+	.vendor = "bosch",
+	.version = 1,
+	.handle = SENSORS_GYROSCOPE_HANDLE,
+	.type = SENSOR_TYPE_GYROSCOPE,
+	.max_range = "34.906586",	/* rad/s */
+	.resolution = "0.0010681152",	/* rad/s */
+	.sensor_power = "3.6",	/* 3.6 mA */
+	.min_delay = BMI160_GYRO_MIN_POLL_INTERVAL_MS * 1000,
+	.max_delay = BMI160_GYRO_MAX_POLL_INTERVAL_MS,
+	.delay_msec = BMI160_GYRO_DEFAULT_POLL_INTERVAL_MS,
+	.fifo_reserved_event_count = 0,
+	.fifo_max_event_count = 0,
+	.enabled = 0,
+	.max_latency = 0,
+	.flags = 0, /* SENSOR_FLAG_CONTINUOUS_MODE */
+	.sensors_enable = NULL,
+	.sensors_poll_delay = NULL,
+	.sensors_enable_wakeup = NULL,
+	.sensors_set_latency = NULL,
+	.sensors_flush = NULL,
+};
+#endif
+static void bmi_delay(u32 msec)
+{
+	if (msec <= 20)
+		usleep_range(msec * 1000, msec * 1000);
+	else
+		msleep(msec);
+}
+
+static void bmi_dump_reg(struct bmi_client_data *client_data)
+{
+	#define REG_MAX0 0x24
+	#define REG_MAX1 0x56
+	int i;
+	u8 dbg_buf0[REG_MAX0];
+	u8 dbg_buf1[REG_MAX1];
+	u8 dbg_buf_str0[REG_MAX0 * 3 + 1] = "";
+	u8 dbg_buf_str1[REG_MAX1 * 3 + 1] = "";
+
+	dev_notice(client_data->dev, "\nFrom 0x00:\n");
+
+	client_data->device.bus_read(client_data->device.dev_addr,
+			BMI_REG_NAME(USER_CHIP_ID), dbg_buf0, REG_MAX0);
+	for (i = 0; i < REG_MAX0; i++) {
+		snprintf(dbg_buf_str0 + i * 3, 16, "%02x%c", dbg_buf0[i],
+				(((i + 1) % BYTES_PER_LINE == 0) ? '\n' : ' '));
+	}
+	dev_notice(client_data->dev, "%s\n", dbg_buf_str0);
+
+	client_data->device.bus_read(client_data->device.dev_addr,
+			BMI160_USER_ACCEL_CONFIG_ADDR, dbg_buf1, REG_MAX1);
+	dev_notice(client_data->dev, "\nFrom 0x40:\n");
+	for (i = 0; i < REG_MAX1; i++) {
+		snprintf(dbg_buf_str1 + i * 3, 16, "%02x%c", dbg_buf1[i],
+				(((i + 1) % BYTES_PER_LINE == 0) ? '\n' : ' '));
+	}
+	dev_notice(client_data->dev, "\n%s\n", dbg_buf_str1);
+	}
+
+
+void bmi_fifo_frame_bytes_extend_calc(
+	struct bmi_client_data *client_data,
+	unsigned int *fifo_frmbytes_extend)
+{
+
+	switch (client_data->fifo_data_sel) {
+	case BMI_FIFO_A_SEL:
+	case BMI_FIFO_G_SEL:
+		*fifo_frmbytes_extend = 7;
+		break;
+	case BMI_FIFO_G_A_SEL:
+		*fifo_frmbytes_extend = 13;
+		break;
+	case BMI_FIFO_M_SEL:
+		*fifo_frmbytes_extend = 9;
+		break;
+	case BMI_FIFO_M_A_SEL:
+	case BMI_FIFO_M_G_SEL:
+		/*8(mag) + 6(gyro or acc) +1(head) = 15*/
+		*fifo_frmbytes_extend = 15;
+		break;
+	case BMI_FIFO_M_G_A_SEL:
+		/*8(mag) + 6(gyro or acc) + 6 + 1 = 21*/
+		*fifo_frmbytes_extend = 21;
+		break;
+	default:
+		*fifo_frmbytes_extend = 0;
+		break;
+
+	};
+
+}
+
+
+static int bmi_input_init(struct bmi_client_data *client_data)
+{
+	struct input_dev *dev;
+	int err = 0;
+
+	dev = input_allocate_device();
+	if (NULL == dev)
+		return -ENOMEM;
+#if defined(CONFIG_USE_QUALCOMM_HAL)
+	dev->name = "bmi160-accel";
+#else
+	dev->name = SENSOR_NAME;
+#endif
+	dev->id.bustype = BUS_I2C;
+
+	input_set_capability(dev, EV_MSC, MSC_GESTURE);
+	input_set_capability(dev, EV_MSC, INPUT_EVENT_SGM);
+
+	input_set_capability(dev, EV_MSC, INPUT_EVENT_FAST_GYRO_CALIB_DONE);
+	input_set_capability(dev, EV_MSC, INPUT_EVENT_STEP_DETECTOR);
+	input_set_capability(dev, EV_MSC, INPUT_EVENT_FAST_ACC_CALIB_DONE);
+
+
+	input_set_capability(dev, EV_REL, REL_X);
+	input_set_capability(dev, EV_REL, REL_Y);
+	input_set_capability(dev, EV_REL, REL_Z);
+	#if defined(CONFIG_USE_QUALCOMM_HAL)
+	input_set_capability(dev, EV_ABS, ABS_MISC);
+	input_set_abs_params(dev, ABS_X,
+	BMI160_ACCEL_MIN_VALUE, BMI160_ACCEL_MAX_VALUE,
+	0, 0);
+	input_set_abs_params(dev, ABS_Y,
+	BMI160_ACCEL_MIN_VALUE, BMI160_ACCEL_MAX_VALUE,
+	0, 0);
+	input_set_abs_params(dev, ABS_Z,
+	BMI160_ACCEL_MIN_VALUE, BMI160_ACCEL_MAX_VALUE,
+	0, 0);
+	#endif
+	input_set_drvdata(dev, client_data);
+
+	err = input_register_device(dev);
+	if (err < 0) {
+		input_free_device(dev);
+		dev_notice(client_data->dev, "bmi160 input free!\n");
+		return err;
+	}
+	client_data->input = dev;
+	dev_notice(client_data->dev,
+		"bmi160 input register successfully, %s!\n",
+		client_data->input->name);
+	return err;
+}
+
+//#if defined(CONFIG_USE_QUALCOMM_HAL)
+static int bmi_gyro_input_init(struct bmi_client_data *client_data)
+{
+	struct input_dev *dev;
+	int err = 0;
+
+	dev = input_allocate_device();
+	if (NULL == dev)
+		return -ENOMEM;
+	dev->name = "bmi160-gyro";
+	dev->id.bustype = BUS_I2C;
+	input_set_capability(dev, EV_ABS, ABS_MISC);
+	input_set_capability(dev, EV_MSC, MSC_GESTURE);
+	input_set_capability(dev, EV_MSC, INPUT_EVENT_SGM);
+	
+	input_set_capability(dev, EV_MSC, INPUT_EVENT_FAST_GYRO_CALIB_DONE);
+	input_set_capability(dev, EV_MSC, INPUT_EVENT_STEP_DETECTOR);
+	input_set_capability(dev, EV_MSC, INPUT_EVENT_FAST_ACC_CALIB_DONE);
+	#if defined(CONFIG_USE_QUALCOMM_HAL)
+	input_set_abs_params(dev, ABS_RX,
+	BMI160_ACCEL_MIN_VALUE, BMI160_ACCEL_MAX_VALUE,
+	0, 0);
+	input_set_abs_params(dev, ABS_RY,
+	BMI160_ACCEL_MIN_VALUE, BMI160_ACCEL_MAX_VALUE,
+	0, 0);
+	input_set_abs_params(dev, ABS_RZ,
+	BMI160_ACCEL_MIN_VALUE, BMI160_ACCEL_MAX_VALUE,
+	0, 0);
+	#endif
+	input_set_drvdata(dev, client_data);
+	err = input_register_device(dev);
+	if (err < 0) {
+		input_free_device(dev);
+		dev_notice(client_data->dev, "bmi160 input free!\n");
+		return err;
+	}
+	client_data->gyro_input = dev;
+	dev_notice(client_data->dev,
+		"bmi160 input register successfully, %s!\n",
+		client_data->gyro_input->name);
+	return err;
+}
+//#endif
+static void bmi_input_destroy(struct bmi_client_data *client_data)
+{
+	struct input_dev *dev = client_data->input;
+
+	input_unregister_device(dev);
+	input_free_device(dev);
+}
+
+static int bmi_check_chip_id(struct bmi_client_data *client_data)
+{
+	int8_t err = 0;
+	int8_t i = 0;
+	uint8_t chip_id = 0;
+	uint8_t read_count = 0;
+	u8 bmi_sensor_cnt = sizeof(sensor_type_map)
+				/ sizeof(struct bmi160_type_mapping_type);
+	/* read and check chip id */
+	while (read_count++ < CHECK_CHIP_ID_TIME_MAX) {
+		if (client_data->device.bus_read(client_data->device.dev_addr,
+				BMI_REG_NAME(USER_CHIP_ID), &chip_id, 1) < 0) {
+
+			dev_err(client_data->dev,
+					"Bosch Sensortec Device not found"
+						"read chip_id:%d\n", chip_id);
+			continue;
+		} else {
+			for (i = 0; i < bmi_sensor_cnt; i++) {
+				if (sensor_type_map[i].chip_id == chip_id) {
+					client_data->chip_id = chip_id;
+					dev_notice(client_data->dev,
+					"Bosch Sensortec Device detected, "
+			"HW IC name: %s\n", sensor_type_map[i].sensor_name);
+					break;
+				}
+			}
+			if (i < bmi_sensor_cnt)
+				break;
+			else {
+				if (read_count == CHECK_CHIP_ID_TIME_MAX) {
+					dev_err(client_data->dev,
+				"Failed!Bosch Sensortec Device not found"
+					" mismatch chip_id:%d\n", chip_id);
+					err = -ENODEV;
+					return err;
+				}
+			}
+			bmi_delay(1);
+		}
+	}
+	return err;
+
+}
+
+static int bmi_pmu_set_suspend(struct bmi_client_data *client_data)
+{
+	int err = 0;
+	if (client_data == NULL)
+		return -EINVAL;
+	else {
+		err += BMI_CALL_API(set_command_register)
+				(bmi_pmu_cmd_acc_arr[SENSOR_PM_SUSPEND]);
+		err += BMI_CALL_API(set_command_register)
+				(bmi_pmu_cmd_gyro_arr[SENSOR_PM_SUSPEND]);
+		err += BMI_CALL_API(set_command_register)
+				(bmi_pmu_cmd_mag_arr[SENSOR_PM_SUSPEND]);
+		client_data->pw.acc_pm = BMI_ACC_PM_SUSPEND;
+		client_data->pw.gyro_pm = BMI_GYRO_PM_SUSPEND;
+		client_data->pw.mag_pm = BMI_MAG_PM_SUSPEND;
+	}
+
+	return err;
+}
+
+static int bmi_get_err_status(struct bmi_client_data *client_data)
+{
+	int err = 0;
+
+	err = BMI_CALL_API(get_error_status)(&client_data->err_st.fatal_err,
+		&client_data->err_st.err_code, &client_data->err_st.i2c_fail,
+	&client_data->err_st.drop_cmd, &client_data->err_st.mag_drdy_err);
+	return err;
+}
+
+static void bmi_work_func(struct work_struct *work)
+{
+	struct bmi_client_data *client_data =
+		container_of((struct delayed_work *)work,
+			struct bmi_client_data, work);
+	unsigned long delay =
+		msecs_to_jiffies(atomic_read(&client_data->delay));
+	struct bmi160_accel_t data;
+	int err;
+
+	err = BMI_CALL_API(read_accel_xyz)(&data);
+	if (err < 0)
+		return;
+
+	/*report current frame via input event*/
+	input_event(client_data->input, EV_REL, REL_X, data.x);
+	input_event(client_data->input, EV_REL, REL_Y, data.y);
+	input_event(client_data->input, EV_REL, REL_Z, data.z);
+	input_sync(client_data->input);
+
+	schedule_delayed_work(&client_data->work, delay);
+}
+
+static ssize_t bmi160_chip_id_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+
+	return snprintf(buf, 16, "0x%x\n", client_data->chip_id);
+}
+
+static ssize_t bmi160_err_st_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+	int err = 0;
+	err = bmi_get_err_status(client_data);
+	if (err)
+		return err;
+	else {
+		return snprintf(buf, 128, "fatal_err:0x%x, err_code:%d,\n\n"
+			"i2c_fail_err:%d, drop_cmd_err:%d, mag_drdy_err:%d\n",
+			client_data->err_st.fatal_err,
+			client_data->err_st.err_code,
+			client_data->err_st.i2c_fail,
+			client_data->err_st.drop_cmd,
+			client_data->err_st.mag_drdy_err);
+
+	}
+}
+
+static ssize_t bmi160_sensor_time_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err = 0;
+	u32 sensor_time;
+	err = BMI_CALL_API(get_sensor_time)(&sensor_time);
+	if (err)
+		return err;
+	else
+		return snprintf(buf, 16, "0x%x\n", (unsigned int)sensor_time);
+}
+
+static ssize_t bmi160_fifo_flush_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	int err;
+	unsigned long enable;
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+
+	err = kstrtoul(buf, 10, &enable);
+	if (err)
+		return err;
+	if (enable)
+		err = BMI_CALL_API(set_command_register)(CMD_CLR_FIFO_DATA);
+
+	if (err)
+		dev_err(client_data->dev, "fifo flush failed!\n");
+
+	return count;
+
+}
+
+
+static ssize_t bmi160_fifo_bytecount_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err;
+	unsigned int fifo_bytecount = 0;
+
+	BMI_CALL_API(fifo_length)(&fifo_bytecount);
+	err = snprintf(buf, 16, "%u\n", fifo_bytecount);
+	return err;
+}
+
+static ssize_t bmi160_fifo_bytecount_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+	int err;
+	unsigned long data;
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+	client_data->fifo_bytecount = (unsigned int) data;
+
+	return count;
+}
+
+int bmi160_fifo_data_sel_get(struct bmi_client_data *client_data)
+{
+	int err = 0;
+	unsigned char fifo_acc_en, fifo_gyro_en, fifo_mag_en;
+	unsigned char fifo_datasel;
+
+	err += BMI_CALL_API(get_fifo_accel_enable)(&fifo_acc_en);
+	err += BMI_CALL_API(get_fifo_gyro_enable)(&fifo_gyro_en);
+	err += BMI_CALL_API(get_fifo_mag_enable)(&fifo_mag_en);
+
+	if (err)
+		return err;
+
+	fifo_datasel = (fifo_acc_en << BMI_ACC_SENSOR) |
+			(fifo_gyro_en << BMI_GYRO_SENSOR) |
+				(fifo_mag_en << BMI_MAG_SENSOR);
+
+	client_data->fifo_data_sel = fifo_datasel;
+
+	return err;
+
+
+}
+
+static ssize_t bmi160_fifo_data_sel_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err = 0;
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+	err = bmi160_fifo_data_sel_get(client_data);
+	if (err) {
+		dev_err(client_data->dev, "get fifo_sel failed!\n");
+		return -EINVAL;
+	}
+	return snprintf(buf, 16, "%d\n", client_data->fifo_data_sel);
+}
+
+/* write any value to clear all the fifo data. */
+static ssize_t bmi160_fifo_data_sel_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+	int err;
+	unsigned long data;
+	unsigned char fifo_datasel;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+	/* data format: aimed 0b0000 0x(m)x(g)x(a), x:1 enable, 0:disable*/
+	if (data > 7)
+		return -EINVAL;
+
+
+	fifo_datasel = (unsigned char)data;
+
+
+	err += BMI_CALL_API(set_fifo_accel_enable)
+			((fifo_datasel & (1 << BMI_ACC_SENSOR)) ? 1 :  0);
+	err += BMI_CALL_API(set_fifo_gyro_enable)
+			(fifo_datasel & (1 << BMI_GYRO_SENSOR) ? 1 : 0);
+	err += BMI_CALL_API(set_fifo_mag_enable)
+			((fifo_datasel & (1 << BMI_MAG_SENSOR)) ? 1 : 0);
+
+	err += BMI_CALL_API(set_command_register)(CMD_CLR_FIFO_DATA);
+	if (err)
+		return -EIO;
+	else {
+		dev_notice(client_data->dev, "FIFO A_en:%d, G_en:%d, M_en:%d\n",
+			(fifo_datasel & (1 << BMI_ACC_SENSOR)) ? 1 :  0,
+			(fifo_datasel & (1 << BMI_GYRO_SENSOR) ? 1 : 0),
+			((fifo_datasel & (1 << BMI_MAG_SENSOR)) ? 1 : 0));
+		client_data->fifo_data_sel = fifo_datasel;
+	}
+	return count;
+}
+
+static ssize_t bmi160_fifo_data_out_frame_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+
+	int err = 0;
+	uint32_t fifo_bytecount = 0;
+
+	err = BMI_CALL_API(fifo_length)(&fifo_bytecount);
+	if (err < 0) {
+		dev_err(client_data->dev, "read fifo_length err");
+		return -EINVAL;
+	}
+	if (fifo_bytecount == 0)
+		return 0;
+	err = bmi_burst_read_wrapper(client_data->device.dev_addr,
+		BMI160_USER_FIFO_DATA__REG, buf,
+		fifo_bytecount);
+	if (err) {
+		dev_err(client_data->dev, "read fifo err");
+		BMI_CALL_API(set_command_register)(CMD_CLR_FIFO_DATA);
+		return -EINVAL;
+	}
+	return fifo_bytecount;
+
+}
+
+static ssize_t bmi160_fifo_watermark_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err;
+	unsigned char data = 0xff;
+
+	err = BMI_CALL_API(get_fifo_wm)(&data);
+
+	if (err)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t bmi160_fifo_watermark_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	int err;
+	unsigned long data;
+	unsigned char fifo_watermark;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	fifo_watermark = (unsigned char)data;
+	err = BMI_CALL_API(set_fifo_wm)(fifo_watermark);
+	if (err)
+		return -EIO;
+
+	return count;
+}
+
+
+static ssize_t bmi160_fifo_header_en_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err;
+	unsigned char data = 0xff;
+
+	err = BMI_CALL_API(get_fifo_header_enable)(&data);
+
+	if (err)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t bmi160_fifo_header_en_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+	int err;
+	unsigned long data;
+	unsigned char fifo_header_en;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+	if (data > 1)
+		return -ENOENT;
+
+	fifo_header_en = (unsigned char)data;
+	err = BMI_CALL_API(set_fifo_header_enable)(fifo_header_en);
+	if (err)
+		return -EIO;
+
+	client_data->fifo_head_en = fifo_header_en;
+
+	return count;
+}
+
+static ssize_t bmi160_fifo_time_en_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err;
+	unsigned char data = 0;
+
+	err = BMI_CALL_API(get_fifo_time_enable)(&data);
+
+	if (!err)
+		err = snprintf(buf, 16, "%d\n", data);
+
+	return err;
+}
+
+static ssize_t bmi160_fifo_time_en_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	int err;
+	unsigned long data;
+	unsigned char fifo_ts_en;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	fifo_ts_en = (unsigned char)data;
+
+	err = BMI_CALL_API(set_fifo_time_enable)(fifo_ts_en);
+	if (err)
+		return -EIO;
+
+	return count;
+}
+
+static ssize_t bmi160_fifo_int_tag_en_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err = 0;
+	unsigned char fifo_tag_int1 = 0;
+	unsigned char fifo_tag_int2 = 0;
+	unsigned char fifo_tag_int;
+
+	err += BMI_CALL_API(get_fifo_tag_intr1_enable)(&fifo_tag_int1);
+	err += BMI_CALL_API(get_fifo_tag_intr2_enable)(&fifo_tag_int2);
+
+	fifo_tag_int = (fifo_tag_int1 << BMI160_INT0) |
+			(fifo_tag_int2 << BMI160_INT1);
+
+	if (!err)
+		err = snprintf(buf, 16, "%d\n", fifo_tag_int);
+
+	return err;
+}
+
+static ssize_t bmi160_fifo_int_tag_en_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+	int err;
+	unsigned long data;
+	unsigned char fifo_tag_int_en;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+	if (data > 3)
+		return -EINVAL;
+
+	fifo_tag_int_en = (unsigned char)data;
+
+	err += BMI_CALL_API(set_fifo_tag_intr1_enable)
+			((fifo_tag_int_en & (1 << BMI160_INT0)) ? 1 :  0);
+	err += BMI_CALL_API(set_fifo_tag_intr2_enable)
+			((fifo_tag_int_en & (1 << BMI160_INT1)) ? 1 :  0);
+
+	if (err) {
+		dev_err(client_data->dev, "fifo int tag en err:%d\n", err);
+		return -EIO;
+	}
+	client_data->fifo_int_tag_en = fifo_tag_int_en;
+
+	return count;
+}
+
+static int bmi160_set_acc_op_mode(struct bmi_client_data *client_data,
+							unsigned long op_mode)
+{
+	int err = 0;
+	unsigned char stc_enable;
+	unsigned char std_enable;
+	mutex_lock(&client_data->mutex_op_mode);
+
+	if (op_mode < BMI_ACC_PM_MAX) {
+		switch (op_mode) {
+		case BMI_ACC_PM_NORMAL:
+			err = BMI_CALL_API(set_command_register)
+			(bmi_pmu_cmd_acc_arr[BMI_ACC_PM_NORMAL]);
+			client_data->pw.acc_pm = BMI_ACC_PM_NORMAL;
+			bmi_delay(10);
+			break;
+		case BMI_ACC_PM_LP1:
+			err = BMI_CALL_API(set_command_register)
+			(bmi_pmu_cmd_acc_arr[BMI_ACC_PM_LP1]);
+			client_data->pw.acc_pm = BMI_ACC_PM_LP1;
+			bmi_delay(3);
+			break;
+		case BMI_ACC_PM_SUSPEND:
+			BMI_CALL_API(get_step_counter_enable)(&stc_enable);
+			BMI_CALL_API(get_step_detector_enable)(&std_enable);
+			if ((stc_enable == 0) && (std_enable == 0) &&
+				(client_data->sig_flag == 0)) {
+				err = BMI_CALL_API(set_command_register)
+				(bmi_pmu_cmd_acc_arr[BMI_ACC_PM_SUSPEND]);
+				client_data->pw.acc_pm = BMI_ACC_PM_SUSPEND;
+				bmi_delay(10);
+			}
+			break;
+		case BMI_ACC_PM_LP2:
+			err = BMI_CALL_API(set_command_register)
+			(bmi_pmu_cmd_acc_arr[BMI_ACC_PM_LP2]);
+			client_data->pw.acc_pm = BMI_ACC_PM_LP2;
+			bmi_delay(3);
+			break;
+		default:
+			mutex_unlock(&client_data->mutex_op_mode);
+			return -EINVAL;
+		}
+	} else {
+		mutex_unlock(&client_data->mutex_op_mode);
+		return -EINVAL;
+	}
+
+	mutex_unlock(&client_data->mutex_op_mode);
+
+	return err;
+
+
+}
+
+static ssize_t bmi160_temperature_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err;
+	s16 temp = 0xff;
+
+	err = BMI_CALL_API(get_temp)(&temp);
+
+	if (!err)
+		err = snprintf(buf, 16, "0x%x\n", temp);
+
+	return err;
+}
+
+static ssize_t bmi160_place_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+	int place = BOSCH_SENSOR_PLACE_UNKNOWN;
+
+	if (NULL != client_data->bst_pd)
+		place = client_data->bst_pd->place;
+
+	return snprintf(buf, 16, "%d\n", place);
+}
+
+static ssize_t bmi160_delay_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+
+	return snprintf(buf, 16, "%d\n", atomic_read(&client_data->delay));
+
+}
+
+static ssize_t bmi160_delay_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+	int err;
+	unsigned long data;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	if (data == 0) {
+		err = -EINVAL;
+		return err;
+	}
+
+	if (data < BMI_DELAY_MIN)
+		data = BMI_DELAY_MIN;
+
+	atomic_set(&client_data->delay, (unsigned int)data);
+
+	return count;
+}
+
+static ssize_t bmi160_enable_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+
+	return snprintf(buf, 16, "%d\n", atomic_read(&client_data->wkqueue_en));
+
+}
+
+static ssize_t bmi160_enable_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+	int err;
+	unsigned long enable;
+	int pre_enable = atomic_read(&client_data->wkqueue_en);
+
+	err = kstrtoul(buf, 10, &enable);
+	if (err)
+		return err;
+
+	enable = enable ? 1 : 0;
+	mutex_lock(&client_data->mutex_enable);
+	if (enable) {
+		if (pre_enable == 0) {
+			bmi160_set_acc_op_mode(client_data,
+							BMI_ACC_PM_NORMAL);
+			schedule_delayed_work(&client_data->work,
+			msecs_to_jiffies(atomic_read(&client_data->delay)));
+			atomic_set(&client_data->wkqueue_en, 1);
+		}
+
+	} else {
+		if (pre_enable == 1) {
+			bmi160_set_acc_op_mode(client_data,
+							BMI_ACC_PM_SUSPEND);
+
+			cancel_delayed_work_sync(&client_data->work);
+			atomic_set(&client_data->wkqueue_en, 0);
+		}
+	}
+
+	mutex_unlock(&client_data->mutex_enable);
+
+	return count;
+}
+
+#if defined(BMI160_ENABLE_INT1) || defined(BMI160_ENABLE_INT2)
+/* accel sensor part */
+static ssize_t bmi160_anymot_duration_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err;
+	unsigned char data;
+
+	err = BMI_CALL_API(get_intr_any_motion_durn)(&data);
+
+	if (err < 0)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t bmi160_anymot_duration_store(struct device *dev,
+		struct device_attribute *attr, const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	err = BMI_CALL_API(set_intr_any_motion_durn)((unsigned char)data);
+	if (err < 0)
+		return -EIO;
+
+	return count;
+}
+
+static ssize_t bmi160_anymot_threshold_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data;
+	int err;
+
+	err = BMI_CALL_API(get_intr_any_motion_thres)(&data);
+
+	if (err < 0)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t bmi160_anymot_threshold_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	err = BMI_CALL_API(set_intr_any_motion_thres)((unsigned char)data);
+
+	if (err < 0)
+		return -EIO;
+	return count;
+}
+
+static ssize_t bmi160_step_detector_status_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	u8 data = 0;
+	u8 step_det;
+	int err;
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+	err = BMI_CALL_API(get_step_detector_enable)(&step_det);
+	/*bmi160_get_status0_step_int*/
+	if (err < 0)
+		return err;
+/*client_data->std will be updated in bmi_stepdetector_interrupt_handle */
+	if ((step_det == 1) && (client_data->std == 1)) {
+		data = 1;
+		client_data->std = 0;
+		}
+	else {
+		data = 0;
+		}
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t bmi160_step_detector_enable_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data;
+	int err;
+
+	err = BMI_CALL_API(get_step_detector_enable)(&data);
+
+	if (err < 0)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t bmi160_step_detector_enable_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	err = BMI_CALL_API(set_step_detector_enable)((unsigned char)data);
+	if (err < 0)
+		return -EIO;
+	if (data == 0)
+		client_data->pedo_data.wkar_step_detector_status = 0;
+	return count;
+}
+
+static ssize_t bmi160_signification_motion_enable_store(
+	struct device *dev, struct device_attribute *attr,
+	const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+	/*0x62 (bit 1) INT_MOTION_3 int_sig_mot_sel*/
+	err = BMI_CALL_API(set_intr_significant_motion_select)(
+		(unsigned char)data);
+	if (err < 0)
+		return -EIO;
+	if (data == 1) {
+		err = BMI_CALL_API(set_intr_enable_0)
+					(BMI160_ANY_MOTION_X_ENABLE, 1);
+		err += BMI_CALL_API(set_intr_enable_0)
+					(BMI160_ANY_MOTION_Y_ENABLE, 1);
+		err += BMI_CALL_API(set_intr_enable_0)
+					(BMI160_ANY_MOTION_Z_ENABLE, 1);
+		if (err < 0)
+			return -EIO;
+		enable_irq_wake(client_data->IRQ);
+		client_data->sig_flag = 1;
+	} else {
+		err = BMI_CALL_API(set_intr_enable_0)
+					(BMI160_ANY_MOTION_X_ENABLE, 0);
+		err += BMI_CALL_API(set_intr_enable_0)
+					(BMI160_ANY_MOTION_Y_ENABLE, 0);
+		err += BMI_CALL_API(set_intr_enable_0)
+					(BMI160_ANY_MOTION_Z_ENABLE, 0);
+		if (err < 0)
+			return -EIO;
+		disable_irq_wake(client_data->IRQ);
+		client_data->sig_flag = 0;
+	}
+	return count;
+}
+
+static ssize_t bmi160_signification_motion_enable_show(
+	struct device *dev, struct device_attribute *attr, char *buf)
+{
+	unsigned char data;
+	int err;
+	/*0x62 (bit 1) INT_MOTION_3 int_sig_mot_sel*/
+	err = BMI_CALL_API(get_intr_significant_motion_select)(&data);
+
+	if (err < 0)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static int sigmotion_init_interrupts(u8 sig_map_int_pin)
+{
+	int ret = 0;
+/*0x60  */
+	ret += bmi160_set_intr_any_motion_thres(0x1e);
+/* 0x62(bit 3~2)	0=1.5s */
+	ret += bmi160_set_intr_significant_motion_skip(0);
+/*0x62(bit 5~4)	1=0.5s*/
+	ret += bmi160_set_intr_significant_motion_proof(1);
+/*0x50 (bit 0, 1, 2)  INT_EN_0 anymo x y z*/
+	ret += bmi160_map_significant_motion_intr(sig_map_int_pin);
+/*0x62 (bit 1) INT_MOTION_3	int_sig_mot_sel
+close the signification_motion*/
+	ret += bmi160_set_intr_significant_motion_select(0);
+/*close the anymotion interrupt*/
+	ret += BMI_CALL_API(set_intr_enable_0)
+					(BMI160_ANY_MOTION_X_ENABLE, 0);
+	ret += BMI_CALL_API(set_intr_enable_0)
+					(BMI160_ANY_MOTION_Y_ENABLE, 0);
+	ret += BMI_CALL_API(set_intr_enable_0)
+					(BMI160_ANY_MOTION_Z_ENABLE, 0);
+	if (ret)
+		printk(KERN_ERR "bmi160 sig motion failed setting,%d!\n", ret);
+	return ret;
+
+}
+#endif
+
+static ssize_t bmi160_acc_range_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err;
+	unsigned char range;
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+
+	err = BMI_CALL_API(get_accel_range)(&range);
+	if (err)
+		return err;
+
+	client_data->range.acc_range = range;
+	return snprintf(buf, 16, "%d\n", range);
+}
+
+static ssize_t bmi160_acc_range_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	int err;
+	unsigned long range;
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+
+
+	err = kstrtoul(buf, 10, &range);
+	if (err)
+		return err;
+
+	err = BMI_CALL_API(set_accel_range)(range);
+	if (err)
+		return -EIO;
+
+	client_data->range.acc_range = range;
+	return count;
+}
+
+static ssize_t bmi160_acc_odr_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err;
+	unsigned char acc_odr;
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+
+	err = BMI_CALL_API(get_accel_output_data_rate)(&acc_odr);
+	if (err)
+		return err;
+
+	client_data->odr.acc_odr = acc_odr;
+	return snprintf(buf, 16, "%d\n", acc_odr);
+}
+
+static ssize_t bmi160_acc_odr_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	int err;
+	unsigned long acc_odr;
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+
+	err = kstrtoul(buf, 10, &acc_odr);
+	if (err)
+		return err;
+
+	if (acc_odr < 1 || acc_odr > 12)
+		return -EIO;
+
+	if (acc_odr < 5)
+		err = BMI_CALL_API(set_accel_under_sampling_parameter)(1);
+	else
+		err = BMI_CALL_API(set_accel_under_sampling_parameter)(0);
+
+	if (err)
+		return err;
+
+	err = BMI_CALL_API(set_accel_output_data_rate)(acc_odr);
+	if (err)
+		return -EIO;
+	client_data->odr.acc_odr = acc_odr;
+	return count;
+}
+
+static ssize_t bmi160_acc_op_mode_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+	int err = 0;
+	u8 accel_pmu_status = 0;
+	err = BMI_CALL_API(get_accel_power_mode_stat)(
+		&accel_pmu_status);
+
+	if (err)
+		return err;
+	else
+	return snprintf(buf, 32, "reg:%d, val:%d\n", accel_pmu_status,
+			client_data->pw.acc_pm);
+}
+
+static ssize_t bmi160_acc_op_mode_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+	int err;
+	unsigned long op_mode;
+	err = kstrtoul(buf, 10, &op_mode);
+	if (err)
+		return err;
+
+	err = bmi160_set_acc_op_mode(client_data, op_mode);
+	if (err)
+		return err;
+	else
+		return count;
+
+}
+
+static ssize_t bmi160_acc_value_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct bmi160_accel_t data;
+
+	int err;
+
+	err = BMI_CALL_API(read_accel_xyz)(&data);
+	if (err < 0)
+		return err;
+
+	return snprintf(buf, 48, "%hd %hd %hd\n",
+			data.x, data.y, data.z);
+}
+
+static ssize_t bmi160_acc_fast_calibration_x_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data;
+	int err;
+
+	err = BMI_CALL_API(get_foc_accel_x)(&data);
+
+	if (err < 0)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t bmi160_acc_fast_calibration_x_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+	s8 accel_offset_x = 0;
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+	/* 0: disable, 1: +1g, 2: -1g, 3: 0g */
+	if (data > 3)
+		return -EINVAL;
+
+	err = BMI_CALL_API(set_accel_foc_trigger)(X_AXIS,
+					data, &accel_offset_x);
+	if (err)
+		return -EIO;
+	else
+		client_data->calib_status |=
+			BMI_FAST_CALI_TRUE << BMI_ACC_X_FAST_CALI_RDY;
+	return count;
+}
+
+static ssize_t bmi160_acc_fast_calibration_y_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data;
+	int err;
+
+	err = BMI_CALL_API(get_foc_accel_y)(&data);
+
+	if (err < 0)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t bmi160_acc_fast_calibration_y_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+	s8 accel_offset_y = 0;
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+	/* 0: disable, 1: +1g, 2: -1g, 3: 0g */
+	if (data > 3)
+		return -EINVAL;
+
+	err = BMI_CALL_API(set_accel_foc_trigger)(Y_AXIS,
+				data, &accel_offset_y);
+	if (err)
+		return -EIO;
+	else
+		client_data->calib_status |=
+			BMI_FAST_CALI_TRUE << BMI_ACC_Y_FAST_CALI_RDY;
+	return count;
+}
+
+static ssize_t bmi160_acc_fast_calibration_z_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data;
+	int err;
+
+	err = BMI_CALL_API(get_foc_accel_z)(&data);
+
+	if (err < 0)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t bmi160_acc_fast_calibration_z_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+	s8 accel_offset_z = 0;
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+	unsigned char data1[3] = {0};
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+	/* 0: disable, 1: +1g, 2: -1g, 3: 0g */
+	if (data > 3)
+		return -EINVAL;
+
+	err = BMI_CALL_API(set_accel_foc_trigger)(Z_AXIS,
+			data, &accel_offset_z);
+	if (err)
+		return -EIO;
+	else
+		client_data->calib_status |=
+			BMI_FAST_CALI_TRUE << BMI_ACC_Z_FAST_CALI_RDY;
+
+	if (client_data->calib_status == BMI_FAST_CALI_ALL_RDY) {
+		err = BMI_CALL_API(get_accel_offset_compensation_xaxis)(
+			&data1[0]);
+		err += BMI_CALL_API(get_accel_offset_compensation_yaxis)(
+			&data1[1]);
+		err += BMI_CALL_API(get_accel_offset_compensation_zaxis)(
+			&data1[2]);
+		dev_info(client_data->dev, "accx %d, accy %d, accz %d\n",
+			data1[0], data1[1], data1[2]);
+		if (err)
+			return -EIO;
+		input_event(client_data->input, EV_MSC,
+		INPUT_EVENT_FAST_ACC_CALIB_DONE,
+		(data1[0] | (data1[1] << 8) | (data1[2] << 16)));
+		input_sync(client_data->input);
+		client_data->calib_status = 0;
+	}
+
+	return count;
+}
+
+static ssize_t bmi160_acc_offset_x_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data;
+	int err;
+
+	err = BMI_CALL_API(get_accel_offset_compensation_xaxis)(&data);
+
+	if (err < 0)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+
+static ssize_t bmi160_acc_offset_x_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	err = BMI_CALL_API(set_accel_offset_compensation_xaxis)
+						((unsigned char)data);
+
+	if (err < 0)
+		return -EIO;
+	return count;
+}
+
+static ssize_t bmi160_acc_offset_y_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data;
+	int err;
+
+	err = BMI_CALL_API(get_accel_offset_compensation_yaxis)(&data);
+
+	if (err < 0)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t bmi160_acc_offset_y_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	err = BMI_CALL_API(set_accel_offset_compensation_yaxis)
+						((unsigned char)data);
+
+	if (err < 0)
+		return -EIO;
+	return count;
+}
+
+static ssize_t bmi160_acc_offset_z_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data;
+	int err;
+
+	err = BMI_CALL_API(get_accel_offset_compensation_zaxis)(&data);
+
+	if (err < 0)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t bmi160_acc_offset_z_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	err = BMI_CALL_API(set_accel_offset_compensation_zaxis)
+						((unsigned char)data);
+
+	if (err < 0)
+		return -EIO;
+	return count;
+}
+
+static ssize_t bmi160_test_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+	u8 raw_data[15] = {0};
+	unsigned int sensor_time = 0;
+
+	int err;
+	memset(raw_data, 0, sizeof(raw_data));
+
+	err = client_data->device.bus_read(client_data->device.dev_addr,
+			BMI160_USER_DATA_8_GYRO_X_LSB__REG, raw_data, 15);
+	if (err)
+		return err;
+
+	udelay(10);
+	sensor_time = (u32)(raw_data[14] << 16 | raw_data[13] << 8
+						| raw_data[12]);
+
+	return snprintf(buf, 128, "%d %d %d %d %d %d %u",
+					(s16)(raw_data[1] << 8 | raw_data[0]),
+				(s16)(raw_data[3] << 8 | raw_data[2]),
+				(s16)(raw_data[5] << 8 | raw_data[4]),
+				(s16)(raw_data[7] << 8 | raw_data[6]),
+				(s16)(raw_data[9] << 8 | raw_data[8]),
+				(s16)(raw_data[11] << 8 | raw_data[10]),
+				sensor_time);
+
+}
+
+static ssize_t bmi160_step_counter_enable_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data;
+	int err;
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+
+	err = BMI_CALL_API(get_step_counter_enable)(&data);
+
+	client_data->stc_enable = data;
+
+	if (err < 0)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t bmi160_step_counter_enable_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	err = BMI_CALL_API(set_step_counter_enable)((unsigned char)data);
+
+	client_data->stc_enable = data;
+
+	if (err < 0)
+		return -EIO;
+	return count;
+}
+
+
+static ssize_t bmi160_step_counter_mode_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	err = BMI_CALL_API(set_step_mode)((unsigned char)data);
+
+	if (err < 0)
+		return -EIO;
+	return count;
+}
+
+static ssize_t bmi160_step_counter_clc_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	err = bmi160_clear_step_counter();
+
+	if (err < 0)
+		return -EIO;
+	return count;
+}
+
+static ssize_t bmi160_step_counter_value_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	u16 data;
+	int err;
+	static u16 last_stc_value;
+
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+
+	err = BMI_CALL_API(read_step_count)(&data);
+
+	if (err < 0)
+		return err;
+	if (data >= last_stc_value) {
+		client_data->pedo_data.last_step_counter_value += (
+			data - last_stc_value);
+		last_stc_value = data;
+	} else
+		last_stc_value = data;
+	return snprintf(buf, 16, "%d\n",
+		client_data->pedo_data.last_step_counter_value);
+}
+
+static ssize_t bmi160_bmi_value_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+	u8 raw_data[12] = {0};
+
+	int err;
+	memset(raw_data, 0, sizeof(raw_data));
+
+	err = client_data->device.bus_read(client_data->device.dev_addr,
+			BMI160_USER_DATA_8_GYRO_X_LSB__REG, raw_data, 12);
+	if (err)
+		return err;
+	/*output:gyro x y z acc x y z*/
+	return snprintf(buf, 96, "%hd %d %hd %hd %hd %hd\n",
+					(s16)(raw_data[1] << 8 | raw_data[0]),
+				(s16)(raw_data[3] << 8 | raw_data[2]),
+				(s16)(raw_data[5] << 8 | raw_data[4]),
+				(s16)(raw_data[7] << 8 | raw_data[6]),
+				(s16)(raw_data[9] << 8 | raw_data[8]),
+				(s16)(raw_data[11] << 8 | raw_data[10]));
+
+}
+
+
+static ssize_t bmi160_selftest_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+
+	return snprintf(buf, 16, "0x%x\n",
+				atomic_read(&client_data->selftest_result));
+}
+
+static int bmi_restore_hw_cfg(struct bmi_client_data *client);
+
+/*!
+ * @brief store selftest result which make up of acc and gyro
+ * format: 0b 0000 xxxx  x:1 failed, 0 success
+ * bit3:     gyro_self
+ * bit2..0: acc_self z y x
+ */
+static ssize_t bmi160_selftest_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+	int err = 0;
+	int i = 0;
+
+	u8 acc_selftest = 0;
+	u8 gyro_selftest = 0;
+	u8 bmi_selftest = 0;
+	s16 axis_p_value, axis_n_value;
+	u16 diff_axis[3] = {0xff, 0xff, 0xff};
+	u8 acc_odr, range, acc_selftest_amp, acc_selftest_sign;
+
+	dev_notice(client_data->dev, "Selftest for BMI16x starting.\n");
+
+	client_data->selftest = 1;
+
+	/*soft reset*/
+	err = BMI_CALL_API(set_command_register)(CMD_RESET_USER_REG);
+	msleep(70);
+	err += BMI_CALL_API(set_command_register)
+				(bmi_pmu_cmd_acc_arr[BMI_ACC_PM_NORMAL]);
+	err += BMI_CALL_API(set_command_register)
+				(bmi_pmu_cmd_gyro_arr[BMI_GYRO_PM_NORMAL]);
+	err += BMI_CALL_API(set_accel_under_sampling_parameter)(0);
+	err += BMI_CALL_API(set_accel_output_data_rate)(
+	BMI160_ACCEL_OUTPUT_DATA_RATE_1600HZ);
+
+	/* set to 8G range*/
+	err += BMI_CALL_API(set_accel_range)(BMI160_ACCEL_RANGE_8G);
+	/* set to self amp high */
+	err += BMI_CALL_API(set_accel_selftest_amp)(BMI_SELFTEST_AMP_HIGH);
+
+
+	err += BMI_CALL_API(get_accel_output_data_rate)(&acc_odr);
+	err += BMI_CALL_API(get_accel_range)(&range);
+	err += BMI_CALL_API(get_accel_selftest_amp)(&acc_selftest_amp);
+	err += BMI_CALL_API(read_accel_x)(&axis_n_value);
+
+	dev_info(client_data->dev,
+			"acc_odr:%d, acc_range:%d, acc_selftest_amp:%d, acc_x:%d\n",
+				acc_odr, range, acc_selftest_amp, axis_n_value);
+
+	for (i = X_AXIS; i < AXIS_MAX; i++) {
+		axis_n_value = 0;
+		axis_p_value = 0;
+		/* set every selftest axis */
+		/*set_acc_selftest_axis(param),param x:1, y:2, z:3
+		* but X_AXIS:0, Y_AXIS:1, Z_AXIS:2
+		* so we need to +1*/
+		err += BMI_CALL_API(set_accel_selftest_axis)(i + 1);
+		msleep(50);
+		switch (i) {
+		case X_AXIS:
+			/* set negative sign */
+			err += BMI_CALL_API(set_accel_selftest_sign)(0);
+			err += BMI_CALL_API(get_accel_selftest_sign)(
+				&acc_selftest_sign);
+
+			msleep(60);
+			err += BMI_CALL_API(read_accel_x)(&axis_n_value);
+			dev_info(client_data->dev,
+			"acc_x_selftest_sign:%d, axis_n_value:%d\n",
+			acc_selftest_sign, axis_n_value);
+
+			/* set postive sign */
+			err += BMI_CALL_API(set_accel_selftest_sign)(1);
+			err += BMI_CALL_API(get_accel_selftest_sign)(
+				&acc_selftest_sign);
+
+			msleep(60);
+			err += BMI_CALL_API(read_accel_x)(&axis_p_value);
+			dev_info(client_data->dev,
+			"acc_x_selftest_sign:%d, axis_p_value:%d\n",
+			acc_selftest_sign, axis_p_value);
+			diff_axis[i] = abs(axis_p_value - axis_n_value);
+			break;
+
+		case Y_AXIS:
+			/* set negative sign */
+			err += BMI_CALL_API(set_accel_selftest_sign)(0);
+			msleep(60);
+			err += BMI_CALL_API(read_accel_y)(&axis_n_value);
+			/* set postive sign */
+			err += BMI_CALL_API(set_accel_selftest_sign)(1);
+			msleep(60);
+			err += BMI_CALL_API(read_accel_y)(&axis_p_value);
+			diff_axis[i] = abs(axis_p_value - axis_n_value);
+			break;
+
+		case Z_AXIS:
+			/* set negative sign */
+			err += BMI_CALL_API(set_accel_selftest_sign)(0);
+			msleep(60);
+			err += BMI_CALL_API(read_accel_z)(&axis_n_value);
+			/* set postive sign */
+			err += BMI_CALL_API(set_accel_selftest_sign)(1);
+			msleep(60);
+			err += BMI_CALL_API(read_accel_z)(&axis_p_value);
+			/* also start gyro self test */
+			err += BMI_CALL_API(set_gyro_selftest_start)(1);
+			msleep(60);
+			err += BMI_CALL_API(get_gyro_selftest)(&gyro_selftest);
+
+			diff_axis[i] = abs(axis_p_value - axis_n_value);
+			break;
+		default:
+			err += -EINVAL;
+			break;
+		}
+		if (err) {
+			dev_err(client_data->dev,
+				"Failed selftest axis:%s, p_val=%d, n_val=%d\n",
+				bmi_axis_name[i], axis_p_value, axis_n_value);
+			client_data->selftest = 0;
+			return -EINVAL;
+		}
+
+		/*400mg for acc z axis*/
+		if (Z_AXIS == i) {
+			if (diff_axis[i] < 1639) {
+				acc_selftest |= 1 << i;
+				dev_err(client_data->dev,
+					"Over selftest minimum for "
+					"axis:%s,diff=%d,p_val=%d, n_val=%d\n",
+					bmi_axis_name[i], diff_axis[i],
+						axis_p_value, axis_n_value);
+			}
+		} else {
+			/*800mg for x or y axis*/
+			if (diff_axis[i] < 3277) {
+				acc_selftest |= 1 << i;
+
+				if (bmi_get_err_status(client_data) < 0)
+					return err;
+				dev_err(client_data->dev,
+					"Over selftest minimum for "
+					"axis:%s,diff=%d, p_val=%d, n_val=%d\n",
+					bmi_axis_name[i], diff_axis[i],
+						axis_p_value, axis_n_value);
+				dev_err(client_data->dev, "err_st:0x%x\n",
+						client_data->err_st.err_st_all);
+
+			}
+		}
+
+	}
+	/* gyro_selftest==1,gyro selftest successfully,
+	* but bmi_result bit4 0 is successful, 1 is failed*/
+	bmi_selftest = (acc_selftest & 0x0f) | ((!gyro_selftest) << AXIS_MAX);
+	atomic_set(&client_data->selftest_result, bmi_selftest);
+	/*soft reset*/
+	err = BMI_CALL_API(set_command_register)(CMD_RESET_USER_REG);
+	if (err) {
+		client_data->selftest = 0;
+		return err;
+	}
+	msleep(50);
+
+	bmi_restore_hw_cfg(client_data);
+
+	client_data->selftest = 0;
+	dev_notice(client_data->dev, "Selftest for BMI16x finished\n");
+
+	return count;
+}
+
+/* gyro sensor part */
+static ssize_t bmi160_gyro_op_mode_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+	int err = 0;
+	u8 gyro_pmu_status = 0;
+
+	err = BMI_CALL_API(get_gyro_power_mode_stat)(
+		&gyro_pmu_status);
+
+	if (err)
+		return err;
+	else
+	return snprintf(buf, 32, "reg:%d, val:%d\n", gyro_pmu_status,
+				client_data->pw.gyro_pm);
+}
+
+static ssize_t bmi160_gyro_op_mode_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+	unsigned long op_mode;
+	int err;
+
+	err = kstrtoul(buf, 10, &op_mode);
+	if (err)
+		return err;
+
+	mutex_lock(&client_data->mutex_op_mode);
+
+	if (op_mode < BMI_GYRO_PM_MAX) {
+		switch (op_mode) {
+		case BMI_GYRO_PM_NORMAL:
+			err = BMI_CALL_API(set_command_register)
+				(bmi_pmu_cmd_gyro_arr[BMI_GYRO_PM_NORMAL]);
+			client_data->pw.gyro_pm = BMI_GYRO_PM_NORMAL;
+			bmi_delay(60);
+			break;
+		case BMI_GYRO_PM_FAST_START:
+			err = BMI_CALL_API(set_command_register)
+				(bmi_pmu_cmd_gyro_arr[BMI_GYRO_PM_FAST_START]);
+			client_data->pw.gyro_pm = BMI_GYRO_PM_FAST_START;
+			bmi_delay(60);
+			break;
+		case BMI_GYRO_PM_SUSPEND:
+			err = BMI_CALL_API(set_command_register)
+				(bmi_pmu_cmd_gyro_arr[BMI_GYRO_PM_SUSPEND]);
+			client_data->pw.gyro_pm = BMI_GYRO_PM_SUSPEND;
+			bmi_delay(60);
+			break;
+		default:
+			mutex_unlock(&client_data->mutex_op_mode);
+			return -EINVAL;
+		}
+	} else {
+		mutex_unlock(&client_data->mutex_op_mode);
+		return -EINVAL;
+	}
+
+	mutex_unlock(&client_data->mutex_op_mode);
+
+	if (err)
+		return err;
+	else
+		return count;
+
+}
+
+static ssize_t bmi160_gyro_value_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct bmi160_gyro_t data;
+	int err;
+
+	err = BMI_CALL_API(read_gyro_xyz)(&data);
+	if (err < 0)
+		return err;
+
+
+	return snprintf(buf, 48, "%hd %hd %hd\n", data.x,
+				data.y, data.z);
+}
+
+static ssize_t bmi160_gyro_range_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err;
+	unsigned char range;
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+
+	err = BMI_CALL_API(get_gyro_range)(&range);
+	if (err)
+		return err;
+
+	client_data->range.gyro_range = range;
+	return snprintf(buf, 16, "%d\n", range);
+}
+
+static ssize_t bmi160_gyro_range_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	int err;
+	unsigned long range;
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+
+	err = kstrtoul(buf, 10, &range);
+	if (err)
+		return err;
+
+	err = BMI_CALL_API(set_gyro_range)(range);
+	if (err)
+		return -EIO;
+
+	client_data->range.gyro_range = range;
+	return count;
+}
+
+static ssize_t bmi160_gyro_odr_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err;
+	unsigned char gyro_odr;
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+
+	err = BMI_CALL_API(get_gyro_output_data_rate)(&gyro_odr);
+	if (err)
+		return err;
+
+	client_data->odr.gyro_odr = gyro_odr;
+	return snprintf(buf, 16, "%d\n", gyro_odr);
+}
+
+static ssize_t bmi160_gyro_odr_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	int err;
+	unsigned long gyro_odr;
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+
+	err = kstrtoul(buf, 10, &gyro_odr);
+	if (err)
+		return err;
+
+	if (gyro_odr < 6 || gyro_odr > 13)
+		return -EIO;
+
+	err = BMI_CALL_API(set_gyro_output_data_rate)(gyro_odr);
+	if (err)
+		return -EIO;
+
+	client_data->odr.gyro_odr = gyro_odr;
+	return count;
+}
+
+static ssize_t bmi160_gyro_fast_calibration_en_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data;
+	int err;
+
+	err = BMI_CALL_API(get_foc_gyro_enable)(&data);
+
+	if (err < 0)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t bmi160_gyro_fast_calibration_en_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long enable;
+	s8 err;
+	s16 gyr_off_x;
+	s16 gyr_off_y;
+	s16 gyr_off_z;
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+
+	err = kstrtoul(buf, 10, &enable);
+	if (err)
+		return err;
+
+	err = BMI_CALL_API(set_foc_gyro_enable)((u8)enable,
+				&gyr_off_x, &gyr_off_y, &gyr_off_z);
+
+	if (err < 0)
+		return -EIO;
+	else {
+		input_event(client_data->input, EV_MSC,
+			INPUT_EVENT_FAST_GYRO_CALIB_DONE, 1);
+		input_sync(client_data->input);
+	}
+	return count;
+}
+
+static ssize_t bmi160_gyro_offset_x_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	s16 data = 0;
+	s8 err = 0;
+
+	err = BMI_CALL_API(get_gyro_offset_compensation_xaxis)(&data);
+
+	if (err < 0)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t bmi160_gyro_offset_x_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	s8 err;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	err = BMI_CALL_API(set_gyro_offset_compensation_xaxis)((s16)data);
+
+	if (err < 0)
+		return -EIO;
+	return count;
+}
+
+static ssize_t bmi160_gyro_offset_y_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	s16 data = 0;
+	s8 err = 0;
+
+	err = BMI_CALL_API(get_gyro_offset_compensation_yaxis)(&data);
+
+	if (err < 0)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t bmi160_gyro_offset_y_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	s8 err;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	err = BMI_CALL_API(set_gyro_offset_compensation_yaxis)((s16)data);
+
+	if (err < 0)
+		return -EIO;
+	return count;
+}
+
+static ssize_t bmi160_gyro_offset_z_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	s16 data = 0;
+	int err = 0;
+
+	err = BMI_CALL_API(get_gyro_offset_compensation_zaxis)(&data);
+
+	if (err < 0)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t bmi160_gyro_offset_z_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	err = BMI_CALL_API(set_gyro_offset_compensation_zaxis)((s16)data);
+
+	if (err < 0)
+		return -EIO;
+	return count;
+}
+
+
+/* mag sensor part */
+#ifdef BMI160_MAG_INTERFACE_SUPPORT
+static ssize_t bmi160_mag_op_mode_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+	u8 mag_op_mode;
+	s8 err;
+	err = bmi160_get_mag_power_mode_stat(&mag_op_mode);
+	if (err) {
+		dev_err(client_data->dev,
+			"Failed to get BMI160 mag power mode:%d\n", err);
+		return err;
+	} else
+		return snprintf(buf, 32, "%d, reg:%d\n",
+					client_data->pw.mag_pm, mag_op_mode);
+}
+
+static ssize_t bmi160_mag_op_mode_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+	unsigned long op_mode;
+	int err;
+
+	err = kstrtoul(buf, 10, &op_mode);
+	if (err)
+		return err;
+
+	if (op_mode == client_data->pw.mag_pm)
+		return count;
+
+	mutex_lock(&client_data->mutex_op_mode);
+
+
+	if (op_mode < BMI_MAG_PM_MAX) {
+		switch (op_mode) {
+		case BMI_MAG_PM_NORMAL:
+			/* need to modify as mag sensor connected,
+			 * set write address to 0x4c and triggers
+			 * write operation
+			 * 0x4c(op mode control reg)
+			 * enables normal mode in magnetometer */
+#if defined(BMI160_AKM09912_SUPPORT)
+			err = bmi160_set_bst_akm_and_secondary_if_powermode(
+			BMI160_MAG_FORCE_MODE);
+#else
+			err = bmi160_set_bmm150_mag_and_secondary_if_power_mode(
+			BMI160_MAG_FORCE_MODE);
+#endif
+			client_data->pw.mag_pm = BMI_MAG_PM_NORMAL;
+			bmi_delay(5);
+			break;
+		case BMI_MAG_PM_LP1:
+			/* need to modify as mag sensor connected,
+			 * set write address to 0x4 band triggers
+			 * write operation
+			 * 0x4b(bmm150, power control reg, bit0)
+			 * enables power in magnetometer*/
+#if defined(BMI160_AKM09912_SUPPORT)
+			err = bmi160_set_bst_akm_and_secondary_if_powermode(
+			BMI160_MAG_FORCE_MODE);
+#else
+			err = bmi160_set_bmm150_mag_and_secondary_if_power_mode(
+			BMI160_MAG_FORCE_MODE);
+#endif
+			client_data->pw.mag_pm = BMI_MAG_PM_LP1;
+			bmi_delay(5);
+			break;
+		case BMI_MAG_PM_SUSPEND:
+		case BMI_MAG_PM_LP2:
+#if defined(BMI160_AKM09912_SUPPORT)
+		err = bmi160_set_bst_akm_and_secondary_if_powermode(
+		BMI160_MAG_SUSPEND_MODE);
+#else
+		err = bmi160_set_bmm150_mag_and_secondary_if_power_mode(
+		BMI160_MAG_SUSPEND_MODE);
+#endif
+			client_data->pw.mag_pm = op_mode;
+			bmi_delay(5);
+			break;
+		default:
+			mutex_unlock(&client_data->mutex_op_mode);
+			return -EINVAL;
+		}
+	} else {
+		mutex_unlock(&client_data->mutex_op_mode);
+		return -EINVAL;
+	}
+
+	mutex_unlock(&client_data->mutex_op_mode);
+
+	if (err) {
+		dev_err(client_data->dev,
+			"Failed to switch BMI160 mag power mode:%d\n",
+			client_data->pw.mag_pm);
+		return err;
+	} else
+		return count;
+
+}
+
+static ssize_t bmi160_mag_odr_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err = 0;
+	unsigned char mag_odr = 0;
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+
+	err = BMI_CALL_API(get_mag_output_data_rate)(&mag_odr);
+	if (err)
+		return err;
+
+	client_data->odr.mag_odr = mag_odr;
+	return snprintf(buf, 16, "%d\n", mag_odr);
+}
+
+static ssize_t bmi160_mag_odr_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	int err;
+	unsigned long mag_odr;
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+
+	err = kstrtoul(buf, 10, &mag_odr);
+	if (err)
+		return err;
+	/*1~25/32hz,..6(25hz),7(50hz),... */
+	err = BMI_CALL_API(set_mag_output_data_rate)(mag_odr);
+	if (err)
+		return -EIO;
+
+	client_data->odr.mag_odr = mag_odr;
+	return count;
+}
+
+static ssize_t bmi160_mag_i2c_address_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	u8 data;
+	s8 err;
+
+	err = BMI_CALL_API(set_mag_manual_enable)(1);
+	err += BMI_CALL_API(get_i2c_device_addr)(&data);
+	err += BMI_CALL_API(set_mag_manual_enable)(0);
+
+	if (err < 0)
+		return err;
+	return snprintf(buf, 16, "0x%x\n", data);
+}
+
+static ssize_t bmi160_mag_i2c_address_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	err += BMI_CALL_API(set_mag_manual_enable)(1);
+	if (!err)
+		err += BMI_CALL_API(set_i2c_device_addr)((unsigned char)data);
+	err += BMI_CALL_API(set_mag_manual_enable)(0);
+
+	if (err < 0)
+		return -EIO;
+	return count;
+}
+
+static ssize_t bmi160_mag_value_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+	struct bmi160_mag_xyz_s32_t data;
+	int err;
+	/* raw data with compensation */
+#if defined(BMI160_AKM09912_SUPPORT)
+	err = bmi160_bst_akm09912_compensate_xyz(&data);
+#else
+	err = bmi160_bmm150_mag_compensate_xyz(&data);
+#endif
+
+	if (err < 0) {
+		memset(&data, 0, sizeof(data));
+		dev_err(client_data->dev, "mag not ready!\n");
+	}
+	return snprintf(buf, 48, "%hd %hd %hd\n", data.x,
+				data.y, data.z);
+}
+static ssize_t bmi160_mag_offset_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err = 0;
+	unsigned char mag_offset;
+	err = BMI_CALL_API(get_mag_offset)(&mag_offset);
+	if (err)
+		return err;
+
+	return snprintf(buf, 16, "%d\n", mag_offset);
+
+}
+
+static ssize_t bmi160_mag_offset_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	err += BMI_CALL_API(set_mag_manual_enable)(1);
+	if (err == 0)
+		err += BMI_CALL_API(set_mag_offset)((unsigned char)data);
+	err += BMI_CALL_API(set_mag_manual_enable)(0);
+
+	if (err < 0)
+		return -EIO;
+	return count;
+}
+
+static ssize_t bmi160_mag_chip_id_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	s8 err = 0;
+	u8 mag_chipid;
+
+	err = bmi160_set_mag_manual_enable(0x01);
+	/* read mag chip_id value */
+#if defined(BMI160_AKM09912_SUPPORT)
+	err += bmi160_set_mag_read_addr(AKM09912_CHIP_ID_REG);
+		/* 0x04 is mag_x lsb register */
+	err += bmi160_read_reg(BMI160_USER_DATA_0_MAG_X_LSB__REG,
+							&mag_chipid, 1);
+
+	/* Must add this commands to re-set data register addr of mag sensor */
+	err += bmi160_set_mag_read_addr(AKM_DATA_REGISTER);
+#else
+	err += bmi160_set_mag_read_addr(BMI160_BMM150_CHIP_ID);
+	/* 0x04 is mag_x lsb register */
+	err += bmi160_read_reg(BMI160_USER_DATA_0_MAG_X_LSB__REG,
+							&mag_chipid, 1);
+
+	/* Must add this commands to re-set data register addr of mag sensor */
+	/* 0x42 is  bmm150 data register address */
+	err += bmi160_set_mag_read_addr(BMI160_BMM150_DATA_REG);
+#endif
+
+	err += bmi160_set_mag_manual_enable(0x00);
+
+	if (err)
+		return err;
+
+	return snprintf(buf, 16, "%x\n", mag_chipid);
+
+}
+
+static ssize_t bmi160_mag_chip_name_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	u8 mag_chipid = 0;
+#if defined(BMI160_AKM09912_SUPPORT)
+	mag_chipid = 15;
+#else
+	mag_chipid = 150;
+#endif
+	return snprintf(buf, 16, "%d\n", mag_chipid);
+}
+
+struct bmi160_mag_xyz_s32_t mag_compensate;
+static ssize_t bmi160_mag_compensate_xyz_show(struct device *dev,
+	struct device_attribute *attr, char *buf)
+{
+	memcpy(buf, &mag_compensate, sizeof(mag_compensate));
+	return sizeof(mag_compensate);
+}
+static ssize_t bmi160_mag_compensate_xyz_store(struct device *dev,
+	struct device_attribute *attr, const char *buf, size_t count)
+{
+	struct bmi160_mag_xyzr_t mag_raw;
+	memset(&mag_compensate, 0, sizeof(mag_compensate));
+	memset(&mag_raw, 0, sizeof(mag_raw));
+	mag_raw.x = (buf[1] << 8 | buf[0]);
+	mag_raw.y = (buf[3] << 8 | buf[2]);
+	mag_raw.z = (buf[5] << 8 | buf[4]);
+	mag_raw.r = (buf[7] << 8 | buf[6]);
+	mag_raw.x = mag_raw.x >> 3;
+	mag_raw.y = mag_raw.y >> 3;
+	mag_raw.z = mag_raw.z >> 1;
+	mag_raw.r = mag_raw.r >> 2;
+	bmi160_bmm150_mag_compensate_xyz_raw(
+	&mag_compensate, mag_raw);
+	return count;
+}
+
+#endif
+
+#if defined(BMI160_ENABLE_INT1) || defined(BMI160_ENABLE_INT2)
+static ssize_t bmi_enable_int_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	int interrupt_type, value;
+
+	sscanf(buf, "%3d %3d", &interrupt_type, &value);
+
+	if (interrupt_type < 0 || interrupt_type > 16)
+		return -EINVAL;
+
+	if (interrupt_type <= BMI_FLAT_INT) {
+		if (BMI_CALL_API(set_intr_enable_0)
+				(bmi_interrupt_type[interrupt_type], value) < 0)
+			return -EINVAL;
+	} else if (interrupt_type <= BMI_FWM_INT) {
+		if (BMI_CALL_API(set_intr_enable_1)
+			(bmi_interrupt_type[interrupt_type], value) < 0)
+			return -EINVAL;
+	} else {
+		if (BMI_CALL_API(set_intr_enable_2)
+			(bmi_interrupt_type[interrupt_type], value) < 0)
+			return -EINVAL;
+	}
+
+	return count;
+}
+
+#endif
+
+static ssize_t bmi160_show_reg_sel(struct device *dev
+		, struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+
+	if (client_data == NULL) {
+		printk(KERN_ERR "Invalid client_data pointer");
+		return -ENODEV;
+	}
+
+	return snprintf(buf, 64, "reg=0X%02X, len=%d\n",
+		client_data->reg_sel, client_data->reg_len);
+}
+
+static ssize_t bmi160_store_reg_sel(struct device *dev
+		, struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+	ssize_t ret;
+
+	if (client_data == NULL) {
+		printk(KERN_ERR "Invalid client_data pointer");
+		return -ENODEV;
+	}
+	ret = sscanf(buf, "%11X %11d",
+		&client_data->reg_sel, &client_data->reg_len);
+	if (ret != 2) {
+		dev_err(client_data->dev, "Invalid argument");
+		return -EINVAL;
+	}
+
+	return count;
+}
+
+static ssize_t bmi160_show_reg_val(struct device *dev
+		, struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+
+	ssize_t ret;
+	u8 reg_data[128], i;
+	int pos;
+
+	if (client_data == NULL) {
+		printk(KERN_ERR "Invalid client_data pointer");
+		return -ENODEV;
+	}
+
+	ret = bmi_burst_read_wrapper(client_data->device.dev_addr,
+		client_data->reg_sel,
+		reg_data, client_data->reg_len);
+	if (ret < 0) {
+		dev_err(client_data->dev, "Reg op failed");
+		return ret;
+	}
+
+	pos = 0;
+	for (i = 0; i < client_data->reg_len; ++i) {
+		pos += snprintf(buf + pos, 16, "%02X", reg_data[i]);
+		buf[pos++] = (i + 1) % 16 == 0 ? '\n' : ' ';
+	}
+	if (buf[pos - 1] == ' ')
+		buf[pos - 1] = '\n';
+
+	return pos;
+}
+
+static ssize_t bmi160_store_reg_val(struct device *dev
+		, struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+	ssize_t ret;
+	u8 reg_data[32];
+	int i, j, status, digit;
+
+	if (client_data == NULL) {
+		printk(KERN_ERR "Invalid client_data pointer");
+		return -ENODEV;
+	}
+	status = 0;
+	for (i = j = 0; i < count && j < client_data->reg_len; ++i) {
+		if (buf[i] == ' ' || buf[i] == '\n' || buf[i] == '\t' ||
+			buf[i] == '\r') {
+			status = 0;
+			++j;
+			continue;
+		}
+		digit = buf[i] & 0x10 ? (buf[i] & 0xF) : ((buf[i] & 0xF) + 9);
+		printk(KERN_INFO "digit is %d", digit);
+		switch (status) {
+		case 2:
+			++j; /* Fall thru */
+		case 0:
+			reg_data[j] = digit;
+			status = 1;
+			break;
+		case 1:
+			reg_data[j] = reg_data[j] * 16 + digit;
+			status = 2;
+			break;
+		}
+	}
+	if (status > 0)
+		++j;
+	if (j > client_data->reg_len)
+		j = client_data->reg_len;
+	else if (j < client_data->reg_len) {
+		dev_err(client_data->dev, "Invalid argument");
+		return -EINVAL;
+	}
+	printk(KERN_INFO "Reg data read as");
+	for (i = 0; i < j; ++i)
+		printk(KERN_INFO "%d", reg_data[i]);
+
+	ret = BMI_CALL_API(write_reg)(
+		client_data->reg_sel,
+		reg_data, client_data->reg_len);
+	if (ret < 0) {
+		dev_err(client_data->dev, "Reg op failed");
+		return ret;
+	}
+
+	return count;
+}
+
+static ssize_t bmi160_driver_version_show(struct device *dev
+		, struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct bmi_client_data *client_data = input_get_drvdata(input);
+	int ret;
+
+	if (client_data == NULL) {
+		printk(KERN_ERR "Invalid client_data pointer");
+		return -ENODEV;
+	}
+
+	ret = snprintf(buf, 128, "Driver version: %s\n",
+			DRIVER_VERSION);
+
+	return ret;
+}
+static DEVICE_ATTR(chip_id, S_IRUGO,
+		bmi160_chip_id_show, NULL);
+static DEVICE_ATTR(err_st, S_IRUGO,
+		bmi160_err_st_show, NULL);
+static DEVICE_ATTR(sensor_time, S_IRUGO,
+		bmi160_sensor_time_show, NULL);
+
+static DEVICE_ATTR(selftest, S_IRUGO | S_IWUSR,
+		bmi160_selftest_show, bmi160_selftest_store);
+static DEVICE_ATTR(fifo_flush, S_IRUGO | S_IWUSR,
+		NULL, bmi160_fifo_flush_store);
+static DEVICE_ATTR(fifo_bytecount, S_IRUGO | S_IWUSR,
+		bmi160_fifo_bytecount_show, bmi160_fifo_bytecount_store);
+static DEVICE_ATTR(fifo_data_sel, S_IRUGO | S_IWUSR,
+		bmi160_fifo_data_sel_show, bmi160_fifo_data_sel_store);
+static DEVICE_ATTR(fifo_data_frame, S_IRUGO,
+		bmi160_fifo_data_out_frame_show, NULL);
+
+static DEVICE_ATTR(fifo_watermark, S_IRUGO | S_IWUSR,
+		bmi160_fifo_watermark_show, bmi160_fifo_watermark_store);
+
+static DEVICE_ATTR(fifo_header_en, S_IRUGO | S_IWUSR,
+		bmi160_fifo_header_en_show, bmi160_fifo_header_en_store);
+static DEVICE_ATTR(fifo_time_en, S_IRUGO | S_IWUSR,
+		bmi160_fifo_time_en_show, bmi160_fifo_time_en_store);
+static DEVICE_ATTR(fifo_int_tag_en, S_IRUGO | S_IWUSR,
+		bmi160_fifo_int_tag_en_show, bmi160_fifo_int_tag_en_store);
+
+static DEVICE_ATTR(temperature, S_IRUGO,
+		bmi160_temperature_show, NULL);
+static DEVICE_ATTR(place, S_IRUGO,
+		bmi160_place_show, NULL);
+static DEVICE_ATTR(delay, S_IRUGO | S_IWUSR,
+		bmi160_delay_show, bmi160_delay_store);
+static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR,
+		bmi160_enable_show, bmi160_enable_store);
+static DEVICE_ATTR(acc_range, S_IRUGO | S_IWUSR,
+		bmi160_acc_range_show, bmi160_acc_range_store);
+static DEVICE_ATTR(acc_odr, S_IRUGO | S_IWUSR,
+		bmi160_acc_odr_show, bmi160_acc_odr_store);
+static DEVICE_ATTR(acc_op_mode, S_IRUGO | S_IWUSR,
+		bmi160_acc_op_mode_show, bmi160_acc_op_mode_store);
+static DEVICE_ATTR(acc_value, S_IRUGO,
+		bmi160_acc_value_show, NULL);
+static DEVICE_ATTR(acc_fast_calibration_x, S_IRUGO | S_IWUSR,
+		bmi160_acc_fast_calibration_x_show,
+		bmi160_acc_fast_calibration_x_store);
+static DEVICE_ATTR(acc_fast_calibration_y, S_IRUGO | S_IWUSR,
+		bmi160_acc_fast_calibration_y_show,
+		bmi160_acc_fast_calibration_y_store);
+static DEVICE_ATTR(acc_fast_calibration_z, S_IRUGO | S_IWUSR,
+		bmi160_acc_fast_calibration_z_show,
+		bmi160_acc_fast_calibration_z_store);
+static DEVICE_ATTR(acc_offset_x, S_IRUGO | S_IWUSR,
+		bmi160_acc_offset_x_show,
+		bmi160_acc_offset_x_store);
+static DEVICE_ATTR(acc_offset_y, S_IRUGO | S_IWUSR,
+		bmi160_acc_offset_y_show,
+		bmi160_acc_offset_y_store);
+static DEVICE_ATTR(acc_offset_z, S_IRUGO | S_IWUSR,
+		bmi160_acc_offset_z_show,
+		bmi160_acc_offset_z_store);
+static DEVICE_ATTR(test, S_IRUGO,
+		bmi160_test_show, NULL);
+static DEVICE_ATTR(stc_enable, S_IRUGO | S_IWUSR,
+		bmi160_step_counter_enable_show,
+		bmi160_step_counter_enable_store);
+static DEVICE_ATTR(stc_mode, S_IRUGO | S_IWUSR,
+		NULL, bmi160_step_counter_mode_store);
+static DEVICE_ATTR(stc_clc, S_IRUGO | S_IWUSR,
+		NULL, bmi160_step_counter_clc_store);
+static DEVICE_ATTR(stc_value, S_IRUGO,
+		bmi160_step_counter_value_show, NULL);
+static DEVICE_ATTR(reg_sel, S_IRUGO | S_IWUSR,
+		bmi160_show_reg_sel, bmi160_store_reg_sel);
+static DEVICE_ATTR(reg_val, S_IRUGO | S_IWUSR,
+		bmi160_show_reg_val, bmi160_store_reg_val);
+static DEVICE_ATTR(driver_version, S_IRUGO,
+		bmi160_driver_version_show, NULL);
+/* gyro part */
+static DEVICE_ATTR(gyro_op_mode, S_IRUGO | S_IWUSR,
+		bmi160_gyro_op_mode_show, bmi160_gyro_op_mode_store);
+static DEVICE_ATTR(gyro_value, S_IRUGO,
+		bmi160_gyro_value_show, NULL);
+static DEVICE_ATTR(gyro_range, S_IRUGO | S_IWUSR,
+		bmi160_gyro_range_show, bmi160_gyro_range_store);
+static DEVICE_ATTR(gyro_odr, S_IRUGO | S_IWUSR,
+		bmi160_gyro_odr_show, bmi160_gyro_odr_store);
+static DEVICE_ATTR(gyro_fast_calibration_en, S_IRUGO | S_IWUSR,
+bmi160_gyro_fast_calibration_en_show, bmi160_gyro_fast_calibration_en_store);
+static DEVICE_ATTR(gyro_offset_x, S_IRUGO | S_IWUSR,
+bmi160_gyro_offset_x_show, bmi160_gyro_offset_x_store);
+static DEVICE_ATTR(gyro_offset_y, S_IRUGO | S_IWUSR,
+bmi160_gyro_offset_y_show, bmi160_gyro_offset_y_store);
+static DEVICE_ATTR(gyro_offset_z, S_IRUGO | S_IWUSR,
+bmi160_gyro_offset_z_show, bmi160_gyro_offset_z_store);
+
+#ifdef BMI160_MAG_INTERFACE_SUPPORT
+static DEVICE_ATTR(mag_op_mode, S_IRUGO | S_IWUSR,
+		bmi160_mag_op_mode_show, bmi160_mag_op_mode_store);
+static DEVICE_ATTR(mag_odr, S_IRUGO | S_IWUSR,
+		bmi160_mag_odr_show, bmi160_mag_odr_store);
+static DEVICE_ATTR(mag_i2c_addr, S_IRUGO | S_IWUSR,
+		bmi160_mag_i2c_address_show, bmi160_mag_i2c_address_store);
+static DEVICE_ATTR(mag_value, S_IRUGO,
+		bmi160_mag_value_show, NULL);
+static DEVICE_ATTR(mag_offset, S_IRUGO | S_IWUSR,
+		bmi160_mag_offset_show, bmi160_mag_offset_store);
+static DEVICE_ATTR(mag_chip_id, S_IRUGO,
+		bmi160_mag_chip_id_show, NULL);
+static DEVICE_ATTR(mag_chip_name, S_IRUGO,
+		bmi160_mag_chip_name_show, NULL);
+static DEVICE_ATTR(mag_compensate, S_IRUGO | S_IWUSR,
+		bmi160_mag_compensate_xyz_show,
+		bmi160_mag_compensate_xyz_store);
+#endif
+
+
+#if defined(BMI160_ENABLE_INT1) || defined(BMI160_ENABLE_INT2)
+static DEVICE_ATTR(enable_int, S_IRUGO | S_IWUSR,
+		NULL, bmi_enable_int_store);
+static DEVICE_ATTR(anymot_duration, S_IRUGO | S_IWUSR,
+		bmi160_anymot_duration_show, bmi160_anymot_duration_store);
+static DEVICE_ATTR(anymot_threshold, S_IRUGO | S_IWUSR,
+		bmi160_anymot_threshold_show, bmi160_anymot_threshold_store);
+static DEVICE_ATTR(std_stu, S_IRUGO,
+		bmi160_step_detector_status_show, NULL);
+static DEVICE_ATTR(std_en, S_IRUGO | S_IWUSR,
+		bmi160_step_detector_enable_show,
+		bmi160_step_detector_enable_store);
+static DEVICE_ATTR(sig_en, S_IRUGO | S_IWUSR,
+		bmi160_signification_motion_enable_show,
+		bmi160_signification_motion_enable_store);
+
+#endif
+
+
+
+static DEVICE_ATTR(bmi_value, S_IRUGO,
+		bmi160_bmi_value_show, NULL);
+
+
+static struct attribute *bmi160_attributes[] = {
+	&dev_attr_chip_id.attr,
+	&dev_attr_err_st.attr,
+	&dev_attr_sensor_time.attr,
+	&dev_attr_selftest.attr,
+	&dev_attr_driver_version.attr,
+	&dev_attr_test.attr,
+	&dev_attr_fifo_flush.attr,
+	&dev_attr_fifo_header_en.attr,
+	&dev_attr_fifo_time_en.attr,
+	&dev_attr_fifo_int_tag_en.attr,
+	&dev_attr_fifo_bytecount.attr,
+	&dev_attr_fifo_data_sel.attr,
+	&dev_attr_fifo_data_frame.attr,
+
+	&dev_attr_fifo_watermark.attr,
+
+	&dev_attr_enable.attr,
+	&dev_attr_delay.attr,
+	&dev_attr_temperature.attr,
+	&dev_attr_place.attr,
+
+	&dev_attr_acc_range.attr,
+	&dev_attr_acc_odr.attr,
+	&dev_attr_acc_op_mode.attr,
+	&dev_attr_acc_value.attr,
+
+	&dev_attr_acc_fast_calibration_x.attr,
+	&dev_attr_acc_fast_calibration_y.attr,
+	&dev_attr_acc_fast_calibration_z.attr,
+	&dev_attr_acc_offset_x.attr,
+	&dev_attr_acc_offset_y.attr,
+	&dev_attr_acc_offset_z.attr,
+
+	&dev_attr_stc_enable.attr,
+	&dev_attr_stc_mode.attr,
+	&dev_attr_stc_clc.attr,
+	&dev_attr_stc_value.attr,
+
+	&dev_attr_gyro_op_mode.attr,
+	&dev_attr_gyro_value.attr,
+	&dev_attr_gyro_range.attr,
+	&dev_attr_gyro_odr.attr,
+	&dev_attr_gyro_fast_calibration_en.attr,
+	&dev_attr_gyro_offset_x.attr,
+	&dev_attr_gyro_offset_y.attr,
+	&dev_attr_gyro_offset_z.attr,
+
+#ifdef BMI160_MAG_INTERFACE_SUPPORT
+	&dev_attr_mag_chip_id.attr,
+	&dev_attr_mag_op_mode.attr,
+	&dev_attr_mag_odr.attr,
+	&dev_attr_mag_i2c_addr.attr,
+	&dev_attr_mag_chip_name.attr,
+	&dev_attr_mag_value.attr,
+	&dev_attr_mag_offset.attr,
+	&dev_attr_mag_compensate.attr,
+#endif
+
+#if defined(BMI160_ENABLE_INT1) || defined(BMI160_ENABLE_INT2)
+	&dev_attr_enable_int.attr,
+
+	&dev_attr_anymot_duration.attr,
+	&dev_attr_anymot_threshold.attr,
+	&dev_attr_std_stu.attr,
+	&dev_attr_std_en.attr,
+	&dev_attr_sig_en.attr,
+
+#endif
+	&dev_attr_reg_sel.attr,
+	&dev_attr_reg_val.attr,
+	&dev_attr_bmi_value.attr,
+	NULL
+};
+
+static struct attribute_group bmi160_attribute_group = {
+	.attrs = bmi160_attributes
+};
+
+#if defined(BMI160_ENABLE_INT1) || defined(BMI160_ENABLE_INT2)
+static void bmi_slope_interrupt_handle(struct bmi_client_data *client_data)
+{
+	/* anym_first[0..2]: x, y, z */
+	u8 anym_first[3] = {0};
+	u8 status2;
+	u8 anym_sign;
+	u8 i = 0;
+
+	client_data->device.bus_read(client_data->device.dev_addr,
+				BMI160_USER_INTR_STAT_2_ADDR, &status2, 1);
+	anym_first[0] = BMI160_GET_BITSLICE(status2,
+				BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_X);
+	anym_first[1] = BMI160_GET_BITSLICE(status2,
+				BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Y);
+	anym_first[2] = BMI160_GET_BITSLICE(status2,
+				BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Z);
+	anym_sign = BMI160_GET_BITSLICE(status2,
+				BMI160_USER_INTR_STAT_2_ANY_MOTION_SIGN);
+
+	for (i = 0; i < 3; i++) {
+		if (anym_first[i]) {
+			/*1: negative*/
+			if (anym_sign)
+				dev_notice(client_data->dev,
+				"Anymotion interrupt happend!"
+				"%s axis, negative sign\n", bmi_axis_name[i]);
+			else
+				dev_notice(client_data->dev,
+				"Anymotion interrupt happend!"
+				"%s axis, postive sign\n", bmi_axis_name[i]);
+		}
+	}
+
+
+}
+
+static void bmi_fifo_watermark_interrupt_handle
+				(struct bmi_client_data *client_data)
+{
+	int err = 0;
+	unsigned int fifo_len0 = 0;
+	unsigned int  fifo_frmbytes_ext = 0;
+	unsigned char *fifo_data = NULL;
+	fifo_data = kzalloc(FIFO_DATA_BUFSIZE, GFP_KERNEL);
+	/*TO DO*/
+	if (NULL == fifo_data) {
+			dev_err(client_data->dev, "no memory available");
+			err = -ENOMEM;
+	}
+	bmi_fifo_frame_bytes_extend_calc(client_data, &fifo_frmbytes_ext);
+
+	if (client_data->pw.acc_pm == 2 && client_data->pw.gyro_pm == 2
+					&& client_data->pw.mag_pm == 2)
+		printk(KERN_INFO "pw_acc: %d, pw_gyro: %d\n",
+			client_data->pw.acc_pm, client_data->pw.gyro_pm);
+	if (!client_data->fifo_data_sel)
+		printk(KERN_INFO "no selsect sensor fifo, fifo_data_sel:%d\n",
+						client_data->fifo_data_sel);
+
+	err = BMI_CALL_API(fifo_length)(&fifo_len0);
+	client_data->fifo_bytecount = fifo_len0;
+
+	if (client_data->fifo_bytecount == 0 || err)
+		return;
+
+	if (client_data->fifo_bytecount + fifo_frmbytes_ext > FIFO_DATA_BUFSIZE)
+		client_data->fifo_bytecount = FIFO_DATA_BUFSIZE;
+	/* need give attention for the time of burst read*/
+	if (!err) {
+		err = bmi_burst_read_wrapper(client_data->device.dev_addr,
+			BMI160_USER_FIFO_DATA__REG, fifo_data,
+			client_data->fifo_bytecount + fifo_frmbytes_ext);
+	} else
+		dev_err(client_data->dev, "read fifo leght err");
+
+	if (err)
+		dev_err(client_data->dev, "brust read fifo err\n");
+	/*err = bmi_fifo_analysis_handle(client_data, fifo_data,
+			client_data->fifo_bytecount + 20, fifo_out_data);*/
+	if (fifo_data != NULL) {
+		kfree(fifo_data);
+		fifo_data = NULL;
+	}
+
+}
+static void bmi_data_ready_interrupt_handle(
+	struct bmi_client_data *client_data, uint8_t status)
+{
+	uint8_t data12[12] = {0};
+	struct bmi160_accel_t accel;
+	struct bmi160_gyro_t gyro;
+	struct timespec ts;
+	client_data->device.bus_read(client_data->device.dev_addr,
+	BMI160_USER_DATA_8_ADDR, data12, 12);
+	if (status & 0x80)
+	{
+		/*report acc data*/
+		/* Data X */
+		accel.x = (s16)((((s32)((s8)data12[7])) << BMI160_SHIFT_BIT_POSITION_BY_08_BITS) | (data12[6]));
+		/* Data Y */
+		accel.y = (s16)((((s32)((s8)data12[9])) << BMI160_SHIFT_BIT_POSITION_BY_08_BITS) | (data12[8]));
+		/* Data Z */
+		accel.z = (s16)((((s32)((s8)data12[11]))<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS) | (data12[10]));
+		ts = ns_to_timespec(client_data->timestamp);
+		//printk("acc puneet ts.tv_sec %ld ts.tv_nsec %ld\n",ts.tv_sec,ts.tv_nsec);
+		input_event(client_data->input, EV_MSC, 6, ts.tv_sec);
+		input_event(client_data->input, EV_MSC, 6, ts.tv_nsec);
+		input_event(client_data->input, EV_MSC, MSC_GESTURE, accel.x);
+		input_event(client_data->input, EV_MSC, MSC_RAW, accel.y);
+		input_event(client_data->input, EV_MSC, MSC_SCAN, accel.z);
+		input_sync(client_data->input);
+	}
+	if (status & 0x40)
+	{
+		/*report gyro data*/
+		/* Data X */
+		gyro.x = (s16)((((s32)((s8)data12[1])) << BMI160_SHIFT_BIT_POSITION_BY_08_BITS) | (data12[0]));
+		/* Data Y */
+		gyro.y = (s16)((((s32)((s8)data12[3])) << BMI160_SHIFT_BIT_POSITION_BY_08_BITS) | (data12[2]));
+		/* Data Z */
+		gyro.z = (s16)((((s32)((s8)data12[5]))<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS) | (data12[4]));
+		ts = ns_to_timespec(client_data->timestamp);
+		//printk("gyro puneet ts.tv_sec %ld ts.tv_nsec %ld\n",ts.tv_sec,ts.tv_nsec);
+		input_event(client_data->gyro_input, EV_MSC, 6, ts.tv_sec);
+		input_event(client_data->gyro_input, EV_MSC, 6, ts.tv_nsec);
+		input_event(client_data->gyro_input, EV_MSC, MSC_GESTURE, gyro.x);
+		input_event(client_data->gyro_input, EV_MSC, MSC_RAW, gyro.y);
+		input_event(client_data->gyro_input, EV_MSC, MSC_SCAN, gyro.z);
+		input_sync(client_data->gyro_input);
+	}
+}
+
+static void bmi_signification_motion_interrupt_handle(
+		struct bmi_client_data *client_data)
+{
+	printk(KERN_INFO "bmi_signification_motion_interrupt_handle\n");
+	input_event(client_data->input, EV_MSC, INPUT_EVENT_SGM, 1);
+/*input_report_rel(client_data->input,INPUT_EVENT_SGM,1);*/
+	input_sync(client_data->input);
+	bmi160_set_command_register(CMD_RESET_INT_ENGINE);
+
+}
+static void bmi_stepdetector_interrupt_handle(
+	struct bmi_client_data *client_data)
+{
+	u8 current_step_dector_st = 0;
+	client_data->pedo_data.wkar_step_detector_status++;
+	current_step_dector_st =
+		client_data->pedo_data.wkar_step_detector_status;
+	client_data->std = ((current_step_dector_st == 1) ? 0 : 1);
+
+	input_event(client_data->input, EV_MSC, INPUT_EVENT_STEP_DETECTOR, 1);
+	input_sync(client_data->input);
+}
+
+static void bmi_irq_work_func(struct work_struct *work)
+{
+	struct bmi_client_data *client_data =
+		container_of((struct work_struct *)work,
+			struct bmi_client_data, irq_work);
+
+	unsigned char int_status[4] = {0, 0, 0, 0};
+	uint8_t status = 0;
+
+	//client_data->device.bus_read(client_data->device.dev_addr,
+	//			BMI160_USER_INTR_STAT_0_ADDR, int_status, 4);
+	client_data->device.bus_read(client_data->device.dev_addr,
+	BMI160_USER_STAT_ADDR, &status, 1);
+	//printk("status = 0x%x", status);
+	if (BMI160_GET_BITSLICE(int_status[0],
+					BMI160_USER_INTR_STAT_0_ANY_MOTION))
+		bmi_slope_interrupt_handle(client_data);
+
+	if (BMI160_GET_BITSLICE(int_status[0],
+			BMI160_USER_INTR_STAT_0_STEP_INTR))
+		bmi_stepdetector_interrupt_handle(client_data);
+	if (BMI160_GET_BITSLICE(int_status[1],
+			BMI160_USER_INTR_STAT_1_FIFO_WM_INTR))
+		bmi_fifo_watermark_interrupt_handle(client_data);
+	if ((status & 0x80) || (status & 0x40))
+		bmi_data_ready_interrupt_handle(client_data, status);
+	/* Clear ALL inputerrupt status after handler sig mition*/
+	/* Put this commads intot the last one*/
+	if (BMI160_GET_BITSLICE(int_status[0],
+		BMI160_USER_INTR_STAT_0_SIGNIFICANT_INTR))
+		bmi_signification_motion_interrupt_handle(client_data);
+
+}
+
+static void bmi160_delay_sigmo_work_func(struct work_struct *work)
+{
+	struct bmi_client_data *client_data =
+	container_of(work, struct bmi_client_data,
+	delay_work_sig.work);
+	unsigned char int_status[4] = {0, 0, 0, 0};
+
+	client_data->device.bus_read(client_data->device.dev_addr,
+				BMI160_USER_INTR_STAT_0_ADDR, int_status, 4);
+	if (BMI160_GET_BITSLICE(int_status[0],
+		BMI160_USER_INTR_STAT_0_SIGNIFICANT_INTR))
+		bmi_signification_motion_interrupt_handle(client_data);
+}
+
+static irqreturn_t bmi_irq_handler(int irq, void *handle)
+{
+	struct bmi_client_data *client_data = handle;
+	int in_suspend_copy;
+	in_suspend_copy = atomic_read(&client_data->in_suspend);
+	client_data->timestamp= get_current_timestamp();
+	if (client_data == NULL)
+		return IRQ_HANDLED;
+	if (client_data->dev == NULL)
+		return IRQ_HANDLED;
+		/*this only deal with SIG_motion CTS test*/
+	if ((in_suspend_copy == 1) &&
+		(client_data->sig_flag == 1)) {
+		/*wake_lock_timeout(&client_data->wakelock, HZ);*/
+		schedule_delayed_work(&client_data->delay_work_sig,
+			msecs_to_jiffies(50));
+	}
+	schedule_work(&client_data->irq_work);
+
+	return IRQ_HANDLED;
+}
+#endif /* defined(BMI_ENABLE_INT1)||defined(BMI_ENABLE_INT2) */
+
+static int bmi_restore_hw_cfg(struct bmi_client_data *client)
+{
+	int err = 0;
+
+	if ((client->fifo_data_sel) & (1 << BMI_ACC_SENSOR)) {
+		err += BMI_CALL_API(set_accel_range)(client->range.acc_range);
+		err += BMI_CALL_API(set_accel_output_data_rate)
+				(client->odr.acc_odr);
+		err += BMI_CALL_API(set_fifo_accel_enable)(1);
+	}
+	if ((client->fifo_data_sel) & (1 << BMI_GYRO_SENSOR)) {
+		err += BMI_CALL_API(set_gyro_range)(client->range.gyro_range);
+		err += BMI_CALL_API(set_gyro_output_data_rate)
+				(client->odr.gyro_odr);
+		err += BMI_CALL_API(set_fifo_gyro_enable)(1);
+	}
+	if ((client->fifo_data_sel) & (1 << BMI_MAG_SENSOR)) {
+		err += BMI_CALL_API(set_mag_output_data_rate)
+				(client->odr.mag_odr);
+		err += BMI_CALL_API(set_fifo_mag_enable)(1);
+	}
+	err += BMI_CALL_API(set_command_register)(CMD_CLR_FIFO_DATA);
+
+	mutex_lock(&client->mutex_op_mode);
+	if (client->pw.acc_pm != BMI_ACC_PM_SUSPEND) {
+		err += BMI_CALL_API(set_command_register)
+				(bmi_pmu_cmd_acc_arr[BMI_ACC_PM_NORMAL]);
+		bmi_delay(3);
+	}
+	mutex_unlock(&client->mutex_op_mode);
+
+	mutex_lock(&client->mutex_op_mode);
+	if (client->pw.gyro_pm != BMI_GYRO_PM_SUSPEND) {
+		err += BMI_CALL_API(set_command_register)
+				(bmi_pmu_cmd_gyro_arr[BMI_GYRO_PM_NORMAL]);
+		bmi_delay(3);
+	}
+	mutex_unlock(&client->mutex_op_mode);
+
+	mutex_lock(&client->mutex_op_mode);
+
+	if (client->pw.mag_pm != BMI_MAG_PM_SUSPEND) {
+#ifdef BMI160_AKM09912_SUPPORT
+		err += bmi160_set_bst_akm_and_secondary_if_powermode
+					(BMI160_MAG_FORCE_MODE);
+#else
+		err += bmi160_set_bmm150_mag_and_secondary_if_power_mode
+					(BMI160_MAG_FORCE_MODE);
+#endif
+		bmi_delay(3);
+	}
+	mutex_unlock(&client->mutex_op_mode);
+
+	return err;
+}
+
+#if defined(CONFIG_USE_QUALCOMM_HAL)
+static void bmi160_accel_work_fn(struct work_struct *work)
+{
+	struct bmi_client_data *sensor;
+	ktime_t timestamp;
+	struct bmi160_accel_t data;
+	int err;
+	sensor = container_of((struct delayed_work *)work,
+				struct bmi_client_data, accel_poll_work);
+	timestamp = ktime_get();
+	err = BMI_CALL_API(read_accel_xyz)(&data);
+	if (err)
+		dev_err(sensor->dev, "read data err");
+	input_report_abs(sensor->input, ABS_X,
+		(data.x));
+	input_report_abs(sensor->input, ABS_Y,
+		(data.y));
+	input_report_abs(sensor->input, ABS_Z,
+		(data.z));
+	input_event(sensor->input,
+			EV_SYN, SYN_TIME_SEC,
+			ktime_to_timespec(timestamp).tv_sec);
+	input_event(sensor->input, EV_SYN,
+		SYN_TIME_NSEC,
+		ktime_to_timespec(timestamp).tv_nsec);
+	input_sync(sensor->input);
+	if (atomic_read(&sensor->accel_en))
+		queue_delayed_work(sensor->data_wq,
+			&sensor->accel_poll_work,
+			msecs_to_jiffies(sensor->accel_poll_ms));
+}
+static void bmi160_gyro_work_fn(struct work_struct *work)
+{
+	struct bmi_client_data *sensor;
+	ktime_t timestamp;
+	struct bmi160_gyro_t data;
+	int err;
+	sensor = container_of((struct delayed_work *)work,
+				struct bmi_client_data, gyro_poll_work);
+	timestamp = ktime_get();
+	err = BMI_CALL_API(read_gyro_xyz)(&data);
+	if (err)
+		dev_err(sensor->dev, "read data err");
+	input_report_abs(sensor->gyro_input, ABS_RX,
+		(data.x));
+	input_report_abs(sensor->gyro_input, ABS_RY,
+		(data.y));
+	input_report_abs(sensor->gyro_input, ABS_RZ,
+		(data.z));
+	input_event(sensor->gyro_input,
+			EV_SYN, SYN_TIME_SEC,
+			ktime_to_timespec(timestamp).tv_sec);
+	input_event(sensor->gyro_input, EV_SYN,
+		SYN_TIME_NSEC,
+		ktime_to_timespec(timestamp).tv_nsec);
+	input_sync(sensor->gyro_input);
+	if (atomic_read(&sensor->gyro_en))
+		queue_delayed_work(sensor->data_wq,
+			&sensor->gyro_poll_work,
+			msecs_to_jiffies(sensor->gyro_poll_ms));
+}
+static int bmi160_set_gyro_op_mode(struct bmi_client_data *client_data,
+							unsigned long op_mode)
+{
+	int err = 0;
+	mutex_lock(&client_data->mutex_op_mode);
+	if (op_mode < BMI_GYRO_PM_MAX) {
+		switch (op_mode) {
+		case BMI_GYRO_PM_NORMAL:
+			err = BMI_CALL_API(set_command_register)
+				(bmi_pmu_cmd_gyro_arr[BMI_GYRO_PM_NORMAL]);
+			client_data->pw.gyro_pm = BMI_GYRO_PM_NORMAL;
+			bmi_delay(60);
+			break;
+		case BMI_GYRO_PM_FAST_START:
+			err = BMI_CALL_API(set_command_register)
+				(bmi_pmu_cmd_gyro_arr[BMI_GYRO_PM_FAST_START]);
+			client_data->pw.gyro_pm = BMI_GYRO_PM_FAST_START;
+			bmi_delay(60);
+			break;
+		case BMI_GYRO_PM_SUSPEND:
+			err = BMI_CALL_API(set_command_register)
+				(bmi_pmu_cmd_gyro_arr[BMI_GYRO_PM_SUSPEND]);
+			client_data->pw.gyro_pm = BMI_GYRO_PM_SUSPEND;
+			bmi_delay(60);
+			break;
+		default:
+			mutex_unlock(&client_data->mutex_op_mode);
+			return -EINVAL;
+		}
+	} else {
+		mutex_unlock(&client_data->mutex_op_mode);
+		return -EINVAL;
+	}
+	mutex_unlock(&client_data->mutex_op_mode);
+	return err;
+}
+static int bmi160_accel_set_enable(
+	struct bmi_client_data *client_data, bool enable)
+{
+	int ret = 0;
+	dev_notice(client_data->dev,
+		"bmi160_accel_set_enable enable=%d\n", enable);
+	if (enable) {
+		ret = bmi160_set_acc_op_mode(client_data, 0);
+		if (ret) {
+			dev_err(client_data->dev,
+				"Fail to enable accel engine ret=%d\n", ret);
+			ret = -EBUSY;
+			goto exit;
+		}
+		queue_delayed_work(client_data->data_wq,
+				&client_data->accel_poll_work,
+				msecs_to_jiffies(client_data->accel_poll_ms));
+		atomic_set(&client_data->accel_en, 1);
+	} else {
+		atomic_set(&client_data->accel_en, 0);
+		cancel_delayed_work_sync(&client_data->accel_poll_work);
+		ret = bmi160_set_acc_op_mode(client_data, 2);
+		if (ret) {
+			dev_err(client_data->dev,
+				"Fail to disable accel engine ret=%d\n", ret);
+			ret = -EBUSY;
+			goto exit;
+		}
+	}
+exit:
+	return ret;
+}
+static int bmi160_accel_set_poll_delay(struct bmi_client_data *client_data,
+					unsigned long delay)
+{
+	dev_info(client_data->dev,
+		"bmi160_accel_set_poll_delay delay_ms=%ld\n", delay);
+	if (delay < BMI160_ACCEL_MIN_POLL_INTERVAL_MS)
+		delay = BMI160_ACCEL_MIN_POLL_INTERVAL_MS;
+	if (delay > BMI160_ACCEL_MAX_POLL_INTERVAL_MS)
+		delay = BMI160_ACCEL_MAX_POLL_INTERVAL_MS;
+	client_data->accel_poll_ms = delay;
+	if (!atomic_read(&client_data->accel_en))
+		goto exit;
+	cancel_delayed_work_sync(&client_data->accel_poll_work);
+	queue_delayed_work(client_data->data_wq,
+			&client_data->accel_poll_work,
+			msecs_to_jiffies(client_data->accel_poll_ms));
+exit:
+	return 0;
+}
+static int bmi160_gyro_set_enable(
+	struct bmi_client_data *client_data, bool enable)
+{
+	int ret = 0;
+	dev_notice(client_data->dev,
+		"bmi160_gyro_set_enable enable=%d\n", enable);
+	if (enable) {
+		ret = bmi160_set_gyro_op_mode(client_data, 0);
+		if (ret) {
+			dev_err(client_data->dev,
+				"Fail to enable gyro engine ret=%d\n", ret);
+			ret = -EBUSY;
+			goto exit;
+		}
+		queue_delayed_work(client_data->data_wq,
+				&client_data->gyro_poll_work,
+				msecs_to_jiffies(client_data->gyro_poll_ms));
+		atomic_set(&client_data->gyro_en, 1);
+	} else {
+		atomic_set(&client_data->gyro_en, 0);
+		cancel_delayed_work_sync(&client_data->gyro_poll_work);
+		ret = bmi160_set_gyro_op_mode(client_data, 2);
+		if (ret) {
+			dev_err(client_data->dev,
+				"Fail to disable accel engine ret=%d\n", ret);
+			ret = -EBUSY;
+			goto exit;
+		}
+	}
+exit:
+	return ret;
+}
+static int bmi160_gyro_set_poll_delay(struct bmi_client_data *client_data,
+					unsigned long delay)
+{
+	dev_info(client_data->dev,
+		"bmi160_accel_set_poll_delay delay_ms=%ld\n", delay);
+	if (delay < BMI160_GYRO_MIN_POLL_INTERVAL_MS)
+		delay = BMI160_GYRO_MIN_POLL_INTERVAL_MS;
+	if (delay > BMI160_GYRO_MAX_POLL_INTERVAL_MS)
+		delay = BMI160_GYRO_MAX_POLL_INTERVAL_MS;
+	client_data->gyro_poll_ms = delay;
+	if (!atomic_read(&client_data->gyro_en))
+		goto exit;
+	cancel_delayed_work_sync(&client_data->gyro_poll_work);
+	queue_delayed_work(client_data->data_wq,
+			&client_data->gyro_poll_work,
+			msecs_to_jiffies(client_data->gyro_poll_ms));
+exit:
+	return 0;
+}
+static int bmi160_accel_cdev_enable(struct sensors_classdev *sensors_cdev,
+			unsigned int enable)
+{
+	struct bmi_client_data *sensor = container_of(sensors_cdev,
+			struct bmi_client_data, accel_cdev);
+	return bmi160_accel_set_enable(sensor, enable);
+}
+static int bmi160_accel_cdev_poll_delay(struct sensors_classdev *sensors_cdev,
+			unsigned int delay_ms)
+{
+	struct bmi_client_data *sensor = container_of(sensors_cdev,
+			struct bmi_client_data, accel_cdev);
+
+	return bmi160_accel_set_poll_delay(sensor, delay_ms);
+}
+
+static int bmi160_gyro_cdev_enable(struct sensors_classdev *sensors_cdev,
+			unsigned int enable)
+{
+	struct bmi_client_data *sensor = container_of(sensors_cdev,
+			struct bmi_client_data, gyro_cdev);
+
+	return bmi160_gyro_set_enable(sensor, enable);
+}
+
+static int bmi160_gyro_cdev_poll_delay(struct sensors_classdev *sensors_cdev,
+			unsigned int delay_ms)
+{
+	struct bmi_client_data *sensor = container_of(sensors_cdev,
+			struct bmi_client_data, gyro_cdev);
+
+	return	bmi160_gyro_set_poll_delay(sensor, delay_ms);
+}
+#endif
+
+int bmi_probe(struct bmi_client_data *client_data, struct device *dev)
+{
+	int err = 0;
+#ifdef BMI160_MAG_INTERFACE_SUPPORT
+	u8 mag_dev_addr;
+	u8 mag_urst_len;
+	u8 mag_op_mode;
+#endif
+	/* check chip id */
+	err = bmi_check_chip_id(client_data);
+	if (err)
+		goto exit_err_clean;
+
+	dev_set_drvdata(dev, client_data);
+	client_data->dev = dev;
+
+	mutex_init(&client_data->mutex_enable);
+	mutex_init(&client_data->mutex_op_mode);
+
+	/* input device init */
+	err = bmi_input_init(client_data);
+	if (err < 0)
+		goto exit_err_clean;
+
+	/* sysfs node creation */
+	err = sysfs_create_group(&client_data->input->dev.kobj,
+			&bmi160_attribute_group);
+
+	if (err < 0)
+		goto exit_err_sysfs;
+
+	if (NULL != dev->platform_data) {
+		client_data->bst_pd = kzalloc(sizeof(*client_data->bst_pd),
+				GFP_KERNEL);
+
+		if (NULL != client_data->bst_pd) {
+			memcpy(client_data->bst_pd, dev->platform_data,
+					sizeof(*client_data->bst_pd));
+			dev_notice(dev, "%s sensor driver set place: p%d\n",
+					client_data->bst_pd->name,
+					client_data->bst_pd->place);
+		}
+	}
+
+	if (NULL != client_data->bst_pd) {
+			memcpy(client_data->bst_pd, dev->platform_data,
+					sizeof(*client_data->bst_pd));
+			dev_notice(dev, "%s sensor driver set place: p%d\n",
+					client_data->bst_pd->name,
+					client_data->bst_pd->place);
+		}
+
+
+	/* workqueue init */
+	INIT_DELAYED_WORK(&client_data->work, bmi_work_func);
+	atomic_set(&client_data->delay, BMI_DELAY_DEFAULT);
+	atomic_set(&client_data->wkqueue_en, 0);
+
+	/* h/w init */
+	client_data->device.delay_msec = bmi_delay;
+	err = BMI_CALL_API(init)(&client_data->device);
+
+	bmi_dump_reg(client_data);
+
+	/*power on detected*/
+	/*or softrest(cmd 0xB6) */
+	/*fatal err check*/
+	/*soft reset*/
+	err += BMI_CALL_API(set_command_register)(CMD_RESET_USER_REG);
+	bmi_delay(3);
+	if (err)
+		dev_err(dev, "Failed soft reset, er=%d", err);
+	/*usr data config page*/
+	err += BMI_CALL_API(set_target_page)(USER_DAT_CFG_PAGE);
+	if (err)
+		dev_err(dev, "Failed cffg page, er=%d", err);
+	err += bmi_get_err_status(client_data);
+	if (err) {
+		dev_err(dev, "Failed to bmi16x init!err_st=0x%x\n",
+				client_data->err_st.err_st_all);
+		goto exit_err_sysfs;
+	}
+
+#ifdef BMI160_MAG_INTERFACE_SUPPORT
+	err += bmi160_set_command_register(MAG_MODE_NORMAL);
+	bmi_delay(2);
+	err += bmi160_get_mag_power_mode_stat(&mag_op_mode);
+	bmi_delay(2);
+	err += BMI_CALL_API(get_i2c_device_addr)(&mag_dev_addr);
+	bmi_delay(2);
+#if defined(BMI160_AKM09912_SUPPORT)
+	err += BMI_CALL_API(set_i2c_device_addr)(BMI160_AKM09912_I2C_ADDRESS);
+	bmi160_bst_akm_mag_interface_init(BMI160_AKM09912_I2C_ADDRESS);
+#else
+	err += BMI_CALL_API(set_i2c_device_addr)(
+		BMI160_AUX_BMM150_I2C_ADDRESS);
+	bmi160_bmm150_mag_interface_init();
+#endif
+
+	err += bmi160_set_mag_burst(3);
+	err += bmi160_get_mag_burst(&mag_urst_len);
+	if (err)
+		dev_err(client_data->dev, "Failed cffg mag, er=%d", err);
+	dev_info(client_data->dev,
+		"BMI160 mag_urst_len:%d, mag_add:0x%x, mag_op_mode:%d\n",
+		mag_urst_len, mag_dev_addr, mag_op_mode);
+#endif
+	if (err < 0)
+		goto exit_err_sysfs;
+
+
+#if defined(BMI160_ENABLE_INT1) || defined(BMI160_ENABLE_INT2)
+		/*wake_lock_init(&client_data->wakelock,
+			WAKE_LOCK_SUSPEND, "bmi160");*/
+		client_data->gpio_pin = of_get_named_gpio_flags(dev->of_node,
+					"bmi,gpio_irq", 0, NULL);
+		dev_info(client_data->dev, "BMI160 qpio number:%d\n",
+					client_data->gpio_pin);
+		err += gpio_request_one(client_data->gpio_pin,
+					GPIOF_IN, "bmi160_int");
+		err += gpio_direction_input(client_data->gpio_pin);
+		client_data->IRQ = gpio_to_irq(client_data->gpio_pin);
+		if (err) {
+			dev_err(client_data->dev,
+				"can not request gpio to irq number\n");
+			client_data->gpio_pin = 0;
+		}
+		INIT_DELAYED_WORK(&client_data->delay_work_sig,
+			bmi160_delay_sigmo_work_func);
+#ifdef BMI160_ENABLE_INT1
+		/* maps interrupt to INT1/InT2 pin */
+		BMI_CALL_API(set_intr_any_motion)(BMI_INT0, ENABLE);
+		BMI_CALL_API(set_intr_fifo_wm)(BMI_INT0, ENABLE);
+		BMI_CALL_API(set_intr_data_rdy)(BMI_INT0, ENABLE);
+
+		/*Set interrupt trige level way */
+		BMI_CALL_API(set_intr_edge_ctrl)(BMI_INT0, BMI_INT_LEVEL);
+		bmi160_set_intr_level(BMI_INT0, 1);
+		/*set interrupt latch temporary, 5 ms*/
+		/*bmi160_set_latch_int(5);*/
+
+		BMI_CALL_API(set_output_enable)(
+		BMI160_INTR1_OUTPUT_ENABLE, ENABLE);
+		sigmotion_init_interrupts(BMI160_MAP_INTR1);
+		BMI_CALL_API(map_step_detector_intr)(BMI160_MAP_INTR1);
+		/*close step_detector in init function*/
+		BMI_CALL_API(set_step_detector_enable)(0);
+#endif
+
+#ifdef BMI160_ENABLE_INT2
+		/* maps interrupt to INT1/InT2 pin */
+		BMI_CALL_API(set_intr_any_motion)(BMI_INT1, ENABLE);
+		BMI_CALL_API(set_intr_fifo_wm)(BMI_INT1, ENABLE);
+		BMI_CALL_API(set_intr_data_rdy)(BMI_INT1, ENABLE);
+
+		/*Set interrupt trige level way */
+		BMI_CALL_API(set_intr_edge_ctrl)(BMI_INT1, BMI_INT_LEVEL);
+		bmi160_set_intr_level(BMI_INT1, 1);
+		/*set interrupt latch temporary, 5 ms*/
+		/*bmi160_set_latch_int(5);*/
+
+		BMI_CALL_API(set_output_enable)(
+		BMI160_INTR2_OUTPUT_ENABLE, ENABLE);
+		sigmotion_init_interrupts(BMI160_MAP_INTR2);
+		BMI_CALL_API(map_step_detector_intr)(BMI160_MAP_INTR2);
+		/*close step_detector in init function*/
+		BMI_CALL_API(set_step_detector_enable)(0);
+#endif
+		err = request_irq(client_data->IRQ, bmi_irq_handler,
+				IRQF_TRIGGER_RISING, "bmi160", client_data);
+		if (err)
+			dev_err(client_data->dev, "could not request irq\n");
+
+		INIT_WORK(&client_data->irq_work, bmi_irq_work_func);
+#endif
+
+	client_data->selftest = 0;
+
+	client_data->fifo_data_sel = 0;
+	#if defined(CONFIG_USE_QUALCOMM_HAL)
+	BMI_CALL_API(set_accel_output_data_rate)(9);/*defalut odr 200HZ*/
+	BMI_CALL_API(set_gyro_output_data_rate)(9);/*defalut odr 200HZ*/
+	#endif
+	BMI_CALL_API(get_accel_output_data_rate)(&client_data->odr.acc_odr);
+	BMI_CALL_API(get_gyro_output_data_rate)(&client_data->odr.gyro_odr);
+	BMI_CALL_API(get_mag_output_data_rate)(&client_data->odr.mag_odr);
+	BMI_CALL_API(set_fifo_time_enable)(1);
+	BMI_CALL_API(get_accel_range)(&client_data->range.acc_range);
+	BMI_CALL_API(get_gyro_range)(&client_data->range.gyro_range);
+	/* now it's power on which is considered as resuming from suspend */
+	
+	/* gyro input device init */
+	err = bmi_gyro_input_init(client_data);
+	#if defined(CONFIG_USE_QUALCOMM_HAL)
+	/* gyro input device init */
+	err = bmi_gyro_input_init(client_data);
+	if (err < 0)
+		goto exit_err_clean;
+	client_data->accel_poll_ms = BMI160_ACCEL_DEFAULT_POLL_INTERVAL_MS;
+	client_data->gyro_poll_ms = BMI160_GYRO_DEFAULT_POLL_INTERVAL_MS;
+	client_data->data_wq = create_freezable_workqueue("bmi160_data_work");
+	if (!client_data->data_wq) {
+		dev_err(dev, "Cannot create workqueue!\n");
+		goto exit_err_clean;
+	}
+	INIT_DELAYED_WORK(&client_data->accel_poll_work,
+		bmi160_accel_work_fn);
+	client_data->accel_cdev = bmi160_accel_cdev;
+	client_data->accel_cdev.delay_msec = client_data->accel_poll_ms;
+	client_data->accel_cdev.sensors_enable = bmi160_accel_cdev_enable;
+	client_data->accel_cdev.sensors_poll_delay =
+	bmi160_accel_cdev_poll_delay;
+	err = sensors_classdev_register(dev, &client_data->accel_cdev);
+	if (err) {
+		dev_err(dev,
+			"create accel class device file failed!\n");
+		goto exit_err_clean;
+	}
+	INIT_DELAYED_WORK(&client_data->gyro_poll_work, bmi160_gyro_work_fn);
+	client_data->gyro_cdev = bmi160_gyro_cdev;
+	client_data->gyro_cdev.delay_msec = client_data->gyro_poll_ms;
+	client_data->gyro_cdev.sensors_enable = bmi160_gyro_cdev_enable;
+	client_data->gyro_cdev.sensors_poll_delay = bmi160_gyro_cdev_poll_delay;
+	err = sensors_classdev_register(dev, &client_data->gyro_cdev);
+	if (err) {
+		dev_err(dev,
+			"create accel class device file failed!\n");
+		goto exit_err_clean;
+	}
+	#endif
+	/* set sensor PMU into suspend power mode for all */
+	if (bmi_pmu_set_suspend(client_data) < 0) {
+		dev_err(dev, "Failed to set BMI160 to suspend power mode\n");
+		goto exit_err_sysfs;
+	}
+	/*enable the data ready interrupt*/
+	BMI_CALL_API(set_intr_enable_1)(BMI160_DATA_RDY_ENABLE, 1);
+	dev_notice(dev, "sensor_time:%d, %d, %d",
+		sensortime_duration_tbl[0].ts_delat,
+		sensortime_duration_tbl[0].ts_duration_lsb,
+		sensortime_duration_tbl[0].ts_duration_us);
+	dev_notice(dev, "sensor %s probed successfully", SENSOR_NAME);
+
+	return 0;
+
+exit_err_sysfs:
+	if (err)
+		bmi_input_destroy(client_data);
+
+exit_err_clean:
+	if (err) {
+		if (client_data != NULL) {
+			if (NULL != client_data->bst_pd) {
+				kfree(client_data->bst_pd);
+				client_data->bst_pd = NULL;
+			}
+		}
+	}
+	return err;
+}
+EXPORT_SYMBOL(bmi_probe);
+
+/*!
+ * @brief remove bmi client
+ *
+ * @param dev the pointer of device
+ *
+ * @return zero
+ * @retval zero
+*/
+int bmi_remove(struct device *dev)
+{
+	int err = 0;
+	struct bmi_client_data *client_data = dev_get_drvdata(dev);
+
+	if (NULL != client_data) {
+#ifdef CONFIG_HAS_EARLYSUSPEND
+		unregister_early_suspend(&client_data->early_suspend_handler);
+#endif
+		mutex_lock(&client_data->mutex_enable);
+		if (BMI_ACC_PM_NORMAL == client_data->pw.acc_pm ||
+			BMI_GYRO_PM_NORMAL == client_data->pw.gyro_pm ||
+				BMI_MAG_PM_NORMAL == client_data->pw.mag_pm) {
+			cancel_delayed_work_sync(&client_data->work);
+		}
+		mutex_unlock(&client_data->mutex_enable);
+
+		err = bmi_pmu_set_suspend(client_data);
+
+		bmi_delay(5);
+
+		sysfs_remove_group(&client_data->input->dev.kobj,
+				&bmi160_attribute_group);
+		bmi_input_destroy(client_data);
+
+		if (NULL != client_data->bst_pd) {
+			kfree(client_data->bst_pd);
+			client_data->bst_pd = NULL;
+		}
+		kfree(client_data);
+	}
+
+	return err;
+}
+EXPORT_SYMBOL(bmi_remove);
+
+static int bmi_post_resume(struct bmi_client_data *client_data)
+{
+	int err = 0;
+
+	mutex_lock(&client_data->mutex_enable);
+
+	if (atomic_read(&client_data->wkqueue_en) == 1) {
+		bmi160_set_acc_op_mode(client_data, BMI_ACC_PM_NORMAL);
+		schedule_delayed_work(&client_data->work,
+				msecs_to_jiffies(
+					atomic_read(&client_data->delay)));
+	}
+	mutex_unlock(&client_data->mutex_enable);
+
+	return err;
+}
+
+
+int bmi_suspend(struct device *dev)
+{
+	int err = 0;
+	struct bmi_client_data *client_data = dev_get_drvdata(dev);
+	unsigned char stc_enable;
+	unsigned char std_enable;
+	dev_err(client_data->dev, "bmi suspend function entrance");
+
+	atomic_set(&client_data->in_suspend, 1);
+	if (atomic_read(&client_data->wkqueue_en) == 1) {
+		bmi160_set_acc_op_mode(client_data, BMI_ACC_PM_SUSPEND);
+		cancel_delayed_work_sync(&client_data->work);
+	}
+	BMI_CALL_API(get_step_counter_enable)(&stc_enable);
+	BMI_CALL_API(get_step_detector_enable)(&std_enable);
+	if (client_data->pw.acc_pm != BMI_ACC_PM_SUSPEND &&
+		(stc_enable != 1) && (std_enable != 1) &&
+		(client_data->sig_flag != 1)) {
+		err += BMI_CALL_API(set_command_register)
+				(bmi_pmu_cmd_acc_arr[BMI_ACC_PM_SUSPEND]);
+		bmi_delay(3);
+	}
+	if (client_data->pw.gyro_pm != BMI_GYRO_PM_SUSPEND) {
+		err += BMI_CALL_API(set_command_register)
+				(bmi_pmu_cmd_gyro_arr[BMI_GYRO_PM_SUSPEND]);
+		bmi_delay(3);
+	}
+
+	if (client_data->pw.mag_pm != BMI_MAG_PM_SUSPEND) {
+#if defined(BMI160_AKM09912_SUPPORT)
+		err += bmi160_set_bst_akm_and_secondary_if_powermode(
+		BMI160_MAG_SUSPEND_MODE);
+#else
+		err += bmi160_set_bmm150_mag_and_secondary_if_power_mode(
+		BMI160_MAG_SUSPEND_MODE);
+#endif
+		bmi_delay(3);
+	}
+
+	return err;
+}
+EXPORT_SYMBOL(bmi_suspend);
+
+int bmi_resume(struct device *dev)
+{
+	int err = 0;
+	struct bmi_client_data *client_data = dev_get_drvdata(dev);
+	atomic_set(&client_data->in_suspend, 0);
+	if (client_data->pw.acc_pm != BMI_ACC_PM_SUSPEND) {
+		err += BMI_CALL_API(set_command_register)
+				(bmi_pmu_cmd_acc_arr[BMI_ACC_PM_NORMAL]);
+		bmi_delay(3);
+	}
+	if (client_data->pw.gyro_pm != BMI_GYRO_PM_SUSPEND) {
+		err += BMI_CALL_API(set_command_register)
+				(bmi_pmu_cmd_gyro_arr[BMI_GYRO_PM_NORMAL]);
+		bmi_delay(3);
+	}
+
+	if (client_data->pw.mag_pm != BMI_MAG_PM_SUSPEND) {
+#if defined(BMI160_AKM09912_SUPPORT)
+		err += bmi160_set_bst_akm_and_secondary_if_powermode
+					(BMI160_MAG_FORCE_MODE);
+#else
+		err += bmi160_set_bmm150_mag_and_secondary_if_power_mode
+					(BMI160_MAG_FORCE_MODE);
+#endif
+		bmi_delay(3);
+	}
+	/* post resume operation */
+	err += bmi_post_resume(client_data);
+
+	return err;
+}
+EXPORT_SYMBOL(bmi_resume);
+
diff --git a/drivers/input/sensors/bmi160/bmi160_driver.h b/drivers/input/sensors/bmi160/bmi160_driver.h
new file mode 100644
index 0000000..993a885
--- /dev/null
+++ b/drivers/input/sensors/bmi160/bmi160_driver.h
@@ -0,0 +1,409 @@
+/*!
+ * @section LICENSE
+ * (C) Copyright 2011~2016 Bosch Sensortec GmbH All Rights Reserved
+ *
+ * This software program is licensed subject to the GNU General
+ * Public License (GPL).Version 2,June 1991,
+ * available at http://www.fsf.org/copyleft/gpl.html
+ *
+ * @filename bmi160_driver.h
+ * @date     2015/08/17 14:40
+ * @id       "e90a329"
+ * @version  1.3
+ *
+ * @brief
+ * The head file of BMI160 device driver core code
+*/
+#ifndef _BMI160_DRIVER_H
+#define _BMI160_DRIVER_H
+
+#ifdef __KERNEL__
+#include <linux/kernel.h>
+#include <linux/unistd.h>
+#include <linux/types.h>
+#include <linux/string.h>
+#else
+#include <unistd.h>
+#include <sys/types.h>
+#include <string.h>
+#endif
+
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/i2c.h>
+#include <linux/interrupt.h>
+#include <linux/input.h>
+#include <linux/workqueue.h>
+#include <linux/mutex.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/time.h>
+#include <linux/ktime.h>
+
+#ifdef CONFIG_HAS_EARLYSUSPEND
+#include <linux/earlysuspend.h>
+#endif
+
+#include "bmi160.h"
+
+#if defined(CONFIG_USE_QUALCOMM_HAL)
+#include <linux/sensors.h>
+#endif
+/* sensor specific */
+#define SENSOR_NAME "bmi160"
+#define BMI160_ENABLE_INT1 1
+//#define BMI160_ENABLE_INT2 1
+/*#define BMI160_MAG_INTERFACE_SUPPORT 1*/
+
+/*#define BMI160_AKM09912_SUPPORT 1*/
+#define BMI_USE_BASIC_I2C_FUNC 1
+#define SENSOR_CHIP_ID_BMI (0xD0)
+#define SENSOR_CHIP_ID_BMI_C2 (0xD1)
+#define SENSOR_CHIP_ID_BMI_C3 (0xD3)
+
+#define SENSOR_CHIP_REV_ID_BMI (0x00)
+
+#define CHECK_CHIP_ID_TIME_MAX  5
+
+#define BMI_REG_NAME(name) BMI160_##name##__REG
+#define BMI_VAL_NAME(name) BMI160_##name
+#define BMI_CALL_API(name) bmi160_##name
+
+#define BMI_I2C_WRITE_DELAY_TIME (1)
+
+/* generic */
+#define BMI_MAX_RETRY_I2C_XFER (10)
+#define BMI_MAX_RETRY_WAKEUP (5)
+#define BMI_MAX_RETRY_WAIT_DRDY (100)
+
+#define BMI_DELAY_MIN (1)
+#define BMI_DELAY_DEFAULT (200)
+
+#define BMI_VALUE_MAX (32767)
+#define BMI_VALUE_MIN (-32768)
+
+#define BYTES_PER_LINE (16)
+
+#define BUF_SIZE_PRINT (16)
+
+#define BMI_FAST_CALI_TRUE  (1)
+#define BMI_FAST_CALI_ALL_RDY (7)
+
+/*! FIFO 1024 byte, max fifo frame count not over 150 */
+#define FIFO_FRAME_CNT 170
+#define FIFO_DATA_BUFSIZE    1024
+
+
+#define FRAME_LEN_ACC    6
+#define FRAME_LEN_GYRO    6
+#define FRAME_LEN_MAG    8
+
+/*! BMI Self test */
+#define BMI_SELFTEST_AMP_HIGH       1
+
+/* CMD  */
+#define CMD_FOC_START                 0x03
+#define CMD_PMU_ACC_SUSPEND           0x10
+#define CMD_PMU_ACC_NORMAL            0x11
+#define CMD_PMU_ACC_LP1               0x12
+#define CMD_PMU_ACC_LP2               0x13
+#define CMD_PMU_GYRO_SUSPEND          0x14
+#define CMD_PMU_GYRO_NORMAL           0x15
+#define CMD_PMU_GYRO_FASTSTART        0x17
+#define CMD_PMU_MAG_SUSPEND           0x18
+#define CMD_PMU_MAG_NORMAL            0x19
+#define CMD_PMU_MAG_LP1               0x1A
+#define CMD_PMU_MAG_LP2               0x1B
+#define CMD_CLR_FIFO_DATA             0xB0
+#define CMD_RESET_INT_ENGINE          0xB1
+#define CMD_RESET_USER_REG            0xB6
+
+#define USER_DAT_CFG_PAGE              0x00
+
+/*! FIFO Head definition*/
+#define FIFO_HEAD_A        0x84
+#define FIFO_HEAD_G        0x88
+#define FIFO_HEAD_M        0x90
+
+#define FIFO_HEAD_G_A        (FIFO_HEAD_G | FIFO_HEAD_A)
+#define FIFO_HEAD_M_A        (FIFO_HEAD_M | FIFO_HEAD_A)
+#define FIFO_HEAD_M_G        (FIFO_HEAD_M | FIFO_HEAD_G)
+
+#define FIFO_HEAD_M_G_A         (FIFO_HEAD_M | FIFO_HEAD_G | FIFO_HEAD_A)
+
+#define FIFO_HEAD_SENSOR_TIME        0x44
+#define FIFO_HEAD_SKIP_FRAME        0x40
+#define FIFO_HEAD_OVER_READ_LSB       0x80
+#define FIFO_HEAD_OVER_READ_MSB       0x00
+
+/*! FIFO head mode Frame bytes number definition */
+#define A_BYTES_FRM      6
+#define G_BYTES_FRM      6
+#define M_BYTES_FRM      8
+#define GA_BYTES_FRM     12
+#define MG_BYTES_FRM     14
+#define MA_BYTES_FRM     14
+#define MGA_BYTES_FRM    20
+
+#define ACC_FIFO_HEAD       "acc"
+#define GYRO_FIFO_HEAD     "gyro"
+#define MAG_FIFO_HEAD         "mag"
+
+/*! Bosch sensor unknown place*/
+#define BOSCH_SENSOR_PLACE_UNKNOWN (-1)
+/*! Bosch sensor remapping table size P0~P7*/
+#define MAX_AXIS_REMAP_TAB_SZ 8
+
+#define ENABLE     1
+#define DISABLE    0
+
+/* bmi sensor HW interrupt pin number */
+#define BMI_INT0      0
+#define BMI_INT1       1
+
+#define BMI_INT_LEVEL      0
+#define BMI_INT_EDGE        1
+
+/*! BMI mag interface */
+
+
+/* compensated output value returned if sensor had overflow */
+#define BMM050_OVERFLOW_OUTPUT       -32768
+#define BMM050_OVERFLOW_OUTPUT_S32   ((s32)(-2147483647-1))
+
+/* Trim Extended Registers */
+#define BMM050_DIG_X1                      0x5D
+#define BMM050_DIG_Y1                      0x5E
+#define BMM050_DIG_Z4_LSB                  0x62
+#define BMM050_DIG_Z4_MSB                  0x63
+#define BMM050_DIG_X2                      0x64
+#define BMM050_DIG_Y2                      0x65
+#define BMM050_DIG_Z2_LSB                  0x68
+#define BMM050_DIG_Z2_MSB                  0x69
+#define BMM050_DIG_Z1_LSB                  0x6A
+#define BMM050_DIG_Z1_MSB                  0x6B
+#define BMM050_DIG_XYZ1_LSB                0x6C
+#define BMM050_DIG_XYZ1_MSB                0x6D
+#define BMM050_DIG_Z3_LSB                  0x6E
+#define BMM050_DIG_Z3_MSB                  0x6F
+#define BMM050_DIG_XY2                     0x70
+#define BMM050_DIG_XY1                     0x71
+
+struct bmi160mag_compensate_t {
+	signed char dig_x1;
+	signed char dig_y1;
+
+	signed char dig_x2;
+	signed char dig_y2;
+
+	u16 dig_z1;
+	s16 dig_z2;
+	s16 dig_z3;
+	s16 dig_z4;
+
+	unsigned char dig_xy1;
+	signed char dig_xy2;
+
+	u16 dig_xyz1;
+};
+
+/*bmi fifo sensor type combination*/
+enum BMI_FIFO_DATA_SELECT_T {
+	BMI_FIFO_A_SEL = 1,
+	BMI_FIFO_G_SEL,
+	BMI_FIFO_G_A_SEL,
+	BMI_FIFO_M_SEL,
+	BMI_FIFO_M_A_SEL,
+	BMI_FIFO_M_G_SEL,
+	BMI_FIFO_M_G_A_SEL,
+	BMI_FIFO_DATA_SEL_MAX
+};
+
+/*bmi interrupt about step_detector and sgm*/
+#define INPUT_EVENT_STEP_DETECTOR    5
+#define INPUT_EVENT_SGM              3/*7*/
+#define INPUT_EVENT_FAST_ACC_CALIB_DONE    6
+#define INPUT_EVENT_FAST_GYRO_CALIB_DONE    4
+
+
+/*!
+* Bst sensor common definition,
+* please give parameters in BSP file.
+*/
+struct bosch_sensor_specific {
+	char *name;
+	/* 0 to 7 */
+	unsigned int place:3;
+	int irq;
+	int (*irq_gpio_cfg)(void);
+};
+
+/*! bmi160 sensor spec of power mode */
+struct pw_mode {
+	u8 acc_pm;
+	u8 gyro_pm;
+	u8 mag_pm;
+};
+
+/*! bmi160 sensor spec of odr */
+struct odr_t {
+	u8 acc_odr;
+	u8 gyro_odr;
+	u8 mag_odr;
+};
+
+/*! bmi160 sensor spec of range */
+struct range_t {
+	u8 acc_range;
+	u8 gyro_range;
+};
+
+/*! bmi160 sensor error status */
+struct err_status {
+	u8 fatal_err;
+	u8 err_code;
+	u8 i2c_fail;
+	u8 drop_cmd;
+	u8 mag_drdy_err;
+	u8 err_st_all;
+};
+
+/*! bmi160 fifo frame for all sensors */
+struct fifo_frame_t {
+	struct bmi160_accel_t *acc_farr;
+	struct bmi160_gyro_t *gyro_farr;
+	struct bmi160_mag_xyz_s32_t *mag_farr;
+
+	unsigned char acc_frame_cnt;
+	unsigned char gyro_frame_cnt;
+	unsigned char mag_frame_cnt;
+
+	u32 acc_lastf_ts;
+	u32 gyro_lastf_ts;
+	u32 mag_lastf_ts;
+};
+
+/*! bmi160 fifo sensor time */
+struct fifo_sensor_time_t {
+	u32 acc_ts;
+	u32 gyro_ts;
+	u32 mag_ts;
+};
+
+struct pedometer_data_t {
+	/*! Fix step detector misinformation for the first time*/
+	u8 wkar_step_detector_status;
+	u_int32_t last_step_counter_value;
+};
+
+struct bmi_client_data {
+	struct bmi160_t device;
+	struct device *dev;
+	struct input_dev *input;/*acc_device*/
+	struct input_dev *gyro_input;
+	#if defined(CONFIG_USE_QUALCOMM_HAL)
+	struct input_dev *gyro_input;
+	struct sensors_classdev accel_cdev;
+	struct sensors_classdev gyro_cdev;
+	struct delayed_work accel_poll_work;
+	struct delayed_work gyro_poll_work;
+	u32 accel_poll_ms;
+	u32 gyro_poll_ms;
+	u32 accel_latency_ms;
+	u32 gyro_latency_ms;
+	atomic_t accel_en;
+	atomic_t gyro_en;
+	struct workqueue_struct *data_wq;
+	#endif
+	struct delayed_work work;
+	struct work_struct irq_work;
+
+	u8 chip_id;
+
+	struct pw_mode pw;
+	struct odr_t odr;
+	struct range_t range; /*TO DO*/
+	struct err_status err_st;
+	struct pedometer_data_t pedo_data;
+	s8 place;
+	u8 selftest;
+	/*struct wake_lock wakelock;*/
+	struct delayed_work delay_work_sig;
+	atomic_t in_suspend;
+
+	atomic_t wkqueue_en; /*TO DO acc gyro mag*/
+	atomic_t delay;
+	atomic_t selftest_result;
+
+	u8  fifo_data_sel;
+	u16 fifo_bytecount;
+	u8 fifo_head_en;
+	unsigned char fifo_int_tag_en;
+	struct fifo_frame_t fifo_frame;
+
+	unsigned char *fifo_data;
+	u64 fifo_time;
+	u8 stc_enable;
+	uint16_t gpio_pin;
+	u8 std;
+	u8 sig_flag;
+	unsigned char calib_status;
+	struct mutex mutex_op_mode;
+	struct mutex mutex_enable;
+	struct bosch_sensor_specific *bst_pd;
+	int IRQ;
+	int reg_sel;
+	int reg_len;
+	uint64_t timestamp;
+#ifdef CONFIG_HAS_EARLYSUSPEND
+	struct early_suspend early_suspend_handler;
+#endif
+};
+
+
+/*!
+ * we use a typedef to hide the detail,
+ * because this type might be changed
+ */
+struct bosch_sensor_axis_remap {
+	/* src means which source will be mapped to target x, y, z axis */
+	/* if an target OS axis is remapped from (-)x,
+	 * src is 0, sign_* is (-)1 */
+	/* if an target OS axis is remapped from (-)y,
+	 * src is 1, sign_* is (-)1 */
+	/* if an target OS axis is remapped from (-)z,
+	 * src is 2, sign_* is (-)1 */
+	int src_x:3;
+	int src_y:3;
+	int src_z:3;
+
+	int sign_x:2;
+	int sign_y:2;
+	int sign_z:2;
+};
+
+
+struct bosch_sensor_data {
+	union {
+		int16_t v[3];
+		struct {
+			int16_t x;
+			int16_t y;
+			int16_t z;
+		};
+	};
+};
+
+s8 bmi_burst_read_wrapper(u8 dev_addr, u8 reg_addr, u8 *data, u16 len);
+int bmi_probe(struct bmi_client_data *client_data, struct device *dev);
+int bmi_remove(struct device *dev);
+int bmi_suspend(struct device *dev);
+int bmi_resume(struct device *dev);
+
+
+
+
+#endif/*_BMI160_DRIVER_H*/
+/*@}*/
+
diff --git a/drivers/input/sensors/bmi160/bmi160_i2c.c b/drivers/input/sensors/bmi160/bmi160_i2c.c
new file mode 100644
index 0000000..57d42c62
--- /dev/null
+++ b/drivers/input/sensors/bmi160/bmi160_i2c.c
@@ -0,0 +1,369 @@
+/*!
+ * @section LICENSE
+ * (C) Copyright 2011~2016 Bosch Sensortec GmbH All Rights Reserved
+ *
+ * This software program is licensed subject to the GNU General
+ * Public License (GPL).Version 2,June 1991,
+ * available at http://www.fsf.org/copyleft/gpl.html
+ *
+ * @filename bmi160_i2c.c
+ * @date     2014/11/25 14:40
+ * @id       "20f77db"
+ * @version  1.3
+ *
+ * @brief
+ * This file implements moudle function, which add
+ * the driver to I2C core.
+*/
+
+#include <linux/module.h>
+#include <linux/i2c.h>
+#include <linux/delay.h>
+#include "bmi160_driver.h"
+
+/*! @defgroup bmi160_i2c_src
+ *  @brief bmi160 i2c driver module
+ @{*/
+
+static struct i2c_client *bmi_client;
+/*!
+ * @brief define i2c wirte function
+ *
+ * @param client the pointer of i2c client
+ * @param reg_addr register address
+ * @param data the pointer of data buffer
+ * @param len block size need to write
+ *
+ * @return zero success, non-zero failed
+ * @retval zero success
+ * @retval non-zero failed
+*/
+/*	i2c read routine for API*/
+static s8 bmi_i2c_read(struct i2c_client *client, u8 reg_addr,
+			u8 *data, u8 len)
+	{
+#if !defined BMI_USE_BASIC_I2C_FUNC
+		s32 dummy;
+		if (NULL == client)
+			return -EINVAL;
+
+		while (0 != len--) {
+#ifdef BMI_SMBUS
+			dummy = i2c_smbus_read_byte_data(client, reg_addr);
+			if (dummy < 0) {
+				dev_err(&client->dev, "i2c smbus read error");
+				return -EIO;
+			}
+			*data = (u8)(dummy & 0xff);
+#else
+			dummy = i2c_master_send(client, (char *)&reg_addr, 1);
+			if (dummy < 0) {
+				dev_err(&client->dev, "i2c bus master write error");
+				return -EIO;
+			}
+
+			dummy = i2c_master_recv(client, (char *)data, 1);
+			if (dummy < 0) {
+				dev_err(&client->dev, "i2c bus master read error");
+				return -EIO;
+			}
+#endif
+			reg_addr++;
+			data++;
+		}
+		return 0;
+#else
+		int retry;
+
+		struct i2c_msg msg[] = {
+			{
+			 .addr = client->addr,
+			 .flags = 0,
+			 .len = 1,
+			 .buf = &reg_addr,
+			},
+
+			{
+			 .addr = client->addr,
+			 .flags = I2C_M_RD,
+			 .len = len,
+			 .buf = data,
+			 },
+		};
+
+		for (retry = 0; retry < BMI_MAX_RETRY_I2C_XFER; retry++) {
+			if (i2c_transfer(client->adapter, msg,
+						ARRAY_SIZE(msg)) > 0)
+				break;
+			else
+				usleep_range(BMI_I2C_WRITE_DELAY_TIME * 1000,
+				BMI_I2C_WRITE_DELAY_TIME * 1000);
+		}
+
+		if (BMI_MAX_RETRY_I2C_XFER <= retry) {
+			dev_err(&client->dev, "I2C xfer error");
+			return -EIO;
+		}
+
+		return 0;
+#endif
+	}
+
+
+static s8 bmi_i2c_burst_read(struct i2c_client *client, u8 reg_addr,
+		u8 *data, u16 len)
+{
+	int retry;
+
+	struct i2c_msg msg[] = {
+		{
+			.addr = client->addr,
+			.flags = 0,
+			.len = 1,
+			.buf = &reg_addr,
+		},
+
+		{
+			.addr = client->addr,
+			.flags = I2C_M_RD,
+			.len = len,
+			.buf = data,
+		},
+	};
+
+	for (retry = 0; retry < BMI_MAX_RETRY_I2C_XFER; retry++) {
+		if (i2c_transfer(client->adapter, msg, ARRAY_SIZE(msg)) > 0)
+			break;
+		else
+			usleep_range(BMI_I2C_WRITE_DELAY_TIME * 1000,
+				BMI_I2C_WRITE_DELAY_TIME * 1000);
+	}
+
+	if (BMI_MAX_RETRY_I2C_XFER <= retry) {
+		dev_err(&client->dev, "I2C xfer error");
+		return -EIO;
+	}
+
+	return 0;
+}
+
+
+/* i2c write routine for */
+static s8 bmi_i2c_write(struct i2c_client *client, u8 reg_addr,
+		u8 *data, u8 len)
+{
+#if !defined BMI_USE_BASIC_I2C_FUNC
+	s32 dummy;
+
+#ifndef BMI_SMBUS
+	u8 buffer[2];
+#endif
+
+	if (NULL == client)
+		return -EPERM;
+
+	while (0 != len--) {
+#ifdef BMI_SMBUS
+		dummy = i2c_smbus_write_byte_data(client, reg_addr, *data);
+#else
+		buffer[0] = reg_addr;
+		buffer[1] = *data;
+		dummy = i2c_master_send(client, (char *)buffer, 2);
+#endif
+		reg_addr++;
+		data++;
+		if (dummy < 0) {
+			dev_err(&client->dev, "error writing i2c bus");
+			return -EPERM;
+		}
+
+	}
+	usleep_range(BMI_I2C_WRITE_DELAY_TIME * 1000,
+	BMI_I2C_WRITE_DELAY_TIME * 1000);
+	return 0;
+#else
+	u8 buffer[2];
+	int retry;
+	struct i2c_msg msg[] = {
+		{
+		 .addr = client->addr,
+		 .flags = 0,
+		 .len = 2,
+		 .buf = buffer,
+		 },
+	};
+
+	while (0 != len--) {
+		buffer[0] = reg_addr;
+		buffer[1] = *data;
+		for (retry = 0; retry < BMI_MAX_RETRY_I2C_XFER; retry++) {
+			if (i2c_transfer(client->adapter, msg,
+						ARRAY_SIZE(msg)) > 0) {
+				break;
+			} else {
+				usleep_range(BMI_I2C_WRITE_DELAY_TIME * 1000,
+				BMI_I2C_WRITE_DELAY_TIME * 1000);
+			}
+		}
+		if (BMI_MAX_RETRY_I2C_XFER <= retry) {
+			dev_err(&client->dev, "I2C xfer error");
+			return -EIO;
+		}
+		reg_addr++;
+		data++;
+	}
+
+	usleep_range(BMI_I2C_WRITE_DELAY_TIME * 1000,
+	BMI_I2C_WRITE_DELAY_TIME * 1000);
+	return 0;
+#endif
+}
+
+
+static s8 bmi_i2c_read_wrapper(u8 dev_addr, u8 reg_addr, u8 *data, u8 len)
+{
+	int err = 0;
+	err = bmi_i2c_read(bmi_client, reg_addr, data, len);
+	return err;
+}
+
+static s8 bmi_i2c_write_wrapper(u8 dev_addr, u8 reg_addr, u8 *data, u8 len)
+{
+	int err = 0;
+	err = bmi_i2c_write(bmi_client, reg_addr, data, len);
+	return err;
+}
+
+s8 bmi_burst_read_wrapper(u8 dev_addr, u8 reg_addr, u8 *data, u16 len)
+{
+	int err = 0;
+	err = bmi_i2c_burst_read(bmi_client, reg_addr, data, len);
+	return err;
+}
+EXPORT_SYMBOL(bmi_burst_read_wrapper);
+/*!
+ * @brief BMI probe function via i2c bus
+ *
+ * @param client the pointer of i2c client
+ * @param id the pointer of i2c device id
+ *
+ * @return zero success, non-zero failed
+ * @retval zero success
+ * @retval non-zero failed
+*/
+static int bmi_i2c_probe(struct i2c_client *client,
+		const struct i2c_device_id *id)
+{
+		int err = 0;
+		struct bmi_client_data *client_data = NULL;
+
+		dev_info(&client->dev, "BMI160 i2c function probe entrance");
+
+		if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
+			dev_err(&client->dev, "i2c_check_functionality error!");
+			err = -EIO;
+			goto exit_err_clean;
+		}
+
+		if (NULL == bmi_client) {
+			bmi_client = client;
+		} else {
+			dev_err(&client->dev,
+				"this driver does not support multiple clients");
+			err = -EBUSY;
+			goto exit_err_clean;
+		}
+
+		client_data = kzalloc(sizeof(struct bmi_client_data),
+							GFP_KERNEL);
+		if (NULL == client_data) {
+			dev_err(&client->dev, "no memory available");
+			err = -ENOMEM;
+			goto exit_err_clean;
+		}
+
+		client_data->device.bus_read = bmi_i2c_read_wrapper;
+		client_data->device.bus_write = bmi_i2c_write_wrapper;
+
+		return bmi_probe(client_data, &client->dev);
+
+exit_err_clean:
+		if (err)
+			bmi_client = NULL;
+		return err;
+}
+/*
+static int bmi_i2c_suspend(struct i2c_client *client, pm_message_t mesg)
+{
+	int err = 0;
+	err = bmi_suspend(&client->dev);
+	return err;
+}
+
+static int bmi_i2c_resume(struct i2c_client *client)
+{
+	int err = 0;
+
+	err = bmi_resume(&client->dev);
+
+	return err;
+}
+*/
+
+static int bmi_i2c_remove(struct i2c_client *client)
+{
+	int err = 0;
+	err = bmi_remove(&client->dev);
+	bmi_client = NULL;
+
+	return err;
+}
+
+
+
+static const struct i2c_device_id bmi_id[] = {
+	{SENSOR_NAME, 0},
+	{}
+};
+
+MODULE_DEVICE_TABLE(i2c, bmi_id);
+
+static const struct of_device_id bmi160_of_match[] = {
+	{ .compatible = "bosch-sensortec,bmi160", },
+	{ .compatible = "bmi160", },
+	{ .compatible = "bosch, bmi160", },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, bmi160_of_match);
+
+static struct i2c_driver bmi_i2c_driver = {
+	.driver = {
+		.owner = THIS_MODULE,
+		.name = SENSOR_NAME,
+		.of_match_table = bmi160_of_match,
+	},
+	.class = I2C_CLASS_HWMON,
+	.id_table = bmi_id,
+	.probe = bmi_i2c_probe,
+	.remove = bmi_i2c_remove,
+	/*.suspend = bmi_i2c_suspend,
+	.resume = bmi_i2c_resume,*/
+};
+
+static int __init BMI_i2c_init(void)
+{
+	return i2c_add_driver(&bmi_i2c_driver);
+}
+
+static void __exit BMI_i2c_exit(void)
+{
+	i2c_del_driver(&bmi_i2c_driver);
+}
+
+MODULE_AUTHOR("Contact <contact@bosch-sensortec.com>");
+MODULE_DESCRIPTION("driver for " SENSOR_NAME);
+MODULE_LICENSE("GPL v2");
+
+module_init(BMI_i2c_init);
+module_exit(BMI_i2c_exit);
+
diff --git a/drivers/input/sensors/bmi160/bmi160_spi.c b/drivers/input/sensors/bmi160/bmi160_spi.c
new file mode 100644
index 0000000..8da1e21
--- /dev/null
+++ b/drivers/input/sensors/bmi160/bmi160_spi.c
@@ -0,0 +1,299 @@
+/*!
+ * @section LICENSE
+ * (C) Copyright 2011~2016 Bosch Sensortec GmbH All Rights Reserved
+ *
+ * This software program is licensed subject to the GNU General
+ * Public License (GPL).Version 2,June 1991,
+ * available at http://www.fsf.org/copyleft/gpl.html
+ *
+ * @filename bmi160_spi.c
+ * @date     2014/11/25 14:40
+ * @id       "20f77db"
+ * @version  1.3
+ *
+ * @brief
+ * This file implements moudle function, which add
+ * the driver to SPI core.
+*/
+
+#include <linux/module.h>
+#include <linux/spi/spi.h>
+#include <linux/delay.h>
+#include "bmi160_driver.h"
+
+/*! @defgroup bmi160_spi_src
+ *  @brief bmi160 spi driver module
+ @{*/
+/*! the maximum of transfer buffer size */
+#define BMI_MAX_BUFFER_SIZE      32
+
+static struct spi_device *bmi_spi_client;
+
+/*!
+ * @brief define spi wirte function
+ *
+ * @param dev_addr sensor device address
+ * @param reg_addr register address
+ * @param data the pointer of data buffer
+ * @param len block size need to write
+ *
+ * @return zero success, non-zero failed
+ * @retval zero success
+ * @retval non-zero failed
+*/
+static char bmi_spi_write_block(u8 dev_addr, u8 reg_addr, u8 *data, u8 len)
+{
+	struct spi_device *client = bmi_spi_client;
+	u8 buffer[BMI_MAX_BUFFER_SIZE + 1];
+	struct spi_transfer xfer = {
+		.tx_buf     = buffer,
+		.len        = len + 1,
+	};
+	struct spi_message msg;
+
+	if (len > BMI_MAX_BUFFER_SIZE)
+		return -EINVAL;
+
+	buffer[0] = reg_addr&0x7F;/* write: MSB = 0 */
+	memcpy(&buffer[1], data, len);
+
+	spi_message_init(&msg);
+	spi_message_add_tail(&xfer, &msg);
+	return spi_sync(client, &msg);
+}
+
+/*!
+ * @brief define spi read function
+ *
+ * @param dev_addr sensor device address
+ * @param reg_addr register address
+ * @param data the pointer of data buffer
+ * @param len block size need to read
+ *
+ * @return zero success, non-zero failed
+ * @retval zero success
+ * @retval non-zero failed
+*/
+static char bmi_spi_read_block(u8 dev_addr, u8 reg_addr, u8 *data, u8 len)
+{
+	struct spi_device *client = bmi_spi_client;
+	u8 reg = reg_addr | 0x80;/* read: MSB = 1 */
+	struct spi_transfer xfer[2] = {
+		[0] = {
+			.tx_buf = &reg,
+			.len = 1,
+		},
+		[1] = {
+			.rx_buf = data,
+			.len = len,
+		}
+	};
+	struct spi_message msg;
+
+	spi_message_init(&msg);
+	spi_message_add_tail(&xfer[0], &msg);
+	spi_message_add_tail(&xfer[1], &msg);
+	return spi_sync(client, &msg);
+}
+
+s8 bmi_burst_read_wrapper(u8 dev_addr, u8 reg_addr, u8 *data, u16 len)
+{
+	struct spi_device *client = bmi_spi_client;
+	u8 reg = reg_addr | 0x80;/* read: MSB = 1 */
+	struct spi_transfer xfer[2] = {
+		[0] = {
+			.tx_buf = &reg,
+			.len = 1,
+		},
+		[1] = {
+			.rx_buf = data,
+			.len = len,
+		}
+	};
+	struct spi_message msg;
+
+	spi_message_init(&msg);
+	spi_message_add_tail(&xfer[0], &msg);
+	spi_message_add_tail(&xfer[1], &msg);
+	return spi_sync(client, &msg);
+}
+EXPORT_SYMBOL(bmi_burst_read_wrapper);
+/*!
+ * @brief BMI probe function via spi bus
+ *
+ * @param client the pointer of spi client
+ *
+ * @return zero success, non-zero failed
+ * @retval zero success
+ * @retval non-zero failed
+*/
+static int bmi_spi_probe(struct spi_device *client)
+{
+	int status;
+	int err = 0;
+	struct bmi_client_data *client_data = NULL;
+
+	if (NULL == bmi_spi_client)
+		bmi_spi_client = client;
+	else{
+		dev_err(&client->dev, "This driver does not support multiple clients!\n");
+		return -EBUSY;
+	}
+
+	client->bits_per_word = 8;
+	status = spi_setup(client);
+	if (status < 0) {
+		dev_err(&client->dev, "spi_setup failed!\n");
+		return status;
+	}
+
+	client_data = kzalloc(sizeof(struct bmi_client_data), GFP_KERNEL);
+	if (NULL == client_data) {
+		dev_err(&client->dev, "no memory available");
+		err = -ENOMEM;
+		goto exit_err_clean;
+	}
+
+	client_data->device.bus_read = bmi_spi_read_block;
+	client_data->device.bus_write = bmi_spi_write_block;
+
+	return bmi_probe(client_data, &client->dev);
+
+exit_err_clean:
+	if (err)
+		bmi_spi_client = NULL;
+	return err;
+}
+
+/*!
+ * @brief shutdown bmi device in spi driver
+ *
+ * @param client the pointer of spi client
+ *
+ * @return no return value
+*/
+static void bmi_spi_shutdown(struct spi_device *client)
+{
+#ifdef CONFIG_PM
+	bmi_suspend(&client->dev);
+#endif
+}
+
+/*!
+ * @brief remove bmi spi client
+ *
+ * @param client the pointer of spi client
+ *
+ * @return zero
+ * @retval zero
+*/
+static int bmi_spi_remove(struct spi_device *client)
+{
+	int err = 0;
+	err = bmi_remove(&client->dev);
+	bmi_spi_client = NULL;
+
+	return err;
+}
+
+#ifdef CONFIG_PM
+/*!
+ * @brief suspend bmi device in spi driver
+ *
+ * @param dev the pointer of device
+ *
+ * @return zero
+ * @retval zero
+*/
+static int bmi_spi_suspend(struct device *dev)
+{
+	int err = 0;
+	err = bmi_suspend(dev);
+	return err;
+}
+
+/*!
+ * @brief resume bmi device in spi driver
+ *
+ * @param dev the pointer of device
+ *
+ * @return zero
+ * @retval zero
+*/
+static int bmi_spi_resume(struct device *dev)
+{
+	int err = 0;
+	/* post resume operation */
+	err = bmi_resume(dev);
+
+	return err;
+}
+
+/*!
+ * @brief register spi device power manager hooks
+*/
+static const struct dev_pm_ops bmi_spi_pm_ops = {
+	/**< device suspend */
+	.suspend = bmi_spi_suspend,
+	/**< device resume */
+	.resume  = bmi_spi_resume
+};
+#endif
+
+/*!
+ * @brief register spi device id
+*/
+static const struct spi_device_id bmi_id[] = {
+	{ SENSOR_NAME, 0 },
+	{ }
+};
+MODULE_DEVICE_TABLE(spi, bmi_id);
+
+/*!
+ * @brief register spi driver hooks
+*/
+static struct spi_driver bmi_spi_driver = {
+	.driver = {
+		.owner = THIS_MODULE,
+		.name  = SENSOR_NAME,
+#ifdef CONFIG_PM
+		.pm = &bmi_spi_pm_ops,
+#endif
+	},
+	.id_table = bmi_id,
+	.probe    = bmi_spi_probe,
+	.shutdown = bmi_spi_shutdown,
+	.remove   = bmi_spi_remove
+};
+
+/*!
+ * @brief initialize bmi spi module
+ *
+ * @return zero success, non-zero failed
+ * @retval zero success
+ * @retval non-zero failed
+*/
+static int __init bmi_spi_init(void)
+{
+	return spi_register_driver(&bmi_spi_driver);
+}
+
+/*!
+ * @brief remove bmi spi module
+ *
+ * @return no return value
+*/
+static void __exit bmi_spi_exit(void)
+{
+	spi_unregister_driver(&bmi_spi_driver);
+}
+
+
+MODULE_AUTHOR("Contact <contact@bosch-sensortec.com>");
+MODULE_DESCRIPTION("BMI160 SPI DRIVER");
+MODULE_LICENSE("GPL v2");
+
+module_init(bmi_spi_init);
+module_exit(bmi_spi_exit);
+/*@}*/
+
diff --git a/drivers/input/sensors/bmi160/bs_log.c b/drivers/input/sensors/bmi160/bs_log.c
new file mode 100644
index 0000000..6574607
--- /dev/null
+++ b/drivers/input/sensors/bmi160/bs_log.c
@@ -0,0 +1,50 @@
+/*!
+ * @section LICENSE
+ * (C) Copyright 2011~2016 Bosch Sensortec GmbH All Rights Reserved
+ *
+ * This software program is licensed subject to the GNU General
+ * Public License (GPL).Version 2,June 1991,
+ * available at http://www.fsf.org/copyleft/gpl.html
+ *
+ * @filename bs_log.c
+ * @date     "Wed Sep 24 15:27:12 2014 +0800"
+ * @id       "e416c14"
+ *
+ * @brief
+ * The source file of BOSCH SENSOR LOG
+*/
+
+
+#ifdef __KERNEL__
+#include <linux/kernel.h>
+#include <linux/unistd.h>
+#include <linux/types.h>
+#else
+#include <unistd.h>
+#include <sys/types.h>
+#endif
+
+#include <linux/time.h>
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/init.h>
+
+#ifdef BOSCH_DRIVER_LOG_FUNC
+#define BSLOG_VAR_DEF
+#include "bs_log.h"
+
+void set_debug_log_level(uint8_t level)
+{
+	debug_log_level = level;
+}
+
+uint8_t get_debug_log_level(void)
+{
+	return debug_log_level;
+}
+
+EXPORT_SYMBOL(set_debug_log_level);
+EXPORT_SYMBOL(get_debug_log_level);
+
+#endif/*BOSCH_DRIVER_LOG_FUNC*/

+/*@}*/
diff --git a/drivers/input/sensors/bmi160/bs_log.h b/drivers/input/sensors/bmi160/bs_log.h
new file mode 100644
index 0000000..ed2d2b3
--- /dev/null
+++ b/drivers/input/sensors/bmi160/bs_log.h
@@ -0,0 +1,171 @@
+/*!
+ * @section LICENSE
+ * (C) Copyright 2011~2016 Bosch Sensortec GmbH All Rights Reserved
+ *
+ * This software program is licensed subject to the GNU General
+ * Public License (GPL).Version 2,June 1991,
+ * available at http://www.fsf.org/copyleft/gpl.html
+ *
+ * @filename bs_log.h
+ * @date     "Sat Oct 11 16:12:16 2014 +0800"
+ * @id       "762cc9e"
+ *
+ * @brief
+ * The head file of BOSCH SENSOR LOG
+*/
+
+#ifndef __BS_LOG_H
+#define __BS_LOG_H
+
+#include <linux/kernel.h>
+
+/*! @ trace functions
+ @{*/
+/*! ERROR LOG LEVEL */
+#define LOG_LEVEL_E 3
+/*! NOTICE LOG LEVEL */
+#define LOG_LEVEL_N 5
+/*! INFORMATION LOG LEVEL */
+#define LOG_LEVEL_I 6
+/*! DEBUG LOG LEVEL */
+#define LOG_LEVEL_D 7
+/*! DEBUG_FWDL LOG LEVEL */
+#define LOG_LEVEL_DF 10
+/*! DEBUG_DATA LOG LEVEL */
+#define LOG_LEVEL_DA 15
+/*! ALL LOG LEVEL */
+#define LOG_LEVEL_A 20
+
+#ifndef MODULE_TAG
+/*! MODULE TAG DEFINATION */
+#define MODULE_TAG "<BS_LOG>"
+#endif
+
+#ifndef LOG_LEVEL
+/*! LOG LEVEL DEFINATION */
+#define LOG_LEVEL LOG_LEVEL_I
+#endif
+
+#ifdef BOSCH_DRIVER_LOG_FUNC
+	#ifdef BSLOG_VAR_DEF
+		uint8_t debug_log_level = LOG_LEVEL;
+	#else
+		extern uint8_t debug_log_level;
+	#endif
+
+	/*! print error message */
+	#define PERR(fmt, args...) do\
+	{\
+		if (debug_log_level >= LOG_LEVEL_E)\
+			printk(KERN_INFO "\n" "[E]" KERN_ERR MODULE_TAG \
+				"<%s><%d>" fmt "\n", __func__, __LINE__, ##args);\
+	} while (0)
+
+	/*! print notice message */
+	#define PNOTICE(fmt, args...) do\
+	{\
+		if (debug_log_level >= LOG_LEVEL_N)\
+			printk(KERN_INFO "\n" "[N]" KERN_NOTICE MODULE_TAG \
+				"<%s><%d>" fmt "\n", __func__, __LINE__, ##args);\
+	} while (0)
+
+	/*! print information message */
+	#define PINFO(fmt, args...) do\
+	{\
+		if (debug_log_level >= LOG_LEVEL_I)\
+			printk(KERN_INFO "\n" "[I]" KERN_INFO MODULE_TAG \
+				"<%s><%d>" fmt "\n", __func__, __LINE__, ##args);\
+	} while (0)
+
+	/*! print debug message */
+	#define PDEBUG(fmt, args...) do\
+	{\
+		if (debug_log_level >= LOG_LEVEL_D)\
+			printk(KERN_INFO "\n" "[D]" KERN_DEBUG MODULE_TAG \
+				"<%s><%d>" fmt "\n", __func__, __LINE__, ##args);\
+	} while (0)
+
+	/*! print debug fw download message */
+	#define PDEBUG_FWDL(fmt, args...) do\
+	{\
+		if (debug_log_level >= LOG_LEVEL_DF)\
+			printk(KERN_INFO "\n" "[DF]" KERN_DEBUG MODULE_TAG \
+				"<%s><%d>" fmt "\n", __func__, __LINE__, ##args);\
+	} while (0)
+
+	/*! print debug data log message */
+	#define PDEBUG_DLOG(fmt, args...) do\
+	{\
+		if (debug_log_level >= LOG_LEVEL_DA)\
+			printk(KERN_INFO "\n" "[DA]" KERN_DEBUG MODULE_TAG \
+				"<%s><%d>" fmt "\n", __func__, __LINE__, ##args);\
+	} while (0)
+
+	void set_debug_log_level(uint8_t level);
+	uint8_t get_debug_log_level(void);
+
+#else
+
+	#if (LOG_LEVEL >= LOG_LEVEL_E)
+	/*! print error message */
+	#define PERR(fmt, args...) \
+		printk(KERN_INFO "\n" "[E]" KERN_ERR MODULE_TAG \
+		"<%s><%d>" fmt "\n", __func__, __LINE__, ##args)
+	#else
+	/*! invalid message */
+	#define PERR(fmt, args...)
+	#endif
+
+	#if (LOG_LEVEL >= LOG_LEVEL_N)
+	/*! print notice message */
+	#define PNOTICE(fmt, args...) \
+		printk(KERN_INFO "\n" "[N]" KERN_NOTICE MODULE_TAG \
+		"<%s><%d>" fmt "\n", __func__, __LINE__, ##args)
+	#else
+	/*! invalid message */
+	#define PNOTICE(fmt, args...)
+	#endif
+
+	#if (LOG_LEVEL >= LOG_LEVEL_I)
+	/*! print information message */
+	#define PINFO(fmt, args...) printk(KERN_INFO "\n" "[I]" KERN_INFO MODULE_TAG \
+		"<%s><%d>" fmt "\n", __func__, __LINE__, ##args)
+	#else
+	/*! invalid message */
+	#define PINFO(fmt, args...)
+	#endif
+
+	#if (LOG_LEVEL >= LOG_LEVEL_D)
+	/*! print debug message */
+	#define PDEBUG(fmt, args...) printk(KERN_INFO "\n" "[D]" KERN_DEBUG MODULE_TAG \
+		"<%s><%d>" fmt "\n", __func__, __LINE__, ##args)
+	#else
+	/*! invalid message */
+	#define PDEBUG(fmt, args...)
+	#endif
+
+	#if (LOG_LEVEL >= LOG_LEVEL_DF)
+	/*! print debug fw download message */
+	#define PDEBUG_FWDL(fmt, args...) printk(KERN_INFO "\n" "[DF]" KERN_DEBUG MODULE_TAG \
+		"<%s><%d>" fmt "\n", __func__, __LINE__, ##args)
+	#else
+	/*! invalid message */
+	#define PDEBUG_FWDL(fmt, args...)
+	#endif
+
+	#if (LOG_LEVEL >= LOG_LEVEL_DA)
+	/*! print debug data log message */
+	#define PDEBUG_DLOG(fmt, args...) printk(KERN_INFO "\n" "[DA]" KERN_DEBUG MODULE_TAG \
+		"<%s><%d>" fmt "\n", __func__, __LINE__, ##args)
+	#else
+	/*! invalid message */
+	#define PDEBUG_DLOG(fmt, args...)
+	#endif
+
+	#define set_debug_log_level(level) {}
+	#define get_debug_log_level() (LOG_LEVEL)
+
+#endif
+
+#endif/*__BS_LOG_H*/
+/*@}*/
diff --git a/drivers/input/sensors/bmi160/bstclass.c b/drivers/input/sensors/bmi160/bstclass.c
new file mode 100644
index 0000000..4937cca
--- /dev/null
+++ b/drivers/input/sensors/bmi160/bstclass.c
@@ -0,0 +1,238 @@
+/*!
+ * @section LICENSE
+ * (C) Copyright 2011~2016 Bosch Sensortec GmbH All Rights Reserved
+ *
+ * This software program is licensed subject to the GNU General
+ * Public License (GPL).Version 2,June 1991,
+ * available at http://www.fsf.org/copyleft/gpl.html
+ *
+ * @filename bstclass.c
+ * @date     2015/11/17 13:44
+ * @id       "836294d"
+ * @version  1.5.9
+ *
+ * @brief    
+ */
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/random.h>
+#include <linux/sched.h>
+#include <linux/seq_file.h>
+#include <linux/poll.h>
+#include <linux/mutex.h>
+#include <linux/rcupdate.h>
+#include <linux/compiler.h>
+#include <linux/compat.h>
+#include "bstclass.h"
+#include "bs_log.h"
+
+static LIST_HEAD(bst_dev_list);
+
+/*
+ * bst_mutex protects access to both bst_dev_list and input_handler_list.
+ * This also causes bst_[un]register_device and bst_[un]register_handler
+ * be mutually exclusive which simplifies locking in drivers implementing
+ * input handlers.
+ */
+static DEFINE_MUTEX(bst_mutex);
+
+
+static void bst_dev_release(struct device *device)
+{
+	struct bst_dev *dev = to_bst_dev(device);
+	if (NULL != dev)
+		kfree(dev);
+	module_put(THIS_MODULE);
+}
+
+
+#ifdef CONFIG_PM
+static int bst_dev_suspend(struct device *dev)
+{
+	return 0;
+}
+
+static int bst_dev_resume(struct device *dev)
+{
+	return 0;
+}
+
+static const struct dev_pm_ops bst_dev_pm_ops = {
+	.suspend    = bst_dev_suspend,
+	.resume     = bst_dev_resume,
+	.poweroff   = bst_dev_suspend,
+	.restore    = bst_dev_resume,
+};
+#endif /* CONFIG_PM */
+
+static const struct attribute_group *bst_dev_attr_groups[] = {
+	NULL
+};
+
+static struct device_type bst_dev_type = {
+	.groups      = bst_dev_attr_groups,
+	.release = bst_dev_release,
+#ifdef CONFIG_PM
+	.pm      = &bst_dev_pm_ops,
+#endif
+};
+
+
+
+static char *bst_devnode(struct device *dev, mode_t *mode)
+{
+	return kasprintf(GFP_KERNEL, "%s", dev_name(dev));
+}
+
+struct class bst_class = {
+	.name        = "bst",
+	.owner       = THIS_MODULE,
+	.devnode     = (void*)bst_devnode,
+	.dev_release = bst_dev_release,
+};
+EXPORT_SYMBOL_GPL(bst_class);
+
+/**
+ * bst_allocate_device - allocate memory for new input device
+ *
+ * Returns prepared struct bst_dev or NULL.
+ *
+ * NOTE: Use bst_free_device() to free devices that have not been
+ * registered; bst_unregister_device() should be used for already
+ * registered devices.
+ */
+struct bst_dev *bst_allocate_device(void)
+{
+	struct bst_dev *dev;
+
+	dev = kzalloc(sizeof(struct bst_dev), GFP_KERNEL);
+	if (dev) {
+		dev->dev.type = &bst_dev_type;
+		dev->dev.class = &bst_class;
+		device_initialize(&dev->dev);
+		mutex_init(&dev->mutex);
+		INIT_LIST_HEAD(&dev->node);
+		__module_get(THIS_MODULE);
+	}
+	return dev;
+}
+EXPORT_SYMBOL(bst_allocate_device);
+
+
+
+/**
+ * bst_free_device - free memory occupied by bst_dev structure
+ * @dev: input device to free
+ *
+ * This function should only be used if bst_register_device()
+ * was not called yet or if it failed. Once device was registered
+ * use bst_unregister_device() and memory will be freed once last
+ * reference to the device is dropped.
+ *
+ * Device should be allocated by bst_allocate_device().
+ *
+ * NOTE: If there are references to the input device then memory
+ * will not be freed until last reference is dropped.
+ */
+void bst_free_device(struct bst_dev *dev)
+{
+	if (dev)
+		bst_put_device(dev);
+}
+EXPORT_SYMBOL(bst_free_device);
+
+/**
+ * bst_register_device - register device with input core
+ * @dev: device to be registered
+ *
+ * This function registers device with input core. The device must be
+ * allocated with bst_allocate_device() and all it's capabilities
+ * set up before registering.
+ * If function fails the device must be freed with bst_free_device().
+ * Once device has been successfully registered it can be unregistered
+ * with bst_unregister_device(); bst_free_device() should not be
+ * called in this case.
+ */
+int bst_register_device(struct bst_dev *dev)
+{
+	const char *path;
+	int error;
+
+
+	/*
+	 * If delay and period are pre-set by the driver, then autorepeating
+	 * is handled by the driver itself and we don't do it in input.c.
+	 */
+	dev_set_name(&dev->dev, dev->name);
+
+	error = device_add(&dev->dev);
+	if (error)
+		return error;
+
+	path = kobject_get_path(&dev->dev.kobj, GFP_KERNEL);
+	PINFO("%s as %s\n",
+			dev->name ? dev->name : "Unspecified device",
+			path ? path : "N/A");
+	kfree(path);
+	error = mutex_lock_interruptible(&bst_mutex);
+	if (error) {
+		device_del(&dev->dev);
+		return error;
+	}
+
+	list_add_tail(&dev->node, &bst_dev_list);
+
+	mutex_unlock(&bst_mutex);
+	return 0;
+}
+EXPORT_SYMBOL(bst_register_device);
+
+/**
+ * bst_unregister_device - unregister previously registered device
+ * @dev: device to be unregistered
+ *
+ * This function unregisters an input device. Once device is unregistered
+ * the caller should not try to access it as it may get freed at any moment.
+ */
+void bst_unregister_device(struct bst_dev *dev)
+{
+	int ret = 0;
+	ret = mutex_lock_interruptible(&bst_mutex);
+	if(ret){
+		return;
+	}
+
+	list_del_init(&dev->node);
+	mutex_unlock(&bst_mutex);
+	device_unregister(&dev->dev);
+}
+EXPORT_SYMBOL(bst_unregister_device);
+
+static int __init bst_init(void)
+{
+	int err;
+	/*bst class register*/
+	err = class_register(&bst_class);
+	if (err) {
+		pr_err("unable to register bst_dev class\n");
+		return err;
+	}
+	return err;
+}
+
+static void __exit bst_exit(void)
+{
+	/*bst class*/
+	class_unregister(&bst_class);
+}
+
+/*subsys_initcall(bst_init);*/
+
+MODULE_AUTHOR("contact@bosch-sensortec.com");
+MODULE_DESCRIPTION("BST CLASS CORE");
+MODULE_LICENSE("GPL V2");
+
+module_init(bst_init);
+module_exit(bst_exit);
diff --git a/drivers/input/sensors/bmi160/bstclass.h b/drivers/input/sensors/bmi160/bstclass.h
new file mode 100644
index 0000000..7aa7760
--- /dev/null
+++ b/drivers/input/sensors/bmi160/bstclass.h
@@ -0,0 +1,78 @@
+/*!
+ * @section LICENSE
+ * (C) Copyright 2011~2016 Bosch Sensortec GmbH All Rights Reserved
+ *
+ * This software program is licensed subject to the GNU General
+ * Public License (GPL).Version 2,June 1991,
+ * available at http://www.fsf.org/copyleft/gpl.html
+ *
+ * @filename bstcalss.h
+ * @date     2015/11/17 13:44
+ * @id       "836294d"
+ * @version  1.5.9
+ *
+ * @brief  
+ */
+
+#ifndef _BSTCLASS_H
+#define _BSTCLASS_H
+
+#ifdef __KERNEL__
+#include <linux/time.h>
+#include <linux/list.h>
+#else
+#include <sys/time.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <linux/types.h>
+#endif
+
+#include <linux/device.h>
+#include <linux/fs.h>
+#include <linux/mod_devicetable.h>
+
+struct bst_dev {
+	const char *name;
+
+	int (*open)(struct bst_dev *dev);
+	void (*close)(struct bst_dev *dev);
+	struct mutex mutex;
+	struct device dev;
+	struct list_head node;
+};
+
+#define to_bst_dev(d) container_of(d, struct bst_dev, dev)
+
+struct bst_dev *bst_allocate_device(void);
+void bst_free_device(struct bst_dev *dev);
+
+static inline struct bst_dev *bst_get_device(struct bst_dev *dev)
+{
+	return dev ? to_bst_dev(get_device(&dev->dev)) : NULL;
+}
+
+static inline void bst_put_device(struct bst_dev *dev)
+{
+	if (dev)
+		put_device(&dev->dev);
+}
+
+static inline void *bst_get_drvdata(struct bst_dev *dev)
+{
+	return dev_get_drvdata(&dev->dev);
+}
+
+static inline void bst_set_drvdata(struct bst_dev *dev, void *data)
+{
+	dev_set_drvdata(&dev->dev, data);
+}
+
+int __must_check bst_register_device(struct bst_dev *);
+void bst_unregister_device(struct bst_dev *);
+
+void bst_reset_device(struct bst_dev *);
+
+
+extern struct class bst_class;
+
+#endif
diff --git a/drivers/input/sensors/smi130/Kconfig b/drivers/input/sensors/smi130/Kconfig
new file mode 100644
index 0000000..0dd0b39
--- /dev/null
+++ b/drivers/input/sensors/smi130/Kconfig
@@ -0,0 +1,121 @@
+#
+# Makefile for Bosch sensors driver.
+#
+config BOSCH_DRIVER_LOG_FUNC
+	tristate "Bosch Sensortec driver smart log function support"
+	depends on (I2C || SPI_MASTER) && SYSFS
+	help
+	 If you say yes here, you get support for smart log function in Bosch Sensortec driver.
+
+config SENSORS_SMI_ACC2X2
+	tristate "SMI130_ACC acceleration sensor support"
+	depends on I2C
+	help
+	  If you say yes here, you get support for Bosch Sensortec's
+	  acceleration sensors SMI_ACC255/SMI_ACC254/SMI_ACC355/SMI_ACC250E/SMI_ACC222E/SMI_ACC280.
+
+config SENSORS_SMI_ACC2X2_ENABLE_INT1
+	tristate "SMI_ACC2X2 acceleration sensor interrupt INT1 support"
+	depends on SENSORS_SMI_ACC2X2
+	help
+	 If you say yes here, you get INT1 support for Bosch Sensortec
+	 acceleration sensors SMI_ACC255/SMI_ACC250E/SMI_ACC222E/SMI_ACC280.
+	 Select it will disable interrupt INT2 support
+
+config SENSORS_SMI_ACC2X2_ENABLE_INT2
+	tristate "SMI_ACC2X2 acceleration sensor interrupt INT2 support"
+	depends on SENSORS_SMI_ACC2X2 && !SENSORS_SMI_ACC2X2_ENABLE_INT1
+	help
+	 If you say yes here, you get INT2 support for Bosch Sensortec
+	 acceleration sensors SMI_ACC255/SMI_ACC250E/SMI_ACC222E/SMI_ACC280.
+	 Can only open if you do NOT open interrupt INT1 support
+
+config SIG_MOTION
+	tristate "support significant motion sensor function"
+	depends on SENSORS_SMI_ACC2X2  && ( SENSORS_SMI_ACC2X2_ENABLE_INT1 || SENSORS_SMI_ACC2X2_ENABLE_INT2)
+	help
+	 If you say yes here, if you want to support Bosch significant motion sensor function
+
+config DOUBLE_TAP
+	tristate "support double tap sensor function"
+	depends on SENSORS_SMI_ACC2X2  && ( SENSORS_SMI_ACC2X2_ENABLE_INT1 || SENSORS_SMI_ACC2X2_ENABLE_INT2)
+	help
+	 If you say yes here, you get support Bosch double tap sensor function
+
+config SENSORS_SMI_GYRO
+	tristate "Bosch Gyroscope Sensor Driver"
+	depends on I2C
+	help
+	 If you say yes here, you get support for Bosch Sensortec's
+	 gyroscope sensor drivers of SMI130_GYRO/SMI055/BMI058 e.t.c.
+
+config SENSORS_SMI_GYRO_FIFO
+	tristate "Bosch Gyroscope FIFO Support"
+	depends on SENSORS_SMI_GYRO
+	help
+	 If you say yes here, you get support for Gyroscope sensor FIFO operations.
+	 Please check whether the chip supports fifo feature to open it.
+
+config SENSORS_BMI058
+	tristate "BMI058 Sensor Support"
+	depends on (SENSORS_SMI_GYRO || SENSORS_SMI_ACC2X2)
+	help
+	 If you say yes here, you get support for Bosch Sensortec's
+	 sensor driver of BMI058.
+
+config SENSORS_YAS537
+	tristate "YAS537 Magnetic Sensor Driver"
+	depends on I2C
+	help
+	 If you say yes here, you get support for YAMAHA
+	 sensor YAS537 Magnetic Sensor
+
+config SENSORS_BMM050
+	tristate "BMM050 Magnetic Sensor Driver"
+	depends on I2C
+	help
+	 If you say yes here, you get support for Bosch Sensortec's
+	 sensor BMM050 Magnetic Sensor
+
+config SENSORS_AKM09911
+	tristate "AKM09911 Mag Sensor Driver"
+	depends on I2C
+	help
+	 If you say yes here, you get support AKM09911 Sensor support.
+
+config SENSORS_AKM09912
+	tristate "AKM09912 Mag Sensor Driver"
+	depends on I2C
+	help
+	 If you say yes here, you get support AKM09912 Sensor support.
+
+config SENSORS_SMI_ACC420
+	tristate "SMI_ACC4XY Sensor Support"
+	depends on I2C || SPI_MASTER
+	help
+	If you say yes here, you get support for Bosch Sensortec's sensor driver of SMI_ACC420.
+config SENSORS_SMI_ACC421
+	tristate "SMI_ACC4XY Sensor Support"
+	depends on I2C || SPI_MASTER
+	help
+	If you say yes here, you get support for Bosch Sensortec's sensor driver of SMI_ACC421.
+config SENSORS_SMI_ACC422
+	tristate "SMI_ACC4XY Sensor Support"
+	depends on I2C || SPI_MASTER
+	help
+	If you say yes here, you get support for Bosch Sensortec's sensor driver of SMI_ACC422.
+config SENSORS_SMI_ACC455
+	tristate "SMI_ACC4XY Sensor Support"
+	depends on I2C || SPI_MASTER
+	help
+	If you say yes here, you get support for Bosch Sensortec's sensor driver of SMI_ACC455.
+
+config SMI_ACC4XY_MAG_INTERFACE_SUPPORT
+tristate "SMI_ACC4XY Sensor mag interface support"
+depends on SENSORS_SMI_ACC4XY
+	help
+	 If you say yes here, you get support for Bosch Sensortec's
+	 sensor driver of SMI_ACC4XY with mag sensor support.
+
+
+
diff --git a/drivers/input/sensors/smi130/Makefile b/drivers/input/sensors/smi130/Makefile
new file mode 100644
index 0000000..ad1e543
--- /dev/null
+++ b/drivers/input/sensors/smi130/Makefile
@@ -0,0 +1,47 @@
+#
+# Makefile for Bosch sensor driver.
+#
+
+obj-$(CONFIG_BOSCH_DRIVER_LOG_FUNC) += bs_log.o
+obj-y += boschclass.o
+ifeq ($(CONFIG_BOSCH_DRIVER_LOG_FUNC),y)
+	EXTRA_CFLAGS += -DBOSCH_DRIVER_LOG_FUNC
+endif
+
+obj-y   += smi130_acc.o
+
+ifeq ($(CONFIG_SENSORS_SMI_ACC2X2_ENABLE_INT1),y)
+	EXTRA_CFLAGS += -DSMI_ACC2X2_ENABLE_INT1
+endif
+
+ifeq ($(CONFIG_BOSCH_SMI_ACC2X2_ENABLE_INT2),y)
+	EXTRA_CFLAGS += -DSMI_ACC2X2_ENABLE_INT2
+endif
+
+obj-y    += smi130_gyro_driver.o smi130_gyro.o
+EXTRA_CFLAGS += -DSMI_GYRO_USE_BASIC_I2C_FUNC
+
+obj-y    += smi130_driver.o smi130.o
+ifeq ($(CONFIG_SMI130_MAG_INTERFACE_SUPPORT),y)
+		EXTRA_CFLAGS += -DSMI130_MAG_INTERFACE_SUPPORT
+endif
+ifeq ($(CONFIG_SENSORS_SMI130_ENABLE_INT1),y)
+		EXTRA_CFLAGS += -DSMI130_ENABLE_INT1
+endif
+
+ifeq ($(CONFIG_SENSORS_SMI130_ENABLE_INT2),y)
+		EXTRA_CFLAGS += -DSMI130_ENABLE_INT2
+endif
+
+obj-y  += smi130_i2c.o
+
+EXTRA_CFLAGS += -DSMI_USE_BASIC_I2C_FUNC
+
+obj-$(CONFIG_SENSORS_SMI130_SPI)  += smi130_spi.o
+
+
+
+
+
+
+
diff --git a/drivers/input/sensors/smi130/boschclass.c b/drivers/input/sensors/smi130/boschclass.c
new file mode 100644
index 0000000..8c28ab1
--- /dev/null
+++ b/drivers/input/sensors/smi130/boschclass.c
@@ -0,0 +1,341 @@
+/*!
+ * @section LICENSE
+ * (C) Copyright 2011~2016 Bosch Sensortec GmbH All Rights Reserved
+ *
+ * (C) Modification Copyright 2018 Robert Bosch Kft  All Rights Reserved
+ *
+ * This software program is licensed subject to the GNU General
+ * Public License (GPL).Version 2,June 1991,
+ * available at http://www.fsf.org/copyleft/gpl.html
+ *
+ * Special: Description of the Software:
+ *
+ * This software module (hereinafter called "Software") and any
+ * information on application-sheets (hereinafter called "Information") is
+ * provided free of charge for the sole purpose to support your application
+ * work. 
+ *
+ * As such, the Software is merely an experimental software, not tested for
+ * safety in the field and only intended for inspiration for further development 
+ * and testing. Any usage in a safety-relevant field of use (like automotive,
+ * seafaring, spacefaring, industrial plants etc.) was not intended, so there are
+ * no precautions for such usage incorporated in the Software.
+ * 
+ * The Software is specifically designed for the exclusive use for Bosch
+ * Sensortec products by personnel who have special experience and training. Do
+ * not use this Software if you do not have the proper experience or training.
+ * 
+ * This Software package is provided as is and without any expressed or
+ * implied warranties, including without limitation, the implied warranties of
+ * merchantability and fitness for a particular purpose.
+ * 
+ * Bosch Sensortec and their representatives and agents deny any liability for
+ * the functional impairment of this Software in terms of fitness, performance
+ * and safety. Bosch Sensortec and their representatives and agents shall not be
+ * liable for any direct or indirect damages or injury, except as otherwise
+ * stipulated in mandatory applicable law.
+ * The Information provided is believed to be accurate and reliable. Bosch
+ * Sensortec assumes no responsibility for the consequences of use of such
+ * Information nor for any infringement of patents or other rights of third
+ * parties which may result from its use.
+ * 
+ *------------------------------------------------------------------------------
+ * The following Product Disclaimer does not apply to the BSX4-HAL-4.1NoFusion Software 
+ * which is licensed under the Apache License, Version 2.0 as stated above.  
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Product Disclaimer
+ *
+ * Common:
+ *
+ * Assessment of Products Returned from Field
+ *
+ * Returned products are considered good if they fulfill the specifications / 
+ * test data for 0-mileage and field listed in this document.
+ *
+ * Engineering Samples
+ * 
+ * Engineering samples are marked with (e) or (E). Samples may vary from the
+ * valid technical specifications of the series product contained in this
+ * data sheet. Therefore, they are not intended or fit for resale to
+ * third parties or for use in end products. Their sole purpose is internal
+ * client testing. The testing of an engineering sample may in no way replace
+ * the testing of a series product. Bosch assumes no liability for the use
+ * of engineering samples. The purchaser shall indemnify Bosch from all claims
+ * arising from the use of engineering samples.
+ *
+ * Intended use
+ *
+ * Provided that SMI130 is used within the conditions (environment, application,
+ * installation, loads) as described in this TCD and the corresponding
+ * agreed upon documents, Bosch ensures that the product complies with
+ * the agreed properties. Agreements beyond this require
+ * the written approval by Bosch. The product is considered fit for the intended
+ * use when the product successfully has passed the tests
+ * in accordance with the TCD and agreed upon documents.
+ *
+ * It is the responsibility of the customer to ensure the proper application
+ * of the product in the overall system/vehicle.
+ *
+ * Bosch does not assume any responsibility for changes to the environment
+ * of the product that deviate from the TCD and the agreed upon documents 
+ * as well as all applications not released by Bosch
+  *
+ * The resale and/or use of products are at the purchaser’s own risk and 
+ * responsibility. The examination and testing of the SMI130 
+ * is the sole responsibility of the purchaser.
+ *
+ * The purchaser shall indemnify Bosch from all third party claims 
+ * arising from any product use not covered by the parameters of 
+ * this product data sheet or not approved by Bosch and reimburse Bosch 
+ * for all costs and damages in connection with such claims.
+ *
+ * The purchaser must monitor the market for the purchased products,
+ * particularly with regard to product safety, and inform Bosch without delay
+ * of all security relevant incidents.
+ *
+ * Application Examples and Hints
+ *
+ * With respect to any application examples, advice, normal values
+ * and/or any information regarding the application of the device,
+ * Bosch hereby disclaims any and all warranties and liabilities of any kind,
+ * including without limitation warranties of
+ * non-infringement of intellectual property rights or copyrights
+ * of any third party.
+ * The information given in this document shall in no event be regarded 
+ * as a guarantee of conditions or characteristics. They are provided
+ * for illustrative purposes only and no evaluation regarding infringement
+ * of intellectual property rights or copyrights or regarding functionality,
+ * performance or error has been made.
+ *
+ * @filename boschclass.c
+ * @date     2015/11/17 13:44
+ * @Modification Date 2018/08/28 18:20
+ * @id       "836294d"
+ * @version  1.5.9
+ *
+ * @brief    
+ */
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/random.h>
+#include <linux/sched.h>
+#include <linux/seq_file.h>
+#include <linux/poll.h>
+#include <linux/mutex.h>
+#include <linux/rcupdate.h>
+#include <linux/compiler.h>
+#include <linux/compat.h>
+#include "boschclass.h"
+#include "bs_log.h"
+
+static LIST_HEAD(bosch_dev_list);
+
+/*
+ * bosch_mutex protects access to both bosch_dev_list and input_handler_list.
+ * This also causes bosch_[un]register_device and bosch_[un]register_handler
+ * be mutually exclusive which simplifies locking in drivers implementing
+ * input handlers.
+ */
+static DEFINE_MUTEX(bosch_mutex);
+
+
+static void bosch_dev_release(struct device *device)
+{
+	struct bosch_dev *dev = to_bosch_dev(device);
+	if (NULL != dev)
+		kfree(dev);
+	module_put(THIS_MODULE);
+}
+
+
+#ifdef CONFIG_PM
+static int bosch_dev_suspend(struct device *dev)
+{
+	return 0;
+}
+
+static int bosch_dev_resume(struct device *dev)
+{
+	return 0;
+}
+
+static const struct dev_pm_ops bosch_dev_pm_ops = {
+	.suspend    = bosch_dev_suspend,
+	.resume     = bosch_dev_resume,
+	.poweroff   = bosch_dev_suspend,
+	.restore    = bosch_dev_resume,
+};
+#endif /* CONFIG_PM */
+
+static const struct attribute_group *bosch_dev_attr_groups[] = {
+	NULL
+};
+
+static struct device_type bosch_dev_type = {
+	.groups      = bosch_dev_attr_groups,
+	.release = bosch_dev_release,
+#ifdef CONFIG_PM
+	.pm      = &bosch_dev_pm_ops,
+#endif
+};
+
+
+
+static char *bosch_devnode(struct device *dev, mode_t *mode)
+{
+	return kasprintf(GFP_KERNEL, "%s", dev_name(dev));
+}
+
+struct class bosch_class = {
+	.name        = "bosch",
+	.owner       = THIS_MODULE,
+	.devnode     = (void*)bosch_devnode,
+	.dev_release = bosch_dev_release,
+};
+EXPORT_SYMBOL_GPL(bosch_class);
+
+/**
+ * bosch_allocate_device - allocate memory for new input device
+ *
+ * Returns prepared struct bosch_dev or NULL.
+ *
+ * NOTE: Use bosch_free_device() to free devices that have not been
+ * registered; bosch_unregister_device() should be used for already
+ * registered devices.
+ */
+struct bosch_dev *bosch_allocate_device(void)
+{
+	struct bosch_dev *dev;
+
+	dev = kzalloc(sizeof(struct bosch_dev), GFP_KERNEL);
+	if (dev) {
+		dev->dev.type = &bosch_dev_type;
+		dev->dev.class = &bosch_class;
+		device_initialize(&dev->dev);
+		mutex_init(&dev->mutex);
+		INIT_LIST_HEAD(&dev->node);
+		__module_get(THIS_MODULE);
+	}
+	return dev;
+}
+EXPORT_SYMBOL(bosch_allocate_device);
+
+
+
+/**
+ * bosch_free_device - free memory occupied by bosch_dev structure
+ * @dev: input device to free
+ *
+ * This function should only be used if bosch_register_device()
+ * was not called yet or if it failed. Once device was registered
+ * use bosch_unregister_device() and memory will be freed once last
+ * reference to the device is dropped.
+ *
+ * Device should be allocated by bosch_allocate_device().
+ *
+ * NOTE: If there are references to the input device then memory
+ * will not be freed until last reference is dropped.
+ */
+void bosch_free_device(struct bosch_dev *dev)
+{
+	if (dev)
+		bosch_put_device(dev);
+}
+EXPORT_SYMBOL(bosch_free_device);
+
+/**
+ * bosch_register_device - register device with input core
+ * @dev: device to be registered
+ *
+ * This function registers device with input core. The device must be
+ * allocated with bosch_allocate_device() and all it's capabilities
+ * set up before registering.
+ * If function fails the device must be freed with bosch_free_device().
+ * Once device has been successfully registered it can be unregistered
+ * with bosch_unregister_device(); bosch_free_device() should not be
+ * called in this case.
+ */
+int bosch_register_device(struct bosch_dev *dev)
+{
+	const char *path;
+	int error;
+
+
+	/*
+	 * If delay and period are pre-set by the driver, then autorepeating
+	 * is handled by the driver itself and we don't do it in input.c.
+	 */
+	dev_set_name(&dev->dev, dev->name);
+
+	error = device_add(&dev->dev);
+	if (error)
+		return error;
+
+	path = kobject_get_path(&dev->dev.kobj, GFP_KERNEL);
+	PINFO("%s as %s\n",
+			dev->name ? dev->name : "Unspecified device",
+			path ? path : "N/A");
+	kfree(path);
+	error = mutex_lock_interruptible(&bosch_mutex);
+	if (error) {
+		device_del(&dev->dev);
+		return error;
+	}
+
+	list_add_tail(&dev->node, &bosch_dev_list);
+
+	mutex_unlock(&bosch_mutex);
+	return 0;
+}
+EXPORT_SYMBOL(bosch_register_device);
+
+/**
+ * bosch_unregister_device - unregister previously registered device
+ * @dev: device to be unregistered
+ *
+ * This function unregisters an input device. Once device is unregistered
+ * the caller should not try to access it as it may get freed at any moment.
+ */
+void bosch_unregister_device(struct bosch_dev *dev)
+{
+	int ret = 0;
+	ret = mutex_lock_interruptible(&bosch_mutex);
+	if(ret){
+		return;
+	}
+
+	list_del_init(&dev->node);
+	mutex_unlock(&bosch_mutex);
+	device_unregister(&dev->dev);
+}
+EXPORT_SYMBOL(bosch_unregister_device);
+
+static int __init bosch_init(void)
+{
+	int err;
+	/*bosch class register*/
+	err = class_register(&bosch_class);
+	if (err) {
+		pr_err("unable to register bosch_dev class\n");
+		return err;
+	}
+	return err;
+}
+
+static void __exit bosch_exit(void)
+{
+	/*bosch class*/
+	class_unregister(&bosch_class);
+}
+
+/*subsys_initcall(bosch_init);*/
+
+MODULE_AUTHOR("contact@bosch-sensortec.com");
+MODULE_DESCRIPTION("BST CLASS CORE");
+MODULE_LICENSE("GPL V2");
+
+module_init(bosch_init);
+module_exit(bosch_exit);
diff --git a/drivers/input/sensors/smi130/boschclass.h b/drivers/input/sensors/smi130/boschclass.h
new file mode 100644
index 0000000..a89cc5d
--- /dev/null
+++ b/drivers/input/sensors/smi130/boschclass.h
@@ -0,0 +1,181 @@
+/*!
+ * @section LICENSE
+ * (C) Copyright 2011~2016 Bosch Sensortec GmbH All Rights Reserved
+ *
+ * (C) Modification Copyright 2018 Robert Bosch Kft  All Rights Reserved
+ *
+ * This software program is licensed subject to the GNU General
+ * Public License (GPL).Version 2,June 1991,
+ * available at http://www.fsf.org/copyleft/gpl.html
+ *
+ * Special: Description of the Software:
+ *
+ * This software module (hereinafter called "Software") and any
+ * information on application-sheets (hereinafter called "Information") is
+ * provided free of charge for the sole purpose to support your application
+ * work. 
+ *
+ * As such, the Software is merely an experimental software, not tested for
+ * safety in the field and only intended for inspiration for further development 
+ * and testing. Any usage in a safety-relevant field of use (like automotive,
+ * seafaring, spacefaring, industrial plants etc.) was not intended, so there are
+ * no precautions for such usage incorporated in the Software.
+ * 
+ * The Software is specifically designed for the exclusive use for Bosch
+ * Sensortec products by personnel who have special experience and training. Do
+ * not use this Software if you do not have the proper experience or training.
+ * 
+ * This Software package is provided as is and without any expressed or
+ * implied warranties, including without limitation, the implied warranties of
+ * merchantability and fitness for a particular purpose.
+ * 
+ * Bosch Sensortec and their representatives and agents deny any liability for
+ * the functional impairment of this Software in terms of fitness, performance
+ * and safety. Bosch Sensortec and their representatives and agents shall not be
+ * liable for any direct or indirect damages or injury, except as otherwise
+ * stipulated in mandatory applicable law.
+ * The Information provided is believed to be accurate and reliable. Bosch
+ * Sensortec assumes no responsibility for the consequences of use of such
+ * Information nor for any infringement of patents or other rights of third
+ * parties which may result from its use.
+ * 
+ *------------------------------------------------------------------------------
+ * The following Product Disclaimer does not apply to the BSX4-HAL-4.1NoFusion Software 
+ * which is licensed under the Apache License, Version 2.0 as stated above.  
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Product Disclaimer
+ *
+ * Common:
+ *
+ * Assessment of Products Returned from Field
+ *
+ * Returned products are considered good if they fulfill the specifications / 
+ * test data for 0-mileage and field listed in this document.
+ *
+ * Engineering Samples
+ * 
+ * Engineering samples are marked with (e) or (E). Samples may vary from the
+ * valid technical specifications of the series product contained in this
+ * data sheet. Therefore, they are not intended or fit for resale to
+ * third parties or for use in end products. Their sole purpose is internal
+ * client testing. The testing of an engineering sample may in no way replace
+ * the testing of a series product. Bosch assumes no liability for the use
+ * of engineering samples. The purchaser shall indemnify Bosch from all claims
+ * arising from the use of engineering samples.
+ *
+ * Intended use
+ *
+ * Provided that SMI130 is used within the conditions (environment, application,
+ * installation, loads) as described in this TCD and the corresponding
+ * agreed upon documents, Bosch ensures that the product complies with
+ * the agreed properties. Agreements beyond this require
+ * the written approval by Bosch. The product is considered fit for the intended
+ * use when the product successfully has passed the tests
+ * in accordance with the TCD and agreed upon documents.
+ *
+ * It is the responsibility of the customer to ensure the proper application
+ * of the product in the overall system/vehicle.
+ *
+ * Bosch does not assume any responsibility for changes to the environment
+ * of the product that deviate from the TCD and the agreed upon documents 
+ * as well as all applications not released by Bosch
+  *
+ * The resale and/or use of products are at the purchaser’s own risk and 
+ * responsibility. The examination and testing of the SMI130 
+ * is the sole responsibility of the purchaser.
+ *
+ * The purchaser shall indemnify Bosch from all third party claims 
+ * arising from any product use not covered by the parameters of 
+ * this product data sheet or not approved by Bosch and reimburse Bosch 
+ * for all costs and damages in connection with such claims.
+ *
+ * The purchaser must monitor the market for the purchased products,
+ * particularly with regard to product safety, and inform Bosch without delay
+ * of all security relevant incidents.
+ *
+ * Application Examples and Hints
+ *
+ * With respect to any application examples, advice, normal values
+ * and/or any information regarding the application of the device,
+ * Bosch hereby disclaims any and all warranties and liabilities of any kind,
+ * including without limitation warranties of
+ * non-infringement of intellectual property rights or copyrights
+ * of any third party.
+ * The information given in this document shall in no event be regarded 
+ * as a guarantee of conditions or characteristics. They are provided
+ * for illustrative purposes only and no evaluation regarding infringement
+ * of intellectual property rights or copyrights or regarding functionality,
+ * performance or error has been made.
+ *
+ * @filename boschcalss.h
+ * @date     2015/11/17 13:44
+ * @Modification Date 2018/08/28 18:20
+ * @id       "836294d"
+ * @version  1.5.9
+ *
+ * @brief  
+ */
+
+#ifndef _BSTCLASS_H
+#define _BSTCLASS_H
+
+#ifdef __KERNEL__
+#include <linux/time.h>
+#include <linux/list.h>
+#else
+#include <sys/time.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <linux/types.h>
+#endif
+
+#include <linux/device.h>
+#include <linux/fs.h>
+#include <linux/mod_devicetable.h>
+
+struct bosch_dev {
+	const char *name;
+
+	int (*open)(struct bosch_dev *dev);
+	void (*close)(struct bosch_dev *dev);
+	struct mutex mutex;
+	struct device dev;
+	struct list_head node;
+};
+
+#define to_bosch_dev(d) container_of(d, struct bosch_dev, dev)
+
+struct bosch_dev *bosch_allocate_device(void);
+void bosch_free_device(struct bosch_dev *dev);
+
+static inline struct bosch_dev *bosch_get_device(struct bosch_dev *dev)
+{
+	return dev ? to_bosch_dev(get_device(&dev->dev)) : NULL;
+}
+
+static inline void bosch_put_device(struct bosch_dev *dev)
+{
+	if (dev)
+		put_device(&dev->dev);
+}
+
+static inline void *bosch_get_drvdata(struct bosch_dev *dev)
+{
+	return dev_get_drvdata(&dev->dev);
+}
+
+static inline void bosch_set_drvdata(struct bosch_dev *dev, void *data)
+{
+	dev_set_drvdata(&dev->dev, data);
+}
+
+int __must_check bosch_register_device(struct bosch_dev *);
+void bosch_unregister_device(struct bosch_dev *);
+
+void bosch_reset_device(struct bosch_dev *);
+
+
+extern struct class bosch_class;
+
+#endif
diff --git a/drivers/input/sensors/smi130/bs_log.c b/drivers/input/sensors/smi130/bs_log.c
new file mode 100644
index 0000000..05ddddd
--- /dev/null
+++ b/drivers/input/sensors/smi130/bs_log.c
@@ -0,0 +1,153 @@
+/*!
+ * @section LICENSE
+ * (C) Copyright 2011~2016 Bosch Sensortec GmbH All Rights Reserved
+ *
+ * (C) Modification Copyright 2018 Robert Bosch Kft  All Rights Reserved
+ *
+ * This software program is licensed subject to the GNU General
+ * Public License (GPL).Version 2,June 1991,
+ * available at http://www.fsf.org/copyleft/gpl.html
+ *
+ * Special: Description of the Software:
+ *
+ * This software module (hereinafter called "Software") and any
+ * information on application-sheets (hereinafter called "Information") is
+ * provided free of charge for the sole purpose to support your application
+ * work. 
+ *
+ * As such, the Software is merely an experimental software, not tested for
+ * safety in the field and only intended for inspiration for further development 
+ * and testing. Any usage in a safety-relevant field of use (like automotive,
+ * seafaring, spacefaring, industrial plants etc.) was not intended, so there are
+ * no precautions for such usage incorporated in the Software.
+ * 
+ * The Software is specifically designed for the exclusive use for Bosch
+ * Sensortec products by personnel who have special experience and training. Do
+ * not use this Software if you do not have the proper experience or training.
+ * 
+ * This Software package is provided as is and without any expressed or
+ * implied warranties, including without limitation, the implied warranties of
+ * merchantability and fitness for a particular purpose.
+ * 
+ * Bosch Sensortec and their representatives and agents deny any liability for
+ * the functional impairment of this Software in terms of fitness, performance
+ * and safety. Bosch Sensortec and their representatives and agents shall not be
+ * liable for any direct or indirect damages or injury, except as otherwise
+ * stipulated in mandatory applicable law.
+ * The Information provided is believed to be accurate and reliable. Bosch
+ * Sensortec assumes no responsibility for the consequences of use of such
+ * Information nor for any infringement of patents or other rights of third
+ * parties which may result from its use.
+ * 
+ *------------------------------------------------------------------------------
+ * The following Product Disclaimer does not apply to the BSX4-HAL-4.1NoFusion Software 
+ * which is licensed under the Apache License, Version 2.0 as stated above.  
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Product Disclaimer
+ *
+ * Common:
+ *
+ * Assessment of Products Returned from Field
+ *
+ * Returned products are considered good if they fulfill the specifications / 
+ * test data for 0-mileage and field listed in this document.
+ *
+ * Engineering Samples
+ * 
+ * Engineering samples are marked with (e) or (E). Samples may vary from the
+ * valid technical specifications of the series product contained in this
+ * data sheet. Therefore, they are not intended or fit for resale to
+ * third parties or for use in end products. Their sole purpose is internal
+ * client testing. The testing of an engineering sample may in no way replace
+ * the testing of a series product. Bosch assumes no liability for the use
+ * of engineering samples. The purchaser shall indemnify Bosch from all claims
+ * arising from the use of engineering samples.
+ *
+ * Intended use
+ *
+ * Provided that SMI130 is used within the conditions (environment, application,
+ * installation, loads) as described in this TCD and the corresponding
+ * agreed upon documents, Bosch ensures that the product complies with
+ * the agreed properties. Agreements beyond this require
+ * the written approval by Bosch. The product is considered fit for the intended
+ * use when the product successfully has passed the tests
+ * in accordance with the TCD and agreed upon documents.
+ *
+ * It is the responsibility of the customer to ensure the proper application
+ * of the product in the overall system/vehicle.
+ *
+ * Bosch does not assume any responsibility for changes to the environment
+ * of the product that deviate from the TCD and the agreed upon documents 
+ * as well as all applications not released by Bosch
+  *
+ * The resale and/or use of products are at the purchaser’s own risk and 
+ * responsibility. The examination and testing of the SMI130 
+ * is the sole responsibility of the purchaser.
+ *
+ * The purchaser shall indemnify Bosch from all third party claims 
+ * arising from any product use not covered by the parameters of 
+ * this product data sheet or not approved by Bosch and reimburse Bosch 
+ * for all costs and damages in connection with such claims.
+ *
+ * The purchaser must monitor the market for the purchased products,
+ * particularly with regard to product safety, and inform Bosch without delay
+ * of all security relevant incidents.
+ *
+ * Application Examples and Hints
+ *
+ * With respect to any application examples, advice, normal values
+ * and/or any information regarding the application of the device,
+ * Bosch hereby disclaims any and all warranties and liabilities of any kind,
+ * including without limitation warranties of
+ * non-infringement of intellectual property rights or copyrights
+ * of any third party.
+ * The information given in this document shall in no event be regarded 
+ * as a guarantee of conditions or characteristics. They are provided
+ * for illustrative purposes only and no evaluation regarding infringement
+ * of intellectual property rights or copyrights or regarding functionality,
+ * performance or error has been made.
+ *
+ * @filename bs_log.c
+ * @date     "Wed Sep 24 15:27:12 2014 +0800"
+ * @Modification Date 2018/08/28 18:20
+ * @id       "e416c14"
+ *
+ * @brief
+ * The source file of BOSCH SENSOR LOG
+*/
+
+
+#ifdef __KERNEL__
+#include <linux/kernel.h>
+#include <linux/unistd.h>
+#include <linux/types.h>
+#else
+#include <unistd.h>
+#include <sys/types.h>
+#endif
+
+#include <linux/time.h>
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/init.h>
+
+#ifdef BOSCH_DRIVER_LOG_FUNC
+#define BSLOG_VAR_DEF
+#include "bs_log.h"
+
+void set_debug_log_level(uint8_t level)
+{
+	debug_log_level = level;
+}
+
+uint8_t get_debug_log_level(void)
+{
+	return debug_log_level;
+}
+
+EXPORT_SYMBOL(set_debug_log_level);
+EXPORT_SYMBOL(get_debug_log_level);
+
+#endif/*BOSCH_DRIVER_LOG_FUNC*/

+/*@}*/
diff --git a/drivers/input/sensors/smi130/bs_log.h b/drivers/input/sensors/smi130/bs_log.h
new file mode 100644
index 0000000..86ef153
--- /dev/null
+++ b/drivers/input/sensors/smi130/bs_log.h
@@ -0,0 +1,274 @@
+/*!
+ * @section LICENSE
+ * (C) Copyright 2011~2016 Bosch Sensortec GmbH All Rights Reserved
+ *
+ * (C) Modification Copyright 2018 Robert Bosch Kft  All Rights Reserved
+ *
+ * This software program is licensed subject to the GNU General
+ * Public License (GPL).Version 2,June 1991,
+ * available at http://www.fsf.org/copyleft/gpl.html
+ *
+ * Special: Description of the Software:
+ *
+ * This software module (hereinafter called "Software") and any
+ * information on application-sheets (hereinafter called "Information") is
+ * provided free of charge for the sole purpose to support your application
+ * work. 
+ *
+ * As such, the Software is merely an experimental software, not tested for
+ * safety in the field and only intended for inspiration for further development 
+ * and testing. Any usage in a safety-relevant field of use (like automotive,
+ * seafaring, spacefaring, industrial plants etc.) was not intended, so there are
+ * no precautions for such usage incorporated in the Software.
+ * 
+ * The Software is specifically designed for the exclusive use for Bosch
+ * Sensortec products by personnel who have special experience and training. Do
+ * not use this Software if you do not have the proper experience or training.
+ * 
+ * This Software package is provided as is and without any expressed or
+ * implied warranties, including without limitation, the implied warranties of
+ * merchantability and fitness for a particular purpose.
+ * 
+ * Bosch Sensortec and their representatives and agents deny any liability for
+ * the functional impairment of this Software in terms of fitness, performance
+ * and safety. Bosch Sensortec and their representatives and agents shall not be
+ * liable for any direct or indirect damages or injury, except as otherwise
+ * stipulated in mandatory applicable law.
+ * The Information provided is believed to be accurate and reliable. Bosch
+ * Sensortec assumes no responsibility for the consequences of use of such
+ * Information nor for any infringement of patents or other rights of third
+ * parties which may result from its use.
+ * 
+ *------------------------------------------------------------------------------
+ * The following Product Disclaimer does not apply to the BSX4-HAL-4.1NoFusion Software 
+ * which is licensed under the Apache License, Version 2.0 as stated above.  
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Product Disclaimer
+ *
+ * Common:
+ *
+ * Assessment of Products Returned from Field
+ *
+ * Returned products are considered good if they fulfill the specifications / 
+ * test data for 0-mileage and field listed in this document.
+ *
+ * Engineering Samples
+ * 
+ * Engineering samples are marked with (e) or (E). Samples may vary from the
+ * valid technical specifications of the series product contained in this
+ * data sheet. Therefore, they are not intended or fit for resale to
+ * third parties or for use in end products. Their sole purpose is internal
+ * client testing. The testing of an engineering sample may in no way replace
+ * the testing of a series product. Bosch assumes no liability for the use
+ * of engineering samples. The purchaser shall indemnify Bosch from all claims
+ * arising from the use of engineering samples.
+ *
+ * Intended use
+ *
+ * Provided that SMI130 is used within the conditions (environment, application,
+ * installation, loads) as described in this TCD and the corresponding
+ * agreed upon documents, Bosch ensures that the product complies with
+ * the agreed properties. Agreements beyond this require
+ * the written approval by Bosch. The product is considered fit for the intended
+ * use when the product successfully has passed the tests
+ * in accordance with the TCD and agreed upon documents.
+ *
+ * It is the responsibility of the customer to ensure the proper application
+ * of the product in the overall system/vehicle.
+ *
+ * Bosch does not assume any responsibility for changes to the environment
+ * of the product that deviate from the TCD and the agreed upon documents 
+ * as well as all applications not released by Bosch
+  *
+ * The resale and/or use of products are at the purchaser’s own risk and 
+ * responsibility. The examination and testing of the SMI130 
+ * is the sole responsibility of the purchaser.
+ *
+ * The purchaser shall indemnify Bosch from all third party claims 
+ * arising from any product use not covered by the parameters of 
+ * this product data sheet or not approved by Bosch and reimburse Bosch 
+ * for all costs and damages in connection with such claims.
+ *
+ * The purchaser must monitor the market for the purchased products,
+ * particularly with regard to product safety, and inform Bosch without delay
+ * of all security relevant incidents.
+ *
+ * Application Examples and Hints
+ *
+ * With respect to any application examples, advice, normal values
+ * and/or any information regarding the application of the device,
+ * Bosch hereby disclaims any and all warranties and liabilities of any kind,
+ * including without limitation warranties of
+ * non-infringement of intellectual property rights or copyrights
+ * of any third party.
+ * The information given in this document shall in no event be regarded 
+ * as a guarantee of conditions or characteristics. They are provided
+ * for illustrative purposes only and no evaluation regarding infringement
+ * of intellectual property rights or copyrights or regarding functionality,
+ * performance or error has been made.
+ *
+ * @filename bs_log.h
+ * @date     "Sat Oct 11 16:12:16 2014 +0800"
+ * @Modification Date 2018/08/28 18:20
+ * @id       "762cc9e"
+ *
+ * @brief
+ * The head file of BOSCH SENSOR LOG
+*/
+
+#ifndef __BS_LOG_H
+#define __BS_LOG_H
+
+#include <linux/kernel.h>
+
+/*! @ trace functions
+ @{*/
+/*! ERROR LOG LEVEL */
+#define LOG_LEVEL_E 3
+/*! NOTICE LOG LEVEL */
+#define LOG_LEVEL_N 5
+/*! INFORMATION LOG LEVEL */
+#define LOG_LEVEL_I 6
+/*! DEBUG LOG LEVEL */
+#define LOG_LEVEL_D 7
+/*! DEBUG_FWDL LOG LEVEL */
+#define LOG_LEVEL_DF 10
+/*! DEBUG_DATA LOG LEVEL */
+#define LOG_LEVEL_DA 15
+/*! ALL LOG LEVEL */
+#define LOG_LEVEL_A 20
+
+#ifndef MODULE_TAG
+/*! MODULE TAG DEFINATION */
+#define MODULE_TAG "<BS_LOG>"
+#endif
+
+#ifndef LOG_LEVEL
+/*! LOG LEVEL DEFINATION */
+#define LOG_LEVEL LOG_LEVEL_I
+#endif
+
+#ifdef BOSCH_DRIVER_LOG_FUNC
+	#ifdef BSLOG_VAR_DEF
+		uint8_t debug_log_level = LOG_LEVEL;
+	#else
+		extern uint8_t debug_log_level;
+	#endif
+
+	/*! print error message */
+	#define PERR(fmt, args...) do\
+	{\
+		if (debug_log_level >= LOG_LEVEL_E)\
+			printk(KERN_INFO "\n" "[E]" KERN_ERR MODULE_TAG \
+				"<%s><%d>" fmt "\n", __func__, __LINE__, ##args);\
+	} while (0)
+
+	/*! print notice message */
+	#define PNOTICE(fmt, args...) do\
+	{\
+		if (debug_log_level >= LOG_LEVEL_N)\
+			printk(KERN_INFO "\n" "[N]" KERN_NOTICE MODULE_TAG \
+				"<%s><%d>" fmt "\n", __func__, __LINE__, ##args);\
+	} while (0)
+
+	/*! print information message */
+	#define PINFO(fmt, args...) do\
+	{\
+		if (debug_log_level >= LOG_LEVEL_I)\
+			printk(KERN_INFO "\n" "[I]" KERN_INFO MODULE_TAG \
+				"<%s><%d>" fmt "\n", __func__, __LINE__, ##args);\
+	} while (0)
+
+	/*! print debug message */
+	#define PDEBUG(fmt, args...) do\
+	{\
+		if (debug_log_level >= LOG_LEVEL_D)\
+			printk(KERN_INFO "\n" "[D]" KERN_DEBUG MODULE_TAG \
+				"<%s><%d>" fmt "\n", __func__, __LINE__, ##args);\
+	} while (0)
+
+	/*! print debug fw download message */
+	#define PDEBUG_FWDL(fmt, args...) do\
+	{\
+		if (debug_log_level >= LOG_LEVEL_DF)\
+			printk(KERN_INFO "\n" "[DF]" KERN_DEBUG MODULE_TAG \
+				"<%s><%d>" fmt "\n", __func__, __LINE__, ##args);\
+	} while (0)
+
+	/*! print debug data log message */
+	#define PDEBUG_DLOG(fmt, args...) do\
+	{\
+		if (debug_log_level >= LOG_LEVEL_DA)\
+			printk(KERN_INFO "\n" "[DA]" KERN_DEBUG MODULE_TAG \
+				"<%s><%d>" fmt "\n", __func__, __LINE__, ##args);\
+	} while (0)
+
+	void set_debug_log_level(uint8_t level);
+	uint8_t get_debug_log_level(void);
+
+#else
+
+	#if (LOG_LEVEL >= LOG_LEVEL_E)
+	/*! print error message */
+	#define PERR(fmt, args...) \
+		printk(KERN_INFO "\n" "[E]" KERN_ERR MODULE_TAG \
+		"<%s><%d>" fmt "\n", __func__, __LINE__, ##args)
+	#else
+	/*! invalid message */
+	#define PERR(fmt, args...)
+	#endif
+
+	#if (LOG_LEVEL >= LOG_LEVEL_N)
+	/*! print notice message */
+	#define PNOTICE(fmt, args...) \
+		printk(KERN_INFO "\n" "[N]" KERN_NOTICE MODULE_TAG \
+		"<%s><%d>" fmt "\n", __func__, __LINE__, ##args)
+	#else
+	/*! invalid message */
+	#define PNOTICE(fmt, args...)
+	#endif
+
+	#if (LOG_LEVEL >= LOG_LEVEL_I)
+	/*! print information message */
+	#define PINFO(fmt, args...) printk(KERN_INFO "\n" "[I]" KERN_INFO MODULE_TAG \
+		"<%s><%d>" fmt "\n", __func__, __LINE__, ##args)
+	#else
+	/*! invalid message */
+	#define PINFO(fmt, args...)
+	#endif
+
+	#if (LOG_LEVEL >= LOG_LEVEL_D)
+	/*! print debug message */
+	#define PDEBUG(fmt, args...) printk(KERN_INFO "\n" "[D]" KERN_DEBUG MODULE_TAG \
+		"<%s><%d>" fmt "\n", __func__, __LINE__, ##args)
+	#else
+	/*! invalid message */
+	#define PDEBUG(fmt, args...)
+	#endif
+
+	#if (LOG_LEVEL >= LOG_LEVEL_DF)
+	/*! print debug fw download message */
+	#define PDEBUG_FWDL(fmt, args...) printk(KERN_INFO "\n" "[DF]" KERN_DEBUG MODULE_TAG \
+		"<%s><%d>" fmt "\n", __func__, __LINE__, ##args)
+	#else
+	/*! invalid message */
+	#define PDEBUG_FWDL(fmt, args...)
+	#endif
+
+	#if (LOG_LEVEL >= LOG_LEVEL_DA)
+	/*! print debug data log message */
+	#define PDEBUG_DLOG(fmt, args...) printk(KERN_INFO "\n" "[DA]" KERN_DEBUG MODULE_TAG \
+		"<%s><%d>" fmt "\n", __func__, __LINE__, ##args)
+	#else
+	/*! invalid message */
+	#define PDEBUG_DLOG(fmt, args...)
+	#endif
+
+	#define set_debug_log_level(level) {}
+	#define get_debug_log_level() (LOG_LEVEL)
+
+#endif
+
+#endif/*__BS_LOG_H*/
+/*@}*/
diff --git a/drivers/input/sensors/smi130/modules.order b/drivers/input/sensors/smi130/modules.order
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/drivers/input/sensors/smi130/modules.order
diff --git a/drivers/input/sensors/smi130/readme.md b/drivers/input/sensors/smi130/readme.md
new file mode 100644
index 0000000..48b2cc1
--- /dev/null
+++ b/drivers/input/sensors/smi130/readme.md
@@ -0,0 +1,49 @@
+# SMI130 sensor API

+## Introduction

+This package contains the Robert Bosch GmbH's SMI130 sensor driver (sensor API)

+

+## Version

+File                 | Version | Date

+---------------------|---------|---------------

+smi130.h             |  2.0.9  |   2018/08/28

+smi130.c             |  2.0.9  |   2018/08/28

+smi130_spi.c         |   1.3   |   2018/08/28

+smi130_i2c.c         |   1.3   |   2018/08/28

+smi130_gyro_driver.c |   1.5.9 |   2018/08/28

+smi130_gyro.c        |   1.5   |   2018/08/28

+smi130_gyro.h        |   1.5   |   2018/08/28

+smi130_driver.h      |   1.3   |   2018/08/28

+smi130_driver.c      |   1.3   |   2018/08/28

+smi130_acc.c         |   2.1.2 |   2018/08/28

+bs_log.h             |         |   2018/08/28

+bs_log.c             |         |   2018/08/28

+boschcalss.h         |  1.5.9  |   2018/08/28

+boschclass.c         |  1.5.9  |   2018/08/28

+

+

+

+## File information

+* smi130.h : The head file of SMI130API

+* smi130.c : Sensor Driver for SMI130 sensor

+* smi130_spi.c : This file implements moudle function, which add the driver to SPI core.

+* smi130_i2c.c : This file implements moudle function, which add the driver to I2C core.

+* smi130_driver.h : The head file of SMI130 device driver core code

+* smi130_driver.c : This file implements the core code of SMI130 device driver

+* bs_log.h : The head file of BOSCH SENSOR LOG

+* bs_log.c : The source file of BOSCH SENSOR LOG

+* boschcalss.h :

+* boschclass.c :

+

+

+## Supported sensor interface

+* SPI 4-wire

+* I2C

+

+## Copyright

+

+Copyright (C) 2016 - 2017 Bosch Sensortec GmbH

+Modification Copyright (C) 2018 Robert Bosch Kft  All Rights Reserved

+

+This software program is licensed subject to the GNU General

+Public License (GPL).Version 2,June 1991,

+available at http://www.fsf.org/copyleft/gpl.html
\ No newline at end of file
diff --git a/drivers/input/sensors/smi130/smi130.c b/drivers/input/sensors/smi130/smi130.c
new file mode 100644
index 0000000..1ddd3b5
--- /dev/null
+++ b/drivers/input/sensors/smi130/smi130.c
@@ -0,0 +1,18785 @@
+/*!
+ * @section LICENSE
+ * (C) Copyright 2011~2016 Bosch Sensortec GmbH All Rights Reserved
+ *
+ * (C) Modification Copyright 2018 Robert Bosch Kft  All Rights Reserved
+ *
+ * This software program is licensed subject to the GNU General
+ * Public License (GPL).Version 2,June 1991,
+ * available at http://www.fsf.org/copyleft/gpl.html
+ *
+ * Special: Description of the Software:
+ *
+ * This software module (hereinafter called "Software") and any
+ * information on application-sheets (hereinafter called "Information") is
+ * provided free of charge for the sole purpose to support your application
+ * work. 
+ *
+ * As such, the Software is merely an experimental software, not tested for
+ * safety in the field and only intended for inspiration for further development 
+ * and testing. Any usage in a safety-relevant field of use (like automotive,
+ * seafaring, spacefaring, industrial plants etc.) was not intended, so there are
+ * no precautions for such usage incorporated in the Software.
+ * 
+ * The Software is specifically designed for the exclusive use for Bosch
+ * Sensortec products by personnel who have special experience and training. Do
+ * not use this Software if you do not have the proper experience or training.
+ * 
+ * This Software package is provided as is and without any expressed or
+ * implied warranties, including without limitation, the implied warranties of
+ * merchantability and fitness for a particular purpose.
+ * 
+ * Bosch Sensortec and their representatives and agents deny any liability for
+ * the functional impairment of this Software in terms of fitness, performance
+ * and safety. Bosch Sensortec and their representatives and agents shall not be
+ * liable for any direct or indirect damages or injury, except as otherwise
+ * stipulated in mandatory applicable law.
+ * The Information provided is believed to be accurate and reliable. Bosch
+ * Sensortec assumes no responsibility for the consequences of use of such
+ * Information nor for any infringement of patents or other rights of third
+ * parties which may result from its use.
+ * 
+ *------------------------------------------------------------------------------
+ * The following Product Disclaimer does not apply to the BSX4-HAL-4.1NoFusion Software 
+ * which is licensed under the Apache License, Version 2.0 as stated above.  
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Product Disclaimer
+ *
+ * Common:
+ *
+ * Assessment of Products Returned from Field
+ *
+ * Returned products are considered good if they fulfill the specifications / 
+ * test data for 0-mileage and field listed in this document.
+ *
+ * Engineering Samples
+ * 
+ * Engineering samples are marked with (e) or (E). Samples may vary from the
+ * valid technical specifications of the series product contained in this
+ * data sheet. Therefore, they are not intended or fit for resale to
+ * third parties or for use in end products. Their sole purpose is internal
+ * client testing. The testing of an engineering sample may in no way replace
+ * the testing of a series product. Bosch assumes no liability for the use
+ * of engineering samples. The purchaser shall indemnify Bosch from all claims
+ * arising from the use of engineering samples.
+ *
+ * Intended use
+ *
+ * Provided that SMI130 is used within the conditions (environment, application,
+ * installation, loads) as described in this TCD and the corresponding
+ * agreed upon documents, Bosch ensures that the product complies with
+ * the agreed properties. Agreements beyond this require
+ * the written approval by Bosch. The product is considered fit for the intended
+ * use when the product successfully has passed the tests
+ * in accordance with the TCD and agreed upon documents.
+ *
+ * It is the responsibility of the customer to ensure the proper application
+ * of the product in the overall system/vehicle.
+ *
+ * Bosch does not assume any responsibility for changes to the environment
+ * of the product that deviate from the TCD and the agreed upon documents 
+ * as well as all applications not released by Bosch
+  *
+ * The resale and/or use of products are at the purchaser’s own risk and 
+ * responsibility. The examination and testing of the SMI130 
+ * is the sole responsibility of the purchaser.
+ *
+ * The purchaser shall indemnify Bosch from all third party claims 
+ * arising from any product use not covered by the parameters of 
+ * this product data sheet or not approved by Bosch and reimburse Bosch 
+ * for all costs and damages in connection with such claims.
+ *
+ * The purchaser must monitor the market for the purchased products,
+ * particularly with regard to product safety, and inform Bosch without delay
+ * of all security relevant incidents.
+ *
+ * Application Examples and Hints
+ *
+ * With respect to any application examples, advice, normal values
+ * and/or any information regarding the application of the device,
+ * Bosch hereby disclaims any and all warranties and liabilities of any kind,
+ * including without limitation warranties of
+ * non-infringement of intellectual property rights or copyrights
+ * of any third party.
+ * The information given in this document shall in no event be regarded 
+ * as a guarantee of conditions or characteristics. They are provided
+ * for illustrative purposes only and no evaluation regarding infringement
+ * of intellectual property rights or copyrights or regarding functionality,
+ * performance or error has been made.
+*
+* @filename smi130.c
+* @Date: 2015/04/02
+* @Modification Date 2018/08/28 18:20
+* @id       836294d
+* @Revision: 2.0.9 $
+*
+* Usage: Sensor Driver for SMI130 sensor
+*/
+
+
+#include "smi130.h"
+#include <linux/kernel.h>
+
+/* user defined code to be added here ... */
+struct smi130_t *p_smi130;
+/* used for reading the mag trim values for compensation*/
+struct trim_data_t mag_trim_mbl;
+/* the following variable used for avoiding the selecting of auto mode
+when it is running in the manual mode of BMM150 mag interface*/
+u8 V_bmm150_maual_auto_condition_u8_mbl = SMI130_INIT_VALUE;
+/* used for reading the AKM compensating data */
+struct bosch_akm_sensitivity_data_t akm_asa_data_mbl;
+/* Assign the fifo time */
+u32 V_fifo_time_U32_mbl = SMI130_INIT_VALUE;
+
+/* FIFO data read for 1024 bytes of data */
+u8 v_fifo_data_u8_mbl[FIFO_FRAME] = {SMI130_INIT_VALUE};
+/* YAMAHA-YAS532*/
+/* value of coeff*/
+static const int yas532_version_ac_coef[] = {YAS532_VERSION_AC_COEF_X,
+YAS532_VERSION_AC_COEF_Y1, YAS532_VERSION_AC_COEF_Y2};
+/* used for reading the yas532 calibration data*/
+struct yas532_t yas532_data_mbl;
+/* used for reading the yas537 calibration data*/
+struct yas537_t yas537_data_mbl;
+/*!
+ *	@brief
+ *	This function is used for initialize
+ *	bus read and bus write functions
+ *	assign the chip id and device address
+ *	chip id is read in the register 0x00 bit from 0 to 7
+ *
+ *	@param smi130 : structure pointer
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *	@note
+ *	While changing the parameter of the smi130_t
+ *	consider the following point:
+ *	Changing the reference value of the parameter
+ *	will changes the local copy or local reference
+ *	make sure your changes will not
+ *	affect the reference value of the parameter
+ *	(Better case don't change the reference value of the parameter)
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_init(struct smi130_t *smi130)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	u8 v_pmu_data_u8 = SMI130_INIT_VALUE;
+	/* assign smi130 ptr */
+	p_smi130 = smi130;
+	com_rslt =
+	p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+	SMI130_USER_CHIP_ID__REG,
+	&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	/* read Chip Id */
+	p_smi130->chip_id = v_data_u8;
+	/* To avoid gyro wakeup it is required to write 0x00 to 0x6C*/
+	com_rslt += smi130_write_reg(SMI130_USER_PMU_TRIGGER_ADDR,
+	&v_pmu_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	return com_rslt;
+}
+/*!
+ * @brief
+ *	This API write the data to
+ *	the given register
+ *
+ *
+ *	@param v_addr_u8 -> Address of the register
+ *	@param v_data_u8 -> The data from the register
+ *	@param v_len_u8 -> no of bytes to read
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_write_reg(u8 v_addr_u8,
+u8 *v_data_u8, u8 v_len_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* write data from register*/
+			com_rslt =
+			p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->dev_addr,
+			v_addr_u8, v_data_u8, v_len_u8);
+		}
+	return com_rslt;
+}
+/*!
+ * @brief
+ *	This API reads the data from
+ *	the given register
+ *
+ *
+ *	@param v_addr_u8 -> Address of the register
+ *	@param v_data_u8 -> The data from the register
+ *	@param v_len_u8 -> no of bytes to read
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_read_reg(u8 v_addr_u8,
+u8 *v_data_u8, u8 v_len_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* Read data from register*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			v_addr_u8, v_data_u8, v_len_u8);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API used to reads the fatal error
+ *	from the Register 0x02 bit 0
+ *	This flag will be reset only by power-on-reset and soft reset
+ *
+ *
+ *  @param v_fatal_err_u8 : The status of fatal error
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_fatal_err(u8
+*v_fatal_err_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* reading the fatal error status*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_FATAL_ERR__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_fatal_err_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_FATAL_ERR);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API used to read the error code
+ *	from register 0x02 bit 1 to 4
+ *
+ *
+ *  @param v_err_code_u8 : The status of error codes
+ *	error_code  |    description
+ *  ------------|---------------
+ *	0x00        |no error
+ *	0x01        |ACC_CONF error (accel ODR and bandwidth not compatible)
+ *	0x02        |GYR_CONF error (Gyroscope ODR and bandwidth not compatible)
+ *	0x03        |Under sampling mode and interrupt uses pre filtered data
+ *	0x04        |reserved
+ *	0x05        |Selected trigger-readout offset in
+ *    -         |MAG_IF greater than selected ODR
+ *	0x06        |FIFO configuration error for header less mode
+ *	0x07        |Under sampling mode and pre filtered data as FIFO source
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_err_code(u8
+*v_err_code_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_ERR_CODE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_err_code_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_ERR_CODE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API Reads the i2c error code from the
+ *	Register 0x02 bit 5.
+ *	This error occurred in I2C master detected
+ *
+ *  @param v_i2c_err_code_u8 : The status of i2c fail error
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_i2c_fail_err(u8
+*v_i2c_err_code_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_I2C_FAIL_ERR__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_i2c_err_code_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_I2C_FAIL_ERR);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API Reads the dropped command error
+ *	from the register 0x02 bit 6
+ *
+ *
+ *  @param v_drop_cmd_err_u8 : The status of drop command error
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_drop_cmd_err(u8
+*v_drop_cmd_err_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_DROP_CMD_ERR__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_drop_cmd_err_u8 = SMI130_GET_BITSLICE(
+			v_data_u8,
+			SMI130_USER_DROP_CMD_ERR);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the magnetometer data ready
+ *	interrupt not active.
+ *	It reads from the error register 0x0x2 bit 7
+ *
+ *
+ *
+ *
+ *  @param v_mag_data_rdy_err_u8 : The status of mag data ready interrupt
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_mag_dada_rdy_err(
+u8 *v_mag_data_rdy_err_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_MAG_DADA_RDY_ERR__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_mag_data_rdy_err_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_MAG_DADA_RDY_ERR);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the error status
+ *	from the error register 0x02 bit 0 to 7
+ *
+ *  @param v_mag_data_rdy_err_u8 : The status of mag data ready interrupt
+ *  @param v_fatal_er_u8r : The status of fatal error
+ *  @param v_err_code_u8 : The status of error code
+ *  @param v_i2c_fail_err_u8 : The status of I2C fail error
+ *  @param v_drop_cmd_err_u8 : The status of drop command error
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_error_status(u8 *v_fatal_er_u8r,
+u8 *v_err_code_u8, u8 *v_i2c_fail_err_u8,
+u8 *v_drop_cmd_err_u8, u8 *v_mag_data_rdy_err_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the error codes*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_ERR_STAT__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			/* fatal error*/
+			*v_fatal_er_u8r =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_FATAL_ERR);
+			/* user error*/
+			*v_err_code_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_ERR_CODE);
+			/* i2c fail error*/
+			*v_i2c_fail_err_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_I2C_FAIL_ERR);
+			/* drop command error*/
+			*v_drop_cmd_err_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_DROP_CMD_ERR);
+			/* mag data ready error*/
+			*v_mag_data_rdy_err_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_MAG_DADA_RDY_ERR);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the magnetometer power mode from
+ *	PMU status register 0x03 bit 0 and 1
+ *
+ *  @param v_mag_power_mode_stat_u8 : The value of mag power mode
+ *	mag_powermode    |   value
+ * ------------------|----------
+ *    SUSPEND        |   0x00
+ *    NORMAL         |   0x01
+ *   LOW POWER       |   0x02
+ *
+ *
+ * @note The power mode of mag set by the 0x7E command register
+ * @note using the function "smi130_set_command_register()"
+ *  value    |   mode
+ *  ---------|----------------
+ *   0x18    | MAG_MODE_SUSPEND
+ *   0x19    | MAG_MODE_NORMAL
+ *   0x1A    | MAG_MODE_LOWPOWER
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_mag_power_mode_stat(u8
+*v_mag_power_mode_stat_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_MAG_POWER_MODE_STAT__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_mag_power_mode_stat_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_MAG_POWER_MODE_STAT);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the gyroscope power mode from
+ *	PMU status register 0x03 bit 2 and 3
+ *
+ *  @param v_gyro_power_mode_stat_u8 :	The value of gyro power mode
+ *	gyro_powermode   |   value
+ * ------------------|----------
+ *    SUSPEND        |   0x00
+ *    NORMAL         |   0x01
+ *   FAST POWER UP   |   0x03
+ *
+ * @note The power mode of gyro set by the 0x7E command register
+ * @note using the function "smi130_set_command_register()"
+ *  value    |   mode
+ *  ---------|----------------
+ *   0x14    | GYRO_MODE_SUSPEND
+ *   0x15    | GYRO_MODE_NORMAL
+ *   0x17    | GYRO_MODE_FASTSTARTUP
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_gyro_power_mode_stat(u8
+*v_gyro_power_mode_stat_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_GYRO_POWER_MODE_STAT__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_gyro_power_mode_stat_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_GYRO_POWER_MODE_STAT);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the accelerometer power mode from
+ *	PMU status register 0x03 bit 4 and 5
+ *
+ *
+ *  @param v_accel_power_mode_stat_u8 :	The value of accel power mode
+ *	accel_powermode  |   value
+ * ------------------|----------
+ *    SUSPEND        |   0x00
+ *    NORMAL         |   0x01
+ *  LOW POWER        |   0x02
+ *
+ * @note The power mode of accel set by the 0x7E command register
+ * @note using the function "smi130_set_command_register()"
+ *  value    |   mode
+ *  ---------|----------------
+ *   0x11    | ACCEL_MODE_NORMAL
+ *   0x12    | ACCEL_LOWPOWER
+ *   0x10    | ACCEL_SUSPEND
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_accel_power_mode_stat(u8
+*v_accel_power_mode_stat_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_ACCEL_POWER_MODE_STAT__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_accel_power_mode_stat_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_ACCEL_POWER_MODE_STAT);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API switch mag interface to normal mode
+ *	and confirm whether the mode switching done successfully or not
+*
+ *	@return results of bus communication function and current MAG_PMU result
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_mag_interface_normal(void)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = SMI130_INIT_VALUE;
+	/* aim to check the result of switching mag normal */
+	u8 v_try_times_u8 = SMI130_MAG_NOAMRL_SWITCH_TIMES;
+	u8 v_mag_pum_status_u8 = SMI130_INIT_VALUE;
+
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	com_rslt = smi130_set_command_register(MAG_MODE_NORMAL);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	while (v_try_times_u8) {
+		com_rslt = smi130_get_mag_power_mode_stat(&v_mag_pum_status_u8);
+		if (v_mag_pum_status_u8 == MAG_INTERFACE_PMU_ENABLE)
+			break;
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		v_try_times_u8--;
+	}
+	if (v_mag_pum_status_u8 == MAG_INTERFACE_PMU_ENABLE)
+		com_rslt += SUCCESS;
+	else
+		com_rslt += E_SMI130_COMM_RES;
+
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads magnetometer data X values
+ *	from the register 0x04 and 0x05
+ *	@brief The mag sensor data read form auxiliary mag
+ *
+ *  @param v_mag_x_s16 : The value of mag x
+ *  @param v_sensor_select_u8 : Mag selection value
+ *  value    |   sensor
+ *  ---------|----------------
+ *   0       | BMM150
+ *   1       | AKM09911 or AKM09912
+ *
+ *	@note For mag data output rate configuration use the following function
+ *	@note smi130_set_mag_output_data_rate()
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_read_mag_x(s16 *v_mag_x_s16,
+u8 v_sensor_select_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* Array contains the mag X lSB and MSB data
+		v_data_u8[0] - LSB
+		v_data_u8[1] - MSB*/
+	u8 v_data_u8[SMI130_MAG_X_DATA_SIZE] = {SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE};
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		switch (v_sensor_select_u8) {
+		case BST_BMM:
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_DATA_MAG_X_LSB__REG,
+			v_data_u8, SMI130_MAG_X_DATA_LENGTH);
+			/* X axis*/
+			v_data_u8[SMI130_MAG_X_LSB_BYTE] =
+			SMI130_GET_BITSLICE(v_data_u8[SMI130_MAG_X_LSB_BYTE],
+			SMI130_USER_DATA_MAG_X_LSB);
+			*v_mag_x_s16 = (s16)
+			((((s32)((s8)v_data_u8[SMI130_MAG_X_MSB_BYTE]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_05_BITS) |
+			(v_data_u8[SMI130_MAG_X_LSB_BYTE]));
+		break;
+		case BST_AKM:
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_DATA_0_MAG_X_LSB__REG,
+			v_data_u8, SMI130_MAG_X_DATA_LENGTH);
+			*v_mag_x_s16 = (s16)
+			((((s32)((s8)v_data_u8[SMI130_MAG_X_MSB_BYTE]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_08_BITS) |
+			(v_data_u8[SMI130_MAG_X_LSB_BYTE]));
+		break;
+		default:
+			com_rslt = E_SMI130_OUT_OF_RANGE;
+		break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads magnetometer data Y values
+ *	from the register 0x06 and 0x07
+ *	@brief The mag sensor data read form auxiliary mag
+ *
+ *  @param v_mag_y_s16 : The value of mag y
+ *  @param v_sensor_select_u8 : Mag selection value
+ *  value    |   sensor
+ *  ---------|----------------
+ *   0       | BMM150
+ *   1       | AKM09911 or AKM09912
+ *
+ *	@note For mag data output rate configuration use the following function
+ *	@note smi130_set_mag_output_data_rate()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_read_mag_y(s16 *v_mag_y_s16,
+u8 v_sensor_select_u8)
+{
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_OUT_OF_RANGE;
+	/* Array contains the mag Y lSB and MSB data
+		v_data_u8[0] - LSB
+		v_data_u8[1] - MSB*/
+	u8 v_data_u8[SMI130_MAG_Y_DATA_SIZE] = {SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE};
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		switch (v_sensor_select_u8) {
+		case BST_BMM:
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_DATA_MAG_Y_LSB__REG,
+			v_data_u8, SMI130_MAG_Y_DATA_LENGTH);
+			/*Y-axis lsb value shifting*/
+			v_data_u8[SMI130_MAG_Y_LSB_BYTE] =
+			SMI130_GET_BITSLICE(v_data_u8[SMI130_MAG_Y_LSB_BYTE],
+			SMI130_USER_DATA_MAG_Y_LSB);
+			*v_mag_y_s16 = (s16)
+			((((s32)((s8)v_data_u8[SMI130_MAG_Y_MSB_BYTE]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_05_BITS) |
+			(v_data_u8[SMI130_MAG_Y_LSB_BYTE]));
+		break;
+		case BST_AKM:
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_DATA_2_MAG_Y_LSB__REG,
+			v_data_u8, SMI130_MAG_Y_DATA_LENGTH);
+			*v_mag_y_s16 = (s16)
+			((((s32)((s8)v_data_u8[SMI130_MAG_Y_MSB_BYTE]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_08_BITS) |
+			(v_data_u8[SMI130_MAG_Y_LSB_BYTE]));
+		break;
+		default:
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads magnetometer data Z values
+ *	from the register 0x08 and 0x09
+ *	@brief The mag sensor data read form auxiliary mag
+ *
+ *  @param v_mag_z_s16 : The value of mag z
+ *  @param v_sensor_select_u8 : Mag selection value
+ *  value    |   sensor
+ *  ---------|----------------
+ *   0       | BMM150
+ *   1       | AKM09911 or AKM09912
+ *
+ *	@note For mag data output rate configuration use the following function
+ *	@note smi130_set_mag_output_data_rate()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_read_mag_z(s16 *v_mag_z_s16,
+u8 v_sensor_select_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* Array contains the mag Z lSB and MSB data
+		v_data_u8[0] - LSB
+		v_data_u8[1] - MSB*/
+	u8 v_data_u8[SMI130_MAG_Z_DATA_SIZE] = {SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE};
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		switch (v_sensor_select_u8) {
+		case BST_BMM:
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_DATA_MAG_Z_LSB__REG,
+			v_data_u8, SMI130_MAG_Z_DATA_LENGTH);
+			/*Z-axis lsb value shifting*/
+			v_data_u8[SMI130_MAG_Z_LSB_BYTE] =
+			SMI130_GET_BITSLICE(v_data_u8[SMI130_MAG_Z_LSB_BYTE],
+			SMI130_USER_DATA_MAG_Z_LSB);
+			*v_mag_z_s16 = (s16)
+			((((s32)((s8)v_data_u8[SMI130_MAG_Z_MSB_BYTE]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_07_BITS) |
+			(v_data_u8[SMI130_MAG_Z_LSB_BYTE]));
+		break;
+		case BST_AKM:
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_DATA_4_MAG_Z_LSB__REG,
+			v_data_u8, SMI130_MAG_Z_DATA_LENGTH);
+			*v_mag_z_s16 = (s16)
+			((((s32)((s8)v_data_u8[SMI130_MAG_Z_MSB_BYTE]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_08_BITS) | (
+			v_data_u8[SMI130_MAG_Z_LSB_BYTE]));
+		break;
+		default:
+			com_rslt = E_SMI130_OUT_OF_RANGE;
+		break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads magnetometer data RHALL values
+ *	from the register 0x0A and 0x0B
+ *
+ *
+ *  @param v_mag_r_s16 : The value of BMM150 r data
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_read_mag_r(s16 *v_mag_r_s16)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* Array contains the mag R lSB and MSB data
+		v_data_u8[0] - LSB
+		v_data_u8[1] - MSB*/
+	u8 v_data_u8[SMI130_MAG_R_DATA_SIZE] = {SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE};
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_DATA_6_RHALL_LSB__REG,
+			v_data_u8, SMI130_MAG_R_DATA_LENGTH);
+			/*R-axis lsb value shifting*/
+			v_data_u8[SMI130_MAG_R_LSB_BYTE] =
+			SMI130_GET_BITSLICE(v_data_u8[SMI130_MAG_R_LSB_BYTE],
+			SMI130_USER_DATA_MAG_R_LSB);
+			*v_mag_r_s16 = (s16)
+			((((s32)((s8)v_data_u8[SMI130_MAG_R_MSB_BYTE]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_06_BITS) |
+			(v_data_u8[SMI130_MAG_R_LSB_BYTE]));
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads magnetometer data X,Y,Z values
+ *	from the register 0x04 to 0x09
+ *
+ *	@brief The mag sensor data read form auxiliary mag
+ *
+ *  @param mag : The value of mag xyz data
+ *  @param v_sensor_select_u8 : Mag selection value
+ *  value    |   sensor
+ *  ---------|----------------
+ *   0       | BMM150
+ *   1       | AKM09911 or AKM09912
+ *
+ *	@note For mag data output rate configuration use the following function
+ *	@note smi130_set_mag_output_data_rate()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_read_mag_xyz(
+struct smi130_mag_t *mag, u8 v_sensor_select_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* Array contains the mag XYZ lSB and MSB data
+		v_data_u8[0] - X-LSB
+		v_data_u8[1] - X-MSB
+		v_data_u8[0] - Y-LSB
+		v_data_u8[1] - Y-MSB
+		v_data_u8[0] - Z-LSB
+		v_data_u8[1] - Z-MSB
+		*/
+	u8 v_data_u8[SMI130_MAG_XYZ_DATA_SIZE] = {
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE};
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		switch (v_sensor_select_u8) {
+		case BST_BMM:
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_DATA_MAG_X_LSB__REG,
+			v_data_u8, SMI130_MAG_XYZ_DATA_LENGTH);
+			/*X-axis lsb value shifting*/
+			v_data_u8[SMI130_DATA_FRAME_MAG_X_LSB_BYTE] =
+			SMI130_GET_BITSLICE(
+			v_data_u8[SMI130_DATA_FRAME_MAG_X_LSB_BYTE],
+			SMI130_USER_DATA_MAG_X_LSB);
+			/* Data X */
+			mag->x = (s16)
+			((((s32)((s8)v_data_u8[
+			SMI130_DATA_FRAME_MAG_X_MSB_BYTE]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_05_BITS) |
+			(v_data_u8[SMI130_DATA_FRAME_MAG_X_LSB_BYTE]));
+			/* Data Y */
+			/*Y-axis lsb value shifting*/
+			v_data_u8[SMI130_DATA_FRAME_MAG_Y_LSB_BYTE] =
+			SMI130_GET_BITSLICE(
+			v_data_u8[SMI130_DATA_FRAME_MAG_Y_LSB_BYTE],
+			SMI130_USER_DATA_MAG_Y_LSB);
+			mag->y = (s16)
+			((((s32)((s8)v_data_u8[
+			SMI130_DATA_FRAME_MAG_Y_MSB_BYTE]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_05_BITS) |
+			(v_data_u8[SMI130_DATA_FRAME_MAG_Y_LSB_BYTE]));
+
+			/* Data Z */
+			/*Z-axis lsb value shifting*/
+			v_data_u8[SMI130_DATA_FRAME_MAG_Z_LSB_BYTE]
+			= SMI130_GET_BITSLICE(
+			v_data_u8[SMI130_DATA_FRAME_MAG_Z_LSB_BYTE],
+			SMI130_USER_DATA_MAG_Z_LSB);
+			mag->z = (s16)
+			((((s32)((s8)v_data_u8[
+			SMI130_DATA_FRAME_MAG_Z_MSB_BYTE]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_07_BITS) |
+			(v_data_u8[SMI130_DATA_FRAME_MAG_Z_LSB_BYTE]));
+		break;
+		case BST_AKM:
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_DATA_0_MAG_X_LSB__REG,
+			v_data_u8, SMI130_MAG_XYZ_DATA_LENGTH);
+			/* Data X */
+			mag->x = (s16)
+			((((s32)((s8)v_data_u8[
+			SMI130_DATA_FRAME_MAG_X_MSB_BYTE]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_08_BITS) |
+			(v_data_u8[SMI130_DATA_FRAME_MAG_X_LSB_BYTE]));
+			/* Data Y */
+			mag->y  = ((((s32)((s8)v_data_u8[
+			SMI130_DATA_FRAME_MAG_Y_MSB_BYTE]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_08_BITS) |
+			(v_data_u8[SMI130_DATA_FRAME_MAG_Y_LSB_BYTE]));
+			/* Data Z */
+			mag->z = (s16)
+			((((s32)((s8)v_data_u8[
+			SMI130_DATA_FRAME_MAG_Z_MSB_BYTE]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_08_BITS) |
+			(v_data_u8[SMI130_DATA_FRAME_MAG_Z_LSB_BYTE]));
+		break;
+		default:
+			com_rslt = E_SMI130_OUT_OF_RANGE;
+		break;
+		}
+	}
+	return com_rslt;
+}
+ /*!*
+ *	@brief This API reads magnetometer data X,Y,Z,r
+ *	values from the register 0x04 to 0x0B
+ *
+ *	@brief The mag sensor data read form auxiliary mag
+ *
+ *  @param mag : The value of mag-BMM150 xyzr data
+ *
+ *	@note For mag data output rate configuration use the following function
+ *	@note smi130_set_mag_output_data_rate()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_read_mag_xyzr(
+struct smi130_mag_xyzr_t *mag)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8[SMI130_MAG_XYZR_DATA_SIZE] = {
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE, SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE, SMI130_INIT_VALUE};
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_DATA_MAG_X_LSB__REG,
+			v_data_u8, SMI130_MAG_XYZR_DATA_LENGTH);
+
+			/* Data X */
+			/*X-axis lsb value shifting*/
+			v_data_u8[SMI130_DATA_FRAME_MAG_X_LSB_BYTE]
+			= SMI130_GET_BITSLICE(
+			v_data_u8[SMI130_DATA_FRAME_MAG_X_LSB_BYTE],
+			SMI130_USER_DATA_MAG_X_LSB);
+			mag->x = (s16)
+			((((s32)((s8)v_data_u8[
+			SMI130_DATA_FRAME_MAG_X_MSB_BYTE]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_05_BITS)
+			| (v_data_u8[SMI130_DATA_FRAME_MAG_X_LSB_BYTE]));
+			/* Data Y */
+			/*Y-axis lsb value shifting*/
+			v_data_u8[SMI130_DATA_FRAME_MAG_Y_LSB_BYTE]
+			= SMI130_GET_BITSLICE(
+			v_data_u8[SMI130_DATA_FRAME_MAG_Y_LSB_BYTE],
+			SMI130_USER_DATA_MAG_Y_LSB);
+			mag->y = (s16)
+			((((s32)((s8)v_data_u8[
+			SMI130_DATA_FRAME_MAG_Y_MSB_BYTE]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_05_BITS)
+			| (v_data_u8[
+			SMI130_DATA_FRAME_MAG_Y_LSB_BYTE]));
+
+			/* Data Z */
+			/*Z-axis lsb value shifting*/
+			v_data_u8[SMI130_DATA_FRAME_MAG_Z_LSB_BYTE]
+			= SMI130_GET_BITSLICE(
+			v_data_u8[SMI130_DATA_FRAME_MAG_Z_LSB_BYTE],
+			SMI130_USER_DATA_MAG_Z_LSB);
+			mag->z = (s16)
+			((((s32)((s8)v_data_u8[
+			SMI130_DATA_FRAME_MAG_Z_MSB_BYTE]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_07_BITS)
+			| (v_data_u8[SMI130_DATA_FRAME_MAG_Z_LSB_BYTE]));
+
+			/* RHall */
+			/*R-axis lsb value shifting*/
+			v_data_u8[SMI130_DATA_FRAME_MAG_R_LSB_BYTE]
+			= SMI130_GET_BITSLICE(
+			v_data_u8[SMI130_DATA_FRAME_MAG_R_LSB_BYTE],
+			SMI130_USER_DATA_MAG_R_LSB);
+			mag->r = (s16)
+			((((s32)((s8)v_data_u8[
+			SMI130_DATA_FRAME_MAG_R_MSB_BYTE]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_06_BITS)
+			| (v_data_u8[SMI130_DATA_FRAME_MAG_R_LSB_BYTE]));
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads gyro data X values
+ *	form the register 0x0C and 0x0D
+ *
+ *
+ *
+ *
+ *  @param v_gyro_x_s16 : The value of gyro x data
+ *
+ *	@note Gyro Configuration use the following function
+ *	@note smi130_set_gyro_output_data_rate()
+ *	@note smi130_set_gyro_bw()
+ *	@note smi130_set_gyro_range()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_read_gyro_x(s16 *v_gyro_x_s16)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* Array contains the gyro X lSB and MSB data
+		v_data_u8[0] - LSB
+		v_data_u8[MSB_ONE] - MSB*/
+	u8 v_data_u8[SMI130_GYRO_X_DATA_SIZE] = {SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE};
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_DATA_8_GYRO_X_LSB__REG,
+			v_data_u8, SMI130_GYRO_DATA_LENGTH);
+
+			*v_gyro_x_s16 = (s16)
+			((((s32)((s8)v_data_u8[SMI130_GYRO_X_MSB_BYTE]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_08_BITS)
+			| (v_data_u8[SMI130_GYRO_X_LSB_BYTE]));
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads gyro data Y values
+ *	form the register 0x0E and 0x0F
+ *
+ *
+ *
+ *
+ *  @param v_gyro_y_s16 : The value of gyro y data
+ *
+ *	@note Gyro Configuration use the following function
+ *	@note smi130_set_gyro_output_data_rate()
+ *	@note smi130_set_gyro_bw()
+ *	@note smi130_set_gyro_range()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error result of communication routines
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_read_gyro_y(s16 *v_gyro_y_s16)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* Array contains the gyro Y lSB and MSB data
+		v_data_u8[LSB_ZERO] - LSB
+		v_data_u8[MSB_ONE] - MSB*/
+	u8 v_data_u8[SMI130_GYRO_Y_DATA_SIZE] = {SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE};
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read gyro y data*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_DATA_10_GYRO_Y_LSB__REG,
+			v_data_u8, SMI130_GYRO_DATA_LENGTH);
+
+			*v_gyro_y_s16 = (s16)
+			((((s32)((s8)v_data_u8[SMI130_GYRO_Y_MSB_BYTE]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_08_BITS)
+			| (v_data_u8[SMI130_GYRO_Y_LSB_BYTE]));
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads gyro data Z values
+ *	form the register 0x10 and 0x11
+ *
+ *
+ *
+ *
+ *  @param v_gyro_z_s16 : The value of gyro z data
+ *
+ *	@note Gyro Configuration use the following function
+ *	@note smi130_set_gyro_output_data_rate()
+ *	@note smi130_set_gyro_bw()
+ *	@note smi130_set_gyro_range()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_read_gyro_z(s16 *v_gyro_z_s16)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* Array contains the gyro Z lSB and MSB data
+		v_data_u8[LSB_ZERO] - LSB
+		v_data_u8[MSB_ONE] - MSB*/
+	u8 v_data_u8[SMI130_GYRO_Z_DATA_SIZE] = {SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE};
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read gyro z data */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_DATA_12_GYRO_Z_LSB__REG,
+			v_data_u8, SMI130_GYRO_DATA_LENGTH);
+
+			*v_gyro_z_s16 = (s16)
+			((((s32)((s8)v_data_u8[SMI130_GYRO_Z_MSB_BYTE]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_08_BITS)
+			| (v_data_u8[SMI130_GYRO_Z_LSB_BYTE]));
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads gyro data X,Y,Z values
+ *	from the register 0x0C to 0x11
+ *
+ *
+ *
+ *
+ *  @param gyro : The value of gyro xyz
+ *
+ *	@note Gyro Configuration use the following function
+ *	@note smi130_set_gyro_output_data_rate()
+ *	@note smi130_set_gyro_bw()
+ *	@note smi130_set_gyro_range()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_read_gyro_xyz(struct smi130_gyro_t *gyro)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* Array contains the mag XYZ lSB and MSB data
+		v_data_u8[0] - X-LSB
+		v_data_u8[1] - X-MSB
+		v_data_u8[0] - Y-LSB
+		v_data_u8[1] - Y-MSB
+		v_data_u8[0] - Z-LSB
+		v_data_u8[1] - Z-MSB
+		*/
+	u8 v_data_u8[SMI130_GYRO_XYZ_DATA_SIZE] = {
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE};
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the gyro xyz data*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_DATA_8_GYRO_X_LSB__REG,
+			v_data_u8, SMI130_GYRO_XYZ_DATA_LENGTH);
+
+			/* Data X */
+			gyro->x = (s16)
+			((((s32)((s8)v_data_u8[
+			SMI130_DATA_FRAME_GYRO_X_MSB_BYTE]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_08_BITS)
+			| (v_data_u8[SMI130_DATA_FRAME_GYRO_X_LSB_BYTE]));
+			/* Data Y */
+			gyro->y = (s16)
+			((((s32)((s8)v_data_u8[
+			SMI130_DATA_FRAME_GYRO_Y_MSB_BYTE]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_08_BITS)
+			| (v_data_u8[SMI130_DATA_FRAME_GYRO_Y_LSB_BYTE]));
+
+			/* Data Z */
+			gyro->z = (s16)
+			((((s32)((s8)v_data_u8[
+			SMI130_DATA_FRAME_GYRO_Z_MSB_BYTE]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_08_BITS)
+			| (v_data_u8[SMI130_DATA_FRAME_GYRO_Z_LSB_BYTE]));
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads accelerometer data X values
+ *	form the register 0x12 and 0x13
+ *
+ *
+ *
+ *
+ *  @param v_accel_x_s16 : The value of accel x
+ *
+ *	@note For accel configuration use the following functions
+ *	@note smi130_set_accel_output_data_rate()
+ *	@note smi130_set_accel_bw()
+ *	@note smi130_set_accel_under_sampling_parameter()
+ *	@note smi130_set_accel_range()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_read_accel_x(s16 *v_accel_x_s16)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* Array contains the accel X lSB and MSB data
+		v_data_u8[0] - LSB
+		v_data_u8[1] - MSB*/
+	u8 v_data_u8[SMI130_ACCEL_X_DATA_SIZE] = {SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE};
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_DATA_14_ACCEL_X_LSB__REG,
+			v_data_u8, SMI130_ACCEL_DATA_LENGTH);
+
+			*v_accel_x_s16 = (s16)
+			((((s32)((s8)v_data_u8[SMI130_ACCEL_X_MSB_BYTE]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_08_BITS)
+			| (v_data_u8[SMI130_ACCEL_X_LSB_BYTE]));
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads accelerometer data Y values
+ *	form the register 0x14 and 0x15
+ *
+ *
+ *
+ *
+ *  @param v_accel_y_s16 : The value of accel y
+ *
+ *	@note For accel configuration use the following functions
+ *	@note smi130_set_accel_output_data_rate()
+ *	@note smi130_set_accel_bw()
+ *	@note smi130_set_accel_under_sampling_parameter()
+ *	@note smi130_set_accel_range()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_read_accel_y(s16 *v_accel_y_s16)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* Array contains the accel Y lSB and MSB data
+		v_data_u8[0] - LSB
+		v_data_u8[1] - MSB*/
+	u8 v_data_u8[SMI130_ACCEL_Y_DATA_SIZE] = {SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE};
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_DATA_16_ACCEL_Y_LSB__REG,
+			v_data_u8, SMI130_ACCEL_DATA_LENGTH);
+
+			*v_accel_y_s16 = (s16)
+			((((s32)((s8)v_data_u8[SMI130_ACCEL_Y_MSB_BYTE]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_08_BITS)
+			| (v_data_u8[SMI130_ACCEL_Y_LSB_BYTE]));
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads accelerometer data Z values
+ *	form the register 0x16 and 0x17
+ *
+ *
+ *
+ *
+ *  @param v_accel_z_s16 : The value of accel z
+ *
+ *	@note For accel configuration use the following functions
+ *	@note smi130_set_accel_output_data_rate()
+ *	@note smi130_set_accel_bw()
+ *	@note smi130_set_accel_under_sampling_parameter()
+ *	@note smi130_set_accel_range()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_read_accel_z(s16 *v_accel_z_s16)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* Array contains the accel Z lSB and MSB data
+		a_data_u8r[LSB_ZERO] - LSB
+		a_data_u8r[MSB_ONE] - MSB*/
+	u8 a_data_u8r[SMI130_ACCEL_Z_DATA_SIZE] = {
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE};
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_DATA_18_ACCEL_Z_LSB__REG,
+			a_data_u8r, SMI130_ACCEL_DATA_LENGTH);
+
+			*v_accel_z_s16 = (s16)
+			((((s32)((s8)a_data_u8r[SMI130_ACCEL_Z_MSB_BYTE]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_08_BITS)
+			| (a_data_u8r[SMI130_ACCEL_Z_LSB_BYTE]));
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads accelerometer data X,Y,Z values
+ *	from the register 0x12 to 0x17
+ *
+ *
+ *
+ *
+ *  @param accel :The value of accel xyz
+ *
+ *	@note For accel configuration use the following functions
+ *	@note smi130_set_accel_output_data_rate()
+ *	@note smi130_set_accel_bw()
+ *	@note smi130_set_accel_under_sampling_parameter()
+ *	@note smi130_set_accel_range()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_read_accel_xyz(
+struct smi130_accel_t *accel)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* Array contains the accel XYZ lSB and MSB data
+	a_data_u8r[0] - X-LSB
+	a_data_u8r[1] - X-MSB
+	a_data_u8r[0] - Y-LSB
+	a_data_u8r[1] - Y-MSB
+	a_data_u8r[0] - Z-LSB
+	a_data_u8r[1] - Z-MSB
+	*/
+	u8 a_data_u8r[SMI130_ACCEL_XYZ_DATA_SIZE] = {
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE};
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_DATA_14_ACCEL_X_LSB__REG,
+			a_data_u8r, SMI130_ACCEL_XYZ_DATA_LENGTH);
+
+			/* Data X */
+			accel->x = (s16)
+			((((s32)((s8)a_data_u8r[
+			SMI130_DATA_FRAME_ACCEL_X_MSB_BYTE]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_08_BITS)
+			| (a_data_u8r[SMI130_DATA_FRAME_ACCEL_X_LSB_BYTE]));
+			/* Data Y */
+			accel->y = (s16)
+			((((s32)((s8)a_data_u8r[
+			SMI130_DATA_FRAME_ACCEL_Y_MSB_BYTE]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_08_BITS)
+			| (a_data_u8r[SMI130_DATA_FRAME_ACCEL_Y_LSB_BYTE]));
+
+			/* Data Z */
+			accel->z = (s16)
+			((((s32)((s8)a_data_u8r[
+			SMI130_DATA_FRAME_ACCEL_Z_MSB_BYTE]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_08_BITS)
+			| (a_data_u8r[SMI130_DATA_FRAME_ACCEL_Z_LSB_BYTE]));
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads sensor_time from the register
+ *	0x18 to 0x1A
+ *
+ *
+ *  @param v_sensor_time_u32 : The value of sensor time
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_sensor_time(u32 *v_sensor_time_u32)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* Array contains the sensor time it is 32 bit data
+	a_data_u8r[0] - sensor time
+	a_data_u8r[1] - sensor time
+	a_data_u8r[0] - sensor time
+	*/
+	u8 a_data_u8r[SMI130_SENSOR_TIME_DATA_SIZE] = {SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE};
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_SENSORTIME_0_SENSOR_TIME_LSB__REG,
+			a_data_u8r, SMI130_SENSOR_TIME_LENGTH);
+
+			*v_sensor_time_u32 = (u32)
+			((((u32)a_data_u8r[SMI130_SENSOR_TIME_MSB_BYTE])
+			<< SMI130_SHIFT_BIT_POSITION_BY_16_BITS)
+			|(((u32)a_data_u8r[SMI130_SENSOR_TIME_XLSB_BYTE])
+			<< SMI130_SHIFT_BIT_POSITION_BY_08_BITS)
+			| (a_data_u8r[SMI130_SENSOR_TIME_LSB_BYTE]));
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the Gyroscope self test
+ *	status from the register 0x1B bit 1
+ *
+ *
+ *  @param v_gyro_selftest_u8 : The value of gyro self test status
+ *  value    |   status
+ *  ---------|----------------
+ *   0       | Gyroscope self test is running or failed
+ *   1       | Gyroscope self test completed successfully
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_gyro_selftest(u8
+*v_gyro_selftest_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_STAT_GYRO_SELFTEST_OK__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_gyro_selftest_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_STAT_GYRO_SELFTEST_OK);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the status of
+ *	mag manual interface operation form the register 0x1B bit 2
+ *
+ *
+ *
+ *  @param v_mag_manual_stat_u8 : The value of mag manual operation status
+ *  value    |   status
+ *  ---------|----------------
+ *   0       | Indicates no manual magnetometer
+ *   -       | interface operation is ongoing
+ *   1       | Indicates manual magnetometer
+ *   -       | interface operation is ongoing
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_mag_manual_operation_stat(u8
+*v_mag_manual_stat_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read manual operation*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_STAT_MAG_MANUAL_OPERATION__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_mag_manual_stat_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_STAT_MAG_MANUAL_OPERATION);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the fast offset compensation
+ *	status form the register 0x1B bit 3
+ *
+ *
+ *  @param v_foc_rdy_u8 : The status of fast compensation
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_foc_rdy(u8
+*v_foc_rdy_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the FOC status*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_STAT_FOC_RDY__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_foc_rdy_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_STAT_FOC_RDY);
+		}
+	return com_rslt;
+}
+/*!
+ * @brief This API Reads the nvm_rdy status from the
+ *	resister 0x1B bit 4
+ *
+ *
+ *  @param v_nvm_rdy_u8 : The value of NVM ready status
+ *  value    |   status
+ *  ---------|----------------
+ *   0       | NVM write operation in progress
+ *   1       | NVM is ready to accept a new write trigger
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_nvm_rdy(u8
+*v_nvm_rdy_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the nvm ready status*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_STAT_NVM_RDY__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_nvm_rdy_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_STAT_NVM_RDY);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the status of mag data ready
+ *	from the register 0x1B bit 5
+ *	The status get reset when one mag data register is read out
+ *
+ *  @param v_data_rdy_u8 : The value of mag data ready status
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_data_rdy_mag(u8
+*v_data_rdy_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_STAT_DATA_RDY_MAG__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_data_rdy_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_STAT_DATA_RDY_MAG);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the status of gyro data ready form the
+ *	register 0x1B bit 6
+ *	The status get reset when gyro data register read out
+ *
+ *
+ *	@param v_data_rdy_u8 :	The value of gyro data ready
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_gyro_data_rdy(u8
+*v_data_rdy_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_STAT_DATA_RDY_GYRO__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_data_rdy_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_STAT_DATA_RDY_GYRO);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the status of accel data ready form the
+ *	register 0x1B bit 7
+ *	The status get reset when accel data register read out
+ *
+ *
+ *	@param v_data_rdy_u8 :	The value of accel data ready status
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_accel_data_rdy(u8
+*v_data_rdy_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/*reads the status of accel data ready*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_STAT_DATA_RDY_ACCEL__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_data_rdy_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_STAT_DATA_RDY_ACCEL);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the step detector interrupt status
+ *	from the register 0x1C bit 0
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the single tab interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt
+ *	signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_step_intr_u8 : The status of step detector interrupt
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat0_step_intr(u8
+*v_step_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_INTR_STAT_0_STEP_INTR__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_step_intr_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_STAT_0_STEP_INTR);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the
+ *	significant motion interrupt status
+ *	from the register 0x1C bit 1
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the single tab interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt
+ *	signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *
+ *  @param v_significant_intr_u8 : The status of step
+ *	motion interrupt
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat0_significant_intr(u8
+*v_significant_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_INTR_STAT_0_SIGNIFICANT_INTR__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_significant_intr_u8  = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_STAT_0_SIGNIFICANT_INTR);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API reads the any motion interrupt status
+ *	from the register 0x1C bit 2
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the single tab interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt
+ *	signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *  @param v_any_motion_intr_u8 : The status of any-motion interrupt
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat0_any_motion_intr(u8
+*v_any_motion_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_INTR_STAT_0_ANY_MOTION__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_any_motion_intr_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_STAT_0_ANY_MOTION);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the power mode trigger interrupt status
+ *	from the register 0x1C bit 3
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the single tab interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt
+ *	signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *
+ *  @param v_pmu_trigger_intr_u8 : The status of power mode trigger interrupt
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat0_pmu_trigger_intr(u8
+*v_pmu_trigger_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_INTR_STAT_0_PMU_TRIGGER__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_pmu_trigger_intr_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_STAT_0_PMU_TRIGGER);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the double tab status
+ *	from the register 0x1C bit 4
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the single tab interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt
+ *	signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_double_tap_intr_u8 :The status of double tab interrupt
+ *
+ *	@note Double tap interrupt can be configured by the following functions
+ *	@note INTERRUPT MAPPING
+ *	@note smi130_set_intr_double_tap()
+ *	@note AXIS MAPPING
+ *	@note smi130_get_stat2_tap_first_x()
+ *	@note smi130_get_stat2_tap_first_y()
+ *	@note smi130_get_stat2_tap_first_z()
+ *	@note DURATION
+ *	@note smi130_set_intr_tap_durn()
+ *	@note THRESHOLD
+ *	@note smi130_set_intr_tap_thres()
+ *	@note TAP QUIET
+ *	@note smi130_set_intr_tap_quiet()
+ *	@note TAP SHOCK
+ *	@note smi130_set_intr_tap_shock()
+ *	@note TAP SOURCE
+ *	@note smi130_set_intr_tap_source()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat0_double_tap_intr(u8
+*v_double_tap_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_INTR_STAT_0_DOUBLE_TAP_INTR__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_double_tap_intr_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_STAT_0_DOUBLE_TAP_INTR);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the single tab status
+ *	from the register 0x1C bit 5
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the single tab interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt
+ *	signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_single_tap_intr_u8 :The status of single tap interrupt
+ *
+ *	@note Single tap interrupt can be configured by the following functions
+ *	@note INTERRUPT MAPPING
+ *	@note smi130_set_intr_single_tap()
+ *	@note AXIS MAPPING
+ *	@note smi130_get_stat2_tap_first_x()
+ *	@note smi130_get_stat2_tap_first_y()
+ *	@note smi130_get_stat2_tap_first_z()
+ *	@note DURATION
+ *	@note smi130_set_intr_tap_durn()
+ *	@note THRESHOLD
+ *	@note smi130_set_intr_tap_thres()
+ *	@note TAP QUIET
+ *	@note smi130_set_intr_tap_quiet()
+ *	@note TAP SHOCK
+ *	@note smi130_set_intr_tap_shock()
+ *	@note TAP SOURCE
+ *	@note smi130_set_intr_tap_source()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat0_single_tap_intr(u8
+*v_single_tap_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_INTR_STAT_0_SINGLE_TAP_INTR__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_single_tap_intr_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_STAT_0_SINGLE_TAP_INTR);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the orient_mbl status
+ *	from the register 0x1C bit 6
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the orient_mbl interrupt triggers. The
+ *	setting of INT_LATCH controls if the
+ *	interrupt signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_orient_mbl_intr_u8 : The status of orient_mbl interrupt
+ *
+ *	@note For orient_mbl interrupt configuration use the following functions
+ *	@note STATUS
+ *	@note smi130_get_stat0_orient_mbl_intr()
+ *	@note AXIS MAPPING
+ *	@note smi130_get_stat3_orient_mbl_xy()
+ *	@note smi130_get_stat3_orient_mbl_z()
+ *	@note smi130_set_intr_orient_mbl_axes_enable()
+ *	@note INTERRUPT MAPPING
+ *	@note smi130_set_intr_orient_mbl()
+ *	@note INTERRUPT OUTPUT
+ *	@note smi130_set_intr_orient_mbl_ud_enable()
+ *	@note THETA
+ *	@note smi130_set_intr_orient_mbl_theta()
+ *	@note HYSTERESIS
+ *	@note smi130_set_intr_orient_mbl_hyst()
+ *	@note BLOCKING
+ *	@note smi130_set_intr_orient_mbl_blocking()
+ *	@note MODE
+ *	@note smi130_set_intr_orient_mbl_mode()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat0_orient_mbl_intr(u8
+*v_orient_mbl_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_INTR_STAT_0_ORIENT__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_orient_mbl_intr_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_STAT_0_ORIENT);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the flat interrupt status
+ *	from the register 0x1C bit 7
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the flat interrupt triggers. The
+ *	setting of INT_LATCH controls if the
+ *	interrupt signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_flat_intr_u8 : The status of  flat interrupt
+ *
+ *	@note For flat configuration use the following functions
+ *	@note STATS
+ *	@note smi130_get_stat0_flat_intr()
+ *	@note smi130_get_stat3_flat()
+ *	@note INTERRUPT MAPPING
+ *	@note smi130_set_intr_flat()
+ *	@note THETA
+ *	@note smi130_set_intr_flat_theta()
+ *	@note HOLD TIME
+ *	@note smi130_set_intr_flat_hold()
+ *	@note HYSTERESIS
+ *	@note smi130_set_intr_flat_hyst()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat0_flat_intr(u8
+*v_flat_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_INTR_STAT_0_FLAT__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_flat_intr_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_STAT_0_FLAT);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the high_g interrupt status
+ *	from the register 0x1D bit 2
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the high g  interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt signal and hence the
+ *	respective interrupt flag will be permanently
+ *	latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_high_g_intr_u8 : The status of high_g interrupt
+ *
+ *	@note High_g interrupt configured by following functions
+ *	@note STATUS
+ *	@note smi130_get_stat1_high_g_intr()
+ *	@note AXIS MAPPING
+ *	@note smi130_get_stat3_high_g_first_x()
+ *	@note smi130_get_stat3_high_g_first_y()
+ *	@note smi130_get_stat3_high_g_first_z()
+ *	@note SIGN MAPPING
+ *	@note smi130_get_stat3_high_g_first_sign()
+ *	@note INTERRUPT MAPPING
+ *	@note smi130_set_intr_high_g()
+  *	@note HYSTERESIS
+ *	@note smi130_set_intr_high_g_hyst()
+ *	@note DURATION
+ *	@note smi130_set_intr_high_g_durn()
+ *	@note THRESHOLD
+ *	@note smi130_set_intr_high_g_thres()
+ *	@note SOURCE
+ *	@note smi130_set_intr_low_high_source()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat1_high_g_intr(u8
+*v_high_g_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_INTR_STAT_1_HIGH_G_INTR__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_high_g_intr_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_STAT_1_HIGH_G_INTR);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the low g interrupt status
+ *	from the register 0x1D bit 3
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the low g  interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_low_g_intr_u8 : The status of low_g interrupt
+ *
+ *	@note Low_g interrupt configured by following functions
+ *	@note STATUS
+ *	@note smi130_get_stat1_low_g_intr()
+ *	@note INTERRUPT MAPPING
+ *	@note smi130_set_intr_low_g()
+ *	@note SOURCE
+ *	@note smi130_set_intr_low_high_source()
+ *	@note DURATION
+ *	@note smi130_set_intr_low_g_durn()
+ *	@note THRESHOLD
+ *	@note smi130_set_intr_low_g_thres()
+ *	@note HYSTERESIS
+ *	@note smi130_set_intr_low_g_hyst()
+ *	@note MODE
+ *	@note smi130_set_intr_low_g_mode()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat1_low_g_intr(u8
+*v_low_g_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_INTR_STAT_1_LOW_G_INTR__REG, &v_data_u8,
+			 SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_low_g_intr_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_STAT_1_LOW_G_INTR);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads data ready interrupt status
+ *	from the register 0x1D bit 4
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the  data ready  interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_data_rdy_intr_u8 : The status of data ready interrupt
+ *
+ *	@note Data ready interrupt configured by following functions
+ *	@note STATUS
+ *	@note smi130_get_stat1_data_rdy_intr()
+ *	@note INTERRUPT MAPPING
+ *	@note smi130_set_intr_data_rdy()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat1_data_rdy_intr(u8
+*v_data_rdy_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_INTR_STAT_1_DATA_RDY_INTR__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_data_rdy_intr_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_STAT_1_DATA_RDY_INTR);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads data ready FIFO full interrupt status
+ *	from the register 0x1D bit 5
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the FIFO full interrupt triggers. The
+ *	setting of INT_LATCH controls if the
+ *	interrupt signal and hence the
+ *	respective interrupt flag will
+ *	be permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_fifo_full_intr_u8 : The status of fifo full interrupt
+ *
+ *	@note FIFO full interrupt can be configured by following functions
+ *	@note smi130_set_intr_fifo_full()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat1_fifo_full_intr(u8
+*v_fifo_full_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_INTR_STAT_1_FIFO_FULL_INTR__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_fifo_full_intr_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_STAT_1_FIFO_FULL_INTR);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads data
+ *	 ready FIFO watermark interrupt status
+ *	from the register 0x1D bit 6
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the FIFO watermark interrupt triggers. The
+ *	setting of INT_LATCH controls if the
+ *	interrupt signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_fifo_wm_intr_u8 : The status of fifo water mark interrupt
+ *
+ *	@note FIFO full interrupt can be configured by following functions
+ *	@note smi130_set_intr_fifo_wm()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat1_fifo_wm_intr(u8
+*v_fifo_wm_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_INTR_STAT_1_FIFO_WM_INTR__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_fifo_wm_intr_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_STAT_1_FIFO_WM_INTR);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads data ready no motion interrupt status
+ *	from the register 0x1D bit 7
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the no motion  interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt signal and hence the
+ *	respective interrupt flag will be permanently
+ *	latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_nomotion_intr_u8 : The status of no motion interrupt
+ *
+ *	@note No motion interrupt can be configured by following function
+ *	@note STATUS
+ *	@note smi130_get_stat1_nomotion_intr()
+ *	@note INTERRUPT MAPPING
+ *	@note smi130_set_intr_nomotion()
+ *	@note DURATION
+ *	@note smi130_set_intr_slow_no_motion_durn()
+ *	@note THRESHOLD
+ *	@note smi130_set_intr_slow_no_motion_thres()
+ *	@note SLOW/NO MOTION SELECT
+ *	@note smi130_set_intr_slow_no_motion_select()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat1_nomotion_intr(u8
+*v_nomotion_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the no motion interrupt*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_INTR_STAT_1_NOMOTION_INTR__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_nomotion_intr_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_STAT_1_NOMOTION_INTR);
+		}
+	return com_rslt;
+}
+/*!
+ *@brief This API reads the status of any motion first x
+ *	from the register 0x1E bit 0
+ *
+ *
+ *@param v_anymotion_first_x_u8 : The status of any motion first x interrupt
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by x axis
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat2_any_motion_first_x(u8
+*v_anymotion_first_x_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the any motion first x interrupt*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_INTR_STAT_2_ANY_MOTION_FIRST_X__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_anymotion_first_x_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_STAT_2_ANY_MOTION_FIRST_X);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the status of any motion first y interrupt
+ *	from the register 0x1E bit 1
+ *
+ *
+ *
+ *@param v_any_motion_first_y_u8 : The status of any motion first y interrupt
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by y axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat2_any_motion_first_y(u8
+*v_any_motion_first_y_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the any motion first y interrupt*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_INTR_STAT_2_ANY_MOTION_FIRST_Y__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_any_motion_first_y_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_STAT_2_ANY_MOTION_FIRST_Y);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the status of any motion first z interrupt
+ *	from the register 0x1E bit 2
+ *
+ *
+ *
+ *
+ *@param v_any_motion_first_z_u8 : The status of any motion first z interrupt
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by y axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat2_any_motion_first_z(u8
+*v_any_motion_first_z_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the any motion first z interrupt*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_INTR_STAT_2_ANY_MOTION_FIRST_Z__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_any_motion_first_z_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_STAT_2_ANY_MOTION_FIRST_Z);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the any motion sign status from the
+ *	register 0x1E bit 3
+ *
+ *
+ *
+ *
+ *  @param v_anymotion_sign_u8 : The status of any motion sign
+ *  value     |  sign
+ * -----------|-------------
+ *   0        | positive
+ *   1        | negative
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat2_any_motion_sign(u8
+*v_anymotion_sign_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read any motion sign interrupt status */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_INTR_STAT_2_ANY_MOTION_SIGN__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_anymotion_sign_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_STAT_2_ANY_MOTION_SIGN);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the any motion tap first x status from the
+ *	register 0x1E bit 4
+ *
+ *
+ *
+ *
+ *  @param v_tap_first_x_u8 :The status of any motion tap first x
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by x axis
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat2_tap_first_x(u8
+*v_tap_first_x_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read tap first x interrupt status */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_INTR_STAT_2_TAP_FIRST_X__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_tap_first_x_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_STAT_2_TAP_FIRST_X);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the tap first y interrupt status from the
+ *	register 0x1E bit 5
+ *
+ *
+ *
+ *
+ *  @param v_tap_first_y_u8 :The status of tap first y interrupt
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by y axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat2_tap_first_y(u8
+*v_tap_first_y_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read tap first y interrupt status */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_INTR_STAT_2_TAP_FIRST_Y__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_tap_first_y_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_STAT_2_TAP_FIRST_Y);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the tap first z interrupt status  from the
+ *	register 0x1E bit 6
+ *
+ *
+ *
+ *
+ *  @param v_tap_first_z_u8 :The status of tap first z interrupt
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by z axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat2_tap_first_z(u8
+*v_tap_first_z_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read tap first z interrupt status */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_INTR_STAT_2_TAP_FIRST_Z__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_tap_first_z_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_STAT_2_TAP_FIRST_Z);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the tap sign status from the
+ *	register 0x1E bit 7
+ *
+ *
+ *
+ *
+ *  @param v_tap_sign_u8 : The status of tap sign
+ *  value     |  sign
+ * -----------|-------------
+ *   0        | positive
+ *   1        | negative
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat2_tap_sign(u8
+*v_tap_sign_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read tap_sign interrupt status */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_INTR_STAT_2_TAP_SIGN__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_tap_sign_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_STAT_2_TAP_SIGN);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the high_g first x status from the
+ *	register 0x1F bit 0
+ *
+ *
+ *
+ *
+ *  @param v_high_g_first_x_u8 :The status of high_g first x
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by x axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat3_high_g_first_x(u8
+*v_high_g_first_x_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read highg_x interrupt status */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_INTR_STAT_3_HIGH_G_FIRST_X__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_high_g_first_x_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_STAT_3_HIGH_G_FIRST_X);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the high_g first y status from the
+ *	register 0x1F bit 1
+ *
+ *
+ *
+ *
+ *  @param v_high_g_first_y_u8 : The status of high_g first y
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by y axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat3_high_g_first_y(u8
+*v_high_g_first_y_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read highg_y interrupt status */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_INTR_STAT_3_HIGH_G_FIRST_Y__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_high_g_first_y_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_STAT_3_HIGH_G_FIRST_Y);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the high_g first z status from the
+ *	register 0x1F bit 3
+ *
+ *
+ *
+ *
+ *  @param v_high_g_first_z_u8 : The status of high_g first z
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by z axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat3_high_g_first_z(u8
+*v_high_g_first_z_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read highg_z interrupt status */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_INTR_STAT_3_HIGH_G_FIRST_Z__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_high_g_first_z_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_STAT_3_HIGH_G_FIRST_Z);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the high sign status from the
+ *	register 0x1F bit 3
+ *
+ *
+ *
+ *
+ *  @param v_high_g_sign_u8 :The status of high sign
+ *  value     |  sign
+ * -----------|-------------
+ *   0        | positive
+ *   1        | negative
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat3_high_g_sign(u8
+*v_high_g_sign_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read highg_sign interrupt status */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_INTR_STAT_3_HIGH_G_SIGN__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_high_g_sign_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_STAT_3_HIGH_G_SIGN);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the status of orient_mbl_xy plane
+ *	from the register 0x1F bit 4 and 5
+ *
+ *
+ *  @param v_orient_mbl_xy_u8 :The status of orient_mbl_xy plane
+ *  value     |  status
+ * -----------|-------------
+ *   0x00     | portrait upright
+ *   0x01     | portrait upside down
+ *   0x02     | landscape left
+ *   0x03     | landscape right
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat3_orient_mbl_xy(u8
+*v_orient_mbl_xy_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read orient_mbl plane xy interrupt status */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_INTR_STAT_3_ORIENT_XY__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_orient_mbl_xy_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_STAT_3_ORIENT_XY);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the status of orient_mbl z plane
+ *	from the register 0x1F bit 6
+ *
+ *
+ *  @param v_orient_mbl_z_u8 :The status of orient_mbl z
+ *  value     |  status
+ * -----------|-------------
+ *   0x00     | upward looking
+ *   0x01     | downward looking
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat3_orient_mbl_z(u8
+*v_orient_mbl_z_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read orient_mbl z plane interrupt status */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_INTR_STAT_3_ORIENT_Z__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_orient_mbl_z_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_STAT_3_ORIENT_Z);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the flat status from the register
+ *	0x1F bit 7
+ *
+ *
+ *  @param v_flat_u8 : The status of flat interrupt
+ *  value     |  status
+ * -----------|-------------
+ *   0x00     | non flat
+ *   0x01     | flat position
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat3_flat(u8
+*v_flat_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read flat interrupt status */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_INTR_STAT_3_FLAT__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_flat_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_STAT_3_FLAT);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the temperature of the sensor
+ *	from the register 0x21 bit 0 to 7
+ *
+ *
+ *
+ *  @param v_temp_s16 : The value of temperature
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_temp(s16
+*v_temp_s16)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* Array contains the temperature lSB and MSB data
+	v_data_u8[0] - LSB
+	v_data_u8[1] - MSB*/
+	u8 v_data_u8[SMI130_TEMP_DATA_SIZE] = {SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE};
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read temperature data */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_TEMP_LSB_VALUE__REG, v_data_u8,
+			SMI130_TEMP_DATA_LENGTH);
+			*v_temp_s16 =
+			(s16)(((s32)((s8) (v_data_u8[SMI130_TEMP_MSB_BYTE]) <<
+			SMI130_SHIFT_BIT_POSITION_BY_08_BITS))
+			| v_data_u8[SMI130_TEMP_LSB_BYTE]);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the  of the sensor
+ *	form the register 0x23 and 0x24 bit 0 to 7 and 0 to 2
+ *	@brief this byte counter is updated each time a complete frame
+ *	was read or writtern
+ *
+ *
+ *  @param v_fifo_length_u32 : The value of fifo byte counter
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_fifo_length(u32 *v_fifo_length_u32)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* Array contains the fifo length data
+	v_data_u8[0] - fifo length
+	v_data_u8[1] - fifo length*/
+	u8 a_data_u8r[SMI130_FIFO_DATA_SIZE] = {SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE};
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read fifo length*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_FIFO_BYTE_COUNTER_LSB__REG, a_data_u8r,
+			 SMI130_FIFO_DATA_LENGTH);
+
+			a_data_u8r[SMI130_FIFO_LENGTH_MSB_BYTE] =
+			SMI130_GET_BITSLICE(
+			a_data_u8r[SMI130_FIFO_LENGTH_MSB_BYTE],
+			SMI130_USER_FIFO_BYTE_COUNTER_MSB);
+
+			*v_fifo_length_u32 =
+			(u32)(((u32)((u8) (
+			a_data_u8r[SMI130_FIFO_LENGTH_MSB_BYTE]) <<
+			SMI130_SHIFT_BIT_POSITION_BY_08_BITS))
+			| a_data_u8r[SMI130_FIFO_LENGTH_LSB_BYTE]);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the fifo data of the sensor
+ *	from the register 0x24
+ *	@brief Data format depends on the setting of register FIFO_CONFIG
+ *
+ *
+ *
+ *  @param v_fifodata_u8 : Pointer holding the fifo data
+ *  @param fifo_length_u16 : The value of fifo length maximum
+ *	1024
+ *
+ *	@note For reading FIFO data use the following functions
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_fifo_data(
+u8 *v_fifodata_u8, u16 v_fifo_length_u16)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read fifo data*/
+			com_rslt =
+			p_smi130->SMI130_BURST_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_FIFO_DATA__REG,
+			v_fifodata_u8, v_fifo_length_u16);
+
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to get the
+ *	accel output date rate form the register 0x40 bit 0 to 3
+ *
+ *
+ *  @param  v_output_data_rate_u8 :The value of accel output date rate
+ *  value |  output data rate
+ * -------|--------------------------
+ *	 0    |	SMI130_ACCEL_OUTPUT_DATA_RATE_RESERVED
+ *	 1	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_0_78HZ
+ *	 2	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_1_56HZ
+ *	 3    |	SMI130_ACCEL_OUTPUT_DATA_RATE_3_12HZ
+ *	 4    | SMI130_ACCEL_OUTPUT_DATA_RATE_6_25HZ
+ *	 5	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_12_5HZ
+ *	 6	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_25HZ
+ *	 7	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_50HZ
+ *	 8	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_100HZ
+ *	 9	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_200HZ
+ *	 10	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_400HZ
+ *	 11	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_800HZ
+ *	 12	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_1600HZ
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_accel_output_data_rate(
+u8 *v_output_data_rate_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the accel output data rate*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_output_data_rate_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set the
+ *	accel output date rate form the register 0x40 bit 0 to 3
+ *
+ *
+ *  @param  v_output_data_rate_u8 :The value of accel output date rate
+ *  value |  output data rate
+ * -------|--------------------------
+ *	 0    |	SMI130_ACCEL_OUTPUT_DATA_RATE_RESERVED
+ *	 1	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_0_78HZ
+ *	 2	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_1_56HZ
+ *	 3    |	SMI130_ACCEL_OUTPUT_DATA_RATE_3_12HZ
+ *	 4    | SMI130_ACCEL_OUTPUT_DATA_RATE_6_25HZ
+ *	 5	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_12_5HZ
+ *	 6	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_25HZ
+ *	 7	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_50HZ
+ *	 8	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_100HZ
+ *	 9	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_200HZ
+ *	 10	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_400HZ
+ *	 11	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_800HZ
+ *	 12	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_1600HZ
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_accel_output_data_rate(
+u8 v_output_data_rate_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		/* accel output data rate selection */
+		if ((v_output_data_rate_u8 != SMI130_INIT_VALUE) &&
+		(v_output_data_rate_u8 <= SMI130_MAX_ACCEL_OUTPUT_DATA_RATE)) {
+			/* write accel output data rate */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE,
+				v_output_data_rate_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to get the
+ *	accel bandwidth from the register 0x40 bit 4 to 6
+ *	@brief bandwidth parameter determines filter configuration(acc_us=0)
+ *	and averaging for under sampling mode(acc_us=1)
+ *
+ *
+ *  @param  v_bw_u8 : The value of accel bandwidth
+ *
+ *	@note accel bandwidth depends on under sampling parameter
+ *	@note under sampling parameter cab be set by the function
+ *	"SMI130_SET_ACCEL_UNDER_SAMPLING_PARAMETER"
+ *
+ *	@note Filter configuration
+ *  accel_us  | Filter configuration
+ * -----------|---------------------
+ *    0x00    |  OSR4 mode
+ *    0x01    |  OSR2 mode
+ *    0x02    |  normal mode
+ *    0x03    |  CIC mode
+ *    0x04    |  Reserved
+ *    0x05    |  Reserved
+ *    0x06    |  Reserved
+ *    0x07    |  Reserved
+ *
+ *	@note accel under sampling mode
+ *  accel_us  | Under sampling mode
+ * -----------|---------------------
+ *    0x00    |  no averaging
+ *    0x01    |  average 2 samples
+ *    0x02    |  average 4 samples
+ *    0x03    |  average 8 samples
+ *    0x04    |  average 16 samples
+ *    0x05    |  average 32 samples
+ *    0x06    |  average 64 samples
+ *    0x07    |  average 128 samples
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_accel_bw(u8 *v_bw_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the accel bandwidth */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_ACCEL_CONFIG_ACCEL_BW__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_bw_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_ACCEL_CONFIG_ACCEL_BW);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set the
+ *	accel bandwidth from the register 0x40 bit 4 to 6
+ *	@brief bandwidth parameter determines filter configuration(acc_us=0)
+ *	and averaging for under sampling mode(acc_us=1)
+ *
+ *
+ *  @param  v_bw_u8 : The value of accel bandwidth
+ *
+ *	@note accel bandwidth depends on under sampling parameter
+ *	@note under sampling parameter cab be set by the function
+ *	"SMI130_SET_ACCEL_UNDER_SAMPLING_PARAMETER"
+ *
+ *	@note Filter configuration
+ *  accel_us  | Filter configuration
+ * -----------|---------------------
+ *    0x00    |  OSR4 mode
+ *    0x01    |  OSR2 mode
+ *    0x02    |  normal mode
+ *    0x03    |  CIC mode
+ *    0x04    |  Reserved
+ *    0x05    |  Reserved
+ *    0x06    |  Reserved
+ *    0x07    |  Reserved
+ *
+ *	@note accel under sampling mode
+ *  accel_us  | Under sampling mode
+ * -----------|---------------------
+ *    0x00    |  no averaging
+ *    0x01    |  average 2 samples
+ *    0x02    |  average 4 samples
+ *    0x03    |  average 8 samples
+ *    0x04    |  average 16 samples
+ *    0x05    |  average 32 samples
+ *    0x06    |  average 64 samples
+ *    0x07    |  average 128 samples
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_accel_bw(u8 v_bw_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		/* select accel bandwidth*/
+		if (v_bw_u8 <= SMI130_MAX_ACCEL_BW) {
+			/* write accel bandwidth*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_ACCEL_CONFIG_ACCEL_BW__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_ACCEL_CONFIG_ACCEL_BW,
+				v_bw_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_ACCEL_CONFIG_ACCEL_BW__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to get the accel
+ *	under sampling parameter form the register 0x40 bit 7
+ *
+ *
+ *
+ *
+ *	@param  v_accel_under_sampling_u8 : The value of accel under sampling
+ *	value    | under_sampling
+ * ----------|---------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_accel_under_sampling_parameter(
+u8 *v_accel_under_sampling_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the accel under sampling parameter */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_accel_under_sampling_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set the accel
+ *	under sampling parameter form the register 0x40 bit 7
+ *
+ *
+ *
+ *
+ *	@param  v_accel_under_sampling_u8 : The value of accel under sampling
+ *	value    | under_sampling
+ * ----------|---------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_accel_under_sampling_parameter(
+u8 v_accel_under_sampling_u8)
+{
+/* variable used for return the status of communication result*/
+SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+	if (v_accel_under_sampling_u8 <= SMI130_MAX_UNDER_SAMPLING) {
+		com_rslt =
+		p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+		SMI130_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			/* write the accel under sampling parameter */
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING,
+			v_accel_under_sampling_u8);
+			com_rslt +=
+			p_smi130->SMI130_BUS_WRITE_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	} else {
+	com_rslt = E_SMI130_OUT_OF_RANGE;
+	}
+}
+return com_rslt;
+}
+/*!
+ *	@brief This API is used to get the ranges
+ *	(g values) of the accel from the register 0x41 bit 0 to 3
+ *
+ *
+ *
+ *
+ *  @param v_range_u8 : The value of accel g range
+ *	value    | g_range
+ * ----------|-----------
+ *   0x03    | SMI130_ACCEL_RANGE_2G
+ *   0x05    | SMI130_ACCEL_RANGE_4G
+ *   0x08    | SMI130_ACCEL_RANGE_8G
+ *   0x0C    | SMI130_ACCEL_RANGE_16G
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_accel_range(
+u8 *v_range_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the accel range*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_ACCEL_RANGE__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_range_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_ACCEL_RANGE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set the ranges
+ *	(g values) of the accel from the register 0x41 bit 0 to 3
+ *
+ *
+ *
+ *
+ *  @param v_range_u8 : The value of accel g range
+ *	value    | g_range
+ * ----------|-----------
+ *   0x03    | SMI130_ACCEL_RANGE_2G
+ *   0x05    | SMI130_ACCEL_RANGE_4G
+ *   0x08    | SMI130_ACCEL_RANGE_8G
+ *   0x0C    | SMI130_ACCEL_RANGE_16G
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_accel_range(u8 v_range_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if ((v_range_u8 == SMI130_ACCEL_RANGE0) ||
+			(v_range_u8 == SMI130_ACCEL_RANGE1) ||
+			(v_range_u8 == SMI130_ACCEL_RANGE3) ||
+			(v_range_u8 == SMI130_ACCEL_RANGE4)) {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_ACCEL_RANGE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8  = SMI130_SET_BITSLICE(
+				v_data_u8, SMI130_USER_ACCEL_RANGE,
+				v_range_u8);
+				/* write the accel range*/
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_ACCEL_RANGE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to get the
+ *	gyroscope output data rate from the register 0x42 bit 0 to 3
+ *
+ *
+ *
+ *
+ *  @param  v_output_data_rate_u8 :The value of gyro output data rate
+ *  value     |      gyro output data rate
+ * -----------|-----------------------------
+ *   0x00     | SMI130_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x01     | SMI130_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x02     | SMI130_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x03     | SMI130_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x04     | SMI130_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x05     | SMI130_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x06     | SMI130_GYRO_OUTPUT_DATA_RATE_25HZ
+ *   0x07     | SMI130_GYRO_OUTPUT_DATA_RATE_50HZ
+ *   0x08     | SMI130_GYRO_OUTPUT_DATA_RATE_100HZ
+ *   0x09     | SMI130_GYRO_OUTPUT_DATA_RATE_200HZ
+ *   0x0A     | SMI130_GYRO_OUTPUT_DATA_RATE_400HZ
+ *   0x0B     | SMI130_GYRO_OUTPUT_DATA_RATE_800HZ
+ *   0x0C     | SMI130_GYRO_OUTPUT_DATA_RATE_1600HZ
+ *   0x0D     | SMI130_GYRO_OUTPUT_DATA_RATE_3200HZ
+ *   0x0E     | SMI130_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x0F     | SMI130_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_gyro_output_data_rate(
+u8 *v_output_data_rate_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the gyro output data rate*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_GYRO_CONFIG_OUTPUT_DATA_RATE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_output_data_rate_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_GYRO_CONFIG_OUTPUT_DATA_RATE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set the
+ *	gyroscope output data rate from the register 0x42 bit 0 to 3
+ *
+ *
+ *
+ *
+ *  @param  v_output_data_rate_u8 :The value of gyro output data rate
+ *  value     |      gyro output data rate
+ * -----------|-----------------------------
+ *   0x00     | SMI130_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x01     | SMI130_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x02     | SMI130_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x03     | SMI130_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x04     | SMI130_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x05     | SMI130_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x06     | SMI130_GYRO_OUTPUT_DATA_RATE_25HZ
+ *   0x07     | SMI130_GYRO_OUTPUT_DATA_RATE_50HZ
+ *   0x08     | SMI130_GYRO_OUTPUT_DATA_RATE_100HZ
+ *   0x09     | SMI130_GYRO_OUTPUT_DATA_RATE_200HZ
+ *   0x0A     | SMI130_GYRO_OUTPUT_DATA_RATE_400HZ
+ *   0x0B     | SMI130_GYRO_OUTPUT_DATA_RATE_800HZ
+ *   0x0C     | SMI130_GYRO_OUTPUT_DATA_RATE_1600HZ
+ *   0x0D     | SMI130_GYRO_OUTPUT_DATA_RATE_3200HZ
+ *   0x0E     | SMI130_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x0F     | SMI130_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_gyro_output_data_rate(
+u8 v_output_data_rate_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		/* select the gyro output data rate*/
+		if ((v_output_data_rate_u8 <  SMI130_OUTPUT_DATA_RATE6) &&
+		(v_output_data_rate_u8 != SMI130_INIT_VALUE)
+		&& (v_output_data_rate_u8 !=  SMI130_OUTPUT_DATA_RATE1)
+		&& (v_output_data_rate_u8 !=  SMI130_OUTPUT_DATA_RATE2)
+		&& (v_output_data_rate_u8 !=  SMI130_OUTPUT_DATA_RATE3)
+		&& (v_output_data_rate_u8 !=  SMI130_OUTPUT_DATA_RATE4)
+		&& (v_output_data_rate_u8 !=  SMI130_OUTPUT_DATA_RATE5)
+		&& (v_output_data_rate_u8 !=  SMI130_OUTPUT_DATA_RATE6)
+		&& (v_output_data_rate_u8 !=  SMI130_OUTPUT_DATA_RATE7)) {
+			/* write the gyro output data rate */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_GYRO_CONFIG_OUTPUT_DATA_RATE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_GYRO_CONFIG_OUTPUT_DATA_RATE,
+				v_output_data_rate_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC
+				(p_smi130->dev_addr,
+				SMI130_USER_GYRO_CONFIG_OUTPUT_DATA_RATE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to get the
+ *	data of gyro from the register 0x42 bit 4 to 5
+ *
+ *
+ *
+ *
+ *  @param  v_bw_u8 : The value of gyro bandwidth
+ *  value     | gyro bandwidth
+ *  ----------|----------------
+ *   0x00     | SMI130_GYRO_OSR4_MODE
+ *   0x01     | SMI130_GYRO_OSR2_MODE
+ *   0x02     | SMI130_GYRO_NORMAL_MODE
+ *   0x03     | SMI130_GYRO_CIC_MODE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_gyro_bw(u8 *v_bw_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read gyro bandwidth*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_GYRO_CONFIG_BW__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_bw_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_GYRO_CONFIG_BW);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set the
+ *	data of gyro from the register 0x42 bit 4 to 5
+ *
+ *
+ *
+ *
+ *  @param  v_bw_u8 : The value of gyro bandwidth
+ *  value     | gyro bandwidth
+ *  ----------|----------------
+ *   0x00     | SMI130_GYRO_OSR4_MODE
+ *   0x01     | SMI130_GYRO_OSR2_MODE
+ *   0x02     | SMI130_GYRO_NORMAL_MODE
+ *   0x03     | SMI130_GYRO_CIC_MODE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_gyro_bw(u8 v_bw_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_bw_u8 <= SMI130_MAX_GYRO_BW) {
+			/* write the gyro bandwidth*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_GYRO_CONFIG_BW__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_GYRO_CONFIG_BW, v_bw_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_GYRO_CONFIG_BW__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads the range
+ *	of gyro from the register 0x43 bit 0 to 2
+ *
+ *  @param  v_range_u8 : The value of gyro range
+ *   value    |    range
+ *  ----------|-------------------------------
+ *    0x00    | SMI130_GYRO_RANGE_2000_DEG_SEC
+ *    0x01    | SMI130_GYRO_RANGE_1000_DEG_SEC
+ *    0x02    | SMI130_GYRO_RANGE_500_DEG_SEC
+ *    0x03    | SMI130_GYRO_RANGE_250_DEG_SEC
+ *    0x04    | SMI130_GYRO_RANGE_125_DEG_SEC
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_gyro_range(u8 *v_range_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the gyro range */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_GYRO_RANGE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_range_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_GYRO_RANGE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API set the range
+ *	of gyro from the register 0x43 bit 0 to 2
+ *
+ *  @param  v_range_u8 : The value of gyro range
+ *   value    |    range
+ *  ----------|-------------------------------
+ *    0x00    | SMI130_GYRO_RANGE_2000_DEG_SEC
+ *    0x01    | SMI130_GYRO_RANGE_1000_DEG_SEC
+ *    0x02    | SMI130_GYRO_RANGE_500_DEG_SEC
+ *    0x03    | SMI130_GYRO_RANGE_250_DEG_SEC
+ *    0x04    | SMI130_GYRO_RANGE_125_DEG_SEC
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_gyro_range(u8 v_range_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_range_u8 <= SMI130_MAX_GYRO_RANGE) {
+			/* write the gyro range value */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_GYRO_RANGE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_GYRO_RANGE,
+				v_range_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC
+				(p_smi130->dev_addr,
+				SMI130_USER_GYRO_RANGE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to get the
+ *	output data rate of magnetometer from the register 0x44 bit 0 to 3
+ *
+ *
+ *
+ *
+ *  @param  v_output_data_rat_u8e : The value of mag output data rate
+ *  value   |    mag output data rate
+ * ---------|---------------------------
+ *  0x00    |SMI130_MAG_OUTPUT_DATA_RATE_RESERVED
+ *  0x01    |SMI130_MAG_OUTPUT_DATA_RATE_0_78HZ
+ *  0x02    |SMI130_MAG_OUTPUT_DATA_RATE_1_56HZ
+ *  0x03    |SMI130_MAG_OUTPUT_DATA_RATE_3_12HZ
+ *  0x04    |SMI130_MAG_OUTPUT_DATA_RATE_6_25HZ
+ *  0x05    |SMI130_MAG_OUTPUT_DATA_RATE_12_5HZ
+ *  0x06    |SMI130_MAG_OUTPUT_DATA_RATE_25HZ
+ *  0x07    |SMI130_MAG_OUTPUT_DATA_RATE_50HZ
+ *  0x08    |SMI130_MAG_OUTPUT_DATA_RATE_100HZ
+ *  0x09    |SMI130_MAG_OUTPUT_DATA_RATE_200HZ
+ *  0x0A    |SMI130_MAG_OUTPUT_DATA_RATE_400HZ
+ *  0x0B    |SMI130_MAG_OUTPUT_DATA_RATE_800HZ
+ *  0x0C    |SMI130_MAG_OUTPUT_DATA_RATE_1600HZ
+ *  0x0D    |SMI130_MAG_OUTPUT_DATA_RATE_RESERVED0
+ *  0x0E    |SMI130_MAG_OUTPUT_DATA_RATE_RESERVED1
+ *  0x0F    |SMI130_MAG_OUTPUT_DATA_RATE_RESERVED2
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_mag_output_data_rate(
+u8 *v_output_data_rat_u8e)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the mag data output rate*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_MAG_CONFIG_OUTPUT_DATA_RATE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_output_data_rat_u8e = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_MAG_CONFIG_OUTPUT_DATA_RATE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set the
+ *	output data rate of magnetometer from the register 0x44 bit 0 to 3
+ *
+ *
+ *
+ *
+ *  @param  v_output_data_rat_u8e : The value of mag output data rate
+ *  value   |    mag output data rate
+ * ---------|---------------------------
+ *  0x00    |SMI130_MAG_OUTPUT_DATA_RATE_RESERVED
+ *  0x01    |SMI130_MAG_OUTPUT_DATA_RATE_0_78HZ
+ *  0x02    |SMI130_MAG_OUTPUT_DATA_RATE_1_56HZ
+ *  0x03    |SMI130_MAG_OUTPUT_DATA_RATE_3_12HZ
+ *  0x04    |SMI130_MAG_OUTPUT_DATA_RATE_6_25HZ
+ *  0x05    |SMI130_MAG_OUTPUT_DATA_RATE_12_5HZ
+ *  0x06    |SMI130_MAG_OUTPUT_DATA_RATE_25HZ
+ *  0x07    |SMI130_MAG_OUTPUT_DATA_RATE_50HZ
+ *  0x08    |SMI130_MAG_OUTPUT_DATA_RATE_100HZ
+ *  0x09    |SMI130_MAG_OUTPUT_DATA_RATE_200HZ
+ *  0x0A    |SMI130_MAG_OUTPUT_DATA_RATE_400HZ
+ *  0x0B    |SMI130_MAG_OUTPUT_DATA_RATE_800HZ
+ *  0x0C    |SMI130_MAG_OUTPUT_DATA_RATE_1600HZ
+ *  0x0D    |SMI130_MAG_OUTPUT_DATA_RATE_RESERVED0
+ *  0x0E    |SMI130_MAG_OUTPUT_DATA_RATE_RESERVED1
+ *  0x0F    |SMI130_MAG_OUTPUT_DATA_RATE_RESERVED2
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_mag_output_data_rate(
+u8 v_output_data_rat_u8e)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		/* select the mag data output rate*/
+		if ((v_output_data_rat_u8e
+		<= SMI130_MAX_ACCEL_OUTPUT_DATA_RATE)
+		&& (v_output_data_rat_u8e
+		!= SMI130_OUTPUT_DATA_RATE0)
+		&& (v_output_data_rat_u8e
+		!=  SMI130_OUTPUT_DATA_RATE6)
+		&& (v_output_data_rat_u8e
+		!=  SMI130_OUTPUT_DATA_RATE7)) {
+			/* write the mag data output rate*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_MAG_CONFIG_OUTPUT_DATA_RATE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_MAG_CONFIG_OUTPUT_DATA_RATE,
+				v_output_data_rat_u8e);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_MAG_CONFIG_OUTPUT_DATA_RATE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API is used to read Down sampling
+ *	for gyro (2**downs_gyro) in the register 0x45 bit 0 to 2
+ *
+ *
+ *
+ *
+ *  @param v_fifo_down_gyro_u8 :The value of gyro fifo down
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_fifo_down_gyro(
+u8 *v_fifo_down_gyro_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the gyro fifo down*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_FIFO_DOWN_GYRO__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_fifo_down_gyro_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_FIFO_DOWN_GYRO);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API is used to set Down sampling
+ *	for gyro (2**downs_gyro) in the register 0x45 bit 0 to 2
+ *
+ *
+ *
+ *
+ *  @param v_fifo_down_gyro_u8 :The value of gyro fifo down
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_fifo_down_gyro(
+u8 v_fifo_down_gyro_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* write the gyro fifo down*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_FIFO_DOWN_GYRO__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(
+				v_data_u8,
+				SMI130_USER_FIFO_DOWN_GYRO,
+				v_fifo_down_gyro_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_FIFO_DOWN_GYRO__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to read gyro fifo filter data
+ *	from the register 0x45 bit 3
+ *
+ *
+ *
+ *  @param v_gyro_fifo_filter_data_u8 :The value of gyro filter data
+ *  value      |  gyro_fifo_filter_data
+ * ------------|-------------------------
+ *    0x00     |  Unfiltered data
+ *    0x01     |  Filtered data
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_gyro_fifo_filter_data(
+u8 *v_gyro_fifo_filter_data_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the gyro fifo filter data */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_FIFO_FILTER_GYRO__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_gyro_fifo_filter_data_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_FIFO_FILTER_GYRO);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set gyro fifo filter data
+ *	from the register 0x45 bit 3
+ *
+ *
+ *
+ *  @param v_gyro_fifo_filter_data_u8 :The value of gyro filter data
+ *  value      |  gyro_fifo_filter_data
+ * ------------|-------------------------
+ *    0x00     |  Unfiltered data
+ *    0x01     |  Filtered data
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_gyro_fifo_filter_data(
+u8 v_gyro_fifo_filter_data_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_gyro_fifo_filter_data_u8
+		<= SMI130_MAX_VALUE_FIFO_FILTER) {
+			/* write the gyro fifo filter data */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_FIFO_FILTER_GYRO__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(
+				v_data_u8,
+				SMI130_USER_FIFO_FILTER_GYRO,
+				v_gyro_fifo_filter_data_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_FIFO_FILTER_GYRO__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to read Down sampling
+ *	for accel (2*downs_accel) from the register 0x45 bit 4 to 6
+ *
+ *
+ *
+ *
+ *  @param v_fifo_down_u8 :The value of accel fifo down
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_fifo_down_accel(
+u8 *v_fifo_down_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the accel fifo down data */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_FIFO_DOWN_ACCEL__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_fifo_down_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_FIFO_DOWN_ACCEL);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API is used to set Down sampling
+ *	for accel (2*downs_accel) from the register 0x45 bit 4 to 6
+ *
+ *
+ *
+ *
+ *  @param v_fifo_down_u8 :The value of accel fifo down
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_fifo_down_accel(
+u8 v_fifo_down_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* write the accel fifo down data */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_FIFO_DOWN_ACCEL__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_FIFO_DOWN_ACCEL, v_fifo_down_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_FIFO_DOWN_ACCEL__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to read accel fifo filter data
+ *	from the register 0x45 bit 7
+ *
+ *
+ *
+ *  @param v_accel_fifo_filter_u8 :The value of accel filter data
+ *  value      |  accel_fifo_filter_data
+ * ------------|-------------------------
+ *    0x00     |  Unfiltered data
+ *    0x01     |  Filtered data
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_accel_fifo_filter_data(
+u8 *v_accel_fifo_filter_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the accel fifo filter data */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_FIFO_FILTER_ACCEL__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_accel_fifo_filter_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_FIFO_FILTER_ACCEL);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set accel fifo filter data
+ *	from the register 0x45 bit 7
+ *
+ *
+ *
+ *  @param v_accel_fifo_filter_u8 :The value of accel filter data
+ *  value      |  accel_fifo_filter_data
+ * ------------|-------------------------
+ *    0x00     |  Unfiltered data
+ *    0x01     |  Filtered data
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_accel_fifo_filter_data(
+u8 v_accel_fifo_filter_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_accel_fifo_filter_u8 <= SMI130_MAX_VALUE_FIFO_FILTER) {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_FIFO_FILTER_ACCEL__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				/* write accel fifo filter data */
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_FIFO_FILTER_ACCEL,
+				v_accel_fifo_filter_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_FIFO_FILTER_ACCEL__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to Trigger an interrupt
+ *	when FIFO contains water mark level from the register 0x46 bit 0 to 7
+ *
+ *
+ *
+ *  @param  v_fifo_wm_u8 : The value of fifo water mark level
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_fifo_wm(
+u8 *v_fifo_wm_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the fifo water mark level*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_FIFO_WM__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_fifo_wm_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_FIFO_WM);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to Trigger an interrupt
+ *	when FIFO contains water mark level from the register 0x46 bit 0 to 7
+ *
+ *
+ *
+ *  @param  v_fifo_wm_u8 : The value of fifo water mark level
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_fifo_wm(
+u8 v_fifo_wm_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* write the fifo water mark level*/
+			com_rslt =
+			p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->dev_addr,
+			SMI130_USER_FIFO_WM__REG,
+			&v_fifo_wm_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads fifo sensor time
+ *	frame after the last valid data frame form the register  0x47 bit 1
+ *
+ *
+ *
+ *
+ *  @param v_fifo_time_enable_u8 : The value of sensor time
+ *  value      |  fifo sensor time
+ * ------------|-------------------------
+ *    0x00     |  do not return sensortime frame
+ *    0x01     |  return sensortime frame
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_get_fifo_time_enable(
+u8 *v_fifo_time_enable_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the fifo sensor time*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_FIFO_TIME_ENABLE__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_fifo_time_enable_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_FIFO_TIME_ENABLE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API set fifo sensor time
+ *	frame after the last valid data frame form the register  0x47 bit 1
+ *
+ *
+ *
+ *
+ *  @param v_fifo_time_enable_u8 : The value of sensor time
+ *  value      |  fifo sensor time
+ * ------------|-------------------------
+ *    0x00     |  do not return sensortime frame
+ *    0x01     |  return sensortime frame
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_set_fifo_time_enable(
+u8 v_fifo_time_enable_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_fifo_time_enable_u8 <= SMI130_MAX_VALUE_FIFO_TIME) {
+			/* write the fifo sensor time*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_FIFO_TIME_ENABLE__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_FIFO_TIME_ENABLE,
+				v_fifo_time_enable_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_FIFO_TIME_ENABLE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads FIFO tag interrupt2 enable status
+ *	from the resister 0x47 bit 2
+ *
+ *  @param v_fifo_tag_intr2_u8 : The value of fifo tag interrupt
+ *	value    | fifo tag interrupt
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_fifo_tag_intr2_enable(
+u8 *v_fifo_tag_intr2_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the fifo tag interrupt2*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_FIFO_TAG_INTR2_ENABLE__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_fifo_tag_intr2_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_FIFO_TAG_INTR2_ENABLE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API set FIFO tag interrupt2 enable status
+ *	from the resister 0x47 bit 2
+ *
+ *  @param v_fifo_tag_intr2_u8 : The value of fifo tag interrupt
+ *	value    | fifo tag interrupt
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_fifo_tag_intr2_enable(
+u8 v_fifo_tag_intr2_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_fifo_tag_intr2_u8 <= SMI130_MAX_VALUE_FIFO_INTR) {
+			/* write the fifo tag interrupt2*/
+			com_rslt = smi130_set_input_enable(1,
+			v_fifo_tag_intr2_u8);
+			com_rslt +=
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_FIFO_TAG_INTR2_ENABLE__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_FIFO_TAG_INTR2_ENABLE,
+				v_fifo_tag_intr2_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_FIFO_TAG_INTR2_ENABLE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API get FIFO tag interrupt1 enable status
+ *	from the resister 0x47 bit 3
+ *
+ *  @param v_fifo_tag_intr1_u8 :The value of fifo tag interrupt1
+ *	value    | fifo tag interrupt
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_fifo_tag_intr1_enable(
+u8 *v_fifo_tag_intr1_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read fifo tag interrupt*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_FIFO_TAG_INTR1_ENABLE__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_fifo_tag_intr1_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_FIFO_TAG_INTR1_ENABLE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API set FIFO tag interrupt1 enable status
+ *	from the resister 0x47 bit 3
+ *
+ *  @param v_fifo_tag_intr1_u8 :The value of fifo tag interrupt1
+ *	value    | fifo tag interrupt
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_fifo_tag_intr1_enable(
+u8 v_fifo_tag_intr1_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_fifo_tag_intr1_u8 <= SMI130_MAX_VALUE_FIFO_INTR) {
+			/* write the fifo tag interrupt*/
+			com_rslt = smi130_set_input_enable(SMI130_INIT_VALUE,
+			v_fifo_tag_intr1_u8);
+			com_rslt +=
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_FIFO_TAG_INTR1_ENABLE__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_FIFO_TAG_INTR1_ENABLE,
+				v_fifo_tag_intr1_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_FIFO_TAG_INTR1_ENABLE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads FIFO frame
+ *	header enable from the register 0x47 bit 4
+ *
+ *  @param v_fifo_header_u8 :The value of fifo header
+ *	value    | fifo header
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_fifo_header_enable(
+u8 *v_fifo_header_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read fifo header */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_FIFO_HEADER_ENABLE__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_fifo_header_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_FIFO_HEADER_ENABLE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API set FIFO frame
+ *	header enable from the register 0x47 bit 4
+ *
+ *  @param v_fifo_header_u8 :The value of fifo header
+ *	value    | fifo header
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_fifo_header_enable(
+u8 v_fifo_header_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_fifo_header_u8 <= SMI130_MAX_VALUE_FIFO_HEADER) {
+			/* write the fifo header */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_FIFO_HEADER_ENABLE__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_FIFO_HEADER_ENABLE,
+				v_fifo_header_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_FIFO_HEADER_ENABLE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to read stored
+ *	magnetometer data in FIFO (all 3 axes) from the register 0x47 bit 5
+ *
+ *  @param v_fifo_mag_u8 : The value of fifo mag enble
+ *	value    | fifo mag
+ * ----------|-------------------
+ *  0x00     |  no magnetometer data is stored
+ *  0x01     |  magnetometer data is stored
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_fifo_mag_enable(
+u8 *v_fifo_mag_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the fifo mag enable*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_FIFO_MAG_ENABLE__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_fifo_mag_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_FIFO_MAG_ENABLE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set stored
+ *	magnetometer data in FIFO (all 3 axes) from the register 0x47 bit 5
+ *
+ *  @param v_fifo_mag_u8 : The value of fifo mag enble
+ *	value    | fifo mag
+ * ----------|-------------------
+ *  0x00     |  no magnetometer data is stored
+ *  0x01     |  magnetometer data is stored
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_fifo_mag_enable(
+u8 v_fifo_mag_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			if (v_fifo_mag_u8 <= SMI130_MAX_VALUE_FIFO_MAG) {
+				/* write the fifo mag enable*/
+				com_rslt =
+				p_smi130->SMI130_BUS_READ_FUNC
+				(p_smi130->dev_addr,
+				SMI130_USER_FIFO_MAG_ENABLE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+				if (com_rslt == SUCCESS) {
+					v_data_u8 =
+					SMI130_SET_BITSLICE(v_data_u8,
+					SMI130_USER_FIFO_MAG_ENABLE,
+					v_fifo_mag_u8);
+					com_rslt +=
+					p_smi130->SMI130_BUS_WRITE_FUNC
+					(p_smi130->dev_addr,
+					SMI130_USER_FIFO_MAG_ENABLE__REG,
+					&v_data_u8,
+					SMI130_GEN_READ_WRITE_DATA_LENGTH);
+				}
+			} else {
+			com_rslt = E_SMI130_OUT_OF_RANGE;
+			}
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to read stored
+ *	accel data in FIFO (all 3 axes) from the register 0x47 bit 6
+ *
+ *  @param v_fifo_accel_u8 : The value of fifo accel enble
+ *	value    | fifo accel
+ * ----------|-------------------
+ *  0x00     |  no accel data is stored
+ *  0x01     |  accel data is stored
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_fifo_accel_enable(
+u8 *v_fifo_accel_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the accel fifo enable*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_FIFO_ACCEL_ENABLE__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_fifo_accel_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_FIFO_ACCEL_ENABLE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set stored
+ *	accel data in FIFO (all 3 axes) from the register 0x47 bit 6
+ *
+ *  @param v_fifo_accel_u8 : The value of fifo accel enble
+ *	value    | fifo accel
+ * ----------|-------------------
+ *  0x00     |  no accel data is stored
+ *  0x01     |  accel data is stored
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_fifo_accel_enable(
+u8 v_fifo_accel_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_fifo_accel_u8 <= SMI130_MAX_VALUE_FIFO_ACCEL) {
+			/* write the fifo mag enables*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_FIFO_ACCEL_ENABLE__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_FIFO_ACCEL_ENABLE, v_fifo_accel_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_FIFO_ACCEL_ENABLE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to read stored
+ *	 gyro data in FIFO (all 3 axes) from the resister 0x47 bit 7
+ *
+ *
+ *  @param v_fifo_gyro_u8 : The value of fifo gyro enble
+ *	value    | fifo gyro
+ * ----------|-------------------
+ *  0x00     |  no gyro data is stored
+ *  0x01     |  gyro data is stored
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_fifo_gyro_enable(
+u8 *v_fifo_gyro_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read fifo gyro enable */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_FIFO_GYRO_ENABLE__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_fifo_gyro_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_FIFO_GYRO_ENABLE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set stored
+ *	gyro data in FIFO (all 3 axes) from the resister 0x47 bit 7
+ *
+ *
+ *  @param v_fifo_gyro_u8 : The value of fifo gyro enble
+ *	value    | fifo gyro
+ * ----------|-------------------
+ *  0x00     |  no gyro data is stored
+ *  0x01     |  gyro data is stored
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_fifo_gyro_enable(
+u8 v_fifo_gyro_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_fifo_gyro_u8 <= SMI130_MAX_VALUE_FIFO_GYRO) {
+			/* write fifo gyro enable*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_FIFO_GYRO_ENABLE__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_FIFO_GYRO_ENABLE, v_fifo_gyro_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_FIFO_GYRO_ENABLE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to read
+ *	I2C device address of auxiliary mag from the register 0x4B bit 1 to 7
+ *
+ *
+ *
+ *
+ *  @param v_i2c_device_addr_u8 : The value of mag I2C device address
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_i2c_device_addr(
+u8 *v_i2c_device_addr_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the mag I2C device address*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_I2C_DEVICE_ADDR__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_i2c_device_addr_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_I2C_DEVICE_ADDR);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set
+ *	I2C device address of auxiliary mag from the register 0x4B bit 1 to 7
+ *
+ *
+ *
+ *
+ *  @param v_i2c_device_addr_u8 : The value of mag I2C device address
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_i2c_device_addr(
+u8 v_i2c_device_addr_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* write the mag I2C device address*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_I2C_DEVICE_ADDR__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_I2C_DEVICE_ADDR,
+				v_i2c_device_addr_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_I2C_DEVICE_ADDR__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to read
+ *	Burst data length (1,2,6,8 byte) from the register 0x4C bit 0 to 1
+ *
+ *
+ *
+ *
+ *  @param v_mag_burst_u8 : The data of mag burst read lenth
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_mag_burst(
+u8 *v_mag_burst_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read mag burst mode length*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_MAG_BURST__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_mag_burst_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_MAG_BURST);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set
+ *	Burst data length (1,2,6,8 byte) from the register 0x4C bit 0 to 1
+ *
+ *
+ *
+ *
+ *  @param v_mag_burst_u8 : The data of mag burst read lenth
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_mag_burst(
+u8 v_mag_burst_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* write mag burst mode length*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_MAG_BURST__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 =
+				SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_MAG_BURST, v_mag_burst_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_MAG_BURST__REG, &v_data_u8,
+				SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to read
+ *	trigger-readout offset in units of 2.5 ms. If set to zero,
+ *	the offset is maximum, i.e. after readout a trigger
+ *	is issued immediately. from the register 0x4C bit 2 to 5
+ *
+ *
+ *
+ *
+ *  @param v_mag_offset_u8 : The value of mag offset
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_mag_offset(
+u8 *v_mag_offset_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_MAG_OFFSET__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_mag_offset_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_MAG_OFFSET);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set
+ *	trigger-readout offset in units of 2.5 ms. If set to zero,
+ *	the offset is maximum, i.e. after readout a trigger
+ *	is issued immediately. from the register 0x4C bit 2 to 5
+ *
+ *
+ *
+ *
+ *  @param v_mag_offset_u8 : The value of mag offset
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_mag_offset(
+u8 v_mag_offset_u8)
+{
+/* variable used for return the status of communication result*/
+SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+		com_rslt =
+		p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+		SMI130_USER_MAG_OFFSET__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 =
+			SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_MAG_OFFSET, v_mag_offset_u8);
+			com_rslt +=
+			p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->dev_addr,
+			SMI130_USER_MAG_OFFSET__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	}
+return com_rslt;
+}
+/*!
+ *	@brief This API is used to read
+ *	Enable register access on MAG_IF[2] or MAG_IF[3] writes.
+ *	This implies that the DATA registers are not updated with
+ *	magnetometer values. Accessing magnetometer requires
+ *	the magnetometer in normal mode in PMU_STATUS.
+ *	from the register 0x4C bit 7
+ *
+ *
+ *
+ *  @param v_mag_manual_u8 : The value of mag manual enable
+ *	value    | mag manual
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_mag_manual_enable(
+u8 *v_mag_manual_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read mag manual */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_MAG_MANUAL_ENABLE__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_mag_manual_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_MAG_MANUAL_ENABLE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set
+ *	Enable register access on MAG_IF[2] or MAG_IF[3] writes.
+ *	This implies that the DATA registers are not updated with
+ *	magnetometer values. Accessing magnetometer requires
+ *	the magnetometer in normal mode in PMU_STATUS.
+ *	from the register 0x4C bit 7
+ *
+ *
+ *
+ *  @param v_mag_manual_u8 : The value of mag manual enable
+ *	value    | mag manual
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_mag_manual_enable(
+u8 v_mag_manual_u8)
+{
+/* variable used for return the status of communication result*/
+SMI130_RETURN_FUNCTION_TYPE com_rslt = SMI130_INIT_VALUE;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+		/* write the mag manual*/
+		com_rslt =
+		p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+		SMI130_USER_MAG_MANUAL_ENABLE__REG, &v_data_u8,
+		SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		if (com_rslt == SUCCESS) {
+			/* set the bit of mag manual enable*/
+			v_data_u8 =
+			SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_MAG_MANUAL_ENABLE, v_mag_manual_u8);
+			com_rslt +=
+			p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->dev_addr,
+			SMI130_USER_MAG_MANUAL_ENABLE__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		if (com_rslt == SUCCESS)
+			p_smi130->mag_manual_enable = v_mag_manual_u8;
+		else
+			p_smi130->mag_manual_enable = E_SMI130_COMM_RES;
+	}
+return com_rslt;
+}
+/*!
+ *	@brief This API is used to read data
+ *	magnetometer address to read from the register 0x4D bit 0 to 7
+ *	@brief It used to provide mag read address of auxiliary mag
+ *
+ *
+ *
+ *
+ *  @param  v_mag_read_addr_u8 : The value of address need to be read
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_mag_read_addr(
+u8 *v_mag_read_addr_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the written address*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_READ_ADDR__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_mag_read_addr_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_READ_ADDR);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set
+ *	magnetometer write address from the register 0x4D bit 0 to 7
+ *	@brief mag write address writes the address of auxiliary mag to write
+ *
+ *
+ *
+ *  @param v_mag_read_addr_u8:
+ *	The data of auxiliary mag address to write data
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_set_mag_read_addr(
+u8 v_mag_read_addr_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* write the mag read address*/
+			com_rslt =
+			p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->dev_addr,
+			SMI130_USER_READ_ADDR__REG, &v_mag_read_addr_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to read
+ *	magnetometer write address from the register 0x4E bit 0 to 7
+ *	@brief mag write address writes the address of auxiliary mag to write
+ *
+ *
+ *
+ *  @param  v_mag_write_addr_u8:
+ *	The data of auxiliary mag address to write data
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_get_mag_write_addr(
+u8 *v_mag_write_addr_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the address of last written */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_WRITE_ADDR__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_mag_write_addr_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_WRITE_ADDR);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set
+ *	magnetometer write address from the register 0x4E bit 0 to 7
+ *	@brief mag write address writes the address of auxiliary mag to write
+ *
+ *
+ *
+ *  @param  v_mag_write_addr_u8:
+ *	The data of auxiliary mag address to write data
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_set_mag_write_addr(
+u8 v_mag_write_addr_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* write the data of mag address to write data */
+			com_rslt =
+			p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->dev_addr,
+			SMI130_USER_WRITE_ADDR__REG, &v_mag_write_addr_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to read magnetometer write data
+ *	form the resister 0x4F bit 0 to 7
+ *	@brief This writes the data will be wrote to mag
+ *
+ *
+ *
+ *  @param  v_mag_write_data_u8: The value of mag data
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_mag_write_data(
+u8 *v_mag_write_data_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_WRITE_DATA__REG, &v_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_mag_write_data_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_WRITE_DATA);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to set magnetometer write data
+ *	form the resister 0x4F bit 0 to 7
+ *	@brief This writes the data will be wrote to mag
+ *
+ *
+ *
+ *  @param  v_mag_write_data_u8: The value of mag data
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_mag_write_data(
+u8 v_mag_write_data_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt =
+			p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->dev_addr,
+			SMI130_USER_WRITE_DATA__REG, &v_mag_write_data_u8,
+			SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief  This API is used to read
+ *	interrupt enable from the register 0x50 bit 0 to 7
+ *
+ *
+ *
+ *
+ *	@param v_enable_u8 : Value to decided to select interrupt
+ *   v_enable_u8   |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_ANY_MOTION_X_ENABLE
+ *       1         | SMI130_ANY_MOTION_Y_ENABLE
+ *       2         | SMI130_ANY_MOTION_Z_ENABLE
+ *       3         | SMI130_DOUBLE_TAP_ENABLE
+ *       4         | SMI130_SINGLE_TAP_ENABLE
+ *       5         | SMI130_ORIENT_ENABLE
+ *       6         | SMI130_FLAT_ENABLE
+ *
+ *	@param v_intr_enable_zero_u8 : The interrupt enable value
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_enable_0(
+u8 v_enable_u8, u8 *v_intr_enable_zero_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		/* select interrupt to read*/
+		switch (v_enable_u8) {
+		case SMI130_ANY_MOTION_X_ENABLE:
+			/* read the any motion interrupt x data */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr,
+			SMI130_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_zero_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE);
+		break;
+		case SMI130_ANY_MOTION_Y_ENABLE:
+			/* read the any motion interrupt y data */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr,
+			SMI130_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_zero_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE);
+		break;
+		case SMI130_ANY_MOTION_Z_ENABLE:
+			/* read the any motion interrupt z data */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr,
+			SMI130_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_zero_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE);
+		break;
+		case SMI130_DOUBLE_TAP_ENABLE:
+			/* read the double tap interrupt data */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr,
+			SMI130_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_zero_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE);
+		break;
+		case SMI130_SINGLE_TAP_ENABLE:
+			/* read the single tap interrupt data */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr,
+			SMI130_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_zero_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE);
+		break;
+		case SMI130_ORIENT_ENABLE:
+			/* read the orient_mbl interrupt data */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_ENABLE_0_ORIENT_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_zero_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_ENABLE_0_ORIENT_ENABLE);
+		break;
+		case SMI130_FLAT_ENABLE:
+			/* read the flat interrupt data */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_ENABLE_0_FLAT_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_zero_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_ENABLE_0_FLAT_ENABLE);
+		break;
+		default:
+			com_rslt = E_SMI130_OUT_OF_RANGE;
+		break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief  This API is used to set
+ *	interrupt enable from the register 0x50 bit 0 to 7
+ *
+ *
+ *
+ *
+ *	@param v_enable_u8 : Value to decided to select interrupt
+ *   v_enable_u8   |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_ANY_MOTION_X_ENABLE
+ *       1         | SMI130_ANY_MOTION_Y_ENABLE
+ *       2         | SMI130_ANY_MOTION_Z_ENABLE
+ *       3         | SMI130_DOUBLE_TAP_ENABLE
+ *       4         | SMI130_SINGLE_TAP_ENABLE
+ *       5         | SMI130_ORIENT_ENABLE
+ *       6         | SMI130_FLAT_ENABLE
+ *
+ *	@param v_intr_enable_zero_u8 : The interrupt enable value
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_enable_0(
+u8 v_enable_u8, u8 v_intr_enable_zero_u8)
+{
+/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+	switch (v_enable_u8) {
+	case SMI130_ANY_MOTION_X_ENABLE:
+		/* write any motion x*/
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+		dev_addr, SMI130_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE,
+			v_intr_enable_zero_u8);
+			com_rslt +=
+			p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+			dev_addr,
+			SMI130_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	case SMI130_ANY_MOTION_Y_ENABLE:
+		/* write any motion y*/
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+		dev_addr, SMI130_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE,
+			v_intr_enable_zero_u8);
+			com_rslt +=
+			p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+			dev_addr,
+			SMI130_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	case SMI130_ANY_MOTION_Z_ENABLE:
+		/* write any motion z*/
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+		dev_addr, SMI130_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE,
+			v_intr_enable_zero_u8);
+			com_rslt +=
+			p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+			dev_addr,
+			SMI130_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	case SMI130_DOUBLE_TAP_ENABLE:
+		/* write double tap*/
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+		dev_addr, SMI130_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE,
+			v_intr_enable_zero_u8);
+			com_rslt +=
+			p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+			dev_addr,
+			SMI130_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	case SMI130_SINGLE_TAP_ENABLE:
+		/* write single tap */
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+		dev_addr, SMI130_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE,
+			v_intr_enable_zero_u8);
+			com_rslt +=
+			p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+			dev_addr,
+			SMI130_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	case SMI130_ORIENT_ENABLE:
+		/* write orient_mbl interrupt*/
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+		dev_addr, SMI130_USER_INTR_ENABLE_0_ORIENT_ENABLE__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_ENABLE_0_ORIENT_ENABLE,
+			v_intr_enable_zero_u8);
+			com_rslt +=
+			p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+			dev_addr,
+			SMI130_USER_INTR_ENABLE_0_ORIENT_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	case SMI130_FLAT_ENABLE:
+		/* write flat interrupt*/
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+		dev_addr, SMI130_USER_INTR_ENABLE_0_FLAT_ENABLE__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_ENABLE_0_FLAT_ENABLE,
+			v_intr_enable_zero_u8);
+			com_rslt +=
+			p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+			dev_addr,
+			SMI130_USER_INTR_ENABLE_0_FLAT_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	default:
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		break;
+	}
+}
+return com_rslt;
+}
+/*!
+ *	@brief  This API is used to read
+ *	interrupt enable byte1 from the register 0x51 bit 0 to 6
+ *	@brief It read the high_g_x,high_g_y,high_g_z,low_g_enable
+ *	data ready, fifo full and fifo water mark.
+ *
+ *
+ *
+ *  @param  v_enable_u8 :  The value of interrupt enable
+ *	@param v_enable_u8 : Value to decided to select interrupt
+ *   v_enable_u8   |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_HIGH_G_X_ENABLE
+ *       1         | SMI130_HIGH_G_Y_ENABLE
+ *       2         | SMI130_HIGH_G_Z_ENABLE
+ *       3         | SMI130_LOW_G_ENABLE
+ *       4         | SMI130_DATA_RDY_ENABLE
+ *       5         | SMI130_FIFO_FULL_ENABLE
+ *       6         | SMI130_FIFO_WM_ENABLE
+ *
+ *	@param v_intr_enable_1_u8 : The interrupt enable value
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_enable_1(
+u8 v_enable_u8, u8 *v_intr_enable_1_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		switch (v_enable_u8) {
+		case SMI130_HIGH_G_X_ENABLE:
+			/* read high_g_x interrupt*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr,
+			SMI130_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_1_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE);
+			break;
+		case SMI130_HIGH_G_Y_ENABLE:
+			/* read high_g_y interrupt*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr,
+			SMI130_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_1_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE);
+			break;
+		case SMI130_HIGH_G_Z_ENABLE:
+			/* read high_g_z interrupt*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr,
+			SMI130_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_1_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE);
+			break;
+		case SMI130_LOW_G_ENABLE:
+			/* read low_g interrupt */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_ENABLE_1_LOW_G_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_1_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_ENABLE_1_LOW_G_ENABLE);
+			break;
+		case SMI130_DATA_RDY_ENABLE:
+			/* read data ready interrupt */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr,
+			SMI130_USER_INTR_ENABLE_1_DATA_RDY_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_1_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_ENABLE_1_DATA_RDY_ENABLE);
+			break;
+		case SMI130_FIFO_FULL_ENABLE:
+			/* read fifo full interrupt */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr,
+			SMI130_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_1_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE);
+			break;
+		case SMI130_FIFO_WM_ENABLE:
+			/* read fifo water mark interrupt */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr,
+			SMI130_USER_INTR_ENABLE_1_FIFO_WM_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_1_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_ENABLE_1_FIFO_WM_ENABLE);
+			break;
+		default:
+			com_rslt = E_SMI130_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief  This API is used to set
+ *	interrupt enable byte1 from the register 0x51 bit 0 to 6
+ *	@brief It read the high_g_x,high_g_y,high_g_z,low_g_enable
+ *	data ready, fifo full and fifo water mark.
+ *
+ *
+ *
+ *  @param  v_enable_u8 :  The value of interrupt enable
+ *	@param v_enable_u8 : Value to decided to select interrupt
+ *   v_enable_u8   |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_HIGH_G_X_ENABLE
+ *       1         | SMI130_HIGH_G_Y_ENABLE
+ *       2         | SMI130_HIGH_G_Z_ENABLE
+ *       3         | SMI130_LOW_G_ENABLE
+ *       4         | SMI130_DATA_RDY_ENABLE
+ *       5         | SMI130_FIFO_FULL_ENABLE
+ *       6         | SMI130_FIFO_WM_ENABLE
+ *
+ *	@param v_intr_enable_1_u8 : The interrupt enable value
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_enable_1(
+u8 v_enable_u8, u8 v_intr_enable_1_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		switch (v_enable_u8) {
+		case SMI130_HIGH_G_X_ENABLE:
+			/* write high_g_x interrupt*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr,
+			SMI130_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE,
+				v_intr_enable_1_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+				dev_addr,
+				SMI130_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		break;
+		case SMI130_HIGH_G_Y_ENABLE:
+			/* write high_g_y interrupt*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr,
+			SMI130_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE,
+				v_intr_enable_1_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+				dev_addr,
+				SMI130_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		break;
+		case SMI130_HIGH_G_Z_ENABLE:
+			/* write high_g_z interrupt*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr,
+			SMI130_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE,
+				v_intr_enable_1_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+				dev_addr,
+				SMI130_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		break;
+		case SMI130_LOW_G_ENABLE:
+			/* write low_g interrupt*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr,
+			SMI130_USER_INTR_ENABLE_1_LOW_G_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR_ENABLE_1_LOW_G_ENABLE,
+				v_intr_enable_1_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+				dev_addr,
+				SMI130_USER_INTR_ENABLE_1_LOW_G_ENABLE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		break;
+		case SMI130_DATA_RDY_ENABLE:
+			/* write data ready interrupt*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr,
+			SMI130_USER_INTR_ENABLE_1_DATA_RDY_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR_ENABLE_1_DATA_RDY_ENABLE,
+				v_intr_enable_1_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+				dev_addr,
+				SMI130_USER_INTR_ENABLE_1_DATA_RDY_ENABLE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		break;
+		case SMI130_FIFO_FULL_ENABLE:
+			/* write fifo full interrupt*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr,
+			SMI130_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE,
+				v_intr_enable_1_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+				dev_addr,
+				SMI130_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		break;
+		case SMI130_FIFO_WM_ENABLE:
+			/* write fifo water mark interrupt*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_ENABLE_1_FIFO_WM_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR_ENABLE_1_FIFO_WM_ENABLE,
+				v_intr_enable_1_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+				dev_addr,
+				SMI130_USER_INTR_ENABLE_1_FIFO_WM_ENABLE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		break;
+		default:
+			com_rslt = E_SMI130_OUT_OF_RANGE;
+		break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief  This API is used to read
+ *	interrupt enable byte2 from the register bit 0x52 bit 0 to 3
+ *	@brief It reads no motion x,y and z
+ *
+ *
+ *
+ *	@param v_enable_u8: The value of interrupt enable
+ *   v_enable_u8   |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_NOMOTION_X_ENABLE
+ *       1         | SMI130_NOMOTION_Y_ENABLE
+ *       2         | SMI130_NOMOTION_Z_ENABLE
+ *
+ *	@param v_intr_enable_2_u8 : The interrupt enable value
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_enable_2(
+u8 v_enable_u8, u8 *v_intr_enable_2_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		switch (v_enable_u8) {
+		case SMI130_NOMOTION_X_ENABLE:
+			/* read no motion x */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr,
+			SMI130_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_2_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE);
+			break;
+		case SMI130_NOMOTION_Y_ENABLE:
+			/* read no motion y */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr,
+			SMI130_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_2_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE);
+			break;
+		case SMI130_NOMOTION_Z_ENABLE:
+			/* read no motion z */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr,
+			SMI130_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_enable_2_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE);
+			break;
+		default:
+			com_rslt = E_SMI130_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief  This API is used to set
+ *	interrupt enable byte2 from the register bit 0x52 bit 0 to 3
+ *	@brief It reads no motion x,y and z
+ *
+ *
+ *
+ *	@param v_enable_u8: The value of interrupt enable
+ *   v_enable_u8   |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_NOMOTION_X_ENABLE
+ *       1         | SMI130_NOMOTION_Y_ENABLE
+ *       2         | SMI130_NOMOTION_Z_ENABLE
+ *
+ *	@param v_intr_enable_2_u8 : The interrupt enable value
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_enable_2(
+u8 v_enable_u8, u8 v_intr_enable_2_u8)
+{
+/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+	switch (v_enable_u8) {
+	case SMI130_NOMOTION_X_ENABLE:
+		/* write no motion x */
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+		dev_addr,
+		SMI130_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE,
+			v_intr_enable_2_u8);
+			com_rslt +=
+			p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+			dev_addr,
+			SMI130_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	case SMI130_NOMOTION_Y_ENABLE:
+		/* write no motion y */
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+		dev_addr,
+		SMI130_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE,
+			v_intr_enable_2_u8);
+			com_rslt +=
+			p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+			dev_addr,
+			SMI130_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	case SMI130_NOMOTION_Z_ENABLE:
+		/* write no motion z */
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+		dev_addr,
+		SMI130_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE,
+			v_intr_enable_2_u8);
+			com_rslt +=
+			p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+			dev_addr,
+			SMI130_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	default:
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		break;
+	}
+}
+return com_rslt;
+}
+ /*!
+ *	@brief This API is used to read
+ *	interrupt enable step detector interrupt from
+ *	the register bit 0x52 bit 3
+ *
+ *
+ *
+ *
+ *	@param v_step_intr_u8 : The value of step detector interrupt enable
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_get_step_detector_enable(
+u8 *v_step_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the step detector interrupt*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr,
+			SMI130_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_step_intr_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API is used to set
+ *	interrupt enable step detector interrupt from
+ *	the register bit 0x52 bit 3
+ *
+ *
+ *
+ *
+ *	@param v_step_intr_u8 : The value of step detector interrupt enable
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_set_step_detector_enable(
+u8 v_step_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+		dev_addr,
+		SMI130_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE,
+			v_step_intr_u8);
+			com_rslt +=
+			p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+			dev_addr,
+			SMI130_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief  Configure trigger condition of interrupt1
+ *	and interrupt2 pin from the register 0x53
+ *	@brief interrupt1 - bit 0
+ *	@brief interrupt2 - bit 4
+ *
+ *  @param v_channel_u8: The value of edge trigger selection
+ *   v_channel_u8  |   Edge trigger
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_EDGE_CTRL
+ *       1         | SMI130_INTR2_EDGE_CTRL
+ *
+ *	@param v_intr_edge_ctrl_u8 : The value of edge trigger enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_EDGE
+ *  0x00     |  SMI130_LEVEL
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_edge_ctrl(
+u8 v_channel_u8, u8 *v_intr_edge_ctrl_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		case SMI130_INTR1_EDGE_CTRL:
+			/* read the edge trigger interrupt1*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR1_EDGE_CTRL__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_edge_ctrl_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR1_EDGE_CTRL);
+			break;
+		case SMI130_INTR2_EDGE_CTRL:
+			/* read the edge trigger interrupt2*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR2_EDGE_CTRL__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_edge_ctrl_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR2_EDGE_CTRL);
+			break;
+		default:
+			com_rslt = E_SMI130_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief  Configure trigger condition of interrupt1
+ *	and interrupt2 pin from the register 0x53
+ *	@brief interrupt1 - bit 0
+ *	@brief interrupt2 - bit 4
+ *
+ *  @param v_channel_u8: The value of edge trigger selection
+ *   v_channel_u8  |   Edge trigger
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_EDGE_CTRL
+ *       1         | SMI130_INTR2_EDGE_CTRL
+ *
+ *	@param v_intr_edge_ctrl_u8 : The value of edge trigger enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_EDGE
+ *  0x00     |  SMI130_LEVEL
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_edge_ctrl(
+u8 v_channel_u8, u8 v_intr_edge_ctrl_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		case SMI130_INTR1_EDGE_CTRL:
+			/* write the edge trigger interrupt1*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR1_EDGE_CTRL__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR1_EDGE_CTRL,
+				v_intr_edge_ctrl_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+				dev_addr, SMI130_USER_INTR1_EDGE_CTRL__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+			break;
+		case SMI130_INTR2_EDGE_CTRL:
+			/* write the edge trigger interrupt2*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR2_EDGE_CTRL__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR2_EDGE_CTRL,
+				v_intr_edge_ctrl_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+				dev_addr, SMI130_USER_INTR2_EDGE_CTRL__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+			break;
+		default:
+			com_rslt = E_SMI130_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief  API used for get the Configure level condition of interrupt1
+ *	and interrupt2 pin form the register 0x53
+ *	@brief interrupt1 - bit 1
+ *	@brief interrupt2 - bit 5
+ *
+ *  @param v_channel_u8: The value of level condition selection
+ *   v_channel_u8  |   level selection
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_LEVEL
+ *       1         | SMI130_INTR2_LEVEL
+ *
+ *	@param v_intr_level_u8 : The value of level of interrupt enable
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x01     |  SMI130_LEVEL_HIGH
+ *  0x00     |  SMI130_LEVEL_LOW
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_level(
+u8 v_channel_u8, u8 *v_intr_level_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		case SMI130_INTR1_LEVEL:
+			/* read the interrupt1 level*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR1_LEVEL__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_level_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR1_LEVEL);
+			break;
+		case SMI130_INTR2_LEVEL:
+			/* read the interrupt2 level*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR2_LEVEL__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_level_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR2_LEVEL);
+			break;
+		default:
+			com_rslt = E_SMI130_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief  API used for set the Configure level condition of interrupt1
+ *	and interrupt2 pin form the register 0x53
+ *	@brief interrupt1 - bit 1
+ *	@brief interrupt2 - bit 5
+ *
+ *  @param v_channel_u8: The value of level condition selection
+ *   v_channel_u8  |   level selection
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_LEVEL
+ *       1         | SMI130_INTR2_LEVEL
+ *
+ *	@param v_intr_level_u8 : The value of level of interrupt enable
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x01     |  SMI130_LEVEL_HIGH
+ *  0x00     |  SMI130_LEVEL_LOW
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_level(
+u8 v_channel_u8, u8 v_intr_level_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		case SMI130_INTR1_LEVEL:
+			/* write the interrupt1 level*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR1_LEVEL__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR1_LEVEL, v_intr_level_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+				dev_addr, SMI130_USER_INTR1_LEVEL__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+			break;
+		case SMI130_INTR2_LEVEL:
+			/* write the interrupt2 level*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR2_LEVEL__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR2_LEVEL, v_intr_level_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+				dev_addr, SMI130_USER_INTR2_LEVEL__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+			break;
+		default:
+			com_rslt = E_SMI130_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief  API used to get configured output enable of interrupt1
+ *	and interrupt2 from the register 0x53
+ *	@brief interrupt1 - bit 2
+ *	@brief interrupt2 - bit 6
+ *
+ *
+ *  @param v_channel_u8: The value of output type enable selection
+ *   v_channel_u8  |   level selection
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_OUTPUT_TYPE
+ *       1         | SMI130_INTR2_OUTPUT_TYPE
+ *
+ *	@param v_intr_output_type_u8 :
+ *	The value of output type of interrupt enable
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x01     |  SMI130_OPEN_DRAIN
+ *  0x00     |  SMI130_PUSH_PULL
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_output_type(
+u8 v_channel_u8, u8 *v_intr_output_type_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		case SMI130_INTR1_OUTPUT_TYPE:
+			/* read the output type of interrupt1*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR1_OUTPUT_TYPE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_output_type_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR1_OUTPUT_TYPE);
+			break;
+		case SMI130_INTR2_OUTPUT_TYPE:
+			/* read the output type of interrupt2*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR2_OUTPUT_TYPE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_output_type_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR2_OUTPUT_TYPE);
+			break;
+		default:
+			com_rslt = E_SMI130_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief  API used to set output enable of interrupt1
+ *	and interrupt2 from the register 0x53
+ *	@brief interrupt1 - bit 2
+ *	@brief interrupt2 - bit 6
+ *
+ *
+ *  @param v_channel_u8: The value of output type enable selection
+ *   v_channel_u8  |   level selection
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_OUTPUT_TYPE
+ *       1         | SMI130_INTR2_OUTPUT_TYPE
+ *
+ *	@param v_intr_output_type_u8 :
+ *	The value of output type of interrupt enable
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x01     |  SMI130_OPEN_DRAIN
+ *  0x00     |  SMI130_PUSH_PULL
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_output_type(
+u8 v_channel_u8, u8 v_intr_output_type_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		case SMI130_INTR1_OUTPUT_TYPE:
+			/* write the output type of interrupt1*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR1_OUTPUT_TYPE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR1_OUTPUT_TYPE,
+				v_intr_output_type_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+				dev_addr, SMI130_USER_INTR1_OUTPUT_TYPE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+			break;
+		case SMI130_INTR2_OUTPUT_TYPE:
+			/* write the output type of interrupt2*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR2_OUTPUT_TYPE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR2_OUTPUT_TYPE,
+				v_intr_output_type_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+				dev_addr, SMI130_USER_INTR2_OUTPUT_TYPE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+			break;
+		default:
+			com_rslt = E_SMI130_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+ /*!
+ *	@brief API used to get the Output enable for interrupt1
+ *	and interrupt1 pin from the register 0x53
+ *	@brief interrupt1 - bit 3
+ *	@brief interrupt2 - bit 7
+ *
+ *  @param v_channel_u8: The value of output enable selection
+ *   v_channel_u8  |   level selection
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_OUTPUT_TYPE
+ *       1         | SMI130_INTR2_OUTPUT_TYPE
+ *
+ *	@param v_output_enable_u8 :
+ *	The value of output enable of interrupt enable
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x01     |  SMI130_INPUT
+ *  0x00     |  SMI130_OUTPUT
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_output_enable(
+u8 v_channel_u8, u8 *v_output_enable_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		case SMI130_INTR1_OUTPUT_ENABLE:
+			/* read the output enable of interrupt1*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR1_OUTPUT_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_output_enable_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR1_OUTPUT_ENABLE);
+			break;
+		case SMI130_INTR2_OUTPUT_ENABLE:
+			/* read the output enable of interrupt2*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR2_OUTPUT_EN__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_output_enable_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR2_OUTPUT_EN);
+			break;
+		default:
+			com_rslt = E_SMI130_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+ /*!
+ *	@brief API used to set the Output enable for interrupt1
+ *	and interrupt1 pin from the register 0x53
+ *	@brief interrupt1 - bit 3
+ *	@brief interrupt2 - bit 7
+ *
+ *  @param v_channel_u8: The value of output enable selection
+ *   v_channel_u8  |   level selection
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_OUTPUT_TYPE
+ *       1         | SMI130_INTR2_OUTPUT_TYPE
+ *
+ *	@param v_output_enable_u8 :
+ *	The value of output enable of interrupt enable
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x01     |  SMI130_INPUT
+ *  0x00     |  SMI130_OUTPUT
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_output_enable(
+u8 v_channel_u8, u8 v_output_enable_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		case SMI130_INTR1_OUTPUT_ENABLE:
+			/* write the output enable of interrupt1*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR1_OUTPUT_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR1_OUTPUT_ENABLE,
+				v_output_enable_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+				dev_addr, SMI130_USER_INTR1_OUTPUT_ENABLE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		break;
+		case SMI130_INTR2_OUTPUT_ENABLE:
+			/* write the output enable of interrupt2*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR2_OUTPUT_EN__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR2_OUTPUT_EN,
+				v_output_enable_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+				dev_addr, SMI130_USER_INTR2_OUTPUT_EN__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		break;
+		default:
+			com_rslt = E_SMI130_OUT_OF_RANGE;
+		break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+*	@brief This API is used to get the latch duration
+*	from the register 0x54 bit 0 to 3
+*	@brief This latch selection is not applicable for data ready,
+*	orient_mblation and flat interrupts.
+*
+*
+*
+*  @param v_latch_intr_u8 : The value of latch duration
+*	Latch Duration                      |     value
+* --------------------------------------|------------------
+*    SMI130_LATCH_DUR_NONE              |      0x00
+*    SMI130_LATCH_DUR_312_5_MICRO_SEC   |      0x01
+*    SMI130_LATCH_DUR_625_MICRO_SEC     |      0x02
+*    SMI130_LATCH_DUR_1_25_MILLI_SEC    |      0x03
+*    SMI130_LATCH_DUR_2_5_MILLI_SEC     |      0x04
+*    SMI130_LATCH_DUR_5_MILLI_SEC       |      0x05
+*    SMI130_LATCH_DUR_10_MILLI_SEC      |      0x06
+*    SMI130_LATCH_DUR_20_MILLI_SEC      |      0x07
+*    SMI130_LATCH_DUR_40_MILLI_SEC      |      0x08
+*    SMI130_LATCH_DUR_80_MILLI_SEC      |      0x09
+*    SMI130_LATCH_DUR_160_MILLI_SEC     |      0x0A
+*    SMI130_LATCH_DUR_320_MILLI_SEC     |      0x0B
+*    SMI130_LATCH_DUR_640_MILLI_SEC     |      0x0C
+*    SMI130_LATCH_DUR_1_28_SEC          |      0x0D
+*    SMI130_LATCH_DUR_2_56_SEC          |      0x0E
+*    SMI130_LATCHED                     |      0x0F
+*
+*
+*
+*	@return results of bus communication function
+*	@retval 0 -> Success
+*	@retval -1 -> Error
+*
+*
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_latch_intr(
+u8 *v_latch_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the latch duration value */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_LATCH__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_latch_intr_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_LATCH);
+		}
+	return com_rslt;
+}
+/*!
+*	@brief This API is used to set the latch duration
+*	from the register 0x54 bit 0 to 3
+*	@brief This latch selection is not applicable for data ready,
+*	orient_mblation and flat interrupts.
+*
+*
+*
+*  @param v_latch_intr_u8 : The value of latch duration
+*	Latch Duration                      |     value
+* --------------------------------------|------------------
+*    SMI130_LATCH_DUR_NONE              |      0x00
+*    SMI130_LATCH_DUR_312_5_MICRO_SEC   |      0x01
+*    SMI130_LATCH_DUR_625_MICRO_SEC     |      0x02
+*    SMI130_LATCH_DUR_1_25_MILLI_SEC    |      0x03
+*    SMI130_LATCH_DUR_2_5_MILLI_SEC     |      0x04
+*    SMI130_LATCH_DUR_5_MILLI_SEC       |      0x05
+*    SMI130_LATCH_DUR_10_MILLI_SEC      |      0x06
+*    SMI130_LATCH_DUR_20_MILLI_SEC      |      0x07
+*    SMI130_LATCH_DUR_40_MILLI_SEC      |      0x08
+*    SMI130_LATCH_DUR_80_MILLI_SEC      |      0x09
+*    SMI130_LATCH_DUR_160_MILLI_SEC     |      0x0A
+*    SMI130_LATCH_DUR_320_MILLI_SEC     |      0x0B
+*    SMI130_LATCH_DUR_640_MILLI_SEC     |      0x0C
+*    SMI130_LATCH_DUR_1_28_SEC          |      0x0D
+*    SMI130_LATCH_DUR_2_56_SEC          |      0x0E
+*    SMI130_LATCHED                     |      0x0F
+*
+*
+*
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+*
+*
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_latch_intr(u8 v_latch_intr_u8)
+{
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_latch_intr_u8 <= SMI130_MAX_LATCH_INTR) {
+			/* write the latch duration value */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_LATCH__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR_LATCH, v_latch_intr_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+				dev_addr, SMI130_USER_INTR_LATCH__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief API used to get input enable for interrupt1
+ *	and interrupt2 pin from the register 0x54
+ *	@brief interrupt1 - bit 4
+ *	@brief interrupt2 - bit 5
+ *
+ *  @param v_channel_u8: The value of input enable selection
+ *   v_channel_u8  |   input selection
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_INPUT_ENABLE
+ *       1         | SMI130_INTR2_INPUT_ENABLE
+ *
+ *	@param v_input_en_u8 :
+ *	The value of input enable of interrupt enable
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x01     |  SMI130_INPUT
+ *  0x00     |  SMI130_OUTPUT
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_input_enable(
+u8 v_channel_u8, u8 *v_input_en_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		/* read input enable of interrup1 and interrupt2*/
+		case SMI130_INTR1_INPUT_ENABLE:
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR1_INPUT_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_input_en_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR1_INPUT_ENABLE);
+			break;
+		case SMI130_INTR2_INPUT_ENABLE:
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR2_INPUT_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_input_en_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR2_INPUT_ENABLE);
+			break;
+		default:
+			com_rslt = E_SMI130_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief API used to set input enable for interrupt1
+ *	and interrupt2 pin from the register 0x54
+ *	@brief interrupt1 - bit 4
+ *	@brief interrupt2 - bit 5
+ *
+ *  @param v_channel_u8: The value of input enable selection
+ *   v_channel_u8  |   input selection
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_INPUT_ENABLE
+ *       1         | SMI130_INTR2_INPUT_ENABLE
+ *
+ *	@param v_input_en_u8 :
+ *	The value of input enable of interrupt enable
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x01     |  SMI130_INPUT
+ *  0x00     |  SMI130_OUTPUT
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_input_enable(
+u8 v_channel_u8, u8 v_input_en_u8)
+{
+/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+	switch (v_channel_u8) {
+	/* write input enable of interrup1 and interrupt2*/
+	case SMI130_INTR1_INPUT_ENABLE:
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+		dev_addr, SMI130_USER_INTR1_INPUT_ENABLE__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR1_INPUT_ENABLE, v_input_en_u8);
+			com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR1_INPUT_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	break;
+	case SMI130_INTR2_INPUT_ENABLE:
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+		dev_addr, SMI130_USER_INTR2_INPUT_ENABLE__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR2_INPUT_ENABLE, v_input_en_u8);
+			com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR2_INPUT_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	break;
+	default:
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+	break;
+	}
+}
+return com_rslt;
+}
+ /*!
+ *	@brief reads the Low g interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 0 in the register 0x55
+ *	@brief interrupt2 bit 0 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of low_g selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_LOW_G
+ *       1         | SMI130_INTR2_MAP_LOW_G
+ *
+ *	@param v_intr_low_g_u8 : The value of low_g enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_low_g(
+u8 v_channel_u8, u8 *v_intr_low_g_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		/* read the low_g interrupt */
+		case SMI130_INTR1_MAP_LOW_G:
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_0_INTR1_LOW_G__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_low_g_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_0_INTR1_LOW_G);
+			break;
+		case SMI130_INTR2_MAP_LOW_G:
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_2_INTR2_LOW_G__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_low_g_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_2_INTR2_LOW_G);
+			break;
+		default:
+			com_rslt = E_SMI130_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+ /*!
+ *	@brief set the Low g interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 0 in the register 0x55
+ *	@brief interrupt2 bit 0 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of low_g selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_LOW_G
+ *       1         | SMI130_INTR2_MAP_LOW_G
+ *
+ *	@param v_intr_low_g_u8 : The value of low_g enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_low_g(
+u8 v_channel_u8, u8 v_intr_low_g_u8)
+{
+/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+u8 v_step_cnt_stat_u8 = SMI130_INIT_VALUE;
+u8 v_step_det_stat_u8 = SMI130_INIT_VALUE;
+
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+	/* check the step detector interrupt enable status*/
+	com_rslt = smi130_get_step_detector_enable(&v_step_det_stat_u8);
+	/* disable the step detector interrupt */
+	if (v_step_det_stat_u8 != SMI130_INIT_VALUE)
+		com_rslt += smi130_set_step_detector_enable(SMI130_INIT_VALUE);
+	/* check the step counter interrupt enable status*/
+	com_rslt += smi130_get_step_counter_enable(&v_step_cnt_stat_u8);
+	/* disable the step counter interrupt */
+	if (v_step_cnt_stat_u8 != SMI130_INIT_VALUE)
+			com_rslt += smi130_set_step_counter_enable(
+			SMI130_INIT_VALUE);
+	switch (v_channel_u8) {
+	/* write the low_g interrupt*/
+	case SMI130_INTR1_MAP_LOW_G:
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+		dev_addr, SMI130_USER_INTR_MAP_0_INTR1_LOW_G__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_0_INTR1_LOW_G, v_intr_low_g_u8);
+			com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_0_INTR1_LOW_G__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	case SMI130_INTR2_MAP_LOW_G:
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+		dev_addr, SMI130_USER_INTR_MAP_2_INTR2_LOW_G__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_2_INTR2_LOW_G, v_intr_low_g_u8);
+			com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_2_INTR2_LOW_G__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	default:
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		break;
+	}
+}
+return com_rslt;
+}
+/*!
+ *	@brief Reads the HIGH g interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 1 in the register 0x55
+ *	@brief interrupt2 bit 1 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of high_g selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_HIGH_G
+ *       1         | SMI130_INTR2_MAP_HIGH_G
+ *
+ *	@param v_intr_high_g_u8 : The value of high_g enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_high_g(
+u8 v_channel_u8, u8 *v_intr_high_g_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		/* read the high_g interrupt*/
+		switch (v_channel_u8) {
+		case SMI130_INTR1_MAP_HIGH_G:
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_0_INTR1_HIGH_G__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_high_g_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_0_INTR1_HIGH_G);
+		break;
+		case SMI130_INTR2_MAP_HIGH_G:
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_2_INTR2_HIGH_G__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_high_g_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_2_INTR2_HIGH_G);
+		break;
+		default:
+			com_rslt = E_SMI130_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief Write the HIGH g interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 1 in the register 0x55
+ *	@brief interrupt2 bit 1 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of high_g selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_HIGH_G
+ *       1         | SMI130_INTR2_MAP_HIGH_G
+ *
+ *	@param v_intr_high_g_u8 : The value of high_g enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_high_g(
+u8 v_channel_u8, u8 v_intr_high_g_u8)
+{
+/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+	switch (v_channel_u8) {
+	/* write the high_g interrupt*/
+	case SMI130_INTR1_MAP_HIGH_G:
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+		dev_addr, SMI130_USER_INTR_MAP_0_INTR1_HIGH_G__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_0_INTR1_HIGH_G, v_intr_high_g_u8);
+			com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_0_INTR1_HIGH_G__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	break;
+	case SMI130_INTR2_MAP_HIGH_G:
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+		dev_addr, SMI130_USER_INTR_MAP_2_INTR2_HIGH_G__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_2_INTR2_HIGH_G, v_intr_high_g_u8);
+			com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_2_INTR2_HIGH_G__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	break;
+	default:
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+	break;
+	}
+}
+return com_rslt;
+}
+/*!
+ *	@brief Reads the Any motion interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 2 in the register 0x55
+ *	@brief interrupt2 bit 2 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of any motion selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_ANY_MOTION
+ *       1         | SMI130_INTR2_MAP_ANY_MOTION
+ *
+ *	@param v_intr_any_motion_u8 : The value of any motion enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_any_motion(
+u8 v_channel_u8, u8 *v_intr_any_motion_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		/* read the any motion interrupt */
+		case SMI130_INTR1_MAP_ANY_MOTION:
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_0_INTR1_ANY_MOTION__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_any_motion_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_0_INTR1_ANY_MOTION);
+		break;
+		case SMI130_INTR2_MAP_ANY_MOTION:
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_2_INTR2_ANY_MOTION__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_any_motion_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_2_INTR2_ANY_MOTION);
+		break;
+		default:
+			com_rslt = E_SMI130_OUT_OF_RANGE;
+		break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief Write the Any motion interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 2 in the register 0x55
+ *	@brief interrupt2 bit 2 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of any motion selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_ANY_MOTION
+ *       1         | SMI130_INTR2_MAP_ANY_MOTION
+ *
+ *	@param v_intr_any_motion_u8 : The value of any motion enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_any_motion(
+u8 v_channel_u8, u8 v_intr_any_motion_u8)
+{
+/* variable used for return the status of communication result*/
+SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+u8 sig_mot_stat = SMI130_INIT_VALUE;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+	/* read the status of significant motion interrupt */
+	com_rslt = smi130_get_intr_significant_motion_select(&sig_mot_stat);
+	/* disable the significant motion interrupt */
+	if (sig_mot_stat != SMI130_INIT_VALUE)
+		com_rslt += smi130_set_intr_significant_motion_select(
+		SMI130_INIT_VALUE);
+	switch (v_channel_u8) {
+	/* write the any motion interrupt */
+	case SMI130_INTR1_MAP_ANY_MOTION:
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+		dev_addr, SMI130_USER_INTR_MAP_0_INTR1_ANY_MOTION__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_0_INTR1_ANY_MOTION,
+			v_intr_any_motion_u8);
+			com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_0_INTR1_ANY_MOTION__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	break;
+	case SMI130_INTR2_MAP_ANY_MOTION:
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+		dev_addr, SMI130_USER_INTR_MAP_2_INTR2_ANY_MOTION__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_2_INTR2_ANY_MOTION,
+			v_intr_any_motion_u8);
+			com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_2_INTR2_ANY_MOTION__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	break;
+	default:
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+	break;
+	}
+}
+return com_rslt;
+}
+/*!
+ *	@brief Reads the No motion interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 3 in the register 0x55
+ *	@brief interrupt2 bit 3 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of no motion selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_NOMO
+ *       1         | SMI130_INTR2_MAP_NOMO
+ *
+ *	@param v_intr_nomotion_u8 : The value of no motion enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_nomotion(
+u8 v_channel_u8, u8 *v_intr_nomotion_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		/* read the no motion interrupt*/
+		case SMI130_INTR1_MAP_NOMO:
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_0_INTR1_NOMOTION__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_nomotion_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_0_INTR1_NOMOTION);
+			break;
+		case SMI130_INTR2_MAP_NOMO:
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_2_INTR2_NOMOTION__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_nomotion_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_2_INTR2_NOMOTION);
+			break;
+		default:
+			com_rslt = E_SMI130_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief Write the No motion interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 3 in the register 0x55
+ *	@brief interrupt2 bit 3 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of no motion selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_NOMO
+ *       1         | SMI130_INTR2_MAP_NOMO
+ *
+ *	@param v_intr_nomotion_u8 : The value of no motion enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_nomotion(
+u8 v_channel_u8, u8 v_intr_nomotion_u8)
+{
+/* variable used for return the status of communication result*/
+SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+	switch (v_channel_u8) {
+	/* write the no motion interrupt*/
+	case SMI130_INTR1_MAP_NOMO:
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+		dev_addr, SMI130_USER_INTR_MAP_0_INTR1_NOMOTION__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_0_INTR1_NOMOTION,
+			v_intr_nomotion_u8);
+			com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_0_INTR1_NOMOTION__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	case SMI130_INTR2_MAP_NOMO:
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+		dev_addr, SMI130_USER_INTR_MAP_2_INTR2_NOMOTION__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_2_INTR2_NOMOTION,
+			v_intr_nomotion_u8);
+			com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_2_INTR2_NOMOTION__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	default:
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		break;
+	}
+}
+return com_rslt;
+}
+/*!
+ *	@brief Reads the Double Tap interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 4 in the register 0x55
+ *	@brief interrupt2 bit 4 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of double tap interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_DOUBLE_TAP
+ *       1         | SMI130_INTR2_MAP_DOUBLE_TAP
+ *
+ *	@param v_intr_double_tap_u8 : The value of double tap enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_double_tap(
+u8 v_channel_u8, u8 *v_intr_double_tap_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		case SMI130_INTR1_MAP_DOUBLE_TAP:
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_0_INTR1_DOUBLE_TAP__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_double_tap_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_0_INTR1_DOUBLE_TAP);
+			break;
+		case SMI130_INTR2_MAP_DOUBLE_TAP:
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_2_INTR2_DOUBLE_TAP__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_double_tap_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_2_INTR2_DOUBLE_TAP);
+			break;
+		default:
+			com_rslt = E_SMI130_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief Write the Double Tap interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 4 in the register 0x55
+ *	@brief interrupt2 bit 4 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of double tap interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_DOUBLE_TAP
+ *       1         | SMI130_INTR2_MAP_DOUBLE_TAP
+ *
+ *	@param v_intr_double_tap_u8 : The value of double tap enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_double_tap(
+u8 v_channel_u8, u8 v_intr_double_tap_u8)
+{
+/* variable used for return the status of communication result*/
+SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+	switch (v_channel_u8) {
+	/* set the double tap interrupt */
+	case SMI130_INTR1_MAP_DOUBLE_TAP:
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+		dev_addr, SMI130_USER_INTR_MAP_0_INTR1_DOUBLE_TAP__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_0_INTR1_DOUBLE_TAP,
+			v_intr_double_tap_u8);
+			com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_0_INTR1_DOUBLE_TAP__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	case SMI130_INTR2_MAP_DOUBLE_TAP:
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+		dev_addr, SMI130_USER_INTR_MAP_2_INTR2_DOUBLE_TAP__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_2_INTR2_DOUBLE_TAP,
+			v_intr_double_tap_u8);
+			com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_2_INTR2_DOUBLE_TAP__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	default:
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		break;
+	}
+}
+return com_rslt;
+}
+/*!
+ *	@brief Reads the Single Tap interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 5 in the register 0x55
+ *	@brief interrupt2 bit 5 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of single tap interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_SINGLE_TAP
+ *       1         | SMI130_INTR2_MAP_SINGLE_TAP
+ *
+ *	@param v_intr_single_tap_u8 : The value of single tap  enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_single_tap(
+u8 v_channel_u8, u8 *v_intr_single_tap_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		/* reads the single tap interrupt*/
+		case SMI130_INTR1_MAP_SINGLE_TAP:
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_0_INTR1_SINGLE_TAP__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_single_tap_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_0_INTR1_SINGLE_TAP);
+			break;
+		case SMI130_INTR2_MAP_SINGLE_TAP:
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_2_INTR2_SINGLE_TAP__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_single_tap_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_2_INTR2_SINGLE_TAP);
+			break;
+		default:
+			com_rslt = E_SMI130_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief Write the Single Tap interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 5 in the register 0x55
+ *	@brief interrupt2 bit 5 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of single tap interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_SINGLE_TAP
+ *       1         | SMI130_INTR2_MAP_SINGLE_TAP
+ *
+ *	@param v_intr_single_tap_u8 : The value of single tap  enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_single_tap(
+u8 v_channel_u8, u8 v_intr_single_tap_u8)
+{
+/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+	switch (v_channel_u8) {
+	/* write the single tap interrupt */
+	case SMI130_INTR1_MAP_SINGLE_TAP:
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+		dev_addr, SMI130_USER_INTR_MAP_0_INTR1_SINGLE_TAP__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_0_INTR1_SINGLE_TAP,
+			v_intr_single_tap_u8);
+			com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_0_INTR1_SINGLE_TAP__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	case SMI130_INTR2_MAP_SINGLE_TAP:
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+		dev_addr, SMI130_USER_INTR_MAP_2_INTR2_SINGLE_TAP__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_2_INTR2_SINGLE_TAP,
+			v_intr_single_tap_u8);
+			com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_2_INTR2_SINGLE_TAP__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	default:
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		break;
+	}
+}
+return com_rslt;
+}
+/*!
+ *	@brief Reads the Orient interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 6 in the register 0x55
+ *	@brief interrupt2 bit 6 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of orient_mbl interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_ORIENT
+ *       1         | SMI130_INTR2_MAP_ORIENT
+ *
+ *	@param v_intr_orient_mbl_u8 : The value of orient_mbl enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_orient_mbl(
+u8 v_channel_u8, u8 *v_intr_orient_mbl_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		/* read the orient_mblation interrupt*/
+		case SMI130_INTR1_MAP_ORIENT:
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_0_INTR1_ORIENT__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_orient_mbl_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_0_INTR1_ORIENT);
+			break;
+		case SMI130_INTR2_MAP_ORIENT:
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_2_INTR2_ORIENT__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_orient_mbl_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_2_INTR2_ORIENT);
+			break;
+		default:
+			com_rslt = E_SMI130_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief Write the Orient interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 6 in the register 0x55
+ *	@brief interrupt2 bit 6 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of orient_mbl interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_ORIENT
+ *       1         | SMI130_INTR2_MAP_ORIENT
+ *
+ *	@param v_intr_orient_mbl_u8 : The value of orient_mbl enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_orient_mbl(
+u8 v_channel_u8, u8 v_intr_orient_mbl_u8)
+{
+/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+	switch (v_channel_u8) {
+	/* write the orient_mblation interrupt*/
+	case SMI130_INTR1_MAP_ORIENT:
+		com_rslt =
+		p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+		dev_addr, SMI130_USER_INTR_MAP_0_INTR1_ORIENT__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_0_INTR1_ORIENT, v_intr_orient_mbl_u8);
+			com_rslt +=
+			p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_0_INTR1_ORIENT__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	case SMI130_INTR2_MAP_ORIENT:
+		com_rslt =
+		p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+		dev_addr, SMI130_USER_INTR_MAP_2_INTR2_ORIENT__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 =
+			SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_2_INTR2_ORIENT, v_intr_orient_mbl_u8);
+			com_rslt +=
+			p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_2_INTR2_ORIENT__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+		break;
+	default:
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		break;
+	}
+}
+return com_rslt;
+}
+ /*!
+ *	@brief Reads the Flat interrupt
+ *	mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 7 in the register 0x55
+ *	@brief interrupt2 bit 7 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of flat interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_FLAT
+ *       1         | SMI130_INTR2_MAP_FLAT
+ *
+ *	@param v_intr_flat_u8 : The value of flat enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_flat(
+u8 v_channel_u8, u8 *v_intr_flat_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		/* read the flat interrupt*/
+		case SMI130_INTR1_MAP_FLAT:
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_0_INTR1_FLAT__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_flat_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_0_INTR1_FLAT);
+			break;
+		case SMI130_INTR2_MAP_FLAT:
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_2_INTR2_FLAT__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_flat_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_2_INTR2_FLAT);
+			break;
+		default:
+			com_rslt = E_SMI130_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+ /*!
+ *	@brief Write the Flat interrupt
+ *	mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 7 in the register 0x55
+ *	@brief interrupt2 bit 7 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of flat interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_FLAT
+ *       1         | SMI130_INTR2_MAP_FLAT
+ *
+ *	@param v_intr_flat_u8 : The value of flat enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_flat(
+u8 v_channel_u8, u8 v_intr_flat_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		/* write the flat interrupt */
+		case SMI130_INTR1_MAP_FLAT:
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_0_INTR1_FLAT__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 =
+				SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR_MAP_0_INTR1_FLAT,
+				v_intr_flat_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+				dev_addr,
+				SMI130_USER_INTR_MAP_0_INTR1_FLAT__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+			break;
+		case SMI130_INTR2_MAP_FLAT:
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_2_INTR2_FLAT__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR_MAP_2_INTR2_FLAT,
+				v_intr_flat_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+				dev_addr,
+				SMI130_USER_INTR_MAP_2_INTR2_FLAT__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+			break;
+		default:
+			com_rslt = E_SMI130_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief Reads PMU trigger interrupt mapped to interrupt1
+ *	and interrupt2 form the register 0x56 bit 0 and 4
+ *	@brief interrupt1 bit 0 in the register 0x56
+ *	@brief interrupt2 bit 4 in the register 0x56
+ *
+ *
+ *	@param v_channel_u8: The value of pmu trigger selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_PMUTRIG
+ *       1         | SMI130_INTR2_MAP_PMUTRIG
+ *
+ *	@param v_intr_pmu_trig_u8 : The value of pmu trigger enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_pmu_trig(
+u8 v_channel_u8, u8 *v_intr_pmu_trig_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		/* read the pmu trigger interrupt*/
+		case SMI130_INTR1_MAP_PMUTRIG:
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_1_INTR1_PMU_TRIG__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_pmu_trig_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_1_INTR1_PMU_TRIG);
+			break;
+		case SMI130_INTR2_MAP_PMUTRIG:
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_1_INTR2_PMU_TRIG__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_pmu_trig_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_1_INTR2_PMU_TRIG);
+			break;
+		default:
+			com_rslt = E_SMI130_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief Write PMU trigger interrupt mapped to interrupt1
+ *	and interrupt2 form the register 0x56 bit 0 and 4
+ *	@brief interrupt1 bit 0 in the register 0x56
+ *	@brief interrupt2 bit 4 in the register 0x56
+ *
+ *
+ *	@param v_channel_u8: The value of pmu trigger selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_PMUTRIG
+ *       1         | SMI130_INTR2_MAP_PMUTRIG
+ *
+ *	@param v_intr_pmu_trig_u8 : The value of pmu trigger enable
+ *	value    | trigger enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_pmu_trig(
+u8 v_channel_u8, u8 v_intr_pmu_trig_u8)
+{
+/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+	switch (v_channel_u8) {
+	/* write the pmu trigger interrupt */
+	case SMI130_INTR1_MAP_PMUTRIG:
+		com_rslt =
+		p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+		dev_addr, SMI130_USER_INTR_MAP_1_INTR1_PMU_TRIG__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 =
+			SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_1_INTR1_PMU_TRIG,
+			v_intr_pmu_trig_u8);
+			com_rslt +=
+			p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_1_INTR1_PMU_TRIG__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	break;
+	case SMI130_INTR2_MAP_PMUTRIG:
+		com_rslt =
+		p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+		dev_addr, SMI130_USER_INTR_MAP_1_INTR2_PMU_TRIG__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 =
+			SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_1_INTR2_PMU_TRIG,
+			v_intr_pmu_trig_u8);
+			com_rslt +=
+			p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_1_INTR2_PMU_TRIG__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	break;
+	default:
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+	break;
+	}
+}
+return com_rslt;
+}
+/*!
+ *	@brief Reads FIFO Full interrupt mapped to interrupt1
+ *	and interrupt2 form the register 0x56 bit 5 and 1
+ *	@brief interrupt1 bit 5 in the register 0x56
+ *	@brief interrupt2 bit 1 in the register 0x56
+ *
+ *
+ *	@param v_channel_u8: The value of fifo full interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_FIFO_FULL
+ *       1         | SMI130_INTR2_MAP_FIFO_FULL
+ *
+ *	@param v_intr_fifo_full_u8 : The value of fifo full interrupt enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_fifo_full(
+u8 v_channel_u8, u8 *v_intr_fifo_full_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		/* read the fifo full interrupt */
+		case SMI130_INTR1_MAP_FIFO_FULL:
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_1_INTR1_FIFO_FULL__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_fifo_full_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_1_INTR1_FIFO_FULL);
+		break;
+		case SMI130_INTR2_MAP_FIFO_FULL:
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_1_INTR2_FIFO_FULL__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_fifo_full_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_1_INTR2_FIFO_FULL);
+		break;
+		default:
+			com_rslt = E_SMI130_OUT_OF_RANGE;
+		break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief Write FIFO Full interrupt mapped to interrupt1
+ *	and interrupt2 form the register 0x56 bit 5 and 1
+ *	@brief interrupt1 bit 5 in the register 0x56
+ *	@brief interrupt2 bit 1 in the register 0x56
+ *
+ *
+ *	@param v_channel_u8: The value of fifo full interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_FIFO_FULL
+ *       1         | SMI130_INTR2_MAP_FIFO_FULL
+ *
+ *	@param v_intr_fifo_full_u8 : The value of fifo full interrupt enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_fifo_full(
+u8 v_channel_u8, u8 v_intr_fifo_full_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		/* write the fifo full interrupt */
+		case SMI130_INTR1_MAP_FIFO_FULL:
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_1_INTR1_FIFO_FULL__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 =
+				SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR_MAP_1_INTR1_FIFO_FULL,
+				v_intr_fifo_full_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+				dev_addr,
+				SMI130_USER_INTR_MAP_1_INTR1_FIFO_FULL__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		break;
+		case SMI130_INTR2_MAP_FIFO_FULL:
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_1_INTR2_FIFO_FULL__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 =
+				SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR_MAP_1_INTR2_FIFO_FULL,
+				v_intr_fifo_full_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+				dev_addr,
+				SMI130_USER_INTR_MAP_1_INTR2_FIFO_FULL__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		break;
+		default:
+			com_rslt = E_SMI130_OUT_OF_RANGE;
+		break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief Reads FIFO Watermark interrupt mapped to interrupt1
+ *	and interrupt2 form the register 0x56 bit 6 and 2
+ *	@brief interrupt1 bit 6 in the register 0x56
+ *	@brief interrupt2 bit 2 in the register 0x56
+ *
+ *
+ *	@param v_channel_u8: The value of fifo Watermark interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_FIFO_WM
+ *       1         | SMI130_INTR2_MAP_FIFO_WM
+ *
+ *	@param v_intr_fifo_wm_u8 : The value of fifo Watermark interrupt enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_fifo_wm(
+u8 v_channel_u8, u8 *v_intr_fifo_wm_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		/* read the fifo water mark interrupt */
+		case SMI130_INTR1_MAP_FIFO_WM:
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_1_INTR1_FIFO_WM__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_fifo_wm_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_1_INTR1_FIFO_WM);
+			break;
+		case SMI130_INTR2_MAP_FIFO_WM:
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_1_INTR2_FIFO_WM__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_fifo_wm_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_1_INTR2_FIFO_WM);
+			break;
+		default:
+			com_rslt = E_SMI130_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief Write FIFO Watermark interrupt mapped to interrupt1
+ *	and interrupt2 form the register 0x56 bit 6 and 2
+ *	@brief interrupt1 bit 6 in the register 0x56
+ *	@brief interrupt2 bit 2 in the register 0x56
+ *
+ *
+ *	@param v_channel_u8: The value of fifo Watermark interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_FIFO_WM
+ *       1         | SMI130_INTR2_MAP_FIFO_WM
+ *
+ *	@param v_intr_fifo_wm_u8 : The value of fifo Watermark interrupt enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_fifo_wm(
+u8 v_channel_u8, u8 v_intr_fifo_wm_u8)
+{
+/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		/* write the fifo water mark interrupt */
+		case SMI130_INTR1_MAP_FIFO_WM:
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_1_INTR1_FIFO_WM__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR_MAP_1_INTR1_FIFO_WM,
+				v_intr_fifo_wm_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+				dev_addr,
+				SMI130_USER_INTR_MAP_1_INTR1_FIFO_WM__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+			break;
+		case SMI130_INTR2_MAP_FIFO_WM:
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_1_INTR2_FIFO_WM__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR_MAP_1_INTR2_FIFO_WM,
+				v_intr_fifo_wm_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+				dev_addr,
+				SMI130_USER_INTR_MAP_1_INTR2_FIFO_WM__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+			break;
+		default:
+			com_rslt = E_SMI130_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief Reads Data Ready interrupt mapped to interrupt1
+ *	and interrupt2 form the register 0x56
+ *	@brief interrupt1 bit 7 in the register 0x56
+ *	@brief interrupt2 bit 3 in the register 0x56
+ *
+ *
+ *	@param v_channel_u8: The value of data ready interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_DATA_RDY
+ *       1         | SMI130_INTR2_MAP_DATA_RDY
+ *
+ *	@param v_intr_data_rdy_u8 : The value of data ready interrupt enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_data_rdy(
+u8 v_channel_u8, u8 *v_intr_data_rdy_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		switch (v_channel_u8) {
+		/*Read Data Ready interrupt*/
+		case SMI130_INTR1_MAP_DATA_RDY:
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_1_INTR1_DATA_RDY__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_data_rdy_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_1_INTR1_DATA_RDY);
+			break;
+		case SMI130_INTR2_MAP_DATA_RDY:
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_1_INTR2_DATA_RDY__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_data_rdy_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_1_INTR2_DATA_RDY);
+			break;
+		default:
+			com_rslt = E_SMI130_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief Write Data Ready interrupt mapped to interrupt1
+ *	and interrupt2 form the register 0x56
+ *	@brief interrupt1 bit 7 in the register 0x56
+ *	@brief interrupt2 bit 3 in the register 0x56
+ *
+ *
+ *	@param v_channel_u8: The value of data ready interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_DATA_RDY
+ *       1         | SMI130_INTR2_MAP_DATA_RDY
+ *
+ *	@param v_intr_data_rdy_u8 : The value of data ready interrupt enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_data_rdy(
+u8 v_channel_u8, u8 v_intr_data_rdy_u8)
+{
+/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+	switch (v_channel_u8) {
+	/*Write Data Ready interrupt*/
+	case SMI130_INTR1_MAP_DATA_RDY:
+		com_rslt =
+		p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+		dev_addr, SMI130_USER_INTR_MAP_1_INTR1_DATA_RDY__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_1_INTR1_DATA_RDY,
+			v_intr_data_rdy_u8);
+			com_rslt +=
+			p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_1_INTR1_DATA_RDY__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	break;
+	case SMI130_INTR2_MAP_DATA_RDY:
+		com_rslt =
+		p_smi130->SMI130_BUS_READ_FUNC(p_smi130->
+		dev_addr, SMI130_USER_INTR_MAP_1_INTR2_DATA_RDY__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MAP_1_INTR2_DATA_RDY,
+			v_intr_data_rdy_u8);
+			com_rslt +=
+			p_smi130->SMI130_BUS_WRITE_FUNC(p_smi130->
+			dev_addr, SMI130_USER_INTR_MAP_1_INTR2_DATA_RDY__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	break;
+	default:
+	com_rslt = E_SMI130_OUT_OF_RANGE;
+	break;
+	}
+}
+return com_rslt;
+}
+ /*!
+ *	@brief This API reads data source for the interrupt
+ *	engine for the single and double tap interrupts from the register
+ *	0x58 bit 3
+ *
+ *
+ *  @param v_tap_source_u8 : The value of the tap source
+ *	value    | Description
+ * ----------|-------------------
+ *  0x01     |  UNFILTER_DATA
+ *  0x00     |  FILTER_DATA
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_tap_source(u8 *v_tap_source_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the tap source interrupt */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_INTR_DATA_0_INTR_TAP_SOURCE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_tap_source_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_DATA_0_INTR_TAP_SOURCE);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write data source for the interrupt
+ *	engine for the single and double tap interrupts from the register
+ *	0x58 bit 3
+ *
+ *
+ *  @param v_tap_source_u8 : The value of the tap source
+ *	value    | Description
+ * ----------|-------------------
+ *  0x01     |  UNFILTER_DATA
+ *  0x00     |  FILTER_DATA
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_tap_source(
+u8 v_tap_source_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_tap_source_u8 <= SMI130_MAX_VALUE_SOURCE_INTR) {
+			/* write the tap source interrupt */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_INTR_DATA_0_INTR_TAP_SOURCE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR_DATA_0_INTR_TAP_SOURCE,
+				v_tap_source_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC
+				(p_smi130->dev_addr,
+				SMI130_USER_INTR_DATA_0_INTR_TAP_SOURCE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API Reads Data source for the
+ *	interrupt engine for the low and high g interrupts
+ *	from the register 0x58 bit 7
+ *
+ *  @param v_low_high_source_u8 : The value of the tap source
+ *	value    | Description
+ * ----------|-------------------
+ *  0x01     |  UNFILTER_DATA
+ *  0x00     |  FILTER_DATA
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_low_high_source(
+u8 *v_low_high_source_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the high_low_g source interrupt */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_low_high_source_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write Data source for the
+ *	interrupt engine for the low and high g interrupts
+ *	from the register 0x58 bit 7
+ *
+ *  @param v_low_high_source_u8 : The value of the tap source
+ *	value    | Description
+ * ----------|-------------------
+ *  0x01     |  UNFILTER_DATA
+ *  0x00     |  FILTER_DATA
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_low_high_source(
+u8 v_low_high_source_u8)
+{
+/* variable used for return the status of communication result*/
+SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+	if (v_low_high_source_u8 <= SMI130_MAX_VALUE_SOURCE_INTR) {
+		/* write the high_low_g source interrupt */
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+		(p_smi130->dev_addr,
+		SMI130_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE,
+			v_low_high_source_u8);
+			com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	} else {
+	com_rslt = E_SMI130_OUT_OF_RANGE;
+	}
+}
+return com_rslt;
+}
+ /*!
+ *	@brief This API reads Data source for the
+ *	interrupt engine for the nomotion and anymotion interrupts
+ *	from the register 0x59 bit 7
+ *
+ *  @param v_motion_source_u8 :
+ *	The value of the any/no motion interrupt source
+ *	value    | Description
+ * ----------|-------------------
+ *  0x01     |  UNFILTER_DATA
+ *  0x00     |  FILTER_DATA
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_motion_source(
+u8 *v_motion_source_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the any/no motion interrupt  */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_INTR_DATA_1_INTR_MOTION_SOURCE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_motion_source_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_DATA_1_INTR_MOTION_SOURCE);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write Data source for the
+ *	interrupt engine for the nomotion and anymotion interrupts
+ *	from the register 0x59 bit 7
+ *
+ *  @param v_motion_source_u8 :
+ *	The value of the any/no motion interrupt source
+ *	value    | Description
+ * ----------|-------------------
+ *  0x01     |  UNFILTER_DATA
+ *  0x00     |  FILTER_DATA
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_motion_source(
+u8 v_motion_source_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_motion_source_u8 <= SMI130_MAX_VALUE_SOURCE_INTR) {
+			/* write the any/no motion interrupt  */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_INTR_DATA_1_INTR_MOTION_SOURCE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR_DATA_1_INTR_MOTION_SOURCE,
+				v_motion_source_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_INTR_DATA_1_INTR_MOTION_SOURCE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API is used to read the low_g duration from register
+ *	0x5A bit 0 to 7
+ *
+ *
+ *
+ *
+ *  @param v_low_g_durn_u8 : The value of low_g duration
+ *
+ *	@note Low_g duration trigger trigger delay according to
+ *	"(v_low_g_durn_u8 * 2.5)ms" in a range from 2.5ms to 640ms.
+ *	the default corresponds delay is 20ms
+ *	@note When low_g data source of interrupt is unfiltered
+ *	the sensor must not be in low power mode
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_low_g_durn(
+u8 *v_low_g_durn_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the low_g interrupt */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_INTR_LOWHIGH_0_INTR_LOW_DURN__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_low_g_durn_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_LOWHIGH_0_INTR_LOW_DURN);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API is used to write the low_g duration from register
+ *	0x5A bit 0 to 7
+ *
+ *
+ *
+ *
+ *  @param v_low_g_durn_u8 : The value of low_g duration
+ *
+ *	@note Low_g duration trigger trigger delay according to
+ *	"(v_low_g_durn_u8 * 2.5)ms" in a range from 2.5ms to 640ms.
+ *	the default corresponds delay is 20ms
+ *	@note When low_g data source of interrupt is unfiltered
+ *	the sensor must not be in low power mode
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_low_g_durn(u8 v_low_g_durn_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* write the low_g interrupt */
+			com_rslt = p_smi130->SMI130_BUS_WRITE_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_INTR_LOWHIGH_0_INTR_LOW_DURN__REG,
+			&v_low_g_durn_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to read Threshold
+ *	definition for the low-g interrupt from the register 0x5B bit 0 to 7
+ *
+ *
+ *
+ *
+ *  @param v_low_g_thres_u8 : The value of low_g threshold
+ *
+ *	@note Low_g interrupt trigger threshold according to
+ *	(v_low_g_thres_u8 * 7.81)mg for v_low_g_thres_u8 > 0
+ *	3.91 mg for v_low_g_thres_u8 = 0
+ *	The threshold range is form 3.91mg to 2.000mg
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_low_g_thres(
+u8 *v_low_g_thres_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read low_g threshold */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_INTR_LOWHIGH_1_INTR_LOW_THRES__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_low_g_thres_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_LOWHIGH_1_INTR_LOW_THRES);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to write Threshold
+ *	definition for the low-g interrupt from the register 0x5B bit 0 to 7
+ *
+ *
+ *
+ *
+ *  @param v_low_g_thres_u8 : The value of low_g threshold
+ *
+ *	@note Low_g interrupt trigger threshold according to
+ *	(v_low_g_thres_u8 * 7.81)mg for v_low_g_thres_u8 > 0
+ *	3.91 mg for v_low_g_thres_u8 = 0
+ *	The threshold range is form 3.91mg to 2.000mg
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_low_g_thres(
+u8 v_low_g_thres_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* write low_g threshold */
+			com_rslt = p_smi130->SMI130_BUS_WRITE_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_INTR_LOWHIGH_1_INTR_LOW_THRES__REG,
+			&v_low_g_thres_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API Reads Low-g interrupt hysteresis
+ *	from the register 0x5C bit 0 to 1
+ *
+ *  @param v_low_hyst_u8 :The value of low_g hysteresis
+ *
+ *	@note Low_g hysteresis calculated by v_low_hyst_u8*125 mg
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_low_g_hyst(
+u8 *v_low_hyst_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read low_g hysteresis*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_low_hyst_u8 = SMI130_GET_BITSLICE(
+			v_data_u8,
+			SMI130_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write Low-g interrupt hysteresis
+ *	from the register 0x5C bit 0 to 1
+ *
+ *  @param v_low_hyst_u8 :The value of low_g hysteresis
+ *
+ *	@note Low_g hysteresis calculated by v_low_hyst_u8*125 mg
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_low_g_hyst(
+u8 v_low_hyst_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* write low_g hysteresis*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST,
+				v_low_hyst_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads Low-g interrupt mode
+ *	from the register 0x5C bit 2
+ *
+ *  @param v_low_g_mode_u8 : The value of low_g mode
+ *	Value    |  Description
+ * ----------|-----------------
+ *	   0     | single-axis
+ *     1     | axis-summing
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_low_g_mode(u8 *v_low_g_mode_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/*read Low-g interrupt mode*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_low_g_mode_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write Low-g interrupt mode
+ *	from the register 0x5C bit 2
+ *
+ *  @param v_low_g_mode_u8 : The value of low_g mode
+ *	Value    |  Description
+ * ----------|-----------------
+ *	   0     | single-axis
+ *     1     | axis-summing
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_low_g_mode(
+u8 v_low_g_mode_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_low_g_mode_u8 <= SMI130_MAX_VALUE_LOW_G_MODE) {
+			/*write Low-g interrupt mode*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE,
+				v_low_g_mode_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads High-g interrupt hysteresis
+ *	from the register 0x5C bit 6 and 7
+ *
+ *  @param v_high_g_hyst_u8 : The value of high hysteresis
+ *
+ *	@note High_g hysteresis changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | high_g hysteresis
+ *  ----------------|---------------------
+ *      2g          |  high_hy*125 mg
+ *      4g          |  high_hy*250 mg
+ *      8g          |  high_hy*500 mg
+ *      16g         |  high_hy*1000 mg
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_high_g_hyst(
+u8 *v_high_g_hyst_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read high_g hysteresis*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_high_g_hyst_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write High-g interrupt hysteresis
+ *	from the register 0x5C bit 6 and 7
+ *
+ *  @param v_high_g_hyst_u8 : The value of high hysteresis
+ *
+ *	@note High_g hysteresis changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | high_g hysteresis
+ *  ----------------|---------------------
+ *      2g          |  high_hy*125 mg
+ *      4g          |  high_hy*250 mg
+ *      8g          |  high_hy*500 mg
+ *      16g         |  high_hy*1000 mg
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_high_g_hyst(
+u8 v_high_g_hyst_u8)
+{
+/* variable used for return the status of communication result*/
+SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+		/* write high_g hysteresis*/
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+		p_smi130->dev_addr,
+		SMI130_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST,
+			v_high_g_hyst_u8);
+			com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	}
+return com_rslt;
+}
+/*!
+ *	@brief This API is used to read Delay
+ *	time definition for the high-g interrupt from the register
+ *	0x5D bit 0 to 7
+ *
+ *
+ *
+ *  @param  v_high_g_durn_u8 :  The value of high duration
+ *
+ *	@note High_g interrupt delay triggered according to
+ *	v_high_g_durn_u8 * 2.5ms in a range from 2.5ms to 640ms
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_high_g_durn(
+u8 *v_high_g_durn_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read high_g duration*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_INTR_LOWHIGH_3_INTR_HIGH_G_DURN__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_high_g_durn_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_LOWHIGH_3_INTR_HIGH_G_DURN);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to write Delay
+ *	time definition for the high-g interrupt from the register
+ *	0x5D bit 0 to 7
+ *
+ *
+ *
+ *  @param  v_high_g_durn_u8 :  The value of high duration
+ *
+ *	@note High_g interrupt delay triggered according to
+ *	v_high_g_durn_u8 * 2.5ms in a range from 2.5ms to 640ms
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_high_g_durn(
+u8 v_high_g_durn_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* write high_g duration*/
+			com_rslt = p_smi130->SMI130_BUS_WRITE_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_INTR_LOWHIGH_3_INTR_HIGH_G_DURN__REG,
+			&v_high_g_durn_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to read Threshold
+ *	definition for the high-g interrupt from the register 0x5E 0 to 7
+ *
+ *
+ *
+ *
+ *  @param  v_high_g_thres_u8 : Pointer holding the value of Threshold
+ *	@note High_g threshold changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | high_g threshold
+ *  ----------------|---------------------
+ *      2g          |  v_high_g_thres_u8*7.81 mg
+ *      4g          |  v_high_g_thres_u8*15.63 mg
+ *      8g          |  v_high_g_thres_u8*31.25 mg
+ *      16g         |  v_high_g_thres_u8*62.5 mg
+ *	@note when v_high_g_thres_u8 = 0
+ *   accel_range    | high_g threshold
+ *  ----------------|---------------------
+ *      2g          |  3.91 mg
+ *      4g          |  7.81 mg
+ *      8g          |  15.63 mg
+ *      16g         |  31.25 mg
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_high_g_thres(
+u8 *v_high_g_thres_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_INTR_LOWHIGH_4_INTR_HIGH_THRES__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_high_g_thres_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_LOWHIGH_4_INTR_HIGH_THRES);
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to write Threshold
+ *	definition for the high-g interrupt from the register 0x5E 0 to 7
+ *
+ *
+ *
+ *
+ *  @param  v_high_g_thres_u8 : Pointer holding the value of Threshold
+ *	@note High_g threshold changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | high_g threshold
+ *  ----------------|---------------------
+ *      2g          |  v_high_g_thres_u8*7.81 mg
+ *      4g          |  v_high_g_thres_u8*15.63 mg
+ *      8g          |  v_high_g_thres_u8*31.25 mg
+ *      16g         |  v_high_g_thres_u8*62.5 mg
+ *	@note when v_high_g_thres_u8 = 0
+ *   accel_range    | high_g threshold
+ *  ----------------|---------------------
+ *      2g          |  3.91 mg
+ *      4g          |  7.81 mg
+ *      8g          |  15.63 mg
+ *      16g         |  31.25 mg
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_high_g_thres(
+u8 v_high_g_thres_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		com_rslt = p_smi130->SMI130_BUS_WRITE_FUNC(
+		p_smi130->dev_addr,
+		SMI130_USER_INTR_LOWHIGH_4_INTR_HIGH_THRES__REG,
+		&v_high_g_thres_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads any motion duration
+ *	from the register 0x5F bit 0 and 1
+ *
+ *  @param v_any_motion_durn_u8 : The value of any motion duration
+ *
+ *	@note Any motion duration can be calculated by "v_any_motion_durn_u8 + 1"
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_any_motion_durn(
+u8 *v_any_motion_durn_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		/* read any motion duration*/
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+		(p_smi130->dev_addr,
+		SMI130_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		*v_any_motion_durn_u8 = SMI130_GET_BITSLICE
+		(v_data_u8,
+		SMI130_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN);
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write any motion duration
+ *	from the register 0x5F bit 0 and 1
+ *
+ *  @param v_any_motion_durn_u8 : The value of any motion duration
+ *
+ *	@note Any motion duration can be calculated by "v_any_motion_durn_u8 + 1"
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_any_motion_durn(
+u8 v_any_motion_durn_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		/* write any motion duration*/
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+		(p_smi130->dev_addr,
+		SMI130_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN,
+			v_any_motion_durn_u8);
+			com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API read Slow/no-motion
+ *	interrupt trigger delay duration from the register 0x5F bit 2 to 7
+ *
+ *  @param v_slow_no_motion_u8 :The value of slow no motion duration
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *	@note
+ *	@note v_slow_no_motion_u8(5:4)=0b00 ->
+ *	[v_slow_no_motion_u8(3:0) + 1] * 1.28s (1.28s-20.48s)
+ *	@note v_slow_no_motion_u8(5:4)=1 ->
+ *	[v_slow_no_motion_u8(3:0)+5] * 5.12s (25.6s-102.4s)
+ *	@note v_slow_no_motion_u8(5)='1' ->
+ *	[(v_slow_no_motion_u8:0)+11] * 10.24s (112.64s-430.08s);
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_slow_no_motion_durn(
+u8 *v_slow_no_motion_u8)
+{
+/* variable used for return the status of communication result*/
+SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+		/* read slow no motion duration*/
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+		(p_smi130->dev_addr,
+		SMI130_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		*v_slow_no_motion_u8 = SMI130_GET_BITSLICE
+		(v_data_u8,
+		SMI130_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN);
+	}
+return com_rslt;
+}
+ /*!
+ *	@brief This API write Slow/no-motion
+ *	interrupt trigger delay duration from the register 0x5F bit 2 to 7
+ *
+ *  @param v_slow_no_motion_u8 :The value of slow no motion duration
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *	@note
+ *	@note v_slow_no_motion_u8(5:4)=0b00 ->
+ *	[v_slow_no_motion_u8(3:0) + 1] * 1.28s (1.28s-20.48s)
+ *	@note v_slow_no_motion_u8(5:4)=1 ->
+ *	[v_slow_no_motion_u8(3:0)+5] * 5.12s (25.6s-102.4s)
+ *	@note v_slow_no_motion_u8(5)='1' ->
+ *	[(v_slow_no_motion_u8:0)+11] * 10.24s (112.64s-430.08s);
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_slow_no_motion_durn(
+u8 v_slow_no_motion_u8)
+{
+/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+	/* write slow no motion duration*/
+	com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+	(p_smi130->dev_addr,
+	SMI130_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN__REG,
+	&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	if (com_rslt == SUCCESS) {
+		v_data_u8 = SMI130_SET_BITSLICE
+		(v_data_u8,
+		SMI130_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN,
+		v_slow_no_motion_u8);
+		com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC
+		(p_smi130->dev_addr,
+		SMI130_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	}
+}
+return com_rslt;
+}
+/*!
+ *	@brief This API is used to read threshold
+ *	definition for the any-motion interrupt
+ *	from the register 0x60 bit 0 to 7
+ *
+ *
+ *  @param  v_any_motion_thres_u8 : The value of any motion threshold
+ *
+ *	@note any motion threshold changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | any motion threshold
+ *  ----------------|---------------------
+ *      2g          |  v_any_motion_thres_u8*3.91 mg
+ *      4g          |  v_any_motion_thres_u8*7.81 mg
+ *      8g          |  v_any_motion_thres_u8*15.63 mg
+ *      16g         |  v_any_motion_thres_u8*31.25 mg
+ *	@note when v_any_motion_thres_u8 = 0
+ *   accel_range    | any motion threshold
+ *  ----------------|---------------------
+ *      2g          |  1.95 mg
+ *      4g          |  3.91 mg
+ *      8g          |  7.81 mg
+ *      16g         |  15.63 mg
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_any_motion_thres(
+u8 *v_any_motion_thres_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read any motion threshold*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_INTR_MOTION_1_INTR_ANY_MOTION_THRES__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_any_motion_thres_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_MOTION_1_INTR_ANY_MOTION_THRES);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to write threshold
+ *	definition for the any-motion interrupt
+ *	from the register 0x60 bit 0 to 7
+ *
+ *
+ *  @param  v_any_motion_thres_u8 : The value of any motion threshold
+ *
+ *	@note any motion threshold changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | any motion threshold
+ *  ----------------|---------------------
+ *      2g          |  v_any_motion_thres_u8*3.91 mg
+ *      4g          |  v_any_motion_thres_u8*7.81 mg
+ *      8g          |  v_any_motion_thres_u8*15.63 mg
+ *      16g         |  v_any_motion_thres_u8*31.25 mg
+ *	@note when v_any_motion_thres_u8 = 0
+ *   accel_range    | any motion threshold
+ *  ----------------|---------------------
+ *      2g          |  1.95 mg
+ *      4g          |  3.91 mg
+ *      8g          |  7.81 mg
+ *      16g         |  15.63 mg
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_any_motion_thres(
+u8 v_any_motion_thres_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		/* write any motion threshold*/
+		com_rslt = p_smi130->SMI130_BUS_WRITE_FUNC
+		(p_smi130->dev_addr,
+		SMI130_USER_INTR_MOTION_1_INTR_ANY_MOTION_THRES__REG,
+		&v_any_motion_thres_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API is used to read threshold
+ *	for the slow/no-motion interrupt
+ *	from the register 0x61 bit 0 to 7
+ *
+ *
+ *
+ *
+ *  @param v_slow_no_motion_thres_u8 : The value of slow no motion threshold
+ *	@note slow no motion threshold changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | slow no motion threshold
+ *  ----------------|---------------------
+ *      2g          |  v_slow_no_motion_thres_u8*3.91 mg
+ *      4g          |  v_slow_no_motion_thres_u8*7.81 mg
+ *      8g          |  v_slow_no_motion_thres_u8*15.63 mg
+ *      16g         |  v_slow_no_motion_thres_u8*31.25 mg
+ *	@note when v_slow_no_motion_thres_u8 = 0
+ *   accel_range    | slow no motion threshold
+ *  ----------------|---------------------
+ *      2g          |  1.95 mg
+ *      4g          |  3.91 mg
+ *      8g          |  7.81 mg
+ *      16g         |  15.63 mg
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_slow_no_motion_thres(
+u8 *v_slow_no_motion_thres_u8)
+{
+SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+		/* read slow no motion threshold*/
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+		(p_smi130->dev_addr,
+		SMI130_USER_INTR_MOTION_2_INTR_SLOW_NO_MOTION_THRES__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		*v_slow_no_motion_thres_u8 =
+		SMI130_GET_BITSLICE(v_data_u8,
+		SMI130_USER_INTR_MOTION_2_INTR_SLOW_NO_MOTION_THRES);
+	}
+return com_rslt;
+}
+ /*!
+ *	@brief This API is used to write threshold
+ *	for the slow/no-motion interrupt
+ *	from the register 0x61 bit 0 to 7
+ *
+ *
+ *
+ *
+ *  @param v_slow_no_motion_thres_u8 : The value of slow no motion threshold
+ *	@note slow no motion threshold changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | slow no motion threshold
+ *  ----------------|---------------------
+ *      2g          |  v_slow_no_motion_thres_u8*3.91 mg
+ *      4g          |  v_slow_no_motion_thres_u8*7.81 mg
+ *      8g          |  v_slow_no_motion_thres_u8*15.63 mg
+ *      16g         |  v_slow_no_motion_thres_u8*31.25 mg
+ *	@note when v_slow_no_motion_thres_u8 = 0
+ *   accel_range    | slow no motion threshold
+ *  ----------------|---------------------
+ *      2g          |  1.95 mg
+ *      4g          |  3.91 mg
+ *      8g          |  7.81 mg
+ *      16g         |  15.63 mg
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_slow_no_motion_thres(
+u8 v_slow_no_motion_thres_u8)
+{
+SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+		/* write slow no motion threshold*/
+		com_rslt = p_smi130->SMI130_BUS_WRITE_FUNC(
+		p_smi130->dev_addr,
+		SMI130_USER_INTR_MOTION_2_INTR_SLOW_NO_MOTION_THRES__REG,
+		&v_slow_no_motion_thres_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	}
+return com_rslt;
+}
+ /*!
+ *	@brief This API is used to read
+ *	the slow/no-motion selection from the register 0x62 bit 0
+ *
+ *
+ *
+ *
+ *  @param  v_intr_slow_no_motion_select_u8 :
+ *	The value of slow/no-motion select
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     |  SLOW_MOTION
+ *  0x01     |  NO_MOTION
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_slow_no_motion_select(
+u8 *v_intr_slow_no_motion_select_u8)
+{
+SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+		/* read slow no motion select*/
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+		p_smi130->dev_addr,
+		SMI130_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		*v_intr_slow_no_motion_select_u8 =
+		SMI130_GET_BITSLICE(v_data_u8,
+		SMI130_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT);
+	}
+return com_rslt;
+}
+ /*!
+ *	@brief This API is used to write
+ *	the slow/no-motion selection from the register 0x62 bit 0
+ *
+ *
+ *
+ *
+ *  @param  v_intr_slow_no_motion_select_u8 :
+ *	The value of slow/no-motion select
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     |  SLOW_MOTION
+ *  0x01     |  NO_MOTION
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_slow_no_motion_select(
+u8 v_intr_slow_no_motion_select_u8)
+{
+/* variable used for return the status of communication result*/
+SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+} else {
+if (v_intr_slow_no_motion_select_u8 <= SMI130_MAX_VALUE_NO_MOTION) {
+	/* write slow no motion select*/
+	com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+	(p_smi130->dev_addr,
+	SMI130_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT__REG,
+	&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	if (com_rslt == SUCCESS) {
+		v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+		SMI130_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT,
+		v_intr_slow_no_motion_select_u8);
+		com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC
+		(p_smi130->dev_addr,
+		SMI130_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	}
+} else {
+com_rslt = E_SMI130_OUT_OF_RANGE;
+}
+}
+return com_rslt;
+}
+ /*!
+ *	@brief This API is used to select
+ *	the significant or any motion interrupt from the register 0x62 bit 1
+ *
+ *
+ *
+ *
+ *  @param  v_intr_significant_motion_select_u8 :
+ *	the value of significant or any motion interrupt selection
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     |  ANY_MOTION
+ *  0x01     |  SIGNIFICANT_MOTION
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_significant_motion_select(
+u8 *v_intr_significant_motion_select_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the significant or any motion interrupt*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_INTR_SIGNIFICATION_MOTION_SELECT__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_intr_significant_motion_select_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_SIGNIFICATION_MOTION_SELECT);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API is used to write, select
+ *	the significant or any motion interrupt from the register 0x62 bit 1
+ *
+ *
+ *
+ *
+ *  @param  v_intr_significant_motion_select_u8 :
+ *	the value of significant or any motion interrupt selection
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     |  ANY_MOTION
+ *  0x01     |  SIGNIFICANT_MOTION
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_significant_motion_select(
+u8 v_intr_significant_motion_select_u8)
+{
+/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+	if (v_intr_significant_motion_select_u8 <=
+	SMI130_MAX_VALUE_SIGNIFICANT_MOTION) {
+		/* write the significant or any motion interrupt*/
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+		(p_smi130->dev_addr,
+		SMI130_USER_INTR_SIGNIFICATION_MOTION_SELECT__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_SIGNIFICATION_MOTION_SELECT,
+			v_intr_significant_motion_select_u8);
+			com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_INTR_SIGNIFICATION_MOTION_SELECT__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	} else {
+	com_rslt = E_SMI130_OUT_OF_RANGE;
+	}
+}
+return com_rslt;
+}
+ /*!
+ *	@brief This API is used to read
+ *	the significant skip time from the register 0x62 bit  2 and 3
+ *
+ *
+ *
+ *
+ *  @param  v_int_sig_mot_skip_u8 : the value of significant skip time
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     |  skip time 1.5 seconds
+ *  0x01     |  skip time 3 seconds
+ *  0x02     |  skip time 6 seconds
+ *  0x03     |  skip time 12 seconds
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_significant_motion_skip(
+u8 *v_int_sig_mot_skip_u8)
+{
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read significant skip time*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_INTR_SIGNIFICANT_MOTION_SKIP__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_int_sig_mot_skip_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_SIGNIFICANT_MOTION_SKIP);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API is used to write
+ *	the significant skip time from the register 0x62 bit  2 and 3
+ *
+ *
+ *
+ *
+ *  @param  v_int_sig_mot_skip_u8 : the value of significant skip time
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     |  skip time 1.5 seconds
+ *  0x01     |  skip time 3 seconds
+ *  0x02     |  skip time 6 seconds
+ *  0x03     |  skip time 12 seconds
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_significant_motion_skip(
+u8 v_int_sig_mot_skip_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_int_sig_mot_skip_u8 <= SMI130_MAX_UNDER_SIG_MOTION) {
+			/* write significant skip time*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_INTR_SIGNIFICANT_MOTION_SKIP__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR_SIGNIFICANT_MOTION_SKIP,
+				v_int_sig_mot_skip_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC
+				(p_smi130->dev_addr,
+				SMI130_USER_INTR_SIGNIFICANT_MOTION_SKIP__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API is used to read
+ *	the significant proof time from the register 0x62 bit  4 and 5
+ *
+ *
+ *
+ *
+ *  @param  v_significant_motion_proof_u8 :
+ *	the value of significant proof time
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     |  proof time 0.25 seconds
+ *  0x01     |  proof time 0.5 seconds
+ *  0x02     |  proof time 1 seconds
+ *  0x03     |  proof time 2 seconds
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_significant_motion_proof(
+u8 *v_significant_motion_proof_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read significant proof time */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_INTR_SIGNIFICANT_MOTION_PROOF__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_significant_motion_proof_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_SIGNIFICANT_MOTION_PROOF);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API is used to write
+ *	the significant proof time from the register 0x62 bit  4 and 5
+ *
+ *
+ *
+ *
+ *  @param  v_significant_motion_proof_u8 :
+ *	the value of significant proof time
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     |  proof time 0.25 seconds
+ *  0x01     |  proof time 0.5 seconds
+ *  0x02     |  proof time 1 seconds
+ *  0x03     |  proof time 2 seconds
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_significant_motion_proof(
+u8 v_significant_motion_proof_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_significant_motion_proof_u8
+		<= SMI130_MAX_UNDER_SIG_MOTION) {
+			/* write significant proof time */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_INTR_SIGNIFICANT_MOTION_PROOF__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR_SIGNIFICANT_MOTION_PROOF,
+				v_significant_motion_proof_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC
+				(p_smi130->dev_addr,
+				SMI130_USER_INTR_SIGNIFICANT_MOTION_PROOF__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to get the tap duration
+ *	from the register 0x63 bit 0 to 2
+ *
+ *
+ *
+ *  @param v_tap_durn_u8 : The value of tap duration
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | SMI130_TAP_DURN_50MS
+ *  0x01     | SMI130_TAP_DURN_100MS
+ *  0x03     | SMI130_TAP_DURN_150MS
+ *  0x04     | SMI130_TAP_DURN_200MS
+ *  0x05     | SMI130_TAP_DURN_250MS
+ *  0x06     | SMI130_TAP_DURN_375MS
+ *  0x07     | SMI130_TAP_DURN_700MS
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_tap_durn(
+u8 *v_tap_durn_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read tap duration*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_INTR_TAP_0_INTR_TAP_DURN__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_tap_durn_u8 = SMI130_GET_BITSLICE(
+			v_data_u8,
+			SMI130_USER_INTR_TAP_0_INTR_TAP_DURN);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API is used to write the tap duration
+ *	from the register 0x63 bit 0 to 2
+ *
+ *
+ *
+ *  @param v_tap_durn_u8 : The value of tap duration
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | SMI130_TAP_DURN_50MS
+ *  0x01     | SMI130_TAP_DURN_100MS
+ *  0x03     | SMI130_TAP_DURN_150MS
+ *  0x04     | SMI130_TAP_DURN_200MS
+ *  0x05     | SMI130_TAP_DURN_250MS
+ *  0x06     | SMI130_TAP_DURN_375MS
+ *  0x07     | SMI130_TAP_DURN_700MS
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_tap_durn(
+u8 v_tap_durn_u8)
+{
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_tap_durn_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_tap_durn_u8 <= SMI130_MAX_TAP_TURN) {
+			switch (v_tap_durn_u8) {
+			case SMI130_TAP_DURN_50MS:
+				v_data_tap_durn_u8 = SMI130_TAP_DURN_50MS;
+				break;
+			case SMI130_TAP_DURN_100MS:
+				v_data_tap_durn_u8 = SMI130_TAP_DURN_100MS;
+				break;
+			case SMI130_TAP_DURN_150MS:
+				v_data_tap_durn_u8 = SMI130_TAP_DURN_150MS;
+				break;
+			case SMI130_TAP_DURN_200MS:
+				v_data_tap_durn_u8 = SMI130_TAP_DURN_200MS;
+				break;
+			case SMI130_TAP_DURN_250MS:
+				v_data_tap_durn_u8 = SMI130_TAP_DURN_250MS;
+				break;
+			case SMI130_TAP_DURN_375MS:
+				v_data_tap_durn_u8 = SMI130_TAP_DURN_375MS;
+				break;
+			case SMI130_TAP_DURN_500MS:
+				v_data_tap_durn_u8 = SMI130_TAP_DURN_500MS;
+				break;
+			case SMI130_TAP_DURN_700MS:
+				v_data_tap_durn_u8 = SMI130_TAP_DURN_700MS;
+				break;
+			default:
+				break;
+			}
+			/* write tap duration*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_INTR_TAP_0_INTR_TAP_DURN__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR_TAP_0_INTR_TAP_DURN,
+				v_data_tap_durn_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC
+				(p_smi130->dev_addr,
+				SMI130_USER_INTR_TAP_0_INTR_TAP_DURN__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API read the
+ *	tap shock duration from the register 0x63 bit 2
+ *
+ *  @param v_tap_shock_u8 :The value of tap shock
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | SMI130_TAP_SHOCK_50MS
+ *  0x01     | SMI130_TAP_SHOCK_75MS
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_tap_shock(
+u8 *v_tap_shock_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read tap shock duration*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_INTR_TAP_0_INTR_TAP_SHOCK__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_tap_shock_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_TAP_0_INTR_TAP_SHOCK);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write the
+ *	tap shock duration from the register 0x63 bit 2
+ *
+ *  @param v_tap_shock_u8 :The value of tap shock
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | SMI130_TAP_SHOCK_50MS
+ *  0x01     | SMI130_TAP_SHOCK_75MS
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_tap_shock(u8 v_tap_shock_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_tap_shock_u8 <= SMI130_MAX_VALUE_TAP_SHOCK) {
+			/* write tap shock duration*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_INTR_TAP_0_INTR_TAP_SHOCK__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR_TAP_0_INTR_TAP_SHOCK,
+				v_tap_shock_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC
+				(p_smi130->dev_addr,
+				SMI130_USER_INTR_TAP_0_INTR_TAP_SHOCK__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read
+ *	tap quiet duration from the register 0x63 bit 7
+ *
+ *
+ *  @param v_tap_quiet_u8 : The value of tap quiet
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | SMI130_TAP_QUIET_30MS
+ *  0x01     | SMI130_TAP_QUIET_20MS
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_tap_quiet(
+u8 *v_tap_quiet_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read tap quiet duration*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_INTR_TAP_0_INTR_TAP_QUIET__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_tap_quiet_u8 = SMI130_GET_BITSLICE(
+			v_data_u8,
+			SMI130_USER_INTR_TAP_0_INTR_TAP_QUIET);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write
+ *	tap quiet duration from the register 0x63 bit 7
+ *
+ *
+ *  @param v_tap_quiet_u8 : The value of tap quiet
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | SMI130_TAP_QUIET_30MS
+ *  0x01     | SMI130_TAP_QUIET_20MS
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_tap_quiet(u8 v_tap_quiet_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_tap_quiet_u8 <= SMI130_MAX_VALUE_TAP_QUIET) {
+			/* write tap quiet duration*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_INTR_TAP_0_INTR_TAP_QUIET__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR_TAP_0_INTR_TAP_QUIET,
+				v_tap_quiet_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC
+				(p_smi130->dev_addr,
+				SMI130_USER_INTR_TAP_0_INTR_TAP_QUIET__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API read Threshold of the
+ *	single/double tap interrupt from the register 0x64 bit 0 to 4
+ *
+ *
+ *	@param v_tap_thres_u8 : The value of single/double tap threshold
+ *
+ *	@note single/double tap threshold changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | single/double tap threshold
+ *  ----------------|---------------------
+ *      2g          |  ((v_tap_thres_u8 + 1) * 62.5)mg
+ *      4g          |  ((v_tap_thres_u8 + 1) * 125)mg
+ *      8g          |  ((v_tap_thres_u8 + 1) * 250)mg
+ *      16g         |  ((v_tap_thres_u8 + 1) * 500)mg
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_tap_thres(
+u8 *v_tap_thres_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read tap threshold*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_INTR_TAP_1_INTR_TAP_THRES__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_tap_thres_u8 = SMI130_GET_BITSLICE
+			(v_data_u8,
+			SMI130_USER_INTR_TAP_1_INTR_TAP_THRES);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write Threshold of the
+ *	single/double tap interrupt from the register 0x64 bit 0 to 4
+ *
+ *
+ *	@param v_tap_thres_u8 : The value of single/double tap threshold
+ *
+ *	@note single/double tap threshold changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | single/double tap threshold
+ *  ----------------|---------------------
+ *      2g          |  ((v_tap_thres_u8 + 1) * 62.5)mg
+ *      4g          |  ((v_tap_thres_u8 + 1) * 125)mg
+ *      8g          |  ((v_tap_thres_u8 + 1) * 250)mg
+ *      16g         |  ((v_tap_thres_u8 + 1) * 500)mg
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_tap_thres(
+u8 v_tap_thres_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* write tap threshold*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_INTR_TAP_1_INTR_TAP_THRES__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR_TAP_1_INTR_TAP_THRES,
+				v_tap_thres_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC
+				(p_smi130->dev_addr,
+				SMI130_USER_INTR_TAP_1_INTR_TAP_THRES__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API read the threshold for orient_mblation interrupt
+ *	from the register 0x65 bit 0 and 1
+ *
+ *  @param v_orient_mbl_mode_u8 : The value of threshold for orient_mblation
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | symmetrical
+ *  0x01     | high-asymmetrical
+ *  0x02     | low-asymmetrical
+ *  0x03     | symmetrical
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_orient_mbl_mode(
+u8 *v_orient_mbl_mode_u8)
+{
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read orient_mblation threshold*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_INTR_ORIENT_0_INTR_ORIENT_MODE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_orient_mbl_mode_u8 = SMI130_GET_BITSLICE
+			(v_data_u8,
+			SMI130_USER_INTR_ORIENT_0_INTR_ORIENT_MODE);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write the threshold for orient_mblation interrupt
+ *	from the register 0x65 bit 0 and 1
+ *
+ *  @param v_orient_mbl_mode_u8 : The value of threshold for orient_mblation
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | symmetrical
+ *  0x01     | high-asymmetrical
+ *  0x02     | low-asymmetrical
+ *  0x03     | symmetrical
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_orient_mbl_mode(
+u8 v_orient_mbl_mode_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_orient_mbl_mode_u8 <= SMI130_MAX_ORIENT_MODE) {
+			/* write orient_mblation threshold*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_INTR_ORIENT_0_INTR_ORIENT_MODE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR_ORIENT_0_INTR_ORIENT_MODE,
+				v_orient_mbl_mode_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC
+				(p_smi130->dev_addr,
+				SMI130_USER_INTR_ORIENT_0_INTR_ORIENT_MODE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read the orient_mbl blocking mode
+ *	that is used for the generation of the orient_mblation interrupt.
+ *	from the register 0x65 bit 2 and 3
+ *
+ *  @param v_orient_mbl_blocking_u8 : The value of orient_mbl blocking mode
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | No blocking
+ *  0x01     | Theta blocking or acceleration in any axis > 1.5g
+ *  0x02     | Theta blocking or acceleration slope in any axis >
+ *   -       | 0.2g or acceleration in any axis > 1.5g
+ *  0x03     | Theta blocking or acceleration slope in any axis >
+ *   -       | 0.4g or acceleration in any axis >
+ *   -       | 1.5g and value of orient_mbl is not stable
+ *   -       | for at least 100 ms
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_orient_mbl_blocking(
+u8 *v_orient_mbl_blocking_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read orient_mbl blocking mode*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_orient_mbl_blocking_u8 = SMI130_GET_BITSLICE
+			(v_data_u8,
+			SMI130_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write the orient_mbl blocking mode
+ *	that is used for the generation of the orient_mblation interrupt.
+ *	from the register 0x65 bit 2 and 3
+ *
+ *  @param v_orient_mbl_blocking_u8 : The value of orient_mbl blocking mode
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | No blocking
+ *  0x01     | Theta blocking or acceleration in any axis > 1.5g
+ *  0x02     | Theta blocking or acceleration slope in any axis >
+ *   -       | 0.2g or acceleration in any axis > 1.5g
+ *  0x03     | Theta blocking or acceleration slope in any axis >
+ *   -       | 0.4g or acceleration in any axis >
+ *   -       | 1.5g and value of orient_mbl is not stable
+ *   -       | for at least 100 ms
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_orient_mbl_blocking(
+u8 v_orient_mbl_blocking_u8)
+{
+/* variable used for return the status of communication result*/
+SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+	if (v_orient_mbl_blocking_u8 <= SMI130_MAX_ORIENT_BLOCKING) {
+		/* write orient_mbl blocking mode*/
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+		(p_smi130->dev_addr,
+		SMI130_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING,
+			v_orient_mbl_blocking_u8);
+			com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	} else {
+	com_rslt = E_SMI130_OUT_OF_RANGE;
+	}
+}
+return com_rslt;
+}
+/*!
+ *	@brief This API read Orient interrupt
+ *	hysteresis, from the register 0x64 bit 4 to 7
+ *
+ *
+ *
+ *  @param v_orient_mbl_hyst_u8 : The value of orient_mbl hysteresis
+ *
+ *	@note 1 LSB corresponds to 62.5 mg,
+ *	irrespective of the selected accel range
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_orient_mbl_hyst(
+u8 *v_orient_mbl_hyst_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read orient_mbl hysteresis*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_INTR_ORIENT_0_INTR_ORIENT_HYST__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_orient_mbl_hyst_u8 = SMI130_GET_BITSLICE
+			(v_data_u8,
+			SMI130_USER_INTR_ORIENT_0_INTR_ORIENT_HYST);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write Orient interrupt
+ *	hysteresis, from the register 0x64 bit 4 to 7
+ *
+ *
+ *
+ *  @param v_orient_mbl_hyst_u8 : The value of orient_mbl hysteresis
+ *
+ *	@note 1 LSB corresponds to 62.5 mg,
+ *	irrespective of the selected accel range
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_orient_mbl_hyst(
+u8 v_orient_mbl_hyst_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* write orient_mbl hysteresis*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_INTR_ORIENT_0_INTR_ORIENT_HYST__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR_ORIENT_0_INTR_ORIENT_HYST,
+				v_orient_mbl_hyst_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC
+				(p_smi130->dev_addr,
+				SMI130_USER_INTR_ORIENT_0_INTR_ORIENT_HYST__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API read Orient
+ *	blocking angle (0 to 44.8) from the register 0x66 bit 0 to 5
+ *
+ *  @param v_orient_mbl_theta_u8 : The value of Orient blocking angle
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_orient_mbl_theta(
+u8 *v_orient_mbl_theta_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read Orient blocking angle*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_INTR_ORIENT_1_INTR_ORIENT_THETA__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_orient_mbl_theta_u8 = SMI130_GET_BITSLICE
+			(v_data_u8,
+			SMI130_USER_INTR_ORIENT_1_INTR_ORIENT_THETA);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write Orient
+ *	blocking angle (0 to 44.8) from the register 0x66 bit 0 to 5
+ *
+ *  @param v_orient_mbl_theta_u8 : The value of Orient blocking angle
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_orient_mbl_theta(
+u8 v_orient_mbl_theta_u8)
+{
+/* variable used for return the status of communication result*/
+SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+	if (v_orient_mbl_theta_u8 <= SMI130_MAX_ORIENT_THETA) {
+		/* write Orient blocking angle*/
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+		(p_smi130->dev_addr,
+		SMI130_USER_INTR_ORIENT_1_INTR_ORIENT_THETA__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_ORIENT_1_INTR_ORIENT_THETA,
+			v_orient_mbl_theta_u8);
+			com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_INTR_ORIENT_1_INTR_ORIENT_THETA__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	} else {
+	com_rslt = E_SMI130_OUT_OF_RANGE;
+	}
+}
+return com_rslt;
+}
+/*!
+ *	@brief This API read orient_mbl change
+ *	of up/down bit from the register 0x66 bit 6
+ *
+ *  @param v_orient_mbl_ud_u8 : The value of orient_mbl change of up/down
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | Is ignored
+ *  0x01     | Generates orient_mblation interrupt
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_orient_mbl_ud_enable(
+u8 *v_orient_mbl_ud_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read orient_mbl up/down enable*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_orient_mbl_ud_u8 = SMI130_GET_BITSLICE
+			(v_data_u8,
+			SMI130_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write orient_mbl change
+ *	of up/down bit from the register 0x66 bit 6
+ *
+ *  @param v_orient_mbl_ud_u8 : The value of orient_mbl change of up/down
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | Is ignored
+ *  0x01     | Generates orient_mblation interrupt
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_orient_mbl_ud_enable(
+u8 v_orient_mbl_ud_u8)
+{
+/* variable used for return the status of communication result*/
+SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+	if (v_orient_mbl_ud_u8 <= SMI130_MAX_VALUE_ORIENT_UD) {
+		/* write orient_mbl up/down enable */
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+		(p_smi130->dev_addr,
+		SMI130_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE,
+			v_orient_mbl_ud_u8);
+			com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	} else {
+	com_rslt = E_SMI130_OUT_OF_RANGE;
+	}
+}
+return com_rslt;
+}
+ /*!
+ *	@brief This API read orient_mblation axes changes
+ *	from the register 0x66 bit 7
+ *
+ *  @param v_orient_mbl_axes_u8 : The value of orient_mbl axes assignment
+ *	value    |       Behaviour    | Name
+ * ----------|--------------------|------
+ *  0x00     | x = x, y = y, z = z|orient_mbl_ax_noex
+ *  0x01     | x = y, y = z, z = x|orient_mbl_ax_ex
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_orient_mbl_axes_enable(
+u8 *v_orient_mbl_axes_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read orient_mblation axes changes  */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_orient_mbl_axes_u8 = SMI130_GET_BITSLICE
+			(v_data_u8,
+			SMI130_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write orient_mblation axes changes
+ *	from the register 0x66 bit 7
+ *
+ *  @param v_orient_mbl_axes_u8 : The value of orient_mbl axes assignment
+ *	value    |       Behaviour    | Name
+ * ----------|--------------------|------
+ *  0x00     | x = x, y = y, z = z|orient_mbl_ax_noex
+ *  0x01     | x = y, y = z, z = x|orient_mbl_ax_ex
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_orient_mbl_axes_enable(
+u8 v_orient_mbl_axes_u8)
+{
+/* variable used for return the status of communication result*/
+SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+	if (v_orient_mbl_axes_u8 <= SMI130_MAX_VALUE_ORIENT_AXES) {
+		/*write orient_mblation axes changes  */
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+		(p_smi130->dev_addr,
+		SMI130_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX,
+			v_orient_mbl_axes_u8);
+			com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	} else {
+	com_rslt = E_SMI130_OUT_OF_RANGE;
+	}
+}
+return com_rslt;
+}
+ /*!
+ *	@brief This API read Flat angle (0 to 44.8) for flat interrupt
+ *	from the register 0x67 bit 0 to 5
+ *
+ *  @param v_flat_theta_u8 : The value of flat angle
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_flat_theta(
+u8 *v_flat_theta_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read Flat angle*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_INTR_FLAT_0_INTR_FLAT_THETA__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_flat_theta_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_FLAT_0_INTR_FLAT_THETA);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write Flat angle (0 to 44.8) for flat interrupt
+ *	from the register 0x67 bit 0 to 5
+ *
+ *  @param v_flat_theta_u8 : The value of flat angle
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_flat_theta(
+u8 v_flat_theta_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_flat_theta_u8 <= SMI130_MAX_FLAT_THETA) {
+			/* write Flat angle */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_INTR_FLAT_0_INTR_FLAT_THETA__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR_FLAT_0_INTR_FLAT_THETA,
+				v_flat_theta_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC
+				(p_smi130->dev_addr,
+				SMI130_USER_INTR_FLAT_0_INTR_FLAT_THETA__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read Flat interrupt hold time;
+ *	from the register 0x68 bit 4 and 5
+ *
+ *  @param v_flat_hold_u8 : The value of flat hold time
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | 0ms
+ *  0x01     | 512ms
+ *  0x01     | 1024ms
+ *  0x01     | 2048ms
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_flat_hold(
+u8 *v_flat_hold_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read flat hold time*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_INTR_FLAT_1_INTR_FLAT_HOLD__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_flat_hold_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_INTR_FLAT_1_INTR_FLAT_HOLD);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write Flat interrupt hold time;
+ *	from the register 0x68 bit 4 and 5
+ *
+ *  @param v_flat_hold_u8 : The value of flat hold time
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | 0ms
+ *  0x01     | 512ms
+ *  0x01     | 1024ms
+ *  0x01     | 2048ms
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_flat_hold(
+u8 v_flat_hold_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_flat_hold_u8 <= SMI130_MAX_FLAT_HOLD) {
+			/* write flat hold time*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_INTR_FLAT_1_INTR_FLAT_HOLD__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR_FLAT_1_INTR_FLAT_HOLD,
+				v_flat_hold_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC
+				(p_smi130->dev_addr,
+				SMI130_USER_INTR_FLAT_1_INTR_FLAT_HOLD__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read flat interrupt hysteresis
+ *	from the register 0x68 bit 0 to 3
+ *
+ *  @param v_flat_hyst_u8 : The value of flat hysteresis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_flat_hyst(
+u8 *v_flat_hyst_u8)
+{
+	/* variable used to return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the flat hysteresis*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_INTR_FLAT_1_INTR_FLAT_HYST__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_flat_hyst_u8 = SMI130_GET_BITSLICE(
+			v_data_u8,
+			SMI130_USER_INTR_FLAT_1_INTR_FLAT_HYST);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write flat interrupt hysteresis
+ *	from the register 0x68 bit 0 to 3
+ *
+ *  @param v_flat_hyst_u8 : The value of flat hysteresis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_flat_hyst(
+u8 v_flat_hyst_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_flat_hyst_u8 <= SMI130_MAX_FLAT_HYST) {
+			/* read the flat hysteresis*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_INTR_FLAT_1_INTR_FLAT_HYST__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_INTR_FLAT_1_INTR_FLAT_HYST,
+				v_flat_hyst_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC
+				(p_smi130->dev_addr,
+				SMI130_USER_INTR_FLAT_1_INTR_FLAT_HYST__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API read accel offset compensation
+ *	target value for z-axis from the register 0x69 bit 0 and 1
+ *
+ *  @param v_foc_accel_z_u8 : the value of accel offset compensation z axis
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_foc_accel_z(u8 *v_foc_accel_z_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the accel offset compensation for z axis*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_FOC_ACCEL_Z__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_foc_accel_z_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_FOC_ACCEL_Z);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write accel offset compensation
+ *	target value for z-axis from the register 0x69 bit 0 and 1
+ *
+ *  @param v_foc_accel_z_u8 : the value of accel offset compensation z axis
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_foc_accel_z(
+u8 v_foc_accel_z_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* write the accel offset compensation for z axis*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_FOC_ACCEL_Z__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_FOC_ACCEL_Z,
+				v_foc_accel_z_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC
+				(p_smi130->dev_addr,
+				SMI130_USER_FOC_ACCEL_Z__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read accel offset compensation
+ *	target value for y-axis
+ *	from the register 0x69 bit 2 and 3
+ *
+ *  @param v_foc_accel_y_u8 : the value of accel offset compensation y axis
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_foc_accel_y(u8 *v_foc_accel_y_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the accel offset compensation for y axis*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_FOC_ACCEL_Y__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_foc_accel_y_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_FOC_ACCEL_Y);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write accel offset compensation
+ *	target value for y-axis
+ *	from the register 0x69 bit 2 and 3
+ *
+ *  @param v_foc_accel_y_u8 : the value of accel offset compensation y axis
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x02     | -1g
+ *  0x03     | 0g
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_foc_accel_y(u8 v_foc_accel_y_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_foc_accel_y_u8 <= SMI130_MAX_ACCEL_FOC) {
+			/* write the accel offset compensation for y axis*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_FOC_ACCEL_Y__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_FOC_ACCEL_Y,
+				v_foc_accel_y_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC
+				(p_smi130->dev_addr,
+				SMI130_USER_FOC_ACCEL_Y__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read accel offset compensation
+ *	target value for x-axis is
+ *	from the register 0x69 bit 4 and 5
+ *
+ *  @param v_foc_accel_x_u8 : the value of accel offset compensation x axis
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x02     | -1g
+ *  0x03     | 0g
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_foc_accel_x(u8 *v_foc_accel_x_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		/* read the accel offset compensation for x axis*/
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+		p_smi130->dev_addr,
+		SMI130_USER_FOC_ACCEL_X__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		*v_foc_accel_x_u8 = SMI130_GET_BITSLICE(v_data_u8,
+		SMI130_USER_FOC_ACCEL_X);
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write accel offset compensation
+ *	target value for x-axis is
+ *	from the register 0x69 bit 4 and 5
+ *
+ *  @param v_foc_accel_x_u8 : the value of accel offset compensation x axis
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_foc_accel_x(u8 v_foc_accel_x_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_foc_accel_x_u8 <= SMI130_MAX_ACCEL_FOC) {
+			/* write the accel offset compensation for x axis*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_FOC_ACCEL_X__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_FOC_ACCEL_X,
+				v_foc_accel_x_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_FOC_ACCEL_X__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API writes accel fast offset compensation
+ *	from the register 0x69 bit 0 to 5
+ *	@brief This API writes each axis individually
+ *	FOC_X_AXIS - bit 4 and 5
+ *	FOC_Y_AXIS - bit 2 and 3
+ *	FOC_Z_AXIS - bit 0 and 1
+ *
+ *  @param  v_foc_accel_u8: The value of accel offset compensation
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *  @param  v_axis_u8: The value of accel offset axis selection
+  *	value    | axis
+ * ----------|-------------------
+ *  0        | FOC_X_AXIS
+ *  1        | FOC_Y_AXIS
+ *  2        | FOC_Z_AXIS
+ *
+ *	@param v_accel_offset_s8: The accel offset value
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_accel_foc_trigger(u8 v_axis_u8,
+u8 v_foc_accel_u8, s8 *v_accel_offset_s8)
+{
+/* variable used for return the status of communication result*/
+SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+s8 v_status_s8 = SUCCESS;
+u8 v_timeout_u8 = SMI130_INIT_VALUE;
+s8 v_foc_accel_offset_x_s8  = SMI130_INIT_VALUE;
+s8 v_foc_accel_offset_y_s8 =  SMI130_INIT_VALUE;
+s8 v_foc_accel_offset_z_s8 =  SMI130_INIT_VALUE;
+u8 focstatus = SMI130_INIT_VALUE;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+} else {
+	v_status_s8 = smi130_set_accel_offset_enable(
+	ACCEL_OFFSET_ENABLE);
+	if (v_status_s8 == SUCCESS) {
+		switch (v_axis_u8) {
+		case FOC_X_AXIS:
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_FOC_ACCEL_X__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 =
+				SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_FOC_ACCEL_X,
+				v_foc_accel_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_FOC_ACCEL_X__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+
+			/* trigger the
+			FOC need to write
+			0x03 in the register 0x7e*/
+			com_rslt +=
+			smi130_set_command_register(
+			START_FOC_ACCEL_GYRO);
+
+			com_rslt +=
+			smi130_get_foc_rdy(&focstatus);
+			if ((com_rslt != SUCCESS) ||
+			(focstatus != SMI130_FOC_STAT_HIGH)) {
+				while ((com_rslt != SUCCESS) ||
+				(focstatus != SMI130_FOC_STAT_HIGH
+				&& v_timeout_u8 <
+				SMI130_MAXIMUM_TIMEOUT)) {
+					p_smi130->delay_msec(
+					SMI130_DELAY_SETTLING_TIME);
+					com_rslt = smi130_get_foc_rdy(
+					&focstatus);
+					v_timeout_u8++;
+				}
+			}
+			if ((com_rslt == SUCCESS) &&
+				(focstatus == SMI130_FOC_STAT_HIGH)) {
+				com_rslt +=
+				smi130_get_accel_offset_compensation_xaxis(
+				&v_foc_accel_offset_x_s8);
+				*v_accel_offset_s8 =
+				v_foc_accel_offset_x_s8;
+			}
+		break;
+		case FOC_Y_AXIS:
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_FOC_ACCEL_Y__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 =
+				SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_FOC_ACCEL_Y,
+				v_foc_accel_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_FOC_ACCEL_Y__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+
+			/* trigger the FOC
+			need to write 0x03
+			in the register 0x7e*/
+			com_rslt +=
+			smi130_set_command_register(
+			START_FOC_ACCEL_GYRO);
+
+			com_rslt +=
+			smi130_get_foc_rdy(&focstatus);
+			if ((com_rslt != SUCCESS) ||
+			(focstatus != SMI130_FOC_STAT_HIGH)) {
+				while ((com_rslt != SUCCESS) ||
+				(focstatus != SMI130_FOC_STAT_HIGH
+				&& v_timeout_u8 <
+				SMI130_MAXIMUM_TIMEOUT)) {
+					p_smi130->delay_msec(
+					SMI130_DELAY_SETTLING_TIME);
+					com_rslt = smi130_get_foc_rdy(
+					&focstatus);
+					v_timeout_u8++;
+				}
+			}
+			if ((com_rslt == SUCCESS) &&
+			(focstatus == SMI130_FOC_STAT_HIGH)) {
+				com_rslt +=
+				smi130_get_accel_offset_compensation_yaxis(
+				&v_foc_accel_offset_y_s8);
+				*v_accel_offset_s8 =
+				v_foc_accel_offset_y_s8;
+			}
+		break;
+		case FOC_Z_AXIS:
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_FOC_ACCEL_Z__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 =
+				SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_FOC_ACCEL_Z,
+				v_foc_accel_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_FOC_ACCEL_Z__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+
+			/* trigger the FOC need to write
+			0x03 in the register 0x7e*/
+			com_rslt +=
+			smi130_set_command_register(
+			START_FOC_ACCEL_GYRO);
+
+			com_rslt +=
+			smi130_get_foc_rdy(&focstatus);
+			if ((com_rslt != SUCCESS) ||
+			(focstatus != SMI130_FOC_STAT_HIGH)) {
+				while ((com_rslt != SUCCESS) ||
+				(focstatus != SMI130_FOC_STAT_HIGH
+				&& v_timeout_u8 <
+				SMI130_MAXIMUM_TIMEOUT)) {
+					p_smi130->delay_msec(
+					SMI130_DELAY_SETTLING_TIME);
+					com_rslt = smi130_get_foc_rdy(
+					&focstatus);
+					v_timeout_u8++;
+				}
+			}
+			if ((com_rslt == SUCCESS) &&
+			(focstatus == SMI130_FOC_STAT_HIGH)) {
+				com_rslt +=
+				smi130_get_accel_offset_compensation_zaxis(
+				&v_foc_accel_offset_z_s8);
+				*v_accel_offset_s8 =
+				v_foc_accel_offset_z_s8;
+			}
+		break;
+		default:
+		break;
+		}
+	} else {
+	com_rslt =  ERROR;
+	}
+}
+return com_rslt;
+}
+/*!
+ *	@brief This API write fast accel offset compensation
+ *	it writes all axis together.To the register 0x69 bit 0 to 5
+ *	FOC_X_AXIS - bit 4 and 5
+ *	FOC_Y_AXIS - bit 2 and 3
+ *	FOC_Z_AXIS - bit 0 and 1
+ *
+ *  @param  v_foc_accel_x_u8: The value of accel offset x compensation
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *  @param  v_foc_accel_y_u8: The value of accel offset y compensation
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *  @param  v_foc_accel_z_u8: The value of accel offset z compensation
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *  @param  v_accel_off_x_s8: The value of accel offset x axis
+ *  @param  v_accel_off_y_s8: The value of accel offset y axis
+ *  @param  v_accel_off_z_s8: The value of accel offset z axis
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_accel_foc_trigger_xyz(u8 v_foc_accel_x_u8,
+u8 v_foc_accel_y_u8, u8 v_foc_accel_z_u8, s8 *v_accel_off_x_s8,
+s8 *v_accel_off_y_s8, s8 *v_accel_off_z_s8)
+{
+/* variable used for return the status of communication result*/
+SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 focx = SMI130_INIT_VALUE;
+u8 focy = SMI130_INIT_VALUE;
+u8 focz = SMI130_INIT_VALUE;
+s8 v_foc_accel_offset_x_s8 = SMI130_INIT_VALUE;
+s8 v_foc_accel_offset_y_s8 = SMI130_INIT_VALUE;
+s8 v_foc_accel_offset_z_s8 = SMI130_INIT_VALUE;
+u8 v_status_s8 = SUCCESS;
+u8 v_timeout_u8 = SMI130_INIT_VALUE;
+u8 focstatus = SMI130_INIT_VALUE;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+		v_status_s8 = smi130_set_accel_offset_enable(
+		ACCEL_OFFSET_ENABLE);
+		if (v_status_s8 == SUCCESS) {
+			/* foc x axis*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_FOC_ACCEL_X__REG,
+			&focx, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				focx = SMI130_SET_BITSLICE(focx,
+				SMI130_USER_FOC_ACCEL_X,
+				v_foc_accel_x_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_FOC_ACCEL_X__REG,
+				&focx, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+
+			/* foc y axis*/
+			com_rslt +=
+			p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_FOC_ACCEL_Y__REG,
+			&focy, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				focy = SMI130_SET_BITSLICE(focy,
+				SMI130_USER_FOC_ACCEL_Y,
+				v_foc_accel_y_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_FOC_ACCEL_Y__REG,
+				&focy, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+
+			/* foc z axis*/
+			com_rslt +=
+			p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_FOC_ACCEL_Z__REG,
+			&focz, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				focz = SMI130_SET_BITSLICE(focz,
+				SMI130_USER_FOC_ACCEL_Z,
+				v_foc_accel_z_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_FOC_ACCEL_Z__REG,
+				&focz, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+
+			/* trigger the FOC need to
+			write 0x03 in the register 0x7e*/
+			com_rslt += smi130_set_command_register(
+			START_FOC_ACCEL_GYRO);
+
+			com_rslt += smi130_get_foc_rdy(
+			&focstatus);
+			if ((com_rslt != SUCCESS) ||
+			(focstatus != SMI130_FOC_STAT_HIGH)) {
+				while ((com_rslt != SUCCESS) ||
+				(focstatus != SMI130_FOC_STAT_HIGH
+				&& v_timeout_u8 <
+				SMI130_MAXIMUM_TIMEOUT)) {
+					p_smi130->delay_msec(
+					SMI130_DELAY_SETTLING_TIME);
+					com_rslt = smi130_get_foc_rdy(
+					&focstatus);
+					v_timeout_u8++;
+				}
+			}
+			if ((com_rslt == SUCCESS) &&
+			(focstatus == SMI130_GEN_READ_WRITE_DATA_LENGTH)) {
+				com_rslt +=
+				smi130_get_accel_offset_compensation_xaxis(
+				&v_foc_accel_offset_x_s8);
+				*v_accel_off_x_s8 =
+				v_foc_accel_offset_x_s8;
+				com_rslt +=
+				smi130_get_accel_offset_compensation_yaxis(
+				&v_foc_accel_offset_y_s8);
+				*v_accel_off_y_s8 =
+				v_foc_accel_offset_y_s8;
+				com_rslt +=
+				smi130_get_accel_offset_compensation_zaxis(
+				&v_foc_accel_offset_z_s8);
+				*v_accel_off_z_s8 =
+				v_foc_accel_offset_z_s8;
+			}
+		} else {
+		com_rslt =  ERROR;
+		}
+	}
+return com_rslt;
+}
+/*!
+ *	@brief This API read gyro fast offset enable
+ *	from the register 0x69 bit 6
+ *
+ *  @param v_foc_gyro_u8 : The value of gyro fast offset enable
+ *  value    |  Description
+ * ----------|-------------
+ *    0      | fast offset compensation disabled
+ *    1      |  fast offset compensation enabled
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_foc_gyro_enable(
+u8 *v_foc_gyro_u8)
+{
+	/* used for return the status of bus communication */
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the gyro fast offset enable*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_FOC_GYRO_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_foc_gyro_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_FOC_GYRO_ENABLE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write gyro fast offset enable
+ *	from the register 0x69 bit 6
+ *
+ *  @param v_foc_gyro_u8 : The value of gyro fast offset enable
+ *  value    |  Description
+ * ----------|-------------
+ *    0      | fast offset compensation disabled
+ *    1      |  fast offset compensation enabled
+ *
+ *	@param v_gyro_off_x_s16 : The value of gyro fast offset x axis data
+ *	@param v_gyro_off_y_s16 : The value of gyro fast offset y axis data
+ *	@param v_gyro_off_z_s16 : The value of gyro fast offset z axis data
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_foc_gyro_enable(
+u8 v_foc_gyro_u8, s16 *v_gyro_off_x_s16,
+s16 *v_gyro_off_y_s16, s16 *v_gyro_off_z_s16)
+{
+/* variable used for return the status of communication result*/
+SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+u8 v_status_s8 = SUCCESS;
+u8 v_timeout_u8 = SMI130_INIT_VALUE;
+s16 offsetx = SMI130_INIT_VALUE;
+s16 offsety = SMI130_INIT_VALUE;
+s16 offsetz = SMI130_INIT_VALUE;
+u8 focstatus = SMI130_INIT_VALUE;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+		v_status_s8 = smi130_set_gyro_offset_enable(
+		GYRO_OFFSET_ENABLE);
+		if (v_status_s8 == SUCCESS) {
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_FOC_GYRO_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 =
+				SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_FOC_GYRO_ENABLE,
+				v_foc_gyro_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC
+				(p_smi130->dev_addr,
+				SMI130_USER_FOC_GYRO_ENABLE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+
+			/* trigger the FOC need to write 0x03
+			in the register 0x7e*/
+			com_rslt += smi130_set_command_register
+			(START_FOC_ACCEL_GYRO);
+
+			com_rslt += smi130_get_foc_rdy(&focstatus);
+			if ((com_rslt != SUCCESS) ||
+			(focstatus != SMI130_FOC_STAT_HIGH)) {
+				while ((com_rslt != SUCCESS) ||
+				(focstatus != SMI130_FOC_STAT_HIGH
+				&& v_timeout_u8 <
+				SMI130_MAXIMUM_TIMEOUT)) {
+					p_smi130->delay_msec(
+					SMI130_DELAY_SETTLING_TIME);
+					com_rslt = smi130_get_foc_rdy(
+					&focstatus);
+					v_timeout_u8++;
+				}
+			}
+			if ((com_rslt == SUCCESS) &&
+			(focstatus == SMI130_FOC_STAT_HIGH)) {
+				com_rslt +=
+				smi130_get_gyro_offset_compensation_xaxis
+				(&offsetx);
+				*v_gyro_off_x_s16 = offsetx;
+
+				com_rslt +=
+				smi130_get_gyro_offset_compensation_yaxis
+				(&offsety);
+				*v_gyro_off_y_s16 = offsety;
+
+				com_rslt +=
+				smi130_get_gyro_offset_compensation_zaxis(
+				&offsetz);
+				*v_gyro_off_z_s16 = offsetz;
+			}
+		} else {
+		com_rslt = ERROR;
+		}
+	}
+return com_rslt;
+}
+ /*!
+ *	@brief This API read NVM program enable
+ *	from the register 0x6A bit 1
+ *
+ *  @param v_nvm_prog_u8 : The value of NVM program enable
+ *  Value  |  Description
+ * --------|-------------
+ *   0     |  DISABLE
+ *   1     |  ENABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_nvm_prog_enable(
+u8 *v_nvm_prog_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read NVM program*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_CONFIG_NVM_PROG_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_nvm_prog_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_CONFIG_NVM_PROG_ENABLE);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write NVM program enable
+ *	from the register 0x6A bit 1
+ *
+ *  @param v_nvm_prog_u8 : The value of NVM program enable
+ *  Value  |  Description
+ * --------|-------------
+ *   0     |  DISABLE
+ *   1     |  ENABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_nvm_prog_enable(
+u8 v_nvm_prog_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_nvm_prog_u8 <= SMI130_MAX_VALUE_NVM_PROG) {
+			/* write the NVM program*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_CONFIG_NVM_PROG_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_CONFIG_NVM_PROG_ENABLE,
+				v_nvm_prog_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_CONFIG_NVM_PROG_ENABLE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ * @brief This API read to configure SPI
+ * Interface Mode for primary and OIS interface
+ * from the register 0x6B bit 0
+ *
+ *  @param v_spi3_u8 : The value of SPI mode selection
+ *  Value  |  Description
+ * --------|-------------
+ *   0     |  SPI 4-wire mode
+ *   1     |  SPI 3-wire mode
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_get_spi3(
+u8 *v_spi3_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read SPI mode*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_IF_CONFIG_SPI3__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_spi3_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_IF_CONFIG_SPI3);
+		}
+	return com_rslt;
+}
+/*!
+ * @brief This API write to configure SPI
+ * Interface Mode for primary and OIS interface
+ * from the register 0x6B bit 0
+ *
+ *  @param v_spi3_u8 : The value of SPI mode selection
+ *  Value  |  Description
+ * --------|-------------
+ *   0     |  SPI 4-wire mode
+ *   1     |  SPI 3-wire mode
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_set_spi3(
+u8 v_spi3_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_spi3_u8 <= SMI130_MAX_VALUE_SPI3) {
+			/* write SPI mode*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_IF_CONFIG_SPI3__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_IF_CONFIG_SPI3,
+				v_spi3_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_IF_CONFIG_SPI3__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read I2C Watchdog timer
+ *	from the register 0x70 bit 1
+ *
+ *  @param v_i2c_wdt_u8 : The value of I2C watch dog timer
+ *  Value  |  Description
+ * --------|-------------
+ *   0     |  I2C watchdog v_timeout_u8 after 1 ms
+ *   1     |  I2C watchdog v_timeout_u8 after 50 ms
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_i2c_wdt_select(
+u8 *v_i2c_wdt_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read I2C watch dog timer */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_IF_CONFIG_I2C_WDT_SELECT__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_i2c_wdt_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_IF_CONFIG_I2C_WDT_SELECT);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write I2C Watchdog timer
+ *	from the register 0x70 bit 1
+ *
+ *  @param v_i2c_wdt_u8 : The value of I2C watch dog timer
+ *  Value  |  Description
+ * --------|-------------
+ *   0     |  I2C watchdog v_timeout_u8 after 1 ms
+ *   1     |  I2C watchdog v_timeout_u8 after 50 ms
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_i2c_wdt_select(
+u8 v_i2c_wdt_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_i2c_wdt_u8 <= SMI130_MAX_VALUE_I2C_WDT) {
+			/* write I2C watch dog timer */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_IF_CONFIG_I2C_WDT_SELECT__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_IF_CONFIG_I2C_WDT_SELECT,
+				v_i2c_wdt_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_IF_CONFIG_I2C_WDT_SELECT__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read I2C watchdog enable
+ *	from the register 0x70 bit 2
+ *
+ *  @param v_i2c_wdt_u8 : The value of I2C watchdog enable
+ *  Value  |  Description
+ * --------|-------------
+ *   0     |  DISABLE
+ *   1     |  ENABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_i2c_wdt_enable(
+u8 *v_i2c_wdt_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read i2c watch dog eneble */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_IF_CONFIG_I2C_WDT_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_i2c_wdt_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_IF_CONFIG_I2C_WDT_ENABLE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write I2C watchdog enable
+ *	from the register 0x70 bit 2
+ *
+ *  @param v_i2c_wdt_u8 : The value of I2C watchdog enable
+ *  Value  |  Description
+ * --------|-------------
+ *   0     |  DISABLE
+ *   1     |  ENABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_i2c_wdt_enable(
+u8 v_i2c_wdt_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_i2c_wdt_u8 <= SMI130_MAX_VALUE_I2C_WDT) {
+			/* write i2c watch dog eneble */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_IF_CONFIG_I2C_WDT_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_IF_CONFIG_I2C_WDT_ENABLE,
+				v_i2c_wdt_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_IF_CONFIG_I2C_WDT_ENABLE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ * @brief This API read I2C interface configuration(if) moe
+ * from the register 0x6B bit 4 and 5
+ *
+ *  @param  v_if_mode_u8 : The value of interface configuration mode
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  |  Primary interface:autoconfig / secondary interface:off
+ *   0x01  |  Primary interface:I2C / secondary interface:OIS
+ *   0x02  |  Primary interface:autoconfig/secondary interface:Magnetometer
+ *   0x03  |   Reserved
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_if_mode(
+u8 *v_if_mode_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read if mode*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_IF_CONFIG_IF_MODE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_if_mode_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_IF_CONFIG_IF_MODE);
+		}
+	return com_rslt;
+}
+/*!
+ * @brief This API write I2C interface configuration(if) moe
+ * from the register 0x6B bit 4 and 5
+ *
+ *  @param  v_if_mode_u8 : The value of interface configuration mode
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  |  Primary interface:autoconfig / secondary interface:off
+ *   0x01  |  Primary interface:I2C / secondary interface:OIS
+ *   0x02  |  Primary interface:autoconfig/secondary interface:Magnetometer
+ *   0x03  |   Reserved
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_if_mode(
+u8 v_if_mode_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_if_mode_u8 <= SMI130_MAX_IF_MODE) {
+			/* write if mode*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_IF_CONFIG_IF_MODE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_IF_CONFIG_IF_MODE,
+				v_if_mode_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_IF_CONFIG_IF_MODE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read gyro sleep trigger
+ *	from the register 0x6C bit 0 to 2
+ *
+ *  @param v_gyro_sleep_trigger_u8 : The value of gyro sleep trigger
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | nomotion: no / Not INT1 pin: no / INT2 pin: no
+ *   0x01  | nomotion: no / Not INT1 pin: no / INT2 pin: yes
+ *   0x02  | nomotion: no / Not INT1 pin: yes / INT2 pin: no
+ *   0x03  | nomotion: no / Not INT1 pin: yes / INT2 pin: yes
+ *   0x04  | nomotion: yes / Not INT1 pin: no / INT2 pin: no
+ *   0x05  | anymotion: yes / Not INT1 pin: no / INT2 pin: yes
+ *   0x06  | anymotion: yes / Not INT1 pin: yes / INT2 pin: no
+ *   0x07  | anymotion: yes / Not INT1 pin: yes / INT2 pin: yes
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_gyro_sleep_trigger(
+u8 *v_gyro_sleep_trigger_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read gyro sleep trigger */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_GYRO_SLEEP_TRIGGER__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_gyro_sleep_trigger_u8 =
+			SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_GYRO_SLEEP_TRIGGER);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write gyro sleep trigger
+ *	from the register 0x6C bit 0 to 2
+ *
+ *  @param v_gyro_sleep_trigger_u8 : The value of gyro sleep trigger
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | nomotion: no / Not INT1 pin: no / INT2 pin: no
+ *   0x01  | nomotion: no / Not INT1 pin: no / INT2 pin: yes
+ *   0x02  | nomotion: no / Not INT1 pin: yes / INT2 pin: no
+ *   0x03  | nomotion: no / Not INT1 pin: yes / INT2 pin: yes
+ *   0x04  | nomotion: yes / Not INT1 pin: no / INT2 pin: no
+ *   0x05  | anymotion: yes / Not INT1 pin: no / INT2 pin: yes
+ *   0x06  | anymotion: yes / Not INT1 pin: yes / INT2 pin: no
+ *   0x07  | anymotion: yes / Not INT1 pin: yes / INT2 pin: yes
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_gyro_sleep_trigger(
+u8 v_gyro_sleep_trigger_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_gyro_sleep_trigger_u8 <= SMI130_MAX_GYRO_SLEEP_TIGGER) {
+			/* write gyro sleep trigger */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_GYRO_SLEEP_TRIGGER__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_GYRO_SLEEP_TRIGGER,
+				v_gyro_sleep_trigger_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_GYRO_SLEEP_TRIGGER__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read gyro wakeup trigger
+ *	from the register 0x6C bit 3 and 4
+ *
+ *  @param v_gyro_wakeup_trigger_u8 : The value of gyro wakeup trigger
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | anymotion: no / INT1 pin: no
+ *   0x01  | anymotion: no / INT1 pin: yes
+ *   0x02  | anymotion: yes / INT1 pin: no
+ *   0x03  | anymotion: yes / INT1 pin: yes
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_gyro_wakeup_trigger(
+u8 *v_gyro_wakeup_trigger_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read gyro wakeup trigger */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_GYRO_WAKEUP_TRIGGER__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_gyro_wakeup_trigger_u8 = SMI130_GET_BITSLICE(
+			v_data_u8,
+			SMI130_USER_GYRO_WAKEUP_TRIGGER);
+	  }
+	return com_rslt;
+}
+/*!
+ *	@brief This API write gyro wakeup trigger
+ *	from the register 0x6C bit 3 and 4
+ *
+ *  @param v_gyro_wakeup_trigger_u8 : The value of gyro wakeup trigger
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | anymotion: no / INT1 pin: no
+ *   0x01  | anymotion: no / INT1 pin: yes
+ *   0x02  | anymotion: yes / INT1 pin: no
+ *   0x03  | anymotion: yes / INT1 pin: yes
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_gyro_wakeup_trigger(
+u8 v_gyro_wakeup_trigger_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_gyro_wakeup_trigger_u8
+		<= SMI130_MAX_GYRO_WAKEUP_TRIGGER) {
+			/* write gyro wakeup trigger */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_GYRO_WAKEUP_TRIGGER__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_GYRO_WAKEUP_TRIGGER,
+				v_gyro_wakeup_trigger_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_GYRO_WAKEUP_TRIGGER__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read Target state for gyro sleep mode
+ *	from the register 0x6C bit 5
+ *
+ *  @param v_gyro_sleep_state_u8 : The value of gyro sleep mode
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | Sleep transition to fast wake up state
+ *   0x01  | Sleep transition to suspend state
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_gyro_sleep_state(
+u8 *v_gyro_sleep_state_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read gyro sleep state*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_GYRO_SLEEP_STATE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_gyro_sleep_state_u8 = SMI130_GET_BITSLICE(
+			v_data_u8,
+			SMI130_USER_GYRO_SLEEP_STATE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write Target state for gyro sleep mode
+ *	from the register 0x6C bit 5
+ *
+ *  @param v_gyro_sleep_state_u8 : The value of gyro sleep mode
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | Sleep transition to fast wake up state
+ *   0x01  | Sleep transition to suspend state
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_gyro_sleep_state(
+u8 v_gyro_sleep_state_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_gyro_sleep_state_u8 <= SMI130_MAX_VALUE_SLEEP_STATE) {
+			/* write gyro sleep state*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_GYRO_SLEEP_STATE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_GYRO_SLEEP_STATE,
+				v_gyro_sleep_state_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_GYRO_SLEEP_STATE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read gyro wakeup interrupt
+ *	from the register 0x6C bit 6
+ *
+ *  @param v_gyro_wakeup_intr_u8 : The valeu of gyro wakeup interrupt
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | DISABLE
+ *   0x01  | ENABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_gyro_wakeup_intr(
+u8 *v_gyro_wakeup_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read gyro wakeup interrupt */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_GYRO_WAKEUP_INTR__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_gyro_wakeup_intr_u8 = SMI130_GET_BITSLICE(
+			v_data_u8,
+			SMI130_USER_GYRO_WAKEUP_INTR);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write gyro wakeup interrupt
+ *	from the register 0x6C bit 6
+ *
+ *  @param v_gyro_wakeup_intr_u8 : The valeu of gyro wakeup interrupt
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | DISABLE
+ *   0x01  | ENABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_gyro_wakeup_intr(
+u8 v_gyro_wakeup_intr_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_gyro_wakeup_intr_u8 <= SMI130_MAX_VALUE_WAKEUP_INTR) {
+			/* write gyro wakeup interrupt */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_GYRO_WAKEUP_INTR__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_GYRO_WAKEUP_INTR,
+				v_gyro_wakeup_intr_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_GYRO_WAKEUP_INTR__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ * @brief This API read accel select axis to be self-test
+ *
+ *  @param v_accel_selftest_axis_u8 :
+ *	The value of accel self test axis selection
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | disabled
+ *   0x01  | x-axis
+ *   0x02  | y-axis
+ *   0x03  | z-axis
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_accel_selftest_axis(
+u8 *v_accel_selftest_axis_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read accel self test axis*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_ACCEL_SELFTEST_AXIS__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_accel_selftest_axis_u8 = SMI130_GET_BITSLICE(
+			v_data_u8,
+			SMI130_USER_ACCEL_SELFTEST_AXIS);
+		}
+	return com_rslt;
+}
+/*!
+ * @brief This API write accel select axis to be self-test
+ *
+ *  @param v_accel_selftest_axis_u8 :
+ *	The value of accel self test axis selection
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | disabled
+ *   0x01  | x-axis
+ *   0x02  | y-axis
+ *   0x03  | z-axis
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_accel_selftest_axis(
+u8 v_accel_selftest_axis_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_accel_selftest_axis_u8
+		<= SMI130_MAX_ACCEL_SELFTEST_AXIS) {
+			/* write accel self test axis*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_ACCEL_SELFTEST_AXIS__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_ACCEL_SELFTEST_AXIS,
+				v_accel_selftest_axis_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_ACCEL_SELFTEST_AXIS__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read accel self test axis sign
+ *	from the register 0x6D bit 2
+ *
+ *  @param v_accel_selftest_sign_u8: The value of accel self test axis sign
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | negative
+ *   0x01  | positive
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_accel_selftest_sign(
+u8 *v_accel_selftest_sign_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read accel self test axis sign*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_ACCEL_SELFTEST_SIGN__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_accel_selftest_sign_u8 = SMI130_GET_BITSLICE(
+			v_data_u8,
+			SMI130_USER_ACCEL_SELFTEST_SIGN);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write accel self test axis sign
+ *	from the register 0x6D bit 2
+ *
+ *  @param v_accel_selftest_sign_u8: The value of accel self test axis sign
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | negative
+ *   0x01  | positive
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_accel_selftest_sign(
+u8 v_accel_selftest_sign_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_accel_selftest_sign_u8 <=
+		SMI130_MAX_VALUE_SELFTEST_SIGN) {
+			/* write accel self test axis sign*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_ACCEL_SELFTEST_SIGN__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_ACCEL_SELFTEST_SIGN,
+				v_accel_selftest_sign_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_ACCEL_SELFTEST_SIGN__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+			com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read accel self test amplitude
+ *	from the register 0x6D bit 3
+ *        select amplitude of the selftest deflection:
+ *
+ *  @param v_accel_selftest_amp_u8 : The value of accel self test amplitude
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | LOW
+ *   0x01  | HIGH
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_accel_selftest_amp(
+u8 *v_accel_selftest_amp_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read  self test amplitude*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_SELFTEST_AMP__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_accel_selftest_amp_u8 = SMI130_GET_BITSLICE(
+			v_data_u8,
+			SMI130_USER_SELFTEST_AMP);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write accel self test amplitude
+ *	from the register 0x6D bit 3
+ *        select amplitude of the selftest deflection:
+ *
+ *  @param v_accel_selftest_amp_u8 : The value of accel self test amplitude
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | LOW
+ *   0x01  | HIGH
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_accel_selftest_amp(
+u8 v_accel_selftest_amp_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_accel_selftest_amp_u8 <=
+		SMI130_MAX_VALUE_SELFTEST_AMP) {
+			/* write  self test amplitude*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_SELFTEST_AMP__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_SELFTEST_AMP,
+				v_accel_selftest_amp_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_SELFTEST_AMP__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read gyro self test trigger
+ *
+ *	@param v_gyro_selftest_start_u8: The value of gyro self test start
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_gyro_selftest_start(
+u8 *v_gyro_selftest_start_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read gyro self test start */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_GYRO_SELFTEST_START__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_gyro_selftest_start_u8 = SMI130_GET_BITSLICE(
+			v_data_u8,
+			SMI130_USER_GYRO_SELFTEST_START);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write gyro self test trigger
+ *
+ *	@param v_gyro_selftest_start_u8: The value of gyro self test start
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_gyro_selftest_start(
+u8 v_gyro_selftest_start_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_gyro_selftest_start_u8 <=
+		SMI130_MAX_VALUE_SELFTEST_START) {
+			/* write gyro self test start */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_GYRO_SELFTEST_START__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_GYRO_SELFTEST_START,
+				v_gyro_selftest_start_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_GYRO_SELFTEST_START__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+ /*!
+ * @brief This API read primary interface selection I2C or SPI
+ *	from the register 0x70 bit 0
+ *
+ *  @param v_spi_enable_u8: The value of Interface selection
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | I2C Enable
+ *   0x01  | I2C DISBALE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_spi_enable(u8 *v_spi_enable_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read interface section*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_NV_CONFIG_SPI_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_spi_enable_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_NV_CONFIG_SPI_ENABLE);
+		}
+	return com_rslt;
+}
+ /*!
+ * @brief This API write primary interface selection I2C or SPI
+ *	from the register 0x70 bit 0
+ *
+ *  @param v_spi_enable_u8: The value of Interface selection
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | I2C Enable
+ *   0x01  | I2C DISBALE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_spi_enable(u8 v_spi_enable_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* write interface section*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_NV_CONFIG_SPI_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_NV_CONFIG_SPI_ENABLE,
+				v_spi_enable_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC
+				(p_smi130->dev_addr,
+				SMI130_USER_NV_CONFIG_SPI_ENABLE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API read the spare zero
+ *	form register 0x70 bit 3
+ *
+ *
+ *  @param v_spare0_trim_u8: The value of spare zero
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_spare0_trim(u8 *v_spare0_trim_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read spare zero*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_NV_CONFIG_SPARE0__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_spare0_trim_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_NV_CONFIG_SPARE0);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write the spare zero
+ *	form register 0x70 bit 3
+ *
+ *
+ *  @param v_spare0_trim_u8: The value of spare zero
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_spare0_trim(u8 v_spare0_trim_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* write  spare zero*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_NV_CONFIG_SPARE0__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_NV_CONFIG_SPARE0,
+				v_spare0_trim_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_NV_CONFIG_SPARE0__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API read the NVM counter
+ *	form register 0x70 bit 4 to 7
+ *
+ *
+ *  @param v_nvm_counter_u8: The value of NVM counter
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_nvm_counter(u8 *v_nvm_counter_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read NVM counter*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_NV_CONFIG_NVM_COUNTER__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_nvm_counter_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_NV_CONFIG_NVM_COUNTER);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write the NVM counter
+ *	form register 0x70 bit 4 to 7
+ *
+ *
+ *  @param v_nvm_counter_u8: The value of NVM counter
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_nvm_counter(
+u8 v_nvm_counter_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* write NVM counter*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_NV_CONFIG_NVM_COUNTER__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_NV_CONFIG_NVM_COUNTER,
+				v_nvm_counter_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_NV_CONFIG_NVM_COUNTER__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read accel manual offset compensation of x axis
+ *	from the register 0x71 bit 0 to 7
+ *
+ *
+ *
+ *  @param v_accel_off_x_s8:
+ *	The value of accel manual offset compensation of x axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_accel_offset_compensation_xaxis(
+s8 *v_accel_off_x_s8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read accel manual offset compensation of x axis*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_OFFSET_0_ACCEL_OFF_X__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_accel_off_x_s8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_OFFSET_0_ACCEL_OFF_X);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write accel manual offset compensation of x axis
+ *	from the register 0x71 bit 0 to 7
+ *
+ *
+ *
+ *  @param v_accel_off_x_s8:
+ *	The value of accel manual offset compensation of x axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_accel_offset_compensation_xaxis(
+s8 v_accel_off_x_s8)
+{
+/* variable used for return the status of communication result*/
+SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+u8 v_status_s8 = SUCCESS;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+		/* enable accel offset */
+		v_status_s8 = smi130_set_accel_offset_enable(
+		ACCEL_OFFSET_ENABLE);
+		if (v_status_s8 == SUCCESS) {
+			/* write accel manual offset compensation of x axis*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_OFFSET_0_ACCEL_OFF_X__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 =
+				SMI130_SET_BITSLICE(
+				v_data_u8,
+				SMI130_USER_OFFSET_0_ACCEL_OFF_X,
+				v_accel_off_x_s8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_OFFSET_0_ACCEL_OFF_X__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt =  ERROR;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read accel manual offset compensation of y axis
+ *	from the register 0x72 bit 0 to 7
+ *
+ *
+ *
+ *  @param v_accel_off_y_s8:
+ *	The value of accel manual offset compensation of y axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_accel_offset_compensation_yaxis(
+s8 *v_accel_off_y_s8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read accel manual offset compensation of y axis*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_OFFSET_1_ACCEL_OFF_Y__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_accel_off_y_s8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_OFFSET_1_ACCEL_OFF_Y);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write accel manual offset compensation of y axis
+ *	from the register 0x72 bit 0 to 7
+ *
+ *
+ *
+ *  @param v_accel_off_y_s8:
+ *	The value of accel manual offset compensation of y axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_accel_offset_compensation_yaxis(
+s8 v_accel_off_y_s8)
+{
+/* variable used for return the status of communication result*/
+SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+u8 v_status_s8 = SUCCESS;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+		/* enable accel offset */
+		v_status_s8 = smi130_set_accel_offset_enable(
+		ACCEL_OFFSET_ENABLE);
+		if (v_status_s8 == SUCCESS) {
+			/* write accel manual offset compensation of y axis*/
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_OFFSET_1_ACCEL_OFF_Y__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 =
+				SMI130_SET_BITSLICE(
+				v_data_u8,
+				SMI130_USER_OFFSET_1_ACCEL_OFF_Y,
+				v_accel_off_y_s8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_OFFSET_1_ACCEL_OFF_Y__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = ERROR;
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read accel manual offset compensation of z axis
+ *	from the register 0x73 bit 0 to 7
+ *
+ *
+ *
+ *  @param v_accel_off_z_s8:
+ *	The value of accel manual offset compensation of z axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_accel_offset_compensation_zaxis(
+s8 *v_accel_off_z_s8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read accel manual offset compensation of z axis*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_OFFSET_2_ACCEL_OFF_Z__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_accel_off_z_s8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_OFFSET_2_ACCEL_OFF_Z);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write accel manual offset compensation of z axis
+ *	from the register 0x73 bit 0 to 7
+ *
+ *
+ *
+ *  @param v_accel_off_z_s8:
+ *	The value of accel manual offset compensation of z axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_accel_offset_compensation_zaxis(
+s8 v_accel_off_z_s8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	u8 v_status_s8 = SUCCESS;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* enable accel offset */
+			v_status_s8 = smi130_set_accel_offset_enable(
+			ACCEL_OFFSET_ENABLE);
+			if (v_status_s8 == SUCCESS) {
+				/* write accel manual offset
+				compensation of z axis*/
+				com_rslt =
+				p_smi130->SMI130_BUS_READ_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_OFFSET_2_ACCEL_OFF_Z__REG,
+				&v_data_u8,
+				SMI130_GEN_READ_WRITE_DATA_LENGTH);
+				if (com_rslt == SUCCESS) {
+					v_data_u8 =
+					SMI130_SET_BITSLICE(v_data_u8,
+					SMI130_USER_OFFSET_2_ACCEL_OFF_Z,
+					v_accel_off_z_s8);
+					com_rslt +=
+					p_smi130->SMI130_BUS_WRITE_FUNC(
+					p_smi130->dev_addr,
+					SMI130_USER_OFFSET_2_ACCEL_OFF_Z__REG,
+					&v_data_u8,
+					SMI130_GEN_READ_WRITE_DATA_LENGTH);
+				}
+			} else {
+			com_rslt = ERROR;
+			}
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read gyro manual offset compensation of x axis
+ *	from the register 0x74 bit 0 to 7 and 0x77 bit 0 and 1
+ *
+ *
+ *
+ *  @param v_gyro_off_x_s16:
+ *	The value of gyro manual offset compensation of x axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_gyro_offset_compensation_xaxis(
+s16 *v_gyro_off_x_s16)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data1_u8r = SMI130_INIT_VALUE;
+	u8 v_data2_u8r = SMI130_INIT_VALUE;
+	s16 v_data3_u8r, v_data4_u8r = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read gyro offset x*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_OFFSET_3_GYRO_OFF_X__REG,
+			&v_data1_u8r, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			v_data1_u8r = SMI130_GET_BITSLICE(v_data1_u8r,
+			SMI130_USER_OFFSET_3_GYRO_OFF_X);
+			com_rslt += p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_OFFSET_6_GYRO_OFF_X__REG,
+			&v_data2_u8r, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			v_data2_u8r = SMI130_GET_BITSLICE(v_data2_u8r,
+			SMI130_USER_OFFSET_6_GYRO_OFF_X);
+			v_data3_u8r = v_data2_u8r
+			<< SMI130_SHIFT_BIT_POSITION_BY_14_BITS;
+			v_data4_u8r =  v_data1_u8r
+			<< SMI130_SHIFT_BIT_POSITION_BY_06_BITS;
+			v_data3_u8r = v_data3_u8r | v_data4_u8r;
+			*v_gyro_off_x_s16 = v_data3_u8r
+			>> SMI130_SHIFT_BIT_POSITION_BY_06_BITS;
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write gyro manual offset compensation of x axis
+ *	from the register 0x74 bit 0 to 7 and 0x77 bit 0 and 1
+ *
+ *
+ *
+ *  @param v_gyro_off_x_s16:
+ *	The value of gyro manual offset compensation of x axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_gyro_offset_compensation_xaxis(
+s16 v_gyro_off_x_s16)
+{
+/* variable used for return the status of communication result*/
+SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_data1_u8r, v_data2_u8r = SMI130_INIT_VALUE;
+u16 v_data3_u8r = SMI130_INIT_VALUE;
+u8 v_status_s8 = SUCCESS;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+		/* write gyro offset x*/
+		v_status_s8 = smi130_set_gyro_offset_enable(
+		GYRO_OFFSET_ENABLE);
+		if (v_status_s8 == SUCCESS) {
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_OFFSET_3_GYRO_OFF_X__REG,
+			&v_data2_u8r, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data1_u8r =
+				((s8) (v_gyro_off_x_s16 &
+				SMI130_GYRO_MANUAL_OFFSET_0_7));
+				v_data2_u8r = SMI130_SET_BITSLICE(
+				v_data2_u8r,
+				SMI130_USER_OFFSET_3_GYRO_OFF_X,
+				v_data1_u8r);
+				/* write 0x74 bit 0 to 7*/
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_OFFSET_3_GYRO_OFF_X__REG,
+				&v_data2_u8r,
+				SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+
+			com_rslt += p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_OFFSET_6_GYRO_OFF_X__REG,
+			&v_data2_u8r, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data3_u8r =
+				(u16) (v_gyro_off_x_s16 &
+				SMI130_GYRO_MANUAL_OFFSET_8_9);
+				v_data1_u8r = (u8)(v_data3_u8r
+				>> SMI130_SHIFT_BIT_POSITION_BY_08_BITS);
+				v_data2_u8r = SMI130_SET_BITSLICE(
+				v_data2_u8r,
+				SMI130_USER_OFFSET_6_GYRO_OFF_X,
+				v_data1_u8r);
+				/* write 0x77 bit 0 and 1*/
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_OFFSET_6_GYRO_OFF_X__REG,
+				&v_data2_u8r,
+				SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		return ERROR;
+		}
+	}
+return com_rslt;
+}
+/*!
+ *	@brief This API read gyro manual offset compensation of y axis
+ *	from the register 0x75 bit 0 to 7 and 0x77 bit 2 and 3
+ *
+ *
+ *
+ *  @param v_gyro_off_y_s16:
+ *	The value of gyro manual offset compensation of y axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_gyro_offset_compensation_yaxis(
+s16 *v_gyro_off_y_s16)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data1_u8r = SMI130_INIT_VALUE;
+	u8 v_data2_u8r = SMI130_INIT_VALUE;
+	s16 v_data3_u8r, v_data4_u8r = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read gyro offset y*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_OFFSET_4_GYRO_OFF_Y__REG,
+			&v_data1_u8r, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			v_data1_u8r = SMI130_GET_BITSLICE(v_data1_u8r,
+			SMI130_USER_OFFSET_4_GYRO_OFF_Y);
+			com_rslt += p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_OFFSET_6_GYRO_OFF_Y__REG,
+			&v_data2_u8r, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			v_data2_u8r = SMI130_GET_BITSLICE(v_data2_u8r,
+			SMI130_USER_OFFSET_6_GYRO_OFF_Y);
+			v_data3_u8r = v_data2_u8r
+			<< SMI130_SHIFT_BIT_POSITION_BY_14_BITS;
+			v_data4_u8r =  v_data1_u8r
+			<< SMI130_SHIFT_BIT_POSITION_BY_06_BITS;
+			v_data3_u8r = v_data3_u8r | v_data4_u8r;
+			*v_gyro_off_y_s16 = v_data3_u8r
+			>> SMI130_SHIFT_BIT_POSITION_BY_06_BITS;
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write gyro manual offset compensation of y axis
+ *	from the register 0x75 bit 0 to 7 and 0x77 bit 2 and 3
+ *
+ *
+ *
+ *  @param v_gyro_off_y_s16:
+ *	The value of gyro manual offset compensation of y axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_gyro_offset_compensation_yaxis(
+s16 v_gyro_off_y_s16)
+{
+/* variable used for return the status of communication result*/
+SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_data1_u8r, v_data2_u8r = SMI130_INIT_VALUE;
+u16 v_data3_u8r = SMI130_INIT_VALUE;
+u8 v_status_s8 = SUCCESS;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+		/* enable gyro offset bit */
+		v_status_s8 = smi130_set_gyro_offset_enable(
+		GYRO_OFFSET_ENABLE);
+		/* write gyro offset y*/
+		if (v_status_s8 == SUCCESS) {
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_OFFSET_4_GYRO_OFF_Y__REG,
+			&v_data2_u8r, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data1_u8r =
+				((s8) (v_gyro_off_y_s16 &
+				SMI130_GYRO_MANUAL_OFFSET_0_7));
+				v_data2_u8r = SMI130_SET_BITSLICE(
+				v_data2_u8r,
+				SMI130_USER_OFFSET_4_GYRO_OFF_Y,
+				v_data1_u8r);
+				/* write 0x75 bit 0 to 7*/
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC
+				(p_smi130->dev_addr,
+				SMI130_USER_OFFSET_4_GYRO_OFF_Y__REG,
+				&v_data2_u8r,
+				SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+
+			com_rslt += p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_OFFSET_6_GYRO_OFF_Y__REG,
+			&v_data2_u8r, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data3_u8r =
+				(u16) (v_gyro_off_y_s16 &
+				SMI130_GYRO_MANUAL_OFFSET_8_9);
+				v_data1_u8r = (u8)(v_data3_u8r
+				>> SMI130_SHIFT_BIT_POSITION_BY_08_BITS);
+				v_data2_u8r = SMI130_SET_BITSLICE(
+				v_data2_u8r,
+				SMI130_USER_OFFSET_6_GYRO_OFF_Y,
+				v_data1_u8r);
+				/* write 0x77 bit 2 and 3*/
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC
+				(p_smi130->dev_addr,
+				SMI130_USER_OFFSET_6_GYRO_OFF_Y__REG,
+				&v_data2_u8r,
+				SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		return ERROR;
+		}
+	}
+return com_rslt;
+}
+/*!
+ *	@brief This API read gyro manual offset compensation of z axis
+ *	from the register 0x76 bit 0 to 7 and 0x77 bit 4 and 5
+ *
+ *
+ *
+ *  @param v_gyro_off_z_s16:
+ *	The value of gyro manual offset compensation of z axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_gyro_offset_compensation_zaxis(
+s16 *v_gyro_off_z_s16)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data1_u8r = SMI130_INIT_VALUE;
+	u8 v_data2_u8r = SMI130_INIT_VALUE;
+	s16 v_data3_u8r, v_data4_u8r = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read gyro manual offset z axis*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_OFFSET_5_GYRO_OFF_Z__REG,
+			&v_data1_u8r, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			v_data1_u8r = SMI130_GET_BITSLICE
+			(v_data1_u8r,
+			SMI130_USER_OFFSET_5_GYRO_OFF_Z);
+			com_rslt +=
+			p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_OFFSET_6_GYRO_OFF_Z__REG,
+			&v_data2_u8r, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			v_data2_u8r = SMI130_GET_BITSLICE(
+			v_data2_u8r,
+			SMI130_USER_OFFSET_6_GYRO_OFF_Z);
+			v_data3_u8r = v_data2_u8r
+			<< SMI130_SHIFT_BIT_POSITION_BY_14_BITS;
+			v_data4_u8r =  v_data1_u8r
+			<< SMI130_SHIFT_BIT_POSITION_BY_06_BITS;
+			v_data3_u8r = v_data3_u8r | v_data4_u8r;
+			*v_gyro_off_z_s16 = v_data3_u8r
+			>> SMI130_SHIFT_BIT_POSITION_BY_06_BITS;
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write gyro manual offset compensation of z axis
+ *	from the register 0x76 bit 0 to 7 and 0x77 bit 4 and 5
+ *
+ *
+ *
+ *  @param v_gyro_off_z_s16:
+ *	The value of gyro manual offset compensation of z axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_gyro_offset_compensation_zaxis(
+s16 v_gyro_off_z_s16)
+{
+/* variable used for return the status of communication result*/
+SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_data1_u8r, v_data2_u8r = SMI130_INIT_VALUE;
+u16 v_data3_u8r = SMI130_INIT_VALUE;
+u8 v_status_s8 = SUCCESS;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+	} else {
+		/* enable gyro offset*/
+		v_status_s8 = smi130_set_gyro_offset_enable(
+		GYRO_OFFSET_ENABLE);
+		/* write gyro manual offset z axis*/
+		if (v_status_s8 == SUCCESS) {
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_OFFSET_5_GYRO_OFF_Z__REG,
+			&v_data2_u8r, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data1_u8r =
+				((u8) (v_gyro_off_z_s16 &
+				SMI130_GYRO_MANUAL_OFFSET_0_7));
+				v_data2_u8r = SMI130_SET_BITSLICE(
+				v_data2_u8r,
+				SMI130_USER_OFFSET_5_GYRO_OFF_Z,
+				v_data1_u8r);
+				/* write 0x76 bit 0 to 7*/
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC
+				(p_smi130->dev_addr,
+				SMI130_USER_OFFSET_5_GYRO_OFF_Z__REG,
+				&v_data2_u8r,
+				SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+
+			com_rslt += p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_OFFSET_6_GYRO_OFF_Z__REG,
+			&v_data2_u8r, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data3_u8r =
+				(u16) (v_gyro_off_z_s16 &
+				SMI130_GYRO_MANUAL_OFFSET_8_9);
+				v_data1_u8r = (u8)(v_data3_u8r
+				>> SMI130_SHIFT_BIT_POSITION_BY_08_BITS);
+				v_data2_u8r = SMI130_SET_BITSLICE(
+				v_data2_u8r,
+				SMI130_USER_OFFSET_6_GYRO_OFF_Z,
+				v_data1_u8r);
+				/* write 0x77 bit 4 and 5*/
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC
+				(p_smi130->dev_addr,
+				SMI130_USER_OFFSET_6_GYRO_OFF_Z__REG,
+				&v_data2_u8r,
+				SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		return ERROR;
+		}
+	}
+return com_rslt;
+}
+/*!
+ *	@brief This API read the accel offset enable bit
+ *	from the register 0x77 bit 6
+ *
+ *
+ *
+ *  @param v_accel_off_enable_u8: The value of accel offset enable
+ *  value    |  Description
+ * ----------|--------------
+ *   0x01    | ENABLE
+ *   0x00    | DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_accel_offset_enable(
+u8 *v_accel_off_enable_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read accel offset enable */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_OFFSET_6_ACCEL_OFF_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_accel_off_enable_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_OFFSET_6_ACCEL_OFF_ENABLE);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write the accel offset enable bit
+ *	from the register 0x77 bit 6
+ *
+ *
+ *
+ *  @param v_accel_off_enable_u8: The value of accel offset enable
+ *  value    |  Description
+ * ----------|--------------
+ *   0x01    | ENABLE
+ *   0x00    | DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_accel_offset_enable(
+u8 v_accel_off_enable_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+			} else {
+			/* write accel offset enable */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_OFFSET_6_ACCEL_OFF_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_OFFSET_6_ACCEL_OFF_ENABLE,
+				v_accel_off_enable_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_OFFSET_6_ACCEL_OFF_ENABLE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API read the accel offset enable bit
+ *	from the register 0x77 bit 7
+ *
+ *
+ *
+ *  @param v_gyro_off_enable_u8: The value of gyro offset enable
+ *  value    |  Description
+ * ----------|--------------
+ *   0x01    | ENABLE
+ *   0x00    | DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_gyro_offset_enable(
+u8 *v_gyro_off_enable_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read gyro offset*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_OFFSET_6_GYRO_OFF_EN__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_gyro_off_enable_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_OFFSET_6_GYRO_OFF_EN);
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API write the accel offset enable bit
+ *	from the register 0x77 bit 7
+ *
+ *
+ *
+ *  @param v_gyro_off_enable_u8: The value of gyro offset enable
+ *  value    |  Description
+ * ----------|--------------
+ *   0x01    | ENABLE
+ *   0x00    | DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_gyro_offset_enable(
+u8 v_gyro_off_enable_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* write gyro offset*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_OFFSET_6_GYRO_OFF_EN__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 = SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_USER_OFFSET_6_GYRO_OFF_EN,
+				v_gyro_off_enable_u8);
+				com_rslt += p_smi130->SMI130_BUS_WRITE_FUNC(
+				p_smi130->dev_addr,
+				SMI130_USER_OFFSET_6_GYRO_OFF_EN__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		}
+	return com_rslt;
+}
+/*!
+ *	@brief This API reads step counter value
+ *	form the register 0x78 and 0x79
+ *
+ *
+ *
+ *
+ *  @param v_step_cnt_s16 : The value of step counter
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_read_step_count(u16 *v_step_cnt_s16)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* array having the step counter LSB and MSB data
+	v_data_u8[0] - LSB
+	v_data_u8[1] - MSB*/
+	u8 a_data_u8r[SMI130_STEP_COUNT_DATA_SIZE] = {SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE};
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read step counter */
+			com_rslt =
+			p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+			SMI130_USER_STEP_COUNT_LSB__REG,
+			a_data_u8r, SMI130_STEP_COUNTER_LENGTH);
+
+			*v_step_cnt_s16 = (s16)
+			((((s32)((s8)a_data_u8r[SMI130_STEP_COUNT_MSB_BYTE]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_08_BITS)
+			| (a_data_u8r[SMI130_STEP_COUNT_LSB_BYTE]));
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API Reads
+ *	step counter configuration
+ *	from the register 0x7A bit 0 to 7
+ *	and from the register 0x7B bit 0 to 2 and 4 to 7
+ *
+ *
+ *  @param v_step_config_u16 : The value of step configuration
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_step_config(
+u16 *v_step_config_u16)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data1_u8r = SMI130_INIT_VALUE;
+	u8 v_data2_u8r = SMI130_INIT_VALUE;
+	u16 v_data3_u8r = SMI130_INIT_VALUE;
+	/* Read the 0 to 7 bit*/
+	com_rslt =
+	p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+	SMI130_USER_STEP_CONFIG_ZERO__REG,
+	&v_data1_u8r, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	/* Read the 8 to 10 bit*/
+	com_rslt +=
+	p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+	SMI130_USER_STEP_CONFIG_ONE_CNF1__REG,
+	&v_data2_u8r, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	v_data2_u8r = SMI130_GET_BITSLICE(v_data2_u8r,
+	SMI130_USER_STEP_CONFIG_ONE_CNF1);
+	v_data3_u8r = ((u16)((((u32)
+	((u8)v_data2_u8r))
+	<< SMI130_SHIFT_BIT_POSITION_BY_08_BITS) | (v_data1_u8r)));
+	/* Read the 11 to 14 bit*/
+	com_rslt +=
+	p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+	SMI130_USER_STEP_CONFIG_ONE_CNF2__REG,
+	&v_data1_u8r, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	v_data1_u8r = SMI130_GET_BITSLICE(v_data1_u8r,
+	SMI130_USER_STEP_CONFIG_ONE_CNF2);
+	*v_step_config_u16 = ((u16)((((u32)
+	((u8)v_data1_u8r))
+	<< SMI130_SHIFT_BIT_POSITION_BY_08_BITS) | (v_data3_u8r)));
+
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write
+ *	step counter configuration
+ *	from the register 0x7A bit 0 to 7
+ *	and from the register 0x7B bit 0 to 2 and 4 to 7
+ *
+ *
+ *  @param v_step_config_u16   :
+ *	the value of  Enable step configuration
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_step_config(
+u16 v_step_config_u16)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data1_u8r = SMI130_INIT_VALUE;
+	u8 v_data2_u8r = SMI130_INIT_VALUE;
+	u16 v_data3_u16 = SMI130_INIT_VALUE;
+
+	/* write the 0 to 7 bit*/
+	v_data1_u8r = (u8)(v_step_config_u16 &
+	SMI130_STEP_CONFIG_0_7);
+	p_smi130->SMI130_BUS_WRITE_FUNC
+	(p_smi130->dev_addr,
+	SMI130_USER_STEP_CONFIG_ZERO__REG,
+	&v_data1_u8r, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	/* write the 8 to 10 bit*/
+	com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+	(p_smi130->dev_addr,
+	SMI130_USER_STEP_CONFIG_ONE_CNF1__REG,
+	&v_data2_u8r, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	if (com_rslt == SUCCESS) {
+		v_data3_u16 = (u16) (v_step_config_u16 &
+		SMI130_STEP_CONFIG_8_10);
+		v_data1_u8r = (u8)(v_data3_u16
+		>> SMI130_SHIFT_BIT_POSITION_BY_08_BITS);
+		v_data2_u8r = SMI130_SET_BITSLICE(v_data2_u8r,
+		SMI130_USER_STEP_CONFIG_ONE_CNF1, v_data1_u8r);
+		p_smi130->SMI130_BUS_WRITE_FUNC
+		(p_smi130->dev_addr,
+		SMI130_USER_STEP_CONFIG_ONE_CNF1__REG,
+		&v_data2_u8r, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	}
+	/* write the 11 to 14 bit*/
+	com_rslt += p_smi130->SMI130_BUS_READ_FUNC
+	(p_smi130->dev_addr,
+	SMI130_USER_STEP_CONFIG_ONE_CNF2__REG,
+	&v_data2_u8r, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	if (com_rslt == SUCCESS) {
+		v_data3_u16 = (u16) (v_step_config_u16 &
+		SMI130_STEP_CONFIG_11_14);
+		v_data1_u8r = (u8)(v_data3_u16
+		>> SMI130_SHIFT_BIT_POSITION_BY_12_BITS);
+		v_data2_u8r = SMI130_SET_BITSLICE(v_data2_u8r,
+		SMI130_USER_STEP_CONFIG_ONE_CNF2, v_data1_u8r);
+		p_smi130->SMI130_BUS_WRITE_FUNC
+		(p_smi130->dev_addr,
+		SMI130_USER_STEP_CONFIG_ONE_CNF2__REG,
+		&v_data2_u8r, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	}
+
+	return com_rslt;
+}
+ /*!
+ *	@brief This API read enable step counter
+ *	from the register 0x7B bit 3
+ *
+ *
+ *  @param v_step_counter_u8 : The value of step counter enable
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_step_counter_enable(
+u8 *v_step_counter_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the step counter */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_step_counter_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write enable step counter
+ *	from the register 0x7B bit 3
+ *
+ *
+ *  @param v_step_counter_u8 : The value of step counter enable
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_step_counter_enable(u8 v_step_counter_u8)
+{
+/* variable used for return the status of communication result*/
+SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+/* check the p_smi130 structure as NULL*/
+if (p_smi130 == SMI130_NULL) {
+	return E_SMI130_NULL_PTR;
+} else {
+	if (v_step_counter_u8 <= SMI130_MAX_GYRO_STEP_COUNTER) {
+		/* write the step counter */
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+		(p_smi130->dev_addr,
+		SMI130_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		if (com_rslt == SUCCESS) {
+			v_data_u8 =
+			SMI130_SET_BITSLICE(v_data_u8,
+			SMI130_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE,
+			v_step_counter_u8);
+			com_rslt +=
+			p_smi130->SMI130_BUS_WRITE_FUNC
+			(p_smi130->dev_addr,
+			SMI130_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	} else {
+	com_rslt = E_SMI130_OUT_OF_RANGE;
+	}
+}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API set Step counter modes
+ *
+ *
+ *  @param  v_step_mode_u8 : The value of step counter mode
+ *  value    |   mode
+ * ----------|-----------
+ *   0       | SMI130_STEP_NORMAL_MODE
+ *   1       | SMI130_STEP_SENSITIVE_MODE
+ *   2       | SMI130_STEP_ROBUST_MODE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_set_step_mode(u8 v_step_mode_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+
+	switch (v_step_mode_u8) {
+	case SMI130_STEP_NORMAL_MODE:
+		com_rslt = smi130_set_step_config(
+		STEP_CONFIG_NORMAL);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	break;
+	case SMI130_STEP_SENSITIVE_MODE:
+		com_rslt = smi130_set_step_config(
+		STEP_CONFIG_SENSITIVE);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	break;
+	case SMI130_STEP_ROBUST_MODE:
+		com_rslt = smi130_set_step_config(
+		STEP_CONFIG_ROBUST);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	break;
+	default:
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+	break;
+	}
+
+	return com_rslt;
+}
+/*!
+ *	@brief This API used to trigger the  signification motion
+ *	interrupt
+ *
+ *
+ *  @param  v_significant_u8 : The value of interrupt selection
+ *  value    |  interrupt
+ * ----------|-----------
+ *   0       |  SMI130_MAP_INTR1
+ *   1       |  SMI130_MAP_INTR2
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_map_significant_motion_intr(
+u8 v_significant_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_sig_motion_u8 = SMI130_INIT_VALUE;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	u8 v_any_motion_intr1_stat_u8 = SMI130_ENABLE_ANY_MOTION_INTR1;
+	u8 v_any_motion_intr2_stat_u8 = SMI130_ENABLE_ANY_MOTION_INTR2;
+	u8 v_any_motion_axis_stat_u8 = SMI130_ENABLE_ANY_MOTION_AXIS;
+	/* enable the significant motion interrupt */
+	com_rslt = smi130_get_intr_significant_motion_select(&v_sig_motion_u8);
+	if (v_sig_motion_u8 != SMI130_SIG_MOTION_STAT_HIGH)
+		com_rslt += smi130_set_intr_significant_motion_select(
+		SMI130_SIG_MOTION_INTR_ENABLE);
+	switch (v_significant_u8) {
+	case SMI130_MAP_INTR1:
+		/* interrupt */
+		com_rslt += smi130_read_reg(
+		SMI130_USER_INTR_MAP_0_INTR1_ANY_MOTION__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		v_data_u8 |= v_any_motion_intr1_stat_u8;
+		/* map the signification interrupt to any-motion interrupt1*/
+		com_rslt += smi130_write_reg(
+		SMI130_USER_INTR_MAP_0_INTR1_ANY_MOTION__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		/* axis*/
+		com_rslt = smi130_read_reg(SMI130_USER_INTR_ENABLE_0_ADDR,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		v_data_u8 |= v_any_motion_axis_stat_u8;
+		com_rslt += smi130_write_reg(
+		SMI130_USER_INTR_ENABLE_0_ADDR,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	break;
+
+	case SMI130_MAP_INTR2:
+		/* map the signification interrupt to any-motion interrupt2*/
+		com_rslt += smi130_read_reg(
+		SMI130_USER_INTR_MAP_2_INTR2_ANY_MOTION__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		v_data_u8 |= v_any_motion_intr2_stat_u8;
+		com_rslt += smi130_write_reg(
+		SMI130_USER_INTR_MAP_2_INTR2_ANY_MOTION__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		/* axis*/
+		com_rslt = smi130_read_reg(SMI130_USER_INTR_ENABLE_0_ADDR,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		v_data_u8 |= v_any_motion_axis_stat_u8;
+		com_rslt += smi130_write_reg(
+		SMI130_USER_INTR_ENABLE_0_ADDR,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	break;
+
+	default:
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+	break;
+
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This API used to trigger the step detector
+ *	interrupt
+ *
+ *
+ *  @param  v_step_detector_u8 : The value of interrupt selection
+ *  value    |  interrupt
+ * ----------|-----------
+ *   0       |  SMI130_MAP_INTR1
+ *   1       |  SMI130_MAP_INTR2
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_map_step_detector_intr(
+u8 v_step_detector_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_step_det_u8 = SMI130_INIT_VALUE;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	u8 v_low_g_intr_u81_stat_u8 = SMI130_LOW_G_INTR_STAT;
+	u8 v_low_g_intr_u82_stat_u8 = SMI130_LOW_G_INTR_STAT;
+	u8 v_low_g_enable_u8 = SMI130_ENABLE_LOW_G;
+	/* read the v_status_s8 of step detector interrupt*/
+	com_rslt = smi130_get_step_detector_enable(&v_step_det_u8);
+	if (v_step_det_u8 != SMI130_STEP_DET_STAT_HIGH)
+		com_rslt += smi130_set_step_detector_enable(
+		SMI130_STEP_DETECT_INTR_ENABLE);
+	switch (v_step_detector_u8) {
+	case SMI130_MAP_INTR1:
+		com_rslt += smi130_read_reg(
+		SMI130_USER_INTR_MAP_0_INTR1_LOW_G__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		v_data_u8 |= v_low_g_intr_u81_stat_u8;
+		/* map the step detector interrupt
+		to Low-g interrupt 1*/
+		com_rslt += smi130_write_reg(
+		SMI130_USER_INTR_MAP_0_INTR1_LOW_G__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		/* Enable the Low-g interrupt*/
+		com_rslt = smi130_read_reg(
+		SMI130_USER_INTR_ENABLE_1_LOW_G_ENABLE__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		v_data_u8 |= v_low_g_enable_u8;
+		com_rslt += smi130_write_reg(
+		SMI130_USER_INTR_ENABLE_1_LOW_G_ENABLE__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	break;
+	case SMI130_MAP_INTR2:
+		/* map the step detector interrupt
+		to Low-g interrupt 1*/
+		com_rslt += smi130_read_reg(
+		SMI130_USER_INTR_MAP_2_INTR2_LOW_G__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		v_data_u8 |= v_low_g_intr_u82_stat_u8;
+
+		com_rslt += smi130_write_reg(
+		SMI130_USER_INTR_MAP_2_INTR2_LOW_G__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		/* Enable the Low-g interrupt*/
+		com_rslt = smi130_read_reg(
+		SMI130_USER_INTR_ENABLE_1_LOW_G_ENABLE__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		v_data_u8 |= v_low_g_enable_u8;
+		com_rslt += smi130_write_reg(
+		SMI130_USER_INTR_ENABLE_1_LOW_G_ENABLE__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	break;
+	default:
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+	break;
+	}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API used to clear the step counter interrupt
+ *	interrupt
+ *
+ *
+ *  @param  : None
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_clear_step_counter(void)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* clear the step counter*/
+	com_rslt = smi130_set_command_register(RESET_STEP_COUNTER);
+	p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+
+	return com_rslt;
+
+}
+ /*!
+ *	@brief This API writes value to the register 0x7E bit 0 to 7
+ *
+ *
+ *  @param  v_command_reg_u8 : The value to write command register
+ *  value   |  Description
+ * ---------|--------------------------------------------------------
+ *	0x00	|	Reserved
+ *  0x03	|	Starts fast offset calibration for the accel and gyro
+ *	0x10	|	Sets the PMU mode for the Accelerometer to suspend
+ *	0x11	|	Sets the PMU mode for the Accelerometer to normal
+ *	0x12	|	Sets the PMU mode for the Accelerometer Lowpower
+ *  0x14	|	Sets the PMU mode for the Gyroscope to suspend
+ *	0x15	|	Sets the PMU mode for the Gyroscope to normal
+ *	0x16	|	Reserved
+ *	0x17	|	Sets the PMU mode for the Gyroscope to fast start-up
+ *  0x18	|	Sets the PMU mode for the Magnetometer to suspend
+ *	0x19	|	Sets the PMU mode for the Magnetometer to normal
+ *	0x1A	|	Sets the PMU mode for the Magnetometer to Lowpower
+ *	0xB0	|	Clears all data in the FIFO
+ *  0xB1	|	Resets the interrupt engine
+ *	0xB2	|	step_cnt_clr Clears the step counter
+ *	0xB6	|	Triggers a reset
+ *	0x37	|	See extmode_en_last
+ *	0x9A	|	See extmode_en_last
+ *	0xC0	|	Enable the extended mode
+ *  0xC4	|	Erase NVM cell
+ *	0xC8	|	Load NVM cell
+ *	0xF0	|	Reset acceleration data path
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_command_register(u8 v_command_reg_u8)
+{
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* write command register */
+			com_rslt = p_smi130->SMI130_BUS_WRITE_FUNC(
+			p_smi130->dev_addr,
+			SMI130_CMD_COMMANDS__REG,
+			&v_command_reg_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API read target page from the register 0x7F bit 4 and 5
+ *
+ *  @param v_target_page_u8: The value of target page
+ *  value   |  page
+ * ---------|-----------
+ *   0      |  User data/configure page
+ *   1      |  Chip level trim/test page
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_target_page(u8 *v_target_page_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* read the page*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+			p_smi130->dev_addr,
+			SMI130_CMD_TARGET_PAGE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			*v_target_page_u8 = SMI130_GET_BITSLICE(v_data_u8,
+			SMI130_CMD_TARGET_PAGE);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write target page from the register 0x7F bit 4 and 5
+ *
+ *  @param v_target_page_u8: The value of target page
+ *  value   |  page
+ * ---------|-----------
+ *   0      |  User data/configure page
+ *   1      |  Chip level trim/test page
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_target_page(u8 v_target_page_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_target_page_u8 <= SMI130_MAX_TARGET_PAGE) {
+			/* write the page*/
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_CMD_TARGET_PAGE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 =
+				SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_CMD_TARGET_PAGE,
+				v_target_page_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC
+				(p_smi130->dev_addr,
+				SMI130_CMD_TARGET_PAGE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API read page enable from the register 0x7F bit 7
+ *
+ *
+ *
+ *  @param v_page_enable_u8: The value of page enable
+ *  value   |  page
+ * ---------|-----------
+ *   0      |  DISABLE
+ *   1      |  ENABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_paging_enable(u8 *v_page_enable_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		/* read the page enable */
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+		p_smi130->dev_addr,
+		SMI130_CMD_PAGING_EN__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		*v_page_enable_u8 = SMI130_GET_BITSLICE(v_data_u8,
+		SMI130_CMD_PAGING_EN);
+		}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API write page enable from the register 0x7F bit 7
+ *
+ *
+ *
+ *  @param v_page_enable_u8: The value of page enable
+ *  value   |  page
+ * ---------|-----------
+ *   0      |  DISABLE
+ *   1      |  ENABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_paging_enable(
+u8 v_page_enable_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		if (v_page_enable_u8 <= SMI130_MAX_VALUE_PAGE) {
+			/* write the page enable */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_CMD_PAGING_EN__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 =
+				SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_CMD_PAGING_EN,
+				v_page_enable_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC
+				(p_smi130->dev_addr,
+				SMI130_CMD_PAGING_EN__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		} else {
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+		}
+	}
+	return com_rslt;
+}
+ /*!
+ *	@brief This API read
+ *	pull up configuration from the register 0X85 bit 4 an 5
+ *
+ *
+ *
+ *  @param v_control_pullup_u8: The value of pull up register
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_pullup_configuration(
+u8 *v_control_pullup_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt  = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		/* read pull up value */
+		com_rslt = p_smi130->SMI130_BUS_READ_FUNC(
+		p_smi130->dev_addr,
+		SMI130_COM_C_TRIM_FIVE__REG,
+		&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		*v_control_pullup_u8 = SMI130_GET_BITSLICE(v_data_u8,
+		SMI130_COM_C_TRIM_FIVE);
+		}
+	return com_rslt;
+
+}
+ /*!
+ *	@brief This API write
+ *	pull up configuration from the register 0X85 bit 4 an 5
+ *
+ *
+ *
+ *  @param v_control_pullup_u8: The value of pull up register
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_pullup_configuration(
+u8 v_control_pullup_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+			/* write  pull up value */
+			com_rslt = p_smi130->SMI130_BUS_READ_FUNC
+			(p_smi130->dev_addr,
+			SMI130_COM_C_TRIM_FIVE__REG,
+			&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			if (com_rslt == SUCCESS) {
+				v_data_u8 =
+				SMI130_SET_BITSLICE(v_data_u8,
+				SMI130_COM_C_TRIM_FIVE,
+				v_control_pullup_u8);
+				com_rslt +=
+				p_smi130->SMI130_BUS_WRITE_FUNC
+				(p_smi130->dev_addr,
+				SMI130_COM_C_TRIM_FIVE__REG,
+				&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+			}
+		}
+	return com_rslt;
+}
+
+/*!
+ *	@brief This function used for read the compensated value of mag
+ *	Before start reading the mag compensated data's
+ *	make sure the following two points are addressed
+ *	@note
+ *	1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note
+ *	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_bmm150_mag_compensate_xyz(
+struct smi130_mag_xyz_s32_t *mag_comp_xyz)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	struct smi130_mag_xyzr_t mag_xyzr;
+	com_rslt = smi130_read_mag_xyzr(&mag_xyzr);
+	if (com_rslt)
+		return com_rslt;
+	/* Compensation for X axis */
+	mag_comp_xyz->x = smi130_bmm150_mag_compensate_X(
+	mag_xyzr.x, mag_xyzr.r);
+
+	/* Compensation for Y axis */
+	mag_comp_xyz->y = smi130_bmm150_mag_compensate_Y(
+	mag_xyzr.y, mag_xyzr.r);
+
+	/* Compensation for Z axis */
+	mag_comp_xyz->z = smi130_bmm150_mag_compensate_Z(
+	mag_xyzr.z, mag_xyzr.r);
+
+	return com_rslt;
+}
+
+/*!
+ *	@brief This function used for read the compensated value of mag
+ *	Before start reading the mag compensated data's
+ *	make sure the following two points are addressed
+ *	@note
+ *	1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note
+ *	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_bmm150_mag_compensate_xyz_raw(
+struct smi130_mag_xyz_s32_t *mag_comp_xyz, struct smi130_mag_xyzr_t mag_xyzr)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+
+	/* Compensation for X axis */
+	mag_comp_xyz->x = smi130_bmm150_mag_compensate_X(
+	mag_xyzr.x, mag_xyzr.r);
+
+	/* Compensation for Y axis */
+	mag_comp_xyz->y = smi130_bmm150_mag_compensate_Y(
+	mag_xyzr.y, mag_xyzr.r);
+
+	/* Compensation for Z axis */
+	mag_comp_xyz->z = smi130_bmm150_mag_compensate_Z(
+	mag_xyzr.z, mag_xyzr.r);
+
+	return com_rslt;
+}
+/*!
+ *	@brief This API used to get the compensated BMM150-X data
+ *	the out put of X as s32
+ *	Before start reading the mag compensated X data
+ *	make sure the following two points are addressed
+ *	@note
+ *	1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note
+ *	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+ *
+ *
+ *
+ *  @param  v_mag_data_x_s16 : The value of mag raw X data
+ *  @param  v_data_r_u16 : The value of mag R data
+ *
+ *	@return results of compensated X data value output as s32
+ *
+ */
+s32 smi130_bmm150_mag_compensate_X(s16 v_mag_data_x_s16, u16 v_data_r_u16)
+{
+s32 inter_retval = SMI130_INIT_VALUE;
+/* no overflow */
+if (v_mag_data_x_s16 != SMI130_MAG_FLIP_OVERFLOW_ADCVAL) {
+	if ((v_data_r_u16 != 0)
+	&& (mag_trim_mbl.dig_xyz1 != 0)) {
+		inter_retval = ((s32)(((u16)
+		((((s32)mag_trim_mbl.dig_xyz1)
+		<< SMI130_SHIFT_BIT_POSITION_BY_14_BITS)/
+		 (v_data_r_u16 != 0 ?
+		 v_data_r_u16 : mag_trim_mbl.dig_xyz1))) -
+		((u16)0x4000)));
+	} else {
+		inter_retval = SMI130_MAG_OVERFLOW_OUTPUT;
+		return inter_retval;
+	}
+	inter_retval = ((s32)((((s32)v_mag_data_x_s16) *
+			((((((((s32)mag_trim_mbl.dig_xy2) *
+			((((s32)inter_retval) *
+			((s32)inter_retval))
+			>> SMI130_SHIFT_BIT_POSITION_BY_07_BITS)) +
+			 (((s32)inter_retval) *
+			  ((s32)(((s16)mag_trim_mbl.dig_xy1)
+			  << SMI130_SHIFT_BIT_POSITION_BY_07_BITS))))
+			  >> SMI130_SHIFT_BIT_POSITION_BY_09_BITS) +
+		   ((s32)0x100000)) *
+		  ((s32)(((s16)mag_trim_mbl.dig_x2) +
+		  ((s16)0xA0))))
+		  >> SMI130_SHIFT_BIT_POSITION_BY_12_BITS))
+		  >> SMI130_SHIFT_BIT_POSITION_BY_13_BITS)) +
+		(((s16)mag_trim_mbl.dig_x1)
+		<< SMI130_SHIFT_BIT_POSITION_BY_03_BITS);
+	/* check the overflow output */
+	if (inter_retval == (s32)SMI130_MAG_OVERFLOW_OUTPUT)
+		inter_retval = SMI130_MAG_OVERFLOW_OUTPUT_S32;
+} else {
+	/* overflow */
+	inter_retval = SMI130_MAG_OVERFLOW_OUTPUT;
+}
+return inter_retval;
+}
+/*!
+ *	@brief This API used to get the compensated BMM150-Y data
+ *	the out put of Y as s32
+ *	Before start reading the mag compensated Y data
+ *	make sure the following two points are addressed
+ *	@note
+ *	1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note
+ *	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+ *
+ *
+ *
+ *  @param  v_mag_data_y_s16 : The value of mag raw Y data
+ *  @param  v_data_r_u16 : The value of mag R data
+ *
+ *	@return results of compensated Y data value output as s32
+ */
+s32 smi130_bmm150_mag_compensate_Y(s16 v_mag_data_y_s16, u16 v_data_r_u16)
+{
+s32 inter_retval = SMI130_INIT_VALUE;
+/* no overflow */
+if (v_mag_data_y_s16 != SMI130_MAG_FLIP_OVERFLOW_ADCVAL) {
+	if ((v_data_r_u16 != 0)
+	&& (mag_trim_mbl.dig_xyz1 != 0)) {
+		inter_retval = ((s32)(((u16)(((
+		(s32)mag_trim_mbl.dig_xyz1)
+		<< SMI130_SHIFT_BIT_POSITION_BY_14_BITS) /
+		(v_data_r_u16 != 0 ?
+		 v_data_r_u16 : mag_trim_mbl.dig_xyz1))) -
+		((u16)0x4000)));
+		} else {
+			inter_retval = SMI130_MAG_OVERFLOW_OUTPUT;
+			return inter_retval;
+		}
+	inter_retval = ((s32)((((s32)v_mag_data_y_s16) * ((((((((s32)
+		mag_trim_mbl.dig_xy2) * ((((s32) inter_retval) *
+		((s32)inter_retval)) >> SMI130_SHIFT_BIT_POSITION_BY_07_BITS))
+		+ (((s32)inter_retval) *
+		((s32)(((s16)mag_trim_mbl.dig_xy1)
+		<< SMI130_SHIFT_BIT_POSITION_BY_07_BITS))))
+		>> SMI130_SHIFT_BIT_POSITION_BY_09_BITS) +
+		((s32)0x100000))
+		* ((s32)(((s16)mag_trim_mbl.dig_y2)
+		+ ((s16)0xA0))))
+		>> SMI130_SHIFT_BIT_POSITION_BY_12_BITS))
+		>> SMI130_SHIFT_BIT_POSITION_BY_13_BITS)) +
+		(((s16)mag_trim_mbl.dig_y1)
+		<< SMI130_SHIFT_BIT_POSITION_BY_03_BITS);
+	/* check the overflow output */
+	if (inter_retval == (s32)SMI130_MAG_OVERFLOW_OUTPUT)
+		inter_retval = SMI130_MAG_OVERFLOW_OUTPUT_S32;
+} else {
+	/* overflow */
+	inter_retval = SMI130_MAG_OVERFLOW_OUTPUT;
+}
+return inter_retval;
+}
+/*!
+ *	@brief This API used to get the compensated BMM150-Z data
+ *	the out put of Z as s32
+ *	Before start reading the mag compensated Z data
+ *	make sure the following two points are addressed
+ *	@note
+ *	1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note
+ *	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+ *
+ *
+ *
+ *  @param  v_mag_data_z_s16 : The value of mag raw Z data
+ *  @param  v_data_r_u16 : The value of mag R data
+ *
+ *	@return results of compensated Z data value output as s32
+ */
+s32 smi130_bmm150_mag_compensate_Z(s16 v_mag_data_z_s16, u16 v_data_r_u16)
+{
+	s32 retval = SMI130_INIT_VALUE;
+
+	if (v_mag_data_z_s16 != SMI130_MAG_HALL_OVERFLOW_ADCVAL) {
+		if ((v_data_r_u16 != 0)
+		   && (mag_trim_mbl.dig_z2 != 0)
+		/*   && (mag_trim_mbl.dig_z3 != 0)*/
+		   && (mag_trim_mbl.dig_z1 != 0)
+		   && (mag_trim_mbl.dig_xyz1 != 0)) {
+			retval = (((((s32)(v_mag_data_z_s16 - mag_trim_mbl.dig_z4))
+			<< SMI130_SHIFT_BIT_POSITION_BY_15_BITS) -
+			((((s32)mag_trim_mbl.dig_z3) *
+			((s32)(((s16)v_data_r_u16) -
+			((s16)mag_trim_mbl.dig_xyz1))))
+			>> SMI130_SHIFT_BIT_POSITION_BY_02_BITS))/
+			(mag_trim_mbl.dig_z2 +
+			((s16)(((((s32)mag_trim_mbl.dig_z1) *
+			((((s16)v_data_r_u16)
+			<< SMI130_SHIFT_BIT_POSITION_BY_01_BIT))) +
+			(1 << SMI130_SHIFT_BIT_POSITION_BY_15_BITS))
+			>> SMI130_SHIFT_BIT_POSITION_BY_16_BITS))));
+		}
+	} else {
+		retval = SMI130_MAG_OVERFLOW_OUTPUT;
+	}
+		return retval;
+}
+ /*!
+ *	@brief This function used for initialize the bmm150 sensor
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_bmm150_mag_interface_init(void)
+{
+	/* This variable used for provide the communication
+	results*/
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = SMI130_INIT_VALUE;
+	u8 v_pull_value_u8 = SMI130_INIT_VALUE;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	/* accel operation mode to normal*/
+	com_rslt = smi130_set_command_register(ACCEL_MODE_NORMAL);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* write the mag power mode as NORMAL*/
+	com_rslt += smi130_set_mag_interface_normal();
+
+	/* register 0x7E write the 0x37, 0x9A and 0x30*/
+	com_rslt += smi130_set_command_register(SMI130_COMMAND_REG_ONE);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	com_rslt += smi130_set_command_register(SMI130_COMMAND_REG_TWO);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	com_rslt += smi130_set_command_register(SMI130_COMMAND_REG_THREE);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/*switch the page1*/
+	com_rslt += smi130_set_target_page(SMI130_WRITE_TARGET_PAGE1);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	smi130_get_target_page(&v_data_u8);
+	com_rslt += smi130_set_paging_enable(SMI130_WRITE_ENABLE_PAGE1);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	smi130_get_paging_enable(&v_data_u8);
+	/* enable the pullup configuration from
+	the register 0x05 bit 4 and 5 as 10*/
+	smi130_get_pullup_configuration(&v_pull_value_u8);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	v_pull_value_u8 = v_pull_value_u8 | SMI130_PULL_UP_DATA;
+	com_rslt += smi130_set_pullup_configuration(v_pull_value_u8);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/*switch the page0*/
+	com_rslt += smi130_set_target_page(SMI130_WRITE_TARGET_PAGE0);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	smi130_get_target_page(&v_data_u8);
+	/* Write the BMM150 i2c address*/
+	com_rslt += smi130_set_i2c_device_addr(SMI130_AUX_BMM150_I2C_ADDRESS);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* enable the mag interface to manual mode*/
+	com_rslt += smi130_set_mag_manual_enable(SMI130_MANUAL_ENABLE);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	smi130_get_mag_manual_enable(&v_data_u8);
+	/*Enable the MAG interface */
+	com_rslt += smi130_set_if_mode(SMI130_ENABLE_MAG_IF_MODE);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	smi130_get_if_mode(&v_data_u8);
+	/* Mag normal mode*/
+	com_rslt += smi130_bmm150_mag_wakeup();
+	printk(KERN_INFO "com_rslt:%d, <%s><%d>\n",
+		com_rslt, __func__, __LINE__);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* Read the BMM150 device id is 0x32*/
+	/*com_rslt += smi130_set_mag_read_addr(SMI130_BMM150_CHIP_ID);*/
+	/*p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);*/
+	/*com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);*/
+	/**v_chip_id_u8 = v_data_u8;*/
+	/*p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);*/
+	/* write the power mode register*/
+	com_rslt += smi130_set_mag_write_data(SMI130_BMM_POWER_MODE_REG);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/*write 0x4C register to write set power mode to normal*/
+	com_rslt += smi130_set_mag_write_addr(
+	SMI130_BMM150_POWE_MODE_REG);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* read the mag trim values*/
+	com_rslt += smi130_read_bmm150_mag_trim_mbl();
+	printk(KERN_INFO "com_rslt:%d, <%s><%d>\n",
+		com_rslt, __func__, __LINE__);
+	/* To avoid the auto mode enable when manual mode operation running*/
+	V_bmm150_maual_auto_condition_u8_mbl = SMI130_MANUAL_ENABLE;
+	/* write the XY and Z repetitions*/
+	com_rslt += smi130_set_bmm150_mag_presetmode(
+	SMI130_MAG_PRESETMODE_REGULAR);
+	printk(KERN_INFO "com_rslt:%d, <%s><%d>\n",
+		com_rslt, __func__, __LINE__);
+	/* To avoid the auto mode enable when manual mode operation running*/
+	V_bmm150_maual_auto_condition_u8_mbl = SMI130_MANUAL_DISABLE;
+	/* Set the power mode of mag as force mode*/
+	/* The data have to write for the register
+	It write the value in the register 0x4F */
+	com_rslt += smi130_set_mag_write_data(SMI130_BMM150_FORCE_MODE);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	printk(KERN_INFO "com_rslt:%d, <%s><%d>\n",
+		com_rslt, __func__, __LINE__);
+	/* write into power mode register*/
+	com_rslt += smi130_set_mag_write_addr(
+	SMI130_BMM150_POWE_MODE_REG);
+	/* write the mag v_data_bw_u8 as 25Hz*/
+	com_rslt += smi130_set_mag_output_data_rate(
+	SMI130_MAG_OUTPUT_DATA_RATE_25HZ);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+
+	/* When mag interface is auto mode - The mag read address
+	starts the register 0x42*/
+	com_rslt += smi130_set_mag_read_addr(
+	SMI130_BMM150_DATA_REG);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* enable mag interface to auto mode*/
+	com_rslt += smi130_set_mag_manual_enable(SMI130_MANUAL_DISABLE);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	smi130_get_mag_manual_enable(&v_data_u8);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+
+	return com_rslt;
+}
+ /*!
+ *	@brief This function used for set the mag power control
+ *	bit enable
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_bmm150_mag_wakeup(void)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = SMI130_INIT_VALUE;
+	u8 v_try_times_u8 = SMI130_BMM150_MAX_RETRY_WAKEUP;
+	u8 v_power_control_bit_u8 = SMI130_INIT_VALUE;
+	u8 i = SMI130_INIT_VALUE;
+
+	for (i = SMI130_INIT_VALUE; i < v_try_times_u8; i++) {
+		com_rslt = smi130_set_mag_write_data(SMI130_BMM150_POWER_ON);
+		p_smi130->delay_msec(SMI130_BMM150_WAKEUP_DELAY1);
+		/*write 0x4B register to enable power control bit*/
+		com_rslt += smi130_set_mag_write_addr(
+		SMI130_BMM150_POWE_CONTROL_REG);
+		p_smi130->delay_msec(SMI130_BMM150_WAKEUP_DELAY2);
+		com_rslt += smi130_set_mag_read_addr(
+		SMI130_BMM150_POWE_CONTROL_REG);
+		/* 0x04 is secondary read mag x lsb register */
+		p_smi130->delay_msec(SMI130_BMM150_WAKEUP_DELAY3);
+		com_rslt += smi130_read_reg(SMI130_USER_DATA_0_ADDR,
+		&v_power_control_bit_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+		v_power_control_bit_u8 = SMI130_BMM150_SET_POWER_CONTROL
+		& v_power_control_bit_u8;
+		if (v_power_control_bit_u8 == SMI130_BMM150_POWER_ON)
+			break;
+	}
+	com_rslt = (i >= v_try_times_u8) ?
+	SMI130_BMM150_POWER_ON_FAIL : SMI130_BMM150_POWER_ON_SUCCESS;
+	return com_rslt;
+}
+ /*!
+ *	@brief This function used for set the magnetometer
+ *	power mode.
+ *	@note
+ *	Before set the mag power mode
+ *	make sure the following two point is addressed
+ *		Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *
+ *	@param v_mag_sec_if_pow_mode_u8 : The value of mag power mode
+ *  value    |  mode
+ * ----------|------------
+ *   0       | SMI130_MAG_FORCE_MODE
+ *   1       | SMI130_MAG_SUSPEND_MODE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_bmm150_mag_and_secondary_if_power_mode(
+u8 v_mag_sec_if_pow_mode_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = SMI130_INIT_VALUE;
+	/* set the accel power mode to NORMAL*/
+	com_rslt = smi130_set_command_register(ACCEL_MODE_NORMAL);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	printk(KERN_INFO "com_rslt:%d, manual:%d, <%s><%d>\n",
+		com_rslt, p_smi130->mag_manual_enable, __func__, __LINE__);
+	/* set mag interface manual mode*/
+	if (p_smi130->mag_manual_enable != SMI130_MANUAL_ENABLE)	{
+		com_rslt += smi130_set_mag_manual_enable(
+		SMI130_MANUAL_ENABLE);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	}
+	printk(KERN_INFO "com_rslt:%d, manual:%d, <%s><%d>\n",
+	com_rslt, p_smi130->mag_manual_enable, __func__, __LINE__);
+
+	switch (v_mag_sec_if_pow_mode_u8) {
+	case SMI130_MAG_FORCE_MODE:
+		/* set the secondary mag power mode as NORMAL*/
+		com_rslt += smi130_set_mag_interface_normal();
+		printk(KERN_INFO "com_rslt:%d, manual:%d, <%s><%d>\n",
+		com_rslt, p_smi130->mag_manual_enable, __func__, __LINE__);
+		/* set the mag power mode as FORCE mode*/
+		com_rslt += smi130_bmm150_mag_set_power_mode(FORCE_MODE);
+		printk(KERN_INFO "com_rslt:%d, manual:%d, <%s><%d>\n",
+		com_rslt, p_smi130->mag_manual_enable, __func__, __LINE__);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	break;
+	case SMI130_MAG_SUSPEND_MODE:
+		/* set the mag power mode as SUSPEND mode*/
+		printk(KERN_INFO "com_rslt:%d, manual:%d, <%s><%d>\n",
+		com_rslt, p_smi130->mag_manual_enable, __func__, __LINE__);
+		com_rslt += smi130_bmm150_mag_set_power_mode(SUSPEND_MODE);
+		printk(KERN_INFO "com_rslt:%d, manual:%d, <%s><%d>\n",
+		com_rslt, p_smi130->mag_manual_enable, __func__, __LINE__);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		/* set the secondary mag power mode as SUSPEND*/
+		com_rslt += smi130_set_command_register(MAG_MODE_SUSPEND);
+		printk(KERN_INFO "com_rslt:%d, manual:%d, <%s><%d>\n",
+		com_rslt, p_smi130->mag_manual_enable, __func__, __LINE__);
+		p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	break;
+	default:
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+	break;
+	}
+	if (p_smi130->mag_manual_enable == SMI130_MANUAL_ENABLE) {
+		/* set mag interface auto mode*/
+		com_rslt += smi130_set_mag_manual_enable(
+		SMI130_MANUAL_DISABLE);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	}
+	printk(KERN_INFO "com_rslt:%d, manual:%d, <%s><%d>\n",
+	com_rslt, p_smi130->mag_manual_enable, __func__, __LINE__);
+	return com_rslt;
+}
+/*!
+ *	@brief This function used for set the magnetometer
+ *	power mode.
+ *	@note
+ *	Before set the mag power mode
+ *	make sure the following two points are addressed
+ *	@note
+ *	1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note
+ *	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+ *
+ *	@param v_mag_pow_mode_u8 : The value of mag power mode
+ *  value    |  mode
+ * ----------|------------
+ *   0       | FORCE_MODE
+ *   1       | SUSPEND_MODE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_bmm150_mag_set_power_mode(
+u8 v_mag_pow_mode_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = SMI130_INIT_VALUE;
+	u8 manual_enable_status = 0;
+	/* set mag interface manual mode*/
+	if (p_smi130->mag_manual_enable != SMI130_MANUAL_ENABLE) {
+		com_rslt = smi130_set_mag_manual_enable(
+		SMI130_MANUAL_ENABLE);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		com_rslt += smi130_get_mag_manual_enable(&manual_enable_status);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		printk(KERN_INFO "1com_rslt:%d, manual:%d, manual_read:%d\n",
+		com_rslt, p_smi130->mag_manual_enable, manual_enable_status);
+	}
+	printk(KERN_INFO "2com_rslt:%d, manual:%d, manual_read:%d\n",
+	com_rslt, p_smi130->mag_manual_enable, manual_enable_status);
+
+	switch (v_mag_pow_mode_u8) {
+	case FORCE_MODE:
+		/* Set the power control bit enabled */
+		com_rslt = smi130_bmm150_mag_wakeup();
+		/* write the mag power mode as FORCE mode*/
+		com_rslt += smi130_set_mag_write_data(
+		SMI130_BMM150_FORCE_MODE);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		com_rslt += smi130_set_mag_write_addr(
+		SMI130_BMM150_POWE_MODE_REG);
+		p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+		/* To avoid the auto mode enable when manual
+		mode operation running*/
+		V_bmm150_maual_auto_condition_u8_mbl = SMI130_MANUAL_ENABLE;
+		/* set the preset mode */
+		com_rslt += smi130_set_bmm150_mag_presetmode(
+		SMI130_MAG_PRESETMODE_REGULAR);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		/* To avoid the auto mode enable when manual
+		mode operation running*/
+		V_bmm150_maual_auto_condition_u8_mbl = SMI130_MANUAL_DISABLE;
+		/* set the mag read address to data registers*/
+		com_rslt += smi130_set_mag_read_addr(
+		SMI130_BMM150_DATA_REG);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	break;
+	case SUSPEND_MODE:
+		printk(KERN_INFO "3com_rslt:%d, manual:%d, read_manual:%d\n",
+		com_rslt, p_smi130->mag_manual_enable, manual_enable_status);
+		/* Set the power mode of mag as suspend mode*/
+		com_rslt += smi130_set_mag_write_data(
+		SMI130_BMM150_POWER_OFF);
+		printk(KERN_INFO "com_rslt:%d, manual:%d, <%s><%d>\n",
+		com_rslt, p_smi130->mag_manual_enable, __func__, __LINE__);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		com_rslt += smi130_set_mag_write_addr(
+		SMI130_BMM150_POWE_CONTROL_REG);
+		printk(KERN_INFO "com_rslt:%d, manual:%d, <%s><%d>\n",
+		com_rslt, p_smi130->mag_manual_enable, __func__, __LINE__);
+		p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	break;
+	default:
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+	break;
+	}
+	printk(KERN_INFO "4com_rslt:%d, manual:%d, manual_read:%d\n",
+	com_rslt, p_smi130->mag_manual_enable, manual_enable_status);
+	/* set mag interface auto mode*/
+	if (p_smi130->mag_manual_enable == SMI130_MANUAL_ENABLE) {
+		com_rslt += smi130_set_mag_manual_enable(
+		SMI130_MANUAL_DISABLE);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		com_rslt += smi130_get_mag_manual_enable(&manual_enable_status);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	}
+	printk(KERN_INFO "5com_rslt:%d, manual:%d, manual_read:%d\n",
+	com_rslt, p_smi130->mag_manual_enable, manual_enable_status);
+	return com_rslt;
+}
+/*!
+ *	@brief This API used to set the pre-set modes of bmm150
+ *	The pre-set mode setting is depend on data rate and xy and z repetitions
+ *
+ *	@note
+ *	Before set the mag preset mode
+ *	make sure the following two points are addressed
+ *	@note
+ *	1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note
+ *	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+ *
+ *
+ *  @param  v_mode_u8: The value of pre-set mode selection value
+ *  value    |  pre_set mode
+ * ----------|------------
+ *   1       | SMI130_MAG_PRESETMODE_LOWPOWER
+ *   2       | SMI130_MAG_PRESETMODE_REGULAR
+ *   3       | SMI130_MAG_PRESETMODE_HIGHACCURACY
+ *   4       | SMI130_MAG_PRESETMODE_ENHANCED
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_set_bmm150_mag_presetmode(u8 v_mode_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	switch (v_mode_u8) {
+	case SMI130_MAG_PRESETMODE_LOWPOWER:
+		/* write the XY and Z repetitions*/
+		/* The v_data_u8 have to write for the register
+		It write the value in the register 0x4F*/
+		com_rslt = smi130_set_mag_write_data(
+		SMI130_MAG_LOWPOWER_REPXY);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		com_rslt += smi130_set_mag_write_addr(
+		SMI130_BMM150_XY_REP);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		/* write the Z repetitions*/
+		/* The v_data_u8 have to write for the register
+		It write the value in the register 0x4F*/
+		com_rslt += smi130_set_mag_write_data(
+		SMI130_MAG_LOWPOWER_REPZ);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		com_rslt += smi130_set_mag_write_addr(
+		SMI130_BMM150_Z_REP);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		/* set the mag v_data_u8 rate as 10 to the register 0x4C*/
+		com_rslt += smi130_set_mag_write_data(
+		SMI130_MAG_LOWPOWER_DR);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		com_rslt += smi130_set_mag_write_addr(
+		SMI130_BMM150_POWE_MODE_REG);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	break;
+	case SMI130_MAG_PRESETMODE_REGULAR:
+		/* write the XY and Z repetitions*/
+		/* The v_data_u8 have to write for the register
+		It write the value in the register 0x4F*/
+		com_rslt = smi130_set_mag_write_data(
+		SMI130_MAG_REGULAR_REPXY);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		com_rslt += smi130_set_mag_write_addr(
+		SMI130_BMM150_XY_REP);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		/* write the Z repetitions*/
+		/* The v_data_u8 have to write for the register
+		It write the value in the register 0x4F*/
+		com_rslt += smi130_set_mag_write_data(
+		SMI130_MAG_REGULAR_REPZ);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		com_rslt += smi130_set_mag_write_addr(
+		SMI130_BMM150_Z_REP);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		/* set the mag v_data_u8 rate as 10 to the register 0x4C*/
+		com_rslt += smi130_set_mag_write_data(
+		SMI130_MAG_REGULAR_DR);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		com_rslt += smi130_set_mag_write_addr(
+		SMI130_BMM150_POWE_MODE_REG);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	break;
+	case SMI130_MAG_PRESETMODE_HIGHACCURACY:
+		/* write the XY and Z repetitions*/
+		/* The v_data_u8 have to write for the register
+		It write the value in the register 0x4F*/
+		com_rslt = smi130_set_mag_write_data(
+		SMI130_MAG_HIGHACCURACY_REPXY);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		com_rslt += smi130_set_mag_write_addr(
+		SMI130_BMM150_XY_REP);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		/* write the Z repetitions*/
+		/* The v_data_u8 have to write for the register
+		It write the value in the register 0x4F*/
+		com_rslt += smi130_set_mag_write_data(
+		SMI130_MAG_HIGHACCURACY_REPZ);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		com_rslt += smi130_set_mag_write_addr(
+		SMI130_BMM150_Z_REP);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		/* set the mag v_data_u8 rate as 20 to the register 0x4C*/
+		com_rslt += smi130_set_mag_write_data(
+		SMI130_MAG_HIGHACCURACY_DR);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		com_rslt += smi130_set_mag_write_addr(
+		SMI130_BMM150_POWE_MODE_REG);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	break;
+	case SMI130_MAG_PRESETMODE_ENHANCED:
+		/* write the XY and Z repetitions*/
+		/* The v_data_u8 have to write for the register
+		It write the value in the register 0x4F*/
+		com_rslt = smi130_set_mag_write_data(
+		SMI130_MAG_ENHANCED_REPXY);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		com_rslt += smi130_set_mag_write_addr(
+		SMI130_BMM150_XY_REP);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		/* write the Z repetitions*/
+		/* The v_data_u8 have to write for the register
+		It write the value in the register 0x4F*/
+		com_rslt += smi130_set_mag_write_data(
+		SMI130_MAG_ENHANCED_REPZ);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		com_rslt += smi130_set_mag_write_addr(
+		SMI130_BMM150_Z_REP);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		/* set the mag v_data_u8 rate as 10 to the register 0x4C*/
+		com_rslt += smi130_set_mag_write_data(
+		SMI130_MAG_ENHANCED_DR);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		com_rslt += smi130_set_mag_write_addr(
+		SMI130_BMM150_POWE_MODE_REG);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	break;
+	default:
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+	break;
+	}
+
+	return com_rslt;
+}
+ /*!
+ *	@brief This function used for read the trim values of magnetometer
+ *
+ *	@note
+ *	Before reading the mag trimming values
+ *	make sure the following two points are addressed
+ *	@note
+ *	1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note
+ *	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_read_bmm150_mag_trim_mbl(void)
+{
+	/* This variable used for provide the communication
+	results*/
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* Array holding the bmm150 trim data
+	*/
+	u8 v_data_u8[SMI130_MAG_TRIM_DATA_SIZE] = {
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE};
+	/* read dig_x1 value */
+	com_rslt = smi130_set_mag_read_addr(
+	SMI130_MAG_DIG_X1);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8[SMI130_BMM150_DIG_X1],
+	SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	mag_trim_mbl.dig_x1 = v_data_u8[SMI130_BMM150_DIG_X1];
+	/* read dig_y1 value */
+	com_rslt += smi130_set_mag_read_addr(
+	SMI130_MAG_DIG_Y1);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8[SMI130_BMM150_DIG_Y1],
+	SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	mag_trim_mbl.dig_y1 = v_data_u8[SMI130_BMM150_DIG_Y1];
+
+	/* read dig_x2 value */
+	com_rslt += smi130_set_mag_read_addr(
+	SMI130_MAG_DIG_X2);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8[SMI130_BMM150_DIG_X2],
+	SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	mag_trim_mbl.dig_x2 = v_data_u8[SMI130_BMM150_DIG_X2];
+	/* read dig_y2 value */
+	com_rslt += smi130_set_mag_read_addr(
+	SMI130_MAG_DIG_Y2);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8[SMI130_BMM150_DIG_Y3],
+	SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	mag_trim_mbl.dig_y2 = v_data_u8[SMI130_BMM150_DIG_Y3];
+
+	/* read dig_xy1 value */
+	com_rslt += smi130_set_mag_read_addr(
+	SMI130_MAG_DIG_XY1);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8[SMI130_BMM150_DIG_XY1],
+	SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	mag_trim_mbl.dig_xy1 = v_data_u8[SMI130_BMM150_DIG_XY1];
+	/* read dig_xy2 value */
+	com_rslt += smi130_set_mag_read_addr(
+	SMI130_MAG_DIG_XY2);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* 0x04 is v_mag_x_s16 ls register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8[SMI130_BMM150_DIG_XY2],
+	SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	mag_trim_mbl.dig_xy2 = v_data_u8[SMI130_BMM150_DIG_XY2];
+
+	/* read dig_z1 lsb value */
+	com_rslt += smi130_set_mag_read_addr(
+	SMI130_MAG_DIG_Z1_LSB);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8[SMI130_BMM150_DIG_Z1_LSB],
+	SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* read dig_z1 msb value */
+	com_rslt += smi130_set_mag_read_addr(SMI130_MAG_DIG_Z1_MSB);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* 0x04 is v_mag_x_s16 msb register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8[SMI130_BMM150_DIG_Z1_MSB],
+	SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	mag_trim_mbl.dig_z1 =
+	(u16)((((u32)((u8)v_data_u8[SMI130_BMM150_DIG_Z1_MSB]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_08_BITS) |
+			(v_data_u8[SMI130_BMM150_DIG_Z1_LSB]));
+
+	/* read dig_z2 lsb value */
+	com_rslt += smi130_set_mag_read_addr(SMI130_MAG_DIG_Z2_LSB);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8[SMI130_BMM150_DIG_Z2_LSB],
+	SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* read dig_z2 msb value */
+	com_rslt += smi130_set_mag_read_addr(SMI130_MAG_DIG_Z2_MSB);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* 0x04 is v_mag_x_s16 msb register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8[SMI130_BMM150_DIG_Z2_MSB],
+	SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	mag_trim_mbl.dig_z2 =
+	(s16)((((s32)((s8)v_data_u8[SMI130_BMM150_DIG_Z2_MSB]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_08_BITS) |
+			(v_data_u8[SMI130_BMM150_DIG_Z2_LSB]));
+
+	/* read dig_z3 lsb value */
+	com_rslt += smi130_set_mag_read_addr(SMI130_MAG_DIG_Z3_LSB);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8[SMI130_BMM150_DIG_DIG_Z3_LSB],
+	SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* read dig_z3 msb value */
+	com_rslt += smi130_set_mag_read_addr(SMI130_MAG_DIG_Z3_MSB);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* 0x04 is v_mag_x_s16 msb register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8[SMI130_BMM150_DIG_DIG_Z3_MSB],
+	SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	mag_trim_mbl.dig_z3 =
+	(s16)((((s32)((s8)v_data_u8[SMI130_BMM150_DIG_DIG_Z3_MSB]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_08_BITS) |
+			(v_data_u8[SMI130_BMM150_DIG_DIG_Z3_LSB]));
+
+	/* read dig_z4 lsb value */
+	com_rslt += smi130_set_mag_read_addr(SMI130_MAG_DIG_Z4_LSB);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8[SMI130_BMM150_DIG_DIG_Z4_LSB],
+	SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* read dig_z4 msb value */
+	com_rslt += smi130_set_mag_read_addr(SMI130_MAG_DIG_Z4_MSB);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* 0x04 is v_mag_x_s16 msb register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8[SMI130_BMM150_DIG_DIG_Z4_MSB],
+	SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	mag_trim_mbl.dig_z4 =
+	(s16)((((s32)((s8)v_data_u8[SMI130_BMM150_DIG_DIG_Z4_MSB]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_08_BITS) |
+			(v_data_u8[SMI130_BMM150_DIG_DIG_Z4_LSB]));
+
+	/* read dig_xyz1 lsb value */
+	com_rslt += smi130_set_mag_read_addr(SMI130_MAG_DIG_XYZ1_LSB);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8[SMI130_BMM150_DIG_DIG_XYZ1_LSB],
+	SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* read dig_xyz1 msb value */
+	com_rslt += smi130_set_mag_read_addr(SMI130_MAG_DIG_XYZ1_MSB);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* 0x04 is v_mag_x_s16 msb register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8[SMI130_BMM150_DIG_DIG_XYZ1_MSB],
+	SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	mag_trim_mbl.dig_xyz1 =
+	(u16)((((u32)((u8)v_data_u8[SMI130_BMM150_DIG_DIG_XYZ1_MSB]))
+			<< SMI130_SHIFT_BIT_POSITION_BY_08_BITS) |
+			(v_data_u8[SMI130_BMM150_DIG_DIG_XYZ1_LSB]));
+
+	return com_rslt;
+}
+ /*!
+ *	@brief This function used for initialize
+ *	the AKM09911 and AKM09912 sensor
+ *
+ *
+ *	@param v_akm_i2c_address_u8: The value of device address
+ *	AKM sensor   |  Slave address
+ * --------------|---------------------
+ *  AKM09911     |  AKM09911_I2C_ADDR_1
+ *     -         |  and AKM09911_I2C_ADDR_2
+ *  AKM09912     |  AKM09912_I2C_ADDR_1
+ *     -         |  AKM09912_I2C_ADDR_2
+ *     -         |  AKM09912_I2C_ADDR_3
+ *     -         |  AKM09912_I2C_ADDR_4
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_akm_mag_interface_init(
+u8 v_akm_i2c_address_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_pull_value_u8 = SMI130_INIT_VALUE;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	u8 v_akm_chip_id_u8 = SMI130_INIT_VALUE;
+	/* accel operation mode to normal*/
+	com_rslt = smi130_set_command_register(ACCEL_MODE_NORMAL);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	com_rslt += smi130_set_command_register(MAG_MODE_NORMAL);
+	p_smi130->delay_msec(SMI130_AKM_INIT_DELAY);
+	smi130_get_mag_power_mode_stat(&v_data_u8);
+	/* register 0x7E write the 0x37, 0x9A and 0x30*/
+	com_rslt += smi130_set_command_register(SMI130_COMMAND_REG_ONE);
+	p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	com_rslt += smi130_set_command_register(SMI130_COMMAND_REG_TWO);
+	p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	com_rslt += smi130_set_command_register(SMI130_COMMAND_REG_THREE);
+	p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	/*switch the page1*/
+	com_rslt += smi130_set_target_page(SMI130_WRITE_TARGET_PAGE1);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	smi130_get_target_page(&v_data_u8);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	com_rslt += smi130_set_paging_enable(SMI130_WRITE_ENABLE_PAGE1);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	smi130_get_paging_enable(&v_data_u8);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* enable the pullup configuration from
+	the register 0x05 bit 4 and 5  to 10*/
+	smi130_get_pullup_configuration(&v_pull_value_u8);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	v_pull_value_u8 = v_pull_value_u8 | SMI130_PULL_UP_DATA;
+	com_rslt += smi130_set_pullup_configuration(v_pull_value_u8);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+
+	/*switch the page0*/
+	com_rslt += smi130_set_target_page(SMI130_WRITE_TARGET_PAGE0);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	smi130_get_target_page(&v_data_u8);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* Write the AKM09911 0r AKM09912 i2c address*/
+	com_rslt += smi130_set_i2c_device_addr(v_akm_i2c_address_u8);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* enable the mag interface to manual mode*/
+	com_rslt += smi130_set_mag_manual_enable(SMI130_MANUAL_ENABLE);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	smi130_get_mag_manual_enable(&v_data_u8);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/*Enable the MAG interface */
+	com_rslt += smi130_set_if_mode(SMI130_ENABLE_MAG_IF_MODE);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	smi130_get_if_mode(&v_data_u8);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+
+	/* Set the AKM Fuse ROM mode */
+	/* Set value for fuse ROM mode*/
+	com_rslt += smi130_set_mag_write_data(AKM_FUSE_ROM_MODE);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* AKM mode address is 0x31*/
+	com_rslt += smi130_set_mag_write_addr(AKM_POWER_MODE_REG);
+	p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	/* Read the Fuse ROM v_data_u8 from registers
+	0x60,0x61 and 0x62*/
+	/* ASAX v_data_u8 */
+	com_rslt += smi130_read_bosch_akm_sensitivity_data();
+	p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	/* read the device id of the AKM sensor
+	if device id is 0x05 - AKM09911
+	if device id is 0x04 - AKM09912*/
+	com_rslt += smi130_set_mag_read_addr(AKM09912_CHIP_ID_REG);
+	/* 0x04 is mag_x lsb register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_akm_chip_id_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	printk(KERN_INFO "smi130,addr:0x%x, akm_chip_id:0x%x",
+	v_akm_i2c_address_u8, v_akm_chip_id_u8);
+	/* Set value power down mode mode*/
+	com_rslt += smi130_set_mag_write_data(AKM_POWER_DOWN_MODE_DATA);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* AKM mode address is 0x31*/
+	com_rslt += smi130_set_mag_write_addr(AKM_POWER_MODE_REG);
+	p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	/* Set AKM Force mode*/
+	com_rslt += smi130_set_mag_write_data(
+	AKM_SINGLE_MEASUREMENT_MODE);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* AKM mode address is 0x31*/
+	com_rslt += smi130_set_mag_write_addr(AKM_POWER_MODE_REG);
+	p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	/* Set the AKM read xyz v_data_u8 address*/
+	com_rslt += smi130_set_mag_read_addr(AKM_DATA_REGISTER);
+	/* write the mag v_data_bw_u8 as 25Hz*/
+	com_rslt += smi130_set_mag_output_data_rate(
+	SMI130_MAG_OUTPUT_DATA_RATE_25HZ);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* Enable mag interface to auto mode*/
+	com_rslt += smi130_set_mag_manual_enable(SMI130_MANUAL_DISABLE);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	smi130_get_mag_manual_enable(&v_data_u8);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+
+	return com_rslt;
+}
+ /*!
+ *	@brief This function used for read the sensitivity data of
+ *	AKM09911 and AKM09912
+ *
+ *	@note Before reading the mag sensitivity values
+ *	make sure the following two points are addressed
+ *	@note	1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_read_bosch_akm_sensitivity_data(void)
+{
+	/* This variable used for provide the communication
+	results*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* Array holding the sensitivity ax,ay and az data*/
+	u8 v_data_u8[SMI130_AKM_SENSITIVITY_DATA_SIZE] = {
+	SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE};
+	/* read asax value */
+	com_rslt = smi130_set_mag_read_addr(SMI130_BST_AKM_ASAX);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8[AKM_ASAX],
+	SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	akm_asa_data_mbl.asax = v_data_u8[AKM_ASAX];
+	/* read asay value */
+	com_rslt += smi130_set_mag_read_addr(SMI130_BST_AKM_ASAY);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8[AKM_ASAY],
+	SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	akm_asa_data_mbl.asay = v_data_u8[AKM_ASAY];
+	/* read asaz value */
+	com_rslt += smi130_set_mag_read_addr(SMI130_BST_AKM_ASAZ);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8[AKM_ASAZ],
+	SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	akm_asa_data_mbl.asaz = v_data_u8[AKM_ASAZ];
+
+	return com_rslt;
+}
+/*!
+ *	@brief This API used to get the compensated X data
+ *	of AKM09911 the out put of X as s32
+ *	@note	Before start reading the mag compensated X data
+ *			make sure the following two points are addressed
+ *	@note 1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note 2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+ *
+ *
+ *  @param v_bosch_akm_x_s16 : The value of X data
+ *
+ *	@return results of compensated X data value output as s32
+ *
+ */
+s32 smi130_bosch_akm09911_compensate_X(s16 v_bosch_akm_x_s16)
+{
+	/*Return value of AKM x compensated v_data_u8*/
+	s32 retval = SMI130_INIT_VALUE;
+	/* Convert raw v_data_u8 into compensated v_data_u8*/
+	retval = (v_bosch_akm_x_s16 *
+	((akm_asa_data_mbl.asax/AKM09911_SENSITIVITY_DIV) +
+	SMI130_GEN_READ_WRITE_DATA_LENGTH));
+	return retval;
+}
+/*!
+ *	@brief This API used to get the compensated Y data
+ *	of AKM09911 the out put of Y as s32
+ *	@note	Before start reading the mag compensated Y data
+ *			make sure the following two points are addressed
+ *	@note 1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note 2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+ *
+ *
+ *  @param v_bosch_akm_y_s16 : The value of Y data
+ *
+ *	@return results of compensated Y data value output as s32
+ *
+ */
+s32 smi130_bosch_akm09911_compensate_Y(s16 v_bosch_akm_y_s16)
+{
+	/*Return value of AKM y compensated v_data_u8*/
+	s32 retval = SMI130_INIT_VALUE;
+	/* Convert raw v_data_u8 into compensated v_data_u8*/
+	retval = (v_bosch_akm_y_s16 *
+	((akm_asa_data_mbl.asay/AKM09911_SENSITIVITY_DIV) +
+	SMI130_GEN_READ_WRITE_DATA_LENGTH));
+	return retval;
+}
+/*!
+ *	@brief This API used to get the compensated Z data
+ *	of AKM09911 the out put of Z as s32
+ *	@note	Before start reading the mag compensated Z data
+ *			make sure the following two points are addressed
+ *	@note 1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note 2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+ *
+ *
+ *  @param v_bosch_akm_z_s16 : The value of Z data
+ *
+ *	@return results of compensated Z data value output as s32
+ *
+ */
+s32 smi130_bosch_akm09911_compensate_Z(s16 v_bosch_akm_z_s16)
+{
+	/*Return value of AKM z compensated v_data_u8*/
+	s32 retval = SMI130_INIT_VALUE;
+	/* Convert raw v_data_u8 into compensated v_data_u8*/
+	retval = (v_bosch_akm_z_s16 *
+	((akm_asa_data_mbl.asaz/AKM09911_SENSITIVITY_DIV) +
+	SMI130_GEN_READ_WRITE_DATA_LENGTH));
+	return retval;
+}
+/*!
+ *	@brief This API used to get the compensated X data
+ *	of AKM09912 the out put of X as s32
+ *	@note	Before start reading the mag compensated X data
+ *			make sure the following two points are addressed
+ *	@note 1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note 2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+ *
+ *
+ *  @param v_bosch_akm_x_s16 : The value of X data
+ *
+ *	@return results of compensated X data value output as s32
+ *
+ */
+s32 smi130_bosch_akm09912_compensate_X(s16 v_bosch_akm_x_s16)
+{
+	/*Return value of AKM x compensated data*/
+	s32 retval = SMI130_INIT_VALUE;
+	/* Convert raw data into compensated data*/
+	retval = v_bosch_akm_x_s16 *
+	(akm_asa_data_mbl.asax + AKM09912_SENSITIVITY)
+	/ AKM09912_SENSITIVITY_DIV;
+	return retval;
+}
+/*!
+ *	@brief This API used to get the compensated Y data
+ *	of AKM09912 the out put of Y as s32
+ *	@note	Before start reading the mag compensated Y data
+ *			make sure the following two points are addressed
+ *	@note 1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note 2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+ *
+ *
+ *  @param v_bosch_akm_y_s16 : The value of Y data
+ *
+ *	@return results of compensated Y data value output as s32
+ *
+ */
+s32 smi130_bosch_akm09912_compensate_Y(s16 v_bosch_akm_y_s16)
+{
+	/*Return value of AKM y compensated data*/
+	s32 retval = SMI130_INIT_VALUE;
+	/* Convert raw data into compensated data*/
+	retval = v_bosch_akm_y_s16 *
+	(akm_asa_data_mbl.asax + AKM09912_SENSITIVITY)
+	/ AKM09912_SENSITIVITY_DIV;
+	return retval;
+}
+/*!
+ *	@brief This API used to get the compensated Z data
+ *	of AKM09912 the out put of Z as s32
+ *	@note	Before start reading the mag compensated Z data
+ *			make sure the following two points are addressed
+ *	@note 1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note 2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+ *
+ *
+ *  @param v_bosch_akm_z_s16 : The value of Z data
+ *
+ *	@return results of compensated Z data value output as s32
+ *
+ */
+s32 smi130_bosch_akm09912_compensate_Z(s16 v_bosch_akm_z_s16)
+{
+	/*Return value of AKM z compensated data*/
+	s32 retval = SMI130_INIT_VALUE;
+	/* Convert raw data into compensated data*/
+	retval = v_bosch_akm_z_s16 *
+	(akm_asa_data_mbl.asax + AKM09912_SENSITIVITY)
+	/ AKM09912_SENSITIVITY_DIV;
+	return retval;
+}
+ /*!
+ *	@brief This function used for read the compensated value of
+ *	AKM09911
+ *	@note Before start reading the mag compensated data's
+ *	make sure the following two points are addressed
+ *	@note	1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_akm09911_compensate_xyz(
+struct smi130_mag_xyz_s32_t *bosch_akm_xyz)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	struct smi130_mag_t mag_xyz;
+
+	com_rslt = smi130_read_mag_xyz(&mag_xyz, BST_AKM);
+	/* Compensation for X axis */
+	bosch_akm_xyz->x = smi130_bosch_akm09911_compensate_X(mag_xyz.x);
+
+	/* Compensation for Y axis */
+	bosch_akm_xyz->y = smi130_bosch_akm09911_compensate_Y(mag_xyz.y);
+
+	/* Compensation for Z axis */
+	bosch_akm_xyz->z = smi130_bosch_akm09911_compensate_Z(mag_xyz.z);
+
+	return com_rslt;
+}
+ /*!
+ *	@brief This function used for read the compensated value of
+ *	AKM09912
+ *	@note Before start reading the mag compensated data's
+ *	make sure the following two points are addressed
+ *	@note	1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_akm09912_compensate_xyz(
+struct smi130_mag_xyz_s32_t *bosch_akm_xyz)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	struct smi130_mag_t mag_xyz;
+
+	com_rslt = smi130_read_mag_xyz(&mag_xyz, BST_AKM);
+	printk(KERN_INFO "akm09912_raw_x:%d, %d, %d, <%s>,<%d>",
+	mag_xyz.x, mag_xyz.y, mag_xyz.z, __func__, __LINE__);
+	/* Compensation for X axis */
+	bosch_akm_xyz->x = smi130_bosch_akm09912_compensate_X(mag_xyz.x);
+
+	/* Compensation for Y axis */
+	bosch_akm_xyz->y = smi130_bosch_akm09912_compensate_Y(mag_xyz.y);
+
+	/* Compensation for Z axis */
+	bosch_akm_xyz->z = smi130_bosch_akm09912_compensate_Z(mag_xyz.z);
+	return com_rslt;
+}
+ /*!
+ *	@brief This function used for read the compensated value of
+ *	AKM09912
+ *	@note Before start reading the mag compensated data's
+ *	make sure the following two points are addressed
+ *	@note	1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_akm09912_compensate_xyz_raw(
+struct smi130_mag_xyz_s32_t *bosch_akm_xyz)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* Compensation for X axis */
+	bosch_akm_xyz->x = smi130_bosch_akm09912_compensate_X(bosch_akm_xyz->x);
+
+	/* Compensation for Y axis */
+	bosch_akm_xyz->y = smi130_bosch_akm09912_compensate_Y(bosch_akm_xyz->y);
+
+	/* Compensation for Z axis */
+	bosch_akm_xyz->z = smi130_bosch_akm09912_compensate_Z(bosch_akm_xyz->z);
+
+	return com_rslt;
+}
+/*!
+ *	@brief This function used for set the AKM09911 and AKM09912
+ *	power mode.
+ *	@note Before set the AKM power mode
+ *	make sure the following two points are addressed
+ *	@note	1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+ *
+ *	@param v_akm_pow_mode_u8 : The value of akm power mode
+ *  value   |    Description
+ * ---------|--------------------
+ *    0     |  AKM_POWER_DOWN_MODE
+ *    1     |  AKM_SINGLE_MEAS_MODE
+ *    2     |  FUSE_ROM_MODE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_akm_set_powermode(
+u8 v_akm_pow_mode_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = SMI130_INIT_VALUE;
+	/* set mag interface manual mode*/
+	if (p_smi130->mag_manual_enable != SMI130_MANUAL_ENABLE) {
+		com_rslt = smi130_set_mag_manual_enable(
+		SMI130_MANUAL_ENABLE);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	}
+	printk(KERN_INFO "com_rslt:%d, manual:%d, <%s>\n",
+	com_rslt, p_smi130->mag_manual_enable, __func__);
+	switch (v_akm_pow_mode_u8) {
+	case AKM_POWER_DOWN_MODE:
+		/* Set the power mode of AKM as power down mode*/
+		com_rslt += smi130_set_mag_write_data(AKM_POWER_DOWN_MODE_DATA);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		com_rslt += smi130_set_mag_write_addr(AKM_POWER_MODE_REG);
+		p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	break;
+	case AKM_SINGLE_MEAS_MODE:
+		/* Set the power mode of AKM as
+		single measurement mode*/
+		com_rslt += smi130_set_mag_write_data
+		(AKM_SINGLE_MEASUREMENT_MODE);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		com_rslt += smi130_set_mag_write_addr(AKM_POWER_MODE_REG);
+		p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+		com_rslt += smi130_set_mag_read_addr(AKM_DATA_REGISTER);
+	break;
+	case FUSE_ROM_MODE:
+		/* Set the power mode of AKM as
+		Fuse ROM mode*/
+		com_rslt += smi130_set_mag_write_data(AKM_FUSE_ROM_MODE);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		com_rslt += smi130_set_mag_write_addr(AKM_POWER_MODE_REG);
+		p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+		/* Sensitivity v_data_u8 */
+		com_rslt += smi130_read_bosch_akm_sensitivity_data();
+		p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+		/* power down mode*/
+		com_rslt += smi130_set_mag_write_data(AKM_POWER_DOWN_MODE);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		com_rslt += smi130_set_mag_write_addr(AKM_POWER_MODE_REG);
+		p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	break;
+	default:
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+	break;
+	}
+	/* set mag interface auto mode*/
+	if (p_smi130->mag_manual_enable == SMI130_MANUAL_ENABLE) {
+		com_rslt += smi130_set_mag_manual_enable(
+		SMI130_MANUAL_DISABLE);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	}
+	printk(KERN_INFO "com_rslt:%d, manual:%d, <%s><%d>\n",
+	com_rslt, p_smi130->mag_manual_enable, __func__, __LINE__);
+	return com_rslt;
+}
+ /*!
+ *	@brief This function used for set the magnetometer
+ *	power mode of AKM09911 and AKM09912
+ *	@note Before set the mag power mode
+ *	make sure the following two point is addressed
+ *		Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *
+ *	@param v_mag_sec_if_pow_mode_u8 : The value of secondary if power mode
+ *  value   |    Description
+ * ---------|--------------------
+ *    0     |  SMI130_MAG_FORCE_MODE
+ *    1     |  SMI130_MAG_SUSPEND_MODE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_bosch_akm_and_secondary_if_powermode(
+u8 v_mag_sec_if_pow_mode_u8)
+{
+	/* variable used for return the status of communication result*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* accel operation mode to normal*/
+	com_rslt = smi130_set_command_register(ACCEL_MODE_NORMAL);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* set mag interface manual mode*/
+	if (p_smi130->mag_manual_enable != SMI130_MANUAL_ENABLE) {
+		com_rslt = smi130_set_mag_manual_enable(
+		SMI130_MANUAL_ENABLE);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	}
+	printk(KERN_ERR "com_rslt:%d, manual:%d,after setacc normal mode\n",
+	com_rslt, p_smi130->mag_manual_enable);
+	switch (v_mag_sec_if_pow_mode_u8) {
+	case SMI130_MAG_FORCE_MODE:
+		/* set the secondary mag power mode as NORMAL*/
+		com_rslt += smi130_set_mag_interface_normal();
+		/* set the akm power mode as single measurement mode*/
+		com_rslt += smi130_bosch_akm_set_powermode(AKM_SINGLE_MEAS_MODE);
+		p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+		com_rslt += smi130_set_mag_read_addr(AKM_DATA_REGISTER);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	break;
+	case SMI130_MAG_SUSPEND_MODE:
+		/* set the akm power mode as power down mode*/
+		com_rslt += smi130_bosch_akm_set_powermode(AKM_POWER_DOWN_MODE);
+		p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+		/* set the secondary mag power mode as SUSPEND*/
+		com_rslt += smi130_set_command_register(MAG_MODE_SUSPEND);
+		p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	break;
+	default:
+		com_rslt = E_SMI130_OUT_OF_RANGE;
+	break;
+	}
+	/* set mag interface auto mode*/
+	if (p_smi130->mag_manual_enable == SMI130_MANUAL_ENABLE)
+		com_rslt += smi130_set_mag_manual_enable(
+		SMI130_MANUAL_DISABLE);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	return com_rslt;
+}
+/*!
+ *	@brief This function used for read the YAMAH-YAS532 init
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_yamaha_yas532_mag_interface_init(
+void)
+{
+	/* This variable used for provide the communication
+	results*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	u8 v_pull_value_u8 = SMI130_INIT_VALUE;
+	u8 v_data_u8 = SMI130_INIT_VALUE;
+	u8 i = SMI130_INIT_VALUE;
+	/* accel operation mode to normal*/
+	com_rslt = smi130_set_command_register(ACCEL_MODE_NORMAL);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* write mag power mode as NORMAL*/
+	com_rslt += smi130_set_mag_interface_normal();
+	/* register 0x7E write the 0x37, 0x9A and 0x30*/
+	com_rslt += smi130_set_command_register(SMI130_COMMAND_REG_ONE);
+	p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	com_rslt += smi130_set_command_register(SMI130_COMMAND_REG_TWO);
+	p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	com_rslt += smi130_set_command_register(SMI130_COMMAND_REG_THREE);
+	p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	/*switch the page1*/
+	com_rslt += smi130_set_target_page(SMI130_WRITE_TARGET_PAGE1);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	smi130_get_target_page(&v_data_u8);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	com_rslt += smi130_set_paging_enable(SMI130_WRITE_ENABLE_PAGE1);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	smi130_get_paging_enable(&v_data_u8);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* enable the pullup configuration from
+	the register 0x05 bit 4 and 5 as 10*/
+	smi130_get_pullup_configuration(&v_pull_value_u8);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	v_pull_value_u8 = v_pull_value_u8 | SMI130_PULL_UP_DATA;
+	com_rslt += smi130_set_pullup_configuration(v_pull_value_u8);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/*switch the page0*/
+	com_rslt += smi130_set_target_page(SMI130_WRITE_TARGET_PAGE0);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	smi130_get_target_page(&v_data_u8);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* Write the YAS532 i2c address*/
+	com_rslt += smi130_set_i2c_device_addr(SMI130_AUX_YAS532_I2C_ADDRESS);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* enable the mag interface to manual mode*/
+	com_rslt += smi130_set_mag_manual_enable(SMI130_MANUAL_ENABLE);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	smi130_get_mag_manual_enable(&v_data_u8);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/*Enable the MAG interface */
+	com_rslt += smi130_set_if_mode(SMI130_ENABLE_MAG_IF_MODE);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	smi130_get_if_mode(&v_data_u8);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	v_data_u8 = SMI130_MANUAL_DISABLE;
+	/* Read the YAS532 device id is 0x02*/
+	com_rslt += smi130_set_mag_read_addr(SMI130_YAS_DEVICE_ID_REG);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* Read the YAS532 calibration data*/
+	com_rslt += smi130_bosch_yamaha_yas532_calib_values();
+	p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	/* Assign the data acquisition mode*/
+	yas532_data_mbl.measure_state = YAS532_MAG_STATE_INIT_COIL;
+	/* Set the default offset as invalid offset*/
+	set_vector(yas532_data_mbl.v_hard_offset_s8, INVALID_OFFSET);
+	/* set the transform to zero */
+	yas532_data_mbl.transform = SMI130_NULL;
+	/* Assign overflow as zero*/
+	yas532_data_mbl.overflow = 0;
+	#if YAS532_MAG_LOG < YAS532_MAG_TEMPERATURE_LOG
+		yas532_data_mbl.temp_data.num =
+		yas532_data_mbl.temp_data.idx = 0;
+	#endif
+	/* Assign the coef value*/
+	for (i = 0; i < 3; i++) {
+		yas532_data_mbl.coef[i] = yas532_version_ac_coef[i];
+		yas532_data_mbl.last_raw[i] = 0;
+	}
+	yas532_data_mbl.last_raw[3] = 0;
+	/* Set the initial values of yas532*/
+	com_rslt += smi130_bosch_yas532_set_initial_values();
+	/* write the mag v_data_bw_u8 as 25Hz*/
+	com_rslt += smi130_set_mag_output_data_rate(
+	SMI130_MAG_OUTPUT_DATA_RATE_25HZ);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* Enable mag interface to auto mode*/
+	com_rslt += smi130_set_mag_manual_enable(
+	SMI130_MANUAL_DISABLE);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	smi130_get_mag_manual_enable(&v_data_u8);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+
+	return com_rslt;
+}
+/*!
+ *	@brief This function used to set the YAS532 initial values
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_yas532_set_initial_values(void)
+{
+/* This variable used for provide the communication
+	results*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* write testr1 as 0x00*/
+	com_rslt = smi130_set_mag_write_data(
+	SMI130_YAS532_WRITE_TESTR1);
+	p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	com_rslt += smi130_set_mag_write_addr(SMI130_YAS532_TESTR1);
+	p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	/* write testr2 as 0x00*/
+	com_rslt += smi130_set_mag_write_data(
+	SMI130_YAS532_WRITE_TESTR2);
+	p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	com_rslt += smi130_set_mag_write_addr(SMI130_YAS532_TESTR2);
+	p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	/* write Rcoil as 0x00*/
+	com_rslt += smi130_set_mag_write_data(
+	SMI130_YAS532_WRITE_RCOIL);
+	p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	com_rslt += smi130_set_mag_write_addr(SMI130_YAS532_RCOIL);
+	p_smi130->delay_msec(SMI130_YAS532_SET_INITIAL_VALUE_DELAY);
+	/* check the valid offset*/
+	if (is_valid_offset(yas532_data_mbl.v_hard_offset_s8)) {
+		com_rslt += smi130_bosch_yas532_set_offset(
+		yas532_data_mbl.v_hard_offset_s8);
+		yas532_data_mbl.measure_state = YAS532_MAG_STATE_NORMAL;
+	} else {
+		/* set the default offset as invalid offset*/
+		set_vector(yas532_data_mbl.v_hard_offset_s8, INVALID_OFFSET);
+		/*Set the default measure state for offset correction*/
+		yas532_data_mbl.measure_state = YAS532_MAG_STATE_MEASURE_OFFSET;
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This function used for YAS532 offset correction
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_yas532_magnetic_measure_set_offset(
+void)
+{
+	/* This variable used for provide the communication
+	results*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* used for offset value set to the offset register*/
+	s8 v_hard_offset_s8[SMI130_HARD_OFFSET_DATA_SIZE] = {
+	SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE};
+	/* offset correction factors*/
+	static const u8 v_correct_u8[SMI130_YAS_CORRECT_DATA_SIZE] = {
+	16, 8, 4, 2, 1};
+	/* used for the temperature */
+	u16 v_temp_u16 = SMI130_INIT_VALUE;
+	/* used for the xy1y2 read*/
+	u16 v_xy1y2_u16[SMI130_YAS_XY1Y2_DATA_SIZE] = {SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE};
+	/* local flag for assign the values*/
+	s32 v_flag_s32[SMI130_YAS_FLAG_DATA_SIZE] = {SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE};
+	u8 i, j, v_busy_u8, v_overflow_u8 = SMI130_INIT_VALUE;
+
+	for (i = 0; i < 5; i++) {
+		/* set the offset values*/
+		com_rslt = smi130_bosch_yas532_set_offset(v_hard_offset_s8);
+		/* read the sensor data*/
+		com_rslt += smi130_bosch_yas532_normal_measurement_data(
+		SMI130_YAS532_ACQ_START, &v_busy_u8, &v_temp_u16,
+		v_xy1y2_u16, &v_overflow_u8);
+		/* check the sensor busy status*/
+		if (v_busy_u8)
+			return E_SMI130_BUSY;
+		/* calculate the magnetic correction with
+		offset and assign the values
+		to the offset register */
+		for (j = 0; j < 3; j++) {
+			if (YAS532_DATA_CENTER == v_xy1y2_u16[j])
+				v_flag_s32[j] = 0;
+			if (YAS532_DATA_CENTER < v_xy1y2_u16[j])
+				v_flag_s32[j] = 1;
+			if (v_xy1y2_u16[j] < YAS532_DATA_CENTER)
+				v_flag_s32[j] = -1;
+		}
+		for (j = 0; j < 3; j++) {
+			if (v_flag_s32[j])
+				v_hard_offset_s8[j] = (s8)(v_hard_offset_s8[j]
+				+ v_flag_s32[j] * v_correct_u8[i]);
+		}
+	}
+	/* set the offset */
+	com_rslt += smi130_bosch_yas532_set_offset(v_hard_offset_s8);
+	return com_rslt;
+}
+/*!
+ *	@brief This function used for read the
+ *	YAMAHA YAS532 calibration data
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_yamaha_yas532_calib_values(void)
+{
+	/* This variable used for provide the communication
+	results*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* Array holding the YAS532 calibration values */
+	u8 v_data_u8[SMI130_YAS532_CALIB_DATA_SIZE] = {
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE, SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE, SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE, SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE, SMI130_INIT_VALUE};
+	/* Read the DX value */
+	com_rslt = smi130_set_mag_read_addr(SMI130_YAS532_CALIB_CX);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8[0], SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	yas532_data_mbl.calib_yas532.cx = (s32)((v_data_u8[0]
+	* 10) - 1280);
+	/* Read the DY1 value */
+	com_rslt += smi130_set_mag_read_addr(SMI130_YAS532_CALIB_CY1);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8[1], SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	yas532_data_mbl.calib_yas532.cy1 =
+	(s32)((v_data_u8[1] * 10) - 1280);
+	/* Read the DY2 value */
+	com_rslt += smi130_set_mag_read_addr(SMI130_YAS532_CALIB_CY2);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8[2], SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	yas532_data_mbl.calib_yas532.cy2 =
+	(s32)((v_data_u8[2] * 10) - 1280);
+	/* Read the D2 and D3 value */
+	com_rslt += smi130_set_mag_read_addr(SMI130_YAS532_CALIB1);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8[3], SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	yas532_data_mbl.calib_yas532.a2 =
+	(s32)(((v_data_u8[3] >>
+	SMI130_SHIFT_BIT_POSITION_BY_02_BITS)
+	& 0x03F) - 32);
+	/* Read the D3 and D4 value */
+	com_rslt += smi130_set_mag_read_addr(SMI130_YAS532_CALIB2);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8[4], SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	/* calculate a3*/
+	yas532_data_mbl.calib_yas532.a3 = (s32)((((v_data_u8[3] <<
+	SMI130_SHIFT_BIT_POSITION_BY_02_BITS) & 0x0C) |
+	((v_data_u8[4]
+	>> SMI130_SHIFT_BIT_POSITION_BY_06_BITS)
+	& 0x03)) - 8);
+	/* calculate a4*/
+	yas532_data_mbl.calib_yas532.a4 = (s32)((v_data_u8[4]
+	& 0x3F) - 32);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+    /* Read the D5 and D6 value */
+	com_rslt += smi130_set_mag_read_addr(SMI130_YAS532_CALIB3);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8[5], SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	/* calculate a5*/
+	yas532_data_mbl.calib_yas532.a5 =
+	(s32)(((v_data_u8[5]
+	>> SMI130_SHIFT_BIT_POSITION_BY_02_BITS)
+	& 0x3F) + 38);
+	/* Read the D6 and D7 value */
+	com_rslt += smi130_set_mag_read_addr(SMI130_YAS532_CALIB4);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8[6], SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	/* calculate a6*/
+	yas532_data_mbl.calib_yas532.a6 =
+	(s32)((((v_data_u8[5]
+	<< SMI130_SHIFT_BIT_POSITION_BY_04_BITS)
+	& 0x30) | ((v_data_u8[6] >>
+	 SMI130_SHIFT_BIT_POSITION_BY_04_BITS)
+	 & 0x0F)) - 32);
+	 /* Read the D7 and D8 value */
+	com_rslt += smi130_set_mag_read_addr(SMI130_YAS532_CALIB5);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8[7], SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	/* calculate a7*/
+	yas532_data_mbl.calib_yas532.a7 = (s32)((((v_data_u8[6]
+	<< SMI130_SHIFT_BIT_POSITION_BY_03_BITS)
+	& 0x78) |
+	((v_data_u8[7]
+	>> SMI130_SHIFT_BIT_POSITION_BY_05_BITS) &
+	0x07)) - 64);
+	/* Read the D8 and D9 value */
+	com_rslt += smi130_set_mag_read_addr(SMI130_YAS532_CLAIB6);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8[8], SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	/* calculate a8*/
+	yas532_data_mbl.calib_yas532.a8 = (s32)((((v_data_u8[7] <<
+	SMI130_GEN_READ_WRITE_DATA_LENGTH) & 0x3E) |
+	((v_data_u8[8] >>
+	SMI130_SHIFT_BIT_POSITION_BY_07_BITS) & 0x01)) -
+	32);
+
+	/* Read the D8 and D9 value */
+	com_rslt += smi130_set_mag_read_addr(SMI130_YAS532_CALIB7);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8[9], SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	/* calculate a9*/
+	yas532_data_mbl.calib_yas532.a9 = (s32)(((v_data_u8[8] <<
+	SMI130_GEN_READ_WRITE_DATA_LENGTH) & 0xFE) |
+	 ((v_data_u8[9] >>
+	 SMI130_SHIFT_BIT_POSITION_BY_07_BITS) & 0x01));
+	/* calculate k*/
+	yas532_data_mbl.calib_yas532.k = (s32)((v_data_u8[9] >>
+	SMI130_SHIFT_BIT_POSITION_BY_02_BITS) & 0x1F);
+	/* Read the  value from register 0x9A*/
+	com_rslt += smi130_set_mag_read_addr(SMI130_YAS532_CALIB8);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8[10],
+	SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	/* Read the  value from register 0x9B*/
+	com_rslt += smi130_set_mag_read_addr(SMI130_YAS532_CALIIB9);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8[11],
+	SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	/* Read the  value from register 0x9C*/
+	com_rslt += smi130_set_mag_read_addr(SMI130_YAS532_CALIB10);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8[12],
+	SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	/* Read the  value from register 0x9D*/
+	com_rslt += smi130_set_mag_read_addr(SMI130_YAS532_CALIB11);
+	/* 0x04 is secondary read mag x lsb register */
+	com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+	&v_data_u8[13],
+	SMI130_GEN_READ_WRITE_DATA_LENGTH);
+	/* Calculate the fxy1y2 and rxy1y1*/
+	yas532_data_mbl.calib_yas532.fxy1y2[0] =
+	(u8)(((v_data_u8[10]
+	& 0x01)
+	<< SMI130_SHIFT_BIT_POSITION_BY_01_BIT)
+	| ((v_data_u8[11] >>
+	SMI130_SHIFT_BIT_POSITION_BY_07_BITS) & 0x01));
+	yas532_data_mbl.calib_yas532.rxy1y2[0] =
+	((s8)(((v_data_u8[10]
+	>> SMI130_SHIFT_BIT_POSITION_BY_01_BIT) & 0x3F)
+	<< SMI130_SHIFT_BIT_POSITION_BY_02_BITS))
+	>> SMI130_SHIFT_BIT_POSITION_BY_02_BITS;
+	yas532_data_mbl.calib_yas532.fxy1y2[1] =
+	(u8)(((v_data_u8[11] & 0x01)
+	<< SMI130_SHIFT_BIT_POSITION_BY_01_BIT)
+	 | ((v_data_u8[12] >>
+	 SMI130_SHIFT_BIT_POSITION_BY_07_BITS) & 0x01));
+	yas532_data_mbl.calib_yas532.rxy1y2[1] =
+	((s8)(((v_data_u8[11]
+	>> SMI130_SHIFT_BIT_POSITION_BY_01_BIT) & 0x3F)
+	<< SMI130_SHIFT_BIT_POSITION_BY_02_BITS))
+	>> SMI130_SHIFT_BIT_POSITION_BY_02_BITS;
+	yas532_data_mbl.calib_yas532.fxy1y2[2] =
+	(u8)(((v_data_u8[12] & 0x01)
+	<< SMI130_SHIFT_BIT_POSITION_BY_01_BIT)
+	| ((v_data_u8[13]
+	>> SMI130_SHIFT_BIT_POSITION_BY_07_BITS) & 0x01));
+	yas532_data_mbl.calib_yas532.rxy1y2[2] =
+	((s8)(((v_data_u8[12]
+	>> SMI130_SHIFT_BIT_POSITION_BY_01_BIT) & 0x3F)
+	 << SMI130_SHIFT_BIT_POSITION_BY_02_BITS))
+	 >> SMI130_SHIFT_BIT_POSITION_BY_02_BITS;
+
+	return com_rslt;
+}
+/*!
+ *	@brief This function used for calculate the
+ *	YAS532 read the linear data
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_yas532_xy1y2_to_linear(
+u16 *v_xy1y2_u16, s32 *xy1y2_linear)
+{
+	/* This variable used for provide the communication
+	results*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = SUCCESS;
+	static const u16 v_calib_data[] = {
+	3721, 3971, 4221, 4471};
+	u8 i = SMI130_INIT_VALUE;
+
+	for (i = 0; i < 3; i++)
+		xy1y2_linear[i] = v_xy1y2_u16[i] -
+		 v_calib_data[yas532_data_mbl.calib_yas532.fxy1y2[i]]
+			+ (yas532_data_mbl.v_hard_offset_s8[i] -
+			yas532_data_mbl.calib_yas532.rxy1y2[i])
+			* yas532_data_mbl.coef[i];
+	return com_rslt;
+}
+/*!
+ *	@brief This function used for read the YAS532 sensor data
+ *	@param	v_acquisition_command_u8: used to set the data acquisition
+ *	acquisition_command  |   operation
+ *  ---------------------|-------------------------
+ *         0x17          | turn on the acquisition coil
+ *         -             | set direction of the coil
+ *         _             | (x and y as minus(-))
+ *         _             | Deferred acquisition mode
+ *        0x07           | turn on the acquisition coil
+ *         _             | set direction of the coil
+ *         _             | (x and y as minus(-))
+ *         _             | Normal acquisition mode
+ *        0x11           | turn OFF the acquisition coil
+ *         _             | set direction of the coil
+ *         _             | (x and y as plus(+))
+ *         _             | Deferred acquisition mode
+ *       0x01            | turn OFF the acquisition coil
+ *        _              | set direction of the coil
+ *        _              | (x and y as plus(+))
+ *        _              | Normal acquisition mode
+ *
+ *	@param	v_busy_u8 : used to get the busy flay for sensor data read
+ *	@param	v_temp_u16 : used to get the temperature data
+ *	@param	v_xy1y2_u16 : used to get the sensor xy1y2 data
+ *	@param	v_overflow_u8 : used to get the overflow data
+ *
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_yas532_normal_measurement_data(
+u8 v_acquisition_command_u8, u8 *v_busy_u8,
+u16 *v_temp_u16, u16 *v_xy1y2_u16, u8 *v_overflow_u8)
+{
+	/* This variable used for provide the communication
+	results*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = SMI130_INIT_VALUE;
+	/* Array holding the YAS532 xyy1 data*/
+	u8 v_data_u8[SMI130_YAS_XY1Y2T_DATA_SIZE] = {
+	SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE, SMI130_INIT_VALUE};
+	u8 i = SMI130_INIT_VALUE;
+	/* check the p_smi130 structure as NULL*/
+	if (p_smi130 == SMI130_NULL) {
+		return E_SMI130_NULL_PTR;
+		} else {
+		/* read the sensor data */
+		com_rslt = smi130_bosch_yas532_acquisition_command_register(
+		v_acquisition_command_u8);
+		com_rslt +=
+		p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+		SMI130_USER_DATA_MAG_X_LSB__REG,
+		v_data_u8, SMI130_MAG_YAS_DATA_LENGTH);
+		/* read the xyy1 data*/
+		*v_busy_u8 =
+		((v_data_u8[0]
+		>> SMI130_SHIFT_BIT_POSITION_BY_07_BITS) & 0x01);
+		*v_temp_u16 =
+		(u16)((((s32)v_data_u8[0]
+		<< SMI130_SHIFT_BIT_POSITION_BY_03_BITS)
+		& 0x3F8) | ((v_data_u8[1]
+		>> SMI130_SHIFT_BIT_POSITION_BY_05_BITS) & 0x07));
+		v_xy1y2_u16[0] =
+		(u16)((((s32)v_data_u8[2]
+		<< SMI130_SHIFT_BIT_POSITION_BY_06_BITS) & 0x1FC0)
+		| ((v_data_u8[3] >>
+		SMI130_SHIFT_BIT_POSITION_BY_02_BITS) & 0x3F));
+		v_xy1y2_u16[1] =
+		(u16)((((s32)v_data_u8[4]
+		<< SMI130_SHIFT_BIT_POSITION_BY_06_BITS)
+		& 0x1FC0)
+		| ((v_data_u8[5]
+		>> SMI130_SHIFT_BIT_POSITION_BY_02_BITS) & 0x3F));
+		v_xy1y2_u16[2] =
+		(u16)((((s32)v_data_u8[6]
+		<< SMI130_SHIFT_BIT_POSITION_BY_06_BITS)
+		& 0x1FC0)
+		| ((v_data_u8[7]
+		>> SMI130_SHIFT_BIT_POSITION_BY_02_BITS) & 0x3F));
+		*v_overflow_u8 = 0;
+		for (i = 0; i < 3; i++) {
+			if (v_xy1y2_u16[i] == YAS532_DATA_OVERFLOW)
+				*v_overflow_u8 |= (1 << (i * 2));
+			if (v_xy1y2_u16[i] == YAS532_DATA_UNDERFLOW)
+				*v_overflow_u8 |= (1 << (i * 2 + 1));
+		}
+	}
+	return com_rslt;
+}
+/*!
+ *	@brief This function used for YAS532 sensor data
+ *	@param	v_acquisition_command_u8	:	the value of CMDR
+ *	acquisition_command  |   operation
+ *  ---------------------|-------------------------
+ *         0x17          | turn on the acquisition coil
+ *         -             | set direction of the coil
+ *         _             | (x and y as minus(-))
+ *         _             | Deferred acquisition mode
+ *        0x07           | turn on the acquisition coil
+ *         _             | set direction of the coil
+ *         _             | (x and y as minus(-))
+ *         _             | Normal acquisition mode
+ *        0x11           | turn OFF the acquisition coil
+ *         _             | set direction of the coil
+ *         _             | (x and y as plus(+))
+ *         _             | Deferred acquisition mode
+ *       0x01            | turn OFF the acquisition coil
+ *        _              | set direction of the coil
+ *        _              | (x and y as plus(+))
+ *        _              | Normal acquisition mode
+ *
+ * @param xyz_data : the vector xyz output
+ * @param v_overflow_s8 : the value of overflow
+ * @param v_temp_correction_u8 : the value of temperate correction enable
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_yas532_measurement_xyz_data(
+struct yas532_vector *xyz_data, u8 *v_overflow_s8, u8 v_temp_correction_u8,
+u8 v_acquisition_command_u8)
+{
+	/* This variable used for provide the communication
+	results*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = SMI130_INIT_VALUE;
+	/* Array holding the linear calculation output*/
+	s32 v_xy1y2_linear_s32[SMI130_YAS_XY1Y2_DATA_SIZE] = {
+	SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE};
+	/* Array holding the temperature data */
+	s32 v_xyz_tmp_s32[SMI130_YAS_TEMP_DATA_SIZE] = {SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE};
+	s32 tmp = SMI130_INIT_VALUE;
+	s32 sx, sy1, sy2, sy, sz = SMI130_INIT_VALUE;
+	u8 i, v_busy_u8 = SMI130_INIT_VALUE;
+	u16 v_temp_u16 = SMI130_INIT_VALUE;
+	/* Array holding the xyy1 sensor raw data*/
+	u16 v_xy1y2_u16[SMI130_YAS_XY1Y2_DATA_SIZE] = {SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE};
+	#if YAS532_MAG_LOG < YAS532_MAG_TEMPERATURE_LOG
+	s32 sum = SMI130_INIT_VALUE;
+	#endif
+	*v_overflow_s8 = SMI130_INIT_VALUE;
+	switch (yas532_data_mbl.measure_state) {
+	case YAS532_MAG_STATE_INIT_COIL:
+		if (p_smi130->mag_manual_enable != SMI130_MANUAL_ENABLE)
+			com_rslt = smi130_set_mag_manual_enable(
+			SMI130_MANUAL_ENABLE);
+		/* write Rcoil*/
+		com_rslt += smi130_set_mag_write_data(
+		SMI130_YAS_DISABLE_RCOIL);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		com_rslt += smi130_set_mag_write_addr(SMI130_YAS532_RCOIL);
+		p_smi130->delay_msec(SMI130_YAS532_MEASUREMENT_DELAY);
+		if (!yas532_data_mbl.overflow && is_valid_offset(
+		yas532_data_mbl.v_hard_offset_s8))
+			yas532_data_mbl.measure_state = 0;
+	break;
+	case YAS532_MAG_STATE_MEASURE_OFFSET:
+		com_rslt = smi130_bosch_yas532_magnetic_measure_set_offset();
+		yas532_data_mbl.measure_state = 0;
+	break;
+	default:
+	break;
+	}
+	/* Read sensor data*/
+	com_rslt += smi130_bosch_yas532_normal_measurement_data(
+	v_acquisition_command_u8, &v_busy_u8, &v_temp_u16,
+	v_xy1y2_u16, v_overflow_s8);
+	/* Calculate the linear data*/
+	com_rslt += smi130_bosch_yas532_xy1y2_to_linear(v_xy1y2_u16,
+	v_xy1y2_linear_s32);
+	/* Calculate temperature correction */
+	#if YAS532_MAG_LOG < YAS532_MAG_TEMPERATURE_LOG
+		yas532_data_mbl.temp_data.log[yas532_data_mbl.temp_data.idx++] =
+		v_temp_u16;
+	if (YAS532_MAG_TEMPERATURE_LOG <= yas532_data_mbl.temp_data.idx)
+		yas532_data_mbl.temp_data.idx = 0;
+		yas532_data_mbl.temp_data.num++;
+	if (YAS532_MAG_TEMPERATURE_LOG <= yas532_data_mbl.temp_data.num)
+		yas532_data_mbl.temp_data.num = YAS532_MAG_TEMPERATURE_LOG;
+	for (i = 0; i < yas532_data_mbl.temp_data.num; i++)
+		sum += yas532_data_mbl.temp_data.log[i];
+		tmp = sum * 10 / yas532_data_mbl.temp_data.num
+		- YAS532_TEMP20DEGREE_TYPICAL * 10;
+	#else
+		tmp = (v_temp_u16 - YAS532_TEMP20DEGREE_TYPICAL)
+		* 10;
+	#endif
+	sx  = v_xy1y2_linear_s32[0];
+	sy1 = v_xy1y2_linear_s32[1];
+	sy2 = v_xy1y2_linear_s32[2];
+	/* Temperature correction */
+	if (v_temp_correction_u8) {
+		sx  -= (yas532_data_mbl.calib_yas532.cx  * tmp)
+		/ 1000;
+		sy1 -= (yas532_data_mbl.calib_yas532.cy1 * tmp)
+		/ 1000;
+		sy2 -= (yas532_data_mbl.calib_yas532.cy2 * tmp)
+		/ 1000;
+	}
+	sy = sy1 - sy2;
+	sz = -sy1 - sy2;
+
+	xyz_data->yas532_vector_xyz[0] = yas532_data_mbl.calib_yas532.k *
+	((100 * sx + yas532_data_mbl.calib_yas532.a2 * sy +
+	yas532_data_mbl.calib_yas532.a3 * sz) / 10);
+	xyz_data->yas532_vector_xyz[1] = yas532_data_mbl.calib_yas532.k *
+	((yas532_data_mbl.calib_yas532.a4 * sx + yas532_data_mbl.calib_yas532.a5 * sy +
+	yas532_data_mbl.calib_yas532.a6 * sz) / 10);
+	xyz_data->yas532_vector_xyz[2] = yas532_data_mbl.calib_yas532.k *
+	((yas532_data_mbl.calib_yas532.a7 * sx + yas532_data_mbl.calib_yas532.a8 * sy +
+	yas532_data_mbl.calib_yas532.a9 * sz) / 10);
+	if (yas532_data_mbl.transform != SMI130_NULL) {
+		for (i = 0; i < 3; i++) {
+				v_xyz_tmp_s32[i] = yas532_data_mbl.transform[i
+				* 3] *
+				xyz_data->yas532_vector_xyz[0]
+				+ yas532_data_mbl.transform[i * 3 + 1] *
+				xyz_data->yas532_vector_xyz[1]
+				+ yas532_data_mbl.transform[i * 3 + 2] *
+				xyz_data->yas532_vector_xyz[2];
+		}
+		set_vector(xyz_data->yas532_vector_xyz, v_xyz_tmp_s32);
+	}
+	for (i = 0; i < 3; i++) {
+		xyz_data->yas532_vector_xyz[i] -=
+		xyz_data->yas532_vector_xyz[i] % 10;
+		if (*v_overflow_s8 & (1
+		<< (i * 2)))
+			xyz_data->yas532_vector_xyz[i] +=
+			1; /* set overflow */
+		if (*v_overflow_s8 & (1 <<
+		(i * 2 + 1)))
+			xyz_data->yas532_vector_xyz[i] += 2; /* set underflow */
+	}
+
+
+if (v_busy_u8)
+		return com_rslt;
+	if (0 < *v_overflow_s8) {
+		if (!yas532_data_mbl.overflow)
+			yas532_data_mbl.overflow = 1;
+		yas532_data_mbl.measure_state = YAS532_MAG_STATE_INIT_COIL;
+	} else
+		yas532_data_mbl.overflow = 0;
+	for (i = 0; i < 3; i++)
+		yas532_data_mbl.last_raw[i] = v_xy1y2_u16[i];
+	  yas532_data_mbl.last_raw[i] = v_temp_u16;
+	return com_rslt;
+}
+/*!
+ *	@brief This function used for YAS532 write data acquisition
+ *	command register write
+ *	@param	v_command_reg_data_u8	:	the value of data acquisition
+ *	acquisition_command  |   operation
+ *  ---------------------|-------------------------
+ *         0x17          | turn on the acquisition coil
+ *         -             | set direction of the coil
+ *         _             | (x and y as minus(-))
+ *         _             | Deferred acquisition mode
+ *        0x07           | turn on the acquisition coil
+ *         _             | set direction of the coil
+ *         _             | (x and y as minus(-))
+ *         _             | Normal acquisition mode
+ *        0x11           | turn OFF the acquisition coil
+ *         _             | set direction of the coil
+ *         _             | (x and y as plus(+))
+ *         _             | Deferred acquisition mode
+ *       0x01            | turn OFF the acquisition coil
+ *        _              | set direction of the coil
+ *        _              | (x and y as plus(+))
+ *        _              | Normal acquisition mode
+ *
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_yas532_acquisition_command_register(
+u8 v_command_reg_data_u8)
+{
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+
+	if (p_smi130->mag_manual_enable != SMI130_MANUAL_ENABLE)
+			com_rslt = smi130_set_mag_manual_enable(
+			SMI130_MANUAL_ENABLE);
+
+		com_rslt = smi130_set_mag_write_data(v_command_reg_data_u8);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		/* YAMAHA YAS532-0x82*/
+		com_rslt += smi130_set_mag_write_addr(
+		SMI130_YAS532_COMMAND_REGISTER);
+		p_smi130->delay_msec(SMI130_YAS_ACQ_COMMAND_DELAY);
+		com_rslt += smi130_set_mag_read_addr(
+		SMI130_YAS532_DATA_REGISTER);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+
+	if (p_smi130->mag_manual_enable == SMI130_MANUAL_ENABLE)
+		com_rslt += smi130_set_mag_manual_enable(SMI130_MANUAL_DISABLE);
+
+	return com_rslt;
+
+}
+/*!
+ *	@brief This function used write offset of YAS532
+ *
+ *	@param	p_offset_s8	: The value of offset to write
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_yas532_set_offset(
+const s8 *p_offset_s8)
+{
+	/* This variable used for provide the communication
+	results*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+
+	if (p_smi130->mag_manual_enable != SMI130_MANUAL_ENABLE)
+		com_rslt = smi130_set_mag_manual_enable(SMI130_MANUAL_ENABLE);
+		p_smi130->delay_msec(SMI130_YAS532_OFFSET_DELAY);
+
+	    /* Write offset X data*/
+		com_rslt = smi130_set_mag_write_data(p_offset_s8[0]);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		/* YAS532 offset x write*/
+		com_rslt += smi130_set_mag_write_addr(SMI130_YAS532_OFFSET_X);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+
+		/* Write offset Y data*/
+		com_rslt = smi130_set_mag_write_data(p_offset_s8[1]);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		/* YAS532 offset y write*/
+		com_rslt += smi130_set_mag_write_addr(SMI130_YAS532_OFFSET_Y);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+
+		/* Write offset Z data*/
+		com_rslt = smi130_set_mag_write_data(p_offset_s8[2]);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		/* YAS532 offset z write*/
+		com_rslt += smi130_set_mag_write_addr(SMI130_YAS532_OFFSET_Z);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		set_vector(yas532_data_mbl.v_hard_offset_s8, p_offset_s8);
+
+	if (p_smi130->mag_manual_enable == SMI130_MANUAL_ENABLE)
+		com_rslt = smi130_set_mag_manual_enable(SMI130_MANUAL_DISABLE);
+	return com_rslt;
+}
+/*!
+ *	@brief This function used to init the YAMAH-YAS537
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_yamaha_yas537_mag_interface_init(
+void)
+{
+/* This variable used for provide the communication
+results*/
+SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+u8 v_pull_value_u8 = SMI130_INIT_VALUE;
+u8 v_data_u8 = SMI130_INIT_VALUE;
+u8 i = SMI130_INIT_VALUE;
+/* accel operation mode to normal*/
+com_rslt = smi130_set_command_register(ACCEL_MODE_NORMAL);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+/* write mag power mode as NORMAL*/
+com_rslt += smi130_set_mag_interface_normal();
+/* register 0x7E write the 0x37, 0x9A and 0x30*/
+com_rslt += smi130_set_command_register(SMI130_COMMAND_REG_ONE);
+p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+com_rslt += smi130_set_command_register(SMI130_COMMAND_REG_TWO);
+p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+com_rslt += smi130_set_command_register(SMI130_COMMAND_REG_THREE);
+p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+/*switch the page1*/
+com_rslt += smi130_set_target_page(SMI130_WRITE_TARGET_PAGE1);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+smi130_get_target_page(&v_data_u8);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+com_rslt += smi130_set_paging_enable(SMI130_WRITE_ENABLE_PAGE1);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+smi130_get_paging_enable(&v_data_u8);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+/* enable the pullup configuration from
+the register 0x05 bit 4 and 5 as 10*/
+smi130_get_pullup_configuration(&v_pull_value_u8);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+v_pull_value_u8 = v_pull_value_u8 | SMI130_PULL_UP_DATA;
+com_rslt += smi130_set_pullup_configuration(v_pull_value_u8);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+/*switch the page0*/
+com_rslt += smi130_set_target_page(SMI130_WRITE_TARGET_PAGE0);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+smi130_get_target_page(&v_data_u8);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+/* Write the YAS532 i2c address*/
+com_rslt += smi130_set_i2c_device_addr(SMI130_YAS537_I2C_ADDRESS);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+/* enable the mag interface to manual mode*/
+com_rslt += smi130_set_mag_manual_enable(SMI130_MANUAL_ENABLE);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+smi130_get_mag_manual_enable(&v_data_u8);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+/*Enable the MAG interface */
+com_rslt += smi130_set_if_mode(SMI130_ENABLE_MAG_IF_MODE);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+smi130_get_if_mode(&v_data_u8);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+v_data_u8 = SMI130_MANUAL_DISABLE;
+/* Read the YAS537 device id*/
+com_rslt += smi130_set_mag_read_addr(SMI130_YAS_DEVICE_ID_REG);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+&v_data_u8, SMI130_GEN_READ_WRITE_DATA_LENGTH);
+yas537_data_mbl.dev_id = v_data_u8;
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+/* Read the YAS532 calibration data*/
+com_rslt +=
+smi130_bosch_yamaha_yas537_calib_values(
+SMI130_GEN_READ_WRITE_DATA_LENGTH);
+p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+/* set the mode to NORMAL*/
+yas537_data_mbl.measure_state = YAS537_MAG_STATE_NORMAL;
+/* set the transform to zero */
+yas537_data_mbl.transform = SMI130_NULL;
+yas537_data_mbl.average = 32;
+for (i = 0; i < 3; i++) {
+	yas537_data_mbl.hard_offset[i] = -128;
+	yas537_data_mbl.last_after_rcoil[i] = 0;
+}
+for (i = 0; i < 4; i++)
+	yas537_data_mbl.last_raw[i] = 0;
+/* write the mag bandwidth as 25Hz*/
+com_rslt += smi130_set_mag_output_data_rate(
+SMI130_MAG_OUTPUT_DATA_RATE_25HZ);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+/* Enable mag interface to auto mode*/
+com_rslt += smi130_set_mag_manual_enable(
+SMI130_MANUAL_DISABLE);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+smi130_get_mag_manual_enable(&v_data_u8);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+return com_rslt;
+}
+/*!
+*	@brief This function used for read the
+*	YAMAHA YAS537 calibration data
+*
+*
+*	@param v_rcoil_u8 : The value of r coil
+*
+*
+*	@return results of bus communication function
+*	@retval 0 -> Success
+*	@retval -1 -> Error
+*
+*
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_yamaha_yas537_calib_values(
+u8 v_rcoil_u8)
+{
+/* This variable used for provide the communication
+results*/
+SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+/* Array holding the YAS532 calibration values */
+u8 a_data_u8[SMI130_YAS537_CALIB_DATA_SIZE] = {
+SMI130_INIT_VALUE, SMI130_INIT_VALUE,
+SMI130_INIT_VALUE, SMI130_INIT_VALUE, SMI130_INIT_VALUE,
+SMI130_INIT_VALUE, SMI130_INIT_VALUE, SMI130_INIT_VALUE,
+SMI130_INIT_VALUE, SMI130_INIT_VALUE, SMI130_INIT_VALUE,
+SMI130_INIT_VALUE, SMI130_INIT_VALUE, SMI130_INIT_VALUE,
+SMI130_INIT_VALUE, SMI130_INIT_VALUE, SMI130_INIT_VALUE,
+};
+static const u8 v_avrr_u8[] = {0x50, 0x60, 0x70};
+u8 v_cal_valid_u8 = SMI130_INIT_VALUE, i;
+/* write soft reset as 0x02*/
+com_rslt = smi130_set_mag_write_data(
+YAS537_SRSTR_DATA);
+p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+com_rslt += smi130_set_mag_write_addr(YAS537_REG_SRSTR);
+p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+/* Read the DX value */
+com_rslt = smi130_set_mag_read_addr(YAS537_REG_CALR_C0);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+&a_data_u8[0], SMI130_GEN_READ_WRITE_DATA_LENGTH);
+/* Read the DY1 value */
+com_rslt += smi130_set_mag_read_addr(YAS537_REG_CALR_C1);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+&a_data_u8[1], SMI130_GEN_READ_WRITE_DATA_LENGTH);
+/* Read the DY2 value */
+com_rslt += smi130_set_mag_read_addr(YAS537_REG_CALR_C2);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+&a_data_u8[2], SMI130_GEN_READ_WRITE_DATA_LENGTH);
+/* Read the D2 value */
+com_rslt += smi130_set_mag_read_addr(YAS537_REG_CALR_C3);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+&a_data_u8[3], SMI130_GEN_READ_WRITE_DATA_LENGTH);
+/* Read the D3 value */
+com_rslt += smi130_set_mag_read_addr(YAS537_REG_CALR_C4);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+&a_data_u8[4], SMI130_GEN_READ_WRITE_DATA_LENGTH);
+/* Read the D4 value */
+com_rslt += smi130_set_mag_read_addr(YAS537_REG_CALR_C5);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+&a_data_u8[5], SMI130_GEN_READ_WRITE_DATA_LENGTH);
+/* Read the D5 value */
+com_rslt += smi130_set_mag_read_addr(YAS537_REG_CALR_C6);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+&a_data_u8[6], SMI130_GEN_READ_WRITE_DATA_LENGTH);
+/* Read the D6 value */
+com_rslt += smi130_set_mag_read_addr(YAS537_REG_CALR_C7);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+&a_data_u8[7], SMI130_GEN_READ_WRITE_DATA_LENGTH);
+/* Read the D7 value */
+com_rslt += smi130_set_mag_read_addr(YAS537_REG_CALR_C8);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+&a_data_u8[8], SMI130_GEN_READ_WRITE_DATA_LENGTH);
+/* Read the D8 value */
+com_rslt += smi130_set_mag_read_addr(YAS537_REG_CALR_C9);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+&a_data_u8[9], SMI130_GEN_READ_WRITE_DATA_LENGTH);
+/* Read the D9 value */
+com_rslt += smi130_set_mag_read_addr(YAS537_REG_CALR_CA);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+&a_data_u8[10], SMI130_GEN_READ_WRITE_DATA_LENGTH);
+/* Read the RX value */
+com_rslt += smi130_set_mag_read_addr(YAS537_REG_CALR_CB);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+&a_data_u8[11], SMI130_GEN_READ_WRITE_DATA_LENGTH);
+/* Read the RY1 value */
+com_rslt += smi130_set_mag_read_addr(YAS537_REG_CALR_CC);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+&a_data_u8[12], SMI130_GEN_READ_WRITE_DATA_LENGTH);
+/* Read the RY2 value */
+com_rslt += smi130_set_mag_read_addr(YAS537_REG_CALR_CD);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+&a_data_u8[13], SMI130_GEN_READ_WRITE_DATA_LENGTH);
+/* Read the RY2 value */
+com_rslt += smi130_set_mag_read_addr(YAS537_REG_CALR_CE);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+&a_data_u8[14], SMI130_GEN_READ_WRITE_DATA_LENGTH);
+/* Read the CHF value */
+com_rslt += smi130_set_mag_read_addr(YAS537_REG_CALR_CF);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+&a_data_u8[15], SMI130_GEN_READ_WRITE_DATA_LENGTH);
+/* Read the VER value */
+com_rslt += smi130_set_mag_read_addr(YAS537_REG_CALR_DO);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+/* 0x04 is secondary read mag x lsb register */
+com_rslt += smi130_read_reg(SMI130_MAG_DATA_READ_REG,
+&a_data_u8[16], SMI130_GEN_READ_WRITE_DATA_LENGTH);
+/* get the calib ver*/
+yas537_data_mbl.calib_yas537.ver =
+(a_data_u8[16] >> SMI130_SHIFT_BIT_POSITION_BY_06_BITS);
+for (i = 0; i < 17; i++) {
+	if (((i < 16 && a_data_u8[i]) != 0))
+		v_cal_valid_u8 = 1;
+	if ((i < 16 &&
+	(a_data_u8[i] & 0x3F)) != 0)
+		v_cal_valid_u8 = 1;
+}
+if (!v_cal_valid_u8)
+	return ERROR;
+if (yas537_data_mbl.calib_yas537.ver == 0) {
+	for (i = 0; i < 17; i++) {
+		if (i < 12) {
+			/* write offset*/
+			com_rslt += smi130_set_mag_write_data(
+			a_data_u8[i]);
+			p_smi130->delay_msec(
+			SMI130_GEN_READ_WRITE_DELAY);
+			com_rslt += smi130_set_mag_write_addr(
+			YAS537_REG_MTCR + i);
+			p_smi130->delay_msec(
+			SMI130_GEN_READ_WRITE_DELAY);
+		} else if (i < 15) {
+			/* write offset correction*/
+			com_rslt += smi130_set_mag_write_data(
+			a_data_u8[i]);
+			p_smi130->delay_msec(
+			SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+			com_rslt += smi130_set_mag_write_addr((
+			(YAS537_REG_OXR + i) - 12));
+			p_smi130->delay_msec(
+			SMI130_GEN_READ_WRITE_DELAY);
+			yas537_data_mbl.hard_offset[i - 12]
+			= a_data_u8[i];
+		} else {
+			/* write offset correction*/
+			com_rslt += smi130_set_mag_write_data(
+			a_data_u8[i]);
+			p_smi130->delay_msec(
+			SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+			com_rslt += smi130_set_mag_write_addr((
+			(YAS537_REG_OXR + i) - 11));
+			p_smi130->delay_msec(
+			SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+		}
+
+}
+} else if (yas537_data_mbl.calib_yas537.ver == 1) {
+	for (i = 0; i < 3; i++) {
+		/* write offset*/
+		com_rslt += smi130_set_mag_write_data(
+		a_data_u8[i]);
+		p_smi130->delay_msec(
+		SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+		com_rslt += smi130_set_mag_write_addr(
+		YAS537_REG_MTCR + i);
+		p_smi130->delay_msec(
+		SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+		if (com_rslt == SUCCESS) {
+			/* write offset*/
+			com_rslt += smi130_set_mag_write_data(
+			a_data_u8[i + 12]);
+			p_smi130->delay_msec(
+			SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+			com_rslt += smi130_set_mag_write_addr(
+			YAS537_REG_OXR + i);
+			p_smi130->delay_msec(
+			SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+			yas537_data_mbl.hard_offset[i] =
+			a_data_u8[i + 12];
+		} else {
+			com_rslt = ERROR;
+		}
+	}
+	/* write offset*/
+	com_rslt += smi130_set_mag_write_data(
+	((a_data_u8[i] & 0xE0) | 0x10));
+	p_smi130->delay_msec(
+	SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	com_rslt += smi130_set_mag_write_addr(
+	YAS537_REG_MTCR + i);
+	p_smi130->delay_msec(
+	SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	/* write offset*/
+	com_rslt += smi130_set_mag_write_data(
+	((a_data_u8[15]
+	>> SMI130_SHIFT_BIT_POSITION_BY_03_BITS)
+	& 0x1E));
+	p_smi130->delay_msec(
+	SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	com_rslt += smi130_set_mag_write_addr(YAS537_REG_HCKR);
+	p_smi130->delay_msec(
+	SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	/* write offset*/
+	com_rslt += smi130_set_mag_write_data(
+	((a_data_u8[15] << 1) & 0x1E));
+	p_smi130->delay_msec(
+	SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	com_rslt += smi130_set_mag_write_addr(YAS537_REG_LCKR);
+	p_smi130->delay_msec(
+	SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	/* write offset*/
+	com_rslt += smi130_set_mag_write_data(
+	(a_data_u8[16] & 0x3F));
+	p_smi130->delay_msec(
+	SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	com_rslt += smi130_set_mag_write_addr(YAS537_REG_OCR);
+	p_smi130->delay_msec(
+	SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+
+	/* Assign the calibration values*/
+	/* a2 */
+	yas537_data_mbl.calib_yas537.a2 =
+	((((a_data_u8[3]
+	<< SMI130_SHIFT_BIT_POSITION_BY_02_BITS)
+	& 0x7C)
+	| (a_data_u8[4]
+	>> SMI130_SHIFT_BIT_POSITION_BY_06_BITS)) - 64);
+	/* a3 */
+	yas537_data_mbl.calib_yas537.a3 =
+	((((a_data_u8[4] << SMI130_SHIFT_BIT_POSITION_BY_01_BIT)
+	& 0x7E)
+	| (a_data_u8[5]
+	>> SMI130_SHIFT_BIT_POSITION_BY_07_BITS)) - 64);
+	/* a4 */
+	yas537_data_mbl.calib_yas537.a4 =
+	((((a_data_u8[5]
+	<< SMI130_SHIFT_BIT_POSITION_BY_01_BIT)
+	& 0xFE)
+	| (a_data_u8[6]
+	>> SMI130_SHIFT_BIT_POSITION_BY_07_BITS))
+	- 128);
+	/* a5 */
+	yas537_data_mbl.calib_yas537.a5 =
+	((((a_data_u8[6]
+	<< SMI130_SHIFT_BIT_POSITION_BY_02_BITS)
+	& 0x1FC)
+	| (a_data_u8[7]
+	>> SMI130_SHIFT_BIT_POSITION_BY_06_BITS))
+	- 112);
+	/* a6 */
+	yas537_data_mbl.calib_yas537.a6 =
+	((((a_data_u8[7]
+	<< SMI130_SHIFT_BIT_POSITION_BY_01_BIT)
+	& 0x7E)
+	| (a_data_u8[8]
+	>> SMI130_SHIFT_BIT_POSITION_BY_07_BITS)) - 64);
+	/* a7 */
+	yas537_data_mbl.calib_yas537.a7 =
+	((((a_data_u8[8]
+	<< SMI130_SHIFT_BIT_POSITION_BY_01_BIT)
+	& 0xFE)
+	| (a_data_u8[9]
+	>> SMI130_SHIFT_BIT_POSITION_BY_07_BITS))
+	- 128);
+	/* a8 */
+	yas537_data_mbl.calib_yas537.a8 = ((a_data_u8[9] &
+	0x7F) - 64);
+	/* a9 */
+	yas537_data_mbl.calib_yas537.a9 = ((((a_data_u8[10]
+	<< SMI130_SHIFT_BIT_POSITION_BY_01_BIT) & 0x1FE)
+	| (a_data_u8[11]
+	>> SMI130_SHIFT_BIT_POSITION_BY_07_BITS))
+	- 112);
+	/* k */
+	yas537_data_mbl.calib_yas537.k = (
+	a_data_u8[11] & 0x7F);
+	} else {
+		return ERROR;
+	}
+/* write A/D converter*/
+com_rslt += smi130_set_mag_write_data(
+YAS537_WRITE_A_D_CONVERTER);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+com_rslt += smi130_set_mag_write_addr(YAS537_REG_ADCCALR);
+p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+/* write A/D converter second register*/
+com_rslt += smi130_set_mag_write_data(
+YAS537_WRITE_A_D_CONVERTER2);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+com_rslt += smi130_set_mag_write_addr(YAS537_REG_ADCCALR_ONE);
+p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+/* write temperature calibration register*/
+com_rslt += smi130_set_mag_write_data(YAS537_WRITE_TEMP_CALIB);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+com_rslt += smi130_set_mag_write_addr(YAS537_REG_TRMR);
+p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+/* write average filter register*/
+com_rslt += smi130_set_mag_write_data(
+v_avrr_u8[yas537_data_mbl.average]);
+p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+com_rslt += smi130_set_mag_write_addr(YAS537_REG_AVRR);
+p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+if (v_rcoil_u8) {
+	/* write average; filter register*/
+	com_rslt += smi130_set_mag_write_data(
+	YAS537_WRITE_FILTER);
+	p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+	com_rslt += smi130_set_mag_write_addr(YAS537_REG_CONFR);
+	p_smi130->delay_msec(
+	SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+}
+
+return com_rslt;
+
+}
+/*!
+ *	@brief This function used for YAS537 write data acquisition
+ *	command register write
+ *	@param	v_command_reg_data_u8	:	the value of data acquisition
+ *	acquisition_command  |   operation
+ *  ---------------------|-------------------------
+ *         0x17          | turn on the acquisition coil
+ *         -             | set direction of the coil
+ *         _             | (x and y as minus(-))
+ *         _             | Deferred acquisition mode
+ *        0x07           | turn on the acquisition coil
+ *         _             | set direction of the coil
+ *         _             | (x and y as minus(-))
+ *         _             | Normal acquisition mode
+ *        0x11           | turn OFF the acquisition coil
+ *         _             | set direction of the coil
+ *         _             | (x and y as plus(+))
+ *         _             | Deferred acquisition mode
+ *       0x01            | turn OFF the acquisition coil
+ *        _              | set direction of the coil
+ *        _              | (x and y as plus(+))
+ *        _              | Normal acquisition mode
+ *
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_yas537_acquisition_command_register(
+u8 v_command_reg_data_u8)
+{
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+
+	if (p_smi130->mag_manual_enable != SMI130_MANUAL_ENABLE)
+			com_rslt = smi130_set_mag_manual_enable(
+			SMI130_MANUAL_ENABLE);
+			p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+
+		com_rslt = smi130_set_mag_write_data(v_command_reg_data_u8);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		/* YAMAHA YAS532-0x82*/
+		com_rslt += smi130_set_mag_write_addr(
+		SMI130_REG_YAS537_CMDR);
+		/* set the mode to RECORD*/
+		yas537_data_mbl.measure_state = YAS537_MAG_STATE_RECORD_DATA;
+		p_smi130->delay_msec(SMI130_YAS_ACQ_COMMAND_DELAY);
+		com_rslt += smi130_set_mag_read_addr(
+		YAS537_REG_TEMPERATURE_0);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+
+	if (p_smi130->mag_manual_enable == SMI130_MANUAL_ENABLE)
+		com_rslt += smi130_set_mag_manual_enable(
+		SMI130_MANUAL_DISABLE);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+
+	return com_rslt;
+
+}
+/*!
+ *	@brief This function used for read the
+ *	YAMAHA YAS537 xy1y2 data
+ *
+ *	@param xy1y2: The value of raw xy1y2 data
+ *	@param xyz: The value of  xyz data
+ *
+ *
+ *	@return None
+ *
+ *
+ */
+static void xy1y2_to_xyz(u16 *xy1y2, s32 *xyz)
+{
+	xyz[0] = ((xy1y2[0] - 8192)
+	* 300);
+	xyz[1] = (((xy1y2[1] - xy1y2[2])
+	* 1732) / 10);
+	xyz[2] = (((-xy1y2[2] - xy1y2[2])
+	+ 16384) * 300);
+}
+/*!
+ *	@brief This function used for read the
+ *	YAMAHA YAS537 xy1y2 data
+ *
+ *	@param v_coil_stat_u8: The value of R coil status
+ *	@param v_busy_u8: The value of busy status
+ *	@param v_temperature_u16: The value of temperature
+ *	@param xy1y2: The value of raw xy1y2 data
+ *	@param v_ouflow_u8: The value of overflow
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_yamaha_yas537_read_xy1y2_data(
+u8 *v_coil_stat_u8, u8 *v_busy_u8,
+u16 *v_temperature_u16, u16 *xy1y2, u8 *v_ouflow_u8)
+{
+	/* This variable used for provide the communication
+	results*/
+	SMI130_RETURN_FUNCTION_TYPE com_rslt = E_SMI130_COMM_RES;
+	/* Array holding the YAS532 calibration values */
+	u8 a_data_u8[SMI130_YAS_XY1Y2T_DATA_SIZE] = {
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE, SMI130_INIT_VALUE,
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE, SMI130_INIT_VALUE,
+	};
+	u8 i = SMI130_INIT_VALUE;
+	s32 a_h_s32[SMI130_YAS_H_DATA_SIZE] = {
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE, SMI130_INIT_VALUE};
+	s32 a_s_s32[SMI130_YAS_S_DATA_SIZE] = {
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE, SMI130_INIT_VALUE};
+	/* set command register*/
+	com_rslt = smi130_bosch_yas537_acquisition_command_register(
+	YAS537_SET_COMMAND_REGISTER);
+	/* read the yas537 sensor data of xy1y2*/
+	com_rslt +=
+	p_smi130->SMI130_BUS_READ_FUNC(p_smi130->dev_addr,
+	SMI130_USER_DATA_MAG_X_LSB__REG,
+	a_data_u8, SMI130_MAG_YAS_DATA_LENGTH);
+	/* read the busy flag*/
+	*v_busy_u8 = a_data_u8[2]
+	>> SMI130_SHIFT_BIT_POSITION_BY_07_BITS;
+	/* read the coil status*/
+	*v_coil_stat_u8 =
+	((a_data_u8[2] >>
+	SMI130_SHIFT_BIT_POSITION_BY_06_BITS) & 0X01);
+	/* read temperature data*/
+	*v_temperature_u16 = (u16)((a_data_u8[0]
+	<< SMI130_SHIFT_BIT_POSITION_BY_08_BITS) | a_data_u8[1]);
+	/* read x data*/
+	xy1y2[0] = (u16)(((a_data_u8[2] &
+	0x3F)
+	<< SMI130_SHIFT_BIT_POSITION_BY_08_BITS)
+	| (a_data_u8[3]));
+	/* read y1 data*/
+	xy1y2[1] = (u16)((a_data_u8[4]
+	<< SMI130_SHIFT_BIT_POSITION_BY_08_BITS)
+	| a_data_u8[5]);
+	/* read y2 data*/
+	xy1y2[2] = (u16)((a_data_u8[6]
+	<< SMI130_SHIFT_BIT_POSITION_BY_08_BITS)
+	| a_data_u8[7]);
+	for (i = 0; i < 3; i++)
+		yas537_data_mbl.last_raw[i] = xy1y2[i];
+	yas537_data_mbl.last_raw[i] = *v_temperature_u16;
+	if (yas537_data_mbl.calib_yas537.ver == 1) {
+		for (i = 0; i < 3; i++)
+			a_s_s32[i] = xy1y2[i] - 8192;
+		/* read hx*/
+		a_h_s32[0] = ((yas537_data_mbl.calib_yas537.k * (
+		(128 * a_s_s32[0]) +
+		(yas537_data_mbl.calib_yas537.a2 * a_s_s32[1]) +
+		(yas537_data_mbl.calib_yas537.a3 * a_s_s32[2])))
+		/ (8192));
+		/* read hy1*/
+		a_h_s32[1] = ((yas537_data_mbl.calib_yas537.k * (
+		(yas537_data_mbl.calib_yas537.a4 * a_s_s32[0]) +
+		(yas537_data_mbl.calib_yas537.a5 * a_s_s32[1]) +
+		(yas537_data_mbl.calib_yas537.a6 * a_s_s32[2])))
+		/ (8192));
+		/* read hy2*/
+		a_h_s32[2] = ((yas537_data_mbl.calib_yas537.k * (
+		(yas537_data_mbl.calib_yas537.a7 * a_s_s32[0]) +
+		(yas537_data_mbl.calib_yas537.a8 * a_s_s32[1]) +
+		(yas537_data_mbl.calib_yas537.a9 * a_s_s32[2])))
+		/ (8192));
+
+		for (i = 0; i < 3; i++) {
+			if (a_h_s32[i] < -8192)
+				a_h_s32[i] = -8192;
+
+			if (8192 < a_h_s32[i])
+				a_h_s32[i] = 8192;
+
+			xy1y2[i] = a_h_s32[i] + 8192;
+
+		}
+	}
+	*v_ouflow_u8 = 0;
+	for (i = 0; i < 3; i++) {
+		if (YAS537_DATA_OVERFLOW <= xy1y2[i])
+			*v_ouflow_u8 |= (1 << (i * 2));
+		if (xy1y2[i] == YAS537_DATA_UNDERFLOW)
+			*v_ouflow_u8 |= (1 << (i * 2 + 1));
+	}
+
+	return com_rslt;
+
+}
+/*!
+ *	@brief This function used for read the
+ *	YAMAHA YAS537 xy1y2 data
+ *
+ *	@param v_ouflow_u8: The value of overflow
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+static SMI130_RETURN_FUNCTION_TYPE invalid_magnetic_field(
+u16 *v_cur_u16, u16 *v_last_u16)
+{
+	s16 invalid_thresh[] = {1500, 1500, 1500};
+	u8 i = SMI130_INIT_VALUE;
+
+	for (i = 0; i < 3; i++)
+		if (invalid_thresh[i] < ABS(v_cur_u16[i] - v_last_u16[i]))
+			return 1;
+	return 0;
+}
+/*!
+ *	@brief This function used for read the
+ *	YAMAHA YAS537 xy1y2 data
+ *
+ *	@param v_ouflow_u8: The value of overflow
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_yamaha_yas537_measure_xyz_data(
+u8 *v_ouflow_u8, struct yas_vector *vector_xyz)
+{
+	s32 a_xyz_tmp_s32[SMI130_YAS_TEMP_DATA_SIZE] = {
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE, SMI130_INIT_VALUE};
+	u8 i = SMI130_INIT_VALUE;
+	s8 com_rslt = SMI130_INIT_VALUE;
+	u8 v_busy_u8 = SMI130_INIT_VALUE;
+	u8 v_rcoil_u8 = SMI130_INIT_VALUE;
+	u16 v_temperature_u16 = SMI130_INIT_VALUE;
+	u16 a_xy1y2_u16[SMI130_YAS_XY1Y2_DATA_SIZE] = {
+	SMI130_INIT_VALUE, SMI130_INIT_VALUE, SMI130_INIT_VALUE};
+	*v_ouflow_u8 = 0;
+	/* read the yas537 xy1y2 data*/
+	com_rslt = smi130_bosch_yamaha_yas537_read_xy1y2_data(
+	&v_rcoil_u8, &v_busy_u8,
+	&v_temperature_u16, a_xy1y2_u16, v_ouflow_u8);
+	/* linear calculation*/
+	xy1y2_to_xyz(a_xy1y2_u16, vector_xyz->yas537_vector_xyz);
+	if (yas537_data_mbl.transform != SMI130_NULL) {
+		for (i = 0; i < 3; i++) {
+			a_xyz_tmp_s32[i] = ((
+			yas537_data_mbl.transform[i + 3]
+			* vector_xyz->yas537_vector_xyz[0])
+			+ (yas537_data_mbl.transform[
+			i * 3 + 1]
+			* vector_xyz->yas537_vector_xyz[1])
+			+ (yas537_data_mbl.transform[
+			i * 3 + 2]
+			* vector_xyz->yas537_vector_xyz[2]));
+		}
+		yas537_set_vector(
+		vector_xyz->yas537_vector_xyz, a_xyz_tmp_s32);
+	}
+	for (i = 0; i < 3; i++) {
+		vector_xyz->yas537_vector_xyz[i] -=
+		vector_xyz->yas537_vector_xyz[i] % 10;
+		if (*v_ouflow_u8 & (1 <<
+		(i * 2)))
+			vector_xyz->yas537_vector_xyz[i] +=
+			1; /* set overflow */
+		if (*v_ouflow_u8 & (1 << (i * 2 + 1)))
+			/* set underflow */
+			vector_xyz->yas537_vector_xyz[i] += 2;
+	}
+	if (v_busy_u8)
+		return ERROR;
+	switch (yas537_data_mbl.measure_state) {
+	case YAS537_MAG_STATE_INIT_COIL:
+		if (p_smi130->mag_manual_enable != SMI130_MANUAL_ENABLE)
+			com_rslt = smi130_set_mag_manual_enable(
+			SMI130_MANUAL_ENABLE);
+		com_rslt += smi130_set_mag_write_data(YAS537_WRITE_CONFR);
+		p_smi130->delay_msec(SMI130_GEN_READ_WRITE_DELAY);
+		com_rslt += smi130_set_mag_write_addr(YAS537_REG_CONFR);
+		p_smi130->delay_msec(SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+		yas537_data_mbl.measure_state = YAS537_MAG_STATE_RECORD_DATA;
+		if (p_smi130->mag_manual_enable == SMI130_MANUAL_ENABLE)
+			com_rslt = smi130_set_mag_manual_enable(
+			SMI130_MANUAL_DISABLE);
+	break;
+	case YAS537_MAG_STATE_RECORD_DATA:
+		if (v_rcoil_u8)
+			break;
+		yas537_set_vector(yas537_data_mbl.last_after_rcoil, a_xy1y2_u16);
+		yas537_data_mbl.measure_state = YAS537_MAG_STATE_NORMAL;
+	break;
+	case YAS537_MAG_STATE_NORMAL:
+		if (SMI130_INIT_VALUE < v_ouflow_u8
+		|| invalid_magnetic_field(a_xy1y2_u16,
+		yas537_data_mbl.last_after_rcoil)) {
+			yas537_data_mbl.measure_state = YAS537_MAG_STATE_INIT_COIL;
+			for (i = 0; i < 3; i++) {
+				if (!*v_ouflow_u8)
+					vector_xyz->yas537_vector_xyz[i] += 3;
+			}
+		}
+	break;
+	}
+
+	return com_rslt;
+}
+/*!
+ *	@brief This function used for reading
+ *	smi130_t structure
+ *
+ *  @return the reference and values of smi130_t
+ *
+ *
+*/
+struct smi130_t *smi130_get_ptr(void)
+{
+	return  p_smi130;
+}
diff --git a/drivers/input/sensors/smi130/smi130.h b/drivers/input/sensors/smi130/smi130.h
new file mode 100644
index 0000000..c62f65c
--- /dev/null
+++ b/drivers/input/sensors/smi130/smi130.h
@@ -0,0 +1,11851 @@
+/*!
+ * @section LICENSE
+ * (C) Copyright 2011~2016 Bosch Sensortec GmbH All Rights Reserved
+ *
+ * (C) Modification Copyright 2018 Robert Bosch Kft  All Rights Reserved
+ *
+ * This software program is licensed subject to the GNU General
+ * Public License (GPL).Version 2,June 1991,
+ * available at http://www.fsf.org/copyleft/gpl.html
+ *
+ * Special: Description of the Software:
+ *
+ * This software module (hereinafter called "Software") and any
+ * information on application-sheets (hereinafter called "Information") is
+ * provided free of charge for the sole purpose to support your application
+ * work. 
+ *
+ * As such, the Software is merely an experimental software, not tested for
+ * safety in the field and only intended for inspiration for further development 
+ * and testing. Any usage in a safety-relevant field of use (like automotive,
+ * seafaring, spacefaring, industrial plants etc.) was not intended, so there are
+ * no precautions for such usage incorporated in the Software.
+ * 
+ * The Software is specifically designed for the exclusive use for Bosch
+ * Sensortec products by personnel who have special experience and training. Do
+ * not use this Software if you do not have the proper experience or training.
+ * 
+ * This Software package is provided as is and without any expressed or
+ * implied warranties, including without limitation, the implied warranties of
+ * merchantability and fitness for a particular purpose.
+ * 
+ * Bosch Sensortec and their representatives and agents deny any liability for
+ * the functional impairment of this Software in terms of fitness, performance
+ * and safety. Bosch Sensortec and their representatives and agents shall not be
+ * liable for any direct or indirect damages or injury, except as otherwise
+ * stipulated in mandatory applicable law.
+ * The Information provided is believed to be accurate and reliable. Bosch
+ * Sensortec assumes no responsibility for the consequences of use of such
+ * Information nor for any infringement of patents or other rights of third
+ * parties which may result from its use.
+ * 
+ *------------------------------------------------------------------------------
+ * The following Product Disclaimer does not apply to the BSX4-HAL-4.1NoFusion Software 
+ * which is licensed under the Apache License, Version 2.0 as stated above.  
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Product Disclaimer
+ *
+ * Common:
+ *
+ * Assessment of Products Returned from Field
+ *
+ * Returned products are considered good if they fulfill the specifications / 
+ * test data for 0-mileage and field listed in this document.
+ *
+ * Engineering Samples
+ * 
+ * Engineering samples are marked with (e) or (E). Samples may vary from the
+ * valid technical specifications of the series product contained in this
+ * data sheet. Therefore, they are not intended or fit for resale to
+ * third parties or for use in end products. Their sole purpose is internal
+ * client testing. The testing of an engineering sample may in no way replace
+ * the testing of a series product. Bosch assumes no liability for the use
+ * of engineering samples. The purchaser shall indemnify Bosch from all claims
+ * arising from the use of engineering samples.
+ *
+ * Intended use
+ *
+ * Provided that SMI130 is used within the conditions (environment, application,
+ * installation, loads) as described in this TCD and the corresponding
+ * agreed upon documents, Bosch ensures that the product complies with
+ * the agreed properties. Agreements beyond this require
+ * the written approval by Bosch. The product is considered fit for the intended
+ * use when the product successfully has passed the tests
+ * in accordance with the TCD and agreed upon documents.
+ *
+ * It is the responsibility of the customer to ensure the proper application
+ * of the product in the overall system/vehicle.
+ *
+ * Bosch does not assume any responsibility for changes to the environment
+ * of the product that deviate from the TCD and the agreed upon documents 
+ * as well as all applications not released by Bosch
+  *
+ * The resale and/or use of products are at the purchaser’s own risk and 
+ * responsibility. The examination and testing of the SMI130 
+ * is the sole responsibility of the purchaser.
+ *
+ * The purchaser shall indemnify Bosch from all third party claims 
+ * arising from any product use not covered by the parameters of 
+ * this product data sheet or not approved by Bosch and reimburse Bosch 
+ * for all costs and damages in connection with such claims.
+ *
+ * The purchaser must monitor the market for the purchased products,
+ * particularly with regard to product safety, and inform Bosch without delay
+ * of all security relevant incidents.
+ *
+ * Application Examples and Hints
+ *
+ * With respect to any application examples, advice, normal values
+ * and/or any information regarding the application of the device,
+ * Bosch hereby disclaims any and all warranties and liabilities of any kind,
+ * including without limitation warranties of
+ * non-infringement of intellectual property rights or copyrights
+ * of any third party.
+ * The information given in this document shall in no event be regarded 
+ * as a guarantee of conditions or characteristics. They are provided
+ * for illustrative purposes only and no evaluation regarding infringement
+ * of intellectual property rights or copyrights or regarding functionality,
+ * performance or error has been made.
+*
+* smi130.h
+* Date : 2015/04/02
+* @id       836294d
+* Revision : 2.0.9 $
+* @brief
+* The head file of SMI130API
+*
+
+**************************************************************************/
+/*! \file smi130.h
+    \brief SMI130 Sensor Driver Support Header File */
+/* user defined code to be added here ... */
+#ifndef __SMI130_H__
+#define __SMI130_H__
+
+/*!
+* @brief The following definition uses for define the data types
+*
+* @note While porting the API please consider the following
+* @note Please check the version of C standard
+* @note Are you using Linux platform
+*/
+
+/*!
+* @brief For the Linux platform support
+* Please use the types.h for your data types definitions
+*/
+#ifdef	__KERNEL__
+
+#include <linux/types.h>
+
+#else /* ! __KERNEL__ */
+/**********************************************************
+* These definition uses for define the C
+* standard version data types
+***********************************************************/
+# if !defined(__STDC_VERSION__)
+
+/************************************************
+ * compiler is C11 C standard
+************************************************/
+#if (__STDC_VERSION__ == 201112L)
+
+/************************************************/
+#include <stdint.h>
+/************************************************/
+
+/*unsigned integer types*/
+#define	u8	uint8_t
+#define	u16	uint16_t
+#define	u32	uint32_t
+#define	u64	uint64_t
+
+/*signed integer types*/
+#define	s8	int8_t
+#define	s16	int16_t
+#define	s32	int32_t
+#define	s64	int64_t
+/************************************************
+ * compiler is C99 C standard
+************************************************/
+
+#elif (__STDC_VERSION__ == 199901L)
+
+/* stdint.h is a C99 supported c library.
+which is used to fixed the integer size*/
+/************************************************/
+#include <stdint.h>
+/************************************************/
+
+/*unsigned integer types*/
+#define	u8	uint8_t
+#define	u16	uint16_t
+#define	u32	uint32_t
+#define	u64	uint64_t
+
+/*signed integer types*/
+#define s8	int8_t
+#define	s16	int16_t
+#define	s32	int32_t
+#define	s64	int64_t
+/************************************************
+ * compiler is C89 or other C standard
+************************************************/
+#else /*  !defined(__STDC_VERSION__) */
+/*	By default it is defined as 32 bit machine configuration*/
+/*	define the definition based on your machine configuration*/
+/*	define the data types based on your
+	machine/compiler/controller configuration*/
+#define  MACHINE_32_BIT
+
+/* If your machine support 16 bit
+define the MACHINE_16_BIT*/
+#ifdef MACHINE_16_BIT
+#include <limits.h>
+/*signed integer types*/
+#define	s8	signed char
+#define	s16	signed short int
+#define	s32	signed long int
+
+#if defined(LONG_MAX) && LONG_MAX == 0x7fffffffffffffffL
+#define s64 long int
+#define u64 unsigned long int
+#elif defined(LLONG_MAX) && (LLONG_MAX == 0x7fffffffffffffffLL)
+#define s64 long long int
+#define u64 unsigned long long int
+#else
+#warning Either the correct data type for signed 64 bit integer \
+could not be found, or 64 bit integers are not supported in your environment.
+#warning If 64 bit integers are supported on your platform, \
+please set s64 manually.
+#endif
+
+/*unsigned integer types*/
+#define	u8	unsigned char
+#define	u16	unsigned short int
+#define	u32	unsigned long int
+
+/* If your machine support 32 bit
+define the MACHINE_32_BIT*/
+#elif defined MACHINE_32_BIT
+/*signed integer types*/
+#define	s8	signed char
+#define	s16	signed short int
+#define	s32	signed int
+#define	s64	signed long long int
+
+/*unsigned integer types*/
+#define	u8	unsigned char
+#define	u16	unsigned short int
+#define	u32	unsigned int
+#define	u64	unsigned long long int
+
+/* If your machine support 64 bit
+define the MACHINE_64_BIT*/
+#elif defined MACHINE_64_BIT
+/*signed integer types*/
+#define	s8	signed char
+#define	s16	signed short int
+#define	s32	signed int
+#define	s64	signed long int
+
+/*unsigned integer types*/
+#define	u8	unsigned char
+#define	u16	unsigned short int
+#define	u32	unsigned int
+#define	u64	unsigned long int
+
+#else
+#warning The data types defined above which not supported \
+define the data types manually
+#endif
+#endif
+
+/*** This else will execute for the compilers
+ *	which are not supported the C standards
+ *	Like C89/C99/C11***/
+#else
+/*	By default it is defined as 32 bit machine configuration*/
+/*	define the definition based on your machine configuration*/
+/*	define the data types based on your
+	machine/compiler/controller configuration*/
+#define  MACHINE_32_BIT
+
+/* If your machine support 16 bit
+define the MACHINE_16_BIT*/
+#ifdef MACHINE_16_BIT
+#include <limits.h>
+/*signed integer types*/
+#define	s8	signed char
+#define	s16	signed short int
+#define	s32	signed long int
+
+#if defined(LONG_MAX) && LONG_MAX == 0x7fffffffffffffffL
+#define s64 long int
+#define u64 unsigned long int
+#elif defined(LLONG_MAX) && (LLONG_MAX == 0x7fffffffffffffffLL)
+#define s64 long long int
+#define u64 unsigned long long int
+#else
+#warning Either the correct data type for signed 64 bit integer \
+could not be found, or 64 bit integers are not supported in your environment.
+#warning If 64 bit integers are supported on your platform, \
+please set s64 manually.
+#endif
+
+/*unsigned integer types*/
+#define	u8	unsigned char
+#define	u16	unsigned short int
+#define	u32	unsigned long int
+
+/* If your machine support 32 bit
+define the MACHINE_32_BIT*/
+#elif defined MACHINE_32_BIT
+/*signed integer types*/
+#define	s8	signed char
+#define	s16	signed short int
+#define	s32	signed int
+#define	s64	signed long long int
+
+/*unsigned integer types*/
+#define	u8	unsigned char
+#define	u16	unsigned short int
+#define	u32	unsigned int
+#define	u64	unsigned long long int
+
+/* If your machine support 64 bit
+define the MACHINE_64_BIT*/
+#elif defined  MACHINE_64_BIT
+/*signed integer types*/
+#define	s8	signed char
+#define	s16	signed short int
+#define	s32	signed int
+#define	s64	signed long int
+
+/*unsigned integer types*/
+#define	u8	unsigned char
+#define	u16	unsigned short int
+#define	u32	unsigned int
+#define	u64	unsigned long int
+
+#else
+#warning The data types defined above which not supported \
+define the data types manually
+#endif
+#endif
+#endif
+/***************************************************************/
+/**\name	BUS READ AND WRITE FUNCTION POINTERS        */
+/***************************************************************/
+/*!
+	@brief Define the calling convention of YOUR bus communication routine.
+	@note This includes types of parameters. This example shows the
+	configuration for an SPI bus link.
+
+    If your communication function looks like this:
+
+    write_my_bus_xy(u8 device_addr, u8 register_addr,
+    u8 * data, u8 length);
+
+    The SMI130_WR_FUNC_PTR would equal:
+
+    SMI130_WR_FUNC_PTR s8 (* bus_write)(u8,
+    u8, u8 *, u8)
+
+    Parameters can be mixed as needed refer to the
+    @ref SMI130_BUS_WRITE_FUNC  macro.
+
+
+*/
+#define SMI130_WR_FUNC_PTR s8 (*bus_write)(u8, u8,\
+u8 *, u8)
+/**< link macro between API function calls and bus write function
+	@note The bus write function can change since this is a
+	system dependant issue.
+
+    If the bus_write parameter calling order is like: reg_addr,
+    reg_data, wr_len it would be as it is here.
+
+    If the parameters are differently ordered or your communication
+    function like I2C need to know the device address,
+    you can change this macro accordingly.
+
+
+    SMI130_BUS_WRITE_FUNC(dev_addr, reg_addr, reg_data, wr_len)\
+    bus_write(dev_addr, reg_addr, reg_data, wr_len)
+
+    This macro lets all API functions call YOUR communication routine in a
+    way that equals your definition in the
+    @ref SMI130_WR_FUNC_PTR definition.
+
+*/
+#define SMI130_BUS_WRITE_FUNC(dev_addr, reg_addr, reg_data, wr_len)\
+				bus_write(dev_addr, reg_addr, reg_data, wr_len)
+
+/**< Define the calling convention of YOUR bus communication routine.
+	@note This includes types of parameters. This example shows the
+	configuration for an SPI bus link.
+
+    If your communication function looks like this:
+
+    read_my_bus_xy(u8 device_addr, u8 register_addr,
+    u8 * data, u8 length);
+
+    The SMI130_RD_FUNC_PTR would equal:
+
+    SMI130_RD_FUNC_PTR s8 (* bus_read)(u8,
+    u8, u8 *, u8)
+
+    Parameters can be mixed as needed refer to the
+    refer SMI130_BUS_READ_FUNC  macro.
+
+*/
+#define SMI130_SPI_RD_MASK (0x80)   /* for spi read transactions on SPI the
+			MSB has to be set */
+#define SMI130_RD_FUNC_PTR s8 (*bus_read)(u8,\
+			u8, u8 *, u8)
+
+#define SMI130_BRD_FUNC_PTR s8 \
+(*burst_read)(u8, u8, u8 *, u32)
+
+/**< link macro between API function calls and bus read function
+	@note The bus write function can change since this is a
+	system dependant issue.
+
+    If the bus_read parameter calling order is like: reg_addr,
+    reg_data, wr_len it would be as it is here.
+
+    If the parameters are differently ordered or your communication
+    function like I2C need to know the device address,
+    you can change this macro accordingly.
+
+
+    SMI130_BUS_READ_FUNC(dev_addr, reg_addr, reg_data, wr_len)\
+    bus_read(dev_addr, reg_addr, reg_data, wr_len)
+
+    This macro lets all API functions call YOUR communication routine in a
+    way that equals your definition in the
+    refer SMI130_WR_FUNC_PTR definition.
+
+    @note: this macro also includes the "MSB='1'
+    for reading SMI130 addresses.
+
+*/
+#define SMI130_BUS_READ_FUNC(dev_addr, reg_addr, reg_data, r_len)\
+				bus_read(dev_addr, reg_addr, reg_data, r_len)
+
+#define SMI130_BURST_READ_FUNC(device_addr, \
+register_addr, register_data, rd_len)\
+burst_read(device_addr, register_addr, register_data, rd_len)
+
+
+#define SMI130_MDELAY_DATA_TYPE                 u32
+
+/***************************************************************/
+/**\name	BUS READ AND WRITE FUNCTION POINTERS        */
+/***************************************************************/
+#define SMI130_I2C_ADDR1	0x68 /**< I2C Address needs to be changed */
+#define SMI130_I2C_ADDR2    0x69 /**< I2C Address needs to be changed */
+#define SMI130_AUX_BMM150_I2C_ADDRESS       (0x10)
+#define SMI130_AUX_YAS532_I2C_ADDRESS       (0x2E)
+/**< I2C address of YAS532*/
+#define SMI130_AKM09911_I2C_ADDRESS   0x0C/**< I2C address of AKM09911*/
+/**< I2C address of AKM09911*/
+#define	SMI130_AUX_AKM09911_I2C_ADDR_2		(0x0D)
+/**< I2C address of AKM09911*/
+#define	SMI130_AUX_AKM09912_I2C_ADDR_1		(0x0C)
+/**< I2C address of AKM09912*/
+#define	SMI130_AUX_AKM09912_I2C_ADDR_2		(0x0D)
+/**< I2C address of AKM09912*/
+#define	SMI130_AUX_AKM09912_I2C_ADDR_3		(0x0E)
+/**< I2C address of AKM09912*/
+#define SMI130_AKM09912_I2C_ADDRESS   0x0F/**< I2C address of akm09912*/
+
+#define SMI130_YAS532_I2C_ADDRESS	0x2E/**< I2C address of YAS532*/
+/*******************************************/
+/**\name	CONSTANTS        */
+/******************************************/
+#define  SMI130_INIT_VALUE					(0)
+#define  SMI130_GEN_READ_WRITE_DATA_LENGTH	(1)
+#define  SMI130_MAXIMUM_TIMEOUT             (10)
+/* output data rate condition check*/
+#define  SMI130_OUTPUT_DATA_RATE0	(0)
+#define  SMI130_OUTPUT_DATA_RATE1	(1)
+#define  SMI130_OUTPUT_DATA_RATE2	(2)
+#define  SMI130_OUTPUT_DATA_RATE3	(3)
+#define  SMI130_OUTPUT_DATA_RATE4	(4)
+#define  SMI130_OUTPUT_DATA_RATE5	(5)
+#define  SMI130_OUTPUT_DATA_RATE6	(14)
+#define  SMI130_OUTPUT_DATA_RATE7	(15)
+/* accel range check*/
+#define SMI130_ACCEL_RANGE0  (3)
+#define SMI130_ACCEL_RANGE1  (5)
+#define SMI130_ACCEL_RANGE3  (8)
+#define SMI130_ACCEL_RANGE4  (12)
+/* check the status of registers*/
+#define  SMI130_FOC_STAT_HIGH			(1)
+#define  SMI130_SIG_MOTION_STAT_HIGH	(1)
+#define  SMI130_STEP_DET_STAT_HIGH		(1)
+
+/*condition check for reading and writing data*/
+#define	SMI130_MAX_VALUE_SIGNIFICANT_MOTION      (1)
+#define	SMI130_MAX_VALUE_FIFO_FILTER    (1)
+#define	SMI130_MAX_VALUE_FIFO_TIME      (1)
+#define	SMI130_MAX_VALUE_FIFO_INTR      (1)
+#define	SMI130_MAX_VALUE_FIFO_HEADER    (1)
+#define	SMI130_MAX_VALUE_FIFO_MAG       (1)
+#define	SMI130_MAX_VALUE_FIFO_ACCEL     (1)
+#define	SMI130_MAX_VALUE_FIFO_GYRO      (1)
+#define	SMI130_MAX_VALUE_SOURCE_INTR    (1)
+#define	SMI130_MAX_VALUE_LOW_G_MODE     (1)
+#define	SMI130_MAX_VALUE_NO_MOTION      (1)
+#define	SMI130_MAX_VALUE_TAP_SHOCK      (1)
+#define	SMI130_MAX_VALUE_TAP_QUIET      (1)
+#define	SMI130_MAX_VALUE_ORIENT_UD      (1)
+#define	SMI130_MAX_VALUE_ORIENT_AXES    (1)
+#define	SMI130_MAX_VALUE_NVM_PROG       (1)
+#define	SMI130_MAX_VALUE_SPI3           (1)
+#define	SMI130_MAX_VALUE_PAGE           (1)
+#define	SMI130_MAX_VALUE_I2C_WDT        (1)
+#define	SMI130_MAX_VALUE_SLEEP_STATE    (1)
+#define	SMI130_MAX_VALUE_WAKEUP_INTR    (1)
+#define	SMI130_MAX_VALUE_SELFTEST_SIGN  (1)
+#define	SMI130_MAX_VALUE_SELFTEST_AMP   (1)
+#define	SMI130_MAX_VALUE_SELFTEST_START (1)
+#define SMI130_MAX_GYRO_WAKEUP_TRIGGER		(3)
+#define SMI130_MAX_ACCEL_SELFTEST_AXIS	    (3)
+#define SMI130_MAX_GYRO_STEP_COUNTER        (1)
+#define SMI130_MAX_GYRO_BW                  (3)
+#define SMI130_MAX_ACCEL_BW                 (7)
+#define SMI130_MAX_ORIENT_MODE              (3)
+#define SMI130_MAX_ORIENT_BLOCKING          (3)
+#define SMI130_MAX_FLAT_HOLD                (3)
+#define SMI130_MAX_ACCEL_FOC                (3)
+#define SMI130_MAX_IF_MODE                  (3)
+#define SMI130_MAX_TARGET_PAGE              (3)
+#define SMI130_MAX_GYRO_RANGE               (4)
+#define SMI130_MAX_GYRO_SLEEP_TIGGER        (7)
+#define SMI130_MAX_TAP_TURN                 (7)
+#define SMI130_MAX_UNDER_SAMPLING           (1)
+#define SMI130_MAX_UNDER_SIG_MOTION         (3)
+#define SMI130_MAX_ACCEL_OUTPUT_DATA_RATE   (12)
+#define SMI130_MAX_LATCH_INTR               (15)
+#define SMI130_MAX_FLAT_HYST                (15)
+#define SMI130_MAX_ORIENT_THETA             (63)
+#define SMI130_MAX_FLAT_THETA               (63)
+
+/* FIFO index definitions*/
+#define SMI130_FIFO_X_LSB_DATA			(0)
+#define SMI130_FIFO_X_MSB_DATA			(1)
+#define SMI130_FIFO_Y_LSB_DATA			(2)
+#define SMI130_FIFO_Y_MSB_DATA			(3)
+#define SMI130_FIFO_Z_LSB_DATA			(4)
+#define SMI130_FIFO_Z_MSB_DATA			(5)
+#define SMI130_FIFO_R_LSB_DATA			(6)
+#define SMI130_FIFO_R_MSB_DATA			(7)
+/* FIFO gyro definition*/
+#define SMI130_GA_FIFO_G_X_LSB		(0)
+#define SMI130_GA_FIFO_G_X_MSB		(1)
+#define SMI130_GA_FIFO_G_Y_LSB		(2)
+#define SMI130_GA_FIFO_G_Y_MSB		(3)
+#define SMI130_GA_FIFO_G_Z_LSB		(4)
+#define SMI130_GA_FIFO_G_Z_MSB		(5)
+#define SMI130_GA_FIFO_A_X_LSB		(6)
+#define SMI130_GA_FIFO_A_X_MSB		(7)
+#define SMI130_GA_FIFO_A_Y_LSB		(8)
+#define SMI130_GA_FIFO_A_Y_MSB		(9)
+#define SMI130_GA_FIFO_A_Z_LSB		(10)
+#define SMI130_GA_FIFO_A_Z_MSB		(11)
+/* FIFO mag/gyro/accel definition*/
+#define SMI130_MGA_FIFO_M_X_LSB		(0)
+#define SMI130_MGA_FIFO_M_X_MSB		(1)
+#define SMI130_MGA_FIFO_M_Y_LSB		(2)
+#define SMI130_MGA_FIFO_M_Y_MSB		(3)
+#define SMI130_MGA_FIFO_M_Z_LSB		(4)
+#define SMI130_MGA_FIFO_M_Z_MSB		(5)
+#define SMI130_MGA_FIFO_M_R_LSB		(6)
+#define SMI130_MGA_FIFO_M_R_MSB		(7)
+#define SMI130_MGA_FIFO_G_X_LSB		(8)
+#define SMI130_MGA_FIFO_G_X_MSB		(9)
+#define SMI130_MGA_FIFO_G_Y_LSB		(10)
+#define SMI130_MGA_FIFO_G_Y_MSB		(11)
+#define SMI130_MGA_FIFO_G_Z_LSB		(12)
+#define SMI130_MGA_FIFO_G_Z_MSB		(13)
+#define SMI130_MGA_FIFO_A_X_LSB		(14)
+#define SMI130_MGA_FIFO_A_X_MSB		(15)
+#define SMI130_MGA_FIFO_A_Y_LSB		(16)
+#define SMI130_MGA_FIFO_A_Y_MSB		(17)
+#define SMI130_MGA_FIFO_A_Z_LSB		(18)
+#define SMI130_MGA_FIFO_A_Z_MSB		(19)
+/* FIFO mag definition*/
+#define SMI130_MA_FIFO_M_X_LSB		(0)
+#define SMI130_MA_FIFO_M_X_MSB		(1)
+#define SMI130_MA_FIFO_M_Y_LSB		(2)
+#define SMI130_MA_FIFO_M_Y_MSB		(3)
+#define SMI130_MA_FIFO_M_Z_LSB		(4)
+#define SMI130_MA_FIFO_M_Z_MSB		(5)
+#define SMI130_MA_FIFO_M_R_LSB		(6)
+#define SMI130_MA_FIFO_M_R_MSB		(7)
+#define SMI130_MA_FIFO_A_X_LSB		(8)
+#define SMI130_MA_FIFO_A_X_MSB		(9)
+#define SMI130_MA_FIFO_A_Y_LSB		(10)
+#define SMI130_MA_FIFO_A_Y_MSB		(11)
+#define SMI130_MA_FIFO_A_Z_LSB		(12)
+#define SMI130_MA_FIFO_A_Z_MSB		(13)
+/* FIFO mag/gyro definition*/
+#define SMI130_MG_FIFO_M_X_LSB		(0)
+#define SMI130_MG_FIFO_M_X_MSB		(1)
+#define SMI130_MG_FIFO_M_Y_LSB		(2)
+#define SMI130_MG_FIFO_M_Y_MSB		(3)
+#define SMI130_MG_FIFO_M_Z_LSB		(4)
+#define SMI130_MG_FIFO_M_Z_MSB		(5)
+#define SMI130_MG_FIFO_M_R_LSB		(6)
+#define SMI130_MG_FIFO_M_R_MSB		(7)
+#define SMI130_MG_FIFO_G_X_LSB		(8)
+#define SMI130_MG_FIFO_G_X_MSB		(9)
+#define SMI130_MG_FIFO_G_Y_LSB		(10)
+#define SMI130_MG_FIFO_G_Y_MSB		(11)
+#define SMI130_MG_FIFO_G_Z_LSB		(12)
+#define SMI130_MG_FIFO_G_Z_MSB		(13)
+/* FIFO length definitions*/
+#define SMI130_FIFO_SENSOR_TIME_LSB     (0)
+#define SMI130_FIFO_SENSOR_TIME_XLSB    (1)
+#define SMI130_FIFO_SENSOR_TIME_MSB     (2)
+#define SMI130_FIFO_SENSOR_TIME_LENGTH  (3)
+#define SMI130_FIFO_A_LENGTH            (6)
+#define SMI130_FIFO_G_LENGTH            (6)
+#define SMI130_FIFO_M_LENGTH            (8)
+#define SMI130_FIFO_AG_LENGTH           (12)
+#define SMI130_FIFO_AMG_LENGTH          (20)
+#define SMI130_FIFO_MA_OR_MG_LENGTH     (14)
+
+/* bus read and write length for mag, accel and gyro*/
+#define SMI130_MAG_X_DATA_LENGTH     (2)
+#define SMI130_MAG_Y_DATA_LENGTH     (2)
+#define SMI130_MAG_Z_DATA_LENGTH     (2)
+#define SMI130_MAG_R_DATA_LENGTH     (2)
+#define SMI130_MAG_XYZ_DATA_LENGTH	 (6)
+#define SMI130_MAG_XYZR_DATA_LENGTH	 (8)
+#define SMI130_MAG_YAS_DATA_LENGTH	 (8)
+#define SMI130_GYRO_DATA_LENGTH		 (2)
+#define SMI130_GYRO_XYZ_DATA_LENGTH	 (6)
+#define SMI130_ACCEL_DATA_LENGTH	 (2)
+#define SMI130_ACCEL_XYZ_DATA_LENGTH (6)
+#define SMI130_TEMP_DATA_LENGTH		 (2)
+#define SMI130_FIFO_DATA_LENGTH		 (2)
+#define SMI130_STEP_COUNTER_LENGTH	 (2)
+#define SMI130_SENSOR_TIME_LENGTH	 (3)
+
+/* Delay definitions*/
+#define SMI130_SEC_INTERFACE_GEN_READ_WRITE_DELAY    (5)
+#define SMI130_BMM150_WAKEUP_DELAY1                  (2)
+#define SMI130_BMM150_WAKEUP_DELAY2                  (3)
+#define SMI130_BMM150_WAKEUP_DELAY3                  (1)
+#define SMI130_YAS532_OFFSET_DELAY                   (2)
+#define SMI130_GEN_READ_WRITE_DELAY                  (1)
+#define SMI130_YAS532_MEASUREMENT_DELAY              (25)
+#define SMI130_YAS_ACQ_COMMAND_DELAY                 (50)
+#define SMI130_YAS532_SET_INITIAL_VALUE_DELAY        (200)
+#define SMI130_AKM_INIT_DELAY                        (60)
+/****************************************************/
+/**\name	ARRAY SIZE DEFINITIONS      */
+/***************************************************/
+#define	SMI130_ACCEL_X_DATA_SIZE   (2)
+#define	SMI130_ACCEL_Y_DATA_SIZE   (2)
+#define	SMI130_ACCEL_Z_DATA_SIZE   (2)
+#define	SMI130_ACCEL_XYZ_DATA_SIZE (6)
+
+#define	SMI130_GYRO_X_DATA_SIZE    (2)
+#define	SMI130_GYRO_Y_DATA_SIZE    (2)
+#define	SMI130_GYRO_Z_DATA_SIZE    (2)
+#define	SMI130_GYRO_XYZ_DATA_SIZE  (6)
+
+#define	SMI130_MAG_X_DATA_SIZE      (2)
+#define	SMI130_MAG_Y_DATA_SIZE      (2)
+#define	SMI130_MAG_Z_DATA_SIZE      (2)
+#define	SMI130_MAG_R_DATA_SIZE      (2)
+#define	SMI130_MAG_XYZ_DATA_SIZE    (6)
+#define	SMI130_MAG_XYZR_DATA_SIZE   (8)
+#define	SMI130_MAG_TRIM_DATA_SIZE   (16)
+
+
+#define	SMI130_TEMP_DATA_SIZE       (2)
+#define	SMI130_FIFO_DATA_SIZE       (2)
+#define	SMI130_STEP_COUNT_DATA_SIZE (2)
+
+#define	SMI130_SENSOR_TIME_DATA_SIZE      (3)
+#define	SMI130_AKM_SENSITIVITY_DATA_SIZE  (3)
+#define	SMI130_HARD_OFFSET_DATA_SIZE      (3)
+#define	SMI130_YAS_XY1Y2_DATA_SIZE        (3)
+#define	SMI130_YAS_FLAG_DATA_SIZE         (3)
+#define	SMI130_YAS_TEMP_DATA_SIZE         (3)
+#define	SMI130_YAS_H_DATA_SIZE            (3)
+#define	SMI130_YAS_S_DATA_SIZE            (3)
+#define SMI130_YAS_CORRECT_DATA_SIZE      (5)
+#define SMI130_YAS_XY1Y2T_DATA_SIZE       (8)
+#define SMI130_YAS537_CALIB_DATA_SIZE     (17)
+#define SMI130_YAS532_CALIB_DATA_SIZE     (14)
+/****************************************************/
+/**\name	ARRAY PARAMETER DEFINITIONS      */
+/***************************************************/
+#define SMI130_SENSOR_TIME_MSB_BYTE   (2)
+#define SMI130_SENSOR_TIME_XLSB_BYTE  (1)
+#define SMI130_SENSOR_TIME_LSB_BYTE   (0)
+
+#define SMI130_MAG_X_LSB_BYTE	          (0)
+#define SMI130_MAG_X_MSB_BYTE              (1)
+#define SMI130_MAG_Y_LSB_BYTE	           (0)
+#define SMI130_MAG_Y_MSB_BYTE              (1)
+#define SMI130_MAG_Z_LSB_BYTE	           (0)
+#define SMI130_MAG_Z_MSB_BYTE              (1)
+#define SMI130_MAG_R_LSB_BYTE	           (0)
+#define SMI130_MAG_R_MSB_BYTE              (1)
+#define SMI130_DATA_FRAME_MAG_X_LSB_BYTE   (0)
+#define SMI130_DATA_FRAME_MAG_X_MSB_BYTE   (1)
+#define SMI130_DATA_FRAME_MAG_Y_LSB_BYTE   (2)
+#define SMI130_DATA_FRAME_MAG_Y_MSB_BYTE   (3)
+#define SMI130_DATA_FRAME_MAG_Z_LSB_BYTE   (4)
+#define SMI130_DATA_FRAME_MAG_Z_MSB_BYTE   (5)
+#define SMI130_DATA_FRAME_MAG_R_LSB_BYTE   (6)
+#define SMI130_DATA_FRAME_MAG_R_MSB_BYTE   (7)
+
+#define SMI130_GYRO_X_LSB_BYTE              (0)
+#define SMI130_GYRO_X_MSB_BYTE              (1)
+#define SMI130_GYRO_Y_LSB_BYTE              (0)
+#define SMI130_GYRO_Y_MSB_BYTE              (1)
+#define SMI130_GYRO_Z_LSB_BYTE              (0)
+#define SMI130_GYRO_Z_MSB_BYTE              (1)
+#define SMI130_DATA_FRAME_GYRO_X_LSB_BYTE   (0)
+#define SMI130_DATA_FRAME_GYRO_X_MSB_BYTE   (1)
+#define SMI130_DATA_FRAME_GYRO_Y_LSB_BYTE   (2)
+#define SMI130_DATA_FRAME_GYRO_Y_MSB_BYTE   (3)
+#define SMI130_DATA_FRAME_GYRO_Z_LSB_BYTE   (4)
+#define SMI130_DATA_FRAME_GYRO_Z_MSB_BYTE   (5)
+
+#define SMI130_ACCEL_X_LSB_BYTE              (0)
+#define SMI130_ACCEL_X_MSB_BYTE              (1)
+#define SMI130_ACCEL_Y_LSB_BYTE              (0)
+#define SMI130_ACCEL_Y_MSB_BYTE              (1)
+#define SMI130_ACCEL_Z_LSB_BYTE              (0)
+#define SMI130_ACCEL_Z_MSB_BYTE              (1)
+#define SMI130_DATA_FRAME_ACCEL_X_LSB_BYTE   (0)
+#define SMI130_DATA_FRAME_ACCEL_X_MSB_BYTE   (1)
+#define SMI130_DATA_FRAME_ACCEL_Y_LSB_BYTE   (2)
+#define SMI130_DATA_FRAME_ACCEL_Y_MSB_BYTE   (3)
+#define SMI130_DATA_FRAME_ACCEL_Z_LSB_BYTE   (4)
+#define SMI130_DATA_FRAME_ACCEL_Z_MSB_BYTE   (5)
+
+#define	SMI130_TEMP_LSB_BYTE    (0)
+#define	SMI130_TEMP_MSB_BYTE    (1)
+
+#define	SMI130_FIFO_LENGTH_LSB_BYTE    (0)
+#define	SMI130_FIFO_LENGTH_MSB_BYTE    (1)
+
+#define	SMI130_STEP_COUNT_LSB_BYTE    (0)
+#define	SMI130_STEP_COUNT_MSB_BYTE    (1)
+/****************************************************/
+/**\name	ERROR CODES       */
+/***************************************************/
+
+#define E_SMI130_NULL_PTR			((s8)-127)
+#define E_SMI130_COMM_RES			((s8)-1)
+#define E_SMI130_OUT_OF_RANGE		((s8)-2)
+#define E_SMI130_BUSY				((s8)-3)
+#define	SUCCESS						((u8)0)
+#define	ERROR						((s8)-1)
+
+/* Constants */
+#define SMI130_NULL						(0)
+#define SMI130_DELAY_SETTLING_TIME		(5)
+/*This refers SMI130 return type as s8 */
+#define SMI130_RETURN_FUNCTION_TYPE        s8
+/****************************************************/
+/**\name	REGISTER DEFINITIONS       */
+/***************************************************/
+/*******************/
+/**\name CHIP ID */
+/*******************/
+#define SMI130_USER_CHIP_ID_ADDR				(0x00)
+/*******************/
+/**\name ERROR STATUS */
+/*******************/
+#define SMI130_USER_ERROR_ADDR					(0X02)
+/*******************/
+/**\name POWER MODE STATUS */
+/*******************/
+#define SMI130_USER_PMU_STAT_ADDR				(0X03)
+/*******************/
+/**\name MAG DATA REGISTERS */
+/*******************/
+#define SMI130_USER_DATA_0_ADDR					(0X04)
+#define SMI130_USER_DATA_1_ADDR					(0X05)
+#define SMI130_USER_DATA_2_ADDR					(0X06)
+#define SMI130_USER_DATA_3_ADDR					(0X07)
+#define SMI130_USER_DATA_4_ADDR					(0X08)
+#define SMI130_USER_DATA_5_ADDR					(0X09)
+#define SMI130_USER_DATA_6_ADDR					(0X0A)
+#define SMI130_USER_DATA_7_ADDR					(0X0B)
+/*******************/
+/**\name GYRO DATA REGISTERS */
+/*******************/
+#define SMI130_USER_DATA_8_ADDR					(0X0C)
+#define SMI130_USER_DATA_9_ADDR					(0X0D)
+#define SMI130_USER_DATA_10_ADDR				(0X0E)
+#define SMI130_USER_DATA_11_ADDR				(0X0F)
+#define SMI130_USER_DATA_12_ADDR				(0X10)
+#define SMI130_USER_DATA_13_ADDR				(0X11)
+#define SMI130_USER_DATA_14_ADDR				(0X12)
+#define SMI130_USER_DATA_15_ADDR				(0X13)
+/*******************/
+/**\name ACCEL DATA REGISTERS */
+/*******************/
+#define SMI130_USER_DATA_16_ADDR				(0X14)
+#define SMI130_USER_DATA_17_ADDR				(0X15)
+#define SMI130_USER_DATA_18_ADDR				(0X16)
+#define SMI130_USER_DATA_19_ADDR				(0X17)
+/*******************/
+/**\name SENSOR TIME REGISTERS */
+/*******************/
+#define SMI130_USER_SENSORTIME_0_ADDR			(0X18)
+#define SMI130_USER_SENSORTIME_1_ADDR			(0X19)
+#define SMI130_USER_SENSORTIME_2_ADDR			(0X1A)
+/*******************/
+/**\name STATUS REGISTER FOR SENSOR STATUS FLAG */
+/*******************/
+#define SMI130_USER_STAT_ADDR					(0X1B)
+/*******************/
+/**\name INTERRUPY STATUS REGISTERS */
+/*******************/
+#define SMI130_USER_INTR_STAT_0_ADDR			(0X1C)
+#define SMI130_USER_INTR_STAT_1_ADDR			(0X1D)
+#define SMI130_USER_INTR_STAT_2_ADDR			(0X1E)
+#define SMI130_USER_INTR_STAT_3_ADDR			(0X1F)
+/*******************/
+/**\name TEMPERATURE REGISTERS */
+/*******************/
+#define SMI130_USER_TEMPERATURE_0_ADDR			(0X20)
+#define SMI130_USER_TEMPERATURE_1_ADDR			(0X21)
+/*******************/
+/**\name FIFO REGISTERS */
+/*******************/
+#define SMI130_USER_FIFO_LENGTH_0_ADDR			(0X22)
+#define SMI130_USER_FIFO_LENGTH_1_ADDR			(0X23)
+#define SMI130_USER_FIFO_DATA_ADDR				(0X24)
+/***************************************************/
+/**\name ACCEL CONFIG REGISTERS  FOR ODR, BANDWIDTH AND UNDERSAMPLING*/
+/******************************************************/
+#define SMI130_USER_ACCEL_CONFIG_ADDR			(0X40)
+/*******************/
+/**\name ACCEL RANGE */
+/*******************/
+#define SMI130_USER_ACCEL_RANGE_ADDR            (0X41)
+/***************************************************/
+/**\name GYRO CONFIG REGISTERS  FOR ODR AND BANDWIDTH */
+/******************************************************/
+#define SMI130_USER_GYRO_CONFIG_ADDR            (0X42)
+/*******************/
+/**\name GYRO RANGE */
+/*******************/
+#define SMI130_USER_GYRO_RANGE_ADDR             (0X43)
+/***************************************************/
+/**\name MAG CONFIG REGISTERS  FOR ODR*/
+/******************************************************/
+#define SMI130_USER_MAG_CONFIG_ADDR				(0X44)
+/***************************************************/
+/**\name REGISTER FOR GYRO AND ACCEL DOWNSAMPLING RATES FOR FIFO*/
+/******************************************************/
+#define SMI130_USER_FIFO_DOWN_ADDR              (0X45)
+/***************************************************/
+/**\name FIFO CONFIG REGISTERS*/
+/******************************************************/
+#define SMI130_USER_FIFO_CONFIG_0_ADDR          (0X46)
+#define SMI130_USER_FIFO_CONFIG_1_ADDR          (0X47)
+/***************************************************/
+/**\name MAG INTERFACE REGISTERS*/
+/******************************************************/
+#define SMI130_USER_MAG_IF_0_ADDR				(0X4B)
+#define SMI130_USER_MAG_IF_1_ADDR				(0X4C)
+#define SMI130_USER_MAG_IF_2_ADDR				(0X4D)
+#define SMI130_USER_MAG_IF_3_ADDR				(0X4E)
+#define SMI130_USER_MAG_IF_4_ADDR				(0X4F)
+/***************************************************/
+/**\name INTERRUPT ENABLE REGISTERS*/
+/******************************************************/
+#define SMI130_USER_INTR_ENABLE_0_ADDR			(0X50)
+#define SMI130_USER_INTR_ENABLE_1_ADDR			(0X51)
+#define SMI130_USER_INTR_ENABLE_2_ADDR			(0X52)
+#define SMI130_USER_INTR_OUT_CTRL_ADDR			(0X53)
+/***************************************************/
+/**\name LATCH DURATION REGISTERS*/
+/******************************************************/
+#define SMI130_USER_INTR_LATCH_ADDR				(0X54)
+/***************************************************/
+/**\name MAP INTERRUPT 1 and 2 REGISTERS*/
+/******************************************************/
+#define SMI130_USER_INTR_MAP_0_ADDR				(0X55)
+#define SMI130_USER_INTR_MAP_1_ADDR				(0X56)
+#define SMI130_USER_INTR_MAP_2_ADDR				(0X57)
+/***************************************************/
+/**\name DATA SOURCE REGISTERS*/
+/******************************************************/
+#define SMI130_USER_INTR_DATA_0_ADDR			(0X58)
+#define SMI130_USER_INTR_DATA_1_ADDR			(0X59)
+/***************************************************/
+/**\name
+INTERRUPT THRESHOLD, HYSTERESIS, DURATION, MODE CONFIGURATION REGISTERS*/
+/******************************************************/
+#define SMI130_USER_INTR_LOWHIGH_0_ADDR			(0X5A)
+#define SMI130_USER_INTR_LOWHIGH_1_ADDR			(0X5B)
+#define SMI130_USER_INTR_LOWHIGH_2_ADDR			(0X5C)
+#define SMI130_USER_INTR_LOWHIGH_3_ADDR			(0X5D)
+#define SMI130_USER_INTR_LOWHIGH_4_ADDR			(0X5E)
+#define SMI130_USER_INTR_MOTION_0_ADDR			(0X5F)
+#define SMI130_USER_INTR_MOTION_1_ADDR			(0X60)
+#define SMI130_USER_INTR_MOTION_2_ADDR			(0X61)
+#define SMI130_USER_INTR_MOTION_3_ADDR			(0X62)
+#define SMI130_USER_INTR_TAP_0_ADDR				(0X63)
+#define SMI130_USER_INTR_TAP_1_ADDR				(0X64)
+#define SMI130_USER_INTR_ORIENT_0_ADDR			(0X65)
+#define SMI130_USER_INTR_ORIENT_1_ADDR			(0X66)
+#define SMI130_USER_INTR_FLAT_0_ADDR			(0X67)
+#define SMI130_USER_INTR_FLAT_1_ADDR			(0X68)
+/***************************************************/
+/**\name FAST OFFSET CONFIGURATION REGISTER*/
+/******************************************************/
+#define SMI130_USER_FOC_CONFIG_ADDR				(0X69)
+/***************************************************/
+/**\name MISCELLANEOUS CONFIGURATION REGISTER*/
+/******************************************************/
+#define SMI130_USER_CONFIG_ADDR					(0X6A)
+/***************************************************/
+/**\name SERIAL INTERFACE SETTINGS REGISTER*/
+/******************************************************/
+#define SMI130_USER_IF_CONFIG_ADDR				(0X6B)
+/***************************************************/
+/**\name GYRO POWER MODE TRIGGER REGISTER */
+/******************************************************/
+#define SMI130_USER_PMU_TRIGGER_ADDR			(0X6C)
+/***************************************************/
+/**\name SELF_TEST REGISTER*/
+/******************************************************/
+#define SMI130_USER_SELF_TEST_ADDR				(0X6D)
+/***************************************************/
+/**\name SPI,I2C SELECTION REGISTER*/
+/******************************************************/
+#define SMI130_USER_NV_CONFIG_ADDR				(0x70)
+/***************************************************/
+/**\name ACCEL AND GYRO OFFSET REGISTERS*/
+/******************************************************/
+#define SMI130_USER_OFFSET_0_ADDR				(0X71)
+#define SMI130_USER_OFFSET_1_ADDR				(0X72)
+#define SMI130_USER_OFFSET_2_ADDR				(0X73)
+#define SMI130_USER_OFFSET_3_ADDR				(0X74)
+#define SMI130_USER_OFFSET_4_ADDR				(0X75)
+#define SMI130_USER_OFFSET_5_ADDR				(0X76)
+#define SMI130_USER_OFFSET_6_ADDR				(0X77)
+/***************************************************/
+/**\name STEP COUNTER INTERRUPT REGISTERS*/
+/******************************************************/
+#define SMI130_USER_STEP_COUNT_0_ADDR			(0X78)
+#define SMI130_USER_STEP_COUNT_1_ADDR			(0X79)
+/***************************************************/
+/**\name STEP COUNTER CONFIGURATION REGISTERS*/
+/******************************************************/
+#define SMI130_USER_STEP_CONFIG_0_ADDR			(0X7A)
+#define SMI130_USER_STEP_CONFIG_1_ADDR			(0X7B)
+/***************************************************/
+/**\name COMMAND REGISTER*/
+/******************************************************/
+#define SMI130_CMD_COMMANDS_ADDR				(0X7E)
+/***************************************************/
+/**\name PAGE REGISTERS*/
+/******************************************************/
+#define SMI130_CMD_EXT_MODE_ADDR				(0X7F)
+#define SMI130_COM_C_TRIM_FIVE_ADDR				(0X05)
+
+/****************************************************/
+/**\name	SHIFT VALUE DEFINITION       */
+/***************************************************/
+#define SMI130_SHIFT_BIT_POSITION_BY_01_BIT      (1)
+#define SMI130_SHIFT_BIT_POSITION_BY_02_BITS     (2)
+#define SMI130_SHIFT_BIT_POSITION_BY_03_BITS     (3)
+#define SMI130_SHIFT_BIT_POSITION_BY_04_BITS     (4)
+#define SMI130_SHIFT_BIT_POSITION_BY_05_BITS     (5)
+#define SMI130_SHIFT_BIT_POSITION_BY_06_BITS     (6)
+#define SMI130_SHIFT_BIT_POSITION_BY_07_BITS     (7)
+#define SMI130_SHIFT_BIT_POSITION_BY_08_BITS     (8)
+#define SMI130_SHIFT_BIT_POSITION_BY_09_BITS     (9)
+#define SMI130_SHIFT_BIT_POSITION_BY_12_BITS     (12)
+#define SMI130_SHIFT_BIT_POSITION_BY_13_BITS     (13)
+#define SMI130_SHIFT_BIT_POSITION_BY_14_BITS     (14)
+#define SMI130_SHIFT_BIT_POSITION_BY_15_BITS     (15)
+#define SMI130_SHIFT_BIT_POSITION_BY_16_BITS     (16)
+
+/****************************************************/
+/**\name	 DEFINITIONS USED FOR YAMAHA-YAS532 */
+/***************************************************/
+#define YAS532_MAG_STATE_NORMAL				(0)
+#define YAS532_MAG_STATE_INIT_COIL			(1)
+#define YAS532_MAG_STATE_MEASURE_OFFSET		(2)
+#define YAS532_MAG_INITCOIL_TIMEOUT			(1000)
+#define YAS532_MAG_NOTRANS_POSITION			(3)
+#define YAS532_DEFAULT_SENSOR_DELAY			(50)
+#define YAS532_DATA_OVERFLOW				(8190)
+#define YAS532_DATA_UNDERFLOW				(0)
+#define YAS532_MAG_LOG				(20)
+#define YAS532_MAG_TEMPERATURE_LOG			(10)
+#define YAS532_TEMP20DEGREE_TYPICAL			(390)
+#define YAS532_VERSION_AC_COEF_X			(850)
+#define YAS532_VERSION_AC_COEF_Y1			(750)
+#define YAS532_VERSION_AC_COEF_Y2			(750)
+#define YAS532_DATA_CENTER					(4096)
+/****************************************************/
+/**\name	YAMAHA-YAS532 OFFSET DEFINITION */
+/***************************************************/
+static const s8 INVALID_OFFSET[] = {0x7f, 0x7f, 0x7f};
+#define set_vector(to, from) \
+	{int _l; for (_l = 0; _l < 3; _l++) (to)[_l] = (from)[_l]; }
+#define is_valid_offset(a) \
+	(((a)[0] <= 31) && ((a)[1] <= 31) && ((a)[2] <= 31) \
+		&& (-31 <= (a)[0]) && (-31 <= (a)[1]) && (-31 <= (a)[2]))
+
+/**************************************************/
+/**\name	YAS532 CALIB DATA DEFINITIONS  */
+/*************************************************/
+
+
+/* register address of YAS532*/
+#define SMI130_YAS532_TESTR1			(0x88)
+#define SMI130_YAS532_TESTR2			(0x89)
+#define SMI130_YAS532_RCOIL				(0x81)
+#define SMI130_YAS532_COMMAND_REGISTER	(0x82)
+#define SMI130_YAS532_DATA_REGISTER		(0xB0)
+/* calib data register definition*/
+#define SMI130_YAS532_CALIB_CX	        (0x90)
+#define SMI130_YAS532_CALIB_CY1	        (0x91)
+#define SMI130_YAS532_CALIB_CY2	        (0x92)
+#define SMI130_YAS532_CALIB1	        (0x93)
+#define SMI130_YAS532_CALIB2	        (0x94)
+#define SMI130_YAS532_CALIB3	        (0x95)
+#define SMI130_YAS532_CALIB4	        (0x96)
+#define SMI130_YAS532_CALIB5	        (0x97)
+#define SMI130_YAS532_CLAIB6	        (0x98)
+#define SMI130_YAS532_CALIB7	        (0x99)
+#define SMI130_YAS532_CALIB8	        (0x9A)
+#define SMI130_YAS532_CALIIB9	        (0x9B)
+#define SMI130_YAS532_CALIB10	        (0x9C)
+#define SMI130_YAS532_CALIB11	        (0x9D)
+/* offset definition */
+#define SMI130_YAS532_OFFSET_X	        (0x85)
+#define SMI130_YAS532_OFFSET_Y	        (0x86)
+#define SMI130_YAS532_OFFSET_Z	        (0x87)
+/* data to write register for yas532*/
+#define SMI130_YAS532_WRITE_TESTR1	    (0x00)
+#define SMI130_YAS532_WRITE_TESTR2	    (0x00)
+#define SMI130_YAS532_WRITE_RCOIL       (0x00)
+/**************************************************/
+/**\name	YAS537 DEFINITION  */
+/*************************************************/
+
+#define	YAS537_SRSTR_DATA		        (0x02)
+#define	YAS537_WRITE_A_D_CONVERTER		(0x03)
+#define	YAS537_WRITE_A_D_CONVERTER2		(0xF8)
+#define	YAS537_WRITE_FILTER             (0x08)
+#define	YAS537_WRITE_CONFR              (0x08)
+#define	YAS537_WRITE_TEMP_CALIB         (0xFF)
+#define	YAS537_SET_COMMAND_REGISTER     (0x01)
+
+/**************************************************/
+/**\name	YAS537 REGISTER DEFINITION  */
+/*************************************************/
+#define	YAS537_REG_SRSTR				(0x90)
+#define	YAS537_REG_CALR_C0				(0xC0)
+#define	YAS537_REG_CALR_C1				(0xC1)
+#define	YAS537_REG_CALR_C2				(0xC2)
+#define	YAS537_REG_CALR_C3				(0xC3)
+#define	YAS537_REG_CALR_C4				(0xC4)
+#define	YAS537_REG_CALR_C5				(0xC5)
+#define	YAS537_REG_CALR_C6				(0xC6)
+#define	YAS537_REG_CALR_C7				(0xC7)
+#define	YAS537_REG_CALR_C8				(0xC8)
+#define	YAS537_REG_CALR_C9				(0xC9)
+#define	YAS537_REG_CALR_CA				(0xCA)
+#define	YAS537_REG_CALR_CB				(0xCB)
+#define	YAS537_REG_CALR_CC				(0xCC)
+#define	YAS537_REG_CALR_CD				(0xCD)
+#define	YAS537_REG_CALR_CE				(0xCE)
+#define	YAS537_REG_CALR_CF				(0xCF)
+#define	YAS537_REG_CALR_DO				(0xD0)
+#define	YAS537_REG_MTCR					(0x93)
+#define	YAS537_REG_CONFR				(0x82)
+#define	SMI130_REG_YAS537_CMDR			(0x81)
+#define	YAS537_REG_OXR					(0x84)
+#define	YAS537_REG_AVRR					(0x87)
+#define	YAS537_REG_HCKR					(0x88)
+#define	YAS537_REG_LCKR					(0x89)
+#define	YAS537_REG_ADCCALR				(0x91)
+#define	YAS537_REG_ADCCALR_ONE			(0x92)
+#define	YAS537_REG_OCR					(0x9E)
+#define	YAS537_REG_TRMR			        (0x9F)
+#define	YAS537_REG_TEMPERATURE_0		(0xB0)
+#define	YAS537_REG_TEMPERATURE_1		(0xB1)
+#define	YAS537_REG_DATA_X_0				(0xB2)
+#define	YAS537_REG_DATA_X_1				(0xB3)
+#define	YAS537_REG_DATA_Y1_0			(0xB4)
+#define	YAS537_REG_DATA_Y1_1			(0xB5)
+#define	YAS537_REG_DATA_Y2_0			(0xB6)
+#define	YAS537_REG_DATA_Y2_1			(0xB7)
+#define YAS537_MAG_STATE_NORMAL			(0)
+#define YAS537_MAG_STATE_INIT_COIL		(1)
+#define YAS537_MAG_STATE_RECORD_DATA	(2)
+#define YAS537_DATA_UNDERFLOW			(0)
+#define YAS537_DATA_OVERFLOW			(16383)
+/****************************************************/
+/**\name	YAS537_set vector */
+/***************************************************/
+#define yas537_set_vector(to, from) \
+	{int _l; for (_l = 0; _l < 3; _l++) (to)[_l] = (from)[_l]; }
+
+#ifndef ABS
+#define ABS(a)		((a) > 0 ? (a) : -(a)) /*!< Absolute value */
+#endif
+/****************************************************/
+/**\name	AKM09911 AND AKM09912 DEFINITION */
+/***************************************************/
+#define AKM09912_SENSITIVITY_DIV	(256)
+#define AKM09912_SENSITIVITY		(128)
+#define AKM09911_SENSITIVITY_DIV	(128)
+#define AKM_ASAX	(0)
+#define AKM_ASAY	(1)
+#define AKM_ASAZ	(2)
+#define AKM_POWER_DOWN_MODE_DATA		(0x00)
+#define AKM_FUSE_ROM_MODE				(0x1F)
+#define AKM_POWER_MODE_REG				(0x31)
+#define	AKM_SINGLE_MEASUREMENT_MODE		(0x01)
+#define AKM_DATA_REGISTER				(0x11)
+/*! AKM09912 Register definition */
+#define AKM09912_CHIP_ID_REG			(0x01)
+/****************************************************/
+/**\name	BMM150 DEFINITION */
+/***************************************************/
+#define SMI130_BMM150_SET_POWER_CONTROL	(0x01)
+#define SMI130_BMM150_MAX_RETRY_WAKEUP	(5)
+#define SMI130_BMM150_POWER_ON			(0x01)
+#define SMI130_BMM150_POWER_OFF			(0x00)
+#define SMI130_BMM150_FORCE_MODE		(0x02)
+#define SMI130_BMM150_POWER_ON_SUCCESS	(0)
+#define SMI130_BMM150_POWER_ON_FAIL		((s8)-1)
+
+#define	SMI130_BMM150_DIG_X1			(0)
+#define	SMI130_BMM150_DIG_Y1			(1)
+#define	SMI130_BMM150_DIG_X2			(2)
+#define	SMI130_BMM150_DIG_Y3			(3)
+#define	SMI130_BMM150_DIG_XY1			(4)
+#define	SMI130_BMM150_DIG_XY2			(5)
+#define	SMI130_BMM150_DIG_Z1_LSB		(6)
+#define	SMI130_BMM150_DIG_Z1_MSB		(7)
+#define	SMI130_BMM150_DIG_Z2_LSB		(8)
+#define	SMI130_BMM150_DIG_Z2_MSB		(9)
+#define	SMI130_BMM150_DIG_DIG_Z3_LSB	(10)
+#define	SMI130_BMM150_DIG_DIG_Z3_MSB	(11)
+#define	SMI130_BMM150_DIG_DIG_Z4_LSB	(12)
+#define	SMI130_BMM150_DIG_DIG_Z4_MSB	(13)
+#define	SMI130_BMM150_DIG_DIG_XYZ1_LSB	(14)
+#define	SMI130_BMM150_DIG_DIG_XYZ1_MSB	(15)
+
+/**************************************************************/
+/**\name	STRUCTURE DEFINITIONS                         */
+/**************************************************************/
+/*!
+*	@brief smi130 structure
+*	This structure holds all relevant information about smi130
+*/
+struct smi130_t {
+u8 chip_id;/**< chip id of SMI130 */
+u8 dev_addr;/**< device address of SMI130 */
+s8 mag_manual_enable;/**< used for check the mag manual/auto mode status */
+SMI130_WR_FUNC_PTR;/**< bus write function pointer */
+SMI130_RD_FUNC_PTR;/**< bus read function pointer */
+SMI130_BRD_FUNC_PTR;/**< burst write function pointer */
+void (*delay_msec)(SMI130_MDELAY_DATA_TYPE);/**< delay function pointer */
+};
+/*!
+ * @brief Structure containing bmm150 and akm09911
+ *	magnetometer values for x,y and
+ *	z-axis in s16
+ */
+struct smi130_mag_t {
+s16 x;/**< BMM150 and AKM09911 and AKM09912 X raw data*/
+s16 y;/**< BMM150 and AKM09911 and AKM09912 Y raw data*/
+s16 z;/**< BMM150 and AKM09911 and AKM09912 Z raw data*/
+};
+/*!
+ * @brief Structure containing bmm150 xyz data and temperature
+ */
+struct smi130_mag_xyzr_t {
+s16 x;/**< BMM150 X raw data*/
+s16 y;/**< BMM150 Y raw data*/
+s16 z;/**<BMM150 Z raw data*/
+u16 r;/**<BMM150 R raw data*/
+};
+/*!
+ * @brief Structure containing gyro xyz data
+ */
+struct smi130_gyro_t {
+s16 x;/**<gyro X  data*/
+s16 y;/**<gyro Y  data*/
+s16 z;/**<gyro Z  data*/
+};
+/*!
+ * @brief Structure containing accel xyz data
+ */
+struct smi130_accel_t {
+s16 x;/**<accel X  data*/
+s16 y;/**<accel Y  data*/
+s16 z;/**<accel Z  data*/
+};
+/*!
+ * @brief Structure bmm150 mag compensated data with s32 output
+ */
+struct smi130_mag_xyz_s32_t {
+s16 x;/**<BMM150 X compensated data*/
+s16 y;/**<BMM150 Y compensated data*/
+s16 z;/**<BMM150 Z compensated data*/
+};
+/*!
+ * @brief Structure bmm150 mag trim data
+ */
+struct trim_data_t {
+s8 dig_x1;/**<BMM150 trim x1 data*/
+s8 dig_y1;/**<BMM150 trim y1 data*/
+
+s8 dig_x2;/**<BMM150 trim x2 data*/
+s8 dig_y2;/**<BMM150 trim y2 data*/
+
+u16 dig_z1;/**<BMM150 trim z1 data*/
+s16 dig_z2;/**<BMM150 trim z2 data*/
+s16 dig_z3;/**<BMM150 trim z3 data*/
+s16 dig_z4;/**<BMM150 trim z4 data*/
+
+u8 dig_xy1;/**<BMM150 trim xy1 data*/
+s8 dig_xy2;/**<BMM150 trim xy2 data*/
+
+u16 dig_xyz1;/**<BMM150 trim xyz1 data*/
+};
+
+/*!
+*	@brief Structure for reading AKM compensating data
+*/
+struct bosch_akm_sensitivity_data_t {
+u8 asax;/**<AKM09911 and AKM09912 X sensitivity data*/
+u8 asay;/**<AKM09911 and AKM09912 Y sensitivity data*/
+u8 asaz;/**<AKM09911 and AKM09912 Z sensitivity data*/
+};
+/*!
+* @brief YAMAHA-YAS532 struct
+* Calibration YAS532 data struct
+*/
+struct bosch_yas532_calib_data_t {
+s32 cx;/**<YAS532 calib cx data */
+s32 cy1;/**<YAS532 calib cy1 data */
+s32 cy2;/**<YAS532 calib cy2 data */
+s32 a2;/**<YAS532 calib a2 data */
+s32 a3;/**<YAS532 calib a3 data */
+s32 a4;/**<YAS532 calib a4 data */
+s32 a5;/**<YAS532 calib a5 data */
+s32 a6;/**<YAS532 calib a6 data */
+s32 a7;/**<YAS532 calib a7 data */
+s32 a8;/**<YAS532 calib a8 data */
+s32 a9;/**<YAS532 calib a9 data */
+s32 k;/**<YAS532 calib k data */
+s8 rxy1y2[3];/**<YAS532 calib rxy1y2 data */
+u8 fxy1y2[3];/**<YAS532 calib fxy1y2 data */
+};
+/*!
+* @brief YAS532 Temperature structure
+*/
+#if YAS532_MAG_LOG < YAS532_MAG_TEMPERATURE_LOG
+struct yas_temp_filter_t {
+u16 log[YAS532_MAG_TEMPERATURE_LOG];/**<YAS532 temp log array */
+u8 num;/**< used for increment the index */
+u8 idx;/**< used for increment the index */
+};
+#endif
+/*!
+* @brief YAS532 sensor initialization
+*/
+struct yas532_t {
+struct bosch_yas532_calib_data_t calib_yas532;/**< calib data */
+s8 measure_state;/**< update measure state */
+s8 v_hard_offset_s8[3];/**< offset write array*/
+s32 coef[3];/**< co efficient data */
+s8 overflow;/**< over flow condition check */
+u8 dev_id;/**< device id information */
+const s8 *transform;/**< transform condition check  */
+#if YAS532_MAG_LOG < YAS532_MAG_TEMPERATURE_LOG
+struct yas_temp_filter_t temp_data;/**< temp data */
+#endif
+u16 last_raw[4];/**< raw data */
+};
+/*!
+* @brief Used for reading the YAS532 XYZ data
+*/
+struct yas532_vector {
+s32 yas532_vector_xyz[3];/**< YAS532 compensated xyz data*/
+};
+/**
+ * @struct yas_vector
+ * @brief Stores the sensor data
+ */
+struct yas_vector {
+	s32 yas537_vector_xyz[3]; /*!< vector data */
+};
+/*!
+* @brief YAMAHA-YAS532 struct
+* Calibration YAS532 data struct
+*/
+struct bosch_yas537_calib_data_t {
+s8 a2;/**<YAS532 calib a2 data */
+s8 a3;/**<YAS532 calib a3 data */
+s8 a4;/**<YAS532 calib a4 data */
+s16 a5;/**<YAS532 calib a5 data */
+s8 a6;/**<YAS532 calib a6 data */
+s8 a7;/**<YAS532 calib a7 data */
+s8 a8;/**<YAS532 calib a8 data */
+s16 a9;/**<YAS532 calib a9 data */
+u8 k;/**<YAS532 calib k data */
+u8 ver;/**<YAS532 calib ver data*/
+};
+/*!
+* @brief YAS537 sensor initialization
+*/
+struct yas537_t {
+struct bosch_yas537_calib_data_t calib_yas537;/**< calib data */
+s8 measure_state;/**< update measure state */
+s8 hard_offset[3];/**< offset write array*/
+u16 last_after_rcoil[3];/**< rcoil write array*/
+s32 coef[3];/**< co efficient data */
+s8 overflow;/**< over flow condition check */
+u8 dev_id;/**< device id information */
+u8 average;/**<average selection for offset configuration*/
+const s8 *transform;/**< transform condition check  */
+u16 last_raw[4];/**< raw data */
+struct yas_vector xyz; /*!< X, Y, Z measurement data of the sensor */
+};
+/**************************************************************/
+/**\name	USER DATA REGISTERS DEFINITION START    */
+/**************************************************************/
+
+/**************************************************************/
+/**\name	CHIP ID LENGTH, POSITION AND MASK    */
+/**************************************************************/
+/* Chip ID Description - Reg Addr --> (0x00), Bit --> 0...7 */
+#define SMI130_USER_CHIP_ID__POS             (0)
+#define SMI130_USER_CHIP_ID__MSK            (0xFF)
+#define SMI130_USER_CHIP_ID__LEN             (8)
+#define SMI130_USER_CHIP_ID__REG             (SMI130_USER_CHIP_ID_ADDR)
+/**************************************************************/
+/**\name	ERROR STATUS LENGTH, POSITION AND MASK    */
+/**************************************************************/
+/* Error Description - Reg Addr --> (0x02), Bit --> 0 */
+#define SMI130_USER_ERR_STAT__POS               (0)
+#define SMI130_USER_ERR_STAT__LEN               (8)
+#define SMI130_USER_ERR_STAT__MSK               (0xFF)
+#define SMI130_USER_ERR_STAT__REG               (SMI130_USER_ERROR_ADDR)
+
+#define SMI130_USER_FATAL_ERR__POS               (0)
+#define SMI130_USER_FATAL_ERR__LEN               (1)
+#define SMI130_USER_FATAL_ERR__MSK               (0x01)
+#define SMI130_USER_FATAL_ERR__REG               (SMI130_USER_ERROR_ADDR)
+
+/* Error Description - Reg Addr --> (0x02), Bit --> 1...4 */
+#define SMI130_USER_ERR_CODE__POS               (1)
+#define SMI130_USER_ERR_CODE__LEN               (4)
+#define SMI130_USER_ERR_CODE__MSK               (0x1E)
+#define SMI130_USER_ERR_CODE__REG               (SMI130_USER_ERROR_ADDR)
+
+/* Error Description - Reg Addr --> (0x02), Bit --> 5 */
+#define SMI130_USER_I2C_FAIL_ERR__POS               (5)
+#define SMI130_USER_I2C_FAIL_ERR__LEN               (1)
+#define SMI130_USER_I2C_FAIL_ERR__MSK               (0x20)
+#define SMI130_USER_I2C_FAIL_ERR__REG               (SMI130_USER_ERROR_ADDR)
+
+/* Error Description - Reg Addr --> (0x02), Bit --> 6 */
+#define SMI130_USER_DROP_CMD_ERR__POS              (6)
+#define SMI130_USER_DROP_CMD_ERR__LEN              (1)
+#define SMI130_USER_DROP_CMD_ERR__MSK              (0x40)
+#define SMI130_USER_DROP_CMD_ERR__REG              (SMI130_USER_ERROR_ADDR)
+/**************************************************************/
+/**\name	MAG DATA READY LENGTH, POSITION AND MASK    */
+/**************************************************************/
+/* Error Description - Reg Addr --> (0x02), Bit --> 7 */
+#define SMI130_USER_MAG_DADA_RDY_ERR__POS               (7)
+#define SMI130_USER_MAG_DADA_RDY_ERR__LEN               (1)
+#define SMI130_USER_MAG_DADA_RDY_ERR__MSK               (0x80)
+#define SMI130_USER_MAG_DADA_RDY_ERR__REG               (SMI130_USER_ERROR_ADDR)
+/**************************************************************/
+/**\name	MAG POWER MODE LENGTH, POSITION AND MASK    */
+/**************************************************************/
+/* PMU_Status Description of MAG - Reg Addr --> (0x03), Bit --> 1..0 */
+#define SMI130_USER_MAG_POWER_MODE_STAT__POS		(0)
+#define SMI130_USER_MAG_POWER_MODE_STAT__LEN		(2)
+#define SMI130_USER_MAG_POWER_MODE_STAT__MSK		(0x03)
+#define SMI130_USER_MAG_POWER_MODE_STAT__REG		\
+(SMI130_USER_PMU_STAT_ADDR)
+/**************************************************************/
+/**\name	GYRO POWER MODE LENGTH, POSITION AND MASK    */
+/**************************************************************/
+/* PMU_Status Description of GYRO - Reg Addr --> (0x03), Bit --> 3...2 */
+#define SMI130_USER_GYRO_POWER_MODE_STAT__POS               (2)
+#define SMI130_USER_GYRO_POWER_MODE_STAT__LEN               (2)
+#define SMI130_USER_GYRO_POWER_MODE_STAT__MSK               (0x0C)
+#define SMI130_USER_GYRO_POWER_MODE_STAT__REG		      \
+(SMI130_USER_PMU_STAT_ADDR)
+/**************************************************************/
+/**\name	ACCEL POWER MODE LENGTH, POSITION AND MASK    */
+/**************************************************************/
+/* PMU_Status Description of ACCEL - Reg Addr --> (0x03), Bit --> 5...4 */
+#define SMI130_USER_ACCEL_POWER_MODE_STAT__POS               (4)
+#define SMI130_USER_ACCEL_POWER_MODE_STAT__LEN               (2)
+#define SMI130_USER_ACCEL_POWER_MODE_STAT__MSK               (0x30)
+#define SMI130_USER_ACCEL_POWER_MODE_STAT__REG		    \
+(SMI130_USER_PMU_STAT_ADDR)
+/**************************************************************/
+/**\name	MAG DATA XYZ LENGTH, POSITION AND MASK    */
+/**************************************************************/
+/* Mag_X(LSB) Description - Reg Addr --> (0x04), Bit --> 0...7 */
+#define SMI130_USER_DATA_0_MAG_X_LSB__POS           (0)
+#define SMI130_USER_DATA_0_MAG_X_LSB__LEN           (8)
+#define SMI130_USER_DATA_0_MAG_X_LSB__MSK          (0xFF)
+#define SMI130_USER_DATA_0_MAG_X_LSB__REG          (SMI130_USER_DATA_0_ADDR)
+
+/* Mag_X(LSB) Description - Reg Addr --> (0x04), Bit --> 3...7 */
+#define SMI130_USER_DATA_MAG_X_LSB__POS           (3)
+#define SMI130_USER_DATA_MAG_X_LSB__LEN           (5)
+#define SMI130_USER_DATA_MAG_X_LSB__MSK          (0xF8)
+#define SMI130_USER_DATA_MAG_X_LSB__REG          (SMI130_USER_DATA_0_ADDR)
+
+/* Mag_X(MSB) Description - Reg Addr --> (0x05), Bit --> 0...7 */
+#define SMI130_USER_DATA_1_MAG_X_MSB__POS           (0)
+#define SMI130_USER_DATA_1_MAG_X_MSB__LEN           (8)
+#define SMI130_USER_DATA_1_MAG_X_MSB__MSK          (0xFF)
+#define SMI130_USER_DATA_1_MAG_X_MSB__REG          (SMI130_USER_DATA_1_ADDR)
+
+/* Mag_Y(LSB) Description - Reg Addr --> (0x06), Bit --> 0...7 */
+#define SMI130_USER_DATA_2_MAG_Y_LSB__POS           (0)
+#define SMI130_USER_DATA_2_MAG_Y_LSB__LEN           (8)
+#define SMI130_USER_DATA_2_MAG_Y_LSB__MSK          (0xFF)
+#define SMI130_USER_DATA_2_MAG_Y_LSB__REG          (SMI130_USER_DATA_2_ADDR)
+
+/* Mag_Y(LSB) Description - Reg Addr --> (0x06), Bit --> 3...7 */
+#define SMI130_USER_DATA_MAG_Y_LSB__POS           (3)
+#define SMI130_USER_DATA_MAG_Y_LSB__LEN           (5)
+#define SMI130_USER_DATA_MAG_Y_LSB__MSK          (0xF8)
+#define SMI130_USER_DATA_MAG_Y_LSB__REG          (SMI130_USER_DATA_2_ADDR)
+
+/* Mag_Y(MSB) Description - Reg Addr --> (0x07), Bit --> 0...7 */
+#define SMI130_USER_DATA_3_MAG_Y_MSB__POS           (0)
+#define SMI130_USER_DATA_3_MAG_Y_MSB__LEN           (8)
+#define SMI130_USER_DATA_3_MAG_Y_MSB__MSK          (0xFF)
+#define SMI130_USER_DATA_3_MAG_Y_MSB__REG          (SMI130_USER_DATA_3_ADDR)
+
+/* Mag_Z(LSB) Description - Reg Addr --> (0x08), Bit --> 0...7 */
+#define SMI130_USER_DATA_4_MAG_Z_LSB__POS           (0)
+#define SMI130_USER_DATA_4_MAG_Z_LSB__LEN           (8)
+#define SMI130_USER_DATA_4_MAG_Z_LSB__MSK          (0xFF)
+#define SMI130_USER_DATA_4_MAG_Z_LSB__REG          (SMI130_USER_DATA_4_ADDR)
+
+/* Mag_X(LSB) Description - Reg Addr --> (0x08), Bit --> 3...7 */
+#define SMI130_USER_DATA_MAG_Z_LSB__POS           (1)
+#define SMI130_USER_DATA_MAG_Z_LSB__LEN           (7)
+#define SMI130_USER_DATA_MAG_Z_LSB__MSK          (0xFE)
+#define SMI130_USER_DATA_MAG_Z_LSB__REG          (SMI130_USER_DATA_4_ADDR)
+
+/* Mag_Z(MSB) Description - Reg Addr --> (0x09), Bit --> 0...7 */
+#define SMI130_USER_DATA_5_MAG_Z_MSB__POS           (0)
+#define SMI130_USER_DATA_5_MAG_Z_MSB__LEN           (8)
+#define SMI130_USER_DATA_5_MAG_Z_MSB__MSK          (0xFF)
+#define SMI130_USER_DATA_5_MAG_Z_MSB__REG          (SMI130_USER_DATA_5_ADDR)
+
+/* RHALL(LSB) Description - Reg Addr --> (0x0A), Bit --> 0...7 */
+#define SMI130_USER_DATA_6_RHALL_LSB__POS           (0)
+#define SMI130_USER_DATA_6_RHALL_LSB__LEN           (8)
+#define SMI130_USER_DATA_6_RHALL_LSB__MSK          (0xFF)
+#define SMI130_USER_DATA_6_RHALL_LSB__REG          (SMI130_USER_DATA_6_ADDR)
+
+/* Mag_R(LSB) Description - Reg Addr --> (0x0A), Bit --> 3...7 */
+#define SMI130_USER_DATA_MAG_R_LSB__POS           (2)
+#define SMI130_USER_DATA_MAG_R_LSB__LEN           (6)
+#define SMI130_USER_DATA_MAG_R_LSB__MSK          (0xFC)
+#define SMI130_USER_DATA_MAG_R_LSB__REG          (SMI130_USER_DATA_6_ADDR)
+
+/* RHALL(MSB) Description - Reg Addr --> (0x0B), Bit --> 0...7 */
+#define SMI130_USER_DATA_7_RHALL_MSB__POS           (0)
+#define SMI130_USER_DATA_7_RHALL_MSB__LEN           (8)
+#define SMI130_USER_DATA_7_RHALL_MSB__MSK          (0xFF)
+#define SMI130_USER_DATA_7_RHALL_MSB__REG          (SMI130_USER_DATA_7_ADDR)
+/**************************************************************/
+/**\name	GYRO DATA XYZ LENGTH, POSITION AND MASK    */
+/**************************************************************/
+/* GYR_X (LSB) Description - Reg Addr --> (0x0C), Bit --> 0...7 */
+#define SMI130_USER_DATA_8_GYRO_X_LSB__POS           (0)
+#define SMI130_USER_DATA_8_GYRO_X_LSB__LEN           (8)
+#define SMI130_USER_DATA_8_GYRO_X_LSB__MSK          (0xFF)
+#define SMI130_USER_DATA_8_GYRO_X_LSB__REG          (SMI130_USER_DATA_8_ADDR)
+
+/* GYR_X (MSB) Description - Reg Addr --> (0x0D), Bit --> 0...7 */
+#define SMI130_USER_DATA_9_GYRO_X_MSB__POS           (0)
+#define SMI130_USER_DATA_9_GYRO_X_MSB__LEN           (8)
+#define SMI130_USER_DATA_9_GYRO_X_MSB__MSK          (0xFF)
+#define SMI130_USER_DATA_9_GYRO_X_MSB__REG          (SMI130_USER_DATA_9_ADDR)
+
+/* GYR_Y (LSB) Description - Reg Addr --> 0x0E, Bit --> 0...7 */
+#define SMI130_USER_DATA_10_GYRO_Y_LSB__POS           (0)
+#define SMI130_USER_DATA_10_GYRO_Y_LSB__LEN           (8)
+#define SMI130_USER_DATA_10_GYRO_Y_LSB__MSK          (0xFF)
+#define SMI130_USER_DATA_10_GYRO_Y_LSB__REG          (SMI130_USER_DATA_10_ADDR)
+
+/* GYR_Y (MSB) Description - Reg Addr --> (0x0F), Bit --> 0...7 */
+#define SMI130_USER_DATA_11_GYRO_Y_MSB__POS           (0)
+#define SMI130_USER_DATA_11_GYRO_Y_MSB__LEN           (8)
+#define SMI130_USER_DATA_11_GYRO_Y_MSB__MSK          (0xFF)
+#define SMI130_USER_DATA_11_GYRO_Y_MSB__REG          (SMI130_USER_DATA_11_ADDR)
+
+/* GYR_Z (LSB) Description - Reg Addr --> (0x10), Bit --> 0...7 */
+#define SMI130_USER_DATA_12_GYRO_Z_LSB__POS           (0)
+#define SMI130_USER_DATA_12_GYRO_Z_LSB__LEN           (8)
+#define SMI130_USER_DATA_12_GYRO_Z_LSB__MSK          (0xFF)
+#define SMI130_USER_DATA_12_GYRO_Z_LSB__REG          (SMI130_USER_DATA_12_ADDR)
+
+/* GYR_Z (MSB) Description - Reg Addr --> (0x11), Bit --> 0...7 */
+#define SMI130_USER_DATA_13_GYRO_Z_MSB__POS           (0)
+#define SMI130_USER_DATA_13_GYRO_Z_MSB__LEN           (8)
+#define SMI130_USER_DATA_13_GYRO_Z_MSB__MSK          (0xFF)
+#define SMI130_USER_DATA_13_GYRO_Z_MSB__REG          (SMI130_USER_DATA_13_ADDR)
+/**************************************************************/
+/**\name	ACCEL DATA XYZ LENGTH, POSITION AND MASK    */
+/**************************************************************/
+/* ACC_X (LSB) Description - Reg Addr --> (0x12), Bit --> 0...7 */
+#define SMI130_USER_DATA_14_ACCEL_X_LSB__POS           (0)
+#define SMI130_USER_DATA_14_ACCEL_X_LSB__LEN           (8)
+#define SMI130_USER_DATA_14_ACCEL_X_LSB__MSK          (0xFF)
+#define SMI130_USER_DATA_14_ACCEL_X_LSB__REG          (SMI130_USER_DATA_14_ADDR)
+
+/* ACC_X (MSB) Description - Reg Addr --> 0x13, Bit --> 0...7 */
+#define SMI130_USER_DATA_15_ACCEL_X_MSB__POS           (0)
+#define SMI130_USER_DATA_15_ACCEL_X_MSB__LEN           (8)
+#define SMI130_USER_DATA_15_ACCEL_X_MSB__MSK          (0xFF)
+#define SMI130_USER_DATA_15_ACCEL_X_MSB__REG          (SMI130_USER_DATA_15_ADDR)
+
+/* ACC_Y (LSB) Description - Reg Addr --> (0x14), Bit --> 0...7 */
+#define SMI130_USER_DATA_16_ACCEL_Y_LSB__POS           (0)
+#define SMI130_USER_DATA_16_ACCEL_Y_LSB__LEN           (8)
+#define SMI130_USER_DATA_16_ACCEL_Y_LSB__MSK          (0xFF)
+#define SMI130_USER_DATA_16_ACCEL_Y_LSB__REG          (SMI130_USER_DATA_16_ADDR)
+
+/* ACC_Y (MSB) Description - Reg Addr --> (0x15), Bit --> 0...7 */
+#define SMI130_USER_DATA_17_ACCEL_Y_MSB__POS           (0)
+#define SMI130_USER_DATA_17_ACCEL_Y_MSB__LEN           (8)
+#define SMI130_USER_DATA_17_ACCEL_Y_MSB__MSK          (0xFF)
+#define SMI130_USER_DATA_17_ACCEL_Y_MSB__REG          (SMI130_USER_DATA_17_ADDR)
+
+/* ACC_Z (LSB) Description - Reg Addr --> 0x16, Bit --> 0...7 */
+#define SMI130_USER_DATA_18_ACCEL_Z_LSB__POS           (0)
+#define SMI130_USER_DATA_18_ACCEL_Z_LSB__LEN           (8)
+#define SMI130_USER_DATA_18_ACCEL_Z_LSB__MSK          (0xFF)
+#define SMI130_USER_DATA_18_ACCEL_Z_LSB__REG          (SMI130_USER_DATA_18_ADDR)
+
+/* ACC_Z (MSB) Description - Reg Addr --> (0x17), Bit --> 0...7 */
+#define SMI130_USER_DATA_19_ACCEL_Z_MSB__POS           (0)
+#define SMI130_USER_DATA_19_ACCEL_Z_MSB__LEN           (8)
+#define SMI130_USER_DATA_19_ACCEL_Z_MSB__MSK          (0xFF)
+#define SMI130_USER_DATA_19_ACCEL_Z_MSB__REG          (SMI130_USER_DATA_19_ADDR)
+/**************************************************************/
+/**\name	SENSOR TIME LENGTH, POSITION AND MASK    */
+/**************************************************************/
+/* SENSORTIME_0 (LSB) Description - Reg Addr --> (0x18), Bit --> 0...7 */
+#define SMI130_USER_SENSORTIME_0_SENSOR_TIME_LSB__POS           (0)
+#define SMI130_USER_SENSORTIME_0_SENSOR_TIME_LSB__LEN           (8)
+#define SMI130_USER_SENSORTIME_0_SENSOR_TIME_LSB__MSK          (0xFF)
+#define SMI130_USER_SENSORTIME_0_SENSOR_TIME_LSB__REG          \
+		(SMI130_USER_SENSORTIME_0_ADDR)
+
+/* SENSORTIME_1 (MSB) Description - Reg Addr --> (0x19), Bit --> 0...7 */
+#define SMI130_USER_SENSORTIME_1_SENSOR_TIME_MSB__POS           (0)
+#define SMI130_USER_SENSORTIME_1_SENSOR_TIME_MSB__LEN           (8)
+#define SMI130_USER_SENSORTIME_1_SENSOR_TIME_MSB__MSK          (0xFF)
+#define SMI130_USER_SENSORTIME_1_SENSOR_TIME_MSB__REG          \
+		(SMI130_USER_SENSORTIME_1_ADDR)
+
+/* SENSORTIME_2 (MSB) Description - Reg Addr --> (0x1A), Bit --> 0...7 */
+#define SMI130_USER_SENSORTIME_2_SENSOR_TIME_MSB__POS           (0)
+#define SMI130_USER_SENSORTIME_2_SENSOR_TIME_MSB__LEN           (8)
+#define SMI130_USER_SENSORTIME_2_SENSOR_TIME_MSB__MSK          (0xFF)
+#define SMI130_USER_SENSORTIME_2_SENSOR_TIME_MSB__REG          \
+		(SMI130_USER_SENSORTIME_2_ADDR)
+/**************************************************************/
+/**\name	GYRO SELF TEST LENGTH, POSITION AND MASK    */
+/**************************************************************/
+/* Status Description - Reg Addr --> 0x1B, Bit --> 1 */
+#define SMI130_USER_STAT_GYRO_SELFTEST_OK__POS          (1)
+#define SMI130_USER_STAT_GYRO_SELFTEST_OK__LEN          (1)
+#define SMI130_USER_STAT_GYRO_SELFTEST_OK__MSK          (0x02)
+#define SMI130_USER_STAT_GYRO_SELFTEST_OK__REG         \
+		(SMI130_USER_STAT_ADDR)
+/**************************************************************/
+/**\name	MAG MANUAL OPERATION LENGTH, POSITION AND MASK    */
+/**************************************************************/
+/* Status Description - Reg Addr --> 0x1B, Bit --> 2 */
+#define SMI130_USER_STAT_MAG_MANUAL_OPERATION__POS          (2)
+#define SMI130_USER_STAT_MAG_MANUAL_OPERATION__LEN          (1)
+#define SMI130_USER_STAT_MAG_MANUAL_OPERATION__MSK          (0x04)
+#define SMI130_USER_STAT_MAG_MANUAL_OPERATION__REG          \
+		(SMI130_USER_STAT_ADDR)
+/**************************************************************/
+/**\name	FOC STATUS LENGTH, POSITION AND MASK    */
+/**************************************************************/
+/* Status Description - Reg Addr --> 0x1B, Bit --> 3 */
+#define SMI130_USER_STAT_FOC_RDY__POS          (3)
+#define SMI130_USER_STAT_FOC_RDY__LEN          (1)
+#define SMI130_USER_STAT_FOC_RDY__MSK          (0x08)
+#define SMI130_USER_STAT_FOC_RDY__REG          (SMI130_USER_STAT_ADDR)
+/**************************************************************/
+/**\name	NVM READY LENGTH, POSITION AND MASK    */
+/**************************************************************/
+/* Status Description - Reg Addr --> 0x1B, Bit --> 4 */
+#define SMI130_USER_STAT_NVM_RDY__POS           (4)
+#define SMI130_USER_STAT_NVM_RDY__LEN           (1)
+#define SMI130_USER_STAT_NVM_RDY__MSK           (0x10)
+#define SMI130_USER_STAT_NVM_RDY__REG           (SMI130_USER_STAT_ADDR)
+/**************************************************************/
+/**\name	DATA READY LENGTH, POSITION AND MASK FOR ACCEL, MAG AND GYRO*/
+/**************************************************************/
+/* Status Description - Reg Addr --> 0x1B, Bit --> 5 */
+#define SMI130_USER_STAT_DATA_RDY_MAG__POS           (5)
+#define SMI130_USER_STAT_DATA_RDY_MAG__LEN           (1)
+#define SMI130_USER_STAT_DATA_RDY_MAG__MSK           (0x20)
+#define SMI130_USER_STAT_DATA_RDY_MAG__REG           (SMI130_USER_STAT_ADDR)
+
+/* Status Description - Reg Addr --> 0x1B, Bit --> 6 */
+#define SMI130_USER_STAT_DATA_RDY_GYRO__POS           (6)
+#define SMI130_USER_STAT_DATA_RDY_GYRO__LEN           (1)
+#define SMI130_USER_STAT_DATA_RDY_GYRO__MSK           (0x40)
+#define SMI130_USER_STAT_DATA_RDY_GYRO__REG           (SMI130_USER_STAT_ADDR)
+
+/* Status Description - Reg Addr --> 0x1B, Bit --> 7 */
+#define SMI130_USER_STAT_DATA_RDY_ACCEL__POS           (7)
+#define SMI130_USER_STAT_DATA_RDY_ACCEL__LEN           (1)
+#define SMI130_USER_STAT_DATA_RDY_ACCEL__MSK           (0x80)
+#define SMI130_USER_STAT_DATA_RDY_ACCEL__REG           (SMI130_USER_STAT_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT STATUS LENGTH, POSITION AND MASK    */
+/**************************************************************/
+/* Int_Status_0 Description - Reg Addr --> 0x1C, Bit --> 0 */
+#define SMI130_USER_INTR_STAT_0_STEP_INTR__POS           (0)
+#define SMI130_USER_INTR_STAT_0_STEP_INTR__LEN           (1)
+#define SMI130_USER_INTR_STAT_0_STEP_INTR__MSK          (0x01)
+#define SMI130_USER_INTR_STAT_0_STEP_INTR__REG          \
+		(SMI130_USER_INTR_STAT_0_ADDR)
+/**************************************************************/
+/**\name	SIGNIFICANT INTERRUPT STATUS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_0 Description - Reg Addr --> 0x1C, Bit --> 1 */
+#define SMI130_USER_INTR_STAT_0_SIGNIFICANT_INTR__POS		(1)
+#define SMI130_USER_INTR_STAT_0_SIGNIFICANT_INTR__LEN		(1)
+#define SMI130_USER_INTR_STAT_0_SIGNIFICANT_INTR__MSK		(0x02)
+#define SMI130_USER_INTR_STAT_0_SIGNIFICANT_INTR__REG       \
+		(SMI130_USER_INTR_STAT_0_ADDR)
+/**************************************************************/
+/**\name	ANY_MOTION INTERRUPT STATUS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_0 Description - Reg Addr --> 0x1C, Bit --> 2 */
+#define SMI130_USER_INTR_STAT_0_ANY_MOTION__POS           (2)
+#define SMI130_USER_INTR_STAT_0_ANY_MOTION__LEN           (1)
+#define SMI130_USER_INTR_STAT_0_ANY_MOTION__MSK          (0x04)
+#define SMI130_USER_INTR_STAT_0_ANY_MOTION__REG          \
+		(SMI130_USER_INTR_STAT_0_ADDR)
+/**************************************************************/
+/**\name	PMU TRIGGER INTERRUPT STATUS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_0 Description - Reg Addr --> 0x1C, Bit --> 3 */
+#define SMI130_USER_INTR_STAT_0_PMU_TRIGGER__POS           3
+#define SMI130_USER_INTR_STAT_0_PMU_TRIGGER__LEN           (1)
+#define SMI130_USER_INTR_STAT_0_PMU_TRIGGER__MSK          (0x08)
+#define SMI130_USER_INTR_STAT_0_PMU_TRIGGER__REG          \
+		(SMI130_USER_INTR_STAT_0_ADDR)
+/**************************************************************/
+/**\name	DOUBLE TAP INTERRUPT STATUS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_0 Description - Reg Addr --> 0x1C, Bit --> 4 */
+#define SMI130_USER_INTR_STAT_0_DOUBLE_TAP_INTR__POS           4
+#define SMI130_USER_INTR_STAT_0_DOUBLE_TAP_INTR__LEN           (1)
+#define SMI130_USER_INTR_STAT_0_DOUBLE_TAP_INTR__MSK          (0x10)
+#define SMI130_USER_INTR_STAT_0_DOUBLE_TAP_INTR__REG          \
+		(SMI130_USER_INTR_STAT_0_ADDR)
+/**************************************************************/
+/**\name	SINGLE TAP INTERRUPT STATUS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_0 Description - Reg Addr --> 0x1C, Bit --> 5 */
+#define SMI130_USER_INTR_STAT_0_SINGLE_TAP_INTR__POS           5
+#define SMI130_USER_INTR_STAT_0_SINGLE_TAP_INTR__LEN           (1)
+#define SMI130_USER_INTR_STAT_0_SINGLE_TAP_INTR__MSK          (0x20)
+#define SMI130_USER_INTR_STAT_0_SINGLE_TAP_INTR__REG          \
+		(SMI130_USER_INTR_STAT_0_ADDR)
+/**************************************************************/
+/**\name	ORIENT INTERRUPT STATUS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_0 Description - Reg Addr --> 0x1C, Bit --> 6 */
+#define SMI130_USER_INTR_STAT_0_ORIENT__POS           (6)
+#define SMI130_USER_INTR_STAT_0_ORIENT__LEN           (1)
+#define SMI130_USER_INTR_STAT_0_ORIENT__MSK          (0x40)
+#define SMI130_USER_INTR_STAT_0_ORIENT__REG          \
+		(SMI130_USER_INTR_STAT_0_ADDR)
+/**************************************************************/
+/**\name	FLAT INTERRUPT STATUS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_0 Description - Reg Addr --> 0x1C, Bit --> 7 */
+#define SMI130_USER_INTR_STAT_0_FLAT__POS           (7)
+#define SMI130_USER_INTR_STAT_0_FLAT__LEN           (1)
+#define SMI130_USER_INTR_STAT_0_FLAT__MSK          (0x80)
+#define SMI130_USER_INTR_STAT_0_FLAT__REG          \
+		(SMI130_USER_INTR_STAT_0_ADDR)
+/**************************************************************/
+/**\name	HIGH_G INTERRUPT STATUS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_1 Description - Reg Addr --> 0x1D, Bit --> 2 */
+#define SMI130_USER_INTR_STAT_1_HIGH_G_INTR__POS               (2)
+#define SMI130_USER_INTR_STAT_1_HIGH_G_INTR__LEN               (1)
+#define SMI130_USER_INTR_STAT_1_HIGH_G_INTR__MSK              (0x04)
+#define SMI130_USER_INTR_STAT_1_HIGH_G_INTR__REG              \
+		(SMI130_USER_INTR_STAT_1_ADDR)
+/**************************************************************/
+/**\name	LOW_G INTERRUPT STATUS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_1 Description - Reg Addr --> 0x1D, Bit --> 3 */
+#define SMI130_USER_INTR_STAT_1_LOW_G_INTR__POS               (3)
+#define SMI130_USER_INTR_STAT_1_LOW_G_INTR__LEN               (1)
+#define SMI130_USER_INTR_STAT_1_LOW_G_INTR__MSK              (0x08)
+#define SMI130_USER_INTR_STAT_1_LOW_G_INTR__REG              \
+		(SMI130_USER_INTR_STAT_1_ADDR)
+/**************************************************************/
+/**\name	DATA READY INTERRUPT STATUS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_1 Description - Reg Addr --> 0x1D, Bit --> 4 */
+#define SMI130_USER_INTR_STAT_1_DATA_RDY_INTR__POS               (4)
+#define SMI130_USER_INTR_STAT_1_DATA_RDY_INTR__LEN               (1)
+#define SMI130_USER_INTR_STAT_1_DATA_RDY_INTR__MSK               (0x10)
+#define SMI130_USER_INTR_STAT_1_DATA_RDY_INTR__REG               \
+		(SMI130_USER_INTR_STAT_1_ADDR)
+/**************************************************************/
+/**\name	FIFO FULL INTERRUPT STATUS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_1 Description - Reg Addr --> 0x1D, Bit --> 5 */
+#define SMI130_USER_INTR_STAT_1_FIFO_FULL_INTR__POS               (5)
+#define SMI130_USER_INTR_STAT_1_FIFO_FULL_INTR__LEN               (1)
+#define SMI130_USER_INTR_STAT_1_FIFO_FULL_INTR__MSK               (0x20)
+#define SMI130_USER_INTR_STAT_1_FIFO_FULL_INTR__REG               \
+		(SMI130_USER_INTR_STAT_1_ADDR)
+/**************************************************************/
+/**\name FIFO WATERMARK INTERRUPT STATUS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_1 Description - Reg Addr --> 0x1D, Bit --> 6 */
+#define SMI130_USER_INTR_STAT_1_FIFO_WM_INTR__POS               (6)
+#define SMI130_USER_INTR_STAT_1_FIFO_WM_INTR__LEN               (1)
+#define SMI130_USER_INTR_STAT_1_FIFO_WM_INTR__MSK               (0x40)
+#define SMI130_USER_INTR_STAT_1_FIFO_WM_INTR__REG               \
+		(SMI130_USER_INTR_STAT_1_ADDR)
+/**************************************************************/
+/**\name	NO MOTION INTERRUPT STATUS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_1 Description - Reg Addr --> 0x1D, Bit --> 7 */
+#define SMI130_USER_INTR_STAT_1_NOMOTION_INTR__POS               (7)
+#define SMI130_USER_INTR_STAT_1_NOMOTION_INTR__LEN               (1)
+#define SMI130_USER_INTR_STAT_1_NOMOTION_INTR__MSK               (0x80)
+#define SMI130_USER_INTR_STAT_1_NOMOTION_INTR__REG               \
+		(SMI130_USER_INTR_STAT_1_ADDR)
+/**************************************************************/
+/**\name	ANY MOTION-XYZ AXIS INTERRUPT STATUS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 0 */
+#define SMI130_USER_INTR_STAT_2_ANY_MOTION_FIRST_X__POS               (0)
+#define SMI130_USER_INTR_STAT_2_ANY_MOTION_FIRST_X__LEN               (1)
+#define SMI130_USER_INTR_STAT_2_ANY_MOTION_FIRST_X__MSK               (0x01)
+#define SMI130_USER_INTR_STAT_2_ANY_MOTION_FIRST_X__REG               \
+		(SMI130_USER_INTR_STAT_2_ADDR)
+
+/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 1 */
+#define SMI130_USER_INTR_STAT_2_ANY_MOTION_FIRST_Y__POS               (1)
+#define SMI130_USER_INTR_STAT_2_ANY_MOTION_FIRST_Y__LEN               (1)
+#define SMI130_USER_INTR_STAT_2_ANY_MOTION_FIRST_Y__MSK               (0x02)
+#define SMI130_USER_INTR_STAT_2_ANY_MOTION_FIRST_Y__REG               \
+		(SMI130_USER_INTR_STAT_2_ADDR)
+
+/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 2 */
+#define SMI130_USER_INTR_STAT_2_ANY_MOTION_FIRST_Z__POS               (2)
+#define SMI130_USER_INTR_STAT_2_ANY_MOTION_FIRST_Z__LEN               (1)
+#define SMI130_USER_INTR_STAT_2_ANY_MOTION_FIRST_Z__MSK               (0x04)
+#define SMI130_USER_INTR_STAT_2_ANY_MOTION_FIRST_Z__REG               \
+		(SMI130_USER_INTR_STAT_2_ADDR)
+/**************************************************************/
+/**\name	ANY MOTION SIGN LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 3 */
+#define SMI130_USER_INTR_STAT_2_ANY_MOTION_SIGN__POS               (3)
+#define SMI130_USER_INTR_STAT_2_ANY_MOTION_SIGN__LEN               (1)
+#define SMI130_USER_INTR_STAT_2_ANY_MOTION_SIGN__MSK               (0x08)
+#define SMI130_USER_INTR_STAT_2_ANY_MOTION_SIGN__REG               \
+		(SMI130_USER_INTR_STAT_2_ADDR)
+/**************************************************************/
+/**\name	TAP_XYZ AND SIGN LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 4 */
+#define SMI130_USER_INTR_STAT_2_TAP_FIRST_X__POS               (4)
+#define SMI130_USER_INTR_STAT_2_TAP_FIRST_X__LEN               (1)
+#define SMI130_USER_INTR_STAT_2_TAP_FIRST_X__MSK               (0x10)
+#define SMI130_USER_INTR_STAT_2_TAP_FIRST_X__REG               \
+		(SMI130_USER_INTR_STAT_2_ADDR)
+
+/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 5 */
+#define SMI130_USER_INTR_STAT_2_TAP_FIRST_Y__POS               (5)
+#define SMI130_USER_INTR_STAT_2_TAP_FIRST_Y__LEN               (1)
+#define SMI130_USER_INTR_STAT_2_TAP_FIRST_Y__MSK               (0x20)
+#define SMI130_USER_INTR_STAT_2_TAP_FIRST_Y__REG               \
+		(SMI130_USER_INTR_STAT_2_ADDR)
+
+/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 6 */
+#define SMI130_USER_INTR_STAT_2_TAP_FIRST_Z__POS               (6)
+#define SMI130_USER_INTR_STAT_2_TAP_FIRST_Z__LEN               (1)
+#define SMI130_USER_INTR_STAT_2_TAP_FIRST_Z__MSK               (0x40)
+#define SMI130_USER_INTR_STAT_2_TAP_FIRST_Z__REG               \
+		(SMI130_USER_INTR_STAT_2_ADDR)
+
+/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 7 */
+#define SMI130_USER_INTR_STAT_2_TAP_SIGN__POS               (7)
+#define SMI130_USER_INTR_STAT_2_TAP_SIGN__LEN               (1)
+#define SMI130_USER_INTR_STAT_2_TAP_SIGN__MSK               (0x80)
+#define SMI130_USER_INTR_STAT_2_TAP_SIGN__REG               \
+		(SMI130_USER_INTR_STAT_2_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT SATAUS FOR WHOLE 0x1E LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 0...7 */
+#define SMI130_USER_INTR_STAT_2__POS               (0)
+#define SMI130_USER_INTR_STAT_2__LEN               (8)
+#define SMI130_USER_INTR_STAT_2__MSK               (0xFF)
+#define SMI130_USER_INTR_STAT_2__REG               \
+		(SMI130_USER_INTR_STAT_2_ADDR)
+/**************************************************************/
+/**\name	HIGH_G-XYZ AND SIGN LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_3 Description - Reg Addr --> (0x1F), Bit --> 0 */
+#define SMI130_USER_INTR_STAT_3_HIGH_G_FIRST_X__POS               (0)
+#define SMI130_USER_INTR_STAT_3_HIGH_G_FIRST_X__LEN               (1)
+#define SMI130_USER_INTR_STAT_3_HIGH_G_FIRST_X__MSK               (0x01)
+#define SMI130_USER_INTR_STAT_3_HIGH_G_FIRST_X__REG               \
+		(SMI130_USER_INTR_STAT_3_ADDR)
+
+/* Int_Status_3 Description - Reg Addr --> 0x1E, Bit --> 1 */
+#define SMI130_USER_INTR_STAT_3_HIGH_G_FIRST_Y__POS               (1)
+#define SMI130_USER_INTR_STAT_3_HIGH_G_FIRST_Y__LEN               (1)
+#define SMI130_USER_INTR_STAT_3_HIGH_G_FIRST_Y__MSK               (0x02)
+#define SMI130_USER_INTR_STAT_3_HIGH_G_FIRST_Y__REG               \
+		(SMI130_USER_INTR_STAT_3_ADDR)
+
+/* Int_Status_3 Description - Reg Addr --> (0x1F), Bit --> 2 */
+#define SMI130_USER_INTR_STAT_3_HIGH_G_FIRST_Z__POS               (2)
+#define SMI130_USER_INTR_STAT_3_HIGH_G_FIRST_Z__LEN               (1)
+#define SMI130_USER_INTR_STAT_3_HIGH_G_FIRST_Z__MSK               (0x04)
+#define SMI130_USER_INTR_STAT_3_HIGH_G_FIRST_Z__REG               \
+		(SMI130_USER_INTR_STAT_3_ADDR)
+
+/* Int_Status_3 Description - Reg Addr --> (0x1F), Bit --> 3 */
+#define SMI130_USER_INTR_STAT_3_HIGH_G_SIGN__POS               (3)
+#define SMI130_USER_INTR_STAT_3_HIGH_G_SIGN__LEN               (1)
+#define SMI130_USER_INTR_STAT_3_HIGH_G_SIGN__MSK               (0x08)
+#define SMI130_USER_INTR_STAT_3_HIGH_G_SIGN__REG               \
+		(SMI130_USER_INTR_STAT_3_ADDR)
+/**************************************************************/
+/**\name	ORIENT XY and Z AXIS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_3 Description - Reg Addr --> (0x1F), Bit --> 4...5 */
+#define SMI130_USER_INTR_STAT_3_ORIENT_XY__POS               (4)
+#define SMI130_USER_INTR_STAT_3_ORIENT_XY__LEN               (2)
+#define SMI130_USER_INTR_STAT_3_ORIENT_XY__MSK               (0x30)
+#define SMI130_USER_INTR_STAT_3_ORIENT_XY__REG               \
+		(SMI130_USER_INTR_STAT_3_ADDR)
+
+/* Int_Status_3 Description - Reg Addr --> (0x1F), Bit --> 6 */
+#define SMI130_USER_INTR_STAT_3_ORIENT_Z__POS               (6)
+#define SMI130_USER_INTR_STAT_3_ORIENT_Z__LEN               (1)
+#define SMI130_USER_INTR_STAT_3_ORIENT_Z__MSK               (0x40)
+#define SMI130_USER_INTR_STAT_3_ORIENT_Z__REG               \
+		(SMI130_USER_INTR_STAT_3_ADDR)
+/**************************************************************/
+/**\name	FLAT LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_3 Description - Reg Addr --> (0x1F), Bit --> 7 */
+#define SMI130_USER_INTR_STAT_3_FLAT__POS               (7)
+#define SMI130_USER_INTR_STAT_3_FLAT__LEN               (1)
+#define SMI130_USER_INTR_STAT_3_FLAT__MSK               (0x80)
+#define SMI130_USER_INTR_STAT_3_FLAT__REG               \
+		(SMI130_USER_INTR_STAT_3_ADDR)
+/**************************************************************/
+/**\name	(0x1F) LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Status_3 Description - Reg Addr --> (0x1F), Bit --> 0...7 */
+#define SMI130_USER_INTR_STAT_3__POS               (0)
+#define SMI130_USER_INTR_STAT_3__LEN               (8)
+#define SMI130_USER_INTR_STAT_3__MSK               (0xFF)
+#define SMI130_USER_INTR_STAT_3__REG               \
+		(SMI130_USER_INTR_STAT_3_ADDR)
+/**************************************************************/
+/**\name	TEMPERATURE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Temperature Description - LSB Reg Addr --> (0x20), Bit --> 0...7 */
+#define SMI130_USER_TEMP_LSB_VALUE__POS               (0)
+#define SMI130_USER_TEMP_LSB_VALUE__LEN               (8)
+#define SMI130_USER_TEMP_LSB_VALUE__MSK               (0xFF)
+#define SMI130_USER_TEMP_LSB_VALUE__REG               \
+		(SMI130_USER_TEMPERATURE_0_ADDR)
+
+/* Temperature Description - LSB Reg Addr --> 0x21, Bit --> 0...7 */
+#define SMI130_USER_TEMP_MSB_VALUE__POS               (0)
+#define SMI130_USER_TEMP_MSB_VALUE__LEN               (8)
+#define SMI130_USER_TEMP_MSB_VALUE__MSK               (0xFF)
+#define SMI130_USER_TEMP_MSB_VALUE__REG               \
+		(SMI130_USER_TEMPERATURE_1_ADDR)
+/**************************************************************/
+/**\name	FIFO BYTE COUNTER LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Fifo_Length0 Description - Reg Addr --> 0x22, Bit --> 0...7 */
+#define SMI130_USER_FIFO_BYTE_COUNTER_LSB__POS           (0)
+#define SMI130_USER_FIFO_BYTE_COUNTER_LSB__LEN           (8)
+#define SMI130_USER_FIFO_BYTE_COUNTER_LSB__MSK          (0xFF)
+#define SMI130_USER_FIFO_BYTE_COUNTER_LSB__REG          \
+		(SMI130_USER_FIFO_LENGTH_0_ADDR)
+
+/*Fifo_Length1 Description - Reg Addr --> 0x23, Bit --> 0...2 */
+#define SMI130_USER_FIFO_BYTE_COUNTER_MSB__POS           (0)
+#define SMI130_USER_FIFO_BYTE_COUNTER_MSB__LEN           3
+#define SMI130_USER_FIFO_BYTE_COUNTER_MSB__MSK          (0x07)
+#define SMI130_USER_FIFO_BYTE_COUNTER_MSB__REG          \
+		(SMI130_USER_FIFO_LENGTH_1_ADDR)
+
+/**************************************************************/
+/**\name	FIFO DATA LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Fifo_Data Description - Reg Addr --> 0x24, Bit --> 0...7 */
+#define SMI130_USER_FIFO_DATA__POS           (0)
+#define SMI130_USER_FIFO_DATA__LEN           (8)
+#define SMI130_USER_FIFO_DATA__MSK          (0xFF)
+#define SMI130_USER_FIFO_DATA__REG          (SMI130_USER_FIFO_DATA_ADDR)
+
+/**************************************************************/
+/**\name	ACCEL CONFIGURATION LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Acc_Conf Description - Reg Addr --> (0x40), Bit --> 0...3 */
+#define SMI130_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE__POS               (0)
+#define SMI130_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE__LEN               (4)
+#define SMI130_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE__MSK               (0x0F)
+#define SMI130_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE__REG		       \
+(SMI130_USER_ACCEL_CONFIG_ADDR)
+
+/* Acc_Conf Description - Reg Addr --> (0x40), Bit --> 4...6 */
+#define SMI130_USER_ACCEL_CONFIG_ACCEL_BW__POS               (4)
+#define SMI130_USER_ACCEL_CONFIG_ACCEL_BW__LEN               (3)
+#define SMI130_USER_ACCEL_CONFIG_ACCEL_BW__MSK               (0x70)
+#define SMI130_USER_ACCEL_CONFIG_ACCEL_BW__REG	(SMI130_USER_ACCEL_CONFIG_ADDR)
+
+/* Acc_Conf Description - Reg Addr --> (0x40), Bit --> 7 */
+#define SMI130_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING__POS           (7)
+#define SMI130_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING__LEN           (1)
+#define SMI130_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING__MSK           (0x80)
+#define SMI130_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING__REG	\
+(SMI130_USER_ACCEL_CONFIG_ADDR)
+
+/* Acc_Range Description - Reg Addr --> 0x41, Bit --> 0...3 */
+#define SMI130_USER_ACCEL_RANGE__POS               (0)
+#define SMI130_USER_ACCEL_RANGE__LEN               (4)
+#define SMI130_USER_ACCEL_RANGE__MSK               (0x0F)
+#define SMI130_USER_ACCEL_RANGE__REG              \
+(SMI130_USER_ACCEL_RANGE_ADDR)
+/**************************************************************/
+/**\name	GYRO CONFIGURATION LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Gyro_Conf Description - Reg Addr --> (0x42), Bit --> 0...3 */
+#define SMI130_USER_GYRO_CONFIG_OUTPUT_DATA_RATE__POS               (0)
+#define SMI130_USER_GYRO_CONFIG_OUTPUT_DATA_RATE__LEN               (4)
+#define SMI130_USER_GYRO_CONFIG_OUTPUT_DATA_RATE__MSK               (0x0F)
+#define SMI130_USER_GYRO_CONFIG_OUTPUT_DATA_RATE__REG               \
+(SMI130_USER_GYRO_CONFIG_ADDR)
+
+/* Gyro_Conf Description - Reg Addr --> (0x42), Bit --> 4...5 */
+#define SMI130_USER_GYRO_CONFIG_BW__POS               (4)
+#define SMI130_USER_GYRO_CONFIG_BW__LEN               (2)
+#define SMI130_USER_GYRO_CONFIG_BW__MSK               (0x30)
+#define SMI130_USER_GYRO_CONFIG_BW__REG               \
+(SMI130_USER_GYRO_CONFIG_ADDR)
+
+/* Gyr_Range Description - Reg Addr --> 0x43, Bit --> 0...2 */
+#define SMI130_USER_GYRO_RANGE__POS               (0)
+#define SMI130_USER_GYRO_RANGE__LEN               (3)
+#define SMI130_USER_GYRO_RANGE__MSK               (0x07)
+#define SMI130_USER_GYRO_RANGE__REG               (SMI130_USER_GYRO_RANGE_ADDR)
+/**************************************************************/
+/**\name	MAG CONFIGURATION LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Mag_Conf Description - Reg Addr --> (0x44), Bit --> 0...3 */
+#define SMI130_USER_MAG_CONFIG_OUTPUT_DATA_RATE__POS               (0)
+#define SMI130_USER_MAG_CONFIG_OUTPUT_DATA_RATE__LEN               (4)
+#define SMI130_USER_MAG_CONFIG_OUTPUT_DATA_RATE__MSK               (0x0F)
+#define SMI130_USER_MAG_CONFIG_OUTPUT_DATA_RATE__REG               \
+(SMI130_USER_MAG_CONFIG_ADDR)
+/**************************************************************/
+/**\name	FIFO DOWNS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Fifo_Downs Description - Reg Addr --> 0x45, Bit --> 0...2 */
+#define SMI130_USER_FIFO_DOWN_GYRO__POS               (0)
+#define SMI130_USER_FIFO_DOWN_GYRO__LEN               (3)
+#define SMI130_USER_FIFO_DOWN_GYRO__MSK               (0x07)
+#define SMI130_USER_FIFO_DOWN_GYRO__REG	(SMI130_USER_FIFO_DOWN_ADDR)
+/**************************************************************/
+/**\name	FIFO FILTER FOR ACCEL AND GYRO LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Fifo_filt Description - Reg Addr --> 0x45, Bit --> 3 */
+#define SMI130_USER_FIFO_FILTER_GYRO__POS               (3)
+#define SMI130_USER_FIFO_FILTER_GYRO__LEN               (1)
+#define SMI130_USER_FIFO_FILTER_GYRO__MSK               (0x08)
+#define SMI130_USER_FIFO_FILTER_GYRO__REG	  (SMI130_USER_FIFO_DOWN_ADDR)
+
+/* Fifo_Downs Description - Reg Addr --> 0x45, Bit --> 4...6 */
+#define SMI130_USER_FIFO_DOWN_ACCEL__POS               (4)
+#define SMI130_USER_FIFO_DOWN_ACCEL__LEN               (3)
+#define SMI130_USER_FIFO_DOWN_ACCEL__MSK               (0x70)
+#define SMI130_USER_FIFO_DOWN_ACCEL__REG	(SMI130_USER_FIFO_DOWN_ADDR)
+
+/* Fifo_FILT Description - Reg Addr --> 0x45, Bit --> 7 */
+#define SMI130_USER_FIFO_FILTER_ACCEL__POS               (7)
+#define SMI130_USER_FIFO_FILTER_ACCEL__LEN               (1)
+#define SMI130_USER_FIFO_FILTER_ACCEL__MSK               (0x80)
+#define SMI130_USER_FIFO_FILTER_ACCEL__REG	(SMI130_USER_FIFO_DOWN_ADDR)
+/**************************************************************/
+/**\name	FIFO WATER MARK LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Fifo_Config_0 Description - Reg Addr --> 0x46, Bit --> 0...7 */
+#define SMI130_USER_FIFO_WM__POS               (0)
+#define SMI130_USER_FIFO_WM__LEN               (8)
+#define SMI130_USER_FIFO_WM__MSK               (0xFF)
+#define SMI130_USER_FIFO_WM__REG	(SMI130_USER_FIFO_CONFIG_0_ADDR)
+/**************************************************************/
+/**\name	FIFO TIME LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Fifo_Config_1 Description - Reg Addr --> 0x47, Bit --> 1 */
+#define SMI130_USER_FIFO_TIME_ENABLE__POS               (1)
+#define SMI130_USER_FIFO_TIME_ENABLE__LEN               (1)
+#define SMI130_USER_FIFO_TIME_ENABLE__MSK               (0x02)
+#define SMI130_USER_FIFO_TIME_ENABLE__REG	(SMI130_USER_FIFO_CONFIG_1_ADDR)
+/**************************************************************/
+/**\name	FIFO TAG INTERRUPT LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Fifo_Config_1 Description - Reg Addr --> 0x47, Bit --> 2 */
+#define SMI130_USER_FIFO_TAG_INTR2_ENABLE__POS               (2)
+#define SMI130_USER_FIFO_TAG_INTR2_ENABLE__LEN               (1)
+#define SMI130_USER_FIFO_TAG_INTR2_ENABLE__MSK               (0x04)
+#define SMI130_USER_FIFO_TAG_INTR2_ENABLE__REG	(SMI130_USER_FIFO_CONFIG_1_ADDR)
+
+/* Fifo_Config_1 Description - Reg Addr --> 0x47, Bit --> 3 */
+#define SMI130_USER_FIFO_TAG_INTR1_ENABLE__POS               (3)
+#define SMI130_USER_FIFO_TAG_INTR1_ENABLE__LEN               (1)
+#define SMI130_USER_FIFO_TAG_INTR1_ENABLE__MSK               (0x08)
+#define SMI130_USER_FIFO_TAG_INTR1_ENABLE__REG	(SMI130_USER_FIFO_CONFIG_1_ADDR)
+/**************************************************************/
+/**\name	FIFO HEADER LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Fifo_Config_1 Description - Reg Addr --> 0x47, Bit --> 4 */
+#define SMI130_USER_FIFO_HEADER_ENABLE__POS               (4)
+#define SMI130_USER_FIFO_HEADER_ENABLE__LEN               (1)
+#define SMI130_USER_FIFO_HEADER_ENABLE__MSK               (0x10)
+#define SMI130_USER_FIFO_HEADER_ENABLE__REG		         \
+(SMI130_USER_FIFO_CONFIG_1_ADDR)
+/**************************************************************/
+/**\name	FIFO MAG ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Fifo_Config_1 Description - Reg Addr --> 0x47, Bit --> 5 */
+#define SMI130_USER_FIFO_MAG_ENABLE__POS               (5)
+#define SMI130_USER_FIFO_MAG_ENABLE__LEN               (1)
+#define SMI130_USER_FIFO_MAG_ENABLE__MSK               (0x20)
+#define SMI130_USER_FIFO_MAG_ENABLE__REG		     \
+(SMI130_USER_FIFO_CONFIG_1_ADDR)
+/**************************************************************/
+/**\name	FIFO ACCEL ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Fifo_Config_1 Description - Reg Addr --> 0x47, Bit --> 6 */
+#define SMI130_USER_FIFO_ACCEL_ENABLE__POS               (6)
+#define SMI130_USER_FIFO_ACCEL_ENABLE__LEN               (1)
+#define SMI130_USER_FIFO_ACCEL_ENABLE__MSK               (0x40)
+#define SMI130_USER_FIFO_ACCEL_ENABLE__REG		        \
+(SMI130_USER_FIFO_CONFIG_1_ADDR)
+/**************************************************************/
+/**\name	FIFO GYRO ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Fifo_Config_1 Description - Reg Addr --> 0x47, Bit --> 7 */
+#define SMI130_USER_FIFO_GYRO_ENABLE__POS               (7)
+#define SMI130_USER_FIFO_GYRO_ENABLE__LEN               (1)
+#define SMI130_USER_FIFO_GYRO_ENABLE__MSK               (0x80)
+#define SMI130_USER_FIFO_GYRO_ENABLE__REG		       \
+(SMI130_USER_FIFO_CONFIG_1_ADDR)
+
+/**************************************************************/
+/**\name	MAG I2C ADDRESS SELECTION LENGTH, POSITION AND MASK*/
+/**************************************************************/
+
+/* Mag_IF_0 Description - Reg Addr --> 0x4b, Bit --> 1...7 */
+#define SMI130_USER_I2C_DEVICE_ADDR__POS               (1)
+#define SMI130_USER_I2C_DEVICE_ADDR__LEN               (7)
+#define SMI130_USER_I2C_DEVICE_ADDR__MSK               (0xFE)
+#define SMI130_USER_I2C_DEVICE_ADDR__REG	(SMI130_USER_MAG_IF_0_ADDR)
+/**************************************************************/
+/**\name MAG CONFIGURATION FOR SECONDARY
+	INTERFACE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Mag_IF_1 Description - Reg Addr --> 0x4c, Bit --> 0...1 */
+#define SMI130_USER_MAG_BURST__POS               (0)
+#define SMI130_USER_MAG_BURST__LEN               (2)
+#define SMI130_USER_MAG_BURST__MSK               (0x03)
+#define SMI130_USER_MAG_BURST__REG               (SMI130_USER_MAG_IF_1_ADDR)
+
+/* Mag_IF_1 Description - Reg Addr --> 0x4c, Bit --> 2...5 */
+#define SMI130_USER_MAG_OFFSET__POS               (2)
+#define SMI130_USER_MAG_OFFSET__LEN               (4)
+#define SMI130_USER_MAG_OFFSET__MSK               (0x3C)
+#define SMI130_USER_MAG_OFFSET__REG               (SMI130_USER_MAG_IF_1_ADDR)
+
+/* Mag_IF_1 Description - Reg Addr --> 0x4c, Bit --> 7 */
+#define SMI130_USER_MAG_MANUAL_ENABLE__POS               (7)
+#define SMI130_USER_MAG_MANUAL_ENABLE__LEN               (1)
+#define SMI130_USER_MAG_MANUAL_ENABLE__MSK               (0x80)
+#define SMI130_USER_MAG_MANUAL_ENABLE__REG               \
+(SMI130_USER_MAG_IF_1_ADDR)
+
+/* Mag_IF_2 Description - Reg Addr --> 0x4d, Bit -->0... 7 */
+#define SMI130_USER_READ_ADDR__POS               (0)
+#define SMI130_USER_READ_ADDR__LEN               (8)
+#define SMI130_USER_READ_ADDR__MSK               (0xFF)
+#define SMI130_USER_READ_ADDR__REG               (SMI130_USER_MAG_IF_2_ADDR)
+
+/* Mag_IF_3 Description - Reg Addr --> 0x4e, Bit -->0... 7 */
+#define SMI130_USER_WRITE_ADDR__POS               (0)
+#define SMI130_USER_WRITE_ADDR__LEN               (8)
+#define SMI130_USER_WRITE_ADDR__MSK               (0xFF)
+#define SMI130_USER_WRITE_ADDR__REG               (SMI130_USER_MAG_IF_3_ADDR)
+
+/* Mag_IF_4 Description - Reg Addr --> 0x4f, Bit -->0... 7 */
+#define SMI130_USER_WRITE_DATA__POS               (0)
+#define SMI130_USER_WRITE_DATA__LEN               (8)
+#define SMI130_USER_WRITE_DATA__MSK               (0xFF)
+#define SMI130_USER_WRITE_DATA__REG               (SMI130_USER_MAG_IF_4_ADDR)
+/**************************************************************/
+/**\name	ANY MOTION XYZ AXIS ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_En_0 Description - Reg Addr --> 0x50, Bit -->0 */
+#define SMI130_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE__POS               (0)
+#define SMI130_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE__LEN               (1)
+#define SMI130_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE__MSK               (0x01)
+#define SMI130_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE__REG	              \
+(SMI130_USER_INTR_ENABLE_0_ADDR)
+
+/* Int_En_0 Description - Reg Addr --> 0x50, Bit -->1 */
+#define SMI130_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE__POS               (1)
+#define SMI130_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE__LEN               (1)
+#define SMI130_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE__MSK               (0x02)
+#define SMI130_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE__REG	          \
+(SMI130_USER_INTR_ENABLE_0_ADDR)
+
+/* Int_En_0 Description - Reg Addr --> 0x50, Bit -->2 */
+#define SMI130_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE__POS               (2)
+#define SMI130_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE__LEN               (1)
+#define SMI130_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE__MSK               (0x04)
+#define SMI130_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE__REG	            \
+(SMI130_USER_INTR_ENABLE_0_ADDR)
+/**************************************************************/
+/**\name	DOUBLE TAP ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_En_0 Description - Reg Addr --> 0x50, Bit -->4 */
+#define SMI130_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE__POS               (4)
+#define SMI130_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE__LEN               (1)
+#define SMI130_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE__MSK               (0x10)
+#define SMI130_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE__REG	        \
+(SMI130_USER_INTR_ENABLE_0_ADDR)
+/**************************************************************/
+/**\name	SINGLE TAP ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_En_0 Description - Reg Addr --> 0x50, Bit -->5 */
+#define SMI130_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE__POS               (5)
+#define SMI130_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE__LEN               (1)
+#define SMI130_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE__MSK               (0x20)
+#define SMI130_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE__REG	       \
+(SMI130_USER_INTR_ENABLE_0_ADDR)
+/**************************************************************/
+/**\name	ORIENT ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_En_0 Description - Reg Addr --> 0x50, Bit -->6 */
+#define SMI130_USER_INTR_ENABLE_0_ORIENT_ENABLE__POS               (6)
+#define SMI130_USER_INTR_ENABLE_0_ORIENT_ENABLE__LEN               (1)
+#define SMI130_USER_INTR_ENABLE_0_ORIENT_ENABLE__MSK               (0x40)
+#define SMI130_USER_INTR_ENABLE_0_ORIENT_ENABLE__REG	           \
+(SMI130_USER_INTR_ENABLE_0_ADDR)
+/**************************************************************/
+/**\name	FLAT ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_En_0 Description - Reg Addr --> 0x50, Bit -->7 */
+#define SMI130_USER_INTR_ENABLE_0_FLAT_ENABLE__POS               (7)
+#define SMI130_USER_INTR_ENABLE_0_FLAT_ENABLE__LEN               (1)
+#define SMI130_USER_INTR_ENABLE_0_FLAT_ENABLE__MSK               (0x80)
+#define SMI130_USER_INTR_ENABLE_0_FLAT_ENABLE__REG	           \
+(SMI130_USER_INTR_ENABLE_0_ADDR)
+/**************************************************************/
+/**\name	HIGH_G XYZ ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_En_1 Description - Reg Addr --> (0x51), Bit -->0 */
+#define SMI130_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE__POS               (0)
+#define SMI130_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE__LEN               (1)
+#define SMI130_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE__MSK               (0x01)
+#define SMI130_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE__REG	           \
+(SMI130_USER_INTR_ENABLE_1_ADDR)
+
+/* Int_En_1 Description - Reg Addr --> (0x51), Bit -->1 */
+#define SMI130_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE__POS               (1)
+#define SMI130_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE__LEN               (1)
+#define SMI130_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE__MSK               (0x02)
+#define SMI130_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE__REG	           \
+(SMI130_USER_INTR_ENABLE_1_ADDR)
+
+/* Int_En_1 Description - Reg Addr --> (0x51), Bit -->2 */
+#define SMI130_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE__POS               (2)
+#define SMI130_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE__LEN               (1)
+#define SMI130_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE__MSK               (0x04)
+#define SMI130_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE__REG	           \
+(SMI130_USER_INTR_ENABLE_1_ADDR)
+/**************************************************************/
+/**\name	LOW_G ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_En_1 Description - Reg Addr --> (0x51), Bit -->3 */
+#define SMI130_USER_INTR_ENABLE_1_LOW_G_ENABLE__POS               (3)
+#define SMI130_USER_INTR_ENABLE_1_LOW_G_ENABLE__LEN               (1)
+#define SMI130_USER_INTR_ENABLE_1_LOW_G_ENABLE__MSK               (0x08)
+#define SMI130_USER_INTR_ENABLE_1_LOW_G_ENABLE__REG	          \
+(SMI130_USER_INTR_ENABLE_1_ADDR)
+/**************************************************************/
+/**\name	DATA READY ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_En_1 Description - Reg Addr --> (0x51), Bit -->4 */
+#define SMI130_USER_INTR_ENABLE_1_DATA_RDY_ENABLE__POS               (4)
+#define SMI130_USER_INTR_ENABLE_1_DATA_RDY_ENABLE__LEN               (1)
+#define SMI130_USER_INTR_ENABLE_1_DATA_RDY_ENABLE__MSK               (0x10)
+#define SMI130_USER_INTR_ENABLE_1_DATA_RDY_ENABLE__REG	            \
+(SMI130_USER_INTR_ENABLE_1_ADDR)
+/**************************************************************/
+/**\name	FIFO FULL AND WATER MARK ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_En_1 Description - Reg Addr --> (0x51), Bit -->5 */
+#define SMI130_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE__POS               (5)
+#define SMI130_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE__LEN               (1)
+#define SMI130_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE__MSK               (0x20)
+#define SMI130_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE__REG	              \
+(SMI130_USER_INTR_ENABLE_1_ADDR)
+
+/* Int_En_1 Description - Reg Addr --> (0x51), Bit -->6 */
+#define SMI130_USER_INTR_ENABLE_1_FIFO_WM_ENABLE__POS               (6)
+#define SMI130_USER_INTR_ENABLE_1_FIFO_WM_ENABLE__LEN               (1)
+#define SMI130_USER_INTR_ENABLE_1_FIFO_WM_ENABLE__MSK               (0x40)
+#define SMI130_USER_INTR_ENABLE_1_FIFO_WM_ENABLE__REG	           \
+(SMI130_USER_INTR_ENABLE_1_ADDR)
+/**************************************************************/
+/**\name	NO MOTION XYZ ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_En_2 Description - Reg Addr --> (0x52), Bit -->0 */
+#define SMI130_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE__POS               (0)
+#define SMI130_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE__LEN               (1)
+#define SMI130_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE__MSK               (0x01)
+#define SMI130_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE__REG	  \
+(SMI130_USER_INTR_ENABLE_2_ADDR)
+
+/* Int_En_2 Description - Reg Addr --> (0x52), Bit -->1 */
+#define SMI130_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE__POS               (1)
+#define SMI130_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE__LEN               (1)
+#define SMI130_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE__MSK               (0x02)
+#define SMI130_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE__REG	  \
+(SMI130_USER_INTR_ENABLE_2_ADDR)
+
+/* Int_En_2 Description - Reg Addr --> (0x52), Bit -->2 */
+#define SMI130_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE__POS               (2)
+#define SMI130_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE__LEN               (1)
+#define SMI130_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE__MSK               (0x04)
+#define SMI130_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE__REG	  \
+(SMI130_USER_INTR_ENABLE_2_ADDR)
+/**************************************************************/
+/**\name	STEP DETECTOR ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_En_2 Description - Reg Addr --> (0x52), Bit -->3 */
+#define SMI130_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE__POS               (3)
+#define SMI130_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE__LEN               (1)
+#define SMI130_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE__MSK               (0x08)
+#define SMI130_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE__REG	  \
+(SMI130_USER_INTR_ENABLE_2_ADDR)
+/**************************************************************/
+/**\name	EDGE CONTROL ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Out_Ctrl Description - Reg Addr --> 0x53, Bit -->0 */
+#define SMI130_USER_INTR1_EDGE_CTRL__POS               (0)
+#define SMI130_USER_INTR1_EDGE_CTRL__LEN               (1)
+#define SMI130_USER_INTR1_EDGE_CTRL__MSK               (0x01)
+#define SMI130_USER_INTR1_EDGE_CTRL__REG		\
+(SMI130_USER_INTR_OUT_CTRL_ADDR)
+/**************************************************************/
+/**\name	LEVEL CONTROL ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Out_Ctrl Description - Reg Addr --> 0x53, Bit -->1 */
+#define SMI130_USER_INTR1_LEVEL__POS               (1)
+#define SMI130_USER_INTR1_LEVEL__LEN               (1)
+#define SMI130_USER_INTR1_LEVEL__MSK               (0x02)
+#define SMI130_USER_INTR1_LEVEL__REG               \
+(SMI130_USER_INTR_OUT_CTRL_ADDR)
+/**************************************************************/
+/**\name	OUTPUT TYPE ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Out_Ctrl Description - Reg Addr --> 0x53, Bit -->2 */
+#define SMI130_USER_INTR1_OUTPUT_TYPE__POS               (2)
+#define SMI130_USER_INTR1_OUTPUT_TYPE__LEN               (1)
+#define SMI130_USER_INTR1_OUTPUT_TYPE__MSK               (0x04)
+#define SMI130_USER_INTR1_OUTPUT_TYPE__REG               \
+(SMI130_USER_INTR_OUT_CTRL_ADDR)
+/**************************************************************/
+/**\name	OUTPUT TYPE ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Out_Ctrl Description - Reg Addr --> 0x53, Bit -->3 */
+#define SMI130_USER_INTR1_OUTPUT_ENABLE__POS               (3)
+#define SMI130_USER_INTR1_OUTPUT_ENABLE__LEN               (1)
+#define SMI130_USER_INTR1_OUTPUT_ENABLE__MSK               (0x08)
+#define SMI130_USER_INTR1_OUTPUT_ENABLE__REG		\
+(SMI130_USER_INTR_OUT_CTRL_ADDR)
+/**************************************************************/
+/**\name	EDGE CONTROL ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Out_Ctrl Description - Reg Addr --> 0x53, Bit -->4 */
+#define SMI130_USER_INTR2_EDGE_CTRL__POS               (4)
+#define SMI130_USER_INTR2_EDGE_CTRL__LEN               (1)
+#define SMI130_USER_INTR2_EDGE_CTRL__MSK               (0x10)
+#define SMI130_USER_INTR2_EDGE_CTRL__REG		\
+(SMI130_USER_INTR_OUT_CTRL_ADDR)
+/**************************************************************/
+/**\name	LEVEL CONTROL ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Out_Ctrl Description - Reg Addr --> 0x53, Bit -->5 */
+#define SMI130_USER_INTR2_LEVEL__POS               (5)
+#define SMI130_USER_INTR2_LEVEL__LEN               (1)
+#define SMI130_USER_INTR2_LEVEL__MSK               (0x20)
+#define SMI130_USER_INTR2_LEVEL__REG               \
+(SMI130_USER_INTR_OUT_CTRL_ADDR)
+/**************************************************************/
+/**\name	OUTPUT TYPE ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Out_Ctrl Description - Reg Addr --> 0x53, Bit -->6 */
+#define SMI130_USER_INTR2_OUTPUT_TYPE__POS               (6)
+#define SMI130_USER_INTR2_OUTPUT_TYPE__LEN               (1)
+#define SMI130_USER_INTR2_OUTPUT_TYPE__MSK               (0x40)
+#define SMI130_USER_INTR2_OUTPUT_TYPE__REG               \
+(SMI130_USER_INTR_OUT_CTRL_ADDR)
+
+/* Int_Out_Ctrl Description - Reg Addr --> 0x53, Bit -->7 */
+#define SMI130_USER_INTR2_OUTPUT_EN__POS               (7)
+#define SMI130_USER_INTR2_OUTPUT_EN__LEN               (1)
+#define SMI130_USER_INTR2_OUTPUT_EN__MSK               (0x80)
+#define SMI130_USER_INTR2_OUTPUT_EN__REG		\
+(SMI130_USER_INTR_OUT_CTRL_ADDR)
+/**************************************************************/
+/**\name	LATCH INTERRUPT LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Latch Description - Reg Addr --> 0x54, Bit -->0...3 */
+#define SMI130_USER_INTR_LATCH__POS               (0)
+#define SMI130_USER_INTR_LATCH__LEN               (4)
+#define SMI130_USER_INTR_LATCH__MSK               (0x0F)
+#define SMI130_USER_INTR_LATCH__REG               (SMI130_USER_INTR_LATCH_ADDR)
+/**************************************************************/
+/**\name	INPUT ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Latch Description - Reg Addr --> 0x54, Bit -->4 */
+#define SMI130_USER_INTR1_INPUT_ENABLE__POS               (4)
+#define SMI130_USER_INTR1_INPUT_ENABLE__LEN               (1)
+#define SMI130_USER_INTR1_INPUT_ENABLE__MSK               (0x10)
+#define SMI130_USER_INTR1_INPUT_ENABLE__REG               \
+(SMI130_USER_INTR_LATCH_ADDR)
+
+/* Int_Latch Description - Reg Addr --> 0x54, Bit -->5*/
+#define SMI130_USER_INTR2_INPUT_ENABLE__POS               (5)
+#define SMI130_USER_INTR2_INPUT_ENABLE__LEN               (1)
+#define SMI130_USER_INTR2_INPUT_ENABLE__MSK               (0x20)
+#define SMI130_USER_INTR2_INPUT_ENABLE__REG              \
+(SMI130_USER_INTR_LATCH_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT1 MAPPIONG OF LOW_G LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_0 Description - Reg Addr --> 0x55, Bit -->0 */
+#define SMI130_USER_INTR_MAP_0_INTR1_LOW_G__POS               (0)
+#define SMI130_USER_INTR_MAP_0_INTR1_LOW_G__LEN               (1)
+#define SMI130_USER_INTR_MAP_0_INTR1_LOW_G__MSK               (0x01)
+#define SMI130_USER_INTR_MAP_0_INTR1_LOW_G__REG	(SMI130_USER_INTR_MAP_0_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT1 MAPPIONG OF HIGH_G LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_0 Description - Reg Addr --> 0x55, Bit -->1 */
+#define SMI130_USER_INTR_MAP_0_INTR1_HIGH_G__POS               (1)
+#define SMI130_USER_INTR_MAP_0_INTR1_HIGH_G__LEN               (1)
+#define SMI130_USER_INTR_MAP_0_INTR1_HIGH_G__MSK               (0x02)
+#define SMI130_USER_INTR_MAP_0_INTR1_HIGH_G__REG	\
+(SMI130_USER_INTR_MAP_0_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT MAPPIONG OF ANY MOTION_G LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_0 Description - Reg Addr --> 0x55, Bit -->2 */
+#define SMI130_USER_INTR_MAP_0_INTR1_ANY_MOTION__POS               (2)
+#define SMI130_USER_INTR_MAP_0_INTR1_ANY_MOTION__LEN               (1)
+#define SMI130_USER_INTR_MAP_0_INTR1_ANY_MOTION__MSK               (0x04)
+#define SMI130_USER_INTR_MAP_0_INTR1_ANY_MOTION__REG            \
+(SMI130_USER_INTR_MAP_0_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT1 MAPPIONG OF NO MOTION LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_0 Description - Reg Addr --> 0x55, Bit -->3 */
+#define SMI130_USER_INTR_MAP_0_INTR1_NOMOTION__POS               (3)
+#define SMI130_USER_INTR_MAP_0_INTR1_NOMOTION__LEN               (1)
+#define SMI130_USER_INTR_MAP_0_INTR1_NOMOTION__MSK               (0x08)
+#define SMI130_USER_INTR_MAP_0_INTR1_NOMOTION__REG (SMI130_USER_INTR_MAP_0_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT1 MAPPIONG OF DOUBLE TAP LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_0 Description - Reg Addr --> 0x55, Bit -->4 */
+#define SMI130_USER_INTR_MAP_0_INTR1_DOUBLE_TAP__POS               (4)
+#define SMI130_USER_INTR_MAP_0_INTR1_DOUBLE_TAP__LEN               (1)
+#define SMI130_USER_INTR_MAP_0_INTR1_DOUBLE_TAP__MSK               (0x10)
+#define SMI130_USER_INTR_MAP_0_INTR1_DOUBLE_TAP__REG	\
+(SMI130_USER_INTR_MAP_0_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT1 MAPPIONG OF SINGLE TAP LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_0 Description - Reg Addr --> 0x55, Bit -->5 */
+#define SMI130_USER_INTR_MAP_0_INTR1_SINGLE_TAP__POS               (5)
+#define SMI130_USER_INTR_MAP_0_INTR1_SINGLE_TAP__LEN               (1)
+#define SMI130_USER_INTR_MAP_0_INTR1_SINGLE_TAP__MSK               (0x20)
+#define SMI130_USER_INTR_MAP_0_INTR1_SINGLE_TAP__REG	      \
+(SMI130_USER_INTR_MAP_0_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT1 MAPPIONG OF ORIENT LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_0 Description - Reg Addr --> 0x55, Bit -->6 */
+#define SMI130_USER_INTR_MAP_0_INTR1_ORIENT__POS               (6)
+#define SMI130_USER_INTR_MAP_0_INTR1_ORIENT__LEN               (1)
+#define SMI130_USER_INTR_MAP_0_INTR1_ORIENT__MSK               (0x40)
+#define SMI130_USER_INTR_MAP_0_INTR1_ORIENT__REG	          \
+(SMI130_USER_INTR_MAP_0_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT MAPPIONG OF FLAT LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_0 Description - Reg Addr --> 0x56, Bit -->7 */
+#define SMI130_USER_INTR_MAP_0_INTR1_FLAT__POS               (7)
+#define SMI130_USER_INTR_MAP_0_INTR1_FLAT__LEN               (1)
+#define SMI130_USER_INTR_MAP_0_INTR1_FLAT__MSK               (0x80)
+#define SMI130_USER_INTR_MAP_0_INTR1_FLAT__REG	(SMI130_USER_INTR_MAP_0_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT1 MAPPIONG OF PMU TRIGGER LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_1 Description - Reg Addr --> 0x56, Bit -->0 */
+#define SMI130_USER_INTR_MAP_1_INTR2_PMU_TRIG__POS               (0)
+#define SMI130_USER_INTR_MAP_1_INTR2_PMU_TRIG__LEN               (1)
+#define SMI130_USER_INTR_MAP_1_INTR2_PMU_TRIG__MSK               (0x01)
+#define SMI130_USER_INTR_MAP_1_INTR2_PMU_TRIG__REG (SMI130_USER_INTR_MAP_1_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT1 MAPPIONG OF FIFO FULL AND
+	WATER MARK LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_1 Description - Reg Addr --> 0x56, Bit -->1 */
+#define SMI130_USER_INTR_MAP_1_INTR2_FIFO_FULL__POS               (1)
+#define SMI130_USER_INTR_MAP_1_INTR2_FIFO_FULL__LEN               (1)
+#define SMI130_USER_INTR_MAP_1_INTR2_FIFO_FULL__MSK               (0x02)
+#define SMI130_USER_INTR_MAP_1_INTR2_FIFO_FULL__REG	         \
+(SMI130_USER_INTR_MAP_1_ADDR)
+
+/* Int_Map_1 Description - Reg Addr --> 0x56, Bit -->2 */
+#define SMI130_USER_INTR_MAP_1_INTR2_FIFO_WM__POS               (2)
+#define SMI130_USER_INTR_MAP_1_INTR2_FIFO_WM__LEN               (1)
+#define SMI130_USER_INTR_MAP_1_INTR2_FIFO_WM__MSK               (0x04)
+#define SMI130_USER_INTR_MAP_1_INTR2_FIFO_WM__REG	         \
+(SMI130_USER_INTR_MAP_1_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT1 MAPPIONG OF DATA READY LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_1 Description - Reg Addr --> 0x56, Bit -->3 */
+#define SMI130_USER_INTR_MAP_1_INTR2_DATA_RDY__POS               (3)
+#define SMI130_USER_INTR_MAP_1_INTR2_DATA_RDY__LEN               (1)
+#define SMI130_USER_INTR_MAP_1_INTR2_DATA_RDY__MSK               (0x08)
+#define SMI130_USER_INTR_MAP_1_INTR2_DATA_RDY__REG	      \
+(SMI130_USER_INTR_MAP_1_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT1 MAPPIONG OF PMU TRIGGER LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_1 Description - Reg Addr --> 0x56, Bit -->4 */
+#define SMI130_USER_INTR_MAP_1_INTR1_PMU_TRIG__POS               (4)
+#define SMI130_USER_INTR_MAP_1_INTR1_PMU_TRIG__LEN               (1)
+#define SMI130_USER_INTR_MAP_1_INTR1_PMU_TRIG__MSK               (0x10)
+#define SMI130_USER_INTR_MAP_1_INTR1_PMU_TRIG__REG (SMI130_USER_INTR_MAP_1_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT1 MAPPIONG OF FIFO FULL AND
+	WATER MARK LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_1 Description - Reg Addr --> 0x56, Bit -->5 */
+#define SMI130_USER_INTR_MAP_1_INTR1_FIFO_FULL__POS               (5)
+#define SMI130_USER_INTR_MAP_1_INTR1_FIFO_FULL__LEN               (1)
+#define SMI130_USER_INTR_MAP_1_INTR1_FIFO_FULL__MSK               (0x20)
+#define SMI130_USER_INTR_MAP_1_INTR1_FIFO_FULL__REG	       \
+(SMI130_USER_INTR_MAP_1_ADDR)
+
+/* Int_Map_1 Description - Reg Addr --> 0x56, Bit -->6 */
+#define SMI130_USER_INTR_MAP_1_INTR1_FIFO_WM__POS               (6)
+#define SMI130_USER_INTR_MAP_1_INTR1_FIFO_WM__LEN               (1)
+#define SMI130_USER_INTR_MAP_1_INTR1_FIFO_WM__MSK               (0x40)
+#define SMI130_USER_INTR_MAP_1_INTR1_FIFO_WM__REG	\
+(SMI130_USER_INTR_MAP_1_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT1 MAPPIONG OF DATA READY LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_1 Description - Reg Addr --> 0x56, Bit -->7 */
+#define SMI130_USER_INTR_MAP_1_INTR1_DATA_RDY__POS               (7)
+#define SMI130_USER_INTR_MAP_1_INTR1_DATA_RDY__LEN               (1)
+#define SMI130_USER_INTR_MAP_1_INTR1_DATA_RDY__MSK               (0x80)
+#define SMI130_USER_INTR_MAP_1_INTR1_DATA_RDY__REG	\
+(SMI130_USER_INTR_MAP_1_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT2 MAPPIONG OF LOW_G LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_2 Description - Reg Addr --> 0x57, Bit -->0 */
+#define SMI130_USER_INTR_MAP_2_INTR2_LOW_G__POS               (0)
+#define SMI130_USER_INTR_MAP_2_INTR2_LOW_G__LEN               (1)
+#define SMI130_USER_INTR_MAP_2_INTR2_LOW_G__MSK               (0x01)
+#define SMI130_USER_INTR_MAP_2_INTR2_LOW_G__REG	(SMI130_USER_INTR_MAP_2_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT2 MAPPIONG OF HIGH_G LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_2 Description - Reg Addr --> 0x57, Bit -->1 */
+#define SMI130_USER_INTR_MAP_2_INTR2_HIGH_G__POS               (1)
+#define SMI130_USER_INTR_MAP_2_INTR2_HIGH_G__LEN               (1)
+#define SMI130_USER_INTR_MAP_2_INTR2_HIGH_G__MSK               (0x02)
+#define SMI130_USER_INTR_MAP_2_INTR2_HIGH_G__REG	\
+(SMI130_USER_INTR_MAP_2_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT2 MAPPIONG OF ANY MOTION LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_2 Description - Reg Addr --> 0x57, Bit -->2 */
+#define SMI130_USER_INTR_MAP_2_INTR2_ANY_MOTION__POS      (2)
+#define SMI130_USER_INTR_MAP_2_INTR2_ANY_MOTION__LEN      (1)
+#define SMI130_USER_INTR_MAP_2_INTR2_ANY_MOTION__MSK     (0x04)
+#define SMI130_USER_INTR_MAP_2_INTR2_ANY_MOTION__REG     \
+(SMI130_USER_INTR_MAP_2_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT2 MAPPIONG OF NO MOTION LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_2 Description - Reg Addr --> 0x57, Bit -->3 */
+#define SMI130_USER_INTR_MAP_2_INTR2_NOMOTION__POS               (3)
+#define SMI130_USER_INTR_MAP_2_INTR2_NOMOTION__LEN               (1)
+#define SMI130_USER_INTR_MAP_2_INTR2_NOMOTION__MSK               (0x08)
+#define SMI130_USER_INTR_MAP_2_INTR2_NOMOTION__REG (SMI130_USER_INTR_MAP_2_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT2 MAPPIONG OF DOUBLE TAP LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_2 Description - Reg Addr --> 0x57, Bit -->4 */
+#define SMI130_USER_INTR_MAP_2_INTR2_DOUBLE_TAP__POS               (4)
+#define SMI130_USER_INTR_MAP_2_INTR2_DOUBLE_TAP__LEN               (1)
+#define SMI130_USER_INTR_MAP_2_INTR2_DOUBLE_TAP__MSK               (0x10)
+#define SMI130_USER_INTR_MAP_2_INTR2_DOUBLE_TAP__REG	\
+(SMI130_USER_INTR_MAP_2_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT2 MAPPIONG OF SINGLE TAP LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_2 Description - Reg Addr --> 0x57, Bit -->5 */
+#define SMI130_USER_INTR_MAP_2_INTR2_SINGLE_TAP__POS               (5)
+#define SMI130_USER_INTR_MAP_2_INTR2_SINGLE_TAP__LEN               (1)
+#define SMI130_USER_INTR_MAP_2_INTR2_SINGLE_TAP__MSK               (0x20)
+#define SMI130_USER_INTR_MAP_2_INTR2_SINGLE_TAP__REG	\
+(SMI130_USER_INTR_MAP_2_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT2 MAPPIONG OF ORIENT LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_2 Description - Reg Addr --> 0x57, Bit -->6 */
+#define SMI130_USER_INTR_MAP_2_INTR2_ORIENT__POS               (6)
+#define SMI130_USER_INTR_MAP_2_INTR2_ORIENT__LEN               (1)
+#define SMI130_USER_INTR_MAP_2_INTR2_ORIENT__MSK               (0x40)
+#define SMI130_USER_INTR_MAP_2_INTR2_ORIENT__REG	\
+(SMI130_USER_INTR_MAP_2_ADDR)
+/**************************************************************/
+/**\name	INTERRUPT2 MAPPIONG OF FLAT LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Map_2 Description - Reg Addr --> 0x57, Bit -->7 */
+#define SMI130_USER_INTR_MAP_2_INTR2_FLAT__POS               (7)
+#define SMI130_USER_INTR_MAP_2_INTR2_FLAT__LEN               (1)
+#define SMI130_USER_INTR_MAP_2_INTR2_FLAT__MSK               (0x80)
+#define SMI130_USER_INTR_MAP_2_INTR2_FLAT__REG	(SMI130_USER_INTR_MAP_2_ADDR)
+
+/**************************************************************/
+/**\name	TAP SOURCE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Data_0 Description - Reg Addr --> 0x58, Bit --> 3 */
+#define SMI130_USER_INTR_DATA_0_INTR_TAP_SOURCE__POS               (3)
+#define SMI130_USER_INTR_DATA_0_INTR_TAP_SOURCE__LEN               (1)
+#define SMI130_USER_INTR_DATA_0_INTR_TAP_SOURCE__MSK               (0x08)
+#define SMI130_USER_INTR_DATA_0_INTR_TAP_SOURCE__REG	           \
+(SMI130_USER_INTR_DATA_0_ADDR)
+
+/**************************************************************/
+/**\name	HIGH SOURCE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Data_0 Description - Reg Addr --> 0x58, Bit --> 7 */
+#define SMI130_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE__POS           (7)
+#define SMI130_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE__LEN           (1)
+#define SMI130_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE__MSK           (0x80)
+#define SMI130_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE__REG            \
+(SMI130_USER_INTR_DATA_0_ADDR)
+
+/**************************************************************/
+/**\name	MOTION SOURCE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Data_1 Description - Reg Addr --> 0x59, Bit --> 7 */
+#define SMI130_USER_INTR_DATA_1_INTR_MOTION_SOURCE__POS               (7)
+#define SMI130_USER_INTR_DATA_1_INTR_MOTION_SOURCE__LEN               (1)
+#define SMI130_USER_INTR_DATA_1_INTR_MOTION_SOURCE__MSK               (0x80)
+#define SMI130_USER_INTR_DATA_1_INTR_MOTION_SOURCE__REG               \
+		(SMI130_USER_INTR_DATA_1_ADDR)
+/**************************************************************/
+/**\name	LOW HIGH DURATION LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_LowHigh_0 Description - Reg Addr --> 0x5a, Bit --> 0...7 */
+#define SMI130_USER_INTR_LOWHIGH_0_INTR_LOW_DURN__POS               (0)
+#define SMI130_USER_INTR_LOWHIGH_0_INTR_LOW_DURN__LEN               (8)
+#define SMI130_USER_INTR_LOWHIGH_0_INTR_LOW_DURN__MSK               (0xFF)
+#define SMI130_USER_INTR_LOWHIGH_0_INTR_LOW_DURN__REG               \
+		(SMI130_USER_INTR_LOWHIGH_0_ADDR)
+/**************************************************************/
+/**\name	LOW THRESHOLD LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_LowHigh_1 Description - Reg Addr --> 0x5b, Bit --> 0...7 */
+#define SMI130_USER_INTR_LOWHIGH_1_INTR_LOW_THRES__POS               (0)
+#define SMI130_USER_INTR_LOWHIGH_1_INTR_LOW_THRES__LEN               (8)
+#define SMI130_USER_INTR_LOWHIGH_1_INTR_LOW_THRES__MSK               (0xFF)
+#define SMI130_USER_INTR_LOWHIGH_1_INTR_LOW_THRES__REG               \
+		(SMI130_USER_INTR_LOWHIGH_1_ADDR)
+/**************************************************************/
+/**\name	LOW HYSTERESIS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_LowHigh_2 Description - Reg Addr --> 0x5c, Bit --> 0...1 */
+#define SMI130_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST__POS               (0)
+#define SMI130_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST__LEN               (2)
+#define SMI130_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST__MSK               (0x03)
+#define SMI130_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST__REG               \
+		(SMI130_USER_INTR_LOWHIGH_2_ADDR)
+/**************************************************************/
+/**\name	LOW MODE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_LowHigh_2 Description - Reg Addr --> 0x5c, Bit --> 2 */
+#define SMI130_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE__POS               (2)
+#define SMI130_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE__LEN               (1)
+#define SMI130_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE__MSK               (0x04)
+#define SMI130_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE__REG               \
+		(SMI130_USER_INTR_LOWHIGH_2_ADDR)
+/**************************************************************/
+/**\name	HIGH_G HYSTERESIS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_LowHigh_2 Description - Reg Addr --> 0x5c, Bit --> 6...7 */
+#define SMI130_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST__POS               (6)
+#define SMI130_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST__LEN               (2)
+#define SMI130_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST__MSK               (0xC0)
+#define SMI130_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST__REG               \
+		(SMI130_USER_INTR_LOWHIGH_2_ADDR)
+/**************************************************************/
+/**\name	HIGH_G DURATION LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_LowHigh_3 Description - Reg Addr --> 0x5d, Bit --> 0...7 */
+#define SMI130_USER_INTR_LOWHIGH_3_INTR_HIGH_G_DURN__POS               (0)
+#define SMI130_USER_INTR_LOWHIGH_3_INTR_HIGH_G_DURN__LEN               (8)
+#define SMI130_USER_INTR_LOWHIGH_3_INTR_HIGH_G_DURN__MSK               (0xFF)
+#define SMI130_USER_INTR_LOWHIGH_3_INTR_HIGH_G_DURN__REG               \
+		(SMI130_USER_INTR_LOWHIGH_3_ADDR)
+/**************************************************************/
+/**\name	HIGH_G THRESHOLD LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_LowHigh_4 Description - Reg Addr --> 0x5e, Bit --> 0...7 */
+#define SMI130_USER_INTR_LOWHIGH_4_INTR_HIGH_THRES__POS               (0)
+#define SMI130_USER_INTR_LOWHIGH_4_INTR_HIGH_THRES__LEN               (8)
+#define SMI130_USER_INTR_LOWHIGH_4_INTR_HIGH_THRES__MSK               (0xFF)
+#define SMI130_USER_INTR_LOWHIGH_4_INTR_HIGH_THRES__REG               \
+		(SMI130_USER_INTR_LOWHIGH_4_ADDR)
+/**************************************************************/
+/**\name	ANY MOTION DURATION LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Motion_0 Description - Reg Addr --> 0x5f, Bit --> 0...1 */
+#define SMI130_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN__POS               (0)
+#define SMI130_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN__LEN               (2)
+#define SMI130_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN__MSK               (0x03)
+#define SMI130_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN__REG               \
+		(SMI130_USER_INTR_MOTION_0_ADDR)
+/**************************************************************/
+/**\name	SLOW/NO MOTION DURATION LENGTH, POSITION AND MASK*/
+/**************************************************************/
+	/* Int_Motion_0 Description - Reg Addr --> 0x5f, Bit --> 2...7 */
+#define SMI130_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN__POS      (2)
+#define SMI130_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN__LEN      (6)
+#define SMI130_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN__MSK      (0xFC)
+#define SMI130_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN__REG       \
+		(SMI130_USER_INTR_MOTION_0_ADDR)
+/**************************************************************/
+/**\name	ANY MOTION THRESHOLD LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Motion_1 Description - Reg Addr --> (0x60), Bit --> 0...7 */
+#define SMI130_USER_INTR_MOTION_1_INTR_ANY_MOTION_THRES__POS      (0)
+#define SMI130_USER_INTR_MOTION_1_INTR_ANY_MOTION_THRES__LEN      (8)
+#define SMI130_USER_INTR_MOTION_1_INTR_ANY_MOTION_THRES__MSK      (0xFF)
+#define SMI130_USER_INTR_MOTION_1_INTR_ANY_MOTION_THRES__REG               \
+		(SMI130_USER_INTR_MOTION_1_ADDR)
+/**************************************************************/
+/**\name	SLOW/NO MOTION THRESHOLD LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Motion_2 Description - Reg Addr --> 0x61, Bit --> 0...7 */
+#define SMI130_USER_INTR_MOTION_2_INTR_SLOW_NO_MOTION_THRES__POS       (0)
+#define SMI130_USER_INTR_MOTION_2_INTR_SLOW_NO_MOTION_THRES__LEN       (8)
+#define SMI130_USER_INTR_MOTION_2_INTR_SLOW_NO_MOTION_THRES__MSK       (0xFF)
+#define SMI130_USER_INTR_MOTION_2_INTR_SLOW_NO_MOTION_THRES__REG       \
+		(SMI130_USER_INTR_MOTION_2_ADDR)
+/**************************************************************/
+/**\name	SLOW/NO MOTION SELECT LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Motion_3 Description - Reg Addr --> (0x62), Bit --> 0 */
+#define SMI130_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT__POS	(0)
+#define SMI130_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT__LEN	(1)
+#define SMI130_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT__MSK	(0x01)
+#define SMI130_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT__REG   \
+(SMI130_USER_INTR_MOTION_3_ADDR)
+/**************************************************************/
+/**\name	SIGNIFICANT MOTION SELECT LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Motion_3 Description - Reg Addr --> (0x62), Bit --> 1 */
+#define SMI130_USER_INTR_SIGNIFICATION_MOTION_SELECT__POS		(1)
+#define SMI130_USER_INTR_SIGNIFICATION_MOTION_SELECT__LEN		(1)
+#define SMI130_USER_INTR_SIGNIFICATION_MOTION_SELECT__MSK		(0x02)
+#define SMI130_USER_INTR_SIGNIFICATION_MOTION_SELECT__REG		\
+		(SMI130_USER_INTR_MOTION_3_ADDR)
+
+/* Int_Motion_3 Description - Reg Addr --> (0x62), Bit --> 3..2 */
+#define SMI130_USER_INTR_SIGNIFICANT_MOTION_SKIP__POS		(2)
+#define SMI130_USER_INTR_SIGNIFICANT_MOTION_SKIP__LEN		(2)
+#define SMI130_USER_INTR_SIGNIFICANT_MOTION_SKIP__MSK		(0x0C)
+#define SMI130_USER_INTR_SIGNIFICANT_MOTION_SKIP__REG		\
+		(SMI130_USER_INTR_MOTION_3_ADDR)
+
+/* Int_Motion_3 Description - Reg Addr --> (0x62), Bit --> 5..4 */
+#define SMI130_USER_INTR_SIGNIFICANT_MOTION_PROOF__POS		(4)
+#define SMI130_USER_INTR_SIGNIFICANT_MOTION_PROOF__LEN		(2)
+#define SMI130_USER_INTR_SIGNIFICANT_MOTION_PROOF__MSK		(0x30)
+#define SMI130_USER_INTR_SIGNIFICANT_MOTION_PROOF__REG		\
+		(SMI130_USER_INTR_MOTION_3_ADDR)
+/**************************************************************/
+/**\name	TAP DURATION LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* INT_TAP_0 Description - Reg Addr --> (0x63), Bit --> 0..2*/
+#define SMI130_USER_INTR_TAP_0_INTR_TAP_DURN__POS               (0)
+#define SMI130_USER_INTR_TAP_0_INTR_TAP_DURN__LEN               (3)
+#define SMI130_USER_INTR_TAP_0_INTR_TAP_DURN__MSK               (0x07)
+#define SMI130_USER_INTR_TAP_0_INTR_TAP_DURN__REG	\
+(SMI130_USER_INTR_TAP_0_ADDR)
+/**************************************************************/
+/**\name	TAP SHOCK LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Tap_0 Description - Reg Addr --> (0x63), Bit --> 6 */
+#define SMI130_USER_INTR_TAP_0_INTR_TAP_SHOCK__POS               (6)
+#define SMI130_USER_INTR_TAP_0_INTR_TAP_SHOCK__LEN               (1)
+#define SMI130_USER_INTR_TAP_0_INTR_TAP_SHOCK__MSK               (0x40)
+#define SMI130_USER_INTR_TAP_0_INTR_TAP_SHOCK__REG (SMI130_USER_INTR_TAP_0_ADDR)
+/**************************************************************/
+/**\name	TAP QUIET LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Tap_0 Description - Reg Addr --> (0x63), Bit --> 7 */
+#define SMI130_USER_INTR_TAP_0_INTR_TAP_QUIET__POS               (7)
+#define SMI130_USER_INTR_TAP_0_INTR_TAP_QUIET__LEN               (1)
+#define SMI130_USER_INTR_TAP_0_INTR_TAP_QUIET__MSK               (0x80)
+#define SMI130_USER_INTR_TAP_0_INTR_TAP_QUIET__REG (SMI130_USER_INTR_TAP_0_ADDR)
+/**************************************************************/
+/**\name	TAP THRESHOLD LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Tap_1 Description - Reg Addr --> (0x64), Bit --> 0...4 */
+#define SMI130_USER_INTR_TAP_1_INTR_TAP_THRES__POS               (0)
+#define SMI130_USER_INTR_TAP_1_INTR_TAP_THRES__LEN               (5)
+#define SMI130_USER_INTR_TAP_1_INTR_TAP_THRES__MSK               (0x1F)
+#define SMI130_USER_INTR_TAP_1_INTR_TAP_THRES__REG (SMI130_USER_INTR_TAP_1_ADDR)
+/**************************************************************/
+/**\name	ORIENT MODE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Orient_0 Description - Reg Addr --> (0x65), Bit --> 0...1 */
+#define SMI130_USER_INTR_ORIENT_0_INTR_ORIENT_MODE__POS               (0)
+#define SMI130_USER_INTR_ORIENT_0_INTR_ORIENT_MODE__LEN               (2)
+#define SMI130_USER_INTR_ORIENT_0_INTR_ORIENT_MODE__MSK               (0x03)
+#define SMI130_USER_INTR_ORIENT_0_INTR_ORIENT_MODE__REG               \
+		(SMI130_USER_INTR_ORIENT_0_ADDR)
+/**************************************************************/
+/**\name	ORIENT BLOCKING LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Orient_0 Description - Reg Addr --> (0x65), Bit --> 2...3 */
+#define SMI130_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING__POS               (2)
+#define SMI130_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING__LEN               (2)
+#define SMI130_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING__MSK               (0x0C)
+#define SMI130_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING__REG               \
+		(SMI130_USER_INTR_ORIENT_0_ADDR)
+/**************************************************************/
+/**\name	ORIENT HYSTERESIS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Orient_0 Description - Reg Addr --> (0x65), Bit --> 4...7 */
+#define SMI130_USER_INTR_ORIENT_0_INTR_ORIENT_HYST__POS               (4)
+#define SMI130_USER_INTR_ORIENT_0_INTR_ORIENT_HYST__LEN               (4)
+#define SMI130_USER_INTR_ORIENT_0_INTR_ORIENT_HYST__MSK               (0xF0)
+#define SMI130_USER_INTR_ORIENT_0_INTR_ORIENT_HYST__REG               \
+		(SMI130_USER_INTR_ORIENT_0_ADDR)
+/**************************************************************/
+/**\name	ORIENT THETA LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Orient_1 Description - Reg Addr --> 0x66, Bit --> 0...5 */
+#define SMI130_USER_INTR_ORIENT_1_INTR_ORIENT_THETA__POS               (0)
+#define SMI130_USER_INTR_ORIENT_1_INTR_ORIENT_THETA__LEN               (6)
+#define SMI130_USER_INTR_ORIENT_1_INTR_ORIENT_THETA__MSK               (0x3F)
+#define SMI130_USER_INTR_ORIENT_1_INTR_ORIENT_THETA__REG               \
+		(SMI130_USER_INTR_ORIENT_1_ADDR)
+/**************************************************************/
+/**\name	ORIENT UD LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Orient_1 Description - Reg Addr --> 0x66, Bit --> 6 */
+#define SMI130_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE__POS         (6)
+#define SMI130_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE__LEN         (1)
+#define SMI130_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE__MSK         (0x40)
+#define SMI130_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE__REG          \
+		(SMI130_USER_INTR_ORIENT_1_ADDR)
+/**************************************************************/
+/**\name	ORIENT AXIS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Orient_1 Description - Reg Addr --> 0x66, Bit --> 7 */
+#define SMI130_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX__POS               (7)
+#define SMI130_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX__LEN               (1)
+#define SMI130_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX__MSK               (0x80)
+#define SMI130_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX__REG               \
+		(SMI130_USER_INTR_ORIENT_1_ADDR)
+/**************************************************************/
+/**\name	FLAT THETA LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Flat_0 Description - Reg Addr --> 0x67, Bit --> 0...5 */
+#define SMI130_USER_INTR_FLAT_0_INTR_FLAT_THETA__POS               (0)
+#define SMI130_USER_INTR_FLAT_0_INTR_FLAT_THETA__LEN               (6)
+#define SMI130_USER_INTR_FLAT_0_INTR_FLAT_THETA__MSK               (0x3F)
+#define SMI130_USER_INTR_FLAT_0_INTR_FLAT_THETA__REG  \
+		(SMI130_USER_INTR_FLAT_0_ADDR)
+/**************************************************************/
+/**\name	FLAT HYSTERESIS LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Flat_1 Description - Reg Addr --> (0x68), Bit --> 0...3 */
+#define SMI130_USER_INTR_FLAT_1_INTR_FLAT_HYST__POS		(0)
+#define SMI130_USER_INTR_FLAT_1_INTR_FLAT_HYST__LEN		(4)
+#define SMI130_USER_INTR_FLAT_1_INTR_FLAT_HYST__MSK		(0x0F)
+#define SMI130_USER_INTR_FLAT_1_INTR_FLAT_HYST__REG	 \
+(SMI130_USER_INTR_FLAT_1_ADDR)
+/**************************************************************/
+/**\name	FLAT HOLD LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Int_Flat_1 Description - Reg Addr --> (0x68), Bit --> 4...5 */
+#define SMI130_USER_INTR_FLAT_1_INTR_FLAT_HOLD__POS                (4)
+#define SMI130_USER_INTR_FLAT_1_INTR_FLAT_HOLD__LEN                (2)
+#define SMI130_USER_INTR_FLAT_1_INTR_FLAT_HOLD__MSK                (0x30)
+#define SMI130_USER_INTR_FLAT_1_INTR_FLAT_HOLD__REG  \
+(SMI130_USER_INTR_FLAT_1_ADDR)
+/**************************************************************/
+/**\name	FOC ACCEL XYZ LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Foc_Conf Description - Reg Addr --> (0x69), Bit --> 0...1 */
+#define SMI130_USER_FOC_ACCEL_Z__POS               (0)
+#define SMI130_USER_FOC_ACCEL_Z__LEN               (2)
+#define SMI130_USER_FOC_ACCEL_Z__MSK               (0x03)
+#define SMI130_USER_FOC_ACCEL_Z__REG               (SMI130_USER_FOC_CONFIG_ADDR)
+
+/* Foc_Conf Description - Reg Addr --> (0x69), Bit --> 2...3 */
+#define SMI130_USER_FOC_ACCEL_Y__POS               (2)
+#define SMI130_USER_FOC_ACCEL_Y__LEN               (2)
+#define SMI130_USER_FOC_ACCEL_Y__MSK               (0x0C)
+#define SMI130_USER_FOC_ACCEL_Y__REG               (SMI130_USER_FOC_CONFIG_ADDR)
+
+/* Foc_Conf Description - Reg Addr --> (0x69), Bit --> 4...5 */
+#define SMI130_USER_FOC_ACCEL_X__POS               (4)
+#define SMI130_USER_FOC_ACCEL_X__LEN               (2)
+#define SMI130_USER_FOC_ACCEL_X__MSK               (0x30)
+#define SMI130_USER_FOC_ACCEL_X__REG               (SMI130_USER_FOC_CONFIG_ADDR)
+/**************************************************************/
+/**\name	FOC GYRO LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Foc_Conf Description - Reg Addr --> (0x69), Bit --> 6 */
+#define SMI130_USER_FOC_GYRO_ENABLE__POS               (6)
+#define SMI130_USER_FOC_GYRO_ENABLE__LEN               (1)
+#define SMI130_USER_FOC_GYRO_ENABLE__MSK               (0x40)
+#define SMI130_USER_FOC_GYRO_ENABLE__REG               \
+(SMI130_USER_FOC_CONFIG_ADDR)
+/**************************************************************/
+/**\name	NVM PROGRAM LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* CONF Description - Reg Addr --> (0x6A), Bit --> 1 */
+#define SMI130_USER_CONFIG_NVM_PROG_ENABLE__POS               (1)
+#define SMI130_USER_CONFIG_NVM_PROG_ENABLE__LEN               (1)
+#define SMI130_USER_CONFIG_NVM_PROG_ENABLE__MSK               (0x02)
+#define SMI130_USER_CONFIG_NVM_PROG_ENABLE__REG               \
+(SMI130_USER_CONFIG_ADDR)
+
+/*IF_CONF Description - Reg Addr --> (0x6B), Bit --> 0 */
+
+#define SMI130_USER_IF_CONFIG_SPI3__POS               (0)
+#define SMI130_USER_IF_CONFIG_SPI3__LEN               (1)
+#define SMI130_USER_IF_CONFIG_SPI3__MSK               (0x01)
+#define SMI130_USER_IF_CONFIG_SPI3__REG               \
+(SMI130_USER_IF_CONFIG_ADDR)
+
+/*IF_CONF Description - Reg Addr --> (0x6B), Bit --> 5..4 */
+#define SMI130_USER_IF_CONFIG_IF_MODE__POS               (4)
+#define SMI130_USER_IF_CONFIG_IF_MODE__LEN               (2)
+#define SMI130_USER_IF_CONFIG_IF_MODE__MSK               (0x30)
+#define SMI130_USER_IF_CONFIG_IF_MODE__REG		\
+(SMI130_USER_IF_CONFIG_ADDR)
+/**************************************************************/
+/**\name	GYRO SLEEP CONFIGURATION LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Pmu_Trigger Description - Reg Addr --> 0x6c, Bit --> 0...2 */
+#define SMI130_USER_GYRO_SLEEP_TRIGGER__POS               (0)
+#define SMI130_USER_GYRO_SLEEP_TRIGGER__LEN               (3)
+#define SMI130_USER_GYRO_SLEEP_TRIGGER__MSK               (0x07)
+#define SMI130_USER_GYRO_SLEEP_TRIGGER__REG	(SMI130_USER_PMU_TRIGGER_ADDR)
+
+/* Pmu_Trigger Description - Reg Addr --> 0x6c, Bit --> 3...4 */
+#define SMI130_USER_GYRO_WAKEUP_TRIGGER__POS               (3)
+#define SMI130_USER_GYRO_WAKEUP_TRIGGER__LEN               (2)
+#define SMI130_USER_GYRO_WAKEUP_TRIGGER__MSK               (0x18)
+#define SMI130_USER_GYRO_WAKEUP_TRIGGER__REG	(SMI130_USER_PMU_TRIGGER_ADDR)
+
+/* Pmu_Trigger Description - Reg Addr --> 0x6c, Bit --> 5 */
+#define SMI130_USER_GYRO_SLEEP_STATE__POS               (5)
+#define SMI130_USER_GYRO_SLEEP_STATE__LEN               (1)
+#define SMI130_USER_GYRO_SLEEP_STATE__MSK               (0x20)
+#define SMI130_USER_GYRO_SLEEP_STATE__REG	(SMI130_USER_PMU_TRIGGER_ADDR)
+
+/* Pmu_Trigger Description - Reg Addr --> 0x6c, Bit --> 6 */
+#define SMI130_USER_GYRO_WAKEUP_INTR__POS               (6)
+#define SMI130_USER_GYRO_WAKEUP_INTR__LEN               (1)
+#define SMI130_USER_GYRO_WAKEUP_INTR__MSK               (0x40)
+#define SMI130_USER_GYRO_WAKEUP_INTR__REG	(SMI130_USER_PMU_TRIGGER_ADDR)
+/**************************************************************/
+/**\name	ACCEL SELF TEST LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Self_Test Description - Reg Addr --> 0x6d, Bit --> 0...1 */
+#define SMI130_USER_ACCEL_SELFTEST_AXIS__POS               (0)
+#define SMI130_USER_ACCEL_SELFTEST_AXIS__LEN               (2)
+#define SMI130_USER_ACCEL_SELFTEST_AXIS__MSK               (0x03)
+#define SMI130_USER_ACCEL_SELFTEST_AXIS__REG	(SMI130_USER_SELF_TEST_ADDR)
+
+/* Self_Test Description - Reg Addr --> 0x6d, Bit --> 2 */
+#define SMI130_USER_ACCEL_SELFTEST_SIGN__POS               (2)
+#define SMI130_USER_ACCEL_SELFTEST_SIGN__LEN               (1)
+#define SMI130_USER_ACCEL_SELFTEST_SIGN__MSK               (0x04)
+#define SMI130_USER_ACCEL_SELFTEST_SIGN__REG	(SMI130_USER_SELF_TEST_ADDR)
+
+/* Self_Test Description - Reg Addr --> 0x6d, Bit --> 3 */
+#define SMI130_USER_SELFTEST_AMP__POS               (3)
+#define SMI130_USER_SELFTEST_AMP__LEN               (1)
+#define SMI130_USER_SELFTEST_AMP__MSK               (0x08)
+#define SMI130_USER_SELFTEST_AMP__REG		(SMI130_USER_SELF_TEST_ADDR)
+/**************************************************************/
+/**\name	GYRO SELF TEST LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Self_Test Description - Reg Addr --> 0x6d, Bit --> 4 */
+#define SMI130_USER_GYRO_SELFTEST_START__POS               (4)
+#define SMI130_USER_GYRO_SELFTEST_START__LEN               (1)
+#define SMI130_USER_GYRO_SELFTEST_START__MSK               (0x10)
+#define SMI130_USER_GYRO_SELFTEST_START__REG		    \
+(SMI130_USER_SELF_TEST_ADDR)
+/**************************************************************/
+/**\name	NV_CONFIG LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* NV_CONF Description - Reg Addr --> (0x70), Bit --> 0 */
+#define SMI130_USER_NV_CONFIG_SPI_ENABLE__POS               (0)
+#define SMI130_USER_NV_CONFIG_SPI_ENABLE__LEN               (1)
+#define SMI130_USER_NV_CONFIG_SPI_ENABLE__MSK               (0x01)
+#define SMI130_USER_NV_CONFIG_SPI_ENABLE__REG	 (SMI130_USER_NV_CONFIG_ADDR)
+
+/*IF_CONF Description - Reg Addr --> (0x70), Bit --> 1 */
+#define SMI130_USER_IF_CONFIG_I2C_WDT_SELECT__POS               (1)
+#define SMI130_USER_IF_CONFIG_I2C_WDT_SELECT__LEN               (1)
+#define SMI130_USER_IF_CONFIG_I2C_WDT_SELECT__MSK               (0x02)
+#define SMI130_USER_IF_CONFIG_I2C_WDT_SELECT__REG		\
+(SMI130_USER_NV_CONFIG_ADDR)
+
+/*IF_CONF Description - Reg Addr --> (0x70), Bit --> 2 */
+#define SMI130_USER_IF_CONFIG_I2C_WDT_ENABLE__POS               (2)
+#define SMI130_USER_IF_CONFIG_I2C_WDT_ENABLE__LEN               (1)
+#define SMI130_USER_IF_CONFIG_I2C_WDT_ENABLE__MSK               (0x04)
+#define SMI130_USER_IF_CONFIG_I2C_WDT_ENABLE__REG		\
+(SMI130_USER_NV_CONFIG_ADDR)
+
+/* NV_CONF Description - Reg Addr --> (0x70), Bit --> 3 */
+#define SMI130_USER_NV_CONFIG_SPARE0__POS               (3)
+#define SMI130_USER_NV_CONFIG_SPARE0__LEN               (1)
+#define SMI130_USER_NV_CONFIG_SPARE0__MSK               (0x08)
+#define SMI130_USER_NV_CONFIG_SPARE0__REG	(SMI130_USER_NV_CONFIG_ADDR)
+
+/* NV_CONF Description - Reg Addr --> (0x70), Bit --> 4...7 */
+#define SMI130_USER_NV_CONFIG_NVM_COUNTER__POS               (4)
+#define SMI130_USER_NV_CONFIG_NVM_COUNTER__LEN               (4)
+#define SMI130_USER_NV_CONFIG_NVM_COUNTER__MSK               (0xF0)
+#define SMI130_USER_NV_CONFIG_NVM_COUNTER__REG	(SMI130_USER_NV_CONFIG_ADDR)
+/**************************************************************/
+/**\name	ACCEL MANUAL OFFSET LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Offset_0 Description - Reg Addr --> (0x71), Bit --> 0...7 */
+#define SMI130_USER_OFFSET_0_ACCEL_OFF_X__POS               (0)
+#define SMI130_USER_OFFSET_0_ACCEL_OFF_X__LEN               (8)
+#define SMI130_USER_OFFSET_0_ACCEL_OFF_X__MSK               (0xFF)
+#define SMI130_USER_OFFSET_0_ACCEL_OFF_X__REG	(SMI130_USER_OFFSET_0_ADDR)
+
+/* Offset_1 Description - Reg Addr --> 0x72, Bit --> 0...7 */
+#define SMI130_USER_OFFSET_1_ACCEL_OFF_Y__POS               (0)
+#define SMI130_USER_OFFSET_1_ACCEL_OFF_Y__LEN               (8)
+#define SMI130_USER_OFFSET_1_ACCEL_OFF_Y__MSK               (0xFF)
+#define SMI130_USER_OFFSET_1_ACCEL_OFF_Y__REG	(SMI130_USER_OFFSET_1_ADDR)
+
+/* Offset_2 Description - Reg Addr --> 0x73, Bit --> 0...7 */
+#define SMI130_USER_OFFSET_2_ACCEL_OFF_Z__POS               (0)
+#define SMI130_USER_OFFSET_2_ACCEL_OFF_Z__LEN               (8)
+#define SMI130_USER_OFFSET_2_ACCEL_OFF_Z__MSK               (0xFF)
+#define SMI130_USER_OFFSET_2_ACCEL_OFF_Z__REG	(SMI130_USER_OFFSET_2_ADDR)
+/**************************************************************/
+/**\name	GYRO MANUAL OFFSET LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Offset_3 Description - Reg Addr --> 0x74, Bit --> 0...7 */
+#define SMI130_USER_OFFSET_3_GYRO_OFF_X__POS               (0)
+#define SMI130_USER_OFFSET_3_GYRO_OFF_X__LEN               (8)
+#define SMI130_USER_OFFSET_3_GYRO_OFF_X__MSK               (0xFF)
+#define SMI130_USER_OFFSET_3_GYRO_OFF_X__REG	(SMI130_USER_OFFSET_3_ADDR)
+
+/* Offset_4 Description - Reg Addr --> 0x75, Bit --> 0...7 */
+#define SMI130_USER_OFFSET_4_GYRO_OFF_Y__POS               (0)
+#define SMI130_USER_OFFSET_4_GYRO_OFF_Y__LEN               (8)
+#define SMI130_USER_OFFSET_4_GYRO_OFF_Y__MSK               (0xFF)
+#define SMI130_USER_OFFSET_4_GYRO_OFF_Y__REG	(SMI130_USER_OFFSET_4_ADDR)
+
+/* Offset_5 Description - Reg Addr --> 0x76, Bit --> 0...7 */
+#define SMI130_USER_OFFSET_5_GYRO_OFF_Z__POS               (0)
+#define SMI130_USER_OFFSET_5_GYRO_OFF_Z__LEN               (8)
+#define SMI130_USER_OFFSET_5_GYRO_OFF_Z__MSK               (0xFF)
+#define SMI130_USER_OFFSET_5_GYRO_OFF_Z__REG	(SMI130_USER_OFFSET_5_ADDR)
+
+
+/* Offset_6 Description - Reg Addr --> 0x77, Bit --> 0..1 */
+#define SMI130_USER_OFFSET_6_GYRO_OFF_X__POS               (0)
+#define SMI130_USER_OFFSET_6_GYRO_OFF_X__LEN               (2)
+#define SMI130_USER_OFFSET_6_GYRO_OFF_X__MSK               (0x03)
+#define SMI130_USER_OFFSET_6_GYRO_OFF_X__REG	(SMI130_USER_OFFSET_6_ADDR)
+
+/* Offset_6 Description - Reg Addr --> 0x77, Bit --> 2...3 */
+#define SMI130_USER_OFFSET_6_GYRO_OFF_Y__POS               (2)
+#define SMI130_USER_OFFSET_6_GYRO_OFF_Y__LEN               (2)
+#define SMI130_USER_OFFSET_6_GYRO_OFF_Y__MSK               (0x0C)
+#define SMI130_USER_OFFSET_6_GYRO_OFF_Y__REG	(SMI130_USER_OFFSET_6_ADDR)
+
+/* Offset_6 Description - Reg Addr --> 0x77, Bit --> 4...5 */
+#define SMI130_USER_OFFSET_6_GYRO_OFF_Z__POS               (4)
+#define SMI130_USER_OFFSET_6_GYRO_OFF_Z__LEN               (2)
+#define SMI130_USER_OFFSET_6_GYRO_OFF_Z__MSK               (0x30)
+#define SMI130_USER_OFFSET_6_GYRO_OFF_Z__REG	 (SMI130_USER_OFFSET_6_ADDR)
+/**************************************************************/
+/**\name	ACCEL OFFSET  ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Offset_6 Description - Reg Addr --> 0x77, Bit --> 6 */
+#define SMI130_USER_OFFSET_6_ACCEL_OFF_ENABLE__POS               (6)
+#define SMI130_USER_OFFSET_6_ACCEL_OFF_ENABLE__LEN               (1)
+#define SMI130_USER_OFFSET_6_ACCEL_OFF_ENABLE__MSK               (0x40)
+#define SMI130_USER_OFFSET_6_ACCEL_OFF_ENABLE__REG	 \
+(SMI130_USER_OFFSET_6_ADDR)
+/**************************************************************/
+/**\name	GYRO OFFSET  ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Offset_6 Description - Reg Addr --> 0x77, Bit -->  7 */
+#define SMI130_USER_OFFSET_6_GYRO_OFF_EN__POS               (7)
+#define SMI130_USER_OFFSET_6_GYRO_OFF_EN__LEN               (1)
+#define SMI130_USER_OFFSET_6_GYRO_OFF_EN__MSK               (0x80)
+#define SMI130_USER_OFFSET_6_GYRO_OFF_EN__REG	 (SMI130_USER_OFFSET_6_ADDR)
+/**************************************************************/
+/**\name	STEP COUNTER LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* STEP_CNT_0  Description - Reg Addr --> 0x78, Bit -->  0 to 7 */
+#define SMI130_USER_STEP_COUNT_LSB__POS               (0)
+#define SMI130_USER_STEP_COUNT_LSB__LEN               (7)
+#define SMI130_USER_STEP_COUNT_LSB__MSK               (0xFF)
+#define SMI130_USER_STEP_COUNT_LSB__REG	 (SMI130_USER_STEP_COUNT_0_ADDR)
+
+/* STEP_CNT_1  Description - Reg Addr --> 0x79, Bit -->  0 to 7 */
+#define SMI130_USER_STEP_COUNT_MSB__POS               (0)
+#define SMI130_USER_STEP_COUNT_MSB__LEN               (7)
+#define SMI130_USER_STEP_COUNT_MSB__MSK               (0xFF)
+#define SMI130_USER_STEP_COUNT_MSB__REG	 (SMI130_USER_STEP_COUNT_1_ADDR)
+/**************************************************************/
+/**\name	STEP COUNTER CONFIGURATION LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* STEP_CONFIG_0  Description - Reg Addr --> 0x7A, Bit -->  0 to 7 */
+#define SMI130_USER_STEP_CONFIG_ZERO__POS               (0)
+#define SMI130_USER_STEP_CONFIG_ZERO__LEN               (7)
+#define SMI130_USER_STEP_CONFIG_ZERO__MSK               (0xFF)
+#define SMI130_USER_STEP_CONFIG_ZERO__REG	 \
+(SMI130_USER_STEP_CONFIG_0_ADDR)
+
+
+/* STEP_CONFIG_1  Description - Reg Addr --> 0x7B, Bit -->  0 to 2 and
+4 to 7 */
+#define SMI130_USER_STEP_CONFIG_ONE_CNF1__POS               (0)
+#define SMI130_USER_STEP_CONFIG_ONE_CNF1__LEN               (3)
+#define SMI130_USER_STEP_CONFIG_ONE_CNF1__MSK               (0x07)
+#define SMI130_USER_STEP_CONFIG_ONE_CNF1__REG	 \
+(SMI130_USER_STEP_CONFIG_1_ADDR)
+
+#define SMI130_USER_STEP_CONFIG_ONE_CNF2__POS               (4)
+#define SMI130_USER_STEP_CONFIG_ONE_CNF2__LEN               (4)
+#define SMI130_USER_STEP_CONFIG_ONE_CNF2__MSK               (0xF0)
+#define SMI130_USER_STEP_CONFIG_ONE_CNF2__REG	 \
+(SMI130_USER_STEP_CONFIG_1_ADDR)
+/**************************************************************/
+/**\name	STEP COUNTER ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* STEP_CONFIG_1  Description - Reg Addr --> 0x7B, Bit -->  0 to 2 */
+#define SMI130_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE__POS		(3)
+#define SMI130_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE__LEN		(1)
+#define SMI130_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE__MSK		(0x08)
+#define SMI130_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE__REG	\
+(SMI130_USER_STEP_CONFIG_1_ADDR)
+
+/* USER REGISTERS DEFINITION END */
+/**************************************************************************/
+/* CMD REGISTERS DEFINITION START */
+/**************************************************************/
+/**\name	COMMAND REGISTER LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Command description address - Reg Addr --> 0x7E, Bit -->  0....7 */
+#define SMI130_CMD_COMMANDS__POS              (0)
+#define SMI130_CMD_COMMANDS__LEN              (8)
+#define SMI130_CMD_COMMANDS__MSK              (0xFF)
+#define SMI130_CMD_COMMANDS__REG	 (SMI130_CMD_COMMANDS_ADDR)
+/**************************************************************/
+/**\name	PAGE ENABLE LENGTH, POSITION AND MASK*/
+/**************************************************************/
+/* Target page address - Reg Addr --> 0x7F, Bit -->  4....5 */
+#define SMI130_CMD_TARGET_PAGE__POS           (4)
+#define SMI130_CMD_TARGET_PAGE__LEN           (2)
+#define SMI130_CMD_TARGET_PAGE__MSK           (0x30)
+#define SMI130_CMD_TARGET_PAGE__REG	 (SMI130_CMD_EXT_MODE_ADDR)
+
+/* Target page address - Reg Addr --> 0x7F, Bit -->  4....5 */
+#define SMI130_CMD_PAGING_EN__POS           (7)
+#define SMI130_CMD_PAGING_EN__LEN           (1)
+#define SMI130_CMD_PAGING_EN__MSK           (0x80)
+#define SMI130_CMD_PAGING_EN__REG		(SMI130_CMD_EXT_MODE_ADDR)
+
+/* Target page address - Reg Addr --> 0x7F, Bit -->  4....5 */
+#define SMI130_COM_C_TRIM_FIVE__POS           (0)
+#define SMI130_COM_C_TRIM_FIVE__LEN           (8)
+#define SMI130_COM_C_TRIM_FIVE__MSK           (0xFF)
+#define SMI130_COM_C_TRIM_FIVE__REG		(SMI130_COM_C_TRIM_FIVE_ADDR)
+
+/**************************************************************************/
+/* CMD REGISTERS DEFINITION END */
+
+/**************************************************/
+/**\name	FIFO FRAME COUNT DEFINITION           */
+/*************************************************/
+#define FIFO_FRAME				(1024)
+#define FIFO_CONFIG_CHECK1		(0x00)
+#define FIFO_CONFIG_CHECK2		(0x80)
+/**************************************************/
+/**\name	MAG SENSOR SELECT          */
+/*************************************************/
+#define BST_BMM		(0)
+#define BST_AKM		(1)
+#define SMI130_YAS537_I2C_ADDRESS	(0x2E)
+/**************************************************/
+/**\name	ACCEL RANGE          */
+/*************************************************/
+#define SMI130_ACCEL_RANGE_2G           (0X03)
+#define SMI130_ACCEL_RANGE_4G           (0X05)
+#define SMI130_ACCEL_RANGE_8G           (0X08)
+#define SMI130_ACCEL_RANGE_16G          (0X0C)
+/**************************************************/
+/**\name	ACCEL ODR          */
+/*************************************************/
+#define SMI130_ACCEL_OUTPUT_DATA_RATE_RESERVED       (0x00)
+#define SMI130_ACCEL_OUTPUT_DATA_RATE_0_78HZ         (0x01)
+#define SMI130_ACCEL_OUTPUT_DATA_RATE_1_56HZ         (0x02)
+#define SMI130_ACCEL_OUTPUT_DATA_RATE_3_12HZ         (0x03)
+#define SMI130_ACCEL_OUTPUT_DATA_RATE_6_25HZ         (0x04)
+#define SMI130_ACCEL_OUTPUT_DATA_RATE_12_5HZ         (0x05)
+#define SMI130_ACCEL_OUTPUT_DATA_RATE_25HZ           (0x06)
+#define SMI130_ACCEL_OUTPUT_DATA_RATE_50HZ           (0x07)
+#define SMI130_ACCEL_OUTPUT_DATA_RATE_100HZ          (0x08)
+#define SMI130_ACCEL_OUTPUT_DATA_RATE_200HZ          (0x09)
+#define SMI130_ACCEL_OUTPUT_DATA_RATE_400HZ          (0x0A)
+#define SMI130_ACCEL_OUTPUT_DATA_RATE_800HZ          (0x0B)
+#define SMI130_ACCEL_OUTPUT_DATA_RATE_1600HZ         (0x0C)
+#define SMI130_ACCEL_OUTPUT_DATA_RATE_RESERVED0      (0x0D)
+#define SMI130_ACCEL_OUTPUT_DATA_RATE_RESERVED1      (0x0E)
+#define SMI130_ACCEL_OUTPUT_DATA_RATE_RESERVED2      (0x0F)
+/**************************************************/
+/**\name	ACCEL BANDWIDTH PARAMETER         */
+/*************************************************/
+#define SMI130_ACCEL_OSR4_AVG1			(0x00)
+#define SMI130_ACCEL_OSR2_AVG2			(0x01)
+#define SMI130_ACCEL_NORMAL_AVG4		(0x02)
+#define SMI130_ACCEL_CIC_AVG8			(0x03)
+#define SMI130_ACCEL_RES_AVG16			(0x04)
+#define SMI130_ACCEL_RES_AVG32			(0x05)
+#define SMI130_ACCEL_RES_AVG64			(0x06)
+#define SMI130_ACCEL_RES_AVG128			(0x07)
+/**************************************************/
+/**\name	GYRO ODR         */
+/*************************************************/
+#define SMI130_GYRO_OUTPUT_DATA_RATE_RESERVED		(0x00)
+#define SMI130_GYRO_OUTPUT_DATA_RATE_25HZ			(0x06)
+#define SMI130_GYRO_OUTPUT_DATA_RATE_50HZ			(0x07)
+#define SMI130_GYRO_OUTPUT_DATA_RATE_100HZ			(0x08)
+#define SMI130_GYRO_OUTPUT_DATA_RATE_200HZ			(0x09)
+#define SMI130_GYRO_OUTPUT_DATA_RATE_400HZ			(0x0A)
+#define SMI130_GYRO_OUTPUT_DATA_RATE_800HZ			(0x0B)
+#define SMI130_GYRO_OUTPUT_DATA_RATE_1600HZ			(0x0C)
+#define SMI130_GYRO_OUTPUT_DATA_RATE_3200HZ			(0x0D)
+/**************************************************/
+/**\name	GYRO BANDWIDTH PARAMETER         */
+/*************************************************/
+#define SMI130_GYRO_OSR4_MODE		(0x00)
+#define SMI130_GYRO_OSR2_MODE		(0x01)
+#define SMI130_GYRO_NORMAL_MODE		(0x02)
+#define SMI130_GYRO_CIC_MODE		(0x03)
+/**************************************************/
+/**\name	GYROSCOPE RANGE PARAMETER         */
+/*************************************************/
+#define SMI130_GYRO_RANGE_2000_DEG_SEC	(0x00)
+#define SMI130_GYRO_RANGE_1000_DEG_SEC	(0x01)
+#define SMI130_GYRO_RANGE_500_DEG_SEC	(0x02)
+#define SMI130_GYRO_RANGE_250_DEG_SEC	(0x03)
+#define SMI130_GYRO_RANGE_125_DEG_SEC	(0x04)
+/**************************************************/
+/**\name	MAG ODR         */
+/*************************************************/
+#define SMI130_MAG_OUTPUT_DATA_RATE_RESERVED       (0x00)
+#define SMI130_MAG_OUTPUT_DATA_RATE_0_78HZ         (0x01)
+#define SMI130_MAG_OUTPUT_DATA_RATE_1_56HZ         (0x02)
+#define SMI130_MAG_OUTPUT_DATA_RATE_3_12HZ         (0x03)
+#define SMI130_MAG_OUTPUT_DATA_RATE_6_25HZ         (0x04)
+#define SMI130_MAG_OUTPUT_DATA_RATE_12_5HZ         (0x05)
+#define SMI130_MAG_OUTPUT_DATA_RATE_25HZ           (0x06)
+#define SMI130_MAG_OUTPUT_DATA_RATE_50HZ           (0x07)
+#define SMI130_MAG_OUTPUT_DATA_RATE_100HZ          (0x08)
+#define SMI130_MAG_OUTPUT_DATA_RATE_200HZ          (0x09)
+#define SMI130_MAG_OUTPUT_DATA_RATE_400HZ          (0x0A)
+#define SMI130_MAG_OUTPUT_DATA_RATE_800HZ          (0x0B)
+#define SMI130_MAG_OUTPUT_DATA_RATE_1600HZ         (0x0C)
+#define SMI130_MAG_OUTPUT_DATA_RATE_RESERVED0      (0x0D)
+#define SMI130_MAG_OUTPUT_DATA_RATE_RESERVED1      (0x0E)
+#define SMI130_MAG_OUTPUT_DATA_RATE_RESERVED2      (0x0F)
+
+/**************************************************/
+/**\name	ENABLE/DISABLE SELECTIONS        */
+/*************************************************/
+
+/* Enable accel and gyro offset */
+#define ACCEL_OFFSET_ENABLE		(0x01)
+#define GYRO_OFFSET_ENABLE		(0x01)
+
+/* command register definition */
+#define START_FOC_ACCEL_GYRO	(0X03)
+
+ /* INT ENABLE 1 */
+#define SMI130_ANY_MOTION_X_ENABLE       (0)
+#define SMI130_ANY_MOTION_Y_ENABLE       (1)
+#define SMI130_ANY_MOTION_Z_ENABLE       (2)
+#define SMI130_DOUBLE_TAP_ENABLE         (4)
+#define SMI130_SINGLE_TAP_ENABLE         (5)
+#define SMI130_ORIENT_ENABLE             (6)
+#define SMI130_FLAT_ENABLE               (7)
+
+/* INT ENABLE 1 */
+#define SMI130_HIGH_G_X_ENABLE       (0)
+#define SMI130_HIGH_G_Y_ENABLE       (1)
+#define SMI130_HIGH_G_Z_ENABLE       (2)
+#define SMI130_LOW_G_ENABLE          (3)
+#define SMI130_DATA_RDY_ENABLE       (4)
+#define SMI130_FIFO_FULL_ENABLE      (5)
+#define SMI130_FIFO_WM_ENABLE        (6)
+
+/* INT ENABLE 2 */
+#define  SMI130_NOMOTION_X_ENABLE	(0)
+#define  SMI130_NOMOTION_Y_ENABLE	(1)
+#define  SMI130_NOMOTION_Z_ENABLE	(2)
+#define  SMI130_STEP_DETECTOR_EN	(3)
+
+/* FOC axis selection for accel*/
+#define	FOC_X_AXIS		(0)
+#define	FOC_Y_AXIS		(1)
+#define	FOC_Z_AXIS		(2)
+
+/* IN OUT CONTROL */
+#define SMI130_INTR1_EDGE_CTRL			(0)
+#define SMI130_INTR2_EDGE_CTRL			(1)
+#define SMI130_INTR1_LEVEL				(0)
+#define SMI130_INTR2_LEVEL				(1)
+#define SMI130_INTR1_OUTPUT_TYPE		(0)
+#define SMI130_INTR2_OUTPUT_TYPE		(1)
+#define SMI130_INTR1_OUTPUT_ENABLE		(0)
+#define SMI130_INTR2_OUTPUT_ENABLE		(1)
+
+#define SMI130_INTR1_INPUT_ENABLE	(0)
+#define SMI130_INTR2_INPUT_ENABLE	(1)
+
+/*  INTERRUPT MAPS    */
+#define SMI130_INTR1_MAP_LOW_G			(0)
+#define SMI130_INTR2_MAP_LOW_G			(1)
+#define SMI130_INTR1_MAP_HIGH_G			(0)
+#define SMI130_INTR2_MAP_HIGH_G			(1)
+#define SMI130_INTR1_MAP_ANY_MOTION		(0)
+#define SMI130_INTR2_MAP_ANY_MOTION		(1)
+#define SMI130_INTR1_MAP_NOMO			(0)
+#define SMI130_INTR2_MAP_NOMO			(1)
+#define SMI130_INTR1_MAP_DOUBLE_TAP		(0)
+#define SMI130_INTR2_MAP_DOUBLE_TAP		(1)
+#define SMI130_INTR1_MAP_SINGLE_TAP		(0)
+#define SMI130_INTR2_MAP_SINGLE_TAP		(1)
+#define SMI130_INTR1_MAP_ORIENT			(0)
+#define SMI130_INTR2_MAP_ORIENT			(1)
+#define SMI130_INTR1_MAP_FLAT			(0)
+#define SMI130_INTR2_MAP_FLAT			(1)
+#define SMI130_INTR1_MAP_DATA_RDY		(0)
+#define SMI130_INTR2_MAP_DATA_RDY		(1)
+#define SMI130_INTR1_MAP_FIFO_WM		(0)
+#define SMI130_INTR2_MAP_FIFO_WM		(1)
+#define SMI130_INTR1_MAP_FIFO_FULL      (0)
+#define SMI130_INTR2_MAP_FIFO_FULL      (1)
+#define SMI130_INTR1_MAP_PMUTRIG        (0)
+#define SMI130_INTR2_MAP_PMUTRIG		(1)
+
+/* Interrupt mapping*/
+#define	SMI130_MAP_INTR1		(0)
+#define	SMI130_MAP_INTR2		(1)
+/**************************************************/
+/**\name	 TAP DURATION         */
+/*************************************************/
+#define SMI130_TAP_DURN_50MS     (0x00)
+#define SMI130_TAP_DURN_100MS    (0x01)
+#define SMI130_TAP_DURN_150MS    (0x02)
+#define SMI130_TAP_DURN_200MS    (0x03)
+#define SMI130_TAP_DURN_250MS    (0x04)
+#define SMI130_TAP_DURN_375MS    (0x05)
+#define SMI130_TAP_DURN_500MS    (0x06)
+#define SMI130_TAP_DURN_700MS    (0x07)
+/**************************************************/
+/**\name	TAP SHOCK         */
+/*************************************************/
+#define SMI130_TAP_SHOCK_50MS	(0x00)
+#define SMI130_TAP_SHOCK_75MS	(0x01)
+/**************************************************/
+/**\name	TAP QUIET        */
+/*************************************************/
+#define SMI130_TAP_QUIET_30MS	(0x00)
+#define SMI130_TAP_QUIET_20MS	(0x01)
+/**************************************************/
+/**\name	STEP DETECTION SELECTION MODES      */
+/*************************************************/
+#define	SMI130_STEP_NORMAL_MODE			(0)
+#define	SMI130_STEP_SENSITIVE_MODE		(1)
+#define	SMI130_STEP_ROBUST_MODE			(2)
+/**************************************************/
+/**\name	STEP CONFIGURATION SELECT MODE    */
+/*************************************************/
+#define	STEP_CONFIG_NORMAL		(0X315)
+#define	STEP_CONFIG_SENSITIVE	(0X2D)
+#define	STEP_CONFIG_ROBUST		(0X71D)
+/**************************************************/
+/**\name	BMM150 TRIM DATA DEFINITIONS      */
+/*************************************************/
+#define SMI130_MAG_DIG_X1                      (0x5D)
+#define SMI130_MAG_DIG_Y1                      (0x5E)
+#define SMI130_MAG_DIG_Z4_LSB                  (0x62)
+#define SMI130_MAG_DIG_Z4_MSB                  (0x63)
+#define SMI130_MAG_DIG_X2                      (0x64)
+#define SMI130_MAG_DIG_Y2                      (0x65)
+#define SMI130_MAG_DIG_Z2_LSB                  (0x68)
+#define SMI130_MAG_DIG_Z2_MSB                  (0x69)
+#define SMI130_MAG_DIG_Z1_LSB                  (0x6A)
+#define SMI130_MAG_DIG_Z1_MSB                  (0x6B)
+#define SMI130_MAG_DIG_XYZ1_LSB                (0x6C)
+#define SMI130_MAG_DIG_XYZ1_MSB                (0x6D)
+#define SMI130_MAG_DIG_Z3_LSB                  (0x6E)
+#define SMI130_MAG_DIG_Z3_MSB                  (0x6F)
+#define SMI130_MAG_DIG_XY2                     (0x70)
+#define SMI130_MAG_DIG_XY1                     (0x71)
+/**************************************************/
+/**\name	BMM150 PRE-SET MODE DEFINITIONS     */
+/*************************************************/
+#define SMI130_MAG_PRESETMODE_LOWPOWER                 (1)
+#define SMI130_MAG_PRESETMODE_REGULAR                  (2)
+#define SMI130_MAG_PRESETMODE_HIGHACCURACY             (3)
+#define SMI130_MAG_PRESETMODE_ENHANCED                 (4)
+/**************************************************/
+/**\name	BMM150 PRESET MODES - DATA RATES    */
+/*************************************************/
+#define SMI130_MAG_LOWPOWER_DR                       (0x02)
+#define SMI130_MAG_REGULAR_DR                        (0x02)
+#define SMI130_MAG_HIGHACCURACY_DR                   (0x2A)
+#define SMI130_MAG_ENHANCED_DR                       (0x02)
+/**************************************************/
+/**\name	BMM150 PRESET MODES - REPETITIONS-XY RATES */
+/*************************************************/
+#define SMI130_MAG_LOWPOWER_REPXY                    (1)
+#define SMI130_MAG_REGULAR_REPXY                     (4)
+#define SMI130_MAG_HIGHACCURACY_REPXY                (23)
+#define SMI130_MAG_ENHANCED_REPXY                    (7)
+/**************************************************/
+/**\name	BMM150 PRESET MODES - REPETITIONS-Z RATES */
+/*************************************************/
+#define SMI130_MAG_LOWPOWER_REPZ                     (2)
+#define SMI130_MAG_REGULAR_REPZ                      (14)
+#define SMI130_MAG_HIGHACCURACY_REPZ                 (82)
+#define SMI130_MAG_ENHANCED_REPZ                     (26)
+#define SMI130_MAG_NOAMRL_SWITCH_TIMES               (5)
+#define MAG_INTERFACE_PMU_ENABLE                     (1)
+#define MAG_INTERFACE_PMU_DISABLE                    (0)
+/**************************************************/
+/**\name	USED FOR MAG OVERFLOW CHECK FOR BMM150  */
+/*************************************************/
+#define SMI130_MAG_OVERFLOW_OUTPUT			((s16)-32768)
+#define SMI130_MAG_OVERFLOW_OUTPUT_S32		((s32)(-2147483647-1))
+#define SMI130_MAG_NEGATIVE_SATURATION_Z   ((s16)-32767)
+#define SMI130_MAG_POSITIVE_SATURATION_Z   ((u16)32767)
+#define SMI130_MAG_FLIP_OVERFLOW_ADCVAL		((s16)-4096)
+#define SMI130_MAG_HALL_OVERFLOW_ADCVAL		((s16)-16384)
+/**************************************************/
+/**\name	BMM150 REGISTER DEFINITION */
+/*************************************************/
+#define SMI130_BMM150_CHIP_ID           (0x40)
+#define SMI130_BMM150_POWE_CONTROL_REG	(0x4B)
+#define SMI130_BMM150_POWE_MODE_REG		(0x4C)
+#define SMI130_BMM150_DATA_REG			(0x42)
+#define SMI130_BMM150_XY_REP			(0x51)
+#define SMI130_BMM150_Z_REP				(0x52)
+/**************************************************/
+/**\name	AKM COMPENSATING DATA REGISTERS     */
+/*************************************************/
+#define SMI130_BST_AKM_ASAX		(0x60)
+#define SMI130_BST_AKM_ASAY		(0x61)
+#define SMI130_BST_AKM_ASAZ		(0x62)
+/**************************************************/
+/**\name	AKM POWER MODE SELECTION     */
+/*************************************************/
+#define AKM_POWER_DOWN_MODE			(0)
+#define AKM_SINGLE_MEAS_MODE		(1)
+#define FUSE_ROM_MODE				(2)
+/**************************************************/
+/**\name	SECONDARY_MAG POWER MODE SELECTION    */
+/*************************************************/
+#define SMI130_MAG_FORCE_MODE		(0)
+#define SMI130_MAG_SUSPEND_MODE		(1)
+/**************************************************/
+/**\name	MAG POWER MODE SELECTION    */
+/*************************************************/
+#define	FORCE_MODE		(0)
+#define	SUSPEND_MODE	(1)
+#define	NORMAL_MODE		(2)
+#define MAG_SUSPEND_MODE (1)
+/**************************************************/
+/**\name	FIFO CONFIGURATIONS    */
+/*************************************************/
+#define FIFO_HEADER_ENABLE			(0x01)
+#define FIFO_MAG_ENABLE				(0x01)
+#define FIFO_ACCEL_ENABLE			(0x01)
+#define FIFO_GYRO_ENABLE			(0x01)
+#define FIFO_TIME_ENABLE			(0x01)
+#define FIFO_STOPONFULL_ENABLE		(0x01)
+#define FIFO_WM_INTERRUPT_ENABLE	(0x01)
+#define	SMI130_FIFO_INDEX_LENGTH	(1)
+#define	SMI130_FIFO_TAG_INTR_MASK	(0xFC)
+
+/**************************************************/
+/**\name	ACCEL POWER MODE    */
+/*************************************************/
+#define ACCEL_MODE_NORMAL	(0x11)
+#define	ACCEL_LOWPOWER		(0X12)
+#define	ACCEL_SUSPEND		(0X10)
+/**************************************************/
+/**\name	GYRO POWER MODE    */
+/*************************************************/
+#define GYRO_MODE_SUSPEND		(0x14)
+#define GYRO_MODE_NORMAL		(0x15)
+#define GYRO_MODE_FASTSTARTUP	(0x17)
+/**************************************************/
+/**\name	MAG POWER MODE    */
+/*************************************************/
+#define MAG_MODE_SUSPEND	(0x18)
+#define MAG_MODE_NORMAL		(0x19)
+#define MAG_MODE_LOWPOWER	(0x1A)
+/**************************************************/
+/**\name	ENABLE/DISABLE BIT VALUES    */
+/*************************************************/
+#define SMI130_ENABLE	(0x01)
+#define SMI130_DISABLE	(0x00)
+/**************************************************/
+/**\name	INTERRUPT EDGE TRIGGER ENABLE    */
+/*************************************************/
+#define SMI130_EDGE		(0x01)
+#define SMI130_LEVEL	(0x00)
+/**************************************************/
+/**\name	INTERRUPT LEVEL ENABLE    */
+/*************************************************/
+#define SMI130_LEVEL_LOW		(0x00)
+#define SMI130_LEVEL_HIGH		(0x01)
+/**************************************************/
+/**\name	INTERRUPT OUTPUT ENABLE    */
+/*************************************************/
+#define SMI130_OPEN_DRAIN	(0x01)
+#define SMI130_PUSH_PULL	(0x00)
+
+/* interrupt output enable*/
+#define SMI130_INPUT	(0x01)
+#define SMI130_OUTPUT	(0x00)
+
+/**************************************************/
+/**\name	INTERRUPT TAP SOURCE ENABLE    */
+/*************************************************/
+#define FILTER_DATA		(0x00)
+#define UNFILTER_DATA	(0x01)
+/**************************************************/
+/**\name	SLOW MOTION/ NO MOTION SELECT   */
+/*************************************************/
+#define SLOW_MOTION		(0x00)
+#define NO_MOTION		(0x01)
+/**************************************************/
+/**\name	SIGNIFICANT MOTION SELECTION   */
+/*************************************************/
+#define ANY_MOTION			(0x00)
+#define SIGNIFICANT_MOTION	(0x01)
+/**************************************************/
+/**\name	LATCH DURATION   */
+/*************************************************/
+#define SMI130_LATCH_DUR_NONE				(0x00)
+#define SMI130_LATCH_DUR_312_5_MICRO_SEC	(0x01)
+#define SMI130_LATCH_DUR_625_MICRO_SEC		(0x02)
+#define SMI130_LATCH_DUR_1_25_MILLI_SEC		(0x03)
+#define SMI130_LATCH_DUR_2_5_MILLI_SEC		(0x04)
+#define SMI130_LATCH_DUR_5_MILLI_SEC		(0x05)
+#define SMI130_LATCH_DUR_10_MILLI_SEC		(0x06)
+#define SMI130_LATCH_DUR_20_MILLI_SEC		(0x07)
+#define SMI130_LATCH_DUR_40_MILLI_SEC		(0x08)
+#define SMI130_LATCH_DUR_80_MILLI_SEC		(0x09)
+#define SMI130_LATCH_DUR_160_MILLI_SEC		(0x0A)
+#define SMI130_LATCH_DUR_320_MILLI_SEC		(0x0B)
+#define SMI130_LATCH_DUR_640_MILLI_SEC		(0x0C)
+#define SMI130_LATCH_DUR_1_28_SEC			(0x0D)
+#define SMI130_LATCH_DUR_2_56_SEC			(0x0E)
+#define SMI130_LATCHED						(0x0F)
+/**************************************************/
+/**\name	GYRO OFFSET MASK DEFINITION   */
+/*************************************************/
+#define SMI130_GYRO_MANUAL_OFFSET_0_7	(0x00FF)
+#define SMI130_GYRO_MANUAL_OFFSET_8_9	(0x0300)
+/**************************************************/
+/**\name	STEP CONFIGURATION MASK DEFINITION   */
+/*************************************************/
+#define SMI130_STEP_CONFIG_0_7		(0x00FF)
+#define SMI130_STEP_CONFIG_8_10		(0x0700)
+#define SMI130_STEP_CONFIG_11_14	(0xF000)
+/**************************************************/
+/**\name	DEFINITION USED FOR DIFFERENT WRITE   */
+/*************************************************/
+#define	SMI130_WRITE_TARGET_PAGE0	(0x00)
+#define	SMI130_WRITE_TARGET_PAGE1	(0x01)
+#define	SMI130_WRITE_ENABLE_PAGE1	(0x01)
+#define	SMI130_MANUAL_DISABLE	    (0x00)
+#define	SMI130_MANUAL_ENABLE	    (0x01)
+#define	SMI130_YAS_DISABLE_RCOIL	(0x00)
+#define	SMI130_ENABLE_MAG_IF_MODE	(0x02)
+#define	SMI130_ENABLE_ANY_MOTION_INTR1	(0x04)
+#define	SMI130_ENABLE_ANY_MOTION_INTR2	(0x04)
+#define	SMI130_MAG_DATA_READ_REG        (0x04)
+#define SMI130_BMM_POWER_MODE_REG		(0x06)
+#define	SMI130_ENABLE_ANY_MOTION_AXIS	(0x07)
+#define	SMI130_ENABLE_LOW_G             (0x08)
+#define	SMI130_YAS532_ACQ_START         (0x11)
+#define	SMI130_YAS_DEVICE_ID_REG        (0x80)
+#define	SMI130_FIFO_GYRO_ENABLE         (0x80)
+#define	SMI130_SIG_MOTION_INTR_ENABLE   (0x01)
+#define	SMI130_STEP_DETECT_INTR_ENABLE  (0x01)
+#define	SMI130_LOW_G_INTR_STAT          (0x01)
+#define SMI130_PULL_UP_DATA             (0x30)
+#define SMI130_FIFO_M_G_A_ENABLE        (0xE0)
+#define SMI130_FIFO_M_G_ENABLE          (0xA0)
+#define SMI130_FIFO_M_A_ENABLE          (0x60)
+#define SMI130_FIFO_G_A_ENABLE          (0xC0)
+#define SMI130_FIFO_A_ENABLE            (0x40)
+#define SMI130_FIFO_M_ENABLE            (0x20)
+/**************************************************/
+/**\name	MAG INIT DEFINITION  */
+/*************************************************/
+#define SMI130_COMMAND_REG_ONE		(0x37)
+#define SMI130_COMMAND_REG_TWO		(0x9A)
+#define SMI130_COMMAND_REG_THREE	(0xC0)
+#define	RESET_STEP_COUNTER			(0xB2)
+/**************************************************/
+/**\name	BIT SLICE GET AND SET FUNCTIONS  */
+/*************************************************/
+#define SMI130_GET_BITSLICE(regvar, bitname)\
+		((regvar & bitname##__MSK) >> bitname##__POS)
+
+
+#define SMI130_SET_BITSLICE(regvar, bitname, val)\
+		((regvar & ~bitname##__MSK) | \
+		((val<<bitname##__POS)&bitname##__MSK))
+
+/**************************************************/
+/**\name	 FUNCTION DECLARATIONS  */
+/*************************************************/
+/**************************************************/
+/**\name	 FUNCTION FOR SMI130 INITIALIZE  */
+/*************************************************/
+/*!
+ *	@brief
+ *	This function is used for initialize
+ *	bus read and bus write functions
+ *	assign the chip id and device address
+ *	chip id is read in the register 0x00 bit from 0 to 7
+ *
+ *	@param smi130 : structure pointer
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *	@note
+ *	While changing the parameter of the smi130_t
+ *	consider the following point:
+ *	Changing the reference value of the parameter
+ *	will changes the local copy or local reference
+ *	make sure your changes will not
+ *	affect the reference value of the parameter
+ *	(Better case don't change the reference value of the parameter)
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_init(struct smi130_t *smi130);
+/**************************************************/
+/**\name	 FUNCTION FOR READ AND WRITE REGISTERS  */
+/*************************************************/
+/*!
+ * @brief
+ *	This API write the data to
+ *	the given register
+ *
+ *
+ *	@param v_addr_u8 -> Address of the register
+ *	@param v_data_u8 -> The data from the register
+ *	@param v_len_u8 -> no of bytes to read
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_write_reg(u8 v_addr_u8,
+u8 *v_data_u8, u8 v_len_u8);
+/*!
+ * @brief
+ *	This API reads the data from
+ *	the given register
+ *
+ *
+ *	@param v_addr_u8 -> Address of the register
+ *	@param v_data_u8 -> The data from the register
+ *	@param v_len_u8 -> no of bytes to read
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_read_reg(u8 v_addr_u8,
+u8 *v_data_u8, u8 v_len_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR ERROR CODES  */
+/*************************************************/
+/*!
+ *	@brief This API used to reads the fatal error
+ *	from the Register 0x02 bit 0
+ *	This flag will be reset only by power-on-reset and soft reset
+ *
+ *
+ *  @param v_fatal_err_u8 : The status of fatal error
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_fatal_err(u8
+*v_fatal_err_u8);
+/*!
+ *	@brief This API used to read the error code
+ *	from register 0x02 bit 1 to 4
+ *
+ *
+ *  @param v_err_code_u8 : The status of error codes
+ *	error_code  |    description
+ *  ------------|---------------
+ *	0x00        |no error
+ *	0x01        |ACC_CONF error (accel ODR and bandwidth not compatible)
+ *	0x02        |GYR_CONF error (Gyroscope ODR and bandwidth not compatible)
+ *	0x03        |Under sampling mode and interrupt uses pre filtered data
+ *	0x04        |reserved
+ *	0x05        |Selected trigger-readout offset in
+ *    -         |MAG_IF greater than selected ODR
+ *	0x06        |FIFO configuration error for header less mode
+ *	0x07        |Under sampling mode and pre filtered data as FIFO source
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_err_code(u8
+*v_error_code_u8);
+/*!
+ *	@brief This API Reads the i2c error code from the
+ *	Register 0x02 bit 5.
+ *	This error occurred in I2C master detected
+ *
+ *  @param v_i2c_err_code_u8 : The status of i2c fail error
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_i2c_fail_err(u8
+*v_i2c_error_code_u8);
+ /*!
+ *	@brief This API Reads the dropped command error
+ *	from the register 0x02 bit 6
+ *
+ *
+ *  @param v_drop_cmd_err_u8 : The status of drop command error
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_drop_cmd_err(u8
+*v_drop_cmd_err_u8);
+/*!
+ *	@brief This API reads the magnetometer data ready
+ *	interrupt not active.
+ *	It reads from the error register 0x0x2 bit 7
+ *
+ *
+ *
+ *
+ *  @param v_mag_data_rdy_err_u8 : The status of mag data ready interrupt
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_mag_dada_rdy_err(u8
+*v_mag_data_rdy_err_u8);
+/*!
+ *	@brief This API reads the error status
+ *	from the error register 0x02 bit 0 to 7
+ *
+ *  @param v_mag_data_rdy_err_u8 : The status of mag data ready interrupt
+ *  @param v_fatal_er_u8r : The status of fatal error
+ *  @param v_err_code_u8 : The status of error code
+ *  @param v_i2c_fail_err_u8 : The status of I2C fail error
+ *  @param v_drop_cmd_err_u8 : The status of drop command error
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_error_status(u8 *v_fatal_er_u8r,
+u8 *v_err_code_u8, u8 *v_i2c_fail_err_u8,
+u8 *v_drop_cmd_err_u8, u8 *v_mag_data_rdy_err_u8);
+/******************************************************************/
+/**\name	 FUNCTIONS FOR MAG,ACCEL AND GYRO POWER MODE STATUS  */
+/*****************************************************************/
+/*!
+ *	@brief This API reads the magnetometer power mode from
+ *	PMU status register 0x03 bit 0 and 1
+ *
+ *  @param v_mag_power_mode_stat_u8 : The value of mag power mode
+ *	mag_powermode    |   value
+ * ------------------|----------
+ *    SUSPEND        |   0x00
+ *    NORMAL         |   0x01
+ *   LOW POWER       |   0x02
+ *
+ *
+ * @note The power mode of mag set by the 0x7E command register
+ * @note using the function "smi130_set_command_register()"
+ *  value    |   mode
+ *  ---------|----------------
+ *   0x18    | MAG_MODE_SUSPEND
+ *   0x19    | MAG_MODE_NORMAL
+ *   0x1A    | MAG_MODE_LOWPOWER
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_mag_power_mode_stat(u8
+*v_mag_power_mode_stat_u8);
+/*!
+ *	@brief This API reads the gyroscope power mode from
+ *	PMU status register 0x03 bit 2 and 3
+ *
+ *  @param v_gyro_power_mode_stat_u8 :	The value of gyro power mode
+ *	gyro_powermode   |   value
+ * ------------------|----------
+ *    SUSPEND        |   0x00
+ *    NORMAL         |   0x01
+ *   FAST POWER UP   |   0x03
+ *
+ * @note The power mode of gyro set by the 0x7E command register
+ * @note using the function "smi130_set_command_register()"
+ *  value    |   mode
+ *  ---------|----------------
+ *   0x14    | GYRO_MODE_SUSPEND
+ *   0x15    | GYRO_MODE_NORMAL
+ *   0x17    | GYRO_MODE_FASTSTARTUP
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_gyro_power_mode_stat(u8
+*v_gyro_power_mode_stat_u8);
+/*!
+ *	@brief This API reads the accelerometer power mode from
+ *	PMU status register 0x03 bit 4 and 5
+ *
+ *
+ *  @param v_accel_power_mode_stat_u8 :	The value of accel power mode
+ *	accel_powermode  |   value
+ * ------------------|----------
+ *    SUSPEND        |   0x00
+ *    NORMAL         |   0x01
+ *  LOW POWER        |   0x03
+ *
+ * @note The power mode of accel set by the 0x7E command register
+ * @note using the function "smi130_set_command_register()"
+ *  value    |   mode
+ *  ---------|----------------
+ *   0x11    | ACCEL_MODE_NORMAL
+ *   0x12    | ACCEL_LOWPOWER
+ *   0x10    | ACCEL_SUSPEND
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_accel_power_mode_stat(u8
+*v_accel_power_mode_stat_u8);
+/*!
+ *	@brief This API switch mag interface to normal mode
+ *	and confirm whether the mode switching done successfully or not
+*
+ *	@return results of bus communication function and current MAG_PMU result
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_mag_interface_normal(void);
+/**************************************************/
+/**\name	 FUNCTION FOR Mag XYZ data read */
+/*************************************************/
+/*!
+ *	@brief This API reads magnetometer data X values
+ *	from the register 0x04 and 0x05
+ *	@brief The mag sensor data read form auxiliary mag
+ *
+ *  @param v_mag_x_s16 : The value of mag x
+ *  @param v_sensor_select_u8 : Mag selection value
+ *  value    |   sensor
+ *  ---------|----------------
+ *   0       | BMM150
+ *   1       | AKM09911 or AKM09912
+ *
+ *	@note For mag data output rate configuration use the following function
+ *	@note smi130_set_mag_output_data_rate()
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_read_mag_x(s16 *v_mag_x_s16,
+u8 v_sensor_select_u8);
+/*!
+ *	@brief This API reads magnetometer data Y values
+ *	from the register 0x06 and 0x07
+ *	@brief The mag sensor data read form auxiliary mag
+ *
+ *  @param v_mag_y_s16 : The value of mag y
+ *  @param v_sensor_select_u8 : Mag selection value
+ *  value    |   sensor
+ *  ---------|----------------
+ *   0       | BMM150
+ *   1       | AKM09911 or AKM09912
+ *
+ *	@note For mag data output rate configuration use the following function
+ *	@note smi130_set_mag_output_data_rate()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_read_mag_y(s16 *v_mag_y_s16,
+u8 v_sensor_select_u8);
+/*!
+ *	@brief This API reads magnetometer data Z values
+ *	from the register 0x08 and 0x09
+ *	@brief The mag sensor data read form auxiliary mag
+ *
+ *  @param v_mag_z_s16 : The value of mag z
+ *  @param v_sensor_select_u8 : Mag selection value
+ *  value    |   sensor
+ *  ---------|----------------
+ *   0       | BMM150
+ *   1       | AKM09911 or AKM09912
+ *
+ *	@note For mag data output rate configuration use the following function
+ *	@note smi130_set_mag_output_data_rate()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_read_mag_z(s16 *v_mag_z_s16,
+u8 v_sensor_select_u8);
+/*!
+ *	@brief This API reads magnetometer data RHALL values
+ *	from the register 0x0A and 0x0B
+ *
+ *
+ *  @param v_mag_r_s16 : The value of BMM150 r data
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_read_mag_r(
+s16 *v_mag_r_s16);
+/*!
+ *	@brief This API reads magnetometer data X,Y,Z values
+ *	from the register 0x04 to 0x09
+ *
+ *	@brief The mag sensor data read form auxiliary mag
+ *
+ *  @param mag : The value of mag xyz data
+ *  @param v_sensor_select_u8 : Mag selection value
+ *  value    |   sensor
+ *  ---------|----------------
+ *   0       | BMM150
+ *   1       | AKM09911 or AKM09912
+ *
+ *	@note For mag data output rate configuration use the following function
+ *	@note smi130_set_mag_output_data_rate()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_read_mag_xyz(
+struct smi130_mag_t *mag, u8 v_sensor_select_u8);
+ /*!*
+ *	@brief This API reads magnetometer data X,Y,Z,r
+ *	values from the register 0x04 to 0x0B
+ *
+ *	@brief The mag sensor data read form auxiliary mag
+ *
+ *  @param mag : The value of mag-BMM150 xyzr data
+ *
+ *	@note For mag data output rate configuration use the following function
+ *	@note smi130_set_mag_output_data_rate()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_read_mag_xyzr(
+struct smi130_mag_xyzr_t *mag);
+/**************************************************/
+/**\name	 FUNCTION FOR GYRO XYZ DATA READ  */
+/*************************************************/
+/*!
+ *	@brief This API reads gyro data X values
+ *	form the register 0x0C and 0x0D
+ *
+ *
+ *
+ *
+ *  @param v_gyro_x_s16 : The value of gyro x data
+ *
+ *	@note Gyro Configuration use the following function
+ *	@note smi130_set_gyro_output_data_rate()
+ *	@note smi130_set_gyro_bw()
+ *	@note smi130_set_gyro_range()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_read_gyro_x(
+s16 *v_gyro_x_s16);
+/*!
+ *	@brief This API reads gyro data Y values
+ *	form the register 0x0E and 0x0F
+ *
+ *
+ *
+ *
+ *  @param v_gyro_y_s16 : The value of gyro y data
+ *
+ *	@note Gyro Configuration use the following function
+ *	@note smi130_set_gyro_output_data_rate()
+ *	@note smi130_set_gyro_bw()
+ *	@note smi130_set_gyro_range()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error result of communication routines
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_read_gyro_y(
+s16 *v_gyro_y_s16);
+/*!
+ *	@brief This API reads gyro data Z values
+ *	form the register 0x10 and 0x11
+ *
+ *
+ *
+ *
+ *  @param v_gyro_z_s16 : The value of gyro z data
+ *
+ *	@note Gyro Configuration use the following function
+ *	@note smi130_set_gyro_output_data_rate()
+ *	@note smi130_set_gyro_bw()
+ *	@note smi130_set_gyro_range()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_read_gyro_z(
+s16 *v_gyro_z_s16);
+/*!
+ *	@brief This API reads gyro data X,Y,Z values
+ *	from the register 0x0C to 0x11
+ *
+ *
+ *
+ *
+ *  @param gyro : The value of gyro xyz
+ *
+ *	@note Gyro Configuration use the following function
+ *	@note smi130_set_gyro_output_data_rate()
+ *	@note smi130_set_gyro_bw()
+ *	@note smi130_set_gyro_range()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_read_gyro_xyz(
+struct smi130_gyro_t *gyro);
+/**************************************************/
+/**\name	 FUNCTION FOR ACCEL XYZ DATA READ  */
+/*************************************************/
+/*!
+ *	@brief This API reads accelerometer data X values
+ *	form the register 0x12 and 0x13
+ *
+ *
+ *
+ *
+ *  @param v_accel_x_s16 : The value of accel x
+ *
+ *	@note For accel configuration use the following functions
+ *	@note smi130_set_accel_output_data_rate()
+ *	@note smi130_set_accel_bw()
+ *	@note smi130_set_accel_under_sampling_parameter()
+ *	@note smi130_set_accel_range()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_read_accel_x(
+s16 *v_accel_x_s16);
+/*!
+ *	@brief This API reads accelerometer data Y values
+ *	form the register 0x14 and 0x15
+ *
+ *
+ *
+ *
+ *  @param v_accel_y_s16 : The value of accel y
+ *
+ *	@note For accel configuration use the following functions
+ *	@note smi130_set_accel_output_data_rate()
+ *	@note smi130_set_accel_bw()
+ *	@note smi130_set_accel_under_sampling_parameter()
+ *	@note smi130_set_accel_range()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_read_accel_y(
+s16 *v_accel_y_s16);
+/*!
+ *	@brief This API reads accelerometer data Z values
+ *	form the register 0x16 and 0x17
+ *
+ *
+ *
+ *
+ *  @param v_accel_z_s16 : The value of accel z
+ *
+ *	@note For accel configuration use the following functions
+ *	@note smi130_set_accel_output_data_rate()
+ *	@note smi130_set_accel_bw()
+ *	@note smi130_set_accel_under_sampling_parameter()
+ *	@note smi130_set_accel_range()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_read_accel_z(
+s16 *v_accel_z_s16);
+/*!
+ *	@brief This API reads accelerometer data X,Y,Z values
+ *	from the register 0x12 to 0x17
+ *
+ *
+ *
+ *
+ *  @param accel :The value of accel xyz
+ *
+ *	@note For accel configuration use the following functions
+ *	@note smi130_set_accel_output_data_rate()
+ *	@note smi130_set_accel_bw()
+ *	@note smi130_set_accel_under_sampling_parameter()
+ *	@note smi130_set_accel_range()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_read_accel_xyz(
+struct smi130_accel_t *accel);
+/**************************************************/
+/**\name	 FUNCTION FOR SENSOR TIME */
+/*************************************************/
+/*!
+ *	@brief This API reads sensor_time from the register
+ *	0x18 to 0x1A
+ *
+ *
+ *  @param v_sensor_time_u32 : The value of sensor time
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_sensor_time(
+u32 *v_sensor_time_u32);
+/**************************************************/
+/**\name	 FUNCTION FOR GYRO SLEF TEST  */
+/*************************************************/
+/*!
+ *	@brief This API reads the Gyroscope self test
+ *	status from the register 0x1B bit 1
+ *
+ *
+ *  @param v_gyro_selftest_u8 : The value of gyro self test status
+ *  value    |   status
+ *  ---------|----------------
+ *   0       | Gyroscope self test is running or failed
+ *   1       | Gyroscope self test completed successfully
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_gyro_selftest(u8
+*v_gyro_selftest_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR MANUAL INTERFACE  */
+/*************************************************/
+/*!
+ *	@brief This API reads the status of
+ *	mag manual interface operation form the register 0x1B bit 2
+ *
+ *
+ *
+ *  @param v_mag_manual_stat_u8 : The value of mag manual operation status
+ *  value    |   status
+ *  ---------|----------------
+ *   0       | Indicates no manual magnetometer
+ *   -       | interface operation is ongoing
+ *   1       | Indicates manual magnetometer
+ *   -       | interface operation is ongoing
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_mag_manual_operation_stat(u8
+*v_mag_manual_stat_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR FAST OFFSET READY  */
+/*************************************************/
+/*!
+ *	@brief This API reads the fast offset compensation
+ *	status form the register 0x1B bit 3
+ *
+ *
+ *  @param v_foc_rdy_u8 : The status of fast compensation
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_foc_rdy(u8
+*v_foc_rdy_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR NVM READY  */
+/*************************************************/
+/*!
+ * @brief This API Reads the nvm_rdy status from the
+ *	resister 0x1B bit 4
+ *
+ *
+ *  @param v_nvm_rdy_u8 : The value of NVM ready status
+ *  value    |   status
+ *  ---------|----------------
+ *   0       | NVM write operation in progress
+ *   1       | NVM is ready to accept a new write trigger
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_nvm_rdy(u8
+*v_nvm_rdy_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR DATA READY FOR MAG, GYRO, AND ACCEL */
+/*************************************************/
+/*!
+ *	@brief This API reads the status of mag data ready
+ *	from the register 0x1B bit 5
+ *	The status get reset when one mag data register is read out
+ *
+ *  @param v_data_rdy_u8 : The value of mag data ready status
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_data_rdy_mag(u8
+*v_data_rdy_u8);
+/*!
+ *	@brief This API reads the status of gyro data ready form the
+ *	register 0x1B bit 6
+ *	The status get reset when gyro data register read out
+ *
+ *
+ *	@param v_data_rdy_u8 :	The value of gyro data ready
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_gyro_data_rdy(u8
+*v_data_rdy_u8);
+/*!
+ *	@brief This API reads the status of accel data ready form the
+ *	register 0x1B bit 7
+ *	The status get reset when accel data register read out
+ *
+ *
+ *	@param v_data_rdy_u8 :	The value of accel data ready status
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_accel_data_rdy(u8
+*drdy_acc);
+/**************************************************/
+/**\name	 FUNCTION FOR STEP INTERRUPT STATUS  */
+/*************************************************/
+/*!
+ *	@brief This API reads the step detector interrupt status
+ *	from the register 0x1C bit 0
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the single tab interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt
+ *	signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_step_intr_u8 : The status of step detector interrupt
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat0_step_intr(u8
+*v_step_intr_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR SIGNIFICANT INTERRUPT STATUS  */
+/*************************************************/
+/*!
+ *	@brief This API reads the
+ *	significant motion interrupt status
+ *	from the register 0x1C bit 1
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the single tab interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt
+ *	signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *
+ *  @param v_significant_intr_u8 : The status of step
+ *	motion interrupt
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat0_significant_intr(u8
+*sigmot_intr);
+/**************************************************/
+/**\name	 FUNCTION FOR ANY MOTION INTERRUPT STATUS  */
+/*************************************************/
+ /*!
+ *	@brief This API reads the any motion interrupt status
+ *	from the register 0x1C bit 2
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the single tab interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt
+ *	signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *  @param v_any_motion_intr_u8 : The status of any-motion interrupt
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat0_any_motion_intr(u8
+*v_any_motion_intr_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR PMU TRIGGER INTERRUPT STATUS  */
+/*************************************************/
+/*!
+ *	@brief This API reads the power mode trigger interrupt status
+ *	from the register 0x1C bit 3
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the single tab interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt
+ *	signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *
+ *  @param v_pmu_trigger_intr_u8 : The status of power mode trigger interrupt
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat0_pmu_trigger_intr(u8
+*v_pmu_trigger_intr_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR DOUBLE TAB STATUS  */
+/*************************************************/
+/*!
+ *	@brief This API reads the double tab status
+ *	from the register 0x1C bit 4
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the single tab interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt
+ *	signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_double_tap_intr_u8 :The status of double tab interrupt
+ *
+ *	@note Double tap interrupt can be configured by the following functions
+ *	@note INTERRUPT MAPPING
+ *	@note smi130_set_intr_double_tap()
+ *	@note AXIS MAPPING
+ *	@note smi130_get_stat2_tap_first_x()
+ *	@note smi130_get_stat2_tap_first_y()
+ *	@note smi130_get_stat2_tap_first_z()
+ *	@note DURATION
+ *	@note smi130_set_intr_tap_durn()
+ *	@note THRESHOLD
+ *	@note smi130_set_intr_tap_thres()
+ *	@note TAP QUIET
+ *	@note smi130_set_intr_tap_quiet()
+ *	@note TAP SHOCK
+ *	@note smi130_set_intr_tap_shock()
+ *	@note TAP SOURCE
+ *	@note smi130_set_intr_tap_source()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat0_double_tap_intr(u8
+*v_double_tap_intr_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR SINGLE TAB STATUS  */
+/*************************************************/
+/*!
+ *	@brief This API reads the single tab status
+ *	from the register 0x1C bit 5
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the single tab interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt
+ *	signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_single_tap_intr_u8 :The status of single tap interrupt
+ *
+ *	@note Single tap interrupt can be configured by the following functions
+ *	@note INTERRUPT MAPPING
+ *	@note smi130_set_intr_single_tap()
+ *	@note AXIS MAPPING
+ *	@note smi130_get_stat2_tap_first_x()
+ *	@note smi130_get_stat2_tap_first_y()
+ *	@note smi130_get_stat2_tap_first_z()
+ *	@note DURATION
+ *	@note smi130_set_intr_tap_durn()
+ *	@note THRESHOLD
+ *	@note smi130_set_intr_tap_thres()
+ *	@note TAP QUIET
+ *	@note smi130_set_intr_tap_quiet()
+ *	@note TAP SHOCK
+ *	@note smi130_set_intr_tap_shock()
+ *	@note TAP SOURCE
+ *	@note smi130_set_intr_tap_source()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat0_single_tap_intr(u8
+*v_single_tap_intr_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR ORIENT INTERRUPT STATUS  */
+/*************************************************/
+/*!
+ *	@brief This API reads the orient_mbl status
+ *	from the register 0x1C bit 6
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the orient_mbl interrupt triggers. The
+ *	setting of INT_LATCH controls if the
+ *	interrupt signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_orient_mbl_intr_u8 : The status of orient_mbl interrupt
+ *
+ *	@note For orient_mbl interrupt configuration use the following functions
+ *	@note STATUS
+ *	@note smi130_get_stat0_orient_mbl_intr()
+ *	@note AXIS MAPPING
+ *	@note smi130_get_stat3_orient_mbl_xy()
+ *	@note smi130_get_stat3_orient_mbl_z()
+ *	@note smi130_set_intr_orient_mbl_axes_enable()
+ *	@note INTERRUPT MAPPING
+ *	@note smi130_set_intr_orient_mbl()
+ *	@note INTERRUPT OUTPUT
+ *	@note smi130_set_intr_orient_mbl_ud_enable()
+ *	@note THETA
+ *	@note smi130_set_intr_orient_mbl_theta()
+ *	@note HYSTERESIS
+ *	@note smi130_set_intr_orient_mbl_hyst()
+ *	@note BLOCKING
+ *	@note smi130_set_intr_orient_mbl_blocking()
+ *	@note MODE
+ *	@note smi130_set_intr_orient_mbl_mode()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat0_orient_mbl_intr(u8
+*v_orient_mbl_intr_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR FLAT INTERRUPT STATUS  */
+/*************************************************/
+/*!
+ *	@brief This API reads the flat interrupt status
+ *	from the register 0x1C bit 7
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the flat interrupt triggers. The
+ *	setting of INT_LATCH controls if the
+ *	interrupt signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_flat_intr_u8 : The status of  flat interrupt
+ *
+ *	@note For flat configuration use the following functions
+ *	@note STATS
+ *	@note smi130_get_stat0_flat_intr()
+ *	@note smi130_get_stat3_flat()
+ *	@note INTERRUPT MAPPING
+ *	@note smi130_set_intr_flat()
+ *	@note THETA
+ *	@note smi130_set_intr_flat_theta()
+ *	@note HOLD TIME
+ *	@note smi130_set_intr_flat_hold()
+ *	@note HYSTERESIS
+ *	@note smi130_set_intr_flat_hyst()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat0_flat_intr(u8
+*v_flat_intr_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR HIGH_G INTERRUPT STATUS  */
+/*************************************************/
+/*!
+ *	@brief This API reads the high_g interrupt status
+ *	from the register 0x1D bit 2
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the high g  interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt signal and hence the
+ *	respective interrupt flag will be permanently
+ *	latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_high_g_intr_u8 : The status of high_g interrupt
+ *
+ *	@note High_g interrupt configured by following functions
+ *	@note STATUS
+ *	@note smi130_get_stat1_high_g_intr()
+ *	@note AXIS MAPPING
+ *	@note smi130_get_stat3_high_g_first_x()
+ *	@note smi130_get_stat3_high_g_first_y()
+ *	@note smi130_get_stat3_high_g_first_z()
+ *	@note SIGN MAPPING
+ *	@note smi130_get_stat3_high_g_first_sign()
+ *	@note INTERRUPT MAPPING
+ *	@note smi130_set_intr_high_g()
+  *	@note HYSTERESIS
+ *	@note smi130_set_intr_high_g_hyst()
+ *	@note DURATION
+ *	@note smi130_set_intr_high_g_durn()
+ *	@note THRESHOLD
+ *	@note smi130_set_intr_high_g_thres()
+ *	@note SOURCE
+ *	@note smi130_set_intr_low_high_source()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat1_high_g_intr(u8
+*v_high_g_intr_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR LOW_G INTERRUPT STATUS  */
+/*************************************************/
+/*!
+ *	@brief This API reads the low g interrupt status
+ *	from the register 0x1D bit 3
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the low g  interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_low_g_intr_u8 : The status of low_g interrupt
+ *
+ *	@note Low_g interrupt configured by following functions
+ *	@note STATUS
+ *	@note smi130_get_stat1_low_g_intr()
+ *	@note INTERRUPT MAPPING
+ *	@note smi130_set_intr_low_g()
+ *	@note SOURCE
+ *	@note smi130_set_intr_low_high_source()
+ *	@note DURATION
+ *	@note smi130_set_intr_low_g_durn()
+ *	@note THRESHOLD
+ *	@note smi130_set_intr_low_g_thres()
+ *	@note HYSTERESIS
+ *	@note smi130_set_intr_low_g_hyst()
+ *	@note MODE
+ *	@note smi130_set_intr_low_g_mode()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat1_low_g_intr(u8
+*v_low_g_intr_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR DATA READY INTERRUPT STATUS  */
+/*************************************************/
+/*!
+ *	@brief This API reads data ready interrupt status
+ *	from the register 0x1D bit 4
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the  data ready  interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_data_rdy_intr_u8 : The status of data ready interrupt
+ *
+ *	@note Data ready interrupt configured by following functions
+ *	@note STATUS
+ *	@note smi130_get_stat1_data_rdy_intr()
+ *	@note INTERRUPT MAPPING
+ *	@note smi130_set_intr_data_rdy()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat1_data_rdy_intr(u8
+*v_data_rdy_intr_u8);
+/**************************************************/
+/**\name	 FUNCTIONS FOR FIFO FULL AND WATER MARK INTERRUPT STATUS*/
+/*************************************************/
+/*!
+ *	@brief This API reads data ready FIFO full interrupt status
+ *	from the register 0x1D bit 5
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the FIFO full interrupt triggers. The
+ *	setting of INT_LATCH controls if the
+ *	interrupt signal and hence the
+ *	respective interrupt flag will
+ *	be permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_fifo_full_intr_u8 : The status of fifo full interrupt
+ *
+ *	@note FIFO full interrupt can be configured by following functions
+ *	@note smi130_set_intr_fifo_full()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat1_fifo_full_intr(u8
+*v_fifo_full_intr_u8);
+/*!
+ *	@brief This API reads data
+ *	 ready FIFO watermark interrupt status
+ *	from the register 0x1D bit 6
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the FIFO watermark interrupt triggers. The
+ *	setting of INT_LATCH controls if the
+ *	interrupt signal and hence the
+ *	respective interrupt flag will be
+ *	permanently latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_fifo_wm_intr_u8 : The status of fifo water mark interrupt
+ *
+ *	@note FIFO full interrupt can be configured by following functions
+ *	@note smi130_set_intr_fifo_wm()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat1_fifo_wm_intr(u8
+*v_fifo_wm_intr_u8);
+/**************************************************/
+/**\name	 FUNCTIONS FOR NO MOTION INTERRUPT STATUS*/
+/*************************************************/
+/*!
+ *	@brief This API reads data ready no motion interrupt status
+ *	from the register 0x1D bit 7
+ *	flag is associated with a specific interrupt function.
+ *	It is set when the no motion  interrupt triggers. The
+ *	setting of INT_LATCH controls if the interrupt signal and hence the
+ *	respective interrupt flag will be permanently
+ *	latched, temporarily latched
+ *	or not latched.
+ *
+ *
+ *
+ *
+ *  @param v_nomotion_intr_u8 : The status of no motion interrupt
+ *
+ *	@note No motion interrupt can be configured by following function
+ *	@note STATUS
+ *	@note smi130_get_stat1_nomotion_intr()
+ *	@note INTERRUPT MAPPING
+ *	@note smi130_set_intr_nomotion()
+ *	@note DURATION
+ *	@note smi130_set_intr_slow_no_motion_durn()
+ *	@note THRESHOLD
+ *	@note smi130_set_intr_slow_no_motion_thres()
+ *	@note SLOW/NO MOTION SELECT
+ *	@note smi130_set_intr_slow_no_motion_select()
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat1_nomotion_intr(u8
+*nomo_intr);
+/**************************************************/
+/**\name	 FUNCTIONS FOR ANY MOTION FIRST XYZ AND SIGN INTERRUPT STATUS*/
+/*************************************************/
+/*!
+ *	@brief This API reads the status of any motion first x
+ *	from the register 0x1E bit 0
+ *
+ *
+ *  @param v_anymotion_first_x_u8 : The status of any motion first x interrupt
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by x axis
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat2_any_motion_first_x(u8
+*v_anymotion_first_x_u8);
+/*!
+ *	@brief This API reads the status of any motion first y interrupt
+ *	from the register 0x1E bit 1
+ *
+ *
+ *
+ *@param v_any_motion_first_y_u8 : The status of any motion first y interrupt
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by y axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat2_any_motion_first_y(u8
+*v_any_motion_first_y_u8);
+/*!
+ *	@brief This API reads the status of any motion first z interrupt
+ *	from the register 0x1E bit 2
+ *
+ *
+ *
+ *
+ *@param v_any_motion_first_z_u8 : The status of any motion first z interrupt
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by y axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat2_any_motion_first_z(u8
+*v_any_motion_first_z_u8);
+/*!
+ *	@brief This API reads the any motion sign status from the
+ *	register 0x1E bit 3
+ *
+ *
+ *
+ *
+ *  @param v_anymotion_sign_u8 : The status of any motion sign
+ *  value     |  sign
+ * -----------|-------------
+ *   0        | positive
+ *   1        | negative
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat2_any_motion_sign(u8
+*v_anymotion_sign_u8);
+/**************************************************/
+/**\name	 FUNCTIONS FOR TAP FIRST XYZ AND SIGN INTERRUPT STATUS*/
+/*************************************************/
+/*!
+ *	@brief This API reads the any motion tap first x status from the
+ *	register 0x1E bit 4
+ *
+ *
+ *
+ *
+ *  @param v_tap_first_x_u8 :The status of any motion tap first x
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by x axis
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat2_tap_first_x(u8
+*v_tap_first_x_u8);
+/*!
+ *	@brief This API reads the tap first y interrupt status from the
+ *	register 0x1E bit 5
+ *
+ *
+ *
+ *
+ *  @param v_tap_first_y_u8 :The status of tap first y interrupt
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by y axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat2_tap_first_y(u8
+*v_tap_first_y_u8);
+/*!
+ *	@brief This API reads the tap first z interrupt status  from the
+ *	register 0x1E bit 6
+ *
+ *
+ *
+ *
+ *  @param v_tap_first_z_u8 :The status of tap first z interrupt
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by z axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat2_tap_first_z(u8
+*v_tap_first_z_u8);
+/*!
+ *	@brief This API reads the tap sign status from the
+ *	register 0x1E bit 7
+ *
+ *
+ *
+ *
+ *  @param v_tap_sign_u8 : The status of tap sign
+ *  value     |  sign
+ * -----------|-------------
+ *   0        | positive
+ *   1        | negative
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat2_tap_sign(u8
+*tap_sign);
+/**************************************************/
+/**\name	 FUNCTIONS FOR HIGH_G FIRST XYZ AND SIGN INTERRUPT STATUS*/
+/*************************************************/
+/*!
+ *	@brief This API reads the high_g first x status from the
+ *	register 0x1F bit 0
+ *
+ *
+ *
+ *
+ *  @param v_high_g_first_x_u8 :The status of high_g first x
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by x axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat3_high_g_first_x(u8
+*v_high_g_first_x_u8);
+/*!
+ *	@brief This API reads the high_g first y status from the
+ *	register 0x1F bit 1
+ *
+ *
+ *
+ *
+ *  @param v_high_g_first_y_u8 : The status of high_g first y
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by y axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat3_high_g_first_y(u8
+*v_high_g_first_y_u8);
+/*!
+ *	@brief This API reads the high_g first z status from the
+ *	register 0x1F bit 3
+ *
+ *
+ *
+ *
+ *  @param v_high_g_first_z_u8 : The status of high_g first z
+ *  value     |  status
+ * -----------|-------------
+ *   0        | not triggered
+ *   1        | triggered by z axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat3_high_g_first_z(u8
+*v_high_g_first_z_u8);
+/*!
+ *	@brief This API reads the high sign status from the
+ *	register 0x1F bit 3
+ *
+ *
+ *
+ *
+ *  @param v_high_g_sign_u8 :The status of high sign
+ *  value     |  sign
+ * -----------|-------------
+ *   0        | positive
+ *   1        | negative
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat3_high_g_sign(u8
+*v_high_g_sign_u8);
+/**************************************************/
+/**\name	 FUNCTIONS FOR ORIENT XY AND Z INTERRUPT STATUS*/
+/*************************************************/
+/*!
+ *	@brief This API reads the status of orient_mbl_xy plane
+ *	from the register 0x1F bit 4 and 5
+ *
+ *
+ *  @param v_orient_mbl_xy_u8 :The status of orient_mbl_xy plane
+ *  value     |  status
+ * -----------|-------------
+ *   0x00     | portrait upright
+ *   0x01     | portrait upside down
+ *   0x02     | landscape left
+ *   0x03     | landscape right
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat3_orient_mbl_xy(u8
+*v_orient_mbl_xy_u8);
+/*!
+ *	@brief This API reads the status of orient_mbl z plane
+ *	from the register 0x1F bit 6
+ *
+ *
+ *  @param v_orient_mbl_z_u8 :The status of orient_mbl z
+ *  value     |  status
+ * -----------|-------------
+ *   0x00     | upward looking
+ *   0x01     | downward looking
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat3_orient_mbl_z(u8
+*v_orient_mbl_z_u8);
+/**************************************************/
+/**\name	 FUNCTIONS FOR FLAT INTERRUPT STATUS*/
+/*************************************************/
+/*!
+ *	@brief This API reads the flat status from the register
+ *	0x1F bit 7
+ *
+ *
+ *  @param v_flat_u8 : The status of flat interrupt
+ *  value     |  status
+ * -----------|-------------
+ *   0x00     | non flat
+ *   0x01     | flat position
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_stat3_flat(u8
+*flat);
+/**************************************************/
+/**\name	 FUNCTION FOR TEMPERATUE READ */
+/*************************************************/
+/*!
+ *	@brief This API reads the temperature of the sensor
+ *	from the register 0x21 bit 0 to 7
+ *
+ *
+ *
+ *  @param v_temp_s16 : The value of temperature
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_temp(s16
+*v_temp_s16);
+/**************************************************/
+/**\name	 FUNCTION FOR FIFO LENGTH AND FIFO DATA READ */
+/*************************************************/
+/*!
+ *	@brief This API reads the  of the sensor
+ *	form the register 0x23 and 0x24 bit 0 to 7 and 0 to 2
+ *	@brief this byte counter is updated each time a complete frame
+ *	was read or writtern
+ *
+ *
+ *  @param v_fifo_length_u32 : The value of fifo byte counter
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_fifo_length(
+u32 *v_fifo_length_u32);
+/*!
+ *	@brief This API reads the fifo data of the sensor
+ *	from the register 0x24
+ *	@brief Data format depends on the setting of register FIFO_CONFIG
+ *
+ *
+ *
+ *  @param v_fifodata_u8 : Pointer holding the fifo data
+ *
+ *	@note For reading FIFO data use the following functions
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_fifo_data(
+u8 *v_fifodata_u8, u16 v_fifo_length_u16);
+/**************************************************/
+/**\name	 FUNCTION FOR ACCEL CONFIGURATIONS */
+/*************************************************/
+/*!
+ *	@brief This API is used to get the
+ *	accel output date rate form the register 0x40 bit 0 to 3
+ *
+ *
+ *  @param  v_output_data_rate_u8 :The value of accel output date rate
+ *  value |  output data rate
+ * -------|--------------------------
+ *	 0    |	SMI130_ACCEL_OUTPUT_DATA_RATE_RESERVED
+ *	 1	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_0_78HZ
+ *	 2	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_1_56HZ
+ *	 3    |	SMI130_ACCEL_OUTPUT_DATA_RATE_3_12HZ
+ *	 4    | SMI130_ACCEL_OUTPUT_DATA_RATE_6_25HZ
+ *	 5	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_12_5HZ
+ *	 6	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_25HZ
+ *	 7	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_50HZ
+ *	 8	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_100HZ
+ *	 9	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_200HZ
+ *	 10	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_400HZ
+ *	 11	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_800HZ
+ *	 12	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_1600HZ
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_accel_output_data_rate(
+u8 *v_output_data_rate_u8);
+/*!
+ *	@brief This API is used to set the
+ *	accel output date rate form the register 0x40 bit 0 to 3
+ *
+ *
+ *  @param  v_output_data_rate_u8 :The value of accel output date rate
+ *  value |  output data rate
+ * -------|--------------------------
+ *	 0    |	SMI130_ACCEL_OUTPUT_DATA_RATE_RESERVED
+ *	 1	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_0_78HZ
+ *	 2	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_1_56HZ
+ *	 3    |	SMI130_ACCEL_OUTPUT_DATA_RATE_3_12HZ
+ *	 4    | SMI130_ACCEL_OUTPUT_DATA_RATE_6_25HZ
+ *	 5	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_12_5HZ
+ *	 6	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_25HZ
+ *	 7	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_50HZ
+ *	 8	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_100HZ
+ *	 9	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_200HZ
+ *	 10	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_400HZ
+ *	 11	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_800HZ
+ *	 12	  |	SMI130_ACCEL_OUTPUT_DATA_RATE_1600HZ
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_accel_output_data_rate(u8 odr);
+/*!
+ *	@brief This API is used to get the
+ *	accel bandwidth from the register 0x40 bit 4 to 6
+ *	@brief bandwidth parameter determines filter configuration(acc_us=0)
+ *	and averaging for under sampling mode(acc_us=1)
+ *
+ *
+ *  @param  v_bw_u8 : The value of accel bandwidth
+ *
+ *	@note accel bandwidth depends on under sampling parameter
+ *	@note under sampling parameter cab be set by the function
+ *	"SMI130_SET_ACCEL_UNDER_SAMPLING_PARAMETER"
+ *
+ *	@note Filter configuration
+ *  accel_us  | Filter configuration
+ * -----------|---------------------
+ *    0x00    |  OSR4 mode
+ *    0x01    |  OSR2 mode
+ *    0x02    |  normal mode
+ *    0x03    |  CIC mode
+ *    0x04    |  Reserved
+ *    0x05    |  Reserved
+ *    0x06    |  Reserved
+ *    0x07    |  Reserved
+ *
+ *	@note accel under sampling mode
+ *  accel_us  | Under sampling mode
+ * -----------|---------------------
+ *    0x00    |  no averaging
+ *    0x01    |  average 2 samples
+ *    0x02    |  average 4 samples
+ *    0x03    |  average 8 samples
+ *    0x04    |  average 16 samples
+ *    0x05    |  average 32 samples
+ *    0x06    |  average 64 samples
+ *    0x07    |  average 128 samples
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_accel_bw(u8 *v_bw_u8);
+/*!
+ *	@brief This API is used to set the
+ *	accel bandwidth from the register 0x40 bit 4 to 6
+ *	@brief bandwidth parameter determines filter configuration(acc_us=0)
+ *	and averaging for under sampling mode(acc_us=1)
+ *
+ *
+ *  @param  v_bw_u8 : The value of accel bandwidth
+ *
+ *	@note accel bandwidth depends on under sampling parameter
+ *	@note under sampling parameter cab be set by the function
+ *	"SMI130_SET_ACCEL_UNDER_SAMPLING_PARAMETER"
+ *
+ *	@note Filter configuration
+ *  accel_us  | Filter configuration
+ * -----------|---------------------
+ *    0x00    |  OSR4 mode
+ *    0x01    |  OSR2 mode
+ *    0x02    |  normal mode
+ *    0x03    |  CIC mode
+ *    0x04    |  Reserved
+ *    0x05    |  Reserved
+ *    0x06    |  Reserved
+ *    0x07    |  Reserved
+ *
+ *	@note accel under sampling mode
+ *  accel_us  | Under sampling mode
+ * -----------|---------------------
+ *    0x00    |  no averaging
+ *    0x01    |  average 2 samples
+ *    0x02    |  average 4 samples
+ *    0x03    |  average 8 samples
+ *    0x04    |  average 16 samples
+ *    0x05    |  average 32 samples
+ *    0x06    |  average 64 samples
+ *    0x07    |  average 128 samples
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_accel_bw(u8 v_bw_u8);
+/*!
+ *	@brief This API is used to get the accel
+ *	under sampling parameter form the register 0x40 bit 7
+ *
+ *
+ *
+ *
+ *	@param  v_accel_under_sampling_u8 : The value of accel under sampling
+ *	value    | under_sampling
+ * ----------|---------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_accel_under_sampling_parameter(
+u8 *v_accel_under_sampling_u8);
+/*!
+ *	@brief This API is used to set the accel
+ *	under sampling parameter form the register 0x40 bit 7
+ *
+ *
+ *
+ *
+ *	@param  v_accel_under_sampling_u8 : The value of accel under sampling
+ *	value    | under_sampling
+ * ----------|---------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_accel_under_sampling_parameter(
+u8 v_accel_under_sampling_u8);
+/*!
+ *	@brief This API is used to get the ranges
+ *	(g values) of the accel from the register 0x41 bit 0 to 3
+ *
+ *
+ *
+ *
+ *  @param v_range_u8 : The value of accel g range
+ *	value    | g_range
+ * ----------|-----------
+ *   0x03    | SMI130_ACCEL_RANGE_2G
+ *   0x05    | SMI130_ACCEL_RANGE_4G
+ *   0x08    | SMI130_ACCEL_RANGE_8G
+ *   0x0C    | SMI130_ACCEL_RANGE_16G
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_accel_range(
+u8 *v_range_u8);
+/*!
+ *	@brief This API is used to set the ranges
+ *	(g values) of the accel from the register 0x41 bit 0 to 3
+ *
+ *
+ *
+ *
+ *  @param v_range_u8 : The value of accel g range
+ *	value    | g_range
+ * ----------|-----------
+ *   0x03    | SMI130_ACCEL_RANGE_2G
+ *   0x05    | SMI130_ACCEL_RANGE_4G
+ *   0x08    | SMI130_ACCEL_RANGE_8G
+ *   0x0C    | SMI130_ACCEL_RANGE_16G
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_accel_range(
+u8 v_range_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR GYRO CONFIGURATIONS */
+/*************************************************/
+/*!
+ *	@brief This API is used to get the
+ *	gyroscope output data rate from the register 0x42 bit 0 to 3
+ *
+ *
+ *
+ *
+ *  @param  v_output_data_rate_u8 :The value of gyro output data rate
+ *  value     |      gyro output data rate
+ * -----------|-----------------------------
+ *   0x00     | SMI130_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x01     | SMI130_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x02     | SMI130_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x03     | SMI130_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x04     | SMI130_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x05     | SMI130_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x06     | SMI130_GYRO_OUTPUT_DATA_RATE_25HZ
+ *   0x07     | SMI130_GYRO_OUTPUT_DATA_RATE_50HZ
+ *   0x08     | SMI130_GYRO_OUTPUT_DATA_RATE_100HZ
+ *   0x09     | SMI130_GYRO_OUTPUT_DATA_RATE_200HZ
+ *   0x0A     | SMI130_GYRO_OUTPUT_DATA_RATE_400HZ
+ *   0x0B     | SMI130_GYRO_OUTPUT_DATA_RATE_800HZ
+ *   0x0C     | SMI130_GYRO_OUTPUT_DATA_RATE_1600HZ
+ *   0x0D     | SMI130_GYRO_OUTPUT_DATA_RATE_3200HZ
+ *   0x0E     | SMI130_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x0F     | SMI130_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_gyro_output_data_rate(
+u8 *gyro_output_typer);
+/*!
+ *	@brief This API is used to set the
+ *	gyroscope output data rate from the register 0x42 bit 0 to 3
+ *
+ *
+ *
+ *
+ *  @param  v_output_data_rate_u8 :The value of gyro output data rate
+ *  value     |      gyro output data rate
+ * -----------|-----------------------------
+ *   0x00     | SMI130_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x01     | SMI130_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x02     | SMI130_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x03     | SMI130_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x04     | SMI130_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x05     | SMI130_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x06     | SMI130_GYRO_OUTPUT_DATA_RATE_25HZ
+ *   0x07     | SMI130_GYRO_OUTPUT_DATA_RATE_50HZ
+ *   0x08     | SMI130_GYRO_OUTPUT_DATA_RATE_100HZ
+ *   0x09     | SMI130_GYRO_OUTPUT_DATA_RATE_200HZ
+ *   0x0A     | SMI130_GYRO_OUTPUT_DATA_RATE_400HZ
+ *   0x0B     | SMI130_GYRO_OUTPUT_DATA_RATE_800HZ
+ *   0x0C     | SMI130_GYRO_OUTPUT_DATA_RATE_1600HZ
+ *   0x0D     | SMI130_GYRO_OUTPUT_DATA_RATE_3200HZ
+ *   0x0E     | SMI130_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *   0x0F     | SMI130_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_gyro_output_data_rate(
+u8 gyro_output_typer);
+/*!
+ *	@brief This API is used to get the
+ *	data of gyro from the register 0x42 bit 4 to 5
+ *
+ *
+ *
+ *
+ *  @param  v_bw_u8 : The value of gyro bandwidth
+ *  value     | gyro bandwidth
+ *  ----------|----------------
+ *   0x00     | SMI130_GYRO_OSR4_MODE
+ *   0x01     | SMI130_GYRO_OSR2_MODE
+ *   0x02     | SMI130_GYRO_NORMAL_MODE
+ *   0x03     | SMI130_GYRO_CIC_MODE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_gyro_bw(u8 *v_bw_u8);
+/*!
+ *	@brief This API is used to set the
+ *	data of gyro from the register 0x42 bit 4 to 5
+ *
+ *
+ *
+ *
+ *  @param  v_bw_u8 : The value of gyro bandwidth
+ *  value     | gyro bandwidth
+ *  ----------|----------------
+ *   0x00     | SMI130_GYRO_OSR4_MODE
+ *   0x01     | SMI130_GYRO_OSR2_MODE
+ *   0x02     | SMI130_GYRO_NORMAL_MODE
+ *   0x03     | SMI130_GYRO_CIC_MODE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_gyro_bw(u8 v_bw_u8);
+/*!
+ *	@brief This API reads the range
+ *	of gyro from the register 0x43 bit 0 to 2
+ *
+ *  @param  v_range_u8 : The value of gyro range
+ *   value    |    range
+ *  ----------|-------------------------------
+ *    0x00    | SMI130_GYRO_RANGE_2000_DEG_SEC
+ *    0x01    | SMI130_GYRO_RANGE_1000_DEG_SEC
+ *    0x02    | SMI130_GYRO_RANGE_500_DEG_SEC
+ *    0x03    | SMI130_GYRO_RANGE_250_DEG_SEC
+ *    0x04    | SMI130_GYRO_RANGE_125_DEG_SEC
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_gyro_range(
+u8 *v_range_u8);
+/*!
+ *	@brief This API set the range
+ *	of gyro from the register 0x43 bit 0 to 2
+ *
+ *  @param  v_range_u8 : The value of gyro range
+ *   value    |    range
+ *  ----------|-------------------------------
+ *    0x00    | SMI130_GYRO_RANGE_2000_DEG_SEC
+ *    0x01    | SMI130_GYRO_RANGE_1000_DEG_SEC
+ *    0x02    | SMI130_GYRO_RANGE_500_DEG_SEC
+ *    0x03    | SMI130_GYRO_RANGE_250_DEG_SEC
+ *    0x04    | SMI130_GYRO_RANGE_125_DEG_SEC
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_gyro_range(
+u8 v_range_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR MAG CONFIGURATIONS */
+/*************************************************/
+/*!
+ *	@brief This API is used to get the
+ *	output data rate of magnetometer from the register 0x44 bit 0 to 3
+ *
+ *
+ *
+ *
+ *  @param  v_output_data_rat_u8e : The value of mag output data rate
+ *  value   |    mag output data rate
+ * ---------|---------------------------
+ *  0x00    |SMI130_MAG_OUTPUT_DATA_RATE_RESERVED
+ *  0x01    |SMI130_MAG_OUTPUT_DATA_RATE_0_78HZ
+ *  0x02    |SMI130_MAG_OUTPUT_DATA_RATE_1_56HZ
+ *  0x03    |SMI130_MAG_OUTPUT_DATA_RATE_3_12HZ
+ *  0x04    |SMI130_MAG_OUTPUT_DATA_RATE_6_25HZ
+ *  0x05    |SMI130_MAG_OUTPUT_DATA_RATE_12_5HZ
+ *  0x06    |SMI130_MAG_OUTPUT_DATA_RATE_25HZ
+ *  0x07    |SMI130_MAG_OUTPUT_DATA_RATE_50HZ
+ *  0x08    |SMI130_MAG_OUTPUT_DATA_RATE_100HZ
+ *  0x09    |SMI130_MAG_OUTPUT_DATA_RATE_200HZ
+ *  0x0A    |SMI130_MAG_OUTPUT_DATA_RATE_400HZ
+ *  0x0B    |SMI130_MAG_OUTPUT_DATA_RATE_800HZ
+ *  0x0C    |SMI130_MAG_OUTPUT_DATA_RATE_1600HZ
+ *  0x0D    |SMI130_MAG_OUTPUT_DATA_RATE_RESERVED0
+ *  0x0E    |SMI130_MAG_OUTPUT_DATA_RATE_RESERVED1
+ *  0x0F    |SMI130_MAG_OUTPUT_DATA_RATE_RESERVED2
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_mag_output_data_rate(u8 *odr);
+/*!
+ *	@brief This API is used to set the
+ *	output data rate of magnetometer from the register 0x44 bit 0 to 3
+ *
+ *
+ *
+ *
+ *  @param  v_output_data_rat_u8e : The value of mag output data rate
+ *  value   |    mag output data rate
+ * ---------|---------------------------
+ *  0x00    |SMI130_MAG_OUTPUT_DATA_RATE_RESERVED
+ *  0x01    |SMI130_MAG_OUTPUT_DATA_RATE_0_78HZ
+ *  0x02    |SMI130_MAG_OUTPUT_DATA_RATE_1_56HZ
+ *  0x03    |SMI130_MAG_OUTPUT_DATA_RATE_3_12HZ
+ *  0x04    |SMI130_MAG_OUTPUT_DATA_RATE_6_25HZ
+ *  0x05    |SMI130_MAG_OUTPUT_DATA_RATE_12_5HZ
+ *  0x06    |SMI130_MAG_OUTPUT_DATA_RATE_25HZ
+ *  0x07    |SMI130_MAG_OUTPUT_DATA_RATE_50HZ
+ *  0x08    |SMI130_MAG_OUTPUT_DATA_RATE_100HZ
+ *  0x09    |SMI130_MAG_OUTPUT_DATA_RATE_200HZ
+ *  0x0A    |SMI130_MAG_OUTPUT_DATA_RATE_400HZ
+ *  0x0B    |SMI130_MAG_OUTPUT_DATA_RATE_800HZ
+ *  0x0C    |SMI130_MAG_OUTPUT_DATA_RATE_1600HZ
+ *  0x0D    |SMI130_MAG_OUTPUT_DATA_RATE_RESERVED0
+ *  0x0E    |SMI130_MAG_OUTPUT_DATA_RATE_RESERVED1
+ *  0x0F    |SMI130_MAG_OUTPUT_DATA_RATE_RESERVED2
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_mag_output_data_rate(u8 odr);
+/**************************************************/
+/**\name	 FUNCTION FOR FIFO CONFIGURATIONS */
+/*************************************************/
+ /*!
+ *	@brief This API is used to read Down sampling
+ *	for gyro (2**downs_gyro) in the register 0x45 bit 0 to 2
+ *
+ *
+ *
+ *
+ *  @param v_fifo_down_gyro_u8 :The value of gyro fifo down
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_fifo_down_gyro(
+u8 *v_fifo_down_gyro_u8);
+ /*!
+ *	@brief This API is used to set Down sampling
+ *	for gyro (2**downs_gyro) in the register 0x45 bit 0 to 2
+ *
+ *
+ *
+ *
+ *  @param v_fifo_down_gyro_u8 :The value of gyro fifo down
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_fifo_down_gyro(
+u8 v_fifo_down_gyro_u8);
+/*!
+ *	@brief This API is used to read gyro fifo filter data
+ *	from the register 0x45 bit 3
+ *
+ *
+ *
+ *  @param v_gyro_fifo_filter_data_u8 :The value of gyro filter data
+ *  value      |  gyro_fifo_filter_data
+ * ------------|-------------------------
+ *    0x00     |  Unfiltered data
+ *    0x01     |  Filtered data
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_gyro_fifo_filter_data(
+u8 *v_gyro_fifo_filter_data_u8);
+/*!
+ *	@brief This API is used to set gyro fifo filter data
+ *	from the register 0x45 bit 3
+ *
+ *
+ *
+ *  @param v_gyro_fifo_filter_data_u8 :The value of gyro filter data
+ *  value      |  gyro_fifo_filter_data
+ * ------------|-------------------------
+ *    0x00     |  Unfiltered data
+ *    0x01     |  Filtered data
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_gyro_fifo_filter_data(
+u8 v_gyro_fifo_filter_data_u8);
+/*!
+ *	@brief This API is used to read Down sampling
+ *	for accel (2*downs_accel) from the register 0x45 bit 4 to 6
+ *
+ *
+ *
+ *
+ *  @param v_fifo_down_u8 :The value of accel fifo down
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_fifo_down_accel(
+u8 *v_fifo_down_u8);
+ /*!
+ *	@brief This API is used to set Down sampling
+ *	for accel (2*downs_accel) from the register 0x45 bit 4 to 6
+ *
+ *
+ *
+ *
+ *  @param v_fifo_down_u8 :The value of accel fifo down
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_fifo_down_accel(
+u8 v_fifo_down_u8);
+/*!
+ *	@brief This API is used to read accel fifo filter data
+ *	from the register 0x45 bit 7
+ *
+ *
+ *
+ *  @param v_accel_fifo_filter_u8 :The value of accel filter data
+ *  value      |  accel_fifo_filter_data
+ * ------------|-------------------------
+ *    0x00     |  Unfiltered data
+ *    0x01     |  Filtered data
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_accel_fifo_filter_data(
+u8 *v_accel_fifo_filter_u8);
+/*!
+ *	@brief This API is used to set accel fifo filter data
+ *	from the register 0x45 bit 7
+ *
+ *
+ *
+ *  @param v_accel_fifo_filter_u8 :The value of accel filter data
+ *  value      |  accel_fifo_filter_data
+ * ------------|-------------------------
+ *    0x00     |  Unfiltered data
+ *    0x01     |  Filtered data
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_accel_fifo_filter_data(
+u8 v_accel_fifo_filter_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR FIFO WATER MARK ENABLE */
+/*************************************************/
+/*!
+ *	@brief This API is used to Trigger an interrupt
+ *	when FIFO contains water mark level from the register 0x46 bit 0 to 7
+ *
+ *
+ *
+ *  @param  v_fifo_wm_u8 : The value of fifo water mark level
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_fifo_wm(
+u8 *v_fifo_wm_u8);
+/*!
+ *	@brief This API is used to Trigger an interrupt
+ *	when FIFO contains water mark level from the register 0x46 bit 0 to 7
+ *
+ *
+ *
+ *  @param  v_fifo_wm_u8 : The value of fifo water mark level
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_fifo_wm(
+u8 v_fifo_wm_u8);
+/**************************************************/
+/**\name	 FUNCTION FOR FIFO CONFIGURATIONS */
+/*************************************************/
+/*!
+ *	@brief This API reads fifo sensor time
+ *	frame after the last valid data frame form the register  0x47 bit 1
+ *
+ *
+ *
+ *
+ *  @param v_fifo_time_enable_u8 : The value of sensor time
+ *  value      |  fifo sensor time
+ * ------------|-------------------------
+ *    0x00     |  do not return sensortime frame
+ *    0x01     |  return sensortime frame
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_get_fifo_time_enable(
+u8 *v_fifo_time_enable_u8);
+/*!
+ *	@brief This API set fifo sensor time
+ *	frame after the last valid data frame form the register  0x47 bit 1
+ *
+ *
+ *
+ *
+ *  @param v_fifo_time_enable_u8 : The value of sensor time
+ *  value      |  fifo sensor time
+ * ------------|-------------------------
+ *    0x00     |  do not return sensortime frame
+ *    0x01     |  return sensortime frame
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_set_fifo_time_enable(
+u8 v_fifo_time_enable_u8);
+/*!
+ *	@brief This API reads FIFO tag interrupt2 enable status
+ *	from the resister 0x47 bit 2
+ *
+ *  @param v_fifo_tag_intr2_u8 : The value of fifo tag interrupt
+ *	value    | fifo tag interrupt
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_fifo_tag_intr2_enable(
+u8 *v_fifo_tag_intr2_u8);
+/*!
+ *	@brief This API set FIFO tag interrupt2 enable status
+ *	from the resister 0x47 bit 2
+ *
+ *  @param v_fifo_tag_intr2_u8 : The value of fifo tag interrupt
+ *	value    | fifo tag interrupt
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_fifo_tag_intr2_enable(
+u8 v_fifo_tag_intr2_u8);
+/*!
+ *	@brief This API get FIFO tag interrupt1 enable status
+ *	from the resister 0x47 bit 3
+ *
+ *  @param v_fifo_tag_intr1_u8 :The value of fifo tag interrupt1
+ *	value    | fifo tag interrupt
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_fifo_tag_intr1_enable(
+u8 *v_fifo_tag_intr1_u8);
+/*!
+ *	@brief This API set FIFO tag interrupt1 enable status
+ *	from the resister 0x47 bit 3
+ *
+ *  @param v_fifo_tag_intr1_u8 :The value of fifo tag interrupt1
+ *	value    | fifo tag interrupt
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_fifo_tag_intr1_enable(
+u8 v_fifo_tag_intr1_u8);
+/*!
+ *	@brief This API reads FIFO frame
+ *	header enable from the register 0x47 bit 4
+ *
+ *  @param v_fifo_header_u8 :The value of fifo header
+ *	value    | fifo header
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_fifo_header_enable(
+u8 *v_fifo_header_u8);
+/*!
+ *	@brief This API set FIFO frame
+ *	header enable from the register 0x47 bit 4
+ *
+ *  @param v_fifo_header_u8 :The value of fifo header
+ *	value    | fifo header
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_fifo_header_enable(
+u8 v_fifo_header_u8);
+/*!
+ *	@brief This API is used to read stored
+ *	magnetometer data in FIFO (all 3 axes) from the register 0x47 bit 5
+ *
+ *  @param v_fifo_mag_u8 : The value of fifo mag enble
+ *	value    | fifo mag
+ * ----------|-------------------
+ *  0x00     |  no magnetometer data is stored
+ *  0x01     |  magnetometer data is stored
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_fifo_mag_enable(
+u8 *v_fifo_mag_u8);
+/*!
+ *	@brief This API is used to set stored
+ *	magnetometer data in FIFO (all 3 axes) from the register 0x47 bit 5
+ *
+ *  @param v_fifo_mag_u8 : The value of fifo mag enble
+ *	value    | fifo mag
+ * ----------|-------------------
+ *  0x00     |  no magnetometer data is stored
+ *  0x01     |  magnetometer data is stored
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_fifo_mag_enable(
+u8 v_fifo_mag_u8);
+/*!
+ *	@brief This API is used to read stored
+ *	accel data in FIFO (all 3 axes) from the register 0x47 bit 6
+ *
+ *  @param v_fifo_accel_u8 : The value of fifo accel enble
+ *	value    | fifo accel
+ * ----------|-------------------
+ *  0x00     |  no accel data is stored
+ *  0x01     |  accel data is stored
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_fifo_accel_enable(
+u8 *v_fifo_accel_u8);
+/*!
+ *	@brief This API is used to set stored
+ *	accel data in FIFO (all 3 axes) from the register 0x47 bit 6
+ *
+ *  @param v_fifo_accel_u8 : The value of fifo accel enble
+ *	value    | fifo accel
+ * ----------|-------------------
+ *  0x00     |  no accel data is stored
+ *  0x01     |  accel data is stored
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_fifo_accel_enable(
+u8 v_fifo_accel_u8);
+/*!
+ *	@brief This API is used to read stored
+ *	 gyro data in FIFO (all 3 axes) from the resister 0x47 bit 7
+ *
+ *
+ *  @param v_fifo_gyro_u8 : The value of fifo gyro enble
+ *	value    | fifo gyro
+ * ----------|-------------------
+ *  0x00     |  no gyro data is stored
+ *  0x01     |  gyro data is stored
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_fifo_gyro_enable(
+u8 *v_fifo_gyro_u8);
+/*!
+ *	@brief This API is used to set stored
+ *	gyro data in FIFO (all 3 axes) from the resister 0x47 bit 7
+ *
+ *
+ *  @param v_fifo_gyro_u8 : The value of fifo gyro enble
+ *	value    | fifo gyro
+ * ----------|-------------------
+ *  0x00     |  no gyro data is stored
+ *  0x01     |  gyro data is stored
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_fifo_gyro_enable(
+u8 v_fifo_gyro_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR MAG I2C ADDRESS SELECTION          */
+/***************************************************************/
+/*!
+ *	@brief This API is used to read
+ *	I2C device address of auxiliary mag from the register 0x4B bit 1 to 7
+ *
+ *
+ *
+ *
+ *  @param v_i2c_device_addr_u8 : The value of mag I2C device address
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_i2c_device_addr(
+u8 *v_i2c_device_addr_u8);
+/*!
+ *	@brief This API is used to set
+ *	I2C device address of auxiliary mag from the register 0x4B bit 1 to 7
+ *
+ *
+ *
+ *
+ *  @param v_i2c_device_addr_u8 : The value of mag I2C device address
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_i2c_device_addr(
+u8 v_i2c_device_addr_u8);
+/*!
+ *	@brief This API is used to read
+ *	Burst data length (1,2,6,8 byte) from the register 0x4C bit 0 to 1
+ *
+ *
+ *
+ *
+ *  @param v_mag_burst_u8 : The data of mag burst read lenth
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_mag_burst(
+u8 *v_mag_burst_u8);
+/*!
+ *	@brief This API is used to set
+ *	Burst data length (1,2,6,8 byte) from the register 0x4C bit 0 to 1
+ *
+ *
+ *
+ *
+ *  @param v_mag_burst_u8 : The data of mag burst read lenth
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_mag_burst(
+u8 v_mag_burst_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR MAG OFFSET         */
+/***************************************************************/
+/*!
+ *	@brief This API is used to read
+ *	trigger-readout offset in units of 2.5 ms. If set to zero,
+ *	the offset is maximum, i.e. after readout a trigger
+ *	is issued immediately. from the register 0x4C bit 2 to 5
+ *
+ *
+ *
+ *
+ *  @param v_mag_offset_u8 : The value of mag offset
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_mag_offset(
+u8 *v_mag_offset_u8);
+/*!
+ *	@brief This API is used to set
+ *	trigger-readout offset in units of 2.5 ms. If set to zero,
+ *	the offset is maximum, i.e. after readout a trigger
+ *	is issued immediately. from the register 0x4C bit 2 to 5
+ *
+ *
+ *
+ *
+ *  @param v_mag_offset_u8 : The value of mag offset
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_mag_offset(
+u8 v_mag_offset_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR MAG MANUAL/AUTO MODE SELECTION          */
+/***************************************************************/
+/*!
+ *	@brief This API is used to read
+ *	Enable register access on MAG_IF[2] or MAG_IF[3] writes.
+ *	This implies that the DATA registers are not updated with
+ *	magnetometer values. Accessing magnetometer requires
+ *	the magnetometer in normal mode in PMU_STATUS.
+ *	from the register 0x4C bit 7
+ *
+ *
+ *
+ *  @param v_mag_manual_u8 : The value of mag manual enable
+ *	value    | mag manual
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_mag_manual_enable(
+u8 *v_mag_manual_u8);
+/*!
+ *	@brief This API is used to set
+ *	Enable register access on MAG_IF[2] or MAG_IF[3] writes.
+ *	This implies that the DATA registers are not updated with
+ *	magnetometer values. Accessing magnetometer requires
+ *	the magnetometer in normal mode in PMU_STATUS.
+ *	from the register 0x4C bit 7
+ *
+ *
+ *
+ *  @param v_mag_manual_u8 : The value of mag manual enable
+ *	value    | mag manual
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_mag_manual_enable(
+u8 v_mag_manual_u8);
+/***************************************************************/
+/**\name	FUNCTIONS FOR MAG READ, WRITE AND WRITE DATA ADDRESS  */
+/***************************************************************/
+/*!
+ *	@brief This API is used to read data
+ *	magnetometer address to read from the register 0x4D bit 0 to 7
+ *	@brief It used to provide mag read address of auxiliary mag
+ *
+ *
+ *
+ *
+ *  @param  v_mag_read_addr_u8 : The value of address need to be read
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_mag_read_addr(
+u8 *v_mag_read_addr_u8);
+/*!
+ *	@brief This API is used to set
+ *	magnetometer write address from the register 0x4D bit 0 to 7
+ *	@brief mag write address writes the address of auxiliary mag to write
+ *
+ *
+ *
+ *  @param v_mag_read_addr_u8:
+ *	The data of auxiliary mag address to write data
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_set_mag_read_addr(
+u8 v_mag_read_addr_u8);
+/*!
+ *	@brief This API is used to read
+ *	magnetometer write address from the register 0x4E bit 0 to 7
+ *	@brief mag write address writes the address of auxiliary mag to write
+ *
+ *
+ *
+ *  @param  v_mag_write_addr_u8:
+ *	The data of auxiliary mag address to write data
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_get_mag_write_addr(
+u8 *v_mag_write_addr_u8);
+/*!
+ *	@brief This API is used to set
+ *	magnetometer write address from the register 0x4E bit 0 to 7
+ *	@brief mag write address writes the address of auxiliary mag to write
+ *
+ *
+ *
+ *  @param  v_mag_write_addr_u8:
+ *	The data of auxiliary mag address to write data
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_set_mag_write_addr(
+u8 v_mag_write_addr_u8);
+/*!
+ *	@brief This API is used to read magnetometer write data
+ *	form the resister 0x4F bit 0 to 7
+ *	@brief This writes the data will be wrote to mag
+ *
+ *
+ *
+ *  @param  v_mag_write_data_u8: The value of mag data
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_mag_write_data(
+u8 *v_mag_write_data_u8);
+/*!
+ *	@brief This API is used to set magnetometer write data
+ *	form the resister 0x4F bit 0 to 7
+ *	@brief This writes the data will be wrote to mag
+ *
+ *
+ *
+ *  @param  v_mag_write_data_u8: The value of mag data
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_mag_write_data(
+u8 v_mag_write_data_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR INTERRUPT ENABLE OF
+ANY-MOTION XYZ, DOUBLE AND SINGLE TAP, ORIENT AND FLAT         */
+/***************************************************************/
+/*!
+ *	@brief  This API is used to read
+ *	interrupt enable from the register 0x50 bit 0 to 7
+ *
+ *
+ *
+ *
+ *	@param v_enable_u8 : Value to decided to select interrupt
+ *   v_enable_u8   |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_ANY_MOTION_X_ENABLE
+ *       1         | SMI130_ANY_MOTION_Y_ENABLE
+ *       2         | SMI130_ANY_MOTION_Z_ENABLE
+ *       3         | SMI130_DOUBLE_TAP_ENABLE
+ *       4         | SMI130_SINGLE_TAP_ENABLE
+ *       5         | SMI130_ORIENT_ENABLE
+ *       6         | SMI130_FLAT_ENABLE
+ *
+ *	@param v_intr_enable_zero_u8 : The interrupt enable value
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_enable_0(
+u8 enable, u8 *v_intr_enable_zero_u8);
+/*!
+ *	@brief  This API is used to set
+ *	interrupt enable from the register 0x50 bit 0 to 7
+ *
+ *
+ *
+ *
+ *	@param v_enable_u8 : Value to decided to select interrupt
+ *   v_enable_u8   |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_ANY_MOTION_X_ENABLE
+ *       1         | SMI130_ANY_MOTION_Y_ENABLE
+ *       2         | SMI130_ANY_MOTION_Z_ENABLE
+ *       3         | SMI130_DOUBLE_TAP_ENABLE
+ *       4         | SMI130_SINGLE_TAP_ENABLE
+ *       5         | SMI130_ORIENT_ENABLE
+ *       6         | SMI130_FLAT_ENABLE
+ *
+ *	@param v_intr_enable_zero_u8 : The interrupt enable value
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_enable_0(
+u8 enable, u8 v_intr_enable_zero_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR INTERRUPT ENABLE OF
+HIGH_G XYZ, LOW_G, DATA READY, FIFO FULL AND FIFO WATER MARK  */
+/***************************************************************/
+/*!
+ *	@brief  This API is used to read
+ *	interrupt enable byte1 from the register 0x51 bit 0 to 6
+ *	@brief It read the high_g_x,high_g_y,high_g_z,low_g_enable
+ *	data ready, fifo full and fifo water mark.
+ *
+ *
+ *
+ *  @param  v_enable_u8 :  The value of interrupt enable
+ *	@param v_enable_u8 : Value to decided to select interrupt
+ *   v_enable_u8   |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_HIGH_G_X_ENABLE
+ *       1         | SMI130_HIGH_G_Y_ENABLE
+ *       2         | SMI130_HIGH_G_Z_ENABLE
+ *       3         | SMI130_LOW_G_ENABLE
+ *       4         | SMI130_DATA_RDY_ENABLE
+ *       5         | SMI130_FIFO_FULL_ENABLE
+ *       6         | SMI130_FIFO_WM_ENABLE
+ *
+ *	@param v_intr_enable_1_u8 : The interrupt enable value
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_enable_1(
+u8 enable, u8 *v_intr_enable_1_u8);
+/*!
+ *	@brief  This API is used to set
+ *	interrupt enable byte1 from the register 0x51 bit 0 to 6
+ *	@brief It read the high_g_x,high_g_y,high_g_z,low_g_enable
+ *	data ready, fifo full and fifo water mark.
+ *
+ *
+ *
+ *  @param  v_enable_u8 :  The value of interrupt enable
+ *	@param v_enable_u8 : Value to decided to select interrupt
+ *   v_enable_u8   |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_HIGH_G_X_ENABLE
+ *       1         | SMI130_HIGH_G_Y_ENABLE
+ *       2         | SMI130_HIGH_G_Z_ENABLE
+ *       3         | SMI130_LOW_G_ENABLE
+ *       4         | SMI130_DATA_RDY_ENABLE
+ *       5         | SMI130_FIFO_FULL_ENABLE
+ *       6         | SMI130_FIFO_WM_ENABLE
+ *
+ *	@param v_intr_enable_1_u8 : The interrupt enable value
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_enable_1(
+u8 enable, u8 v_intr_enable_1_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR INTERRUPT ENABLE OF
+NO MOTION XYZ  */
+/***************************************************************/
+/*!
+ *	@brief  This API is used to read
+ *	interrupt enable byte2 from the register bit 0x52 bit 0 to 3
+ *	@brief It reads no motion x,y and z
+ *
+ *
+ *
+ *	@param v_enable_u8: The value of interrupt enable
+ *   v_enable_u8   |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_NOMOTION_X_ENABLE
+ *       1         | SMI130_NOMOTION_Y_ENABLE
+ *       2         | SMI130_NOMOTION_Z_ENABLE
+ *
+ *	@param v_intr_enable_2_u8 : The interrupt enable value
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_enable_2(
+u8 enable, u8 *v_intr_enable_2_u8);
+/*!
+ *	@brief  This API is used to set
+ *	interrupt enable byte2 from the register bit 0x52 bit 0 to 3
+ *	@brief It reads no motion x,y and z
+ *
+ *
+ *
+ *	@param v_enable_u8: The value of interrupt enable
+ *   v_enable_u8   |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_NOMOTION_X_ENABLE
+ *       1         | SMI130_NOMOTION_Y_ENABLE
+ *       2         | SMI130_NOMOTION_Z_ENABLE
+ *
+ *	@param v_intr_enable_2_u8 : The interrupt enable value
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_enable_2(
+u8 enable, u8 v_intr_enable_2_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR INTERRUPT ENABLE OF
+  STEP DETECTOR */
+/***************************************************************/
+ /*!
+ *	@brief This API is used to read
+ *	interrupt enable step detector interrupt from
+ *	the register bit 0x52 bit 3
+ *
+ *
+ *
+ *
+ *	@param v_step_intr_u8 : The value of step detector interrupt enable
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_get_step_detector_enable(
+u8 *v_step_intr_u8);
+ /*!
+ *	@brief This API is used to set
+ *	interrupt enable step detector interrupt from
+ *	the register bit 0x52 bit 3
+ *
+ *
+ *
+ *
+ *	@param v_step_intr_u8 : The value of step detector interrupt enable
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_set_step_detector_enable(
+u8 v_step_intr_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR INTERRUPT CONTROL */
+/***************************************************************/
+/*!
+ *	@brief  Configure trigger condition of interrupt1
+ *	and interrupt2 pin from the register 0x53
+ *	@brief interrupt1 - bit 0
+ *	@brief interrupt2 - bit 4
+ *
+ *  @param v_channel_u8: The value of edge trigger selection
+ *   v_channel_u8  |   Edge trigger
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_EDGE_CTRL
+ *       1         | SMI130_INTR2_EDGE_CTRL
+ *
+ *	@param v_intr_edge_ctrl_u8 : The value of edge trigger enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_EDGE
+ *  0x00     |  SMI130_LEVEL
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_edge_ctrl(
+u8 v_channel_u8, u8 *v_intr_edge_ctrl_u8);
+/*!
+ *	@brief  Configure trigger condition of interrupt1
+ *	and interrupt2 pin from the register 0x53
+ *	@brief interrupt1 - bit 0
+ *	@brief interrupt2 - bit 4
+ *
+ *  @param v_channel_u8: The value of edge trigger selection
+ *   v_channel_u8  |   Edge trigger
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_EDGE_CTRL
+ *       1         | SMI130_INTR2_EDGE_CTRL
+ *
+ *	@param v_intr_edge_ctrl_u8 : The value of edge trigger enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_EDGE
+ *  0x00     |  SMI130_LEVEL
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_edge_ctrl(
+u8 v_channel_u8, u8 v_intr_edge_ctrl_u8);
+/*!
+ *	@brief  API used for get the Configure level condition of interrupt1
+ *	and interrupt2 pin form the register 0x53
+ *	@brief interrupt1 - bit 1
+ *	@brief interrupt2 - bit 5
+ *
+ *  @param v_channel_u8: The value of level condition selection
+ *   v_channel_u8  |   level selection
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_LEVEL
+ *       1         | SMI130_INTR2_LEVEL
+ *
+ *	@param v_intr_level_u8 : The value of level of interrupt enable
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x01     |  SMI130_LEVEL_HIGH
+ *  0x00     |  SMI130_LEVEL_LOW
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_level(
+u8 v_channel_u8, u8 *v_intr_level_u8);
+/*!
+ *	@brief  API used for set the Configure level condition of interrupt1
+ *	and interrupt2 pin form the register 0x53
+ *	@brief interrupt1 - bit 1
+ *	@brief interrupt2 - bit 5
+ *
+ *  @param v_channel_u8: The value of level condition selection
+ *   v_channel_u8  |   level selection
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_LEVEL
+ *       1         | SMI130_INTR2_LEVEL
+ *
+ *	@param v_intr_level_u8 : The value of level of interrupt enable
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x01     |  SMI130_LEVEL_HIGH
+ *  0x00     |  SMI130_LEVEL_LOW
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_level(
+u8 v_channel_u8, u8 v_intr_level_u8);
+/*!
+ *	@brief  API used to get configured output enable of interrupt1
+ *	and interrupt2 from the register 0x53
+ *	@brief interrupt1 - bit 2
+ *	@brief interrupt2 - bit 6
+ *
+ *
+ *  @param v_channel_u8: The value of output type enable selection
+ *   v_channel_u8  |   level selection
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_OUTPUT_TYPE
+ *       1         | SMI130_INTR2_OUTPUT_TYPE
+ *
+ *	@param v_intr_output_type_u8 :
+ *	The value of output type of interrupt enable
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x01     |  SMI130_OPEN_DRAIN
+ *  0x00     |  SMI130_PUSH_PULL
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_output_type(
+u8 v_channel_u8, u8 *v_intr_output_type_u8);
+/*!
+ *	@brief  API used to set output enable of interrupt1
+ *	and interrupt2 from the register 0x53
+ *	@brief interrupt1 - bit 2
+ *	@brief interrupt2 - bit 6
+ *
+ *
+ *  @param v_channel_u8: The value of output type enable selection
+ *   v_channel_u8  |   level selection
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_OUTPUT_TYPE
+ *       1         | SMI130_INTR2_OUTPUT_TYPE
+ *
+ *	@param v_intr_output_type_u8 :
+ *	The value of output type of interrupt enable
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x01     |  SMI130_OPEN_DRAIN
+ *  0x00     |  SMI130_PUSH_PULL
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_output_type(
+u8 v_channel_u8, u8 v_intr_output_type_u8);
+ /*!
+ *	@brief API used to get the Output enable for interrupt1
+ *	and interrupt1 pin from the register 0x53
+ *	@brief interrupt1 - bit 3
+ *	@brief interrupt2 - bit 7
+ *
+ *  @param v_channel_u8: The value of output enable selection
+ *   v_channel_u8  |   level selection
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_OUTPUT_TYPE
+ *       1         | SMI130_INTR2_OUTPUT_TYPE
+ *
+ *	@param v_output_enable_u8 :
+ *	The value of output enable of interrupt enable
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x01     |  SMI130_INPUT
+ *  0x00     |  SMI130_OUTPUT
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_output_enable(
+u8 v_channel_u8, u8 *v_output_enable_u8);
+ /*!
+ *	@brief API used to set the Output enable for interrupt1
+ *	and interrupt1 pin from the register 0x53
+ *	@brief interrupt1 - bit 3
+ *	@brief interrupt2 - bit 7
+ *
+ *  @param v_channel_u8: The value of output enable selection
+ *   v_channel_u8  |   level selection
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_OUTPUT_TYPE
+ *       1         | SMI130_INTR2_OUTPUT_TYPE
+ *
+ *	@param v_output_enable_u8 :
+ *	The value of output enable of interrupt enable
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x01     |  SMI130_INPUT
+ *  0x00     |  SMI130_OUTPUT
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_output_enable(
+u8 v_channel_u8, u8 v_output_enable_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR INTERRUPT LATCH INTERRUPT  */
+/***************************************************************/
+/*!
+*	@brief This API is used to get the latch duration
+*	from the register 0x54 bit 0 to 3
+*	@brief This latch selection is not applicable for data ready,
+*	orient_mblation and flat interrupts.
+*
+*
+*
+*  @param v_latch_intr_u8 : The value of latch duration
+*	Latch Duration                      |     value
+* --------------------------------------|------------------
+*    SMI130_LATCH_DUR_NONE              |      0x00
+*    SMI130_LATCH_DUR_312_5_MICRO_SEC   |      0x01
+*    SMI130_LATCH_DUR_625_MICRO_SEC     |      0x02
+*    SMI130_LATCH_DUR_1_25_MILLI_SEC    |      0x03
+*    SMI130_LATCH_DUR_2_5_MILLI_SEC     |      0x04
+*    SMI130_LATCH_DUR_5_MILLI_SEC       |      0x05
+*    SMI130_LATCH_DUR_10_MILLI_SEC      |      0x06
+*    SMI130_LATCH_DUR_20_MILLI_SEC      |      0x07
+*    SMI130_LATCH_DUR_40_MILLI_SEC      |      0x08
+*    SMI130_LATCH_DUR_80_MILLI_SEC      |      0x09
+*    SMI130_LATCH_DUR_160_MILLI_SEC     |      0x0A
+*    SMI130_LATCH_DUR_320_MILLI_SEC     |      0x0B
+*    SMI130_LATCH_DUR_640_MILLI_SEC     |      0x0C
+*    SMI130_LATCH_DUR_1_28_SEC          |      0x0D
+*    SMI130_LATCH_DUR_2_56_SEC          |      0x0E
+*    SMI130_LATCHED                     |      0x0F
+*
+*
+*
+*	@return results of bus communication function
+*	@retval 0 -> Success
+*	@retval -1 -> Error
+*
+*
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_latch_intr(
+u8 *v_latch_intr_u8);
+/*!
+*	@brief This API is used to set the latch duration
+*	from the register 0x54 bit 0 to 3
+*	@brief This latch selection is not applicable for data ready,
+*	orient_mblation and flat interrupts.
+*
+*
+*
+*  @param v_latch_intr_u8 : The value of latch duration
+*	Latch Duration                      |     value
+* --------------------------------------|------------------
+*    SMI130_LATCH_DUR_NONE              |      0x00
+*    SMI130_LATCH_DUR_312_5_MICRO_SEC   |      0x01
+*    SMI130_LATCH_DUR_625_MICRO_SEC     |      0x02
+*    SMI130_LATCH_DUR_1_25_MILLI_SEC    |      0x03
+*    SMI130_LATCH_DUR_2_5_MILLI_SEC     |      0x04
+*    SMI130_LATCH_DUR_5_MILLI_SEC       |      0x05
+*    SMI130_LATCH_DUR_10_MILLI_SEC      |      0x06
+*    SMI130_LATCH_DUR_20_MILLI_SEC      |      0x07
+*    SMI130_LATCH_DUR_40_MILLI_SEC      |      0x08
+*    SMI130_LATCH_DUR_80_MILLI_SEC      |      0x09
+*    SMI130_LATCH_DUR_160_MILLI_SEC     |      0x0A
+*    SMI130_LATCH_DUR_320_MILLI_SEC     |      0x0B
+*    SMI130_LATCH_DUR_640_MILLI_SEC     |      0x0C
+*    SMI130_LATCH_DUR_1_28_SEC          |      0x0D
+*    SMI130_LATCH_DUR_2_56_SEC          |      0x0E
+*    SMI130_LATCHED                     |      0x0F
+*
+*
+*
+*	@return results of bus communication function
+*	@retval 0 -> Success
+*	@retval -1 -> Error
+*
+*
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_latch_intr(
+u8 v_latch_intr_u8);
+/*!
+ *	@brief API used to get input enable for interrupt1
+ *	and interrupt2 pin from the register 0x54
+ *	@brief interrupt1 - bit 4
+ *	@brief interrupt2 - bit 5
+ *
+ *  @param v_channel_u8: The value of input enable selection
+ *   v_channel_u8  |   input selection
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_INPUT_ENABLE
+ *       1         | SMI130_INTR2_INPUT_ENABLE
+ *
+ *	@param v_input_en_u8 :
+ *	The value of input enable of interrupt enable
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x01     |  SMI130_INPUT
+ *  0x00     |  SMI130_OUTPUT
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_input_enable(
+u8 v_channel_u8, u8 *v_input_en_u8);
+/*!
+ *	@brief API used to set input enable for interrupt1
+ *	and interrupt2 pin from the register 0x54
+ *	@brief interrupt1 - bit 4
+ *	@brief interrupt2 - bit 5
+ *
+ *  @param v_channel_u8: The value of input enable selection
+ *   v_channel_u8  |   input selection
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_INPUT_ENABLE
+ *       1         | SMI130_INTR2_INPUT_ENABLE
+ *
+ *	@param v_input_en_u8 :
+ *	The value of input enable of interrupt enable
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x01     |  SMI130_INPUT
+ *  0x00     |  SMI130_OUTPUT
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_input_enable(
+u8 v_channel_u8, u8 v_input_en_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR INTERRUPT1 AND INTERRUPT2 MAPPING */
+/***************************************************************/
+ /*!
+ *	@brief reads the Low g interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 0 in the register 0x55
+ *	@brief interrupt2 bit 0 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of low_g selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_LOW_G
+ *       1         | SMI130_INTR2_MAP_LOW_G
+ *
+ *	@param v_intr_low_g_u8 : The value of low_g enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_low_g(
+u8 v_channel_u8, u8 *v_intr_low_g_u8);
+ /*!
+ *	@brief set the Low g interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 0 in the register 0x55
+ *	@brief interrupt2 bit 0 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of low_g selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_LOW_G
+ *       1         | SMI130_INTR2_MAP_LOW_G
+ *
+ *	@param v_intr_low_g_u8 : The value of low_g enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_low_g(
+u8 v_channel_u8, u8 v_intr_low_g_u8);
+/*!
+ *	@brief Reads the HIGH g interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 1 in the register 0x55
+ *	@brief interrupt2 bit 1 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of high_g selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_HIGH_G
+ *       1         | SMI130_INTR2_MAP_HIGH_G
+ *
+ *	@param v_intr_high_g_u8 : The value of high_g enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_high_g(
+u8 v_channel_u8, u8 *v_intr_high_g_u8);
+/*!
+ *	@brief Write the HIGH g interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 1 in the register 0x55
+ *	@brief interrupt2 bit 1 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of high_g selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_HIGH_G
+ *       1         | SMI130_INTR2_MAP_HIGH_G
+ *
+ *	@param v_intr_high_g_u8 : The value of high_g enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_high_g(
+u8 v_channel_u8, u8 v_intr_high_g_u8);
+/*!
+ *	@brief Reads the Any motion interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 2 in the register 0x55
+ *	@brief interrupt2 bit 2 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of any motion selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_ANY_MOTION
+ *       1         | SMI130_INTR2_MAP_ANY_MOTION
+ *
+ *	@param v_intr_any_motion_u8 : The value of any motion enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_any_motion(
+u8 v_channel_u8, u8 *v_intr_any_motion_u8);
+/*!
+ *	@brief Write the Any motion interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 2 in the register 0x55
+ *	@brief interrupt2 bit 2 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of any motion selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_ANY_MOTION
+ *       1         | SMI130_INTR2_MAP_ANY_MOTION
+ *
+ *	@param v_intr_any_motion_u8 : The value of any motion enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_any_motion(
+u8 v_channel_u8, u8 v_intr_any_motion_u8);
+/*!
+ *	@brief Reads the No motion interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 3 in the register 0x55
+ *	@brief interrupt2 bit 3 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of no motion selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_NOMO
+ *       1         | SMI130_INTR2_MAP_NOMO
+ *
+ *	@param v_intr_nomotion_u8 : The value of no motion enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_nomotion(
+u8 v_channel_u8, u8 *v_intr_nomotion_u8);
+/*!
+ *	@brief Write the No motion interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 3 in the register 0x55
+ *	@brief interrupt2 bit 3 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of no motion selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_NOMO
+ *       1         | SMI130_INTR2_MAP_NOMO
+ *
+ *	@param v_intr_nomotion_u8 : The value of no motion enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_nomotion(
+u8 v_channel_u8, u8 v_intr_nomotion_u8);
+/*!
+ *	@brief Reads the Double Tap interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 4 in the register 0x55
+ *	@brief interrupt2 bit 4 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of double tap interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_DOUBLE_TAP
+ *       1         | SMI130_INTR2_MAP_DOUBLE_TAP
+ *
+ *	@param v_intr_double_tap_u8 : The value of double tap enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_double_tap(
+u8 v_channel_u8, u8 *v_intr_double_tap_u8);
+/*!
+ *	@brief Write the Double Tap interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 4 in the register 0x55
+ *	@brief interrupt2 bit 4 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of double tap interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_DOUBLE_TAP
+ *       1         | SMI130_INTR2_MAP_DOUBLE_TAP
+ *
+ *	@param v_intr_double_tap_u8 : The value of double tap enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_double_tap(
+u8 v_channel_u8, u8 v_intr_double_tap_u8);
+/*!
+ *	@brief Reads the Single Tap interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 5 in the register 0x55
+ *	@brief interrupt2 bit 5 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of single tap interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_SINGLE_TAP
+ *       1         | SMI130_INTR2_MAP_SINGLE_TAP
+ *
+ *	@param v_intr_single_tap_u8 : The value of single tap  enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_single_tap(
+u8 v_channel_u8, u8 *v_intr_single_tap_u8);
+/*!
+ *	@brief Write the Single Tap interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 5 in the register 0x55
+ *	@brief interrupt2 bit 5 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of single tap interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_SINGLE_TAP
+ *       1         | SMI130_INTR2_MAP_SINGLE_TAP
+ *
+ *	@param v_intr_single_tap_u8 : The value of single tap  enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_single_tap(
+u8 v_channel_u8, u8 v_intr_single_tap_u8);
+/*!
+ *	@brief Reads the Orient interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 6 in the register 0x55
+ *	@brief interrupt2 bit 6 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of orient_mbl interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_ORIENT
+ *       1         | SMI130_INTR2_MAP_ORIENT
+ *
+ *	@param v_intr_orient_mbl_u8 : The value of orient_mbl enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_orient_mbl(
+u8 v_channel_u8, u8 *v_intr_orient_mbl_u8);
+/*!
+ *	@brief Write the Orient interrupt
+ *	interrupt mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 6 in the register 0x55
+ *	@brief interrupt2 bit 6 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of orient_mbl interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_ORIENT
+ *       1         | SMI130_INTR2_MAP_ORIENT
+ *
+ *	@param v_intr_orient_mbl_u8 : The value of orient_mbl enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_orient_mbl(
+u8 v_channel_u8, u8 v_intr_orient_mbl_u8);
+ /*!
+ *	@brief Reads the Flat interrupt
+ *	mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 7 in the register 0x55
+ *	@brief interrupt2 bit 7 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of flat interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_FLAT
+ *       1         | SMI130_INTR2_MAP_FLAT
+ *
+ *	@param v_intr_flat_u8 : The value of flat enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_flat(
+u8 v_channel_u8, u8 *v_intr_flat_u8);
+ /*!
+ *	@brief Write the Flat interrupt
+ *	mapped to interrupt1
+ *	and interrupt2 from the register 0x55 and 0x57
+ *	@brief interrupt1 bit 7 in the register 0x55
+ *	@brief interrupt2 bit 7 in the register 0x57
+ *
+ *
+ *	@param v_channel_u8: The value of flat interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_FLAT
+ *       1         | SMI130_INTR2_MAP_FLAT
+ *
+ *	@param v_intr_flat_u8 : The value of flat enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_flat(
+u8 v_channel_u8, u8 v_intr_flat_u8);
+/*!
+ *	@brief Reads PMU trigger interrupt mapped to interrupt1
+ *	and interrupt2 form the register 0x56 bit 0 and 4
+ *	@brief interrupt1 bit 0 in the register 0x56
+ *	@brief interrupt2 bit 4 in the register 0x56
+ *
+ *
+ *	@param v_channel_u8: The value of pmu trigger selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_PMUTRIG
+ *       1         | SMI130_INTR2_MAP_PMUTRIG
+ *
+ *	@param v_intr_pmu_trig_u8 : The value of pmu trigger enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_pmu_trig(
+u8 v_channel_u8, u8 *v_intr_pmu_trig_u8);
+/*!
+ *	@brief Write PMU trigger interrupt mapped to interrupt1
+ *	and interrupt2 form the register 0x56 bit 0 and 4
+ *	@brief interrupt1 bit 0 in the register 0x56
+ *	@brief interrupt2 bit 4 in the register 0x56
+ *
+ *
+ *	@param v_channel_u8: The value of pmu trigger selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_PMUTRIG
+ *       1         | SMI130_INTR2_MAP_PMUTRIG
+ *
+ *	@param v_intr_pmu_trig_u8 : The value of pmu trigger enable
+ *	value    | trigger enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_pmu_trig(
+u8 v_channel_u8, u8 v_intr_pmu_trig_u8);
+/*!
+ *	@brief Reads FIFO Full interrupt mapped to interrupt1
+ *	and interrupt2 form the register 0x56 bit 5 and 1
+ *	@brief interrupt1 bit 5 in the register 0x56
+ *	@brief interrupt2 bit 1 in the register 0x56
+ *
+ *
+ *	@param v_channel_u8: The value of fifo full interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_FIFO_FULL
+ *       1         | SMI130_INTR2_MAP_FIFO_FULL
+ *
+ *	@param v_intr_fifo_full_u8 : The value of fifo full interrupt enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_fifo_full(
+u8 v_channel_u8, u8 *v_intr_fifo_full_u8);
+/*!
+ *	@brief Write FIFO Full interrupt mapped to interrupt1
+ *	and interrupt2 form the register 0x56 bit 5 and 1
+ *	@brief interrupt1 bit 5 in the register 0x56
+ *	@brief interrupt2 bit 1 in the register 0x56
+ *
+ *
+ *	@param v_channel_u8: The value of fifo full interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_FIFO_FULL
+ *       1         | SMI130_INTR2_MAP_FIFO_FULL
+ *
+ *	@param v_intr_fifo_full_u8 : The value of fifo full interrupt enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_fifo_full(
+u8 v_channel_u8, u8 v_intr_fifo_full_u8);
+/*!
+ *	@brief Reads FIFO Watermark interrupt mapped to interrupt1
+ *	and interrupt2 form the register 0x56 bit 6 and 2
+ *	@brief interrupt1 bit 6 in the register 0x56
+ *	@brief interrupt2 bit 2 in the register 0x56
+ *
+ *
+ *	@param v_channel_u8: The value of fifo Watermark interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_FIFO_WM
+ *       1         | SMI130_INTR2_MAP_FIFO_WM
+ *
+ *	@param v_intr_fifo_wm_u8 : The value of fifo Watermark interrupt enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_fifo_wm(
+u8 v_channel_u8, u8 *v_intr_fifo_wm_u8);
+/*!
+ *	@brief Write FIFO Watermark interrupt mapped to interrupt1
+ *	and interrupt2 form the register 0x56 bit 6 and 2
+ *	@brief interrupt1 bit 6 in the register 0x56
+ *	@brief interrupt2 bit 2 in the register 0x56
+ *
+ *
+ *	@param v_channel_u8: The value of fifo Watermark interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_FIFO_WM
+ *       1         | SMI130_INTR2_MAP_FIFO_WM
+ *
+ *	@param v_intr_fifo_wm_u8 : The value of fifo Watermark interrupt enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_fifo_wm(
+u8 v_channel_u8, u8 v_intr_fifo_wm_u8);
+/*!
+ *	@brief Reads Data Ready interrupt mapped to interrupt1
+ *	and interrupt2 form the register 0x56
+ *	@brief interrupt1 bit 7 in the register 0x56
+ *	@brief interrupt2 bit 3 in the register 0x56
+ *
+ *
+ *	@param v_channel_u8: The value of data ready interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_DATA_RDY
+ *       1         | SMI130_INTR2_MAP_DATA_RDY
+ *
+ *	@param v_intr_data_rdy_u8 : The value of data ready interrupt enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_data_rdy(
+u8 v_channel_u8, u8 *v_intr_data_rdy_u8);
+/*!
+ *	@brief Write Data Ready interrupt mapped to interrupt1
+ *	and interrupt2 form the register 0x56
+ *	@brief interrupt1 bit 7 in the register 0x56
+ *	@brief interrupt2 bit 3 in the register 0x56
+ *
+ *
+ *	@param v_channel_u8: The value of data ready interrupt selection
+ *   v_channel_u8  |   interrupt
+ *  ---------------|---------------
+ *       0         | SMI130_INTR1_MAP_DATA_RDY
+ *       1         | SMI130_INTR2_MAP_DATA_RDY
+ *
+ *	@param v_intr_data_rdy_u8 : The value of data ready interrupt enable
+ *	value    | interrupt enable
+ * ----------|-------------------
+ *  0x01     |  SMI130_ENABLE
+ *  0x00     |  SMI130_DISABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_data_rdy(
+u8 v_channel_u8, u8 v_intr_data_rdy_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR TAP SOURCE CONFIGURATION          */
+/***************************************************************/
+ /*!
+ *	@brief This API reads data source for the interrupt
+ *	engine for the single and double tap interrupts from the register
+ *	0x58 bit 3
+ *
+ *
+ *  @param v_tap_source_u8 : The value of the tap source
+ *	value    | Description
+ * ----------|-------------------
+ *  0x01     |  UNFILTER_DATA
+ *  0x00     |  FILTER_DATA
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_tap_source(
+u8 *v_tap_source_u8);
+ /*!
+ *	@brief This API write data source for the interrupt
+ *	engine for the single and double tap interrupts from the register
+ *	0x58 bit 3
+ *
+ *
+ *  @param v_tap_source_u8 : The value of the tap source
+ *	value    | Description
+ * ----------|-------------------
+ *  0x01     |  UNFILTER_DATA
+ *  0x00     |  FILTER_DATA
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_tap_source(
+u8 v_tap_source_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR LOW_G AND HIGH_G SOURCE CONFIGURATION */
+/***************************************************************/
+ /*!
+ *	@brief This API Reads Data source for the
+ *	interrupt engine for the low and high g interrupts
+ *	from the register 0x58 bit 7
+ *
+ *  @param v_low_high_source_u8 : The value of the tap source
+ *	value    | Description
+ * ----------|-------------------
+ *  0x01     |  UNFILTER_DATA
+ *  0x00     |  FILTER_DATA
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_low_high_source(
+u8 *v_low_high_source_u8);
+ /*!
+ *	@brief This API write Data source for the
+ *	interrupt engine for the low and high g interrupts
+ *	from the register 0x58 bit 7
+ *
+ *  @param v_low_high_source_u8 : The value of the tap source
+ *	value    | Description
+ * ----------|-------------------
+ *  0x01     |  UNFILTER_DATA
+ *  0x00     |  FILTER_DATA
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_low_high_source(
+u8 v_low_high_source_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR MOTION SOURCE CONFIGURATION          */
+/***************************************************************/
+ /*!
+ *	@brief This API reads Data source for the
+ *	interrupt engine for the nomotion and anymotion interrupts
+ *	from the register 0x59 bit 7
+ *
+ *  @param v_motion_source_u8 :
+ *	The value of the any/no motion interrupt source
+ *	value    | Description
+ * ----------|-------------------
+ *  0x01     |  UNFILTER_DATA
+ *  0x00     |  FILTER_DATA
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_motion_source(
+u8 *v_motion_source_u8);
+ /*!
+ *	@brief This API write Data source for the
+ *	interrupt engine for the nomotion and anymotion interrupts
+ *	from the register 0x59 bit 7
+ *
+ *  @param v_motion_source_u8 :
+ *	The value of the any/no motion interrupt source
+ *	value    | Description
+ * ----------|-------------------
+ *  0x01     |  UNFILTER_DATA
+ *  0x00     |  FILTER_DATA
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_motion_source(
+u8 v_motion_source_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR LOW_G DURATION CONFIGURATION          */
+/***************************************************************/
+/*!
+ *	@brief This API is used to read the low_g duration from register
+ *	0x5A bit 0 to 7
+ *
+ *
+ *
+ *
+ *  @param v_low_g_durn_u8 : The value of low_g duration
+ *
+ *	@note Low_g duration trigger trigger delay according to
+ *	"(v_low_g_durn_u8 * 2.5)ms" in a range from 2.5ms to 640ms.
+ *	the default corresponds delay is 20ms
+ *	@note When low_g data source of interrupt is unfiltered
+ *	the sensor must not be in low power mode
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_low_g_durn(
+u8 *v_low_durn_u8);
+ /*!
+ *	@brief This API is used to write the low_g duration from register
+ *	0x5A bit 0 to 7
+ *
+ *
+ *
+ *
+ *  @param v_low_g_durn_u8 : The value of low_g duration
+ *
+ *	@note Low_g duration trigger trigger delay according to
+ *	"(v_low_g_durn_u8 * 2.5)ms" in a range from 2.5ms to 640ms.
+ *	the default corresponds delay is 20ms
+ *	@note When low_g data source of interrupt is unfiltered
+ *	the sensor must not be in low power mode
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_low_g_durn(
+u8 v_low_durn_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR LOW_G THRESH CONFIGURATION          */
+/***************************************************************/
+/*!
+ *	@brief This API is used to read Threshold
+ *	definition for the low-g interrupt from the register 0x5B bit 0 to 7
+ *
+ *
+ *
+ *
+ *  @param v_low_g_thres_u8 : The value of low_g threshold
+ *
+ *	@note Low_g interrupt trigger threshold according to
+ *	(v_low_g_thres_u8 * 7.81)mg for v_low_g_thres_u8 > 0
+ *	3.91 mg for v_low_g_thres_u8 = 0
+ *	The threshold range is form 3.91mg to 2.000mg
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_low_g_thres(
+u8 *v_low_g_thres_u8);
+/*!
+ *	@brief This API is used to write Threshold
+ *	definition for the low-g interrupt from the register 0x5B bit 0 to 7
+ *
+ *
+ *
+ *
+ *  @param v_low_g_thres_u8 : The value of low_g threshold
+ *
+ *	@note Low_g interrupt trigger threshold according to
+ *	(v_low_g_thres_u8 * 7.81)mg for v_low_g_thres_u8 > 0
+ *	3.91 mg for v_low_g_thres_u8 = 0
+ *	The threshold range is form 3.91mg to 2.000mg
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_low_g_thres(
+u8 v_low_g_thres_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR LOW_G HYSTERESIS CONFIGURATION     */
+/***************************************************************/
+ /*!
+ *	@brief This API Reads Low-g interrupt hysteresis
+ *	from the register 0x5C bit 0 to 1
+ *
+ *  @param v_low_hyst_u8 :The value of low_g hysteresis
+ *
+ *	@note Low_g hysteresis calculated by v_low_hyst_u8*125 mg
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_low_g_hyst(
+u8 *v_low_hyst_u8);
+ /*!
+ *	@brief This API write Low-g interrupt hysteresis
+ *	from the register 0x5C bit 0 to 1
+ *
+ *  @param v_low_hyst_u8 :The value of low_g hysteresis
+ *
+ *	@note Low_g hysteresis calculated by v_low_hyst_u8*125 mg
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_low_g_hyst(
+u8 v_low_hyst_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR LOW_G MODE CONFIGURATION     */
+/***************************************************************/
+/*!
+ *	@brief This API reads Low-g interrupt mode
+ *	from the register 0x5C bit 2
+ *
+ *  @param v_low_g_mode_u8 : The value of low_g mode
+ *	Value    |  Description
+ * ----------|-----------------
+ *	   0     | single-axis
+ *     1     | axis-summing
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_low_g_mode(
+u8 *v_low_g_mode_u8);
+/*!
+ *	@brief This API write Low-g interrupt mode
+ *	from the register 0x5C bit 2
+ *
+ *  @param v_low_g_mode_u8 : The value of low_g mode
+ *	Value    |  Description
+ * ----------|-----------------
+ *	   0     | single-axis
+ *     1     | axis-summing
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_low_g_mode(
+u8 v_low_g_mode_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR HIGH_G HYST CONFIGURATION     */
+/***************************************************************/
+/*!
+ *	@brief This API reads High-g interrupt hysteresis
+ *	from the register 0x5C bit 6 and 7
+ *
+ *  @param v_high_g_hyst_u8 : The value of high hysteresis
+ *
+ *	@note High_g hysteresis changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | high_g hysteresis
+ *  ----------------|---------------------
+ *      2g          |  high_hy*125 mg
+ *      4g          |  high_hy*250 mg
+ *      8g          |  high_hy*500 mg
+ *      16g         |  high_hy*1000 mg
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_high_g_hyst(
+u8 *v_high_g_hyst_u8);
+/*!
+ *	@brief This API write High-g interrupt hysteresis
+ *	from the register 0x5C bit 6 and 7
+ *
+ *  @param v_high_g_hyst_u8 : The value of high hysteresis
+ *
+ *	@note High_g hysteresis changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | high_g hysteresis
+ *  ----------------|---------------------
+ *      2g          |  high_hy*125 mg
+ *      4g          |  high_hy*250 mg
+ *      8g          |  high_hy*500 mg
+ *      16g         |  high_hy*1000 mg
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_high_g_hyst(
+u8 v_high_g_hyst_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR HIGH_G DURATION CONFIGURATION     */
+/***************************************************************/
+/*!
+ *	@brief This API is used to read Delay
+ *	time definition for the high-g interrupt from the register
+ *	0x5D bit 0 to 7
+ *
+ *
+ *
+ *  @param  v_high_g_durn_u8 :  The value of high duration
+ *
+ *	@note High_g interrupt delay triggered according to
+ *	v_high_g_durn_u8 * 2.5ms in a range from 2.5ms to 640ms
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_high_g_durn(
+u8 *v_high_g_durn_u8);
+/*!
+ *	@brief This API is used to write Delay
+ *	time definition for the high-g interrupt from the register
+ *	0x5D bit 0 to 7
+ *
+ *
+ *
+ *  @param  v_high_g_durn_u8 :  The value of high duration
+ *
+ *	@note High_g interrupt delay triggered according to
+ *	v_high_g_durn_u8 * 2.5ms in a range from 2.5ms to 640ms
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_high_g_durn(
+u8 v_high_g_durn_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR HIGH_G THRESHOLD CONFIGURATION     */
+/***************************************************************/
+/*!
+ *	@brief This API is used to read Threshold
+ *	definition for the high-g interrupt from the register 0x5E 0 to 7
+ *
+ *
+ *
+ *
+ *  @param  v_high_g_thres_u8 : Pointer holding the value of Threshold
+ *	@note High_g threshold changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | high_g threshold
+ *  ----------------|---------------------
+ *      2g          |  v_high_g_thres_u8*7.81 mg
+ *      4g          |  v_high_g_thres_u8*15.63 mg
+ *      8g          |  v_high_g_thres_u8*31.25 mg
+ *      16g         |  v_high_g_thres_u8*62.5 mg
+ *	@note when v_high_g_thres_u8 = 0
+ *   accel_range    | high_g threshold
+ *  ----------------|---------------------
+ *      2g          |  3.91 mg
+ *      4g          |  7.81 mg
+ *      8g          |  15.63 mg
+ *      16g         |  31.25 mg
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_high_g_thres(
+u8 *v_high_g_thres_u8);
+/*!
+ *	@brief This API is used to write Threshold
+ *	definition for the high-g interrupt from the register 0x5E 0 to 7
+ *
+ *
+ *
+ *
+ *  @param  v_high_g_thres_u8 : Pointer holding the value of Threshold
+ *	@note High_g threshold changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | high_g threshold
+ *  ----------------|---------------------
+ *      2g          |  v_high_g_thres_u8*7.81 mg
+ *      4g          |  v_high_g_thres_u8*15.63 mg
+ *      8g          |  v_high_g_thres_u8*31.25 mg
+ *      16g         |  v_high_g_thres_u8*62.5 mg
+ *	@note when v_high_g_thres_u8 = 0
+ *   accel_range    | high_g threshold
+ *  ----------------|---------------------
+ *      2g          |  3.91 mg
+ *      4g          |  7.81 mg
+ *      8g          |  15.63 mg
+ *      16g         |  31.25 mg
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_high_g_thres(
+u8 v_high_g_thres_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR ANY MOTION DURATION CONFIGURATION     */
+/***************************************************************/
+/*!
+ *	@brief This API reads any motion duration
+ *	from the register 0x5F bit 0 and 1
+ *
+ *  @param v_any_motion_durn_u8 : The value of any motion duration
+ *
+ *	@note Any motion duration can be calculated by "v_any_motion_durn_u8 + 1"
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_any_motion_durn(
+u8 *v_any_motion_durn_u8);
+/*!
+ *	@brief This API write any motion duration
+ *	from the register 0x5F bit 0 and 1
+ *
+ *  @param v_any_motion_durn_u8 : The value of any motion duration
+ *
+ *	@note Any motion duration can be calculated by "v_any_motion_durn_u8 + 1"
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_any_motion_durn(
+u8 nomotion);
+/***************************************************************/
+/**\name	FUNCTION FOR SLOW NO MOTION DURATION CONFIGURATION  */
+/***************************************************************/
+ /*!
+ *	@brief This API read Slow/no-motion
+ *	interrupt trigger delay duration from the register 0x5F bit 2 to 7
+ *
+ *  @param v_slow_no_motion_u8 :The value of slow no motion duration
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *	@note
+ *	@note v_slow_no_motion_u8(5:4)=0b00 ->
+ *	[v_slow_no_motion_u8(3:0) + 1] * 1.28s (1.28s-20.48s)
+ *	@note v_slow_no_motion_u8(5:4)=1 ->
+ *	[v_slow_no_motion_u8(3:0)+5] * 5.12s (25.6s-102.4s)
+ *	@note v_slow_no_motion_u8(5)='1' ->
+ *	[(v_slow_no_motion_u8:0)+11] * 10.24s (112.64s-430.08s);
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_slow_no_motion_durn(
+u8 *v_slow_no_motion_u8);
+ /*!
+ *	@brief This API write Slow/no-motion
+ *	interrupt trigger delay duration from the register 0x5F bit 2 to 7
+ *
+ *  @param v_slow_no_motion_u8 :The value of slow no motion duration
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *	@note
+ *	@note v_slow_no_motion_u8(5:4)=0b00 ->
+ *	[v_slow_no_motion_u8(3:0) + 1] * 1.28s (1.28s-20.48s)
+ *	@note v_slow_no_motion_u8(5:4)=1 ->
+ *	[v_slow_no_motion_u8(3:0)+5] * 5.12s (25.6s-102.4s)
+ *	@note v_slow_no_motion_u8(5)='1' ->
+ *	[(v_slow_no_motion_u8:0)+11] * 10.24s (112.64s-430.08s);
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_slow_no_motion_durn(
+u8 v_slow_no_motion_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR ANY MOTION THRESHOLD CONFIGURATION  */
+/***************************************************************/
+/*!
+ *	@brief This API is used to read threshold
+ *	definition for the any-motion interrupt
+ *	from the register 0x60 bit 0 to 7
+ *
+ *
+ *  @param  v_any_motion_thres_u8 : The value of any motion threshold
+ *
+ *	@note any motion threshold changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | any motion threshold
+ *  ----------------|---------------------
+ *      2g          |  v_any_motion_thres_u8*3.91 mg
+ *      4g          |  v_any_motion_thres_u8*7.81 mg
+ *      8g          |  v_any_motion_thres_u8*15.63 mg
+ *      16g         |  v_any_motion_thres_u8*31.25 mg
+ *	@note when v_any_motion_thres_u8 = 0
+ *   accel_range    | any motion threshold
+ *  ----------------|---------------------
+ *      2g          |  1.95 mg
+ *      4g          |  3.91 mg
+ *      8g          |  7.81 mg
+ *      16g         |  15.63 mg
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_any_motion_thres(
+u8 *v_any_motion_thres_u8);
+/*!
+ *	@brief This API is used to write threshold
+ *	definition for the any-motion interrupt
+ *	from the register 0x60 bit 0 to 7
+ *
+ *
+ *  @param  v_any_motion_thres_u8 : The value of any motion threshold
+ *
+ *	@note any motion threshold changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | any motion threshold
+ *  ----------------|---------------------
+ *      2g          |  v_any_motion_thres_u8*3.91 mg
+ *      4g          |  v_any_motion_thres_u8*7.81 mg
+ *      8g          |  v_any_motion_thres_u8*15.63 mg
+ *      16g         |  v_any_motion_thres_u8*31.25 mg
+ *	@note when v_any_motion_thres_u8 = 0
+ *   accel_range    | any motion threshold
+ *  ----------------|---------------------
+ *      2g          |  1.95 mg
+ *      4g          |  3.91 mg
+ *      8g          |  7.81 mg
+ *      16g         |  15.63 mg
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_any_motion_thres(
+u8 v_any_motion_thres_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR SLO/NO MOTION THRESHOLD CONFIGURATION  */
+/***************************************************************/
+ /*!
+ *	@brief This API is used to read threshold
+ *	for the slow/no-motion interrupt
+ *	from the register 0x61 bit 0 to 7
+ *
+ *
+ *
+ *
+ *  @param v_slow_no_motion_thres_u8 : The value of slow no motion threshold
+ *	@note slow no motion threshold changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | slow no motion threshold
+ *  ----------------|---------------------
+ *      2g          |  v_slow_no_motion_thres_u8*3.91 mg
+ *      4g          |  v_slow_no_motion_thres_u8*7.81 mg
+ *      8g          |  v_slow_no_motion_thres_u8*15.63 mg
+ *      16g         |  v_slow_no_motion_thres_u8*31.25 mg
+ *	@note when v_slow_no_motion_thres_u8 = 0
+ *   accel_range    | slow no motion threshold
+ *  ----------------|---------------------
+ *      2g          |  1.95 mg
+ *      4g          |  3.91 mg
+ *      8g          |  7.81 mg
+ *      16g         |  15.63 mg
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_slow_no_motion_thres(
+u8 *v_slow_no_motion_thres_u8);
+ /*!
+ *	@brief This API is used to write threshold
+ *	for the slow/no-motion interrupt
+ *	from the register 0x61 bit 0 to 7
+ *
+ *
+ *
+ *
+ *  @param v_slow_no_motion_thres_u8 : The value of slow no motion threshold
+ *	@note slow no motion threshold changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | slow no motion threshold
+ *  ----------------|---------------------
+ *      2g          |  v_slow_no_motion_thres_u8*3.91 mg
+ *      4g          |  v_slow_no_motion_thres_u8*7.81 mg
+ *      8g          |  v_slow_no_motion_thres_u8*15.63 mg
+ *      16g         |  v_slow_no_motion_thres_u8*31.25 mg
+ *	@note when v_slow_no_motion_thres_u8 = 0
+ *   accel_range    | slow no motion threshold
+ *  ----------------|---------------------
+ *      2g          |  1.95 mg
+ *      4g          |  3.91 mg
+ *      8g          |  7.81 mg
+ *      16g         |  15.63 mg
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_slow_no_motion_thres(
+u8 v_slow_no_motion_thres_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR SLO/NO MOTION SELECT CONFIGURATION  */
+/***************************************************************/
+ /*!
+ *	@brief This API is used to read
+ *	the slow/no-motion selection from the register 0x62 bit 0
+ *
+ *
+ *
+ *
+ *  @param  v_intr_slow_no_motion_select_u8 :
+ *	The value of slow/no-motion select
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     |  SLOW_MOTION
+ *  0x01     |  NO_MOTION
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_slow_no_motion_select(
+u8 *v_intr_slow_no_motion_select_u8);
+ /*!
+ *	@brief This API is used to write
+ *	the slow/no-motion selection from the register 0x62 bit 0
+ *
+ *
+ *
+ *
+ *  @param  v_intr_slow_no_motion_select_u8 :
+ *	The value of slow/no-motion select
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     |  SLOW_MOTION
+ *  0x01     |  NO_MOTION
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_slow_no_motion_select(
+u8 v_intr_slow_no_motion_select_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR SIGNIFICANT MOTION SELECT CONFIGURATION*/
+/***************************************************************/
+ /*!
+ *	@brief This API is used to select
+ *	the significant or any motion interrupt from the register 0x62 bit 1
+ *
+ *
+ *
+ *
+ *  @param  v_intr_significant_motion_select_u8 :
+ *	the value of significant or any motion interrupt selection
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     |  ANY_MOTION
+ *  0x01     |  SIGNIFICANT_MOTION
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_significant_motion_select(
+u8 *int_sig_mot_sel);
+ /*!
+ *	@brief This API is used to write, select
+ *	the significant or any motion interrupt from the register 0x62 bit 1
+ *
+ *
+ *
+ *
+ *  @param  v_intr_significant_motion_select_u8 :
+ *	the value of significant or any motion interrupt selection
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     |  ANY_MOTION
+ *  0x01     |  SIGNIFICANT_MOTION
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_significant_motion_select(
+u8 int_sig_mot_sel);
+ /*!
+ *	@brief This API is used to read
+ *	the significant skip time from the register 0x62 bit  2 and 3
+ *
+ *
+ *
+ *
+ *  @param  v_int_sig_mot_skip_u8 : the value of significant skip time
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     |  skip time 1.5 seconds
+ *  0x01     |  skip time 3 seconds
+ *  0x02     |  skip time 6 seconds
+ *  0x03     |  skip time 12 seconds
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_significant_motion_skip(
+u8 *v_int_sig_mot_skip_u8);
+ /*!
+ *	@brief This API is used to write
+ *	the significant skip time from the register 0x62 bit  2 and 3
+ *
+ *
+ *
+ *
+ *  @param  v_int_sig_mot_skip_u8 : the value of significant skip time
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     |  skip time 1.5 seconds
+ *  0x01     |  skip time 3 seconds
+ *  0x02     |  skip time 6 seconds
+ *  0x03     |  skip time 12 seconds
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_significant_motion_skip(
+u8 v_int_sig_mot_skip_u8);
+ /*!
+ *	@brief This API is used to read
+ *	the significant proof time from the register 0x62 bit  4 and 5
+ *
+ *
+ *
+ *
+ *  @param  v_significant_motion_proof_u8 :
+ *	the value of significant proof time
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     |  proof time 0.25 seconds
+ *  0x01     |  proof time 0.5 seconds
+ *  0x02     |  proof time 1 seconds
+ *  0x03     |  proof time 2 seconds
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_significant_motion_proof(
+u8 *int_sig_mot_proof);
+ /*!
+ *	@brief This API is used to write
+ *	the significant proof time from the register 0x62 bit  4 and 5
+ *
+ *
+ *
+ *
+ *  @param  v_significant_motion_proof_u8 :
+ *	the value of significant proof time
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     |  proof time 0.25 seconds
+ *  0x01     |  proof time 0.5 seconds
+ *  0x02     |  proof time 1 seconds
+ *  0x03     |  proof time 2 seconds
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_significant_motion_proof(
+u8 int_sig_mot_proof);
+/***************************************************************/
+/**\name	FUNCTION FOR TAP DURATION CONFIGURATION*/
+/***************************************************************/
+/*!
+ *	@brief This API is used to get the tap duration
+ *	from the register 0x63 bit 0 to 2
+ *
+ *
+ *
+ *  @param v_tap_durn_u8 : The value of tap duration
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | SMI130_TAP_DURN_50MS
+ *  0x01     | SMI130_TAP_DURN_100MS
+ *  0x03     | SMI130_TAP_DURN_150MS
+ *  0x04     | SMI130_TAP_DURN_200MS
+ *  0x05     | SMI130_TAP_DURN_250MS
+ *  0x06     | SMI130_TAP_DURN_375MS
+ *  0x07     | SMI130_TAP_DURN_700MS
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_tap_durn(
+u8 *v_tap_durn_u8);
+/*!
+ *	@brief This API is used to write the tap duration
+ *	from the register 0x63 bit 0 to 2
+ *
+ *
+ *
+ *  @param v_tap_durn_u8 : The value of tap duration
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | SMI130_TAP_DURN_50MS
+ *  0x01     | SMI130_TAP_DURN_100MS
+ *  0x03     | SMI130_TAP_DURN_150MS
+ *  0x04     | SMI130_TAP_DURN_200MS
+ *  0x05     | SMI130_TAP_DURN_250MS
+ *  0x06     | SMI130_TAP_DURN_375MS
+ *  0x07     | SMI130_TAP_DURN_700MS
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_tap_durn(
+u8 v_tap_durn_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR TAP SHOCK CONFIGURATION*/
+/***************************************************************/
+ /*!
+ *	@brief This API read the
+ *	tap shock duration from the register 0x63 bit 2
+ *
+ *  @param v_tap_shock_u8 :The value of tap shock
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | SMI130_TAP_SHOCK_50MS
+ *  0x01     | SMI130_TAP_SHOCK_75MS
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_tap_shock(
+u8 *v_tap_shock_u8);
+ /*!
+ *	@brief This API write the
+ *	tap shock duration from the register 0x63 bit 2
+ *
+ *  @param v_tap_shock_u8 :The value of tap shock
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | SMI130_TAP_SHOCK_50MS
+ *  0x01     | SMI130_TAP_SHOCK_75MS
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_tap_shock(
+u8 v_tap_shock_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR TAP QUIET CONFIGURATION*/
+/***************************************************************/
+/*!
+ *	@brief This API read
+ *	tap quiet duration from the register 0x63 bit 7
+ *
+ *
+ *  @param v_tap_quiet_u8 : The value of tap quiet
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | SMI130_TAP_QUIET_30MS
+ *  0x01     | SMI130_TAP_QUIET_20MS
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_tap_quiet(
+u8 *v_tap_quiet_u8);
+/*!
+ *	@brief This API write
+ *	tap quiet duration from the register 0x63 bit 7
+ *
+ *
+ *  @param v_tap_quiet_u8 : The value of tap quiet
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | SMI130_TAP_QUIET_30MS
+ *  0x01     | SMI130_TAP_QUIET_20MS
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_tap_quiet(
+u8 v_tap_quiet_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR TAP THRESHOLD CONFIGURATION*/
+/***************************************************************/
+ /*!
+ *	@brief This API read Threshold of the
+ *	single/double tap interrupt from the register 0x64 bit 0 to 4
+ *
+ *
+ *	@param v_tap_thres_u8 : The value of single/double tap threshold
+ *
+ *	@note single/double tap threshold changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | single/double tap threshold
+ *  ----------------|---------------------
+ *      2g          |  ((v_tap_thres_u8 + 1) * 62.5)mg
+ *      4g          |  ((v_tap_thres_u8 + 1) * 125)mg
+ *      8g          |  ((v_tap_thres_u8 + 1) * 250)mg
+ *      16g         |  ((v_tap_thres_u8 + 1) * 500)mg
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_tap_thres(
+u8 *v_tap_thres_u8);
+ /*!
+ *	@brief This API write Threshold of the
+ *	single/double tap interrupt from the register 0x64 bit 0 to 4
+ *
+ *
+ *	@param v_tap_thres_u8 : The value of single/double tap threshold
+ *
+ *	@note single/double tap threshold changes according to accel g range
+ *	accel g range can be set by the function ""
+ *   accel_range    | single/double tap threshold
+ *  ----------------|---------------------
+ *      2g          |  ((v_tap_thres_u8 + 1) * 62.5)mg
+ *      4g          |  ((v_tap_thres_u8 + 1) * 125)mg
+ *      8g          |  ((v_tap_thres_u8 + 1) * 250)mg
+ *      16g         |  ((v_tap_thres_u8 + 1) * 500)mg
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_tap_thres(
+u8 v_tap_thres_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR ORIENT MODE CONFIGURATION*/
+/***************************************************************/
+ /*!
+ *	@brief This API read the threshold for orient_mblation interrupt
+ *	from the register 0x65 bit 0 and 1
+ *
+ *  @param v_orient_mbl_mode_u8 : The value of threshold for orient_mblation
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | symmetrical
+ *  0x01     | high-asymmetrical
+ *  0x02     | low-asymmetrical
+ *  0x03     | symmetrical
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_orient_mbl_mode(
+u8 *v_orient_mbl_mode_u8);
+ /*!
+ *	@brief This API write the threshold for orient_mblation interrupt
+ *	from the register 0x65 bit 0 and 1
+ *
+ *  @param v_orient_mbl_mode_u8 : The value of threshold for orient_mblation
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | symmetrical
+ *  0x01     | high-asymmetrical
+ *  0x02     | low-asymmetrical
+ *  0x03     | symmetrical
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_orient_mbl_mode(
+u8 v_orient_mbl_mode_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR ORIENT BLOCKING CONFIGURATION*/
+/***************************************************************/
+/*!
+ *	@brief This API read the orient_mbl blocking mode
+ *	that is used for the generation of the orient_mblation interrupt.
+ *	from the register 0x65 bit 2 and 3
+ *
+ *  @param v_orient_mbl_blocking_u8 : The value of orient_mbl blocking mode
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | No blocking
+ *  0x01     | Theta blocking or acceleration in any axis > 1.5g
+ *  0x02     | Theta blocking or acceleration slope in any axis >
+ *   -       | 0.2g or acceleration in any axis > 1.5g
+ *  0x03     | Theta blocking or acceleration slope in any axis >
+ *   -       | 0.4g or acceleration in any axis >
+ *   -       | 1.5g and value of orient_mbl is not stable
+ *   -       | for at least 100 ms
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_orient_mbl_blocking(
+u8 *v_orient_mbl_blocking_u8);
+/*!
+ *	@brief This API write the orient_mbl blocking mode
+ *	that is used for the generation of the orient_mblation interrupt.
+ *	from the register 0x65 bit 2 and 3
+ *
+ *  @param v_orient_mbl_blocking_u8 : The value of orient_mbl blocking mode
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | No blocking
+ *  0x01     | Theta blocking or acceleration in any axis > 1.5g
+ *  0x02     | Theta blocking or acceleration slope in any axis >
+ *   -       | 0.2g or acceleration in any axis > 1.5g
+ *  0x03     | Theta blocking or acceleration slope in any axis >
+ *   -       | 0.4g or acceleration in any axis >
+ *   -       | 1.5g and value of orient_mbl is not stable
+ *   -       | for at least 100 ms
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_orient_mbl_blocking(
+u8 v_orient_mbl_blocking_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR ORIENT HYSTERESIS CONFIGURATION*/
+/***************************************************************/
+/*!
+ *	@brief This API read Orient interrupt
+ *	hysteresis, from the register 0x64 bit 4 to 7
+ *
+ *
+ *
+ *  @param v_orient_mbl_hyst_u8 : The value of orient_mbl hysteresis
+ *
+ *	@note 1 LSB corresponds to 62.5 mg,
+ *	irrespective of the selected accel range
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_orient_mbl_hyst(
+u8 *v_orient_mbl_hyst_u8);
+/*!
+ *	@brief This API write Orient interrupt
+ *	hysteresis, from the register 0x64 bit 4 to 7
+ *
+ *
+ *
+ *  @param v_orient_mbl_hyst_u8 : The value of orient_mbl hysteresis
+ *
+ *	@note 1 LSB corresponds to 62.5 mg,
+ *	irrespective of the selected accel range
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_orient_mbl_hyst(
+u8 v_orient_mbl_hyst_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR ORIENT THETA CONFIGURATION*/
+/***************************************************************/
+ /*!
+ *	@brief This API read Orient
+ *	blocking angle (0 to 44.8) from the register 0x66 bit 0 to 5
+ *
+ *  @param v_orient_mbl_theta_u8 : The value of Orient blocking angle
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_orient_mbl_theta(
+u8 *v_orient_mbl_theta_u8);
+ /*!
+ *	@brief This API write Orient
+ *	blocking angle (0 to 44.8) from the register 0x66 bit 0 to 5
+ *
+ *  @param v_orient_mbl_theta_u8 : The value of Orient blocking angle
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_orient_mbl_theta(
+u8 v_orient_mbl_theta_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR ORIENT OUTPUT ENABLE CONFIGURATION*/
+/***************************************************************/
+/*!
+ *	@brief This API read orient_mbl change
+ *	of up/down bit from the register 0x66 bit 6
+ *
+ *  @param v_orient_mbl_ud_u8 : The value of orient_mbl change of up/down
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | Is ignored
+ *  0x01     | Generates orient_mblation interrupt
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_orient_mbl_ud_enable(
+u8 *v_orient_mbl_ud_u8);
+/*!
+ *	@brief This API write orient_mbl change
+ *	of up/down bit from the register 0x66 bit 6
+ *
+ *  @param v_orient_mbl_ud_u8 : The value of orient_mbl change of up/down
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | Is ignored
+ *  0x01     | Generates orient_mblation interrupt
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_orient_mbl_ud_enable(
+u8 v_orient_mbl_ud_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR ORIENT AXIS ENABLE CONFIGURATION*/
+/***************************************************************/
+ /*!
+ *	@brief This API read orient_mblation axes changes
+ *	from the register 0x66 bit 7
+ *
+ *  @param v_orient_mbl_axes_u8 : The value of orient_mbl axes assignment
+ *	value    |       Behaviour    | Name
+ * ----------|--------------------|------
+ *  0x00     | x = x, y = y, z = z|orient_mbl_ax_noex
+ *  0x01     | x = y, y = z, z = x|orient_mbl_ax_ex
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_orient_mbl_axes_enable(
+u8 *v_orient_mbl_axes_u8);
+ /*!
+ *	@brief This API write orient_mblation axes changes
+ *	from the register 0x66 bit 7
+ *
+ *  @param v_orient_mbl_axes_u8 : The value of orient_mbl axes assignment
+ *	value    |       Behaviour    | Name
+ * ----------|--------------------|------
+ *  0x00     | x = x, y = y, z = z|orient_mbl_ax_noex
+ *  0x01     | x = y, y = z, z = x|orient_mbl_ax_ex
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_orient_mbl_axes_enable(
+u8 v_orient_mbl_axes_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR FLAT THETA CONFIGURATION*/
+/***************************************************************/
+ /*!
+ *	@brief This API read Flat angle (0 to 44.8) for flat interrupt
+ *	from the register 0x67 bit 0 to 5
+ *
+ *  @param v_flat_theta_u8 : The value of flat angle
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_flat_theta(
+u8 *v_flat_theta_u8);
+ /*!
+ *	@brief This API write Flat angle (0 to 44.8) for flat interrupt
+ *	from the register 0x67 bit 0 to 5
+ *
+ *  @param v_flat_theta_u8 : The value of flat angle
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_flat_theta(
+u8 v_flat_theta_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR FLAT HOLD CONFIGURATION*/
+/***************************************************************/
+/*!
+ *	@brief This API read Flat interrupt hold time;
+ *	from the register 0x68 bit 4 and 5
+ *
+ *  @param v_flat_hold_u8 : The value of flat hold time
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | 0ms
+ *  0x01     | 512ms
+ *  0x01     | 1024ms
+ *  0x01     | 2048ms
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_flat_hold(
+u8 *v_flat_hold_u8);
+/*!
+ *	@brief This API write Flat interrupt hold time;
+ *	from the register 0x68 bit 4 and 5
+ *
+ *  @param v_flat_hold_u8 : The value of flat hold time
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | 0ms
+ *  0x01     | 512ms
+ *  0x01     | 1024ms
+ *  0x01     | 2048ms
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_flat_hold(
+u8 v_flat_hold_u8);
+/***************************************************************/
+/**\name	FUNCTION FOR FLAT HYSTERESIS CONFIGURATION*/
+/***************************************************************/
+/*!
+ *	@brief This API read flat interrupt hysteresis
+ *	from the register 0x68 bit 0 to 3
+ *
+ *  @param v_flat_hyst_u8 : The value of flat hysteresis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_intr_flat_hyst(
+u8 *v_flat_hyst_u8);
+/*!
+ *	@brief This API write flat interrupt hysteresis
+ *	from the register 0x68 bit 0 to 3
+ *
+ *  @param v_flat_hyst_u8 : The value of flat hysteresis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_intr_flat_hyst(
+u8 v_flat_hyst_u8);
+/***************************************************************/
+/**\name	FUNCTION FAST OFFSET COMPENSATION FOR ACCEL */
+/***************************************************************/
+ /*!
+ *	@brief This API read accel offset compensation
+ *	target value for z-axis from the register 0x69 bit 0 and 1
+ *
+ *  @param v_foc_accel_z_u8 : the value of accel offset compensation z axis
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_foc_accel_z(
+u8 *v_foc_accel_z_u8);
+ /*!
+ *	@brief This API write accel offset compensation
+ *	target value for z-axis from the register 0x69 bit 0 and 1
+ *
+ *  @param v_foc_accel_z_u8 : the value of accel offset compensation z axis
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_foc_accel_z(
+u8 v_foc_accel_z_u8);
+/*!
+ *	@brief This API read accel offset compensation
+ *	target value for y-axis
+ *	from the register 0x69 bit 2 and 3
+ *
+ *  @param v_foc_accel_y_u8 : the value of accel offset compensation y axis
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_foc_accel_y(
+u8 *v_foc_accel_y_u8);
+/*!
+ *	@brief This API write accel offset compensation
+ *	target value for y-axis
+ *	from the register 0x69 bit 2 and 3
+ *
+ *  @param v_foc_accel_y_u8 : the value of accel offset compensation y axis
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_foc_accel_y(
+u8 v_foc_accel_y_u8);
+/*!
+ *	@brief This API read accel offset compensation
+ *	target value for x-axis is
+ *	from the register 0x69 bit 4 and 5
+ *
+ *  @param v_foc_accel_x_u8 : the value of accel offset compensation x axis
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_foc_accel_x(
+u8 *v_foc_accel_x_u8);
+/*!
+ *	@brief This API write accel offset compensation
+ *	target value for x-axis is
+ *	from the register 0x69 bit 4 and 5
+ *
+ *  @param v_foc_accel_x_u8 : the value of accel offset compensation x axis
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_foc_accel_x(
+u8 v_foc_accel_x_u8);
+/***************************************************************/
+/**\name	FUNCTION FAST OFFSET COMPENSATION FOR GYRO */
+/***************************************************************/
+/*!
+ *	@brief This API write gyro fast offset enable
+ *	from the register 0x69 bit 6
+ *
+ *  @param v_foc_gyro_u8 : The value of gyro fast offset enable
+ *  value    |  Description
+ * ----------|-------------
+ *    0      | fast offset compensation disabled
+ *    1      |  fast offset compensation enabled
+ *
+ *	@param v_gyro_off_x_s16 : The value of gyro fast offset x axis data
+ *	@param v_gyro_off_y_s16 : The value of gyro fast offset y axis data
+ *	@param v_gyro_off_z_s16 : The value of gyro fast offset z axis data
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_foc_gyro_enable(
+u8 v_foc_gyro_u8, s16 *v_gyro_off_x_s16,
+s16 *v_gyro_off_y_s16, s16 *v_gyro_off_z_s16);
+/***************************************************/
+/**\name	FUNCTION FOR NVM*/
+/***************************************************/
+ /*!
+ *	@brief This API read NVM program enable
+ *	from the register 0x6A bit 1
+ *
+ *  @param v_nvm_prog_u8 : The value of NVM program enable
+ *  Value  |  Description
+ * --------|-------------
+ *   0     |  DISABLE
+ *   1     |  ENABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_nvm_prog_enable(
+u8 *v_nvm_prog_u8);
+ /*!
+ *	@brief This API write NVM program enable
+ *	from the register 0x6A bit 1
+ *
+ *  @param v_nvm_prog_u8 : The value of NVM program enable
+ *  Value  |  Description
+ * --------|-------------
+ *   0     |  DISABLE
+ *   1     |  ENABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_nvm_prog_enable(
+u8 v_nvm_prog_u8);
+/***************************************************/
+/**\name	FUNCTION FOR SPI MODE*/
+/***************************************************/
+/*!
+ * @brief This API read to configure SPI
+ * Interface Mode for primary and OIS interface
+ * from the register 0x6B bit 0
+ *
+ *  @param v_spi3_u8 : The value of SPI mode selection
+ *  Value  |  Description
+ * --------|-------------
+ *   0     |  SPI 4-wire mode
+ *   1     |  SPI 3-wire mode
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_get_spi3(
+u8 *v_spi3_u8);
+/*!
+ * @brief This API write to configure SPI
+ * Interface Mode for primary and OIS interface
+ * from the register 0x6B bit 0
+ *
+ *  @param v_spi3_u8 : The value of SPI mode selection
+ *  Value  |  Description
+ * --------|-------------
+ *   0     |  SPI 4-wire mode
+ *   1     |  SPI 3-wire mode
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_set_spi3(
+u8 v_spi3_u8);
+/***************************************************/
+/**\name	FUNCTION FOR FOC GYRO */
+/***************************************************/
+/*!
+ *	@brief This API read gyro fast offset enable
+ *	from the register 0x69 bit 6
+ *
+ *  @param v_foc_gyro_u8 : The value of gyro fast offset enable
+ *  value    |  Description
+ * ----------|-------------
+ *    0      | fast offset compensation disabled
+ *    1      |  fast offset compensation enabled
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_foc_gyro_enable(
+u8 *v_foc_gyro_u8);
+/***************************************************/
+/**\name	FUNCTION FOR I2C WATCHDOG TIMBER */
+/***************************************************/
+/*!
+ *	@brief This API read I2C Watchdog timer
+ *	from the register 0x70 bit 1
+ *
+ *  @param v_i2c_wdt_u8 : The value of I2C watch dog timer
+ *  Value  |  Description
+ * --------|-------------
+ *   0     |  I2C watchdog v_timeout_u8 after 1 ms
+ *   1     |  I2C watchdog v_timeout_u8 after 50 ms
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_i2c_wdt_select(
+u8 *v_i2c_wdt_u8);
+/*!
+ *	@brief This API write I2C Watchdog timer
+ *	from the register 0x70 bit 1
+ *
+ *  @param v_i2c_wdt_u8 : The value of I2C watch dog timer
+ *  Value  |  Description
+ * --------|-------------
+ *   0     |  I2C watchdog v_timeout_u8 after 1 ms
+ *   1     |  I2C watchdog v_timeout_u8 after 50 ms
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE
+smi130_set_i2c_wdt_select(u8 v_i2c_wdt_u8);
+/*!
+ *	@brief This API read I2C watchdog enable
+ *	from the register 0x70 bit 2
+ *
+ *  @param v_i2c_wdt_u8 : The value of I2C watchdog enable
+ *  Value  |  Description
+ * --------|-------------
+ *   0     |  DISABLE
+ *   1     |  ENABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_i2c_wdt_enable(
+u8 *v_i2c_wdt_u8);
+/*!
+ *	@brief This API write I2C watchdog enable
+ *	from the register 0x70 bit 2
+ *
+ *  @param v_i2c_wdt_u8 : The value of I2C watchdog enable
+ *  Value  |  Description
+ * --------|-------------
+ *   0     |  DISABLE
+ *   1     |  ENABLE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_i2c_wdt_enable(
+u8 v_i2c_wdt_u8);
+/***************************************************/
+/**\name	FUNCTION FOR IF MODE*/
+/***************************************************/
+/*!
+ * @brief This API read I2C interface configuration(if) moe
+ * from the register 0x6B bit 4 and 5
+ *
+ *  @param  v_if_mode_u8 : The value of interface configuration mode
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  |  Primary interface:autoconfig / secondary interface:off
+ *   0x01  |  Primary interface:I2C / secondary interface:OIS
+ *   0x02  |  Primary interface:autoconfig/secondary interface:Magnetometer
+ *   0x03  |   Reserved
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_if_mode(
+u8 *v_if_mode_u8);
+/*!
+ * @brief This API write I2C interface configuration(if) moe
+ * from the register 0x6B bit 4 and 5
+ *
+ *  @param  v_if_mode_u8 : The value of interface configuration mode
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  |  Primary interface:autoconfig / secondary interface:off
+ *   0x01  |  Primary interface:I2C / secondary interface:OIS
+ *   0x02  |  Primary interface:autoconfig/secondary interface:Magnetometer
+ *   0x03  |   Reserved
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_if_mode(
+u8 v_if_mode_u8);
+/***************************************************/
+/**\name	FUNCTION FOR GYRO SLEEP TRIGGER INTERRUPT CONFIGURATION*/
+/***************************************************/
+/*!
+ *	@brief This API read gyro sleep trigger
+ *	from the register 0x6C bit 0 to 2
+ *
+ *  @param v_gyro_sleep_trigger_u8 : The value of gyro sleep trigger
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | nomotion: no / Not INT1 pin: no / INT2 pin: no
+ *   0x01  | nomotion: no / Not INT1 pin: no / INT2 pin: yes
+ *   0x02  | nomotion: no / Not INT1 pin: yes / INT2 pin: no
+ *   0x03  | nomotion: no / Not INT1 pin: yes / INT2 pin: yes
+ *   0x04  | nomotion: yes / Not INT1 pin: no / INT2 pin: no
+ *   0x05  | anymotion: yes / Not INT1 pin: no / INT2 pin: yes
+ *   0x06  | anymotion: yes / Not INT1 pin: yes / INT2 pin: no
+ *   0x07  | anymotion: yes / Not INT1 pin: yes / INT2 pin: yes
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_gyro_sleep_trigger(
+u8 *v_gyro_sleep_trigger_u8);
+/*!
+ *	@brief This API write gyro sleep trigger
+ *	from the register 0x6C bit 0 to 2
+ *
+ *  @param v_gyro_sleep_trigger_u8 : The value of gyro sleep trigger
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | nomotion: no / Not INT1 pin: no / INT2 pin: no
+ *   0x01  | nomotion: no / Not INT1 pin: no / INT2 pin: yes
+ *   0x02  | nomotion: no / Not INT1 pin: yes / INT2 pin: no
+ *   0x03  | nomotion: no / Not INT1 pin: yes / INT2 pin: yes
+ *   0x04  | nomotion: yes / Not INT1 pin: no / INT2 pin: no
+ *   0x05  | anymotion: yes / Not INT1 pin: no / INT2 pin: yes
+ *   0x06  | anymotion: yes / Not INT1 pin: yes / INT2 pin: no
+ *   0x07  | anymotion: yes / Not INT1 pin: yes / INT2 pin: yes
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_gyro_sleep_trigger(
+u8 v_gyro_sleep_trigger_u8);
+/*!
+ *	@brief This API read gyro wakeup trigger
+ *	from the register 0x6C bit 3 and 4
+ *
+ *  @param v_gyro_wakeup_trigger_u8 : The value of gyro wakeup trigger
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | anymotion: no / INT1 pin: no
+ *   0x01  | anymotion: no / INT1 pin: yes
+ *   0x02  | anymotion: yes / INT1 pin: no
+ *   0x03  | anymotion: yes / INT1 pin: yes
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_gyro_wakeup_trigger(
+u8 *v_gyro_wakeup_trigger_u8);
+/*!
+ *	@brief This API write gyro wakeup trigger
+ *	from the register 0x6C bit 3 and 4
+ *
+ *  @param v_gyro_wakeup_trigger_u8 : The value of gyro wakeup trigger
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | anymotion: no / INT1 pin: no
+ *   0x01  | anymotion: no / INT1 pin: yes
+ *   0x02  | anymotion: yes / INT1 pin: no
+ *   0x03  | anymotion: yes / INT1 pin: yes
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_gyro_wakeup_trigger(
+u8 v_gyro_wakeup_trigger_u8);
+/*!
+ *	@brief This API read Target state for gyro sleep mode
+ *	from the register 0x6C bit 5
+ *
+ *  @param v_gyro_sleep_state_u8 : The value of gyro sleep mode
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | Sleep transition to fast wake up state
+ *   0x01  | Sleep transition to suspend state
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_gyro_sleep_state(
+u8 *v_gyro_sleep_state_u8);
+/*!
+ *	@brief This API write Target state for gyro sleep mode
+ *	from the register 0x6C bit 5
+ *
+ *  @param v_gyro_sleep_state_u8 : The value of gyro sleep mode
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | Sleep transition to fast wake up state
+ *   0x01  | Sleep transition to suspend state
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_gyro_sleep_state(
+u8 v_gyro_sleep_state_u8);
+/*!
+ *	@brief This API read gyro wakeup interrupt
+ *	from the register 0x6C bit 6
+ *
+ *  @param v_gyro_wakeup_intr_u8 : The valeu of gyro wakeup interrupt
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | DISABLE
+ *   0x01  | ENABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_gyro_wakeup_intr(
+u8 *v_gyro_wakeup_intr_u8);
+/*!
+ *	@brief This API write gyro wakeup interrupt
+ *	from the register 0x6C bit 6
+ *
+ *  @param v_gyro_wakeup_intr_u8 : The valeu of gyro wakeup interrupt
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | DISABLE
+ *   0x01  | ENABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_gyro_wakeup_intr(
+u8 v_gyro_wakeup_intr_u8);
+/***************************************************/
+/**\name	FUNCTION FOR ACCEL SELF TEST */
+/***************************************************/
+/*!
+ * @brief This API read accel select axis to be self-test
+ *
+ *  @param v_accel_selftest_axis_u8 :
+ *	The value of accel self test axis selection
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | disabled
+ *   0x01  | x-axis
+ *   0x02  | y-axis
+ *   0x03  | z-axis
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_accel_selftest_axis(
+u8 *acc_selftest_axis);
+/*!
+ * @brief This API write accel select axis to be self-test
+ *
+ *  @param v_accel_selftest_axis_u8 :
+ *	The value of accel self test axis selection
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | disabled
+ *   0x01  | x-axis
+ *   0x02  | y-axis
+ *   0x03  | z-axis
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_accel_selftest_axis(
+u8 acc_selftest_axis);
+/*!
+ *	@brief This API read accel self test axis sign
+ *	from the register 0x6D bit 2
+ *
+ *  @param v_accel_selftest_sign_u8: The value of accel self test axis sign
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | negative
+ *   0x01  | positive
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_accel_selftest_sign(
+u8 *acc_selftest_sign);
+/*!
+ *	@brief This API write accel self test axis sign
+ *	from the register 0x6D bit 2
+ *
+ *  @param v_accel_selftest_sign_u8: The value of accel self test axis sign
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | negative
+ *   0x01  | positive
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_accel_selftest_sign(
+u8 acc_selftest_sign);
+/*!
+ *	@brief This API read accel self test amplitude
+ *	from the register 0x6D bit 3
+ *        select amplitude of the selftest deflection:
+ *
+ *  @param v_accel_selftest_amp_u8 : The value of accel self test amplitude
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | LOW
+ *   0x01  | HIGH
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_accel_selftest_amp(
+u8 *acc_selftest_amp);
+/*!
+ *	@brief This API write accel self test amplitude
+ *	from the register 0x6D bit 3
+ *        select amplitude of the selftest deflection:
+ *
+ *  @param v_accel_selftest_amp_u8 : The value of accel self test amplitude
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | LOW
+ *   0x01  | HIGH
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_accel_selftest_amp(
+u8 acc_selftest_amp);
+/***************************************************/
+/**\name	FUNCTION FOR GYRO SELF TEST */
+/***************************************************/
+/*!
+ *	@brief This API read gyro self test trigger
+ *
+ *	@param v_gyro_selftest_start_u8: The value of gyro self test start
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_gyro_selftest_start(
+u8 *v_gyro_selftest_start_u8);
+/*!
+ *	@brief This API write gyro self test trigger
+ *
+ *	@param v_gyro_selftest_start_u8: The value of gyro self test start
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_gyro_selftest_start(
+u8 v_gyro_selftest_start_u8);
+/***************************************************/
+/**\name	FUNCTION FOR SPI/I2C ENABLE */
+/***************************************************/
+ /*!
+ * @brief This API read primary interface selection I2C or SPI
+ *	from the register 0x70 bit 0
+ *
+ *  @param v_spi_enable_u8: The value of Interface selection
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | I2C Enable
+ *   0x01  | I2C DISBALE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_spi_enable(
+u8 *v_spi_enable_u8);
+ /*!
+ * @brief This API write primary interface selection I2C or SPI
+ *	from the register 0x70 bit 0
+ *
+ *  @param v_spi_enable_u8: The value of Interface selection
+ *  Value  |  Description
+ * --------|-------------
+ *   0x00  | I2C Enable
+ *   0x01  | I2C DISBALE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_spi_enable(
+u8 v_spi_enable_u8);
+ /*!
+ *	@brief This API read the spare zero
+ *	form register 0x70 bit 3
+ *
+ *
+ *  @param v_spare0_trim_u8: The value of spare zero
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_spare0_trim
+(u8 *v_spare0_trim_u8);
+ /*!
+ *	@brief This API write the spare zero
+ *	form register 0x70 bit 3
+ *
+ *
+ *  @param v_spare0_trim_u8: The value of spare zero
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_spare0_trim
+(u8 v_spare0_trim_u8);
+/***************************************************/
+/**\name	FUNCTION FOR NVM COUNTER */
+/***************************************************/
+ /*!
+ *	@brief This API read the NVM counter
+ *	form register 0x70 bit 4 to 7
+ *
+ *
+ *  @param v_nvm_counter_u8: The value of NVM counter
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_nvm_counter(
+u8 *v_nvm_counter_u8);
+ /*!
+ *	@brief This API write the NVM counter
+ *	form register 0x70 bit 4 to 7
+ *
+ *
+ *  @param v_nvm_counter_u8: The value of NVM counter
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_nvm_counter(
+u8 v_nvm_counter_u8);
+/***************************************************/
+/**\name	FUNCTION FOR ACCEL MANUAL OFFSET COMPENSATION */
+/***************************************************/
+/*!
+ *	@brief This API read accel manual offset compensation of x axis
+ *	from the register 0x71 bit 0 to 7
+ *
+ *
+ *
+ *  @param v_accel_off_x_s8:
+ *	The value of accel manual offset compensation of x axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_accel_offset_compensation_xaxis(
+s8 *v_accel_off_x_s8);
+/*!
+ *	@brief This API write accel manual offset compensation of x axis
+ *	from the register 0x71 bit 0 to 7
+ *
+ *
+ *
+ *  @param v_accel_off_x_s8:
+ *	The value of accel manual offset compensation of x axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_accel_offset_compensation_xaxis(
+s8 v_accel_off_x_s8);
+/*!
+ *	@brief This API read accel manual offset compensation of y axis
+ *	from the register 0x72 bit 0 to 7
+ *
+ *
+ *
+ *  @param v_accel_off_y_s8:
+ *	The value of accel manual offset compensation of y axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_accel_offset_compensation_yaxis(
+s8 *v_accel_off_y_s8);
+/*!
+ *	@brief This API write accel manual offset compensation of y axis
+ *	from the register 0x72 bit 0 to 7
+ *
+ *
+ *
+ *  @param v_accel_off_y_s8:
+ *	The value of accel manual offset compensation of y axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_accel_offset_compensation_yaxis(
+s8 v_accel_off_y_s8);
+/*!
+ *	@brief This API read accel manual offset compensation of z axis
+ *	from the register 0x73 bit 0 to 7
+ *
+ *
+ *
+ *  @param v_accel_off_z_s8:
+ *	The value of accel manual offset compensation of z axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_accel_offset_compensation_zaxis(
+s8 *v_accel_off_z_s8);
+/*!
+ *	@brief This API write accel manual offset compensation of z axis
+ *	from the register 0x73 bit 0 to 7
+ *
+ *
+ *
+ *  @param v_accel_off_z_s8:
+ *	The value of accel manual offset compensation of z axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_accel_offset_compensation_zaxis(
+s8 v_accel_off_z_s8);
+/***************************************************/
+/**\name	FUNCTION FOR GYRO MANUAL OFFSET COMPENSATION */
+/***************************************************/
+/*!
+ *	@brief This API read gyro manual offset compensation of x axis
+ *	from the register 0x74 bit 0 to 7 and 0x77 bit 0 and 1
+ *
+ *
+ *
+ *  @param v_gyro_off_x_s16:
+ *	The value of gyro manual offset compensation of x axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_gyro_offset_compensation_xaxis(
+s16 *v_gyro_off_x_s16);
+/*!
+ *	@brief This API write gyro manual offset compensation of x axis
+ *	from the register 0x74 bit 0 to 7 and 0x77 bit 0 and 1
+ *
+ *
+ *
+ *  @param v_gyro_off_x_s16:
+ *	The value of gyro manual offset compensation of x axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_gyro_offset_compensation_xaxis(
+s16 v_gyro_off_x_s16);
+/*!
+ *	@brief This API read gyro manual offset compensation of y axis
+ *	from the register 0x75 bit 0 to 7 and 0x77 bit 2 and 3
+ *
+ *
+ *
+ *  @param v_gyro_off_y_s16:
+ *	The value of gyro manual offset compensation of y axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_gyro_offset_compensation_yaxis(
+s16 *v_gyro_off_y_s16);
+/*!
+ *	@brief This API write gyro manual offset compensation of y axis
+ *	from the register 0x75 bit 0 to 7 and 0x77 bit 2 and 3
+ *
+ *
+ *
+ *  @param v_gyro_off_y_s16:
+ *	The value of gyro manual offset compensation of y axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_gyro_offset_compensation_yaxis(
+s16 v_gyro_off_y_s16);
+/*!
+ *	@brief This API read gyro manual offset compensation of z axis
+ *	from the register 0x76 bit 0 to 7 and 0x77 bit 4 and 5
+ *
+ *
+ *
+ *  @param v_gyro_off_z_s16:
+ *	The value of gyro manual offset compensation of z axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_gyro_offset_compensation_zaxis(
+s16 *v_gyro_off_z_s16);
+/*!
+ *	@brief This API write gyro manual offset compensation of z axis
+ *	from the register 0x76 bit 0 to 7 and 0x77 bit 4 and 5
+ *
+ *
+ *
+ *  @param v_gyro_off_z_s16:
+ *	The value of gyro manual offset compensation of z axis
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_gyro_offset_compensation_zaxis(
+s16 v_gyro_off_z_s16);
+/*!
+ *	@brief This API writes accel fast offset compensation
+ *	from the register 0x69 bit 0 to 5
+ *	@brief This API writes each axis individually
+ *	FOC_X_AXIS - bit 4 and 5
+ *	FOC_Y_AXIS - bit 2 and 3
+ *	FOC_Z_AXIS - bit 0 and 1
+ *
+ *  @param  v_foc_accel_u8: The value of accel offset compensation
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *  @param  v_axis_u8: The value of accel offset axis selection
+  *	value    | axis
+ * ----------|-------------------
+ *  0        | FOC_X_AXIS
+ *  1        | FOC_Y_AXIS
+ *  2        | FOC_Z_AXIS
+ *
+ *	@param v_accel_offset_s8: The accel offset value
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_accel_foc_trigger(u8 axis,
+u8 foc_acc, s8 *accel_offset);
+/*!
+ *	@brief This API write fast accel offset compensation
+ *	it writes all axis together.To the register 0x69 bit 0 to 5
+ *	FOC_X_AXIS - bit 4 and 5
+ *	FOC_Y_AXIS - bit 2 and 3
+ *	FOC_Z_AXIS - bit 0 and 1
+ *
+ *  @param  v_foc_accel_x_u8: The value of accel offset x compensation
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *  @param  v_foc_accel_y_u8: The value of accel offset y compensation
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *  @param  v_foc_accel_z_u8: The value of accel offset z compensation
+ *	value    | Behaviour
+ * ----------|-------------------
+ *  0x00     | disable
+ *  0x01     | +1g
+ *  0x01     | -1g
+ *  0x01     | 0g
+ *
+ *  @param  v_accel_off_x_s8: The value of accel offset x axis
+ *  @param  v_accel_off_y_s8: The value of accel offset y axis
+ *  @param  v_accel_off_z_s8: The value of accel offset z axis
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_accel_foc_trigger_xyz(u8 v_foc_accel_x_u8,
+u8 v_foc_accel_y_u8, u8 v_foc_accel_z_u8,
+s8 *acc_off_x, s8 *acc_off_y, s8 *acc_off_z);
+/***************************************************/
+/**\name	FUNCTION FOR ACEL AND GYRO OFFSET ENABLE */
+/***************************************************/
+/*!
+ *	@brief This API read the accel offset enable bit
+ *	from the register 0x77 bit 6
+ *
+ *
+ *
+ *  @param v_accel_off_enable_u8: The value of accel offset enable
+ *  value    |  Description
+ * ----------|--------------
+ *   0x01    | ENABLE
+ *   0x00    | DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_accel_offset_enable(
+u8 *acc_off_en);
+/*!
+ *	@brief This API write the accel offset enable bit
+ *	from the register 0x77 bit 6
+ *
+ *
+ *
+ *  @param v_accel_off_enable_u8: The value of accel offset enable
+ *  value    |  Description
+ * ----------|--------------
+ *   0x01    | ENABLE
+ *   0x00    | DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_accel_offset_enable(
+u8 acc_off_en);
+/*!
+ *	@brief This API read the accel offset enable bit
+ *	from the register 0x77 bit 7
+ *
+ *
+ *
+ *  @param v_gyro_off_enable_u8: The value of gyro offset enable
+ *  value    |  Description
+ * ----------|--------------
+ *   0x01    | ENABLE
+ *   0x00    | DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_gyro_offset_enable(
+u8 *v_gyro_off_enable_u8);
+/*!
+ *	@brief This API write the accel offset enable bit
+ *	from the register 0x77 bit 7
+ *
+ *
+ *
+ *  @param v_gyro_off_enable_u8: The value of gyro offset enable
+ *  value    |  Description
+ * ----------|--------------
+ *   0x01    | ENABLE
+ *   0x00    | DISABLE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_gyro_offset_enable(
+u8 v_gyro_off_enable_u8);
+/***************************************************/
+/**\name	FUNCTION FOR STEP COUNTER INTERRUPT */
+/***************************************************/
+/*!
+ *	@brief This API reads step counter value
+ *	form the register 0x78 and 0x79
+ *
+ *
+ *
+ *
+ *  @param v_step_cnt_s16 : The value of step counter
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_read_step_count(u16 *v_step_cnt_s16);
+ /*!
+ *	@brief This API Reads
+ *	step counter configuration
+ *	from the register 0x7A bit 0 to 7
+ *	and from the register 0x7B bit 0 to 2 and 4 to 7
+ *
+ *
+ *  @param v_step_config_u16 : The value of step configuration
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_step_config(
+u16 *v_step_config_u16);
+ /*!
+ *	@brief This API write
+ *	step counter configuration
+ *	from the register 0x7A bit 0 to 7
+ *	and from the register 0x7B bit 0 to 2 and 4 to 7
+ *
+ *
+ *  @param v_step_config_u16   :
+ *	the value of  Enable step configuration
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_step_config(
+u16 v_step_config_u16);
+ /*!
+ *	@brief This API read enable step counter
+ *	from the register 0x7B bit 3
+ *
+ *
+ *  @param v_step_counter_u8 : The value of step counter enable
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_step_counter_enable(
+u8 *v_step_counter_u8);
+ /*!
+ *	@brief This API write enable step counter
+ *	from the register 0x7B bit 3
+ *
+ *
+ *  @param v_step_counter_u8 : The value of step counter enable
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_step_counter_enable(
+u8 v_step_counter_u8);
+ /*!
+ *	@brief This API set Step counter modes
+ *
+ *
+ *  @param  v_step_mode_u8 : The value of step counter mode
+ *  value    |   mode
+ * ----------|-----------
+ *   0       | SMI130_STEP_NORMAL_MODE
+ *   1       | SMI130_STEP_SENSITIVE_MODE
+ *   2       | SMI130_STEP_ROBUST_MODE
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_set_step_mode(u8 v_step_mode_u8);
+/*!
+ *	@brief This API used to trigger the  signification motion
+ *	interrupt
+ *
+ *
+ *  @param  v_significant_u8 : The value of interrupt selection
+ *  value    |  interrupt
+ * ----------|-----------
+ *   0       |  SMI130_MAP_INTR1
+ *   1       |  SMI130_MAP_INTR2
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_map_significant_motion_intr(
+u8 v_significant_u8);
+/*!
+ *	@brief This API used to trigger the step detector
+ *	interrupt
+ *
+ *
+ *  @param  v_step_detector_u8 : The value of interrupt selection
+ *  value    |  interrupt
+ * ----------|-----------
+ *   0       |  SMI130_MAP_INTR1
+ *   1       |  SMI130_MAP_INTR2
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_map_step_detector_intr(
+u8 v_step_detector_u8);
+ /*!
+ *	@brief This API used to clear the step counter interrupt
+ *	interrupt
+ *
+ *
+ *  @param  : None
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_clear_step_counter(void);
+/***************************************************/
+/**\name	FUNCTION FOR STEP COMMAND REGISTER WRITE */
+/***************************************************/
+ /*!
+ *	@brief This API writes value to the register 0x7E bit 0 to 7
+ *
+ *
+ *  @param  v_command_reg_u8 : The value to write command register
+ *  value   |  Description
+ * ---------|--------------------------------------------------------
+ *	0x00	|	Reserved
+ *  0x03	|	Starts fast offset calibration for the accel and gyro
+ *	0x10	|	Sets the PMU mode for the Accelerometer to suspend
+ *	0x11	|	Sets the PMU mode for the Accelerometer to normal
+ *	0x12	|	Sets the PMU mode for the Accelerometer Lowpower
+ *  0x14	|	Sets the PMU mode for the Gyroscope to suspend
+ *	0x15	|	Sets the PMU mode for the Gyroscope to normal
+ *	0x16	|	Reserved
+ *	0x17	|	Sets the PMU mode for the Gyroscope to fast start-up
+ *  0x18	|	Sets the PMU mode for the Magnetometer to suspend
+ *	0x19	|	Sets the PMU mode for the Magnetometer to normal
+ *	0x1A	|	Sets the PMU mode for the Magnetometer to Lowpower
+ *	0xB0	|	Clears all data in the FIFO
+ *  0xB1	|	Resets the interrupt engine
+ *	0xB2	|	step_cnt_clr Clears the step counter
+ *	0xB6	|	Triggers a reset
+ *	0x37	|	See extmode_en_last
+ *	0x9A	|	See extmode_en_last
+ *	0xC0	|	Enable the extended mode
+ *  0xC4	|	Erase NVM cell
+ *	0xC8	|	Load NVM cell
+ *	0xF0	|	Reset acceleration data path
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_command_register(
+u8 v_command_reg_u8);
+/***************************************************/
+/**\name	FUNCTION FOR PAGE ENABLE */
+/***************************************************/
+ /*!
+ *	@brief This API read target page from the register 0x7F bit 4 and 5
+ *
+ *  @param v_target_page_u8: The value of target page
+ *  value   |  page
+ * ---------|-----------
+ *   0      |  User data/configure page
+ *   1      |  Chip level trim/test page
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_target_page(
+u8 *v_target_page_u8);
+ /*!
+ *	@brief This API write target page from the register 0x7F bit 4 and 5
+ *
+ *  @param v_target_page_u8: The value of target page
+ *  value   |  page
+ * ---------|-----------
+ *   0      |  User data/configure page
+ *   1      |  Chip level trim/test page
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_target_page(
+u8 v_target_page_u8);
+ /*!
+ *	@brief This API read page enable from the register 0x7F bit 7
+ *
+ *
+ *
+ *  @param v_page_enable_u8: The value of page enable
+ *  value   |  page
+ * ---------|-----------
+ *   0      |  DISABLE
+ *   1      |  ENABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_paging_enable(
+u8 *v_page_enable_u8);
+ /*!
+ *	@brief This API write page enable from the register 0x7F bit 7
+ *
+ *
+ *
+ *  @param v_page_enable_u8: The value of page enable
+ *  value   |  page
+ * ---------|-----------
+ *   0      |  DISABLE
+ *   1      |  ENABLE
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_paging_enable(
+u8 v_page_enable_u8);
+ /*!
+ *	@brief This API read
+ *	pull up configuration from the register 0X85 bit 4 an 5
+ *
+ *
+ *
+ *  @param v_control_pullup_u8: The value of pull up register
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_get_pullup_configuration(
+u8 *v_control_pullup_u8);
+ /*!
+ *	@brief This API write
+ *	pull up configuration from the register 0X85 bit 4 an 5
+ *
+ *
+ *
+ *  @param v_control_pullup_u8: The value of pull up register
+ *
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_pullup_configuration(
+u8 v_control_pullup_u8);
+/***************************************************/
+/**\name	FUNCTION FOR BMM150 */
+/***************************************************/
+ /*!
+ *	@brief This function used for initialize the bmm150 sensor
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_bmm150_mag_interface_init(void);
+ /*!
+ *	@brief This function used for set the mag power control
+ *	bit enable
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_bmm150_mag_wakeup(void);
+ /*!
+ *	@brief This function used for read the trim values of magnetometer
+ *
+ *	@note
+ *	Before reading the mag trimming values
+ *	make sure the following two points are addressed
+ *	@note
+ *	1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note
+ *	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_read_bmm150_mag_trim_mbl(void);
+ /*!
+ *	@brief This function used for read the compensated value of mag
+ *	Before start reading the mag compensated data's
+ *	make sure the following two points are addressed
+ *	@note
+ *	1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note
+ *	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_bmm150_mag_compensate_xyz(
+struct smi130_mag_xyz_s32_t *mag_comp_xyz);
+SMI130_RETURN_FUNCTION_TYPE smi130_bmm150_mag_compensate_xyz_raw(
+struct smi130_mag_xyz_s32_t *mag_comp_xyz, struct smi130_mag_xyzr_t mag_xyzr);
+
+/*!
+ *	@brief This API used to get the compensated BMM150-X data
+ *	the out put of X as s32
+ *	Before start reading the mag compensated X data
+ *	make sure the following two points are addressed
+ *	@note
+ *	1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note
+ *	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+ *
+ *
+ *
+ *  @param  v_mag_data_x_s16 : The value of mag raw X data
+ *  @param  v_data_r_u16 : The value of mag R data
+ *
+ *	@return results of compensated X data value output as s32
+ *
+ */
+s32 smi130_bmm150_mag_compensate_X(s16 v_mag_data_x_s16, u16 v_data_r_u16);
+/*!
+ *	@brief This API used to get the compensated BMM150-Y data
+ *	the out put of Y as s32
+ *	Before start reading the mag compensated Y data
+ *	make sure the following two points are addressed
+ *	@note
+ *	1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note
+ *	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+ *
+ *
+ *
+ *  @param  v_mag_data_y_s16 : The value of mag raw Y data
+ *  @param  v_data_r_u16 : The value of mag R data
+ *
+ *	@return results of compensated Y data value output as s32
+ */
+s32 smi130_bmm150_mag_compensate_Y(s16 v_mag_data_y_s16, u16 v_data_r_u16);
+/*!
+ *	@brief This API used to get the compensated BMM150-Z data
+ *	the out put of Z as s32
+ *	Before start reading the mag compensated Z data
+ *	make sure the following two points are addressed
+ *	@note
+ *	1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note
+ *	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+ *
+ *
+ *
+ *  @param  v_mag_data_z_s16 : The value of mag raw Z data
+ *  @param  v_data_r_u16 : The value of mag R data
+ *
+ *	@return results of compensated Z data value output as s32
+ */
+s32 smi130_bmm150_mag_compensate_Z(s16 v_mag_data_z_s16, u16 v_data_r_u16);
+/*!
+ *	@brief This API used to set the pre-set modes of bmm150
+ *	The pre-set mode setting is depend on data rate and xy and z repetitions
+ *
+ *	@note
+ *	Before set the mag preset mode
+ *	make sure the following two points are addressed
+ *	@note
+ *	1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note
+ *	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+ *
+ *
+ *  @param  v_mode_u8: The value of pre-set mode selection value
+ *  value    |  pre_set mode
+ * ----------|------------
+ *   1       | SMI130_MAG_PRESETMODE_LOWPOWER
+ *   2       | SMI130_MAG_PRESETMODE_REGULAR
+ *   3       | SMI130_MAG_PRESETMODE_HIGHACCURACY
+ *   4       | SMI130_MAG_PRESETMODE_ENHANCED
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_set_bmm150_mag_presetmode(u8 mode);
+/*!
+ *	@brief This function used for set the magnetometer
+ *	power mode.
+ *	@note
+ *	Before set the mag power mode
+ *	make sure the following two points are addressed
+ *	@note
+ *	1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note
+ *	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+ *
+ *	@param v_mag_pow_mode_u8 : The value of mag power mode
+ *  value    |  mode
+ * ----------|------------
+ *   0       | FORCE_MODE
+ *   1       | SUSPEND_MODE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_bmm150_mag_set_power_mode(u8 mag_pow_mode);
+ /*!
+ *	@brief This function used for set the magnetometer
+ *	power mode.
+ *	@note
+ *	Before set the mag power mode
+ *	make sure the following two point is addressed
+ *		Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *
+ *	@param v_mag_sec_if_pow_mode_u8 : The value of mag power mode
+ *  value    |  mode
+ * ----------|------------
+ *   0       | SMI130_MAG_FORCE_MODE
+ *   1       | SMI130_MAG_SUSPEND_MODE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_bmm150_mag_and_secondary_if_power_mode(
+u8 v_mag_sec_if_pow_mode_u8);
+/***************************************************/
+/**\name	FUNCTIONS FOR AKM09911 AND AKM09912*/
+/***************************************************/
+ /*!
+ *	@brief This function used for initialize
+ *	the AKM09911 and AKM09912 sensor
+ *
+ *
+ *	@param v_akm_i2c_address_u8: The value of device address
+ *	AKM sensor   |  Slave address
+ * --------------|---------------------
+ *  AKM09911     |  AKM09911_I2C_ADDR_1
+ *     -         |  and AKM09911_I2C_ADDR_2
+ *  AKM09912     |  AKM09912_I2C_ADDR_1
+ *     -         |  AKM09912_I2C_ADDR_2
+ *     -         |  AKM09912_I2C_ADDR_3
+ *     -         |  AKM09912_I2C_ADDR_4
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_akm_mag_interface_init(
+u8 v_akm_i2c_address_u8);
+ /*!
+ *	@brief This function used for read the sensitivity data of
+ *	AKM09911 and AKM09912
+ *
+ *	@note Before reading the mag sensitivity values
+ *	make sure the following two points are addressed
+ *	@note	1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_read_bosch_akm_sensitivity_data(void);
+/*!
+ *	@brief This API used to get the compensated X data
+ *	of AKM09911 the out put of X as s32
+ *	@note	Before start reading the mag compensated X data
+ *			make sure the following two points are addressed
+ *	@note 1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note 2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+ *
+ *
+ *  @param v_bosch_akm_x_s16 : The value of X data
+ *
+ *	@return results of compensated X data value output as s32
+ *
+ */
+s32 smi130_bosch_akm09911_compensate_X(s16 v_bosch_akm_x_s16);
+/*!
+ *	@brief This API used to get the compensated Y data
+ *	of AKM09911 the out put of Y as s32
+ *	@note	Before start reading the mag compensated Y data
+ *			make sure the following two points are addressed
+ *	@note 1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note 2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+ *
+ *
+ *  @param v_bosch_akm_y_s16 : The value of Y data
+ *
+ *	@return results of compensated Y data value output as s32
+ *
+ */
+s32 smi130_bosch_akm09911_compensate_Y(s16 v_bosch_akm_y_s16);
+/*!
+ *	@brief This API used to get the compensated Z data
+ *	of AKM09911 the out put of Z as s32
+ *	@note	Before start reading the mag compensated Z data
+ *			make sure the following two points are addressed
+ *	@note 1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note 2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+ *
+ *
+ *  @param v_bosch_akm_z_s16 : The value of Z data
+ *
+ *	@return results of compensated Z data value output as s32
+ *
+ */
+s32 smi130_bosch_akm09911_compensate_Z(s16 v_bosch_akm_z_s16);
+/*!
+ *	@brief This API used to get the compensated X data
+ *	of AKM09912 the out put of X as s32
+ *	@note	Before start reading the mag compensated X data
+ *			make sure the following two points are addressed
+ *	@note 1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note 2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+ *
+ *
+ *  @param v_bosch_akm_x_s16 : The value of X data
+ *
+ *	@return results of compensated X data value output as s32
+ *
+ */
+s32 smi130_bosch_akm09912_compensate_X(s16 v_bosch_akm_x_s16);
+/*!
+ *	@brief This API used to get the compensated Y data
+ *	of AKM09912 the out put of Y as s32
+ *	@note	Before start reading the mag compensated Y data
+ *			make sure the following two points are addressed
+ *	@note 1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note 2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+ *
+ *
+ *  @param v_bosch_akm_y_s16 : The value of Y data
+ *
+ *	@return results of compensated Y data value output as s32
+ *
+ */
+s32 smi130_bosch_akm09912_compensate_Y(s16 v_bosch_akm_y_s16);
+/*!
+ *	@brief This API used to get the compensated Z data
+ *	of AKM09912 the out put of Z as s32
+ *	@note	Before start reading the mag compensated Z data
+ *			make sure the following two points are addressed
+ *	@note 1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note 2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+ *
+ *
+ *  @param v_bosch_akm_z_s16 : The value of Z data
+ *
+ *	@return results of compensated Z data value output as s32
+ *
+ */
+s32 smi130_bosch_akm09912_compensate_Z(s16 v_bosch_akm_z_s16);
+ /*!
+ *	@brief This function used for read the compensated value of
+ *	AKM09911
+ *	@note Before start reading the mag compensated data's
+ *	make sure the following two points are addressed
+ *	@note	1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_akm09911_compensate_xyz(
+struct smi130_mag_xyz_s32_t *bosch_akm_xyz);
+ /*!
+ *	@brief This function used for read the compensated value of
+ *	AKM09912
+ *	@note Before start reading the mag compensated data's
+ *	make sure the following two points are addressed
+ *	@note	1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_akm09912_compensate_xyz(
+struct smi130_mag_xyz_s32_t *bosch_akm_xyz);
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_akm09912_compensate_xyz_raw(
+struct smi130_mag_xyz_s32_t *bosch_akm_xyz);
+/*!
+ *	@brief This function used for set the AKM09911 and AKM09912
+ *	power mode.
+ *	@note Before set the AKM power mode
+ *	make sure the following two points are addressed
+ *	@note	1.	Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *	@note	2.	And also confirm the secondary-interface power mode
+ *		is not in the SUSPEND mode.
+ *		by using the function smi130_get_mag_pmu_status().
+ *		If the secondary-interface power mode is in SUSPEND mode
+ *		set the value of 0x19(NORMAL mode)by using the
+ *		smi130_set_command_register(0x19) function.
+ *
+ *	@param v_akm_pow_mode_u8 : The value of akm power mode
+ *  value   |    Description
+ * ---------|--------------------
+ *    0     |  AKM_POWER_DOWN_MODE
+ *    1     |  AKM_SINGLE_MEAS_MODE
+ *    2     |  FUSE_ROM_MODE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_akm_set_powermode(u8 v_akm_pow_mode_u8);
+ /*!
+ *	@brief This function used for set the magnetometer
+ *	power mode of AKM09911 and AKM09912
+ *	@note Before set the mag power mode
+ *	make sure the following two point is addressed
+ *		Make sure the mag interface is enabled or not,
+ *		by using the smi130_get_if_mode() function.
+ *		If mag interface is not enabled set the value of 0x02
+ *		to the function smi130_get_if_mode(0x02)
+ *
+ *	@param v_mag_sec_if_pow_mode_u8 : The value of secondary if power mode
+ *  value   |    Description
+ * ---------|--------------------
+ *    0     |  SMI130_MAG_FORCE_MODE
+ *    1     |  SMI130_MAG_SUSPEND_MODE
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_set_bosch_akm_and_secondary_if_powermode(
+u8 v_mag_sec_if_pow_mode_u8);
+/***************************************************/
+/**\name	FUNCTIONS FOR YAMAH-YAS532 */
+/***************************************************/
+/*!
+ *	@brief This function used for read the YAMAH-YAS532 init
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_yamaha_yas532_mag_interface_init(
+void);
+/*!
+ *	@brief This function used to set the YAS532 initial values
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_yas532_set_initial_values(void);
+/*!
+ *	@brief This function used for YAS532 offset correction
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_yas532_magnetic_measure_set_offset(
+void);
+/*!
+ *	@brief This function used for read the
+ *	YAMAHA YAS532 calibration data
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_yamaha_yas532_calib_values(void);
+/*!
+ *	@brief This function used for calculate the
+ *	YAS532 read the linear data
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_yas532_xy1y2_to_linear(
+u16 *v_xy1y2_u16, s32 *xy1y2_linear);
+/*!
+ *	@brief This function used for read the YAS532 sensor data
+ *	@param	v_acquisition_command_u8: used to set the data acquisition
+ *	acquisition_command  |   operation
+ *  ---------------------|-------------------------
+ *         0x17          | turn on the acquisition coil
+ *         -             | set direction of the coil
+ *         _             | (x and y as minus(-))
+ *         _             | Deferred acquisition mode
+ *        0x07           | turn on the acquisition coil
+ *         _             | set direction of the coil
+ *         _             | (x and y as minus(-))
+ *         _             | Normal acquisition mode
+ *        0x11           | turn OFF the acquisition coil
+ *         _             | set direction of the coil
+ *         _             | (x and y as plus(+))
+ *         _             | Deferred acquisition mode
+ *       0x01            | turn OFF the acquisition coil
+ *        _              | set direction of the coil
+ *        _              | (x and y as plus(+))
+ *        _              | Normal acquisition mode
+ *
+ *	@param	v_busy_u8 : used to get the busy flay for sensor data read
+ *	@param	v_temp_u16 : used to get the temperature data
+ *	@param	v_xy1y2_u16 : used to get the sensor xy1y2 data
+ *	@param	v_overflow_u8 : used to get the overflow data
+ *
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_yas532_normal_measurement_data(
+u8 v_acquisition_command_u8, u8 *v_busy_u8,
+u16 *v_temp_u16, u16 *v_xy1y2_u16, u8 *v_overflow_u8);
+/*!
+ *	@brief This function used for YAS532 sensor data
+ *	@param	v_acquisition_command_u8	:	the value of CMDR
+ *	acquisition_command  |   operation
+ *  ---------------------|-------------------------
+ *         0x17          | turn on the acquisition coil
+ *         -             | set direction of the coil
+ *         _             | (x and y as minus(-))
+ *         _             | Deferred acquisition mode
+ *        0x07           | turn on the acquisition coil
+ *         _             | set direction of the coil
+ *         _             | (x and y as minus(-))
+ *         _             | Normal acquisition mode
+ *        0x11           | turn OFF the acquisition coil
+ *         _             | set direction of the coil
+ *         _             | (x and y as plus(+))
+ *         _             | Deferred acquisition mode
+ *       0x01            | turn OFF the acquisition coil
+ *        _              | set direction of the coil
+ *        _              | (x and y as plus(+))
+ *        _              | Normal acquisition mode
+ *
+ * @param xyz_data : the vector xyz output
+ * @param v_overflow_s8 : the value of overflow
+ * @param v_temp_correction_u8 : the value of temperate correction enable
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_yas532_measurement_xyz_data(
+struct yas532_vector *xyz_data, u8 *v_overflow_s8, u8 v_temp_correction_u8,
+u8 v_acquisition_command_u8);
+/*!
+ *	@brief This function used for YAS532 write data acquisition
+ *	command register write
+ *	@param	v_command_reg_data_u8	:	the value of data acquisition
+ *	acquisition_command  |   operation
+ *  ---------------------|-------------------------
+ *         0x17          | turn on the acquisition coil
+ *         -             | set direction of the coil
+ *         _             | (x and y as minus(-))
+ *         _             | Deferred acquisition mode
+ *        0x07           | turn on the acquisition coil
+ *         _             | set direction of the coil
+ *         _             | (x and y as minus(-))
+ *         _             | Normal acquisition mode
+ *        0x11           | turn OFF the acquisition coil
+ *         _             | set direction of the coil
+ *         _             | (x and y as plus(+))
+ *         _             | Deferred acquisition mode
+ *       0x01            | turn OFF the acquisition coil
+ *        _              | set direction of the coil
+ *        _              | (x and y as plus(+))
+ *        _              | Normal acquisition mode
+ *
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_yas532_acquisition_command_register(
+u8 v_command_reg_data_u8);
+/*!
+ *	@brief This function used write offset of YAS532
+ *
+ *	@param	p_offset_s8	: The value of offset to write
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_yas532_set_offset(
+const s8 *p_offset_s8);
+/*!
+ *	@brief This function used to init the YAMAH-YAS537
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+*/
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_yamaha_yas537_mag_interface_init(
+void);
+/*!
+ *	@brief This function used for read the
+ *	YAMAHA YAS537 calibration data
+ *
+ *
+ *	@param v_rcoil_u8 : The value of r coil
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_yamaha_yas537_calib_values(
+u8 v_rcoil_u8);
+/*!
+ *	@brief This function used for YAS537 write data acquisition
+ *	command register write
+ *	@param	v_command_reg_data_u8	:	the value of data acquisition
+ *	acquisition_command  |   operation
+ *  ---------------------|-------------------------
+ *         0x17          | turn on the acquisition coil
+ *         -             | set direction of the coil
+ *         _             | (x and y as minus(-))
+ *         _             | Deferred acquisition mode
+ *        0x07           | turn on the acquisition coil
+ *         _             | set direction of the coil
+ *         _             | (x and y as minus(-))
+ *         _             | Normal acquisition mode
+ *        0x11           | turn OFF the acquisition coil
+ *         _             | set direction of the coil
+ *         _             | (x and y as plus(+))
+ *         _             | Deferred acquisition mode
+ *       0x01            | turn OFF the acquisition coil
+ *        _              | set direction of the coil
+ *        _              | (x and y as plus(+))
+ *        _              | Normal acquisition mode
+ *
+ *
+ *
+  *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_yas537_acquisition_command_register(
+u8 v_command_reg_data_u8);
+
+/*!
+ *	@brief This function used for read the
+ *	YAMAHA YAS537 xy1y2 data
+ *
+ *	@param v_coil_stat_u8: The value of R coil status
+ *	@param v_busy_u8: The value of busy status
+ *	@param v_temperature_u16: The value of temperature
+ *	@param xy1y2: The value of raw xy1y2 data
+ *	@param v_ouflow_u8: The value of overflow
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_yamaha_yas537_read_xy1y2_data(
+u8 *v_coil_stat_u8, u8 *v_busy_u8,
+u16 *v_temperature_u16, u16 *xy1y2, u8 *v_ouflow_u8);
+/*!
+ *	@brief This function used for read the
+ *	YAMAHA YAS537 xy1y2 data
+ *
+ *	@param v_ouflow_u8: The value of overflow
+ *
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_bosch_yamaha_yas537_measure_xyz_data(
+u8 *v_ouflow_u8, struct yas_vector *vector_xyz);
+
+/***************************************************/
+/**\name	FUNCTIONS FOR FIFO DATA READ */
+/***************************************************/
+/*!
+ *	@brief This function used for reading the
+ *	fifo data of  header less mode
+ *
+ *
+ *
+ *	@note Configure the below functions for FIFO header less mode
+ *	@note 1. smi130_set_fifo_down_gyro
+ *	@note 2. smi130_set_gyro_fifo_filter_data
+ *	@note 3. smi130_set_fifo_down_accel
+ *	@note 4. smi130_set_accel_fifo_filter_dat
+ *	@note 5. smi130_set_fifo_mag_enable
+ *	@note 6. smi130_set_fifo_accel_enable
+ *	@note 7. smi130_set_fifo_gyro_enable
+ *	@note For interrupt configuration
+ *	@note 1. smi130_set_intr_fifo_full
+ *	@note 2. smi130_set_intr_fifo_wm
+ *	@note 3. smi130_set_fifo_tag_intr2_enable
+ *	@note 4. smi130_set_fifo_tag_intr1_enable
+ *
+ *	@note The fifo reads the whole 1024 bytes
+ *	and processing the data
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_read_fifo_headerless_mode(
+void);
+/*!
+ *	@brief This function used for reading the
+ *	fifo data of  header less mode for using user defined length
+ *
+ *
+ *	@param v_fifo_user_length_u16: The value of length of fifo read data
+ *
+ *	@note Configure the below functions for FIFO header less mode
+ *	@note 1. smi130_set_fifo_down_gyro
+ *	@note 2. smi130_set_gyro_fifo_filter_data
+ *	@note 3. smi130_set_fifo_down_accel
+ *	@note 4. smi130_set_accel_fifo_filter_dat
+ *	@note 5. smi130_set_fifo_mag_enable
+ *	@note 6. smi130_set_fifo_accel_enable
+ *	@note 7. smi130_set_fifo_gyro_enable
+ *	@note For interrupt configuration
+ *	@note 1. smi130_set_intr_fifo_full
+ *	@note 2. smi130_set_intr_fifo_wm
+ *	@note 3. smi130_set_fifo_tag_intr2_enable
+ *	@note 4. smi130_set_fifo_tag_intr1_enable
+ *
+ *	@note The fifo reads the whole 1024 bytes
+ *	and processing the data
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE
+smi130_read_fifo_headerless_mode_user_defined_length(
+u16 v_fifo_user_length_u16);
+/*!
+ *	@brief This function used for reading the
+ *	fifo data of  header mode
+ *
+ *
+ *	@note Configure the below functions for FIFO header mode
+ *	@note 1. smi130_set_fifo_down_gyro()
+ *	@note 2. smi130_set_gyro_fifo_filter_data()
+ *	@note 3. smi130_set_fifo_down_accel()
+ *	@note 4. smi130_set_accel_fifo_filter_dat()
+ *	@note 5. smi130_set_fifo_mag_enable()
+ *	@note 6. smi130_set_fifo_accel_enable()
+ *	@note 7. smi130_set_fifo_gyro_enable()
+ *	@note 8. smi130_set_fifo_header_enable()
+ *	@note For interrupt configuration
+ *	@note 1. smi130_set_intr_fifo_full()
+ *	@note 2. smi130_set_intr_fifo_wm()
+ *	@note 3. smi130_set_fifo_tag_intr2_enable()
+ *	@note 4. smi130_set_fifo_tag_intr1_enable()
+ *
+ *	@note The fifo reads the whole 1024 bytes
+ *	and processing the data
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_read_fifo_header_data(
+void);
+/*!
+ *	@brief This function used for reading the
+ *	fifo data of  header mode for using user defined length
+ *
+ *
+ *	@note Configure the below functions for FIFO header mode
+ *	@note 1. smi130_set_fifo_down_gyro()
+ *	@note 2. smi130_set_gyro_fifo_filter_data()
+ *	@note 3. smi130_set_fifo_down_accel()
+ *	@note 4. smi130_set_accel_fifo_filter_dat()
+ *	@note 5. smi130_set_fifo_mag_enable()
+ *	@note 6. smi130_set_fifo_accel_enable()
+ *	@note 7. smi130_set_fifo_gyro_enable()
+ *	@note 8. smi130_set_fifo_header_enable()
+ *	@note For interrupt configuration
+ *	@note 1. smi130_set_intr_fifo_full()
+ *	@note 2. smi130_set_intr_fifo_wm()
+ *	@note 3. smi130_set_fifo_tag_intr2_enable()
+ *	@note 4. smi130_set_fifo_tag_intr1_enable()
+ *
+ *	@note The fifo reads the whole 1024 bytes
+ *	and processing the data
+ *
+ *	@return results of bus communication function
+ *	@retval 0 -> Success
+ *	@retval -1 -> Error
+ *
+ *
+ */
+SMI130_RETURN_FUNCTION_TYPE smi130_read_fifo_header_data_user_defined_length(
+u16 v_fifo_user_length_u16);
+/*!
+ *	@brief This function used for reading
+ *	smi130_t structure
+ *
+ *  @return the reference and values of smi130_t
+ *
+ *
+*/
+struct smi130_t *smi130_get_ptr(void);
+
+#endif
+
diff --git a/drivers/input/sensors/smi130/smi130_acc.c b/drivers/input/sensors/smi130/smi130_acc.c
new file mode 100644
index 0000000..4828b39
--- /dev/null
+++ b/drivers/input/sensors/smi130/smi130_acc.c
@@ -0,0 +1,7507 @@
+/*!
+ * @section LICENSE
+ * (C) Copyright 2011~2016 Bosch Sensortec GmbH All Rights Reserved
+ *
+ * (C) Modification Copyright 2018 Robert Bosch Kft  All Rights Reserved
+ *
+ * This software program is licensed subject to the GNU General
+ * Public License (GPL).Version 2,June 1991,
+ * available at http://www.fsf.org/copyleft/gpl.html
+ *
+ * Special: Description of the Software:
+ *
+ * This software module (hereinafter called "Software") and any
+ * information on application-sheets (hereinafter called "Information") is
+ * provided free of charge for the sole purpose to support your application
+ * work. 
+ *
+ * As such, the Software is merely an experimental software, not tested for
+ * safety in the field and only intended for inspiration for further development 
+ * and testing. Any usage in a safety-relevant field of use (like automotive,
+ * seafaring, spacefaring, industrial plants etc.) was not intended, so there are
+ * no precautions for such usage incorporated in the Software.
+ * 
+ * The Software is specifically designed for the exclusive use for Bosch
+ * Sensortec products by personnel who have special experience and training. Do
+ * not use this Software if you do not have the proper experience or training.
+ * 
+ * This Software package is provided as is and without any expressed or
+ * implied warranties, including without limitation, the implied warranties of
+ * merchantability and fitness for a particular purpose.
+ * 
+ * Bosch Sensortec and their representatives and agents deny any liability for
+ * the functional impairment of this Software in terms of fitness, performance
+ * and safety. Bosch Sensortec and their representatives and agents shall not be
+ * liable for any direct or indirect damages or injury, except as otherwise
+ * stipulated in mandatory applicable law.
+ * The Information provided is believed to be accurate and reliable. Bosch
+ * Sensortec assumes no responsibility for the consequences of use of such
+ * Information nor for any infringement of patents or other rights of third
+ * parties which may result from its use.
+ * 
+ *------------------------------------------------------------------------------
+ * The following Product Disclaimer does not apply to the BSX4-HAL-4.1NoFusion Software 
+ * which is licensed under the Apache License, Version 2.0 as stated above.  
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Product Disclaimer
+ *
+ * Common:
+ *
+ * Assessment of Products Returned from Field
+ *
+ * Returned products are considered good if they fulfill the specifications / 
+ * test data for 0-mileage and field listed in this document.
+ *
+ * Engineering Samples
+ * 
+ * Engineering samples are marked with (e) or (E). Samples may vary from the
+ * valid technical specifications of the series product contained in this
+ * data sheet. Therefore, they are not intended or fit for resale to
+ * third parties or for use in end products. Their sole purpose is internal
+ * client testing. The testing of an engineering sample may in no way replace
+ * the testing of a series product. Bosch assumes no liability for the use
+ * of engineering samples. The purchaser shall indemnify Bosch from all claims
+ * arising from the use of engineering samples.
+ *
+ * Intended use
+ *
+ * Provided that SMI130 is used within the conditions (environment, application,
+ * installation, loads) as described in this TCD and the corresponding
+ * agreed upon documents, Bosch ensures that the product complies with
+ * the agreed properties. Agreements beyond this require
+ * the written approval by Bosch. The product is considered fit for the intended
+ * use when the product successfully has passed the tests
+ * in accordance with the TCD and agreed upon documents.
+ *
+ * It is the responsibility of the customer to ensure the proper application
+ * of the product in the overall system/vehicle.
+ *
+ * Bosch does not assume any responsibility for changes to the environment
+ * of the product that deviate from the TCD and the agreed upon documents 
+ * as well as all applications not released by Bosch
+  *
+ * The resale and/or use of products are at the purchaser’s own risk and 
+ * responsibility. The examination and testing of the SMI130 
+ * is the sole responsibility of the purchaser.
+ *
+ * The purchaser shall indemnify Bosch from all third party claims 
+ * arising from any product use not covered by the parameters of 
+ * this product data sheet or not approved by Bosch and reimburse Bosch 
+ * for all costs and damages in connection with such claims.
+ *
+ * The purchaser must monitor the market for the purchased products,
+ * particularly with regard to product safety, and inform Bosch without delay
+ * of all security relevant incidents.
+ *
+ * Application Examples and Hints
+ *
+ * With respect to any application examples, advice, normal values
+ * and/or any information regarding the application of the device,
+ * Bosch hereby disclaims any and all warranties and liabilities of any kind,
+ * including without limitation warranties of
+ * non-infringement of intellectual property rights or copyrights
+ * of any third party.
+ * The information given in this document shall in no event be regarded 
+ * as a guarantee of conditions or characteristics. They are provided
+ * for illustrative purposes only and no evaluation regarding infringement
+ * of intellectual property rights or copyrights or regarding functionality,
+ * performance or error has been made.
+ *
+ * @filename smi130_acc.c
+ * @date    2015/11/17 10:32
+ * @Modification Date 2018/08/28 18:20
+ * @id       "836294d"
+ * @version  2.1.2
+ *
+ * @brief
+ * This file contains all function implementations for the SMI_ACC2X2 in linux
+*/
+
+#ifdef CONFIG_SIG_MOTION
+#undef CONFIG_HAS_EARLYSUSPEND
+#endif
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/i2c.h>
+#include <linux/input.h>
+#include <linux/workqueue.h>
+#include <linux/mutex.h>
+#include <linux/slab.h>
+#include <linux/mutex.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+#include <asm/irq.h>
+#include <linux/math64.h>
+
+#ifdef CONFIG_HAS_EARLYSUSPEND
+#include <linux/earlysuspend.h>
+#endif
+
+#ifdef __KERNEL__
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/unistd.h>
+#include <linux/types.h>
+#include <linux/string.h>
+#else
+#include <unistd.h>
+#include <sys/types.h>
+#include <string.h>
+#endif
+
+#include "boschclass.h"
+#include "bs_log.h"
+#define DRIVER_VERSION "0.0.53.0"
+#define ACC_NAME  "ACC"
+#define SMI_ACC2X2_ENABLE_INT1 1
+#define CONFIG_SMI_ACC_ENABLE_NEWDATA_INT 1
+
+#define SENSOR_NAME                 "smi130_acc"
+#define SMI130_ACC_USE_BASIC_I2C_FUNC        1
+
+#define MSC_TIME                6
+#define ABSMIN                      -512
+#define ABSMAX                      512
+#define SLOPE_THRESHOLD_VALUE       32
+#define SLOPE_DURATION_VALUE        1
+#define INTERRUPT_LATCH_MODE        13
+#define INTERRUPT_ENABLE            1
+#define INTERRUPT_DISABLE           0
+#define MAP_SLOPE_INTERRUPT         2
+#define SLOPE_X_INDEX               5
+#define SLOPE_Y_INDEX               6
+#define SLOPE_Z_INDEX               7
+#define SMI_ACC2X2_MAX_DELAY            200
+#define SMI_ACC2X2_RANGE_SET            3  /* +/- 2G */
+#define SMI_ACC2X2_BW_SET               12 /* 125HZ  */
+
+#define LOW_G_INTERRUPT             REL_Z
+#define HIGH_G_INTERRUPT            REL_HWHEEL
+#define SLOP_INTERRUPT              REL_DIAL
+#define DOUBLE_TAP_INTERRUPT        REL_WHEEL
+#define SINGLE_TAP_INTERRUPT        REL_MISC
+#define ORIENT_INTERRUPT            ABS_PRESSURE
+#define FLAT_INTERRUPT              ABS_DISTANCE
+#define SLOW_NO_MOTION_INTERRUPT    REL_Y
+
+#define HIGH_G_INTERRUPT_X_HAPPENED                 1
+#define HIGH_G_INTERRUPT_Y_HAPPENED                 2
+#define HIGH_G_INTERRUPT_Z_HAPPENED                 3
+#define HIGH_G_INTERRUPT_X_NEGATIVE_HAPPENED        4
+#define HIGH_G_INTERRUPT_Y_NEGATIVE_HAPPENED        5
+#define HIGH_G_INTERRUPT_Z_NEGATIVE_HAPPENED        6
+#define SLOPE_INTERRUPT_X_HAPPENED                  7
+#define SLOPE_INTERRUPT_Y_HAPPENED                  8
+#define SLOPE_INTERRUPT_Z_HAPPENED                  9
+#define SLOPE_INTERRUPT_X_NEGATIVE_HAPPENED         10
+#define SLOPE_INTERRUPT_Y_NEGATIVE_HAPPENED         11
+#define SLOPE_INTERRUPT_Z_NEGATIVE_HAPPENED         12
+#define DOUBLE_TAP_INTERRUPT_HAPPENED               13
+#define SINGLE_TAP_INTERRUPT_HAPPENED               14
+#define UPWARD_PORTRAIT_UP_INTERRUPT_HAPPENED       15
+#define UPWARD_PORTRAIT_DOWN_INTERRUPT_HAPPENED     16
+#define UPWARD_LANDSCAPE_LEFT_INTERRUPT_HAPPENED    17
+#define UPWARD_LANDSCAPE_RIGHT_INTERRUPT_HAPPENED   18
+#define DOWNWARD_PORTRAIT_UP_INTERRUPT_HAPPENED     19
+#define DOWNWARD_PORTRAIT_DOWN_INTERRUPT_HAPPENED   20
+#define DOWNWARD_LANDSCAPE_LEFT_INTERRUPT_HAPPENED  21
+#define DOWNWARD_LANDSCAPE_RIGHT_INTERRUPT_HAPPENED 22
+#define FLAT_INTERRUPT_TURE_HAPPENED                23
+#define FLAT_INTERRUPT_FALSE_HAPPENED               24
+#define LOW_G_INTERRUPT_HAPPENED                    25
+#define SLOW_NO_MOTION_INTERRUPT_HAPPENED           26
+
+#define PAD_LOWG                    0
+#define PAD_HIGHG                   1
+#define PAD_SLOP                    2
+#define PAD_DOUBLE_TAP              3
+#define PAD_SINGLE_TAP              4
+#define PAD_ORIENT                  5
+#define PAD_FLAT                    6
+#define PAD_SLOW_NO_MOTION          7
+
+#define SMI_ACC2X2_EEP_OFFSET                       0x16
+#define SMI_ACC2X2_IMAGE_BASE                       0x38
+#define SMI_ACC2X2_IMAGE_LEN                        22
+
+#define SMI_ACC2X2_CHIP_ID_REG                      0x00
+#define SMI_ACC2X2_VERSION_REG                      0x01
+#define SMI_ACC2X2_X_AXIS_LSB_REG                   0x02
+#define SMI_ACC2X2_X_AXIS_MSB_REG                   0x03
+#define SMI_ACC2X2_Y_AXIS_LSB_REG                   0x04
+#define SMI_ACC2X2_Y_AXIS_MSB_REG                   0x05
+#define SMI_ACC2X2_Z_AXIS_LSB_REG                   0x06
+#define SMI_ACC2X2_Z_AXIS_MSB_REG                   0x07
+#define SMI_ACC2X2_TEMPERATURE_REG                  0x08
+#define SMI_ACC2X2_STATUS1_REG                      0x09
+#define SMI_ACC2X2_STATUS2_REG                      0x0A
+#define SMI_ACC2X2_STATUS_TAP_SLOPE_REG             0x0B
+#define SMI_ACC2X2_STATUS_ORIENT_HIGH_REG           0x0C
+#define SMI_ACC2X2_STATUS_FIFO_REG                  0x0E
+#define SMI_ACC2X2_RANGE_SEL_REG                    0x0F
+#define SMI_ACC2X2_BW_SEL_REG                       0x10
+#define SMI_ACC2X2_MODE_CTRL_REG                    0x11
+#define SMI_ACC2X2_LOW_NOISE_CTRL_REG               0x12
+#define SMI_ACC2X2_DATA_CTRL_REG                    0x13
+#define SMI_ACC2X2_RESET_REG                        0x14
+#define SMI_ACC2X2_INT_ENABLE1_REG                  0x16
+#define SMI_ACC2X2_INT_ENABLE2_REG                  0x17
+#define SMI_ACC2X2_INT_SLO_NO_MOT_REG               0x18
+#define SMI_ACC2X2_INT1_PAD_SEL_REG                 0x19
+#define SMI_ACC2X2_INT_DATA_SEL_REG                 0x1A
+#define SMI_ACC2X2_INT2_PAD_SEL_REG                 0x1B
+#define SMI_ACC2X2_INT_SRC_REG                      0x1E
+#define SMI_ACC2X2_INT_SET_REG                      0x20
+#define SMI_ACC2X2_INT_CTRL_REG                     0x21
+#define SMI_ACC2X2_LOW_DURN_REG                     0x22
+#define SMI_ACC2X2_LOW_THRES_REG                    0x23
+#define SMI_ACC2X2_LOW_HIGH_HYST_REG                0x24
+#define SMI_ACC2X2_HIGH_DURN_REG                    0x25
+#define SMI_ACC2X2_HIGH_THRES_REG                   0x26
+#define SMI_ACC2X2_SLOPE_DURN_REG                   0x27
+#define SMI_ACC2X2_SLOPE_THRES_REG                  0x28
+#define SMI_ACC2X2_SLO_NO_MOT_THRES_REG             0x29
+#define SMI_ACC2X2_TAP_PARAM_REG                    0x2A
+#define SMI_ACC2X2_TAP_THRES_REG                    0x2B
+#define SMI_ACC2X2_ORIENT_PARAM_REG                 0x2C
+#define SMI_ACC2X2_THETA_BLOCK_REG                  0x2D
+#define SMI_ACC2X2_THETA_FLAT_REG                   0x2E
+#define SMI_ACC2X2_FLAT_HOLD_TIME_REG               0x2F
+#define SMI_ACC2X2_FIFO_WML_TRIG                    0x30
+#define SMI_ACC2X2_SELF_TEST_REG                    0x32
+#define SMI_ACC2X2_EEPROM_CTRL_REG                  0x33
+#define SMI_ACC2X2_SERIAL_CTRL_REG                  0x34
+#define SMI_ACC2X2_EXTMODE_CTRL_REG                 0x35
+#define SMI_ACC2X2_OFFSET_CTRL_REG                  0x36
+#define SMI_ACC2X2_OFFSET_PARAMS_REG                0x37
+#define SMI_ACC2X2_OFFSET_X_AXIS_REG                0x38
+#define SMI_ACC2X2_OFFSET_Y_AXIS_REG                0x39
+#define SMI_ACC2X2_OFFSET_Z_AXIS_REG                0x3A
+#define SMI_ACC2X2_GP0_REG                          0x3B
+#define SMI_ACC2X2_GP1_REG                          0x3C
+#define SMI_ACC2X2_FIFO_MODE_REG                    0x3E
+#define SMI_ACC2X2_FIFO_DATA_OUTPUT_REG             0x3F
+
+#define SMI_ACC2X2_CHIP_ID__POS             0
+#define SMI_ACC2X2_CHIP_ID__MSK             0xFF
+#define SMI_ACC2X2_CHIP_ID__LEN             8
+#define SMI_ACC2X2_CHIP_ID__REG             SMI_ACC2X2_CHIP_ID_REG
+
+#define SMI_ACC2X2_VERSION__POS          0
+#define SMI_ACC2X2_VERSION__LEN          8
+#define SMI_ACC2X2_VERSION__MSK          0xFF
+#define SMI_ACC2X2_VERSION__REG          SMI_ACC2X2_VERSION_REG
+
+#define SMI130_ACC_SLO_NO_MOT_DUR__POS   2
+#define SMI130_ACC_SLO_NO_MOT_DUR__LEN   6
+#define SMI130_ACC_SLO_NO_MOT_DUR__MSK   0xFC
+#define SMI130_ACC_SLO_NO_MOT_DUR__REG   SMI_ACC2X2_SLOPE_DURN_REG
+
+#define SMI_ACC2X2_NEW_DATA_X__POS          0
+#define SMI_ACC2X2_NEW_DATA_X__LEN          1
+#define SMI_ACC2X2_NEW_DATA_X__MSK          0x01
+#define SMI_ACC2X2_NEW_DATA_X__REG          SMI_ACC2X2_X_AXIS_LSB_REG
+
+#define SMI_ACC2X2_ACC_X14_LSB__POS           2
+#define SMI_ACC2X2_ACC_X14_LSB__LEN           6
+#define SMI_ACC2X2_ACC_X14_LSB__MSK           0xFC
+#define SMI_ACC2X2_ACC_X14_LSB__REG           SMI_ACC2X2_X_AXIS_LSB_REG
+
+#define SMI_ACC2X2_ACC_X12_LSB__POS           4
+#define SMI_ACC2X2_ACC_X12_LSB__LEN           4
+#define SMI_ACC2X2_ACC_X12_LSB__MSK           0xF0
+#define SMI_ACC2X2_ACC_X12_LSB__REG           SMI_ACC2X2_X_AXIS_LSB_REG
+
+#define SMI_ACC2X2_ACC_X10_LSB__POS           6
+#define SMI_ACC2X2_ACC_X10_LSB__LEN           2
+#define SMI_ACC2X2_ACC_X10_LSB__MSK           0xC0
+#define SMI_ACC2X2_ACC_X10_LSB__REG           SMI_ACC2X2_X_AXIS_LSB_REG
+
+#define SMI_ACC2X2_ACC_X8_LSB__POS           0
+#define SMI_ACC2X2_ACC_X8_LSB__LEN           0
+#define SMI_ACC2X2_ACC_X8_LSB__MSK           0x00
+#define SMI_ACC2X2_ACC_X8_LSB__REG           SMI_ACC2X2_X_AXIS_LSB_REG
+
+#define SMI_ACC2X2_ACC_X_MSB__POS           0
+#define SMI_ACC2X2_ACC_X_MSB__LEN           8
+#define SMI_ACC2X2_ACC_X_MSB__MSK           0xFF
+#define SMI_ACC2X2_ACC_X_MSB__REG           SMI_ACC2X2_X_AXIS_MSB_REG
+
+#define SMI_ACC2X2_NEW_DATA_Y__POS          0
+#define SMI_ACC2X2_NEW_DATA_Y__LEN          1
+#define SMI_ACC2X2_NEW_DATA_Y__MSK          0x01
+#define SMI_ACC2X2_NEW_DATA_Y__REG          SMI_ACC2X2_Y_AXIS_LSB_REG
+
+#define SMI_ACC2X2_ACC_Y14_LSB__POS           2
+#define SMI_ACC2X2_ACC_Y14_LSB__LEN           6
+#define SMI_ACC2X2_ACC_Y14_LSB__MSK           0xFC
+#define SMI_ACC2X2_ACC_Y14_LSB__REG           SMI_ACC2X2_Y_AXIS_LSB_REG
+
+#define SMI_ACC2X2_ACC_Y12_LSB__POS           4
+#define SMI_ACC2X2_ACC_Y12_LSB__LEN           4
+#define SMI_ACC2X2_ACC_Y12_LSB__MSK           0xF0
+#define SMI_ACC2X2_ACC_Y12_LSB__REG           SMI_ACC2X2_Y_AXIS_LSB_REG
+
+#define SMI_ACC2X2_ACC_Y10_LSB__POS           6
+#define SMI_ACC2X2_ACC_Y10_LSB__LEN           2
+#define SMI_ACC2X2_ACC_Y10_LSB__MSK           0xC0
+#define SMI_ACC2X2_ACC_Y10_LSB__REG           SMI_ACC2X2_Y_AXIS_LSB_REG
+
+#define SMI_ACC2X2_ACC_Y8_LSB__POS           0
+#define SMI_ACC2X2_ACC_Y8_LSB__LEN           0
+#define SMI_ACC2X2_ACC_Y8_LSB__MSK           0x00
+#define SMI_ACC2X2_ACC_Y8_LSB__REG           SMI_ACC2X2_Y_AXIS_LSB_REG
+
+#define SMI_ACC2X2_ACC_Y_MSB__POS           0
+#define SMI_ACC2X2_ACC_Y_MSB__LEN           8
+#define SMI_ACC2X2_ACC_Y_MSB__MSK           0xFF
+#define SMI_ACC2X2_ACC_Y_MSB__REG           SMI_ACC2X2_Y_AXIS_MSB_REG
+
+#define SMI_ACC2X2_NEW_DATA_Z__POS          0
+#define SMI_ACC2X2_NEW_DATA_Z__LEN          1
+#define SMI_ACC2X2_NEW_DATA_Z__MSK          0x01
+#define SMI_ACC2X2_NEW_DATA_Z__REG          SMI_ACC2X2_Z_AXIS_LSB_REG
+
+#define SMI_ACC2X2_ACC_Z14_LSB__POS           2
+#define SMI_ACC2X2_ACC_Z14_LSB__LEN           6
+#define SMI_ACC2X2_ACC_Z14_LSB__MSK           0xFC
+#define SMI_ACC2X2_ACC_Z14_LSB__REG           SMI_ACC2X2_Z_AXIS_LSB_REG
+
+#define SMI_ACC2X2_ACC_Z12_LSB__POS           4
+#define SMI_ACC2X2_ACC_Z12_LSB__LEN           4
+#define SMI_ACC2X2_ACC_Z12_LSB__MSK           0xF0
+#define SMI_ACC2X2_ACC_Z12_LSB__REG           SMI_ACC2X2_Z_AXIS_LSB_REG
+
+#define SMI_ACC2X2_ACC_Z10_LSB__POS           6
+#define SMI_ACC2X2_ACC_Z10_LSB__LEN           2
+#define SMI_ACC2X2_ACC_Z10_LSB__MSK           0xC0
+#define SMI_ACC2X2_ACC_Z10_LSB__REG           SMI_ACC2X2_Z_AXIS_LSB_REG
+
+#define SMI_ACC2X2_ACC_Z8_LSB__POS           0
+#define SMI_ACC2X2_ACC_Z8_LSB__LEN           0
+#define SMI_ACC2X2_ACC_Z8_LSB__MSK           0x00
+#define SMI_ACC2X2_ACC_Z8_LSB__REG           SMI_ACC2X2_Z_AXIS_LSB_REG
+
+#define SMI_ACC2X2_ACC_Z_MSB__POS           0
+#define SMI_ACC2X2_ACC_Z_MSB__LEN           8
+#define SMI_ACC2X2_ACC_Z_MSB__MSK           0xFF
+#define SMI_ACC2X2_ACC_Z_MSB__REG           SMI_ACC2X2_Z_AXIS_MSB_REG
+
+#define SMI_ACC2X2_TEMPERATURE__POS         0
+#define SMI_ACC2X2_TEMPERATURE__LEN         8
+#define SMI_ACC2X2_TEMPERATURE__MSK         0xFF
+#define SMI_ACC2X2_TEMPERATURE__REG         SMI_ACC2X2_TEMP_RD_REG
+
+#define SMI_ACC2X2_LOWG_INT_S__POS          0
+#define SMI_ACC2X2_LOWG_INT_S__LEN          1
+#define SMI_ACC2X2_LOWG_INT_S__MSK          0x01
+#define SMI_ACC2X2_LOWG_INT_S__REG          SMI_ACC2X2_STATUS1_REG
+
+#define SMI_ACC2X2_HIGHG_INT_S__POS          1
+#define SMI_ACC2X2_HIGHG_INT_S__LEN          1
+#define SMI_ACC2X2_HIGHG_INT_S__MSK          0x02
+#define SMI_ACC2X2_HIGHG_INT_S__REG          SMI_ACC2X2_STATUS1_REG
+
+#define SMI_ACC2X2_SLOPE_INT_S__POS          2
+#define SMI_ACC2X2_SLOPE_INT_S__LEN          1
+#define SMI_ACC2X2_SLOPE_INT_S__MSK          0x04
+#define SMI_ACC2X2_SLOPE_INT_S__REG          SMI_ACC2X2_STATUS1_REG
+
+
+#define SMI_ACC2X2_SLO_NO_MOT_INT_S__POS          3
+#define SMI_ACC2X2_SLO_NO_MOT_INT_S__LEN          1
+#define SMI_ACC2X2_SLO_NO_MOT_INT_S__MSK          0x08
+#define SMI_ACC2X2_SLO_NO_MOT_INT_S__REG          SMI_ACC2X2_STATUS1_REG
+
+#define SMI_ACC2X2_DOUBLE_TAP_INT_S__POS     4
+#define SMI_ACC2X2_DOUBLE_TAP_INT_S__LEN     1
+#define SMI_ACC2X2_DOUBLE_TAP_INT_S__MSK     0x10
+#define SMI_ACC2X2_DOUBLE_TAP_INT_S__REG     SMI_ACC2X2_STATUS1_REG
+
+#define SMI_ACC2X2_SINGLE_TAP_INT_S__POS     5
+#define SMI_ACC2X2_SINGLE_TAP_INT_S__LEN     1
+#define SMI_ACC2X2_SINGLE_TAP_INT_S__MSK     0x20
+#define SMI_ACC2X2_SINGLE_TAP_INT_S__REG     SMI_ACC2X2_STATUS1_REG
+
+#define SMI_ACC2X2_ORIENT_INT_S__POS         6
+#define SMI_ACC2X2_ORIENT_INT_S__LEN         1
+#define SMI_ACC2X2_ORIENT_INT_S__MSK         0x40
+#define SMI_ACC2X2_ORIENT_INT_S__REG         SMI_ACC2X2_STATUS1_REG
+
+#define SMI_ACC2X2_FLAT_INT_S__POS           7
+#define SMI_ACC2X2_FLAT_INT_S__LEN           1
+#define SMI_ACC2X2_FLAT_INT_S__MSK           0x80
+#define SMI_ACC2X2_FLAT_INT_S__REG           SMI_ACC2X2_STATUS1_REG
+
+#define SMI_ACC2X2_FIFO_FULL_INT_S__POS           5
+#define SMI_ACC2X2_FIFO_FULL_INT_S__LEN           1
+#define SMI_ACC2X2_FIFO_FULL_INT_S__MSK           0x20
+#define SMI_ACC2X2_FIFO_FULL_INT_S__REG           SMI_ACC2X2_STATUS2_REG
+
+#define SMI_ACC2X2_FIFO_WM_INT_S__POS           6
+#define SMI_ACC2X2_FIFO_WM_INT_S__LEN           1
+#define SMI_ACC2X2_FIFO_WM_INT_S__MSK           0x40
+#define SMI_ACC2X2_FIFO_WM_INT_S__REG           SMI_ACC2X2_STATUS2_REG
+
+#define SMI_ACC2X2_DATA_INT_S__POS           7
+#define SMI_ACC2X2_DATA_INT_S__LEN           1
+#define SMI_ACC2X2_DATA_INT_S__MSK           0x80
+#define SMI_ACC2X2_DATA_INT_S__REG           SMI_ACC2X2_STATUS2_REG
+
+#define SMI_ACC2X2_SLOPE_FIRST_X__POS        0
+#define SMI_ACC2X2_SLOPE_FIRST_X__LEN        1
+#define SMI_ACC2X2_SLOPE_FIRST_X__MSK        0x01
+#define SMI_ACC2X2_SLOPE_FIRST_X__REG        SMI_ACC2X2_STATUS_TAP_SLOPE_REG
+
+#define SMI_ACC2X2_SLOPE_FIRST_Y__POS        1
+#define SMI_ACC2X2_SLOPE_FIRST_Y__LEN        1
+#define SMI_ACC2X2_SLOPE_FIRST_Y__MSK        0x02
+#define SMI_ACC2X2_SLOPE_FIRST_Y__REG        SMI_ACC2X2_STATUS_TAP_SLOPE_REG
+
+#define SMI_ACC2X2_SLOPE_FIRST_Z__POS        2
+#define SMI_ACC2X2_SLOPE_FIRST_Z__LEN        1
+#define SMI_ACC2X2_SLOPE_FIRST_Z__MSK        0x04
+#define SMI_ACC2X2_SLOPE_FIRST_Z__REG        SMI_ACC2X2_STATUS_TAP_SLOPE_REG
+
+#define SMI_ACC2X2_SLOPE_SIGN_S__POS         3
+#define SMI_ACC2X2_SLOPE_SIGN_S__LEN         1
+#define SMI_ACC2X2_SLOPE_SIGN_S__MSK         0x08
+#define SMI_ACC2X2_SLOPE_SIGN_S__REG         SMI_ACC2X2_STATUS_TAP_SLOPE_REG
+
+#define SMI_ACC2X2_TAP_FIRST_X__POS        4
+#define SMI_ACC2X2_TAP_FIRST_X__LEN        1
+#define SMI_ACC2X2_TAP_FIRST_X__MSK        0x10
+#define SMI_ACC2X2_TAP_FIRST_X__REG        SMI_ACC2X2_STATUS_TAP_SLOPE_REG
+
+#define SMI_ACC2X2_TAP_FIRST_Y__POS        5
+#define SMI_ACC2X2_TAP_FIRST_Y__LEN        1
+#define SMI_ACC2X2_TAP_FIRST_Y__MSK        0x20
+#define SMI_ACC2X2_TAP_FIRST_Y__REG        SMI_ACC2X2_STATUS_TAP_SLOPE_REG
+
+#define SMI_ACC2X2_TAP_FIRST_Z__POS        6
+#define SMI_ACC2X2_TAP_FIRST_Z__LEN        1
+#define SMI_ACC2X2_TAP_FIRST_Z__MSK        0x40
+#define SMI_ACC2X2_TAP_FIRST_Z__REG        SMI_ACC2X2_STATUS_TAP_SLOPE_REG
+
+#define SMI_ACC2X2_TAP_SIGN_S__POS         7
+#define SMI_ACC2X2_TAP_SIGN_S__LEN         1
+#define SMI_ACC2X2_TAP_SIGN_S__MSK         0x80
+#define SMI_ACC2X2_TAP_SIGN_S__REG         SMI_ACC2X2_STATUS_TAP_SLOPE_REG
+
+#define SMI_ACC2X2_HIGHG_FIRST_X__POS        0
+#define SMI_ACC2X2_HIGHG_FIRST_X__LEN        1
+#define SMI_ACC2X2_HIGHG_FIRST_X__MSK        0x01
+#define SMI_ACC2X2_HIGHG_FIRST_X__REG        SMI_ACC2X2_STATUS_ORIENT_HIGH_REG
+
+#define SMI_ACC2X2_HIGHG_FIRST_Y__POS        1
+#define SMI_ACC2X2_HIGHG_FIRST_Y__LEN        1
+#define SMI_ACC2X2_HIGHG_FIRST_Y__MSK        0x02
+#define SMI_ACC2X2_HIGHG_FIRST_Y__REG        SMI_ACC2X2_STATUS_ORIENT_HIGH_REG
+
+#define SMI_ACC2X2_HIGHG_FIRST_Z__POS        2
+#define SMI_ACC2X2_HIGHG_FIRST_Z__LEN        1
+#define SMI_ACC2X2_HIGHG_FIRST_Z__MSK        0x04
+#define SMI_ACC2X2_HIGHG_FIRST_Z__REG        SMI_ACC2X2_STATUS_ORIENT_HIGH_REG
+
+#define SMI_ACC2X2_HIGHG_SIGN_S__POS         3
+#define SMI_ACC2X2_HIGHG_SIGN_S__LEN         1
+#define SMI_ACC2X2_HIGHG_SIGN_S__MSK         0x08
+#define SMI_ACC2X2_HIGHG_SIGN_S__REG         SMI_ACC2X2_STATUS_ORIENT_HIGH_REG
+
+#define SMI_ACC2X2_ORIENT_S__POS             4
+#define SMI_ACC2X2_ORIENT_S__LEN             3
+#define SMI_ACC2X2_ORIENT_S__MSK             0x70
+#define SMI_ACC2X2_ORIENT_S__REG             SMI_ACC2X2_STATUS_ORIENT_HIGH_REG
+
+#define SMI_ACC2X2_FLAT_S__POS               7
+#define SMI_ACC2X2_FLAT_S__LEN               1
+#define SMI_ACC2X2_FLAT_S__MSK               0x80
+#define SMI_ACC2X2_FLAT_S__REG               SMI_ACC2X2_STATUS_ORIENT_HIGH_REG
+
+#define SMI_ACC2X2_FIFO_FRAME_COUNTER_S__POS             0
+#define SMI_ACC2X2_FIFO_FRAME_COUNTER_S__LEN             7
+#define SMI_ACC2X2_FIFO_FRAME_COUNTER_S__MSK             0x7F
+#define SMI_ACC2X2_FIFO_FRAME_COUNTER_S__REG             SMI_ACC2X2_STATUS_FIFO_REG
+
+#define SMI_ACC2X2_FIFO_OVERRUN_S__POS             7
+#define SMI_ACC2X2_FIFO_OVERRUN_S__LEN             1
+#define SMI_ACC2X2_FIFO_OVERRUN_S__MSK             0x80
+#define SMI_ACC2X2_FIFO_OVERRUN_S__REG             SMI_ACC2X2_STATUS_FIFO_REG
+
+#define SMI_ACC2X2_RANGE_SEL__POS             0
+#define SMI_ACC2X2_RANGE_SEL__LEN             4
+#define SMI_ACC2X2_RANGE_SEL__MSK             0x0F
+#define SMI_ACC2X2_RANGE_SEL__REG             SMI_ACC2X2_RANGE_SEL_REG
+
+#define SMI_ACC2X2_BANDWIDTH__POS             0
+#define SMI_ACC2X2_BANDWIDTH__LEN             5
+#define SMI_ACC2X2_BANDWIDTH__MSK             0x1F
+#define SMI_ACC2X2_BANDWIDTH__REG             SMI_ACC2X2_BW_SEL_REG
+
+#define SMI_ACC2X2_SLEEP_DUR__POS             1
+#define SMI_ACC2X2_SLEEP_DUR__LEN             4
+#define SMI_ACC2X2_SLEEP_DUR__MSK             0x1E
+#define SMI_ACC2X2_SLEEP_DUR__REG             SMI_ACC2X2_MODE_CTRL_REG
+
+#define SMI_ACC2X2_MODE_CTRL__POS             5
+#define SMI_ACC2X2_MODE_CTRL__LEN             3
+#define SMI_ACC2X2_MODE_CTRL__MSK             0xE0
+#define SMI_ACC2X2_MODE_CTRL__REG             SMI_ACC2X2_MODE_CTRL_REG
+
+#define SMI_ACC2X2_DEEP_SUSPEND__POS          5
+#define SMI_ACC2X2_DEEP_SUSPEND__LEN          1
+#define SMI_ACC2X2_DEEP_SUSPEND__MSK          0x20
+#define SMI_ACC2X2_DEEP_SUSPEND__REG          SMI_ACC2X2_MODE_CTRL_REG
+
+#define SMI_ACC2X2_EN_LOW_POWER__POS          6
+#define SMI_ACC2X2_EN_LOW_POWER__LEN          1
+#define SMI_ACC2X2_EN_LOW_POWER__MSK          0x40
+#define SMI_ACC2X2_EN_LOW_POWER__REG          SMI_ACC2X2_MODE_CTRL_REG
+
+#define SMI_ACC2X2_EN_SUSPEND__POS            7
+#define SMI_ACC2X2_EN_SUSPEND__LEN            1
+#define SMI_ACC2X2_EN_SUSPEND__MSK            0x80
+#define SMI_ACC2X2_EN_SUSPEND__REG            SMI_ACC2X2_MODE_CTRL_REG
+
+#define SMI_ACC2X2_SLEEP_TIMER__POS          5
+#define SMI_ACC2X2_SLEEP_TIMER__LEN          1
+#define SMI_ACC2X2_SLEEP_TIMER__MSK          0x20
+#define SMI_ACC2X2_SLEEP_TIMER__REG          SMI_ACC2X2_LOW_NOISE_CTRL_REG
+
+#define SMI_ACC2X2_LOW_POWER_MODE__POS          6
+#define SMI_ACC2X2_LOW_POWER_MODE__LEN          1
+#define SMI_ACC2X2_LOW_POWER_MODE__MSK          0x40
+#define SMI_ACC2X2_LOW_POWER_MODE__REG          SMI_ACC2X2_LOW_NOISE_CTRL_REG
+
+#define SMI_ACC2X2_EN_LOW_NOISE__POS          7
+#define SMI_ACC2X2_EN_LOW_NOISE__LEN          1
+#define SMI_ACC2X2_EN_LOW_NOISE__MSK          0x80
+#define SMI_ACC2X2_EN_LOW_NOISE__REG          SMI_ACC2X2_LOW_NOISE_CTRL_REG
+
+#define SMI_ACC2X2_DIS_SHADOW_PROC__POS       6
+#define SMI_ACC2X2_DIS_SHADOW_PROC__LEN       1
+#define SMI_ACC2X2_DIS_SHADOW_PROC__MSK       0x40
+#define SMI_ACC2X2_DIS_SHADOW_PROC__REG       SMI_ACC2X2_DATA_CTRL_REG
+
+#define SMI_ACC2X2_EN_DATA_HIGH_BW__POS         7
+#define SMI_ACC2X2_EN_DATA_HIGH_BW__LEN         1
+#define SMI_ACC2X2_EN_DATA_HIGH_BW__MSK         0x80
+#define SMI_ACC2X2_EN_DATA_HIGH_BW__REG         SMI_ACC2X2_DATA_CTRL_REG
+
+#define SMI_ACC2X2_EN_SOFT_RESET__POS         0
+#define SMI_ACC2X2_EN_SOFT_RESET__LEN         8
+#define SMI_ACC2X2_EN_SOFT_RESET__MSK         0xFF
+#define SMI_ACC2X2_EN_SOFT_RESET__REG         SMI_ACC2X2_RESET_REG
+
+#define SMI_ACC2X2_EN_SOFT_RESET_VALUE        0xB6
+
+#define SMI_ACC2X2_EN_SLOPE_X_INT__POS         0
+#define SMI_ACC2X2_EN_SLOPE_X_INT__LEN         1
+#define SMI_ACC2X2_EN_SLOPE_X_INT__MSK         0x01
+#define SMI_ACC2X2_EN_SLOPE_X_INT__REG         SMI_ACC2X2_INT_ENABLE1_REG
+
+#define SMI_ACC2X2_EN_SLOPE_Y_INT__POS         1
+#define SMI_ACC2X2_EN_SLOPE_Y_INT__LEN         1
+#define SMI_ACC2X2_EN_SLOPE_Y_INT__MSK         0x02
+#define SMI_ACC2X2_EN_SLOPE_Y_INT__REG         SMI_ACC2X2_INT_ENABLE1_REG
+
+#define SMI_ACC2X2_EN_SLOPE_Z_INT__POS         2
+#define SMI_ACC2X2_EN_SLOPE_Z_INT__LEN         1
+#define SMI_ACC2X2_EN_SLOPE_Z_INT__MSK         0x04
+#define SMI_ACC2X2_EN_SLOPE_Z_INT__REG         SMI_ACC2X2_INT_ENABLE1_REG
+
+#define SMI_ACC2X2_EN_DOUBLE_TAP_INT__POS      4
+#define SMI_ACC2X2_EN_DOUBLE_TAP_INT__LEN      1
+#define SMI_ACC2X2_EN_DOUBLE_TAP_INT__MSK      0x10
+#define SMI_ACC2X2_EN_DOUBLE_TAP_INT__REG      SMI_ACC2X2_INT_ENABLE1_REG
+
+#define SMI_ACC2X2_EN_SINGLE_TAP_INT__POS      5
+#define SMI_ACC2X2_EN_SINGLE_TAP_INT__LEN      1
+#define SMI_ACC2X2_EN_SINGLE_TAP_INT__MSK      0x20
+#define SMI_ACC2X2_EN_SINGLE_TAP_INT__REG      SMI_ACC2X2_INT_ENABLE1_REG
+
+#define SMI_ACC2X2_EN_ORIENT_INT__POS          6
+#define SMI_ACC2X2_EN_ORIENT_INT__LEN          1
+#define SMI_ACC2X2_EN_ORIENT_INT__MSK          0x40
+#define SMI_ACC2X2_EN_ORIENT_INT__REG          SMI_ACC2X2_INT_ENABLE1_REG
+
+#define SMI_ACC2X2_EN_FLAT_INT__POS            7
+#define SMI_ACC2X2_EN_FLAT_INT__LEN            1
+#define SMI_ACC2X2_EN_FLAT_INT__MSK            0x80
+#define SMI_ACC2X2_EN_FLAT_INT__REG            SMI_ACC2X2_INT_ENABLE1_REG
+
+#define SMI_ACC2X2_EN_HIGHG_X_INT__POS         0
+#define SMI_ACC2X2_EN_HIGHG_X_INT__LEN         1
+#define SMI_ACC2X2_EN_HIGHG_X_INT__MSK         0x01
+#define SMI_ACC2X2_EN_HIGHG_X_INT__REG         SMI_ACC2X2_INT_ENABLE2_REG
+
+#define SMI_ACC2X2_EN_HIGHG_Y_INT__POS         1
+#define SMI_ACC2X2_EN_HIGHG_Y_INT__LEN         1
+#define SMI_ACC2X2_EN_HIGHG_Y_INT__MSK         0x02
+#define SMI_ACC2X2_EN_HIGHG_Y_INT__REG         SMI_ACC2X2_INT_ENABLE2_REG
+
+#define SMI_ACC2X2_EN_HIGHG_Z_INT__POS         2
+#define SMI_ACC2X2_EN_HIGHG_Z_INT__LEN         1
+#define SMI_ACC2X2_EN_HIGHG_Z_INT__MSK         0x04
+#define SMI_ACC2X2_EN_HIGHG_Z_INT__REG         SMI_ACC2X2_INT_ENABLE2_REG
+
+#define SMI_ACC2X2_EN_LOWG_INT__POS            3
+#define SMI_ACC2X2_EN_LOWG_INT__LEN            1
+#define SMI_ACC2X2_EN_LOWG_INT__MSK            0x08
+#define SMI_ACC2X2_EN_LOWG_INT__REG            SMI_ACC2X2_INT_ENABLE2_REG
+
+#define SMI_ACC2X2_EN_NEW_DATA_INT__POS        4
+#define SMI_ACC2X2_EN_NEW_DATA_INT__LEN        1
+#define SMI_ACC2X2_EN_NEW_DATA_INT__MSK        0x10
+#define SMI_ACC2X2_EN_NEW_DATA_INT__REG        SMI_ACC2X2_INT_ENABLE2_REG
+
+#define SMI_ACC2X2_INT_FFULL_EN_INT__POS        5
+#define SMI_ACC2X2_INT_FFULL_EN_INT__LEN        1
+#define SMI_ACC2X2_INT_FFULL_EN_INT__MSK        0x20
+#define SMI_ACC2X2_INT_FFULL_EN_INT__REG        SMI_ACC2X2_INT_ENABLE2_REG
+
+#define SMI_ACC2X2_INT_FWM_EN_INT__POS        6
+#define SMI_ACC2X2_INT_FWM_EN_INT__LEN        1
+#define SMI_ACC2X2_INT_FWM_EN_INT__MSK        0x40
+#define SMI_ACC2X2_INT_FWM_EN_INT__REG        SMI_ACC2X2_INT_ENABLE2_REG
+
+#define SMI_ACC2X2_INT_SLO_NO_MOT_EN_X_INT__POS        0
+#define SMI_ACC2X2_INT_SLO_NO_MOT_EN_X_INT__LEN        1
+#define SMI_ACC2X2_INT_SLO_NO_MOT_EN_X_INT__MSK        0x01
+#define SMI_ACC2X2_INT_SLO_NO_MOT_EN_X_INT__REG        SMI_ACC2X2_INT_SLO_NO_MOT_REG
+
+#define SMI_ACC2X2_INT_SLO_NO_MOT_EN_Y_INT__POS        1
+#define SMI_ACC2X2_INT_SLO_NO_MOT_EN_Y_INT__LEN        1
+#define SMI_ACC2X2_INT_SLO_NO_MOT_EN_Y_INT__MSK        0x02
+#define SMI_ACC2X2_INT_SLO_NO_MOT_EN_Y_INT__REG        SMI_ACC2X2_INT_SLO_NO_MOT_REG
+
+#define SMI_ACC2X2_INT_SLO_NO_MOT_EN_Z_INT__POS        2
+#define SMI_ACC2X2_INT_SLO_NO_MOT_EN_Z_INT__LEN        1
+#define SMI_ACC2X2_INT_SLO_NO_MOT_EN_Z_INT__MSK        0x04
+#define SMI_ACC2X2_INT_SLO_NO_MOT_EN_Z_INT__REG        SMI_ACC2X2_INT_SLO_NO_MOT_REG
+
+#define SMI_ACC2X2_INT_SLO_NO_MOT_EN_SEL_INT__POS        3
+#define SMI_ACC2X2_INT_SLO_NO_MOT_EN_SEL_INT__LEN        1
+#define SMI_ACC2X2_INT_SLO_NO_MOT_EN_SEL_INT__MSK        0x08
+#define SMI_ACC2X2_INT_SLO_NO_MOT_EN_SEL_INT__REG        SMI_ACC2X2_INT_SLO_NO_MOT_REG
+
+#define SMI_ACC2X2_EN_INT1_PAD_LOWG__POS        0
+#define SMI_ACC2X2_EN_INT1_PAD_LOWG__LEN        1
+#define SMI_ACC2X2_EN_INT1_PAD_LOWG__MSK        0x01
+#define SMI_ACC2X2_EN_INT1_PAD_LOWG__REG        SMI_ACC2X2_INT1_PAD_SEL_REG
+
+#define SMI_ACC2X2_EN_INT1_PAD_HIGHG__POS       1
+#define SMI_ACC2X2_EN_INT1_PAD_HIGHG__LEN       1
+#define SMI_ACC2X2_EN_INT1_PAD_HIGHG__MSK       0x02
+#define SMI_ACC2X2_EN_INT1_PAD_HIGHG__REG       SMI_ACC2X2_INT1_PAD_SEL_REG
+
+#define SMI_ACC2X2_EN_INT1_PAD_SLOPE__POS       2
+#define SMI_ACC2X2_EN_INT1_PAD_SLOPE__LEN       1
+#define SMI_ACC2X2_EN_INT1_PAD_SLOPE__MSK       0x04
+#define SMI_ACC2X2_EN_INT1_PAD_SLOPE__REG       SMI_ACC2X2_INT1_PAD_SEL_REG
+
+#define SMI_ACC2X2_EN_INT1_PAD_SLO_NO_MOT__POS        3
+#define SMI_ACC2X2_EN_INT1_PAD_SLO_NO_MOT__LEN        1
+#define SMI_ACC2X2_EN_INT1_PAD_SLO_NO_MOT__MSK        0x08
+#define SMI_ACC2X2_EN_INT1_PAD_SLO_NO_MOT__REG        SMI_ACC2X2_INT1_PAD_SEL_REG
+
+#define SMI_ACC2X2_EN_INT1_PAD_DB_TAP__POS      4
+#define SMI_ACC2X2_EN_INT1_PAD_DB_TAP__LEN      1
+#define SMI_ACC2X2_EN_INT1_PAD_DB_TAP__MSK      0x10
+#define SMI_ACC2X2_EN_INT1_PAD_DB_TAP__REG      SMI_ACC2X2_INT1_PAD_SEL_REG
+
+#define SMI_ACC2X2_EN_INT1_PAD_SNG_TAP__POS     5
+#define SMI_ACC2X2_EN_INT1_PAD_SNG_TAP__LEN     1
+#define SMI_ACC2X2_EN_INT1_PAD_SNG_TAP__MSK     0x20
+#define SMI_ACC2X2_EN_INT1_PAD_SNG_TAP__REG     SMI_ACC2X2_INT1_PAD_SEL_REG
+
+#define SMI_ACC2X2_EN_INT1_PAD_ORIENT__POS      6
+#define SMI_ACC2X2_EN_INT1_PAD_ORIENT__LEN      1
+#define SMI_ACC2X2_EN_INT1_PAD_ORIENT__MSK      0x40
+#define SMI_ACC2X2_EN_INT1_PAD_ORIENT__REG      SMI_ACC2X2_INT1_PAD_SEL_REG
+
+#define SMI_ACC2X2_EN_INT1_PAD_FLAT__POS        7
+#define SMI_ACC2X2_EN_INT1_PAD_FLAT__LEN        1
+#define SMI_ACC2X2_EN_INT1_PAD_FLAT__MSK        0x80
+#define SMI_ACC2X2_EN_INT1_PAD_FLAT__REG        SMI_ACC2X2_INT1_PAD_SEL_REG
+
+#define SMI_ACC2X2_EN_INT2_PAD_LOWG__POS        0
+#define SMI_ACC2X2_EN_INT2_PAD_LOWG__LEN        1
+#define SMI_ACC2X2_EN_INT2_PAD_LOWG__MSK        0x01
+#define SMI_ACC2X2_EN_INT2_PAD_LOWG__REG        SMI_ACC2X2_INT2_PAD_SEL_REG
+
+#define SMI_ACC2X2_EN_INT2_PAD_HIGHG__POS       1
+#define SMI_ACC2X2_EN_INT2_PAD_HIGHG__LEN       1
+#define SMI_ACC2X2_EN_INT2_PAD_HIGHG__MSK       0x02
+#define SMI_ACC2X2_EN_INT2_PAD_HIGHG__REG       SMI_ACC2X2_INT2_PAD_SEL_REG
+
+#define SMI_ACC2X2_EN_INT2_PAD_SLOPE__POS       2
+#define SMI_ACC2X2_EN_INT2_PAD_SLOPE__LEN       1
+#define SMI_ACC2X2_EN_INT2_PAD_SLOPE__MSK       0x04
+#define SMI_ACC2X2_EN_INT2_PAD_SLOPE__REG       SMI_ACC2X2_INT2_PAD_SEL_REG
+
+#define SMI_ACC2X2_EN_INT2_PAD_SLO_NO_MOT__POS        3
+#define SMI_ACC2X2_EN_INT2_PAD_SLO_NO_MOT__LEN        1
+#define SMI_ACC2X2_EN_INT2_PAD_SLO_NO_MOT__MSK        0x08
+#define SMI_ACC2X2_EN_INT2_PAD_SLO_NO_MOT__REG        SMI_ACC2X2_INT2_PAD_SEL_REG
+
+#define SMI_ACC2X2_EN_INT2_PAD_DB_TAP__POS      4
+#define SMI_ACC2X2_EN_INT2_PAD_DB_TAP__LEN      1
+#define SMI_ACC2X2_EN_INT2_PAD_DB_TAP__MSK      0x10
+#define SMI_ACC2X2_EN_INT2_PAD_DB_TAP__REG      SMI_ACC2X2_INT2_PAD_SEL_REG
+
+#define SMI_ACC2X2_EN_INT2_PAD_SNG_TAP__POS     5
+#define SMI_ACC2X2_EN_INT2_PAD_SNG_TAP__LEN     1
+#define SMI_ACC2X2_EN_INT2_PAD_SNG_TAP__MSK     0x20
+#define SMI_ACC2X2_EN_INT2_PAD_SNG_TAP__REG     SMI_ACC2X2_INT2_PAD_SEL_REG
+
+#define SMI_ACC2X2_EN_INT2_PAD_ORIENT__POS      6
+#define SMI_ACC2X2_EN_INT2_PAD_ORIENT__LEN      1
+#define SMI_ACC2X2_EN_INT2_PAD_ORIENT__MSK      0x40
+#define SMI_ACC2X2_EN_INT2_PAD_ORIENT__REG      SMI_ACC2X2_INT2_PAD_SEL_REG
+
+#define SMI_ACC2X2_EN_INT2_PAD_FLAT__POS        7
+#define SMI_ACC2X2_EN_INT2_PAD_FLAT__LEN        1
+#define SMI_ACC2X2_EN_INT2_PAD_FLAT__MSK        0x80
+#define SMI_ACC2X2_EN_INT2_PAD_FLAT__REG        SMI_ACC2X2_INT2_PAD_SEL_REG
+
+#define SMI_ACC2X2_EN_INT1_PAD_NEWDATA__POS     0
+#define SMI_ACC2X2_EN_INT1_PAD_NEWDATA__LEN     1
+#define SMI_ACC2X2_EN_INT1_PAD_NEWDATA__MSK     0x01
+#define SMI_ACC2X2_EN_INT1_PAD_NEWDATA__REG     SMI_ACC2X2_INT_DATA_SEL_REG
+
+#define SMI_ACC2X2_EN_INT1_PAD_FWM__POS     1
+#define SMI_ACC2X2_EN_INT1_PAD_FWM__LEN     1
+#define SMI_ACC2X2_EN_INT1_PAD_FWM__MSK     0x02
+#define SMI_ACC2X2_EN_INT1_PAD_FWM__REG     SMI_ACC2X2_INT_DATA_SEL_REG
+
+#define SMI_ACC2X2_EN_INT1_PAD_FFULL__POS     2
+#define SMI_ACC2X2_EN_INT1_PAD_FFULL__LEN     1
+#define SMI_ACC2X2_EN_INT1_PAD_FFULL__MSK     0x04
+#define SMI_ACC2X2_EN_INT1_PAD_FFULL__REG     SMI_ACC2X2_INT_DATA_SEL_REG
+
+#define SMI_ACC2X2_EN_INT2_PAD_FFULL__POS     5
+#define SMI_ACC2X2_EN_INT2_PAD_FFULL__LEN     1
+#define SMI_ACC2X2_EN_INT2_PAD_FFULL__MSK     0x20
+#define SMI_ACC2X2_EN_INT2_PAD_FFULL__REG     SMI_ACC2X2_INT_DATA_SEL_REG
+
+#define SMI_ACC2X2_EN_INT2_PAD_FWM__POS     6
+#define SMI_ACC2X2_EN_INT2_PAD_FWM__LEN     1
+#define SMI_ACC2X2_EN_INT2_PAD_FWM__MSK     0x40
+#define SMI_ACC2X2_EN_INT2_PAD_FWM__REG     SMI_ACC2X2_INT_DATA_SEL_REG
+
+#define SMI_ACC2X2_EN_INT2_PAD_NEWDATA__POS     7
+#define SMI_ACC2X2_EN_INT2_PAD_NEWDATA__LEN     1
+#define SMI_ACC2X2_EN_INT2_PAD_NEWDATA__MSK     0x80
+#define SMI_ACC2X2_EN_INT2_PAD_NEWDATA__REG     SMI_ACC2X2_INT_DATA_SEL_REG
+
+#define SMI_ACC2X2_UNFILT_INT_SRC_LOWG__POS        0
+#define SMI_ACC2X2_UNFILT_INT_SRC_LOWG__LEN        1
+#define SMI_ACC2X2_UNFILT_INT_SRC_LOWG__MSK        0x01
+#define SMI_ACC2X2_UNFILT_INT_SRC_LOWG__REG        SMI_ACC2X2_INT_SRC_REG
+
+#define SMI_ACC2X2_UNFILT_INT_SRC_HIGHG__POS       1
+#define SMI_ACC2X2_UNFILT_INT_SRC_HIGHG__LEN       1
+#define SMI_ACC2X2_UNFILT_INT_SRC_HIGHG__MSK       0x02
+#define SMI_ACC2X2_UNFILT_INT_SRC_HIGHG__REG       SMI_ACC2X2_INT_SRC_REG
+
+#define SMI_ACC2X2_UNFILT_INT_SRC_SLOPE__POS       2
+#define SMI_ACC2X2_UNFILT_INT_SRC_SLOPE__LEN       1
+#define SMI_ACC2X2_UNFILT_INT_SRC_SLOPE__MSK       0x04
+#define SMI_ACC2X2_UNFILT_INT_SRC_SLOPE__REG       SMI_ACC2X2_INT_SRC_REG
+
+#define SMI_ACC2X2_UNFILT_INT_SRC_SLO_NO_MOT__POS        3
+#define SMI_ACC2X2_UNFILT_INT_SRC_SLO_NO_MOT__LEN        1
+#define SMI_ACC2X2_UNFILT_INT_SRC_SLO_NO_MOT__MSK        0x08
+#define SMI_ACC2X2_UNFILT_INT_SRC_SLO_NO_MOT__REG        SMI_ACC2X2_INT_SRC_REG
+
+#define SMI_ACC2X2_UNFILT_INT_SRC_TAP__POS         4
+#define SMI_ACC2X2_UNFILT_INT_SRC_TAP__LEN         1
+#define SMI_ACC2X2_UNFILT_INT_SRC_TAP__MSK         0x10
+#define SMI_ACC2X2_UNFILT_INT_SRC_TAP__REG         SMI_ACC2X2_INT_SRC_REG
+
+#define SMI_ACC2X2_UNFILT_INT_SRC_DATA__POS        5
+#define SMI_ACC2X2_UNFILT_INT_SRC_DATA__LEN        1
+#define SMI_ACC2X2_UNFILT_INT_SRC_DATA__MSK        0x20
+#define SMI_ACC2X2_UNFILT_INT_SRC_DATA__REG        SMI_ACC2X2_INT_SRC_REG
+
+#define SMI_ACC2X2_INT1_PAD_ACTIVE_LEVEL__POS       0
+#define SMI_ACC2X2_INT1_PAD_ACTIVE_LEVEL__LEN       1
+#define SMI_ACC2X2_INT1_PAD_ACTIVE_LEVEL__MSK       0x01
+#define SMI_ACC2X2_INT1_PAD_ACTIVE_LEVEL__REG       SMI_ACC2X2_INT_SET_REG
+
+#define SMI_ACC2X2_INT2_PAD_ACTIVE_LEVEL__POS       2
+#define SMI_ACC2X2_INT2_PAD_ACTIVE_LEVEL__LEN       1
+#define SMI_ACC2X2_INT2_PAD_ACTIVE_LEVEL__MSK       0x04
+#define SMI_ACC2X2_INT2_PAD_ACTIVE_LEVEL__REG       SMI_ACC2X2_INT_SET_REG
+
+#define SMI_ACC2X2_INT1_PAD_OUTPUT_TYPE__POS        1
+#define SMI_ACC2X2_INT1_PAD_OUTPUT_TYPE__LEN        1
+#define SMI_ACC2X2_INT1_PAD_OUTPUT_TYPE__MSK        0x02
+#define SMI_ACC2X2_INT1_PAD_OUTPUT_TYPE__REG        SMI_ACC2X2_INT_SET_REG
+
+#define SMI_ACC2X2_INT2_PAD_OUTPUT_TYPE__POS        3
+#define SMI_ACC2X2_INT2_PAD_OUTPUT_TYPE__LEN        1
+#define SMI_ACC2X2_INT2_PAD_OUTPUT_TYPE__MSK        0x08
+#define SMI_ACC2X2_INT2_PAD_OUTPUT_TYPE__REG        SMI_ACC2X2_INT_SET_REG
+
+#define SMI_ACC2X2_INT_MODE_SEL__POS                0
+#define SMI_ACC2X2_INT_MODE_SEL__LEN                4
+#define SMI_ACC2X2_INT_MODE_SEL__MSK                0x0F
+#define SMI_ACC2X2_INT_MODE_SEL__REG                SMI_ACC2X2_INT_CTRL_REG
+
+#define SMI_ACC2X2_RESET_INT__POS           7
+#define SMI_ACC2X2_RESET_INT__LEN           1
+#define SMI_ACC2X2_RESET_INT__MSK           0x80
+#define SMI_ACC2X2_RESET_INT__REG           SMI_ACC2X2_INT_CTRL_REG
+
+#define SMI_ACC2X2_LOWG_DUR__POS                    0
+#define SMI_ACC2X2_LOWG_DUR__LEN                    8
+#define SMI_ACC2X2_LOWG_DUR__MSK                    0xFF
+#define SMI_ACC2X2_LOWG_DUR__REG                    SMI_ACC2X2_LOW_DURN_REG
+
+#define SMI_ACC2X2_LOWG_THRES__POS                  0
+#define SMI_ACC2X2_LOWG_THRES__LEN                  8
+#define SMI_ACC2X2_LOWG_THRES__MSK                  0xFF
+#define SMI_ACC2X2_LOWG_THRES__REG                  SMI_ACC2X2_LOW_THRES_REG
+
+#define SMI_ACC2X2_LOWG_HYST__POS                   0
+#define SMI_ACC2X2_LOWG_HYST__LEN                   2
+#define SMI_ACC2X2_LOWG_HYST__MSK                   0x03
+#define SMI_ACC2X2_LOWG_HYST__REG                   SMI_ACC2X2_LOW_HIGH_HYST_REG
+
+#define SMI_ACC2X2_LOWG_INT_MODE__POS               2
+#define SMI_ACC2X2_LOWG_INT_MODE__LEN               1
+#define SMI_ACC2X2_LOWG_INT_MODE__MSK               0x04
+#define SMI_ACC2X2_LOWG_INT_MODE__REG               SMI_ACC2X2_LOW_HIGH_HYST_REG
+
+#define SMI_ACC2X2_HIGHG_DUR__POS                    0
+#define SMI_ACC2X2_HIGHG_DUR__LEN                    8
+#define SMI_ACC2X2_HIGHG_DUR__MSK                    0xFF
+#define SMI_ACC2X2_HIGHG_DUR__REG                    SMI_ACC2X2_HIGH_DURN_REG
+
+#define SMI_ACC2X2_HIGHG_THRES__POS                  0
+#define SMI_ACC2X2_HIGHG_THRES__LEN                  8
+#define SMI_ACC2X2_HIGHG_THRES__MSK                  0xFF
+#define SMI_ACC2X2_HIGHG_THRES__REG                  SMI_ACC2X2_HIGH_THRES_REG
+
+#define SMI_ACC2X2_HIGHG_HYST__POS                  6
+#define SMI_ACC2X2_HIGHG_HYST__LEN                  2
+#define SMI_ACC2X2_HIGHG_HYST__MSK                  0xC0
+#define SMI_ACC2X2_HIGHG_HYST__REG                  SMI_ACC2X2_LOW_HIGH_HYST_REG
+
+#define SMI_ACC2X2_SLOPE_DUR__POS                    0
+#define SMI_ACC2X2_SLOPE_DUR__LEN                    2
+#define SMI_ACC2X2_SLOPE_DUR__MSK                    0x03
+#define SMI_ACC2X2_SLOPE_DUR__REG                    SMI_ACC2X2_SLOPE_DURN_REG
+
+#define SMI_ACC2X2_SLO_NO_MOT_DUR__POS                    2
+#define SMI_ACC2X2_SLO_NO_MOT_DUR__LEN                    6
+#define SMI_ACC2X2_SLO_NO_MOT_DUR__MSK                    0xFC
+#define SMI_ACC2X2_SLO_NO_MOT_DUR__REG                    SMI_ACC2X2_SLOPE_DURN_REG
+
+#define SMI_ACC2X2_SLOPE_THRES__POS                  0
+#define SMI_ACC2X2_SLOPE_THRES__LEN                  8
+#define SMI_ACC2X2_SLOPE_THRES__MSK                  0xFF
+#define SMI_ACC2X2_SLOPE_THRES__REG                  SMI_ACC2X2_SLOPE_THRES_REG
+
+#define SMI_ACC2X2_SLO_NO_MOT_THRES__POS                  0
+#define SMI_ACC2X2_SLO_NO_MOT_THRES__LEN                  8
+#define SMI_ACC2X2_SLO_NO_MOT_THRES__MSK                  0xFF
+#define SMI_ACC2X2_SLO_NO_MOT_THRES__REG           SMI_ACC2X2_SLO_NO_MOT_THRES_REG
+
+#define SMI_ACC2X2_TAP_DUR__POS                    0
+#define SMI_ACC2X2_TAP_DUR__LEN                    3
+#define SMI_ACC2X2_TAP_DUR__MSK                    0x07
+#define SMI_ACC2X2_TAP_DUR__REG                    SMI_ACC2X2_TAP_PARAM_REG
+
+#define SMI_ACC2X2_TAP_SHOCK_DURN__POS             6
+#define SMI_ACC2X2_TAP_SHOCK_DURN__LEN             1
+#define SMI_ACC2X2_TAP_SHOCK_DURN__MSK             0x40
+#define SMI_ACC2X2_TAP_SHOCK_DURN__REG             SMI_ACC2X2_TAP_PARAM_REG
+
+#define SMI_ACC2X2_ADV_TAP_INT__POS                5
+#define SMI_ACC2X2_ADV_TAP_INT__LEN                1
+#define SMI_ACC2X2_ADV_TAP_INT__MSK                0x20
+#define SMI_ACC2X2_ADV_TAP_INT__REG                SMI_ACC2X2_TAP_PARAM_REG
+
+#define SMI_ACC2X2_TAP_QUIET_DURN__POS             7
+#define SMI_ACC2X2_TAP_QUIET_DURN__LEN             1
+#define SMI_ACC2X2_TAP_QUIET_DURN__MSK             0x80
+#define SMI_ACC2X2_TAP_QUIET_DURN__REG             SMI_ACC2X2_TAP_PARAM_REG
+
+#define SMI_ACC2X2_TAP_THRES__POS                  0
+#define SMI_ACC2X2_TAP_THRES__LEN                  5
+#define SMI_ACC2X2_TAP_THRES__MSK                  0x1F
+#define SMI_ACC2X2_TAP_THRES__REG                  SMI_ACC2X2_TAP_THRES_REG
+
+#define SMI_ACC2X2_TAP_SAMPLES__POS                6
+#define SMI_ACC2X2_TAP_SAMPLES__LEN                2
+#define SMI_ACC2X2_TAP_SAMPLES__MSK                0xC0
+#define SMI_ACC2X2_TAP_SAMPLES__REG                SMI_ACC2X2_TAP_THRES_REG
+
+#define SMI_ACC2X2_ORIENT_MODE__POS                  0
+#define SMI_ACC2X2_ORIENT_MODE__LEN                  2
+#define SMI_ACC2X2_ORIENT_MODE__MSK                  0x03
+#define SMI_ACC2X2_ORIENT_MODE__REG                  SMI_ACC2X2_ORIENT_PARAM_REG
+
+#define SMI_ACC2X2_ORIENT_BLOCK__POS                 2
+#define SMI_ACC2X2_ORIENT_BLOCK__LEN                 2
+#define SMI_ACC2X2_ORIENT_BLOCK__MSK                 0x0C
+#define SMI_ACC2X2_ORIENT_BLOCK__REG                 SMI_ACC2X2_ORIENT_PARAM_REG
+
+#define SMI_ACC2X2_ORIENT_HYST__POS                  4
+#define SMI_ACC2X2_ORIENT_HYST__LEN                  3
+#define SMI_ACC2X2_ORIENT_HYST__MSK                  0x70
+#define SMI_ACC2X2_ORIENT_HYST__REG                  SMI_ACC2X2_ORIENT_PARAM_REG
+
+#define SMI_ACC2X2_ORIENT_AXIS__POS                  7
+#define SMI_ACC2X2_ORIENT_AXIS__LEN                  1
+#define SMI_ACC2X2_ORIENT_AXIS__MSK                  0x80
+#define SMI_ACC2X2_ORIENT_AXIS__REG                  SMI_ACC2X2_THETA_BLOCK_REG
+
+#define SMI_ACC2X2_ORIENT_UD_EN__POS                  6
+#define SMI_ACC2X2_ORIENT_UD_EN__LEN                  1
+#define SMI_ACC2X2_ORIENT_UD_EN__MSK                  0x40
+#define SMI_ACC2X2_ORIENT_UD_EN__REG                  SMI_ACC2X2_THETA_BLOCK_REG
+
+#define SMI_ACC2X2_THETA_BLOCK__POS                  0
+#define SMI_ACC2X2_THETA_BLOCK__LEN                  6
+#define SMI_ACC2X2_THETA_BLOCK__MSK                  0x3F
+#define SMI_ACC2X2_THETA_BLOCK__REG                  SMI_ACC2X2_THETA_BLOCK_REG
+
+#define SMI_ACC2X2_THETA_FLAT__POS                  0
+#define SMI_ACC2X2_THETA_FLAT__LEN                  6
+#define SMI_ACC2X2_THETA_FLAT__MSK                  0x3F
+#define SMI_ACC2X2_THETA_FLAT__REG                  SMI_ACC2X2_THETA_FLAT_REG
+
+#define SMI_ACC2X2_FLAT_HOLD_TIME__POS              4
+#define SMI_ACC2X2_FLAT_HOLD_TIME__LEN              2
+#define SMI_ACC2X2_FLAT_HOLD_TIME__MSK              0x30
+#define SMI_ACC2X2_FLAT_HOLD_TIME__REG              SMI_ACC2X2_FLAT_HOLD_TIME_REG
+
+#define SMI_ACC2X2_FLAT_HYS__POS                   0
+#define SMI_ACC2X2_FLAT_HYS__LEN                   3
+#define SMI_ACC2X2_FLAT_HYS__MSK                   0x07
+#define SMI_ACC2X2_FLAT_HYS__REG                   SMI_ACC2X2_FLAT_HOLD_TIME_REG
+
+#define SMI_ACC2X2_FIFO_WML_TRIG_RETAIN__POS                   0
+#define SMI_ACC2X2_FIFO_WML_TRIG_RETAIN__LEN                   6
+#define SMI_ACC2X2_FIFO_WML_TRIG_RETAIN__MSK                   0x3F
+#define SMI_ACC2X2_FIFO_WML_TRIG_RETAIN__REG                   SMI_ACC2X2_FIFO_WML_TRIG
+
+#define SMI_ACC2X2_EN_SELF_TEST__POS                0
+#define SMI_ACC2X2_EN_SELF_TEST__LEN                2
+#define SMI_ACC2X2_EN_SELF_TEST__MSK                0x03
+#define SMI_ACC2X2_EN_SELF_TEST__REG                SMI_ACC2X2_SELF_TEST_REG
+
+#define SMI_ACC2X2_NEG_SELF_TEST__POS               2
+#define SMI_ACC2X2_NEG_SELF_TEST__LEN               1
+#define SMI_ACC2X2_NEG_SELF_TEST__MSK               0x04
+#define SMI_ACC2X2_NEG_SELF_TEST__REG               SMI_ACC2X2_SELF_TEST_REG
+
+#define SMI_ACC2X2_SELF_TEST_AMP__POS               4
+#define SMI_ACC2X2_SELF_TEST_AMP__LEN               1
+#define SMI_ACC2X2_SELF_TEST_AMP__MSK               0x10
+#define SMI_ACC2X2_SELF_TEST_AMP__REG               SMI_ACC2X2_SELF_TEST_REG
+
+
+#define SMI_ACC2X2_UNLOCK_EE_PROG_MODE__POS     0
+#define SMI_ACC2X2_UNLOCK_EE_PROG_MODE__LEN     1
+#define SMI_ACC2X2_UNLOCK_EE_PROG_MODE__MSK     0x01
+#define SMI_ACC2X2_UNLOCK_EE_PROG_MODE__REG     SMI_ACC2X2_EEPROM_CTRL_REG
+
+#define SMI_ACC2X2_START_EE_PROG_TRIG__POS      1
+#define SMI_ACC2X2_START_EE_PROG_TRIG__LEN      1
+#define SMI_ACC2X2_START_EE_PROG_TRIG__MSK      0x02
+#define SMI_ACC2X2_START_EE_PROG_TRIG__REG      SMI_ACC2X2_EEPROM_CTRL_REG
+
+#define SMI_ACC2X2_EE_PROG_READY__POS          2
+#define SMI_ACC2X2_EE_PROG_READY__LEN          1
+#define SMI_ACC2X2_EE_PROG_READY__MSK          0x04
+#define SMI_ACC2X2_EE_PROG_READY__REG          SMI_ACC2X2_EEPROM_CTRL_REG
+
+#define SMI_ACC2X2_UPDATE_IMAGE__POS                3
+#define SMI_ACC2X2_UPDATE_IMAGE__LEN                1
+#define SMI_ACC2X2_UPDATE_IMAGE__MSK                0x08
+#define SMI_ACC2X2_UPDATE_IMAGE__REG                SMI_ACC2X2_EEPROM_CTRL_REG
+
+#define SMI_ACC2X2_EE_REMAIN__POS                4
+#define SMI_ACC2X2_EE_REMAIN__LEN                4
+#define SMI_ACC2X2_EE_REMAIN__MSK                0xF0
+#define SMI_ACC2X2_EE_REMAIN__REG                SMI_ACC2X2_EEPROM_CTRL_REG
+
+#define SMI_ACC2X2_EN_SPI_MODE_3__POS              0
+#define SMI_ACC2X2_EN_SPI_MODE_3__LEN              1
+#define SMI_ACC2X2_EN_SPI_MODE_3__MSK              0x01
+#define SMI_ACC2X2_EN_SPI_MODE_3__REG              SMI_ACC2X2_SERIAL_CTRL_REG
+
+#define SMI_ACC2X2_I2C_WATCHDOG_PERIOD__POS        1
+#define SMI_ACC2X2_I2C_WATCHDOG_PERIOD__LEN        1
+#define SMI_ACC2X2_I2C_WATCHDOG_PERIOD__MSK        0x02
+#define SMI_ACC2X2_I2C_WATCHDOG_PERIOD__REG        SMI_ACC2X2_SERIAL_CTRL_REG
+
+#define SMI_ACC2X2_EN_I2C_WATCHDOG__POS            2
+#define SMI_ACC2X2_EN_I2C_WATCHDOG__LEN            1
+#define SMI_ACC2X2_EN_I2C_WATCHDOG__MSK            0x04
+#define SMI_ACC2X2_EN_I2C_WATCHDOG__REG            SMI_ACC2X2_SERIAL_CTRL_REG
+
+#define SMI_ACC2X2_EXT_MODE__POS              7
+#define SMI_ACC2X2_EXT_MODE__LEN              1
+#define SMI_ACC2X2_EXT_MODE__MSK              0x80
+#define SMI_ACC2X2_EXT_MODE__REG              SMI_ACC2X2_EXTMODE_CTRL_REG
+
+#define SMI_ACC2X2_ALLOW_UPPER__POS        6
+#define SMI_ACC2X2_ALLOW_UPPER__LEN        1
+#define SMI_ACC2X2_ALLOW_UPPER__MSK        0x40
+#define SMI_ACC2X2_ALLOW_UPPER__REG        SMI_ACC2X2_EXTMODE_CTRL_REG
+
+#define SMI_ACC2X2_MAP_2_LOWER__POS            5
+#define SMI_ACC2X2_MAP_2_LOWER__LEN            1
+#define SMI_ACC2X2_MAP_2_LOWER__MSK            0x20
+#define SMI_ACC2X2_MAP_2_LOWER__REG            SMI_ACC2X2_EXTMODE_CTRL_REG
+
+#define SMI_ACC2X2_MAGIC_NUMBER__POS            0
+#define SMI_ACC2X2_MAGIC_NUMBER__LEN            5
+#define SMI_ACC2X2_MAGIC_NUMBER__MSK            0x1F
+#define SMI_ACC2X2_MAGIC_NUMBER__REG            SMI_ACC2X2_EXTMODE_CTRL_REG
+
+#define SMI_ACC2X2_UNLOCK_EE_WRITE_TRIM__POS        4
+#define SMI_ACC2X2_UNLOCK_EE_WRITE_TRIM__LEN        4
+#define SMI_ACC2X2_UNLOCK_EE_WRITE_TRIM__MSK        0xF0
+#define SMI_ACC2X2_UNLOCK_EE_WRITE_TRIM__REG        SMI_ACC2X2_CTRL_UNLOCK_REG
+
+#define SMI_ACC2X2_EN_SLOW_COMP_X__POS              0
+#define SMI_ACC2X2_EN_SLOW_COMP_X__LEN              1
+#define SMI_ACC2X2_EN_SLOW_COMP_X__MSK              0x01
+#define SMI_ACC2X2_EN_SLOW_COMP_X__REG              SMI_ACC2X2_OFFSET_CTRL_REG
+
+#define SMI_ACC2X2_EN_SLOW_COMP_Y__POS              1
+#define SMI_ACC2X2_EN_SLOW_COMP_Y__LEN              1
+#define SMI_ACC2X2_EN_SLOW_COMP_Y__MSK              0x02
+#define SMI_ACC2X2_EN_SLOW_COMP_Y__REG              SMI_ACC2X2_OFFSET_CTRL_REG
+
+#define SMI_ACC2X2_EN_SLOW_COMP_Z__POS              2
+#define SMI_ACC2X2_EN_SLOW_COMP_Z__LEN              1
+#define SMI_ACC2X2_EN_SLOW_COMP_Z__MSK              0x04
+#define SMI_ACC2X2_EN_SLOW_COMP_Z__REG              SMI_ACC2X2_OFFSET_CTRL_REG
+
+#define SMI_ACC2X2_FAST_CAL_RDY_S__POS             4
+#define SMI_ACC2X2_FAST_CAL_RDY_S__LEN             1
+#define SMI_ACC2X2_FAST_CAL_RDY_S__MSK             0x10
+#define SMI_ACC2X2_FAST_CAL_RDY_S__REG             SMI_ACC2X2_OFFSET_CTRL_REG
+
+#define SMI_ACC2X2_CAL_TRIGGER__POS                5
+#define SMI_ACC2X2_CAL_TRIGGER__LEN                2
+#define SMI_ACC2X2_CAL_TRIGGER__MSK                0x60
+#define SMI_ACC2X2_CAL_TRIGGER__REG                SMI_ACC2X2_OFFSET_CTRL_REG
+
+#define SMI_ACC2X2_RESET_OFFSET_REGS__POS           7
+#define SMI_ACC2X2_RESET_OFFSET_REGS__LEN           1
+#define SMI_ACC2X2_RESET_OFFSET_REGS__MSK           0x80
+#define SMI_ACC2X2_RESET_OFFSET_REGS__REG           SMI_ACC2X2_OFFSET_CTRL_REG
+
+#define SMI_ACC2X2_COMP_CUTOFF__POS                 0
+#define SMI_ACC2X2_COMP_CUTOFF__LEN                 1
+#define SMI_ACC2X2_COMP_CUTOFF__MSK                 0x01
+#define SMI_ACC2X2_COMP_CUTOFF__REG                 SMI_ACC2X2_OFFSET_PARAMS_REG
+
+#define SMI_ACC2X2_COMP_TARGET_OFFSET_X__POS        1
+#define SMI_ACC2X2_COMP_TARGET_OFFSET_X__LEN        2
+#define SMI_ACC2X2_COMP_TARGET_OFFSET_X__MSK        0x06
+#define SMI_ACC2X2_COMP_TARGET_OFFSET_X__REG        SMI_ACC2X2_OFFSET_PARAMS_REG
+
+#define SMI_ACC2X2_COMP_TARGET_OFFSET_Y__POS        3
+#define SMI_ACC2X2_COMP_TARGET_OFFSET_Y__LEN        2
+#define SMI_ACC2X2_COMP_TARGET_OFFSET_Y__MSK        0x18
+#define SMI_ACC2X2_COMP_TARGET_OFFSET_Y__REG        SMI_ACC2X2_OFFSET_PARAMS_REG
+
+#define SMI_ACC2X2_COMP_TARGET_OFFSET_Z__POS        5
+#define SMI_ACC2X2_COMP_TARGET_OFFSET_Z__LEN        2
+#define SMI_ACC2X2_COMP_TARGET_OFFSET_Z__MSK        0x60
+#define SMI_ACC2X2_COMP_TARGET_OFFSET_Z__REG        SMI_ACC2X2_OFFSET_PARAMS_REG
+
+#define SMI_ACC2X2_FIFO_DATA_SELECT__POS                 0
+#define SMI_ACC2X2_FIFO_DATA_SELECT__LEN                 2
+#define SMI_ACC2X2_FIFO_DATA_SELECT__MSK                 0x03
+#define SMI_ACC2X2_FIFO_DATA_SELECT__REG                 SMI_ACC2X2_FIFO_MODE_REG
+
+#define SMI_ACC2X2_FIFO_TRIGGER_SOURCE__POS                 2
+#define SMI_ACC2X2_FIFO_TRIGGER_SOURCE__LEN                 2
+#define SMI_ACC2X2_FIFO_TRIGGER_SOURCE__MSK                 0x0C
+#define SMI_ACC2X2_FIFO_TRIGGER_SOURCE__REG                 SMI_ACC2X2_FIFO_MODE_REG
+
+#define SMI_ACC2X2_FIFO_TRIGGER_ACTION__POS                 4
+#define SMI_ACC2X2_FIFO_TRIGGER_ACTION__LEN                 2
+#define SMI_ACC2X2_FIFO_TRIGGER_ACTION__MSK                 0x30
+#define SMI_ACC2X2_FIFO_TRIGGER_ACTION__REG                 SMI_ACC2X2_FIFO_MODE_REG
+
+#define SMI_ACC2X2_FIFO_MODE__POS                 6
+#define SMI_ACC2X2_FIFO_MODE__LEN                 2
+#define SMI_ACC2X2_FIFO_MODE__MSK                 0xC0
+#define SMI_ACC2X2_FIFO_MODE__REG                 SMI_ACC2X2_FIFO_MODE_REG
+
+
+#define SMI_ACC2X2_STATUS1                             0
+#define SMI_ACC2X2_STATUS2                             1
+#define SMI_ACC2X2_STATUS3                             2
+#define SMI_ACC2X2_STATUS4                             3
+#define SMI_ACC2X2_STATUS5                             4
+
+
+#define SMI_ACC2X2_RANGE_2G                 3
+#define SMI_ACC2X2_RANGE_4G                 5
+#define SMI_ACC2X2_RANGE_8G                 8
+#define SMI_ACC2X2_RANGE_16G                12
+
+
+#define SMI_ACC2X2_BW_7_81HZ        0x08
+#define SMI_ACC2X2_BW_15_63HZ       0x09
+#define SMI_ACC2X2_BW_31_25HZ       0x0A
+#define SMI_ACC2X2_BW_62_50HZ       0x0B
+#define SMI_ACC2X2_BW_125HZ         0x0C
+#define SMI_ACC2X2_BW_250HZ         0x0D
+#define SMI_ACC2X2_BW_500HZ         0x0E
+#define SMI_ACC2X2_BW_1000HZ        0x0F
+
+#define SMI_ACC2X2_SLEEP_DUR_0_5MS        0x05
+#define SMI_ACC2X2_SLEEP_DUR_1MS          0x06
+#define SMI_ACC2X2_SLEEP_DUR_2MS          0x07
+#define SMI_ACC2X2_SLEEP_DUR_4MS          0x08
+#define SMI_ACC2X2_SLEEP_DUR_6MS          0x09
+#define SMI_ACC2X2_SLEEP_DUR_10MS         0x0A
+#define SMI_ACC2X2_SLEEP_DUR_25MS         0x0B
+#define SMI_ACC2X2_SLEEP_DUR_50MS         0x0C
+#define SMI_ACC2X2_SLEEP_DUR_100MS        0x0D
+#define SMI_ACC2X2_SLEEP_DUR_500MS        0x0E
+#define SMI_ACC2X2_SLEEP_DUR_1S           0x0F
+
+#define SMI_ACC2X2_LATCH_DUR_NON_LATCH    0x00
+#define SMI_ACC2X2_LATCH_DUR_250MS        0x01
+#define SMI_ACC2X2_LATCH_DUR_500MS        0x02
+#define SMI_ACC2X2_LATCH_DUR_1S           0x03
+#define SMI_ACC2X2_LATCH_DUR_2S           0x04
+#define SMI_ACC2X2_LATCH_DUR_4S           0x05
+#define SMI_ACC2X2_LATCH_DUR_8S           0x06
+#define SMI_ACC2X2_LATCH_DUR_LATCH        0x07
+#define SMI_ACC2X2_LATCH_DUR_NON_LATCH1   0x08
+#define SMI_ACC2X2_LATCH_DUR_250US        0x09
+#define SMI_ACC2X2_LATCH_DUR_500US        0x0A
+#define SMI_ACC2X2_LATCH_DUR_1MS          0x0B
+#define SMI_ACC2X2_LATCH_DUR_12_5MS       0x0C
+#define SMI_ACC2X2_LATCH_DUR_25MS         0x0D
+#define SMI_ACC2X2_LATCH_DUR_50MS         0x0E
+#define SMI_ACC2X2_LATCH_DUR_LATCH1       0x0F
+
+#define SMI_ACC2X2_MODE_NORMAL             0
+#define SMI_ACC2X2_MODE_LOWPOWER1          1
+#define SMI_ACC2X2_MODE_SUSPEND            2
+#define SMI_ACC2X2_MODE_DEEP_SUSPEND       3
+#define SMI_ACC2X2_MODE_LOWPOWER2          4
+#define SMI_ACC2X2_MODE_STANDBY            5
+
+#define SMI_ACC2X2_X_AXIS           0
+#define SMI_ACC2X2_Y_AXIS           1
+#define SMI_ACC2X2_Z_AXIS           2
+
+#define SMI_ACC2X2_Low_G_Interrupt       0
+#define SMI_ACC2X2_High_G_X_Interrupt    1
+#define SMI_ACC2X2_High_G_Y_Interrupt    2
+#define SMI_ACC2X2_High_G_Z_Interrupt    3
+#define SMI_ACC2X2_DATA_EN               4
+#define SMI_ACC2X2_Slope_X_Interrupt     5
+#define SMI_ACC2X2_Slope_Y_Interrupt     6
+#define SMI_ACC2X2_Slope_Z_Interrupt     7
+#define SMI_ACC2X2_Single_Tap_Interrupt  8
+#define SMI_ACC2X2_Double_Tap_Interrupt  9
+#define SMI_ACC2X2_Orient_Interrupt      10
+#define SMI_ACC2X2_Flat_Interrupt        11
+#define SMI_ACC2X2_FFULL_INTERRUPT       12
+#define SMI_ACC2X2_FWM_INTERRUPT         13
+
+#define SMI_ACC2X2_INT1_LOWG         0
+#define SMI_ACC2X2_INT2_LOWG         1
+#define SMI_ACC2X2_INT1_HIGHG        0
+#define SMI_ACC2X2_INT2_HIGHG        1
+#define SMI_ACC2X2_INT1_SLOPE        0
+#define SMI_ACC2X2_INT2_SLOPE        1
+#define SMI_ACC2X2_INT1_SLO_NO_MOT   0
+#define SMI_ACC2X2_INT2_SLO_NO_MOT   1
+#define SMI_ACC2X2_INT1_DTAP         0
+#define SMI_ACC2X2_INT2_DTAP         1
+#define SMI_ACC2X2_INT1_STAP         0
+#define SMI_ACC2X2_INT2_STAP         1
+#define SMI_ACC2X2_INT1_ORIENT       0
+#define SMI_ACC2X2_INT2_ORIENT       1
+#define SMI_ACC2X2_INT1_FLAT         0
+#define SMI_ACC2X2_INT2_FLAT         1
+#define SMI_ACC2X2_INT1_NDATA        0
+#define SMI_ACC2X2_INT2_NDATA        1
+#define SMI_ACC2X2_INT1_FWM          0
+#define SMI_ACC2X2_INT2_FWM          1
+#define SMI_ACC2X2_INT1_FFULL        0
+#define SMI_ACC2X2_INT2_FFULL        1
+
+#define SMI_ACC2X2_SRC_LOWG         0
+#define SMI_ACC2X2_SRC_HIGHG        1
+#define SMI_ACC2X2_SRC_SLOPE        2
+#define SMI_ACC2X2_SRC_SLO_NO_MOT   3
+#define SMI_ACC2X2_SRC_TAP          4
+#define SMI_ACC2X2_SRC_DATA         5
+
+#define SMI_ACC2X2_INT1_OUTPUT      0
+#define SMI_ACC2X2_INT2_OUTPUT      1
+#define SMI_ACC2X2_INT1_LEVEL       0
+#define SMI_ACC2X2_INT2_LEVEL       1
+
+#define SMI_ACC2X2_LOW_DURATION            0
+#define SMI_ACC2X2_HIGH_DURATION           1
+#define SMI_ACC2X2_SLOPE_DURATION          2
+#define SMI_ACC2X2_SLO_NO_MOT_DURATION     3
+
+#define SMI_ACC2X2_LOW_THRESHOLD            0
+#define SMI_ACC2X2_HIGH_THRESHOLD           1
+#define SMI_ACC2X2_SLOPE_THRESHOLD          2
+#define SMI_ACC2X2_SLO_NO_MOT_THRESHOLD     3
+
+
+#define SMI_ACC2X2_LOWG_HYST                0
+#define SMI_ACC2X2_HIGHG_HYST               1
+
+#define SMI_ACC2X2_ORIENT_THETA             0
+#define SMI_ACC2X2_FLAT_THETA               1
+
+#define SMI_ACC2X2_I2C_SELECT               0
+#define SMI_ACC2X2_I2C_EN                   1
+
+#define SMI_ACC2X2_SLOW_COMP_X              0
+#define SMI_ACC2X2_SLOW_COMP_Y              1
+#define SMI_ACC2X2_SLOW_COMP_Z              2
+
+#define SMI_ACC2X2_CUT_OFF                  0
+#define SMI_ACC2X2_OFFSET_TRIGGER_X         1
+#define SMI_ACC2X2_OFFSET_TRIGGER_Y         2
+#define SMI_ACC2X2_OFFSET_TRIGGER_Z         3
+
+#define SMI_ACC2X2_GP0                      0
+#define SMI_ACC2X2_GP1                      1
+
+#define SMI_ACC2X2_SLO_NO_MOT_EN_X          0
+#define SMI_ACC2X2_SLO_NO_MOT_EN_Y          1
+#define SMI_ACC2X2_SLO_NO_MOT_EN_Z          2
+#define SMI_ACC2X2_SLO_NO_MOT_EN_SEL        3
+
+#define SMI_ACC2X2_WAKE_UP_DUR_20MS         0
+#define SMI_ACC2X2_WAKE_UP_DUR_80MS         1
+#define SMI_ACC2X2_WAKE_UP_DUR_320MS                2
+#define SMI_ACC2X2_WAKE_UP_DUR_2560MS               3
+
+#define SMI_ACC2X2_SELF_TEST0_ON            1
+#define SMI_ACC2X2_SELF_TEST1_ON            2
+
+#define SMI_ACC2X2_EE_W_OFF                 0
+#define SMI_ACC2X2_EE_W_ON                  1
+
+#define SMI_ACC2X2_LOW_TH_IN_G(gthres, range)           ((256 * gthres) / range)
+
+
+#define SMI_ACC2X2_HIGH_TH_IN_G(gthres, range)          ((256 * gthres) / range)
+
+
+#define SMI_ACC2X2_LOW_HY_IN_G(ghyst, range)            ((32 * ghyst) / range)
+
+
+#define SMI_ACC2X2_HIGH_HY_IN_G(ghyst, range)           ((32 * ghyst) / range)
+
+
+#define SMI_ACC2X2_SLOPE_TH_IN_G(gthres, range)    ((128 * gthres) / range)
+
+
+#define SMI_ACC2X2_GET_BITSLICE(regvar, bitname)\
+	((regvar & bitname##__MSK) >> bitname##__POS)
+
+
+#define SMI_ACC2X2_SET_BITSLICE(regvar, bitname, val)\
+	((regvar & ~bitname##__MSK) | ((val<<bitname##__POS)&bitname##__MSK))
+
+#define CHECK_CHIP_ID_TIME_MAX 5
+#define SMI_ACC255_CHIP_ID 0XFA
+#define SMI_ACC250E_CHIP_ID 0XF9
+#define SMI_ACC222E_CHIP_ID 0XF8
+#define SMI_ACC280_CHIP_ID 0XFB
+#define SMI_ACC355_CHIP_ID 0XEA
+
+#define SMI_ACC255_TYPE 0
+#define SMI_ACC250E_TYPE 1
+#define SMI_ACC222E_TYPE 2
+#define SMI_ACC280_TYPE 3
+
+#define MAX_FIFO_F_LEVEL 32
+#define MAX_FIFO_F_BYTES 6
+#define SMI_ACC_MAX_RETRY_I2C_XFER (100)
+
+#ifdef CONFIG_DOUBLE_TAP
+#define DEFAULT_TAP_JUDGE_PERIOD 1000    /* default judge in 1 second */
+#endif
+
+/*! Bosch sensor unknown place*/
+#define BOSCH_SENSOR_PLACE_UNKNOWN (-1)
+/*! Bosch sensor remapping table size P0~P7*/
+#define MAX_AXIS_REMAP_TAB_SZ 8
+
+/* How was SMI_ACC enabled(set to operation mode) */
+#define SMI_ACC_ENABLED_ALL 0
+#define SMI_ACC_ENABLED_SGM 1
+#define SMI_ACC_ENABLED_DTAP 2
+#define SMI_ACC_ENABLED_INPUT 3
+#define SMI_ACC_ENABLED_BSX 4
+
+
+/*!
+ * @brief:BMI058 feature
+ *  macro definition
+*/
+
+#define SMI_ACC2X2_FIFO_DAT_SEL_X                     1
+#define SMI_ACC2X2_FIFO_DAT_SEL_Y                     2
+#define SMI_ACC2X2_FIFO_DAT_SEL_Z                     3
+
+#ifdef CONFIG_SENSORS_BMI058
+#define C_BMI058_One_U8X                                 1
+#define C_BMI058_Two_U8X                                 2
+#define BMI058_OFFSET_TRIGGER_X                SMI_ACC2X2_OFFSET_TRIGGER_Y
+#define BMI058_OFFSET_TRIGGER_Y                SMI_ACC2X2_OFFSET_TRIGGER_X
+
+/*! BMI058 X AXIS OFFSET REG definition*/
+#define BMI058_OFFSET_X_AXIS_REG              SMI_ACC2X2_OFFSET_Y_AXIS_REG
+/*! BMI058 Y AXIS OFFSET REG definition*/
+#define BMI058_OFFSET_Y_AXIS_REG              SMI_ACC2X2_OFFSET_X_AXIS_REG
+
+#define BMI058_FIFO_DAT_SEL_X                       SMI_ACC2X2_FIFO_DAT_SEL_Y
+#define BMI058_FIFO_DAT_SEL_Y                       SMI_ACC2X2_FIFO_DAT_SEL_X
+
+/*! SMI130_ACC common slow no motion X interrupt type definition*/
+#define SMI_ACC2X2_SLOW_NO_MOT_X_INT          12
+/*! SMI130_ACC common slow no motion Y interrupt type definition*/
+#define SMI_ACC2X2_SLOW_NO_MOT_Y_INT          13
+/*! SMI130_ACC common High G X interrupt type definition*/
+#define SMI_ACC2X2_HIGHG_X_INT          1
+/*! SMI130_ACC common High G Y interrupt type definition*/
+#define SMI_ACC2X2_HIGHG_Y_INT          2
+/*! SMI130_ACC common slope X interrupt type definition*/
+#define SMI_ACC2X2_SLOPE_X_INT          5
+/*! SMI130_ACC common slope Y interrupt type definition*/
+#define SMI_ACC2X2_SLOPE_Y_INT          6
+
+/*! this structure holds some interrupt types difference
+**between SMI130_ACC and BMI058.
+*/
+struct interrupt_map_t {
+	int x;
+	int y;
+};
+/*!*Need to use SMI130_ACC Common interrupt type definition to
+* instead of Some of BMI058 reversed Interrupt type
+* because of HW Register.
+* The reversed Interrupt types contain:
+* slow_no_mot_x_int && slow_not_mot_y_int
+* highg_x_int && highg_y_int
+* slope_x_int && slope_y_int
+**/
+static const struct interrupt_map_t int_map[] = {
+	{SMI_ACC2X2_SLOW_NO_MOT_X_INT, SMI_ACC2X2_SLOW_NO_MOT_Y_INT},
+	{SMI_ACC2X2_HIGHG_X_INT, SMI_ACC2X2_HIGHG_Y_INT},
+	{SMI_ACC2X2_SLOPE_X_INT, SMI_ACC2X2_SLOPE_Y_INT}
+};
+
+/*! high g or slope interrupt type definition for BMI058*/
+/*! High G interrupt of x, y, z axis happened */
+#define HIGH_G_INTERRUPT_X            HIGH_G_INTERRUPT_Y_HAPPENED
+#define HIGH_G_INTERRUPT_Y            HIGH_G_INTERRUPT_X_HAPPENED
+#define HIGH_G_INTERRUPT_Z            HIGH_G_INTERRUPT_Z_HAPPENED
+/*! High G interrupt of x, y, z negative axis happened */
+#define HIGH_G_INTERRUPT_X_N          HIGH_G_INTERRUPT_Y_NEGATIVE_HAPPENED
+#define HIGH_G_INTERRUPT_Y_N          HIGH_G_INTERRUPT_X_NEGATIVE_HAPPENED
+#define HIGH_G_INTERRUPT_Z_N          HIGH_G_INTERRUPT_Z_NEGATIVE_HAPPENED
+/*! Slope interrupt of x, y, z axis happened */
+#define SLOPE_INTERRUPT_X             SLOPE_INTERRUPT_Y_HAPPENED
+#define SLOPE_INTERRUPT_Y             SLOPE_INTERRUPT_X_HAPPENED
+#define SLOPE_INTERRUPT_Z             SLOPE_INTERRUPT_Z_HAPPENED
+/*! Slope interrupt of x, y, z negative axis happened */
+#define SLOPE_INTERRUPT_X_N           SLOPE_INTERRUPT_Y_NEGATIVE_HAPPENED
+#define SLOPE_INTERRUPT_Y_N           SLOPE_INTERRUPT_X_NEGATIVE_HAPPENED
+#define SLOPE_INTERRUPT_Z_N           SLOPE_INTERRUPT_Z_NEGATIVE_HAPPENED
+
+
+#else
+
+/*! high g or slope interrupt type definition*/
+/*! High G interrupt of x, y, z axis happened */
+#define HIGH_G_INTERRUPT_X            HIGH_G_INTERRUPT_X_HAPPENED
+#define HIGH_G_INTERRUPT_Y            HIGH_G_INTERRUPT_Y_HAPPENED
+#define HIGH_G_INTERRUPT_Z            HIGH_G_INTERRUPT_Z_HAPPENED
+/*! High G interrupt of x, y, z negative axis happened */
+#define HIGH_G_INTERRUPT_X_N          HIGH_G_INTERRUPT_X_NEGATIVE_HAPPENED
+#define HIGH_G_INTERRUPT_Y_N          HIGH_G_INTERRUPT_Y_NEGATIVE_HAPPENED
+#define HIGH_G_INTERRUPT_Z_N          HIGH_G_INTERRUPT_Z_NEGATIVE_HAPPENED
+/*! Slope interrupt of x, y, z axis happened */
+#define SLOPE_INTERRUPT_X             SLOPE_INTERRUPT_X_HAPPENED
+#define SLOPE_INTERRUPT_Y             SLOPE_INTERRUPT_Y_HAPPENED
+#define SLOPE_INTERRUPT_Z             SLOPE_INTERRUPT_Z_HAPPENED
+/*! Slope interrupt of x, y, z negative axis happened */
+#define SLOPE_INTERRUPT_X_N           SLOPE_INTERRUPT_X_NEGATIVE_HAPPENED
+#define SLOPE_INTERRUPT_Y_N           SLOPE_INTERRUPT_Y_NEGATIVE_HAPPENED
+#define SLOPE_INTERRUPT_Z_N           SLOPE_INTERRUPT_Z_NEGATIVE_HAPPENED
+
+
+#endif/*End of CONFIG_SENSORS_BMI058*/
+
+/*! A workaroud mask definition with complete resolution exists
+* aim at writing operation FIFO_CONFIG_1, 0x3E register */
+#define FIFO_WORKAROUNDS_MSK         SMI_ACC2X2_FIFO_TRIGGER_SOURCE__MSK
+
+struct smi130_acc_type_map_t {
+
+	/*! smi130_acc sensor chip id */
+	uint16_t chip_id;
+
+	/*! smi130_acc sensor type */
+	uint16_t sensor_type;
+
+	/*! smi130_acc sensor name */
+	const char *sensor_name;
+};
+
+static const struct smi130_acc_type_map_t sensor_type_map[] = {
+
+	{SMI_ACC255_CHIP_ID, SMI_ACC255_TYPE, "SMI_ACC255/254"},
+	{SMI_ACC355_CHIP_ID, SMI_ACC255_TYPE, "SMI_ACC355"},
+	{SMI_ACC250E_CHIP_ID, SMI_ACC250E_TYPE, "SMI_ACC250E"},
+	{SMI_ACC222E_CHIP_ID, SMI_ACC222E_TYPE, "SMI_ACC222E"},
+	{SMI_ACC280_CHIP_ID, SMI_ACC280_TYPE, "SMI_ACC280"},
+
+};
+
+/*!
+* Bst sensor common definition,
+* please give parameters in BSP file.
+*/
+struct bosch_sensor_specific {
+	char *name;
+	/* 0 to 7 */
+	int place;
+	int irq;
+	int (*irq_gpio_cfg)(void);
+};
+
+
+/*!
+ * we use a typedef to hide the detail,
+ * because this type might be changed
+ */
+struct bosch_sensor_axis_remap {
+	/* src means which source will be mapped to target x, y, z axis */
+	/* if an target OS axis is remapped from (-)x,
+	 * src is 0, sign_* is (-)1 */
+	/* if an target OS axis is remapped from (-)y,
+	 * src is 1, sign_* is (-)1 */
+	/* if an target OS axis is remapped from (-)z,
+	 * src is 2, sign_* is (-)1 */
+	int src_x:3;
+	int src_y:3;
+	int src_z:3;
+
+	int sign_x:2;
+	int sign_y:2;
+	int sign_z:2;
+};
+
+struct bosch_sensor_data {
+	union {
+		int16_t v[3];
+		struct {
+			int16_t x;
+			int16_t y;
+			int16_t z;
+		};
+	};
+};
+
+struct smi130_accacc {
+	s16 x;
+	s16 y;
+	s16 z;
+};
+
+struct smi130_acc_data {
+	struct i2c_client *smi130_acc_client;
+	atomic_t delay;
+	atomic_t enable;
+	atomic_t selftest_result;
+	unsigned int chip_id;
+	unsigned int fifo_count;
+	unsigned char fifo_datasel;
+	unsigned char mode;
+	signed char sensor_type;
+	uint64_t timestamp;
+	uint64_t fifo_time;
+	uint64_t base_time;
+	uint64_t acc_count;
+	uint64_t time_odr;
+	uint8_t debug_level;
+	struct work_struct report_data_work;
+	int is_timer_running;
+	struct hrtimer timer;
+	ktime_t work_delay_kt;
+	struct input_dev *input;
+
+	struct bosch_dev *bosch_acc;
+
+	struct smi130_accacc value;
+	struct mutex value_mutex;
+	struct mutex enable_mutex;
+	struct mutex mode_mutex;
+	struct delayed_work work;
+	struct work_struct irq_work;
+#ifdef CONFIG_HAS_EARLYSUSPEND
+	struct early_suspend early_suspend;
+#endif
+	int16_t IRQ;
+	struct bosch_sensor_specific *bosch_pd;
+
+	int smi_acc_mode_enabled;
+	struct input_dev *dev_interrupt;
+
+#ifdef CONFIG_SIG_MOTION
+	struct class *g_sensor_class;
+	struct device *g_sensor_dev;
+
+	/*struct smi_acc250_platform_data *pdata;*/
+	atomic_t en_sig_motion;
+#endif
+
+#ifdef CONFIG_DOUBLE_TAP
+	struct class *g_sensor_class_doubletap;
+	struct device *g_sensor_dev_doubletap;
+	atomic_t en_double_tap;
+	unsigned char tap_times;
+	struct mutex		tap_mutex;
+	struct timer_list	tap_timer;
+	int tap_time_period;
+#endif
+};
+
+#ifdef CONFIG_HAS_EARLYSUSPEND
+static void smi130_acc_early_suspend(struct early_suspend *h);
+static void smi130_acc_late_resume(struct early_suspend *h);
+#endif
+
+static int smi130_acc_set_mode(struct i2c_client *client,
+			u8 mode, u8 enabled_mode);
+static int smi130_acc_get_mode(struct i2c_client *client, u8 *mode);
+static int smi130_acc_get_fifo_mode(struct i2c_client *client, u8 *fifo_mode);
+static int smi130_acc_set_fifo_mode(struct i2c_client *client, u8 fifo_mode);
+static int smi130_acc_normal_to_suspend(struct smi130_acc_data *smi130_acc,
+				unsigned char data1, unsigned char data2);
+
+static void smi130_acc_delay(u32 msec)
+{
+	if (msec <= 20)
+		usleep_range(msec * 1000, msec * 1000);
+	else
+		msleep(msec);
+}
+/*Remapping for SMI_ACC2X2*/
+static const struct bosch_sensor_axis_remap
+bosch_axis_remap_tab_dft[MAX_AXIS_REMAP_TAB_SZ] = {
+	/* src_x src_y src_z  sign_x  sign_y  sign_z */
+	{  0,    1,    2,     1,      1,      1 }, /* P0 */
+	{  1,    0,    2,     1,     -1,      1 }, /* P1 */
+	{  0,    1,    2,    -1,     -1,      1 }, /* P2 */
+	{  1,    0,    2,    -1,      1,      1 }, /* P3 */
+
+	{  0,    1,    2,    -1,      1,     -1 }, /* P4 */
+	{  1,    0,    2,    -1,     -1,     -1 }, /* P5 */
+	{  0,    1,    2,     1,     -1,     -1 }, /* P6 */
+	{  1,    0,    2,     1,      1,     -1 }, /* P7 */
+};
+
+
+static void bosch_remap_sensor_data(struct bosch_sensor_data *data,
+		const struct bosch_sensor_axis_remap *remap)
+{
+	struct bosch_sensor_data tmp;
+
+	tmp.x = data->v[remap->src_x] * remap->sign_x;
+	tmp.y = data->v[remap->src_y] * remap->sign_y;
+	tmp.z = data->v[remap->src_z] * remap->sign_z;
+
+	memcpy(data, &tmp, sizeof(*data));
+}
+
+
+static void bosch_remap_sensor_data_dft_tab(struct bosch_sensor_data *data,
+		int place)
+{
+	/* sensor with place 0 needs not to be remapped */
+	if ((place <= 0) || (place >= MAX_AXIS_REMAP_TAB_SZ))
+		return;
+
+	bosch_remap_sensor_data(data, &bosch_axis_remap_tab_dft[place]);
+}
+
+static void smi130_acc_remap_sensor_data(struct smi130_accacc *val,
+		struct smi130_acc_data *client_data)
+{
+	struct bosch_sensor_data bsd;
+	int place;
+
+	if ((NULL == client_data->bosch_pd) || (BOSCH_SENSOR_PLACE_UNKNOWN
+			 == client_data->bosch_pd->place))
+		place = BOSCH_SENSOR_PLACE_UNKNOWN;
+	else
+		place = client_data->bosch_pd->place;
+
+#ifdef CONFIG_SENSORS_BMI058
+/*x,y need to be invesed becase of HW Register for BMI058*/
+	bsd.y = val->x;
+	bsd.x = val->y;
+	bsd.z = val->z;
+#else
+	bsd.x = val->x;
+	bsd.y = val->y;
+	bsd.z = val->z;
+#endif
+
+	bosch_remap_sensor_data_dft_tab(&bsd, place);
+
+	val->x = bsd.x;
+	val->y = bsd.y;
+	val->z = bsd.z;
+
+}
+
+
+static int smi130_acc_smbus_read_byte(struct i2c_client *client,
+		unsigned char reg_addr, unsigned char *data)
+{
+#if !defined SMI130_ACC_USE_BASIC_I2C_FUNC
+	s32 dummy;
+	int len = 1;
+	if (NULL == client)
+		return -ENODEV;
+
+	while (0 != len--) {
+#ifdef SMI130_ACC_SMBUS
+		dummy = i2c_smbus_read_byte_data(client, reg_addr);
+		if (dummy < 0) {
+			PERR("i2c bus read error");
+			return -EIO;
+		}
+		*data = (u8)(dummy & 0xff);
+#else
+		dummy = i2c_master_send(client, (char *)&reg_addr, 1);
+		if (dummy < 0)
+			return -EIO;
+
+		dummy = i2c_master_recv(client, (char *)data, 1);
+		if (dummy < 0)
+			return -EIO;
+#endif
+		reg_addr++;
+		data++;
+	}
+	return 0;
+#else
+	int retry;
+	int len = 1;
+	struct i2c_msg msg[] = {
+		{
+		 .addr = client->addr,
+		 .flags = 0,
+		 .len = 1,
+		 .buf = &reg_addr,
+		},
+
+		{
+		 .addr = client->addr,
+		 .flags = I2C_M_RD,
+		 .len = len,
+		 .buf = data,
+		 },
+	};
+
+	for (retry = 0; retry < SMI_ACC_MAX_RETRY_I2C_XFER; retry++) {
+		if (i2c_transfer(client->adapter, msg, ARRAY_SIZE(msg)) > 0)
+			break;
+		else
+			smi130_acc_delay(1);
+	}
+
+	if (SMI_ACC_MAX_RETRY_I2C_XFER <= retry) {
+		PERR("I2C xfer error");
+		return -EIO;
+	}
+
+	return 0;
+#endif
+}
+
+static int smi130_acc_smbus_write_byte(struct i2c_client *client,
+		unsigned char reg_addr, unsigned char *data)
+{
+#if !defined SMI130_ACC_USE_BASIC_I2C_FUNC
+	s32 dummy;
+	int len = 1;
+#ifndef SMI130_ACC_SMBUS
+	u8 buffer[2];
+#endif
+	if (NULL == client)
+		return -ENODEV;
+
+	while (0 != len--) {
+#ifdef SMI130_ACC_SMBUS
+		dummy = i2c_smbus_write_byte_data(client, reg_addr, *data);
+#else
+		buffer[0] = reg_addr;
+		buffer[1] = *data;
+		dummy = i2c_master_send(client, (char *)buffer, 2);
+#endif
+		reg_addr++;
+		data++;
+		if (dummy < 0) {
+			PERR("error writing i2c bus");
+			return -EIO;
+		}
+
+	}
+	return 0;
+#else
+	u8 buffer[2];
+	int retry;
+	int len = 1;
+	struct i2c_msg msg[] = {
+		{
+			.addr = client->addr,
+			.flags = 0,
+			.len = 2,
+			.buf = buffer,
+		},
+	};
+	while (0 != len--) {
+		buffer[0] = reg_addr;
+		buffer[1] = *data;
+		for (retry = 0; retry < SMI_ACC_MAX_RETRY_I2C_XFER; retry++) {
+			if (i2c_transfer(client->adapter, msg,
+						ARRAY_SIZE(msg)) > 0) {
+				break;
+			} else {
+				smi130_acc_delay(1);
+			}
+		}
+		if (SMI_ACC_MAX_RETRY_I2C_XFER <= retry) {
+			PERR("I2C xfer error");
+			return -EIO;
+		}
+		reg_addr++;
+		data++;
+	}
+
+	return 0;
+#endif
+}
+
+static int smi130_acc_smbus_read_byte_block(struct i2c_client *client,
+		unsigned char reg_addr, unsigned char *data, unsigned char len)
+{
+	int retry;
+
+	struct i2c_msg msg[] = {
+		{
+			.addr = client->addr,
+			.flags = 0,
+			.len = 1,
+			.buf = &reg_addr,
+		},
+
+		{
+			.addr = client->addr,
+			.flags = I2C_M_RD,
+			.len = len,
+			.buf = data,
+		},
+	};
+
+	for (retry = 0; retry < SMI_ACC_MAX_RETRY_I2C_XFER; retry++) {
+		if (i2c_transfer(client->adapter, msg, ARRAY_SIZE(msg)) > 0)
+			break;
+		else
+			smi130_acc_delay(1);
+	}
+
+	if (SMI_ACC_MAX_RETRY_I2C_XFER <= retry) {
+		PERR("I2C xfer error");
+		return -EIO;
+	}
+	return 0;
+}
+
+static int smi_acc_i2c_burst_read(struct i2c_client *client, u8 reg_addr,
+		u8 *data, u16 len)
+{
+	int retry;
+
+	struct i2c_msg msg[] = {
+		{
+		 .addr = client->addr,
+		 .flags = 0,
+		 .len = 1,
+		 .buf = &reg_addr,
+		},
+
+		{
+		 .addr = client->addr,
+		 .flags = I2C_M_RD,
+		 .len = len,
+		 .buf = data,
+		 },
+	};
+
+	for (retry = 0; retry < SMI_ACC_MAX_RETRY_I2C_XFER; retry++) {
+		if (i2c_transfer(client->adapter, msg, ARRAY_SIZE(msg)) > 0)
+			break;
+		else
+			smi130_acc_delay(1);
+	}
+
+	if (SMI_ACC_MAX_RETRY_I2C_XFER <= retry) {
+		PINFO("I2C xfer error");
+		return -EIO;
+	}
+
+	return 0;
+}
+
+static int smi130_acc_check_chip_id(struct i2c_client *client,
+					struct smi130_acc_data *data)
+{
+	int i = 0;
+	int err = 0;
+	unsigned char chip_id = 0;
+	unsigned char read_count = 0;
+	unsigned char smi130_acc_sensor_type_count = 0;
+
+	smi130_acc_sensor_type_count =
+		sizeof(sensor_type_map) / sizeof(struct smi130_acc_type_map_t);
+
+	while (read_count++ < CHECK_CHIP_ID_TIME_MAX) {
+		if (smi130_acc_smbus_read_byte(client, SMI_ACC2X2_CHIP_ID_REG,
+							&chip_id) < 0) {
+			PERR("Bosch Sensortec Device not found\n\n"
+			"i2c bus read error, read chip_id:%d\n", chip_id);
+			continue;
+		} else {
+		for (i = 0; i < smi130_acc_sensor_type_count; i++) {
+			if (sensor_type_map[i].chip_id == chip_id) {
+				data->sensor_type =
+					sensor_type_map[i].sensor_type;
+				data->chip_id = chip_id;
+				PINFO("Bosch Sensortec Device detected,\n\n"
+					" HW IC name: %s\n",
+						sensor_type_map[i].sensor_name);
+					return err;
+			}
+		}
+		if (i < smi130_acc_sensor_type_count)
+			return err;
+		else {
+			if (read_count == CHECK_CHIP_ID_TIME_MAX) {
+				PERR("Failed! Bosch Sensortec Device\n\n"
+					" not found, mismatch chip_id:%d\n",
+								chip_id);
+					err = -ENODEV;
+					return err;
+			}
+		}
+		smi130_acc_delay(1);
+		}
+	}
+	return err;
+}
+
+#ifdef CONFIG_SMI_ACC_ENABLE_NEWDATA_INT
+static int smi130_acc_set_newdata(struct i2c_client *client,
+			unsigned char channel, unsigned char int_newdata)
+{
+
+	unsigned char data = 0;
+	int comres = 0;
+
+	switch (channel) {
+	case SMI_ACC2X2_INT1_NDATA:
+		comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_EN_INT1_PAD_NEWDATA__REG, &data);
+		data = SMI_ACC2X2_SET_BITSLICE(data,
+				SMI_ACC2X2_EN_INT1_PAD_NEWDATA, int_newdata);
+		comres = smi130_acc_smbus_write_byte(client,
+				SMI_ACC2X2_EN_INT1_PAD_NEWDATA__REG, &data);
+		break;
+	case SMI_ACC2X2_INT2_NDATA:
+		comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_EN_INT2_PAD_NEWDATA__REG, &data);
+		data = SMI_ACC2X2_SET_BITSLICE(data,
+				SMI_ACC2X2_EN_INT2_PAD_NEWDATA, int_newdata);
+		comres = smi130_acc_smbus_write_byte(client,
+				SMI_ACC2X2_EN_INT2_PAD_NEWDATA__REG, &data);
+		break;
+	default:
+		comres = -1;
+		break;
+	}
+
+	return comres;
+
+}
+#endif /* CONFIG_SMI_ACC_ENABLE_NEWDATA_INT */
+
+#ifdef SMI_ACC2X2_ENABLE_INT1
+static int smi130_acc_set_int1_pad_sel(struct i2c_client *client, unsigned char
+		int1sel)
+{
+	int comres = 0;
+	unsigned char data = 0;
+	unsigned char state;
+	state = 0x01;
+
+
+	switch (int1sel) {
+	case 0:
+		comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_EN_INT1_PAD_LOWG__REG, &data);
+		data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_EN_INT1_PAD_LOWG,
+				state);
+		comres = smi130_acc_smbus_write_byte(client,
+				SMI_ACC2X2_EN_INT1_PAD_LOWG__REG, &data);
+		break;
+	case 1:
+		comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_EN_INT1_PAD_HIGHG__REG, &data);
+		data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_EN_INT1_PAD_HIGHG,
+				state);
+		comres = smi130_acc_smbus_write_byte(client,
+				SMI_ACC2X2_EN_INT1_PAD_HIGHG__REG, &data);
+		break;
+	case 2:
+		comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_EN_INT1_PAD_SLOPE__REG, &data);
+		data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_EN_INT1_PAD_SLOPE,
+				state);
+		comres = smi130_acc_smbus_write_byte(client,
+				SMI_ACC2X2_EN_INT1_PAD_SLOPE__REG, &data);
+		break;
+	case 3:
+		comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_EN_INT1_PAD_DB_TAP__REG, &data);
+		data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_EN_INT1_PAD_DB_TAP,
+				state);
+		comres = smi130_acc_smbus_write_byte(client,
+				SMI_ACC2X2_EN_INT1_PAD_DB_TAP__REG, &data);
+		break;
+	case 4:
+		comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_EN_INT1_PAD_SNG_TAP__REG, &data);
+		data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_EN_INT1_PAD_SNG_TAP,
+				state);
+		comres = smi130_acc_smbus_write_byte(client,
+				SMI_ACC2X2_EN_INT1_PAD_SNG_TAP__REG, &data);
+		break;
+	case 5:
+		comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_EN_INT1_PAD_ORIENT__REG, &data);
+		data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_EN_INT1_PAD_ORIENT,
+				state);
+		comres = smi130_acc_smbus_write_byte(client,
+				SMI_ACC2X2_EN_INT1_PAD_ORIENT__REG, &data);
+		break;
+	case 6:
+		comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_EN_INT1_PAD_FLAT__REG, &data);
+		data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_EN_INT1_PAD_FLAT,
+				state);
+		comres = smi130_acc_smbus_write_byte(client,
+				SMI_ACC2X2_EN_INT1_PAD_FLAT__REG, &data);
+		break;
+	case 7:
+		comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_EN_INT1_PAD_SLO_NO_MOT__REG, &data);
+		data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_EN_INT1_PAD_SLO_NO_MOT,
+				state);
+		comres = smi130_acc_smbus_write_byte(client,
+				SMI_ACC2X2_EN_INT1_PAD_SLO_NO_MOT__REG, &data);
+		break;
+
+	default:
+		break;
+	}
+
+	return comres;
+}
+#endif /* SMI_ACC2X2_ENABLE_INT1 */
+
+#ifdef SMI_ACC2X2_ENABLE_INT2
+static int smi130_acc_set_int2_pad_sel(struct i2c_client *client, unsigned char
+		int2sel)
+{
+	int comres = 0;
+	unsigned char data = 0;
+	unsigned char state;
+	state = 0x01;
+
+
+	switch (int2sel) {
+	case 0:
+		comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_EN_INT2_PAD_LOWG__REG, &data);
+		data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_EN_INT2_PAD_LOWG,
+				state);
+		comres = smi130_acc_smbus_write_byte(client,
+				SMI_ACC2X2_EN_INT2_PAD_LOWG__REG, &data);
+		break;
+	case 1:
+		comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_EN_INT2_PAD_HIGHG__REG, &data);
+		data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_EN_INT2_PAD_HIGHG,
+				state);
+		comres = smi130_acc_smbus_write_byte(client,
+				SMI_ACC2X2_EN_INT2_PAD_HIGHG__REG, &data);
+		break;
+	case 2:
+		comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_EN_INT2_PAD_SLOPE__REG, &data);
+		data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_EN_INT2_PAD_SLOPE,
+				state);
+		comres = smi130_acc_smbus_write_byte(client,
+				SMI_ACC2X2_EN_INT2_PAD_SLOPE__REG, &data);
+		break;
+	case 3:
+		comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_EN_INT2_PAD_DB_TAP__REG, &data);
+		data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_EN_INT2_PAD_DB_TAP,
+				state);
+		comres = smi130_acc_smbus_write_byte(client,
+				SMI_ACC2X2_EN_INT2_PAD_DB_TAP__REG, &data);
+		break;
+	case 4:
+		comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_EN_INT2_PAD_SNG_TAP__REG, &data);
+		data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_EN_INT2_PAD_SNG_TAP,
+				state);
+		comres = smi130_acc_smbus_write_byte(client,
+				SMI_ACC2X2_EN_INT2_PAD_SNG_TAP__REG, &data);
+		break;
+	case 5:
+		comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_EN_INT2_PAD_ORIENT__REG, &data);
+		data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_EN_INT2_PAD_ORIENT,
+				state);
+		comres = smi130_acc_smbus_write_byte(client,
+				SMI_ACC2X2_EN_INT2_PAD_ORIENT__REG, &data);
+		break;
+	case 6:
+		comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_EN_INT2_PAD_FLAT__REG, &data);
+		data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_EN_INT2_PAD_FLAT,
+				state);
+		comres = smi130_acc_smbus_write_byte(client,
+				SMI_ACC2X2_EN_INT2_PAD_FLAT__REG, &data);
+		break;
+	case 7:
+		comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_EN_INT2_PAD_SLO_NO_MOT__REG, &data);
+		data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_EN_INT2_PAD_SLO_NO_MOT,
+				state);
+		comres = smi130_acc_smbus_write_byte(client,
+				SMI_ACC2X2_EN_INT2_PAD_SLO_NO_MOT__REG, &data);
+		break;
+	default:
+		break;
+	}
+
+	return comres;
+}
+#endif /* SMI_ACC2X2_ENABLE_INT2 */
+
+static int smi130_acc_set_Int_Enable(struct i2c_client *client, unsigned char
+		InterruptType , unsigned char value)
+{
+	int comres = 0;
+	unsigned char data1 = 0;
+	unsigned char data2 = 0;
+
+	if ((11 < InterruptType) && (InterruptType < 16)) {
+		switch (InterruptType) {
+		case 12:
+			/* slow/no motion X Interrupt  */
+			comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_INT_SLO_NO_MOT_EN_X_INT__REG, &data1);
+			data1 = SMI_ACC2X2_SET_BITSLICE(data1,
+				SMI_ACC2X2_INT_SLO_NO_MOT_EN_X_INT, value);
+			comres = smi130_acc_smbus_write_byte(client,
+				SMI_ACC2X2_INT_SLO_NO_MOT_EN_X_INT__REG, &data1);
+			break;
+		case 13:
+			/* slow/no motion Y Interrupt  */
+			comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_INT_SLO_NO_MOT_EN_Y_INT__REG, &data1);
+			data1 = SMI_ACC2X2_SET_BITSLICE(data1,
+				SMI_ACC2X2_INT_SLO_NO_MOT_EN_Y_INT, value);
+			comres = smi130_acc_smbus_write_byte(client,
+				SMI_ACC2X2_INT_SLO_NO_MOT_EN_Y_INT__REG, &data1);
+			break;
+		case 14:
+			/* slow/no motion Z Interrupt  */
+			comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_INT_SLO_NO_MOT_EN_Z_INT__REG, &data1);
+			data1 = SMI_ACC2X2_SET_BITSLICE(data1,
+				SMI_ACC2X2_INT_SLO_NO_MOT_EN_Z_INT, value);
+			comres = smi130_acc_smbus_write_byte(client,
+				SMI_ACC2X2_INT_SLO_NO_MOT_EN_Z_INT__REG, &data1);
+			break;
+		case 15:
+			/* slow / no motion Interrupt select */
+			comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_INT_SLO_NO_MOT_EN_SEL_INT__REG, &data1);
+			data1 = SMI_ACC2X2_SET_BITSLICE(data1,
+				SMI_ACC2X2_INT_SLO_NO_MOT_EN_SEL_INT, value);
+			comres = smi130_acc_smbus_write_byte(client,
+				SMI_ACC2X2_INT_SLO_NO_MOT_EN_SEL_INT__REG, &data1);
+		}
+
+	return comres;
+	}
+
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_INT_ENABLE1_REG, &data1);
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_INT_ENABLE2_REG, &data2);
+
+	value = value & 1;
+	switch (InterruptType) {
+	case 0:
+		/* Low G Interrupt  */
+		data2 = SMI_ACC2X2_SET_BITSLICE(data2, SMI_ACC2X2_EN_LOWG_INT, value);
+		break;
+
+	case 1:
+		/* High G X Interrupt */
+		data2 = SMI_ACC2X2_SET_BITSLICE(data2, SMI_ACC2X2_EN_HIGHG_X_INT,
+				value);
+		break;
+
+	case 2:
+		/* High G Y Interrupt */
+		data2 = SMI_ACC2X2_SET_BITSLICE(data2, SMI_ACC2X2_EN_HIGHG_Y_INT,
+				value);
+		break;
+
+	case 3:
+		/* High G Z Interrupt */
+		data2 = SMI_ACC2X2_SET_BITSLICE(data2, SMI_ACC2X2_EN_HIGHG_Z_INT,
+				value);
+		break;
+
+	case 4:
+		/* New Data Interrupt  */
+		data2 = SMI_ACC2X2_SET_BITSLICE(data2, SMI_ACC2X2_EN_NEW_DATA_INT,
+				value);
+		break;
+
+	case 5:
+		/* Slope X Interrupt */
+		data1 = SMI_ACC2X2_SET_BITSLICE(data1, SMI_ACC2X2_EN_SLOPE_X_INT,
+				value);
+		break;
+
+	case 6:
+		/* Slope Y Interrupt */
+		data1 = SMI_ACC2X2_SET_BITSLICE(data1, SMI_ACC2X2_EN_SLOPE_Y_INT,
+				value);
+		break;
+
+	case 7:
+		/* Slope Z Interrupt */
+		data1 = SMI_ACC2X2_SET_BITSLICE(data1, SMI_ACC2X2_EN_SLOPE_Z_INT,
+				value);
+		break;
+
+	case 8:
+		/* Single Tap Interrupt */
+		data1 = SMI_ACC2X2_SET_BITSLICE(data1, SMI_ACC2X2_EN_SINGLE_TAP_INT,
+				value);
+		break;
+
+	case 9:
+		/* Double Tap Interrupt */
+		data1 = SMI_ACC2X2_SET_BITSLICE(data1, SMI_ACC2X2_EN_DOUBLE_TAP_INT,
+				value);
+		break;
+
+	case 10:
+		/* Orient Interrupt  */
+		data1 = SMI_ACC2X2_SET_BITSLICE(data1, SMI_ACC2X2_EN_ORIENT_INT, value);
+		break;
+
+	case 11:
+		/* Flat Interrupt */
+		data1 = SMI_ACC2X2_SET_BITSLICE(data1, SMI_ACC2X2_EN_FLAT_INT, value);
+		break;
+
+	default:
+		break;
+	}
+	comres = smi130_acc_smbus_write_byte(client, SMI_ACC2X2_INT_ENABLE1_REG,
+			&data1);
+	comres = smi130_acc_smbus_write_byte(client, SMI_ACC2X2_INT_ENABLE2_REG,
+			&data2);
+
+	return comres;
+}
+
+
+#if defined(SMI_ACC2X2_ENABLE_INT1) || defined(SMI_ACC2X2_ENABLE_INT2)
+static int smi130_acc_get_interruptstatus1(struct i2c_client *client, unsigned char
+		*intstatus)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_STATUS1_REG, &data);
+	*intstatus = data;
+
+	return comres;
+}
+
+#ifdef CONFIG_SMI_ACC_ENABLE_NEWDATA_INT
+/*
+static int smi130_acc_get_interruptstatus2(struct i2c_client *client, unsigned char
+		*intstatus)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_STATUS2_REG, &data);
+	*intstatus = data;
+
+	return comres;
+}
+*/
+#endif
+
+static int smi130_acc_get_HIGH_first(struct i2c_client *client, unsigned char
+						param, unsigned char *intstatus)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	switch (param) {
+	case 0:
+		comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_STATUS_ORIENT_HIGH_REG, &data);
+		data = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_HIGHG_FIRST_X);
+		*intstatus = data;
+		break;
+	case 1:
+		comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_STATUS_ORIENT_HIGH_REG, &data);
+		data = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_HIGHG_FIRST_Y);
+		*intstatus = data;
+		break;
+	case 2:
+		comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_STATUS_ORIENT_HIGH_REG, &data);
+		data = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_HIGHG_FIRST_Z);
+		*intstatus = data;
+		break;
+	default:
+		break;
+	}
+
+	return comres;
+}
+
+static int smi130_acc_get_HIGH_sign(struct i2c_client *client, unsigned char
+		*intstatus)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_STATUS_ORIENT_HIGH_REG,
+			&data);
+	data = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_HIGHG_SIGN_S);
+	*intstatus = data;
+
+	return comres;
+}
+
+#ifndef CONFIG_SIG_MOTION
+static int smi130_acc_get_slope_first(struct i2c_client *client, unsigned char
+	param, unsigned char *intstatus)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	switch (param) {
+	case 0:
+		comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_STATUS_TAP_SLOPE_REG, &data);
+		data = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_SLOPE_FIRST_X);
+		*intstatus = data;
+		break;
+	case 1:
+		comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_STATUS_TAP_SLOPE_REG, &data);
+		data = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_SLOPE_FIRST_Y);
+		*intstatus = data;
+		break;
+	case 2:
+		comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_STATUS_TAP_SLOPE_REG, &data);
+		data = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_SLOPE_FIRST_Z);
+		*intstatus = data;
+		break;
+	default:
+		break;
+	}
+
+	return comres;
+}
+
+static int smi130_acc_get_slope_sign(struct i2c_client *client, unsigned char
+		*intstatus)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_STATUS_TAP_SLOPE_REG,
+			&data);
+	data = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_SLOPE_SIGN_S);
+	*intstatus = data;
+
+	return comres;
+}
+#endif
+
+static int smi130_acc_get_orient_mbl_status(struct i2c_client *client, unsigned char
+		*intstatus)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_STATUS_ORIENT_HIGH_REG,
+			&data);
+	data = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_ORIENT_S);
+	*intstatus = data;
+
+	return comres;
+}
+
+static int smi130_acc_get_orient_mbl_flat_status(struct i2c_client *client, unsigned
+		char *intstatus)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_STATUS_ORIENT_HIGH_REG,
+			&data);
+	data = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_FLAT_S);
+	*intstatus = data;
+
+	return comres;
+}
+#endif /* defined(SMI_ACC2X2_ENABLE_INT1)||defined(SMI_ACC2X2_ENABLE_INT2) */
+
+static int smi130_acc_set_Int_Mode(struct i2c_client *client, unsigned char Mode)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+
+	comres = smi130_acc_smbus_read_byte(client,
+			SMI_ACC2X2_INT_MODE_SEL__REG, &data);
+	data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_INT_MODE_SEL, Mode);
+	comres = smi130_acc_smbus_write_byte(client,
+			SMI_ACC2X2_INT_MODE_SEL__REG, &data);
+
+
+	return comres;
+}
+
+static int smi130_acc_get_Int_Mode(struct i2c_client *client, unsigned char *Mode)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+
+	comres = smi130_acc_smbus_read_byte(client,
+			SMI_ACC2X2_INT_MODE_SEL__REG, &data);
+	data  = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_INT_MODE_SEL);
+	*Mode = data;
+
+
+	return comres;
+}
+static int smi130_acc_set_slope_duration(struct i2c_client *client, unsigned char
+		duration)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+
+	comres = smi130_acc_smbus_read_byte(client,
+			SMI_ACC2X2_SLOPE_DUR__REG, &data);
+	data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_SLOPE_DUR, duration);
+	comres = smi130_acc_smbus_write_byte(client,
+			SMI_ACC2X2_SLOPE_DUR__REG, &data);
+
+	return comres;
+}
+
+static int smi130_acc_get_slope_duration(struct i2c_client *client, unsigned char
+		*status)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+
+	comres = smi130_acc_smbus_read_byte(client,
+			SMI_ACC2X2_SLOPE_DURN_REG, &data);
+	data = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_SLOPE_DUR);
+	*status = data;
+
+
+	return comres;
+}
+
+static int smi130_acc_set_slope_no_mot_duration(struct i2c_client *client,
+			unsigned char duration)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+
+	comres = smi130_acc_smbus_read_byte(client,
+			SMI130_ACC_SLO_NO_MOT_DUR__REG, &data);
+	data = SMI_ACC2X2_SET_BITSLICE(data, SMI130_ACC_SLO_NO_MOT_DUR, duration);
+	comres = smi130_acc_smbus_write_byte(client,
+			SMI130_ACC_SLO_NO_MOT_DUR__REG, &data);
+
+
+	return comres;
+}
+
+static int smi130_acc_get_slope_no_mot_duration(struct i2c_client *client,
+			unsigned char *status)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+
+	comres = smi130_acc_smbus_read_byte(client,
+			SMI130_ACC_SLO_NO_MOT_DUR__REG, &data);
+	data = SMI_ACC2X2_GET_BITSLICE(data, SMI130_ACC_SLO_NO_MOT_DUR);
+	*status = data;
+
+
+	return comres;
+}
+
+static int smi130_acc_set_slope_threshold(struct i2c_client *client,
+		unsigned char threshold)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	data = threshold;
+	comres = smi130_acc_smbus_write_byte(client,
+			SMI_ACC2X2_SLOPE_THRES__REG, &data);
+
+	return comres;
+}
+
+static int smi130_acc_get_slope_threshold(struct i2c_client *client,
+		unsigned char *status)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+
+	comres = smi130_acc_smbus_read_byte(client,
+			SMI_ACC2X2_SLOPE_THRES_REG, &data);
+	*status = data;
+
+	return comres;
+}
+
+static int smi130_acc_set_slope_no_mot_threshold(struct i2c_client *client,
+		unsigned char threshold)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	data = threshold;
+	comres = smi130_acc_smbus_write_byte(client,
+			SMI_ACC2X2_SLO_NO_MOT_THRES_REG, &data);
+
+	return comres;
+}
+
+static int smi130_acc_get_slope_no_mot_threshold(struct i2c_client *client,
+		unsigned char *status)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+
+	comres = smi130_acc_smbus_read_byte(client,
+			SMI_ACC2X2_SLO_NO_MOT_THRES_REG, &data);
+	*status = data;
+
+	return comres;
+}
+
+
+static int smi130_acc_set_low_g_duration(struct i2c_client *client, unsigned char
+		duration)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_LOWG_DUR__REG, &data);
+	data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_LOWG_DUR, duration);
+	comres = smi130_acc_smbus_write_byte(client, SMI_ACC2X2_LOWG_DUR__REG, &data);
+
+	return comres;
+}
+
+static int smi130_acc_get_low_g_duration(struct i2c_client *client, unsigned char
+		*status)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_LOW_DURN_REG, &data);
+	data = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_LOWG_DUR);
+	*status = data;
+
+	return comres;
+}
+
+static int smi130_acc_set_low_g_threshold(struct i2c_client *client, unsigned char
+		threshold)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_LOWG_THRES__REG, &data);
+	data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_LOWG_THRES, threshold);
+	comres = smi130_acc_smbus_write_byte(client, SMI_ACC2X2_LOWG_THRES__REG, &data);
+
+	return comres;
+}
+
+static int smi130_acc_get_low_g_threshold(struct i2c_client *client, unsigned char
+		*status)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_LOW_THRES_REG, &data);
+	data = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_LOWG_THRES);
+	*status = data;
+
+	return comres;
+}
+
+static int smi130_acc_set_high_g_duration(struct i2c_client *client, unsigned char
+		duration)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_HIGHG_DUR__REG, &data);
+	data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_HIGHG_DUR, duration);
+	comres = smi130_acc_smbus_write_byte(client, SMI_ACC2X2_HIGHG_DUR__REG, &data);
+
+	return comres;
+}
+
+static int smi130_acc_get_high_g_duration(struct i2c_client *client, unsigned char
+		*status)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_HIGH_DURN_REG, &data);
+	data = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_HIGHG_DUR);
+	*status = data;
+
+	return comres;
+}
+
+static int smi130_acc_set_high_g_threshold(struct i2c_client *client, unsigned char
+		threshold)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_HIGHG_THRES__REG, &data);
+	data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_HIGHG_THRES, threshold);
+	comres = smi130_acc_smbus_write_byte(client, SMI_ACC2X2_HIGHG_THRES__REG,
+			&data);
+
+	return comres;
+}
+
+static int smi130_acc_get_high_g_threshold(struct i2c_client *client, unsigned char
+		*status)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_HIGH_THRES_REG, &data);
+	data = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_HIGHG_THRES);
+	*status = data;
+
+	return comres;
+}
+
+
+static int smi130_acc_set_tap_duration(struct i2c_client *client, unsigned char
+		duration)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_TAP_DUR__REG, &data);
+	data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_TAP_DUR, duration);
+	comres = smi130_acc_smbus_write_byte(client, SMI_ACC2X2_TAP_DUR__REG, &data);
+
+	return comres;
+}
+
+static int smi130_acc_get_tap_duration(struct i2c_client *client, unsigned char
+		*status)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_TAP_PARAM_REG, &data);
+	data = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_TAP_DUR);
+	*status = data;
+
+	return comres;
+}
+
+static int smi130_acc_set_tap_shock(struct i2c_client *client, unsigned char setval)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_TAP_SHOCK_DURN__REG,
+			&data);
+	data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_TAP_SHOCK_DURN, setval);
+	comres = smi130_acc_smbus_write_byte(client, SMI_ACC2X2_TAP_SHOCK_DURN__REG,
+			&data);
+
+	return comres;
+}
+
+static int smi130_acc_get_tap_shock(struct i2c_client *client, unsigned char
+		*status)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_TAP_PARAM_REG, &data);
+	data = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_TAP_SHOCK_DURN);
+	*status = data;
+
+	return comres;
+}
+
+static int smi130_acc_set_tap_quiet(struct i2c_client *client, unsigned char
+		duration)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_TAP_QUIET_DURN__REG,
+			&data);
+	data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_TAP_QUIET_DURN, duration);
+	comres = smi130_acc_smbus_write_byte(client, SMI_ACC2X2_TAP_QUIET_DURN__REG,
+			&data);
+
+	return comres;
+}
+
+static int smi130_acc_get_tap_quiet(struct i2c_client *client, unsigned char
+		*status)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_TAP_PARAM_REG, &data);
+	data = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_TAP_QUIET_DURN);
+	*status = data;
+
+	return comres;
+}
+
+static int smi130_acc_set_tap_threshold(struct i2c_client *client, unsigned char
+		threshold)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_TAP_THRES__REG, &data);
+	data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_TAP_THRES, threshold);
+	comres = smi130_acc_smbus_write_byte(client, SMI_ACC2X2_TAP_THRES__REG, &data);
+
+	return comres;
+}
+
+static int smi130_acc_get_tap_threshold(struct i2c_client *client, unsigned char
+		*status)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_TAP_THRES_REG, &data);
+	data = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_TAP_THRES);
+	*status = data;
+
+	return comres;
+}
+
+static int smi130_acc_set_tap_samp(struct i2c_client *client, unsigned char samp)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_TAP_SAMPLES__REG, &data);
+	data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_TAP_SAMPLES, samp);
+	comres = smi130_acc_smbus_write_byte(client, SMI_ACC2X2_TAP_SAMPLES__REG,
+			&data);
+
+	return comres;
+}
+
+static int smi130_acc_get_tap_samp(struct i2c_client *client, unsigned char *status)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_TAP_THRES_REG, &data);
+	data = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_TAP_SAMPLES);
+	*status = data;
+
+	return comres;
+}
+
+static int smi130_acc_set_orient_mbl_mode(struct i2c_client *client, unsigned char mode)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_ORIENT_MODE__REG, &data);
+	data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_ORIENT_MODE, mode);
+	comres = smi130_acc_smbus_write_byte(client, SMI_ACC2X2_ORIENT_MODE__REG,
+			&data);
+
+	return comres;
+}
+
+static int smi130_acc_get_orient_mbl_mode(struct i2c_client *client, unsigned char
+		*status)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_ORIENT_PARAM_REG, &data);
+	data = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_ORIENT_MODE);
+	*status = data;
+
+	return comres;
+}
+
+static int smi130_acc_set_orient_mbl_blocking(struct i2c_client *client, unsigned char
+		samp)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_ORIENT_BLOCK__REG,
+			&data);
+	data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_ORIENT_BLOCK, samp);
+	comres = smi130_acc_smbus_write_byte(client, SMI_ACC2X2_ORIENT_BLOCK__REG,
+			&data);
+
+	return comres;
+}
+
+static int smi130_acc_get_orient_mbl_blocking(struct i2c_client *client, unsigned char
+		*status)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_ORIENT_PARAM_REG, &data);
+	data = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_ORIENT_BLOCK);
+	*status = data;
+
+	return comres;
+}
+
+static int smi130_acc_set_orient_mbl_hyst(struct i2c_client *client, unsigned char
+		orient_mblhyst)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_ORIENT_HYST__REG, &data);
+	data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_ORIENT_HYST, orient_mblhyst);
+	comres = smi130_acc_smbus_write_byte(client, SMI_ACC2X2_ORIENT_HYST__REG,
+			&data);
+
+	return comres;
+}
+
+static int smi130_acc_get_orient_mbl_hyst(struct i2c_client *client, unsigned char
+		*status)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_ORIENT_PARAM_REG, &data);
+	data = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_ORIENT_HYST);
+	*status = data;
+
+	return comres;
+}
+static int smi130_acc_set_theta_blocking(struct i2c_client *client, unsigned char
+		thetablk)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_THETA_BLOCK__REG, &data);
+	data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_THETA_BLOCK, thetablk);
+	comres = smi130_acc_smbus_write_byte(client, SMI_ACC2X2_THETA_BLOCK__REG,
+			&data);
+
+	return comres;
+}
+
+static int smi130_acc_get_theta_blocking(struct i2c_client *client, unsigned char
+		*status)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_THETA_BLOCK_REG, &data);
+	data = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_THETA_BLOCK);
+	*status = data;
+
+	return comres;
+}
+
+static int smi130_acc_set_theta_flat(struct i2c_client *client, unsigned char
+		thetaflat)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_THETA_FLAT__REG, &data);
+	data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_THETA_FLAT, thetaflat);
+	comres = smi130_acc_smbus_write_byte(client, SMI_ACC2X2_THETA_FLAT__REG, &data);
+
+	return comres;
+}
+
+static int smi130_acc_get_theta_flat(struct i2c_client *client, unsigned char
+		*status)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_THETA_FLAT_REG, &data);
+	data = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_THETA_FLAT);
+	*status = data;
+
+	return comres;
+}
+
+static int smi130_acc_set_flat_hold_time(struct i2c_client *client, unsigned char
+		holdtime)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_FLAT_HOLD_TIME__REG,
+			&data);
+	data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_FLAT_HOLD_TIME, holdtime);
+	comres = smi130_acc_smbus_write_byte(client, SMI_ACC2X2_FLAT_HOLD_TIME__REG,
+			&data);
+
+	return comres;
+}
+
+static int smi130_acc_get_flat_hold_time(struct i2c_client *client, unsigned char
+		*holdtime)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_FLAT_HOLD_TIME_REG,
+			&data);
+	data  = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_FLAT_HOLD_TIME);
+	*holdtime = data;
+
+	return comres;
+}
+
+/*!
+ * brief: smi130_acc switch from normal to suspend mode
+ * @param[i] smi130_acc
+ * @param[i] data1, write to PMU_LPW
+ * @param[i] data2, write to PMU_LOW_NOSIE
+ *
+ * @return zero success, none-zero failed
+ */
+static int smi130_acc_normal_to_suspend(struct smi130_acc_data *smi130_acc,
+				unsigned char data1, unsigned char data2)
+{
+	unsigned char current_fifo_mode;
+	unsigned char current_op_mode;
+	if (smi130_acc == NULL)
+		return -ENODEV;
+	/* get current op mode from mode register */
+	if (smi130_acc_get_mode(smi130_acc->smi130_acc_client, &current_op_mode) < 0)
+		return -EIO;
+	/* only aimed at operatiom mode chang from normal/lpw1 mode
+	 * to suspend state.
+	*/
+	if (current_op_mode == SMI_ACC2X2_MODE_NORMAL ||
+			current_op_mode == SMI_ACC2X2_MODE_LOWPOWER1) {
+		/* get current fifo mode from fifo config register */
+		if (smi130_acc_get_fifo_mode(smi130_acc->smi130_acc_client,
+							&current_fifo_mode) < 0)
+			return -EIO;
+		else {
+			smi130_acc_smbus_write_byte(smi130_acc->smi130_acc_client,
+					SMI_ACC2X2_LOW_NOISE_CTRL_REG, &data2);
+			smi130_acc_smbus_write_byte(smi130_acc->smi130_acc_client,
+					SMI_ACC2X2_MODE_CTRL_REG, &data1);
+			/*! Aim at fifo workarounds with FIFO_CONFIG_1 */
+			current_fifo_mode |= FIFO_WORKAROUNDS_MSK;
+			smi130_acc_smbus_write_byte(smi130_acc->smi130_acc_client,
+				SMI_ACC2X2_FIFO_MODE__REG, &current_fifo_mode);
+			smi130_acc_delay(3);
+			return 0;
+		}
+	} else {
+		smi130_acc_smbus_write_byte(smi130_acc->smi130_acc_client,
+					SMI_ACC2X2_LOW_NOISE_CTRL_REG, &data2);
+		smi130_acc_smbus_write_byte(smi130_acc->smi130_acc_client,
+					SMI_ACC2X2_MODE_CTRL_REG, &data1);
+		smi130_acc_delay(3);
+		return 0;
+	}
+
+}
+
+static int smi130_acc_set_mode(struct i2c_client *client, unsigned char mode,
+						unsigned char enabled_mode)
+{
+	int comres = 0;
+	unsigned char data1 = 0;
+	unsigned char data2 = 0;
+	int ret = 0;
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	mutex_lock(&smi130_acc->mode_mutex);
+	if (SMI_ACC2X2_MODE_SUSPEND == mode) {
+		if (enabled_mode != SMI_ACC_ENABLED_ALL) {
+			if ((smi130_acc->smi_acc_mode_enabled &
+						(1<<enabled_mode)) == 0) {
+				/* sensor is already closed in this mode */
+				mutex_unlock(&smi130_acc->mode_mutex);
+				return 0;
+			} else {
+				smi130_acc->smi_acc_mode_enabled &= ~(1<<enabled_mode);
+			}
+		} else {
+			/* shut down, close all and force do it*/
+			smi130_acc->smi_acc_mode_enabled = 0;
+		}
+	} else if (SMI_ACC2X2_MODE_NORMAL == mode) {
+		if ((smi130_acc->smi_acc_mode_enabled & (1<<enabled_mode)) != 0) {
+			/* sensor is already enabled in this mode */
+			mutex_unlock(&smi130_acc->mode_mutex);
+			return 0;
+		} else {
+			smi130_acc->smi_acc_mode_enabled |= (1<<enabled_mode);
+		}
+	} else {
+		/* other mode, close all and force do it*/
+		smi130_acc->smi_acc_mode_enabled = 0;
+	}
+	mutex_unlock(&smi130_acc->mode_mutex);
+
+	if (mode < 6) {
+		comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_MODE_CTRL_REG,
+				&data1);
+		comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_LOW_NOISE_CTRL_REG,
+				&data2);
+		switch (mode) {
+		case SMI_ACC2X2_MODE_NORMAL:
+				data1  = SMI_ACC2X2_SET_BITSLICE(data1,
+						SMI_ACC2X2_MODE_CTRL, 0);
+				data2  = SMI_ACC2X2_SET_BITSLICE(data2,
+						SMI_ACC2X2_LOW_POWER_MODE, 0);
+				smi130_acc_smbus_write_byte(client,
+						SMI_ACC2X2_MODE_CTRL_REG, &data1);
+				smi130_acc_delay(3);
+				smi130_acc_smbus_write_byte(client,
+					SMI_ACC2X2_LOW_NOISE_CTRL_REG, &data2);
+				break;
+		case SMI_ACC2X2_MODE_LOWPOWER1:
+				data1  = SMI_ACC2X2_SET_BITSLICE(data1,
+						SMI_ACC2X2_MODE_CTRL, 2);
+				data2  = SMI_ACC2X2_SET_BITSLICE(data2,
+						SMI_ACC2X2_LOW_POWER_MODE, 0);
+				smi130_acc_smbus_write_byte(client,
+						SMI_ACC2X2_MODE_CTRL_REG, &data1);
+				smi130_acc_delay(3);
+				smi130_acc_smbus_write_byte(client,
+					SMI_ACC2X2_LOW_NOISE_CTRL_REG, &data2);
+				break;
+		case SMI_ACC2X2_MODE_SUSPEND:
+			if (smi130_acc->smi_acc_mode_enabled != 0) {
+				PERR("smi_acc still working");
+				return 0;
+			}
+			data1  = SMI_ACC2X2_SET_BITSLICE(data1,
+					SMI_ACC2X2_MODE_CTRL, 4);
+			data2  = SMI_ACC2X2_SET_BITSLICE(data2,
+					SMI_ACC2X2_LOW_POWER_MODE, 0);
+			/*aimed at anomaly resolution when switch to suspend*/
+			ret = smi130_acc_normal_to_suspend(smi130_acc, data1, data2);
+			if (ret < 0)
+				PERR("Error switching to suspend");
+			break;
+		case SMI_ACC2X2_MODE_DEEP_SUSPEND:
+			if (smi130_acc->smi_acc_mode_enabled != 0) {
+				PERR("smi_acc still working");
+				return 0;
+			}
+			data1  = SMI_ACC2X2_SET_BITSLICE(data1,
+				SMI_ACC2X2_MODE_CTRL, 1);
+			data2  = SMI_ACC2X2_SET_BITSLICE(data2,
+				SMI_ACC2X2_LOW_POWER_MODE, 1);
+			smi130_acc_smbus_write_byte(client,
+				SMI_ACC2X2_MODE_CTRL_REG, &data1);
+			smi130_acc_delay(3);
+			smi130_acc_smbus_write_byte(client,
+				SMI_ACC2X2_LOW_NOISE_CTRL_REG, &data2);
+			break;
+		case SMI_ACC2X2_MODE_LOWPOWER2:
+				data1  = SMI_ACC2X2_SET_BITSLICE(data1,
+						SMI_ACC2X2_MODE_CTRL, 2);
+				data2  = SMI_ACC2X2_SET_BITSLICE(data2,
+						SMI_ACC2X2_LOW_POWER_MODE, 1);
+				smi130_acc_smbus_write_byte(client,
+						SMI_ACC2X2_MODE_CTRL_REG, &data1);
+				smi130_acc_delay(3);
+				smi130_acc_smbus_write_byte(client,
+					SMI_ACC2X2_LOW_NOISE_CTRL_REG, &data2);
+				break;
+		case SMI_ACC2X2_MODE_STANDBY:
+				data1  = SMI_ACC2X2_SET_BITSLICE(data1,
+						SMI_ACC2X2_MODE_CTRL, 4);
+				data2  = SMI_ACC2X2_SET_BITSLICE(data2,
+						SMI_ACC2X2_LOW_POWER_MODE, 1);
+				smi130_acc_smbus_write_byte(client,
+					SMI_ACC2X2_LOW_NOISE_CTRL_REG, &data2);
+				smi130_acc_delay(3);
+				smi130_acc_smbus_write_byte(client,
+						SMI_ACC2X2_MODE_CTRL_REG, &data1);
+				break;
+		}
+	} else {
+		comres = -1;
+	}
+
+	return comres;
+}
+
+
+static int smi130_acc_get_mode(struct i2c_client *client, unsigned char *mode)
+{
+	int comres = 0;
+	unsigned char data1 = 0;
+	unsigned char data2 = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_MODE_CTRL_REG, &data1);
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_LOW_NOISE_CTRL_REG,
+			&data2);
+
+	data1  = (data1 & 0xE0) >> 5;
+	data2  = (data2 & 0x40) >> 6;
+
+
+	if ((data1 == 0x00) && (data2 == 0x00)) {
+		*mode  = SMI_ACC2X2_MODE_NORMAL;
+	} else {
+		if ((data1 == 0x02) && (data2 == 0x00)) {
+			*mode  = SMI_ACC2X2_MODE_LOWPOWER1;
+		} else {
+			if ((data1 == 0x04 || data1 == 0x06) &&
+						(data2 == 0x00)) {
+				*mode  = SMI_ACC2X2_MODE_SUSPEND;
+			} else {
+				if (((data1 & 0x01) == 0x01)) {
+					*mode  = SMI_ACC2X2_MODE_DEEP_SUSPEND;
+				} else {
+					if ((data1 == 0x02) &&
+							(data2 == 0x01)) {
+						*mode  = SMI_ACC2X2_MODE_LOWPOWER2;
+					} else {
+					if ((data1 == 0x04) && (data2 ==
+									0x01)) {
+							*mode  =
+							SMI_ACC2X2_MODE_STANDBY;
+					} else {
+							*mode =
+						SMI_ACC2X2_MODE_DEEP_SUSPEND;
+						}
+					}
+				}
+			}
+		}
+	}
+
+	return comres;
+}
+
+static int smi130_acc_set_range(struct i2c_client *client, unsigned char Range)
+{
+	int comres = 0;
+	unsigned char data1 = 0;
+
+	if ((Range == 3) || (Range == 5) || (Range == 8) || (Range == 12)) {
+		comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_RANGE_SEL_REG,
+				&data1);
+		switch (Range) {
+		case SMI_ACC2X2_RANGE_2G:
+			data1  = SMI_ACC2X2_SET_BITSLICE(data1,
+					SMI_ACC2X2_RANGE_SEL, 3);
+			break;
+		case SMI_ACC2X2_RANGE_4G:
+			data1  = SMI_ACC2X2_SET_BITSLICE(data1,
+					SMI_ACC2X2_RANGE_SEL, 5);
+			break;
+		case SMI_ACC2X2_RANGE_8G:
+			data1  = SMI_ACC2X2_SET_BITSLICE(data1,
+					SMI_ACC2X2_RANGE_SEL, 8);
+			break;
+		case SMI_ACC2X2_RANGE_16G:
+			data1  = SMI_ACC2X2_SET_BITSLICE(data1,
+					SMI_ACC2X2_RANGE_SEL, 12);
+			break;
+		default:
+			break;
+		}
+		comres += smi130_acc_smbus_write_byte(client, SMI_ACC2X2_RANGE_SEL_REG,
+				&data1);
+	} else {
+		comres = -1;
+	}
+
+	return comres;
+}
+
+static int smi130_acc_get_range(struct i2c_client *client, unsigned char *Range)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_RANGE_SEL__REG, &data);
+	data = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_RANGE_SEL);
+	*Range = data;
+
+	return comres;
+}
+
+
+static int smi130_acc_set_bandwidth(struct i2c_client *client, unsigned char BW)
+{
+	int comres = 0;
+	unsigned char data = 0;
+	int Bandwidth = 0;
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (BW > 7 && BW < 16) {
+		switch (BW) {
+		case SMI_ACC2X2_BW_7_81HZ:
+			Bandwidth = SMI_ACC2X2_BW_7_81HZ;
+			smi130_acc->time_odr = 64000000;
+
+			/*  7.81 Hz      64000 uS   */
+			break;
+		case SMI_ACC2X2_BW_15_63HZ:
+			Bandwidth = SMI_ACC2X2_BW_15_63HZ;
+			smi130_acc->time_odr = 32000000;
+			/*  15.63 Hz     32000 uS   */
+			break;
+		case SMI_ACC2X2_BW_31_25HZ:
+			Bandwidth = SMI_ACC2X2_BW_31_25HZ;
+			smi130_acc->time_odr = 16000000;
+			/*  31.25 Hz     16000 uS   */
+			break;
+		case SMI_ACC2X2_BW_62_50HZ:
+			Bandwidth = SMI_ACC2X2_BW_62_50HZ;
+			smi130_acc->time_odr = 8000000;
+			/*  62.50 Hz     8000 uS   */
+			break;
+		case SMI_ACC2X2_BW_125HZ:
+			Bandwidth = SMI_ACC2X2_BW_125HZ;
+			smi130_acc->time_odr = 4000000;
+			/*  125 Hz       4000 uS   */
+			break;
+		case SMI_ACC2X2_BW_250HZ:
+			Bandwidth = SMI_ACC2X2_BW_250HZ;
+			smi130_acc->time_odr = 2000000;
+			/*  250 Hz       2000 uS   */
+			break;
+		case SMI_ACC2X2_BW_500HZ:
+			Bandwidth = SMI_ACC2X2_BW_500HZ;
+			smi130_acc->time_odr = 1000000;
+			/*  500 Hz       1000 uS   */
+			break;
+		case SMI_ACC2X2_BW_1000HZ:
+			Bandwidth = SMI_ACC2X2_BW_1000HZ;
+			smi130_acc->time_odr = 500000;
+			/*  1000 Hz      500 uS   */
+			break;
+		default:
+			break;
+		}
+		comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_BANDWIDTH__REG,
+				&data);
+		data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_BANDWIDTH, Bandwidth);
+		comres += smi130_acc_smbus_write_byte(client, SMI_ACC2X2_BANDWIDTH__REG,
+				&data);
+	} else {
+		comres = -1;
+	}
+
+	return comres;
+}
+
+static int smi130_acc_get_bandwidth(struct i2c_client *client, unsigned char *BW)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_BANDWIDTH__REG, &data);
+	data = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_BANDWIDTH);
+	*BW = data;
+
+	return comres;
+}
+
+int smi130_acc_get_sleep_duration(struct i2c_client *client, unsigned char
+		*sleep_dur)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client,
+			SMI_ACC2X2_SLEEP_DUR__REG, &data);
+	data = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_SLEEP_DUR);
+	*sleep_dur = data;
+
+	return comres;
+}
+
+int smi130_acc_set_sleep_duration(struct i2c_client *client, unsigned char
+		sleep_dur)
+{
+	int comres = 0;
+	unsigned char data = 0;
+	int sleep_duration = 0;
+
+	if (sleep_dur > 4 && sleep_dur < 16) {
+		switch (sleep_dur) {
+		case SMI_ACC2X2_SLEEP_DUR_0_5MS:
+			sleep_duration = SMI_ACC2X2_SLEEP_DUR_0_5MS;
+
+			/*  0.5 MS   */
+			break;
+		case SMI_ACC2X2_SLEEP_DUR_1MS:
+			sleep_duration = SMI_ACC2X2_SLEEP_DUR_1MS;
+
+			/*  1 MS  */
+			break;
+		case SMI_ACC2X2_SLEEP_DUR_2MS:
+			sleep_duration = SMI_ACC2X2_SLEEP_DUR_2MS;
+
+			/*  2 MS  */
+			break;
+		case SMI_ACC2X2_SLEEP_DUR_4MS:
+			sleep_duration = SMI_ACC2X2_SLEEP_DUR_4MS;
+
+			/*  4 MS   */
+			break;
+		case SMI_ACC2X2_SLEEP_DUR_6MS:
+			sleep_duration = SMI_ACC2X2_SLEEP_DUR_6MS;
+
+			/*  6 MS  */
+			break;
+		case SMI_ACC2X2_SLEEP_DUR_10MS:
+			sleep_duration = SMI_ACC2X2_SLEEP_DUR_10MS;
+
+			/*  10 MS  */
+			break;
+		case SMI_ACC2X2_SLEEP_DUR_25MS:
+			sleep_duration = SMI_ACC2X2_SLEEP_DUR_25MS;
+
+			/*  25 MS  */
+			break;
+		case SMI_ACC2X2_SLEEP_DUR_50MS:
+			sleep_duration = SMI_ACC2X2_SLEEP_DUR_50MS;
+
+			/*  50 MS   */
+			break;
+		case SMI_ACC2X2_SLEEP_DUR_100MS:
+			sleep_duration = SMI_ACC2X2_SLEEP_DUR_100MS;
+
+			/*  100 MS  */
+			break;
+		case SMI_ACC2X2_SLEEP_DUR_500MS:
+			sleep_duration = SMI_ACC2X2_SLEEP_DUR_500MS;
+
+			/*  500 MS   */
+			break;
+		case SMI_ACC2X2_SLEEP_DUR_1S:
+			sleep_duration = SMI_ACC2X2_SLEEP_DUR_1S;
+
+			/*  1 SECS   */
+			break;
+		default:
+			break;
+		}
+		comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_SLEEP_DUR__REG,
+				&data);
+		data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_SLEEP_DUR,
+				sleep_duration);
+		comres = smi130_acc_smbus_write_byte(client, SMI_ACC2X2_SLEEP_DUR__REG,
+				&data);
+	} else {
+		comres = -1;
+	}
+
+
+	return comres;
+}
+
+static int smi130_acc_get_fifo_mode(struct i2c_client *client, unsigned char
+		*fifo_mode)
+{
+	int comres;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_FIFO_MODE__REG, &data);
+	*fifo_mode = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_FIFO_MODE);
+
+	return comres;
+}
+
+static int smi130_acc_set_fifo_mode(struct i2c_client *client, unsigned char
+		fifo_mode)
+{
+	unsigned char data = 0;
+	int comres = 0;
+
+	if (fifo_mode < 4) {
+		comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_FIFO_MODE__REG,
+				&data);
+		data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_FIFO_MODE, fifo_mode);
+		/*! Aim at fifo workarounds with FIFO_CONFIG_1 */
+		data |= FIFO_WORKAROUNDS_MSK;
+		comres = smi130_acc_smbus_write_byte(client, SMI_ACC2X2_FIFO_MODE__REG,
+				&data);
+	} else {
+		comres = -1;
+	}
+
+	return comres;
+}
+
+static int smi130_acc_get_fifo_trig(struct i2c_client *client, unsigned char
+		*fifo_trig)
+{
+	int comres;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client,
+			SMI_ACC2X2_FIFO_TRIGGER_ACTION__REG, &data);
+	*fifo_trig = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_FIFO_TRIGGER_ACTION);
+
+	return comres;
+}
+
+static int smi130_acc_set_fifo_trig(struct i2c_client *client, unsigned char
+		fifo_trig)
+{
+	unsigned char data = 0;
+	int comres = 0;
+
+	if (fifo_trig < 4) {
+		comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_FIFO_TRIGGER_ACTION__REG, &data);
+		data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_FIFO_TRIGGER_ACTION,
+				fifo_trig);
+		/*! Aim at fifo workarounds with FIFO_CONFIG_1 */
+		data |= FIFO_WORKAROUNDS_MSK;
+		comres = smi130_acc_smbus_write_byte(client,
+				SMI_ACC2X2_FIFO_TRIGGER_ACTION__REG, &data);
+	} else {
+		comres = -1;
+	}
+
+	return comres;
+}
+
+static int smi130_acc_get_fifo_trig_src(struct i2c_client *client, unsigned char
+		*trig_src)
+{
+	int comres;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client,
+			SMI_ACC2X2_FIFO_TRIGGER_SOURCE__REG, &data);
+	*trig_src = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_FIFO_TRIGGER_SOURCE);
+
+	return comres;
+}
+
+static int smi130_acc_set_fifo_trig_src(struct i2c_client *client, unsigned char
+		trig_src)
+{
+	unsigned char data = 0;
+	int comres = 0;
+
+	if (trig_src < 4) {
+		comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_FIFO_TRIGGER_SOURCE__REG, &data);
+		data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_FIFO_TRIGGER_SOURCE,
+				trig_src);
+		comres = smi130_acc_smbus_write_byte(client,
+				SMI_ACC2X2_FIFO_TRIGGER_SOURCE__REG, &data);
+	} else {
+		comres = -1;
+	}
+
+	return comres;
+}
+
+static int smi130_acc_get_fifo_framecount(struct i2c_client *client, unsigned char
+			 *framecount)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client,
+			SMI_ACC2X2_FIFO_FRAME_COUNTER_S__REG, &data);
+	*framecount = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_FIFO_FRAME_COUNTER_S);
+
+	return comres;
+}
+
+static int smi130_acc_get_fifo_data_sel(struct i2c_client *client, unsigned char
+		*data_sel)
+{
+	int comres;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client,
+			SMI_ACC2X2_FIFO_DATA_SELECT__REG, &data);
+	*data_sel = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_FIFO_DATA_SELECT);
+
+	return comres;
+}
+
+static int smi130_acc_set_fifo_data_sel(struct i2c_client *client, unsigned char
+		data_sel)
+{
+	unsigned char data = 0;
+	int comres = 0;
+
+	if (data_sel < 4) {
+		comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_FIFO_DATA_SELECT__REG,
+				&data);
+		data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_FIFO_DATA_SELECT,
+				data_sel);
+		/*! Aim at fifo workarounds with FIFO_CONFIG_1 */
+		data |= FIFO_WORKAROUNDS_MSK;
+		comres = smi130_acc_smbus_write_byte(client,
+				SMI_ACC2X2_FIFO_DATA_SELECT__REG,
+				&data);
+	} else {
+		comres = -1;
+	}
+
+	return comres;
+}
+
+
+static int smi130_acc_get_offset_target(struct i2c_client *client, unsigned char
+		channel, unsigned char *offset)
+{
+	unsigned char data = 0;
+	int comres = 0;
+
+	switch (channel) {
+	case SMI_ACC2X2_CUT_OFF:
+		comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_COMP_CUTOFF__REG, &data);
+		*offset = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_COMP_CUTOFF);
+		break;
+	case SMI_ACC2X2_OFFSET_TRIGGER_X:
+		comres = smi130_acc_smbus_read_byte(client,
+			SMI_ACC2X2_COMP_TARGET_OFFSET_X__REG, &data);
+		*offset = SMI_ACC2X2_GET_BITSLICE(data,
+				SMI_ACC2X2_COMP_TARGET_OFFSET_X);
+		break;
+	case SMI_ACC2X2_OFFSET_TRIGGER_Y:
+		comres = smi130_acc_smbus_read_byte(client,
+			SMI_ACC2X2_COMP_TARGET_OFFSET_Y__REG, &data);
+		*offset = SMI_ACC2X2_GET_BITSLICE(data,
+				SMI_ACC2X2_COMP_TARGET_OFFSET_Y);
+		break;
+	case SMI_ACC2X2_OFFSET_TRIGGER_Z:
+		comres = smi130_acc_smbus_read_byte(client,
+			SMI_ACC2X2_COMP_TARGET_OFFSET_Z__REG, &data);
+		*offset = SMI_ACC2X2_GET_BITSLICE(data,
+				SMI_ACC2X2_COMP_TARGET_OFFSET_Z);
+		break;
+	default:
+		comres = -1;
+		break;
+	}
+
+	return comres;
+}
+
+static int smi130_acc_set_offset_target(struct i2c_client *client, unsigned char
+		channel, unsigned char offset)
+{
+	unsigned char data = 0;
+	int comres = 0;
+
+	switch (channel) {
+	case SMI_ACC2X2_CUT_OFF:
+		comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_COMP_CUTOFF__REG, &data);
+		data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_COMP_CUTOFF,
+				offset);
+		comres = smi130_acc_smbus_write_byte(client,
+				SMI_ACC2X2_COMP_CUTOFF__REG, &data);
+		break;
+	case SMI_ACC2X2_OFFSET_TRIGGER_X:
+		comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_COMP_TARGET_OFFSET_X__REG,
+				&data);
+		data = SMI_ACC2X2_SET_BITSLICE(data,
+				SMI_ACC2X2_COMP_TARGET_OFFSET_X,
+				offset);
+		comres = smi130_acc_smbus_write_byte(client,
+				SMI_ACC2X2_COMP_TARGET_OFFSET_X__REG,
+				&data);
+		break;
+	case SMI_ACC2X2_OFFSET_TRIGGER_Y:
+		comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_COMP_TARGET_OFFSET_Y__REG,
+				&data);
+		data = SMI_ACC2X2_SET_BITSLICE(data,
+				SMI_ACC2X2_COMP_TARGET_OFFSET_Y,
+				offset);
+		comres = smi130_acc_smbus_write_byte(client,
+				SMI_ACC2X2_COMP_TARGET_OFFSET_Y__REG,
+				&data);
+		break;
+	case SMI_ACC2X2_OFFSET_TRIGGER_Z:
+		comres = smi130_acc_smbus_read_byte(client,
+				SMI_ACC2X2_COMP_TARGET_OFFSET_Z__REG,
+				&data);
+		data = SMI_ACC2X2_SET_BITSLICE(data,
+				SMI_ACC2X2_COMP_TARGET_OFFSET_Z,
+				offset);
+		comres = smi130_acc_smbus_write_byte(client,
+				SMI_ACC2X2_COMP_TARGET_OFFSET_Z__REG,
+				&data);
+		break;
+	default:
+		comres = -1;
+		break;
+	}
+
+	return comres;
+}
+
+static int smi130_acc_get_cal_ready(struct i2c_client *client,
+					unsigned char *calrdy)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_FAST_CAL_RDY_S__REG,
+			&data);
+	data = SMI_ACC2X2_GET_BITSLICE(data, SMI_ACC2X2_FAST_CAL_RDY_S);
+	*calrdy = data;
+
+	return comres;
+}
+
+static int smi130_acc_set_cal_trigger(struct i2c_client *client, unsigned char
+		caltrigger)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_CAL_TRIGGER__REG, &data);
+	data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_CAL_TRIGGER, caltrigger);
+	comres = smi130_acc_smbus_write_byte(client, SMI_ACC2X2_CAL_TRIGGER__REG,
+			&data);
+
+	return comres;
+}
+
+static int smi130_acc_write_reg(struct i2c_client *client, unsigned char addr,
+		unsigned char *data)
+{
+	int comres = 0;
+	comres = smi130_acc_smbus_write_byte(client, addr, data);
+
+	return comres;
+}
+
+
+static int smi130_acc_set_offset_x(struct i2c_client *client, unsigned char
+		offsetfilt)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	data =  offsetfilt;
+
+#ifdef CONFIG_SENSORS_BMI058
+	comres = smi130_acc_smbus_write_byte(client, BMI058_OFFSET_X_AXIS_REG,
+							&data);
+#else
+	comres = smi130_acc_smbus_write_byte(client, SMI_ACC2X2_OFFSET_X_AXIS_REG,
+						&data);
+#endif
+
+	return comres;
+}
+
+
+static int smi130_acc_get_offset_x(struct i2c_client *client, unsigned char
+						*offsetfilt)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+#ifdef CONFIG_SENSORS_BMI058
+	comres = smi130_acc_smbus_read_byte(client, BMI058_OFFSET_X_AXIS_REG,
+							&data);
+#else
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_OFFSET_X_AXIS_REG,
+							&data);
+#endif
+	*offsetfilt = data;
+
+	return comres;
+}
+
+static int smi130_acc_set_offset_y(struct i2c_client *client, unsigned char
+						offsetfilt)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	data =  offsetfilt;
+
+#ifdef CONFIG_SENSORS_BMI058
+	comres = smi130_acc_smbus_write_byte(client, BMI058_OFFSET_Y_AXIS_REG,
+							&data);
+#else
+	comres = smi130_acc_smbus_write_byte(client, SMI_ACC2X2_OFFSET_Y_AXIS_REG,
+							&data);
+#endif
+	return comres;
+}
+
+static int smi130_acc_get_offset_y(struct i2c_client *client, unsigned char
+						*offsetfilt)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+#ifdef CONFIG_SENSORS_BMI058
+	comres = smi130_acc_smbus_read_byte(client, BMI058_OFFSET_Y_AXIS_REG,
+							&data);
+#else
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_OFFSET_Y_AXIS_REG,
+							&data);
+#endif
+	*offsetfilt = data;
+
+	return comres;
+}
+
+static int smi130_acc_set_offset_z(struct i2c_client *client, unsigned char
+						offsetfilt)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	data =  offsetfilt;
+	comres = smi130_acc_smbus_write_byte(client, SMI_ACC2X2_OFFSET_Z_AXIS_REG,
+						&data);
+
+	return comres;
+}
+
+static int smi130_acc_get_offset_z(struct i2c_client *client, unsigned char
+						*offsetfilt)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_OFFSET_Z_AXIS_REG,
+						&data);
+	*offsetfilt = data;
+
+	return comres;
+}
+
+
+static int smi130_acc_set_selftest_st(struct i2c_client *client, unsigned char
+		selftest)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_EN_SELF_TEST__REG,
+			&data);
+	data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_EN_SELF_TEST, selftest);
+	comres = smi130_acc_smbus_write_byte(client, SMI_ACC2X2_EN_SELF_TEST__REG,
+			&data);
+
+	return comres;
+}
+
+static int smi130_acc_set_selftest_stn(struct i2c_client *client, unsigned char stn)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_NEG_SELF_TEST__REG,
+			&data);
+	data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_NEG_SELF_TEST, stn);
+	comres = smi130_acc_smbus_write_byte(client, SMI_ACC2X2_NEG_SELF_TEST__REG,
+			&data);
+
+	return comres;
+}
+
+static int smi130_acc_set_selftest_amp(struct i2c_client *client, unsigned char amp)
+{
+	int comres = 0;
+	unsigned char data = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_SELF_TEST_AMP__REG,
+			&data);
+	data = SMI_ACC2X2_SET_BITSLICE(data, SMI_ACC2X2_SELF_TEST_AMP, amp);
+	comres = smi130_acc_smbus_write_byte(client, SMI_ACC2X2_SELF_TEST_AMP__REG,
+			&data);
+
+	return comres;
+}
+
+static int smi130_acc_read_accel_x(struct i2c_client *client,
+				signed char sensor_type, short *a_x)
+{
+	int comres = 0;
+	unsigned char data[2];
+
+	switch (sensor_type) {
+	case 0:
+		comres = smi130_acc_smbus_read_byte_block(client,
+					SMI_ACC2X2_ACC_X12_LSB__REG, data, 2);
+		*a_x = SMI_ACC2X2_GET_BITSLICE(data[0], SMI_ACC2X2_ACC_X12_LSB)|
+			(SMI_ACC2X2_GET_BITSLICE(data[1],
+				SMI_ACC2X2_ACC_X_MSB)<<(SMI_ACC2X2_ACC_X12_LSB__LEN));
+		*a_x = *a_x << (sizeof(short)*8-(SMI_ACC2X2_ACC_X12_LSB__LEN
+					+ SMI_ACC2X2_ACC_X_MSB__LEN));
+		*a_x = *a_x >> (sizeof(short)*8-(SMI_ACC2X2_ACC_X12_LSB__LEN
+					+ SMI_ACC2X2_ACC_X_MSB__LEN));
+		break;
+	case 1:
+		comres = smi130_acc_smbus_read_byte_block(client,
+					SMI_ACC2X2_ACC_X10_LSB__REG, data, 2);
+		*a_x = SMI_ACC2X2_GET_BITSLICE(data[0], SMI_ACC2X2_ACC_X10_LSB)|
+			(SMI_ACC2X2_GET_BITSLICE(data[1],
+				SMI_ACC2X2_ACC_X_MSB)<<(SMI_ACC2X2_ACC_X10_LSB__LEN));
+		*a_x = *a_x << (sizeof(short)*8-(SMI_ACC2X2_ACC_X10_LSB__LEN
+					+ SMI_ACC2X2_ACC_X_MSB__LEN));
+		*a_x = *a_x >> (sizeof(short)*8-(SMI_ACC2X2_ACC_X10_LSB__LEN
+					+ SMI_ACC2X2_ACC_X_MSB__LEN));
+		break;
+	case 2:
+		comres = smi130_acc_smbus_read_byte_block(client,
+					SMI_ACC2X2_ACC_X8_LSB__REG, data, 2);
+		*a_x = SMI_ACC2X2_GET_BITSLICE(data[0], SMI_ACC2X2_ACC_X8_LSB)|
+			(SMI_ACC2X2_GET_BITSLICE(data[1],
+				SMI_ACC2X2_ACC_X_MSB)<<(SMI_ACC2X2_ACC_X8_LSB__LEN));
+		*a_x = *a_x << (sizeof(short)*8-(SMI_ACC2X2_ACC_X8_LSB__LEN
+					+ SMI_ACC2X2_ACC_X_MSB__LEN));
+		*a_x = *a_x >> (sizeof(short)*8-(SMI_ACC2X2_ACC_X8_LSB__LEN
+					+ SMI_ACC2X2_ACC_X_MSB__LEN));
+		break;
+	case 3:
+		comres = smi130_acc_smbus_read_byte_block(client,
+					SMI_ACC2X2_ACC_X14_LSB__REG, data, 2);
+		*a_x = SMI_ACC2X2_GET_BITSLICE(data[0], SMI_ACC2X2_ACC_X14_LSB)|
+			(SMI_ACC2X2_GET_BITSLICE(data[1],
+				SMI_ACC2X2_ACC_X_MSB)<<(SMI_ACC2X2_ACC_X14_LSB__LEN));
+		*a_x = *a_x << (sizeof(short)*8-(SMI_ACC2X2_ACC_X14_LSB__LEN
+					+ SMI_ACC2X2_ACC_X_MSB__LEN));
+		*a_x = *a_x >> (sizeof(short)*8-(SMI_ACC2X2_ACC_X14_LSB__LEN
+					+ SMI_ACC2X2_ACC_X_MSB__LEN));
+		break;
+	default:
+		break;
+	}
+
+	return comres;
+}
+
+static int smi130_acc_soft_reset(struct i2c_client *client)
+{
+	int comres = 0;
+	unsigned char data = SMI_ACC2X2_EN_SOFT_RESET_VALUE;
+
+	comres = smi130_acc_smbus_write_byte(client, SMI_ACC2X2_EN_SOFT_RESET__REG,
+					&data);
+
+	return comres;
+}
+
+static int smi130_acc_read_accel_y(struct i2c_client *client,
+				signed char sensor_type, short *a_y)
+{
+	int comres = 0;
+	unsigned char data[2];
+
+	switch (sensor_type) {
+	case 0:
+		comres = smi130_acc_smbus_read_byte_block(client,
+				SMI_ACC2X2_ACC_Y12_LSB__REG, data, 2);
+		*a_y = SMI_ACC2X2_GET_BITSLICE(data[0], SMI_ACC2X2_ACC_Y12_LSB)|
+			(SMI_ACC2X2_GET_BITSLICE(data[1],
+				SMI_ACC2X2_ACC_Y_MSB)<<(SMI_ACC2X2_ACC_Y12_LSB__LEN));
+		*a_y = *a_y << (sizeof(short)*8-(SMI_ACC2X2_ACC_Y12_LSB__LEN
+						+ SMI_ACC2X2_ACC_Y_MSB__LEN));
+		*a_y = *a_y >> (sizeof(short)*8-(SMI_ACC2X2_ACC_Y12_LSB__LEN
+						+ SMI_ACC2X2_ACC_Y_MSB__LEN));
+		break;
+	case 1:
+		comres = smi130_acc_smbus_read_byte_block(client,
+				SMI_ACC2X2_ACC_Y10_LSB__REG, data, 2);
+		*a_y = SMI_ACC2X2_GET_BITSLICE(data[0], SMI_ACC2X2_ACC_Y10_LSB)|
+			(SMI_ACC2X2_GET_BITSLICE(data[1],
+				SMI_ACC2X2_ACC_Y_MSB)<<(SMI_ACC2X2_ACC_Y10_LSB__LEN));
+		*a_y = *a_y << (sizeof(short)*8-(SMI_ACC2X2_ACC_Y10_LSB__LEN
+						+ SMI_ACC2X2_ACC_Y_MSB__LEN));
+		*a_y = *a_y >> (sizeof(short)*8-(SMI_ACC2X2_ACC_Y10_LSB__LEN
+						+ SMI_ACC2X2_ACC_Y_MSB__LEN));
+		break;
+	case 2:
+		comres = smi130_acc_smbus_read_byte_block(client,
+				SMI_ACC2X2_ACC_Y8_LSB__REG, data, 2);
+		*a_y = SMI_ACC2X2_GET_BITSLICE(data[0], SMI_ACC2X2_ACC_Y8_LSB)|
+				(SMI_ACC2X2_GET_BITSLICE(data[1],
+				SMI_ACC2X2_ACC_Y_MSB)<<(SMI_ACC2X2_ACC_Y8_LSB__LEN));
+		*a_y = *a_y << (sizeof(short)*8-(SMI_ACC2X2_ACC_Y8_LSB__LEN
+						+ SMI_ACC2X2_ACC_Y_MSB__LEN));
+		*a_y = *a_y >> (sizeof(short)*8-(SMI_ACC2X2_ACC_Y8_LSB__LEN
+						+ SMI_ACC2X2_ACC_Y_MSB__LEN));
+		break;
+	case 3:
+		comres = smi130_acc_smbus_read_byte_block(client,
+				SMI_ACC2X2_ACC_Y14_LSB__REG, data, 2);
+		*a_y = SMI_ACC2X2_GET_BITSLICE(data[0], SMI_ACC2X2_ACC_Y14_LSB)|
+			(SMI_ACC2X2_GET_BITSLICE(data[1],
+				SMI_ACC2X2_ACC_Y_MSB)<<(SMI_ACC2X2_ACC_Y14_LSB__LEN));
+		*a_y = *a_y << (sizeof(short)*8-(SMI_ACC2X2_ACC_Y14_LSB__LEN
+						+ SMI_ACC2X2_ACC_Y_MSB__LEN));
+		*a_y = *a_y >> (sizeof(short)*8-(SMI_ACC2X2_ACC_Y14_LSB__LEN
+						+ SMI_ACC2X2_ACC_Y_MSB__LEN));
+		break;
+	default:
+		break;
+	}
+
+	return comres;
+}
+
+static int smi130_acc_read_accel_z(struct i2c_client *client,
+				signed char sensor_type, short *a_z)
+{
+	int comres = 0;
+	unsigned char data[2];
+
+	switch (sensor_type) {
+	case 0:
+		comres = smi130_acc_smbus_read_byte_block(client,
+				SMI_ACC2X2_ACC_Z12_LSB__REG, data, 2);
+		*a_z = SMI_ACC2X2_GET_BITSLICE(data[0], SMI_ACC2X2_ACC_Z12_LSB)|
+			(SMI_ACC2X2_GET_BITSLICE(data[1],
+				SMI_ACC2X2_ACC_Z_MSB)<<(SMI_ACC2X2_ACC_Z12_LSB__LEN));
+		*a_z = *a_z << (sizeof(short)*8-(SMI_ACC2X2_ACC_Z12_LSB__LEN
+						+ SMI_ACC2X2_ACC_Z_MSB__LEN));
+		*a_z = *a_z >> (sizeof(short)*8-(SMI_ACC2X2_ACC_Z12_LSB__LEN
+						+ SMI_ACC2X2_ACC_Z_MSB__LEN));
+		break;
+	case 1:
+		comres = smi130_acc_smbus_read_byte_block(client,
+				SMI_ACC2X2_ACC_Z10_LSB__REG, data, 2);
+		*a_z = SMI_ACC2X2_GET_BITSLICE(data[0], SMI_ACC2X2_ACC_Z10_LSB)|
+			(SMI_ACC2X2_GET_BITSLICE(data[1],
+				SMI_ACC2X2_ACC_Z_MSB)<<(SMI_ACC2X2_ACC_Z10_LSB__LEN));
+		*a_z = *a_z << (sizeof(short)*8-(SMI_ACC2X2_ACC_Z10_LSB__LEN
+						+ SMI_ACC2X2_ACC_Z_MSB__LEN));
+		*a_z = *a_z >> (sizeof(short)*8-(SMI_ACC2X2_ACC_Z10_LSB__LEN
+						+ SMI_ACC2X2_ACC_Z_MSB__LEN));
+		break;
+	case 2:
+		comres = smi130_acc_smbus_read_byte_block(client,
+				SMI_ACC2X2_ACC_Z8_LSB__REG, data, 2);
+		*a_z = SMI_ACC2X2_GET_BITSLICE(data[0], SMI_ACC2X2_ACC_Z8_LSB)|
+			(SMI_ACC2X2_GET_BITSLICE(data[1],
+				SMI_ACC2X2_ACC_Z_MSB)<<(SMI_ACC2X2_ACC_Z8_LSB__LEN));
+		*a_z = *a_z << (sizeof(short)*8-(SMI_ACC2X2_ACC_Z8_LSB__LEN
+						+ SMI_ACC2X2_ACC_Z_MSB__LEN));
+		*a_z = *a_z >> (sizeof(short)*8-(SMI_ACC2X2_ACC_Z8_LSB__LEN
+						+ SMI_ACC2X2_ACC_Z_MSB__LEN));
+		break;
+	case 3:
+		comres = smi130_acc_smbus_read_byte_block(client,
+				SMI_ACC2X2_ACC_Z14_LSB__REG, data, 2);
+		*a_z = SMI_ACC2X2_GET_BITSLICE(data[0], SMI_ACC2X2_ACC_Z14_LSB)|
+				(SMI_ACC2X2_GET_BITSLICE(data[1],
+				SMI_ACC2X2_ACC_Z_MSB)<<(SMI_ACC2X2_ACC_Z14_LSB__LEN));
+		*a_z = *a_z << (sizeof(short)*8-(SMI_ACC2X2_ACC_Z14_LSB__LEN
+						+ SMI_ACC2X2_ACC_Z_MSB__LEN));
+		*a_z = *a_z >> (sizeof(short)*8-(SMI_ACC2X2_ACC_Z14_LSB__LEN
+						+ SMI_ACC2X2_ACC_Z_MSB__LEN));
+		break;
+	default:
+		break;
+	}
+
+	return comres;
+}
+
+
+static int smi130_acc_read_temperature(struct i2c_client *client,
+					signed char *temperature)
+{
+	unsigned char data = 0;
+	int comres = 0;
+
+	comres = smi130_acc_smbus_read_byte(client, SMI_ACC2X2_TEMPERATURE_REG, &data);
+	*temperature = (signed char)data;
+
+	return comres;
+}
+
+static ssize_t smi130_acc_enable_int_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	int type, value;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+#ifdef CONFIG_SENSORS_BMI058
+	int i;
+#endif
+
+	sscanf(buf, "%3d %3d", &type, &value);
+
+#ifdef CONFIG_SENSORS_BMI058
+	for (i = 0; i < sizeof(int_map) / sizeof(struct interrupt_map_t); i++) {
+		if (int_map[i].x == type) {
+			type = int_map[i].y;
+			break;
+		}
+		if (int_map[i].y == type) {
+			type = int_map[i].x;
+			break;
+		}
+	}
+#endif
+
+	if (smi130_acc_set_Int_Enable(smi130_acc->smi130_acc_client, type, value) < 0)
+		return -EINVAL;
+
+	return count;
+}
+
+
+static ssize_t smi130_acc_int_mode_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_get_Int_Mode(smi130_acc->smi130_acc_client, &data) < 0)
+		return -EINVAL;
+
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t smi130_acc_int_mode_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+
+	if (smi130_acc_set_Int_Mode(smi130_acc->smi130_acc_client, (unsigned char)data) < 0)
+		return -EINVAL;
+
+	return count;
+}
+static ssize_t smi130_acc_slope_duration_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_get_slope_duration(smi130_acc->smi130_acc_client, &data) < 0)
+		return -EINVAL;
+
+	return snprintf(buf, 16, "%d\n", data);
+
+}
+
+static ssize_t smi130_acc_slope_duration_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+
+	if (smi130_acc_set_slope_duration(smi130_acc->smi130_acc_client, (unsigned
+					char)data) < 0)
+		return -EINVAL;
+
+	return count;
+}
+
+static ssize_t smi130_acc_slope_no_mot_duration_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_get_slope_no_mot_duration(smi130_acc->smi130_acc_client, &data) < 0)
+		return -EINVAL;
+
+	return snprintf(buf, 16, "%d\n", data);
+
+}
+
+static ssize_t smi130_acc_slope_no_mot_duration_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+
+	if (smi130_acc_set_slope_no_mot_duration(smi130_acc->smi130_acc_client, (unsigned
+					char)data) < 0)
+		return -EINVAL;
+
+	return count;
+}
+
+
+static ssize_t smi130_acc_slope_threshold_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_get_slope_threshold(smi130_acc->smi130_acc_client, &data) < 0)
+		return -EINVAL;
+
+	return snprintf(buf, 16, "%d\n", data);
+
+}
+
+static ssize_t smi130_acc_slope_threshold_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+	if (smi130_acc_set_slope_threshold(smi130_acc->smi130_acc_client, (unsigned
+					char)data) < 0)
+		return -EINVAL;
+
+	return count;
+}
+
+static ssize_t smi130_acc_slope_no_mot_threshold_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_get_slope_no_mot_threshold(smi130_acc->smi130_acc_client, &data) < 0)
+		return -EINVAL;
+
+	return snprintf(buf, 16, "%d\n", data);
+
+}
+
+static ssize_t smi130_acc_slope_no_mot_threshold_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+	if (smi130_acc_set_slope_no_mot_threshold(smi130_acc->smi130_acc_client, (unsigned
+					char)data) < 0)
+		return -EINVAL;
+
+	return count;
+}
+
+static ssize_t smi130_acc_high_g_duration_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_get_high_g_duration(smi130_acc->smi130_acc_client, &data) < 0)
+		return -EINVAL;
+
+	return snprintf(buf, 16, "%d\n", data);
+
+}
+
+static ssize_t smi130_acc_high_g_duration_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+
+	if (smi130_acc_set_high_g_duration(smi130_acc->smi130_acc_client, (unsigned
+					char)data) < 0)
+		return -EINVAL;
+
+	return count;
+}
+
+static ssize_t smi130_acc_high_g_threshold_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_get_high_g_threshold(smi130_acc->smi130_acc_client, &data) < 0)
+		return -EINVAL;
+
+	return snprintf(buf, 16, "%d\n", data);
+
+}
+
+static ssize_t smi130_acc_high_g_threshold_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+	if (smi130_acc_set_high_g_threshold(smi130_acc->smi130_acc_client, (unsigned
+					char)data) < 0)
+		return -EINVAL;
+
+	return count;
+}
+
+static ssize_t smi130_acc_low_g_duration_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_get_low_g_duration(smi130_acc->smi130_acc_client, &data) < 0)
+		return -EINVAL;
+
+	return snprintf(buf, 16, "%d\n", data);
+
+}
+
+static ssize_t smi130_acc_low_g_duration_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+
+	if (smi130_acc_set_low_g_duration(smi130_acc->smi130_acc_client, (unsigned
+					char)data) < 0)
+		return -EINVAL;
+
+	return count;
+}
+
+static ssize_t smi130_acc_low_g_threshold_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_get_low_g_threshold(smi130_acc->smi130_acc_client, &data) < 0)
+		return -EINVAL;
+
+	return snprintf(buf, 16, "%d\n", data);
+
+}
+
+static ssize_t smi130_acc_low_g_threshold_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+	if (smi130_acc_set_low_g_threshold(smi130_acc->smi130_acc_client, (unsigned
+					char)data) < 0)
+		return -EINVAL;
+
+	return count;
+}
+static ssize_t smi130_acc_tap_threshold_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_get_tap_threshold(smi130_acc->smi130_acc_client, &data) < 0)
+		return -EINVAL;
+
+	return snprintf(buf, 16, "%d\n", data);
+
+}
+
+static ssize_t smi130_acc_tap_threshold_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+	if (smi130_acc_set_tap_threshold(smi130_acc->smi130_acc_client, (unsigned char)data)
+			< 0)
+		return -EINVAL;
+
+	return count;
+}
+static ssize_t smi130_acc_tap_duration_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_get_tap_duration(smi130_acc->smi130_acc_client, &data) < 0)
+		return -EINVAL;
+
+	return snprintf(buf, 16, "%d\n", data);
+
+}
+
+static ssize_t smi130_acc_tap_duration_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+
+	if (smi130_acc_set_tap_duration(smi130_acc->smi130_acc_client, (unsigned char)data)
+			< 0)
+		return -EINVAL;
+
+	return count;
+}
+static ssize_t smi130_acc_tap_quiet_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_get_tap_quiet(smi130_acc->smi130_acc_client, &data) < 0)
+		return -EINVAL;
+
+	return snprintf(buf, 16, "%d\n", data);
+
+}
+
+static ssize_t smi130_acc_tap_quiet_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+
+	if (smi130_acc_set_tap_quiet(smi130_acc->smi130_acc_client, (unsigned char)data) <
+			0)
+		return -EINVAL;
+
+	return count;
+}
+
+static ssize_t smi130_acc_tap_shock_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_get_tap_shock(smi130_acc->smi130_acc_client, &data) < 0)
+		return -EINVAL;
+
+	return snprintf(buf, 16, "%d\n", data);
+
+}
+
+static ssize_t smi130_acc_tap_shock_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+
+	if (smi130_acc_set_tap_shock(smi130_acc->smi130_acc_client, (unsigned char)data) <
+			0)
+		return -EINVAL;
+
+	return count;
+}
+
+static ssize_t smi130_acc_tap_samp_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_get_tap_samp(smi130_acc->smi130_acc_client, &data) < 0)
+		return -EINVAL;
+
+	return snprintf(buf, 16, "%d\n", data);
+
+}
+
+static ssize_t smi130_acc_tap_samp_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+
+	if (smi130_acc_set_tap_samp(smi130_acc->smi130_acc_client, (unsigned char)data) < 0)
+		return -EINVAL;
+
+	return count;
+}
+
+static ssize_t smi130_acc_orient_mbl_mode_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_get_orient_mbl_mode(smi130_acc->smi130_acc_client, &data) < 0)
+		return -EINVAL;
+
+	return snprintf(buf, 16, "%d\n", data);
+
+}
+
+static ssize_t smi130_acc_orient_mbl_mode_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+
+	if (smi130_acc_set_orient_mbl_mode(smi130_acc->smi130_acc_client, (unsigned char)data) <
+			0)
+		return -EINVAL;
+
+	return count;
+}
+
+static ssize_t smi130_acc_orient_mbl_blocking_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_get_orient_mbl_blocking(smi130_acc->smi130_acc_client, &data) < 0)
+		return -EINVAL;
+
+	return snprintf(buf, 16, "%d\n", data);
+
+}
+
+static ssize_t smi130_acc_orient_mbl_blocking_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+
+	if (smi130_acc_set_orient_mbl_blocking(smi130_acc->smi130_acc_client, (unsigned
+					char)data) < 0)
+		return -EINVAL;
+
+	return count;
+}
+static ssize_t smi130_acc_orient_mbl_hyst_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_get_orient_mbl_hyst(smi130_acc->smi130_acc_client, &data) < 0)
+		return -EINVAL;
+
+	return snprintf(buf, 16, "%d\n", data);
+
+}
+
+static ssize_t smi130_acc_orient_mbl_hyst_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+
+	if (smi130_acc_set_orient_mbl_hyst(smi130_acc->smi130_acc_client, (unsigned char)data) <
+			0)
+		return -EINVAL;
+
+	return count;
+}
+
+static ssize_t smi130_acc_orient_mbl_theta_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_get_theta_blocking(smi130_acc->smi130_acc_client, &data) < 0)
+		return -EINVAL;
+
+	return snprintf(buf, 16, "%d\n", data);
+
+}
+
+static ssize_t smi130_acc_orient_mbl_theta_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+
+	if (smi130_acc_set_theta_blocking(smi130_acc->smi130_acc_client, (unsigned
+					char)data) < 0)
+		return -EINVAL;
+
+	return count;
+}
+
+static ssize_t smi130_acc_flat_theta_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_get_theta_flat(smi130_acc->smi130_acc_client, &data) < 0)
+		return -EINVAL;
+
+	return snprintf(buf, 16, "%d\n", data);
+
+}
+
+static ssize_t smi130_acc_flat_theta_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+
+	if (smi130_acc_set_theta_flat(smi130_acc->smi130_acc_client, (unsigned char)data) <
+			0)
+		return -EINVAL;
+
+	return count;
+}
+static ssize_t smi130_acc_flat_hold_time_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_get_flat_hold_time(smi130_acc->smi130_acc_client, &data) < 0)
+		return -EINVAL;
+
+	return snprintf(buf, 16, "%d\n", data);
+
+}
+static ssize_t smi130_acc_selftest_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+
+
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	return snprintf(buf, 16, "%d\n", atomic_read(&smi130_acc->selftest_result));
+
+}
+
+static ssize_t smi130_acc_softreset_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_soft_reset(smi130_acc->smi130_acc_client) < 0)
+		return -EINVAL;
+
+	return count;
+}
+static ssize_t smi130_acc_selftest_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+
+	unsigned long data;
+	unsigned char clear_value = 0;
+	int error;
+	short value1 = 0;
+	short value2 = 0;
+	short diff = 0;
+	unsigned long result = 0;
+	unsigned char test_result_branch = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	smi130_acc_soft_reset(smi130_acc->smi130_acc_client);
+	smi130_acc_delay(5);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+
+	if (data != 1)
+		return -EINVAL;
+
+	smi130_acc_write_reg(smi130_acc->smi130_acc_client, 0x32, &clear_value);
+
+	if ((smi130_acc->sensor_type == SMI_ACC280_TYPE) ||
+		(smi130_acc->sensor_type == SMI_ACC255_TYPE)) {
+#ifdef CONFIG_SENSORS_BMI058
+		/*set self test amp */
+		if (smi130_acc_set_selftest_amp(smi130_acc->smi130_acc_client, 1) < 0)
+			return -EINVAL;
+		/* set to 8 G range */
+		if (smi130_acc_set_range(smi130_acc->smi130_acc_client,
+							SMI_ACC2X2_RANGE_8G) < 0)
+			return -EINVAL;
+#else
+		/* set to 4 G range */
+		if (smi130_acc_set_range(smi130_acc->smi130_acc_client,
+							SMI_ACC2X2_RANGE_4G) < 0)
+			return -EINVAL;
+#endif
+	}
+
+	if ((smi130_acc->sensor_type == SMI_ACC250E_TYPE) ||
+			(smi130_acc->sensor_type == SMI_ACC222E_TYPE)) {
+		/* set to 8 G range */
+		if (smi130_acc_set_range(smi130_acc->smi130_acc_client, 8) < 0)
+			return -EINVAL;
+		if (smi130_acc_set_selftest_amp(smi130_acc->smi130_acc_client, 1) < 0)
+			return -EINVAL;
+	}
+
+	/* 1 for x-axis(but BMI058 is 1 for y-axis )*/
+	smi130_acc_set_selftest_st(smi130_acc->smi130_acc_client, 1);
+	smi130_acc_set_selftest_stn(smi130_acc->smi130_acc_client, 0);
+	smi130_acc_delay(10);
+	smi130_acc_read_accel_x(smi130_acc->smi130_acc_client,
+					smi130_acc->sensor_type, &value1);
+	smi130_acc_set_selftest_stn(smi130_acc->smi130_acc_client, 1);
+	smi130_acc_delay(10);
+	smi130_acc_read_accel_x(smi130_acc->smi130_acc_client,
+					smi130_acc->sensor_type, &value2);
+	diff = value1-value2;
+
+#ifdef CONFIG_SENSORS_BMI058
+	PINFO("diff y is %d,value1 is %d, value2 is %d\n", diff,
+				value1, value2);
+	test_result_branch = 2;
+#else
+	PINFO("diff x is %d,value1 is %d, value2 is %d\n", diff,
+				value1, value2);
+	test_result_branch = 1;
+#endif
+
+	if (smi130_acc->sensor_type == SMI_ACC280_TYPE) {
+#ifdef CONFIG_SENSORS_BMI058
+		if (abs(diff) < 819)
+			result |= test_result_branch;
+#else
+		if (abs(diff) < 1638)
+			result |= test_result_branch;
+#endif
+	}
+	if (smi130_acc->sensor_type == SMI_ACC255_TYPE) {
+		if (abs(diff) < 409)
+			result |= 1;
+	}
+	if (smi130_acc->sensor_type == SMI_ACC250E_TYPE) {
+		if (abs(diff) < 51)
+			result |= 1;
+	}
+	if (smi130_acc->sensor_type == SMI_ACC222E_TYPE) {
+		if (abs(diff) < 12)
+			result |= 1;
+	}
+
+	/* 2 for y-axis but BMI058 is 1*/
+	smi130_acc_set_selftest_st(smi130_acc->smi130_acc_client, 2);
+	smi130_acc_set_selftest_stn(smi130_acc->smi130_acc_client, 0);
+	smi130_acc_delay(10);
+	smi130_acc_read_accel_y(smi130_acc->smi130_acc_client,
+					smi130_acc->sensor_type, &value1);
+	smi130_acc_set_selftest_stn(smi130_acc->smi130_acc_client, 1);
+	smi130_acc_delay(10);
+	smi130_acc_read_accel_y(smi130_acc->smi130_acc_client,
+					smi130_acc->sensor_type, &value2);
+	diff = value1-value2;
+
+#ifdef CONFIG_SENSORS_BMI058
+	PINFO("diff x is %d,value1 is %d, value2 is %d\n", diff,
+				value1, value2);
+	test_result_branch = 1;
+#else
+	PINFO("diff y is %d,value1 is %d, value2 is %d\n", diff,
+				value1, value2);
+	test_result_branch = 2;
+#endif
+
+	if (smi130_acc->sensor_type == SMI_ACC280_TYPE) {
+#ifdef CONFIG_SENSORS_BMI058
+		if (abs(diff) < 819)
+			result |= test_result_branch;
+#else
+		if (abs(diff) < 1638)
+			result |= test_result_branch;
+#endif
+	}
+	if (smi130_acc->sensor_type == SMI_ACC255_TYPE) {
+		if (abs(diff) < 409)
+			result |= test_result_branch;
+	}
+	if (smi130_acc->sensor_type == SMI_ACC250E_TYPE) {
+		if (abs(diff) < 51)
+			result |= test_result_branch;
+	}
+	if (smi130_acc->sensor_type == SMI_ACC222E_TYPE) {
+		if (abs(diff) < 12)
+			result |= test_result_branch;
+	}
+
+
+	smi130_acc_set_selftest_st(smi130_acc->smi130_acc_client, 3); /* 3 for z-axis*/
+	smi130_acc_set_selftest_stn(smi130_acc->smi130_acc_client, 0);
+	smi130_acc_delay(10);
+	smi130_acc_read_accel_z(smi130_acc->smi130_acc_client,
+					smi130_acc->sensor_type, &value1);
+	smi130_acc_set_selftest_stn(smi130_acc->smi130_acc_client, 1);
+	smi130_acc_delay(10);
+	smi130_acc_read_accel_z(smi130_acc->smi130_acc_client,
+					smi130_acc->sensor_type, &value2);
+	diff = value1-value2;
+
+	PINFO("diff z is %d,value1 is %d, value2 is %d\n", diff,
+			value1, value2);
+
+	if (smi130_acc->sensor_type == SMI_ACC280_TYPE) {
+#ifdef CONFIG_SENSORS_BMI058
+			if (abs(diff) < 409)
+				result |= 4;
+#else
+			if (abs(diff) < 819)
+				result |= 4;
+#endif
+	}
+	if (smi130_acc->sensor_type == SMI_ACC255_TYPE) {
+		if (abs(diff) < 204)
+			result |= 4;
+	}
+	if (smi130_acc->sensor_type == SMI_ACC250E_TYPE) {
+		if (abs(diff) < 25)
+			result |= 4;
+	}
+	if (smi130_acc->sensor_type == SMI_ACC222E_TYPE) {
+		if (abs(diff) < 6)
+			result |= 4;
+	}
+
+	/* self test for smi_acc254 */
+	if ((smi130_acc->sensor_type == SMI_ACC255_TYPE) && (result > 0)) {
+		result = 0;
+		smi130_acc_soft_reset(smi130_acc->smi130_acc_client);
+		smi130_acc_delay(5);
+		smi130_acc_write_reg(smi130_acc->smi130_acc_client, 0x32, &clear_value);
+		/* set to 8 G range */
+		if (smi130_acc_set_range(smi130_acc->smi130_acc_client, 8) < 0)
+			return -EINVAL;
+		if (smi130_acc_set_selftest_amp(smi130_acc->smi130_acc_client, 1) < 0)
+			return -EINVAL;
+
+		smi130_acc_set_selftest_st(smi130_acc->smi130_acc_client, 1); /* 1
+								for x-axis*/
+		smi130_acc_set_selftest_stn(smi130_acc->smi130_acc_client, 0); /*
+							positive direction*/
+		smi130_acc_delay(10);
+		smi130_acc_read_accel_x(smi130_acc->smi130_acc_client,
+						smi130_acc->sensor_type, &value1);
+		smi130_acc_set_selftest_stn(smi130_acc->smi130_acc_client, 1); /*
+							negative direction*/
+		smi130_acc_delay(10);
+		smi130_acc_read_accel_x(smi130_acc->smi130_acc_client,
+						smi130_acc->sensor_type, &value2);
+		diff = value1-value2;
+
+		PINFO("diff x is %d,value1 is %d, value2 is %d\n",
+						diff, value1, value2);
+		if (abs(diff) < 204)
+			result |= 1;
+
+		smi130_acc_set_selftest_st(smi130_acc->smi130_acc_client, 2); /* 2
+								for y-axis*/
+		smi130_acc_set_selftest_stn(smi130_acc->smi130_acc_client, 0); /*
+							positive direction*/
+		smi130_acc_delay(10);
+		smi130_acc_read_accel_y(smi130_acc->smi130_acc_client,
+						smi130_acc->sensor_type, &value1);
+		smi130_acc_set_selftest_stn(smi130_acc->smi130_acc_client, 1); /*
+							negative direction*/
+		smi130_acc_delay(10);
+		smi130_acc_read_accel_y(smi130_acc->smi130_acc_client,
+						smi130_acc->sensor_type, &value2);
+		diff = value1-value2;
+		PINFO("diff y is %d,value1 is %d, value2 is %d\n",
+						diff, value1, value2);
+
+		if (abs(diff) < 204)
+			result |= 2;
+
+		smi130_acc_set_selftest_st(smi130_acc->smi130_acc_client, 3); /* 3
+								for z-axis*/
+		smi130_acc_set_selftest_stn(smi130_acc->smi130_acc_client, 0); /*
+							positive direction*/
+		smi130_acc_delay(10);
+		smi130_acc_read_accel_z(smi130_acc->smi130_acc_client,
+						smi130_acc->sensor_type, &value1);
+		smi130_acc_set_selftest_stn(smi130_acc->smi130_acc_client, 1); /*
+							negative direction*/
+		smi130_acc_delay(10);
+		smi130_acc_read_accel_z(smi130_acc->smi130_acc_client,
+						smi130_acc->sensor_type, &value2);
+		diff = value1-value2;
+
+		PINFO("diff z is %d,value1 is %d, value2 is %d\n",
+						diff, value1, value2);
+		if (abs(diff) < 102)
+			result |= 4;
+	}
+
+	atomic_set(&smi130_acc->selftest_result, (unsigned int)result);
+
+	smi130_acc_soft_reset(smi130_acc->smi130_acc_client);
+	smi130_acc_delay(5);
+	PINFO("self test finished\n");
+
+	return count;
+}
+
+
+
+static ssize_t smi130_acc_flat_hold_time_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+
+	if (smi130_acc_set_flat_hold_time(smi130_acc->smi130_acc_client, (unsigned
+					char)data) < 0)
+		return -EINVAL;
+
+	return count;
+}
+
+const int smi130_acc_sensor_bitwidth[] = {
+	12,  10,  8, 14
+};
+
+static int smi130_acc_read_accel_xyz(struct i2c_client *client,
+		signed char sensor_type, struct smi130_accacc *acc)
+{
+	int comres = 0;
+	unsigned char data[6];
+	struct smi130_acc_data *client_data = i2c_get_clientdata(client);
+#ifndef SMI_ACC2X2_SENSOR_IDENTIFICATION_ENABLE
+	int bitwidth;
+#endif
+	comres = smi130_acc_smbus_read_byte_block(client,
+				SMI_ACC2X2_ACC_X12_LSB__REG, data, 6);
+	if (sensor_type >= 4)
+		return -EINVAL;
+
+	acc->x = (data[1]<<8)|data[0];
+	acc->y = (data[3]<<8)|data[2];
+	acc->z = (data[5]<<8)|data[4];
+
+#ifndef SMI_ACC2X2_SENSOR_IDENTIFICATION_ENABLE
+	bitwidth = smi130_acc_sensor_bitwidth[sensor_type];
+
+	acc->x = (acc->x >> (16 - bitwidth));
+	acc->y = (acc->y >> (16 - bitwidth));
+	acc->z = (acc->z >> (16 - bitwidth));
+#endif
+
+	smi130_acc_remap_sensor_data(acc, client_data);
+	return comres;
+}
+
+#ifndef CONFIG_SMI_ACC_ENABLE_NEWDATA_INT
+static void smi130_acc_work_func(struct work_struct *work)
+{
+	struct smi130_acc_data *smi130_acc = container_of((struct delayed_work *)work,
+			struct smi130_acc_data, work);
+	static struct smi130_accacc acc;
+	unsigned long delay = msecs_to_jiffies(atomic_read(&smi130_acc->delay));
+
+	smi130_acc_read_accel_xyz(smi130_acc->smi130_acc_client, smi130_acc->sensor_type, &acc);
+	input_report_abs(smi130_acc->input, ABS_X, acc.x);
+	input_report_abs(smi130_acc->input, ABS_Y, acc.y);
+	input_report_abs(smi130_acc->input, ABS_Z, acc.z);
+	input_sync(smi130_acc->input);
+	mutex_lock(&smi130_acc->value_mutex);
+	smi130_acc->value = acc;
+	mutex_unlock(&smi130_acc->value_mutex);
+	schedule_delayed_work(&smi130_acc->work, delay);
+}
+#endif
+static struct workqueue_struct *reportdata_wq;
+
+uint64_t smi130_acc_get_alarm_timestamp(void)
+{
+	uint64_t ts_ap;
+	struct timespec tmp_time;
+	get_monotonic_boottime(&tmp_time);
+	ts_ap = (uint64_t)tmp_time.tv_sec * 1000000000 + tmp_time.tv_nsec;
+	return ts_ap;
+}
+
+#define ABS(x) ((x) > 0 ? (x) : -(x))
+
+static void smi130_acc_timer_work_fun(struct work_struct *work)
+{
+	struct  smi130_acc_data *smi130_acc =
+		container_of(work,
+				struct smi130_acc_data, report_data_work);
+	int i;
+	unsigned char count = 0;
+	unsigned char mode = 0;
+	signed char fifo_data_out[MAX_FIFO_F_LEVEL * MAX_FIFO_F_BYTES] = {0};
+	unsigned char f_len = 0;
+	uint64_t del = 0;
+	uint64_t time_internal = 0;
+	int64_t drift_time = 0;
+	static uint64_t time_odr;
+	struct smi130_accacc acc_lsb;
+	struct timespec ts;
+	static uint32_t data_cnt;
+	static uint32_t pre_data_cnt;
+	static int64_t sample_drift_offset;
+
+	if (smi130_acc->fifo_datasel) {
+		/*Select one axis data output for every fifo frame*/
+		f_len = 2;
+	} else	{
+		/*Select X Y Z axis data output for every fifo frame*/
+		f_len = 6;
+	}
+	if (smi130_acc_get_fifo_framecount(smi130_acc->smi130_acc_client, &count) < 0) {
+		PERR("smi130_acc_get_fifo_framecount err\n");
+		return;
+	}
+	if (count == 0) {
+		PERR("smi130_acc_get_fifo_framecount zero\n");
+		return;
+	}
+	if (count > MAX_FIFO_F_LEVEL) {
+		if (smi130_acc_get_mode(smi130_acc->smi130_acc_client, &mode) < 0) {
+			PERR("smi130_acc_get_mode err\n");
+			return;
+		}
+		if (SMI_ACC2X2_MODE_NORMAL == mode) {
+			PERR("smi130_acc fifo_count: %d abnormal, op_mode: %d\n",
+					count, mode);
+			count = MAX_FIFO_F_LEVEL;
+		} else {
+			/*chip already suspend or shutdown*/
+			count = 0;
+			return;
+		}
+	}
+	if (smi_acc_i2c_burst_read(smi130_acc->smi130_acc_client,
+			SMI_ACC2X2_FIFO_DATA_OUTPUT_REG, fifo_data_out,
+						count * f_len) < 0) {
+		PERR("smi130_acc read fifo err\n");
+		return;
+	}
+	smi130_acc->fifo_time = smi130_acc_get_alarm_timestamp();
+	if (smi130_acc->acc_count == 0)
+		smi130_acc->base_time = smi130_acc->timestamp =
+		smi130_acc->fifo_time - (count-1) * smi130_acc->time_odr;
+
+	smi130_acc->acc_count += count;
+	del = smi130_acc->fifo_time - smi130_acc->base_time;
+	time_internal = div64_u64(del, smi130_acc->acc_count);
+
+	data_cnt++;
+	if (data_cnt == 1)
+		time_odr = smi130_acc->time_odr;
+
+	if (time_internal > time_odr) {
+		if (time_internal - time_odr > div64_u64 (time_odr, 200))
+			time_internal = time_odr + div64_u64(time_odr, 200);
+	} else {
+		if (time_odr - time_internal > div64_u64(time_odr, 200))
+			time_internal = time_odr - div64_u64(time_odr, 200);
+	}
+/* please give attation for the fifo output data format*/
+	if (f_len == 6) {
+		/* Select X Y Z axis data output for every frame */
+		for (i = 0; i < count; i++) {
+			if (smi130_acc->debug_level & 0x01)
+				printk(KERN_INFO "smi_acc time =%llu fifo_time =%llu  smi_acc->count=%llu time_internal =%lld time_odr = %lld ",
+				smi130_acc->timestamp, smi130_acc->fifo_time,
+				smi130_acc->acc_count, time_internal, time_odr);
+
+			ts = ns_to_timespec(smi130_acc->timestamp);
+			acc_lsb.x =
+			((unsigned char)fifo_data_out[i * f_len + 1] << 8 |
+				(unsigned char)fifo_data_out[i * f_len + 0]);
+			acc_lsb.y =
+			((unsigned char)fifo_data_out[i * f_len + 3] << 8 |
+				(unsigned char)fifo_data_out[i * f_len + 2]);
+			acc_lsb.z =
+			((unsigned char)fifo_data_out[i * f_len + 5] << 8 |
+				(unsigned char)fifo_data_out[i * f_len + 4]);
+#ifndef SMI_ACC2X2_SENSOR_IDENTIFICATION_ENABLE
+			acc_lsb.x >>=
+			(16 - smi130_acc_sensor_bitwidth[smi130_acc->sensor_type]);
+			acc_lsb.y >>=
+			(16 - smi130_acc_sensor_bitwidth[smi130_acc->sensor_type]);
+			acc_lsb.z >>=
+			(16 - smi130_acc_sensor_bitwidth[smi130_acc->sensor_type]);
+#endif
+			smi130_acc_remap_sensor_data(&acc_lsb, smi130_acc);
+			input_event(smi130_acc->input, EV_MSC, MSC_TIME,
+			ts.tv_sec);
+			input_event(smi130_acc->input, EV_MSC, MSC_TIME,
+			ts.tv_nsec);
+			input_event(smi130_acc->input, EV_MSC,
+				MSC_GESTURE, acc_lsb.x);
+			input_event(smi130_acc->input, EV_MSC,
+				MSC_RAW, acc_lsb.y);
+			input_event(smi130_acc->input, EV_MSC,
+				MSC_SCAN, acc_lsb.z);
+			input_sync(smi130_acc->input);
+			smi130_acc->timestamp +=
+				time_internal - sample_drift_offset;
+		}
+	}
+	drift_time = smi130_acc->timestamp - smi130_acc->fifo_time;
+	if (data_cnt % 20 == 0) {
+		if (ABS(drift_time) > div64_u64(time_odr, 5)) {
+			sample_drift_offset =
+			div64_s64(drift_time, smi130_acc->acc_count - pre_data_cnt);
+			pre_data_cnt = smi130_acc->acc_count;
+			time_odr = time_internal;
+		}
+	}
+
+}
+
+static enum hrtimer_restart reportdata_timer_fun(
+	struct hrtimer *hrtimer)
+{
+	struct smi130_acc_data *client_data =
+		container_of(hrtimer, struct smi130_acc_data, timer);
+	int32_t delay = 0;
+	delay = 8;
+	queue_work(reportdata_wq, &(client_data->report_data_work));
+	/*set delay 8ms*/
+	client_data->work_delay_kt = ns_to_ktime(delay*1000000);
+	hrtimer_forward(hrtimer, ktime_get(), client_data->work_delay_kt);
+
+	return HRTIMER_RESTART;
+}
+
+static ssize_t smi130_acc_enable_timer_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	return snprintf(buf, 16, "%d\n", smi130_acc->is_timer_running);
+}
+
+static ssize_t smi130_acc_enable_timer_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+
+	if (data) {
+		if (0 == smi130_acc->is_timer_running) {
+			hrtimer_start(&smi130_acc->timer,
+			ns_to_ktime(1000000),
+			HRTIMER_MODE_REL);
+			smi130_acc->base_time = 0;
+			smi130_acc->timestamp = 0;
+			smi130_acc->is_timer_running = 1;
+	}
+	} else {
+		if (1 == smi130_acc->is_timer_running) {
+			hrtimer_cancel(&smi130_acc->timer);
+			smi130_acc->is_timer_running = 0;
+			smi130_acc->base_time = 0;
+			smi130_acc->timestamp = 0;
+			smi130_acc->fifo_time = 0;
+			smi130_acc->acc_count = 0;
+	}
+	}
+	return count;
+}
+
+static ssize_t smi130_acc_debug_level_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+	err = snprintf(buf, 8, "%d\n", smi130_acc->debug_level);
+	return err;
+}
+static ssize_t smi130_acc_debug_level_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	int32_t ret = 0;
+	unsigned long data;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	ret = kstrtoul(buf, 16, &data);
+	if (ret)
+		return ret;
+	smi130_acc->debug_level = (uint8_t)data;
+	return count;
+}
+
+static ssize_t smi130_acc_register_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	int address, value;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	sscanf(buf, "%3d %3d", &address, &value);
+	if (smi130_acc_write_reg(smi130_acc->smi130_acc_client, (unsigned char)address,
+				(unsigned char *)&value) < 0)
+		return -EINVAL;
+	return count;
+}
+static ssize_t smi130_acc_register_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	size_t count = 0;
+	u8 reg[0x40];
+	int i;
+
+	for (i = 0; i < 0x40; i++) {
+		smi130_acc_smbus_read_byte(smi130_acc->smi130_acc_client, i, reg+i);
+
+		count += snprintf(&buf[count], 32, "0x%x: %d\n", i, reg[i]);
+	}
+	return count;
+
+
+}
+
+static ssize_t smi130_acc_range_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_get_range(smi130_acc->smi130_acc_client, &data) < 0)
+		return -EINVAL;
+
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t smi130_acc_range_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+	if (smi130_acc_set_range(smi130_acc->smi130_acc_client, (unsigned char) data) < 0)
+		return -EINVAL;
+
+	return count;
+}
+
+static ssize_t smi130_acc_bandwidth_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_get_bandwidth(smi130_acc->smi130_acc_client, &data) < 0)
+		return -EINVAL;
+
+	return snprintf(buf, 16, "%d\n", data);
+
+}
+
+static ssize_t smi130_acc_bandwidth_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+
+	if (smi130_acc->sensor_type == SMI_ACC280_TYPE)
+		if ((unsigned char) data > 14)
+			return -EINVAL;
+
+	if (smi130_acc_set_bandwidth(smi130_acc->smi130_acc_client,
+				(unsigned char) data) < 0)
+		return -EINVAL;
+	smi130_acc->base_time = 0;
+	smi130_acc->acc_count = 0;
+
+	return count;
+}
+
+static ssize_t smi130_acc_mode_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_get_mode(smi130_acc->smi130_acc_client, &data) < 0)
+		return -EINVAL;
+
+	return snprintf(buf, 32, "%d %d\n", data, smi130_acc->smi_acc_mode_enabled);
+}
+
+static ssize_t smi130_acc_mode_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+	if (smi130_acc_set_mode(smi130_acc->smi130_acc_client,
+		(unsigned char) data, SMI_ACC_ENABLED_BSX) < 0)
+			return -EINVAL;
+
+	return count;
+}
+
+static ssize_t smi130_acc_value_cache_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi130_acc_data *smi130_acc = input_get_drvdata(input);
+	struct smi130_accacc acc_value;
+
+	mutex_lock(&smi130_acc->value_mutex);
+	acc_value = smi130_acc->value;
+	mutex_unlock(&smi130_acc->value_mutex);
+
+	return snprintf(buf, 96, "%d %d %d\n", acc_value.x, acc_value.y,
+			acc_value.z);
+}
+
+static ssize_t smi130_acc_value_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi130_acc_data *smi130_acc = input_get_drvdata(input);
+	struct smi130_accacc acc_value;
+
+	smi130_acc_read_accel_xyz(smi130_acc->smi130_acc_client, smi130_acc->sensor_type,
+								&acc_value);
+
+	return snprintf(buf, 96, "%d %d %d\n", acc_value.x, acc_value.y,
+			acc_value.z);
+}
+
+static ssize_t smi130_acc_delay_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	return snprintf(buf, 16, "%d\n", atomic_read(&smi130_acc->delay));
+
+}
+
+static ssize_t smi130_acc_chip_id_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	return snprintf(buf, 16, "%u\n", smi130_acc->chip_id);
+
+}
+
+
+static ssize_t smi130_acc_place_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+	int place = BOSCH_SENSOR_PLACE_UNKNOWN;
+
+	if (NULL != smi130_acc->bosch_pd)
+		place = smi130_acc->bosch_pd->place;
+
+	return snprintf(buf, 16, "%d\n", place);
+}
+
+
+static ssize_t smi130_acc_delay_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+	if (data > SMI_ACC2X2_MAX_DELAY)
+		data = SMI_ACC2X2_MAX_DELAY;
+	atomic_set(&smi130_acc->delay, (unsigned int) data);
+
+	return count;
+}
+
+
+static ssize_t smi130_acc_enable_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	return snprintf(buf, 16, "%d\n", atomic_read(&smi130_acc->enable));
+
+}
+
+static void smi130_acc_set_enable(struct device *dev, int enable)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+	int pre_enable = atomic_read(&smi130_acc->enable);
+
+	mutex_lock(&smi130_acc->enable_mutex);
+	if (enable) {
+		if (pre_enable == 0) {
+			smi130_acc_set_mode(smi130_acc->smi130_acc_client,
+					SMI_ACC2X2_MODE_NORMAL, SMI_ACC_ENABLED_INPUT);
+
+		#ifndef CONFIG_SMI_ACC_ENABLE_NEWDATA_INT
+			schedule_delayed_work(&smi130_acc->work,
+				msecs_to_jiffies(atomic_read(&smi130_acc->delay)));
+#endif
+			atomic_set(&smi130_acc->enable, 1);
+		}
+
+	} else {
+		if (pre_enable == 1) {
+			smi130_acc_set_mode(smi130_acc->smi130_acc_client,
+					SMI_ACC2X2_MODE_SUSPEND, SMI_ACC_ENABLED_INPUT);
+
+		#ifndef CONFIG_SMI_ACC_ENABLE_NEWDATA_INT
+			cancel_delayed_work_sync(&smi130_acc->work);
+#endif
+			atomic_set(&smi130_acc->enable, 0);
+		}
+	}
+	mutex_unlock(&smi130_acc->enable_mutex);
+
+}
+
+static ssize_t smi130_acc_enable_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+	if ((data == 0) || (data == 1))
+		smi130_acc_set_enable(dev, data);
+
+	return count;
+}
+static ssize_t smi130_acc_fast_calibration_x_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+
+
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+#ifdef CONFIG_SENSORS_BMI058
+	if (smi130_acc_get_offset_target(smi130_acc->smi130_acc_client,
+				BMI058_OFFSET_TRIGGER_X, &data) < 0)
+		return -EINVAL;
+#else
+	if (smi130_acc_get_offset_target(smi130_acc->smi130_acc_client,
+				SMI_ACC2X2_OFFSET_TRIGGER_X, &data) < 0)
+		return -EINVAL;
+#endif
+
+	return snprintf(buf, 16, "%d\n", data);
+
+}
+
+static ssize_t smi130_acc_fast_calibration_x_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	signed char tmp;
+	unsigned char timeout = 0;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+
+#ifdef CONFIG_SENSORS_BMI058
+	if (smi130_acc_set_offset_target(smi130_acc->smi130_acc_client,
+			BMI058_OFFSET_TRIGGER_X, (unsigned char)data) < 0)
+		return -EINVAL;
+#else
+	if (smi130_acc_set_offset_target(smi130_acc->smi130_acc_client,
+			SMI_ACC2X2_OFFSET_TRIGGER_X, (unsigned char)data) < 0)
+		return -EINVAL;
+#endif
+
+	if (smi130_acc_set_cal_trigger(smi130_acc->smi130_acc_client, 1) < 0)
+		return -EINVAL;
+
+	do {
+		smi130_acc_delay(2);
+		smi130_acc_get_cal_ready(smi130_acc->smi130_acc_client, &tmp);
+
+		/*PINFO("wait 2ms cal ready flag is %d\n", tmp); */
+		timeout++;
+		if (timeout == 50) {
+			PINFO("get fast calibration ready error\n");
+			return -EINVAL;
+		};
+
+	} while (tmp == 0);
+
+	PINFO("x axis fast calibration finished\n");
+	return count;
+}
+
+static ssize_t smi130_acc_fast_calibration_y_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+
+
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+#ifdef CONFIG_SENSORS_BMI058
+	if (smi130_acc_get_offset_target(smi130_acc->smi130_acc_client,
+					BMI058_OFFSET_TRIGGER_Y, &data) < 0)
+		return -EINVAL;
+#else
+	if (smi130_acc_get_offset_target(smi130_acc->smi130_acc_client,
+					SMI_ACC2X2_OFFSET_TRIGGER_Y, &data) < 0)
+		return -EINVAL;
+#endif
+
+	return snprintf(buf, 16, "%d\n", data);
+
+}
+
+static ssize_t smi130_acc_fast_calibration_y_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	signed char tmp;
+	unsigned char timeout = 0;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+
+#ifdef CONFIG_SENSORS_BMI058
+	if (smi130_acc_set_offset_target(smi130_acc->smi130_acc_client,
+			BMI058_OFFSET_TRIGGER_Y, (unsigned char)data) < 0)
+		return -EINVAL;
+#else
+	if (smi130_acc_set_offset_target(smi130_acc->smi130_acc_client,
+			SMI_ACC2X2_OFFSET_TRIGGER_Y, (unsigned char)data) < 0)
+		return -EINVAL;
+#endif
+
+	if (smi130_acc_set_cal_trigger(smi130_acc->smi130_acc_client, 2) < 0)
+		return -EINVAL;
+
+	do {
+		smi130_acc_delay(2);
+		smi130_acc_get_cal_ready(smi130_acc->smi130_acc_client, &tmp);
+
+		/*PINFO("wait 2ms cal ready flag is %d\n", tmp);*/
+		timeout++;
+		if (timeout == 50) {
+			PINFO("get fast calibration ready error\n");
+			return -EINVAL;
+		};
+
+	} while (tmp == 0);
+
+	PINFO("y axis fast calibration finished\n");
+	return count;
+}
+
+static ssize_t smi130_acc_fast_calibration_z_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+
+
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_get_offset_target(smi130_acc->smi130_acc_client, 3, &data) < 0)
+		return -EINVAL;
+
+	return snprintf(buf, 16, "%d\n", data);
+
+}
+
+static ssize_t smi130_acc_fast_calibration_z_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	signed char tmp;
+	unsigned char timeout = 0;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+
+	if (smi130_acc_set_offset_target(smi130_acc->smi130_acc_client, 3, (unsigned
+					char)data) < 0)
+		return -EINVAL;
+
+	if (smi130_acc_set_cal_trigger(smi130_acc->smi130_acc_client, 3) < 0)
+		return -EINVAL;
+
+	do {
+		smi130_acc_delay(2);
+		smi130_acc_get_cal_ready(smi130_acc->smi130_acc_client, &tmp);
+
+		/*PINFO("wait 2ms cal ready flag is %d\n", tmp);*/
+		timeout++;
+		if (timeout == 50) {
+			PINFO("get fast calibration ready error\n");
+			return -EINVAL;
+		};
+
+	} while (tmp == 0);
+
+	PINFO("z axis fast calibration finished\n");
+	return count;
+}
+
+
+static ssize_t smi130_acc_SleepDur_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_get_sleep_duration(smi130_acc->smi130_acc_client, &data) < 0)
+		return -EINVAL;
+
+	return snprintf(buf, 16, "%d\n", data);
+
+}
+
+static ssize_t smi130_acc_SleepDur_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+	if (smi130_acc_set_sleep_duration(smi130_acc->smi130_acc_client,
+				(unsigned char) data) < 0)
+		return -EINVAL;
+
+	return count;
+}
+
+static ssize_t smi130_acc_fifo_mode_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_get_fifo_mode(smi130_acc->smi130_acc_client, &data) < 0)
+		return -EINVAL;
+
+	return snprintf(buf, 16, "%d\n", data);
+
+}
+
+static ssize_t smi130_acc_fifo_mode_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+	if (smi130_acc_set_fifo_mode(smi130_acc->smi130_acc_client,
+				(unsigned char) data) < 0)
+		return -EINVAL;
+	return count;
+}
+
+
+
+static ssize_t smi130_acc_fifo_trig_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_get_fifo_trig(smi130_acc->smi130_acc_client, &data) < 0)
+		return -EINVAL;
+
+	return snprintf(buf, 16, "%d\n", data);
+
+}
+
+static ssize_t smi130_acc_fifo_trig_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+	if (smi130_acc_set_fifo_trig(smi130_acc->smi130_acc_client,
+				(unsigned char) data) < 0)
+		return -EINVAL;
+
+	return count;
+}
+
+
+
+static ssize_t smi130_acc_fifo_trig_src_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_get_fifo_trig_src(smi130_acc->smi130_acc_client, &data) < 0)
+		return -EINVAL;
+
+	return snprintf(buf, 16, "%d\n", data);
+
+}
+
+static ssize_t smi130_acc_fifo_trig_src_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+	if (smi130_acc_set_fifo_trig_src(smi130_acc->smi130_acc_client,
+				(unsigned char) data) < 0)
+		return -EINVAL;
+
+	return count;
+}
+
+
+/*!
+ * @brief show fifo_data_sel axis definition(Android definition, not sensor HW reg).
+ * 0--> x, y, z axis fifo data for every frame
+ * 1--> only x axis fifo data for every frame
+ * 2--> only y axis fifo data for every frame
+ * 3--> only z axis fifo data for every frame
+ */
+static ssize_t smi130_acc_fifo_data_sel_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+	signed char place = BOSCH_SENSOR_PLACE_UNKNOWN;
+	if (smi130_acc_get_fifo_data_sel(smi130_acc->smi130_acc_client, &data) < 0)
+		return -EINVAL;
+
+#ifdef CONFIG_SENSORS_BMI058
+/*Update BMI058 fifo_data_sel to the SMI130_ACC common definition*/
+	if (BMI058_FIFO_DAT_SEL_X == data)
+		data = SMI_ACC2X2_FIFO_DAT_SEL_X;
+	else if (BMI058_FIFO_DAT_SEL_Y == data)
+		data = SMI_ACC2X2_FIFO_DAT_SEL_Y;
+#endif
+
+	/*remaping fifo_dat_sel if define virtual place in BSP files*/
+	if ((NULL != smi130_acc->bosch_pd) &&
+		(BOSCH_SENSOR_PLACE_UNKNOWN != smi130_acc->bosch_pd->place)) {
+		place = smi130_acc->bosch_pd->place;
+		/* sensor with place 0 needs not to be remapped */
+		if ((place > 0) && (place < MAX_AXIS_REMAP_TAB_SZ)) {
+			/* SMI_ACC2X2_FIFO_DAT_SEL_X: 1, Y:2, Z:3;
+			* but bosch_axis_remap_tab_dft[i].src_x:0, y:1, z:2
+			* so we need to +1*/
+			if (SMI_ACC2X2_FIFO_DAT_SEL_X == data)
+				data = bosch_axis_remap_tab_dft[place].src_x + 1;
+			else if (SMI_ACC2X2_FIFO_DAT_SEL_Y == data)
+				data = bosch_axis_remap_tab_dft[place].src_y + 1;
+		}
+	}
+
+	return snprintf(buf, 16, "%d\n", data);
+
+}
+
+static ssize_t smi130_acc_fifo_framecount_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data = 0;
+	unsigned char mode;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_get_fifo_framecount(smi130_acc->smi130_acc_client, &data) < 0)
+		return -EINVAL;
+
+	if (data > MAX_FIFO_F_LEVEL) {
+
+		if (smi130_acc_get_mode(smi130_acc->smi130_acc_client, &mode) < 0)
+			return -EINVAL;
+
+		if (SMI_ACC2X2_MODE_NORMAL == mode) {
+			PERR("smi130_acc fifo_count: %d abnormal, op_mode: %d",
+					data, mode);
+			data = MAX_FIFO_F_LEVEL;
+		} else {
+			/*chip already suspend or shutdown*/
+			data = 0;
+		}
+	}
+
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t smi130_acc_fifo_framecount_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+	smi130_acc->fifo_count = (unsigned int) data;
+
+	return count;
+}
+
+static ssize_t smi130_acc_temperature_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_read_temperature(smi130_acc->smi130_acc_client, &data) < 0)
+		return -EINVAL;
+
+	return snprintf(buf, 16, "%d\n", data);
+
+}
+
+/*!
+ * @brief store fifo_data_sel axis definition(Android definition, not sensor HW reg).
+ * 0--> x, y, z axis fifo data for every frame
+ * 1--> only x axis fifo data for every frame
+ * 2--> only y axis fifo data for every frame
+ * 3--> only z axis fifo data for every frame
+ */
+static ssize_t smi130_acc_fifo_data_sel_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+	signed char place;
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+	/*save fifo_data_sel(android definition)*/
+	smi130_acc->fifo_datasel = (unsigned char) data;
+
+	/*remaping fifo_dat_sel if define virtual place*/
+	if ((NULL != smi130_acc->bosch_pd) &&
+		(BOSCH_SENSOR_PLACE_UNKNOWN != smi130_acc->bosch_pd->place)) {
+		place = smi130_acc->bosch_pd->place;
+		/* sensor with place 0 needs not to be remapped */
+		if ((place > 0) && (place < MAX_AXIS_REMAP_TAB_SZ)) {
+			/*Need X Y axis revesal sensor place: P1, P3, P5, P7 */
+			/* SMI_ACC2X2_FIFO_DAT_SEL_X: 1, Y:2, Z:3;
+			  * but bosch_axis_remap_tab_dft[i].src_x:0, y:1, z:2
+			  * so we need to +1*/
+			if (SMI_ACC2X2_FIFO_DAT_SEL_X == data)
+				data =  bosch_axis_remap_tab_dft[place].src_x + 1;
+			else if (SMI_ACC2X2_FIFO_DAT_SEL_Y == data)
+				data =  bosch_axis_remap_tab_dft[place].src_y + 1;
+		}
+	}
+#ifdef CONFIG_SENSORS_BMI058
+	/*Update BMI058 fifo_data_sel to the SMI130_ACC common definition*/
+		if (SMI_ACC2X2_FIFO_DAT_SEL_X == data)
+			data = BMI058_FIFO_DAT_SEL_X;
+		else if (SMI_ACC2X2_FIFO_DAT_SEL_Y == data)
+			data = BMI058_FIFO_DAT_SEL_Y;
+
+#endif
+	if (smi130_acc_set_fifo_data_sel(smi130_acc->smi130_acc_client,
+				(unsigned char) data) < 0)
+		return -EINVAL;
+
+	return count;
+}
+
+static ssize_t smi130_acc_fifo_data_out_frame_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char f_len = 0;
+	unsigned char count = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+	if (smi130_acc->fifo_datasel) {
+		/*Select one axis data output for every fifo frame*/
+		f_len = 2;
+	} else	{
+		/*Select X Y Z axis data output for every fifo frame*/
+		f_len = 6;
+	}
+	if (smi130_acc_get_fifo_framecount(smi130_acc->smi130_acc_client, &count) < 0) {
+		PERR("smi130_acc_get_fifo_framecount err\n");
+		return -EINVAL;
+	}
+	if (count == 0)
+		return 0;
+	if (smi_acc_i2c_burst_read(smi130_acc->smi130_acc_client,
+			SMI_ACC2X2_FIFO_DATA_OUTPUT_REG, buf,
+						count * f_len) < 0)
+		return -EINVAL;
+
+	return count * f_len;
+}
+
+static ssize_t smi130_acc_offset_x_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_get_offset_x(smi130_acc->smi130_acc_client, &data) < 0)
+		return snprintf(buf, 48, "Read error\n");
+
+	return snprintf(buf, 16, "%d\n", data);
+
+}
+
+static ssize_t smi130_acc_offset_x_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+
+	if (smi130_acc_set_offset_x(smi130_acc->smi130_acc_client, (unsigned
+					char)data) < 0)
+		return -EINVAL;
+
+	return count;
+}
+
+static ssize_t smi130_acc_offset_y_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_get_offset_y(smi130_acc->smi130_acc_client, &data) < 0)
+		return snprintf(buf, 48, "Read error\n");
+
+	return snprintf(buf, 16, "%d\n", data);
+
+}
+
+static ssize_t smi130_acc_offset_y_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+
+	if (smi130_acc_set_offset_y(smi130_acc->smi130_acc_client, (unsigned
+					char)data) < 0)
+		return -EINVAL;
+
+	return count;
+}
+
+static ssize_t smi130_acc_offset_z_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data = 0;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	if (smi130_acc_get_offset_z(smi130_acc->smi130_acc_client, &data) < 0)
+		return snprintf(buf, 48, "Read error\n");
+
+	return snprintf(buf, 16, "%d\n", data);
+
+}
+
+static ssize_t smi130_acc_offset_z_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+
+	if (smi130_acc_set_offset_z(smi130_acc->smi130_acc_client, (unsigned
+					char)data) < 0)
+		return -EINVAL;
+
+	return count;
+}
+
+static ssize_t smi130_acc_driver_version_show(struct device *dev
+		, struct device_attribute *attr, char *buf)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+	int ret;
+
+	if (smi130_acc == NULL) {
+		printk(KERN_ERR "Invalid client_data pointer");
+		return -ENODEV;
+	}
+
+	ret = snprintf(buf, 128, "Driver version: %s\n",
+			DRIVER_VERSION);
+	return ret;
+}
+
+#ifdef CONFIG_SIG_MOTION
+static int smi130_acc_set_en_slope_int(struct smi130_acc_data *smi130_acc,
+		int en)
+{
+	int err;
+	struct i2c_client *client = smi130_acc->smi130_acc_client;
+
+	if (en) {
+		/* Set the related parameters which needs to be fine tuned by
+		* interfaces: slope_threshold and slope_duration
+		*/
+		/*dur: 192 samples ~= 3s*/
+		err = smi130_acc_set_slope_duration(client, 0x0);
+		err += smi130_acc_set_slope_threshold(client, 0x16);
+
+		/*Enable the interrupts*/
+		err += smi130_acc_set_Int_Enable(client, 5, 1);/*Slope X*/
+		err += smi130_acc_set_Int_Enable(client, 6, 1);/*Slope Y*/
+		err += smi130_acc_set_Int_Enable(client, 7, 1);/*Slope Z*/
+	#ifdef SMI_ACC2X2_ENABLE_INT1
+		/* TODO: SLOPE can now only be routed to INT1 pin*/
+		err += smi130_acc_set_int1_pad_sel(client, PAD_SLOP);
+	#else
+		/* err += smi130_acc_set_int2_pad_sel(client, PAD_SLOP); */
+	#endif
+	} else {
+		err = smi130_acc_set_Int_Enable(client, 5, 0);/*Slope X*/
+		err += smi130_acc_set_Int_Enable(client, 6, 0);/*Slope Y*/
+		err += smi130_acc_set_Int_Enable(client, 7, 0);/*Slope Z*/
+	}
+	return err;
+}
+
+static ssize_t smi130_acc_en_sig_motion_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	return snprintf(buf, 16, "%d\n", atomic_read(&smi130_acc->en_sig_motion));
+}
+
+static int smi130_acc_set_en_sig_motion(struct smi130_acc_data *smi130_acc,
+		int en)
+{
+	int err = 0;
+
+	en = (en >= 1) ? 1 : 0;  /* set sig motion sensor status */
+
+	if (atomic_read(&smi130_acc->en_sig_motion) != en) {
+		if (en) {
+			err = smi130_acc_set_mode(smi130_acc->smi130_acc_client,
+					SMI_ACC2X2_MODE_NORMAL, SMI_ACC_ENABLED_SGM);
+			err = smi130_acc_set_en_slope_int(smi130_acc, en);
+			enable_irq_wake(smi130_acc->IRQ);
+		} else {
+			disable_irq_wake(smi130_acc->IRQ);
+			err = smi130_acc_set_en_slope_int(smi130_acc, en);
+			err = smi130_acc_set_mode(smi130_acc->smi130_acc_client,
+					SMI_ACC2X2_MODE_SUSPEND, SMI_ACC_ENABLED_SGM);
+		}
+		atomic_set(&smi130_acc->en_sig_motion, en);
+	}
+	return err;
+}
+
+static ssize_t smi130_acc_en_sig_motion_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+
+	if ((data == 0) || (data == 1))
+		smi130_acc_set_en_sig_motion(smi130_acc, data);
+
+	return count;
+}
+#endif
+
+#ifdef CONFIG_DOUBLE_TAP
+static int smi130_acc_set_en_single_tap_int(struct smi130_acc_data *smi130_acc, int en)
+{
+	int err;
+	struct i2c_client *client = smi130_acc->smi130_acc_client;
+
+	if (en) {
+		/* set tap interruption parameter here if needed.
+		smi130_acc_set_tap_duration(client, 0xc0);
+		smi130_acc_set_tap_threshold(client, 0x16);
+		*/
+
+		/*Enable the single tap interrupts*/
+		err = smi130_acc_set_Int_Enable(client, 8, 1);
+	#ifdef SMI_ACC2X2_ENABLE_INT1
+		err += smi130_acc_set_int1_pad_sel(client, PAD_SINGLE_TAP);
+	#else
+		err += smi130_acc_set_int2_pad_sel(client, PAD_SINGLE_TAP);
+	#endif
+	} else {
+		err = smi130_acc_set_Int_Enable(client, 8, 0);
+	}
+	return err;
+}
+
+static ssize_t smi130_acc_tap_time_period_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	return snprintf(buf, 16, "%d\n", smi130_acc->tap_time_period);
+}
+
+static ssize_t smi130_acc_tap_time_period_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+
+	smi130_acc->tap_time_period = data;
+
+	return count;
+}
+
+static ssize_t smi130_acc_en_double_tap_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	return snprintf(buf, 16, "%d\n", atomic_read(&smi130_acc->en_double_tap));
+}
+
+static int smi130_acc_set_en_double_tap(struct smi130_acc_data *smi130_acc,
+		int en)
+{
+	int err = 0;
+
+	en = (en >= 1) ? 1 : 0;
+
+	if (atomic_read(&smi130_acc->en_double_tap) != en) {
+		if (en) {
+			err = smi130_acc_set_mode(smi130_acc->smi130_acc_client,
+					SMI_ACC2X2_MODE_NORMAL, SMI_ACC_ENABLED_DTAP);
+			err = smi130_acc_set_en_single_tap_int(smi130_acc, en);
+		} else {
+			err = smi130_acc_set_en_single_tap_int(smi130_acc, en);
+			err = smi130_acc_set_mode(smi130_acc->smi130_acc_client,
+					SMI_ACC2X2_MODE_SUSPEND, SMI_ACC_ENABLED_DTAP);
+		}
+		atomic_set(&smi130_acc->en_double_tap, en);
+	}
+	return err;
+}
+
+static ssize_t smi130_acc_en_double_tap_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi130_acc_data *smi130_acc = i2c_get_clientdata(client);
+
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+
+	if ((data == 0) || (data == 1))
+		smi130_acc_set_en_double_tap(smi130_acc, data);
+
+	return count;
+}
+
+static void smi130_acc_tap_timeout_handle(unsigned long data)
+{
+	struct smi130_acc_data *smi130_acc = (struct smi130_acc_data *)data;
+
+	PINFO("tap interrupt handle, timeout\n");
+	mutex_lock(&smi130_acc->tap_mutex);
+	smi130_acc->tap_times = 0;
+	mutex_unlock(&smi130_acc->tap_mutex);
+
+	/* if a single tap need to report, open the define */
+#ifdef REPORT_SINGLE_TAP_WHEN_DOUBLE_TAP_SENSOR_ENABLED
+	input_report_rel(smi130_acc->dev_interrupt,
+		SINGLE_TAP_INTERRUPT,
+		SINGLE_TAP_INTERRUPT_HAPPENED);
+	input_sync(smi130_acc->dev_interrupt);
+#endif
+
+}
+#endif
+
+static DEVICE_ATTR(range, S_IRUGO | S_IWUSR,
+		smi130_acc_range_show, smi130_acc_range_store);
+static DEVICE_ATTR(bandwidth, S_IRUGO | S_IWUSR,
+		smi130_acc_bandwidth_show, smi130_acc_bandwidth_store);
+static DEVICE_ATTR(op_mode, S_IRUGO | S_IWUSR,
+		smi130_acc_mode_show, smi130_acc_mode_store);
+static DEVICE_ATTR(value, S_IRUSR,
+		smi130_acc_value_show, NULL);
+static DEVICE_ATTR(value_cache, S_IRUSR,
+		smi130_acc_value_cache_show, NULL);
+static DEVICE_ATTR(delay, S_IRUGO | S_IWUSR,
+		smi130_acc_delay_show, smi130_acc_delay_store);
+static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR,
+		smi130_acc_enable_show, smi130_acc_enable_store);
+static DEVICE_ATTR(SleepDur, S_IRUGO | S_IWUSR,
+		smi130_acc_SleepDur_show, smi130_acc_SleepDur_store);
+static DEVICE_ATTR(fast_calibration_x, S_IRUGO | S_IWUSR,
+		smi130_acc_fast_calibration_x_show,
+		smi130_acc_fast_calibration_x_store);
+static DEVICE_ATTR(fast_calibration_y, S_IRUGO | S_IWUSR,
+		smi130_acc_fast_calibration_y_show,
+		smi130_acc_fast_calibration_y_store);
+static DEVICE_ATTR(fast_calibration_z, S_IRUGO | S_IWUSR,
+		smi130_acc_fast_calibration_z_show,
+		smi130_acc_fast_calibration_z_store);
+static DEVICE_ATTR(fifo_mode, S_IRUGO | S_IWUSR,
+		smi130_acc_fifo_mode_show, smi130_acc_fifo_mode_store);
+static DEVICE_ATTR(fifo_framecount, S_IRUGO | S_IWUSR,
+		smi130_acc_fifo_framecount_show, smi130_acc_fifo_framecount_store);
+static DEVICE_ATTR(fifo_trig, S_IRUGO | S_IWUSR,
+		smi130_acc_fifo_trig_show, smi130_acc_fifo_trig_store);
+static DEVICE_ATTR(fifo_trig_src, S_IRUGO | S_IWUSR,
+		smi130_acc_fifo_trig_src_show, smi130_acc_fifo_trig_src_store);
+static DEVICE_ATTR(fifo_data_sel, S_IRUGO | S_IWUSR,
+		smi130_acc_fifo_data_sel_show, smi130_acc_fifo_data_sel_store);
+static DEVICE_ATTR(fifo_data_frame, S_IRUGO,
+		smi130_acc_fifo_data_out_frame_show, NULL);
+static DEVICE_ATTR(reg, S_IRUGO | S_IWUSR,
+		smi130_acc_register_show, smi130_acc_register_store);
+static DEVICE_ATTR(chip_id, S_IRUSR,
+		smi130_acc_chip_id_show, NULL);
+static DEVICE_ATTR(offset_x, S_IRUGO | S_IWUSR,
+		smi130_acc_offset_x_show,
+		smi130_acc_offset_x_store);
+static DEVICE_ATTR(offset_y, S_IRUGO | S_IWUSR,
+		smi130_acc_offset_y_show,
+		smi130_acc_offset_y_store);
+static DEVICE_ATTR(offset_z, S_IRUGO | S_IWUSR,
+		smi130_acc_offset_z_show,
+		smi130_acc_offset_z_store);
+static DEVICE_ATTR(enable_int, S_IWUSR,
+		NULL, smi130_acc_enable_int_store);
+static DEVICE_ATTR(int_mode, S_IRUGO | S_IWUSR,
+		smi130_acc_int_mode_show, smi130_acc_int_mode_store);
+static DEVICE_ATTR(slope_duration, S_IRUGO | S_IWUSR,
+		smi130_acc_slope_duration_show, smi130_acc_slope_duration_store);
+static DEVICE_ATTR(slope_threshold, S_IRUGO | S_IWUSR,
+		smi130_acc_slope_threshold_show, smi130_acc_slope_threshold_store);
+static DEVICE_ATTR(slope_no_mot_duration, S_IRUGO | S_IWUSR,
+		smi130_acc_slope_no_mot_duration_show,
+			smi130_acc_slope_no_mot_duration_store);
+static DEVICE_ATTR(slope_no_mot_threshold, S_IRUGO | S_IWUSR,
+		smi130_acc_slope_no_mot_threshold_show,
+			smi130_acc_slope_no_mot_threshold_store);
+static DEVICE_ATTR(high_g_duration, S_IRUGO | S_IWUSR,
+		smi130_acc_high_g_duration_show, smi130_acc_high_g_duration_store);
+static DEVICE_ATTR(high_g_threshold, S_IRUGO | S_IWUSR,
+		smi130_acc_high_g_threshold_show, smi130_acc_high_g_threshold_store);
+static DEVICE_ATTR(low_g_duration, S_IRUGO | S_IWUSR,
+		smi130_acc_low_g_duration_show, smi130_acc_low_g_duration_store);
+static DEVICE_ATTR(low_g_threshold, S_IRUGO | S_IWUSR,
+		smi130_acc_low_g_threshold_show, smi130_acc_low_g_threshold_store);
+static DEVICE_ATTR(tap_duration, S_IRUGO | S_IWUSR,
+		smi130_acc_tap_duration_show, smi130_acc_tap_duration_store);
+static DEVICE_ATTR(tap_threshold, S_IRUGO | S_IWUSR,
+		smi130_acc_tap_threshold_show, smi130_acc_tap_threshold_store);
+static DEVICE_ATTR(tap_quiet, S_IRUGO | S_IWUSR,
+		smi130_acc_tap_quiet_show, smi130_acc_tap_quiet_store);
+static DEVICE_ATTR(tap_shock, S_IRUGO | S_IWUSR,
+		smi130_acc_tap_shock_show, smi130_acc_tap_shock_store);
+static DEVICE_ATTR(tap_samp, S_IRUGO | S_IWUSR,
+		smi130_acc_tap_samp_show, smi130_acc_tap_samp_store);
+static DEVICE_ATTR(orient_mbl_mode, S_IRUGO | S_IWUSR,
+		smi130_acc_orient_mbl_mode_show, smi130_acc_orient_mbl_mode_store);
+static DEVICE_ATTR(orient_mbl_blocking, S_IRUGO | S_IWUSR,
+		smi130_acc_orient_mbl_blocking_show, smi130_acc_orient_mbl_blocking_store);
+static DEVICE_ATTR(orient_mbl_hyst, S_IRUGO | S_IWUSR,
+		smi130_acc_orient_mbl_hyst_show, smi130_acc_orient_mbl_hyst_store);
+static DEVICE_ATTR(orient_mbl_theta, S_IRUGO | S_IWUSR,
+		smi130_acc_orient_mbl_theta_show, smi130_acc_orient_mbl_theta_store);
+static DEVICE_ATTR(flat_theta, S_IRUGO | S_IWUSR,
+		smi130_acc_flat_theta_show, smi130_acc_flat_theta_store);
+static DEVICE_ATTR(flat_hold_time, S_IRUGO | S_IWUSR,
+		smi130_acc_flat_hold_time_show, smi130_acc_flat_hold_time_store);
+static DEVICE_ATTR(selftest, S_IRUGO | S_IWUSR,
+		smi130_acc_selftest_show, smi130_acc_selftest_store);
+static DEVICE_ATTR(softreset, S_IWUSR,
+		NULL, smi130_acc_softreset_store);
+static DEVICE_ATTR(enable_timer, S_IRUGO | S_IWUSR,
+		smi130_acc_enable_timer_show, smi130_acc_enable_timer_store);
+static DEVICE_ATTR(debug_level, S_IRUGO | S_IWUSR,
+		smi130_acc_debug_level_show, smi130_acc_debug_level_store);
+static DEVICE_ATTR(temperature, S_IRUSR,
+		smi130_acc_temperature_show, NULL);
+static DEVICE_ATTR(place, S_IRUSR,
+		smi130_acc_place_show, NULL);
+static DEVICE_ATTR(driver_version, S_IRUSR,
+		smi130_acc_driver_version_show, NULL);
+
+#ifdef CONFIG_SIG_MOTION
+static DEVICE_ATTR(en_sig_motion, S_IRUGO|S_IWUSR|S_IWGRP|S_IWOTH,
+		smi130_acc_en_sig_motion_show, smi130_acc_en_sig_motion_store);
+#endif
+#ifdef CONFIG_DOUBLE_TAP
+static DEVICE_ATTR(tap_time_period, S_IRUGO|S_IWUSR|S_IWGRP|S_IWOTH,
+		smi130_acc_tap_time_period_show, smi130_acc_tap_time_period_store);
+static DEVICE_ATTR(en_double_tap, S_IRUGO|S_IWUSR|S_IWGRP|S_IWOTH,
+		smi130_acc_en_double_tap_show, smi130_acc_en_double_tap_store);
+#endif
+
+static struct attribute *smi130_acc_attributes[] = {
+	&dev_attr_range.attr,
+	&dev_attr_bandwidth.attr,
+	&dev_attr_op_mode.attr,
+	&dev_attr_value.attr,
+	&dev_attr_value_cache.attr,
+	&dev_attr_delay.attr,
+	&dev_attr_enable.attr,
+	&dev_attr_SleepDur.attr,
+	&dev_attr_reg.attr,
+	&dev_attr_fast_calibration_x.attr,
+	&dev_attr_fast_calibration_y.attr,
+	&dev_attr_fast_calibration_z.attr,
+	&dev_attr_fifo_mode.attr,
+	&dev_attr_fifo_framecount.attr,
+	&dev_attr_fifo_trig.attr,
+	&dev_attr_fifo_trig_src.attr,
+	&dev_attr_fifo_data_sel.attr,
+	&dev_attr_fifo_data_frame.attr,
+	&dev_attr_chip_id.attr,
+	&dev_attr_offset_x.attr,
+	&dev_attr_offset_y.attr,
+	&dev_attr_offset_z.attr,
+	&dev_attr_enable_int.attr,
+	&dev_attr_enable_timer.attr,
+	&dev_attr_debug_level.attr,
+	&dev_attr_int_mode.attr,
+	&dev_attr_slope_duration.attr,
+	&dev_attr_slope_threshold.attr,
+	&dev_attr_slope_no_mot_duration.attr,
+	&dev_attr_slope_no_mot_threshold.attr,
+	&dev_attr_high_g_duration.attr,
+	&dev_attr_high_g_threshold.attr,
+	&dev_attr_low_g_duration.attr,
+	&dev_attr_low_g_threshold.attr,
+	&dev_attr_tap_threshold.attr,
+	&dev_attr_tap_duration.attr,
+	&dev_attr_tap_quiet.attr,
+	&dev_attr_tap_shock.attr,
+	&dev_attr_tap_samp.attr,
+	&dev_attr_orient_mbl_mode.attr,
+	&dev_attr_orient_mbl_blocking.attr,
+	&dev_attr_orient_mbl_hyst.attr,
+	&dev_attr_orient_mbl_theta.attr,
+	&dev_attr_flat_theta.attr,
+	&dev_attr_flat_hold_time.attr,
+	&dev_attr_selftest.attr,
+	&dev_attr_softreset.attr,
+	&dev_attr_temperature.attr,
+	&dev_attr_place.attr,
+	&dev_attr_driver_version.attr,
+#ifdef CONFIG_SIG_MOTION
+	&dev_attr_en_sig_motion.attr,
+#endif
+#ifdef CONFIG_DOUBLE_TAP
+	&dev_attr_en_double_tap.attr,
+#endif
+
+	NULL
+};
+
+static struct attribute_group smi130_acc_attribute_group = {
+	.attrs = smi130_acc_attributes
+};
+
+#ifdef CONFIG_SIG_MOTION
+static struct attribute *smi130_acc_sig_motion_attributes[] = {
+	&dev_attr_slope_duration.attr,
+	&dev_attr_slope_threshold.attr,
+	&dev_attr_en_sig_motion.attr,
+	NULL
+};
+static struct attribute_group smi130_acc_sig_motion_attribute_group = {
+	.attrs = smi130_acc_sig_motion_attributes
+};
+#endif
+
+#ifdef CONFIG_DOUBLE_TAP
+static struct attribute *smi130_acc_double_tap_attributes[] = {
+	&dev_attr_tap_threshold.attr,
+	&dev_attr_tap_duration.attr,
+	&dev_attr_tap_quiet.attr,
+	&dev_attr_tap_shock.attr,
+	&dev_attr_tap_samp.attr,
+	&dev_attr_tap_time_period.attr,
+	&dev_attr_en_double_tap.attr,
+	NULL
+};
+static struct attribute_group smi130_acc_double_tap_attribute_group = {
+	.attrs = smi130_acc_double_tap_attributes
+};
+#endif
+
+
+#if defined(SMI_ACC2X2_ENABLE_INT1) || defined(SMI_ACC2X2_ENABLE_INT2)
+unsigned char *orient_mbl[] = {"upward looking portrait upright",
+	"upward looking portrait upside-down",
+		"upward looking landscape left",
+		"upward looking landscape right",
+		"downward looking portrait upright",
+		"downward looking portrait upside-down",
+		"downward looking landscape left",
+		"downward looking landscape right"};
+
+
+static void smi130_acc_high_g_interrupt_handle(struct smi130_acc_data *smi130_acc)
+{
+	unsigned char first_value = 0;
+	unsigned char sign_value = 0;
+	int i;
+
+	for (i = 0; i < 3; i++) {
+		smi130_acc_get_HIGH_first(smi130_acc->smi130_acc_client, i, &first_value);
+		if (first_value == 1) {
+			smi130_acc_get_HIGH_sign(smi130_acc->smi130_acc_client,
+								&sign_value);
+			if (sign_value == 1) {
+				if (i == 0)
+					input_report_rel(smi130_acc->dev_interrupt,
+							HIGH_G_INTERRUPT,
+							HIGH_G_INTERRUPT_X_N);
+				if (i == 1)
+					input_report_rel(smi130_acc->dev_interrupt,
+							HIGH_G_INTERRUPT,
+							HIGH_G_INTERRUPT_Y_N);
+				if (i == 2)
+					input_report_rel(smi130_acc->dev_interrupt,
+							HIGH_G_INTERRUPT,
+							HIGH_G_INTERRUPT_Z_N);
+			} else {
+				if (i == 0)
+					input_report_rel(smi130_acc->dev_interrupt,
+							HIGH_G_INTERRUPT,
+							HIGH_G_INTERRUPT_X);
+				if (i == 1)
+					input_report_rel(smi130_acc->dev_interrupt,
+							HIGH_G_INTERRUPT,
+							HIGH_G_INTERRUPT_Y);
+				if (i == 2)
+					input_report_rel(smi130_acc->dev_interrupt,
+							HIGH_G_INTERRUPT,
+							HIGH_G_INTERRUPT_Z);
+			}
+		}
+
+		PINFO("High G interrupt happened,exis is %d,\n\n"
+					"first is %d,sign is %d\n", i,
+						first_value, sign_value);
+	}
+
+
+}
+
+#ifndef CONFIG_SIG_MOTION
+static void smi130_acc_slope_interrupt_handle(struct smi130_acc_data *smi130_acc)
+{
+	unsigned char first_value = 0;
+	unsigned char sign_value = 0;
+	int i;
+	for (i = 0; i < 3; i++) {
+		smi130_acc_get_slope_first(smi130_acc->smi130_acc_client, i, &first_value);
+		if (first_value == 1) {
+			smi130_acc_get_slope_sign(smi130_acc->smi130_acc_client,
+								&sign_value);
+			if (sign_value == 1) {
+				if (i == 0)
+					input_report_rel(smi130_acc->dev_interrupt,
+							SLOP_INTERRUPT,
+							SLOPE_INTERRUPT_X_N);
+				if (i == 1)
+					input_report_rel(smi130_acc->dev_interrupt,
+							SLOP_INTERRUPT,
+							SLOPE_INTERRUPT_Y_N);
+				if (i == 2)
+					input_report_rel(smi130_acc->dev_interrupt,
+							SLOP_INTERRUPT,
+							SLOPE_INTERRUPT_Z_N);
+			} else {
+				if (i == 0)
+					input_report_rel(smi130_acc->dev_interrupt,
+							SLOP_INTERRUPT,
+							SLOPE_INTERRUPT_X);
+				if (i == 1)
+					input_report_rel(smi130_acc->dev_interrupt,
+							SLOP_INTERRUPT,
+							SLOPE_INTERRUPT_Y);
+				if (i == 2)
+					input_report_rel(smi130_acc->dev_interrupt,
+							SLOP_INTERRUPT,
+							SLOPE_INTERRUPT_Z);
+
+			}
+		}
+
+		PINFO("Slop interrupt happened,exis is %d,\n\n"
+					"first is %d,sign is %d\n", i,
+						first_value, sign_value);
+	}
+}
+#endif
+
+static void smi130_acc_irq_work_func(struct work_struct *work)
+{
+	struct smi130_acc_data *smi130_acc = container_of((struct work_struct *)work,
+			struct smi130_acc_data, irq_work);
+#ifdef CONFIG_DOUBLE_TAP
+	struct i2c_client *client = smi130_acc->smi130_acc_client;
+#endif
+
+	unsigned char status = 0;
+	unsigned char first_value = 0;
+	unsigned char sign_value = 0;
+
+#ifdef CONFIG_SMI_ACC_ENABLE_NEWDATA_INT
+	static struct smi130_accacc acc;
+	struct timespec ts;
+	/*
+	do not use this function judge new data interrupt
+	smi130_acc_get_interruptstatus2(smi130_acc->smi130_acc_client, &status);
+	use the
+	x-axis value bit new_data_x
+	y-axis value bit new_data_y
+	z-axis value bit new_data_z
+	judge if this is the new data
+	*/
+	/* PINFO("New data interrupt happened\n");*/
+	smi130_acc_read_accel_xyz(smi130_acc->smi130_acc_client,
+				smi130_acc->sensor_type, &acc);
+	ts = ns_to_timespec(smi130_acc->timestamp);
+	//if ((acc.x & SMI_ACC2X2_NEW_DATA_X__MSK) &&
+	//	(acc.y & SMI_ACC2X2_NEW_DATA_Y__MSK) &&
+	//	(acc.x & SMI_ACC2X2_NEW_DATA_Z__MSK))
+	{
+		input_event(smi130_acc->input, EV_MSC, MSC_TIME,
+			ts.tv_sec);
+		input_event(smi130_acc->input, EV_MSC, MSC_TIME,
+			ts.tv_nsec);
+		input_event(smi130_acc->input, EV_MSC,
+			MSC_GESTURE, acc.x);
+		input_event(smi130_acc->input, EV_MSC,
+			MSC_RAW, acc.y);
+		input_event(smi130_acc->input, EV_MSC,
+			MSC_SCAN, acc.z);
+		input_sync(smi130_acc->input);
+		mutex_lock(&smi130_acc->value_mutex);
+		smi130_acc->value = acc;
+		mutex_unlock(&smi130_acc->value_mutex);
+	}
+#endif
+
+	smi130_acc_get_interruptstatus1(smi130_acc->smi130_acc_client, &status);
+	PINFO("smi130_acc_irq_work_func, status = 0x%x\n", status);
+
+#ifdef CONFIG_SIG_MOTION
+	if (status & 0x04)	{
+		if (atomic_read(&smi130_acc->en_sig_motion) == 1) {
+			PINFO("Significant motion interrupt happened\n");
+			/* close sig sensor,
+			it will be open again if APP wants */
+			smi130_acc_set_en_sig_motion(smi130_acc, 0);
+
+			input_report_rel(smi130_acc->dev_interrupt,
+				SLOP_INTERRUPT, 1);
+			input_sync(smi130_acc->dev_interrupt);
+		}
+	}
+#endif
+
+#ifdef CONFIG_DOUBLE_TAP
+	if (status & 0x20) {
+		if (atomic_read(&smi130_acc->en_double_tap) == 1) {
+			PINFO("single tap interrupt happened\n");
+			smi130_acc_set_Int_Enable(client, 8, 0);
+			if (smi130_acc->tap_times == 0)	{
+				mod_timer(&smi130_acc->tap_timer, jiffies +
+				msecs_to_jiffies(smi130_acc->tap_time_period));
+				smi130_acc->tap_times = 1;
+			} else {
+				/* only double tap is judged */
+				PINFO("double tap\n");
+				mutex_lock(&smi130_acc->tap_mutex);
+				smi130_acc->tap_times = 0;
+				del_timer(&smi130_acc->tap_timer);
+				mutex_unlock(&smi130_acc->tap_mutex);
+				input_report_rel(smi130_acc->dev_interrupt,
+					DOUBLE_TAP_INTERRUPT,
+					DOUBLE_TAP_INTERRUPT_HAPPENED);
+				input_sync(smi130_acc->dev_interrupt);
+			}
+			smi130_acc_set_Int_Enable(client, 8, 1);
+		}
+	}
+#endif
+
+	switch (status) {
+
+	case 0x01:
+		PINFO("Low G interrupt happened\n");
+		input_report_rel(smi130_acc->dev_interrupt, LOW_G_INTERRUPT,
+				LOW_G_INTERRUPT_HAPPENED);
+		break;
+
+	case 0x02:
+		smi130_acc_high_g_interrupt_handle(smi130_acc);
+		break;
+
+#ifndef CONFIG_SIG_MOTION
+	case 0x04:
+		smi130_acc_slope_interrupt_handle(smi130_acc);
+		break;
+#endif
+
+	case 0x08:
+		PINFO("slow/ no motion interrupt happened\n");
+		input_report_rel(smi130_acc->dev_interrupt,
+			SLOW_NO_MOTION_INTERRUPT,
+			SLOW_NO_MOTION_INTERRUPT_HAPPENED);
+		break;
+
+#ifndef CONFIG_DOUBLE_TAP
+	case 0x10:
+		PINFO("double tap interrupt happened\n");
+		input_report_rel(smi130_acc->dev_interrupt,
+			DOUBLE_TAP_INTERRUPT,
+			DOUBLE_TAP_INTERRUPT_HAPPENED);
+		break;
+	case 0x20:
+		PINFO("single tap interrupt happened\n");
+		input_report_rel(smi130_acc->dev_interrupt,
+			SINGLE_TAP_INTERRUPT,
+			SINGLE_TAP_INTERRUPT_HAPPENED);
+		break;
+#endif
+
+	case 0x40:
+		smi130_acc_get_orient_mbl_status(smi130_acc->smi130_acc_client,
+				    &first_value);
+		PINFO("orient_mbl interrupt happened,%s\n",
+				orient_mbl[first_value]);
+		if (first_value == 0)
+			input_report_abs(smi130_acc->dev_interrupt,
+			ORIENT_INTERRUPT,
+			UPWARD_PORTRAIT_UP_INTERRUPT_HAPPENED);
+		else if (first_value == 1)
+			input_report_abs(smi130_acc->dev_interrupt,
+				ORIENT_INTERRUPT,
+				UPWARD_PORTRAIT_DOWN_INTERRUPT_HAPPENED);
+		else if (first_value == 2)
+			input_report_abs(smi130_acc->dev_interrupt,
+				ORIENT_INTERRUPT,
+				UPWARD_LANDSCAPE_LEFT_INTERRUPT_HAPPENED);
+		else if (first_value == 3)
+			input_report_abs(smi130_acc->dev_interrupt,
+				ORIENT_INTERRUPT,
+				UPWARD_LANDSCAPE_RIGHT_INTERRUPT_HAPPENED);
+		else if (first_value == 4)
+			input_report_abs(smi130_acc->dev_interrupt,
+				ORIENT_INTERRUPT,
+				DOWNWARD_PORTRAIT_UP_INTERRUPT_HAPPENED);
+		else if (first_value == 5)
+			input_report_abs(smi130_acc->dev_interrupt,
+				ORIENT_INTERRUPT,
+				DOWNWARD_PORTRAIT_DOWN_INTERRUPT_HAPPENED);
+		else if (first_value == 6)
+			input_report_abs(smi130_acc->dev_interrupt,
+				ORIENT_INTERRUPT,
+				DOWNWARD_LANDSCAPE_LEFT_INTERRUPT_HAPPENED);
+		else if (first_value == 7)
+			input_report_abs(smi130_acc->dev_interrupt,
+				ORIENT_INTERRUPT,
+				DOWNWARD_LANDSCAPE_RIGHT_INTERRUPT_HAPPENED);
+		break;
+	case 0x80:
+		smi130_acc_get_orient_mbl_flat_status(smi130_acc->smi130_acc_client,
+				    &sign_value);
+		PINFO("flat interrupt happened,flat status is %d\n",
+				    sign_value);
+		if (sign_value == 1) {
+			input_report_abs(smi130_acc->dev_interrupt,
+				FLAT_INTERRUPT,
+				FLAT_INTERRUPT_TURE_HAPPENED);
+		} else {
+			input_report_abs(smi130_acc->dev_interrupt,
+				FLAT_INTERRUPT,
+				FLAT_INTERRUPT_FALSE_HAPPENED);
+		}
+		break;
+
+	default:
+		break;
+	}
+}
+
+static irqreturn_t smi130_acc_irq_handler(int irq, void *handle)
+{
+	struct smi130_acc_data *data = handle;
+
+	if (data == NULL)
+		return IRQ_HANDLED;
+	if (data->smi130_acc_client == NULL)
+		return IRQ_HANDLED;
+	data->timestamp = smi130_acc_get_alarm_timestamp();
+
+	schedule_work(&data->irq_work);
+
+	return IRQ_HANDLED;
+}
+#endif /* defined(SMI_ACC2X2_ENABLE_INT1)||defined(SMI_ACC2X2_ENABLE_INT2) */
+
+
+static int smi130_acc_probe(struct i2c_client *client,
+		const struct i2c_device_id *id)
+{
+	int err = 0;
+	struct smi130_acc_data *data;
+	struct input_dev *dev;
+	struct bosch_dev  *dev_acc;
+#if defined(SMI_ACC2X2_ENABLE_INT1) || defined(SMI_ACC2X2_ENABLE_INT2)
+	struct bosch_sensor_specific *pdata;
+#endif
+	struct input_dev *dev_interrupt;
+
+	PINFO("smi130_acc_probe start\n");
+
+	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
+		PERR("i2c_check_functionality error\n");
+		err = -EIO;
+		goto exit;
+	}
+	data = kzalloc(sizeof(struct smi130_acc_data), GFP_KERNEL);
+	if (!data) {
+		err = -ENOMEM;
+		goto exit;
+	}
+
+	/* read and check chip id */
+	if (smi130_acc_check_chip_id(client, data) < 0) {
+		err = -EINVAL;
+		goto kfree_exit;
+	}
+
+	/* do soft reset */
+	smi130_acc_delay(5);
+	if (smi130_acc_soft_reset(client) < 0) {
+		PERR("i2c bus write error, pls check HW connection\n");
+		err = -EINVAL;
+		goto kfree_exit;
+	}
+	smi130_acc_delay(20);
+
+	i2c_set_clientdata(client, data);
+	data->smi130_acc_client = client;
+	mutex_init(&data->value_mutex);
+	mutex_init(&data->mode_mutex);
+	mutex_init(&data->enable_mutex);
+	smi130_acc_set_bandwidth(client, SMI_ACC2X2_BW_SET);
+	smi130_acc_set_range(client, SMI_ACC2X2_RANGE_SET);
+
+#if defined(SMI_ACC2X2_ENABLE_INT1) || defined(SMI_ACC2X2_ENABLE_INT2)
+
+	pdata = client->dev.platform_data;
+	if (pdata) {
+		if (pdata->irq_gpio_cfg && (pdata->irq_gpio_cfg() < 0)) {
+			PERR("IRQ GPIO conf. error %d\n",
+				client->irq);
+		}
+	}
+
+#ifdef SMI_ACC2X2_ENABLE_INT1
+	/* maps interrupt to INT1 pin */
+	smi130_acc_set_int1_pad_sel(client, PAD_LOWG);
+	smi130_acc_set_int1_pad_sel(client, PAD_HIGHG);
+	smi130_acc_set_int1_pad_sel(client, PAD_SLOP);
+	smi130_acc_set_int1_pad_sel(client, PAD_DOUBLE_TAP);
+	smi130_acc_set_int1_pad_sel(client, PAD_SINGLE_TAP);
+	smi130_acc_set_int1_pad_sel(client, PAD_ORIENT);
+	smi130_acc_set_int1_pad_sel(client, PAD_FLAT);
+	smi130_acc_set_int1_pad_sel(client, PAD_SLOW_NO_MOTION);
+#ifdef CONFIG_SMI_ACC_ENABLE_NEWDATA_INT
+	smi130_acc_set_newdata(client, SMI_ACC2X2_INT1_NDATA, 1);
+	smi130_acc_set_newdata(client, SMI_ACC2X2_INT2_NDATA, 0);
+#endif
+#endif
+
+#ifdef SMI_ACC2X2_ENABLE_INT2
+	/* maps interrupt to INT2 pin */
+	smi130_acc_set_int2_pad_sel(client, PAD_LOWG);
+	smi130_acc_set_int2_pad_sel(client, PAD_HIGHG);
+	smi130_acc_set_int2_pad_sel(client, PAD_SLOP);
+	smi130_acc_set_int2_pad_sel(client, PAD_DOUBLE_TAP);
+	smi130_acc_set_int2_pad_sel(client, PAD_SINGLE_TAP);
+	smi130_acc_set_int2_pad_sel(client, PAD_ORIENT);
+	smi130_acc_set_int2_pad_sel(client, PAD_FLAT);
+	smi130_acc_set_int2_pad_sel(client, PAD_SLOW_NO_MOTION);
+#ifdef CONFIG_SMI_ACC_ENABLE_NEWDATA_INT
+	smi130_acc_set_newdata(client, SMI_ACC2X2_INT1_NDATA, 0);
+	smi130_acc_set_newdata(client, SMI_ACC2X2_INT2_NDATA, 1);
+#endif
+#endif
+
+	smi130_acc_set_Int_Mode(client, 1);/*latch interrupt 250ms*/
+
+	/* do not open any interrupt here  */
+	/*10,orient_mbl
+	11,flat*/
+	/* smi130_acc_set_Int_Enable(client, 10, 1);	*/
+	/* smi130_acc_set_Int_Enable(client, 11, 1); */
+
+#ifdef CONFIG_SMI_ACC_ENABLE_NEWDATA_INT
+	/* enable new data interrupt */
+	smi130_acc_set_Int_Enable(client, 4, 1);
+#endif
+
+#ifdef CONFIG_SIG_MOTION
+	enable_irq_wake(data->IRQ);
+#endif
+	if (err)
+		PERR("could not request irq\n");
+
+	INIT_WORK(&data->irq_work, smi130_acc_irq_work_func);
+#endif
+
+#ifndef CONFIG_SMI_ACC_ENABLE_NEWDATA_INT
+	INIT_DELAYED_WORK(&data->work, smi130_acc_work_func);
+#endif
+	atomic_set(&data->delay, SMI_ACC2X2_MAX_DELAY);
+	atomic_set(&data->enable, 0);
+
+	dev = input_allocate_device();
+	if (!dev)
+		return -ENOMEM;
+
+	dev_interrupt = input_allocate_device();
+	if (!dev_interrupt) {
+		kfree(data);
+		input_free_device(dev); /*free the successful dev and return*/
+		return -ENOMEM;
+	}
+
+	/* only value events reported */
+	dev->name = SENSOR_NAME;
+	dev->id.bustype = BUS_I2C;
+	input_set_capability(dev, EV_ABS, ABS_MISC);
+	input_set_abs_params(dev, ABS_X, ABSMIN, ABSMAX, 0, 0);
+	input_set_abs_params(dev, ABS_Y, ABSMIN, ABSMAX, 0, 0);
+	input_set_abs_params(dev, ABS_Z, ABSMIN, ABSMAX, 0, 0);
+	input_set_capability(dev, EV_MSC, MSC_GESTURE);
+	input_set_capability(dev, EV_MSC, MSC_RAW);
+	input_set_capability(dev, EV_MSC, MSC_SCAN);
+	input_set_capability(dev, EV_MSC, MSC_TIME);
+	input_set_drvdata(dev, data);
+	err = input_register_device(dev);
+	if (err < 0)
+		goto err_register_input_device;
+
+	/* all interrupt generated events are moved to interrupt input devices*/
+	dev_interrupt->name = "smi_acc_interrupt";
+	dev_interrupt->id.bustype = BUS_I2C;
+	input_set_capability(dev_interrupt, EV_REL,
+		SLOW_NO_MOTION_INTERRUPT);
+	input_set_capability(dev_interrupt, EV_REL,
+		LOW_G_INTERRUPT);
+	input_set_capability(dev_interrupt, EV_REL,
+		HIGH_G_INTERRUPT);
+	input_set_capability(dev_interrupt, EV_REL,
+		SLOP_INTERRUPT);
+	input_set_capability(dev_interrupt, EV_REL,
+		DOUBLE_TAP_INTERRUPT);
+	input_set_capability(dev_interrupt, EV_REL,
+		SINGLE_TAP_INTERRUPT);
+	input_set_capability(dev_interrupt, EV_ABS,
+		ORIENT_INTERRUPT);
+	input_set_capability(dev_interrupt, EV_ABS,
+		FLAT_INTERRUPT);
+	input_set_drvdata(dev_interrupt, data);
+
+	err = input_register_device(dev_interrupt);
+	if (err < 0)
+		goto err_register_input_device_interrupt;
+
+	data->dev_interrupt = dev_interrupt;
+	data->input = dev;
+
+#ifdef CONFIG_SIG_MOTION
+	data->g_sensor_class = class_create(THIS_MODULE, "sig_sensor");
+	if (IS_ERR(data->g_sensor_class)) {
+		err = PTR_ERR(data->g_sensor_class);
+		data->g_sensor_class = NULL;
+		PERR("could not allocate g_sensor_class\n");
+		goto err_create_class;
+	}
+
+	data->g_sensor_dev = device_create(data->g_sensor_class,
+				NULL, 0, "%s", "g_sensor");
+	if (unlikely(IS_ERR(data->g_sensor_dev))) {
+		err = PTR_ERR(data->g_sensor_dev);
+		data->g_sensor_dev = NULL;
+
+		PERR("could not allocate g_sensor_dev\n");
+		goto err_create_g_sensor_device;
+	}
+
+	dev_set_drvdata(data->g_sensor_dev, data);
+
+	err = sysfs_create_group(&data->g_sensor_dev->kobj,
+			&smi130_acc_sig_motion_attribute_group);
+	if (err < 0)
+		goto error_sysfs;
+#endif
+
+#ifdef CONFIG_DOUBLE_TAP
+	data->g_sensor_class_doubletap =
+		class_create(THIS_MODULE, "dtap_sensor");
+	if (IS_ERR(data->g_sensor_class_doubletap)) {
+		err = PTR_ERR(data->g_sensor_class_doubletap);
+		data->g_sensor_class_doubletap = NULL;
+		PERR("could not allocate g_sensor_class_doubletap\n");
+		goto err_create_class;
+	}
+
+	data->g_sensor_dev_doubletap = device_create(
+				data->g_sensor_class_doubletap,
+				NULL, 0, "%s", "g_sensor");
+	if (unlikely(IS_ERR(data->g_sensor_dev_doubletap))) {
+		err = PTR_ERR(data->g_sensor_dev_doubletap);
+		data->g_sensor_dev_doubletap = NULL;
+
+		PERR("could not allocate g_sensor_dev_doubletap\n");
+		goto err_create_g_sensor_device_double_tap;
+	}
+
+	dev_set_drvdata(data->g_sensor_dev_doubletap, data);
+
+	err = sysfs_create_group(&data->g_sensor_dev_doubletap->kobj,
+			&smi130_acc_double_tap_attribute_group);
+	if (err < 0)
+		goto error_sysfs;
+#endif
+
+	err = sysfs_create_group(&data->input->dev.kobj,
+			&smi130_acc_attribute_group);
+	if (err < 0)
+		goto error_sysfs;
+
+	dev_acc = bosch_allocate_device();
+	if (!dev_acc) {
+		err = -ENOMEM;
+		goto error_sysfs;
+	}
+	dev_acc->name = ACC_NAME;
+
+	bosch_set_drvdata(dev_acc, data);
+
+	err = bosch_register_device(dev_acc);
+	if (err < 0)
+		goto bosch_free_acc_exit;
+
+	data->bosch_acc = dev_acc;
+	err = sysfs_create_group(&data->bosch_acc->dev.kobj,
+			&smi130_acc_attribute_group);
+
+	if (err < 0)
+		goto bosch_free_exit;
+
+	if (NULL != client->dev.platform_data) {
+		data->bosch_pd = kzalloc(sizeof(*data->bosch_pd),
+				GFP_KERNEL);
+
+		if (NULL != data->bosch_pd) {
+			memcpy(data->bosch_pd, client->dev.platform_data,
+					sizeof(*data->bosch_pd));
+			PINFO("%s sensor driver set place: p%d",
+				data->bosch_pd->name, data->bosch_pd->place);
+		}
+	}
+
+#ifdef CONFIG_HAS_EARLYSUSPEND
+	data->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
+	data->early_suspend.suspend = smi130_acc_early_suspend;
+	data->early_suspend.resume = smi130_acc_late_resume;
+	register_early_suspend(&data->early_suspend);
+#endif
+	INIT_WORK(&data->report_data_work,
+	smi130_acc_timer_work_fun);
+	reportdata_wq = create_singlethread_workqueue("smi130_acc_wq");
+	if (NULL == reportdata_wq)
+		PERR("fail to create the reportdta_wq");
+	hrtimer_init(&data->timer, CLOCK_MONOTONIC,
+		HRTIMER_MODE_REL);
+	data->timer.function = reportdata_timer_fun;
+	data->work_delay_kt = ns_to_ktime(4000000);
+	data->is_timer_running = 0;
+	data->timestamp = 0;
+	data->time_odr = 4000000;/*default bandwidth 125HZ*/
+	data->smi_acc_mode_enabled = 0;
+	data->fifo_datasel = 0;
+	data->fifo_count = 0;
+	data->acc_count = 0;
+
+#ifdef CONFIG_SIG_MOTION
+	atomic_set(&data->en_sig_motion, 0);
+#endif
+#ifdef CONFIG_DOUBLE_TAP
+	atomic_set(&data->en_double_tap, 0);
+	data->tap_times = 0;
+	data->tap_time_period = DEFAULT_TAP_JUDGE_PERIOD;
+	mutex_init(&data->tap_mutex);
+	setup_timer(&data->tap_timer, smi130_acc_tap_timeout_handle,
+			(unsigned long)data);
+#endif
+	if (smi130_acc_set_mode(client, SMI_ACC2X2_MODE_SUSPEND, SMI_ACC_ENABLED_ALL) < 0)
+		return -EINVAL;
+	data->IRQ = client->irq;
+	PDEBUG("data->IRQ = %d", data->IRQ);
+	err = request_irq(data->IRQ, smi130_acc_irq_handler, IRQF_TRIGGER_RISING,
+			"smi130_acc", data);
+	PINFO("SMI130_ACC driver probe successfully");
+
+	return 0;
+
+bosch_free_exit:
+	bosch_unregister_device(dev_acc);
+
+bosch_free_acc_exit:
+	bosch_free_device(dev_acc);
+
+error_sysfs:
+	input_unregister_device(data->input);
+
+#ifdef CONFIG_DOUBLE_TAP
+err_create_g_sensor_device_double_tap:
+	class_destroy(data->g_sensor_class_doubletap);
+#endif
+
+#ifdef CONFIG_SIG_MOTION
+err_create_g_sensor_device:
+	class_destroy(data->g_sensor_class);
+#endif
+
+#if defined(CONFIG_SIG_MOTION) || defined(CONFIG_DOUBLE_TAP)
+err_create_class:
+	input_unregister_device(data->dev_interrupt);
+#endif
+
+err_register_input_device_interrupt:
+	input_free_device(dev_interrupt);
+	input_unregister_device(data->input);
+
+err_register_input_device:
+	input_free_device(dev);
+
+kfree_exit:
+	if ((NULL != data) && (NULL != data->bosch_pd)) {
+		kfree(data->bosch_pd);
+		data->bosch_pd = NULL;
+	}
+	kfree(data);
+exit:
+	return err;
+}
+
+#ifdef CONFIG_HAS_EARLYSUSPEND
+static void smi130_acc_early_suspend(struct early_suspend *h)
+{
+	struct smi130_acc_data *data =
+		container_of(h, struct smi130_acc_data, early_suspend);
+
+	mutex_lock(&data->enable_mutex);
+	if (atomic_read(&data->enable) == 1) {
+		smi130_acc_set_mode(data->smi130_acc_client,
+			SMI_ACC2X2_MODE_SUSPEND, SMI_ACC_ENABLED_INPUT);
+#ifndef CONFIG_SMI_ACC_ENABLE_NEWDATA_INT
+		cancel_delayed_work_sync(&data->work);
+#endif
+	}
+	if (data->is_timer_running) {
+		/*diable fifo_mode when close timer*/
+		if (smi130_acc_set_fifo_mode(data->smi130_acc_client, 0) < 0)
+			PERR("set fifo_mode falied");
+		hrtimer_cancel(&data->timer);
+		data->base_time = 0;
+		data->timestamp = 0;
+		data->fifo_time = 0;
+		data->acc_count = 0;
+	}
+	mutex_unlock(&data->enable_mutex);
+}
+
+static void smi130_acc_late_resume(struct early_suspend *h)
+{
+	struct smi130_acc_data *data =
+		container_of(h, struct smi130_acc_data, early_suspend);
+	if (NULL == data)
+		return;
+
+	mutex_lock(&data->enable_mutex);
+	if (atomic_read(&data->enable) == 1) {
+		smi130_acc_set_mode(data->smi130_acc_client,
+			SMI_ACC2X2_MODE_NORMAL, SMI_ACC_ENABLED_INPUT);
+#ifndef CONFIG_SMI_ACC_ENABLE_NEWDATA_INT
+		schedule_delayed_work(&data->work,
+				msecs_to_jiffies(atomic_read(&data->delay)));
+#endif
+	}
+	if (data->is_timer_running) {
+		hrtimer_start(&data->timer,
+					ns_to_ktime(data->time_odr),
+			HRTIMER_MODE_REL);
+		/*enable fifo_mode when init*/
+		if (smi130_acc_set_fifo_mode(data->smi130_acc_client, 2) < 0)
+			PERR("set fifo_mode falied");
+		data->base_time = 0;
+		data->timestamp = 0;
+		data->is_timer_running = 1;
+		data->acc_count = 0;
+	}
+	mutex_unlock(&data->enable_mutex);
+}
+#endif
+
+static int smi130_acc_remove(struct i2c_client *client)
+{
+	struct smi130_acc_data *data = i2c_get_clientdata(client);
+
+	if (NULL == data)
+		return 0;
+
+	smi130_acc_set_enable(&client->dev, 0);
+#ifdef CONFIG_HAS_EARLYSUSPEND
+	unregister_early_suspend(&data->early_suspend);
+#endif
+	sysfs_remove_group(&data->input->dev.kobj, &smi130_acc_attribute_group);
+	input_unregister_device(data->input);
+
+	if (NULL != data->bosch_pd) {
+		kfree(data->bosch_pd);
+		data->bosch_pd = NULL;
+	}
+
+	kfree(data);
+	return 0;
+}
+
+void smi130_acc_shutdown(struct i2c_client *client)
+{
+	struct smi130_acc_data *data = i2c_get_clientdata(client);
+
+	mutex_lock(&data->enable_mutex);
+	smi130_acc_set_mode(data->smi130_acc_client,
+		SMI_ACC2X2_MODE_DEEP_SUSPEND, SMI_ACC_ENABLED_ALL);
+	mutex_unlock(&data->enable_mutex);
+}
+
+#ifdef CONFIG_PM
+static int smi130_acc_suspend(struct i2c_client *client, pm_message_t mesg)
+{
+	struct smi130_acc_data *data = i2c_get_clientdata(client);
+
+	mutex_lock(&data->enable_mutex);
+	if (atomic_read(&data->enable) == 1) {
+		smi130_acc_set_mode(data->smi130_acc_client,
+			SMI_ACC2X2_MODE_SUSPEND, SMI_ACC_ENABLED_INPUT);
+#ifndef CONFIG_SMI_ACC_ENABLE_NEWDATA_INT
+		cancel_delayed_work_sync(&data->work);
+#endif
+	}
+	if (data->is_timer_running) {
+		hrtimer_cancel(&data->timer);
+		data->base_time = 0;
+		data->timestamp = 0;
+		data->fifo_time = 0;
+		data->acc_count = 0;
+	}
+	mutex_unlock(&data->enable_mutex);
+
+	return 0;
+}
+
+static int smi130_acc_resume(struct i2c_client *client)
+{
+	struct smi130_acc_data *data = i2c_get_clientdata(client);
+
+	mutex_lock(&data->enable_mutex);
+	if (atomic_read(&data->enable) == 1) {
+		smi130_acc_set_mode(data->smi130_acc_client,
+			SMI_ACC2X2_MODE_NORMAL, SMI_ACC_ENABLED_INPUT);
+#ifndef CONFIG_SMI_ACC_ENABLE_NEWDATA_INT
+		schedule_delayed_work(&data->work,
+				msecs_to_jiffies(atomic_read(&data->delay)));
+#endif
+	}
+	if (data->is_timer_running) {
+		hrtimer_start(&data->timer,
+					ns_to_ktime(data->time_odr),
+			HRTIMER_MODE_REL);
+		data->base_time = 0;
+		data->timestamp = 0;
+		data->is_timer_running = 1;
+	}
+	mutex_unlock(&data->enable_mutex);
+
+	return 0;
+}
+
+#else
+
+#define smi130_acc_suspend      NULL
+#define smi130_acc_resume       NULL
+
+#endif /* CONFIG_PM */
+
+static const struct i2c_device_id smi130_acc_id[] = {
+	{ SENSOR_NAME, 0 },
+	{ }
+};
+
+MODULE_DEVICE_TABLE(i2c, smi130_acc_id);
+static const struct of_device_id smi130_acc_of_match[] = {
+	{ .compatible = "smi130_acc", },
+	{ }
+};
+MODULE_DEVICE_TABLE(i2c, smi130_acc_of_match);
+
+static struct i2c_driver smi130_acc_driver = {
+	.driver = {
+		.owner  = THIS_MODULE,
+		.name   = SENSOR_NAME,
+		.of_match_table = smi130_acc_of_match,
+	},
+	//.suspend    = smi130_acc_suspend,
+	//.resume     = smi130_acc_resume,
+	.id_table   = smi130_acc_id,
+	.probe      = smi130_acc_probe,
+	.remove     = smi130_acc_remove,
+	.shutdown   = smi130_acc_shutdown,
+};
+
+static int __init SMI_ACC2X2_init(void)
+{
+	return i2c_add_driver(&smi130_acc_driver);
+}
+
+static void __exit SMI_ACC2X2_exit(void)
+{
+	i2c_del_driver(&smi130_acc_driver);
+}
+
+MODULE_AUTHOR("contact@bosch-sensortec.com");
+MODULE_DESCRIPTION("SMI_ACC2X2 ACCELEROMETER SENSOR DRIVER");
+MODULE_LICENSE("GPL v2");
+
+module_init(SMI_ACC2X2_init);
+module_exit(SMI_ACC2X2_exit);
+
diff --git a/drivers/input/sensors/smi130/smi130_driver.c b/drivers/input/sensors/smi130/smi130_driver.c
new file mode 100644
index 0000000..42a0a57
--- /dev/null
+++ b/drivers/input/sensors/smi130/smi130_driver.c
@@ -0,0 +1,4121 @@
+/*!
+ * @section LICENSE
+ * (C) Copyright 2011~2016 Bosch Sensortec GmbH All Rights Reserved
+ *
+ * (C) Modification Copyright 2018 Robert Bosch Kft  All Rights Reserved
+ *
+ * This software program is licensed subject to the GNU General
+ * Public License (GPL).Version 2,June 1991,
+ * available at http://www.fsf.org/copyleft/gpl.html
+ *
+ * Special: Description of the Software:
+ *
+ * This software module (hereinafter called "Software") and any
+ * information on application-sheets (hereinafter called "Information") is
+ * provided free of charge for the sole purpose to support your application
+ * work. 
+ *
+ * As such, the Software is merely an experimental software, not tested for
+ * safety in the field and only intended for inspiration for further development 
+ * and testing. Any usage in a safety-relevant field of use (like automotive,
+ * seafaring, spacefaring, industrial plants etc.) was not intended, so there are
+ * no precautions for such usage incorporated in the Software.
+ * 
+ * The Software is specifically designed for the exclusive use for Bosch
+ * Sensortec products by personnel who have special experience and training. Do
+ * not use this Software if you do not have the proper experience or training.
+ * 
+ * This Software package is provided as is and without any expressed or
+ * implied warranties, including without limitation, the implied warranties of
+ * merchantability and fitness for a particular purpose.
+ * 
+ * Bosch Sensortec and their representatives and agents deny any liability for
+ * the functional impairment of this Software in terms of fitness, performance
+ * and safety. Bosch Sensortec and their representatives and agents shall not be
+ * liable for any direct or indirect damages or injury, except as otherwise
+ * stipulated in mandatory applicable law.
+ * The Information provided is believed to be accurate and reliable. Bosch
+ * Sensortec assumes no responsibility for the consequences of use of such
+ * Information nor for any infringement of patents or other rights of third
+ * parties which may result from its use.
+ * 
+ *------------------------------------------------------------------------------
+ * The following Product Disclaimer does not apply to the BSX4-HAL-4.1NoFusion Software 
+ * which is licensed under the Apache License, Version 2.0 as stated above.  
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Product Disclaimer
+ *
+ * Common:
+ *
+ * Assessment of Products Returned from Field
+ *
+ * Returned products are considered good if they fulfill the specifications / 
+ * test data for 0-mileage and field listed in this document.
+ *
+ * Engineering Samples
+ * 
+ * Engineering samples are marked with (e) or (E). Samples may vary from the
+ * valid technical specifications of the series product contained in this
+ * data sheet. Therefore, they are not intended or fit for resale to
+ * third parties or for use in end products. Their sole purpose is internal
+ * client testing. The testing of an engineering sample may in no way replace
+ * the testing of a series product. Bosch assumes no liability for the use
+ * of engineering samples. The purchaser shall indemnify Bosch from all claims
+ * arising from the use of engineering samples.
+ *
+ * Intended use
+ *
+ * Provided that SMI130 is used within the conditions (environment, application,
+ * installation, loads) as described in this TCD and the corresponding
+ * agreed upon documents, Bosch ensures that the product complies with
+ * the agreed properties. Agreements beyond this require
+ * the written approval by Bosch. The product is considered fit for the intended
+ * use when the product successfully has passed the tests
+ * in accordance with the TCD and agreed upon documents.
+ *
+ * It is the responsibility of the customer to ensure the proper application
+ * of the product in the overall system/vehicle.
+ *
+ * Bosch does not assume any responsibility for changes to the environment
+ * of the product that deviate from the TCD and the agreed upon documents 
+ * as well as all applications not released by Bosch
+  *
+ * The resale and/or use of products are at the purchaser’s own risk and 
+ * responsibility. The examination and testing of the SMI130 
+ * is the sole responsibility of the purchaser.
+ *
+ * The purchaser shall indemnify Bosch from all third party claims 
+ * arising from any product use not covered by the parameters of 
+ * this product data sheet or not approved by Bosch and reimburse Bosch 
+ * for all costs and damages in connection with such claims.
+ *
+ * The purchaser must monitor the market for the purchased products,
+ * particularly with regard to product safety, and inform Bosch without delay
+ * of all security relevant incidents.
+ *
+ * Application Examples and Hints
+ *
+ * With respect to any application examples, advice, normal values
+ * and/or any information regarding the application of the device,
+ * Bosch hereby disclaims any and all warranties and liabilities of any kind,
+ * including without limitation warranties of
+ * non-infringement of intellectual property rights or copyrights
+ * of any third party.
+ * The information given in this document shall in no event be regarded 
+ * as a guarantee of conditions or characteristics. They are provided
+ * for illustrative purposes only and no evaluation regarding infringement
+ * of intellectual property rights or copyrights or regarding functionality,
+ * performance or error has been made.
+ *
+ * @filename smi130_driver.c
+ * @date     2016/08/01 14:40
+ * @Modification Date 2018/08/28 18:20
+ * @id       "b5ff23a"
+ * @version  1.3
+ *
+ * @brief
+ * The core code of SMI130 device driver
+ *
+ * @detail
+ * This file implements the core code of SMI130 device driver,
+ * which includes hardware related functions, input device register,
+ * device attribute files, etc.
+*/
+
+#include "smi130.h"
+#include "smi130_driver.h"
+#include <linux/device.h>
+#include <linux/gpio.h>
+#include <linux/of_gpio.h>
+#include <linux/of_irq.h>
+
+
+#define DRIVER_VERSION "0.0.53.0"
+#define I2C_BURST_READ_MAX_LEN      (256)
+#define SMI130_STORE_COUNT  (6000)
+#define LMADA     (1)
+uint64_t g_current_apts_us_mbl;
+
+
+enum SMI_SENSOR_INT_T {
+	/* Interrupt enable0*/
+	SMI_ANYMO_X_INT = 0,
+	SMI_ANYMO_Y_INT,
+	SMI_ANYMO_Z_INT,
+	SMI_D_TAP_INT,
+	SMI_S_TAP_INT,
+	SMI_ORIENT_INT,
+	SMI_FLAT_INT,
+	/* Interrupt enable1*/
+	SMI_HIGH_X_INT,
+	SMI_HIGH_Y_INT,
+	SMI_HIGH_Z_INT,
+	SMI_LOW_INT,
+	SMI_DRDY_INT,
+	SMI_FFULL_INT,
+	SMI_FWM_INT,
+	/* Interrupt enable2 */
+	SMI_NOMOTION_X_INT,
+	SMI_NOMOTION_Y_INT,
+	SMI_NOMOTION_Z_INT,
+	SMI_STEP_DETECTOR_INT,
+	INT_TYPE_MAX
+};
+
+/*smi fifo sensor type combination*/
+enum SMI_SENSOR_FIFO_COMBINATION {
+	SMI_FIFO_A = 0,
+	SMI_FIFO_G,
+	SMI_FIFO_M,
+	SMI_FIFO_G_A,
+	SMI_FIFO_M_A,
+	SMI_FIFO_M_G,
+	SMI_FIFO_M_G_A,
+	SMI_FIFO_COM_MAX
+};
+
+/*smi fifo analyse return err status*/
+enum SMI_FIFO_ANALYSE_RETURN_T {
+	FIFO_OVER_READ_RETURN = -10,
+	FIFO_SENSORTIME_RETURN = -9,
+	FIFO_SKIP_OVER_LEN = -8,
+	FIFO_M_G_A_OVER_LEN = -7,
+	FIFO_M_G_OVER_LEN = -6,
+	FIFO_M_A_OVER_LEN = -5,
+	FIFO_G_A_OVER_LEN = -4,
+	FIFO_M_OVER_LEN = -3,
+	FIFO_G_OVER_LEN = -2,
+	FIFO_A_OVER_LEN = -1
+};
+
+/*!smi sensor generic power mode enum */
+enum SMI_DEV_OP_MODE {
+	SENSOR_PM_NORMAL = 0,
+	SENSOR_PM_LP1,
+	SENSOR_PM_SUSPEND,
+	SENSOR_PM_LP2
+};
+
+/*! smi acc sensor power mode enum */
+enum SMI_ACC_PM_TYPE {
+	SMI_ACC_PM_NORMAL = 0,
+	SMI_ACC_PM_LP1,
+	SMI_ACC_PM_SUSPEND,
+	SMI_ACC_PM_LP2,
+	SMI_ACC_PM_MAX
+};
+
+/*! smi gyro sensor power mode enum */
+enum SMI_GYRO_PM_TYPE {
+	SMI_GYRO_PM_NORMAL = 0,
+	SMI_GYRO_PM_FAST_START,
+	SMI_GYRO_PM_SUSPEND,
+	SMI_GYRO_PM_MAX
+};
+
+/*! smi mag sensor power mode enum */
+enum SMI_MAG_PM_TYPE {
+	SMI_MAG_PM_NORMAL = 0,
+	SMI_MAG_PM_LP1,
+	SMI_MAG_PM_SUSPEND,
+	SMI_MAG_PM_LP2,
+	SMI_MAG_PM_MAX
+};
+
+
+/*! smi sensor support type*/
+enum SMI_SENSOR_TYPE {
+	SMI_ACC_SENSOR,
+	SMI_GYRO_SENSOR,
+	SMI_MAG_SENSOR,
+	SMI_SENSOR_TYPE_MAX
+};
+
+/*!smi sensor generic power mode enum */
+enum SMI_AXIS_TYPE {
+	X_AXIS = 0,
+	Y_AXIS,
+	Z_AXIS,
+	AXIS_MAX
+};
+
+/*!smi sensor generic intterrupt enum */
+enum SMI_INT_TYPE {
+	SMI130_INT0 = 0,
+	SMI130_INT1,
+	SMI130_INT_MAX
+};
+
+/*! smi sensor time resolution definition*/
+enum SMI_SENSOR_TIME_RS_TYPE {
+	TS_0_78_HZ = 1,/*0.78HZ*/
+	TS_1_56_HZ,/*1.56HZ*/
+	TS_3_125_HZ,/*3.125HZ*/
+	TS_6_25_HZ,/*6.25HZ*/
+	TS_12_5_HZ,/*12.5HZ*/
+	TS_25_HZ,/*25HZ, odr=6*/
+	TS_50_HZ,/*50HZ*/
+	TS_100_HZ,/*100HZ*/
+	TS_200_HZ,/*200HZ*/
+	TS_400_HZ,/*400HZ*/
+	TS_800_HZ,/*800HZ*/
+	TS_1600_HZ,/*1600HZ*/
+	TS_MAX_HZ
+};
+
+/*! smi sensor interface mode */
+enum SMI_SENSOR_IF_MODE_TYPE {
+	/*primary interface:autoconfig/secondary interface off*/
+	P_AUTO_S_OFF = 0,
+	/*primary interface:I2C/secondary interface:OIS*/
+	P_I2C_S_OIS,
+	/*primary interface:autoconfig/secondary interface:Magnetometer*/
+	P_AUTO_S_MAG,
+	/*interface mode reseved*/
+	IF_MODE_RESEVED
+
+};
+
+/*! smi130 acc/gyro calibration status in H/W layer */
+enum SMI_CALIBRATION_STATUS_TYPE {
+	/*SMI FAST Calibration ready x/y/z status*/
+	SMI_ACC_X_FAST_CALI_RDY = 0,
+	SMI_ACC_Y_FAST_CALI_RDY,
+	SMI_ACC_Z_FAST_CALI_RDY
+};
+
+unsigned int reg_op_addr_mbl;
+
+static const int smi_pmu_cmd_acc_arr[SMI_ACC_PM_MAX] = {
+	/*!smi pmu for acc normal, low power1,
+	 * suspend, low power2 mode command */
+	CMD_PMU_ACC_NORMAL,
+	CMD_PMU_ACC_LP1,
+	CMD_PMU_ACC_SUSPEND,
+	CMD_PMU_ACC_LP2
+};
+
+static const int smi_pmu_cmd_gyro_arr[SMI_GYRO_PM_MAX] = {
+	/*!smi pmu for gyro normal, fast startup,
+	 * suspend mode command */
+	CMD_PMU_GYRO_NORMAL,
+	CMD_PMU_GYRO_FASTSTART,
+	CMD_PMU_GYRO_SUSPEND
+};
+
+static const int smi_pmu_cmd_mag_arr[SMI_MAG_PM_MAX] = {
+	/*!smi pmu for mag normal, low power1,
+	 * suspend, low power2 mode command */
+	CMD_PMU_MAG_NORMAL,
+	CMD_PMU_MAG_LP1,
+	CMD_PMU_MAG_SUSPEND,
+	CMD_PMU_MAG_LP2
+};
+
+static const char *smi_axis_name[AXIS_MAX] = {"x", "y", "z"};
+
+static const int smi_interrupt_type[] = {
+	/*!smi interrupt type */
+	/* Interrupt enable0 , index=0~6*/
+	SMI130_ANY_MOTION_X_ENABLE,
+	SMI130_ANY_MOTION_Y_ENABLE,
+	SMI130_ANY_MOTION_Z_ENABLE,
+	SMI130_DOUBLE_TAP_ENABLE,
+	SMI130_SINGLE_TAP_ENABLE,
+	SMI130_ORIENT_ENABLE,
+	SMI130_FLAT_ENABLE,
+	/* Interrupt enable1, index=7~13*/
+	SMI130_HIGH_G_X_ENABLE,
+	SMI130_HIGH_G_Y_ENABLE,
+	SMI130_HIGH_G_Z_ENABLE,
+	SMI130_LOW_G_ENABLE,
+	SMI130_DATA_RDY_ENABLE,
+	SMI130_FIFO_FULL_ENABLE,
+	SMI130_FIFO_WM_ENABLE,
+	/* Interrupt enable2, index = 14~17*/
+	SMI130_NOMOTION_X_ENABLE,
+	SMI130_NOMOTION_Y_ENABLE,
+	SMI130_NOMOTION_Z_ENABLE,
+	SMI130_STEP_DETECTOR_EN
+};
+
+/*! smi sensor time depend on ODR*/
+struct smi_sensor_time_odr_tbl {
+	u32 ts_duration_lsb;
+	u32 ts_duration_us;
+	u32 ts_delat;/*sub current delat fifo_time*/
+};
+
+struct smi130_axis_data_t {
+	s16 x;
+	s16 y;
+	s16 z;
+};
+
+struct smi130_type_mapping_type {
+
+	/*! smi16x sensor chip id */
+	uint16_t chip_id;
+
+	/*! smi16x chip revision code */
+	uint16_t revision_id;
+
+	/*! smi130_acc sensor name */
+	const char *sensor_name;
+};
+
+struct smi130_store_info_t {
+	uint8_t current_frm_cnt;
+	uint64_t current_apts_us[2];
+	uint8_t fifo_ts_total_frmcnt;
+	uint64_t fifo_time;
+};
+
+uint64_t get_current_timestamp_mbl(void)
+{
+	uint64_t ts_ap;
+	struct timespec tmp_time;
+	get_monotonic_boottime(&tmp_time);
+	ts_ap = (uint64_t)tmp_time.tv_sec * 1000000000 + tmp_time.tv_nsec;
+	return ts_ap;
+
+}
+
+/*! sensor support type map */
+static const struct smi130_type_mapping_type sensor_type_map[] = {
+
+	{SENSOR_CHIP_ID_SMI, SENSOR_CHIP_REV_ID_SMI, "SMI130/162AB"},
+	{SENSOR_CHIP_ID_SMI_C2, SENSOR_CHIP_REV_ID_SMI, "SMI130C2"},
+	{SENSOR_CHIP_ID_SMI_C3, SENSOR_CHIP_REV_ID_SMI, "SMI130C3"},
+
+};
+
+/*!smi130 sensor time depends on ODR */
+static const struct smi_sensor_time_odr_tbl
+		sensortime_duration_tbl[TS_MAX_HZ] = {
+	{0x010000, 2560000, 0x00ffff},/*2560ms, 0.39hz, odr=resver*/
+	{0x008000, 1280000, 0x007fff},/*1280ms, 0.78hz, odr_acc=1*/
+	{0x004000, 640000, 0x003fff},/*640ms, 1.56hz, odr_acc=2*/
+	{0x002000, 320000, 0x001fff},/*320ms, 3.125hz, odr_acc=3*/
+	{0x001000, 160000, 0x000fff},/*160ms, 6.25hz, odr_acc=4*/
+	{0x000800, 80000,  0x0007ff},/*80ms, 12.5hz*/
+	{0x000400, 40000, 0x0003ff},/*40ms, 25hz, odr_acc = odr_gyro =6*/
+	{0x000200, 20000, 0x0001ff},/*20ms, 50hz, odr = 7*/
+	{0x000100, 10000, 0x0000ff},/*10ms, 100hz, odr=8*/
+	{0x000080, 5000, 0x00007f},/*5ms, 200hz, odr=9*/
+	{0x000040, 2500, 0x00003f},/*2.5ms, 400hz, odr=10*/
+	{0x000020, 1250, 0x00001f},/*1.25ms, 800hz, odr=11*/
+	{0x000010, 625, 0x00000f},/*0.625ms, 1600hz, odr=12*/
+
+};
+
+#if defined(CONFIG_USE_QUALCOMM_HAL)
+#define POLL_INTERVAL_MIN_MS	10
+#define POLL_INTERVAL_MAX_MS	4000
+#define POLL_DEFAULT_INTERVAL_MS 200
+#define SMI130_ACCEL_MIN_VALUE	-32768
+#define SMI130_ACCEL_MAX_VALUE	32767
+#define SMI130_GYRO_MIN_VALUE	-32768
+#define SMI130_GYRO_MAX_VALUE	32767
+#define SMI130_ACCEL_DEFAULT_POLL_INTERVAL_MS	200
+#define SMI130_GYRO_DEFAULT_POLL_INTERVAL_MS	200
+#define SMI130_ACCEL_MIN_POLL_INTERVAL_MS	10
+#define SMI130_ACCEL_MAX_POLL_INTERVAL_MS	5000
+#define SMI130_GYRO_MIN_POLL_INTERVAL_MS	10
+#define SMI130_GYRO_MAX_POLL_INTERVAL_MS	5000
+static struct sensors_classdev smi130_accel_cdev = {
+		.name = "smi130-accel",
+		.vendor = "bosch",
+		.version = 1,
+		.handle = SENSORS_ACCELERATION_HANDLE,
+		.type = SENSOR_TYPE_ACCELEROMETER,
+		.max_range = "156.8",	/* 16g */
+		.resolution = "0.153125",	/* 15.6mg */
+		.sensor_power = "0.13",	/* typical value */
+		.min_delay = POLL_INTERVAL_MIN_MS * 1000, /* in microseconds */
+		.max_delay = POLL_INTERVAL_MAX_MS,
+		.delay_msec = POLL_DEFAULT_INTERVAL_MS, /* in millisecond */
+		.fifo_reserved_event_count = 0,
+		.fifo_max_event_count = 0,
+		.enabled = 0,
+		.max_latency = 0,
+		.flags = 0,
+		.sensors_enable = NULL,
+		.sensors_poll_delay = NULL,
+		.sensors_set_latency = NULL,
+		.sensors_flush = NULL,
+		.sensors_self_test = NULL,
+};
+static struct sensors_classdev smi130_gyro_cdev = {
+	.name = "smi130-gyro",
+	.vendor = "bosch",
+	.version = 1,
+	.handle = SENSORS_GYROSCOPE_HANDLE,
+	.type = SENSOR_TYPE_GYROSCOPE,
+	.max_range = "34.906586",	/* rad/s */
+	.resolution = "0.0010681152",	/* rad/s */
+	.sensor_power = "3.6",	/* 3.6 mA */
+	.min_delay = SMI130_GYRO_MIN_POLL_INTERVAL_MS * 1000,
+	.max_delay = SMI130_GYRO_MAX_POLL_INTERVAL_MS,
+	.delay_msec = SMI130_GYRO_DEFAULT_POLL_INTERVAL_MS,
+	.fifo_reserved_event_count = 0,
+	.fifo_max_event_count = 0,
+	.enabled = 0,
+	.max_latency = 0,
+	.flags = 0, /* SENSOR_FLAG_CONTINUOUS_MODE */
+	.sensors_enable = NULL,
+	.sensors_poll_delay = NULL,
+	.sensors_enable_wakeup = NULL,
+	.sensors_set_latency = NULL,
+	.sensors_flush = NULL,
+};
+#endif
+static void smi_delay(u32 msec)
+{
+	if (msec <= 20)
+		usleep_range(msec * 1000, msec * 1000);
+	else
+		msleep(msec);
+}
+
+static void smi_dump_reg(struct smi_client_data *client_data)
+{
+	#define REG_MAX0 0x24
+	#define REG_MAX1 0x56
+	int i;
+	u8 dbg_buf0[REG_MAX0];
+	u8 dbg_buf1[REG_MAX1];
+	u8 dbg_buf_str0[REG_MAX0 * 3 + 1] = "";
+	u8 dbg_buf_str1[REG_MAX1 * 3 + 1] = "";
+
+	dev_notice(client_data->dev, "\nFrom 0x00:\n");
+
+	client_data->device.bus_read(client_data->device.dev_addr,
+			SMI_REG_NAME(USER_CHIP_ID), dbg_buf0, REG_MAX0);
+	for (i = 0; i < REG_MAX0; i++) {
+		snprintf(dbg_buf_str0 + i * 3, 16, "%02x%c", dbg_buf0[i],
+				(((i + 1) % BYTES_PER_LINE == 0) ? '\n' : ' '));
+	}
+	dev_notice(client_data->dev, "%s\n", dbg_buf_str0);
+
+	client_data->device.bus_read(client_data->device.dev_addr,
+			SMI130_USER_ACCEL_CONFIG_ADDR, dbg_buf1, REG_MAX1);
+	dev_notice(client_data->dev, "\nFrom 0x40:\n");
+	for (i = 0; i < REG_MAX1; i++) {
+		snprintf(dbg_buf_str1 + i * 3, 16, "%02x%c", dbg_buf1[i],
+				(((i + 1) % BYTES_PER_LINE == 0) ? '\n' : ' '));
+	}
+	dev_notice(client_data->dev, "\n%s\n", dbg_buf_str1);
+	}
+
+
+void smi_fifo_frame_bytes_extend_calc(
+	struct smi_client_data *client_data,
+	unsigned int *fifo_frmbytes_extend)
+{
+
+	switch (client_data->fifo_data_sel) {
+	case SMI_FIFO_A_SEL:
+	case SMI_FIFO_G_SEL:
+		*fifo_frmbytes_extend = 7;
+		break;
+	case SMI_FIFO_G_A_SEL:
+		*fifo_frmbytes_extend = 13;
+		break;
+	case SMI_FIFO_M_SEL:
+		*fifo_frmbytes_extend = 9;
+		break;
+	case SMI_FIFO_M_A_SEL:
+	case SMI_FIFO_M_G_SEL:
+		/*8(mag) + 6(gyro or acc) +1(head) = 15*/
+		*fifo_frmbytes_extend = 15;
+		break;
+	case SMI_FIFO_M_G_A_SEL:
+		/*8(mag) + 6(gyro or acc) + 6 + 1 = 21*/
+		*fifo_frmbytes_extend = 21;
+		break;
+	default:
+		*fifo_frmbytes_extend = 0;
+		break;
+
+	};
+
+}
+
+static int smi_input_init(struct smi_client_data *client_data)
+{
+	struct input_dev *dev;
+	int err = 0;
+
+	dev = input_allocate_device();
+	if (NULL == dev)
+		return -ENOMEM;
+#if defined(CONFIG_USE_QUALCOMM_HAL)
+	dev->name = "smi130-accel";
+#else
+	dev->name = SENSOR_NAME;
+#endif
+	dev->id.bustype = BUS_I2C;
+
+	input_set_capability(dev, EV_MSC, MSC_GESTURE);
+	input_set_capability(dev, EV_MSC, INPUT_EVENT_SGM);
+
+	input_set_capability(dev, EV_MSC, INPUT_EVENT_FAST_GYRO_CALIB_DONE);
+	input_set_capability(dev, EV_MSC, INPUT_EVENT_STEP_DETECTOR);
+	input_set_capability(dev, EV_MSC, INPUT_EVENT_FAST_ACC_CALIB_DONE);
+
+
+	input_set_capability(dev, EV_REL, REL_X);
+	input_set_capability(dev, EV_REL, REL_Y);
+	input_set_capability(dev, EV_REL, REL_Z);
+	#if defined(CONFIG_USE_QUALCOMM_HAL)
+	input_set_capability(dev, EV_ABS, ABS_MISC);
+	input_set_abs_params(dev, ABS_X,
+	SMI130_ACCEL_MIN_VALUE, SMI130_ACCEL_MAX_VALUE,
+	0, 0);
+	input_set_abs_params(dev, ABS_Y,
+	SMI130_ACCEL_MIN_VALUE, SMI130_ACCEL_MAX_VALUE,
+	0, 0);
+	input_set_abs_params(dev, ABS_Z,
+	SMI130_ACCEL_MIN_VALUE, SMI130_ACCEL_MAX_VALUE,
+	0, 0);
+	#endif
+	input_set_drvdata(dev, client_data);
+
+	err = input_register_device(dev);
+	if (err < 0) {
+		input_free_device(dev);
+		dev_notice(client_data->dev, "smi130 input free!\n");
+		return err;
+	}
+	client_data->input = dev;
+	dev_notice(client_data->dev,
+		"smi130 input register successfully, %s!\n",
+		client_data->input->name);
+	return err;
+}
+
+//#if defined(CONFIG_USE_QUALCOMM_HAL)
+static int smi_gyro_input_init(struct smi_client_data *client_data)
+{
+	struct input_dev *dev;
+	int err = 0;
+
+	dev = input_allocate_device();
+	if (NULL == dev)
+		return -ENOMEM;
+	dev->name = "smi130-gyro";
+	dev->id.bustype = BUS_I2C;
+	input_set_capability(dev, EV_ABS, ABS_MISC);
+	input_set_capability(dev, EV_MSC, MSC_GESTURE);
+	input_set_capability(dev, EV_MSC, INPUT_EVENT_SGM);
+	
+	input_set_capability(dev, EV_MSC, INPUT_EVENT_FAST_GYRO_CALIB_DONE);
+	input_set_capability(dev, EV_MSC, INPUT_EVENT_STEP_DETECTOR);
+	input_set_capability(dev, EV_MSC, INPUT_EVENT_FAST_ACC_CALIB_DONE);
+	#if defined(CONFIG_USE_QUALCOMM_HAL)
+	input_set_abs_params(dev, ABS_RX,
+	SMI130_ACCEL_MIN_VALUE, SMI130_ACCEL_MAX_VALUE,
+	0, 0);
+	input_set_abs_params(dev, ABS_RY,
+	SMI130_ACCEL_MIN_VALUE, SMI130_ACCEL_MAX_VALUE,
+	0, 0);
+	input_set_abs_params(dev, ABS_RZ,
+	SMI130_ACCEL_MIN_VALUE, SMI130_ACCEL_MAX_VALUE,
+	0, 0);
+	#endif
+	input_set_drvdata(dev, client_data);
+	err = input_register_device(dev);
+	if (err < 0) {
+		input_free_device(dev);
+		dev_notice(client_data->dev, "smi130 input free!\n");
+		return err;
+	}
+	client_data->gyro_input = dev;
+	dev_notice(client_data->dev,
+		"smi130 input register successfully, %s!\n",
+		client_data->gyro_input->name);
+	return err;
+}
+//#endif
+static void smi_input_destroy(struct smi_client_data *client_data)
+{
+	struct input_dev *dev = client_data->input;
+
+	input_unregister_device(dev);
+	input_free_device(dev);
+}
+
+static int smi_check_chip_id(struct smi_client_data *client_data)
+{
+	int8_t err = 0;
+	int8_t i = 0;
+	uint8_t chip_id = 0;
+	uint8_t read_count = 0;
+	u8 smi_sensor_cnt = sizeof(sensor_type_map)
+				/ sizeof(struct smi130_type_mapping_type);
+	/* read and check chip id */
+	while (read_count++ < CHECK_CHIP_ID_TIME_MAX) {
+		if (client_data->device.bus_read(client_data->device.dev_addr,
+				SMI_REG_NAME(USER_CHIP_ID), &chip_id, 1) < 0) {
+
+			dev_err(client_data->dev,
+					"Bosch Sensortec Device not found"
+						"read chip_id:%d\n", chip_id);
+			continue;
+		} else {
+			for (i = 0; i < smi_sensor_cnt; i++) {
+				if (sensor_type_map[i].chip_id == chip_id) {
+					client_data->chip_id = chip_id;
+					dev_notice(client_data->dev,
+					"Bosch Sensortec Device detected, "
+			"HW IC name: %s\n", sensor_type_map[i].sensor_name);
+					break;
+				}
+			}
+			if (i < smi_sensor_cnt)
+				break;
+			else {
+				if (read_count == CHECK_CHIP_ID_TIME_MAX) {
+					dev_err(client_data->dev,
+				"Failed!Bosch Sensortec Device not found"
+					" mismatch chip_id:%d\n", chip_id);
+					err = -ENODEV;
+					return err;
+				}
+			}
+			smi_delay(1);
+		}
+	}
+	return err;
+
+}
+
+static int smi_pmu_set_suspend(struct smi_client_data *client_data)
+{
+	int err = 0;
+	if (client_data == NULL)
+		return -EINVAL;
+	else {
+		err += SMI_CALL_API(set_command_register)
+				(smi_pmu_cmd_acc_arr[SENSOR_PM_SUSPEND]);
+		err += SMI_CALL_API(set_command_register)
+				(smi_pmu_cmd_gyro_arr[SENSOR_PM_SUSPEND]);
+		err += SMI_CALL_API(set_command_register)
+				(smi_pmu_cmd_mag_arr[SENSOR_PM_SUSPEND]);
+		client_data->pw.acc_pm = SMI_ACC_PM_SUSPEND;
+		client_data->pw.gyro_pm = SMI_GYRO_PM_SUSPEND;
+		client_data->pw.mag_pm = SMI_MAG_PM_SUSPEND;
+	}
+
+	return err;
+}
+
+static int smi_get_err_status(struct smi_client_data *client_data)
+{
+	int err = 0;
+
+	err = SMI_CALL_API(get_error_status)(&client_data->err_st.fatal_err,
+		&client_data->err_st.err_code, &client_data->err_st.i2c_fail,
+	&client_data->err_st.drop_cmd, &client_data->err_st.mag_drdy_err);
+	return err;
+}
+
+static void smi_work_func(struct work_struct *work)
+{
+	struct smi_client_data *client_data =
+		container_of((struct delayed_work *)work,
+			struct smi_client_data, work);
+	unsigned long delay =
+		msecs_to_jiffies(atomic_read(&client_data->delay));
+	struct smi130_accel_t data;
+	int err;
+
+	err = SMI_CALL_API(read_accel_xyz)(&data);
+	if (err < 0)
+		return;
+
+	/*report current frame via input event*/
+	input_event(client_data->input, EV_REL, REL_X, data.x);
+	input_event(client_data->input, EV_REL, REL_Y, data.y);
+	input_event(client_data->input, EV_REL, REL_Z, data.z);
+	input_sync(client_data->input);
+
+	schedule_delayed_work(&client_data->work, delay);
+}
+
+static ssize_t smi130_chip_id_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+
+	return snprintf(buf, 16, "0x%x\n", client_data->chip_id);
+}
+
+static ssize_t smi130_err_st_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+	int err = 0;
+	err = smi_get_err_status(client_data);
+	if (err)
+		return err;
+	else {
+		return snprintf(buf, 128, "fatal_err:0x%x, err_code:%d,\n\n"
+			"i2c_fail_err:%d, drop_cmd_err:%d, mag_drdy_err:%d\n",
+			client_data->err_st.fatal_err,
+			client_data->err_st.err_code,
+			client_data->err_st.i2c_fail,
+			client_data->err_st.drop_cmd,
+			client_data->err_st.mag_drdy_err);
+
+	}
+}
+
+static ssize_t smi130_sensor_time_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err = 0;
+	u32 sensor_time;
+	err = SMI_CALL_API(get_sensor_time)(&sensor_time);
+	if (err)
+		return err;
+	else
+		return snprintf(buf, 16, "0x%x\n", (unsigned int)sensor_time);
+}
+
+static ssize_t smi130_fifo_flush_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	int err;
+	unsigned long enable;
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+
+	err = kstrtoul(buf, 10, &enable);
+	if (err)
+		return err;
+	if (enable)
+		err = SMI_CALL_API(set_command_register)(CMD_CLR_FIFO_DATA);
+
+	if (err)
+		dev_err(client_data->dev, "fifo flush failed!\n");
+
+	return count;
+
+}
+
+
+static ssize_t smi130_fifo_bytecount_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err;
+	unsigned int fifo_bytecount = 0;
+
+	SMI_CALL_API(fifo_length)(&fifo_bytecount);
+	err = snprintf(buf, 16, "%u\n", fifo_bytecount);
+	return err;
+}
+
+static ssize_t smi130_fifo_bytecount_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+	int err;
+	unsigned long data;
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+	client_data->fifo_bytecount = (unsigned int) data;
+
+	return count;
+}
+
+int smi130_fifo_data_sel_get(struct smi_client_data *client_data)
+{
+	int err = 0;
+	unsigned char fifo_acc_en, fifo_gyro_en, fifo_mag_en;
+	unsigned char fifo_datasel;
+
+	err += SMI_CALL_API(get_fifo_accel_enable)(&fifo_acc_en);
+	err += SMI_CALL_API(get_fifo_gyro_enable)(&fifo_gyro_en);
+	err += SMI_CALL_API(get_fifo_mag_enable)(&fifo_mag_en);
+
+	if (err)
+		return err;
+
+	fifo_datasel = (fifo_acc_en << SMI_ACC_SENSOR) |
+			(fifo_gyro_en << SMI_GYRO_SENSOR) |
+				(fifo_mag_en << SMI_MAG_SENSOR);
+
+	client_data->fifo_data_sel = fifo_datasel;
+
+	return err;
+
+
+}
+
+static ssize_t smi130_fifo_data_sel_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err = 0;
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+	err = smi130_fifo_data_sel_get(client_data);
+	if (err) {
+		dev_err(client_data->dev, "get fifo_sel failed!\n");
+		return -EINVAL;
+	}
+	return snprintf(buf, 16, "%d\n", client_data->fifo_data_sel);
+}
+
+/* write any value to clear all the fifo data. */
+static ssize_t smi130_fifo_data_sel_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+	int err;
+	unsigned long data;
+	unsigned char fifo_datasel;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+	/* data format: aimed 0b0000 0x(m)x(g)x(a), x:1 enable, 0:disable*/
+	if (data > 7)
+		return -EINVAL;
+
+
+	fifo_datasel = (unsigned char)data;
+
+
+	err += SMI_CALL_API(set_fifo_accel_enable)
+			((fifo_datasel & (1 << SMI_ACC_SENSOR)) ? 1 :  0);
+	err += SMI_CALL_API(set_fifo_gyro_enable)
+			(fifo_datasel & (1 << SMI_GYRO_SENSOR) ? 1 : 0);
+	err += SMI_CALL_API(set_fifo_mag_enable)
+			((fifo_datasel & (1 << SMI_MAG_SENSOR)) ? 1 : 0);
+
+	err += SMI_CALL_API(set_command_register)(CMD_CLR_FIFO_DATA);
+	if (err)
+		return -EIO;
+	else {
+		dev_notice(client_data->dev, "FIFO A_en:%d, G_en:%d, M_en:%d\n",
+			(fifo_datasel & (1 << SMI_ACC_SENSOR)) ? 1 :  0,
+			(fifo_datasel & (1 << SMI_GYRO_SENSOR) ? 1 : 0),
+			((fifo_datasel & (1 << SMI_MAG_SENSOR)) ? 1 : 0));
+		client_data->fifo_data_sel = fifo_datasel;
+	}
+	return count;
+}
+
+static ssize_t smi130_fifo_data_out_frame_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+
+	int err = 0;
+	uint32_t fifo_bytecount = 0;
+
+	err = SMI_CALL_API(fifo_length)(&fifo_bytecount);
+	if (err < 0) {
+		dev_err(client_data->dev, "read fifo_length err");
+		return -EINVAL;
+	}
+	if (fifo_bytecount == 0)
+		return 0;
+	err = smi_burst_read_wrapper(client_data->device.dev_addr,
+		SMI130_USER_FIFO_DATA__REG, buf,
+		fifo_bytecount);
+	if (err) {
+		dev_err(client_data->dev, "read fifo err");
+		SMI_CALL_API(set_command_register)(CMD_CLR_FIFO_DATA);
+		return -EINVAL;
+	}
+	return fifo_bytecount;
+
+}
+
+static ssize_t smi130_fifo_watermark_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err;
+	unsigned char data = 0xff;
+
+	err = SMI_CALL_API(get_fifo_wm)(&data);
+
+	if (err)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t smi130_fifo_watermark_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	int err;
+	unsigned long data;
+	unsigned char fifo_watermark;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	fifo_watermark = (unsigned char)data;
+	err = SMI_CALL_API(set_fifo_wm)(fifo_watermark);
+	if (err)
+		return -EIO;
+
+	return count;
+}
+
+
+static ssize_t smi130_fifo_header_en_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err;
+	unsigned char data = 0xff;
+
+	err = SMI_CALL_API(get_fifo_header_enable)(&data);
+
+	if (err)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t smi130_fifo_header_en_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+	int err;
+	unsigned long data;
+	unsigned char fifo_header_en;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+	if (data > 1)
+		return -ENOENT;
+
+	fifo_header_en = (unsigned char)data;
+	err = SMI_CALL_API(set_fifo_header_enable)(fifo_header_en);
+	if (err)
+		return -EIO;
+
+	client_data->fifo_head_en = fifo_header_en;
+
+	return count;
+}
+
+static ssize_t smi130_fifo_time_en_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err;
+	unsigned char data = 0;
+
+	err = SMI_CALL_API(get_fifo_time_enable)(&data);
+
+	if (!err)
+		err = snprintf(buf, 16, "%d\n", data);
+
+	return err;
+}
+
+static ssize_t smi130_fifo_time_en_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	int err;
+	unsigned long data;
+	unsigned char fifo_ts_en;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	fifo_ts_en = (unsigned char)data;
+
+	err = SMI_CALL_API(set_fifo_time_enable)(fifo_ts_en);
+	if (err)
+		return -EIO;
+
+	return count;
+}
+
+static ssize_t smi130_fifo_int_tag_en_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err = 0;
+	unsigned char fifo_tag_int1 = 0;
+	unsigned char fifo_tag_int2 = 0;
+	unsigned char fifo_tag_int;
+
+	err += SMI_CALL_API(get_fifo_tag_intr1_enable)(&fifo_tag_int1);
+	err += SMI_CALL_API(get_fifo_tag_intr2_enable)(&fifo_tag_int2);
+
+	fifo_tag_int = (fifo_tag_int1 << SMI130_INT0) |
+			(fifo_tag_int2 << SMI130_INT1);
+
+	if (!err)
+		err = snprintf(buf, 16, "%d\n", fifo_tag_int);
+
+	return err;
+}
+
+static ssize_t smi130_fifo_int_tag_en_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+	int err;
+	unsigned long data;
+	unsigned char fifo_tag_int_en;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+	if (data > 3)
+		return -EINVAL;
+
+	fifo_tag_int_en = (unsigned char)data;
+
+	err += SMI_CALL_API(set_fifo_tag_intr1_enable)
+			((fifo_tag_int_en & (1 << SMI130_INT0)) ? 1 :  0);
+	err += SMI_CALL_API(set_fifo_tag_intr2_enable)
+			((fifo_tag_int_en & (1 << SMI130_INT1)) ? 1 :  0);
+
+	if (err) {
+		dev_err(client_data->dev, "fifo int tag en err:%d\n", err);
+		return -EIO;
+	}
+	client_data->fifo_int_tag_en = fifo_tag_int_en;
+
+	return count;
+}
+
+static int smi130_set_acc_op_mode(struct smi_client_data *client_data,
+							unsigned long op_mode)
+{
+	int err = 0;
+	unsigned char stc_enable;
+	unsigned char std_enable;
+	mutex_lock(&client_data->mutex_op_mode);
+
+	if (op_mode < SMI_ACC_PM_MAX) {
+		switch (op_mode) {
+		case SMI_ACC_PM_NORMAL:
+			err = SMI_CALL_API(set_command_register)
+			(smi_pmu_cmd_acc_arr[SMI_ACC_PM_NORMAL]);
+			client_data->pw.acc_pm = SMI_ACC_PM_NORMAL;
+			smi_delay(10);
+			break;
+		case SMI_ACC_PM_LP1:
+			err = SMI_CALL_API(set_command_register)
+			(smi_pmu_cmd_acc_arr[SMI_ACC_PM_LP1]);
+			client_data->pw.acc_pm = SMI_ACC_PM_LP1;
+			smi_delay(3);
+			break;
+		case SMI_ACC_PM_SUSPEND:
+			SMI_CALL_API(get_step_counter_enable)(&stc_enable);
+			SMI_CALL_API(get_step_detector_enable)(&std_enable);
+			if ((stc_enable == 0) && (std_enable == 0) &&
+				(client_data->sig_flag == 0)) {
+				err = SMI_CALL_API(set_command_register)
+				(smi_pmu_cmd_acc_arr[SMI_ACC_PM_SUSPEND]);
+				client_data->pw.acc_pm = SMI_ACC_PM_SUSPEND;
+				smi_delay(10);
+			}
+			break;
+		case SMI_ACC_PM_LP2:
+			err = SMI_CALL_API(set_command_register)
+			(smi_pmu_cmd_acc_arr[SMI_ACC_PM_LP2]);
+			client_data->pw.acc_pm = SMI_ACC_PM_LP2;
+			smi_delay(3);
+			break;
+		default:
+			mutex_unlock(&client_data->mutex_op_mode);
+			return -EINVAL;
+		}
+	} else {
+		mutex_unlock(&client_data->mutex_op_mode);
+		return -EINVAL;
+	}
+
+	mutex_unlock(&client_data->mutex_op_mode);
+
+	return err;
+
+
+}
+
+static ssize_t smi130_temperature_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err;
+	s16 temp = 0xff;
+
+	err = SMI_CALL_API(get_temp)(&temp);
+
+	if (!err)
+		err = snprintf(buf, 16, "0x%x\n", temp);
+
+	return err;
+}
+
+static ssize_t smi130_place_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+	int place = BOSCH_SENSOR_PLACE_UNKNOWN;
+
+	if (NULL != client_data->bosch_pd)
+		place = client_data->bosch_pd->place;
+
+	return snprintf(buf, 16, "%d\n", place);
+}
+
+static ssize_t smi130_delay_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+
+	return snprintf(buf, 16, "%d\n", atomic_read(&client_data->delay));
+
+}
+
+static ssize_t smi130_delay_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+	int err;
+	unsigned long data;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	if (data == 0) {
+		err = -EINVAL;
+		return err;
+	}
+
+	if (data < SMI_DELAY_MIN)
+		data = SMI_DELAY_MIN;
+
+	atomic_set(&client_data->delay, (unsigned int)data);
+
+	return count;
+}
+
+static ssize_t smi130_enable_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+
+	return snprintf(buf, 16, "%d\n", atomic_read(&client_data->wkqueue_en));
+
+}
+
+static ssize_t smi130_enable_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+	int err;
+	unsigned long enable;
+	int pre_enable = atomic_read(&client_data->wkqueue_en);
+
+	err = kstrtoul(buf, 10, &enable);
+	if (err)
+		return err;
+
+	enable = enable ? 1 : 0;
+	mutex_lock(&client_data->mutex_enable);
+	if (enable) {
+		if (pre_enable == 0) {
+			smi130_set_acc_op_mode(client_data,
+							SMI_ACC_PM_NORMAL);
+			schedule_delayed_work(&client_data->work,
+			msecs_to_jiffies(atomic_read(&client_data->delay)));
+			atomic_set(&client_data->wkqueue_en, 1);
+		}
+
+	} else {
+		if (pre_enable == 1) {
+			smi130_set_acc_op_mode(client_data,
+							SMI_ACC_PM_SUSPEND);
+
+			cancel_delayed_work_sync(&client_data->work);
+			atomic_set(&client_data->wkqueue_en, 0);
+		}
+	}
+
+	mutex_unlock(&client_data->mutex_enable);
+
+	return count;
+}
+
+#if defined(SMI130_ENABLE_INT1) || defined(SMI130_ENABLE_INT2)
+/* accel sensor part */
+static ssize_t smi130_anymot_duration_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err;
+	unsigned char data;
+
+	err = SMI_CALL_API(get_intr_any_motion_durn)(&data);
+
+	if (err < 0)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t smi130_anymot_duration_store(struct device *dev,
+		struct device_attribute *attr, const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	err = SMI_CALL_API(set_intr_any_motion_durn)((unsigned char)data);
+	if (err < 0)
+		return -EIO;
+
+	return count;
+}
+
+static ssize_t smi130_anymot_threshold_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data;
+	int err;
+
+	err = SMI_CALL_API(get_intr_any_motion_thres)(&data);
+
+	if (err < 0)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t smi130_anymot_threshold_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	err = SMI_CALL_API(set_intr_any_motion_thres)((unsigned char)data);
+
+	if (err < 0)
+		return -EIO;
+	return count;
+}
+
+static ssize_t smi130_step_detector_status_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	u8 data = 0;
+	u8 step_det;
+	int err;
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+	err = SMI_CALL_API(get_step_detector_enable)(&step_det);
+	/*smi130_get_status0_step_int*/
+	if (err < 0)
+		return err;
+/*client_data->std will be updated in smi_stepdetector_interrupt_handle */
+	if ((step_det == 1) && (client_data->std == 1)) {
+		data = 1;
+		client_data->std = 0;
+		}
+	else {
+		data = 0;
+		}
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t smi130_step_detector_enable_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data;
+	int err;
+
+	err = SMI_CALL_API(get_step_detector_enable)(&data);
+
+	if (err < 0)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t smi130_step_detector_enable_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	err = SMI_CALL_API(set_step_detector_enable)((unsigned char)data);
+	if (err < 0)
+		return -EIO;
+	if (data == 0)
+		client_data->pedo_data.wkar_step_detector_status = 0;
+	return count;
+}
+
+static ssize_t smi130_signification_motion_enable_store(
+	struct device *dev, struct device_attribute *attr,
+	const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+	/*0x62 (bit 1) INT_MOTION_3 int_sig_mot_sel*/
+	err = SMI_CALL_API(set_intr_significant_motion_select)(
+		(unsigned char)data);
+	if (err < 0)
+		return -EIO;
+	if (data == 1) {
+		err = SMI_CALL_API(set_intr_enable_0)
+					(SMI130_ANY_MOTION_X_ENABLE, 1);
+		err += SMI_CALL_API(set_intr_enable_0)
+					(SMI130_ANY_MOTION_Y_ENABLE, 1);
+		err += SMI_CALL_API(set_intr_enable_0)
+					(SMI130_ANY_MOTION_Z_ENABLE, 1);
+		if (err < 0)
+			return -EIO;
+		enable_irq_wake(client_data->IRQ);
+		client_data->sig_flag = 1;
+	} else {
+		err = SMI_CALL_API(set_intr_enable_0)
+					(SMI130_ANY_MOTION_X_ENABLE, 0);
+		err += SMI_CALL_API(set_intr_enable_0)
+					(SMI130_ANY_MOTION_Y_ENABLE, 0);
+		err += SMI_CALL_API(set_intr_enable_0)
+					(SMI130_ANY_MOTION_Z_ENABLE, 0);
+		if (err < 0)
+			return -EIO;
+		disable_irq_wake(client_data->IRQ);
+		client_data->sig_flag = 0;
+	}
+	return count;
+}
+
+static ssize_t smi130_signification_motion_enable_show(
+	struct device *dev, struct device_attribute *attr, char *buf)
+{
+	unsigned char data;
+	int err;
+	/*0x62 (bit 1) INT_MOTION_3 int_sig_mot_sel*/
+	err = SMI_CALL_API(get_intr_significant_motion_select)(&data);
+
+	if (err < 0)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static int sigmotion_init_interrupts(u8 sig_map_int_pin)
+{
+	int ret = 0;
+/*0x60  */
+	ret += smi130_set_intr_any_motion_thres(0x1e);
+/* 0x62(bit 3~2)	0=1.5s */
+	ret += smi130_set_intr_significant_motion_skip(0);
+/*0x62(bit 5~4)	1=0.5s*/
+	ret += smi130_set_intr_significant_motion_proof(1);
+/*0x50 (bit 0, 1, 2)  INT_EN_0 anymo x y z*/
+	ret += smi130_map_significant_motion_intr(sig_map_int_pin);
+/*0x62 (bit 1) INT_MOTION_3	int_sig_mot_sel
+close the signification_motion*/
+	ret += smi130_set_intr_significant_motion_select(0);
+/*close the anymotion interrupt*/
+	ret += SMI_CALL_API(set_intr_enable_0)
+					(SMI130_ANY_MOTION_X_ENABLE, 0);
+	ret += SMI_CALL_API(set_intr_enable_0)
+					(SMI130_ANY_MOTION_Y_ENABLE, 0);
+	ret += SMI_CALL_API(set_intr_enable_0)
+					(SMI130_ANY_MOTION_Z_ENABLE, 0);
+	if (ret)
+		printk(KERN_ERR "smi130 sig motion failed setting,%d!\n", ret);
+	return ret;
+
+}
+#endif
+
+static ssize_t smi130_acc_range_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err;
+	unsigned char range;
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+
+	err = SMI_CALL_API(get_accel_range)(&range);
+	if (err)
+		return err;
+
+	client_data->range.acc_range = range;
+	return snprintf(buf, 16, "%d\n", range);
+}
+
+static ssize_t smi130_acc_range_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	int err;
+	unsigned long range;
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+
+
+	err = kstrtoul(buf, 10, &range);
+	if (err)
+		return err;
+
+	err = SMI_CALL_API(set_accel_range)(range);
+	if (err)
+		return -EIO;
+
+	client_data->range.acc_range = range;
+	return count;
+}
+
+static ssize_t smi130_acc_odr_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err;
+	unsigned char acc_odr;
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+
+	err = SMI_CALL_API(get_accel_output_data_rate)(&acc_odr);
+	if (err)
+		return err;
+
+	client_data->odr.acc_odr = acc_odr;
+	return snprintf(buf, 16, "%d\n", acc_odr);
+}
+
+static ssize_t smi130_acc_odr_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	int err;
+	unsigned long acc_odr;
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+
+	err = kstrtoul(buf, 10, &acc_odr);
+	if (err)
+		return err;
+
+	if (acc_odr < 1 || acc_odr > 12)
+		return -EIO;
+
+	if (acc_odr < 5)
+		err = SMI_CALL_API(set_accel_under_sampling_parameter)(1);
+	else
+		err = SMI_CALL_API(set_accel_under_sampling_parameter)(0);
+
+	if (err)
+		return err;
+
+	err = SMI_CALL_API(set_accel_output_data_rate)(acc_odr);
+	if (err)
+		return -EIO;
+	client_data->odr.acc_odr = acc_odr;
+	return count;
+}
+
+static ssize_t smi130_acc_op_mode_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+	int err = 0;
+	u8 accel_pmu_status = 0;
+	err = SMI_CALL_API(get_accel_power_mode_stat)(
+		&accel_pmu_status);
+
+	if (err)
+		return err;
+	else
+	return snprintf(buf, 32, "reg:%d, val:%d\n", accel_pmu_status,
+			client_data->pw.acc_pm);
+}
+
+static ssize_t smi130_acc_op_mode_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+	int err;
+	unsigned long op_mode;
+	err = kstrtoul(buf, 10, &op_mode);
+	if (err)
+		return err;
+
+	err = smi130_set_acc_op_mode(client_data, op_mode);
+	if (err)
+		return err;
+	else
+		return count;
+
+}
+
+static ssize_t smi130_acc_value_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct smi130_accel_t data;
+
+	int err;
+
+	err = SMI_CALL_API(read_accel_xyz)(&data);
+	if (err < 0)
+		return err;
+
+	return snprintf(buf, 48, "%hd %hd %hd\n",
+			data.x, data.y, data.z);
+}
+
+static ssize_t smi130_acc_fast_calibration_x_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data;
+	int err;
+
+	err = SMI_CALL_API(get_foc_accel_x)(&data);
+
+	if (err < 0)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t smi130_acc_fast_calibration_x_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+	s8 accel_offset_x = 0;
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+	/* 0: disable, 1: +1g, 2: -1g, 3: 0g */
+	if (data > 3)
+		return -EINVAL;
+
+	err = SMI_CALL_API(set_accel_foc_trigger)(X_AXIS,
+					data, &accel_offset_x);
+	if (err)
+		return -EIO;
+	else
+		client_data->calib_status |=
+			SMI_FAST_CALI_TRUE << SMI_ACC_X_FAST_CALI_RDY;
+	return count;
+}
+
+static ssize_t smi130_acc_fast_calibration_y_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data;
+	int err;
+
+	err = SMI_CALL_API(get_foc_accel_y)(&data);
+
+	if (err < 0)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t smi130_acc_fast_calibration_y_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+	s8 accel_offset_y = 0;
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+	/* 0: disable, 1: +1g, 2: -1g, 3: 0g */
+	if (data > 3)
+		return -EINVAL;
+
+	err = SMI_CALL_API(set_accel_foc_trigger)(Y_AXIS,
+				data, &accel_offset_y);
+	if (err)
+		return -EIO;
+	else
+		client_data->calib_status |=
+			SMI_FAST_CALI_TRUE << SMI_ACC_Y_FAST_CALI_RDY;
+	return count;
+}
+
+static ssize_t smi130_acc_fast_calibration_z_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data;
+	int err;
+
+	err = SMI_CALL_API(get_foc_accel_z)(&data);
+
+	if (err < 0)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t smi130_acc_fast_calibration_z_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+	s8 accel_offset_z = 0;
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+	unsigned char data1[3] = {0};
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+	/* 0: disable, 1: +1g, 2: -1g, 3: 0g */
+	if (data > 3)
+		return -EINVAL;
+
+	err = SMI_CALL_API(set_accel_foc_trigger)(Z_AXIS,
+			data, &accel_offset_z);
+	if (err)
+		return -EIO;
+	else
+		client_data->calib_status |=
+			SMI_FAST_CALI_TRUE << SMI_ACC_Z_FAST_CALI_RDY;
+
+	if (client_data->calib_status == SMI_FAST_CALI_ALL_RDY) {
+		err = SMI_CALL_API(get_accel_offset_compensation_xaxis)(
+			&data1[0]);
+		err += SMI_CALL_API(get_accel_offset_compensation_yaxis)(
+			&data1[1]);
+		err += SMI_CALL_API(get_accel_offset_compensation_zaxis)(
+			&data1[2]);
+		dev_info(client_data->dev, "accx %d, accy %d, accz %d\n",
+			data1[0], data1[1], data1[2]);
+		if (err)
+			return -EIO;
+		input_event(client_data->input, EV_MSC,
+		INPUT_EVENT_FAST_ACC_CALIB_DONE,
+		(data1[0] | (data1[1] << 8) | (data1[2] << 16)));
+		input_sync(client_data->input);
+		client_data->calib_status = 0;
+	}
+
+	return count;
+}
+
+static ssize_t smi130_acc_offset_x_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data;
+	int err;
+
+	err = SMI_CALL_API(get_accel_offset_compensation_xaxis)(&data);
+
+	if (err < 0)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+
+static ssize_t smi130_acc_offset_x_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	err = SMI_CALL_API(set_accel_offset_compensation_xaxis)
+						((unsigned char)data);
+
+	if (err < 0)
+		return -EIO;
+	return count;
+}
+
+static ssize_t smi130_acc_offset_y_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data;
+	int err;
+
+	err = SMI_CALL_API(get_accel_offset_compensation_yaxis)(&data);
+
+	if (err < 0)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t smi130_acc_offset_y_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	err = SMI_CALL_API(set_accel_offset_compensation_yaxis)
+						((unsigned char)data);
+
+	if (err < 0)
+		return -EIO;
+	return count;
+}
+
+static ssize_t smi130_acc_offset_z_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data;
+	int err;
+
+	err = SMI_CALL_API(get_accel_offset_compensation_zaxis)(&data);
+
+	if (err < 0)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t smi130_acc_offset_z_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	err = SMI_CALL_API(set_accel_offset_compensation_zaxis)
+						((unsigned char)data);
+
+	if (err < 0)
+		return -EIO;
+	return count;
+}
+
+static ssize_t smi130_test_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+	u8 raw_data[15] = {0};
+	unsigned int sensor_time = 0;
+
+	int err;
+	memset(raw_data, 0, sizeof(raw_data));
+
+	err = client_data->device.bus_read(client_data->device.dev_addr,
+			SMI130_USER_DATA_8_GYRO_X_LSB__REG, raw_data, 15);
+	if (err)
+		return err;
+
+	udelay(10);
+	sensor_time = (u32)(raw_data[14] << 16 | raw_data[13] << 8
+						| raw_data[12]);
+
+	return snprintf(buf, 128, "%d %d %d %d %d %d %u",
+					(s16)(raw_data[1] << 8 | raw_data[0]),
+				(s16)(raw_data[3] << 8 | raw_data[2]),
+				(s16)(raw_data[5] << 8 | raw_data[4]),
+				(s16)(raw_data[7] << 8 | raw_data[6]),
+				(s16)(raw_data[9] << 8 | raw_data[8]),
+				(s16)(raw_data[11] << 8 | raw_data[10]),
+				sensor_time);
+
+}
+
+static ssize_t smi130_step_counter_enable_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data;
+	int err;
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+
+	err = SMI_CALL_API(get_step_counter_enable)(&data);
+
+	client_data->stc_enable = data;
+
+	if (err < 0)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t smi130_step_counter_enable_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	err = SMI_CALL_API(set_step_counter_enable)((unsigned char)data);
+
+	client_data->stc_enable = data;
+
+	if (err < 0)
+		return -EIO;
+	return count;
+}
+
+
+static ssize_t smi130_step_counter_mode_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	err = SMI_CALL_API(set_step_mode)((unsigned char)data);
+
+	if (err < 0)
+		return -EIO;
+	return count;
+}
+
+static ssize_t smi130_step_counter_clc_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	err = smi130_clear_step_counter();
+
+	if (err < 0)
+		return -EIO;
+	return count;
+}
+
+static ssize_t smi130_step_counter_value_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	u16 data;
+	int err;
+	static u16 last_stc_value;
+
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+
+	err = SMI_CALL_API(read_step_count)(&data);
+
+	if (err < 0)
+		return err;
+	if (data >= last_stc_value) {
+		client_data->pedo_data.last_step_counter_value += (
+			data - last_stc_value);
+		last_stc_value = data;
+	} else
+		last_stc_value = data;
+	return snprintf(buf, 16, "%d\n",
+		client_data->pedo_data.last_step_counter_value);
+}
+
+static ssize_t smi130_smi_value_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+	u8 raw_data[12] = {0};
+
+	int err;
+	memset(raw_data, 0, sizeof(raw_data));
+
+	err = client_data->device.bus_read(client_data->device.dev_addr,
+			SMI130_USER_DATA_8_GYRO_X_LSB__REG, raw_data, 12);
+	if (err)
+		return err;
+	/*output:gyro x y z acc x y z*/
+	return snprintf(buf, 96, "%hd %d %hd %hd %hd %hd\n",
+					(s16)(raw_data[1] << 8 | raw_data[0]),
+				(s16)(raw_data[3] << 8 | raw_data[2]),
+				(s16)(raw_data[5] << 8 | raw_data[4]),
+				(s16)(raw_data[7] << 8 | raw_data[6]),
+				(s16)(raw_data[9] << 8 | raw_data[8]),
+				(s16)(raw_data[11] << 8 | raw_data[10]));
+
+}
+
+
+static ssize_t smi130_selftest_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+
+	return snprintf(buf, 16, "0x%x\n",
+				atomic_read(&client_data->selftest_result));
+}
+
+static int smi_restore_hw_cfg(struct smi_client_data *client);
+
+/*!
+ * @brief store selftest result which make up of acc and gyro
+ * format: 0b 0000 xxxx  x:1 failed, 0 success
+ * bit3:     gyro_self
+ * bit2..0: acc_self z y x
+ */
+static ssize_t smi130_selftest_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+	int err = 0;
+	int i = 0;
+
+	u8 acc_selftest = 0;
+	u8 gyro_selftest = 0;
+	u8 smi_selftest = 0;
+	s16 axis_p_value, axis_n_value;
+	u16 diff_axis[3] = {0xff, 0xff, 0xff};
+	u8 acc_odr, range, acc_selftest_amp, acc_selftest_sign;
+
+	dev_notice(client_data->dev, "Selftest for SMI16x starting.\n");
+
+	client_data->selftest = 1;
+
+	/*soft reset*/
+	err = SMI_CALL_API(set_command_register)(CMD_RESET_USER_REG);
+	msleep(70);
+	err += SMI_CALL_API(set_command_register)
+				(smi_pmu_cmd_acc_arr[SMI_ACC_PM_NORMAL]);
+	err += SMI_CALL_API(set_command_register)
+				(smi_pmu_cmd_gyro_arr[SMI_GYRO_PM_NORMAL]);
+	err += SMI_CALL_API(set_accel_under_sampling_parameter)(0);
+	err += SMI_CALL_API(set_accel_output_data_rate)(
+	SMI130_ACCEL_OUTPUT_DATA_RATE_1600HZ);
+
+	/* set to 8G range*/
+	err += SMI_CALL_API(set_accel_range)(SMI130_ACCEL_RANGE_8G);
+	/* set to self amp high */
+	err += SMI_CALL_API(set_accel_selftest_amp)(SMI_SELFTEST_AMP_HIGH);
+
+
+	err += SMI_CALL_API(get_accel_output_data_rate)(&acc_odr);
+	err += SMI_CALL_API(get_accel_range)(&range);
+	err += SMI_CALL_API(get_accel_selftest_amp)(&acc_selftest_amp);
+	err += SMI_CALL_API(read_accel_x)(&axis_n_value);
+
+	dev_info(client_data->dev,
+			"acc_odr:%d, acc_range:%d, acc_selftest_amp:%d, acc_x:%d\n",
+				acc_odr, range, acc_selftest_amp, axis_n_value);
+
+	for (i = X_AXIS; i < AXIS_MAX; i++) {
+		axis_n_value = 0;
+		axis_p_value = 0;
+		/* set every selftest axis */
+		/*set_acc_selftest_axis(param),param x:1, y:2, z:3
+		* but X_AXIS:0, Y_AXIS:1, Z_AXIS:2
+		* so we need to +1*/
+		err += SMI_CALL_API(set_accel_selftest_axis)(i + 1);
+		msleep(50);
+		switch (i) {
+		case X_AXIS:
+			/* set negative sign */
+			err += SMI_CALL_API(set_accel_selftest_sign)(0);
+			err += SMI_CALL_API(get_accel_selftest_sign)(
+				&acc_selftest_sign);
+
+			msleep(60);
+			err += SMI_CALL_API(read_accel_x)(&axis_n_value);
+			dev_info(client_data->dev,
+			"acc_x_selftest_sign:%d, axis_n_value:%d\n",
+			acc_selftest_sign, axis_n_value);
+
+			/* set postive sign */
+			err += SMI_CALL_API(set_accel_selftest_sign)(1);
+			err += SMI_CALL_API(get_accel_selftest_sign)(
+				&acc_selftest_sign);
+
+			msleep(60);
+			err += SMI_CALL_API(read_accel_x)(&axis_p_value);
+			dev_info(client_data->dev,
+			"acc_x_selftest_sign:%d, axis_p_value:%d\n",
+			acc_selftest_sign, axis_p_value);
+			diff_axis[i] = abs(axis_p_value - axis_n_value);
+			break;
+
+		case Y_AXIS:
+			/* set negative sign */
+			err += SMI_CALL_API(set_accel_selftest_sign)(0);
+			msleep(60);
+			err += SMI_CALL_API(read_accel_y)(&axis_n_value);
+			/* set postive sign */
+			err += SMI_CALL_API(set_accel_selftest_sign)(1);
+			msleep(60);
+			err += SMI_CALL_API(read_accel_y)(&axis_p_value);
+			diff_axis[i] = abs(axis_p_value - axis_n_value);
+			break;
+
+		case Z_AXIS:
+			/* set negative sign */
+			err += SMI_CALL_API(set_accel_selftest_sign)(0);
+			msleep(60);
+			err += SMI_CALL_API(read_accel_z)(&axis_n_value);
+			/* set postive sign */
+			err += SMI_CALL_API(set_accel_selftest_sign)(1);
+			msleep(60);
+			err += SMI_CALL_API(read_accel_z)(&axis_p_value);
+			/* also start gyro self test */
+			err += SMI_CALL_API(set_gyro_selftest_start)(1);
+			msleep(60);
+			err += SMI_CALL_API(get_gyro_selftest)(&gyro_selftest);
+
+			diff_axis[i] = abs(axis_p_value - axis_n_value);
+			break;
+		default:
+			err += -EINVAL;
+			break;
+		}
+		if (err) {
+			dev_err(client_data->dev,
+				"Failed selftest axis:%s, p_val=%d, n_val=%d\n",
+				smi_axis_name[i], axis_p_value, axis_n_value);
+			client_data->selftest = 0;
+			return -EINVAL;
+		}
+
+		/*400mg for acc z axis*/
+		if (Z_AXIS == i) {
+			if (diff_axis[i] < 1639) {
+				acc_selftest |= 1 << i;
+				dev_err(client_data->dev,
+					"Over selftest minimum for "
+					"axis:%s,diff=%d,p_val=%d, n_val=%d\n",
+					smi_axis_name[i], diff_axis[i],
+						axis_p_value, axis_n_value);
+			}
+		} else {
+			/*800mg for x or y axis*/
+			if (diff_axis[i] < 3277) {
+				acc_selftest |= 1 << i;
+
+				if (smi_get_err_status(client_data) < 0)
+					return err;
+				dev_err(client_data->dev,
+					"Over selftest minimum for "
+					"axis:%s,diff=%d, p_val=%d, n_val=%d\n",
+					smi_axis_name[i], diff_axis[i],
+						axis_p_value, axis_n_value);
+				dev_err(client_data->dev, "err_st:0x%x\n",
+						client_data->err_st.err_st_all);
+
+			}
+		}
+
+	}
+	/* gyro_selftest==1,gyro selftest successfully,
+	* but smi_result bit4 0 is successful, 1 is failed*/
+	smi_selftest = (acc_selftest & 0x0f) | ((!gyro_selftest) << AXIS_MAX);
+	atomic_set(&client_data->selftest_result, smi_selftest);
+	/*soft reset*/
+	err = SMI_CALL_API(set_command_register)(CMD_RESET_USER_REG);
+	if (err) {
+		client_data->selftest = 0;
+		return err;
+	}
+	msleep(50);
+
+	smi_restore_hw_cfg(client_data);
+
+	client_data->selftest = 0;
+	dev_notice(client_data->dev, "Selftest for SMI16x finished\n");
+
+	return count;
+}
+
+/* gyro sensor part */
+static ssize_t smi130_gyro_op_mode_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+	int err = 0;
+	u8 gyro_pmu_status = 0;
+
+	err = SMI_CALL_API(get_gyro_power_mode_stat)(
+		&gyro_pmu_status);
+
+	if (err)
+		return err;
+	else
+	return snprintf(buf, 32, "reg:%d, val:%d\n", gyro_pmu_status,
+				client_data->pw.gyro_pm);
+}
+
+static ssize_t smi130_gyro_op_mode_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+	unsigned long op_mode;
+	int err;
+
+	err = kstrtoul(buf, 10, &op_mode);
+	if (err)
+		return err;
+
+	mutex_lock(&client_data->mutex_op_mode);
+
+	if (op_mode < SMI_GYRO_PM_MAX) {
+		switch (op_mode) {
+		case SMI_GYRO_PM_NORMAL:
+			err = SMI_CALL_API(set_command_register)
+				(smi_pmu_cmd_gyro_arr[SMI_GYRO_PM_NORMAL]);
+			client_data->pw.gyro_pm = SMI_GYRO_PM_NORMAL;
+			smi_delay(60);
+			break;
+		case SMI_GYRO_PM_FAST_START:
+			err = SMI_CALL_API(set_command_register)
+				(smi_pmu_cmd_gyro_arr[SMI_GYRO_PM_FAST_START]);
+			client_data->pw.gyro_pm = SMI_GYRO_PM_FAST_START;
+			smi_delay(60);
+			break;
+		case SMI_GYRO_PM_SUSPEND:
+			err = SMI_CALL_API(set_command_register)
+				(smi_pmu_cmd_gyro_arr[SMI_GYRO_PM_SUSPEND]);
+			client_data->pw.gyro_pm = SMI_GYRO_PM_SUSPEND;
+			smi_delay(60);
+			break;
+		default:
+			mutex_unlock(&client_data->mutex_op_mode);
+			return -EINVAL;
+		}
+	} else {
+		mutex_unlock(&client_data->mutex_op_mode);
+		return -EINVAL;
+	}
+
+	mutex_unlock(&client_data->mutex_op_mode);
+
+	if (err)
+		return err;
+	else
+		return count;
+
+}
+
+static ssize_t smi130_gyro_value_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct smi130_gyro_t data;
+	int err;
+
+	err = SMI_CALL_API(read_gyro_xyz)(&data);
+	if (err < 0)
+		return err;
+
+
+	return snprintf(buf, 48, "%hd %hd %hd\n", data.x,
+				data.y, data.z);
+}
+
+static ssize_t smi130_gyro_range_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err;
+	unsigned char range;
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+
+	err = SMI_CALL_API(get_gyro_range)(&range);
+	if (err)
+		return err;
+
+	client_data->range.gyro_range = range;
+	return snprintf(buf, 16, "%d\n", range);
+}
+
+static ssize_t smi130_gyro_range_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	int err;
+	unsigned long range;
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+
+	err = kstrtoul(buf, 10, &range);
+	if (err)
+		return err;
+
+	err = SMI_CALL_API(set_gyro_range)(range);
+	if (err)
+		return -EIO;
+
+	client_data->range.gyro_range = range;
+	return count;
+}
+
+static ssize_t smi130_gyro_odr_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err;
+	unsigned char gyro_odr;
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+
+	err = SMI_CALL_API(get_gyro_output_data_rate)(&gyro_odr);
+	if (err)
+		return err;
+
+	client_data->odr.gyro_odr = gyro_odr;
+	return snprintf(buf, 16, "%d\n", gyro_odr);
+}
+
+static ssize_t smi130_gyro_odr_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	int err;
+	unsigned long gyro_odr;
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+
+	err = kstrtoul(buf, 10, &gyro_odr);
+	if (err)
+		return err;
+
+	if (gyro_odr < 6 || gyro_odr > 13)
+		return -EIO;
+
+	err = SMI_CALL_API(set_gyro_output_data_rate)(gyro_odr);
+	if (err)
+		return -EIO;
+
+	client_data->odr.gyro_odr = gyro_odr;
+	return count;
+}
+
+static ssize_t smi130_gyro_fast_calibration_en_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char data;
+	int err;
+
+	err = SMI_CALL_API(get_foc_gyro_enable)(&data);
+
+	if (err < 0)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t smi130_gyro_fast_calibration_en_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long enable;
+	s8 err;
+	s16 gyr_off_x;
+	s16 gyr_off_y;
+	s16 gyr_off_z;
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+
+	err = kstrtoul(buf, 10, &enable);
+	if (err)
+		return err;
+
+	err = SMI_CALL_API(set_foc_gyro_enable)((u8)enable,
+				&gyr_off_x, &gyr_off_y, &gyr_off_z);
+
+	if (err < 0)
+		return -EIO;
+	else {
+		input_event(client_data->input, EV_MSC,
+			INPUT_EVENT_FAST_GYRO_CALIB_DONE, 1);
+		input_sync(client_data->input);
+	}
+	return count;
+}
+
+static ssize_t smi130_gyro_offset_x_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	s16 data = 0;
+	s8 err = 0;
+
+	err = SMI_CALL_API(get_gyro_offset_compensation_xaxis)(&data);
+
+	if (err < 0)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t smi130_gyro_offset_x_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	s8 err;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	err = SMI_CALL_API(set_gyro_offset_compensation_xaxis)((s16)data);
+
+	if (err < 0)
+		return -EIO;
+	return count;
+}
+
+static ssize_t smi130_gyro_offset_y_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	s16 data = 0;
+	s8 err = 0;
+
+	err = SMI_CALL_API(get_gyro_offset_compensation_yaxis)(&data);
+
+	if (err < 0)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t smi130_gyro_offset_y_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	s8 err;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	err = SMI_CALL_API(set_gyro_offset_compensation_yaxis)((s16)data);
+
+	if (err < 0)
+		return -EIO;
+	return count;
+}
+
+static ssize_t smi130_gyro_offset_z_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	s16 data = 0;
+	int err = 0;
+
+	err = SMI_CALL_API(get_gyro_offset_compensation_zaxis)(&data);
+
+	if (err < 0)
+		return err;
+	return snprintf(buf, 16, "%d\n", data);
+}
+
+static ssize_t smi130_gyro_offset_z_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	err = SMI_CALL_API(set_gyro_offset_compensation_zaxis)((s16)data);
+
+	if (err < 0)
+		return -EIO;
+	return count;
+}
+
+
+/* mag sensor part */
+#ifdef SMI130_MAG_INTERFACE_SUPPORT
+static ssize_t smi130_mag_op_mode_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+	u8 mag_op_mode;
+	s8 err;
+	err = smi130_get_mag_power_mode_stat(&mag_op_mode);
+	if (err) {
+		dev_err(client_data->dev,
+			"Failed to get SMI130 mag power mode:%d\n", err);
+		return err;
+	} else
+		return snprintf(buf, 32, "%d, reg:%d\n",
+					client_data->pw.mag_pm, mag_op_mode);
+}
+
+static ssize_t smi130_mag_op_mode_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+	unsigned long op_mode;
+	int err;
+
+	err = kstrtoul(buf, 10, &op_mode);
+	if (err)
+		return err;
+
+	if (op_mode == client_data->pw.mag_pm)
+		return count;
+
+	mutex_lock(&client_data->mutex_op_mode);
+
+
+	if (op_mode < SMI_MAG_PM_MAX) {
+		switch (op_mode) {
+		case SMI_MAG_PM_NORMAL:
+			/* need to modify as mag sensor connected,
+			 * set write address to 0x4c and triggers
+			 * write operation
+			 * 0x4c(op mode control reg)
+			 * enables normal mode in magnetometer */
+#if defined(SMI130_AKM09912_SUPPORT)
+			err = smi130_set_bosch_akm_and_secondary_if_powermode(
+			SMI130_MAG_FORCE_MODE);
+#else
+			err = smi130_set_bmm150_mag_and_secondary_if_power_mode(
+			SMI130_MAG_FORCE_MODE);
+#endif
+			client_data->pw.mag_pm = SMI_MAG_PM_NORMAL;
+			smi_delay(5);
+			break;
+		case SMI_MAG_PM_LP1:
+			/* need to modify as mag sensor connected,
+			 * set write address to 0x4 band triggers
+			 * write operation
+			 * 0x4b(bmm150, power control reg, bit0)
+			 * enables power in magnetometer*/
+#if defined(SMI130_AKM09912_SUPPORT)
+			err = smi130_set_bosch_akm_and_secondary_if_powermode(
+			SMI130_MAG_FORCE_MODE);
+#else
+			err = smi130_set_bmm150_mag_and_secondary_if_power_mode(
+			SMI130_MAG_FORCE_MODE);
+#endif
+			client_data->pw.mag_pm = SMI_MAG_PM_LP1;
+			smi_delay(5);
+			break;
+		case SMI_MAG_PM_SUSPEND:
+		case SMI_MAG_PM_LP2:
+#if defined(SMI130_AKM09912_SUPPORT)
+		err = smi130_set_bosch_akm_and_secondary_if_powermode(
+		SMI130_MAG_SUSPEND_MODE);
+#else
+		err = smi130_set_bmm150_mag_and_secondary_if_power_mode(
+		SMI130_MAG_SUSPEND_MODE);
+#endif
+			client_data->pw.mag_pm = op_mode;
+			smi_delay(5);
+			break;
+		default:
+			mutex_unlock(&client_data->mutex_op_mode);
+			return -EINVAL;
+		}
+	} else {
+		mutex_unlock(&client_data->mutex_op_mode);
+		return -EINVAL;
+	}
+
+	mutex_unlock(&client_data->mutex_op_mode);
+
+	if (err) {
+		dev_err(client_data->dev,
+			"Failed to switch SMI130 mag power mode:%d\n",
+			client_data->pw.mag_pm);
+		return err;
+	} else
+		return count;
+
+}
+
+static ssize_t smi130_mag_odr_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err = 0;
+	unsigned char mag_odr = 0;
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+
+	err = SMI_CALL_API(get_mag_output_data_rate)(&mag_odr);
+	if (err)
+		return err;
+
+	client_data->odr.mag_odr = mag_odr;
+	return snprintf(buf, 16, "%d\n", mag_odr);
+}
+
+static ssize_t smi130_mag_odr_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	int err;
+	unsigned long mag_odr;
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+
+	err = kstrtoul(buf, 10, &mag_odr);
+	if (err)
+		return err;
+	/*1~25/32hz,..6(25hz),7(50hz),... */
+	err = SMI_CALL_API(set_mag_output_data_rate)(mag_odr);
+	if (err)
+		return -EIO;
+
+	client_data->odr.mag_odr = mag_odr;
+	return count;
+}
+
+static ssize_t smi130_mag_i2c_address_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	u8 data;
+	s8 err;
+
+	err = SMI_CALL_API(set_mag_manual_enable)(1);
+	err += SMI_CALL_API(get_i2c_device_addr)(&data);
+	err += SMI_CALL_API(set_mag_manual_enable)(0);
+
+	if (err < 0)
+		return err;
+	return snprintf(buf, 16, "0x%x\n", data);
+}
+
+static ssize_t smi130_mag_i2c_address_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	err += SMI_CALL_API(set_mag_manual_enable)(1);
+	if (!err)
+		err += SMI_CALL_API(set_i2c_device_addr)((unsigned char)data);
+	err += SMI_CALL_API(set_mag_manual_enable)(0);
+
+	if (err < 0)
+		return -EIO;
+	return count;
+}
+
+static ssize_t smi130_mag_value_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+	struct smi130_mag_xyz_s32_t data;
+	int err;
+	/* raw data with compensation */
+#if defined(SMI130_AKM09912_SUPPORT)
+	err = smi130_bosch_akm09912_compensate_xyz(&data);
+#else
+	err = smi130_bmm150_mag_compensate_xyz(&data);
+#endif
+
+	if (err < 0) {
+		memset(&data, 0, sizeof(data));
+		dev_err(client_data->dev, "mag not ready!\n");
+	}
+	return snprintf(buf, 48, "%hd %hd %hd\n", data.x,
+				data.y, data.z);
+}
+static ssize_t smi130_mag_offset_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err = 0;
+	unsigned char mag_offset;
+	err = SMI_CALL_API(get_mag_offset)(&mag_offset);
+	if (err)
+		return err;
+
+	return snprintf(buf, 16, "%d\n", mag_offset);
+
+}
+
+static ssize_t smi130_mag_offset_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	err += SMI_CALL_API(set_mag_manual_enable)(1);
+	if (err == 0)
+		err += SMI_CALL_API(set_mag_offset)((unsigned char)data);
+	err += SMI_CALL_API(set_mag_manual_enable)(0);
+
+	if (err < 0)
+		return -EIO;
+	return count;
+}
+
+static ssize_t smi130_mag_chip_id_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	s8 err = 0;
+	u8 mag_chipid;
+
+	err = smi130_set_mag_manual_enable(0x01);
+	/* read mag chip_id value */
+#if defined(SMI130_AKM09912_SUPPORT)
+	err += smi130_set_mag_read_addr(AKM09912_CHIP_ID_REG);
+		/* 0x04 is mag_x lsb register */
+	err += smi130_read_reg(SMI130_USER_DATA_0_MAG_X_LSB__REG,
+							&mag_chipid, 1);
+
+	/* Must add this commands to re-set data register addr of mag sensor */
+	err += smi130_set_mag_read_addr(AKM_DATA_REGISTER);
+#else
+	err += smi130_set_mag_read_addr(SMI130_BMM150_CHIP_ID);
+	/* 0x04 is mag_x lsb register */
+	err += smi130_read_reg(SMI130_USER_DATA_0_MAG_X_LSB__REG,
+							&mag_chipid, 1);
+
+	/* Must add this commands to re-set data register addr of mag sensor */
+	/* 0x42 is  bmm150 data register address */
+	err += smi130_set_mag_read_addr(SMI130_BMM150_DATA_REG);
+#endif
+
+	err += smi130_set_mag_manual_enable(0x00);
+
+	if (err)
+		return err;
+
+	return snprintf(buf, 16, "%x\n", mag_chipid);
+
+}
+
+static ssize_t smi130_mag_chip_name_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	u8 mag_chipid = 0;
+#if defined(SMI130_AKM09912_SUPPORT)
+	mag_chipid = 15;
+#else
+	mag_chipid = 150;
+#endif
+	return snprintf(buf, 16, "%d\n", mag_chipid);
+}
+
+struct smi130_mag_xyz_s32_t mag_compensate;
+static ssize_t smi130_mag_compensate_xyz_show(struct device *dev,
+	struct device_attribute *attr, char *buf)
+{
+	memcpy(buf, &mag_compensate, sizeof(mag_compensate));
+	return sizeof(mag_compensate);
+}
+static ssize_t smi130_mag_compensate_xyz_store(struct device *dev,
+	struct device_attribute *attr, const char *buf, size_t count)
+{
+	struct smi130_mag_xyzr_t mag_raw;
+	memset(&mag_compensate, 0, sizeof(mag_compensate));
+	memset(&mag_raw, 0, sizeof(mag_raw));
+	mag_raw.x = (buf[1] << 8 | buf[0]);
+	mag_raw.y = (buf[3] << 8 | buf[2]);
+	mag_raw.z = (buf[5] << 8 | buf[4]);
+	mag_raw.r = (buf[7] << 8 | buf[6]);
+	mag_raw.x = mag_raw.x >> 3;
+	mag_raw.y = mag_raw.y >> 3;
+	mag_raw.z = mag_raw.z >> 1;
+	mag_raw.r = mag_raw.r >> 2;
+	smi130_bmm150_mag_compensate_xyz_raw(
+	&mag_compensate, mag_raw);
+	return count;
+}
+
+#endif
+
+#if defined(SMI130_ENABLE_INT1) || defined(SMI130_ENABLE_INT2)
+static ssize_t smi_enable_int_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	int interrupt_type, value;
+
+	sscanf(buf, "%3d %3d", &interrupt_type, &value);
+
+	if (interrupt_type < 0 || interrupt_type > 16)
+		return -EINVAL;
+
+	if (interrupt_type <= SMI_FLAT_INT) {
+		if (SMI_CALL_API(set_intr_enable_0)
+				(smi_interrupt_type[interrupt_type], value) < 0)
+			return -EINVAL;
+	} else if (interrupt_type <= SMI_FWM_INT) {
+		if (SMI_CALL_API(set_intr_enable_1)
+			(smi_interrupt_type[interrupt_type], value) < 0)
+			return -EINVAL;
+	} else {
+		if (SMI_CALL_API(set_intr_enable_2)
+			(smi_interrupt_type[interrupt_type], value) < 0)
+			return -EINVAL;
+	}
+
+	return count;
+}
+
+#endif
+
+static ssize_t smi130_show_reg_sel(struct device *dev
+		, struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+
+	if (client_data == NULL) {
+		printk(KERN_ERR "Invalid client_data pointer");
+		return -ENODEV;
+	}
+
+	return snprintf(buf, 64, "reg=0X%02X, len=%d\n",
+		client_data->reg_sel, client_data->reg_len);
+}
+
+static ssize_t smi130_store_reg_sel(struct device *dev
+		, struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+	ssize_t ret;
+
+	if (client_data == NULL) {
+		printk(KERN_ERR "Invalid client_data pointer");
+		return -ENODEV;
+	}
+	ret = sscanf(buf, "%11X %11d",
+		&client_data->reg_sel, &client_data->reg_len);
+	if (ret != 2) {
+		dev_err(client_data->dev, "Invalid argument");
+		return -EINVAL;
+	}
+
+	return count;
+}
+
+static ssize_t smi130_show_reg_val(struct device *dev
+		, struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+
+	ssize_t ret;
+	u8 reg_data[128], i;
+	int pos;
+
+	if (client_data == NULL) {
+		printk(KERN_ERR "Invalid client_data pointer");
+		return -ENODEV;
+	}
+
+	ret = smi_burst_read_wrapper(client_data->device.dev_addr,
+		client_data->reg_sel,
+		reg_data, client_data->reg_len);
+	if (ret < 0) {
+		dev_err(client_data->dev, "Reg op failed");
+		return ret;
+	}
+
+	pos = 0;
+	for (i = 0; i < client_data->reg_len; ++i) {
+		pos += snprintf(buf + pos, 16, "%02X", reg_data[i]);
+		buf[pos++] = (i + 1) % 16 == 0 ? '\n' : ' ';
+	}
+	if (buf[pos - 1] == ' ')
+		buf[pos - 1] = '\n';
+
+	return pos;
+}
+
+static ssize_t smi130_store_reg_val(struct device *dev
+		, struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+	ssize_t ret;
+	u8 reg_data[32];
+	int i, j, status, digit;
+
+	if (client_data == NULL) {
+		printk(KERN_ERR "Invalid client_data pointer");
+		return -ENODEV;
+	}
+	status = 0;
+	for (i = j = 0; i < count && j < client_data->reg_len; ++i) {
+		if (buf[i] == ' ' || buf[i] == '\n' || buf[i] == '\t' ||
+			buf[i] == '\r') {
+			status = 0;
+			++j;
+			continue;
+		}
+		digit = buf[i] & 0x10 ? (buf[i] & 0xF) : ((buf[i] & 0xF) + 9);
+		printk(KERN_INFO "digit is %d", digit);
+		switch (status) {
+		case 2:
+			++j; /* Fall thru */
+		case 0:
+			reg_data[j] = digit;
+			status = 1;
+			break;
+		case 1:
+			reg_data[j] = reg_data[j] * 16 + digit;
+			status = 2;
+			break;
+		}
+	}
+	if (status > 0)
+		++j;
+	if (j > client_data->reg_len)
+		j = client_data->reg_len;
+	else if (j < client_data->reg_len) {
+		dev_err(client_data->dev, "Invalid argument");
+		return -EINVAL;
+	}
+	printk(KERN_INFO "Reg data read as");
+	for (i = 0; i < j; ++i)
+		printk(KERN_INFO "%d", reg_data[i]);
+
+	ret = SMI_CALL_API(write_reg)(
+		client_data->reg_sel,
+		reg_data, client_data->reg_len);
+	if (ret < 0) {
+		dev_err(client_data->dev, "Reg op failed");
+		return ret;
+	}
+
+	return count;
+}
+
+static ssize_t smi130_driver_version_show(struct device *dev
+		, struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_client_data *client_data = input_get_drvdata(input);
+	int ret;
+
+	if (client_data == NULL) {
+		printk(KERN_ERR "Invalid client_data pointer");
+		return -ENODEV;
+	}
+
+	ret = snprintf(buf, 128, "Driver version: %s\n",
+			DRIVER_VERSION);
+
+	return ret;
+}
+static DEVICE_ATTR(chip_id, S_IRUGO,
+		smi130_chip_id_show, NULL);
+static DEVICE_ATTR(err_st, S_IRUGO,
+		smi130_err_st_show, NULL);
+static DEVICE_ATTR(sensor_time, S_IRUGO,
+		smi130_sensor_time_show, NULL);
+
+static DEVICE_ATTR(selftest, S_IRUGO | S_IWUSR,
+		smi130_selftest_show, smi130_selftest_store);
+static DEVICE_ATTR(fifo_flush, S_IRUGO | S_IWUSR,
+		NULL, smi130_fifo_flush_store);
+static DEVICE_ATTR(fifo_bytecount, S_IRUGO | S_IWUSR,
+		smi130_fifo_bytecount_show, smi130_fifo_bytecount_store);
+static DEVICE_ATTR(fifo_data_sel, S_IRUGO | S_IWUSR,
+		smi130_fifo_data_sel_show, smi130_fifo_data_sel_store);
+static DEVICE_ATTR(fifo_data_frame, S_IRUGO,
+		smi130_fifo_data_out_frame_show, NULL);
+
+static DEVICE_ATTR(fifo_watermark, S_IRUGO | S_IWUSR,
+		smi130_fifo_watermark_show, smi130_fifo_watermark_store);
+
+static DEVICE_ATTR(fifo_header_en, S_IRUGO | S_IWUSR,
+		smi130_fifo_header_en_show, smi130_fifo_header_en_store);
+static DEVICE_ATTR(fifo_time_en, S_IRUGO | S_IWUSR,
+		smi130_fifo_time_en_show, smi130_fifo_time_en_store);
+static DEVICE_ATTR(fifo_int_tag_en, S_IRUGO | S_IWUSR,
+		smi130_fifo_int_tag_en_show, smi130_fifo_int_tag_en_store);
+
+static DEVICE_ATTR(temperature, S_IRUGO,
+		smi130_temperature_show, NULL);
+static DEVICE_ATTR(place, S_IRUGO,
+		smi130_place_show, NULL);
+static DEVICE_ATTR(delay, S_IRUGO | S_IWUSR,
+		smi130_delay_show, smi130_delay_store);
+static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR,
+		smi130_enable_show, smi130_enable_store);
+static DEVICE_ATTR(acc_range, S_IRUGO | S_IWUSR,
+		smi130_acc_range_show, smi130_acc_range_store);
+static DEVICE_ATTR(acc_odr, S_IRUGO | S_IWUSR,
+		smi130_acc_odr_show, smi130_acc_odr_store);
+static DEVICE_ATTR(acc_op_mode, S_IRUGO | S_IWUSR,
+		smi130_acc_op_mode_show, smi130_acc_op_mode_store);
+static DEVICE_ATTR(acc_value, S_IRUGO,
+		smi130_acc_value_show, NULL);
+static DEVICE_ATTR(acc_fast_calibration_x, S_IRUGO | S_IWUSR,
+		smi130_acc_fast_calibration_x_show,
+		smi130_acc_fast_calibration_x_store);
+static DEVICE_ATTR(acc_fast_calibration_y, S_IRUGO | S_IWUSR,
+		smi130_acc_fast_calibration_y_show,
+		smi130_acc_fast_calibration_y_store);
+static DEVICE_ATTR(acc_fast_calibration_z, S_IRUGO | S_IWUSR,
+		smi130_acc_fast_calibration_z_show,
+		smi130_acc_fast_calibration_z_store);
+static DEVICE_ATTR(acc_offset_x, S_IRUGO | S_IWUSR,
+		smi130_acc_offset_x_show,
+		smi130_acc_offset_x_store);
+static DEVICE_ATTR(acc_offset_y, S_IRUGO | S_IWUSR,
+		smi130_acc_offset_y_show,
+		smi130_acc_offset_y_store);
+static DEVICE_ATTR(acc_offset_z, S_IRUGO | S_IWUSR,
+		smi130_acc_offset_z_show,
+		smi130_acc_offset_z_store);
+static DEVICE_ATTR(test, S_IRUGO,
+		smi130_test_show, NULL);
+static DEVICE_ATTR(stc_enable, S_IRUGO | S_IWUSR,
+		smi130_step_counter_enable_show,
+		smi130_step_counter_enable_store);
+static DEVICE_ATTR(stc_mode, S_IRUGO | S_IWUSR,
+		NULL, smi130_step_counter_mode_store);
+static DEVICE_ATTR(stc_clc, S_IRUGO | S_IWUSR,
+		NULL, smi130_step_counter_clc_store);
+static DEVICE_ATTR(stc_value, S_IRUGO,
+		smi130_step_counter_value_show, NULL);
+static DEVICE_ATTR(reg_sel, S_IRUGO | S_IWUSR,
+		smi130_show_reg_sel, smi130_store_reg_sel);
+static DEVICE_ATTR(reg_val, S_IRUGO | S_IWUSR,
+		smi130_show_reg_val, smi130_store_reg_val);
+static DEVICE_ATTR(driver_version, S_IRUGO,
+		smi130_driver_version_show, NULL);
+/* gyro part */
+static DEVICE_ATTR(gyro_op_mode, S_IRUGO | S_IWUSR,
+		smi130_gyro_op_mode_show, smi130_gyro_op_mode_store);
+static DEVICE_ATTR(gyro_value, S_IRUGO,
+		smi130_gyro_value_show, NULL);
+static DEVICE_ATTR(gyro_range, S_IRUGO | S_IWUSR,
+		smi130_gyro_range_show, smi130_gyro_range_store);
+static DEVICE_ATTR(gyro_odr, S_IRUGO | S_IWUSR,
+		smi130_gyro_odr_show, smi130_gyro_odr_store);
+static DEVICE_ATTR(gyro_fast_calibration_en, S_IRUGO | S_IWUSR,
+smi130_gyro_fast_calibration_en_show, smi130_gyro_fast_calibration_en_store);
+static DEVICE_ATTR(gyro_offset_x, S_IRUGO | S_IWUSR,
+smi130_gyro_offset_x_show, smi130_gyro_offset_x_store);
+static DEVICE_ATTR(gyro_offset_y, S_IRUGO | S_IWUSR,
+smi130_gyro_offset_y_show, smi130_gyro_offset_y_store);
+static DEVICE_ATTR(gyro_offset_z, S_IRUGO | S_IWUSR,
+smi130_gyro_offset_z_show, smi130_gyro_offset_z_store);
+
+#ifdef SMI130_MAG_INTERFACE_SUPPORT
+static DEVICE_ATTR(mag_op_mode, S_IRUGO | S_IWUSR,
+		smi130_mag_op_mode_show, smi130_mag_op_mode_store);
+static DEVICE_ATTR(mag_odr, S_IRUGO | S_IWUSR,
+		smi130_mag_odr_show, smi130_mag_odr_store);
+static DEVICE_ATTR(mag_i2c_addr, S_IRUGO | S_IWUSR,
+		smi130_mag_i2c_address_show, smi130_mag_i2c_address_store);
+static DEVICE_ATTR(mag_value, S_IRUGO,
+		smi130_mag_value_show, NULL);
+static DEVICE_ATTR(mag_offset, S_IRUGO | S_IWUSR,
+		smi130_mag_offset_show, smi130_mag_offset_store);
+static DEVICE_ATTR(mag_chip_id, S_IRUGO,
+		smi130_mag_chip_id_show, NULL);
+static DEVICE_ATTR(mag_chip_name, S_IRUGO,
+		smi130_mag_chip_name_show, NULL);
+static DEVICE_ATTR(mag_compensate, S_IRUGO | S_IWUSR,
+		smi130_mag_compensate_xyz_show,
+		smi130_mag_compensate_xyz_store);
+#endif
+
+
+#if defined(SMI130_ENABLE_INT1) || defined(SMI130_ENABLE_INT2)
+static DEVICE_ATTR(enable_int, S_IRUGO | S_IWUSR,
+		NULL, smi_enable_int_store);
+static DEVICE_ATTR(anymot_duration, S_IRUGO | S_IWUSR,
+		smi130_anymot_duration_show, smi130_anymot_duration_store);
+static DEVICE_ATTR(anymot_threshold, S_IRUGO | S_IWUSR,
+		smi130_anymot_threshold_show, smi130_anymot_threshold_store);
+static DEVICE_ATTR(std_stu, S_IRUGO,
+		smi130_step_detector_status_show, NULL);
+static DEVICE_ATTR(std_en, S_IRUGO | S_IWUSR,
+		smi130_step_detector_enable_show,
+		smi130_step_detector_enable_store);
+static DEVICE_ATTR(sig_en, S_IRUGO | S_IWUSR,
+		smi130_signification_motion_enable_show,
+		smi130_signification_motion_enable_store);
+
+#endif
+
+
+
+static DEVICE_ATTR(smi_value, S_IRUGO,
+		smi130_smi_value_show, NULL);
+
+
+static struct attribute *smi130_attributes[] = {
+	&dev_attr_chip_id.attr,
+	&dev_attr_err_st.attr,
+	&dev_attr_sensor_time.attr,
+	&dev_attr_selftest.attr,
+	&dev_attr_driver_version.attr,
+	&dev_attr_test.attr,
+	&dev_attr_fifo_flush.attr,
+	&dev_attr_fifo_header_en.attr,
+	&dev_attr_fifo_time_en.attr,
+	&dev_attr_fifo_int_tag_en.attr,
+	&dev_attr_fifo_bytecount.attr,
+	&dev_attr_fifo_data_sel.attr,
+	&dev_attr_fifo_data_frame.attr,
+
+	&dev_attr_fifo_watermark.attr,
+
+	&dev_attr_enable.attr,
+	&dev_attr_delay.attr,
+	&dev_attr_temperature.attr,
+	&dev_attr_place.attr,
+
+	&dev_attr_acc_range.attr,
+	&dev_attr_acc_odr.attr,
+	&dev_attr_acc_op_mode.attr,
+	&dev_attr_acc_value.attr,
+
+	&dev_attr_acc_fast_calibration_x.attr,
+	&dev_attr_acc_fast_calibration_y.attr,
+	&dev_attr_acc_fast_calibration_z.attr,
+	&dev_attr_acc_offset_x.attr,
+	&dev_attr_acc_offset_y.attr,
+	&dev_attr_acc_offset_z.attr,
+
+	&dev_attr_stc_enable.attr,
+	&dev_attr_stc_mode.attr,
+	&dev_attr_stc_clc.attr,
+	&dev_attr_stc_value.attr,
+
+	&dev_attr_gyro_op_mode.attr,
+	&dev_attr_gyro_value.attr,
+	&dev_attr_gyro_range.attr,
+	&dev_attr_gyro_odr.attr,
+	&dev_attr_gyro_fast_calibration_en.attr,
+	&dev_attr_gyro_offset_x.attr,
+	&dev_attr_gyro_offset_y.attr,
+	&dev_attr_gyro_offset_z.attr,
+
+#ifdef SMI130_MAG_INTERFACE_SUPPORT
+	&dev_attr_mag_chip_id.attr,
+	&dev_attr_mag_op_mode.attr,
+	&dev_attr_mag_odr.attr,
+	&dev_attr_mag_i2c_addr.attr,
+	&dev_attr_mag_chip_name.attr,
+	&dev_attr_mag_value.attr,
+	&dev_attr_mag_offset.attr,
+	&dev_attr_mag_compensate.attr,
+#endif
+
+#if defined(SMI130_ENABLE_INT1) || defined(SMI130_ENABLE_INT2)
+	&dev_attr_enable_int.attr,
+
+	&dev_attr_anymot_duration.attr,
+	&dev_attr_anymot_threshold.attr,
+	&dev_attr_std_stu.attr,
+	&dev_attr_std_en.attr,
+	&dev_attr_sig_en.attr,
+
+#endif
+	&dev_attr_reg_sel.attr,
+	&dev_attr_reg_val.attr,
+	&dev_attr_smi_value.attr,
+	NULL
+};
+
+static struct attribute_group smi130_attribute_group = {
+	.attrs = smi130_attributes
+};
+
+#if defined(SMI130_ENABLE_INT1) || defined(SMI130_ENABLE_INT2)
+static void smi_slope_interrupt_handle(struct smi_client_data *client_data)
+{
+	/* anym_first[0..2]: x, y, z */
+	u8 anym_first[3] = {0};
+	u8 status2;
+	u8 anym_sign;
+	u8 i = 0;
+
+	client_data->device.bus_read(client_data->device.dev_addr,
+				SMI130_USER_INTR_STAT_2_ADDR, &status2, 1);
+	anym_first[0] = SMI130_GET_BITSLICE(status2,
+				SMI130_USER_INTR_STAT_2_ANY_MOTION_FIRST_X);
+	anym_first[1] = SMI130_GET_BITSLICE(status2,
+				SMI130_USER_INTR_STAT_2_ANY_MOTION_FIRST_Y);
+	anym_first[2] = SMI130_GET_BITSLICE(status2,
+				SMI130_USER_INTR_STAT_2_ANY_MOTION_FIRST_Z);
+	anym_sign = SMI130_GET_BITSLICE(status2,
+				SMI130_USER_INTR_STAT_2_ANY_MOTION_SIGN);
+
+	for (i = 0; i < 3; i++) {
+		if (anym_first[i]) {
+			/*1: negative*/
+			if (anym_sign)
+				dev_notice(client_data->dev,
+				"Anymotion interrupt happend!"
+				"%s axis, negative sign\n", smi_axis_name[i]);
+			else
+				dev_notice(client_data->dev,
+				"Anymotion interrupt happend!"
+				"%s axis, postive sign\n", smi_axis_name[i]);
+		}
+	}
+
+
+}
+
+static void smi_fifo_watermark_interrupt_handle
+				(struct smi_client_data *client_data)
+{
+	int err = 0;
+	unsigned int fifo_len0 = 0;
+	unsigned int  fifo_frmbytes_ext = 0;
+	unsigned char *fifo_data = NULL;
+	fifo_data = kzalloc(FIFO_DATA_BUFSIZE, GFP_KERNEL);
+	/*TO DO*/
+	if (NULL == fifo_data) {
+			dev_err(client_data->dev, "no memory available");
+			err = -ENOMEM;
+	}
+	smi_fifo_frame_bytes_extend_calc(client_data, &fifo_frmbytes_ext);
+
+	if (client_data->pw.acc_pm == 2 && client_data->pw.gyro_pm == 2
+					&& client_data->pw.mag_pm == 2)
+		printk(KERN_INFO "pw_acc: %d, pw_gyro: %d\n",
+			client_data->pw.acc_pm, client_data->pw.gyro_pm);
+	if (!client_data->fifo_data_sel)
+		printk(KERN_INFO "no selsect sensor fifo, fifo_data_sel:%d\n",
+						client_data->fifo_data_sel);
+
+	err = SMI_CALL_API(fifo_length)(&fifo_len0);
+	client_data->fifo_bytecount = fifo_len0;
+
+	if (client_data->fifo_bytecount == 0 || err)
+		return;
+
+	if (client_data->fifo_bytecount + fifo_frmbytes_ext > FIFO_DATA_BUFSIZE)
+		client_data->fifo_bytecount = FIFO_DATA_BUFSIZE;
+	/* need give attention for the time of burst read*/
+	if (!err) {
+		err = smi_burst_read_wrapper(client_data->device.dev_addr,
+			SMI130_USER_FIFO_DATA__REG, fifo_data,
+			client_data->fifo_bytecount + fifo_frmbytes_ext);
+	} else
+		dev_err(client_data->dev, "read fifo leght err");
+
+	if (err)
+		dev_err(client_data->dev, "brust read fifo err\n");
+	/*err = smi_fifo_analysis_handle(client_data, fifo_data,
+			client_data->fifo_bytecount + 20, fifo_out_data);*/
+	if (fifo_data != NULL) {
+		kfree(fifo_data);
+		fifo_data = NULL;
+	}
+
+}
+static void smi_data_ready_interrupt_handle(
+	struct smi_client_data *client_data, uint8_t status)
+{
+	uint8_t data12[12] = {0};
+	struct smi130_accel_t accel;
+	struct smi130_gyro_t gyro;
+	struct timespec ts;
+	client_data->device.bus_read(client_data->device.dev_addr,
+	SMI130_USER_DATA_8_ADDR, data12, 12);
+	if (status & 0x80)
+	{
+		/*report acc data*/
+		/* Data X */
+		accel.x = (s16)((((s32)((s8)data12[7])) << SMI130_SHIFT_BIT_POSITION_BY_08_BITS) | (data12[6]));
+		/* Data Y */
+		accel.y = (s16)((((s32)((s8)data12[9])) << SMI130_SHIFT_BIT_POSITION_BY_08_BITS) | (data12[8]));
+		/* Data Z */
+		accel.z = (s16)((((s32)((s8)data12[11]))<< SMI130_SHIFT_BIT_POSITION_BY_08_BITS) | (data12[10]));
+		ts = ns_to_timespec(client_data->timestamp);
+		input_event(client_data->input, EV_MSC, 6, ts.tv_sec);
+		input_event(client_data->input, EV_MSC, 6, ts.tv_nsec);
+		input_event(client_data->input, EV_MSC, MSC_GESTURE, accel.x);
+		input_event(client_data->input, EV_MSC, MSC_RAW, accel.y);
+		input_event(client_data->input, EV_MSC, MSC_SCAN, accel.z);
+		input_sync(client_data->input);
+	}
+	if (status & 0x40)
+	{
+		/*report gyro data*/
+		/* Data X */
+		gyro.x = (s16)((((s32)((s8)data12[1])) << SMI130_SHIFT_BIT_POSITION_BY_08_BITS) | (data12[0]));
+		/* Data Y */
+		gyro.y = (s16)((((s32)((s8)data12[3])) << SMI130_SHIFT_BIT_POSITION_BY_08_BITS) | (data12[2]));
+		/* Data Z */
+		gyro.z = (s16)((((s32)((s8)data12[5]))<< SMI130_SHIFT_BIT_POSITION_BY_08_BITS) | (data12[4]));
+		ts = ns_to_timespec(client_data->timestamp);
+		input_event(client_data->gyro_input, EV_MSC, 6, ts.tv_sec);
+		input_event(client_data->gyro_input, EV_MSC, 6, ts.tv_nsec);
+		input_event(client_data->gyro_input, EV_MSC, MSC_GESTURE, gyro.x);
+		input_event(client_data->gyro_input, EV_MSC, MSC_RAW, gyro.y);
+		input_event(client_data->gyro_input, EV_MSC, MSC_SCAN, gyro.z);
+		input_sync(client_data->gyro_input);
+	}
+}
+
+static void smi_signification_motion_interrupt_handle(
+		struct smi_client_data *client_data)
+{
+	printk(KERN_INFO "smi_signification_motion_interrupt_handle\n");
+	input_event(client_data->input, EV_MSC, INPUT_EVENT_SGM, 1);
+/*input_report_rel(client_data->input,INPUT_EVENT_SGM,1);*/
+	input_sync(client_data->input);
+	smi130_set_command_register(CMD_RESET_INT_ENGINE);
+
+}
+static void smi_stepdetector_interrupt_handle(
+	struct smi_client_data *client_data)
+{
+	u8 current_step_dector_st = 0;
+	client_data->pedo_data.wkar_step_detector_status++;
+	current_step_dector_st =
+		client_data->pedo_data.wkar_step_detector_status;
+	client_data->std = ((current_step_dector_st == 1) ? 0 : 1);
+
+	input_event(client_data->input, EV_MSC, INPUT_EVENT_STEP_DETECTOR, 1);
+	input_sync(client_data->input);
+}
+
+static void smi_irq_work_func(struct work_struct *work)
+{
+	struct smi_client_data *client_data =
+		container_of((struct work_struct *)work,
+			struct smi_client_data, irq_work);
+
+	unsigned char int_status[4] = {0, 0, 0, 0};
+	uint8_t status = 0;
+
+	//client_data->device.bus_read(client_data->device.dev_addr,
+	//			SMI130_USER_INTR_STAT_0_ADDR, int_status, 4);
+	client_data->device.bus_read(client_data->device.dev_addr,
+	SMI130_USER_STAT_ADDR, &status, 1);
+	printk("status = 0x%x", status);
+	if (SMI130_GET_BITSLICE(int_status[0],
+					SMI130_USER_INTR_STAT_0_ANY_MOTION))
+		smi_slope_interrupt_handle(client_data);
+
+	if (SMI130_GET_BITSLICE(int_status[0],
+			SMI130_USER_INTR_STAT_0_STEP_INTR))
+		smi_stepdetector_interrupt_handle(client_data);
+	if (SMI130_GET_BITSLICE(int_status[1],
+			SMI130_USER_INTR_STAT_1_FIFO_WM_INTR))
+		smi_fifo_watermark_interrupt_handle(client_data);
+	if ((status & 0x80) || (status & 0x40))
+		smi_data_ready_interrupt_handle(client_data, status);
+	/* Clear ALL inputerrupt status after handler sig mition*/
+	/* Put this commads intot the last one*/
+	if (SMI130_GET_BITSLICE(int_status[0],
+		SMI130_USER_INTR_STAT_0_SIGNIFICANT_INTR))
+		smi_signification_motion_interrupt_handle(client_data);
+
+}
+
+static void smi130_delay_sigmo_work_func(struct work_struct *work)
+{
+	struct smi_client_data *client_data =
+	container_of(work, struct smi_client_data,
+	delay_work_sig.work);
+	unsigned char int_status[4] = {0, 0, 0, 0};
+
+	client_data->device.bus_read(client_data->device.dev_addr,
+				SMI130_USER_INTR_STAT_0_ADDR, int_status, 4);
+	if (SMI130_GET_BITSLICE(int_status[0],
+		SMI130_USER_INTR_STAT_0_SIGNIFICANT_INTR))
+		smi_signification_motion_interrupt_handle(client_data);
+}
+
+static irqreturn_t smi_irq_handler(int irq, void *handle)
+{
+	struct smi_client_data *client_data = handle;
+	int in_suspend_copy;
+	in_suspend_copy = atomic_read(&client_data->in_suspend);
+
+	if (client_data == NULL)
+		return IRQ_HANDLED;
+	if (client_data->dev == NULL)
+		return IRQ_HANDLED;
+		/*this only deal with SIG_motion CTS test*/
+	if ((in_suspend_copy == 1) &&
+		(client_data->sig_flag == 1)) {
+		/*wake_lock_timeout(&client_data->wakelock, HZ);*/
+		schedule_delayed_work(&client_data->delay_work_sig,
+			msecs_to_jiffies(50));
+	}
+	schedule_work(&client_data->irq_work);
+
+	return IRQ_HANDLED;
+}
+#endif /* defined(SMI_ENABLE_INT1)||defined(SMI_ENABLE_INT2) */
+
+static int smi_restore_hw_cfg(struct smi_client_data *client)
+{
+	int err = 0;
+
+	if ((client->fifo_data_sel) & (1 << SMI_ACC_SENSOR)) {
+		err += SMI_CALL_API(set_accel_range)(client->range.acc_range);
+		err += SMI_CALL_API(set_accel_output_data_rate)
+				(client->odr.acc_odr);
+		err += SMI_CALL_API(set_fifo_accel_enable)(1);
+	}
+	if ((client->fifo_data_sel) & (1 << SMI_GYRO_SENSOR)) {
+		err += SMI_CALL_API(set_gyro_range)(client->range.gyro_range);
+		err += SMI_CALL_API(set_gyro_output_data_rate)
+				(client->odr.gyro_odr);
+		err += SMI_CALL_API(set_fifo_gyro_enable)(1);
+	}
+	if ((client->fifo_data_sel) & (1 << SMI_MAG_SENSOR)) {
+		err += SMI_CALL_API(set_mag_output_data_rate)
+				(client->odr.mag_odr);
+		err += SMI_CALL_API(set_fifo_mag_enable)(1);
+	}
+	err += SMI_CALL_API(set_command_register)(CMD_CLR_FIFO_DATA);
+
+	mutex_lock(&client->mutex_op_mode);
+	if (client->pw.acc_pm != SMI_ACC_PM_SUSPEND) {
+		err += SMI_CALL_API(set_command_register)
+				(smi_pmu_cmd_acc_arr[SMI_ACC_PM_NORMAL]);
+		smi_delay(3);
+	}
+	mutex_unlock(&client->mutex_op_mode);
+
+	mutex_lock(&client->mutex_op_mode);
+	if (client->pw.gyro_pm != SMI_GYRO_PM_SUSPEND) {
+		err += SMI_CALL_API(set_command_register)
+				(smi_pmu_cmd_gyro_arr[SMI_GYRO_PM_NORMAL]);
+		smi_delay(3);
+	}
+	mutex_unlock(&client->mutex_op_mode);
+
+	mutex_lock(&client->mutex_op_mode);
+
+	if (client->pw.mag_pm != SMI_MAG_PM_SUSPEND) {
+#ifdef SMI130_AKM09912_SUPPORT
+		err += smi130_set_bosch_akm_and_secondary_if_powermode
+					(SMI130_MAG_FORCE_MODE);
+#else
+		err += smi130_set_bmm150_mag_and_secondary_if_power_mode
+					(SMI130_MAG_FORCE_MODE);
+#endif
+		smi_delay(3);
+	}
+	mutex_unlock(&client->mutex_op_mode);
+
+	return err;
+}
+
+#if defined(CONFIG_USE_QUALCOMM_HAL)
+static void smi130_accel_work_fn(struct work_struct *work)
+{
+	struct smi_client_data *sensor;
+	ktime_t timestamp;
+	struct smi130_accel_t data;
+	int err;
+	sensor = container_of((struct delayed_work *)work,
+				struct smi_client_data, accel_poll_work);
+	timestamp = ktime_get();
+	err = SMI_CALL_API(read_accel_xyz)(&data);
+	if (err)
+		dev_err(sensor->dev, "read data err");
+	input_report_abs(sensor->input, ABS_X,
+		(data.x));
+	input_report_abs(sensor->input, ABS_Y,
+		(data.y));
+	input_report_abs(sensor->input, ABS_Z,
+		(data.z));
+	input_event(sensor->input,
+			EV_SYN, SYN_TIME_SEC,
+			ktime_to_timespec(timestamp).tv_sec);
+	input_event(sensor->input, EV_SYN,
+		SYN_TIME_NSEC,
+		ktime_to_timespec(timestamp).tv_nsec);
+	input_sync(sensor->input);
+	if (atomic_read(&sensor->accel_en))
+		queue_delayed_work(sensor->data_wq,
+			&sensor->accel_poll_work,
+			msecs_to_jiffies(sensor->accel_poll_ms));
+}
+static void smi130_gyro_work_fn(struct work_struct *work)
+{
+	struct smi_client_data *sensor;
+	ktime_t timestamp;
+	struct smi130_gyro_t data;
+	int err;
+	sensor = container_of((struct delayed_work *)work,
+				struct smi_client_data, gyro_poll_work);
+	timestamp = ktime_get();
+	err = SMI_CALL_API(read_gyro_xyz)(&data);
+	if (err)
+		dev_err(sensor->dev, "read data err");
+	input_report_abs(sensor->gyro_input, ABS_RX,
+		(data.x));
+	input_report_abs(sensor->gyro_input, ABS_RY,
+		(data.y));
+	input_report_abs(sensor->gyro_input, ABS_RZ,
+		(data.z));
+	input_event(sensor->gyro_input,
+			EV_SYN, SYN_TIME_SEC,
+			ktime_to_timespec(timestamp).tv_sec);
+	input_event(sensor->gyro_input, EV_SYN,
+		SYN_TIME_NSEC,
+		ktime_to_timespec(timestamp).tv_nsec);
+	input_sync(sensor->gyro_input);
+	if (atomic_read(&sensor->gyro_en))
+		queue_delayed_work(sensor->data_wq,
+			&sensor->gyro_poll_work,
+			msecs_to_jiffies(sensor->gyro_poll_ms));
+}
+static int smi130_set_gyro_op_mode(struct smi_client_data *client_data,
+							unsigned long op_mode)
+{
+	int err = 0;
+	mutex_lock(&client_data->mutex_op_mode);
+	if (op_mode < SMI_GYRO_PM_MAX) {
+		switch (op_mode) {
+		case SMI_GYRO_PM_NORMAL:
+			err = SMI_CALL_API(set_command_register)
+				(smi_pmu_cmd_gyro_arr[SMI_GYRO_PM_NORMAL]);
+			client_data->pw.gyro_pm = SMI_GYRO_PM_NORMAL;
+			smi_delay(60);
+			break;
+		case SMI_GYRO_PM_FAST_START:
+			err = SMI_CALL_API(set_command_register)
+				(smi_pmu_cmd_gyro_arr[SMI_GYRO_PM_FAST_START]);
+			client_data->pw.gyro_pm = SMI_GYRO_PM_FAST_START;
+			smi_delay(60);
+			break;
+		case SMI_GYRO_PM_SUSPEND:
+			err = SMI_CALL_API(set_command_register)
+				(smi_pmu_cmd_gyro_arr[SMI_GYRO_PM_SUSPEND]);
+			client_data->pw.gyro_pm = SMI_GYRO_PM_SUSPEND;
+			smi_delay(60);
+			break;
+		default:
+			mutex_unlock(&client_data->mutex_op_mode);
+			return -EINVAL;
+		}
+	} else {
+		mutex_unlock(&client_data->mutex_op_mode);
+		return -EINVAL;
+	}
+	mutex_unlock(&client_data->mutex_op_mode);
+	return err;
+}
+static int smi130_accel_set_enable(
+	struct smi_client_data *client_data, bool enable)
+{
+	int ret = 0;
+	dev_notice(client_data->dev,
+		"smi130_accel_set_enable enable=%d\n", enable);
+	if (enable) {
+		ret = smi130_set_acc_op_mode(client_data, 0);
+		if (ret) {
+			dev_err(client_data->dev,
+				"Fail to enable accel engine ret=%d\n", ret);
+			ret = -EBUSY;
+			goto exit;
+		}
+		queue_delayed_work(client_data->data_wq,
+				&client_data->accel_poll_work,
+				msecs_to_jiffies(client_data->accel_poll_ms));
+		atomic_set(&client_data->accel_en, 1);
+	} else {
+		atomic_set(&client_data->accel_en, 0);
+		cancel_delayed_work_sync(&client_data->accel_poll_work);
+		ret = smi130_set_acc_op_mode(client_data, 2);
+		if (ret) {
+			dev_err(client_data->dev,
+				"Fail to disable accel engine ret=%d\n", ret);
+			ret = -EBUSY;
+			goto exit;
+		}
+	}
+exit:
+	return ret;
+}
+static int smi130_accel_set_poll_delay(struct smi_client_data *client_data,
+					unsigned long delay)
+{
+	dev_info(client_data->dev,
+		"smi130_accel_set_poll_delay delay_ms=%ld\n", delay);
+	if (delay < SMI130_ACCEL_MIN_POLL_INTERVAL_MS)
+		delay = SMI130_ACCEL_MIN_POLL_INTERVAL_MS;
+	if (delay > SMI130_ACCEL_MAX_POLL_INTERVAL_MS)
+		delay = SMI130_ACCEL_MAX_POLL_INTERVAL_MS;
+	client_data->accel_poll_ms = delay;
+	if (!atomic_read(&client_data->accel_en))
+		goto exit;
+	cancel_delayed_work_sync(&client_data->accel_poll_work);
+	queue_delayed_work(client_data->data_wq,
+			&client_data->accel_poll_work,
+			msecs_to_jiffies(client_data->accel_poll_ms));
+exit:
+	return 0;
+}
+static int smi130_gyro_set_enable(
+	struct smi_client_data *client_data, bool enable)
+{
+	int ret = 0;
+	dev_notice(client_data->dev,
+		"smi130_gyro_set_enable enable=%d\n", enable);
+	if (enable) {
+		ret = smi130_set_gyro_op_mode(client_data, 0);
+		if (ret) {
+			dev_err(client_data->dev,
+				"Fail to enable gyro engine ret=%d\n", ret);
+			ret = -EBUSY;
+			goto exit;
+		}
+		queue_delayed_work(client_data->data_wq,
+				&client_data->gyro_poll_work,
+				msecs_to_jiffies(client_data->gyro_poll_ms));
+		atomic_set(&client_data->gyro_en, 1);
+	} else {
+		atomic_set(&client_data->gyro_en, 0);
+		cancel_delayed_work_sync(&client_data->gyro_poll_work);
+		ret = smi130_set_gyro_op_mode(client_data, 2);
+		if (ret) {
+			dev_err(client_data->dev,
+				"Fail to disable accel engine ret=%d\n", ret);
+			ret = -EBUSY;
+			goto exit;
+		}
+	}
+exit:
+	return ret;
+}
+static int smi130_gyro_set_poll_delay(struct smi_client_data *client_data,
+					unsigned long delay)
+{
+	dev_info(client_data->dev,
+		"smi130_accel_set_poll_delay delay_ms=%ld\n", delay);
+	if (delay < SMI130_GYRO_MIN_POLL_INTERVAL_MS)
+		delay = SMI130_GYRO_MIN_POLL_INTERVAL_MS;
+	if (delay > SMI130_GYRO_MAX_POLL_INTERVAL_MS)
+		delay = SMI130_GYRO_MAX_POLL_INTERVAL_MS;
+	client_data->gyro_poll_ms = delay;
+	if (!atomic_read(&client_data->gyro_en))
+		goto exit;
+	cancel_delayed_work_sync(&client_data->gyro_poll_work);
+	queue_delayed_work(client_data->data_wq,
+			&client_data->gyro_poll_work,
+			msecs_to_jiffies(client_data->gyro_poll_ms));
+exit:
+	return 0;
+}
+static int smi130_accel_cdev_enable(struct sensors_classdev *sensors_cdev,
+			unsigned int enable)
+{
+	struct smi_client_data *sensor = container_of(sensors_cdev,
+			struct smi_client_data, accel_cdev);
+	return smi130_accel_set_enable(sensor, enable);
+}
+static int smi130_accel_cdev_poll_delay(struct sensors_classdev *sensors_cdev,
+			unsigned int delay_ms)
+{
+	struct smi_client_data *sensor = container_of(sensors_cdev,
+			struct smi_client_data, accel_cdev);
+
+	return smi130_accel_set_poll_delay(sensor, delay_ms);
+}
+
+static int smi130_gyro_cdev_enable(struct sensors_classdev *sensors_cdev,
+			unsigned int enable)
+{
+	struct smi_client_data *sensor = container_of(sensors_cdev,
+			struct smi_client_data, gyro_cdev);
+
+	return smi130_gyro_set_enable(sensor, enable);
+}
+
+static int smi130_gyro_cdev_poll_delay(struct sensors_classdev *sensors_cdev,
+			unsigned int delay_ms)
+{
+	struct smi_client_data *sensor = container_of(sensors_cdev,
+			struct smi_client_data, gyro_cdev);
+
+	return	smi130_gyro_set_poll_delay(sensor, delay_ms);
+}
+#endif
+
+int smi_probe(struct smi_client_data *client_data, struct device *dev)
+{
+	int err = 0;
+#ifdef SMI130_MAG_INTERFACE_SUPPORT
+	u8 mag_dev_addr;
+	u8 mag_urst_len;
+	u8 mag_op_mode;
+#endif
+	/* check chip id */
+	err = smi_check_chip_id(client_data);
+	if (err)
+		goto exit_err_clean;
+
+	dev_set_drvdata(dev, client_data);
+	client_data->dev = dev;
+
+	mutex_init(&client_data->mutex_enable);
+	mutex_init(&client_data->mutex_op_mode);
+
+	/* input device init */
+	err = smi_input_init(client_data);
+	if (err < 0)
+		goto exit_err_clean;
+
+	/* sysfs node creation */
+	err = sysfs_create_group(&client_data->input->dev.kobj,
+			&smi130_attribute_group);
+
+	if (err < 0)
+		goto exit_err_sysfs;
+
+	if (NULL != dev->platform_data) {
+		client_data->bosch_pd = kzalloc(sizeof(*client_data->bosch_pd),
+				GFP_KERNEL);
+
+		if (NULL != client_data->bosch_pd) {
+			memcpy(client_data->bosch_pd, dev->platform_data,
+					sizeof(*client_data->bosch_pd));
+			dev_notice(dev, "%s sensor driver set place: p%d\n",
+					client_data->bosch_pd->name,
+					client_data->bosch_pd->place);
+		}
+	}
+
+	if (NULL != client_data->bosch_pd) {
+			memcpy(client_data->bosch_pd, dev->platform_data,
+					sizeof(*client_data->bosch_pd));
+			dev_notice(dev, "%s sensor driver set place: p%d\n",
+					client_data->bosch_pd->name,
+					client_data->bosch_pd->place);
+		}
+
+
+	/* workqueue init */
+	INIT_DELAYED_WORK(&client_data->work, smi_work_func);
+	atomic_set(&client_data->delay, SMI_DELAY_DEFAULT);
+	atomic_set(&client_data->wkqueue_en, 0);
+
+	/* h/w init */
+	client_data->device.delay_msec = smi_delay;
+	err = SMI_CALL_API(init)(&client_data->device);
+
+	smi_dump_reg(client_data);
+
+	/*power on detected*/
+	/*or softrest(cmd 0xB6) */
+	/*fatal err check*/
+	/*soft reset*/
+	err += SMI_CALL_API(set_command_register)(CMD_RESET_USER_REG);
+	smi_delay(3);
+	if (err)
+		dev_err(dev, "Failed soft reset, er=%d", err);
+	/*usr data config page*/
+	err += SMI_CALL_API(set_target_page)(USER_DAT_CFG_PAGE);
+	if (err)
+		dev_err(dev, "Failed cffg page, er=%d", err);
+	err += smi_get_err_status(client_data);
+	if (err) {
+		dev_err(dev, "Failed to smi16x init!err_st=0x%x\n",
+				client_data->err_st.err_st_all);
+		goto exit_err_sysfs;
+	}
+
+#ifdef SMI130_MAG_INTERFACE_SUPPORT
+	err += smi130_set_command_register(MAG_MODE_NORMAL);
+	smi_delay(2);
+	err += smi130_get_mag_power_mode_stat(&mag_op_mode);
+	smi_delay(2);
+	err += SMI_CALL_API(get_i2c_device_addr)(&mag_dev_addr);
+	smi_delay(2);
+#if defined(SMI130_AKM09912_SUPPORT)
+	err += SMI_CALL_API(set_i2c_device_addr)(SMI130_AKM09912_I2C_ADDRESS);
+	smi130_bosch_akm_mag_interface_init(SMI130_AKM09912_I2C_ADDRESS);
+#else
+	err += SMI_CALL_API(set_i2c_device_addr)(
+		SMI130_AUX_BMM150_I2C_ADDRESS);
+	smi130_bmm150_mag_interface_init();
+#endif
+
+	err += smi130_set_mag_burst(3);
+	err += smi130_get_mag_burst(&mag_urst_len);
+	if (err)
+		dev_err(client_data->dev, "Failed cffg mag, er=%d", err);
+	dev_info(client_data->dev,
+		"SMI130 mag_urst_len:%d, mag_add:0x%x, mag_op_mode:%d\n",
+		mag_urst_len, mag_dev_addr, mag_op_mode);
+#endif
+	if (err < 0)
+		goto exit_err_sysfs;
+
+
+#if defined(SMI130_ENABLE_INT1) || defined(SMI130_ENABLE_INT2)
+		/*wake_lock_init(&client_data->wakelock,
+			WAKE_LOCK_SUSPEND, "smi130");*/
+		client_data->gpio_pin = of_get_named_gpio_flags(dev->of_node,
+					"smi,gpio_irq", 0, NULL);
+		dev_info(client_data->dev, "SMI130 qpio number:%d\n",
+					client_data->gpio_pin);
+		err += gpio_request_one(client_data->gpio_pin,
+					GPIOF_IN, "smi130_int");
+		err += gpio_direction_input(client_data->gpio_pin);
+		client_data->IRQ = gpio_to_irq(client_data->gpio_pin);
+		if (err) {
+			dev_err(client_data->dev,
+				"can not request gpio to irq number\n");
+			client_data->gpio_pin = 0;
+		}
+		INIT_DELAYED_WORK(&client_data->delay_work_sig,
+			smi130_delay_sigmo_work_func);
+#ifdef SMI130_ENABLE_INT1
+		/* maps interrupt to INT1/InT2 pin */
+		SMI_CALL_API(set_intr_any_motion)(SMI_INT0, ENABLE);
+		SMI_CALL_API(set_intr_fifo_wm)(SMI_INT0, ENABLE);
+		SMI_CALL_API(set_intr_data_rdy)(SMI_INT0, ENABLE);
+
+		/*Set interrupt trige level way */
+		SMI_CALL_API(set_intr_edge_ctrl)(SMI_INT0, SMI_INT_LEVEL);
+		smi130_set_intr_level(SMI_INT0, 1);
+		/*set interrupt latch temporary, 5 ms*/
+		/*smi130_set_latch_int(5);*/
+
+		SMI_CALL_API(set_output_enable)(
+		SMI130_INTR1_OUTPUT_ENABLE, ENABLE);
+		sigmotion_init_interrupts(SMI130_MAP_INTR1);
+		SMI_CALL_API(map_step_detector_intr)(SMI130_MAP_INTR1);
+		/*close step_detector in init function*/
+		SMI_CALL_API(set_step_detector_enable)(0);
+#endif
+
+#ifdef SMI130_ENABLE_INT2
+		/* maps interrupt to INT1/InT2 pin */
+		SMI_CALL_API(set_intr_any_motion)(SMI_INT1, ENABLE);
+		SMI_CALL_API(set_intr_fifo_wm)(SMI_INT1, ENABLE);
+		SMI_CALL_API(set_intr_data_rdy)(SMI_INT1, ENABLE);
+
+		/*Set interrupt trige level way */
+		SMI_CALL_API(set_intr_edge_ctrl)(SMI_INT1, SMI_INT_LEVEL);
+		smi130_set_intr_level(SMI_INT1, 1);
+		/*set interrupt latch temporary, 5 ms*/
+		/*smi130_set_latch_int(5);*/
+
+		SMI_CALL_API(set_output_enable)(
+		SMI130_INTR2_OUTPUT_ENABLE, ENABLE);
+		sigmotion_init_interrupts(SMI130_MAP_INTR2);
+		SMI_CALL_API(map_step_detector_intr)(SMI130_MAP_INTR2);
+		/*close step_detector in init function*/
+		SMI_CALL_API(set_step_detector_enable)(0);
+#endif
+		err = request_irq(client_data->IRQ, smi_irq_handler,
+				IRQF_TRIGGER_RISING, "smi130", client_data);
+		if (err)
+			dev_err(client_data->dev, "could not request irq\n");
+
+		INIT_WORK(&client_data->irq_work, smi_irq_work_func);
+#endif
+
+	client_data->selftest = 0;
+
+	client_data->fifo_data_sel = 0;
+	#if defined(CONFIG_USE_QUALCOMM_HAL)
+	SMI_CALL_API(set_accel_output_data_rate)(9);/*defalut odr 200HZ*/
+	SMI_CALL_API(set_gyro_output_data_rate)(9);/*defalut odr 200HZ*/
+	#endif
+	SMI_CALL_API(get_accel_output_data_rate)(&client_data->odr.acc_odr);
+	SMI_CALL_API(get_gyro_output_data_rate)(&client_data->odr.gyro_odr);
+	SMI_CALL_API(get_mag_output_data_rate)(&client_data->odr.mag_odr);
+	SMI_CALL_API(set_fifo_time_enable)(1);
+	SMI_CALL_API(get_accel_range)(&client_data->range.acc_range);
+	SMI_CALL_API(get_gyro_range)(&client_data->range.gyro_range);
+	/* now it's power on which is considered as resuming from suspend */
+	
+	/* gyro input device init */
+	err = smi_gyro_input_init(client_data);
+	#if defined(CONFIG_USE_QUALCOMM_HAL)
+	/* gyro input device init */
+	err = smi_gyro_input_init(client_data);
+	if (err < 0)
+		goto exit_err_clean;
+	client_data->accel_poll_ms = SMI130_ACCEL_DEFAULT_POLL_INTERVAL_MS;
+	client_data->gyro_poll_ms = SMI130_GYRO_DEFAULT_POLL_INTERVAL_MS;
+	client_data->data_wq = create_freezable_workqueue("smi130_data_work");
+	if (!client_data->data_wq) {
+		dev_err(dev, "Cannot create workqueue!\n");
+		goto exit_err_clean;
+	}
+	INIT_DELAYED_WORK(&client_data->accel_poll_work,
+		smi130_accel_work_fn);
+	client_data->accel_cdev = smi130_accel_cdev;
+	client_data->accel_cdev.delay_msec = client_data->accel_poll_ms;
+	client_data->accel_cdev.sensors_enable = smi130_accel_cdev_enable;
+	client_data->accel_cdev.sensors_poll_delay =
+	smi130_accel_cdev_poll_delay;
+	err = sensors_classdev_register(dev, &client_data->accel_cdev);
+	if (err) {
+		dev_err(dev,
+			"create accel class device file failed!\n");
+		goto exit_err_clean;
+	}
+	INIT_DELAYED_WORK(&client_data->gyro_poll_work, smi130_gyro_work_fn);
+	client_data->gyro_cdev = smi130_gyro_cdev;
+	client_data->gyro_cdev.delay_msec = client_data->gyro_poll_ms;
+	client_data->gyro_cdev.sensors_enable = smi130_gyro_cdev_enable;
+	client_data->gyro_cdev.sensors_poll_delay = smi130_gyro_cdev_poll_delay;
+	err = sensors_classdev_register(dev, &client_data->gyro_cdev);
+	if (err) {
+		dev_err(dev,
+			"create accel class device file failed!\n");
+		goto exit_err_clean;
+	}
+	#endif
+	/* set sensor PMU into suspend power mode for all */
+	if (smi_pmu_set_suspend(client_data) < 0) {
+		dev_err(dev, "Failed to set SMI130 to suspend power mode\n");
+		goto exit_err_sysfs;
+	}
+	/*enable the data ready interrupt*/
+	SMI_CALL_API(set_intr_enable_1)(SMI130_DATA_RDY_ENABLE, 1);
+	dev_notice(dev, "sensor_time:%d, %d, %d",
+		sensortime_duration_tbl[0].ts_delat,
+		sensortime_duration_tbl[0].ts_duration_lsb,
+		sensortime_duration_tbl[0].ts_duration_us);
+	dev_notice(dev, "sensor %s probed successfully", SENSOR_NAME);
+
+	return 0;
+
+exit_err_sysfs:
+	if (err)
+		smi_input_destroy(client_data);
+
+exit_err_clean:
+	if (err) {
+		if (client_data != NULL) {
+			if (NULL != client_data->bosch_pd) {
+				kfree(client_data->bosch_pd);
+				client_data->bosch_pd = NULL;
+			}
+		}
+	}
+	return err;
+}
+EXPORT_SYMBOL(smi_probe);
+
+/*!
+ * @brief remove smi client
+ *
+ * @param dev the pointer of device
+ *
+ * @return zero
+ * @retval zero
+*/
+int smi_remove(struct device *dev)
+{
+	int err = 0;
+	struct smi_client_data *client_data = dev_get_drvdata(dev);
+
+	if (NULL != client_data) {
+#ifdef CONFIG_HAS_EARLYSUSPEND
+		unregister_early_suspend(&client_data->early_suspend_handler);
+#endif
+		mutex_lock(&client_data->mutex_enable);
+		if (SMI_ACC_PM_NORMAL == client_data->pw.acc_pm ||
+			SMI_GYRO_PM_NORMAL == client_data->pw.gyro_pm ||
+				SMI_MAG_PM_NORMAL == client_data->pw.mag_pm) {
+			cancel_delayed_work_sync(&client_data->work);
+		}
+		mutex_unlock(&client_data->mutex_enable);
+
+		err = smi_pmu_set_suspend(client_data);
+
+		smi_delay(5);
+
+		sysfs_remove_group(&client_data->input->dev.kobj,
+				&smi130_attribute_group);
+		smi_input_destroy(client_data);
+
+		if (NULL != client_data->bosch_pd) {
+			kfree(client_data->bosch_pd);
+			client_data->bosch_pd = NULL;
+		}
+		kfree(client_data);
+	}
+
+	return err;
+}
+EXPORT_SYMBOL(smi_remove);
+
+static int smi_post_resume(struct smi_client_data *client_data)
+{
+	int err = 0;
+
+	mutex_lock(&client_data->mutex_enable);
+
+	if (atomic_read(&client_data->wkqueue_en) == 1) {
+		smi130_set_acc_op_mode(client_data, SMI_ACC_PM_NORMAL);
+		schedule_delayed_work(&client_data->work,
+				msecs_to_jiffies(
+					atomic_read(&client_data->delay)));
+	}
+	mutex_unlock(&client_data->mutex_enable);
+
+	return err;
+}
+
+
+int smi_suspend(struct device *dev)
+{
+	int err = 0;
+	struct smi_client_data *client_data = dev_get_drvdata(dev);
+	unsigned char stc_enable;
+	unsigned char std_enable;
+	dev_err(client_data->dev, "smi suspend function entrance");
+
+	atomic_set(&client_data->in_suspend, 1);
+	if (atomic_read(&client_data->wkqueue_en) == 1) {
+		smi130_set_acc_op_mode(client_data, SMI_ACC_PM_SUSPEND);
+		cancel_delayed_work_sync(&client_data->work);
+	}
+	SMI_CALL_API(get_step_counter_enable)(&stc_enable);
+	SMI_CALL_API(get_step_detector_enable)(&std_enable);
+	if (client_data->pw.acc_pm != SMI_ACC_PM_SUSPEND &&
+		(stc_enable != 1) && (std_enable != 1) &&
+		(client_data->sig_flag != 1)) {
+		err += SMI_CALL_API(set_command_register)
+				(smi_pmu_cmd_acc_arr[SMI_ACC_PM_SUSPEND]);
+		smi_delay(3);
+	}
+	if (client_data->pw.gyro_pm != SMI_GYRO_PM_SUSPEND) {
+		err += SMI_CALL_API(set_command_register)
+				(smi_pmu_cmd_gyro_arr[SMI_GYRO_PM_SUSPEND]);
+		smi_delay(3);
+	}
+
+	if (client_data->pw.mag_pm != SMI_MAG_PM_SUSPEND) {
+#if defined(SMI130_AKM09912_SUPPORT)
+		err += smi130_set_bosch_akm_and_secondary_if_powermode(
+		SMI130_MAG_SUSPEND_MODE);
+#else
+		err += smi130_set_bmm150_mag_and_secondary_if_power_mode(
+		SMI130_MAG_SUSPEND_MODE);
+#endif
+		smi_delay(3);
+	}
+
+	return err;
+}
+EXPORT_SYMBOL(smi_suspend);
+
+int smi_resume(struct device *dev)
+{
+	int err = 0;
+	struct smi_client_data *client_data = dev_get_drvdata(dev);
+	atomic_set(&client_data->in_suspend, 0);
+	if (client_data->pw.acc_pm != SMI_ACC_PM_SUSPEND) {
+		err += SMI_CALL_API(set_command_register)
+				(smi_pmu_cmd_acc_arr[SMI_ACC_PM_NORMAL]);
+		smi_delay(3);
+	}
+	if (client_data->pw.gyro_pm != SMI_GYRO_PM_SUSPEND) {
+		err += SMI_CALL_API(set_command_register)
+				(smi_pmu_cmd_gyro_arr[SMI_GYRO_PM_NORMAL]);
+		smi_delay(3);
+	}
+
+	if (client_data->pw.mag_pm != SMI_MAG_PM_SUSPEND) {
+#if defined(SMI130_AKM09912_SUPPORT)
+		err += smi130_set_bosch_akm_and_secondary_if_powermode
+					(SMI130_MAG_FORCE_MODE);
+#else
+		err += smi130_set_bmm150_mag_and_secondary_if_power_mode
+					(SMI130_MAG_FORCE_MODE);
+#endif
+		smi_delay(3);
+	}
+	/* post resume operation */
+	err += smi_post_resume(client_data);
+
+	return err;
+}
+EXPORT_SYMBOL(smi_resume);
+
diff --git a/drivers/input/sensors/smi130/smi130_driver.h b/drivers/input/sensors/smi130/smi130_driver.h
new file mode 100644
index 0000000..4307ae5
--- /dev/null
+++ b/drivers/input/sensors/smi130/smi130_driver.h
@@ -0,0 +1,512 @@
+/*!
+ * @section LICENSE
+ * (C) Copyright 2011~2016 Bosch Sensortec GmbH All Rights Reserved
+ *
+ * (C) Modification Copyright 2018 Robert Bosch Kft  All Rights Reserved
+ *
+ * This software program is licensed subject to the GNU General
+ * Public License (GPL).Version 2,June 1991,
+ * available at http://www.fsf.org/copyleft/gpl.html
+ *
+ * Special: Description of the Software:
+ *
+ * This software module (hereinafter called "Software") and any
+ * information on application-sheets (hereinafter called "Information") is
+ * provided free of charge for the sole purpose to support your application
+ * work. 
+ *
+ * As such, the Software is merely an experimental software, not tested for
+ * safety in the field and only intended for inspiration for further development 
+ * and testing. Any usage in a safety-relevant field of use (like automotive,
+ * seafaring, spacefaring, industrial plants etc.) was not intended, so there are
+ * no precautions for such usage incorporated in the Software.
+ * 
+ * The Software is specifically designed for the exclusive use for Bosch
+ * Sensortec products by personnel who have special experience and training. Do
+ * not use this Software if you do not have the proper experience or training.
+ * 
+ * This Software package is provided as is and without any expressed or
+ * implied warranties, including without limitation, the implied warranties of
+ * merchantability and fitness for a particular purpose.
+ * 
+ * Bosch Sensortec and their representatives and agents deny any liability for
+ * the functional impairment of this Software in terms of fitness, performance
+ * and safety. Bosch Sensortec and their representatives and agents shall not be
+ * liable for any direct or indirect damages or injury, except as otherwise
+ * stipulated in mandatory applicable law.
+ * The Information provided is believed to be accurate and reliable. Bosch
+ * Sensortec assumes no responsibility for the consequences of use of such
+ * Information nor for any infringement of patents or other rights of third
+ * parties which may result from its use.
+ * 
+ *------------------------------------------------------------------------------
+ * The following Product Disclaimer does not apply to the BSX4-HAL-4.1NoFusion Software 
+ * which is licensed under the Apache License, Version 2.0 as stated above.  
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Product Disclaimer
+ *
+ * Common:
+ *
+ * Assessment of Products Returned from Field
+ *
+ * Returned products are considered good if they fulfill the specifications / 
+ * test data for 0-mileage and field listed in this document.
+ *
+ * Engineering Samples
+ * 
+ * Engineering samples are marked with (e) or (E). Samples may vary from the
+ * valid technical specifications of the series product contained in this
+ * data sheet. Therefore, they are not intended or fit for resale to
+ * third parties or for use in end products. Their sole purpose is internal
+ * client testing. The testing of an engineering sample may in no way replace
+ * the testing of a series product. Bosch assumes no liability for the use
+ * of engineering samples. The purchaser shall indemnify Bosch from all claims
+ * arising from the use of engineering samples.
+ *
+ * Intended use
+ *
+ * Provided that SMI130 is used within the conditions (environment, application,
+ * installation, loads) as described in this TCD and the corresponding
+ * agreed upon documents, Bosch ensures that the product complies with
+ * the agreed properties. Agreements beyond this require
+ * the written approval by Bosch. The product is considered fit for the intended
+ * use when the product successfully has passed the tests
+ * in accordance with the TCD and agreed upon documents.
+ *
+ * It is the responsibility of the customer to ensure the proper application
+ * of the product in the overall system/vehicle.
+ *
+ * Bosch does not assume any responsibility for changes to the environment
+ * of the product that deviate from the TCD and the agreed upon documents 
+ * as well as all applications not released by Bosch
+  *
+ * The resale and/or use of products are at the purchaser’s own risk and 
+ * responsibility. The examination and testing of the SMI130 
+ * is the sole responsibility of the purchaser.
+ *
+ * The purchaser shall indemnify Bosch from all third party claims 
+ * arising from any product use not covered by the parameters of 
+ * this product data sheet or not approved by Bosch and reimburse Bosch 
+ * for all costs and damages in connection with such claims.
+ *
+ * The purchaser must monitor the market for the purchased products,
+ * particularly with regard to product safety, and inform Bosch without delay
+ * of all security relevant incidents.
+ *
+ * Application Examples and Hints
+ *
+ * With respect to any application examples, advice, normal values
+ * and/or any information regarding the application of the device,
+ * Bosch hereby disclaims any and all warranties and liabilities of any kind,
+ * including without limitation warranties of
+ * non-infringement of intellectual property rights or copyrights
+ * of any third party.
+ * The information given in this document shall in no event be regarded 
+ * as a guarantee of conditions or characteristics. They are provided
+ * for illustrative purposes only and no evaluation regarding infringement
+ * of intellectual property rights or copyrights or regarding functionality,
+ * performance or error has been made.
+ *
+ * @filename smi130_driver.h
+ * @date     2015/08/17 14:40
+ * @Modification Date 2018/08/28 18:20
+ * @id       "e90a329"
+ * @version  1.3
+ *
+ * @brief
+ * The head file of SMI130 device driver core code
+*/
+#ifndef _SMI130_DRIVER_H
+#define _SMI130_DRIVER_H
+
+#ifdef __KERNEL__
+#include <linux/kernel.h>
+#include <linux/unistd.h>
+#include <linux/types.h>
+#include <linux/string.h>
+#else
+#include <unistd.h>
+#include <sys/types.h>
+#include <string.h>
+#endif
+
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/i2c.h>
+#include <linux/interrupt.h>
+#include <linux/input.h>
+#include <linux/workqueue.h>
+#include <linux/mutex.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/time.h>
+#include <linux/ktime.h>
+
+#ifdef CONFIG_HAS_EARLYSUSPEND
+#include <linux/earlysuspend.h>
+#endif
+
+#include "smi130.h"
+
+#if defined(CONFIG_USE_QUALCOMM_HAL)
+#include <linux/sensors.h>
+#endif
+/* sensor specific */
+#define SENSOR_NAME "smi130"
+#define SMI130_ENABLE_INT1 1
+#define SMI130_ENABLE_INT2 1
+/*#define SMI130_MAG_INTERFACE_SUPPORT 1*/
+
+/*#define SMI130_AKM09912_SUPPORT 1*/
+#define SMI_USE_BASIC_I2C_FUNC 1
+#define SENSOR_CHIP_ID_SMI (0xD0)
+#define SENSOR_CHIP_ID_SMI_C2 (0xD1)
+#define SENSOR_CHIP_ID_SMI_C3 (0xD3)
+
+#define SENSOR_CHIP_REV_ID_SMI (0x00)
+
+#define CHECK_CHIP_ID_TIME_MAX  5
+
+#define SMI_REG_NAME(name) SMI130_##name##__REG
+#define SMI_VAL_NAME(name) SMI130_##name
+#define SMI_CALL_API(name) smi130_##name
+
+#define SMI_I2C_WRITE_DELAY_TIME (1)
+
+/* generic */
+#define SMI_MAX_RETRY_I2C_XFER (10)
+#define SMI_MAX_RETRY_WAKEUP (5)
+#define SMI_MAX_RETRY_WAIT_DRDY (100)
+
+#define SMI_DELAY_MIN (1)
+#define SMI_DELAY_DEFAULT (200)
+
+#define SMI_VALUE_MAX (32767)
+#define SMI_VALUE_MIN (-32768)
+
+#define BYTES_PER_LINE (16)
+
+#define BUF_SIZE_PRINT (16)
+
+#define SMI_FAST_CALI_TRUE  (1)
+#define SMI_FAST_CALI_ALL_RDY (7)
+
+/*! FIFO 1024 byte, max fifo frame count not over 150 */
+#define FIFO_FRAME_CNT 170
+#define FIFO_DATA_BUFSIZE    1024
+
+
+#define FRAME_LEN_ACC    6
+#define FRAME_LEN_GYRO    6
+#define FRAME_LEN_MAG    8
+
+/*! SMI Self test */
+#define SMI_SELFTEST_AMP_HIGH       1
+
+/* CMD  */
+#define CMD_FOC_START                 0x03
+#define CMD_PMU_ACC_SUSPEND           0x10
+#define CMD_PMU_ACC_NORMAL            0x11
+#define CMD_PMU_ACC_LP1               0x12
+#define CMD_PMU_ACC_LP2               0x13
+#define CMD_PMU_GYRO_SUSPEND          0x14
+#define CMD_PMU_GYRO_NORMAL           0x15
+#define CMD_PMU_GYRO_FASTSTART        0x17
+#define CMD_PMU_MAG_SUSPEND           0x18
+#define CMD_PMU_MAG_NORMAL            0x19
+#define CMD_PMU_MAG_LP1               0x1A
+#define CMD_PMU_MAG_LP2               0x1B
+#define CMD_CLR_FIFO_DATA             0xB0
+#define CMD_RESET_INT_ENGINE          0xB1
+#define CMD_RESET_USER_REG            0xB6
+
+#define USER_DAT_CFG_PAGE              0x00
+
+/*! FIFO Head definition*/
+#define FIFO_HEAD_A        0x84
+#define FIFO_HEAD_G        0x88
+#define FIFO_HEAD_M        0x90
+
+#define FIFO_HEAD_G_A        (FIFO_HEAD_G | FIFO_HEAD_A)
+#define FIFO_HEAD_M_A        (FIFO_HEAD_M | FIFO_HEAD_A)
+#define FIFO_HEAD_M_G        (FIFO_HEAD_M | FIFO_HEAD_G)
+
+#define FIFO_HEAD_M_G_A         (FIFO_HEAD_M | FIFO_HEAD_G | FIFO_HEAD_A)
+
+#define FIFO_HEAD_SENSOR_TIME        0x44
+#define FIFO_HEAD_SKIP_FRAME        0x40
+#define FIFO_HEAD_OVER_READ_LSB       0x80
+#define FIFO_HEAD_OVER_READ_MSB       0x00
+
+/*! FIFO head mode Frame bytes number definition */
+#define A_BYTES_FRM      6
+#define G_BYTES_FRM      6
+#define M_BYTES_FRM      8
+#define GA_BYTES_FRM     12
+#define MG_BYTES_FRM     14
+#define MA_BYTES_FRM     14
+#define MGA_BYTES_FRM    20
+
+#define ACC_FIFO_HEAD       "acc"
+#define GYRO_FIFO_HEAD     "gyro"
+#define MAG_FIFO_HEAD         "mag"
+
+/*! Bosch sensor unknown place*/
+#define BOSCH_SENSOR_PLACE_UNKNOWN (-1)
+/*! Bosch sensor remapping table size P0~P7*/
+#define MAX_AXIS_REMAP_TAB_SZ 8
+
+#define ENABLE     1
+#define DISABLE    0
+
+/* smi sensor HW interrupt pin number */
+#define SMI_INT0      0
+#define SMI_INT1       1
+
+#define SMI_INT_LEVEL      0
+#define SMI_INT_EDGE        1
+
+/*! SMI mag interface */
+
+
+/* compensated output value returned if sensor had overflow */
+#define BMM050_OVERFLOW_OUTPUT       -32768
+#define BMM050_OVERFLOW_OUTPUT_S32   ((s32)(-2147483647-1))
+
+/* Trim Extended Registers */
+#define BMM050_DIG_X1                      0x5D
+#define BMM050_DIG_Y1                      0x5E
+#define BMM050_DIG_Z4_LSB                  0x62
+#define BMM050_DIG_Z4_MSB                  0x63
+#define BMM050_DIG_X2                      0x64
+#define BMM050_DIG_Y2                      0x65
+#define BMM050_DIG_Z2_LSB                  0x68
+#define BMM050_DIG_Z2_MSB                  0x69
+#define BMM050_DIG_Z1_LSB                  0x6A
+#define BMM050_DIG_Z1_MSB                  0x6B
+#define BMM050_DIG_XYZ1_LSB                0x6C
+#define BMM050_DIG_XYZ1_MSB                0x6D
+#define BMM050_DIG_Z3_LSB                  0x6E
+#define BMM050_DIG_Z3_MSB                  0x6F
+#define BMM050_DIG_XY2                     0x70
+#define BMM050_DIG_XY1                     0x71
+
+struct smi130mag_compensate_t {
+	signed char dig_x1;
+	signed char dig_y1;
+
+	signed char dig_x2;
+	signed char dig_y2;
+
+	u16 dig_z1;
+	s16 dig_z2;
+	s16 dig_z3;
+	s16 dig_z4;
+
+	unsigned char dig_xy1;
+	signed char dig_xy2;
+
+	u16 dig_xyz1;
+};
+
+/*smi fifo sensor type combination*/
+enum SMI_FIFO_DATA_SELECT_T {
+	SMI_FIFO_A_SEL = 1,
+	SMI_FIFO_G_SEL,
+	SMI_FIFO_G_A_SEL,
+	SMI_FIFO_M_SEL,
+	SMI_FIFO_M_A_SEL,
+	SMI_FIFO_M_G_SEL,
+	SMI_FIFO_M_G_A_SEL,
+	SMI_FIFO_DATA_SEL_MAX
+};
+
+/*smi interrupt about step_detector and sgm*/
+#define INPUT_EVENT_STEP_DETECTOR    5
+#define INPUT_EVENT_SGM              3/*7*/
+#define INPUT_EVENT_FAST_ACC_CALIB_DONE    6
+#define INPUT_EVENT_FAST_GYRO_CALIB_DONE    4
+
+
+/*!
+* Bst sensor common definition,
+* please give parameters in BSP file.
+*/
+struct bosch_sensor_specific {
+	char *name;
+	/* 0 to 7 */
+	unsigned int place:3;
+	int irq;
+	int (*irq_gpio_cfg)(void);
+};
+
+/*! smi130 sensor spec of power mode */
+struct pw_mode {
+	u8 acc_pm;
+	u8 gyro_pm;
+	u8 mag_pm;
+};
+
+/*! smi130 sensor spec of odr */
+struct odr_t {
+	u8 acc_odr;
+	u8 gyro_odr;
+	u8 mag_odr;
+};
+
+/*! smi130 sensor spec of range */
+struct range_t {
+	u8 acc_range;
+	u8 gyro_range;
+};
+
+/*! smi130 sensor error status */
+struct err_status {
+	u8 fatal_err;
+	u8 err_code;
+	u8 i2c_fail;
+	u8 drop_cmd;
+	u8 mag_drdy_err;
+	u8 err_st_all;
+};
+
+/*! smi130 fifo frame for all sensors */
+struct fifo_frame_t {
+	struct smi130_accel_t *acc_farr;
+	struct smi130_gyro_t *gyro_farr;
+	struct smi130_mag_xyz_s32_t *mag_farr;
+
+	unsigned char acc_frame_cnt;
+	unsigned char gyro_frame_cnt;
+	unsigned char mag_frame_cnt;
+
+	u32 acc_lastf_ts;
+	u32 gyro_lastf_ts;
+	u32 mag_lastf_ts;
+};
+
+/*! smi130 fifo sensor time */
+struct fifo_sensor_time_t {
+	u32 acc_ts;
+	u32 gyro_ts;
+	u32 mag_ts;
+};
+
+struct pedometer_data_t {
+	/*! Fix step detector misinformation for the first time*/
+	u8 wkar_step_detector_status;
+	u_int32_t last_step_counter_value;
+};
+
+struct smi_client_data {
+	struct smi130_t device;
+	struct device *dev;
+	struct input_dev *input;/*acc_device*/
+	struct input_dev *gyro_input;
+	#if defined(CONFIG_USE_QUALCOMM_HAL)
+	struct input_dev *gyro_input;
+	struct sensors_classdev accel_cdev;
+	struct sensors_classdev gyro_cdev;
+	struct delayed_work accel_poll_work;
+	struct delayed_work gyro_poll_work;
+	u32 accel_poll_ms;
+	u32 gyro_poll_ms;
+	u32 accel_latency_ms;
+	u32 gyro_latency_ms;
+	atomic_t accel_en;
+	atomic_t gyro_en;
+	struct workqueue_struct *data_wq;
+	#endif
+	struct delayed_work work;
+	struct work_struct irq_work;
+
+	u8 chip_id;
+
+	struct pw_mode pw;
+	struct odr_t odr;
+	struct range_t range; /*TO DO*/
+	struct err_status err_st;
+	struct pedometer_data_t pedo_data;
+	s8 place;
+	u8 selftest;
+	/*struct wake_lock wakelock;*/
+	struct delayed_work delay_work_sig;
+	atomic_t in_suspend;
+
+	atomic_t wkqueue_en; /*TO DO acc gyro mag*/
+	atomic_t delay;
+	atomic_t selftest_result;
+
+	u8  fifo_data_sel;
+	u16 fifo_bytecount;
+	u8 fifo_head_en;
+	unsigned char fifo_int_tag_en;
+	struct fifo_frame_t fifo_frame;
+
+	unsigned char *fifo_data;
+	u64 fifo_time;
+	u8 stc_enable;
+	uint16_t gpio_pin;
+	u8 std;
+	u8 sig_flag;
+	unsigned char calib_status;
+	struct mutex mutex_op_mode;
+	struct mutex mutex_enable;
+	struct bosch_sensor_specific *bosch_pd;
+	int IRQ;
+	int reg_sel;
+	int reg_len;
+	uint64_t timestamp;
+#ifdef CONFIG_HAS_EARLYSUSPEND
+	struct early_suspend early_suspend_handler;
+#endif
+};
+
+
+/*!
+ * we use a typedef to hide the detail,
+ * because this type might be changed
+ */
+struct bosch_sensor_axis_remap {
+	/* src means which source will be mapped to target x, y, z axis */
+	/* if an target OS axis is remapped from (-)x,
+	 * src is 0, sign_* is (-)1 */
+	/* if an target OS axis is remapped from (-)y,
+	 * src is 1, sign_* is (-)1 */
+	/* if an target OS axis is remapped from (-)z,
+	 * src is 2, sign_* is (-)1 */
+	int src_x:3;
+	int src_y:3;
+	int src_z:3;
+
+	int sign_x:2;
+	int sign_y:2;
+	int sign_z:2;
+};
+
+
+struct bosch_sensor_data {
+	union {
+		int16_t v[3];
+		struct {
+			int16_t x;
+			int16_t y;
+			int16_t z;
+		};
+	};
+};
+
+s8 smi_burst_read_wrapper(u8 dev_addr, u8 reg_addr, u8 *data, u16 len);
+int smi_probe(struct smi_client_data *client_data, struct device *dev);
+int smi_remove(struct device *dev);
+int smi_suspend(struct device *dev);
+int smi_resume(struct device *dev);
+
+
+
+
+#endif/*_SMI130_DRIVER_H*/
+/*@}*/
+
diff --git a/drivers/input/sensors/smi130/smi130_gyro.c b/drivers/input/sensors/smi130/smi130_gyro.c
new file mode 100644
index 0000000..ef3fc38f
--- /dev/null
+++ b/drivers/input/sensors/smi130/smi130_gyro.c
@@ -0,0 +1,7422 @@
+/*!
+ * @section LICENSE
+ * (C) Copyright 2011~2016 Bosch Sensortec GmbH All Rights Reserved
+ *
+ * (C) Modification Copyright 2018 Robert Bosch Kft  All Rights Reserved
+ *
+ * This software program is licensed subject to the GNU General
+ * Public License (GPL).Version 2,June 1991,
+ * available at http://www.fsf.org/copyleft/gpl.html
+ *
+ * Special: Description of the Software:
+ *
+ * This software module (hereinafter called "Software") and any
+ * information on application-sheets (hereinafter called "Information") is
+ * provided free of charge for the sole purpose to support your application
+ * work. 
+ *
+ * As such, the Software is merely an experimental software, not tested for
+ * safety in the field and only intended for inspiration for further development 
+ * and testing. Any usage in a safety-relevant field of use (like automotive,
+ * seafaring, spacefaring, industrial plants etc.) was not intended, so there are
+ * no precautions for such usage incorporated in the Software.
+ * 
+ * The Software is specifically designed for the exclusive use for Bosch
+ * Sensortec products by personnel who have special experience and training. Do
+ * not use this Software if you do not have the proper experience or training.
+ * 
+ * This Software package is provided as is and without any expressed or
+ * implied warranties, including without limitation, the implied warranties of
+ * merchantability and fitness for a particular purpose.
+ * 
+ * Bosch Sensortec and their representatives and agents deny any liability for
+ * the functional impairment of this Software in terms of fitness, performance
+ * and safety. Bosch Sensortec and their representatives and agents shall not be
+ * liable for any direct or indirect damages or injury, except as otherwise
+ * stipulated in mandatory applicable law.
+ * The Information provided is believed to be accurate and reliable. Bosch
+ * Sensortec assumes no responsibility for the consequences of use of such
+ * Information nor for any infringement of patents or other rights of third
+ * parties which may result from its use.
+ * 
+ *------------------------------------------------------------------------------
+ * The following Product Disclaimer does not apply to the BSX4-HAL-4.1NoFusion Software 
+ * which is licensed under the Apache License, Version 2.0 as stated above.  
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Product Disclaimer
+ *
+ * Common:
+ *
+ * Assessment of Products Returned from Field
+ *
+ * Returned products are considered good if they fulfill the specifications / 
+ * test data for 0-mileage and field listed in this document.
+ *
+ * Engineering Samples
+ * 
+ * Engineering samples are marked with (e) or (E). Samples may vary from the
+ * valid technical specifications of the series product contained in this
+ * data sheet. Therefore, they are not intended or fit for resale to
+ * third parties or for use in end products. Their sole purpose is internal
+ * client testing. The testing of an engineering sample may in no way replace
+ * the testing of a series product. Bosch assumes no liability for the use
+ * of engineering samples. The purchaser shall indemnify Bosch from all claims
+ * arising from the use of engineering samples.
+ *
+ * Intended use
+ *
+ * Provided that SMI130 is used within the conditions (environment, application,
+ * installation, loads) as described in this TCD and the corresponding
+ * agreed upon documents, Bosch ensures that the product complies with
+ * the agreed properties. Agreements beyond this require
+ * the written approval by Bosch. The product is considered fit for the intended
+ * use when the product successfully has passed the tests
+ * in accordance with the TCD and agreed upon documents.
+ *
+ * It is the responsibility of the customer to ensure the proper application
+ * of the product in the overall system/vehicle.
+ *
+ * Bosch does not assume any responsibility for changes to the environment
+ * of the product that deviate from the TCD and the agreed upon documents 
+ * as well as all applications not released by Bosch
+  *
+ * The resale and/or use of products are at the purchaser’s own risk and 
+ * responsibility. The examination and testing of the SMI130 
+ * is the sole responsibility of the purchaser.
+ *
+ * The purchaser shall indemnify Bosch from all third party claims 
+ * arising from any product use not covered by the parameters of 
+ * this product data sheet or not approved by Bosch and reimburse Bosch 
+ * for all costs and damages in connection with such claims.
+ *
+ * The purchaser must monitor the market for the purchased products,
+ * particularly with regard to product safety, and inform Bosch without delay
+ * of all security relevant incidents.
+ *
+ * Application Examples and Hints
+ *
+ * With respect to any application examples, advice, normal values
+ * and/or any information regarding the application of the device,
+ * Bosch hereby disclaims any and all warranties and liabilities of any kind,
+ * including without limitation warranties of
+ * non-infringement of intellectual property rights or copyrights
+ * of any third party.
+ * The information given in this document shall in no event be regarded 
+ * as a guarantee of conditions or characteristics. They are provided
+ * for illustrative purposes only and no evaluation regarding infringement
+ * of intellectual property rights or copyrights or regarding functionality,
+ * performance or error has been made.
+ * @filename smi130_gyro.c
+ * @date    2013/11/25
+ * @Modification Date 2018/08/28 18:20
+ * @id       "8fcde22"
+ * @version  1.5
+ *
+ * @brief    SMI130_GYROAPI
+*/
+
+#include "smi130_gyro.h"
+static struct smi130_gyro_t *p_smi130_gyro;
+
+
+/*****************************************************************************
+ * Description: *//**brief API Initialization routine
+ *
+ *
+ *
+ *
+* \param smi130_gyro_t *smi130_gyro
+ *      Pointer to a structure.
+ *
+ *       structure members are
+ *
+ *       unsigned char chip_id;
+ *       unsigned char dev_addr;
+ *       SMI130_GYRO_BRD_FUNC_PTR;
+ *       SMI130_GYRO_WR_FUNC_PTR;
+ *       SMI130_GYRO_RD_FUNC_PTR;
+ *       void(*delay_msec)( SMI130_GYRO_MDELAY_DATA_TYPE );
+ *
+ *
+ *
+ *
+ *
+ *  \return result of communication routines
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_init(struct smi130_gyro_t *smi130_gyro)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char a_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	p_smi130_gyro = smi130_gyro;
+
+	p_smi130_gyro->dev_addr = SMI130_GYRO_I2C_ADDR;
+
+	/*Read CHIP_ID */
+	comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+	 SMI130_GYRO_CHIP_ID_ADDR, &a_data_u8r, 1);
+	p_smi130_gyro->chip_id = a_data_u8r;
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief Reads Rate dataX from location 02h and 03h
+ * registers
+ *
+ *
+ *
+ *
+ *  \param
+ *      SMI130_GYRO_S16  *data_x   :  Address of data_x
+ *
+ *
+ *  \return
+ *      result of communication routines
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_dataX(SMI130_GYRO_S16 *data_x)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char a_data_u8r[2] = {0, 0};
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		 SMI130_GYRO_RATE_X_LSB_VALUEX__REG, a_data_u8r, 2);
+		a_data_u8r[0] = SMI130_GYRO_GET_BITSLICE(a_data_u8r[0],
+		SMI130_GYRO_RATE_X_LSB_VALUEX);
+		*data_x = (SMI130_GYRO_S16)
+		((((SMI130_GYRO_S16)((signed char)a_data_u8r[1])) <<
+		SMI130_GYRO_SHIFT_8_POSITION) | (a_data_u8r[0]));
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief Reads rate dataY from location 04h and 05h
+ * registers
+ *
+ *
+ *
+ *
+ *  \param
+ *      SMI130_GYRO_S16  *data_y   :  Address of data_y
+ *
+ *
+ *  \return
+ *      result of communication routines
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_dataY(SMI130_GYRO_S16 *data_y)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char a_data_u8r[2] = {0, 0};
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		 SMI130_GYRO_RATE_Y_LSB_VALUEY__REG, a_data_u8r, 2);
+		a_data_u8r[0] = SMI130_GYRO_GET_BITSLICE(a_data_u8r[0],
+		SMI130_GYRO_RATE_Y_LSB_VALUEY);
+		*data_y = (SMI130_GYRO_S16)
+		((((SMI130_GYRO_S16)((signed char)a_data_u8r[1]))
+		<< SMI130_GYRO_SHIFT_8_POSITION) | (a_data_u8r[0]));
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief Reads rate dataZ from location 06h and 07h
+ * registers
+ *
+ *
+ *
+ *
+ *  \param
+ *      SMI130_GYRO_S16  *data_z   :  Address of data_z
+ *
+ *
+ *  \return
+ *      result of communication routines
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_dataZ(SMI130_GYRO_S16 *data_z)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char a_data_u8r[2] = {0, 0};
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		 SMI130_GYRO_RATE_Z_LSB_VALUEZ__REG, a_data_u8r, 2);
+		a_data_u8r[0] = SMI130_GYRO_GET_BITSLICE(a_data_u8r[0],
+		SMI130_GYRO_RATE_Z_LSB_VALUEZ);
+		*data_z = (SMI130_GYRO_S16)
+		((((SMI130_GYRO_S16)((signed char)a_data_u8r[1]))
+		<< SMI130_GYRO_SHIFT_8_POSITION) | (a_data_u8r[0]));
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief Reads data X,Y and Z from location 02h to 07h
+ *
+ *
+ *
+ *
+ *  \param
+ *      smi130_gyro_data_t *data   :  Address of smi130_gyro_data_t
+ *
+ *
+ *  \return
+ *      result of communication routines
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_dataXYZ(struct smi130_gyro_data_t *data)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char a_data_u8r[6] = {0, 0, 0, 0, 0, 0};
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		 SMI130_GYRO_RATE_X_LSB_VALUEX__REG, a_data_u8r, 6);
+		/* Data X */
+		a_data_u8r[0] =
+		SMI130_GYRO_GET_BITSLICE(a_data_u8r[0], SMI130_GYRO_RATE_X_LSB_VALUEX);
+		data->datax = (SMI130_GYRO_S16)
+		((((SMI130_GYRO_S16)((signed char)a_data_u8r[1]))
+		<< SMI130_GYRO_SHIFT_8_POSITION) | (a_data_u8r[0]));
+		/* Data Y */
+		a_data_u8r[2] = SMI130_GYRO_GET_BITSLICE(a_data_u8r[2],
+		SMI130_GYRO_RATE_Y_LSB_VALUEY);
+		data->datay = (SMI130_GYRO_S16)
+		((((SMI130_GYRO_S16)((signed char)a_data_u8r[3]))
+		<< SMI130_GYRO_SHIFT_8_POSITION) | (a_data_u8r[2]));
+		/* Data Z */
+		a_data_u8r[4] = SMI130_GYRO_GET_BITSLICE(a_data_u8r[4],
+		SMI130_GYRO_RATE_Z_LSB_VALUEZ);
+		data->dataz = (SMI130_GYRO_S16)
+		((((SMI130_GYRO_S16)((signed char)a_data_u8r[5]))
+		<< SMI130_GYRO_SHIFT_8_POSITION) | (a_data_u8r[4]));
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief Reads data X,Y,Z and Interrupts
+ *							from location 02h to 07h
+ *
+ *
+ *
+ *
+ *  \param
+ *      smi130_gyro_data_t *data   :  Address of smi130_gyro_data_t
+ *
+ *
+ *  \return
+ *      result of communication routines
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_dataXYZI(struct smi130_gyro_data_t *data)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char a_data_u8r[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		 SMI130_GYRO_RATE_X_LSB_VALUEX__REG, a_data_u8r, 12);
+		/* Data X */
+		a_data_u8r[0] = SMI130_GYRO_GET_BITSLICE(a_data_u8r[0],
+		SMI130_GYRO_RATE_X_LSB_VALUEX);
+		data->datax = (SMI130_GYRO_S16)
+		((((SMI130_GYRO_S16)((signed char)a_data_u8r[1]))
+		<< SMI130_GYRO_SHIFT_8_POSITION) | (a_data_u8r[0]));
+		/* Data Y */
+		a_data_u8r[2] = SMI130_GYRO_GET_BITSLICE(a_data_u8r[2],
+		SMI130_GYRO_RATE_Y_LSB_VALUEY);
+		data->datay = (SMI130_GYRO_S16)
+		((((SMI130_GYRO_S16)((signed char)a_data_u8r[3]))
+		<< SMI130_GYRO_SHIFT_8_POSITION) | (a_data_u8r[2]));
+		/* Data Z */
+		a_data_u8r[4] = SMI130_GYRO_GET_BITSLICE(a_data_u8r[4],
+		SMI130_GYRO_RATE_Z_LSB_VALUEZ);
+		data->dataz = (SMI130_GYRO_S16)
+		((((SMI130_GYRO_S16)((signed char)a_data_u8r[5]))
+		<< SMI130_GYRO_SHIFT_8_POSITION) | (a_data_u8r[4]));
+		data->intstatus[0] = a_data_u8r[7];
+		data->intstatus[1] = a_data_u8r[8];
+		data->intstatus[2] = a_data_u8r[9];
+		data->intstatus[3] = a_data_u8r[10];
+		data->intstatus[4] = a_data_u8r[11];
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief Reads Temperature from location 08h
+ *
+ *
+ *
+ *
+ *  \param
+ *      unsigned char *temp   :  Address of temperature
+ *
+ *
+ *  \return
+ *      result of communication routines
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_Temperature(unsigned char *temperature)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		 SMI130_GYRO_TEMP_ADDR, &v_data_u8r, 1);
+		*temperature = v_data_u8r;
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API reads the data from the given register
+ *
+ *
+ *
+ *
+ *\param unsigned char addr, unsigned char *data unsigned char len
+ *                       addr -> Address of the register
+ *                       data -> address of the variable, read value will be
+ *								kept
+ *						len -> No of byte to be read.
+ *  \return  results of bus communication function
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_read_register(unsigned char addr,
+unsigned char *data, unsigned char len)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+		(p_smi130_gyro->dev_addr, addr, data, len);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API reads the data from the given register
+ *
+ *
+ *
+ *
+ *\param unsigned char addr, unsigned char *data SMI130_GYRO_S32 len
+ *                       addr -> Address of the register
+ *                       data -> address of the variable, read value will be
+ *								kept
+ *						len -> No of byte to be read.
+ *  \return  results of bus communication function
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_burst_read(unsigned char addr,
+unsigned char *data, SMI130_GYRO_S32 len)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BURST_READ_FUNC(p_smi130_gyro->dev_addr,
+		addr, data, len);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API given data to the given register
+ *
+ *
+ *
+ *
+ *\param unsigned char addr, unsigned char data,unsigned char len
+ *                   addr -> Address of the register
+ *                   data -> Data to be written to the register
+ *					len -> No of byte to be read.
+ *
+ *  \return Results of bus communication function
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_write_register(unsigned char addr,
+unsigned char *data, unsigned char len)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+		(p_smi130_gyro->dev_addr, addr, data, len);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief Reads interrupt status 0 register byte from 09h
+ *
+ *
+ *
+ *
+ *  \param
+ *      unsigned char *status0_data : Address of status 0 register
+ *
+ *
+ *  \return
+ *      Result of bus communication function
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_interrupt_status_reg_0(
+unsigned char *status0_data)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+		(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_INT_STATUSZERO__REG, &v_data_u8r, 1);
+		*status0_data =
+		SMI130_GYRO_GET_BITSLICE(v_data_u8r, SMI130_GYRO_INT_STATUSZERO);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief Reads interrupt status 1 register byte from 0Ah
+ *
+ *
+ *
+ *
+ *  \param
+ *      unsigned char *status1_data : Address of status register
+ *
+ *
+ *  \return
+ *      Result of bus communication function
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_interrupt_status_reg_1(
+unsigned char *status1_data)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+		(p_smi130_gyro->dev_addr, SMI130_GYRO_INT_STATUSONE__REG,
+		&v_data_u8r, 1);
+		*status1_data =
+		SMI130_GYRO_GET_BITSLICE(v_data_u8r, SMI130_GYRO_INT_STATUSONE);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief Reads interrupt status register byte from 0Bh
+ *
+ *
+ *
+ *
+ *  \param
+ *      unsigned char *status2_data : Address of status 2 register
+ *
+ *
+ *  \return
+ *      Result of bus communication function
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_interrupt_status_reg_2(
+unsigned char *status2_data)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+		(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_INT_STATUSTWO__REG, &v_data_u8r, 1);
+		*status2_data =
+		SMI130_GYRO_GET_BITSLICE(v_data_u8r, SMI130_GYRO_INT_STATUSTWO);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief Reads interrupt status 3 register byte from 0Ch
+ *
+ *
+ *
+ *
+ *  \param
+ *      unsigned char *status3_data : Address of status 3 register
+ *
+ *
+ *  \return
+ *      Result of bus communication function
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_interrupt_status_reg_3(
+unsigned char *status3_data)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+		(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_INT_STATUSTHREE__REG, &v_data_u8r, 1);
+		*status3_data =
+		SMI130_GYRO_GET_BITSLICE(v_data_u8r, SMI130_GYRO_INT_STATUSTHREE);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API reads the range from register 0x0Fh of
+ * (0 to 2) bits
+ *
+ *
+ *
+ *
+ *\param unsigned char *range
+ *      Range[0....7]
+ *      0 2000/s
+ *      1 1000/s
+ *      2 500/s
+ *      3 250/s
+ *      4 125/s
+ *
+ *
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_range_reg(unsigned char *range)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+		(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_RANGE_ADDR_RANGE__REG, &v_data_u8r, 1);
+		*range =
+		SMI130_GYRO_GET_BITSLICE(v_data_u8r, SMI130_GYRO_RANGE_ADDR_RANGE);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API sets the range register 0x0Fh
+ * (0 to 2 bits)
+ *
+ *
+ *
+ *
+ *\param unsigned char range
+ *
+ *      Range[0....7]
+ *      0 2000/s
+ *      1 1000/s
+ *      2 500/s
+ *      3 250/s
+ *      4 125/s
+ *
+ *
+ *
+ *
+ *  \return Communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_range_reg(unsigned char range)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		if (range < C_SMI130_GYRO_Five_U8X) {
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+			(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_RANGE_ADDR_RANGE__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_RANGE_ADDR_RANGE,
+			range);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+			(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_RANGE_ADDR_RANGE__REG, &v_data_u8r, 1);
+		} else {
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API reads the high resolution bit of 0x10h
+ * Register 7th bit
+ *
+ *
+ *
+ *
+ *\param unsigned char *high_res
+ *                      Pointer to a variable passed as a parameter
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_high_res(unsigned char *high_res)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+		(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_BW_ADDR_HIGH_RES__REG, &v_data_u8r, 1);
+		*high_res =
+		SMI130_GYRO_GET_BITSLICE(v_data_u8r, SMI130_GYRO_BW_ADDR_HIGH_RES);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API reads the bandwidth register of 0x10h 0 to
+ *  3 bits
+ *
+ *
+ *
+ *
+* \param unsigned char *bandwidth
+ *              pointer to a variable passed as a parameter
+ *
+ *              0 no filter(523 Hz)
+ *              1 230Hz
+ *              2 116Hz
+ *              3 47Hz
+ *              4 23Hz
+ *              5 12Hz
+ *              6 64Hz
+ *              7 32Hz
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_bw(unsigned char *bandwidth)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+		(p_smi130_gyro->dev_addr, SMI130_GYRO_BW_ADDR__REG, &v_data_u8r, 1);
+		*bandwidth = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_BW_ADDR);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API writes the Bandwidth register (0x10h of 0
+ * to 3 bits)
+ *
+ *
+ *
+ *
+ *\param unsigned char bandwidth,
+ *              The bandwidth to be set passed as a parameter
+ *
+ *              0 no filter(523 Hz)
+ *              1 230Hz
+ *              2 116Hz
+ *              3 47Hz
+ *              4 23Hz
+ *              5 12Hz
+ *              6 64Hz
+ *              7 32Hz
+ *
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_bw(unsigned char bandwidth)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_mode_u8r  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_autosleepduration  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		if (bandwidth < C_SMI130_GYRO_Eight_U8X) {
+			smi130_gyro_get_mode(&v_mode_u8r);
+			if (v_mode_u8r == SMI130_GYRO_MODE_ADVANCEDPOWERSAVING) {
+				smi130_gyro_get_autosleepdur(&v_autosleepduration);
+				smi130_gyro_set_autosleepdur(v_autosleepduration,
+				bandwidth);
+			}
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+			(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_BW_ADDR__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+				SMI130_GYRO_BW_ADDR, bandwidth);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_BW_ADDR__REG, &v_data_u8r, 1);
+		} else {
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API reads the status of External Trigger
+ * selection bits (4 and 5) of 0x12h registers
+ *
+ *
+ *
+ *
+ *\param unsigned char *pwu_ext_tri_sel
+ *                      Pointer to a variable passed as a parameter
+ *
+ *
+ *
+ *  \return Communication Results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_pmu_ext_tri_sel(
+unsigned char *pwu_ext_tri_sel)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		 SMI130_GYRO_MODE_LPM2_ADDR_EXT_TRI_SEL__REG, &v_data_u8r, 1);
+		*pwu_ext_tri_sel = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_MODE_LPM2_ADDR_EXT_TRI_SEL);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API writes the External Trigger selection
+ * bits (4 and 5) of 0x12h registers
+ *
+ *
+ *
+ *
+ *\param unsigned char pwu_ext_tri_sel
+ *               Value to be written passed as a parameter
+ *
+ *
+ *
+ *  \return Communication Results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_pmu_ext_tri_sel(
+unsigned char pwu_ext_tri_sel)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_MODE_LPM2_ADDR_EXT_TRI_SEL__REG, &v_data_u8r, 1);
+		v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_MODE_LPM2_ADDR_EXT_TRI_SEL, pwu_ext_tri_sel);
+		comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_MODE_LPM2_ADDR_EXT_TRI_SEL__REG, &v_data_u8r, 1);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief  This API is used to get data high bandwidth
+ *
+ *
+ *
+ *
+ *\param unsigned char *high_bw : Address of high_bw
+ *                         Pointer to a variable passed as a parameter
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_high_bw(unsigned char *high_bw)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		 SMI130_GYRO_RATED_HBW_ADDR_DATA_HIGHBW__REG, &v_data_u8r, 1);
+		*high_bw = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_RATED_HBW_ADDR_DATA_HIGHBW);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set data high bandwidth
+ *
+ *
+ *
+ *
+ *\param unsigned char high_bw:
+ *          Value to be written passed as a parameter
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_high_bw(unsigned char high_bw)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		if (high_bw < C_SMI130_GYRO_Two_U8X) {
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_RATED_HBW_ADDR_DATA_HIGHBW__REG,
+			&v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_RATED_HBW_ADDR_DATA_HIGHBW, high_bw);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_RATED_HBW_ADDR_DATA_HIGHBW__REG,
+			&v_data_u8r, 1);
+		} else {
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get shadow dis
+ *
+ *
+ *
+ *
+ *\param unsigned char *shadow_dis : Address of shadow_dis
+ *                       Pointer to a variable passed as a parameter
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_shadow_dis(unsigned char *shadow_dis)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_RATED_HBW_ADDR_SHADOW_DIS__REG, &v_data_u8r, 1);
+		*shadow_dis = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_RATED_HBW_ADDR_SHADOW_DIS);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set shadow dis
+ *
+ *
+ *
+ *
+ *\param unsigned char shadow_dis
+ *         Value to be written passed as a parameter
+ *
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_shadow_dis(unsigned char shadow_dis)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		if (shadow_dis < C_SMI130_GYRO_Two_U8X) {
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+			(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_RATED_HBW_ADDR_SHADOW_DIS__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_RATED_HBW_ADDR_SHADOW_DIS, shadow_dis);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_RATED_HBW_ADDR_SHADOW_DIS__REG, &v_data_u8r, 1);
+		} else {
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief
+ *               This function is used for the soft reset
+ *     The soft reset register will be written with 0xB6.
+ *
+ *
+ *
+* \param None
+ *
+ *
+ *
+ *  \return Communication results.
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_soft_reset()
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_SoftReset_u8r  = C_SMI130_GYRO_Zero_U8X;
+	v_SoftReset_u8r = 0xB6;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_BGW_SOFTRESET_ADDR, &v_SoftReset_u8r, 1);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get data enable data
+ *
+ *
+ *
+ *
+ *\param unsigned char *data_en : Address of data_en
+ *                         Pointer to a variable passed as a parameter
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_data_enable(unsigned char *data_en)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		 SMI130_GYRO_INT_ENABLE0_DATAEN__REG, &v_data_u8r, 1);
+		*data_en = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_INT_ENABLE0_DATAEN);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set data enable data
+ *
+ *
+ *
+ *
+ *  \param unsigned char data_en:
+ *          Value to be written passed as a \parameter
+ *           0 --> Disable
+ *           1 --> Enable
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_data_en(unsigned char data_en)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+			(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_INT_ENABLE0_DATAEN__REG, &v_data_u8r, 1);
+		v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_INT_ENABLE0_DATAEN, data_en);
+		comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+			(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_INT_ENABLE0_DATAEN__REG, &v_data_u8r, 1);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get fifo enable bit
+ *
+ *
+ *
+ *
+ *  \param unsigned char *fifo_en : Address of fifo_en
+ *                         Pointer to a variable passed as a parameter
+
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_fifo_enable(unsigned char *fifo_en)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		 SMI130_GYRO_INT_ENABLE0_FIFOEN__REG, &v_data_u8r, 1);
+		*fifo_en = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_INT_ENABLE0_FIFOEN);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set fifo enable bit
+ *
+ *
+ *
+ *
+ *  \param unsigned char fifo_en:
+ *          Value to be written passed as a parameter
+ *           0 --> Disable
+ *           1 --> Enable
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_fifo_enable(unsigned char fifo_en)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		if (fifo_en < C_SMI130_GYRO_Two_U8X) {
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_INT_ENABLE0_FIFOEN__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_INT_ENABLE0_FIFOEN, fifo_en);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_INT_ENABLE0_FIFOEN__REG, &v_data_u8r, 1);
+		} else {
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API reads the status of the Auto offset
+ * Enable bit
+ *                      (0x15 Reg 3rd Bit)
+ *
+ *
+ *
+ *
+ *  \param unsigned char *offset_en
+ *              address of a variable,
+ *
+ *
+ *
+ *  \return   Communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_auto_offset_en(
+unsigned char *offset_en)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		 SMI130_GYRO_INT_ENABLE0_AUTO_OFFSETEN__REG, &v_data_u8r, 1);
+		*offset_en = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_INT_ENABLE0_AUTO_OFFSETEN);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API sets the Auto offset enable bit
+ *                      (Reg 0x15 3rd Bit)
+ *
+ *
+ *
+ *
+ *  \param unsigned char offset_en
+ *                      0 --> Disable
+ *                      1 --> Enable
+ *
+ *  \return  Communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_auto_offset_en(unsigned char offset_en)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_INT_ENABLE0_AUTO_OFFSETEN__REG, &v_data_u8r, 1);
+		v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_INT_ENABLE0_AUTO_OFFSETEN, offset_en);
+		comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_INT_ENABLE0_AUTO_OFFSETEN__REG, &v_data_u8r, 1);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get the output type status
+ *
+ *
+ *
+ *
+ *  \param unsigned char channel,unsigned char *int_od
+ *                  SMI130_GYRO_INT1    ->   0
+ *                  SMI130_GYRO_INT2    ->   1
+ *                  int_od : open drain   ->   1
+ *                           push pull    ->   0
+ *
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_int_od(unsigned char param,
+unsigned char *int_od)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (param) {
+		case SMI130_GYRO_INT1:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			 SMI130_GYRO_INT_ENABLE1_IT1_OD__REG, &v_data_u8r, 1);
+			*int_od = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_INT_ENABLE1_IT1_OD);
+			break;
+		case SMI130_GYRO_INT2:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			 SMI130_GYRO_INT_ENABLE1_IT2_OD__REG, &v_data_u8r, 1);
+			*int_od = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_INT_ENABLE1_IT2_OD);
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set the output type status
+ *
+ *
+ *
+ *
+ *  \param unsigned char channel,unsigned char *int_od
+ *                  SMI130_GYRO_INT1    ->   0
+ *                  SMI130_GYRO_INT2    ->   1
+ *                  int_od : open drain   ->   1
+ *                           push pull    ->   0
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_int_od(unsigned char param,
+unsigned char int_od)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (param) {
+		case SMI130_GYRO_INT1:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_INT_ENABLE1_IT1_OD__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_INT_ENABLE1_IT1_OD, int_od);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_INT_ENABLE1_IT1_OD__REG, &v_data_u8r, 1);
+			break;
+		case SMI130_GYRO_INT2:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_INT_ENABLE1_IT2_OD__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_INT_ENABLE1_IT2_OD, int_od);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_INT_ENABLE1_IT2_OD__REG, &v_data_u8r, 1);
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get Active Level status
+ *
+ *
+ *
+ *
+ *  \param unsigned char channel,unsigned char *int_lvl
+ *                  SMI130_GYRO_INT1    ->    0
+ *                  SMI130_GYRO_INT2    ->    1
+ *                  int_lvl : Active HI   ->   1
+ *                            Active LO   ->   0
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_int_lvl(unsigned char param,
+unsigned char *int_lvl)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (param) {
+		case SMI130_GYRO_INT1:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			 SMI130_GYRO_INT_ENABLE1_IT1_LVL__REG, &v_data_u8r, 1);
+			*int_lvl = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_INT_ENABLE1_IT1_LVL);
+			break;
+		case SMI130_GYRO_INT2:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			 SMI130_GYRO_INT_ENABLE1_IT2_LVL__REG, &v_data_u8r, 1);
+			*int_lvl = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_INT_ENABLE1_IT2_LVL);
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set Active Level status
+ *
+ *
+ *
+ *
+ *  \param unsigned char channel,unsigned char *int_lvl
+ *                  SMI130_GYRO_INT1    ->    0
+ *                  SMI130_GYRO_INT2    ->    1
+ *                  int_lvl : Active HI   ->   1
+ *                            Active LO   ->   0
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_int_lvl(unsigned char param,
+unsigned char int_lvl)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (param) {
+		case SMI130_GYRO_INT1:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_INT_ENABLE1_IT1_LVL__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_INT_ENABLE1_IT1_LVL, int_lvl);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_INT_ENABLE1_IT1_LVL__REG, &v_data_u8r, 1);
+			break;
+		case SMI130_GYRO_INT2:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_INT_ENABLE1_IT2_LVL__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_INT_ENABLE1_IT2_LVL, int_lvl);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_INT_ENABLE1_IT2_LVL__REG, &v_data_u8r, 1);
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get High Interrupt1
+ *
+ *
+ *
+ *
+ *  \param unsigned char *int1_high : Address of high_bw
+ *                         Pointer to a variable passed as a parameter
+
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_int1_high(unsigned char *int1_high)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		 SMI130_GYRO_INT_MAP_0_INT1_HIGH__REG, &v_data_u8r, 1);
+		*int1_high = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_INT_MAP_0_INT1_HIGH);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set High Interrupt1
+ *
+ *
+ *
+ *
+ *  \param unsigned char int1_high
+ *                  0 -> Disable
+ *                  1 -> Enable
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_int1_high(unsigned char int1_high)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_INT_MAP_0_INT1_HIGH__REG, &v_data_u8r, 1);
+		v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_INT_MAP_0_INT1_HIGH, int1_high);
+		comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_INT_MAP_0_INT1_HIGH__REG, &v_data_u8r, 1);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get Any Interrupt1
+ *
+ *
+ *
+ *
+ *  \param unsigned char *int1_any : Address of high_bw
+ *                         Pointer to a variable passed as a parameter
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_int1_any(unsigned char *int1_any)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		 SMI130_GYRO_INT_MAP_0_INT1_ANY__REG, &v_data_u8r, 1);
+		*int1_any = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_INT_MAP_0_INT1_ANY);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set Any Interrupt1
+ *
+ *
+ *
+ *
+ *\param unsigned char int1_any
+ *                   0 -> Disable
+ *                   1 -> Enable
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_int1_any(unsigned char int1_any)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_INT_MAP_0_INT1_ANY__REG, &v_data_u8r, 1);
+		v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_INT_MAP_0_INT1_ANY, int1_any);
+		comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_INT_MAP_0_INT1_ANY__REG, &v_data_u8r, 1);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get data Interrupt1 and data
+ * Interrupt2
+ *
+ *
+ *
+ *
+ *  \param unsigned char axis,unsigned char *int_data
+ *                       axis :
+ *                       SMI130_GYRO_INT1_DATA -> 0
+ *                       SMI130_GYRO_INT2_DATA -> 1
+ *                       int_data :
+ *                       Disable     -> 0
+ *                       Enable      -> 1
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_int_data(unsigned char axis,
+unsigned char *int_data)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (axis) {
+		case SMI130_GYRO_INT1_DATA:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			 SMI130_GYRO_MAP_1_INT1_DATA__REG, &v_data_u8r, 1);
+			*int_data = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+				SMI130_GYRO_MAP_1_INT1_DATA);
+			break;
+		case SMI130_GYRO_INT2_DATA:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			 SMI130_GYRO_MAP_1_INT2_DATA__REG, &v_data_u8r, 1);
+			*int_data = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+				SMI130_GYRO_MAP_1_INT2_DATA);
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set data Interrupt1 and data
+ * Interrupt2
+ *
+ *
+ *
+ *
+ * \param unsigned char axis,unsigned char *int_data
+ *                       axis :
+ *                       SMI130_GYRO_INT1_DATA -> 0
+ *                       SMI130_GYRO_INT2_DATA -> 1
+ *                       int_data :
+ *                       Disable     -> 0
+ *                       Enable      -> 1
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_int_data(unsigned char axis,
+unsigned char int_data)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	}   else {
+			switch (axis) {
+			case SMI130_GYRO_INT1_DATA:
+				comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+					(p_smi130_gyro->dev_addr,
+				SMI130_GYRO_MAP_1_INT1_DATA__REG, &v_data_u8r, 1);
+				v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+				SMI130_GYRO_MAP_1_INT1_DATA, int_data);
+				comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+					(p_smi130_gyro->dev_addr,
+				SMI130_GYRO_MAP_1_INT1_DATA__REG, &v_data_u8r, 1);
+				break;
+			case SMI130_GYRO_INT2_DATA:
+				comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+					(p_smi130_gyro->dev_addr,
+				SMI130_GYRO_MAP_1_INT2_DATA__REG, &v_data_u8r, 1);
+				v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+				SMI130_GYRO_MAP_1_INT2_DATA, int_data);
+				comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+					(p_smi130_gyro->dev_addr,
+				SMI130_GYRO_MAP_1_INT2_DATA__REG, &v_data_u8r, 1);
+				break;
+			default:
+				comres = E_SMI130_GYRO_OUT_OF_RANGE;
+				break;
+			}
+		}
+		return comres;
+	}
+
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get fast offset and auto
+ * offset Interrupt2
+ *
+ *
+ *
+ *
+ *\param unsigned char axis,unsigned char *int2_offset
+ *                       axis :
+ *                       SMI130_GYRO_AUTO_OFFSET -> 1
+ *                       SMI130_GYRO_FAST_OFFSET -> 2
+ *                       int2_offset :
+ *                       Disable     -> 0
+ *                       Enable      -> 1
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_int2_offset(unsigned char axis,
+unsigned char *int2_offset)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (axis) {
+		case SMI130_GYRO_FAST_OFFSET:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			 SMI130_GYRO_MAP_1_INT2_FAST_OFFSET__REG, &v_data_u8r, 1);
+			*int2_offset = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_MAP_1_INT2_FAST_OFFSET);
+			break;
+		case SMI130_GYRO_AUTO_OFFSET:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			 SMI130_GYRO_MAP_1_INT2_AUTO_OFFSET__REG, &v_data_u8r, 1);
+			*int2_offset = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_MAP_1_INT2_AUTO_OFFSET);
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set fast offset and auto
+ * offset Interrupt2
+ *
+ *
+ *
+ *
+ *\param unsigned char axis,unsigned char *int2_offset
+ *                       axis :
+ *                       SMI130_GYRO_AUTO_OFFSET -> 1
+ *                       SMI130_GYRO_FAST_OFFSET -> 2
+ *                       int2_offset :
+ *                       Disable     -> 0
+ *                       Enable      -> 1
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_int2_offset(unsigned char axis,
+unsigned char int2_offset)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (axis) {
+		case SMI130_GYRO_FAST_OFFSET:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_MAP_1_INT2_FAST_OFFSET__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_MAP_1_INT2_FAST_OFFSET, int2_offset);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_MAP_1_INT2_FAST_OFFSET__REG, &v_data_u8r, 1);
+			break;
+		case SMI130_GYRO_AUTO_OFFSET:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_MAP_1_INT2_AUTO_OFFSET__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_MAP_1_INT2_AUTO_OFFSET, int2_offset);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_MAP_1_INT2_AUTO_OFFSET__REG, &v_data_u8r, 1);
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get fast offset and auto
+ * offset Interrupt1
+ *
+ *
+ *
+ *
+ *\param unsigned char axis,unsigned char *int1_offset
+ *                       axis :
+ *                       SMI130_GYRO_AUTO_OFFSET -> 1
+ *                       SMI130_GYRO_FAST_OFFSET -> 2
+ *                       int2_offset :
+ *                       Disable     -> 0
+ *                       Enable      -> 1
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_int1_offset(unsigned char axis,
+unsigned char *int1_offset)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (axis) {
+		case SMI130_GYRO_FAST_OFFSET:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			 SMI130_GYRO_MAP_1_INT1_FAST_OFFSET__REG, &v_data_u8r, 1);
+			*int1_offset = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_MAP_1_INT1_FAST_OFFSET);
+			break;
+		case SMI130_GYRO_AUTO_OFFSET:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			 SMI130_GYRO_MAP_1_INT1_AUTO_OFFSET__REG, &v_data_u8r, 1);
+			*int1_offset = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_MAP_1_INT1_AUTO_OFFSET);
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set fast offset and auto
+ * offset Interrupt1
+ *
+ *
+ *
+ *
+ *\param unsigned char axis,unsigned char *int1_offset
+ *                       axis :
+ *                       SMI130_GYRO_AUTO_OFFSET -> 1
+ *                       SMI130_GYRO_FAST_OFFSET -> 2
+ *                       int2_offset :
+ *                       Disable     -> 0
+ *                       Enable      -> 1
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_int1_offset(unsigned char axis,
+unsigned char int1_offset)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (axis) {
+		case SMI130_GYRO_FAST_OFFSET:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_MAP_1_INT1_FAST_OFFSET__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_MAP_1_INT1_FAST_OFFSET, int1_offset);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_MAP_1_INT1_FAST_OFFSET__REG, &v_data_u8r, 1);
+			break;
+		case SMI130_GYRO_AUTO_OFFSET:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_MAP_1_INT1_AUTO_OFFSET__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_MAP_1_INT1_AUTO_OFFSET, int1_offset);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_MAP_1_INT1_AUTO_OFFSET__REG, &v_data_u8r, 1);
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get status of FIFO Interrupt
+ *
+ *
+ *
+ *
+ *\param unsigned char *int_fifo : Address of int_fifo
+ *                         Pointer to a variable passed as a parameter
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_int_fifo(unsigned char *int_fifo)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		 SMI130_GYRO_INT_STATUS1_FIFO_INT__REG, &v_data_u8r, 1);
+		*int_fifo = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_INT_STATUS1_FIFO_INT);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get FIFO Interrupt2
+ *
+ *
+ *
+ *
+ *\param unsigned char *int_fifo
+ *                  int_fifo :
+ *                       Disable     -> 0
+ *                       Enable      -> 1
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_int2_fifo(unsigned char *int_fifo)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_MAP_1_INT2_FIFO__REG, &v_data_u8r, 1);
+		*int_fifo = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_MAP_1_INT2_FIFO);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get FIFO Interrupt1
+ *
+ *
+ *
+ *
+ *\param unsigned char *int_fifo
+ *                  int_fifo :
+ *                       Disable     -> 0
+ *                       Enable      -> 1
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_int1_fifo(unsigned char *int_fifo)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		 SMI130_GYRO_MAP_1_INT1_FIFO__REG, &v_data_u8r, 1);
+		*int_fifo = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_MAP_1_INT1_FIFO);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_int_fifo(unsigned char axis,
+unsigned char int_fifo)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (axis) {
+		case SMI130_GYRO_INT1:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			 SMI130_GYRO_MAP_1_INT1_FIFO__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_MAP_1_INT1_FIFO, int_fifo);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_MAP_1_INT1_FIFO__REG, &v_data_u8r, 1);
+			break;
+		case SMI130_GYRO_INT2:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_MAP_1_INT2_FIFO__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_MAP_1_INT2_FIFO, int_fifo);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_MAP_1_INT2_FIFO__REG, &v_data_u8r, 1);
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set FIFO Interrupt1
+ *
+ *
+ *
+ *
+ *\param unsigned char *fifo_int1
+ *                  fifo_int1 :
+ *                       Disable     -> 0
+ *                       Enable      -> 1
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_int1_fifo(unsigned char fifo_int1)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		if (fifo_int1 < C_SMI130_GYRO_Two_U8X) {
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_MAP_1_INT1_FIFO__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_MAP_1_INT1_FIFO, fifo_int1);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_MAP_1_INT1_FIFO__REG, &v_data_u8r, 1);
+		} else {
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set FIFO Interrupt2
+ *
+ *
+ *
+ *
+ *\param unsigned char *fifo_int2
+ *                  fifo_int2 :
+ *                       Disable     -> 0
+ *                       Enable      -> 1
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_int2_fifo(unsigned char fifo_int2)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		if (fifo_int2 < C_SMI130_GYRO_Two_U8X) {
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_MAP_1_INT2_FIFO__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_MAP_1_INT2_FIFO, fifo_int2);
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_MAP_1_INT2_FIFO__REG, &v_data_u8r, 1);
+		} else {
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get High Interrupt2
+ *
+ *
+ *
+ *
+ *\param unsigned char *int2_high : Address of int2_high
+ *                         Pointer to a variable passed as a parameter
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_int2_high(unsigned char *int2_high)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_INT_MAP_2_INT2_HIGH__REG, &v_data_u8r, 1);
+		*int2_high = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_INT_MAP_2_INT2_HIGH);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get High Interrupt2
+ *
+ *
+ *
+ *
+ *\param unsigned char int2_high
+ *                  0 -> Disable
+ *                  1 -> Enable
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_int2_high(unsigned char int2_high)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_INT_MAP_2_INT2_HIGH__REG, &v_data_u8r, 1);
+		v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_INT_MAP_2_INT2_HIGH, int2_high);
+		comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_INT_MAP_2_INT2_HIGH__REG, &v_data_u8r, 1);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get Any Interrupt2
+ *
+ *
+ *
+ *
+ *\param unsigned char *int2_any : Address of int2_any
+ *                         Pointer to a variable passed as a parameter
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_int2_any(unsigned char *int2_any)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_INT_MAP_2_INT2_ANY__REG, &v_data_u8r, 1);
+		*int2_any = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_INT_MAP_2_INT2_ANY);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set Any Interrupt2
+ *
+ *
+ *
+ *
+ *\param unsigned char int2_any
+ *                  0 -> Disable
+ *                  1 -> Enable
+ *
+ *
+ *
+ *
+ * \return  communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_int2_any(unsigned char int2_any)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_INT_MAP_2_INT2_ANY__REG, &v_data_u8r, 1);
+		v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_INT_MAP_2_INT2_ANY, int2_any);
+		comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_INT_MAP_2_INT2_ANY__REG, &v_data_u8r, 1);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get slow offset and fast
+ * offset unfilt data
+ *
+ *
+ *
+ *\param unsigned char param,unsigned char *offset_unfilt
+ *                  param :
+ *                  SMI130_GYRO_SLOW_OFFSET -> 0
+ *                  SMI130_GYRO_FAST_OFFSET -> 2
+ *                  offset_unfilt: Enable  -> 1
+ *                                Disable -> 0
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_offset_unfilt(unsigned char param,
+unsigned char *offset_unfilt)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (param) {
+		case SMI130_GYRO_SLOW_OFFSET:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_INT_0_ADDR_SLOW_OFFSET_UNFILT__REG,
+			&v_data_u8r, 1);
+			*offset_unfilt = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_INT_0_ADDR_SLOW_OFFSET_UNFILT);
+			break;
+		case SMI130_GYRO_FAST_OFFSET:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_INT_1_ADDR_FAST_OFFSET_UNFILT__REG,
+			&v_data_u8r, 1);
+			*offset_unfilt = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_INT_1_ADDR_FAST_OFFSET_UNFILT);
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set slow offset and fast
+ * offset unfilt data
+ *
+ *
+ *
+ *
+ *\param unsigned char param,unsigned char *offset_unfilt
+ *                  param :
+ *                  SMI130_GYRO_SLOW_OFFSET -> 0
+ *                  SMI130_GYRO_FAST_OFFSET -> 2
+ *                  offset_unfilt: Enable  -> 1
+ *                                Disable -> 0
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_offset_unfilt(unsigned char param,
+unsigned char offset_unfilt)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (param) {
+		case SMI130_GYRO_SLOW_OFFSET:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_INT_0_ADDR_SLOW_OFFSET_UNFILT__REG,
+			&v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_INT_0_ADDR_SLOW_OFFSET_UNFILT, offset_unfilt);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_INT_0_ADDR_SLOW_OFFSET_UNFILT__REG,
+			&v_data_u8r, 1);
+			break;
+		case SMI130_GYRO_FAST_OFFSET:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_INT_1_ADDR_FAST_OFFSET_UNFILT__REG,
+			&v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_INT_1_ADDR_FAST_OFFSET_UNFILT, offset_unfilt);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_INT_1_ADDR_FAST_OFFSET_UNFILT__REG,
+			&v_data_u8r, 1);
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get Tap, High, Constant, Any,
+ * Shake unfilt data
+ *
+ *
+ *
+ *
+ *\param unsigned char param,unsigned char *unfilt_data
+ *                  param :
+ *
+ *                  SMI130_GYRO_HIGH_UNFILT_DATA      -> 1
+ *                  SMI130_GYRO_ANY_UNFILT_DATA       -> 3
+ *
+ *                  unfilt_data:   Enable  -> 1
+ *                                Disable -> 0
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_unfilt_data(unsigned char param,
+unsigned char *unfilt_data)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (param) {
+		case SMI130_GYRO_HIGH_UNFILT_DATA:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_INT_0_ADDR_HIGH_UNFILT_DATA__REG,
+			&v_data_u8r, 1);
+			*unfilt_data = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_INT_0_ADDR_HIGH_UNFILT_DATA);
+			break;
+		case SMI130_GYRO_ANY_UNFILT_DATA:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_INT_0_ADDR_ANY_UNFILT_DATA__REG, &v_data_u8r, 1);
+			*unfilt_data = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_INT_0_ADDR_ANY_UNFILT_DATA);
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set Tap, High, Constant, Any,
+ * Shake unfilt data
+ *
+ *
+ *
+ *
+ *\param unsigned char param,unsigned char *unfilt_data
+ *                  param :
+ *
+ *                  SMI130_GYRO_HIGH_UNFILT_DATA      -> 1
+ *                  SMI130_GYRO_ANY_UNFILT_DATA       -> 3
+ *
+ *                  unfilt_data:   Enable  -> 1
+ *                                Disable -> 0
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_unfilt_data(unsigned char param,
+unsigned char unfilt_data)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (param) {
+		case SMI130_GYRO_HIGH_UNFILT_DATA:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_INT_0_ADDR_HIGH_UNFILT_DATA__REG,
+			&v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_INT_0_ADDR_HIGH_UNFILT_DATA, unfilt_data);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_INT_0_ADDR_HIGH_UNFILT_DATA__REG,
+			&v_data_u8r, 1);
+			break;
+		case SMI130_GYRO_ANY_UNFILT_DATA:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_INT_0_ADDR_ANY_UNFILT_DATA__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_INT_0_ADDR_ANY_UNFILT_DATA, unfilt_data);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_INT_0_ADDR_ANY_UNFILT_DATA__REG, &v_data_u8r, 1);
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get Any Threshold
+ *
+ *
+ *
+ *
+ *\param unsigned char *any_th : Address of any_th
+ *                         Pointer to a variable passed as a parameter
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_any_th(unsigned char *any_th)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_INT_1_ADDR_ANY_TH__REG, &v_data_u8r, 1);
+		*any_th = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_INT_1_ADDR_ANY_TH);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set Any Threshold
+ *
+ *
+ *
+ *
+ *\param unsigned char any_th:
+ *          Value to be written passed as a parameter
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_any_th(unsigned char any_th)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_INT_1_ADDR_ANY_TH__REG, &v_data_u8r, 1);
+		v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_INT_1_ADDR_ANY_TH, any_th);
+		comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_INT_1_ADDR_ANY_TH__REG, &v_data_u8r, 1);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get Awake Duration
+ *
+ *
+ *
+ *
+ *\param unsigned char *awake_dur : Address of awake_dur
+ *                         Pointer to a variable passed as a parameter
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_awake_dur(unsigned char *awake_dur)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_INT_2_ADDR_AWAKE_DUR__REG, &v_data_u8r, 1);
+		*awake_dur = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_INT_2_ADDR_AWAKE_DUR);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set Awake Duration
+ *
+ *
+ *
+ *
+ *\param unsigned char awake_dur:
+ *          Value to be written passed as a parameter
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************
+ * Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_awake_dur(unsigned char awake_dur)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_INT_2_ADDR_AWAKE_DUR__REG, &v_data_u8r, 1);
+		v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_INT_2_ADDR_AWAKE_DUR, awake_dur);
+		comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_INT_2_ADDR_AWAKE_DUR__REG, &v_data_u8r, 1);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get Any Duration Sample
+ *
+ *
+ *
+ *
+ *\param unsigned char *dursample : Address of dursample
+ *                         Pointer to a variable passed as a parameter
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_any_dursample(unsigned char *dursample)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_INT_2_ADDR_ANY_DURSAMPLE__REG, &v_data_u8r, 1);
+		*dursample = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_INT_2_ADDR_ANY_DURSAMPLE);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set Any Duration Sample
+ *
+ *
+ *
+ *
+ *\param unsigned char dursample:
+ *          Value to be written passed as a parameter
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_any_dursample(unsigned char dursample)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_INT_2_ADDR_ANY_DURSAMPLE__REG, &v_data_u8r, 1);
+		v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_INT_2_ADDR_ANY_DURSAMPLE, dursample);
+		comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_INT_2_ADDR_ANY_DURSAMPLE__REG, &v_data_u8r, 1);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get the status of Any Enable
+ * Channel X,Y,Z
+ *
+ *
+ *
+ *
+ *\param unsigned char channel,unsigned char *data
+ *                       channel :
+ *                       SMI130_GYRO_X_AXIS -> 0
+ *                       SMI130_GYRO_Y_AXIS -> 1
+ *                       SMI130_GYRO_Z_AXIS -> 2
+ *                       data :
+ *                       Enable  -> 1
+ *                       disable -> 0
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_any_en_ch(unsigned char channel,
+unsigned char *data)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (channel) {
+		case SMI130_GYRO_X_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_INT_2_ADDR_ANY_EN_X__REG, &v_data_u8r, 1);
+			*data = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_INT_2_ADDR_ANY_EN_X);
+			break;
+		case SMI130_GYRO_Y_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_INT_2_ADDR_ANY_EN_Y__REG, &v_data_u8r, 1);
+			*data = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+				SMI130_GYRO_INT_2_ADDR_ANY_EN_Y);
+			break;
+		case SMI130_GYRO_Z_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_INT_2_ADDR_ANY_EN_Z__REG, &v_data_u8r, 1);
+			*data = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+				SMI130_GYRO_INT_2_ADDR_ANY_EN_Z);
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set the status of Any Enable
+ * Channel X,Y,Z
+ *
+ *
+ *
+ *
+ *\param unsigned char channel,unsigned char *data
+ *                       channel :
+ *                       SMI130_GYRO_X_AXIS -> 0
+ *                       SMI130_GYRO_Y_AXIS -> 1
+ *                       SMI130_GYRO_Z_AXIS -> 2
+ *                       data :
+ *                       Enable  -> 1
+ *                       disable -> 0
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_any_en_ch(unsigned char channel,
+unsigned char data)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (channel) {
+		case SMI130_GYRO_X_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_INT_2_ADDR_ANY_EN_X__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_INT_2_ADDR_ANY_EN_X, data);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_INT_2_ADDR_ANY_EN_X__REG, &v_data_u8r, 1);
+			break;
+		case SMI130_GYRO_Y_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_INT_2_ADDR_ANY_EN_Y__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_INT_2_ADDR_ANY_EN_Y, data);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_INT_2_ADDR_ANY_EN_Y__REG, &v_data_u8r, 1);
+			break;
+		case SMI130_GYRO_Z_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_INT_2_ADDR_ANY_EN_Z__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_INT_2_ADDR_ANY_EN_Z, data);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_INT_2_ADDR_ANY_EN_Z__REG, &v_data_u8r, 1);
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get the status of FIFO WM
+ * Enable
+ *
+ *
+ *
+ *
+ *\param unsigned char *fifo_wn_en
+ *                       Enable  -> 1
+ *                       Disable -> 0
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_fifo_watermark_enable(
+unsigned char *fifo_wn_en)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_INT_4_FIFO_WM_EN__REG, &v_data_u8r, 1);
+		*fifo_wn_en = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_INT_4_FIFO_WM_EN);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set FIFO WM Enable
+ *
+ *
+ *
+ *
+ *\param unsigned char *fifo_wn_en
+ *                       Enable  -> 1
+ *                       Disable -> 0
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_fifo_watermark_enable(
+unsigned char fifo_wn_en)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		if (fifo_wn_en < C_SMI130_GYRO_Two_U8X) {
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_INT_4_FIFO_WM_EN__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_INT_4_FIFO_WM_EN, fifo_wn_en);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_INT_4_FIFO_WM_EN__REG, &v_data_u8r, 1);
+		} else {
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set the Interrupt Reset
+ *
+ *
+ *
+ *
+ *\param unsigned char reset_int
+ *                    1 -> Reset All Interrupts
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_reset_int(unsigned char reset_int)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_RST_LATCH_ADDR_RESET_INT__REG, &v_data_u8r, 1);
+		v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_RST_LATCH_ADDR_RESET_INT, reset_int);
+		comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_RST_LATCH_ADDR_RESET_INT__REG, &v_data_u8r, 1);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set the Offset Reset
+ *
+ *
+ *
+ *
+ *\param unsigned char offset_reset
+ *                  1 -> Resets All the Offsets
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_offset_reset(
+unsigned char offset_reset)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_RST_LATCH_ADDR_OFFSET_RESET__REG, &v_data_u8r, 1);
+		v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_RST_LATCH_ADDR_OFFSET_RESET, offset_reset);
+		comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_RST_LATCH_ADDR_OFFSET_RESET__REG, &v_data_u8r, 1);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get the Latch Status
+ *
+ *
+ *
+ *
+ *\param unsigned char *latch_status : Address of latch_status
+ *                         Pointer to a variable passed as a parameter
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_latch_status(
+unsigned char *latch_status)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_RST_LATCH_ADDR_LATCH_STATUS__REG, &v_data_u8r, 1);
+		*latch_status = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_RST_LATCH_ADDR_LATCH_STATUS);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set the Latch Status
+ *
+ *
+ *
+ *
+ *\param unsigned char latch_status:
+ *          Value to be written passed as a parameter
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_latch_status(
+unsigned char latch_status)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_RST_LATCH_ADDR_LATCH_STATUS__REG, &v_data_u8r, 1);
+		v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_RST_LATCH_ADDR_LATCH_STATUS, latch_status);
+		comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_RST_LATCH_ADDR_LATCH_STATUS__REG, &v_data_u8r, 1);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get the Latch Interrupt
+ *
+ *
+ *
+ *
+ *\param unsigned char *latch_int : Address of latch_int
+ *                         Pointer to a variable passed as a parameter
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_latch_int(unsigned char *latch_int)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_RST_LATCH_ADDR_LATCH_INT__REG, &v_data_u8r, 1);
+		*latch_int = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_RST_LATCH_ADDR_LATCH_INT);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set the Latch Interrupt
+ *
+ *
+ *
+ *
+ *\param unsigned char latch_int:
+ *          Value to be written passed as a parameter
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_latch_int(unsigned char latch_int)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_RST_LATCH_ADDR_LATCH_INT__REG, &v_data_u8r, 1);
+		v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_RST_LATCH_ADDR_LATCH_INT, latch_int);
+		comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_RST_LATCH_ADDR_LATCH_INT__REG, &v_data_u8r, 1);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get the status of High
+ * Hysteresis X,Y,Z
+ *
+ *
+ *
+ *
+ *\param unsigned char channel,unsigned char *high_hy
+ *                       channel :
+ *                       SMI130_GYRO_X_AXIS -> 0
+ *                       SMI130_GYRO_Y_AXIS -> 1
+ *                       SMI130_GYRO_Z_AXIS -> 2
+ *                       high_hy :
+ *                       Enable  -> 1
+ *                       disable -> 0
+ *
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_high_hy(unsigned char channel,
+unsigned char *high_hy)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (channel) {
+		case SMI130_GYRO_X_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_HIGH_HY_X__REG, &v_data_u8r, 1);
+			*high_hy = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+				SMI130_GYRO_HIGH_HY_X);
+			break;
+		case SMI130_GYRO_Y_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_HIGH_HY_Y__REG, &v_data_u8r, 1);
+			*high_hy = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+				SMI130_GYRO_HIGH_HY_Y);
+			break;
+		case SMI130_GYRO_Z_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_HIGH_HY_Z__REG, &v_data_u8r, 1);
+			*high_hy = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+				SMI130_GYRO_HIGH_HY_Z);
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set the status of High
+ * Hysteresis X,Y,Z
+ *
+ *
+ *
+ *
+ *\param unsigned char channel,unsigned char *high_hy
+ *                       channel :
+ *                       SMI130_GYRO_X_AXIS -> 0
+ *                       SMI130_GYRO_Y_AXIS -> 1
+ *                       SMI130_GYRO_Z_AXIS -> 2
+ *                       high_hy :
+ *                       Enable  -> 1
+ *                       disable -> 0
+ *
+ *
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_high_hy(unsigned char channel,
+unsigned char high_hy)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (channel) {
+		case SMI130_GYRO_X_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_HIGH_HY_X__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_HIGH_HY_X, high_hy);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_HIGH_HY_X__REG, &v_data_u8r, 1);
+			break;
+		case SMI130_GYRO_Y_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_HIGH_HY_Y__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_HIGH_HY_Y, high_hy);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_HIGH_HY_Y__REG, &v_data_u8r, 1);
+			break;
+		case SMI130_GYRO_Z_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_HIGH_HY_Z__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_HIGH_HY_Z, high_hy);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_HIGH_HY_Z__REG, &v_data_u8r, 1);
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get the status of High
+ * Threshold X,Y,Z
+ *
+ *
+ *
+ *
+ *\param unsigned char channel,unsigned char *high_th
+ *                       channel :
+ *                       SMI130_GYRO_X_AXIS -> 0
+ *                       SMI130_GYRO_Y_AXIS -> 1
+ *                       SMI130_GYRO_Z_AXIS -> 2
+ *                       high_th :
+ *                       Enable  -> 1
+ *                       disable -> 0
+ *
+ *
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_high_th(unsigned char channel,
+unsigned char *high_th)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (channel) {
+		case SMI130_GYRO_X_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_HIGH_TH_X__REG, &v_data_u8r, 1);
+			*high_th = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+				SMI130_GYRO_HIGH_TH_X);
+			break;
+		case SMI130_GYRO_Y_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_HIGH_TH_Y__REG, &v_data_u8r, 1);
+			*high_th = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+				SMI130_GYRO_HIGH_TH_Y);
+			break;
+		case SMI130_GYRO_Z_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_HIGH_TH_Z__REG, &v_data_u8r, 1);
+			*high_th = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+				SMI130_GYRO_HIGH_TH_Z);
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set the status of High
+ * Threshold X,Y,Z
+ *
+ *
+ *
+ *
+ *\param unsigned char channel,unsigned char *high_th
+ *                       channel :
+ *                       SMI130_GYRO_X_AXIS -> 0
+ *                       SMI130_GYRO_Y_AXIS -> 1
+ *                       SMI130_GYRO_Z_AXIS -> 2
+ *                       high_th :
+ *                       Enable  -> 1
+ *                       disable -> 0
+ *
+ *
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_high_th(unsigned char channel,
+unsigned char high_th)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (channel) {
+		case SMI130_GYRO_X_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_HIGH_TH_X__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+				SMI130_GYRO_HIGH_TH_X, high_th);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_HIGH_TH_X__REG, &v_data_u8r, 1);
+			break;
+		case SMI130_GYRO_Y_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_HIGH_TH_Y__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+				SMI130_GYRO_HIGH_TH_Y, high_th);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_HIGH_TH_Y__REG, &v_data_u8r, 1);
+			break;
+		case SMI130_GYRO_Z_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_HIGH_TH_Z__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+				SMI130_GYRO_HIGH_TH_Z, high_th);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_HIGH_TH_Z__REG, &v_data_u8r, 1);
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get the status of High Enable
+ * Channel X,Y,Z
+ *
+ *
+ *
+ *
+ *\param unsigned char channel,unsigned char *high_en
+ *                       channel :
+ *                       SMI130_GYRO_X_AXIS -> 0
+ *                       SMI130_GYRO_Y_AXIS -> 1
+ *                       SMI130_GYRO_Z_AXIS -> 2
+ *                       high_en :
+ *                       Enable  -> 1
+ *                       disable -> 0
+ *
+ *
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_high_en_ch(unsigned char channel,
+unsigned char *high_en)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (channel) {
+		case SMI130_GYRO_X_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_HIGH_EN_X__REG, &v_data_u8r, 1);
+			*high_en = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+				SMI130_GYRO_HIGH_EN_X);
+			break;
+		case SMI130_GYRO_Y_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_HIGH_EN_Y__REG, &v_data_u8r, 1);
+			*high_en = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+				SMI130_GYRO_HIGH_EN_Y);
+			break;
+		case SMI130_GYRO_Z_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_HIGH_EN_Z__REG, &v_data_u8r, 1);
+			*high_en = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+				SMI130_GYRO_HIGH_EN_Z);
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set the status of High Enable
+ * Channel X,Y,Z
+ *
+ *
+ *
+ *
+ *\param unsigned char channel,unsigned char *high_en
+ *                       channel :
+ *                       SMI130_GYRO_X_AXIS -> 0
+ *                       SMI130_GYRO_Y_AXIS -> 1
+ *                       SMI130_GYRO_Z_AXIS -> 2
+ *                       high_en :
+ *                       Enable  -> 1
+ *                       disable -> 0
+ *
+ *
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_high_en_ch(unsigned char channel,
+unsigned char high_en)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (channel) {
+		case SMI130_GYRO_X_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_HIGH_EN_X__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+				SMI130_GYRO_HIGH_EN_X, high_en);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_HIGH_EN_X__REG, &v_data_u8r, 1);
+			break;
+		case SMI130_GYRO_Y_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_HIGH_EN_Y__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+				SMI130_GYRO_HIGH_EN_Y, high_en);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_HIGH_EN_Y__REG, &v_data_u8r, 1);
+			break;
+		case SMI130_GYRO_Z_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_HIGH_EN_Z__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+				SMI130_GYRO_HIGH_EN_Z, high_en);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_HIGH_EN_Z__REG, &v_data_u8r, 1);
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get High Duration
+ *
+ *
+ *
+ *
+ *\param unsigned char channel,unsigned char *high_dur
+ *                       channel :
+ *                       SMI130_GYRO_X_AXIS -> 0
+ *                       SMI130_GYRO_Y_AXIS -> 1
+ *                       SMI130_GYRO_Z_AXIS -> 2
+ *                       *high_dur : Address of high_bw
+ *                                   Pointer to a variable passed as a
+ *                                   parameter
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_high_dur_ch(unsigned char channel,
+unsigned char *high_dur)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (channel) {
+		case SMI130_GYRO_X_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_HIGH_DUR_X_ADDR, &v_data_u8r, 1);
+			*high_dur = v_data_u8r;
+			break;
+		case SMI130_GYRO_Y_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_HIGH_DUR_Y_ADDR, &v_data_u8r, 1);
+			*high_dur = v_data_u8r;
+			break;
+		case SMI130_GYRO_Z_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_HIGH_DUR_Z_ADDR, &v_data_u8r, 1);
+			*high_dur = v_data_u8r;
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set High Duration
+ *
+ *
+ *
+ *
+ *\param unsigned char channel,unsigned char *high_dur
+ *                       channel :
+ *                       SMI130_GYRO_X_AXIS -> 0
+ *                       SMI130_GYRO_Y_AXIS -> 1
+ *                       SMI130_GYRO_Z_AXIS -> 2
+ *                       high_dur : Value to be written passed as a parameter
+ *
+ *
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_high_dur_ch(unsigned char channel,
+unsigned char high_dur)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (channel) {
+		case SMI130_GYRO_X_AXIS:
+			v_data_u8r = high_dur;
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_HIGH_DUR_X_ADDR, &v_data_u8r, 1);
+			break;
+		case SMI130_GYRO_Y_AXIS:
+			v_data_u8r = high_dur;
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_HIGH_DUR_Y_ADDR, &v_data_u8r, 1);
+			break;
+		case SMI130_GYRO_Z_AXIS:
+			v_data_u8r = high_dur;
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_HIGH_DUR_Z_ADDR, &v_data_u8r, 1);
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get Slow Offset Threshold
+ *
+ *
+ *
+ *
+ *\param unsigned char *offset_th : Address of offset_th
+ *                         Pointer to a variable passed as a parameter
+
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_slow_offset_th(
+unsigned char *offset_th)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_SLOW_OFFSET_TH__REG, &v_data_u8r, 1);
+		*offset_th = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_SLOW_OFFSET_TH);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set Slow Offset Threshold
+ *
+ *
+ *
+ *
+ *\param unsigned char offset_th:
+ *          Value to be written passed as a parameter
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_slow_offset_th(unsigned char offset_th)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_SLOW_OFFSET_TH__REG, &v_data_u8r, 1);
+		v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_SLOW_OFFSET_TH, offset_th);
+		comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_SLOW_OFFSET_TH__REG, &v_data_u8r, 1);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get Slow Offset Duration
+ *
+ *
+ *
+ *
+ *\param unsigned char *offset_dur : Address of offset_dur
+ *                         Pointer to a variable passed as a parameter
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_slow_offset_dur(
+unsigned char *offset_dur)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_SLOW_OFFSET_DUR__REG, &v_data_u8r, 1);
+		*offset_dur = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_SLOW_OFFSET_DUR);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set Slow Offset Duration
+ *
+ *
+ *
+ *
+ *\param unsigned char offset_dur:
+ *          Value to be written passed as a parameter
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_slow_offset_dur(
+unsigned char offset_dur)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_SLOW_OFFSET_DUR__REG, &v_data_u8r, 1);
+		v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_SLOW_OFFSET_DUR, offset_dur);
+		comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_SLOW_OFFSET_DUR__REG, &v_data_u8r, 1);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get Slow Offset Enable channel
+ * X,Y,Z
+ *
+ *
+ *
+ *
+ *\param unsigned char channel,unsigned char *slow_offset
+ *                       channel :
+ *                       SMI130_GYRO_X_AXIS -> 0
+ *                       SMI130_GYRO_Y_AXIS -> 1
+ *                       SMI130_GYRO_Z_AXIS -> 2
+ *                       slow_offset :
+ *                       Enable  -> 1
+ *                       disable -> 0
+ *
+ *
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_slow_offset_en_ch(
+unsigned char channel, unsigned char *slow_offset)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (channel) {
+		case SMI130_GYRO_X_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_SLOW_OFFSET_EN_X__REG, &v_data_u8r, 1);
+			*slow_offset = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_SLOW_OFFSET_EN_X);
+			break;
+		case SMI130_GYRO_Y_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_SLOW_OFFSET_EN_Y__REG, &v_data_u8r, 1);
+			*slow_offset = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_SLOW_OFFSET_EN_Y);
+			break;
+		case SMI130_GYRO_Z_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_SLOW_OFFSET_EN_Z__REG, &v_data_u8r, 1);
+			*slow_offset = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_SLOW_OFFSET_EN_Z);
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set Slow Offset Enable channel
+ * X,Y,Z
+ *
+ *
+ *
+ *
+ *\param unsigned char channel,unsigned char *slow_offset
+ *                       channel :
+ *                       SMI130_GYRO_X_AXIS -> 0
+ *                       SMI130_GYRO_Y_AXIS -> 1
+ *                       SMI130_GYRO_Z_AXIS -> 2
+ *                       slow_offset :
+ *                       Enable  -> 1
+ *                       disable -> 0
+ *
+ *
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_slow_offset_en_ch(
+unsigned char channel, unsigned char slow_offset)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (channel) {
+		case SMI130_GYRO_X_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_SLOW_OFFSET_EN_X__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_SLOW_OFFSET_EN_X, slow_offset);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_SLOW_OFFSET_EN_X__REG, &v_data_u8r, 1);
+			break;
+		case SMI130_GYRO_Y_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_SLOW_OFFSET_EN_Y__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_SLOW_OFFSET_EN_Y, slow_offset);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_SLOW_OFFSET_EN_Y__REG, &v_data_u8r, 1);
+			break;
+		case SMI130_GYRO_Z_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_SLOW_OFFSET_EN_Z__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+				SMI130_GYRO_SLOW_OFFSET_EN_Z,
+			slow_offset);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_SLOW_OFFSET_EN_Z__REG, &v_data_u8r, 1);
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get Fast Offset WordLength and
+ * Auto Offset WordLength
+ *
+ *
+ *
+ *
+ *\param unsigned char channel,unsigned char *offset_wl
+ *                       channel :
+ *                       SMI130_GYRO_AUTO_OFFSET_WL -> 0
+ *                       SMI130_GYRO_FAST_OFFSET_WL -> 1
+ *                       *offset_wl : Address of high_bw
+ *                                    Pointer to a variable passed as a
+ *                                    parameter
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_offset_wl(unsigned char channel,
+unsigned char *offset_wl)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (channel) {
+		case SMI130_GYRO_AUTO_OFFSET_WL:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_AUTO_OFFSET_WL__REG, &v_data_u8r, 1);
+			*offset_wl = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+				SMI130_GYRO_AUTO_OFFSET_WL);
+			break;
+		case SMI130_GYRO_FAST_OFFSET_WL:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_FAST_OFFSET_WL__REG, &v_data_u8r, 1);
+			*offset_wl = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+				SMI130_GYRO_FAST_OFFSET_WL);
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set Fast Offset WordLength and
+ *  Auto Offset WordLength
+ *
+ *
+ *
+ *
+ *\param unsigned char channel,unsigned char *offset_wl
+ *                       channel :
+ *                       SMI130_GYRO_AUTO_OFFSET_WL -> 0
+ *                       SMI130_GYRO_FAST_OFFSET_WL -> 1
+ *                       offset_wl : Value to be written passed as a parameter
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_offset_wl(
+unsigned char channel, unsigned char offset_wl)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (channel) {
+		case SMI130_GYRO_AUTO_OFFSET_WL:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_AUTO_OFFSET_WL__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_AUTO_OFFSET_WL, offset_wl);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_AUTO_OFFSET_WL__REG, &v_data_u8r, 1);
+			break;
+		case SMI130_GYRO_FAST_OFFSET_WL:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_FAST_OFFSET_WL__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_FAST_OFFSET_WL, offset_wl);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_FAST_OFFSET_WL__REG, &v_data_u8r, 1);
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to enable fast offset
+ *
+ *
+ *
+ *
+* \param smi130_gyro_enable_fast_offset
+ *                 Enable  -> 1
+ *                 Disable -> 0
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_enable_fast_offset()
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_FAST_OFFSET_EN__REG, &v_data_u8r, 1);
+		v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_FAST_OFFSET_EN, 1);
+		comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_FAST_OFFSET_EN__REG, &v_data_u8r, 1);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API read the Fast offset en status from the
+ * 0x32h of 0 to 2 bits.
+ *
+ *
+ *
+ *
+ *\param unsigned char *fast_offset
+ *             Pointer to a variable passed as a parameter
+ *
+ *
+ *
+ *  \return Communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_fast_offset_en_ch(
+unsigned char *fast_offset)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+			(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_FAST_OFFSET_EN_XYZ__REG, &v_data_u8r, 1);
+		*fast_offset = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_FAST_OFFSET_EN_XYZ);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API writes the Fast offset enable bit based
+ * on the Channel selection 0x32h of (0 to 2 bits)
+ *
+ *
+ *
+ *
+* \param  unsigned char channel,unsigned char fast_offset
+ *
+ *                      channel --> SMI130_GYRO_X_AXIS,SMI130_GYRO_Y_AXIS,SMI130_GYRO_Z_AXIS
+ *                      fast_offset --> 0 - Disable
+ *                                      1 - Enable
+ *
+ *
+ *
+ *  \return Communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_fast_offset_en_ch(
+unsigned char channel, unsigned char fast_offset)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres  = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (channel) {
+		case SMI130_GYRO_X_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_FAST_OFFSET_EN_X__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_FAST_OFFSET_EN_X, fast_offset);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_FAST_OFFSET_EN_X__REG, &v_data_u8r, 1);
+			break;
+		case SMI130_GYRO_Y_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_FAST_OFFSET_EN_Y__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_FAST_OFFSET_EN_Y, fast_offset);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_FAST_OFFSET_EN_Y__REG, &v_data_u8r, 1);
+			break;
+		case SMI130_GYRO_Z_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_FAST_OFFSET_EN_Z__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_FAST_OFFSET_EN_Z, fast_offset);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_FAST_OFFSET_EN_Z__REG, &v_data_u8r, 1);
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get the status of nvm program
+ * remain
+ *
+ *
+ *
+ *
+ *\param unsigned char *nvm_remain
+ *
+ *
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_nvm_remain(unsigned char *nvm_remain)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_REMAIN__REG, &v_data_u8r, 1);
+		*nvm_remain = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_REMAIN);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set the status of nvm load
+ *
+ *
+ *
+ *
+ *\param unsigned char nvm_load
+ *              1 -> load offset value from NVM
+ *              0 -> no action
+ *
+ *
+ *
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_nvm_load(unsigned char nvm_load)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_LOAD__REG, &v_data_u8r, 1);
+		v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_LOAD, nvm_load);
+		comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_LOAD__REG, &v_data_u8r, 1);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get the status of nvmprogram
+ * ready
+ *
+ *
+ *
+ *
+ *\param unsigned char *nvm_rdy
+ *             1 -> program seq finished
+ *             0 -> program seq in progress
+ *
+ *
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_nvm_rdy(unsigned char *nvm_rdy)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_RDY__REG, &v_data_u8r, 1);
+		*nvm_rdy = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_RDY);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set the status of nvm program
+ * trigger
+ *
+ *
+ *
+ *
+ *\param unsigned char trig
+ *            1 -> trig program seq (wo)
+ *            0 -> No Action
+ *
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_nvm_prog_trig(unsigned char prog_trig)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_PROG_TRIG__REG, &v_data_u8r, 1);
+		v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_PROG_TRIG, prog_trig);
+		comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_PROG_TRIG__REG, &v_data_u8r, 1);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get the status of nvm program
+ * mode
+ *
+ *
+ *
+ *
+* \param unsigned char *prog_mode : Address of *prog_mode
+ *                  1 -> Enable program mode
+ *                  0 -> Disable program mode
+ *
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_nvm_prog_mode(unsigned char *prog_mode)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_PROG_MODE__REG, &v_data_u8r, 1);
+		*prog_mode = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_PROG_MODE);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/******************************************************************************
+ * Description: *//**brief This API is used to set the status of nvmprogram
+ * mode
+ *
+ *
+ *
+ *
+* \param(unsigned char prog_mode)
+ *                   1 -> Enable program mode
+ *                   0 -> Disable program mode
+ *
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_nvm_prog_mode(unsigned char prog_mode)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_PROG_MODE__REG, &v_data_u8r, 1);
+		v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_PROG_MODE, prog_mode);
+		comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_PROG_MODE__REG, &v_data_u8r, 1);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get the status of i2c wdt
+ *
+ *
+ *
+ *
+ *\param unsigned char channel,unsigned char *prog_mode
+ *            SMI130_GYRO_I2C_WDT_SEL               1
+ *            SMI130_GYRO_I2C_WDT_EN                0
+ *            *prog_mode : Address of prog_mode
+ *                         Pointer to a variable passed as a parameter
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_i2c_wdt(unsigned char i2c_wdt,
+unsigned char *prog_mode)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (i2c_wdt) {
+		case SMI130_GYRO_I2C_WDT_EN:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_BGW_SPI3_WDT_ADDR_I2C_WDT_EN__REG,
+			&v_data_u8r, 1);
+			*prog_mode = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_BGW_SPI3_WDT_ADDR_I2C_WDT_EN);
+			break;
+		case SMI130_GYRO_I2C_WDT_SEL:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_BGW_SPI3_WDT_ADDR_I2C_WDT_SEL__REG,
+			&v_data_u8r, 1);
+			*prog_mode = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_BGW_SPI3_WDT_ADDR_I2C_WDT_SEL);
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set the status of i2c wdt
+ *
+ *
+ *
+ *
+ *\param unsigned char channel,unsigned char prog_mode
+ *            SMI130_GYRO_I2C_WDT_SEL               1
+ *            SMI130_GYRO_I2C_WDT_EN                0
+ *            prog_mode : Value to be written passed as a parameter
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_i2c_wdt(unsigned char i2c_wdt,
+unsigned char prog_mode)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (i2c_wdt) {
+		case SMI130_GYRO_I2C_WDT_EN:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_BGW_SPI3_WDT_ADDR_I2C_WDT_EN__REG,
+			&v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_BGW_SPI3_WDT_ADDR_I2C_WDT_EN, prog_mode);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_BGW_SPI3_WDT_ADDR_I2C_WDT_EN__REG,
+			&v_data_u8r, 1);
+			break;
+		case SMI130_GYRO_I2C_WDT_SEL:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_BGW_SPI3_WDT_ADDR_I2C_WDT_SEL__REG,
+			&v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_BGW_SPI3_WDT_ADDR_I2C_WDT_SEL, prog_mode);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_BGW_SPI3_WDT_ADDR_I2C_WDT_SEL__REG,
+			&v_data_u8r, 1);
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief  This API is used to get the status of spi3
+ *
+ *
+ *
+ *
+* \param unsigned char *spi3 : Address of spi3
+ *                                Pointer to a variable passed as a parameter
+ *
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_spi3(unsigned char *spi3)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_BGW_SPI3_WDT_ADDR_SPI3__REG, &v_data_u8r, 1);
+		*spi3 = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_BGW_SPI3_WDT_ADDR_SPI3);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set the status of spi3
+ *
+ *
+ *
+ *
+ *\param unsigned char spi3
+ *
+ *
+ *
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_spi3(unsigned char spi3)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_BGW_SPI3_WDT_ADDR_SPI3__REG, &v_data_u8r, 1);
+		v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_BGW_SPI3_WDT_ADDR_SPI3, spi3);
+		comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_BGW_SPI3_WDT_ADDR_SPI3__REG, &v_data_u8r, 1);
+	}
+	return comres;
+}
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_fifo_tag(unsigned char *tag)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_FIFO_CGF1_ADDR_TAG__REG, &v_data_u8r, 1);
+		*tag = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_FIFO_CGF1_ADDR_TAG);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set the status of Tag
+ *
+ *
+ *
+ *
+ *\param unsigned char tag
+ *                  Enable  -> 1
+ *                  Disable -> 0
+ *
+ *
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_fifo_tag(unsigned char tag)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		if (tag < C_SMI130_GYRO_Two_U8X) {
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_FIFO_CGF1_ADDR_TAG__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_FIFO_CGF1_ADDR_TAG, tag);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_FIFO_CGF1_ADDR_TAG__REG, &v_data_u8r, 1);
+		} else {
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get Water Mark Level
+ *
+ *
+ *
+ *
+ *\param unsigned char *water_mark_level : Address of water_mark_level
+ *                         Pointer to a variable passed as a parameter
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_fifo_watermarklevel(
+unsigned char *water_mark_level)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_FIFO_CGF1_ADDR_WML__REG, &v_data_u8r, 1);
+		*water_mark_level = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_FIFO_CGF1_ADDR_WML);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set Water Mark Level
+ *
+ *
+ *
+ *
+ *\param unsigned char water_mark_level:
+ *          Value to be written passed as a parameter
+
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_fifo_watermarklevel(
+unsigned char water_mark_level)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		if (water_mark_level < C_SMI130_GYRO_OneTwentyEight_U8X) {
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_FIFO_CGF1_ADDR_WML__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_FIFO_CGF1_ADDR_WML, water_mark_level);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_FIFO_CGF1_ADDR_WML__REG, &v_data_u8r, 1);
+		} else {
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get the status of offset
+ *
+ *
+ *
+ *
+ *\param unsigned char axis,unsigned char *offset
+ *                         axis ->
+ *                   SMI130_GYRO_X_AXIS     ->      0
+ *                   SMI130_GYRO_Y_AXIS     ->      1
+ *                   SMI130_GYRO_Z_AXIS     ->      2
+ *                   offset -> Any valid value
+ *
+ *
+ *
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_offset(unsigned char axis,
+SMI130_GYRO_S16 *offset)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data1_u8r = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data2_u8r = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (axis) {
+		case SMI130_GYRO_X_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_TRIM_GP0_ADDR_OFFSET_X__REG, &v_data1_u8r, 1);
+			v_data1_u8r = SMI130_GYRO_GET_BITSLICE(v_data1_u8r,
+			SMI130_GYRO_TRIM_GP0_ADDR_OFFSET_X);
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_OFC1_ADDR_OFFSET_X__REG, &v_data2_u8r, 1);
+			v_data2_u8r = SMI130_GYRO_GET_BITSLICE(v_data2_u8r,
+			SMI130_GYRO_OFC1_ADDR_OFFSET_X);
+			v_data2_u8r = ((v_data2_u8r <<
+			SMI130_GYRO_SHIFT_2_POSITION) | v_data1_u8r);
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+			(p_smi130_gyro->dev_addr, SMI130_GYRO_OFC2_ADDR, &v_data1_u8r, 1);
+			*offset = (SMI130_GYRO_S16)((((SMI130_GYRO_S16)
+				((signed char)v_data1_u8r))
+			<< SMI130_GYRO_SHIFT_4_POSITION) | (v_data2_u8r));
+			break;
+		case SMI130_GYRO_Y_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_TRIM_GP0_ADDR_OFFSET_Y__REG, &v_data1_u8r, 1);
+			v_data1_u8r = SMI130_GYRO_GET_BITSLICE(v_data1_u8r,
+			SMI130_GYRO_TRIM_GP0_ADDR_OFFSET_Y);
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_OFC1_ADDR_OFFSET_Y__REG, &v_data2_u8r, 1);
+			v_data2_u8r = SMI130_GYRO_GET_BITSLICE(v_data2_u8r,
+			SMI130_GYRO_OFC1_ADDR_OFFSET_Y);
+			v_data2_u8r = ((v_data2_u8r <<
+			SMI130_GYRO_SHIFT_1_POSITION) | v_data1_u8r);
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_OFC3_ADDR, &v_data1_u8r, 1);
+			*offset = (SMI130_GYRO_S16)((((SMI130_GYRO_S16)
+				((signed char)v_data1_u8r))
+			<< SMI130_GYRO_SHIFT_4_POSITION) | (v_data2_u8r));
+			break;
+		case SMI130_GYRO_Z_AXIS:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_TRIM_GP0_ADDR_OFFSET_Z__REG, &v_data1_u8r, 1);
+			v_data1_u8r = SMI130_GYRO_GET_BITSLICE(v_data1_u8r,
+			SMI130_GYRO_TRIM_GP0_ADDR_OFFSET_Z);
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_OFC1_ADDR_OFFSET_Z__REG, &v_data2_u8r, 1);
+			v_data2_u8r = SMI130_GYRO_GET_BITSLICE(v_data2_u8r,
+			SMI130_GYRO_OFC1_ADDR_OFFSET_Z);
+			v_data2_u8r = ((v_data2_u8r << SMI130_GYRO_SHIFT_1_POSITION)
+				| v_data1_u8r);
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_OFC4_ADDR, &v_data1_u8r, 1);
+			*offset = (SMI130_GYRO_S16)((((SMI130_GYRO_S16)
+				((signed char)v_data1_u8r))
+			<< SMI130_GYRO_SHIFT_4_POSITION) | (v_data2_u8r));
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set the status of offset
+ *
+ *
+ *
+ *
+ *\param unsigned char axis,unsigned char offset
+ *                         axis ->
+ *                   SMI130_GYRO_X_AXIS     ->      0
+ *                   SMI130_GYRO_Y_AXIS     ->      1
+ *                   SMI130_GYRO_Z_AXIS     ->      2
+ *                   offset -> Any valid value
+ *
+ *
+ *
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_offset(
+unsigned char axis, SMI130_GYRO_S16 offset)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data1_u8r = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data2_u8r = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (axis) {
+		case SMI130_GYRO_X_AXIS:
+			v_data1_u8r = ((signed char) (offset & 0x0FF0))
+			>> SMI130_GYRO_SHIFT_4_POSITION;
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_OFC2_ADDR, &v_data1_u8r, 1);
+
+			v_data1_u8r = (unsigned char) (offset & 0x000C);
+			v_data2_u8r = SMI130_GYRO_SET_BITSLICE(v_data2_u8r,
+			SMI130_GYRO_OFC1_ADDR_OFFSET_X, v_data1_u8r);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_OFC1_ADDR_OFFSET_X__REG, &v_data2_u8r, 1);
+
+			v_data1_u8r = (unsigned char) (offset & 0x0003);
+			v_data2_u8r = SMI130_GYRO_SET_BITSLICE(v_data2_u8r,
+			SMI130_GYRO_TRIM_GP0_ADDR_OFFSET_X, v_data1_u8r);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_TRIM_GP0_ADDR_OFFSET_X__REG, &v_data2_u8r, 1);
+			break;
+		case SMI130_GYRO_Y_AXIS:
+			v_data1_u8r = ((signed char) (offset & 0x0FF0)) >>
+			SMI130_GYRO_SHIFT_4_POSITION;
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_OFC3_ADDR, &v_data1_u8r, 1);
+
+			v_data1_u8r = (unsigned char) (offset & 0x000E);
+			v_data2_u8r = SMI130_GYRO_SET_BITSLICE(v_data2_u8r,
+			SMI130_GYRO_OFC1_ADDR_OFFSET_Y, v_data1_u8r);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_OFC1_ADDR_OFFSET_Y__REG, &v_data2_u8r, 1);
+
+			v_data1_u8r = (unsigned char) (offset & 0x0001);
+			v_data2_u8r = SMI130_GYRO_SET_BITSLICE(v_data2_u8r,
+			SMI130_GYRO_TRIM_GP0_ADDR_OFFSET_Y, v_data1_u8r);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_TRIM_GP0_ADDR_OFFSET_Y__REG, &v_data2_u8r, 1);
+			break;
+		case SMI130_GYRO_Z_AXIS:
+			v_data1_u8r = ((signed char) (offset & 0x0FF0)) >>
+			SMI130_GYRO_SHIFT_4_POSITION;
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_OFC4_ADDR, &v_data1_u8r, 1);
+
+			v_data1_u8r = (unsigned char) (offset & 0x000E);
+			v_data2_u8r = SMI130_GYRO_SET_BITSLICE(v_data2_u8r,
+			SMI130_GYRO_OFC1_ADDR_OFFSET_Z, v_data1_u8r);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_OFC1_ADDR_OFFSET_Z__REG, &v_data2_u8r, 1);
+
+			v_data1_u8r = (unsigned char) (offset & 0x0001);
+			v_data2_u8r = SMI130_GYRO_SET_BITSLICE(v_data2_u8r,
+			SMI130_GYRO_TRIM_GP0_ADDR_OFFSET_Z, v_data1_u8r);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_TRIM_GP0_ADDR_OFFSET_Z__REG, &v_data2_u8r, 1);
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get the status of general
+ * purpose register
+ *
+ *
+ *
+ *
+ *\param unsigned char param,unsigned char *value
+ *             param ->
+ *              SMI130_GYRO_GP0                      0
+ *              SMI130_GYRO_GP0                      1
+ *               *value -> Address of high_bw
+ *                         Pointer to a variable passed as a parameter
+ *
+ *
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_gp(unsigned char param,
+unsigned char *value)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (param) {
+		case SMI130_GYRO_GP0:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_TRIM_GP0_ADDR_GP0__REG, &v_data_u8r, 1);
+			*value = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+				SMI130_GYRO_TRIM_GP0_ADDR_GP0);
+			break;
+		case SMI130_GYRO_GP1:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_TRIM_GP1_ADDR, &v_data_u8r, 1);
+			*value = v_data_u8r;
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set the status of general
+ * purpose register
+ *
+ *
+ *
+ *
+ *\param unsigned char param,unsigned char value
+ *             param ->
+ *              SMI130_GYRO_GP0                      0
+ *              SMI130_GYRO_GP0                      1
+ *             value -> Value to be written passed as a parameter
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_gp(unsigned char param,
+unsigned char value)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		switch (param) {
+		case SMI130_GYRO_GP0:
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_TRIM_GP0_ADDR_GP0__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_TRIM_GP0_ADDR_GP0, value);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_TRIM_GP0_ADDR_GP0__REG, &v_data_u8r, 1);
+			break;
+		case SMI130_GYRO_GP1:
+			v_data_u8r = value;
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_TRIM_GP1_ADDR, &v_data_u8r, 1);
+			break;
+		default:
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+			break;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief Reads FIFI data from location 3Fh
+ *
+ *
+ *
+ *
+ *  \param
+ *      unsigned char *fifo_data : Address of FIFO data bits
+ *
+ *
+ *
+ *
+ *  \return result of communication routines
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_FIFO_data_reg(unsigned char *fifo_data)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_FIFO_DATA_ADDR, &v_data_u8r, 1);
+		*fifo_data = v_data_u8r;
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief Reads interrupt fifo status register byte from 0Eh
+ *
+ *
+ *
+ *
+ *  \param
+ *      unsigned char *fifo_status : Address of Fifo status register
+ *
+ *
+ *  \return
+ *      Result of bus communication function
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_fifostatus_reg(
+unsigned char *fifo_status)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_FIFO_STATUS_ADDR, fifo_status, 1);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief Reads interrupt fifo status register byte from 0Eh
+ *
+ *
+ *
+ *
+ *  \param
+ *      unsigned char *fifo_framecount: Address of FIFO status register
+ *
+ *
+ *  \return
+ *      Result of bus communication function
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_fifo_framecount(
+unsigned char *fifo_framecount)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r  = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_FIFO_STATUS_FRAME_COUNTER__REG, &v_data_u8r, 1);
+		*fifo_framecount = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_FIFO_STATUS_FRAME_COUNTER);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief Reads interrupt fifo status register byte from 0Eh
+ *
+ *
+ *
+ *
+ *  \param
+ *      unsigned char *fifo_overrun: Address of FIFO status register
+ *
+ *
+ *  \return
+ *      Result of bus communication function
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_fifo_overrun(
+unsigned char *fifo_overrun)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_FIFO_STATUS_OVERRUN__REG, &v_data_u8r, 1);
+		*fifo_overrun = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_FIFO_STATUS_OVERRUN);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get the status of fifo mode
+ *
+ *
+ *
+ *
+ *\param unsigned char *mode : Address of mode
+ *                         fifo_mode  0 --> Bypass
+ *                         1 --> FIFO
+ *                         2 --> Stream
+ *                         3 --> Reserved
+ *
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_fifo_mode(unsigned char *mode)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_FIFO_CGF0_ADDR_MODE__REG, &v_data_u8r, 1);
+		*mode = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_FIFO_CGF0_ADDR_MODE);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used set to FIFO mode
+ *
+ *
+ *
+ *
+* \param             0 --> BYPASS
+ *                      1 --> FIFO
+ *                      2 --> STREAM
+ *
+ *
+ *  \return Communication Results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_fifo_mode(unsigned char mode)
+{
+	int comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		if (mode < C_SMI130_GYRO_Four_U8X) {
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_FIFO_CGF0_ADDR_MODE__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_FIFO_CGF0_ADDR_MODE, mode);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_FIFO_CGF0_ADDR_MODE__REG, &v_data_u8r, 1);
+		} else {
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get the status of fifo data
+ * sel
+ *
+ *
+ *
+ *
+ *\param unsigned char *data_sel : Address of data_sel
+ *         data_sel --> [0:3]
+ *         0 --> X,Y and Z (DEFAULT)
+ *         1 --> X only
+ *         2 --> Y only
+ *         3 --> Z only
+ *
+ *
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_fifo_data_sel(unsigned char *data_sel)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_FIFO_CGF0_ADDR_DATA_SEL__REG, &v_data_u8r, 1);
+		*data_sel = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_FIFO_CGF0_ADDR_DATA_SEL);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set the status of fifo data
+ * sel
+ *
+ *
+ *
+ *
+ *\param unsigned char data_sel
+ *         data_sel --> [0:3]
+ *         0 --> X,Y and Z (DEFAULT)
+ *         1 --> X only
+ *         2 --> Y only
+ *         3 --> Z only
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_fifo_data_sel(unsigned char data_sel)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		if (data_sel < C_SMI130_GYRO_Four_U8X) {
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_FIFO_CGF0_ADDR_DATA_SEL__REG, &v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_FIFO_CGF0_ADDR_DATA_SEL, data_sel);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_FIFO_CGF0_ADDR_DATA_SEL__REG, &v_data_u8r, 1);
+		} else {
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to get the operating modes of the
+ * sensor
+ *
+ *
+ *
+ *
+ *\param unsigned char * mode : Address of mode
+ *                       0 -> NORMAL
+ *                       1 -> SUSPEND
+ *                       2 -> DEEP SUSPEND
+ *						 3 -> FAST POWERUP
+ *						 4 -> ADVANCED POWERSAVING
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_mode(unsigned char *mode)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char data1 = C_SMI130_GYRO_Zero_U8X;
+	unsigned char data2 = C_SMI130_GYRO_Zero_U8X;
+	unsigned char data3 = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == C_SMI130_GYRO_Zero_U8X) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_MODE_LPM1_ADDR, &data1, C_SMI130_GYRO_One_U8X);
+		comres += p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		SMI130_GYRO_MODE_LPM2_ADDR, &data2, C_SMI130_GYRO_One_U8X);
+		data1  = (data1 & 0xA0) >> 5;
+		data3  = (data2 & 0x40) >> 6;
+		data2  = (data2 & 0x80) >> 7;
+		if (data3 == 0x01) {
+			*mode  = SMI130_GYRO_MODE_ADVANCEDPOWERSAVING;
+		} else {
+			if ((data1 == 0x00) && (data2 == 0x00)) {
+				*mode  = SMI130_GYRO_MODE_NORMAL;
+				} else {
+				if ((data1 == 0x01) || (data1 == 0x05)) {
+					*mode  = SMI130_GYRO_MODE_DEEPSUSPEND;
+					} else {
+					if ((data1 == 0x04) &&
+					(data2 == 0x00)) {
+						*mode  = SMI130_GYRO_MODE_SUSPEND;
+					} else {
+					if ((data1 == 0x04) &&
+						(data2 == 0x01))
+							*mode  =
+							SMI130_GYRO_MODE_FASTPOWERUP;
+						}
+					}
+				}
+			}
+		}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set the operating Modes of the
+ * sensor
+ *
+ *
+ *
+ *
+ *\param unsigned char Mode
+ *                       0 -> NORMAL
+ *                       1 -> DEEPSUSPEND
+ *                       2 -> SUSPEND
+ *						 3 -> Fast Powerup
+ *						 4 -> Advance Powerup
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_mode(unsigned char mode)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char data1 = C_SMI130_GYRO_Zero_U8X;
+	unsigned char data2 = C_SMI130_GYRO_Zero_U8X;
+	unsigned char data3 = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_autosleepduration = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_bw_u8r = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == C_SMI130_GYRO_Zero_U8X) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		if (mode < C_SMI130_GYRO_Five_U8X) {
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_MODE_LPM1_ADDR, &data1, C_SMI130_GYRO_One_U8X);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_MODE_LPM2_ADDR, &data2, C_SMI130_GYRO_One_U8X);
+			switch (mode) {
+			case SMI130_GYRO_MODE_NORMAL:
+				data1  = SMI130_GYRO_SET_BITSLICE(data1,
+				SMI130_GYRO_MODE_LPM1, C_SMI130_GYRO_Zero_U8X);
+				data2  = SMI130_GYRO_SET_BITSLICE(data2,
+				SMI130_GYRO_MODE_LPM2_ADDR_FAST_POWERUP,
+				C_SMI130_GYRO_Zero_U8X);
+				data3  = SMI130_GYRO_SET_BITSLICE(data2,
+				SMI130_GYRO_MODE_LPM2_ADDR_ADV_POWERSAVING,
+				C_SMI130_GYRO_Zero_U8X);
+				comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_MODE_LPM1_ADDR, &data1, C_SMI130_GYRO_One_U8X);
+			p_smi130_gyro->delay_msec(1);/*A minimum delay of atleast
+			450us is required for Multiple write.*/
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_MODE_LPM2_ADDR, &data3, C_SMI130_GYRO_One_U8X);
+				break;
+			case SMI130_GYRO_MODE_DEEPSUSPEND:
+				data1  = SMI130_GYRO_SET_BITSLICE(data1,
+				SMI130_GYRO_MODE_LPM1, C_SMI130_GYRO_One_U8X);
+				data2  = SMI130_GYRO_SET_BITSLICE(data2,
+				SMI130_GYRO_MODE_LPM2_ADDR_FAST_POWERUP,
+				C_SMI130_GYRO_Zero_U8X);
+				data3  = SMI130_GYRO_SET_BITSLICE(data2,
+				SMI130_GYRO_MODE_LPM2_ADDR_ADV_POWERSAVING,
+				C_SMI130_GYRO_Zero_U8X);
+				comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_MODE_LPM1_ADDR, &data1, C_SMI130_GYRO_One_U8X);
+			p_smi130_gyro->delay_msec(1);/*A minimum delay of atleast
+			450us is required for Multiple write.*/
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_MODE_LPM2_ADDR, &data3, C_SMI130_GYRO_One_U8X);
+				break;
+			case SMI130_GYRO_MODE_SUSPEND:
+				data1  = SMI130_GYRO_SET_BITSLICE(data1,
+				SMI130_GYRO_MODE_LPM1, C_SMI130_GYRO_Four_U8X);
+				data2  = SMI130_GYRO_SET_BITSLICE(data2,
+				SMI130_GYRO_MODE_LPM2_ADDR_FAST_POWERUP,
+				C_SMI130_GYRO_Zero_U8X);
+				data3  = SMI130_GYRO_SET_BITSLICE(data2,
+				SMI130_GYRO_MODE_LPM2_ADDR_ADV_POWERSAVING,
+				C_SMI130_GYRO_Zero_U8X);
+				comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_MODE_LPM1_ADDR, &data1, C_SMI130_GYRO_One_U8X);
+			p_smi130_gyro->delay_msec(1);/*A minimum delay of atleast
+			450us is required for Multiple write.*/
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_MODE_LPM2_ADDR, &data3, C_SMI130_GYRO_One_U8X);
+				break;
+			case SMI130_GYRO_MODE_FASTPOWERUP:
+				data1  = SMI130_GYRO_SET_BITSLICE(data1,
+				SMI130_GYRO_MODE_LPM1, C_SMI130_GYRO_Four_U8X);
+				data2  = SMI130_GYRO_SET_BITSLICE(data2,
+				SMI130_GYRO_MODE_LPM2_ADDR_FAST_POWERUP,
+				C_SMI130_GYRO_One_U8X);
+				data3  = SMI130_GYRO_SET_BITSLICE(data2,
+				SMI130_GYRO_MODE_LPM2_ADDR_ADV_POWERSAVING,
+				C_SMI130_GYRO_Zero_U8X);
+				comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_MODE_LPM1_ADDR, &data1, C_SMI130_GYRO_One_U8X);
+			p_smi130_gyro->delay_msec(1);/*A minimum delay of atleast
+			450us is required for Multiple write.*/
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_MODE_LPM2_ADDR, &data3, C_SMI130_GYRO_One_U8X);
+				break;
+			case SMI130_GYRO_MODE_ADVANCEDPOWERSAVING:
+				/* Configuring the proper settings for auto
+				sleep duration */
+				smi130_gyro_get_bw(&v_bw_u8r);
+				smi130_gyro_get_autosleepdur(&v_autosleepduration);
+				smi130_gyro_set_autosleepdur(v_autosleepduration,
+				v_bw_u8r);
+				comres += p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+					(p_smi130_gyro->dev_addr,
+				SMI130_GYRO_MODE_LPM2_ADDR, &data2,
+				C_SMI130_GYRO_One_U8X);
+				/* Configuring the advanced power saving mode*/
+				data1  = SMI130_GYRO_SET_BITSLICE(data1,
+				SMI130_GYRO_MODE_LPM1, C_SMI130_GYRO_Zero_U8X);
+				data2  = SMI130_GYRO_SET_BITSLICE(data2,
+				SMI130_GYRO_MODE_LPM2_ADDR_FAST_POWERUP,
+				C_SMI130_GYRO_Zero_U8X);
+				data3  = SMI130_GYRO_SET_BITSLICE(data2,
+				SMI130_GYRO_MODE_LPM2_ADDR_ADV_POWERSAVING,
+				C_SMI130_GYRO_One_U8X);
+				comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_MODE_LPM1_ADDR, &data1, C_SMI130_GYRO_One_U8X);
+			p_smi130_gyro->delay_msec(1);/*A minimum delay of atleast
+			450us is required for Multiple write.*/
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_MODE_LPM2_ADDR, &data3, C_SMI130_GYRO_One_U8X);
+				break;
+				}
+		} else {
+		comres = E_SMI130_GYRO_OUT_OF_RANGE;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to to do selftest to sensor
+ * sensor
+ *
+ *
+ *
+ *
+ *\param unsigned char *result
+ *
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_selftest(unsigned char *result)
+	{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char data1 = C_SMI130_GYRO_Zero_U8X;
+	unsigned char data2 = C_SMI130_GYRO_Zero_U8X;
+
+	comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+	SMI130_GYRO_SELF_TEST_ADDR, &data1, C_SMI130_GYRO_One_U8X);
+	data2  = SMI130_GYRO_GET_BITSLICE(data1, SMI130_GYRO_SELF_TEST_ADDR_RATEOK);
+	data1  = SMI130_GYRO_SET_BITSLICE(data1, SMI130_GYRO_SELF_TEST_ADDR_TRIGBIST,
+	C_SMI130_GYRO_One_U8X);
+	comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC(p_smi130_gyro->dev_addr,
+	SMI130_GYRO_SELF_TEST_ADDR_TRIGBIST__REG, &data1, C_SMI130_GYRO_One_U8X);
+
+	/* Waiting time to complete the selftest process */
+	p_smi130_gyro->delay_msec(10);
+
+	/* Reading Selftest result bir bist_failure */
+	comres += p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+	SMI130_GYRO_SELF_TEST_ADDR_BISTFAIL__REG, &data1, C_SMI130_GYRO_One_U8X);
+	data1  = SMI130_GYRO_GET_BITSLICE(data1, SMI130_GYRO_SELF_TEST_ADDR_BISTFAIL);
+	if ((data1 == 0x00) && (data2 == 0x01))
+		*result = C_SMI130_GYRO_SUCCESS;
+	else
+		*result = C_SMI130_GYRO_FAILURE;
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief  This API is used to get data auto sleep duration
+ *
+ *
+ *
+ *
+ *\param unsigned char *duration : Address of auto sleep duration
+ *                         Pointer to a variable passed as a parameter
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_autosleepdur(unsigned char *duration)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		 SMI130_GYRO_MODE_LPM2_ADDR_AUTOSLEEPDUR__REG, &v_data_u8r, 1);
+		*duration = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_MODE_LPM2_ADDR_AUTOSLEEPDUR);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set duration
+ *
+ *
+ *
+ *
+ *\param unsigned char duration:
+ *          Value to be written passed as a parameter
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_autosleepdur(unsigned char duration,
+unsigned char bandwith)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_autosleepduration_u8r = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+			(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_MODE_LPM2_ADDR_AUTOSLEEPDUR__REG,
+			&v_data_u8r, 1);
+			if (duration < C_SMI130_GYRO_Eight_U8X) {
+				switch (bandwith) {
+				case C_SMI130_GYRO_No_Filter_U8X:
+					if (duration >
+					C_SMI130_GYRO_4ms_AutoSleepDur_U8X)
+						v_autosleepduration_u8r =
+						duration;
+					else
+						v_autosleepduration_u8r =
+						C_SMI130_GYRO_4ms_AutoSleepDur_U8X;
+					break;
+				case C_SMI130_GYRO_BW_230Hz_U8X:
+					if (duration >
+					C_SMI130_GYRO_4ms_AutoSleepDur_U8X)
+						v_autosleepduration_u8r =
+						duration;
+					else
+						v_autosleepduration_u8r =
+						C_SMI130_GYRO_4ms_AutoSleepDur_U8X;
+					break;
+				case C_SMI130_GYRO_BW_116Hz_U8X:
+					if (duration >
+					C_SMI130_GYRO_4ms_AutoSleepDur_U8X)
+						v_autosleepduration_u8r =
+						duration;
+					else
+						v_autosleepduration_u8r =
+						C_SMI130_GYRO_4ms_AutoSleepDur_U8X;
+					break;
+				case C_SMI130_GYRO_BW_47Hz_U8X:
+					if (duration >
+					C_SMI130_GYRO_5ms_AutoSleepDur_U8X)
+						v_autosleepduration_u8r =
+						duration;
+					else
+						v_autosleepduration_u8r =
+						C_SMI130_GYRO_5ms_AutoSleepDur_U8X;
+					break;
+				case C_SMI130_GYRO_BW_23Hz_U8X:
+					if (duration >
+					C_SMI130_GYRO_10ms_AutoSleepDur_U8X)
+						v_autosleepduration_u8r =
+						duration;
+					else
+						v_autosleepduration_u8r =
+						C_SMI130_GYRO_10ms_AutoSleepDur_U8X;
+					break;
+				case C_SMI130_GYRO_BW_12Hz_U8X:
+					if (duration >
+					C_SMI130_GYRO_20ms_AutoSleepDur_U8X)
+						v_autosleepduration_u8r =
+						duration;
+					else
+					v_autosleepduration_u8r =
+					C_SMI130_GYRO_20ms_AutoSleepDur_U8X;
+					break;
+				case C_SMI130_GYRO_BW_64Hz_U8X:
+					if (duration >
+					C_SMI130_GYRO_10ms_AutoSleepDur_U8X)
+						v_autosleepduration_u8r =
+						duration;
+					else
+						v_autosleepduration_u8r =
+						C_SMI130_GYRO_10ms_AutoSleepDur_U8X;
+					break;
+				case C_SMI130_GYRO_BW_32Hz_U8X:
+					if (duration >
+					C_SMI130_GYRO_20ms_AutoSleepDur_U8X)
+						v_autosleepduration_u8r =
+						duration;
+					else
+						v_autosleepduration_u8r =
+						C_SMI130_GYRO_20ms_AutoSleepDur_U8X;
+					break;
+				default:
+				if (duration >
+					C_SMI130_GYRO_4ms_AutoSleepDur_U8X)
+					v_autosleepduration_u8r =
+						duration;
+					else
+					v_autosleepduration_u8r =
+					C_SMI130_GYRO_4ms_AutoSleepDur_U8X;
+					break;
+				}
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_MODE_LPM2_ADDR_AUTOSLEEPDUR,
+			v_autosleepduration_u8r);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_MODE_LPM2_ADDR_AUTOSLEEPDUR__REG,
+			&v_data_u8r, 1);
+		} else {
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+		}
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief  This API is used to get data sleep duration
+ *
+ *
+ *
+ *
+ *\param unsigned char *duration : Address of sleep duration
+ *                         Pointer to a variable passed as a parameter
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_sleepdur(unsigned char *duration)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC(p_smi130_gyro->dev_addr,
+		 SMI130_GYRO_MODELPM1_ADDR_SLEEPDUR__REG, &v_data_u8r, 1);
+		*duration = SMI130_GYRO_GET_BITSLICE(v_data_u8r,
+		SMI130_GYRO_MODELPM1_ADDR_SLEEPDUR);
+	}
+	return comres;
+}
+/* Compiler Switch if applicable
+#ifdef
+
+#endif
+*/
+/*****************************************************************************
+ * Description: *//**brief This API is used to set duration
+ *
+ *
+ *
+ *
+ *\param unsigned char duration:
+ *          Value to be written passed as a parameter
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_sleepdur(unsigned char duration)
+{
+	SMI130_GYRO_RETURN_FUNCTION_TYPE comres = C_SMI130_GYRO_Zero_U8X;
+	unsigned char v_data_u8r = C_SMI130_GYRO_Zero_U8X;
+	if (p_smi130_gyro == SMI130_GYRO_NULL) {
+		return  E_SMI130_GYRO_NULL_PTR;
+	} else {
+		if (duration < C_SMI130_GYRO_Eight_U8X) {
+			comres = p_smi130_gyro->SMI130_GYRO_BUS_READ_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_MODELPM1_ADDR_SLEEPDUR__REG,
+			&v_data_u8r, 1);
+			v_data_u8r = SMI130_GYRO_SET_BITSLICE(v_data_u8r,
+			SMI130_GYRO_MODELPM1_ADDR_SLEEPDUR, duration);
+			comres += p_smi130_gyro->SMI130_GYRO_BUS_WRITE_FUNC
+				(p_smi130_gyro->dev_addr,
+			SMI130_GYRO_MODELPM1_ADDR_SLEEPDUR__REG,
+			&v_data_u8r, 1);
+		} else {
+			comres = E_SMI130_GYRO_OUT_OF_RANGE;
+		}
+	}
+	return comres;
+}
+
diff --git a/drivers/input/sensors/smi130/smi130_gyro.h b/drivers/input/sensors/smi130/smi130_gyro.h
new file mode 100644
index 0000000..38e52ac
--- /dev/null
+++ b/drivers/input/sensors/smi130/smi130_gyro.h
@@ -0,0 +1,4705 @@
+/*!
+ * @section LICENSE
+ * (C) Copyright 2011~2016 Bosch Sensortec GmbH All Rights Reserved
+ *
+ * (C) Modification Copyright 2018 Robert Bosch Kft  All Rights Reserved
+ *
+ * This software program is licensed subject to the GNU General
+ * Public License (GPL).Version 2,June 1991,
+ * available at http://www.fsf.org/copyleft/gpl.html
+ *
+ * Special: Description of the Software:
+ *
+ * This software module (hereinafter called "Software") and any
+ * information on application-sheets (hereinafter called "Information") is
+ * provided free of charge for the sole purpose to support your application
+ * work. 
+ *
+ * As such, the Software is merely an experimental software, not tested for
+ * safety in the field and only intended for inspiration for further development 
+ * and testing. Any usage in a safety-relevant field of use (like automotive,
+ * seafaring, spacefaring, industrial plants etc.) was not intended, so there are
+ * no precautions for such usage incorporated in the Software.
+ * 
+ * The Software is specifically designed for the exclusive use for Bosch
+ * Sensortec products by personnel who have special experience and training. Do
+ * not use this Software if you do not have the proper experience or training.
+ * 
+ * This Software package is provided as is and without any expressed or
+ * implied warranties, including without limitation, the implied warranties of
+ * merchantability and fitness for a particular purpose.
+ * 
+ * Bosch Sensortec and their representatives and agents deny any liability for
+ * the functional impairment of this Software in terms of fitness, performance
+ * and safety. Bosch Sensortec and their representatives and agents shall not be
+ * liable for any direct or indirect damages or injury, except as otherwise
+ * stipulated in mandatory applicable law.
+ * The Information provided is believed to be accurate and reliable. Bosch
+ * Sensortec assumes no responsibility for the consequences of use of such
+ * Information nor for any infringement of patents or other rights of third
+ * parties which may result from its use.
+ * 
+ *------------------------------------------------------------------------------
+ * The following Product Disclaimer does not apply to the BSX4-HAL-4.1NoFusion Software 
+ * which is licensed under the Apache License, Version 2.0 as stated above.  
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Product Disclaimer
+ *
+ * Common:
+ *
+ * Assessment of Products Returned from Field
+ *
+ * Returned products are considered good if they fulfill the specifications / 
+ * test data for 0-mileage and field listed in this document.
+ *
+ * Engineering Samples
+ * 
+ * Engineering samples are marked with (e) or (E). Samples may vary from the
+ * valid technical specifications of the series product contained in this
+ * data sheet. Therefore, they are not intended or fit for resale to
+ * third parties or for use in end products. Their sole purpose is internal
+ * client testing. The testing of an engineering sample may in no way replace
+ * the testing of a series product. Bosch assumes no liability for the use
+ * of engineering samples. The purchaser shall indemnify Bosch from all claims
+ * arising from the use of engineering samples.
+ *
+ * Intended use
+ *
+ * Provided that SMI130 is used within the conditions (environment, application,
+ * installation, loads) as described in this TCD and the corresponding
+ * agreed upon documents, Bosch ensures that the product complies with
+ * the agreed properties. Agreements beyond this require
+ * the written approval by Bosch. The product is considered fit for the intended
+ * use when the product successfully has passed the tests
+ * in accordance with the TCD and agreed upon documents.
+ *
+ * It is the responsibility of the customer to ensure the proper application
+ * of the product in the overall system/vehicle.
+ *
+ * Bosch does not assume any responsibility for changes to the environment
+ * of the product that deviate from the TCD and the agreed upon documents 
+ * as well as all applications not released by Bosch
+  *
+ * The resale and/or use of products are at the purchaser’s own risk and 
+ * responsibility. The examination and testing of the SMI130 
+ * is the sole responsibility of the purchaser.
+ *
+ * The purchaser shall indemnify Bosch from all third party claims 
+ * arising from any product use not covered by the parameters of 
+ * this product data sheet or not approved by Bosch and reimburse Bosch 
+ * for all costs and damages in connection with such claims.
+ *
+ * The purchaser must monitor the market for the purchased products,
+ * particularly with regard to product safety, and inform Bosch without delay
+ * of all security relevant incidents.
+ *
+ * Application Examples and Hints
+ *
+ * With respect to any application examples, advice, normal values
+ * and/or any information regarding the application of the device,
+ * Bosch hereby disclaims any and all warranties and liabilities of any kind,
+ * including without limitation warranties of
+ * non-infringement of intellectual property rights or copyrights
+ * of any third party.
+ * The information given in this document shall in no event be regarded 
+ * as a guarantee of conditions or characteristics. They are provided
+ * for illustrative purposes only and no evaluation regarding infringement
+ * of intellectual property rights or copyrights or regarding functionality,
+ * performance or error has been made.
+ *
+ * @filename smi130_gyro.h
+ * @date    2013/11/25
+ * @Modification Date 2018/08/28 18:20
+ * @id       "8fcde22"
+ * @version  1.5
+ *
+ * @brief    Header of SMI130_GYRO API
+*/
+
+/* user defined code to be added here ... */
+#ifndef __SMI130_GYRO_H__
+#define __SMI130_GYRO_H__
+
+#ifdef __KERNEL__
+#define SMI130_GYRO_U16 unsigned short       /* 16 bit achieved with short */
+#define SMI130_GYRO_S16 signed short
+#define SMI130_GYRO_S32 signed int           /* 32 bit achieved with int   */
+#else
+#include <limits.h> /*needed to test integer limits */
+
+
+/* find correct data type for signed/unsigned 16 bit variables \
+by checking max of unsigned variant */
+#if USHRT_MAX == 0xFFFF
+		/* 16 bit achieved with short */
+		#define SMI130_GYRO_U16 unsigned short
+		#define SMI130_GYRO_S16 signed short
+#elif UINT_MAX == 0xFFFF
+		/* 16 bit achieved with int */
+		#define SMI130_GYRO_U16 unsigned int
+		#define SMI130_GYRO_S16 signed int
+#else
+		#error SMI130_GYRO_U16 and SMI130_GYRO_S16 could not be
+		#error defined automatically, please do so manually
+#endif
+
+/* find correct data type for signed 32 bit variables */
+#if INT_MAX == 0x7FFFFFFF
+		/* 32 bit achieved with int */
+		#define SMI130_GYRO_S32 signed int
+#elif LONG_MAX == 0x7FFFFFFF
+		/* 32 bit achieved with long int */
+		#define SMI130_GYRO_S32 signed long int
+#else
+		#error SMI130_GYRO_S32 could not be
+		#error defined automatically, please do so manually
+#endif
+#endif
+
+/**\brief defines the calling parameter types of the SMI130_GYRO_WR_FUNCTION */
+#define SMI130_GYRO_BUS_WR_RETURN_TYPE char
+
+/**\brief links the order of parameters defined in
+SMI130_GYRO_BUS_WR_PARAM_TYPE to function calls used inside the API*/
+#define SMI130_GYRO_BUS_WR_PARAM_TYPES unsigned char, unsigned char,\
+unsigned char *, unsigned char
+
+/**\brief links the order of parameters defined in
+SMI130_GYRO_BUS_WR_PARAM_TYPE to function calls used inside the API*/
+#define SMI130_GYRO_BUS_WR_PARAM_ORDER(device_addr, register_addr,\
+register_data, wr_len)
+
+/* never change this line */
+#define SMI130_GYRO_BUS_WRITE_FUNC(device_addr, register_addr,\
+register_data, wr_len) bus_write(device_addr, register_addr,\
+register_data, wr_len)
+/**\brief defines the return parameter type of the SMI130_GYRO_RD_FUNCTION
+*/
+#define SMI130_GYRO_BUS_RD_RETURN_TYPE char
+/**\brief defines the calling parameter types of the SMI130_GYRO_RD_FUNCTION
+*/
+#define SMI130_GYRO_BUS_RD_PARAM_TYPES unsigned char, unsigned char,\
+unsigned char *, unsigned char
+/**\brief links the order of parameters defined in \
+SMI130_GYRO_BUS_RD_PARAM_TYPE to function calls used inside the API
+*/
+#define SMI130_GYRO_BUS_RD_PARAM_ORDER (device_addr, register_addr,\
+register_data)
+/* never change this line */
+#define SMI130_GYRO_BUS_READ_FUNC(device_addr, register_addr,\
+register_data, rd_len)bus_read(device_addr, register_addr,\
+register_data, rd_len)
+/**\brief defines the return parameter type of the SMI130_GYRO_RD_FUNCTION
+*/
+#define SMI130_GYRO_BURST_RD_RETURN_TYPE char
+/**\brief defines the calling parameter types of the SMI130_GYRO_RD_FUNCTION
+*/
+#define SMI130_GYRO_BURST_RD_PARAM_TYPES unsigned char,\
+unsigned char, unsigned char *, signed int
+/**\brief links the order of parameters defined in \
+SMI130_GYRO_BURST_RD_PARAM_TYPE to function calls used inside the API
+*/
+#define SMI130_GYRO_BURST_RD_PARAM_ORDER (device_addr, register_addr,\
+register_data)
+/* never change this line */
+#define SMI130_GYRO_BURST_READ_FUNC(device_addr, register_addr,\
+register_data, rd_len)burst_read(device_addr, \
+register_addr, register_data, rd_len)
+/**\brief defines the return parameter type of the SMI130_GYRO_DELAY_FUNCTION
+*/
+#define SMI130_GYRO_DELAY_RETURN_TYPE void
+/* never change this line */
+#define SMI130_GYRO_DELAY_FUNC(delay_in_msec)\
+		delay_func(delay_in_msec)
+#define SMI130_GYRO_RETURN_FUNCTION_TYPE			int
+/**< This refers SMI130_GYRO return type as char */
+
+#define	SMI130_GYRO_I2C_ADDR1				0x68
+#define	SMI130_GYRO_I2C_ADDR					SMI130_GYRO_I2C_ADDR1
+#define	SMI130_GYRO_I2C_ADDR2				0x69
+
+
+
+/*Define of registers*/
+
+/* Hard Wired */
+#define SMI130_GYRO_CHIP_ID_ADDR						0x00
+/**<Address of Chip ID Register*/
+
+
+/* Data Register */
+#define SMI130_GYRO_RATE_X_LSB_ADDR                   0x02
+/**<        Address of X axis Rate LSB Register       */
+#define SMI130_GYRO_RATE_X_MSB_ADDR                   0x03
+/**<        Address of X axis Rate MSB Register       */
+#define SMI130_GYRO_RATE_Y_LSB_ADDR                   0x04
+/**<        Address of Y axis Rate LSB Register       */
+#define SMI130_GYRO_RATE_Y_MSB_ADDR                   0x05
+/**<        Address of Y axis Rate MSB Register       */
+#define SMI130_GYRO_RATE_Z_LSB_ADDR                   0x06
+/**<        Address of Z axis Rate LSB Register       */
+#define SMI130_GYRO_RATE_Z_MSB_ADDR                   0x07
+/**<        Address of Z axis Rate MSB Register       */
+#define SMI130_GYRO_TEMP_ADDR                        0x08
+/**<        Address of Temperature Data LSB Register  */
+
+/* Status Register */
+#define SMI130_GYRO_INT_STATUS0_ADDR                 0x09
+/**<        Address of Interrupt status Register 0    */
+#define SMI130_GYRO_INT_STATUS1_ADDR                 0x0A
+/**<        Address of Interrupt status Register 1    */
+#define SMI130_GYRO_INT_STATUS2_ADDR                 0x0B
+/**<        Address of Interrupt status Register 2    */
+#define SMI130_GYRO_INT_STATUS3_ADDR                 0x0C
+/**<        Address of Interrupt status Register 3    */
+#define SMI130_GYRO_FIFO_STATUS_ADDR                 0x0E
+/**<        Address of FIFO status Register           */
+
+/* Control Register */
+#define SMI130_GYRO_RANGE_ADDR                  0x0F
+/**<        Address of Range address Register     */
+#define SMI130_GYRO_BW_ADDR                     0x10
+/**<        Address of Bandwidth Register         */
+#define SMI130_GYRO_MODE_LPM1_ADDR              0x11
+/**<        Address of Mode LPM1 Register         */
+#define SMI130_GYRO_MODE_LPM2_ADDR              0x12
+/**<        Address of Mode LPM2 Register         */
+#define SMI130_GYRO_RATED_HBW_ADDR              0x13
+/**<        Address of Rate HBW Register          */
+#define SMI130_GYRO_BGW_SOFTRESET_ADDR          0x14
+/**<        Address of BGW Softreset Register      */
+#define SMI130_GYRO_INT_ENABLE0_ADDR            0x15
+/**<        Address of Interrupt Enable 0             */
+#define SMI130_GYRO_INT_ENABLE1_ADDR            0x16
+/**<        Address of Interrupt Enable 1             */
+#define SMI130_GYRO_INT_MAP_0_ADDR              0x17
+/**<        Address of Interrupt MAP 0                */
+#define SMI130_GYRO_INT_MAP_1_ADDR              0x18
+/**<        Address of Interrupt MAP 1                */
+#define SMI130_GYRO_INT_MAP_2_ADDR              0x19
+/**<        Address of Interrupt MAP 2                */
+#define SMI130_GYRO_INT_0_ADDR                  0x1A
+/**<        Address of Interrupt 0 register   */
+#define SMI130_GYRO_INT_1_ADDR                  0x1B
+/**<        Address of Interrupt 1 register   */
+#define SMI130_GYRO_INT_2_ADDR                  0x1C
+/**<        Address of Interrupt 2 register   */
+#define SMI130_GYRO_INT_4_ADDR                  0x1E
+/**<        Address of Interrupt 4 register   */
+#define SMI130_GYRO_RST_LATCH_ADDR              0x21
+/**<        Address of Reset Latch Register           */
+#define SMI130_GYRO_HIGH_TH_X_ADDR              0x22
+/**<        Address of High Th x Address register     */
+#define SMI130_GYRO_HIGH_DUR_X_ADDR             0x23
+/**<        Address of High Dur x Address register    */
+#define SMI130_GYRO_HIGH_TH_Y_ADDR              0x24
+/**<        Address of High Th y  Address register    */
+#define SMI130_GYRO_HIGH_DUR_Y_ADDR             0x25
+/**<        Address of High Dur y Address register    */
+#define SMI130_GYRO_HIGH_TH_Z_ADDR              0x26
+/**<        Address of High Th z Address register  */
+#define SMI130_GYRO_HIGH_DUR_Z_ADDR             0x27
+/**<        Address of High Dur z Address register  */
+#define SMI130_GYRO_SOC_ADDR                        0x31
+/**<        Address of SOC register        */
+#define SMI130_GYRO_A_FOC_ADDR                      0x32
+/**<        Address of A_FOC Register        */
+#define SMI130_GYRO_TRIM_NVM_CTRL_ADDR          0x33
+/**<        Address of Trim NVM control register      */
+#define SMI130_GYRO_BGW_SPI3_WDT_ADDR           0x34
+/**<        Address of BGW SPI3,WDT Register           */
+
+
+/* Trim Register */
+#define SMI130_GYRO_OFC1_ADDR                   0x36
+/**<        Address of OFC1 Register          */
+#define SMI130_GYRO_OFC2_ADDR                       0x37
+/**<        Address of OFC2 Register          */
+#define SMI130_GYRO_OFC3_ADDR                   0x38
+/**<        Address of OFC3 Register          */
+#define SMI130_GYRO_OFC4_ADDR                   0x39
+/**<        Address of OFC4 Register          */
+#define SMI130_GYRO_TRIM_GP0_ADDR               0x3A
+/**<        Address of Trim GP0 Register              */
+#define SMI130_GYRO_TRIM_GP1_ADDR               0x3B
+/**<        Address of Trim GP1 Register              */
+#define SMI130_GYRO_SELF_TEST_ADDR              0x3C
+/**<        Address of BGW Self test Register           */
+
+/* Control Register */
+#define SMI130_GYRO_FIFO_CGF1_ADDR              0x3D
+/**<        Address of FIFO CGF0 Register             */
+#define SMI130_GYRO_FIFO_CGF0_ADDR              0x3E
+/**<        Address of FIFO CGF1 Register             */
+
+/* Data Register */
+#define SMI130_GYRO_FIFO_DATA_ADDR              0x3F
+/**<        Address of FIFO Data Register             */
+
+/* Rate X LSB Register */
+#define SMI130_GYRO_RATE_X_LSB_VALUEX__POS        0
+
+/**< Last 8 bits of RateX LSB Registers */
+#define SMI130_GYRO_RATE_X_LSB_VALUEX__LEN        8
+#define SMI130_GYRO_RATE_X_LSB_VALUEX__MSK        0xFF
+#define SMI130_GYRO_RATE_X_LSB_VALUEX__REG        SMI130_GYRO_RATE_X_LSB_ADDR
+
+/* Rate Y LSB Register */
+/**<  Last 8 bits of RateY LSB Registers */
+#define SMI130_GYRO_RATE_Y_LSB_VALUEY__POS        0
+#define SMI130_GYRO_RATE_Y_LSB_VALUEY__LEN        8
+#define SMI130_GYRO_RATE_Y_LSB_VALUEY__MSK        0xFF
+#define SMI130_GYRO_RATE_Y_LSB_VALUEY__REG        SMI130_GYRO_RATE_Y_LSB_ADDR
+
+/* Rate Z LSB Register */
+/**< Last 8 bits of RateZ LSB Registers */
+#define SMI130_GYRO_RATE_Z_LSB_VALUEZ__POS        0
+#define SMI130_GYRO_RATE_Z_LSB_VALUEZ__LEN        8
+#define SMI130_GYRO_RATE_Z_LSB_VALUEZ__MSK        0xFF
+#define SMI130_GYRO_RATE_Z_LSB_VALUEZ__REG        SMI130_GYRO_RATE_Z_LSB_ADDR
+
+/* Interrupt status 0 Register */
+   /**< 2th bit of Interrupt status 0 register */
+#define SMI130_GYRO_INT_STATUS0_ANY_INT__POS     2
+#define SMI130_GYRO_INT_STATUS0_ANY_INT__LEN     1
+#define SMI130_GYRO_INT_STATUS0_ANY_INT__MSK     0x04
+#define SMI130_GYRO_INT_STATUS0_ANY_INT__REG     SMI130_GYRO_INT_STATUS0_ADDR
+
+/**< 1st bit of Interrupt status 0 register */
+#define SMI130_GYRO_INT_STATUS0_HIGH_INT__POS    1
+#define SMI130_GYRO_INT_STATUS0_HIGH_INT__LEN    1
+#define SMI130_GYRO_INT_STATUS0_HIGH_INT__MSK    0x02
+#define SMI130_GYRO_INT_STATUS0_HIGH_INT__REG    SMI130_GYRO_INT_STATUS0_ADDR
+
+ /**< 1st and 2nd bit of Interrupt status 0 register */
+#define SMI130_GYRO_INT_STATUSZERO__POS    1
+#define SMI130_GYRO_INT_STATUSZERO__LEN    2
+#define SMI130_GYRO_INT_STATUSZERO__MSK    0x06
+#define SMI130_GYRO_INT_STATUSZERO__REG    SMI130_GYRO_INT_STATUS0_ADDR
+
+/* Interrupt status 1 Register */
+/**< 7th bit of Interrupt status 1 register */
+#define SMI130_GYRO_INT_STATUS1_DATA_INT__POS           7
+#define SMI130_GYRO_INT_STATUS1_DATA_INT__LEN           1
+#define SMI130_GYRO_INT_STATUS1_DATA_INT__MSK           0x80
+#define SMI130_GYRO_INT_STATUS1_DATA_INT__REG           SMI130_GYRO_INT_STATUS1_ADDR
+
+ /**< 6th bit of Interrupt status 1 register */
+#define SMI130_GYRO_INT_STATUS1_AUTO_OFFSET_INT__POS    6
+#define SMI130_GYRO_INT_STATUS1_AUTO_OFFSET_INT__LEN    1
+#define SMI130_GYRO_INT_STATUS1_AUTO_OFFSET_INT__MSK    0x40
+#define SMI130_GYRO_INT_STATUS1_AUTO_OFFSET_INT__REG    SMI130_GYRO_INT_STATUS1_ADDR
+
+/**< 5th bit of Interrupt status 1 register */
+#define SMI130_GYRO_INT_STATUS1_FAST_OFFSET_INT__POS    5
+#define SMI130_GYRO_INT_STATUS1_FAST_OFFSET_INT__LEN    1
+#define SMI130_GYRO_INT_STATUS1_FAST_OFFSET_INT__MSK    0x20
+#define SMI130_GYRO_INT_STATUS1_FAST_OFFSET_INT__REG    SMI130_GYRO_INT_STATUS1_ADDR
+
+/**< 4th bit of Interrupt status 1 register */
+#define SMI130_GYRO_INT_STATUS1_FIFO_INT__POS           4
+#define SMI130_GYRO_INT_STATUS1_FIFO_INT__LEN           1
+#define SMI130_GYRO_INT_STATUS1_FIFO_INT__MSK           0x10
+#define SMI130_GYRO_INT_STATUS1_FIFO_INT__REG           SMI130_GYRO_INT_STATUS1_ADDR
+
+/**< MSB 4 bits of Interrupt status1 register */
+#define SMI130_GYRO_INT_STATUSONE__POS           4
+#define SMI130_GYRO_INT_STATUSONE__LEN           4
+#define SMI130_GYRO_INT_STATUSONE__MSK           0xF0
+#define SMI130_GYRO_INT_STATUSONE__REG           SMI130_GYRO_INT_STATUS1_ADDR
+
+/* Interrupt status 2 Register */
+/**< 3th bit of Interrupt status 2 register */
+#define SMI130_GYRO_INT_STATUS2_ANY_SIGN_INT__POS     3
+#define SMI130_GYRO_INT_STATUS2_ANY_SIGN_INT__LEN     1
+#define SMI130_GYRO_INT_STATUS2_ANY_SIGN_INT__MSK     0x08
+#define SMI130_GYRO_INT_STATUS2_ANY_SIGN_INT__REG     SMI130_GYRO_INT_STATUS2_ADDR
+
+/**< 2th bit of Interrupt status 2 register */
+#define SMI130_GYRO_INT_STATUS2_ANY_FIRSTZ_INT__POS   2
+#define SMI130_GYRO_INT_STATUS2_ANY_FIRSTZ_INT__LEN   1
+#define SMI130_GYRO_INT_STATUS2_ANY_FIRSTZ_INT__MSK   0x04
+#define SMI130_GYRO_INT_STATUS2_ANY_FIRSTZ_INT__REG   SMI130_GYRO_INT_STATUS2_ADDR
+
+/**< 1st bit of Interrupt status 2 register */
+#define SMI130_GYRO_INT_STATUS2_ANY_FIRSTY_INT__POS   1
+#define SMI130_GYRO_INT_STATUS2_ANY_FIRSTY_INT__LEN   1
+#define SMI130_GYRO_INT_STATUS2_ANY_FIRSTY_INT__MSK   0x02
+#define SMI130_GYRO_INT_STATUS2_ANY_FIRSTY_INT__REG   SMI130_GYRO_INT_STATUS2_ADDR
+
+/**< 0th bit of Interrupt status 2 register */
+#define SMI130_GYRO_INT_STATUS2_ANY_FIRSTX_INT__POS   0
+#define SMI130_GYRO_INT_STATUS2_ANY_FIRSTX_INT__LEN   1
+#define SMI130_GYRO_INT_STATUS2_ANY_FIRSTX_INT__MSK   0x01
+#define SMI130_GYRO_INT_STATUS2_ANY_FIRSTX_INT__REG   SMI130_GYRO_INT_STATUS2_ADDR
+
+/**< 4 bits of Interrupt status 2 register */
+#define SMI130_GYRO_INT_STATUSTWO__POS   0
+#define SMI130_GYRO_INT_STATUSTWO__LEN   4
+#define SMI130_GYRO_INT_STATUSTWO__MSK   0x0F
+#define SMI130_GYRO_INT_STATUSTWO__REG   SMI130_GYRO_INT_STATUS2_ADDR
+
+/* Interrupt status 3 Register */
+/**< 3th bit of Interrupt status 3 register */
+#define SMI130_GYRO_INT_STATUS3_HIGH_SIGN_INT__POS     3
+#define SMI130_GYRO_INT_STATUS3_HIGH_SIGN_INT__LEN     1
+#define SMI130_GYRO_INT_STATUS3_HIGH_SIGN_INT__MSK     0x08
+#define SMI130_GYRO_INT_STATUS3_HIGH_SIGN_INT__REG     SMI130_GYRO_INT_STATUS3_ADDR
+
+/**< 2th bit of Interrupt status 3 register */
+#define SMI130_GYRO_INT_STATUS3_HIGH_FIRSTZ_INT__POS   2
+#define SMI130_GYRO_INT_STATUS3_HIGH_FIRSTZ_INT__LEN   1
+#define SMI130_GYRO_INT_STATUS3_HIGH_FIRSTZ_INT__MSK   0x04
+#define SMI130_GYRO_INT_STATUS3_HIGH_FIRSTZ_INT__REG  SMI130_GYRO_INT_STATUS3_ADDR
+
+/**< 1st bit of Interrupt status 3 register */
+#define SMI130_GYRO_INT_STATUS3_HIGH_FIRSTY_INT__POS   1
+#define SMI130_GYRO_INT_STATUS3_HIGH_FIRSTY_INT__LEN   1
+#define SMI130_GYRO_INT_STATUS3_HIGH_FIRSTY_INT__MSK   0x02
+#define SMI130_GYRO_INT_STATUS3_HIGH_FIRSTY_INT__REG   SMI130_GYRO_INT_STATUS3_ADDR
+
+/**< 0th bit of Interrupt status 3 register */
+#define SMI130_GYRO_INT_STATUS3_HIGH_FIRSTX_INT__POS   0
+#define SMI130_GYRO_INT_STATUS3_HIGH_FIRSTX_INT__LEN   1
+#define SMI130_GYRO_INT_STATUS3_HIGH_FIRSTX_INT__MSK   0x01
+#define SMI130_GYRO_INT_STATUS3_HIGH_FIRSTX_INT__REG   SMI130_GYRO_INT_STATUS3_ADDR
+
+/**< LSB 4 bits of Interrupt status 3 register */
+#define SMI130_GYRO_INT_STATUSTHREE__POS   0
+#define SMI130_GYRO_INT_STATUSTHREE__LEN   4
+#define SMI130_GYRO_INT_STATUSTHREE__MSK   0x0F
+#define SMI130_GYRO_INT_STATUSTHREE__REG   SMI130_GYRO_INT_STATUS3_ADDR
+
+/* SMI130_GYRO FIFO Status Register */
+/**< 7th bit of FIFO status Register */
+#define SMI130_GYRO_FIFO_STATUS_OVERRUN__POS         7
+#define SMI130_GYRO_FIFO_STATUS_OVERRUN__LEN         1
+#define SMI130_GYRO_FIFO_STATUS_OVERRUN__MSK         0x80
+#define SMI130_GYRO_FIFO_STATUS_OVERRUN__REG         SMI130_GYRO_FIFO_STATUS_ADDR
+
+/**< First 7 bits of FIFO status Register */
+#define SMI130_GYRO_FIFO_STATUS_FRAME_COUNTER__POS   0
+#define SMI130_GYRO_FIFO_STATUS_FRAME_COUNTER__LEN   7
+#define SMI130_GYRO_FIFO_STATUS_FRAME_COUNTER__MSK   0x7F
+#define SMI130_GYRO_FIFO_STATUS_FRAME_COUNTER__REG   SMI130_GYRO_FIFO_STATUS_ADDR
+
+/**< First 3 bits of range Registers */
+#define SMI130_GYRO_RANGE_ADDR_RANGE__POS           0
+#define SMI130_GYRO_RANGE_ADDR_RANGE__LEN           3
+#define SMI130_GYRO_RANGE_ADDR_RANGE__MSK           0x07
+#define SMI130_GYRO_RANGE_ADDR_RANGE__REG           SMI130_GYRO_RANGE_ADDR
+
+/**< Last bit of Bandwidth Registers */
+#define SMI130_GYRO_BW_ADDR_HIGH_RES__POS       7
+#define SMI130_GYRO_BW_ADDR_HIGH_RES__LEN       1
+#define SMI130_GYRO_BW_ADDR_HIGH_RES__MSK       0x80
+#define SMI130_GYRO_BW_ADDR_HIGH_RES__REG       SMI130_GYRO_BW_ADDR
+
+/**< First 3 bits of Bandwidth Registers */
+#define SMI130_GYRO_BW_ADDR__POS             0
+#define SMI130_GYRO_BW_ADDR__LEN             3
+#define SMI130_GYRO_BW_ADDR__MSK             0x07
+#define SMI130_GYRO_BW_ADDR__REG             SMI130_GYRO_BW_ADDR
+
+/**< 6th bit of Bandwidth Registers */
+#define SMI130_GYRO_BW_ADDR_IMG_STB__POS             6
+#define SMI130_GYRO_BW_ADDR_IMG_STB__LEN             1
+#define SMI130_GYRO_BW_ADDR_IMG_STB__MSK             0x40
+#define SMI130_GYRO_BW_ADDR_IMG_STB__REG             SMI130_GYRO_BW_ADDR
+
+/**< 5th and 7th bit of LPM1 Register */
+#define SMI130_GYRO_MODE_LPM1__POS             5
+#define SMI130_GYRO_MODE_LPM1__LEN             3
+#define SMI130_GYRO_MODE_LPM1__MSK             0xA0
+#define SMI130_GYRO_MODE_LPM1__REG             SMI130_GYRO_MODE_LPM1_ADDR
+
+/**< 1st to 3rd bit of LPM1 Register */
+#define SMI130_GYRO_MODELPM1_ADDR_SLEEPDUR__POS              1
+#define SMI130_GYRO_MODELPM1_ADDR_SLEEPDUR__LEN              3
+#define SMI130_GYRO_MODELPM1_ADDR_SLEEPDUR__MSK              0x0E
+#define SMI130_GYRO_MODELPM1_ADDR_SLEEPDUR__REG              SMI130_GYRO_MODE_LPM1_ADDR
+
+/**< 7th bit of Mode LPM2 Register */
+#define SMI130_GYRO_MODE_LPM2_ADDR_FAST_POWERUP__POS         7
+#define SMI130_GYRO_MODE_LPM2_ADDR_FAST_POWERUP__LEN         1
+#define SMI130_GYRO_MODE_LPM2_ADDR_FAST_POWERUP__MSK         0x80
+#define SMI130_GYRO_MODE_LPM2_ADDR_FAST_POWERUP__REG         SMI130_GYRO_MODE_LPM2_ADDR
+
+/**< 6th bit of Mode LPM2 Register */
+#define SMI130_GYRO_MODE_LPM2_ADDR_ADV_POWERSAVING__POS      6
+#define SMI130_GYRO_MODE_LPM2_ADDR_ADV_POWERSAVING__LEN      1
+#define SMI130_GYRO_MODE_LPM2_ADDR_ADV_POWERSAVING__MSK      0x40
+#define SMI130_GYRO_MODE_LPM2_ADDR_ADV_POWERSAVING__REG      SMI130_GYRO_MODE_LPM2_ADDR
+
+/**< 4th & 5th bit of Mode LPM2 Register */
+#define SMI130_GYRO_MODE_LPM2_ADDR_EXT_TRI_SEL__POS          4
+#define SMI130_GYRO_MODE_LPM2_ADDR_EXT_TRI_SEL__LEN          2
+#define SMI130_GYRO_MODE_LPM2_ADDR_EXT_TRI_SEL__MSK          0x30
+#define SMI130_GYRO_MODE_LPM2_ADDR_EXT_TRI_SEL__REG          SMI130_GYRO_MODE_LPM2_ADDR
+
+/**< 0th to 2nd bit of LPM2 Register */
+#define SMI130_GYRO_MODE_LPM2_ADDR_AUTOSLEEPDUR__POS  0
+#define SMI130_GYRO_MODE_LPM2_ADDR_AUTOSLEEPDUR__LEN  3
+#define SMI130_GYRO_MODE_LPM2_ADDR_AUTOSLEEPDUR__MSK  0x07
+#define SMI130_GYRO_MODE_LPM2_ADDR_AUTOSLEEPDUR__REG  SMI130_GYRO_MODE_LPM2_ADDR
+
+/**< 7th bit of HBW Register */
+#define SMI130_GYRO_RATED_HBW_ADDR_DATA_HIGHBW__POS         7
+#define SMI130_GYRO_RATED_HBW_ADDR_DATA_HIGHBW__LEN         1
+#define SMI130_GYRO_RATED_HBW_ADDR_DATA_HIGHBW__MSK         0x80
+#define SMI130_GYRO_RATED_HBW_ADDR_DATA_HIGHBW__REG         SMI130_GYRO_RATED_HBW_ADDR
+
+/**< 6th bit of HBW Register */
+#define SMI130_GYRO_RATED_HBW_ADDR_SHADOW_DIS__POS          6
+#define SMI130_GYRO_RATED_HBW_ADDR_SHADOW_DIS__LEN          1
+#define SMI130_GYRO_RATED_HBW_ADDR_SHADOW_DIS__MSK          0x40
+#define SMI130_GYRO_RATED_HBW_ADDR_SHADOW_DIS__REG          SMI130_GYRO_RATED_HBW_ADDR
+
+/**< 7th bit of Interrupt Enable 0 Registers */
+#define SMI130_GYRO_INT_ENABLE0_DATAEN__POS               7
+#define SMI130_GYRO_INT_ENABLE0_DATAEN__LEN               1
+#define SMI130_GYRO_INT_ENABLE0_DATAEN__MSK               0x80
+#define SMI130_GYRO_INT_ENABLE0_DATAEN__REG               SMI130_GYRO_INT_ENABLE0_ADDR
+
+/**< 6th bit of Interrupt Enable 0 Registers */
+#define SMI130_GYRO_INT_ENABLE0_FIFOEN__POS               6
+#define SMI130_GYRO_INT_ENABLE0_FIFOEN__LEN               1
+#define SMI130_GYRO_INT_ENABLE0_FIFOEN__MSK               0x40
+#define SMI130_GYRO_INT_ENABLE0_FIFOEN__REG               SMI130_GYRO_INT_ENABLE0_ADDR
+
+/**< 2nd bit of Interrupt Enable 0 Registers */
+#define SMI130_GYRO_INT_ENABLE0_AUTO_OFFSETEN__POS        2
+#define SMI130_GYRO_INT_ENABLE0_AUTO_OFFSETEN__LEN        1
+#define SMI130_GYRO_INT_ENABLE0_AUTO_OFFSETEN__MSK        0x04
+#define SMI130_GYRO_INT_ENABLE0_AUTO_OFFSETEN__REG        SMI130_GYRO_INT_ENABLE0_ADDR
+
+/**< 3rd bit of Interrupt Enable 1 Registers */
+#define SMI130_GYRO_INT_ENABLE1_IT2_OD__POS               3
+#define SMI130_GYRO_INT_ENABLE1_IT2_OD__LEN               1
+#define SMI130_GYRO_INT_ENABLE1_IT2_OD__MSK               0x08
+#define SMI130_GYRO_INT_ENABLE1_IT2_OD__REG               SMI130_GYRO_INT_ENABLE1_ADDR
+
+/**< 2nd bit of Interrupt Enable 1 Registers */
+#define SMI130_GYRO_INT_ENABLE1_IT2_LVL__POS              2
+#define SMI130_GYRO_INT_ENABLE1_IT2_LVL__LEN              1
+#define SMI130_GYRO_INT_ENABLE1_IT2_LVL__MSK              0x04
+#define SMI130_GYRO_INT_ENABLE1_IT2_LVL__REG              SMI130_GYRO_INT_ENABLE1_ADDR
+
+/**< 1st bit of Interrupt Enable 1 Registers */
+#define SMI130_GYRO_INT_ENABLE1_IT1_OD__POS               1
+#define SMI130_GYRO_INT_ENABLE1_IT1_OD__LEN               1
+#define SMI130_GYRO_INT_ENABLE1_IT1_OD__MSK               0x02
+#define SMI130_GYRO_INT_ENABLE1_IT1_OD__REG               SMI130_GYRO_INT_ENABLE1_ADDR
+
+/**< 0th bit of Interrupt Enable 1 Registers */
+#define SMI130_GYRO_INT_ENABLE1_IT1_LVL__POS              0
+#define SMI130_GYRO_INT_ENABLE1_IT1_LVL__LEN              1
+#define SMI130_GYRO_INT_ENABLE1_IT1_LVL__MSK              0x01
+#define SMI130_GYRO_INT_ENABLE1_IT1_LVL__REG              SMI130_GYRO_INT_ENABLE1_ADDR
+
+/**< 3rd bit of Interrupt MAP 0 Registers */
+#define SMI130_GYRO_INT_MAP_0_INT1_HIGH__POS            3
+#define SMI130_GYRO_INT_MAP_0_INT1_HIGH__LEN            1
+#define SMI130_GYRO_INT_MAP_0_INT1_HIGH__MSK            0x08
+#define SMI130_GYRO_INT_MAP_0_INT1_HIGH__REG            SMI130_GYRO_INT_MAP_0_ADDR
+
+/**< 1st bit of Interrupt MAP 0 Registers */
+#define SMI130_GYRO_INT_MAP_0_INT1_ANY__POS             1
+#define SMI130_GYRO_INT_MAP_0_INT1_ANY__LEN             1
+#define SMI130_GYRO_INT_MAP_0_INT1_ANY__MSK             0x02
+#define SMI130_GYRO_INT_MAP_0_INT1_ANY__REG             SMI130_GYRO_INT_MAP_0_ADDR
+
+/**< 7th bit of MAP_1Registers */
+#define SMI130_GYRO_MAP_1_INT2_DATA__POS                  7
+#define SMI130_GYRO_MAP_1_INT2_DATA__LEN                  1
+#define SMI130_GYRO_MAP_1_INT2_DATA__MSK                  0x80
+#define SMI130_GYRO_MAP_1_INT2_DATA__REG                  SMI130_GYRO_INT_MAP_1_ADDR
+
+/**< 6th bit of MAP_1Registers */
+#define SMI130_GYRO_MAP_1_INT2_FAST_OFFSET__POS           6
+#define SMI130_GYRO_MAP_1_INT2_FAST_OFFSET__LEN           1
+#define SMI130_GYRO_MAP_1_INT2_FAST_OFFSET__MSK           0x40
+#define SMI130_GYRO_MAP_1_INT2_FAST_OFFSET__REG           SMI130_GYRO_INT_MAP_1_ADDR
+
+/**< 5th bit of MAP_1Registers */
+#define SMI130_GYRO_MAP_1_INT2_FIFO__POS                  5
+#define SMI130_GYRO_MAP_1_INT2_FIFO__LEN                  1
+#define SMI130_GYRO_MAP_1_INT2_FIFO__MSK                  0x20
+#define SMI130_GYRO_MAP_1_INT2_FIFO__REG                  SMI130_GYRO_INT_MAP_1_ADDR
+
+/**< 4th bit of MAP_1Registers */
+#define SMI130_GYRO_MAP_1_INT2_AUTO_OFFSET__POS           4
+#define SMI130_GYRO_MAP_1_INT2_AUTO_OFFSET__LEN           1
+#define SMI130_GYRO_MAP_1_INT2_AUTO_OFFSET__MSK           0x10
+#define SMI130_GYRO_MAP_1_INT2_AUTO_OFFSET__REG           SMI130_GYRO_INT_MAP_1_ADDR
+
+/**< 3rd bit of MAP_1Registers */
+#define SMI130_GYRO_MAP_1_INT1_AUTO_OFFSET__POS           3
+#define SMI130_GYRO_MAP_1_INT1_AUTO_OFFSET__LEN           1
+#define SMI130_GYRO_MAP_1_INT1_AUTO_OFFSET__MSK           0x08
+#define SMI130_GYRO_MAP_1_INT1_AUTO_OFFSET__REG           SMI130_GYRO_INT_MAP_1_ADDR
+
+/**< 2nd bit of MAP_1Registers */
+#define SMI130_GYRO_MAP_1_INT1_FIFO__POS                  2
+#define SMI130_GYRO_MAP_1_INT1_FIFO__LEN                  1
+#define SMI130_GYRO_MAP_1_INT1_FIFO__MSK                  0x04
+#define SMI130_GYRO_MAP_1_INT1_FIFO__REG                  SMI130_GYRO_INT_MAP_1_ADDR
+
+/**< 1st bit of MAP_1Registers */
+#define SMI130_GYRO_MAP_1_INT1_FAST_OFFSET__POS           1
+#define SMI130_GYRO_MAP_1_INT1_FAST_OFFSET__LEN           1
+#define SMI130_GYRO_MAP_1_INT1_FAST_OFFSET__MSK           0x02
+#define SMI130_GYRO_MAP_1_INT1_FAST_OFFSET__REG           SMI130_GYRO_INT_MAP_1_ADDR
+
+/**< 0th bit of MAP_1Registers */
+#define SMI130_GYRO_MAP_1_INT1_DATA__POS                  0
+#define SMI130_GYRO_MAP_1_INT1_DATA__LEN                  1
+#define SMI130_GYRO_MAP_1_INT1_DATA__MSK                  0x01
+#define SMI130_GYRO_MAP_1_INT1_DATA__REG                  SMI130_GYRO_INT_MAP_1_ADDR
+
+/**< 3rd bit of Interrupt Map 2 Registers */
+#define SMI130_GYRO_INT_MAP_2_INT2_HIGH__POS            3
+#define SMI130_GYRO_INT_MAP_2_INT2_HIGH__LEN            1
+#define SMI130_GYRO_INT_MAP_2_INT2_HIGH__MSK            0x08
+#define SMI130_GYRO_INT_MAP_2_INT2_HIGH__REG            SMI130_GYRO_INT_MAP_2_ADDR
+
+/**< 1st bit of Interrupt Map 2 Registers */
+#define SMI130_GYRO_INT_MAP_2_INT2_ANY__POS             1
+#define SMI130_GYRO_INT_MAP_2_INT2_ANY__LEN             1
+#define SMI130_GYRO_INT_MAP_2_INT2_ANY__MSK             0x02
+#define SMI130_GYRO_INT_MAP_2_INT2_ANY__REG             SMI130_GYRO_INT_MAP_2_ADDR
+
+/**< 5th bit of Interrupt 0 Registers */
+#define SMI130_GYRO_INT_0_ADDR_SLOW_OFFSET_UNFILT__POS          5
+#define SMI130_GYRO_INT_0_ADDR_SLOW_OFFSET_UNFILT__LEN          1
+#define SMI130_GYRO_INT_0_ADDR_SLOW_OFFSET_UNFILT__MSK          0x20
+#define SMI130_GYRO_INT_0_ADDR_SLOW_OFFSET_UNFILT__REG          SMI130_GYRO_INT_0_ADDR
+
+/**< 3rd bit of Interrupt 0 Registers */
+#define SMI130_GYRO_INT_0_ADDR_HIGH_UNFILT_DATA__POS            3
+#define SMI130_GYRO_INT_0_ADDR_HIGH_UNFILT_DATA__LEN            1
+#define SMI130_GYRO_INT_0_ADDR_HIGH_UNFILT_DATA__MSK            0x08
+#define SMI130_GYRO_INT_0_ADDR_HIGH_UNFILT_DATA__REG            SMI130_GYRO_INT_0_ADDR
+
+/**< 1st bit of Interrupt 0 Registers */
+#define SMI130_GYRO_INT_0_ADDR_ANY_UNFILT_DATA__POS             1
+#define SMI130_GYRO_INT_0_ADDR_ANY_UNFILT_DATA__LEN             1
+#define SMI130_GYRO_INT_0_ADDR_ANY_UNFILT_DATA__MSK             0x02
+#define SMI130_GYRO_INT_0_ADDR_ANY_UNFILT_DATA__REG             SMI130_GYRO_INT_0_ADDR
+
+/**< 7th bit of INT_1  Registers */
+#define SMI130_GYRO_INT_1_ADDR_FAST_OFFSET_UNFILT__POS            7
+#define SMI130_GYRO_INT_1_ADDR_FAST_OFFSET_UNFILT__LEN            1
+#define SMI130_GYRO_INT_1_ADDR_FAST_OFFSET_UNFILT__MSK            0x80
+#define SMI130_GYRO_INT_1_ADDR_FAST_OFFSET_UNFILT__REG            SMI130_GYRO_INT_1_ADDR
+
+/**< First 7 bits of INT_1  Registers */
+#define SMI130_GYRO_INT_1_ADDR_ANY_TH__POS                       0
+#define SMI130_GYRO_INT_1_ADDR_ANY_TH__LEN                       7
+#define SMI130_GYRO_INT_1_ADDR_ANY_TH__MSK                       0x7F
+#define SMI130_GYRO_INT_1_ADDR_ANY_TH__REG                       SMI130_GYRO_INT_1_ADDR
+
+/**< Last 2 bits of INT 2Registers */
+#define SMI130_GYRO_INT_2_ADDR_AWAKE_DUR__POS          6
+#define SMI130_GYRO_INT_2_ADDR_AWAKE_DUR__LEN          2
+#define SMI130_GYRO_INT_2_ADDR_AWAKE_DUR__MSK          0xC0
+#define SMI130_GYRO_INT_2_ADDR_AWAKE_DUR__REG          SMI130_GYRO_INT_2_ADDR
+
+/**< 4th & 5th bit of INT 2Registers */
+#define SMI130_GYRO_INT_2_ADDR_ANY_DURSAMPLE__POS      4
+#define SMI130_GYRO_INT_2_ADDR_ANY_DURSAMPLE__LEN      2
+#define SMI130_GYRO_INT_2_ADDR_ANY_DURSAMPLE__MSK      0x30
+#define SMI130_GYRO_INT_2_ADDR_ANY_DURSAMPLE__REG      SMI130_GYRO_INT_2_ADDR
+
+/**< 2nd bit of INT 2Registers */
+#define SMI130_GYRO_INT_2_ADDR_ANY_EN_Z__POS           2
+#define SMI130_GYRO_INT_2_ADDR_ANY_EN_Z__LEN           1
+#define SMI130_GYRO_INT_2_ADDR_ANY_EN_Z__MSK           0x04
+#define SMI130_GYRO_INT_2_ADDR_ANY_EN_Z__REG           SMI130_GYRO_INT_2_ADDR
+
+/**< 1st bit of INT 2Registers */
+#define SMI130_GYRO_INT_2_ADDR_ANY_EN_Y__POS           1
+#define SMI130_GYRO_INT_2_ADDR_ANY_EN_Y__LEN           1
+#define SMI130_GYRO_INT_2_ADDR_ANY_EN_Y__MSK           0x02
+#define SMI130_GYRO_INT_2_ADDR_ANY_EN_Y__REG           SMI130_GYRO_INT_2_ADDR
+
+/**< 0th bit of INT 2Registers */
+#define SMI130_GYRO_INT_2_ADDR_ANY_EN_X__POS           0
+#define SMI130_GYRO_INT_2_ADDR_ANY_EN_X__LEN           1
+#define SMI130_GYRO_INT_2_ADDR_ANY_EN_X__MSK           0x01
+#define SMI130_GYRO_INT_2_ADDR_ANY_EN_X__REG           SMI130_GYRO_INT_2_ADDR
+
+/**< Last bit of INT 4 Registers */
+#define SMI130_GYRO_INT_4_FIFO_WM_EN__POS           7
+#define SMI130_GYRO_INT_4_FIFO_WM_EN__LEN           1
+#define SMI130_GYRO_INT_4_FIFO_WM_EN__MSK           0x80
+#define SMI130_GYRO_INT_4_FIFO_WM_EN__REG           SMI130_GYRO_INT_4_ADDR
+
+/**< Last bit of Reset Latch Registers */
+#define SMI130_GYRO_RST_LATCH_ADDR_RESET_INT__POS           7
+#define SMI130_GYRO_RST_LATCH_ADDR_RESET_INT__LEN           1
+#define SMI130_GYRO_RST_LATCH_ADDR_RESET_INT__MSK           0x80
+#define SMI130_GYRO_RST_LATCH_ADDR_RESET_INT__REG           SMI130_GYRO_RST_LATCH_ADDR
+
+/**< 6th bit of Reset Latch Registers */
+#define SMI130_GYRO_RST_LATCH_ADDR_OFFSET_RESET__POS        6
+#define SMI130_GYRO_RST_LATCH_ADDR_OFFSET_RESET__LEN        1
+#define SMI130_GYRO_RST_LATCH_ADDR_OFFSET_RESET__MSK        0x40
+#define SMI130_GYRO_RST_LATCH_ADDR_OFFSET_RESET__REG        SMI130_GYRO_RST_LATCH_ADDR
+
+/**< 4th bit of Reset Latch Registers */
+#define SMI130_GYRO_RST_LATCH_ADDR_LATCH_STATUS__POS        4
+#define SMI130_GYRO_RST_LATCH_ADDR_LATCH_STATUS__LEN        1
+#define SMI130_GYRO_RST_LATCH_ADDR_LATCH_STATUS__MSK        0x10
+#define SMI130_GYRO_RST_LATCH_ADDR_LATCH_STATUS__REG        SMI130_GYRO_RST_LATCH_ADDR
+
+/**< First 4 bits of Reset Latch Registers */
+#define SMI130_GYRO_RST_LATCH_ADDR_LATCH_INT__POS           0
+#define SMI130_GYRO_RST_LATCH_ADDR_LATCH_INT__LEN           4
+#define SMI130_GYRO_RST_LATCH_ADDR_LATCH_INT__MSK           0x0F
+#define SMI130_GYRO_RST_LATCH_ADDR_LATCH_INT__REG           SMI130_GYRO_RST_LATCH_ADDR
+
+/**< Last 2 bits of HIGH_TH_X Registers */
+#define SMI130_GYRO_HIGH_HY_X__POS        6
+#define SMI130_GYRO_HIGH_HY_X__LEN        2
+#define SMI130_GYRO_HIGH_HY_X__MSK        0xC0
+#define SMI130_GYRO_HIGH_HY_X__REG        SMI130_GYRO_HIGH_TH_X_ADDR
+
+/**< 5 bits of HIGH_TH_X Registers */
+#define SMI130_GYRO_HIGH_TH_X__POS        1
+#define SMI130_GYRO_HIGH_TH_X__LEN        5
+#define SMI130_GYRO_HIGH_TH_X__MSK        0x3E
+#define SMI130_GYRO_HIGH_TH_X__REG        SMI130_GYRO_HIGH_TH_X_ADDR
+
+/**< 0th bit of HIGH_TH_X Registers */
+#define SMI130_GYRO_HIGH_EN_X__POS        0
+#define SMI130_GYRO_HIGH_EN_X__LEN        1
+#define SMI130_GYRO_HIGH_EN_X__MSK        0x01
+#define SMI130_GYRO_HIGH_EN_X__REG        SMI130_GYRO_HIGH_TH_X_ADDR
+
+/**< Last 2 bits of HIGH_TH_Y Registers */
+#define SMI130_GYRO_HIGH_HY_Y__POS        6
+#define SMI130_GYRO_HIGH_HY_Y__LEN        2
+#define SMI130_GYRO_HIGH_HY_Y__MSK        0xC0
+#define SMI130_GYRO_HIGH_HY_Y__REG        SMI130_GYRO_HIGH_TH_Y_ADDR
+
+/**< 5 bits of HIGH_TH_Y Registers */
+#define SMI130_GYRO_HIGH_TH_Y__POS        1
+#define SMI130_GYRO_HIGH_TH_Y__LEN        5
+#define SMI130_GYRO_HIGH_TH_Y__MSK        0x3E
+#define SMI130_GYRO_HIGH_TH_Y__REG        SMI130_GYRO_HIGH_TH_Y_ADDR
+
+/**< 0th bit of HIGH_TH_Y Registers */
+#define SMI130_GYRO_HIGH_EN_Y__POS        0
+#define SMI130_GYRO_HIGH_EN_Y__LEN        1
+#define SMI130_GYRO_HIGH_EN_Y__MSK        0x01
+#define SMI130_GYRO_HIGH_EN_Y__REG        SMI130_GYRO_HIGH_TH_Y_ADDR
+
+/**< Last 2 bits of HIGH_TH_Z Registers */
+#define SMI130_GYRO_HIGH_HY_Z__POS        6
+#define SMI130_GYRO_HIGH_HY_Z__LEN        2
+#define SMI130_GYRO_HIGH_HY_Z__MSK        0xC0
+#define SMI130_GYRO_HIGH_HY_Z__REG        SMI130_GYRO_HIGH_TH_Z_ADDR
+
+/**< 5 bits of HIGH_TH_Z Registers */
+#define SMI130_GYRO_HIGH_TH_Z__POS        1
+#define SMI130_GYRO_HIGH_TH_Z__LEN        5
+#define SMI130_GYRO_HIGH_TH_Z__MSK        0x3E
+#define SMI130_GYRO_HIGH_TH_Z__REG        SMI130_GYRO_HIGH_TH_Z_ADDR
+
+/**< 0th bit of HIGH_TH_Z Registers */
+#define SMI130_GYRO_HIGH_EN_Z__POS        0
+#define SMI130_GYRO_HIGH_EN_Z__LEN        1
+#define SMI130_GYRO_HIGH_EN_Z__MSK        0x01
+#define SMI130_GYRO_HIGH_EN_Z__REG        SMI130_GYRO_HIGH_TH_Z_ADDR
+
+/**< Last 3 bits of INT OFF0 Registers */
+#define SMI130_GYRO_SLOW_OFFSET_TH__POS          6
+#define SMI130_GYRO_SLOW_OFFSET_TH__LEN          2
+#define SMI130_GYRO_SLOW_OFFSET_TH__MSK          0xC0
+#define SMI130_GYRO_SLOW_OFFSET_TH__REG          SMI130_GYRO_SOC_ADDR
+
+/**< 2  bits of INT OFF0 Registers */
+#define SMI130_GYRO_SLOW_OFFSET_DUR__POS         3
+#define SMI130_GYRO_SLOW_OFFSET_DUR__LEN         3
+#define SMI130_GYRO_SLOW_OFFSET_DUR__MSK         0x38
+#define SMI130_GYRO_SLOW_OFFSET_DUR__REG         SMI130_GYRO_SOC_ADDR
+
+/**< 2nd bit of INT OFF0 Registers */
+#define SMI130_GYRO_SLOW_OFFSET_EN_Z__POS        2
+#define SMI130_GYRO_SLOW_OFFSET_EN_Z__LEN        1
+#define SMI130_GYRO_SLOW_OFFSET_EN_Z__MSK        0x04
+#define SMI130_GYRO_SLOW_OFFSET_EN_Z__REG        SMI130_GYRO_SOC_ADDR
+
+/**< 1st bit of INT OFF0 Registers */
+#define SMI130_GYRO_SLOW_OFFSET_EN_Y__POS        1
+#define SMI130_GYRO_SLOW_OFFSET_EN_Y__LEN        1
+#define SMI130_GYRO_SLOW_OFFSET_EN_Y__MSK        0x02
+#define SMI130_GYRO_SLOW_OFFSET_EN_Y__REG        SMI130_GYRO_SOC_ADDR
+
+/**< 0th bit of INT OFF0 Registers */
+#define SMI130_GYRO_SLOW_OFFSET_EN_X__POS        0
+#define SMI130_GYRO_SLOW_OFFSET_EN_X__LEN        1
+#define SMI130_GYRO_SLOW_OFFSET_EN_X__MSK        0x01
+#define SMI130_GYRO_SLOW_OFFSET_EN_X__REG        SMI130_GYRO_SOC_ADDR
+
+/**< Last 2 bits of INT OFF1 Registers */
+#define SMI130_GYRO_AUTO_OFFSET_WL__POS        6
+#define SMI130_GYRO_AUTO_OFFSET_WL__LEN        2
+#define SMI130_GYRO_AUTO_OFFSET_WL__MSK        0xC0
+#define SMI130_GYRO_AUTO_OFFSET_WL__REG        SMI130_GYRO_A_FOC_ADDR
+
+/**< 2  bits of INT OFF1 Registers */
+#define SMI130_GYRO_FAST_OFFSET_WL__POS        4
+#define SMI130_GYRO_FAST_OFFSET_WL__LEN        2
+#define SMI130_GYRO_FAST_OFFSET_WL__MSK        0x30
+#define SMI130_GYRO_FAST_OFFSET_WL__REG        SMI130_GYRO_A_FOC_ADDR
+
+/**< 3nd bit of INT OFF1 Registers */
+#define SMI130_GYRO_FAST_OFFSET_EN__POS        3
+#define SMI130_GYRO_FAST_OFFSET_EN__LEN        1
+#define SMI130_GYRO_FAST_OFFSET_EN__MSK        0x08
+#define SMI130_GYRO_FAST_OFFSET_EN__REG        SMI130_GYRO_A_FOC_ADDR
+
+/**< 2nd bit of INT OFF1 Registers */
+#define SMI130_GYRO_FAST_OFFSET_EN_Z__POS      2
+#define SMI130_GYRO_FAST_OFFSET_EN_Z__LEN      1
+#define SMI130_GYRO_FAST_OFFSET_EN_Z__MSK      0x04
+#define SMI130_GYRO_FAST_OFFSET_EN_Z__REG      SMI130_GYRO_A_FOC_ADDR
+
+/**< 1st bit of INT OFF1 Registers */
+#define SMI130_GYRO_FAST_OFFSET_EN_Y__POS      1
+#define SMI130_GYRO_FAST_OFFSET_EN_Y__LEN      1
+#define SMI130_GYRO_FAST_OFFSET_EN_Y__MSK      0x02
+#define SMI130_GYRO_FAST_OFFSET_EN_Y__REG      SMI130_GYRO_A_FOC_ADDR
+
+/**< 0th bit of INT OFF1 Registers */
+#define SMI130_GYRO_FAST_OFFSET_EN_X__POS      0
+#define SMI130_GYRO_FAST_OFFSET_EN_X__LEN      1
+#define SMI130_GYRO_FAST_OFFSET_EN_X__MSK      0x01
+#define SMI130_GYRO_FAST_OFFSET_EN_X__REG      SMI130_GYRO_A_FOC_ADDR
+
+/**< 0 to 2 bits of INT OFF1 Registers */
+#define SMI130_GYRO_FAST_OFFSET_EN_XYZ__POS      0
+#define SMI130_GYRO_FAST_OFFSET_EN_XYZ__LEN      3
+#define SMI130_GYRO_FAST_OFFSET_EN_XYZ__MSK      0x07
+#define SMI130_GYRO_FAST_OFFSET_EN_XYZ__REG      SMI130_GYRO_A_FOC_ADDR
+
+/**< Last 4 bits of Trim NVM control Registers */
+#define SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_REMAIN__POS        4
+#define SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_REMAIN__LEN        4
+#define SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_REMAIN__MSK        0xF0
+#define SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_REMAIN__REG        \
+SMI130_GYRO_TRIM_NVM_CTRL_ADDR
+
+/**< 3rd bit of Trim NVM control Registers */
+#define SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_LOAD__POS          3
+#define SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_LOAD__LEN          1
+#define SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_LOAD__MSK          0x08
+#define SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_LOAD__REG          \
+SMI130_GYRO_TRIM_NVM_CTRL_ADDR
+
+/**< 2nd bit of Trim NVM control Registers */
+#define SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_RDY__POS           2
+#define SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_RDY__LEN           1
+#define SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_RDY__MSK           0x04
+#define SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_RDY__REG           \
+SMI130_GYRO_TRIM_NVM_CTRL_ADDR
+
+ /**< 1st bit of Trim NVM control Registers */
+#define SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_PROG_TRIG__POS     1
+#define SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_PROG_TRIG__LEN     1
+#define SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_PROG_TRIG__MSK     0x02
+#define SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_PROG_TRIG__REG     \
+SMI130_GYRO_TRIM_NVM_CTRL_ADDR
+
+/**< 0th bit of Trim NVM control Registers */
+#define SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_PROG_MODE__POS     0
+#define SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_PROG_MODE__LEN     1
+#define SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_PROG_MODE__MSK     0x01
+#define SMI130_GYRO_TRIM_NVM_CTRL_ADDR_NVM_PROG_MODE__REG     \
+SMI130_GYRO_TRIM_NVM_CTRL_ADDR
+
+ /**< 2nd bit of SPI3 WDT Registers */
+#define SMI130_GYRO_BGW_SPI3_WDT_ADDR_I2C_WDT_EN__POS      2
+#define SMI130_GYRO_BGW_SPI3_WDT_ADDR_I2C_WDT_EN__LEN      1
+#define SMI130_GYRO_BGW_SPI3_WDT_ADDR_I2C_WDT_EN__MSK      0x04
+#define SMI130_GYRO_BGW_SPI3_WDT_ADDR_I2C_WDT_EN__REG      \
+SMI130_GYRO_BGW_SPI3_WDT_ADDR
+
+ /**< 1st bit of SPI3 WDT Registers */
+#define SMI130_GYRO_BGW_SPI3_WDT_ADDR_I2C_WDT_SEL__POS     1
+#define SMI130_GYRO_BGW_SPI3_WDT_ADDR_I2C_WDT_SEL__LEN     1
+#define SMI130_GYRO_BGW_SPI3_WDT_ADDR_I2C_WDT_SEL__MSK     0x02
+#define SMI130_GYRO_BGW_SPI3_WDT_ADDR_I2C_WDT_SEL__REG     \
+SMI130_GYRO_BGW_SPI3_WDT_ADDR
+
+/**< 0th bit of SPI3 WDT Registers */
+#define SMI130_GYRO_BGW_SPI3_WDT_ADDR_SPI3__POS            0
+#define SMI130_GYRO_BGW_SPI3_WDT_ADDR_SPI3__LEN            1
+#define SMI130_GYRO_BGW_SPI3_WDT_ADDR_SPI3__MSK            0x01
+#define SMI130_GYRO_BGW_SPI3_WDT_ADDR_SPI3__REG            \
+SMI130_GYRO_BGW_SPI3_WDT_ADDR
+
+/**< 4th bit of Self test Registers */
+#define SMI130_GYRO_SELF_TEST_ADDR_RATEOK__POS            4
+#define SMI130_GYRO_SELF_TEST_ADDR_RATEOK__LEN            1
+#define SMI130_GYRO_SELF_TEST_ADDR_RATEOK__MSK            0x10
+#define SMI130_GYRO_SELF_TEST_ADDR_RATEOK__REG            \
+SMI130_GYRO_SELF_TEST_ADDR
+
+/**< 2nd bit of Self test Registers */
+#define SMI130_GYRO_SELF_TEST_ADDR_BISTFAIL__POS          2
+#define SMI130_GYRO_SELF_TEST_ADDR_BISTFAIL__LEN          1
+#define SMI130_GYRO_SELF_TEST_ADDR_BISTFAIL__MSK          0x04
+#define SMI130_GYRO_SELF_TEST_ADDR_BISTFAIL__REG          \
+SMI130_GYRO_SELF_TEST_ADDR
+
+/**< 1st bit of Self test Registers */
+#define SMI130_GYRO_SELF_TEST_ADDR_BISTRDY__POS           1
+#define SMI130_GYRO_SELF_TEST_ADDR_BISTRDY__LEN           1
+#define SMI130_GYRO_SELF_TEST_ADDR_BISTRDY__MSK           0x02
+#define SMI130_GYRO_SELF_TEST_ADDR_BISTRDY__REG           \
+SMI130_GYRO_SELF_TEST_ADDR
+
+/**< 0th bit of Self test Registers */
+#define SMI130_GYRO_SELF_TEST_ADDR_TRIGBIST__POS          0
+#define SMI130_GYRO_SELF_TEST_ADDR_TRIGBIST__LEN          1
+#define SMI130_GYRO_SELF_TEST_ADDR_TRIGBIST__MSK          0x01
+#define SMI130_GYRO_SELF_TEST_ADDR_TRIGBIST__REG          \
+SMI130_GYRO_SELF_TEST_ADDR
+
+/**< 7th bit of FIFO CGF1 Registers */
+#define SMI130_GYRO_FIFO_CGF1_ADDR_TAG__POS     7
+#define SMI130_GYRO_FIFO_CGF1_ADDR_TAG__LEN     1
+#define SMI130_GYRO_FIFO_CGF1_ADDR_TAG__MSK     0x80
+#define SMI130_GYRO_FIFO_CGF1_ADDR_TAG__REG     SMI130_GYRO_FIFO_CGF1_ADDR
+
+/**< First 7 bits of FIFO CGF1 Registers */
+#define SMI130_GYRO_FIFO_CGF1_ADDR_WML__POS     0
+#define SMI130_GYRO_FIFO_CGF1_ADDR_WML__LEN     7
+#define SMI130_GYRO_FIFO_CGF1_ADDR_WML__MSK     0x7F
+#define SMI130_GYRO_FIFO_CGF1_ADDR_WML__REG     SMI130_GYRO_FIFO_CGF1_ADDR
+
+/**< Last 2 bits of FIFO CGF0 Addr Registers */
+#define SMI130_GYRO_FIFO_CGF0_ADDR_MODE__POS         6
+#define SMI130_GYRO_FIFO_CGF0_ADDR_MODE__LEN         2
+#define SMI130_GYRO_FIFO_CGF0_ADDR_MODE__MSK         0xC0
+#define SMI130_GYRO_FIFO_CGF0_ADDR_MODE__REG         SMI130_GYRO_FIFO_CGF0_ADDR
+
+/**< First 2 bits of FIFO CGF0 Addr Registers */
+#define SMI130_GYRO_FIFO_CGF0_ADDR_DATA_SEL__POS     0
+#define SMI130_GYRO_FIFO_CGF0_ADDR_DATA_SEL__LEN     2
+#define SMI130_GYRO_FIFO_CGF0_ADDR_DATA_SEL__MSK     0x03
+#define SMI130_GYRO_FIFO_CGF0_ADDR_DATA_SEL__REG     SMI130_GYRO_FIFO_CGF0_ADDR
+
+ /**< Last 2 bits of INL Offset MSB Registers */
+#define SMI130_GYRO_OFC1_ADDR_OFFSET_X__POS       6
+#define SMI130_GYRO_OFC1_ADDR_OFFSET_X__LEN       2
+#define SMI130_GYRO_OFC1_ADDR_OFFSET_X__MSK       0xC0
+#define SMI130_GYRO_OFC1_ADDR_OFFSET_X__REG       SMI130_GYRO_OFC1_ADDR
+
+/**< 3 bits of INL Offset MSB Registers */
+#define SMI130_GYRO_OFC1_ADDR_OFFSET_Y__POS       3
+#define SMI130_GYRO_OFC1_ADDR_OFFSET_Y__LEN       3
+#define SMI130_GYRO_OFC1_ADDR_OFFSET_Y__MSK       0x38
+#define SMI130_GYRO_OFC1_ADDR_OFFSET_Y__REG       SMI130_GYRO_OFC1_ADDR
+
+/**< First 3 bits of INL Offset MSB Registers */
+#define SMI130_GYRO_OFC1_ADDR_OFFSET_Z__POS       0
+#define SMI130_GYRO_OFC1_ADDR_OFFSET_Z__LEN       3
+#define SMI130_GYRO_OFC1_ADDR_OFFSET_Z__MSK       0x07
+#define SMI130_GYRO_OFC1_ADDR_OFFSET_Z__REG       SMI130_GYRO_OFC1_ADDR
+
+/**< 4 bits of Trim GP0 Registers */
+#define SMI130_GYRO_TRIM_GP0_ADDR_GP0__POS            4
+#define SMI130_GYRO_TRIM_GP0_ADDR_GP0__LEN            4
+#define SMI130_GYRO_TRIM_GP0_ADDR_GP0__MSK            0xF0
+#define SMI130_GYRO_TRIM_GP0_ADDR_GP0__REG            SMI130_GYRO_TRIM_GP0_ADDR
+
+/**< 2 bits of Trim GP0 Registers */
+#define SMI130_GYRO_TRIM_GP0_ADDR_OFFSET_X__POS       2
+#define SMI130_GYRO_TRIM_GP0_ADDR_OFFSET_X__LEN       2
+#define SMI130_GYRO_TRIM_GP0_ADDR_OFFSET_X__MSK       0x0C
+#define SMI130_GYRO_TRIM_GP0_ADDR_OFFSET_X__REG       SMI130_GYRO_TRIM_GP0_ADDR
+
+/**< 1st bit of Trim GP0 Registers */
+#define SMI130_GYRO_TRIM_GP0_ADDR_OFFSET_Y__POS       1
+#define SMI130_GYRO_TRIM_GP0_ADDR_OFFSET_Y__LEN       1
+#define SMI130_GYRO_TRIM_GP0_ADDR_OFFSET_Y__MSK       0x02
+#define SMI130_GYRO_TRIM_GP0_ADDR_OFFSET_Y__REG       SMI130_GYRO_TRIM_GP0_ADDR
+
+/**< First bit of Trim GP0 Registers */
+#define SMI130_GYRO_TRIM_GP0_ADDR_OFFSET_Z__POS       0
+#define SMI130_GYRO_TRIM_GP0_ADDR_OFFSET_Z__LEN       1
+#define SMI130_GYRO_TRIM_GP0_ADDR_OFFSET_Z__MSK       0x01
+#define SMI130_GYRO_TRIM_GP0_ADDR_OFFSET_Z__REG       SMI130_GYRO_TRIM_GP0_ADDR
+
+/* For Axis Selection   */
+/**< It refers SMI130_GYRO X-axis */
+#define SMI130_GYRO_X_AXIS           0
+/**< It refers SMI130_GYRO Y-axis */
+#define SMI130_GYRO_Y_AXIS           1
+/**< It refers SMI130_GYRO Z-axis */
+#define SMI130_GYRO_Z_AXIS           2
+
+/* For Mode Settings    */
+#define SMI130_GYRO_MODE_NORMAL              0
+#define SMI130_GYRO_MODE_DEEPSUSPEND         1
+#define SMI130_GYRO_MODE_SUSPEND             2
+#define SMI130_GYRO_MODE_FASTPOWERUP			3
+#define SMI130_GYRO_MODE_ADVANCEDPOWERSAVING 4
+
+/* get bit slice  */
+#define SMI130_GYRO_GET_BITSLICE(regvar, bitname)\
+((regvar & bitname##__MSK) >> bitname##__POS)
+
+/* Set bit slice */
+#define SMI130_GYRO_SET_BITSLICE(regvar, bitname, val)\
+((regvar&~bitname##__MSK)|((val<<bitname##__POS)&bitname##__MSK))
+/* Constants */
+
+#define SMI130_GYRO_NULL                             0
+/**< constant declaration of NULL */
+#define SMI130_GYRO_DISABLE                          0
+/**< It refers SMI130_GYRO disable */
+#define SMI130_GYRO_ENABLE                           1
+/**< It refers SMI130_GYRO enable */
+#define SMI130_GYRO_OFF                              0
+/**< It refers SMI130_GYRO OFF state */
+#define SMI130_GYRO_ON                               1
+/**< It refers SMI130_GYRO ON state  */
+
+
+#define SMI130_GYRO_TURN1                            0
+/**< It refers SMI130_GYRO TURN1 */
+#define SMI130_GYRO_TURN2                            1
+/**< It refers SMI130_GYRO TURN2 */
+
+#define SMI130_GYRO_INT1                             0
+/**< It refers SMI130_GYRO INT1 */
+#define SMI130_GYRO_INT2                             1
+/**< It refers SMI130_GYRO INT2 */
+
+#define SMI130_GYRO_SLOW_OFFSET                      0
+/**< It refers SMI130_GYRO Slow Offset */
+#define SMI130_GYRO_AUTO_OFFSET                      1
+/**< It refers SMI130_GYRO Auto Offset */
+#define SMI130_GYRO_FAST_OFFSET                      2
+/**< It refers SMI130_GYRO Fast Offset */
+#define SMI130_GYRO_S_TAP                            0
+/**< It refers SMI130_GYRO Single Tap */
+#define SMI130_GYRO_D_TAP                            1
+/**< It refers SMI130_GYRO Double Tap */
+#define SMI130_GYRO_INT1_DATA                        0
+/**< It refers SMI130_GYRO Int1 Data */
+#define SMI130_GYRO_INT2_DATA                        1
+/**< It refers SMI130_GYRO Int2 Data */
+#define SMI130_GYRO_TAP_UNFILT_DATA                   0
+/**< It refers SMI130_GYRO Tap unfilt data */
+#define SMI130_GYRO_HIGH_UNFILT_DATA                  1
+/**< It refers SMI130_GYRO High unfilt data */
+#define SMI130_GYRO_CONST_UNFILT_DATA                 2
+/**< It refers SMI130_GYRO Const unfilt data */
+#define SMI130_GYRO_ANY_UNFILT_DATA                   3
+/**< It refers SMI130_GYRO Any unfilt data */
+#define SMI130_GYRO_SHAKE_UNFILT_DATA                 4
+/**< It refers SMI130_GYRO Shake unfilt data */
+#define SMI130_GYRO_SHAKE_TH                         0
+/**< It refers SMI130_GYRO Shake Threshold */
+#define SMI130_GYRO_SHAKE_TH2                        1
+/**< It refers SMI130_GYRO Shake Threshold2 */
+#define SMI130_GYRO_AUTO_OFFSET_WL                   0
+/**< It refers SMI130_GYRO Auto Offset word length */
+#define SMI130_GYRO_FAST_OFFSET_WL                   1
+/**< It refers SMI130_GYRO Fast Offset word length */
+#define SMI130_GYRO_I2C_WDT_EN                       0
+/**< It refers SMI130_GYRO I2C WDT En */
+#define SMI130_GYRO_I2C_WDT_SEL                      1
+/**< It refers SMI130_GYRO I2C WDT Sel */
+#define SMI130_GYRO_EXT_MODE                         0
+/**< It refers SMI130_GYRO Ext Mode */
+#define SMI130_GYRO_EXT_PAGE                         1
+/**< It refers SMI130_GYRO Ext page */
+#define SMI130_GYRO_START_ADDR                       0
+/**< It refers SMI130_GYRO Start Address */
+#define SMI130_GYRO_STOP_ADDR                        1
+/**< It refers SMI130_GYRO Stop Address */
+#define SMI130_GYRO_SLOW_CMD                         0
+/**< It refers SMI130_GYRO Slow Command */
+#define SMI130_GYRO_FAST_CMD                         1
+/**< It refers SMI130_GYRO Fast Command */
+#define SMI130_GYRO_TRIM_VRA                         0
+/**< It refers SMI130_GYRO Trim VRA */
+#define SMI130_GYRO_TRIM_VRD                         1
+/**< It refers SMI130_GYRO Trim VRD */
+#define SMI130_GYRO_LOGBIT_EM                        0
+/**< It refers SMI130_GYRO LogBit Em */
+#define SMI130_GYRO_LOGBIT_VM                        1
+/**< It refers SMI130_GYRO LogBit VM */
+#define SMI130_GYRO_GP0                              0
+/**< It refers SMI130_GYRO GP0 */
+#define SMI130_GYRO_GP1                              1
+/**< It refers SMI130_GYRO GP1*/
+#define SMI130_GYRO_LOW_SPEED                        0
+/**< It refers SMI130_GYRO Low Speed Oscillator */
+#define SMI130_GYRO_HIGH_SPEED                       1
+/**< It refers SMI130_GYRO High Speed Oscillator */
+#define SMI130_GYRO_DRIVE_OFFSET_P                   0
+/**< It refers SMI130_GYRO Drive Offset P */
+#define SMI130_GYRO_DRIVE_OFFSET_N                   1
+/**< It refers SMI130_GYRO Drive Offset N */
+#define SMI130_GYRO_TEST_MODE_EN                     0
+/**< It refers SMI130_GYRO Test Mode Enable */
+#define SMI130_GYRO_TEST_MODE_REG                    1
+/**< It refers SMI130_GYRO Test Mode reg */
+#define SMI130_GYRO_IBIAS_DRIVE_TRIM                 0
+/**< It refers SMI130_GYRO IBIAS Drive Trim */
+#define SMI130_GYRO_IBIAS_RATE_TRIM                  1
+/**< It refers SMI130_GYRO IBIAS Rate Trim */
+#define SMI130_GYRO_BAA_MODE                         0
+/**< It refers SMI130_GYRO BAA Mode Trim */
+#define SMI130_GYRO_SMI_ACC_MODE                         1
+/**< It refers SMI130_GYRO SMI_ACC Mode Trim */
+#define SMI130_GYRO_PI_KP                            0
+/**< It refers SMI130_GYRO PI KP */
+#define SMI130_GYRO_PI_KI                            1
+/**< It refers SMI130_GYRO PI KI */
+
+
+#define C_SMI130_GYRO_SUCCESS						0
+/**< It refers SMI130_GYRO operation is success */
+#define C_SMI130_GYRO_FAILURE						1
+/**< It refers SMI130_GYRO operation is Failure */
+
+#define SMI130_GYRO_SPI_RD_MASK                      0x80
+/**< Read mask **/
+#define SMI130_GYRO_READ_SET                         0x01
+/**< Setting for rading data **/
+
+#define SMI130_GYRO_SHIFT_1_POSITION                 1
+/**< Shift bit by 1 Position **/
+#define SMI130_GYRO_SHIFT_2_POSITION                 2
+/**< Shift bit by 2 Position **/
+#define SMI130_GYRO_SHIFT_3_POSITION                 3
+/**< Shift bit by 3 Position **/
+#define SMI130_GYRO_SHIFT_4_POSITION                 4
+/**< Shift bit by 4 Position **/
+#define SMI130_GYRO_SHIFT_5_POSITION                 5
+/**< Shift bit by 5 Position **/
+#define SMI130_GYRO_SHIFT_6_POSITION                 6
+/**< Shift bit by 6 Position **/
+#define SMI130_GYRO_SHIFT_7_POSITION                 7
+/**< Shift bit by 7 Position **/
+#define SMI130_GYRO_SHIFT_8_POSITION                 8
+/**< Shift bit by 8 Position **/
+#define SMI130_GYRO_SHIFT_12_POSITION                12
+/**< Shift bit by 12 Position **/
+
+#define         C_SMI130_GYRO_Null_U8X                              0
+#define         C_SMI130_GYRO_Zero_U8X                              0
+#define         C_SMI130_GYRO_One_U8X                               1
+#define         C_SMI130_GYRO_Two_U8X                               2
+#define         C_SMI130_GYRO_Three_U8X                             3
+#define         C_SMI130_GYRO_Four_U8X                              4
+#define         C_SMI130_GYRO_Five_U8X                              5
+#define         C_SMI130_GYRO_Six_U8X                               6
+#define         C_SMI130_GYRO_Seven_U8X                             7
+#define         C_SMI130_GYRO_Eight_U8X                             8
+#define         C_SMI130_GYRO_Nine_U8X                              9
+#define         C_SMI130_GYRO_Ten_U8X                               10
+#define         C_SMI130_GYRO_Eleven_U8X                            11
+#define         C_SMI130_GYRO_Twelve_U8X                            12
+#define         C_SMI130_GYRO_Thirteen_U8X                          13
+#define         C_SMI130_GYRO_Fifteen_U8X                           15
+#define         C_SMI130_GYRO_Sixteen_U8X                           16
+#define         C_SMI130_GYRO_TwentyTwo_U8X                         22
+#define         C_SMI130_GYRO_TwentyThree_U8X                       23
+#define         C_SMI130_GYRO_TwentyFour_U8X                        24
+#define         C_SMI130_GYRO_TwentyFive_U8X                        25
+#define         C_SMI130_GYRO_ThirtyTwo_U8X                         32
+#define         C_SMI130_GYRO_Hundred_U8X                           100
+#define         C_SMI130_GYRO_OneTwentySeven_U8X                    127
+#define         C_SMI130_GYRO_OneTwentyEight_U8X                    128
+#define         C_SMI130_GYRO_TwoFiftyFive_U8X                      255
+#define         C_SMI130_GYRO_TwoFiftySix_U16X                      256
+
+#define         E_SMI130_GYRO_NULL_PTR               (signed char)(-127)
+#define         E_SMI130_GYRO_COMM_RES               (signed char)(-1)
+#define         E_SMI130_GYRO_OUT_OF_RANGE           (signed char)(-2)
+
+#define	C_SMI130_GYRO_No_Filter_U8X			0
+#define	C_SMI130_GYRO_BW_230Hz_U8X			1
+#define	C_SMI130_GYRO_BW_116Hz_U8X			2
+#define	C_SMI130_GYRO_BW_47Hz_U8X			3
+#define	C_SMI130_GYRO_BW_23Hz_U8X			4
+#define	C_SMI130_GYRO_BW_12Hz_U8X			5
+#define	C_SMI130_GYRO_BW_64Hz_U8X			6
+#define	C_SMI130_GYRO_BW_32Hz_U8X			7
+
+#define C_SMI130_GYRO_No_AutoSleepDur_U8X	0
+#define	C_SMI130_GYRO_4ms_AutoSleepDur_U8X	1
+#define	C_SMI130_GYRO_5ms_AutoSleepDur_U8X	2
+#define	C_SMI130_GYRO_8ms_AutoSleepDur_U8X	3
+#define	C_SMI130_GYRO_10ms_AutoSleepDur_U8X	4
+#define	C_SMI130_GYRO_15ms_AutoSleepDur_U8X	5
+#define	C_SMI130_GYRO_20ms_AutoSleepDur_U8X	6
+#define	C_SMI130_GYRO_40ms_AutoSleepDur_U8X	7
+
+
+
+
+#define SMI130_GYRO_WR_FUNC_PTR int (*bus_write)\
+(unsigned char, unsigned char, unsigned char *, unsigned char)
+#define SMI130_GYRO_RD_FUNC_PTR int (*bus_read)\
+(unsigned char, unsigned char, unsigned char *, unsigned char)
+#define SMI130_GYRO_BRD_FUNC_PTR int (*burst_read)\
+(unsigned char, unsigned char, unsigned char *, SMI130_GYRO_S32)
+#define SMI130_GYRO_MDELAY_DATA_TYPE SMI130_GYRO_U16
+
+
+
+
+/*user defined Structures*/
+struct smi130_gyro_data_t {
+		SMI130_GYRO_S16 datax;
+		SMI130_GYRO_S16 datay;
+		SMI130_GYRO_S16 dataz;
+		char intstatus[5];
+};
+
+
+struct smi130_gyro_offset_t {
+		SMI130_GYRO_U16 datax;
+		SMI130_GYRO_U16 datay;
+		SMI130_GYRO_U16 dataz;
+};
+
+
+struct smi130_gyro_t {
+		unsigned char chip_id;
+		unsigned char dev_addr;
+		SMI130_GYRO_BRD_FUNC_PTR;
+		SMI130_GYRO_WR_FUNC_PTR;
+		SMI130_GYRO_RD_FUNC_PTR;
+		void(*delay_msec)(SMI130_GYRO_MDELAY_DATA_TYPE);
+};
+
+/***************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ***************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ***************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_init(struct smi130_gyro_t *p_smi130_gyro);
+/***************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ***************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_dataX(SMI130_GYRO_S16 *data_x);
+/****************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ***************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_dataY(SMI130_GYRO_S16 *data_y);
+/***************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ***************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_dataZ(SMI130_GYRO_S16 *data_z);
+/************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ***************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_dataXYZ(struct smi130_gyro_data_t *data);
+/***************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ********************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_dataXYZI(struct smi130_gyro_data_t *data);
+/********************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ********************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_Temperature(unsigned char *temperature);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_FIFO_data_reg
+(unsigned char *fifo_data);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_read_register(unsigned char addr,
+unsigned char *data, unsigned char len);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_burst_read(unsigned char addr,
+unsigned char *data, SMI130_GYRO_S32 len);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_write_register(unsigned char addr,
+unsigned char *data, unsigned char len);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_interrupt_status_reg_0
+(unsigned char *status0_data);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_interrupt_status_reg_1
+(unsigned char *status1_data);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_interrupt_status_reg_2
+(unsigned char *status2_data);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_interrupt_status_reg_3
+(unsigned char *status3_data);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_fifostatus_reg
+(unsigned char *fifo_status);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_range_reg
+(unsigned char *range);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_range_reg
+(unsigned char range);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_high_res
+(unsigned char *high_res);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_high_res
+(unsigned char high_res);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_bw(unsigned char *bandwidth);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_bw(unsigned char bandwidth);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_pmu_ext_tri_sel
+(unsigned char *pwu_ext_tri_sel);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_pmu_ext_tri_sel
+(unsigned char pwu_ext_tri_sel);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_high_bw
+(unsigned char *high_bw);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_high_bw
+(unsigned char high_bw);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_shadow_dis
+(unsigned char *shadow_dis);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_shadow_dis
+(unsigned char shadow_dis);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_soft_reset(void);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_data_enable(unsigned char *data_en);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_data_en(unsigned char data_en);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_fifo_enable(unsigned char *fifo_en);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_fifo_enable(unsigned char fifo_en);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_offset_enable
+(unsigned char mode, unsigned char *offset_en);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_offset_enable
+(unsigned char mode, unsigned char offset_en);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_int_od
+(unsigned char param, unsigned char *int_od);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_int_od
+(unsigned char param, unsigned char int_od);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_int_lvl
+(unsigned char param, unsigned char *int_lvl);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_int_lvl
+(unsigned char param, unsigned char int_lvl);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_int1_high
+(unsigned char *int1_high);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_int1_high
+(unsigned char int1_high);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_int1_any
+(unsigned char *int1_any);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_int1_any
+(unsigned char int1_any);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_int_data
+(unsigned char axis, unsigned char *int_data);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_int_data
+(unsigned char axis, unsigned char int_data);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_int2_offset
+(unsigned char axis, unsigned char *int2_offset);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_int2_offset
+(unsigned char axis, unsigned char int2_offset);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_int1_offset
+(unsigned char axis, unsigned char *int1_offset);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_int1_offset
+(unsigned char axis, unsigned char int1_offset);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_int_fifo(unsigned char *int_fifo);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_int_fifo
+(unsigned char axis, unsigned char int_fifo);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_int2_high
+(unsigned char *int2_high);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_int2_high
+(unsigned char int2_high);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_int2_any
+(unsigned char *int2_any);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_int2_any
+(unsigned char int2_any);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_offset_unfilt
+(unsigned char param, unsigned char *offset_unfilt);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_offset_unfilt
+(unsigned char param, unsigned char offset_unfilt);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_unfilt_data
+(unsigned char param, unsigned char *unfilt_data);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_unfilt_data
+(unsigned char param, unsigned char unfilt_data);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_any_th
+(unsigned char *any_th);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_any_th
+(unsigned char any_th);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_awake_dur
+(unsigned char *awake_dur);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_awake_dur
+(unsigned char awake_dur);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_any_dursample
+(unsigned char *dursample);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_any_dursample
+(unsigned char dursample);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_any_en_ch
+(unsigned char channel, unsigned char *data);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_any_en_ch
+(unsigned char channel, unsigned char data);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_fifo_watermark_enable
+(unsigned char *fifo_wn_en);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_fifo_watermark_enable
+(unsigned char fifo_wn_en);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_reset_int
+(unsigned char reset_int);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_offset_reset
+(unsigned char offset_reset);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_latch_status
+(unsigned char *latch_status);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_latch_status
+(unsigned char latch_status);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_latch_int
+(unsigned char *latch_int);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_latch_int
+(unsigned char latch_int);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_high_hy
+(unsigned char channel, unsigned char *high_hy);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_high_hy
+(unsigned char channel, unsigned char high_hy);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_high_th
+(unsigned char channel, unsigned char *high_th);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_high_th
+(unsigned char channel, unsigned char high_th);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_high_en_ch
+(unsigned char channel, unsigned char *high_en);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_high_en_ch
+(unsigned char channel, unsigned char high_en);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_high_dur_ch
+(unsigned char channel, unsigned char *high_dur);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_high_dur_ch
+(unsigned char channel, unsigned char high_dur);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_slow_offset_th
+(unsigned char *offset_th);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_slow_offset_th
+(unsigned char offset_th);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_slow_offset_dur
+(unsigned char *offset_dur);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_slow_offset_dur
+(unsigned char offset_dur);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_slow_offset_en_ch
+(unsigned char channel, unsigned char *slow_offset);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_slow_offset_en_ch
+(unsigned char channel, unsigned char slow_offset);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_offset_wl
+(unsigned char channel, unsigned char *offset_wl);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_offset_wl
+(unsigned char channel, unsigned char offset_wl);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_fast_offset_en
+(unsigned char fast_offset);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_fast_offset_en_ch
+(unsigned char *fast_offset);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_fast_offset_en_ch
+(unsigned char channel, unsigned char fast_offset);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_enable_fast_offset(void);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_nvm_remain
+(unsigned char *nvm_remain);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_nvm_load
+(unsigned char nvm_load);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_nvm_rdy
+(unsigned char *nvm_rdy);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_nvm_prog_trig
+(unsigned char prog_trig);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_nvm_prog_mode
+(unsigned char *prog_mode);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_nvm_prog_mode
+(unsigned char prog_mode);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_i2c_wdt
+(unsigned char i2c_wdt, unsigned char *prog_mode);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_i2c_wdt
+(unsigned char i2c_wdt, unsigned char prog_mode);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_spi3(unsigned char *spi3);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_spi3(unsigned char spi3);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_fifo_tag(unsigned char *tag);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_fifo_tag(unsigned char tag);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_fifo_watermarklevel
+(unsigned char *water_mark_level);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_fifo_watermarklevel
+(unsigned char water_mark_level);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_fifo_mode
+(unsigned char *mode);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_fifo_mode(unsigned char mode);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_fifo_data_sel
+(unsigned char *data_sel);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_fifo_data_sel
+(unsigned char data_sel);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_offset
+(unsigned char axis, SMI130_GYRO_S16 *offset);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_offset
+(unsigned char axis, SMI130_GYRO_S16 offset);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_gp
+(unsigned char param, unsigned char *value);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_gp
+(unsigned char param, unsigned char value);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_fifo_framecount
+(unsigned char *fifo_framecount);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_fifo_overrun
+(unsigned char *fifo_overrun);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_int2_fifo
+(unsigned char *int_fifo);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_int1_fifo
+(unsigned char *int_fifo);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_int2_fifo
+(unsigned char fifo_int2);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_int1_fifo
+(unsigned char fifo_int1);
+/****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_mode(unsigned char *mode);
+/*****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_mode(unsigned char mode);
+/*****************************************************************************
+ * Description: *//**\brief
+ *
+ *
+ *
+ *
+ *  \param
+ *
+ *
+ *  \return
+ *
+ *
+ ****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ ****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_selftest(unsigned char *result);
+/*****************************************************************************
+ * Description: *//**\brief  This API is used to get data auto sleep duration
+ *
+ *
+ *
+ *
+ *  \param unsigned char *duration : Address of auto sleep duration
+ *                         Pointer to a variable passed as a parameter
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_autosleepdur(unsigned char *duration);
+/*****************************************************************************
+ * Description: *//**\brief This API is used to set duration
+ *
+ *
+ *
+ *
+ *  \param unsigned char duration:
+ *          Value to be written passed as a parameter
+ *		   unsigned char bandwidth:
+ *			Value to be written passed as a parameter
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_autosleepdur(unsigned char duration,
+unsigned char bandwith);
+/*****************************************************************************
+ * Description: *//**\brief  This API is used to get data sleep duration
+ *
+ *
+ *
+ *
+ *  \param unsigned char *duration : Address of sleep duration
+ *                         Pointer to a variable passed as a parameter
+ *
+ *
+ *
+ *  \return
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_sleepdur(unsigned char *duration);
+/*****************************************************************************
+ * Description: *//**\brief This API is used to set duration
+ *
+ *
+ *
+ *
+ *  \param unsigned char duration:
+ *          Value to be written passed as a parameter
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_sleepdur(unsigned char duration);
+/*****************************************************************************
+ * Description: *//**\brief This API is used to set auto offset
+ *
+ *
+ *
+ *
+ *  \param unsigned char duration:
+ *          Value to be written passed as a parameter
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_set_auto_offset_en(unsigned char offset_en);
+/*****************************************************************************
+ * Description: *//**\brief This API is used to get auto offset
+ *
+ *
+ *
+ *
+ *  \param unsigned char duration:
+ *          Value to be written passed as a parameter
+ *
+ *
+ *
+ *  \return communication results
+ *
+ *
+ *****************************************************************************/
+/* Scheduling:
+ *
+ *
+ *
+ * Usage guide:
+ *
+ *
+ * Remarks:
+ *
+ *****************************************************************************/
+SMI130_GYRO_RETURN_FUNCTION_TYPE smi130_gyro_get_auto_offset_en(
+unsigned char *offset_en);
+#endif
diff --git a/drivers/input/sensors/smi130/smi130_gyro_driver.c b/drivers/input/sensors/smi130/smi130_gyro_driver.c
new file mode 100644
index 0000000..65e303c
--- /dev/null
+++ b/drivers/input/sensors/smi130/smi130_gyro_driver.c
@@ -0,0 +1,2036 @@
+/*!
+ * @section LICENSE
+ * (C) Copyright 2011~2016 Bosch Sensortec GmbH All Rights Reserved
+ *
+ * (C) Modification Copyright 2018 Robert Bosch Kft  All Rights Reserved
+ *
+ * This software program is licensed subject to the GNU General
+ * Public License (GPL).Version 2,June 1991,
+ * available at http://www.fsf.org/copyleft/gpl.html
+ *
+ * Special: Description of the Software:
+ *
+ * This software module (hereinafter called "Software") and any
+ * information on application-sheets (hereinafter called "Information") is
+ * provided free of charge for the sole purpose to support your application
+ * work. 
+ *
+ * As such, the Software is merely an experimental software, not tested for
+ * safety in the field and only intended for inspiration for further development 
+ * and testing. Any usage in a safety-relevant field of use (like automotive,
+ * seafaring, spacefaring, industrial plants etc.) was not intended, so there are
+ * no precautions for such usage incorporated in the Software.
+ * 
+ * The Software is specifically designed for the exclusive use for Bosch
+ * Sensortec products by personnel who have special experience and training. Do
+ * not use this Software if you do not have the proper experience or training.
+ * 
+ * This Software package is provided as is and without any expressed or
+ * implied warranties, including without limitation, the implied warranties of
+ * merchantability and fitness for a particular purpose.
+ * 
+ * Bosch Sensortec and their representatives and agents deny any liability for
+ * the functional impairment of this Software in terms of fitness, performance
+ * and safety. Bosch Sensortec and their representatives and agents shall not be
+ * liable for any direct or indirect damages or injury, except as otherwise
+ * stipulated in mandatory applicable law.
+ * The Information provided is believed to be accurate and reliable. Bosch
+ * Sensortec assumes no responsibility for the consequences of use of such
+ * Information nor for any infringement of patents or other rights of third
+ * parties which may result from its use.
+ * 
+ *------------------------------------------------------------------------------
+ * The following Product Disclaimer does not apply to the BSX4-HAL-4.1NoFusion Software 
+ * which is licensed under the Apache License, Version 2.0 as stated above.  
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Product Disclaimer
+ *
+ * Common:
+ *
+ * Assessment of Products Returned from Field
+ *
+ * Returned products are considered good if they fulfill the specifications / 
+ * test data for 0-mileage and field listed in this document.
+ *
+ * Engineering Samples
+ * 
+ * Engineering samples are marked with (e) or (E). Samples may vary from the
+ * valid technical specifications of the series product contained in this
+ * data sheet. Therefore, they are not intended or fit for resale to
+ * third parties or for use in end products. Their sole purpose is internal
+ * client testing. The testing of an engineering sample may in no way replace
+ * the testing of a series product. Bosch assumes no liability for the use
+ * of engineering samples. The purchaser shall indemnify Bosch from all claims
+ * arising from the use of engineering samples.
+ *
+ * Intended use
+ *
+ * Provided that SMI130 is used within the conditions (environment, application,
+ * installation, loads) as described in this TCD and the corresponding
+ * agreed upon documents, Bosch ensures that the product complies with
+ * the agreed properties. Agreements beyond this require
+ * the written approval by Bosch. The product is considered fit for the intended
+ * use when the product successfully has passed the tests
+ * in accordance with the TCD and agreed upon documents.
+ *
+ * It is the responsibility of the customer to ensure the proper application
+ * of the product in the overall system/vehicle.
+ *
+ * Bosch does not assume any responsibility for changes to the environment
+ * of the product that deviate from the TCD and the agreed upon documents 
+ * as well as all applications not released by Bosch
+  *
+ * The resale and/or use of products are at the purchaser’s own risk and 
+ * responsibility. The examination and testing of the SMI130 
+ * is the sole responsibility of the purchaser.
+ *
+ * The purchaser shall indemnify Bosch from all third party claims 
+ * arising from any product use not covered by the parameters of 
+ * this product data sheet or not approved by Bosch and reimburse Bosch 
+ * for all costs and damages in connection with such claims.
+ *
+ * The purchaser must monitor the market for the purchased products,
+ * particularly with regard to product safety, and inform Bosch without delay
+ * of all security relevant incidents.
+ *
+ * Application Examples and Hints
+ *
+ * With respect to any application examples, advice, normal values
+ * and/or any information regarding the application of the device,
+ * Bosch hereby disclaims any and all warranties and liabilities of any kind,
+ * including without limitation warranties of
+ * non-infringement of intellectual property rights or copyrights
+ * of any third party.
+ * The information given in this document shall in no event be regarded 
+ * as a guarantee of conditions or characteristics. They are provided
+ * for illustrative purposes only and no evaluation regarding infringement
+ * of intellectual property rights or copyrights or regarding functionality,
+ * performance or error has been made.
+ * @filename smi130_gyro_driver.c
+ * @date     2015/11/17 13:44
+ * @Modification Date 2018/08/28 18:20
+ * @id       "836294d"
+ * @version  1.5.9
+ *
+ * @brief    SMI130_GYRO Linux Driver
+ */
+#ifdef __KERNEL__
+#include <linux/kernel.h>
+#include <linux/unistd.h>
+#include <linux/types.h>
+#include <linux/string.h>
+#else
+#include <unistd.h>
+#include <sys/types.h>
+#include <string.h>
+#endif
+#include <linux/math64.h>
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/i2c.h>
+#include <linux/interrupt.h>
+#include <linux/input.h>
+#include <linux/workqueue.h>
+#include <linux/mutex.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/gpio.h>
+#include <linux/of_gpio.h>
+#include <linux/of_irq.h>
+
+#ifdef CONFIG_HAS_EARLYSUSPEND
+#include <linux/earlysuspend.h>
+#endif
+
+#include "smi130_gyro.h"
+#include "bs_log.h"
+
+/* sensor specific */
+#define SENSOR_NAME "smi130_gyro"
+#define SMI130_GYRO_ENABLE_INT1 1
+#define SENSOR_CHIP_ID_SMI_GYRO (0x0f)
+#define CHECK_CHIP_ID_TIME_MAX   5
+#define DRIVER_VERSION "0.0.53.0"
+#define SMI_GYRO_USE_FIFO          1
+#define SMI_GYRO_USE_BASIC_I2C_FUNC     1
+#define SMI_GYRO_REG_NAME(name) SMI130_GYRO_##name
+#define SMI_GYRO_VAL_NAME(name) SMI130_GYRO_##name
+#define SMI_GYRO_CALL_API(name) smi130_gyro_##name
+#define MSC_TIME                6
+
+#define SMI_GYRO_I2C_WRITE_DELAY_TIME 1
+
+/* generic */
+#define SMI_GYRO_MAX_RETRY_I2C_XFER (100)
+#define SMI_GYRO_MAX_RETRY_WAKEUP (5)
+#define SMI_GYRO_MAX_RETRY_WAIT_DRDY (100)
+
+#define SMI_GYRO_DELAY_MIN (1)
+#define SMI_GYRO_DELAY_DEFAULT (200)
+
+#define SMI_GYRO_VALUE_MAX (32767)
+#define SMI_GYRO_VALUE_MIN (-32768)
+
+#define BYTES_PER_LINE (16)
+
+#define SMI_GYRO_SELF_TEST 0
+
+#define SMI_GYRO_SOFT_RESET_VALUE                0xB6
+
+#ifdef SMI_GYRO_USE_FIFO
+#define MAX_FIFO_F_LEVEL 100
+#define MAX_FIFO_F_BYTES 8
+#define SMI130_GYRO_FIFO_DAT_SEL_X                     1
+#define SMI130_GYRO_FIFO_DAT_SEL_Y                     2
+#define SMI130_GYRO_FIFO_DAT_SEL_Z                     3
+#endif
+
+/*!
+ * @brief:BMI058 feature
+ *  macro definition
+*/
+#ifdef CONFIG_SENSORS_BMI058
+/*! BMI058 X AXIS definition*/
+#define BMI058_X_AXIS	SMI130_GYRO_Y_AXIS
+/*! BMI058 Y AXIS definition*/
+#define BMI058_Y_AXIS	SMI130_GYRO_X_AXIS
+
+#define C_BMI058_One_U8X	1
+#define C_BMI058_Two_U8X	2
+#endif
+
+/*! Bosch sensor unknown place*/
+#define BOSCH_SENSOR_PLACE_UNKNOWN (-1)
+/*! Bosch sensor remapping table size P0~P7*/
+#define MAX_AXIS_REMAP_TAB_SZ 8
+
+
+struct bosch_sensor_specific {
+	char *name;
+	/* 0 to 7 */
+	int place;
+	int irq;
+	int (*irq_gpio_cfg)(void);
+};
+
+
+/*!
+ * we use a typedef to hide the detail,
+ * because this type might be changed
+ */
+struct bosch_sensor_axis_remap {
+	/* src means which source will be mapped to target x, y, z axis */
+	/* if an target OS axis is remapped from (-)x,
+	 * src is 0, sign_* is (-)1 */
+	/* if an target OS axis is remapped from (-)y,
+	 * src is 1, sign_* is (-)1 */
+	/* if an target OS axis is remapped from (-)z,
+	 * src is 2, sign_* is (-)1 */
+	int src_x:3;
+	int src_y:3;
+	int src_z:3;
+
+	int sign_x:2;
+	int sign_y:2;
+	int sign_z:2;
+};
+
+
+struct bosch_sensor_data {
+	union {
+		int16_t v[3];
+		struct {
+			int16_t x;
+			int16_t y;
+			int16_t z;
+		};
+	};
+};
+
+struct smi_gyro_client_data {
+	struct smi130_gyro_t device;
+	struct i2c_client *client;
+	struct input_dev *input;
+	struct delayed_work work;
+
+#ifdef CONFIG_HAS_EARLYSUSPEND
+	struct early_suspend early_suspend_handler;
+#endif
+
+	atomic_t delay;
+	uint8_t debug_level;
+	struct smi130_gyro_data_t value;
+	u8 enable:1;
+	unsigned int fifo_count;
+	unsigned char fifo_datasel;
+	uint64_t timestamp;
+	uint64_t base_time;
+	uint64_t fifo_time;
+	uint64_t gyro_count;
+	uint64_t time_odr;
+	/* controls not only reg, but also workqueue */
+	struct mutex mutex_op_mode;
+	struct mutex mutex_enable;
+	struct bosch_sensor_specific *bosch_pd;
+	struct work_struct report_data_work;
+	int is_timer_running;
+	struct hrtimer timer;
+	ktime_t work_delay_kt;
+	uint8_t gpio_pin;
+	int16_t IRQ;
+	struct work_struct irq_work;
+};
+
+static struct i2c_client *smi_gyro_client;
+/* i2c operation for API */
+static int smi_gyro_i2c_read(struct i2c_client *client, u8 reg_addr,
+		u8 *data, u8 len);
+static int smi_gyro_i2c_write(struct i2c_client *client, u8 reg_addr,
+		u8 *data, u8 len);
+
+static void smi_gyro_dump_reg(struct i2c_client *client);
+static int smi_gyro_check_chip_id(struct i2c_client *client);
+
+static int smi_gyro_pre_suspend(struct i2c_client *client);
+static int smi_gyro_post_resume(struct i2c_client *client);
+
+#ifdef CONFIG_HAS_EARLYSUSPEND
+static void smi_gyro_early_suspend(struct early_suspend *handler);
+static void smi_gyro_late_resume(struct early_suspend *handler);
+#endif
+
+static void smi130_gyro_delay(SMI130_GYRO_U16 msec)
+{
+	if (msec <= 20)
+		usleep_range(msec * 1000, msec * 1000);
+	else
+		msleep(msec);
+}
+
+/*!
+* SMI130_GYRO sensor remapping function
+* need to give some parameter in BSP files first.
+*/
+static const struct bosch_sensor_axis_remap
+	bosch_axis_remap_tab_dft[MAX_AXIS_REMAP_TAB_SZ] = {
+	/* src_x src_y src_z  sign_x  sign_y  sign_z */
+	{  0,	 1,    2,	  1,	  1,	  1 }, /* P0 */
+	{  1,	 0,    2,	  1,	 -1,	  1 }, /* P1 */
+	{  0,	 1,    2,	 -1,	 -1,	  1 }, /* P2 */
+	{  1,	 0,    2,	 -1,	  1,	  1 }, /* P3 */
+
+	{  0,	 1,    2,	 -1,	  1,	 -1 }, /* P4 */
+	{  1,	 0,    2,	 -1,	 -1,	 -1 }, /* P5 */
+	{  0,	 1,    2,	  1,	 -1,	 -1 }, /* P6 */
+	{  1,	 0,    2,	  1,	  1,	 -1 }, /* P7 */
+};
+
+static void bosch_remap_sensor_data(struct bosch_sensor_data *data,
+			const struct bosch_sensor_axis_remap *remap)
+{
+	struct bosch_sensor_data tmp;
+
+	tmp.x = data->v[remap->src_x] * remap->sign_x;
+	tmp.y = data->v[remap->src_y] * remap->sign_y;
+	tmp.z = data->v[remap->src_z] * remap->sign_z;
+
+	memcpy(data, &tmp, sizeof(*data));
+}
+
+static void bosch_remap_sensor_data_dft_tab(struct bosch_sensor_data *data,
+			int place)
+{
+/* sensor with place 0 needs not to be remapped */
+	if ((place <= 0) || (place >= MAX_AXIS_REMAP_TAB_SZ))
+		return;
+	bosch_remap_sensor_data(data, &bosch_axis_remap_tab_dft[place]);
+}
+
+static void smi130_gyro_remap_sensor_data(struct smi130_gyro_data_t *val,
+		struct smi_gyro_client_data *client_data)
+{
+	struct bosch_sensor_data bsd;
+	int place;
+
+	if ((NULL == client_data->bosch_pd) || (BOSCH_SENSOR_PLACE_UNKNOWN
+			 == client_data->bosch_pd->place))
+		place = BOSCH_SENSOR_PLACE_UNKNOWN;
+	else
+		place = client_data->bosch_pd->place;
+
+#ifdef CONFIG_SENSORS_BMI058
+/*x,y need to be invesed becase of HW Register for BMI058*/
+	bsd.y = val->datax;
+	bsd.x = val->datay;
+	bsd.z = val->dataz;
+#else
+	bsd.x = val->datax;
+	bsd.y = val->datay;
+	bsd.z = val->dataz;
+#endif
+
+	bosch_remap_sensor_data_dft_tab(&bsd, place);
+
+	val->datax = bsd.x;
+	val->datay = bsd.y;
+	val->dataz = bsd.z;
+
+}
+
+static int smi_gyro_check_chip_id(struct i2c_client *client)
+{
+	int err = -1;
+	u8 chip_id = 0;
+	u8 read_count = 0;
+
+	while (read_count++ < CHECK_CHIP_ID_TIME_MAX) {
+		smi_gyro_i2c_read(client, SMI_GYRO_REG_NAME(CHIP_ID_ADDR), &chip_id, 1);
+		PINFO("read chip id result: %#x", chip_id);
+
+		if ((chip_id & 0xff) != SENSOR_CHIP_ID_SMI_GYRO) {
+			smi130_gyro_delay(1);
+		} else {
+			err = 0;
+			break;
+		}
+	}
+	return err;
+}
+
+static void smi_gyro_dump_reg(struct i2c_client *client)
+{
+	int i;
+	u8 dbg_buf[64];
+	u8 dbg_buf_str[64 * 3 + 1] = "";
+
+	for (i = 0; i < BYTES_PER_LINE; i++) {
+		dbg_buf[i] = i;
+		snprintf(dbg_buf_str + i * 3, 16, "%02x%c",
+				dbg_buf[i],
+				(((i + 1) % BYTES_PER_LINE == 0) ? '\n' : ' '));
+	}
+	dev_dbg(&client->dev, "%s\n", dbg_buf_str);
+
+	smi_gyro_i2c_read(client, SMI_GYRO_REG_NAME(CHIP_ID_ADDR), dbg_buf, 64);
+	for (i = 0; i < 64; i++) {
+		snprintf(dbg_buf_str + i * 3, 16, "%02x%c",
+				dbg_buf[i],
+				(((i + 1) % BYTES_PER_LINE == 0) ? '\n' : ' '));
+	}
+	dev_dbg(&client->dev, "%s\n", dbg_buf_str);
+}
+
+/*i2c read routine for API*/
+static int smi_gyro_i2c_read(struct i2c_client *client, u8 reg_addr,
+		u8 *data, u8 len)
+{
+#if !defined SMI_GYRO_USE_BASIC_I2C_FUNC
+	s32 dummy;
+	if (NULL == client)
+		return -ENODEV;
+
+	while (0 != len--) {
+#ifdef SMI_GYRO_SMBUS
+		dummy = i2c_smbus_read_byte_data(client, reg_addr);
+		if (dummy < 0) {
+			dev_err(&client->dev, "i2c bus read error");
+			return -EIO;
+		}
+		*data = (u8)(dummy & 0xff);
+#else
+		dummy = i2c_master_send(client, (char *)&reg_addr, 1);
+		if (dummy < 0)
+			return -EIO;
+
+		dummy = i2c_master_recv(client, (char *)data, 1);
+		if (dummy < 0)
+			return -EIO;
+#endif
+		reg_addr++;
+		data++;
+	}
+	return 0;
+#else
+	int retry;
+
+	struct i2c_msg msg[] = {
+		{
+			.addr = client->addr,
+			.flags = 0,
+			.len = 1,
+			.buf = &reg_addr,
+		},
+
+		{
+			.addr = client->addr,
+			.flags = I2C_M_RD,
+			.len = len,
+			.buf = data,
+		},
+	};
+
+	for (retry = 0; retry < SMI_GYRO_MAX_RETRY_I2C_XFER; retry++) {
+		if (i2c_transfer(client->adapter, msg, ARRAY_SIZE(msg)) > 0)
+			break;
+		else
+			smi130_gyro_delay(SMI_GYRO_I2C_WRITE_DELAY_TIME);
+	}
+
+	if (SMI_GYRO_MAX_RETRY_I2C_XFER <= retry) {
+		dev_err(&client->dev, "I2C xfer error");
+		return -EIO;
+	}
+
+	return 0;
+#endif
+}
+
+#ifdef SMI_GYRO_USE_FIFO
+static int smi_gyro_i2c_burst_read(struct i2c_client *client, u8 reg_addr,
+		u8 *data, u16 len)
+{
+	int retry;
+
+	struct i2c_msg msg[] = {
+		{
+			.addr = client->addr,
+			.flags = 0,
+			.len = 1,
+			.buf = &reg_addr,
+		},
+
+		{
+			.addr = client->addr,
+			.flags = I2C_M_RD,
+			.len = len,
+			.buf = data,
+		},
+	};
+
+	for (retry = 0; retry < SMI_GYRO_MAX_RETRY_I2C_XFER; retry++) {
+		if (i2c_transfer(client->adapter, msg, ARRAY_SIZE(msg)) > 0)
+			break;
+		else
+			smi130_gyro_delay(SMI_GYRO_I2C_WRITE_DELAY_TIME);
+	}
+
+	if (SMI_GYRO_MAX_RETRY_I2C_XFER <= retry) {
+		dev_err(&client->dev, "I2C xfer error");
+		return -EIO;
+	}
+
+	return 0;
+}
+#endif
+
+/*i2c write routine for */
+static int smi_gyro_i2c_write(struct i2c_client *client, u8 reg_addr,
+		u8 *data, u8 len)
+{
+#if !defined SMI_GYRO_USE_BASIC_I2C_FUNC
+	s32 dummy;
+
+#ifndef SMI_GYRO_SMBUS
+	u8 buffer[2];
+#endif
+
+	if (NULL == client)
+		return -ENODEV;
+
+	while (0 != len--) {
+#ifdef SMI_GYRO_SMBUS
+		dummy = i2c_smbus_write_byte_data(client, reg_addr, *data);
+#else
+		buffer[0] = reg_addr;
+		buffer[1] = *data;
+		dummy = i2c_master_send(client, (char *)buffer, 2);
+#endif
+		reg_addr++;
+		data++;
+		if (dummy < 0) {
+			dev_err(&client->dev, "error writing i2c bus");
+			return -EIO;
+		}
+
+	}
+	return 0;
+#else
+	u8 buffer[2];
+	int retry;
+	struct i2c_msg msg[] = {
+		{
+		 .addr = client->addr,
+		 .flags = 0,
+		 .len = 2,
+		 .buf = buffer,
+		 },
+	};
+
+	while (0 != len--) {
+		buffer[0] = reg_addr;
+		buffer[1] = *data;
+		for (retry = 0; retry < SMI_GYRO_MAX_RETRY_I2C_XFER; retry++) {
+			if (i2c_transfer(client->adapter, msg,
+						ARRAY_SIZE(msg)) > 0) {
+				break;
+			} else {
+				smi130_gyro_delay(SMI_GYRO_I2C_WRITE_DELAY_TIME);
+			}
+		}
+		if (SMI_GYRO_MAX_RETRY_I2C_XFER <= retry) {
+			dev_err(&client->dev, "I2C xfer error");
+			return -EIO;
+		}
+		reg_addr++;
+		data++;
+	}
+
+	return 0;
+#endif
+}
+
+static int smi_gyro_i2c_read_wrapper(u8 dev_addr, u8 reg_addr, u8 *data, u8 len)
+{
+	int err;
+	err = smi_gyro_i2c_read(smi_gyro_client, reg_addr, data, len);
+	return err;
+}
+
+static int smi_gyro_i2c_write_wrapper(u8 dev_addr, u8 reg_addr, u8 *data, u8 len)
+{
+	int err;
+	err = smi_gyro_i2c_write(smi_gyro_client, reg_addr, data, len);
+	return err;
+}
+
+
+static void smi_gyro_work_func(struct work_struct *work)
+{
+	struct smi_gyro_client_data *client_data =
+		container_of((struct delayed_work *)work,
+			struct smi_gyro_client_data, work);
+
+	unsigned long delay =
+		msecs_to_jiffies(atomic_read(&client_data->delay));
+	struct smi130_gyro_data_t gyro_data;
+
+	SMI_GYRO_CALL_API(get_dataXYZ)(&gyro_data);
+	/*remapping for SMI130_GYRO sensor*/
+	smi130_gyro_remap_sensor_data(&gyro_data, client_data);
+
+	input_report_abs(client_data->input, ABS_X, gyro_data.datax);
+	input_report_abs(client_data->input, ABS_Y, gyro_data.datay);
+	input_report_abs(client_data->input, ABS_Z, gyro_data.dataz);
+	input_sync(client_data->input);
+
+	schedule_delayed_work(&client_data->work, delay);
+}
+
+static struct workqueue_struct *reportdata_wq;
+
+uint64_t smi130_gyro_get_alarm_timestamp(void)
+{
+	uint64_t ts_ap;
+	struct timespec tmp_time;
+	get_monotonic_boottime(&tmp_time);
+	ts_ap = (uint64_t)tmp_time.tv_sec * 1000000000 + tmp_time.tv_nsec;
+	return ts_ap;
+}
+#define ABS(x) ((x) > 0 ? (x) : -(x))
+
+static void smi130_gyro_work_func(struct work_struct *work)
+{
+	struct	smi_gyro_client_data *smi130_gyro =
+		container_of(work,
+				struct smi_gyro_client_data, report_data_work);
+	int i;
+	struct smi130_gyro_data_t gyro_lsb;
+	unsigned char fifo_framecount;
+	signed char fifo_data_out[MAX_FIFO_F_LEVEL * MAX_FIFO_F_BYTES] = {0};
+	unsigned char f_len = 0;
+	uint64_t del;
+	uint64_t time_internal;
+	struct timespec ts;
+	int64_t drift_time = 0;
+	static uint64_t time_odr;
+	static uint32_t data_cnt;
+	static uint32_t pre_data_cnt;
+	static int64_t sample_drift_offset;
+	if (smi130_gyro->fifo_datasel)
+		/*Select one axis data output for every fifo frame*/
+		f_len = 2;
+	else
+		/*Select X Y Z axis data output for every fifo frame*/
+		f_len = 6;
+	if (SMI_GYRO_CALL_API(get_fifo_framecount)(&fifo_framecount) < 0) {
+		PERR("bm160_get_fifo_framecount err\n");
+		return;
+	}
+	if (fifo_framecount == 0)
+		return;
+	if (fifo_framecount > MAX_FIFO_F_LEVEL)
+			fifo_framecount = MAX_FIFO_F_LEVEL;
+	if (smi_gyro_i2c_burst_read(smi130_gyro->client, SMI130_GYRO_FIFO_DATA_ADDR,
+			fifo_data_out, fifo_framecount * f_len) < 0) {
+			PERR("smi130_gyro read fifo err\n");
+			return;
+	}
+	smi130_gyro->fifo_time = smi130_gyro_get_alarm_timestamp();
+	if (smi130_gyro->gyro_count == 0)
+		smi130_gyro->base_time = smi130_gyro->timestamp =
+		smi130_gyro->fifo_time - (fifo_framecount-1) * smi130_gyro->time_odr;
+
+	smi130_gyro->gyro_count += fifo_framecount;
+	del = smi130_gyro->fifo_time - smi130_gyro->base_time;
+	time_internal = div64_u64(del, smi130_gyro->gyro_count);
+	data_cnt++;
+	if (data_cnt == 1)
+		time_odr = smi130_gyro->time_odr;
+	if (time_internal > time_odr) {
+		if (time_internal - time_odr > div64_u64 (time_odr, 200))
+			time_internal = time_odr + div64_u64(time_odr, 200);
+	} else {
+		if (time_odr - time_internal > div64_u64(time_odr, 200))
+			time_internal = time_odr - div64_u64(time_odr, 200);
+	}
+
+	/* Select X Y Z axis data output for every frame */
+	for (i = 0; i < fifo_framecount; i++) {
+		if (smi130_gyro->debug_level & 0x01)
+			printk(KERN_INFO "smi_gyro time =%llu fifo_time = %llu time_internal = %llu smi_gyro->count= %llu count = %d",
+		smi130_gyro->timestamp, smi130_gyro->fifo_time,
+		time_internal, smi130_gyro->gyro_count, fifo_framecount);
+		ts = ns_to_timespec(smi130_gyro->timestamp);
+		gyro_lsb.datax =
+		((unsigned char)fifo_data_out[i * f_len + 1] << 8
+				| (unsigned char)fifo_data_out[i * f_len + 0]);
+		gyro_lsb.datay =
+		((unsigned char)fifo_data_out[i * f_len + 3] << 8
+				| (unsigned char)fifo_data_out[i * f_len + 2]);
+		gyro_lsb.dataz =
+		((unsigned char)fifo_data_out[i * f_len + 5] << 8
+				| (unsigned char)fifo_data_out[i * f_len + 4]);
+		smi130_gyro_remap_sensor_data(&gyro_lsb, smi130_gyro);
+		input_event(smi130_gyro->input, EV_MSC, MSC_TIME,
+		ts.tv_sec);
+		input_event(smi130_gyro->input, EV_MSC, MSC_TIME,
+		ts.tv_nsec);
+		input_event(smi130_gyro->input, EV_MSC,
+			MSC_GESTURE, gyro_lsb.datax);
+		input_event(smi130_gyro->input, EV_MSC,
+			MSC_RAW, gyro_lsb.datay);
+		input_event(smi130_gyro->input, EV_MSC,
+			MSC_SCAN, gyro_lsb.dataz);
+		input_sync(smi130_gyro->input);
+		smi130_gyro->timestamp += time_internal - sample_drift_offset;
+	}
+	drift_time = smi130_gyro->timestamp - smi130_gyro->fifo_time;
+	if (data_cnt % 20 == 0) {
+		if (ABS(drift_time) > div64_u64(time_odr, 5)) {
+			sample_drift_offset =
+		div64_s64(drift_time, smi130_gyro->gyro_count - pre_data_cnt);
+			pre_data_cnt = smi130_gyro->gyro_count;
+			time_odr = time_internal;
+		}
+	}
+}
+
+
+static enum hrtimer_restart reportdata_timer_fun(
+	struct hrtimer *hrtimer)
+{
+	struct smi_gyro_client_data *client_data =
+		container_of(hrtimer, struct smi_gyro_client_data, timer);
+	int32_t delay = 0;
+	delay = 10;
+	queue_work(reportdata_wq, &(client_data->report_data_work));
+	client_data->work_delay_kt = ns_to_ktime(delay*1000000);
+	hrtimer_forward(hrtimer, ktime_get(), client_data->work_delay_kt);
+
+	return HRTIMER_RESTART;
+}
+
+static ssize_t smi_gyro_show_enable_timer(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_gyro_client_data *client_data = input_get_drvdata(input);
+
+	return snprintf(buf, 16, "%d\n", client_data->is_timer_running);
+}
+
+static ssize_t smi_gyro_store_enable_timer(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_gyro_client_data *client_data = input_get_drvdata(input);
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+	if (data) {
+		if (0 == client_data->is_timer_running) {
+			hrtimer_start(&client_data->timer,
+			ns_to_ktime(10000000),
+			HRTIMER_MODE_REL);
+		client_data->is_timer_running = 1;
+		client_data->base_time = 0;
+		client_data->timestamp = 0;
+		client_data->gyro_count = 0;
+	}
+	} else {
+		if (1 == client_data->is_timer_running) {
+			hrtimer_cancel(&client_data->timer);
+			client_data->is_timer_running = 0;
+			client_data->base_time = 0;
+			client_data->timestamp = 0;
+			client_data->gyro_count = 0;
+	}
+	}
+	return count;
+}
+
+static ssize_t smi130_gyro_show_debug_level(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err;
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_gyro_client_data *client_data = input_get_drvdata(input);
+	err = snprintf(buf, 8, "%d\n", client_data->debug_level);
+	return err;
+}
+static ssize_t smi130_gyro_store_debug_level(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	int32_t ret = 0;
+	unsigned long data;
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_gyro_client_data *client_data = input_get_drvdata(input);
+	ret = kstrtoul(buf, 16, &data);
+	if (ret)
+		return ret;
+	client_data->debug_level = (uint8_t)data;
+	return count;
+}
+
+static int smi_gyro_set_soft_reset(struct i2c_client *client)
+{
+	int err = 0;
+	unsigned char data = SMI_GYRO_SOFT_RESET_VALUE;
+	err = smi_gyro_i2c_write(client, SMI130_GYRO_BGW_SOFTRESET_ADDR, &data, 1);
+	return err;
+}
+
+static ssize_t smi_gyro_show_chip_id(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	return snprintf(buf, 16, "%d\n", SENSOR_CHIP_ID_SMI_GYRO);
+}
+
+static ssize_t smi_gyro_show_op_mode(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int ret;
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_gyro_client_data *client_data = input_get_drvdata(input);
+	u8 op_mode = 0xff;
+
+	mutex_lock(&client_data->mutex_op_mode);
+	SMI_GYRO_CALL_API(get_mode)(&op_mode);
+	mutex_unlock(&client_data->mutex_op_mode);
+
+	ret = snprintf(buf, 16, "%d\n", op_mode);
+
+	return ret;
+}
+
+static ssize_t smi_gyro_store_op_mode(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	int err;
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_gyro_client_data *client_data = input_get_drvdata(input);
+
+	long op_mode;
+
+	err = kstrtoul(buf, 10, &op_mode);
+	if (err)
+		return err;
+	mutex_lock(&client_data->mutex_op_mode);
+
+	err = SMI_GYRO_CALL_API(set_mode)(op_mode);
+
+	mutex_unlock(&client_data->mutex_op_mode);
+
+	if (err)
+		return err;
+	else
+		return count;
+}
+
+
+
+static ssize_t smi_gyro_show_value(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_gyro_client_data *client_data = input_get_drvdata(input);
+	int count;
+
+	struct smi130_gyro_data_t value_data;
+	SMI_GYRO_CALL_API(get_dataXYZ)(&value_data);
+	/*SMI130_GYRO sensor raw data remapping*/
+	smi130_gyro_remap_sensor_data(&value_data, client_data);
+
+	count = snprintf(buf, 96, "%hd %hd %hd\n",
+				value_data.datax,
+				value_data.datay,
+				value_data.dataz);
+
+	return count;
+}
+
+static ssize_t smi_gyro_show_range(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err;
+	unsigned char range = 0;
+	SMI_GYRO_CALL_API(get_range_reg)(&range);
+	err = snprintf(buf, 16, "%d\n", range);
+	return err;
+}
+
+static ssize_t smi_gyro_store_range(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	int err;
+	unsigned long range;
+	err = kstrtoul(buf, 10, &range);
+	if (err)
+		return err;
+	SMI_GYRO_CALL_API(set_range_reg)(range);
+	return count;
+}
+
+/*
+decimation    odr     filter bandwidth     bits
+20	100HZ		32HZ		7
+10	200Hz		64HZ		6
+20	100HZ		12HZ		5
+10	200hz		23HZ		4
+5	400HZ		47HZ		3
+2	1000HZ		116HZ		2
+0	2000HZ		230HZ		1
+0	2000HZ		Unfiltered(523HZ)	0
+*/
+
+static const uint64_t odr_map[8] = {
+500000, 500000, 1000000, 2500000, 5000000, 10000000, 5000000, 10000000};
+
+static ssize_t smi_gyro_show_bandwidth(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err;
+	unsigned char bandwidth = 0;
+	SMI_GYRO_CALL_API(get_bw)(&bandwidth);
+	err = snprintf(buf, 16, "%d\n", bandwidth);
+	return err;
+}
+
+static ssize_t smi_gyro_store_bandwidth(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	int err;
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_gyro_client_data *client_data = input_get_drvdata(input);
+	unsigned long bandwidth;
+	u8 op_mode = 0xff;
+	err = kstrtoul(buf, 10, &bandwidth);
+	if (err)
+		return err;
+	/*
+	set bandwidth only in the op_mode=0
+	*/
+	err = SMI_GYRO_CALL_API(get_mode)(&op_mode);
+	if (op_mode == 0) {
+		err += SMI_GYRO_CALL_API(set_bw)(bandwidth);
+	} else {
+		err += SMI_GYRO_CALL_API(set_mode)(0);
+		err += SMI_GYRO_CALL_API(set_bw)(bandwidth);
+		smi130_gyro_delay(1);
+		err += SMI_GYRO_CALL_API(set_mode)(2);
+		smi130_gyro_delay(3);
+	}
+
+	if (err)
+		PERR("set failed");
+	client_data->time_odr = odr_map[bandwidth];
+	client_data->base_time = 0;
+	client_data->gyro_count = 0;
+	return count;
+}
+
+
+static ssize_t smi_gyro_show_enable(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_gyro_client_data *client_data = input_get_drvdata(input);
+	int err;
+
+	mutex_lock(&client_data->mutex_enable);
+	err = snprintf(buf, 16, "%d\n", client_data->enable);
+	mutex_unlock(&client_data->mutex_enable);
+	return err;
+}
+
+static ssize_t smi_gyro_store_enable(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_gyro_client_data *client_data = input_get_drvdata(input);
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	data = data ? 1 : 0;
+	mutex_lock(&client_data->mutex_enable);
+	if (data != client_data->enable) {
+		if (data) {
+			schedule_delayed_work(
+					&client_data->work,
+					msecs_to_jiffies(atomic_read(
+							&client_data->delay)));
+		} else {
+			cancel_delayed_work_sync(&client_data->work);
+		}
+
+		client_data->enable = data;
+	}
+	mutex_unlock(&client_data->mutex_enable);
+
+	return count;
+}
+
+static ssize_t smi_gyro_show_delay(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_gyro_client_data *client_data = input_get_drvdata(input);
+
+	return snprintf(buf, 16, "%d\n", atomic_read(&client_data->delay));
+
+}
+
+static ssize_t smi_gyro_store_delay(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int err;
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_gyro_client_data *client_data = input_get_drvdata(input);
+
+	err = kstrtoul(buf, 10, &data);
+	if (err)
+		return err;
+
+	if (data == 0) {
+		err = -EINVAL;
+		return err;
+	}
+
+	if (data < SMI_GYRO_DELAY_MIN)
+		data = SMI_GYRO_DELAY_MIN;
+
+	atomic_set(&client_data->delay, data);
+
+	return count;
+}
+
+
+static ssize_t smi_gyro_store_fastoffset_en(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	int err;
+	unsigned long fastoffset_en;
+	err = kstrtoul(buf, 10, &fastoffset_en);
+	if (err)
+		return err;
+	if (fastoffset_en) {
+
+#ifdef CONFIG_SENSORS_BMI058
+		SMI_GYRO_CALL_API(set_fast_offset_en_ch)(BMI058_X_AXIS, 1);
+		SMI_GYRO_CALL_API(set_fast_offset_en_ch)(BMI058_Y_AXIS, 1);
+#else
+		SMI_GYRO_CALL_API(set_fast_offset_en_ch)(SMI130_GYRO_X_AXIS, 1);
+		SMI_GYRO_CALL_API(set_fast_offset_en_ch)(SMI130_GYRO_Y_AXIS, 1);
+#endif
+
+		SMI_GYRO_CALL_API(set_fast_offset_en_ch)(SMI130_GYRO_Z_AXIS, 1);
+		SMI_GYRO_CALL_API(enable_fast_offset)();
+	}
+	return count;
+}
+
+static ssize_t smi_gyro_store_slowoffset_en(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	int err;
+	unsigned long slowoffset_en;
+	err = kstrtoul(buf, 10, &slowoffset_en);
+	if (err)
+		return err;
+	if (slowoffset_en) {
+		SMI_GYRO_CALL_API(set_slow_offset_th)(3);
+		SMI_GYRO_CALL_API(set_slow_offset_dur)(0);
+#ifdef CONFIG_SENSORS_BMI058
+		SMI_GYRO_CALL_API(set_slow_offset_en_ch)(BMI058_X_AXIS, 1);
+		SMI_GYRO_CALL_API(set_slow_offset_en_ch)(BMI058_Y_AXIS, 1);
+#else
+		SMI_GYRO_CALL_API(set_slow_offset_en_ch)(SMI130_GYRO_X_AXIS, 1);
+		SMI_GYRO_CALL_API(set_slow_offset_en_ch)(SMI130_GYRO_Y_AXIS, 1);
+#endif
+		SMI_GYRO_CALL_API(set_slow_offset_en_ch)(SMI130_GYRO_Z_AXIS, 1);
+	} else {
+#ifdef CONFIG_SENSORS_BMI058
+	SMI_GYRO_CALL_API(set_slow_offset_en_ch)(BMI058_X_AXIS, 0);
+	SMI_GYRO_CALL_API(set_slow_offset_en_ch)(BMI058_Y_AXIS, 0);
+#else
+	SMI_GYRO_CALL_API(set_slow_offset_en_ch)(SMI130_GYRO_X_AXIS, 0);
+	SMI_GYRO_CALL_API(set_slow_offset_en_ch)(SMI130_GYRO_Y_AXIS, 0);
+#endif
+	SMI_GYRO_CALL_API(set_slow_offset_en_ch)(SMI130_GYRO_Z_AXIS, 0);
+	}
+
+	return count;
+}
+
+static ssize_t smi_gyro_show_selftest(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err;
+	unsigned char selftest;
+	SMI_GYRO_CALL_API(selftest)(&selftest);
+	err = snprintf(buf, 16, "%d\n", selftest);
+	return err;
+}
+
+static ssize_t smi_gyro_show_sleepdur(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err;
+	unsigned char sleepdur;
+	SMI_GYRO_CALL_API(get_sleepdur)(&sleepdur);
+	err = snprintf(buf, 16, "%d\n", sleepdur);
+	return err;
+}
+
+static ssize_t smi_gyro_store_sleepdur(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	int err;
+	unsigned long sleepdur;
+	err = kstrtoul(buf, 10, &sleepdur);
+	if (err)
+		return err;
+	SMI_GYRO_CALL_API(set_sleepdur)(sleepdur);
+	return count;
+}
+
+static ssize_t smi_gyro_show_autosleepdur(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err;
+	unsigned char autosleepdur;
+	SMI_GYRO_CALL_API(get_autosleepdur)(&autosleepdur);
+	err = snprintf(buf, 16, "%d\n", autosleepdur);
+	return err;
+}
+
+static ssize_t smi_gyro_store_autosleepdur(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	int err;
+	unsigned long autosleepdur;
+	unsigned char bandwidth;
+	err = kstrtoul(buf, 10, &autosleepdur);
+	if (err)
+		return err;
+	SMI_GYRO_CALL_API(get_bw)(&bandwidth);
+	SMI_GYRO_CALL_API(set_autosleepdur)(autosleepdur, bandwidth);
+	return count;
+}
+
+static ssize_t smi_gyro_show_place(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_gyro_client_data *client_data = input_get_drvdata(input);
+	int place = BOSCH_SENSOR_PLACE_UNKNOWN;
+
+	if (NULL != client_data->bosch_pd)
+		place = client_data->bosch_pd->place;
+
+	return snprintf(buf, 16, "%d\n", place);
+}
+
+
+#ifdef SMI_GYRO_DEBUG
+static ssize_t smi_gyro_store_softreset(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	int err;
+	unsigned long softreset;
+	err = kstrtoul(buf, 10, &softreset);
+	if (err)
+		return err;
+	SMI_GYRO_CALL_API(set_soft_reset)();
+	return count;
+}
+
+static ssize_t smi_gyro_show_dumpreg(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	size_t count = 0;
+	u8 reg[0x40];
+	int i;
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_gyro_client_data *client_data = input_get_drvdata(input);
+
+	for (i = 0; i < 0x40; i++) {
+		smi_gyro_i2c_read(client_data->client, i, reg+i, 1);
+
+		count += snprintf(&buf[count], 48, "0x%x: 0x%x\n", i, reg[i]);
+	}
+	return count;
+}
+#endif
+
+#ifdef SMI_GYRO_USE_FIFO
+static ssize_t smi_gyro_show_fifo_mode(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err;
+	unsigned char fifo_mode;
+	SMI_GYRO_CALL_API(get_fifo_mode)(&fifo_mode);
+	err = snprintf(buf, 16, "%d\n", fifo_mode);
+	return err;
+}
+
+static ssize_t smi_gyro_store_fifo_mode(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	int err;
+	unsigned long fifo_mode;
+	err = kstrtoul(buf, 10, &fifo_mode);
+	if (err)
+		return err;
+	SMI_GYRO_CALL_API(set_fifo_mode)(fifo_mode);
+	return count;
+}
+
+static ssize_t smi_gyro_show_fifo_framecount(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err;
+	unsigned char fifo_framecount;
+	SMI_GYRO_CALL_API(get_fifo_framecount)(&fifo_framecount);
+	err = snprintf(buf, 32, "%d\n", fifo_framecount);
+	return err;
+}
+
+static ssize_t smi_gyro_store_fifo_framecount(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	unsigned long data;
+	int error;
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_gyro_client_data *client_data = input_get_drvdata(input);
+	error = kstrtoul(buf, 10, &data);
+	if (error)
+		return error;
+	client_data->fifo_count = (unsigned int) data;
+
+	return count;
+}
+
+static ssize_t smi_gyro_show_fifo_overrun(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err;
+	unsigned char fifo_overrun;
+	SMI_GYRO_CALL_API(get_fifo_overrun)(&fifo_overrun);
+	err = snprintf(buf, 16, "%d\n", fifo_overrun);
+	return err;
+}
+
+static ssize_t smi_gyro_show_fifo_data_frame(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	unsigned char f_len = 0;
+	unsigned char fifo_framecount;
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_gyro_client_data *client_data = input_get_drvdata(input);
+
+	if (client_data->fifo_datasel)
+		/*Select one axis data output for every fifo frame*/
+		f_len = 2;
+	else
+		/*Select X Y Z axis data output for every fifo frame*/
+		f_len = 6;
+
+	if (SMI_GYRO_CALL_API(get_fifo_framecount)(&fifo_framecount) < 0) {
+		PERR("bm160_get_fifo_framecount err\n");
+		return -EINVAL;
+	}
+	if (fifo_framecount == 0)
+		return 0;
+
+	smi_gyro_i2c_burst_read(client_data->client, SMI130_GYRO_FIFO_DATA_ADDR,
+			buf, fifo_framecount * f_len);
+	return fifo_framecount * f_len;
+}
+
+/*!
+ * @brief show fifo_data_sel axis definition(Android definition, not sensor HW reg).
+ * 0--> x, y, z axis fifo data for every frame
+ * 1--> only x axis fifo data for every frame
+ * 2--> only y axis fifo data for every frame
+ * 3--> only z axis fifo data for every frame
+ */
+static ssize_t smi_gyro_show_fifo_data_sel(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err;
+	unsigned char fifo_data_sel;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct smi_gyro_client_data *client_data = i2c_get_clientdata(client);
+	signed char place = BOSCH_SENSOR_PLACE_UNKNOWN;
+
+	SMI_GYRO_CALL_API(get_fifo_data_sel)(&fifo_data_sel);
+
+	/*remapping fifo_dat_sel if define virtual place in BSP files*/
+	if ((NULL != client_data->bosch_pd) &&
+		(BOSCH_SENSOR_PLACE_UNKNOWN != client_data->bosch_pd->place)) {
+		place = client_data->bosch_pd->place;
+		/* sensor with place 0 needs not to be remapped */
+		if ((place > 0) && (place < MAX_AXIS_REMAP_TAB_SZ)) {
+			if (SMI130_GYRO_FIFO_DAT_SEL_X == fifo_data_sel)
+				/* SMI130_GYRO_FIFO_DAT_SEL_X: 1, Y:2, Z:3;
+				*bosch_axis_remap_tab_dft[i].src_x:0, y:1, z:2
+				*so we need to +1*/
+				fifo_data_sel =
+					bosch_axis_remap_tab_dft[place].src_x + 1;
+
+			else if (SMI130_GYRO_FIFO_DAT_SEL_Y == fifo_data_sel)
+				fifo_data_sel =
+					bosch_axis_remap_tab_dft[place].src_y + 1;
+		}
+
+	}
+
+	err = snprintf(buf, 16, "%d\n", fifo_data_sel);
+	return err;
+}
+
+/*!
+ * @brief store fifo_data_sel axis definition(Android definition, not sensor HW reg).
+ * 0--> x, y, z axis fifo data for every frame
+ * 1--> only x axis fifo data for every frame
+ * 2--> only y axis fifo data for every frame
+ * 3--> only z axis fifo data for every frame
+ */
+static ssize_t smi_gyro_store_fifo_data_sel(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+
+{
+	int err;
+	unsigned long fifo_data_sel;
+
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_gyro_client_data *client_data = input_get_drvdata(input);
+	signed char place;
+
+	err = kstrtoul(buf, 10, &fifo_data_sel);
+	if (err)
+		return err;
+
+	/*save fifo_data_sel(android axis definition)*/
+	client_data->fifo_datasel = (unsigned char) fifo_data_sel;
+
+	/*remaping fifo_dat_sel if define virtual place*/
+	if ((NULL != client_data->bosch_pd) &&
+		(BOSCH_SENSOR_PLACE_UNKNOWN != client_data->bosch_pd->place)) {
+		place = client_data->bosch_pd->place;
+		/* sensor with place 0 needs not to be remapped */
+		if ((place > 0) && (place < MAX_AXIS_REMAP_TAB_SZ)) {
+			/*Need X Y axis revesal sensor place: P1, P3, P5, P7 */
+			/* SMI130_GYRO_FIFO_DAT_SEL_X: 1, Y:2, Z:3;
+			  * but bosch_axis_remap_tab_dft[i].src_x:0, y:1, z:2
+			  * so we need to +1*/
+			if (SMI130_GYRO_FIFO_DAT_SEL_X == fifo_data_sel)
+				fifo_data_sel =
+					bosch_axis_remap_tab_dft[place].src_x + 1;
+
+			else if (SMI130_GYRO_FIFO_DAT_SEL_Y == fifo_data_sel)
+				fifo_data_sel =
+					bosch_axis_remap_tab_dft[place].src_y + 1;
+		}
+	}
+
+	if (SMI_GYRO_CALL_API(set_fifo_data_sel)(fifo_data_sel) < 0)
+		return -EINVAL;
+
+	return count;
+}
+
+static ssize_t smi_gyro_show_fifo_tag(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int err;
+	unsigned char fifo_tag;
+	SMI_GYRO_CALL_API(get_fifo_tag)(&fifo_tag);
+	err = snprintf(buf, 16, "%d\n", fifo_tag);
+	return err;
+}
+
+static ssize_t smi_gyro_store_fifo_tag(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t count)
+
+{
+	int err;
+	unsigned long fifo_tag;
+	err = kstrtoul(buf, 10, &fifo_tag);
+	if (err)
+		return err;
+	SMI_GYRO_CALL_API(set_fifo_tag)(fifo_tag);
+	return count;
+}
+#endif
+
+static ssize_t smi130_gyro_driver_version_show(struct device *dev
+		, struct device_attribute *attr, char *buf)
+{
+	struct input_dev *input = to_input_dev(dev);
+	struct smi_gyro_client_data *client_data = input_get_drvdata(input);
+	int ret;
+
+	if (client_data == NULL) {
+		printk(KERN_ERR "Invalid client_data pointer");
+		return -ENODEV;
+	}
+
+	ret = snprintf(buf, 128, "Driver version: %s\n",
+			DRIVER_VERSION);
+	return ret;
+}
+static DEVICE_ATTR(chip_id, S_IRUSR,
+		smi_gyro_show_chip_id, NULL);
+static DEVICE_ATTR(op_mode, S_IRUGO | S_IWUSR,
+		smi_gyro_show_op_mode, smi_gyro_store_op_mode);
+static DEVICE_ATTR(value, S_IRUSR,
+		smi_gyro_show_value, NULL);
+static DEVICE_ATTR(range, S_IRUGO | S_IWUSR,
+		smi_gyro_show_range, smi_gyro_store_range);
+static DEVICE_ATTR(bandwidth, S_IRUGO | S_IWUSR,
+		smi_gyro_show_bandwidth, smi_gyro_store_bandwidth);
+static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR,
+		smi_gyro_show_enable, smi_gyro_store_enable);
+static DEVICE_ATTR(delay, S_IRUGO | S_IWUSR,
+		smi_gyro_show_delay, smi_gyro_store_delay);
+static DEVICE_ATTR(fastoffset_en, S_IWUSR,
+		NULL, smi_gyro_store_fastoffset_en);
+static DEVICE_ATTR(slowoffset_en, S_IWUSR,
+		NULL, smi_gyro_store_slowoffset_en);
+static DEVICE_ATTR(selftest, S_IRUGO,
+		smi_gyro_show_selftest, NULL);
+static DEVICE_ATTR(sleepdur, S_IRUGO | S_IWUSR,
+		smi_gyro_show_sleepdur, smi_gyro_store_sleepdur);
+static DEVICE_ATTR(autosleepdur, S_IRUGO | S_IWUSR,
+		smi_gyro_show_autosleepdur, smi_gyro_store_autosleepdur);
+static DEVICE_ATTR(place, S_IRUSR,
+		smi_gyro_show_place, NULL);
+static DEVICE_ATTR(enable_timer, S_IRUGO | S_IWUSR,
+		smi_gyro_show_enable_timer, smi_gyro_store_enable_timer);
+static DEVICE_ATTR(debug_level, S_IRUGO | S_IWUSR,
+		smi130_gyro_show_debug_level, smi130_gyro_store_debug_level);
+static DEVICE_ATTR(driver_version, S_IRUSR,
+		smi130_gyro_driver_version_show, NULL);
+#ifdef SMI_GYRO_DEBUG
+static DEVICE_ATTR(softreset, S_IWUSR,
+		NULL, smi_gyro_store_softreset);
+static DEVICE_ATTR(regdump, S_IRUSR,
+		smi_gyro_show_dumpreg, NULL);
+#endif
+#ifdef SMI_GYRO_USE_FIFO
+static DEVICE_ATTR(fifo_mode, S_IRUGO | S_IWUSR,
+		smi_gyro_show_fifo_mode, smi_gyro_store_fifo_mode);
+static DEVICE_ATTR(fifo_framecount, S_IRUGO | S_IWUSR,
+		smi_gyro_show_fifo_framecount, smi_gyro_store_fifo_framecount);
+static DEVICE_ATTR(fifo_overrun, S_IRUGO,
+		smi_gyro_show_fifo_overrun, NULL);
+static DEVICE_ATTR(fifo_data_frame, S_IRUSR,
+		smi_gyro_show_fifo_data_frame, NULL);
+static DEVICE_ATTR(fifo_data_sel, S_IRUGO | S_IWUSR,
+		smi_gyro_show_fifo_data_sel, smi_gyro_store_fifo_data_sel);
+static DEVICE_ATTR(fifo_tag, S_IRUGO | S_IWUSR,
+		smi_gyro_show_fifo_tag, smi_gyro_store_fifo_tag);
+#endif
+
+static struct attribute *smi_gyro_attributes[] = {
+	&dev_attr_chip_id.attr,
+	&dev_attr_op_mode.attr,
+	&dev_attr_value.attr,
+	&dev_attr_range.attr,
+	&dev_attr_bandwidth.attr,
+	&dev_attr_enable.attr,
+	&dev_attr_delay.attr,
+	&dev_attr_fastoffset_en.attr,
+	&dev_attr_slowoffset_en.attr,
+	&dev_attr_selftest.attr,
+	&dev_attr_sleepdur.attr,
+	&dev_attr_autosleepdur.attr,
+	&dev_attr_place.attr,
+	&dev_attr_enable_timer.attr,
+	&dev_attr_debug_level.attr,
+	&dev_attr_driver_version.attr,
+#ifdef SMI_GYRO_DEBUG
+	&dev_attr_softreset.attr,
+	&dev_attr_regdump.attr,
+#endif
+#ifdef SMI_GYRO_USE_FIFO
+	&dev_attr_fifo_mode.attr,
+	&dev_attr_fifo_framecount.attr,
+	&dev_attr_fifo_overrun.attr,
+	&dev_attr_fifo_data_frame.attr,
+	&dev_attr_fifo_data_sel.attr,
+	&dev_attr_fifo_tag.attr,
+#endif
+	NULL
+};
+
+static struct attribute_group smi_gyro_attribute_group = {
+	.attrs = smi_gyro_attributes
+};
+
+
+static int smi_gyro_input_init(struct smi_gyro_client_data *client_data)
+{
+	struct input_dev *dev;
+	int err = 0;
+
+	dev = input_allocate_device();
+	if (NULL == dev)
+		return -ENOMEM;
+
+	dev->name = SENSOR_NAME;
+	dev->id.bustype = BUS_I2C;
+
+	input_set_capability(dev, EV_ABS, ABS_MISC);
+	input_set_abs_params(dev, ABS_X, SMI_GYRO_VALUE_MIN, SMI_GYRO_VALUE_MAX, 0, 0);
+	input_set_abs_params(dev, ABS_Y, SMI_GYRO_VALUE_MIN, SMI_GYRO_VALUE_MAX, 0, 0);
+	input_set_abs_params(dev, ABS_Z, SMI_GYRO_VALUE_MIN, SMI_GYRO_VALUE_MAX, 0, 0);
+	input_set_capability(dev, EV_MSC, MSC_GESTURE);
+	input_set_capability(dev, EV_MSC, MSC_RAW);
+	input_set_capability(dev, EV_MSC, MSC_SCAN);
+	input_set_capability(dev, EV_MSC, MSC_TIME);
+	input_set_drvdata(dev, client_data);
+
+	err = input_register_device(dev);
+	if (err < 0) {
+		input_free_device(dev);
+		return err;
+	}
+	client_data->input = dev;
+
+	return 0;
+}
+
+static void smi_gyro_input_destroy(struct smi_gyro_client_data *client_data)
+{
+	struct input_dev *dev = client_data->input;
+
+	input_unregister_device(dev);
+	input_free_device(dev);
+}
+
+#if defined(SMI130_GYRO_ENABLE_INT1) || defined(SMI130_GYRO_ENABLE_INT2)
+static void smi130_gyro_irq_work_func(struct work_struct *work)
+{
+	struct smi_gyro_client_data *client_data = container_of(work,
+		struct smi_gyro_client_data, irq_work);
+	struct smi130_gyro_data_t gyro_data;
+	struct timespec ts;
+	ts = ns_to_timespec(client_data->timestamp);
+
+	SMI_GYRO_CALL_API(get_dataXYZ)(&gyro_data);
+	/*remapping for SMI130_GYRO sensor*/
+	smi130_gyro_remap_sensor_data(&gyro_data, client_data);
+	input_event(client_data->input, EV_MSC, MSC_TIME,
+		ts.tv_sec);
+	input_event(client_data->input, EV_MSC, MSC_TIME,
+		ts.tv_nsec);
+	input_event(client_data->input, EV_MSC,
+		MSC_GESTURE, gyro_data.datax);
+	input_event(client_data->input, EV_MSC,
+		MSC_RAW, gyro_data.datay);
+	input_event(client_data->input, EV_MSC,
+		MSC_SCAN, gyro_data.dataz);
+	input_sync(client_data->input);
+
+}
+
+static irqreturn_t smi_gyro_irq_handler(int irq, void *handle)
+{
+	struct smi_gyro_client_data *client_data = handle;
+	client_data->timestamp= smi130_gyro_get_alarm_timestamp();
+	schedule_work(&client_data->irq_work);
+	return IRQ_HANDLED;
+}
+#endif
+static int smi_gyro_probe(struct i2c_client *client, const struct i2c_device_id *id)
+{
+	int err = 0;
+	struct smi_gyro_client_data *client_data = NULL;
+	PINFO("function entrance");
+
+	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
+		PERR("i2c_check_functionality error!");
+		err = -EIO;
+		goto exit_err_clean;
+	}
+
+	if (NULL == smi_gyro_client) {
+		smi_gyro_client = client;
+	} else {
+		PERR("this driver does not support multiple clients");
+		err = -EINVAL;
+		goto exit_err_clean;
+	}
+
+	/* check chip id */
+	err = smi_gyro_check_chip_id(client);
+	if (!err) {
+		PINFO("Bosch Sensortec Device %s detected", SENSOR_NAME);
+	} else {
+		PERR("Bosch Sensortec Device not found, chip id mismatch");
+		err = -1;
+		goto exit_err_clean;
+	}
+
+	/* do soft reset */
+	smi130_gyro_delay(5);
+	err = smi_gyro_set_soft_reset(client);
+	if (err < 0) {
+		PERR("erro soft reset!\n");
+		err = -EINVAL;
+		goto exit_err_clean;
+	}
+	smi130_gyro_delay(30);
+
+
+	client_data = kzalloc(sizeof(struct smi_gyro_client_data), GFP_KERNEL);
+	if (NULL == client_data) {
+		PERR("no memory available");
+		err = -ENOMEM;
+		goto exit_err_clean;
+	}
+
+	i2c_set_clientdata(client, client_data);
+	client_data->client = client;
+
+	mutex_init(&client_data->mutex_op_mode);
+	mutex_init(&client_data->mutex_enable);
+
+	/* input device init */
+	err = smi_gyro_input_init(client_data);
+	if (err < 0)
+		goto exit_err_clean;
+
+	/* sysfs node creation */
+	err = sysfs_create_group(&client_data->input->dev.kobj,
+			&smi_gyro_attribute_group);
+
+	if (err < 0)
+		goto exit_err_sysfs;
+
+	if (NULL != client->dev.platform_data) {
+		client_data->bosch_pd = kzalloc(sizeof(*client_data->bosch_pd),
+				GFP_KERNEL);
+
+		if (NULL != client_data->bosch_pd) {
+			memcpy(client_data->bosch_pd, client->dev.platform_data,
+					sizeof(*client_data->bosch_pd));
+			PINFO("%s sensor driver set place: p%d",
+					SENSOR_NAME,
+					client_data->bosch_pd->place);
+		}
+	}
+
+	/* workqueue init */
+	INIT_DELAYED_WORK(&client_data->work, smi_gyro_work_func);
+	atomic_set(&client_data->delay, SMI_GYRO_DELAY_DEFAULT);
+
+	/* h/w init */
+	client_data->device.bus_read = smi_gyro_i2c_read_wrapper;
+	client_data->device.bus_write = smi_gyro_i2c_write_wrapper;
+	client_data->device.delay_msec = smi130_gyro_delay;
+	SMI_GYRO_CALL_API(init)(&client_data->device);
+
+	smi_gyro_dump_reg(client);
+
+	client_data->enable = 0;
+	client_data->fifo_datasel = 0;
+	client_data->fifo_count = 0;
+
+	/*workqueue init*/
+	INIT_WORK(&client_data->report_data_work,
+	smi130_gyro_work_func);
+	reportdata_wq = create_singlethread_workqueue("smi130_gyro_wq");
+	if (NULL == reportdata_wq)
+		PERR("fail to create the reportdta_wq %d", -ENOMEM);
+	hrtimer_init(&client_data->timer, CLOCK_MONOTONIC,
+		HRTIMER_MODE_REL);
+	client_data->timer.function = reportdata_timer_fun;
+	client_data->work_delay_kt = ns_to_ktime(10000000);
+	client_data->is_timer_running = 0;
+	client_data->time_odr = 500000;
+#ifdef SMI130_GYRO_ENABLE_INT1
+	err = SMI_GYRO_CALL_API(set_mode)(SMI130_GYRO_MODE_NORMAL);
+	smi130_gyro_delay(5);
+	/*config the interrupt and map the interrupt*/
+	/*high level trigger*/
+	err += smi130_gyro_set_int_lvl(SMI130_GYRO_INT1_DATA, 1);
+	smi130_gyro_delay(5);
+	err += smi130_gyro_set_int_od(SMI130_GYRO_INT1, 0);
+	smi130_gyro_delay(5);
+	err += smi130_gyro_set_int_data(SMI130_GYRO_INT1_DATA, SMI130_GYRO_ENABLE);
+	smi130_gyro_delay(5);
+	err += smi130_gyro_set_data_en(SMI130_GYRO_ENABLE);
+	smi130_gyro_delay(5);
+	/*default odr is 100HZ*/
+	err += SMI_GYRO_CALL_API(set_bw)(7);
+	smi130_gyro_delay(5);
+	if (err)
+		PERR("config sensor data ready interrupt failed");
+#endif
+#ifdef SMI130_GYRO_ENABLE_INT2
+	err = SMI_GYRO_CALL_API(set_mode)(SMI130_GYRO_MODE_NORMAL);
+	/*config the interrupt and map the interrupt*/
+	/*high level trigger*/
+	err += smi130_gyro_set_int_lvl(SMI130_GYRO_INT2_DATA, 1);
+	smi130_gyro_delay(3);
+	err += smi130_gyro_set_int_od(SMI130_GYRO_INT2, 0);
+	smi130_gyro_delay(5);
+	err += smi130_gyro_set_int_data(SMI130_GYRO_INT2_DATA, SMI130_GYRO_ENABLE);
+	smi130_gyro_delay(3);
+	err += smi130_gyro_set_data_en(SMI130_GYRO_ENABLE);
+	/*default odr is 100HZ*/
+	err += SMI_GYRO_CALL_API(set_bw)(7);
+	smi130_gyro_delay(5);
+	if (err)
+		PERR("config sensor data ready interrupt failed");
+#endif
+	err += SMI_GYRO_CALL_API(set_mode)(
+		SMI_GYRO_VAL_NAME(MODE_SUSPEND));
+	if (err < 0)
+		goto exit_err_sysfs;
+#ifdef CONFIG_HAS_EARLYSUSPEND
+	client_data->early_suspend_handler.suspend = smi_gyro_early_suspend;
+	client_data->early_suspend_handler.resume = smi_gyro_late_resume;
+	register_early_suspend(&client_data->early_suspend_handler);
+#endif
+#if defined(SMI130_GYRO_ENABLE_INT1) || defined(SMI130_GYRO_ENABLE_INT2)
+	client_data->gpio_pin = of_get_named_gpio_flags(
+		client->dev.of_node,
+		"smi130_gyro,gpio_irq", 0, NULL);
+	PDEBUG("smi130_gyro qpio number:%d\n", client_data->gpio_pin);
+	err = gpio_request_one(client_data->gpio_pin,
+				GPIOF_IN, "bm160_interrupt");
+	if (err < 0) {
+		PDEBUG("requestgpio  failed\n");
+		client_data->gpio_pin = 0;
+	}
+	if (client_data->gpio_pin != 0) {
+		err = gpio_direction_input(client_data->gpio_pin);
+		if (err < 0) {
+			PDEBUG("request failed\n");
+		}
+		client_data->IRQ = gpio_to_irq(client_data->gpio_pin);
+		err = request_irq(client_data->IRQ, smi_gyro_irq_handler,
+				IRQF_TRIGGER_RISING,
+				SENSOR_NAME, client_data);
+		if (err < 0)
+			PDEBUG("request handle failed\n");
+	}
+	INIT_WORK(&client_data->irq_work, smi130_gyro_irq_work_func);
+#endif
+	PINFO("sensor %s probed successfully", SENSOR_NAME);
+
+	dev_dbg(&client->dev,
+		"i2c_client: %p client_data: %p i2c_device: %p input: %p",
+		client, client_data, &client->dev, client_data->input);
+
+	return 0;
+
+exit_err_sysfs:
+	if (err)
+		smi_gyro_input_destroy(client_data);
+
+exit_err_clean:
+	if (err) {
+		if (client_data != NULL) {
+			kfree(client_data);
+			client_data = NULL;
+		}
+
+		smi_gyro_client = NULL;
+	}
+
+	return err;
+}
+
+static int smi_gyro_pre_suspend(struct i2c_client *client)
+{
+	int err = 0;
+	struct smi_gyro_client_data *client_data =
+		(struct smi_gyro_client_data *)i2c_get_clientdata(client);
+	PINFO("function entrance");
+
+	mutex_lock(&client_data->mutex_enable);
+	if (client_data->enable) {
+		cancel_delayed_work_sync(&client_data->work);
+		PINFO("cancel work");
+	}
+	mutex_unlock(&client_data->mutex_enable);
+	if (client_data->is_timer_running) {
+		hrtimer_cancel(&client_data->timer);
+		client_data->base_time = 0;
+		client_data->timestamp = 0;
+		client_data->fifo_time = 0;
+		client_data->gyro_count = 0;
+	}
+	return err;
+}
+
+static int smi_gyro_post_resume(struct i2c_client *client)
+{
+	int err = 0;
+	struct smi_gyro_client_data *client_data =
+		(struct smi_gyro_client_data *)i2c_get_clientdata(client);
+
+	PINFO("function entrance");
+	mutex_lock(&client_data->mutex_enable);
+	if (client_data->enable) {
+		schedule_delayed_work(&client_data->work,
+				msecs_to_jiffies(
+					atomic_read(&client_data->delay)));
+	}
+	mutex_unlock(&client_data->mutex_enable);
+	if (client_data->is_timer_running) {
+		hrtimer_start(&client_data->timer,
+					ns_to_ktime(client_data->time_odr),
+			HRTIMER_MODE_REL);
+		client_data->base_time = 0;
+		client_data->timestamp = 0;
+		client_data->is_timer_running = 1;
+		client_data->gyro_count = 0;
+	}
+	return err;
+}
+
+#ifdef CONFIG_HAS_EARLYSUSPEND
+static void smi_gyro_early_suspend(struct early_suspend *handler)
+{
+	int err = 0;
+	struct smi_gyro_client_data *client_data =
+		(struct smi_gyro_client_data *)container_of(handler,
+			struct smi_gyro_client_data, early_suspend_handler);
+	struct i2c_client *client = client_data->client;
+
+	PINFO("function entrance");
+
+	mutex_lock(&client_data->mutex_op_mode);
+	if (client_data->enable) {
+		err = smi_gyro_pre_suspend(client);
+		err = SMI_GYRO_CALL_API(set_mode)(
+				SMI_GYRO_VAL_NAME(MODE_SUSPEND));
+	}
+	mutex_unlock(&client_data->mutex_op_mode);
+}
+
+static void smi_gyro_late_resume(struct early_suspend *handler)
+{
+
+	int err = 0;
+	struct smi_gyro_client_data *client_data =
+		(struct smi_gyro_client_data *)container_of(handler,
+			struct smi_gyro_client_data, early_suspend_handler);
+	struct i2c_client *client = client_data->client;
+
+	PINFO("function entrance");
+
+	mutex_lock(&client_data->mutex_op_mode);
+
+	if (client_data->enable)
+		err = SMI_GYRO_CALL_API(set_mode)(SMI_GYRO_VAL_NAME(MODE_NORMAL));
+
+	/* post resume operation */
+	smi_gyro_post_resume(client);
+
+	mutex_unlock(&client_data->mutex_op_mode);
+}
+#else
+static int smi_gyro_suspend(struct i2c_client *client, pm_message_t mesg)
+{
+	int err = 0;
+	struct smi_gyro_client_data *client_data =
+		(struct smi_gyro_client_data *)i2c_get_clientdata(client);
+
+	PINFO("function entrance");
+
+	mutex_lock(&client_data->mutex_op_mode);
+	if (client_data->enable) {
+		err = smi_gyro_pre_suspend(client);
+		err = SMI_GYRO_CALL_API(set_mode)(
+				SMI_GYRO_VAL_NAME(MODE_SUSPEND));
+	}
+	mutex_unlock(&client_data->mutex_op_mode);
+	return err;
+}
+
+static int smi_gyro_resume(struct i2c_client *client)
+{
+
+	int err = 0;
+	struct smi_gyro_client_data *client_data =
+		(struct smi_gyro_client_data *)i2c_get_clientdata(client);
+
+	PINFO("function entrance");
+
+	mutex_lock(&client_data->mutex_op_mode);
+
+	if (client_data->enable)
+		err = SMI_GYRO_CALL_API(set_mode)(SMI_GYRO_VAL_NAME(MODE_NORMAL));
+
+	/* post resume operation */
+	smi_gyro_post_resume(client);
+
+	mutex_unlock(&client_data->mutex_op_mode);
+	return err;
+}
+#endif
+
+void smi_gyro_shutdown(struct i2c_client *client)
+{
+	struct smi_gyro_client_data *client_data =
+		(struct smi_gyro_client_data *)i2c_get_clientdata(client);
+
+	mutex_lock(&client_data->mutex_op_mode);
+	SMI_GYRO_CALL_API(set_mode)(
+		SMI_GYRO_VAL_NAME(MODE_DEEPSUSPEND));
+	mutex_unlock(&client_data->mutex_op_mode);
+}
+
+static int smi_gyro_remove(struct i2c_client *client)
+{
+	int err = 0;
+	u8 op_mode;
+
+	struct smi_gyro_client_data *client_data =
+		(struct smi_gyro_client_data *)i2c_get_clientdata(client);
+
+	if (NULL != client_data) {
+#ifdef CONFIG_HAS_EARLYSUSPEND
+		unregister_early_suspend(&client_data->early_suspend_handler);
+#endif
+		mutex_lock(&client_data->mutex_op_mode);
+		SMI_GYRO_CALL_API(get_mode)(&op_mode);
+		if (SMI_GYRO_VAL_NAME(MODE_NORMAL) == op_mode) {
+			cancel_delayed_work_sync(&client_data->work);
+			PINFO("cancel work");
+		}
+		mutex_unlock(&client_data->mutex_op_mode);
+
+		err = SMI_GYRO_CALL_API(set_mode)(
+				SMI_GYRO_VAL_NAME(MODE_SUSPEND));
+		smi130_gyro_delay(SMI_GYRO_I2C_WRITE_DELAY_TIME);
+
+		sysfs_remove_group(&client_data->input->dev.kobj,
+				&smi_gyro_attribute_group);
+		smi_gyro_input_destroy(client_data);
+		kfree(client_data);
+
+		smi_gyro_client = NULL;
+	}
+
+	return err;
+}
+
+static const struct i2c_device_id smi_gyro_id[] = {
+	{ SENSOR_NAME, 0 },
+	{ }
+};
+
+MODULE_DEVICE_TABLE(i2c, smi_gyro_id);
+static const struct of_device_id smi130_gyro_of_match[] = {
+	{ .compatible = "smi130_gyro", },
+	{ }
+};
+MODULE_DEVICE_TABLE(i2c, smi130_gyro_of_match);
+
+static struct i2c_driver smi_gyro_driver = {
+	.driver = {
+		.owner = THIS_MODULE,
+		.name = SENSOR_NAME,
+		.of_match_table = smi130_gyro_of_match,
+	},
+	.class = I2C_CLASS_HWMON,
+	.id_table = smi_gyro_id,
+	.probe = smi_gyro_probe,
+	.remove = smi_gyro_remove,
+	.shutdown = smi_gyro_shutdown,
+#ifndef CONFIG_HAS_EARLYSUSPEND
+	//.suspend = smi_gyro_suspend,
+	//.resume = smi_gyro_resume,
+#endif
+};
+
+static int __init SMI_GYRO_init(void)
+{
+	return i2c_add_driver(&smi_gyro_driver);
+}
+
+static void __exit SMI_GYRO_exit(void)
+{
+	i2c_del_driver(&smi_gyro_driver);
+}
+
+MODULE_AUTHOR("contact@bosch-sensortec.com>");
+MODULE_DESCRIPTION("SMI_GYRO GYROSCOPE SENSOR DRIVER");
+MODULE_LICENSE("GPL v2");
+
+module_init(SMI_GYRO_init);
+module_exit(SMI_GYRO_exit);
diff --git a/drivers/input/sensors/smi130/smi130_i2c.c b/drivers/input/sensors/smi130/smi130_i2c.c
new file mode 100644
index 0000000..09c4d29
--- /dev/null
+++ b/drivers/input/sensors/smi130/smi130_i2c.c
@@ -0,0 +1,472 @@
+/*!
+ * @section LICENSE
+ * (C) Copyright 2011~2016 Bosch Sensortec GmbH All Rights Reserved
+ *
+ * (C) Modification Copyright 2018 Robert Bosch Kft  All Rights Reserved
+ *
+ * This software program is licensed subject to the GNU General
+ * Public License (GPL).Version 2,June 1991,
+ * available at http://www.fsf.org/copyleft/gpl.html
+ *
+ * Special: Description of the Software:
+ *
+ * This software module (hereinafter called "Software") and any
+ * information on application-sheets (hereinafter called "Information") is
+ * provided free of charge for the sole purpose to support your application
+ * work. 
+ *
+ * As such, the Software is merely an experimental software, not tested for
+ * safety in the field and only intended for inspiration for further development 
+ * and testing. Any usage in a safety-relevant field of use (like automotive,
+ * seafaring, spacefaring, industrial plants etc.) was not intended, so there are
+ * no precautions for such usage incorporated in the Software.
+ * 
+ * The Software is specifically designed for the exclusive use for Bosch
+ * Sensortec products by personnel who have special experience and training. Do
+ * not use this Software if you do not have the proper experience or training.
+ * 
+ * This Software package is provided as is and without any expressed or
+ * implied warranties, including without limitation, the implied warranties of
+ * merchantability and fitness for a particular purpose.
+ * 
+ * Bosch Sensortec and their representatives and agents deny any liability for
+ * the functional impairment of this Software in terms of fitness, performance
+ * and safety. Bosch Sensortec and their representatives and agents shall not be
+ * liable for any direct or indirect damages or injury, except as otherwise
+ * stipulated in mandatory applicable law.
+ * The Information provided is believed to be accurate and reliable. Bosch
+ * Sensortec assumes no responsibility for the consequences of use of such
+ * Information nor for any infringement of patents or other rights of third
+ * parties which may result from its use.
+ * 
+ *------------------------------------------------------------------------------
+ * The following Product Disclaimer does not apply to the BSX4-HAL-4.1NoFusion Software 
+ * which is licensed under the Apache License, Version 2.0 as stated above.  
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Product Disclaimer
+ *
+ * Common:
+ *
+ * Assessment of Products Returned from Field
+ *
+ * Returned products are considered good if they fulfill the specifications / 
+ * test data for 0-mileage and field listed in this document.
+ *
+ * Engineering Samples
+ * 
+ * Engineering samples are marked with (e) or (E). Samples may vary from the
+ * valid technical specifications of the series product contained in this
+ * data sheet. Therefore, they are not intended or fit for resale to
+ * third parties or for use in end products. Their sole purpose is internal
+ * client testing. The testing of an engineering sample may in no way replace
+ * the testing of a series product. Bosch assumes no liability for the use
+ * of engineering samples. The purchaser shall indemnify Bosch from all claims
+ * arising from the use of engineering samples.
+ *
+ * Intended use
+ *
+ * Provided that SMI130 is used within the conditions (environment, application,
+ * installation, loads) as described in this TCD and the corresponding
+ * agreed upon documents, Bosch ensures that the product complies with
+ * the agreed properties. Agreements beyond this require
+ * the written approval by Bosch. The product is considered fit for the intended
+ * use when the product successfully has passed the tests
+ * in accordance with the TCD and agreed upon documents.
+ *
+ * It is the responsibility of the customer to ensure the proper application
+ * of the product in the overall system/vehicle.
+ *
+ * Bosch does not assume any responsibility for changes to the environment
+ * of the product that deviate from the TCD and the agreed upon documents 
+ * as well as all applications not released by Bosch
+  *
+ * The resale and/or use of products are at the purchaser’s own risk and 
+ * responsibility. The examination and testing of the SMI130 
+ * is the sole responsibility of the purchaser.
+ *
+ * The purchaser shall indemnify Bosch from all third party claims 
+ * arising from any product use not covered by the parameters of 
+ * this product data sheet or not approved by Bosch and reimburse Bosch 
+ * for all costs and damages in connection with such claims.
+ *
+ * The purchaser must monitor the market for the purchased products,
+ * particularly with regard to product safety, and inform Bosch without delay
+ * of all security relevant incidents.
+ *
+ * Application Examples and Hints
+ *
+ * With respect to any application examples, advice, normal values
+ * and/or any information regarding the application of the device,
+ * Bosch hereby disclaims any and all warranties and liabilities of any kind,
+ * including without limitation warranties of
+ * non-infringement of intellectual property rights or copyrights
+ * of any third party.
+ * The information given in this document shall in no event be regarded 
+ * as a guarantee of conditions or characteristics. They are provided
+ * for illustrative purposes only and no evaluation regarding infringement
+ * of intellectual property rights or copyrights or regarding functionality,
+ * performance or error has been made.
+ *
+ * @filename smi130_i2c.c
+ * @date     2014/11/25 14:40
+ * @Modification Date 2018/08/28 18:20
+ * @id       "20f77db"
+ * @version  1.3
+ *
+ * @brief
+ * This file implements moudle function, which add
+ * the driver to I2C core.
+*/
+
+#include <linux/module.h>
+#include <linux/i2c.h>
+#include <linux/delay.h>
+#include "smi130_driver.h"
+
+/*! @defgroup smi130_i2c_src
+ *  @brief smi130 i2c driver module
+ @{*/
+
+static struct i2c_client *smi_client;
+/*!
+ * @brief define i2c wirte function
+ *
+ * @param client the pointer of i2c client
+ * @param reg_addr register address
+ * @param data the pointer of data buffer
+ * @param len block size need to write
+ *
+ * @return zero success, non-zero failed
+ * @retval zero success
+ * @retval non-zero failed
+*/
+/*	i2c read routine for API*/
+static s8 smi_i2c_read(struct i2c_client *client, u8 reg_addr,
+			u8 *data, u8 len)
+	{
+#if !defined SMI_USE_BASIC_I2C_FUNC
+		s32 dummy;
+		if (NULL == client)
+			return -EINVAL;
+
+		while (0 != len--) {
+#ifdef SMI_SMBUS
+			dummy = i2c_smbus_read_byte_data(client, reg_addr);
+			if (dummy < 0) {
+				dev_err(&client->dev, "i2c smbus read error");
+				return -EIO;
+			}
+			*data = (u8)(dummy & 0xff);
+#else
+			dummy = i2c_master_send(client, (char *)&reg_addr, 1);
+			if (dummy < 0) {
+				dev_err(&client->dev, "i2c bus master write error");
+				return -EIO;
+			}
+
+			dummy = i2c_master_recv(client, (char *)data, 1);
+			if (dummy < 0) {
+				dev_err(&client->dev, "i2c bus master read error");
+				return -EIO;
+			}
+#endif
+			reg_addr++;
+			data++;
+		}
+		return 0;
+#else
+		int retry;
+
+		struct i2c_msg msg[] = {
+			{
+			 .addr = client->addr,
+			 .flags = 0,
+			 .len = 1,
+			 .buf = &reg_addr,
+			},
+
+			{
+			 .addr = client->addr,
+			 .flags = I2C_M_RD,
+			 .len = len,
+			 .buf = data,
+			 },
+		};
+
+		for (retry = 0; retry < SMI_MAX_RETRY_I2C_XFER; retry++) {
+			if (i2c_transfer(client->adapter, msg,
+						ARRAY_SIZE(msg)) > 0)
+				break;
+			else
+				usleep_range(SMI_I2C_WRITE_DELAY_TIME * 1000,
+				SMI_I2C_WRITE_DELAY_TIME * 1000);
+		}
+
+		if (SMI_MAX_RETRY_I2C_XFER <= retry) {
+			dev_err(&client->dev, "I2C xfer error");
+			return -EIO;
+		}
+
+		return 0;
+#endif
+	}
+
+
+static s8 smi_i2c_burst_read(struct i2c_client *client, u8 reg_addr,
+		u8 *data, u16 len)
+{
+	int retry;
+
+	struct i2c_msg msg[] = {
+		{
+			.addr = client->addr,
+			.flags = 0,
+			.len = 1,
+			.buf = &reg_addr,
+		},
+
+		{
+			.addr = client->addr,
+			.flags = I2C_M_RD,
+			.len = len,
+			.buf = data,
+		},
+	};
+
+	for (retry = 0; retry < SMI_MAX_RETRY_I2C_XFER; retry++) {
+		if (i2c_transfer(client->adapter, msg, ARRAY_SIZE(msg)) > 0)
+			break;
+		else
+			usleep_range(SMI_I2C_WRITE_DELAY_TIME * 1000,
+				SMI_I2C_WRITE_DELAY_TIME * 1000);
+	}
+
+	if (SMI_MAX_RETRY_I2C_XFER <= retry) {
+		dev_err(&client->dev, "I2C xfer error");
+		return -EIO;
+	}
+
+	return 0;
+}
+
+
+/* i2c write routine for */
+static s8 smi_i2c_write(struct i2c_client *client, u8 reg_addr,
+		u8 *data, u8 len)
+{
+#if !defined SMI_USE_BASIC_I2C_FUNC
+	s32 dummy;
+
+#ifndef SMI_SMBUS
+	u8 buffer[2];
+#endif
+
+	if (NULL == client)
+		return -EPERM;
+
+	while (0 != len--) {
+#ifdef SMI_SMBUS
+		dummy = i2c_smbus_write_byte_data(client, reg_addr, *data);
+#else
+		buffer[0] = reg_addr;
+		buffer[1] = *data;
+		dummy = i2c_master_send(client, (char *)buffer, 2);
+#endif
+		reg_addr++;
+		data++;
+		if (dummy < 0) {
+			dev_err(&client->dev, "error writing i2c bus");
+			return -EPERM;
+		}
+
+	}
+	usleep_range(SMI_I2C_WRITE_DELAY_TIME * 1000,
+	SMI_I2C_WRITE_DELAY_TIME * 1000);
+	return 0;
+#else
+	u8 buffer[2];
+	int retry;
+	struct i2c_msg msg[] = {
+		{
+		 .addr = client->addr,
+		 .flags = 0,
+		 .len = 2,
+		 .buf = buffer,
+		 },
+	};
+
+	while (0 != len--) {
+		buffer[0] = reg_addr;
+		buffer[1] = *data;
+		for (retry = 0; retry < SMI_MAX_RETRY_I2C_XFER; retry++) {
+			if (i2c_transfer(client->adapter, msg,
+						ARRAY_SIZE(msg)) > 0) {
+				break;
+			} else {
+				usleep_range(SMI_I2C_WRITE_DELAY_TIME * 1000,
+				SMI_I2C_WRITE_DELAY_TIME * 1000);
+			}
+		}
+		if (SMI_MAX_RETRY_I2C_XFER <= retry) {
+			dev_err(&client->dev, "I2C xfer error");
+			return -EIO;
+		}
+		reg_addr++;
+		data++;
+	}
+
+	usleep_range(SMI_I2C_WRITE_DELAY_TIME * 1000,
+	SMI_I2C_WRITE_DELAY_TIME * 1000);
+	return 0;
+#endif
+}
+
+
+static s8 smi_i2c_read_wrapper(u8 dev_addr, u8 reg_addr, u8 *data, u8 len)
+{
+	int err = 0;
+	err = smi_i2c_read(smi_client, reg_addr, data, len);
+	return err;
+}
+
+static s8 smi_i2c_write_wrapper(u8 dev_addr, u8 reg_addr, u8 *data, u8 len)
+{
+	int err = 0;
+	err = smi_i2c_write(smi_client, reg_addr, data, len);
+	return err;
+}
+
+s8 smi_burst_read_wrapper(u8 dev_addr, u8 reg_addr, u8 *data, u16 len)
+{
+	int err = 0;
+	err = smi_i2c_burst_read(smi_client, reg_addr, data, len);
+	return err;
+}
+EXPORT_SYMBOL(smi_burst_read_wrapper);
+/*!
+ * @brief SMI probe function via i2c bus
+ *
+ * @param client the pointer of i2c client
+ * @param id the pointer of i2c device id
+ *
+ * @return zero success, non-zero failed
+ * @retval zero success
+ * @retval non-zero failed
+*/
+static int smi_i2c_probe(struct i2c_client *client,
+		const struct i2c_device_id *id)
+{
+		int err = 0;
+		struct smi_client_data *client_data = NULL;
+
+		dev_info(&client->dev, "SMI130 i2c function probe entrance");
+
+		if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
+			dev_err(&client->dev, "i2c_check_functionality error!");
+			err = -EIO;
+			goto exit_err_clean;
+		}
+
+		if (NULL == smi_client) {
+			smi_client = client;
+		} else {
+			dev_err(&client->dev,
+				"this driver does not support multiple clients");
+			err = -EBUSY;
+			goto exit_err_clean;
+		}
+
+		client_data = kzalloc(sizeof(struct smi_client_data),
+							GFP_KERNEL);
+		if (NULL == client_data) {
+			dev_err(&client->dev, "no memory available");
+			err = -ENOMEM;
+			goto exit_err_clean;
+		}
+
+		client_data->device.bus_read = smi_i2c_read_wrapper;
+		client_data->device.bus_write = smi_i2c_write_wrapper;
+
+		return smi_probe(client_data, &client->dev);
+
+exit_err_clean:
+		if (err)
+			smi_client = NULL;
+		return err;
+}
+/*
+static int smi_i2c_suspend(struct i2c_client *client, pm_message_t mesg)
+{
+	int err = 0;
+	err = smi_suspend(&client->dev);
+	return err;
+}
+
+static int smi_i2c_resume(struct i2c_client *client)
+{
+	int err = 0;
+
+	err = smi_resume(&client->dev);
+
+	return err;
+}
+*/
+
+static int smi_i2c_remove(struct i2c_client *client)
+{
+	int err = 0;
+	err = smi_remove(&client->dev);
+	smi_client = NULL;
+
+	return err;
+}
+
+
+
+static const struct i2c_device_id smi_id[] = {
+	{SENSOR_NAME, 0},
+	{}
+};
+
+MODULE_DEVICE_TABLE(i2c, smi_id);
+
+static const struct of_device_id smi130_of_match[] = {
+	{ .compatible = "bosch-sensortec,smi130", },
+	{ .compatible = "smi130", },
+	{ .compatible = "bosch, smi130", },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, smi130_of_match);
+
+static struct i2c_driver smi_i2c_driver = {
+	.driver = {
+		.owner = THIS_MODULE,
+		.name = SENSOR_NAME,
+		.of_match_table = smi130_of_match,
+	},
+	.class = I2C_CLASS_HWMON,
+	.id_table = smi_id,
+	.probe = smi_i2c_probe,
+	.remove = smi_i2c_remove,
+	/*.suspend = smi_i2c_suspend,
+	.resume = smi_i2c_resume,*/
+};
+
+static int __init SMI_i2c_init(void)
+{
+	return i2c_add_driver(&smi_i2c_driver);
+}
+
+static void __exit SMI_i2c_exit(void)
+{
+	i2c_del_driver(&smi_i2c_driver);
+}
+
+MODULE_AUTHOR("Contact <contact@bosch-sensortec.com>");
+MODULE_DESCRIPTION("driver for " SENSOR_NAME);
+MODULE_LICENSE("GPL v2");
+
+module_init(SMI_i2c_init);
+module_exit(SMI_i2c_exit);
+
diff --git a/drivers/input/sensors/smi130/smi130_spi.c b/drivers/input/sensors/smi130/smi130_spi.c
new file mode 100644
index 0000000..b02efbf1
--- /dev/null
+++ b/drivers/input/sensors/smi130/smi130_spi.c
@@ -0,0 +1,402 @@
+/*!
+ * @section LICENSE
+ * (C) Copyright 2011~2016 Bosch Sensortec GmbH All Rights Reserved
+ *
+ * (C) Modification Copyright 2018 Robert Bosch Kft  All Rights Reserved
+ *
+ * This software program is licensed subject to the GNU General
+ * Public License (GPL).Version 2,June 1991,
+ * available at http://www.fsf.org/copyleft/gpl.html
+ *
+ * Special: Description of the Software:
+ *
+ * This software module (hereinafter called "Software") and any
+ * information on application-sheets (hereinafter called "Information") is
+ * provided free of charge for the sole purpose to support your application
+ * work. 
+ *
+ * As such, the Software is merely an experimental software, not tested for
+ * safety in the field and only intended for inspiration for further development 
+ * and testing. Any usage in a safety-relevant field of use (like automotive,
+ * seafaring, spacefaring, industrial plants etc.) was not intended, so there are
+ * no precautions for such usage incorporated in the Software.
+ * 
+ * The Software is specifically designed for the exclusive use for Bosch
+ * Sensortec products by personnel who have special experience and training. Do
+ * not use this Software if you do not have the proper experience or training.
+ * 
+ * This Software package is provided as is and without any expressed or
+ * implied warranties, including without limitation, the implied warranties of
+ * merchantability and fitness for a particular purpose.
+ * 
+ * Bosch Sensortec and their representatives and agents deny any liability for
+ * the functional impairment of this Software in terms of fitness, performance
+ * and safety. Bosch Sensortec and their representatives and agents shall not be
+ * liable for any direct or indirect damages or injury, except as otherwise
+ * stipulated in mandatory applicable law.
+ * The Information provided is believed to be accurate and reliable. Bosch
+ * Sensortec assumes no responsibility for the consequences of use of such
+ * Information nor for any infringement of patents or other rights of third
+ * parties which may result from its use.
+ * 
+ *------------------------------------------------------------------------------
+ * The following Product Disclaimer does not apply to the BSX4-HAL-4.1NoFusion Software 
+ * which is licensed under the Apache License, Version 2.0 as stated above.  
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Product Disclaimer
+ *
+ * Common:
+ *
+ * Assessment of Products Returned from Field
+ *
+ * Returned products are considered good if they fulfill the specifications / 
+ * test data for 0-mileage and field listed in this document.
+ *
+ * Engineering Samples
+ * 
+ * Engineering samples are marked with (e) or (E). Samples may vary from the
+ * valid technical specifications of the series product contained in this
+ * data sheet. Therefore, they are not intended or fit for resale to
+ * third parties or for use in end products. Their sole purpose is internal
+ * client testing. The testing of an engineering sample may in no way replace
+ * the testing of a series product. Bosch assumes no liability for the use
+ * of engineering samples. The purchaser shall indemnify Bosch from all claims
+ * arising from the use of engineering samples.
+ *
+ * Intended use
+ *
+ * Provided that SMI130 is used within the conditions (environment, application,
+ * installation, loads) as described in this TCD and the corresponding
+ * agreed upon documents, Bosch ensures that the product complies with
+ * the agreed properties. Agreements beyond this require
+ * the written approval by Bosch. The product is considered fit for the intended
+ * use when the product successfully has passed the tests
+ * in accordance with the TCD and agreed upon documents.
+ *
+ * It is the responsibility of the customer to ensure the proper application
+ * of the product in the overall system/vehicle.
+ *
+ * Bosch does not assume any responsibility for changes to the environment
+ * of the product that deviate from the TCD and the agreed upon documents 
+ * as well as all applications not released by Bosch
+  *
+ * The resale and/or use of products are at the purchaser’s own risk and 
+ * responsibility. The examination and testing of the SMI130 
+ * is the sole responsibility of the purchaser.
+ *
+ * The purchaser shall indemnify Bosch from all third party claims 
+ * arising from any product use not covered by the parameters of 
+ * this product data sheet or not approved by Bosch and reimburse Bosch 
+ * for all costs and damages in connection with such claims.
+ *
+ * The purchaser must monitor the market for the purchased products,
+ * particularly with regard to product safety, and inform Bosch without delay
+ * of all security relevant incidents.
+ *
+ * Application Examples and Hints
+ *
+ * With respect to any application examples, advice, normal values
+ * and/or any information regarding the application of the device,
+ * Bosch hereby disclaims any and all warranties and liabilities of any kind,
+ * including without limitation warranties of
+ * non-infringement of intellectual property rights or copyrights
+ * of any third party.
+ * The information given in this document shall in no event be regarded 
+ * as a guarantee of conditions or characteristics. They are provided
+ * for illustrative purposes only and no evaluation regarding infringement
+ * of intellectual property rights or copyrights or regarding functionality,
+ * performance or error has been made.
+ *
+ * @filename smi130_spi.c
+ * @date     2014/11/25 14:40
+ * @Modification Date 2018/08/28 18:20
+ * @id       "20f77db"
+ * @version  1.3
+ *
+ * @brief
+ * This file implements moudle function, which add
+ * the driver to SPI core.
+*/
+
+#include <linux/module.h>
+#include <linux/spi/spi.h>
+#include <linux/delay.h>
+#include "smi130_driver.h"
+
+/*! @defgroup smi130_spi_src
+ *  @brief smi130 spi driver module
+ @{*/
+/*! the maximum of transfer buffer size */
+#define SMI_MAX_BUFFER_SIZE      32
+
+static struct spi_device *smi_spi_client;
+
+/*!
+ * @brief define spi wirte function
+ *
+ * @param dev_addr sensor device address
+ * @param reg_addr register address
+ * @param data the pointer of data buffer
+ * @param len block size need to write
+ *
+ * @return zero success, non-zero failed
+ * @retval zero success
+ * @retval non-zero failed
+*/
+static char smi_spi_write_block(u8 dev_addr, u8 reg_addr, u8 *data, u8 len)
+{
+	struct spi_device *client = smi_spi_client;
+	u8 buffer[SMI_MAX_BUFFER_SIZE + 1];
+	struct spi_transfer xfer = {
+		.tx_buf     = buffer,
+		.len        = len + 1,
+	};
+	struct spi_message msg;
+
+	if (len > SMI_MAX_BUFFER_SIZE)
+		return -EINVAL;
+
+	buffer[0] = reg_addr&0x7F;/* write: MSB = 0 */
+	memcpy(&buffer[1], data, len);
+
+	spi_message_init(&msg);
+	spi_message_add_tail(&xfer, &msg);
+	return spi_sync(client, &msg);
+}
+
+/*!
+ * @brief define spi read function
+ *
+ * @param dev_addr sensor device address
+ * @param reg_addr register address
+ * @param data the pointer of data buffer
+ * @param len block size need to read
+ *
+ * @return zero success, non-zero failed
+ * @retval zero success
+ * @retval non-zero failed
+*/
+static char smi_spi_read_block(u8 dev_addr, u8 reg_addr, u8 *data, u8 len)
+{
+	struct spi_device *client = smi_spi_client;
+	u8 reg = reg_addr | 0x80;/* read: MSB = 1 */
+	struct spi_transfer xfer[2] = {
+		[0] = {
+			.tx_buf = &reg,
+			.len = 1,
+		},
+		[1] = {
+			.rx_buf = data,
+			.len = len,
+		}
+	};
+	struct spi_message msg;
+
+	spi_message_init(&msg);
+	spi_message_add_tail(&xfer[0], &msg);
+	spi_message_add_tail(&xfer[1], &msg);
+	return spi_sync(client, &msg);
+}
+
+s8 smi_burst_read_wrapper(u8 dev_addr, u8 reg_addr, u8 *data, u16 len)
+{
+	struct spi_device *client = smi_spi_client;
+	u8 reg = reg_addr | 0x80;/* read: MSB = 1 */
+	struct spi_transfer xfer[2] = {
+		[0] = {
+			.tx_buf = &reg,
+			.len = 1,
+		},
+		[1] = {
+			.rx_buf = data,
+			.len = len,
+		}
+	};
+	struct spi_message msg;
+
+	spi_message_init(&msg);
+	spi_message_add_tail(&xfer[0], &msg);
+	spi_message_add_tail(&xfer[1], &msg);
+	return spi_sync(client, &msg);
+}
+EXPORT_SYMBOL(smi_burst_read_wrapper);
+/*!
+ * @brief SMI probe function via spi bus
+ *
+ * @param client the pointer of spi client
+ *
+ * @return zero success, non-zero failed
+ * @retval zero success
+ * @retval non-zero failed
+*/
+static int smi_spi_probe(struct spi_device *client)
+{
+	int status;
+	int err = 0;
+	struct smi_client_data *client_data = NULL;
+
+	if (NULL == smi_spi_client)
+		smi_spi_client = client;
+	else{
+		dev_err(&client->dev, "This driver does not support multiple clients!\n");
+		return -EBUSY;
+	}
+
+	client->bits_per_word = 8;
+	status = spi_setup(client);
+	if (status < 0) {
+		dev_err(&client->dev, "spi_setup failed!\n");
+		return status;
+	}
+
+	client_data = kzalloc(sizeof(struct smi_client_data), GFP_KERNEL);
+	if (NULL == client_data) {
+		dev_err(&client->dev, "no memory available");
+		err = -ENOMEM;
+		goto exit_err_clean;
+	}
+
+	client_data->device.bus_read = smi_spi_read_block;
+	client_data->device.bus_write = smi_spi_write_block;
+
+	return smi_probe(client_data, &client->dev);
+
+exit_err_clean:
+	if (err)
+		smi_spi_client = NULL;
+	return err;
+}
+
+/*!
+ * @brief shutdown smi device in spi driver
+ *
+ * @param client the pointer of spi client
+ *
+ * @return no return value
+*/
+static void smi_spi_shutdown(struct spi_device *client)
+{
+#ifdef CONFIG_PM
+	smi_suspend(&client->dev);
+#endif
+}
+
+/*!
+ * @brief remove smi spi client
+ *
+ * @param client the pointer of spi client
+ *
+ * @return zero
+ * @retval zero
+*/
+static int smi_spi_remove(struct spi_device *client)
+{
+	int err = 0;
+	err = smi_remove(&client->dev);
+	smi_spi_client = NULL;
+
+	return err;
+}
+
+#ifdef CONFIG_PM
+/*!
+ * @brief suspend smi device in spi driver
+ *
+ * @param dev the pointer of device
+ *
+ * @return zero
+ * @retval zero
+*/
+static int smi_spi_suspend(struct device *dev)
+{
+	int err = 0;
+	err = smi_suspend(dev);
+	return err;
+}
+
+/*!
+ * @brief resume smi device in spi driver
+ *
+ * @param dev the pointer of device
+ *
+ * @return zero
+ * @retval zero
+*/
+static int smi_spi_resume(struct device *dev)
+{
+	int err = 0;
+	/* post resume operation */
+	err = smi_resume(dev);
+
+	return err;
+}
+
+/*!
+ * @brief register spi device power manager hooks
+*/
+static const struct dev_pm_ops smi_spi_pm_ops = {
+	/**< device suspend */
+	.suspend = smi_spi_suspend,
+	/**< device resume */
+	.resume  = smi_spi_resume
+};
+#endif
+
+/*!
+ * @brief register spi device id
+*/
+static const struct spi_device_id smi_id[] = {
+	{ SENSOR_NAME, 0 },
+	{ }
+};
+MODULE_DEVICE_TABLE(spi, smi_id);
+
+/*!
+ * @brief register spi driver hooks
+*/
+static struct spi_driver smi_spi_driver = {
+	.driver = {
+		.owner = THIS_MODULE,
+		.name  = SENSOR_NAME,
+#ifdef CONFIG_PM
+		.pm = &smi_spi_pm_ops,
+#endif
+	},
+	.id_table = smi_id,
+	.probe    = smi_spi_probe,
+	.shutdown = smi_spi_shutdown,
+	.remove   = smi_spi_remove
+};
+
+/*!
+ * @brief initialize smi spi module
+ *
+ * @return zero success, non-zero failed
+ * @retval zero success
+ * @retval non-zero failed
+*/
+static int __init smi_spi_init(void)
+{
+	return spi_register_driver(&smi_spi_driver);
+}
+
+/*!
+ * @brief remove smi spi module
+ *
+ * @return no return value
+*/
+static void __exit smi_spi_exit(void)
+{
+	spi_unregister_driver(&smi_spi_driver);
+}
+
+
+MODULE_AUTHOR("Contact <contact@bosch-sensortec.com>");
+MODULE_DESCRIPTION("SMI130 SPI DRIVER");
+MODULE_LICENSE("GPL v2");
+
+module_init(smi_spi_init);
+module_exit(smi_spi_exit);
+/*@}*/
+
diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig
index 20c70c0..bb1935f 100644
--- a/drivers/md/Kconfig
+++ b/drivers/md/Kconfig
@@ -292,6 +292,22 @@
 	  To compile this code as a module, choose M here: the module will
 	  be called dm-req-crypt.
 
+config DM_DEFAULT_KEY
+	tristate "Default-key crypt target support"
+	depends on BLK_DEV_DM
+	depends on PFK
+	---help---
+	  This (currently Android-specific) device-mapper target allows you to
+	  create a device that assigns a default encryption key to bios that
+	  don't already have one.  This can sit between inline cryptographic
+	  acceleration hardware and filesystems that use it.  This ensures that
+	  where the filesystem doesn't explicitly specify a key, such as for
+	  filesystem metadata, a default key will be used instead, leaving no
+	  sectors unencrypted.
+
+	  To compile this code as a module, choose M here: the module will be
+	  called dm-default-key.
+
 	  If unsure, say N.
 
 config DM_SNAPSHOT
diff --git a/drivers/md/Makefile b/drivers/md/Makefile
index f14e2fc..c3bf33b 100644
--- a/drivers/md/Makefile
+++ b/drivers/md/Makefile
@@ -40,6 +40,7 @@
 obj-$(CONFIG_DM_BUFIO)		+= dm-bufio.o
 obj-$(CONFIG_DM_BIO_PRISON)	+= dm-bio-prison.o
 obj-$(CONFIG_DM_CRYPT)		+= dm-crypt.o
+obj-$(CONFIG_DM_DEFAULT_KEY)	+= dm-default-key.o
 obj-$(CONFIG_DM_DELAY)		+= dm-delay.o
 obj-$(CONFIG_DM_FLAKEY)		+= dm-flakey.o
 obj-$(CONFIG_DM_MULTIPATH)	+= dm-multipath.o dm-round-robin.o
diff --git a/drivers/md/dm-default-key.c b/drivers/md/dm-default-key.c
new file mode 100644
index 0000000..ca50de1
--- /dev/null
+++ b/drivers/md/dm-default-key.c
@@ -0,0 +1,224 @@
+/*
+ * Copyright (C) 2017 Google, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/device-mapper.h>
+#include <linux/module.h>
+#include <linux/pfk.h>
+
+#define DM_MSG_PREFIX "default-key"
+
+struct default_key_c {
+	struct dm_dev *dev;
+	sector_t start;
+	struct blk_encryption_key key;
+};
+
+static void default_key_dtr(struct dm_target *ti)
+{
+	struct default_key_c *dkc = ti->private;
+
+	if (dkc->dev)
+		dm_put_device(ti, dkc->dev);
+	kzfree(dkc);
+}
+
+/*
+ * Construct a default-key mapping: <mode> <key> <dev_path> <start>
+ */
+static int default_key_ctr(struct dm_target *ti, unsigned int argc, char **argv)
+{
+	struct default_key_c *dkc;
+	size_t key_size;
+	unsigned long long tmp;
+	char dummy;
+	int err;
+
+	if (argc != 4) {
+		ti->error = "Invalid argument count";
+		return -EINVAL;
+	}
+
+	dkc = kzalloc(sizeof(*dkc), GFP_KERNEL);
+	if (!dkc) {
+		ti->error = "Out of memory";
+		return -ENOMEM;
+	}
+	ti->private = dkc;
+
+	if (strcmp(argv[0], "AES-256-XTS") != 0) {
+		ti->error = "Unsupported encryption mode";
+		err = -EINVAL;
+		goto bad;
+	}
+
+	key_size = strlen(argv[1]);
+	if (key_size != 2 * BLK_ENCRYPTION_KEY_SIZE_AES_256_XTS) {
+		ti->error = "Unsupported key size";
+		err = -EINVAL;
+		goto bad;
+	}
+	key_size /= 2;
+
+	if (hex2bin(dkc->key.raw, argv[1], key_size) != 0) {
+		ti->error = "Malformed key string";
+		err = -EINVAL;
+		goto bad;
+	}
+
+	err = dm_get_device(ti, argv[2], dm_table_get_mode(ti->table),
+			    &dkc->dev);
+	if (err) {
+		ti->error = "Device lookup failed";
+		goto bad;
+	}
+
+	if (sscanf(argv[3], "%llu%c", &tmp, &dummy) != 1) {
+		ti->error = "Invalid start sector";
+		err = -EINVAL;
+		goto bad;
+	}
+	dkc->start = tmp;
+
+	if (!blk_queue_inlinecrypt(bdev_get_queue(dkc->dev->bdev))) {
+		ti->error = "Device does not support inline encryption";
+		err = -EINVAL;
+		goto bad;
+	}
+
+	/* Pass flush requests through to the underlying device. */
+	ti->num_flush_bios = 1;
+
+	/*
+	 * We pass discard requests through to the underlying device, although
+	 * the discarded blocks will be zeroed, which leaks information about
+	 * unused blocks.  It's also impossible for dm-default-key to know not
+	 * to decrypt discarded blocks, so they will not be read back as zeroes
+	 * and we must set discard_zeroes_data_unsupported.
+	 */
+	ti->num_discard_bios = 1;
+
+	/*
+	 * It's unclear whether WRITE_SAME would work with inline encryption; it
+	 * would depend on whether the hardware duplicates the data before or
+	 * after encryption.  But since the internal storage in some  devices
+	 * (MSM8998-based) doesn't claim to support WRITE_SAME anyway, we don't
+	 * currently have a way to test it.  Leave it disabled it for now.
+	 */
+	/*ti->num_write_same_bios = 1;*/
+
+	return 0;
+
+bad:
+	default_key_dtr(ti);
+	return err;
+}
+
+static int default_key_map(struct dm_target *ti, struct bio *bio)
+{
+	const struct default_key_c *dkc = ti->private;
+
+	bio->bi_bdev = dkc->dev->bdev;
+	if (bio_sectors(bio)) {
+		bio->bi_iter.bi_sector = dkc->start +
+			dm_target_offset(ti, bio->bi_iter.bi_sector);
+	}
+
+	if (!bio->bi_crypt_key && !bio->bi_crypt_skip)
+		bio->bi_crypt_key = &dkc->key;
+
+	return DM_MAPIO_REMAPPED;
+}
+
+static void default_key_status(struct dm_target *ti, status_type_t type,
+			       unsigned int status_flags, char *result,
+			       unsigned int maxlen)
+{
+	const struct default_key_c *dkc = ti->private;
+	unsigned int sz = 0;
+
+	switch (type) {
+	case STATUSTYPE_INFO:
+		result[0] = '\0';
+		break;
+
+	case STATUSTYPE_TABLE:
+
+		/* encryption mode */
+		DMEMIT("AES-256-XTS");
+
+		/* reserved for key; dm-crypt shows it, but we don't for now */
+		DMEMIT(" -");
+
+		/* name of underlying device, and the start sector in it */
+		DMEMIT(" %s %llu", dkc->dev->name,
+		       (unsigned long long)dkc->start);
+		break;
+	}
+}
+
+static int default_key_prepare_ioctl(struct dm_target *ti,
+				     struct block_device **bdev, fmode_t *mode)
+{
+	struct default_key_c *dkc = ti->private;
+	struct dm_dev *dev = dkc->dev;
+
+	*bdev = dev->bdev;
+
+	/*
+	 * Only pass ioctls through if the device sizes match exactly.
+	 */
+	if (dkc->start ||
+	    ti->len != i_size_read(dev->bdev->bd_inode) >> SECTOR_SHIFT)
+		return 1;
+	return 0;
+}
+
+static int default_key_iterate_devices(struct dm_target *ti,
+				       iterate_devices_callout_fn fn,
+				       void *data)
+{
+	struct default_key_c *dkc = ti->private;
+
+	return fn(ti, dkc->dev, dkc->start, ti->len, data);
+}
+
+static struct target_type default_key_target = {
+	.name   = "default-key",
+	.version = {1, 0, 0},
+	.module = THIS_MODULE,
+	.ctr    = default_key_ctr,
+	.dtr    = default_key_dtr,
+	.map    = default_key_map,
+	.status = default_key_status,
+	.prepare_ioctl = default_key_prepare_ioctl,
+	.iterate_devices = default_key_iterate_devices,
+};
+
+static int __init dm_default_key_init(void)
+{
+	return dm_register_target(&default_key_target);
+}
+
+static void __exit dm_default_key_exit(void)
+{
+	dm_unregister_target(&default_key_target);
+}
+
+module_init(dm_default_key_init);
+module_exit(dm_default_key_exit);
+
+MODULE_AUTHOR("Paul Lawrence <paullawrence@google.com>");
+MODULE_AUTHOR("Paul Crowley <paulcrowley@google.com>");
+MODULE_AUTHOR("Eric Biggers <ebiggers@google.com>");
+MODULE_DESCRIPTION(DM_NAME " target for encrypting filesystem metadata");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 2763adf..6b7b4dd 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -1495,6 +1495,16 @@
 	return q && !test_bit(QUEUE_FLAG_NO_SG_MERGE, &q->queue_flags);
 }
 
+static int queue_supports_inline_encryption(struct dm_target *ti,
+					    struct dm_dev *dev,
+					    sector_t start, sector_t len,
+					    void *data)
+{
+	struct request_queue *q = bdev_get_queue(dev->bdev);
+
+	return q && blk_queue_inlinecrypt(q);
+}
+
 static bool dm_table_all_devices_attribute(struct dm_table *t,
 					   iterate_devices_callout_fn func)
 {
@@ -1615,6 +1625,11 @@
 	else
 		queue_flag_set_unlocked(QUEUE_FLAG_NO_SG_MERGE, q);
 
+	if (dm_table_all_devices_attribute(t, queue_supports_inline_encryption))
+		queue_flag_set_unlocked(QUEUE_FLAG_INLINECRYPT, q);
+	else
+		queue_flag_clear_unlocked(QUEUE_FLAG_INLINECRYPT, q);
+
 	dm_table_verify_integrity(t);
 
 	/*
diff --git a/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_hw_core.c b/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_hw_core.c
index f2796be..4ae2f0a 100644
--- a/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_hw_core.c
+++ b/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_hw_core.c
@@ -624,7 +624,8 @@
 }
 
 static void cam_hw_cdm_iommu_fault_handler(struct iommu_domain *domain,
-	struct device *dev, unsigned long iova, int flags, void *token)
+	struct device *dev, unsigned long iova, int flags, void *token,
+	uint32_t buf_info)
 {
 	struct cam_hw_info *cdm_hw = NULL;
 	struct cam_cdm *core = NULL;
@@ -910,7 +911,7 @@
 		CAM_ERR(CAM_CDM, "cpas-cdm get iommu handle failed");
 		goto unlock_release_mem;
 	}
-	cam_smmu_reg_client_page_fault_handler(cdm_core->iommu_hdl.non_secure,
+	cam_smmu_set_client_page_fault_handler(cdm_core->iommu_hdl.non_secure,
 		cam_hw_cdm_iommu_fault_handler, cdm_hw);
 
 	rc = cam_smmu_ops(cdm_core->iommu_hdl.non_secure, CAM_SMMU_ATTACH);
@@ -1034,7 +1035,7 @@
 	flush_workqueue(cdm_core->work_queue);
 	destroy_workqueue(cdm_core->work_queue);
 destroy_non_secure_hdl:
-	cam_smmu_reg_client_page_fault_handler(cdm_core->iommu_hdl.non_secure,
+	cam_smmu_set_client_page_fault_handler(cdm_core->iommu_hdl.non_secure,
 		NULL, cdm_hw);
 	if (cam_smmu_destroy_handle(cdm_core->iommu_hdl.non_secure))
 		CAM_ERR(CAM_CDM, "Release iommu secure hdl failed");
@@ -1106,8 +1107,8 @@
 
 	if (cam_smmu_destroy_handle(cdm_core->iommu_hdl.non_secure))
 		CAM_ERR(CAM_CDM, "Release iommu secure hdl failed");
-	cam_smmu_reg_client_page_fault_handler(cdm_core->iommu_hdl.non_secure,
-		NULL, cdm_hw);
+	cam_smmu_unset_client_page_fault_handler(
+		cdm_core->iommu_hdl.non_secure, cdm_hw);
 
 	mutex_destroy(&cdm_hw->hw_mutex);
 	kfree(cdm_hw->soc_info.soc_private);
diff --git a/drivers/media/platform/msm/camera/cam_core/cam_context.c b/drivers/media/platform/msm/camera/cam_core/cam_context.c
index da78527..4ed53f9 100644
--- a/drivers/media/platform/msm/camera/cam_core/cam_context.c
+++ b/drivers/media/platform/msm/camera/cam_core/cam_context.c
@@ -42,6 +42,7 @@
 	int rc = 0;
 	int32_t ctx_hdl = ctx->dev_hdl;
 
+	mutex_lock(&ctx->ctx_mutex);
 	if (ctx->state_machine[ctx->state].ioctl_ops.stop_dev) {
 		rc = ctx->state_machine[ctx->state].ioctl_ops.stop_dev(
 			ctx, NULL);
@@ -54,6 +55,7 @@
 		if (rc < 0)
 			CAM_ERR(CAM_CORE, "Error while dev release %d", rc);
 	}
+	mutex_unlock(&ctx->ctx_mutex);
 
 	if (!rc)
 		rc = cam_destroy_device_hdl(ctx_hdl);
@@ -221,6 +223,27 @@
 	return rc;
 }
 
+int cam_context_dump_pf_info(struct cam_context *ctx, unsigned long iova,
+	uint32_t buf_info)
+{
+	int rc = 0;
+
+	if (!ctx->state_machine) {
+		CAM_ERR(CAM_CORE, "Context is not ready");
+		return -EINVAL;
+	}
+
+	if (ctx->state_machine[ctx->state].pagefault_ops) {
+		rc = ctx->state_machine[ctx->state].pagefault_ops(ctx, iova,
+			buf_info);
+	} else {
+		CAM_WARN(CAM_CORE, "No dump ctx in dev %d, state %d",
+			ctx->dev_hdl, ctx->state);
+	}
+
+	return rc;
+}
+
 int cam_context_handle_acquire_dev(struct cam_context *ctx,
 	struct cam_acquire_dev_cmd *cmd)
 {
diff --git a/drivers/media/platform/msm/camera/cam_core/cam_context.h b/drivers/media/platform/msm/camera/cam_core/cam_context.h
index ffceea2..420f9f6 100644
--- a/drivers/media/platform/msm/camera/cam_core/cam_context.h
+++ b/drivers/media/platform/msm/camera/cam_core/cam_context.h
@@ -57,23 +57,25 @@
  * @num_out_acked:         Number of out fence acked
  * @flushed:               Request is flushed
  * @ctx:                   The context to which this request belongs
+ * @pf_data                page fault debug data
  *
  */
 struct cam_ctx_request {
-	struct list_head              list;
-	uint32_t                      status;
-	uint64_t                      request_id;
+	struct list_head               list;
+	uint32_t                       status;
+	uint64_t                       request_id;
 	void                          *req_priv;
-	struct cam_hw_update_entry    hw_update_entries[CAM_CTX_CFG_MAX];
-	uint32_t                      num_hw_update_entries;
-	struct cam_hw_fence_map_entry in_map_entries[CAM_CTX_CFG_MAX];
-	uint32_t                      num_in_map_entries;
-	struct cam_hw_fence_map_entry out_map_entries[CAM_CTX_CFG_MAX];
-	uint32_t                      num_out_map_entries;
-	atomic_t                      num_in_acked;
-	uint32_t                      num_out_acked;
-	int                           flushed;
-	struct cam_context           *ctx;
+	struct cam_hw_update_entry     hw_update_entries[CAM_CTX_CFG_MAX];
+	uint32_t                       num_hw_update_entries;
+	struct cam_hw_fence_map_entry  in_map_entries[CAM_CTX_CFG_MAX];
+	uint32_t                       num_in_map_entries;
+	struct cam_hw_fence_map_entry  out_map_entries[CAM_CTX_CFG_MAX];
+	uint32_t                       num_out_map_entries;
+	atomic_t                       num_in_acked;
+	uint32_t                       num_out_acked;
+	int                            flushed;
+	struct cam_context            *ctx;
+	struct cam_hw_mgr_dump_pf_data pf_data;
 };
 
 /**
@@ -135,12 +137,14 @@
  * @ioctl_ops:             Ioctl funciton table
  * @crm_ops:               CRM to context interface function table
  * @irq_ops:               Hardware event handle function
+ * @pagefault_ops:         Function to be called on page fault
  *
  */
 struct cam_ctx_ops {
 	struct cam_ctx_ioctl_ops     ioctl_ops;
 	struct cam_ctx_crm_ops       crm_ops;
 	cam_hw_event_cb_func         irq_ops;
+	cam_hw_pagefault_cb_func     pagefault_ops;
 };
 
 /**
@@ -292,6 +296,19 @@
 	struct cam_req_mgr_link_evt_data *process_evt);
 
 /**
+ * cam_context_dump_pf_info()
+ *
+ * @brief:        Handle dump active request request command
+ *
+ * @ctx:          Object pointer for cam_context
+ * @iova:         Page fault address
+ * @buf_info:     Information about closest memory handle
+ *
+ */
+int cam_context_dump_pf_info(struct cam_context *ctx, unsigned long iova,
+	uint32_t buf_info);
+
+/**
  * cam_context_handle_acquire_dev()
  *
  * @brief:        Handle acquire device command
diff --git a/drivers/media/platform/msm/camera/cam_core/cam_context_utils.c b/drivers/media/platform/msm/camera/cam_core/cam_context_utils.c
index 6c2383e..d78203a 100644
--- a/drivers/media/platform/msm/camera/cam_core/cam_context_utils.c
+++ b/drivers/media/platform/msm/camera/cam_core/cam_context_utils.c
@@ -337,6 +337,7 @@
 	cfg.out_map_entries = req->out_map_entries;
 	cfg.max_in_map_entries = CAM_CTX_CFG_MAX;
 	cfg.in_map_entries = req->in_map_entries;
+	cfg.pf_data = &(req->pf_data);
 
 	rc = ctx->hw_mgr_intf->hw_prepare_update(
 		ctx->hw_mgr_intf->hw_mgr_priv, &cfg);
@@ -905,3 +906,38 @@
 end:
 	return rc;
 }
+
+int32_t cam_context_dump_pf_info_to_hw(struct cam_context *ctx,
+	struct cam_packet *packet, unsigned long iova, uint32_t buf_info,
+	bool *mem_found)
+{
+	int rc = 0;
+	struct cam_hw_cmd_args cmd_args;
+
+	if (!ctx) {
+		CAM_ERR(CAM_CTXT, "Invalid input params %pK ", ctx);
+		rc = -EINVAL;
+		goto end;
+	}
+
+	if (!ctx->hw_mgr_intf) {
+		CAM_ERR(CAM_CTXT, "[%s][%d] HW interface is not ready",
+			ctx->dev_name, ctx->ctx_id);
+		rc = -EFAULT;
+		goto end;
+	}
+
+	if (ctx->hw_mgr_intf->hw_cmd) {
+		cmd_args.ctxt_to_hw_map = ctx->ctxt_to_hw_map;
+		cmd_args.cmd_type = CAM_HW_MGR_CMD_DUMP_PF_INFO;
+		cmd_args.u.pf_args.pf_data.packet = packet;
+		cmd_args.u.pf_args.iova = iova;
+		cmd_args.u.pf_args.buf_info = buf_info;
+		cmd_args.u.pf_args.mem_found = mem_found;
+		ctx->hw_mgr_intf->hw_cmd(ctx->hw_mgr_intf->hw_mgr_priv,
+			&cmd_args);
+	}
+
+end:
+	return rc;
+}
diff --git a/drivers/media/platform/msm/camera/cam_core/cam_context_utils.h b/drivers/media/platform/msm/camera/cam_core/cam_context_utils.h
index 9b95ead..43e6940 100644
--- a/drivers/media/platform/msm/camera/cam_core/cam_context_utils.h
+++ b/drivers/media/platform/msm/camera/cam_core/cam_context_utils.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -31,5 +31,8 @@
 int32_t cam_context_flush_ctx_to_hw(struct cam_context *ctx);
 int32_t cam_context_flush_req_to_hw(struct cam_context *ctx,
 	struct cam_flush_dev_cmd *cmd);
+int32_t cam_context_dump_pf_info_to_hw(struct cam_context *ctx,
+	struct cam_packet *packet, unsigned long iova, uint32_t buf_info,
+	bool *mem_found);
 
 #endif /* _CAM_CONTEXT_UTILS_H_ */
diff --git a/drivers/media/platform/msm/camera/cam_core/cam_hw_mgr_intf.h b/drivers/media/platform/msm/camera/cam_core/cam_hw_mgr_intf.h
index f7990b6..ecd00b69 100644
--- a/drivers/media/platform/msm/camera/cam_core/cam_hw_mgr_intf.h
+++ b/drivers/media/platform/msm/camera/cam_core/cam_hw_mgr_intf.h
@@ -29,6 +29,10 @@
 typedef int (*cam_hw_event_cb_func)(void *context, uint32_t evt_id,
 	void *evt_data);
 
+/* hardware page fault callback function type */
+typedef int (*cam_hw_pagefault_cb_func)(void *context, unsigned long iova,
+	uint32_t buf_info);
+
 /**
  * struct cam_hw_update_entry - Entry for hardware config
  *
@@ -131,6 +135,16 @@
 	void              *args;
 };
 
+
+/**
+ * struct cam_hw_mgr_dump_pf_data - page fault debug data
+ *
+ * packet:     pointer to packet
+ */
+struct cam_hw_mgr_dump_pf_data {
+	void    *packet;
+};
+
 /**
  * struct cam_hw_prepare_update_args - Payload for prepare command
  *
@@ -146,6 +160,7 @@
  * @in_map_entries:        Actual input fence mapping list (returned)
  * @num_in_map_entries:    Number of acutal input fence mapping (returned)
  * @priv:                  Private pointer of hw update
+ * @pf_data:               Debug data for page fault
  *
  */
 struct cam_hw_prepare_update_args {
@@ -161,6 +176,7 @@
 	struct cam_hw_fence_map_entry  *in_map_entries;
 	uint32_t                        num_in_map_entries;
 	void                           *priv;
+	struct cam_hw_mgr_dump_pf_data *pf_data;
 };
 
 /**
@@ -207,6 +223,48 @@
 };
 
 /**
+ * struct cam_hw_dump_pf_args - Payload for dump pf info command
+ *
+ * @pf_data:               Debug data for page fault
+ * @iova:                  Page fault address
+ * @buf_info:              Info about memory buffer where page
+ *                               fault occurred
+ * @mem_found:             If fault memory found in current
+ *                               request
+ *
+ */
+struct cam_hw_dump_pf_args {
+	struct cam_hw_mgr_dump_pf_data  pf_data;
+	unsigned long                   iova;
+	uint32_t                        buf_info;
+	bool                           *mem_found;
+};
+
+/* enum cam_hw_mgr_command - Hardware manager command type */
+enum cam_hw_mgr_command {
+	CAM_HW_MGR_CMD_INTERNAL,
+	CAM_HW_MGR_CMD_DUMP_PF_INFO,
+};
+
+/**
+ * struct cam_hw_cmd_args - Payload for hw manager command
+ *
+ * @ctxt_to_hw_map:        HW context from the acquire
+ * @cmd_type               HW command type
+ * @internal_args          Arguments for internal command
+ * @pf_args                Arguments for Dump PF info command
+ *
+ */
+struct cam_hw_cmd_args {
+	void                               *ctxt_to_hw_map;
+	uint32_t                            cmd_type;
+	union {
+		void                       *internal_args;
+		struct cam_hw_dump_pf_args  pf_args;
+	} u;
+};
+
+/**
  * cam_hw_mgr_intf - HW manager interface
  *
  * @hw_mgr_priv:           HW manager object
diff --git a/drivers/media/platform/msm/camera/cam_core/cam_node.c b/drivers/media/platform/msm/camera/cam_core/cam_node.c
index 18d5446..1a33722 100644
--- a/drivers/media/platform/msm/camera/cam_core/cam_node.c
+++ b/drivers/media/platform/msm/camera/cam_core/cam_node.c
@@ -430,6 +430,9 @@
 
 	for (i = 0; i < node->ctx_size; i++) {
 		if (node->ctx_list[i].dev_hdl > 0) {
+			CAM_DBG(CAM_CORE,
+				"Node [%s] invoking shutdown on context [%d]",
+				node->name, i);
 			rc = cam_context_shutdown(&(node->ctx_list[i]));
 			if (rc)
 				continue;
diff --git a/drivers/media/platform/msm/camera/cam_icp/cam_icp_context.c b/drivers/media/platform/msm/camera/cam_icp/cam_icp_context.c
index 502c95d..522a602 100644
--- a/drivers/media/platform/msm/camera/cam_icp/cam_icp_context.c
+++ b/drivers/media/platform/msm/camera/cam_icp/cam_icp_context.c
@@ -25,9 +25,46 @@
 #include "cam_mem_mgr.h"
 #include "cam_trace.h"
 #include "cam_debug_util.h"
+#include "cam_packet_util.h"
 
 static const char icp_dev_name[] = "icp";
 
+static int cam_icp_context_dump_active_request(void *data, unsigned long iova,
+	uint32_t buf_info)
+{
+	struct cam_context *ctx = (struct cam_context *)data;
+	struct cam_ctx_request          *req = NULL;
+	struct cam_ctx_request          *req_temp = NULL;
+	struct cam_hw_mgr_dump_pf_data  *pf_dbg_entry = NULL;
+	int rc = 0;
+	bool b_mem_found = false;
+
+	if (!ctx) {
+		CAM_ERR(CAM_ICP, "Invalid ctx");
+		return -EINVAL;
+	}
+
+	CAM_INFO(CAM_ICP, "iommu fault for icp ctx %d state %d",
+		ctx->ctx_id, ctx->state);
+
+	list_for_each_entry_safe(req, req_temp,
+			&ctx->active_req_list, list) {
+		pf_dbg_entry = &(req->pf_data);
+		CAM_INFO(CAM_ICP, "req_id : %lld", req->request_id);
+
+		rc = cam_context_dump_pf_info_to_hw(ctx, pf_dbg_entry->packet,
+			iova, buf_info, &b_mem_found);
+		if (rc)
+			CAM_ERR(CAM_ICP, "Failed to dump pf info");
+
+		if (b_mem_found)
+			CAM_ERR(CAM_ICP, "Found page fault in req %lld %d",
+				req->request_id, rc);
+	}
+
+	return rc;
+}
+
 static int __cam_icp_acquire_dev_in_available(struct cam_context *ctx,
 	struct cam_acquire_dev_cmd *cmd)
 {
@@ -156,6 +193,7 @@
 		},
 		.crm_ops = {},
 		.irq_ops = __cam_icp_handle_buf_done_in_ready,
+		.pagefault_ops = cam_icp_context_dump_active_request,
 	},
 	/* Ready */
 	{
@@ -167,12 +205,14 @@
 		},
 		.crm_ops = {},
 		.irq_ops = __cam_icp_handle_buf_done_in_ready,
+		.pagefault_ops = cam_icp_context_dump_active_request,
 	},
 	/* Activated */
 	{
 		.ioctl_ops = {},
 		.crm_ops = {},
 		.irq_ops = NULL,
+		.pagefault_ops = cam_icp_context_dump_active_request,
 	},
 };
 
diff --git a/drivers/media/platform/msm/camera/cam_icp/cam_icp_subdev.c b/drivers/media/platform/msm/camera/cam_icp/cam_icp_subdev.c
index 7df806b..2ea7738 100644
--- a/drivers/media/platform/msm/camera/cam_icp/cam_icp_subdev.c
+++ b/drivers/media/platform/msm/camera/cam_icp/cam_icp_subdev.c
@@ -35,6 +35,7 @@
 #include "cam_hw_mgr_intf.h"
 #include "cam_icp_hw_mgr_intf.h"
 #include "cam_debug_util.h"
+#include "cam_smmu_api.h"
 
 #define CAM_ICP_DEV_NAME        "cam-icp"
 
@@ -55,6 +56,25 @@
 	{}
 };
 
+static void cam_icp_dev_iommu_fault_handler(
+	struct iommu_domain *domain, struct device *dev, unsigned long iova,
+	int flags, void *token, uint32_t buf_info)
+{
+	int i = 0;
+	struct cam_node *node = NULL;
+
+	if (!token) {
+		CAM_ERR(CAM_ICP, "invalid token in page handler cb");
+		return;
+	}
+
+	node = (struct cam_node *)token;
+
+	for (i = 0; i < node->ctx_size; i++)
+		cam_context_dump_pf_info(&(node->ctx_list[i]), iova,
+			buf_info);
+}
+
 static int cam_icp_subdev_open(struct v4l2_subdev *sd,
 	struct v4l2_subdev_fh *fh)
 {
@@ -96,7 +116,7 @@
 
 	mutex_lock(&g_icp_dev.icp_lock);
 	if (g_icp_dev.open_cnt <= 0) {
-		CAM_ERR(CAM_ICP, "ICP subdev is already closed");
+		CAM_DBG(CAM_ICP, "ICP subdev is already closed");
 		rc = -EINVAL;
 		goto end;
 	}
@@ -135,6 +155,7 @@
 	int rc = 0, i = 0;
 	struct cam_node *node;
 	struct cam_hw_mgr_intf *hw_mgr_intf;
+	int iommu_hdl = -1;
 
 	if (!pdev) {
 		CAM_ERR(CAM_ICP, "pdev is NULL");
@@ -158,7 +179,8 @@
 		goto hw_alloc_fail;
 	}
 
-	rc = cam_icp_hw_mgr_init(pdev->dev.of_node, (uint64_t *)hw_mgr_intf);
+	rc = cam_icp_hw_mgr_init(pdev->dev.of_node, (uint64_t *)hw_mgr_intf,
+		&iommu_hdl);
 	if (rc) {
 		CAM_ERR(CAM_ICP, "ICP HW manager init failed: %d", rc);
 		goto hw_init_fail;
@@ -181,6 +203,9 @@
 		goto ctx_fail;
 	}
 
+	cam_smmu_set_client_page_fault_handler(iommu_hdl,
+		cam_icp_dev_iommu_fault_handler, node);
+
 	g_icp_dev.open_cnt = 0;
 	mutex_init(&g_icp_dev.icp_lock);
 
diff --git a/drivers/media/platform/msm/camera/cam_icp/hfi.c b/drivers/media/platform/msm/camera/cam_icp/hfi.c
index 14a3e65..cbe6886 100644
--- a/drivers/media/platform/msm/camera/cam_icp/hfi.c
+++ b/drivers/media/platform/msm/camera/cam_icp/hfi.c
@@ -42,6 +42,9 @@
 
 #define HFI_MAX_POLL_TRY 5
 
+#define HFI_MAX_PC_POLL_TRY 50
+#define HFI_POLL_TRY_SLEEP 20
+
 static struct hfi_info *g_hfi;
 unsigned int g_icp_mmu_hdl;
 static DEFINE_MUTEX(hfi_cmd_q_mutex);
@@ -513,8 +516,8 @@
 	uint32_t val;
 	uint32_t try = 0;
 
-	while (try < HFI_MAX_POLL_TRY) {
-		data = cam_io_r(icp_base + HFI_REG_A5_CSR_A5_STATUS);
+	while (try < HFI_MAX_PC_POLL_TRY) {
+		data = cam_io_r_mb(icp_base + HFI_REG_A5_CSR_A5_STATUS);
 		CAM_DBG(CAM_HFI, "wfi status = %x\n", (int)data);
 
 		if (data & ICP_CSR_A5_STATUS_WFI)
@@ -523,7 +526,7 @@
 		 * and Host can the proceed. No interrupt is expected from FW
 		 * at this time.
 		 */
-		msleep(100);
+		msleep_interruptible(HFI_POLL_TRY_SLEEP);
 		try++;
 	}
 
@@ -533,6 +536,11 @@
 
 	val = cam_io_r(icp_base + HFI_REG_A5_CSR_NSEC_RESET);
 	cam_io_w_mb(val, icp_base + HFI_REG_A5_CSR_NSEC_RESET);
+
+	cam_io_w_mb((uint32_t)ICP_INIT_REQUEST_RESET,
+		icp_base + HFI_REG_HOST_ICP_INIT_REQUEST);
+	cam_io_w_mb((uint32_t)INTR_DISABLE,
+		g_hfi->csr_base + HFI_REG_A5_CSR_A2HOSTINTEN);
 }
 
 void cam_hfi_enable_cpu(void __iomem *icp_base)
@@ -883,11 +891,6 @@
 	g_hfi->cmd_q_state = false;
 	g_hfi->msg_q_state = false;
 
-	cam_io_w_mb((uint32_t)ICP_INIT_REQUEST_RESET,
-		icp_base + HFI_REG_HOST_ICP_INIT_REQUEST);
-
-	cam_io_w_mb((uint32_t)INTR_DISABLE,
-		g_hfi->csr_base + HFI_REG_A5_CSR_A2HOSTINTEN);
 	kzfree(g_hfi);
 	g_hfi = NULL;
 
diff --git a/drivers/media/platform/msm/camera/cam_icp/icp_hw/bps_hw/bps_core.c b/drivers/media/platform/msm/camera/cam_icp/icp_hw/bps_hw/bps_core.c
index d016374..b969c92 100644
--- a/drivers/media/platform/msm/camera/cam_icp/icp_hw/bps_hw/bps_core.c
+++ b/drivers/media/platform/msm/camera/cam_icp/icp_hw/bps_hw/bps_core.c
@@ -199,8 +199,10 @@
 	cam_cpas_reg_read(core_info->cpas_handle,
 		CAM_CPAS_REG_CPASTOP, hw_info->pwr_ctrl, true, &pwr_ctrl);
 	if (pwr_ctrl & BPS_COLLAPSE_MASK) {
-		CAM_ERR(CAM_ICP, "BPS: pwr_ctrl(%x)", pwr_ctrl);
-		return -EINVAL;
+		CAM_DBG(CAM_ICP, "BPS: pwr_ctrl set(%x)", pwr_ctrl);
+		cam_cpas_reg_write(core_info->cpas_handle,
+			CAM_CPAS_REG_CPASTOP,
+			hw_info->pwr_ctrl, true, 0);
 	}
 
 	rc = cam_bps_transfer_gdsc_control(soc_info);
diff --git a/drivers/media/platform/msm/camera/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c b/drivers/media/platform/msm/camera/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c
index 1d5e483..c33c6a5 100644
--- a/drivers/media/platform/msm/camera/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c
+++ b/drivers/media/platform/msm/camera/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c
@@ -3388,10 +3388,11 @@
 			prepare_args->num_out_map_entries++;
 		}
 		CAM_DBG(CAM_REQ,
-			"ctx_id: %u req_id: %llu dir[%d]: %u, fence: %u resource_type = %u",
+			"ctx_id: %u req_id: %llu dir[%d]: %u, fence: %u resource_type = %u memh %x",
 			ctx_data->ctx_id, packet->header.request_id, i,
 			io_cfg_ptr[i].direction, io_cfg_ptr[i].fence,
-			io_cfg_ptr[i].resource_type);
+			io_cfg_ptr[i].resource_type,
+			io_cfg_ptr[i].mem_handle[0]);
 	}
 
 	if (prepare_args->num_in_map_entries > 1)
@@ -3593,6 +3594,77 @@
 	return rc;
 }
 
+static void cam_icp_mgr_print_io_bufs(struct cam_packet *packet,
+	int32_t iommu_hdl, int32_t sec_mmu_hdl, uint32_t pf_buf_info,
+	bool *mem_found)
+{
+	uint64_t   iova_addr;
+	size_t     src_buf_size;
+	int        i;
+	int        j;
+	int        rc = 0;
+	int32_t    mmu_hdl;
+
+	struct cam_buf_io_cfg  *io_cfg = NULL;
+
+	if (mem_found)
+		*mem_found = false;
+
+	io_cfg = (struct cam_buf_io_cfg *)((uint32_t *)&packet->payload +
+		packet->io_configs_offset / 4);
+
+	for (i = 0; i < packet->num_io_configs; i++) {
+		for (j = 0; j < CAM_PACKET_MAX_PLANES; j++) {
+			if (!io_cfg[i].mem_handle[j])
+				break;
+
+			if (GET_FD_FROM_HANDLE(io_cfg[i].mem_handle[j]) ==
+				GET_FD_FROM_HANDLE(pf_buf_info)) {
+				CAM_INFO(CAM_ICP,
+					"Found PF at port: %d mem %x fd: %x",
+					io_cfg[i].resource_type,
+					io_cfg[i].mem_handle[j],
+					pf_buf_info);
+				if (mem_found)
+					*mem_found = true;
+			}
+
+			CAM_INFO(CAM_ICP, "port: %d f: %u format: %d dir %d",
+				io_cfg[i].resource_type,
+				io_cfg[i].fence,
+				io_cfg[i].format,
+				io_cfg[i].direction);
+
+			mmu_hdl = cam_mem_is_secure_buf(
+				io_cfg[i].mem_handle[j]) ? sec_mmu_hdl :
+				iommu_hdl;
+			rc = cam_mem_get_io_buf(io_cfg[i].mem_handle[j],
+				mmu_hdl, &iova_addr, &src_buf_size);
+			if (rc < 0) {
+				CAM_ERR(CAM_UTIL, "get src buf address fail");
+				continue;
+			}
+			if (iova_addr >> 32) {
+				CAM_ERR(CAM_ICP, "Invalid mapped address");
+				rc = -EINVAL;
+				continue;
+			}
+
+			CAM_INFO(CAM_ICP,
+				"pln %d w %d h %d size %d addr 0x%x offset 0x%x memh %x",
+				j, io_cfg[i].planes[j].width,
+				io_cfg[i].planes[j].height,
+				(int32_t)src_buf_size,
+				(unsigned int)iova_addr,
+				io_cfg[i].offsets[j],
+				io_cfg[i].mem_handle[j]);
+
+			iova_addr += io_cfg[i].offsets[j];
+
+		}
+	}
+}
+
 static int cam_icp_mgr_prepare_hw_update(void *hw_mgr_priv,
 	void *prepare_hw_update_args)
 {
@@ -3635,6 +3707,8 @@
 		return rc;
 	}
 
+	prepare_args->pf_data->packet = packet;
+
 	CAM_DBG(CAM_REQ, "req id = %lld for ctx = %u",
 		packet->header.request_id, ctx_data->ctx_id);
 	/* Update Buffer Address from handles and patch information */
@@ -4551,7 +4625,35 @@
 	return rc;
 }
 
-int cam_icp_hw_mgr_init(struct device_node *of_node, uint64_t *hw_mgr_hdl)
+static int cam_icp_mgr_cmd(void *hw_mgr_priv, void *cmd_args)
+{
+	int rc = 0;
+	struct cam_hw_cmd_args *hw_cmd_args = cmd_args;
+	struct cam_icp_hw_mgr  *hw_mgr = hw_mgr_priv;
+
+	if (!hw_mgr_priv || !cmd_args) {
+		CAM_ERR(CAM_ICP, "Invalid arguments");
+		return -EINVAL;
+	}
+
+	switch (hw_cmd_args->cmd_type) {
+	case CAM_HW_MGR_CMD_DUMP_PF_INFO:
+		cam_icp_mgr_print_io_bufs(
+			hw_cmd_args->u.pf_args.pf_data.packet,
+			hw_mgr->iommu_hdl,
+			hw_mgr->iommu_sec_hdl,
+			hw_cmd_args->u.pf_args.buf_info,
+			hw_cmd_args->u.pf_args.mem_found);
+		break;
+	default:
+		CAM_ERR(CAM_ICP, "Invalid cmd");
+	}
+
+	return rc;
+}
+
+int cam_icp_hw_mgr_init(struct device_node *of_node, uint64_t *hw_mgr_hdl,
+	int *iommu_hdl)
 {
 	int i, rc = 0;
 	struct cam_hw_mgr_intf *hw_mgr_intf;
@@ -4574,6 +4676,7 @@
 	hw_mgr_intf->hw_open = cam_icp_mgr_hw_open_u;
 	hw_mgr_intf->hw_close = cam_icp_mgr_hw_close_u;
 	hw_mgr_intf->hw_flush = cam_icp_mgr_hw_flush;
+	hw_mgr_intf->hw_cmd = cam_icp_mgr_cmd;
 
 	icp_hw_mgr.secure_mode = CAM_SECURE_MODE_NON_SECURE;
 	mutex_init(&icp_hw_mgr.hw_mgr_mutex);
@@ -4617,6 +4720,9 @@
 	if (rc)
 		goto icp_wq_create_failed;
 
+	if (iommu_hdl)
+		*iommu_hdl = icp_hw_mgr.iommu_hdl;
+
 	init_completion(&icp_hw_mgr.a5_complete);
 	return rc;
 
diff --git a/drivers/media/platform/msm/camera/cam_icp/icp_hw/include/cam_icp_hw_mgr_intf.h b/drivers/media/platform/msm/camera/cam_icp/icp_hw/include/cam_icp_hw_mgr_intf.h
index 771c4ed..7bb9b9ed 100644
--- a/drivers/media/platform/msm/camera/cam_icp/icp_hw/include/cam_icp_hw_mgr_intf.h
+++ b/drivers/media/platform/msm/camera/cam_icp/icp_hw/include/cam_icp_hw_mgr_intf.h
@@ -28,7 +28,7 @@
 #define CPAS_IPE1_BIT            0x2000
 
 int cam_icp_hw_mgr_init(struct device_node *of_node,
-	uint64_t *hw_mgr_hdl);
+	uint64_t *hw_mgr_hdl, int *iommu_hdl);
 
 /**
  * struct cam_icp_cpas_vote
diff --git a/drivers/media/platform/msm/camera/cam_icp/icp_hw/ipe_hw/ipe_core.c b/drivers/media/platform/msm/camera/cam_icp/icp_hw/ipe_hw/ipe_core.c
index 620a4bd..142fcdc 100644
--- a/drivers/media/platform/msm/camera/cam_icp/icp_hw/ipe_hw/ipe_core.c
+++ b/drivers/media/platform/msm/camera/cam_icp/icp_hw/ipe_hw/ipe_core.c
@@ -195,9 +195,12 @@
 		CAM_CPAS_REG_CPASTOP, hw_info->pwr_ctrl,
 		true, &pwr_ctrl);
 	if (pwr_ctrl & IPE_COLLAPSE_MASK) {
-		CAM_ERR(CAM_ICP, "IPE: resume failed : %d", pwr_ctrl);
-		return -EINVAL;
+		CAM_DBG(CAM_ICP, "IPE pwr_ctrl set(%x)", pwr_ctrl);
+		cam_cpas_reg_write(core_info->cpas_handle,
+			CAM_CPAS_REG_CPASTOP,
+			hw_info->pwr_ctrl, true, 0);
 	}
+
 	rc = cam_ipe_transfer_gdsc_control(soc_info);
 	cam_cpas_reg_read(core_info->cpas_handle,
 		CAM_CPAS_REG_CPASTOP, hw_info->pwr_ctrl, true, &pwr_ctrl);
diff --git a/drivers/media/platform/msm/camera/cam_isp/cam_isp_context.c b/drivers/media/platform/msm/camera/cam_isp/cam_isp_context.c
index 5760371..1aaa5c3 100644
--- a/drivers/media/platform/msm/camera/cam_isp/cam_isp_context.c
+++ b/drivers/media/platform/msm/camera/cam_isp/cam_isp_context.c
@@ -23,8 +23,14 @@
 #include "cam_req_mgr_dev.h"
 #include "cam_trace.h"
 #include "cam_debug_util.h"
+#include "cam_packet_util.h"
+#include "cam_context_utils.h"
 
 static const char isp_dev_name[] = "isp";
+
+static int cam_isp_context_dump_active_request(void *data, unsigned long iova,
+	uint32_t buf_info);
+
 static void __cam_isp_ctx_update_state_monitor_array(
 	struct cam_isp_context *ctx_isp,
 	enum cam_isp_state_change_trigger trigger_type,
@@ -375,7 +381,7 @@
 			continue;
 		}
 
-		if (!bubble_state) {
+		if (!req_isp->bubble_detected) {
 			CAM_DBG(CAM_ISP,
 				"Sync with success: req %lld res 0x%x fd 0x%x",
 				req->request_id,
@@ -402,15 +408,14 @@
 		} else {
 			/*
 			 * Ignore the buffer done if bubble detect is on
-			 * In most case, active list should be empty when
-			 * bubble detects. But for safety, we just move the
-			 * current active request to the pending list here.
+			 * Increment the ack number here, and queue the
+			 * request back to pending list whenever all the
+			 * buffers are done.
 			 */
+			req_isp->num_acked++;
 			CAM_DBG(CAM_ISP,
 				"buf done with bubble state %d recovery %d",
 				bubble_state, req_isp->bubble_report);
-			list_del_init(&req->list);
-			list_add(&req->list, &ctx->pending_req_list);
 			continue;
 		}
 
@@ -431,10 +436,25 @@
 			req_isp->num_fence_map_out);
 		WARN_ON(req_isp->num_acked > req_isp->num_fence_map_out);
 	}
-	if (req_isp->num_acked == req_isp->num_fence_map_out) {
+
+	if (req_isp->num_acked != req_isp->num_fence_map_out)
+		return rc;
+
+	ctx_isp->active_req_cnt--;
+
+	if (req_isp->bubble_detected && req_isp->bubble_report) {
+		req_isp->num_acked = 0;
+		req_isp->bubble_detected = false;
+		list_del_init(&req->list);
+		list_add(&req->list, &ctx->pending_req_list);
+
+		CAM_DBG(CAM_REQ,
+			"Move active request %lld to pending list(cnt = %d) [bubble recovery]",
+			 req->request_id, ctx_isp->active_req_cnt);
+	} else {
 		list_del_init(&req->list);
 		list_add_tail(&req->list, &ctx->free_req_list);
-		ctx_isp->active_req_cnt--;
+
 		CAM_DBG(CAM_REQ,
 			"Move active request %lld to free list(cnt = %d) [all fences done]",
 			 req->request_id, ctx_isp->active_req_cnt);
@@ -732,15 +752,13 @@
 	req = list_first_entry(&ctx->wait_req_list, struct cam_ctx_request,
 		list);
 	req_isp = (struct cam_isp_ctx_req *)req->req_priv;
+	req_isp->bubble_detected = true;
 
 	CAM_DBG(CAM_ISP, "Report Bubble flag %d", req_isp->bubble_report);
 	if (req_isp->bubble_report && ctx->ctx_crm_intf &&
 		ctx->ctx_crm_intf->notify_err) {
 		struct cam_req_mgr_error_notify notify;
 
-		list_del_init(&req->list);
-		list_add(&req->list, &ctx->pending_req_list);
-
 		notify.link_hdl = ctx->link_hdl;
 		notify.dev_hdl = ctx->dev_hdl;
 		notify.req_id = req->request_id;
@@ -749,18 +767,19 @@
 		CAM_DBG(CAM_ISP, "Notify CRM about Bubble frame %lld",
 			ctx_isp->frame_id);
 	} else {
-		/*
-		 * Since can not bubble report, always move the request to
-		 * active list.
-		 */
-		list_del_init(&req->list);
-		list_add_tail(&req->list, &ctx->active_req_list);
-		ctx_isp->active_req_cnt++;
-		CAM_DBG(CAM_REQ, "move request %lld to active list(cnt = %d)",
-			 req->request_id, ctx_isp->active_req_cnt);
 		req_isp->bubble_report = 0;
 	}
 
+	/*
+	 * Always move the request to active list. Let buf done
+	 * function handles the rest.
+	 */
+	CAM_DBG(CAM_REQ, "move request %lld to active list(cnt = %d)",
+		req->request_id, ctx_isp->active_req_cnt);
+	ctx_isp->active_req_cnt++;
+	list_del_init(&req->list);
+	list_add_tail(&req->list, &ctx->active_req_list);
+
 	if (req->request_id > ctx_isp->reported_req_id) {
 		request_id = req->request_id;
 		ctx_isp->reported_req_id = request_id;
@@ -882,13 +901,12 @@
 	req = list_first_entry(&ctx->wait_req_list, struct cam_ctx_request,
 		list);
 	req_isp = (struct cam_isp_ctx_req *)req->req_priv;
-	list_del_init(&req->list);
+	req_isp->bubble_detected = true;
 
 	if (req_isp->bubble_report && ctx->ctx_crm_intf &&
 		ctx->ctx_crm_intf->notify_err) {
 		struct cam_req_mgr_error_notify notify;
 
-		list_add(&req->list, &ctx->pending_req_list);
 		notify.link_hdl = ctx->link_hdl;
 		notify.dev_hdl = ctx->dev_hdl;
 		notify.req_id = req->request_id;
@@ -898,17 +916,19 @@
 			"Notify CRM about Bubble req_id %llu frame %lld",
 			req->request_id, ctx_isp->frame_id);
 	} else {
-		/*
-		 * If we can not report bubble, then treat it as if no bubble
-		 * report. Just move the req to active list.
-		 */
-		list_add_tail(&req->list, &ctx->active_req_list);
-		ctx_isp->active_req_cnt++;
-		CAM_DBG(CAM_ISP, "move request %lld to active list(cnt = %d)",
-			 req->request_id, ctx_isp->active_req_cnt);
 		req_isp->bubble_report = 0;
 	}
 
+	/*
+	 * Always move the request to active list. Let buf done
+	 * function handles the rest.
+	 */
+	CAM_DBG(CAM_ISP, "move request %lld to active list(cnt = %d)",
+		req->request_id, ctx_isp->active_req_cnt);
+	ctx_isp->active_req_cnt++;
+	list_del_init(&req->list);
+	list_add_tail(&req->list, &ctx->active_req_list);
+
 	if (!req_isp->bubble_report) {
 		if (req->request_id > ctx_isp->reported_req_id) {
 			request_id = req->request_id;
@@ -1411,6 +1431,7 @@
 		CAM_DBG(CAM_ISP, "try to flush active list");
 		rc = __cam_isp_ctx_flush_req(ctx, &ctx->active_req_list,
 		flush_req);
+		ctx_isp->active_req_cnt = 0;
 		spin_unlock_bh(&ctx->lock);
 
 		/* Start hw */
@@ -1609,12 +1630,12 @@
 	CAM_DBG(CAM_ISP, "frame id: %lld time stamp:0x%llx",
 		ctx_isp->frame_id, ctx_isp->sof_timestamp_val);
 
-	if (list_empty(&ctx->pending_req_list)) {
+	if (list_empty(&ctx->wait_req_list)) {
 		/*
 		 * If no pending req in epoch, this is an error case.
 		 * The recovery is to go back to sof state
 		 */
-		CAM_ERR(CAM_ISP, "No pending request");
+		CAM_ERR(CAM_ISP, "No wait request");
 		ctx_isp->substate_activated = CAM_ISP_CTX_ACTIVATED_SOF;
 
 		/* Send SOF event as empty frame*/
@@ -1624,9 +1645,10 @@
 		goto end;
 	}
 
-	req = list_first_entry(&ctx->pending_req_list, struct cam_ctx_request,
+	req = list_first_entry(&ctx->wait_req_list, struct cam_ctx_request,
 		list);
 	req_isp = (struct cam_isp_ctx_req *)req->req_priv;
+	req_isp->bubble_detected = true;
 
 	CAM_DBG(CAM_ISP, "Report Bubble flag %d", req_isp->bubble_report);
 	if (req_isp->bubble_report && ctx->ctx_crm_intf &&
@@ -1641,18 +1663,19 @@
 		CAM_DBG(CAM_ISP, "Notify CRM about Bubble frame %lld",
 			ctx_isp->frame_id);
 	} else {
-		/*
-		 * Since can not bubble report, always move the request to
-		 * active list.
-		 */
-		list_del_init(&req->list);
-		list_add_tail(&req->list, &ctx->active_req_list);
-		ctx_isp->active_req_cnt++;
-		CAM_DBG(CAM_ISP, "move request %lld to active list(cnt = %d)",
-			req->request_id, ctx_isp->active_req_cnt);
 		req_isp->bubble_report = 0;
 	}
 
+	/*
+	 * Always move the request to active list. Let buf done
+	 * function handles the rest.
+	 */
+	ctx_isp->active_req_cnt++;
+	list_del_init(&req->list);
+	list_add_tail(&req->list, &ctx->active_req_list);
+	CAM_DBG(CAM_ISP, "move request %lld to active list(cnt = %d)",
+			req->request_id, ctx_isp->active_req_cnt);
+
 	if (!req_isp->bubble_report) {
 		if (req->request_id > ctx_isp->reported_req_id) {
 			request_id = req->request_id;
@@ -2066,6 +2089,7 @@
 	cfg.out_map_entries = req_isp->fence_map_out;
 	cfg.in_map_entries = req_isp->fence_map_in;
 	cfg.priv  = &req_isp->hw_update_data;
+	cfg.pf_data = &(req->pf_data);
 
 	CAM_DBG(CAM_ISP, "try to prepare config packet......");
 
@@ -2080,6 +2104,7 @@
 	req_isp->num_fence_map_out = cfg.num_out_map_entries;
 	req_isp->num_fence_map_in = cfg.num_in_map_entries;
 	req_isp->num_acked = 0;
+	req_isp->bubble_detected = false;
 
 	for (i = 0; i < req_isp->num_fence_map_out; i++) {
 		rc = cam_sync_get_obj_ref(req_isp->fence_map_out[i].sync_id);
@@ -2164,7 +2189,8 @@
 	struct cam_hw_release_args       release;
 	struct cam_isp_context          *ctx_isp =
 		(struct cam_isp_context *) ctx->ctx_priv;
-	struct cam_isp_hw_cmd_args       hw_cmd_args;
+	struct cam_hw_cmd_args       hw_cmd_args;
+	struct cam_isp_hw_cmd_args   isp_hw_cmd_args;
 
 	if (!ctx->hw_mgr_intf) {
 		CAM_ERR(CAM_ISP, "HW interface is not ready");
@@ -2221,7 +2247,9 @@
 
 	/* Query the context has rdi only resource */
 	hw_cmd_args.ctxt_to_hw_map = param.ctxt_to_hw_map;
-	hw_cmd_args.cmd_type = CAM_ISP_HW_MGR_CMD_IS_RDI_ONLY_CONTEXT;
+	hw_cmd_args.cmd_type = CAM_HW_MGR_CMD_INTERNAL;
+	isp_hw_cmd_args.cmd_type = CAM_ISP_HW_MGR_CMD_IS_RDI_ONLY_CONTEXT;
+	hw_cmd_args.u.internal_args = (void *)&isp_hw_cmd_args;
 	rc = ctx->hw_mgr_intf->hw_cmd(ctx->hw_mgr_intf->hw_mgr_priv,
 				&hw_cmd_args);
 	if (rc) {
@@ -2229,7 +2257,7 @@
 		goto free_hw;
 	}
 
-	if (hw_cmd_args.u.is_rdi_only_context) {
+	if (isp_hw_cmd_args.u.is_rdi_only_context) {
 		/*
 		 * this context has rdi only resource assign rdi only
 		 * state machine
@@ -2248,8 +2276,9 @@
 			cam_isp_ctx_activated_state_machine;
 	}
 
-	ctx_isp->rdi_only_context = hw_cmd_args.u.is_rdi_only_context;
+	ctx_isp->rdi_only_context = isp_hw_cmd_args.u.is_rdi_only_context;
 	ctx_isp->hw_ctx = param.ctxt_to_hw_map;
+	ctx->ctxt_to_hw_map = param.ctxt_to_hw_map;
 
 	req_hdl_param.session_hdl = cmd->session_handle;
 	/* bridge is not ready for these flags. so false for now */
@@ -2276,7 +2305,7 @@
 	CAM_DBG(CAM_ISP,
 		"Acquire success on session_hdl 0x%x num_rsrces %d RDI only %d ctx %u",
 		cmd->session_handle, cmd->num_resources,
-		(hw_cmd_args.u.is_rdi_only_context ? 1 : 0), ctx->ctx_id);
+		(isp_hw_cmd_args.u.is_rdi_only_context ? 1 : 0), ctx->ctx_id);
 	kfree(isp_res);
 	return rc;
 
@@ -2567,12 +2596,15 @@
 static int __cam_isp_ctx_link_pause(struct cam_context *ctx)
 {
 	int rc = 0;
-	struct cam_isp_hw_cmd_args   hw_cmd_args;
+	struct cam_hw_cmd_args       hw_cmd_args;
+	struct cam_isp_hw_cmd_args   isp_hw_cmd_args;
 	struct cam_isp_context      *ctx_isp =
 		(struct cam_isp_context *) ctx->ctx_priv;
 
 	hw_cmd_args.ctxt_to_hw_map = ctx_isp->hw_ctx;
-	hw_cmd_args.cmd_type = CAM_ISP_HW_MGR_CMD_PAUSE_HW;
+	hw_cmd_args.cmd_type = CAM_HW_MGR_CMD_INTERNAL;
+	isp_hw_cmd_args.cmd_type = CAM_ISP_HW_MGR_CMD_PAUSE_HW;
+	hw_cmd_args.u.internal_args = (void *)&isp_hw_cmd_args;
 	rc = ctx->hw_mgr_intf->hw_cmd(ctx->hw_mgr_intf->hw_mgr_priv,
 		&hw_cmd_args);
 
@@ -2582,12 +2614,15 @@
 static int __cam_isp_ctx_link_resume(struct cam_context *ctx)
 {
 	int rc = 0;
-	struct cam_isp_hw_cmd_args   hw_cmd_args;
+	struct cam_hw_cmd_args       hw_cmd_args;
+	struct cam_isp_hw_cmd_args   isp_hw_cmd_args;
 	struct cam_isp_context      *ctx_isp =
 		(struct cam_isp_context *) ctx->ctx_priv;
 
 	hw_cmd_args.ctxt_to_hw_map = ctx_isp->hw_ctx;
-	hw_cmd_args.cmd_type = CAM_ISP_HW_MGR_CMD_RESUME_HW;
+	hw_cmd_args.cmd_type = CAM_HW_MGR_CMD_INTERNAL;
+	isp_hw_cmd_args.cmd_type = CAM_ISP_HW_MGR_CMD_RESUME_HW;
+	hw_cmd_args.u.internal_args = (void *)&isp_hw_cmd_args;
 	rc = ctx->hw_mgr_intf->hw_cmd(ctx->hw_mgr_intf->hw_mgr_priv,
 		&hw_cmd_args);
 
@@ -2598,13 +2633,16 @@
 	struct cam_context *ctx)
 {
 	int rc = 0;
-	struct cam_isp_hw_cmd_args   hw_cmd_args;
+	struct cam_hw_cmd_args       hw_cmd_args;
+	struct cam_isp_hw_cmd_args   isp_hw_cmd_args;
 	struct cam_isp_context      *ctx_isp =
 		(struct cam_isp_context *) ctx->ctx_priv;
 
 	hw_cmd_args.ctxt_to_hw_map = ctx_isp->hw_ctx;
-	hw_cmd_args.cmd_type = CAM_ISP_HW_MGR_CMD_SOF_DEBUG;
-	hw_cmd_args.u.sof_irq_enable = 1;
+	hw_cmd_args.cmd_type = CAM_HW_MGR_CMD_INTERNAL;
+	isp_hw_cmd_args.cmd_type = CAM_ISP_HW_MGR_CMD_SOF_DEBUG;
+	isp_hw_cmd_args.u.sof_irq_enable = 1;
+	hw_cmd_args.u.internal_args = (void *)&isp_hw_cmd_args;
 
 	rc = ctx->hw_mgr_intf->hw_cmd(ctx->hw_mgr_intf->hw_mgr_priv,
 		&hw_cmd_args);
@@ -2746,6 +2784,7 @@
 			.flush_req = __cam_isp_ctx_flush_req_in_top_state,
 		},
 		.irq_ops = NULL,
+		.pagefault_ops = cam_isp_context_dump_active_request,
 	},
 	/* Ready */
 	{
@@ -2759,6 +2798,7 @@
 			.flush_req = __cam_isp_ctx_flush_req_in_ready,
 		},
 		.irq_ops = NULL,
+		.pagefault_ops = cam_isp_context_dump_active_request,
 	},
 	/* Activated */
 	{
@@ -2774,10 +2814,55 @@
 			.process_evt = __cam_isp_ctx_process_evt,
 		},
 		.irq_ops = __cam_isp_ctx_handle_irq_in_activated,
+		.pagefault_ops = cam_isp_context_dump_active_request,
 	},
 };
 
 
+static int cam_isp_context_dump_active_request(void *data, unsigned long iova,
+	uint32_t buf_info)
+{
+
+	struct cam_context *ctx = (struct cam_context *)data;
+	struct cam_ctx_request *req = NULL;
+	struct cam_ctx_request *req_temp = NULL;
+	struct cam_isp_ctx_req *req_isp  = NULL;
+	struct cam_isp_prepare_hw_update_data *hw_update_data = NULL;
+	struct cam_hw_mgr_dump_pf_data *pf_dbg_entry = NULL;
+	bool mem_found = false;
+	int rc = 0;
+
+	struct cam_isp_context *isp_ctx =
+		(struct cam_isp_context *)ctx->ctx_priv;
+
+	if (!isp_ctx) {
+		CAM_ERR(CAM_ISP, "Invalid isp ctx");
+		return -EINVAL;
+	}
+
+	CAM_INFO(CAM_ISP, "iommu fault handler for isp ctx %d state %d",
+		ctx->ctx_id, ctx->state);
+
+	list_for_each_entry_safe(req, req_temp,
+		&ctx->active_req_list, list) {
+		req_isp = (struct cam_isp_ctx_req *) req->req_priv;
+		hw_update_data = &req_isp->hw_update_data;
+		pf_dbg_entry = &(req->pf_data);
+		CAM_INFO(CAM_ISP, "req_id : %lld ", req->request_id);
+
+		rc = cam_context_dump_pf_info_to_hw(ctx, pf_dbg_entry->packet,
+			iova, buf_info, &mem_found);
+		if (rc)
+			CAM_ERR(CAM_ISP, "Failed to dump pf info");
+
+		if (mem_found)
+			CAM_ERR(CAM_ISP, "Found page fault in req %lld %d",
+				req->request_id, rc);
+	}
+
+	return rc;
+}
+
 int cam_isp_context_init(struct cam_isp_context *ctx,
 	struct cam_context *ctx_base,
 	struct cam_req_mgr_kmd_ops *crm_node_intf,
diff --git a/drivers/media/platform/msm/camera/cam_isp/cam_isp_context.h b/drivers/media/platform/msm/camera/cam_isp/cam_isp_context.h
index 4592e42..6f89841 100644
--- a/drivers/media/platform/msm/camera/cam_isp/cam_isp_context.h
+++ b/drivers/media/platform/msm/camera/cam_isp/cam_isp_context.h
@@ -115,6 +115,7 @@
 	uint32_t                              num_acked;
 	int32_t                               bubble_report;
 	struct cam_isp_prepare_hw_update_data hw_update_data;
+	bool                                  bubble_detected;
 };
 
 /**
diff --git a/drivers/media/platform/msm/camera/cam_isp/cam_isp_dev.c b/drivers/media/platform/msm/camera/cam_isp/cam_isp_dev.c
index a067915..c7e5d38 100644
--- a/drivers/media/platform/msm/camera/cam_isp/cam_isp_dev.c
+++ b/drivers/media/platform/msm/camera/cam_isp/cam_isp_dev.c
@@ -26,9 +26,29 @@
 #include "cam_isp_hw_mgr_intf.h"
 #include "cam_node.h"
 #include "cam_debug_util.h"
+#include "cam_smmu_api.h"
 
 static struct cam_isp_dev g_isp_dev;
 
+static void cam_isp_dev_iommu_fault_handler(
+	struct iommu_domain *domain, struct device *dev, unsigned long iova,
+	int flags, void *token, uint32_t buf_info)
+{
+	int i = 0;
+	struct cam_node *node = NULL;
+
+	if (!token) {
+		CAM_ERR(CAM_ISP, "invalid token in page handler cb");
+		return;
+	}
+
+	node = (struct cam_node *)token;
+
+	for (i = 0; i < node->ctx_size; i++)
+		cam_context_dump_pf_info(&(node->ctx_list[i]), iova,
+			buf_info);
+}
+
 static const struct of_device_id cam_isp_dt_match[] = {
 	{
 		.compatible = "qcom,cam-isp"
@@ -36,23 +56,47 @@
 	{}
 };
 
-static int cam_isp_subdev_close(struct v4l2_subdev *sd,
+static int cam_isp_subdev_open(struct v4l2_subdev *sd,
 	struct v4l2_subdev_fh *fh)
 {
-	struct cam_node *node = v4l2_get_subdevdata(sd);
-
-	if (!node) {
-		CAM_ERR(CAM_ISP, "Node ptr is NULL");
-		return -EINVAL;
-	}
-
-	cam_node_shutdown(node);
+	mutex_lock(&g_isp_dev.isp_mutex);
+	g_isp_dev.open_cnt++;
+	mutex_unlock(&g_isp_dev.isp_mutex);
 
 	return 0;
 }
 
+static int cam_isp_subdev_close(struct v4l2_subdev *sd,
+	struct v4l2_subdev_fh *fh)
+{
+	int rc = 0;
+	struct cam_node *node = v4l2_get_subdevdata(sd);
+
+	mutex_lock(&g_isp_dev.isp_mutex);
+	if (g_isp_dev.open_cnt <= 0) {
+		CAM_DBG(CAM_ISP, "ISP subdev is already closed");
+		rc = -EINVAL;
+		goto end;
+	}
+
+	g_isp_dev.open_cnt--;
+	if (!node) {
+		CAM_ERR(CAM_ISP, "Node ptr is NULL");
+		rc = -EINVAL;
+		goto end;
+	}
+
+	if (g_isp_dev.open_cnt == 0)
+		cam_node_shutdown(node);
+
+end:
+	mutex_unlock(&g_isp_dev.isp_mutex);
+	return rc;
+}
+
 static const struct v4l2_subdev_internal_ops cam_isp_subdev_internal_ops = {
 	.close = cam_isp_subdev_close,
+	.open = cam_isp_subdev_open,
 };
 
 static int cam_isp_dev_remove(struct platform_device *pdev)
@@ -82,6 +126,7 @@
 	int i;
 	struct cam_hw_mgr_intf         hw_mgr_intf;
 	struct cam_node               *node;
+	int iommu_hdl = -1;
 
 	g_isp_dev.sd.internal_ops = &cam_isp_subdev_internal_ops;
 	/* Initialze the v4l2 subdevice first. (create cam_node) */
@@ -94,7 +139,7 @@
 	node = (struct cam_node *) g_isp_dev.sd.token;
 
 	memset(&hw_mgr_intf, 0, sizeof(hw_mgr_intf));
-	rc = cam_isp_hw_mgr_init(pdev->dev.of_node, &hw_mgr_intf);
+	rc = cam_isp_hw_mgr_init(pdev->dev.of_node, &hw_mgr_intf, &iommu_hdl);
 	if (rc != 0) {
 		CAM_ERR(CAM_ISP, "Can not initialized ISP HW manager!");
 		goto unregister;
@@ -119,6 +164,11 @@
 		goto unregister;
 	}
 
+	cam_smmu_set_client_page_fault_handler(iommu_hdl,
+		cam_isp_dev_iommu_fault_handler, node);
+
+	mutex_init(&g_isp_dev.isp_mutex);
+
 	CAM_INFO(CAM_ISP, "Camera ISP probe complete");
 
 	return 0;
diff --git a/drivers/media/platform/msm/camera/cam_isp/cam_isp_dev.h b/drivers/media/platform/msm/camera/cam_isp/cam_isp_dev.h
index 95463ca..a88ed55 100644
--- a/drivers/media/platform/msm/camera/cam_isp/cam_isp_dev.h
+++ b/drivers/media/platform/msm/camera/cam_isp/cam_isp_dev.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -24,12 +24,15 @@
  * @sd:                    Commone camera subdevice node
  * @ctx:                   Isp base context storage
  * @ctx_isp:               Isp private context storage
- *
+ * @isp_mutex:             ISP dev mutex
+ * @open_cnt:              Open device count
  */
 struct cam_isp_dev {
 	struct cam_subdev          sd;
 	struct cam_context         ctx[CAM_CTX_MAX];
 	struct cam_isp_context     ctx_isp[CAM_CTX_MAX];
+	struct mutex               isp_mutex;
+	int32_t                    open_cnt;
 };
 
 #endif /* __CAM_ISP_DEV_H__ */
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c
index 7e0aa4b..4d09a9a 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c
@@ -28,6 +28,7 @@
 #include "cam_packet_util.h"
 #include "cam_debug_util.h"
 #include "cam_cpas_api.h"
+#include "cam_mem_mgr_api.h"
 
 #define CAM_IFE_HW_ENTRIES_MAX  20
 
@@ -2161,7 +2162,8 @@
 	struct cam_isp_stop_args          stop_isp;
 	struct cam_ife_hw_mgr_ctx        *ctx;
 	struct cam_ife_hw_mgr_res        *hw_mgr_res;
-	uint32_t                          i;
+	struct cam_isp_resource_node     *rsrc_node = NULL;
+	uint32_t                          i, camif_debug;
 
 	if (!hw_mgr_priv || !start_isp) {
 		CAM_ERR(CAM_ISP, "Invalid arguments");
@@ -2195,6 +2197,24 @@
 				sizeof(g_ife_hw_mgr.debug_cfg.csid_debug));
 	}
 
+	camif_debug = g_ife_hw_mgr.debug_cfg.camif_debug;
+	list_for_each_entry(hw_mgr_res, &ctx->res_list_ife_src, list) {
+		for (i = 0; i < CAM_ISP_HW_SPLIT_MAX; i++) {
+			if (!hw_mgr_res->hw_res[i])
+				continue;
+
+			rsrc_node = hw_mgr_res->hw_res[i];
+			if (rsrc_node->process_cmd && (rsrc_node->res_id ==
+				CAM_ISP_HW_VFE_IN_CAMIF)) {
+				rc = hw_mgr_res->hw_res[i]->process_cmd(
+					hw_mgr_res->hw_res[i],
+					CAM_ISP_HW_CMD_SET_CAMIF_DEBUG,
+					&camif_debug,
+					sizeof(camif_debug));
+			}
+		}
+	}
+
 	rc = cam_ife_hw_mgr_init_hw(ctx);
 	if (rc) {
 		CAM_ERR(CAM_ISP, "Init failed");
@@ -2806,45 +2826,133 @@
 	return rc;
 }
 
+static void cam_ife_mgr_print_io_bufs(struct cam_packet *packet,
+	int32_t iommu_hdl, int32_t sec_mmu_hdl, uint32_t pf_buf_info,
+	bool *mem_found)
+{
+	uint64_t   iova_addr;
+	size_t     src_buf_size;
+	int        i;
+	int        j;
+	int        rc = 0;
+	int32_t    mmu_hdl;
+
+	struct cam_buf_io_cfg  *io_cfg = NULL;
+
+	if (mem_found)
+		*mem_found = false;
+
+	io_cfg = (struct cam_buf_io_cfg *)((uint32_t *)&packet->payload +
+		packet->io_configs_offset / 4);
+
+	for (i = 0; i < packet->num_io_configs; i++) {
+		for (j = 0; j < CAM_PACKET_MAX_PLANES; j++) {
+			if (!io_cfg[i].mem_handle[j])
+				break;
+
+			if (GET_FD_FROM_HANDLE(io_cfg[i].mem_handle[j]) ==
+				GET_FD_FROM_HANDLE(pf_buf_info)) {
+				CAM_INFO(CAM_ISP,
+					"Found PF at port: %d mem %x fd: %x",
+					io_cfg[i].resource_type,
+					io_cfg[i].mem_handle[j],
+					pf_buf_info);
+				if (mem_found)
+					*mem_found = true;
+			}
+
+			CAM_INFO(CAM_ISP, "port: %d f: %u format: %d dir %d",
+				io_cfg[i].resource_type,
+				io_cfg[i].fence,
+				io_cfg[i].format,
+				io_cfg[i].direction);
+
+			mmu_hdl = cam_mem_is_secure_buf(
+				io_cfg[i].mem_handle[j]) ? sec_mmu_hdl :
+				iommu_hdl;
+			rc = cam_mem_get_io_buf(io_cfg[i].mem_handle[j],
+				mmu_hdl, &iova_addr, &src_buf_size);
+			if (rc < 0) {
+				CAM_ERR(CAM_ISP, "get src buf address fail");
+				continue;
+			}
+			if (iova_addr >> 32) {
+				CAM_ERR(CAM_ISP, "Invalid mapped address");
+				rc = -EINVAL;
+				continue;
+			}
+
+			CAM_INFO(CAM_ISP,
+				"pln %d w %d h %d size %d addr 0x%x offset 0x%x memh %x",
+				j, io_cfg[i].planes[j].width,
+				io_cfg[i].planes[j].height,
+				(int32_t)src_buf_size,
+				(unsigned int)iova_addr,
+				io_cfg[i].offsets[j],
+				io_cfg[i].mem_handle[j]);
+		}
+	}
+}
+
 static int cam_ife_mgr_cmd(void *hw_mgr_priv, void *cmd_args)
 {
 	int rc = 0;
-	struct cam_isp_hw_cmd_args  *hw_cmd_args  = cmd_args;
-	struct cam_ife_hw_mgr_ctx   *ctx;
+	struct cam_hw_cmd_args *hw_cmd_args = cmd_args;
+	struct cam_ife_hw_mgr  *hw_mgr = hw_mgr_priv;
+	struct cam_ife_hw_mgr_ctx *ctx = (struct cam_ife_hw_mgr_ctx *)
+		hw_cmd_args->ctxt_to_hw_map;
 
 	if (!hw_mgr_priv || !cmd_args) {
 		CAM_ERR(CAM_ISP, "Invalid arguments");
 		return -EINVAL;
 	}
 
-	ctx = (struct cam_ife_hw_mgr_ctx *)hw_cmd_args->ctxt_to_hw_map;
 	if (!ctx || !ctx->ctx_in_use) {
 		CAM_ERR(CAM_ISP, "Fatal: Invalid context is used");
 		return -EPERM;
 	}
 
 	switch (hw_cmd_args->cmd_type) {
-	case CAM_ISP_HW_MGR_CMD_IS_RDI_ONLY_CONTEXT:
-		if (ctx->is_rdi_only_context)
-			hw_cmd_args->u.is_rdi_only_context = 1;
-		else
-			hw_cmd_args->u.is_rdi_only_context = 0;
+	case CAM_HW_MGR_CMD_INTERNAL: {
+		struct cam_isp_hw_cmd_args *isp_hw_cmd_args =
+			(struct cam_isp_hw_cmd_args *)hw_cmd_args->
+				u.internal_args;
 
+		switch (isp_hw_cmd_args->cmd_type) {
+		case CAM_ISP_HW_MGR_CMD_IS_RDI_ONLY_CONTEXT:
+			if (ctx->is_rdi_only_context)
+				isp_hw_cmd_args->u.is_rdi_only_context = 1;
+			else
+				isp_hw_cmd_args->u.is_rdi_only_context = 0;
+			break;
+		case CAM_ISP_HW_MGR_CMD_PAUSE_HW:
+			cam_ife_mgr_pause_hw(ctx);
+			break;
+		case CAM_ISP_HW_MGR_CMD_RESUME_HW:
+			cam_ife_mgr_resume_hw(ctx);
+			break;
+		case CAM_ISP_HW_MGR_CMD_SOF_DEBUG:
+			cam_ife_mgr_sof_irq_debug(ctx,
+				isp_hw_cmd_args->u.sof_irq_enable);
+			break;
+		default:
+			CAM_ERR(CAM_ISP, "Invalid HW mgr command:0x%x",
+				hw_cmd_args->cmd_type);
+			rc = -EINVAL;
+			break;
+		}
 		break;
-	case CAM_ISP_HW_MGR_CMD_PAUSE_HW:
-		cam_ife_mgr_pause_hw(ctx);
-		break;
-	case CAM_ISP_HW_MGR_CMD_RESUME_HW:
-		cam_ife_mgr_resume_hw(ctx);
-		break;
-	case CAM_ISP_HW_MGR_CMD_SOF_DEBUG:
-		cam_ife_mgr_sof_irq_debug(ctx, hw_cmd_args->u.sof_irq_enable);
+	}
+	case CAM_HW_MGR_CMD_DUMP_PF_INFO:
+		cam_ife_mgr_print_io_bufs(
+			hw_cmd_args->u.pf_args.pf_data.packet,
+			hw_mgr->mgr_common.img_iommu_hdl,
+			hw_mgr->mgr_common.img_iommu_hdl_secure,
+			hw_cmd_args->u.pf_args.buf_info,
+			hw_cmd_args->u.pf_args.mem_found);
 		break;
 	default:
-		CAM_ERR(CAM_ISP, "Invalid HW mgr command:0x%x",
-			hw_cmd_args->cmd_type);
-		rc = -EINVAL;
-		break;
+		CAM_ERR(CAM_ISP, "Invalid cmd");
 	}
 
 	return rc;
@@ -4176,6 +4284,28 @@
 	cam_ife_get_csid_debug,
 	cam_ife_set_csid_debug, "%16llu");
 
+static int cam_ife_set_camif_debug(void *data, u64 val)
+{
+	g_ife_hw_mgr.debug_cfg.camif_debug = val;
+	CAM_DBG(CAM_ISP,
+		"Set camif enable_diag_sensor_status value :%lld", val);
+	return 0;
+}
+
+static int cam_ife_get_camif_debug(void *data, u64 *val)
+{
+	*val = g_ife_hw_mgr.debug_cfg.camif_debug;
+	CAM_DBG(CAM_ISP,
+		"Set camif enable_diag_sensor_status value :%lld",
+		g_ife_hw_mgr.debug_cfg.csid_debug);
+
+	return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(cam_ife_camif_debug,
+	cam_ife_get_camif_debug,
+	cam_ife_set_camif_debug, "%16llu");
+
 static int cam_ife_hw_mgr_debug_register(void)
 {
 	g_ife_hw_mgr.debug_cfg.dentry = debugfs_create_dir("camera_ife",
@@ -4201,6 +4331,14 @@
 		CAM_ERR(CAM_ISP, "failed to create enable_recovery");
 		goto err;
 	}
+
+	if (!debugfs_create_file("ife_camif_debug",
+		0644,
+		g_ife_hw_mgr.debug_cfg.dentry, NULL,
+		&cam_ife_camif_debug)) {
+		CAM_ERR(CAM_ISP, "failed to create cam_ife_camif_debug");
+		goto err;
+	}
 	g_ife_hw_mgr.debug_cfg.enable_recovery = 0;
 
 	return 0;
@@ -4210,7 +4348,7 @@
 	return -ENOMEM;
 }
 
-int cam_ife_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf)
+int cam_ife_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf, int *iommu_hdl)
 {
 	int rc = -EFAULT;
 	int i, j;
@@ -4382,6 +4520,9 @@
 	hw_mgr_intf->hw_config = cam_ife_mgr_config_hw;
 	hw_mgr_intf->hw_cmd = cam_ife_mgr_cmd;
 
+	if (iommu_hdl)
+		*iommu_hdl = g_ife_hw_mgr.mgr_common.img_iommu_hdl;
+
 	cam_ife_hw_mgr_debug_register();
 	CAM_DBG(CAM_ISP, "Exit");
 
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.h b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.h
index 0198f3d..9bfa34f 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.h
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.h
@@ -81,15 +81,17 @@
 /**
  * struct cam_ife_hw_mgr_debug - contain the debug information
  *
- * @dentry:              Debugfs entry
- * @csid_debug:          csid debug information
- * @enable_recovery      enable recovery
+ * @dentry:                    Debugfs entry
+ * @csid_debug:                csid debug information
+ * @enable_recovery:           enable recovery
+ * @enable_diag_sensor_status: enable sensor diagnosis status
  *
  */
 struct cam_ife_hw_mgr_debug {
 	struct dentry  *dentry;
 	uint64_t       csid_debug;
 	uint32_t       enable_recovery;
+	uint32_t       camif_debug;
 };
 
 /**
@@ -203,9 +205,10 @@
  *                      etnry functinon for the IFE HW manager.
  *
  * @hw_mgr_intf:        IFE hardware manager object returned
+ * @iommu_hdl:          Iommu handle to be returned
  *
  */
-int cam_ife_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf);
+int cam_ife_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf, int *iommu_hdl);
 
 /**
  * cam_ife_mgr_do_tasklet_buf_done()
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_isp_hw_mgr.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_isp_hw_mgr.c
index 2f18895..8b9c555 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_isp_hw_mgr.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_isp_hw_mgr.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -16,7 +16,7 @@
 
 
 int cam_isp_hw_mgr_init(struct device_node *of_node,
-	struct cam_hw_mgr_intf *hw_mgr)
+	struct cam_hw_mgr_intf *hw_mgr, int *iommu_hdl)
 {
 	int rc = 0;
 	const char *compat_str = NULL;
@@ -25,7 +25,7 @@
 		(const char **)&compat_str);
 
 	if (strnstr(compat_str, "ife", strlen(compat_str)))
-		rc = cam_ife_hw_mgr_init(hw_mgr);
+		rc = cam_ife_hw_mgr_init(hw_mgr, iommu_hdl);
 	else {
 		CAM_ERR(CAM_ISP, "Invalid ISP hw type");
 		rc = -EINVAL;
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/cam_isp_packet_parser.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/cam_isp_packet_parser.c
index eaa7325..c30d27f 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/cam_isp_packet_parser.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/cam_isp_packet_parser.c
@@ -457,6 +457,7 @@
 	num_out_buf = 0;
 	num_in_buf  = 0;
 	io_cfg_used_bytes = 0;
+	prepare->pf_data->packet = prepare->packet;
 
 	/* Max one hw entries required for each base */
 	if (prepare->num_hw_update_entries + 1 >=
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/include/cam_isp_hw_mgr_intf.h b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/include/cam_isp_hw_mgr_intf.h
index fd71c37..1586216 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/include/cam_isp_hw_mgr_intf.h
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/include/cam_isp_hw_mgr_intf.h
@@ -203,13 +203,11 @@
 /**
  * struct cam_isp_hw_cmd_args - Payload for hw manager command
  *
- * @ctxt_to_hw_map:        HW context from the acquire
  * @cmd_type               HW command type
  * @get_context            Get context type information
  */
 struct cam_isp_hw_cmd_args {
-	void                               *ctxt_to_hw_map;
-	uint32_t                            cmd_type;
+	uint32_t                              cmd_type;
 	union {
 		uint32_t                      is_rdi_only_context;
 		uint32_t                      sof_irq_enable;
@@ -225,9 +223,9 @@
  * @of_node:            Device node input
  * @hw_mgr:             Input/output structure for the ISP hardware manager
  *                          initialization
- *
+ * @iommu_hdl:          Iommu handle to be returned
  */
 int cam_isp_hw_mgr_init(struct device_node *of_node,
-	struct cam_hw_mgr_intf *hw_mgr);
+	struct cam_hw_mgr_intf *hw_mgr, int *iommu_hdl);
 
 #endif /* __CAM_ISP_HW_MGR_INTF_H__ */
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid170.h b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid170.h
index c68ddf7..f90356a 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid170.h
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid170.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -52,6 +52,7 @@
 	.csid_ipp_timestamp_perv1_eof_addr   = 0x2ac,
 	/* configurations */
 	.pix_store_en_shift_val              = 7,
+	.early_eof_en_shift_val              = 29,
 };
 
 static struct cam_ife_csid_rdi_reg_offset cam_ife_csid_170_rdi_0_reg_offset = {
@@ -286,6 +287,8 @@
 	.crop_shift                                   = 16,
 	.ipp_irq_mask_all                             = 0x7FFF,
 	.rdi_irq_mask_all                             = 0x7FFF,
+	.measure_en_hbi_vbi_cnt_mask                  = 0xC,
+	.format_measure_en_val                        = 1,
 };
 
 struct cam_ife_csid_reg_offset cam_ife_csid_170_reg_offset = {
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.c
index 47f44ea..9ffd923 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.c
@@ -1395,8 +1395,12 @@
 	cam_io_w_mb(val, soc_info->reg_map[0].mem_base +
 		csid_reg->ipp_reg->csid_ipp_cfg0_addr);
 
+	val = cam_io_r_mb(soc_info->reg_map[0].mem_base +
+		csid_reg->ipp_reg->csid_ipp_cfg1_addr);
+
 	/* select the post irq sub sample strobe for time stamp capture */
-	cam_io_w_mb(CSID_TIMESTAMP_STB_POST_IRQ, soc_info->reg_map[0].mem_base +
+	val |= CSID_TIMESTAMP_STB_POST_IRQ;
+	cam_io_w_mb(val, soc_info->reg_map[0].mem_base +
 		csid_reg->ipp_reg->csid_ipp_cfg1_addr);
 
 	if (path_data->crop_enable) {
@@ -1415,6 +1419,16 @@
 			csid_reg->ipp_reg->csid_ipp_vcrop_addr);
 		CAM_DBG(CAM_ISP, "CSID:%d Vertical Crop config val: 0x%x",
 			csid_hw->hw_intf->hw_idx, val);
+
+		/* Enable generating early eof strobe based on crop config */
+		if (!(csid_hw->csid_debug & CSID_DEBUG_DISABLE_EARLY_EOF)) {
+			val = cam_io_r_mb(soc_info->reg_map[0].mem_base +
+				csid_reg->ipp_reg->csid_ipp_cfg0_addr);
+			val |= (1 <<
+				csid_reg->ipp_reg->early_eof_en_shift_val);
+			cam_io_w_mb(val, soc_info->reg_map[0].mem_base +
+				csid_reg->ipp_reg->csid_ipp_cfg0_addr);
+		}
 	}
 
 	/* set frame drop pattern to 0 and period to 1 */
@@ -1443,9 +1457,23 @@
 	val = cam_io_r_mb(soc_info->reg_map[0].mem_base +
 		csid_reg->ipp_reg->csid_ipp_cfg0_addr);
 	val |= (1 << csid_reg->cmn_reg->path_en_shift_val);
+
+	if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_HBI_VBI_INFO)
+		val |= csid_reg->cmn_reg->format_measure_en_val;
+
 	cam_io_w_mb(val, soc_info->reg_map[0].mem_base +
 		csid_reg->ipp_reg->csid_ipp_cfg0_addr);
 
+	/* Enable the HBI/VBI counter */
+	if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_HBI_VBI_INFO) {
+		val = cam_io_r_mb(soc_info->reg_map[0].mem_base +
+			csid_reg->ipp_reg->csid_ipp_format_measure_cfg0_addr);
+		val |= csid_reg->cmn_reg->measure_en_hbi_vbi_cnt_mask;
+		cam_io_w_mb(val,
+			soc_info->reg_map[0].mem_base +
+			csid_reg->ipp_reg->csid_ipp_format_measure_cfg0_addr);
+	}
+
 	/* configure the rx packet capture based on csid debug set */
 	val = 0;
 	if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_SHORT_PKT_CAPTURE)
@@ -1484,8 +1512,10 @@
 	struct cam_isp_resource_node    *res)
 {
 	int rc = 0;
+	uint32_t val = 0;
 	struct cam_ife_csid_reg_offset      *csid_reg;
 	struct cam_hw_soc_info              *soc_info;
+	struct cam_ife_csid_ipp_reg_offset  *ipp_reg;
 
 	csid_reg = csid_hw->csid_info->csid_reg;
 	soc_info = &csid_hw->hw_info->soc_info;
@@ -1503,8 +1533,26 @@
 			csid_hw->hw_intf->hw_idx,
 			res->res_id);
 		rc = -EINVAL;
+		goto end;
 	}
 
+	ipp_reg = csid_reg->ipp_reg;
+	val = cam_io_r_mb(soc_info->reg_map[0].mem_base +
+			ipp_reg->csid_ipp_cfg0_addr);
+	if (val & csid_reg->cmn_reg->format_measure_en_val) {
+		val &= ~csid_reg->cmn_reg->format_measure_en_val;
+		cam_io_w_mb(val, soc_info->reg_map[0].mem_base +
+			ipp_reg->csid_ipp_cfg0_addr);
+
+		/* Disable the HBI/VBI counter */
+		val = cam_io_r_mb(soc_info->reg_map[0].mem_base +
+			ipp_reg->csid_ipp_format_measure_cfg0_addr);
+		val &= ~csid_reg->cmn_reg->measure_en_hbi_vbi_cnt_mask;
+		cam_io_w_mb(val, soc_info->reg_map[0].mem_base +
+			ipp_reg->csid_ipp_format_measure_cfg0_addr);
+	}
+
+end:
 	res->res_state = CAM_ISP_RESOURCE_STATE_RESERVED;
 	return rc;
 }
@@ -1649,6 +1697,7 @@
 	struct cam_ife_csid_reg_offset         *csid_reg;
 	struct cam_hw_soc_info                 *soc_info;
 	uint32_t path_format = 0, plain_fmt = 0, val = 0, id;
+	uint32_t format_measure_addr;
 
 	path_data = (struct cam_ife_csid_path_cfg   *) res->res_priv;
 	csid_reg = csid_hw->csid_info->csid_reg;
@@ -1742,9 +1791,24 @@
 		csid_reg->rdi_reg[id]->csid_rdi_cfg0_addr);
 	val |= (1 << csid_reg->cmn_reg->path_en_shift_val);
 
+	if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_HBI_VBI_INFO)
+		val |= csid_reg->cmn_reg->format_measure_en_val;
+
 	cam_io_w_mb(val, soc_info->reg_map[0].mem_base +
 		csid_reg->rdi_reg[id]->csid_rdi_cfg0_addr);
 
+	format_measure_addr =
+		csid_reg->rdi_reg[id]->csid_rdi_format_measure_cfg0_addr;
+
+	/* Enable the HBI/VBI counter */
+	if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_HBI_VBI_INFO) {
+		val = cam_io_r_mb(soc_info->reg_map[0].mem_base +
+			format_measure_addr);
+		val |= csid_reg->cmn_reg->measure_en_hbi_vbi_cnt_mask;
+		cam_io_w_mb(val,
+			soc_info->reg_map[0].mem_base + format_measure_addr);
+	}
+
 	/* configure the rx packet capture based on csid debug set */
 	if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_SHORT_PKT_CAPTURE)
 		val = ((1 <<
@@ -1780,7 +1844,7 @@
 	struct cam_isp_resource_node    *res)
 {
 	int rc = 0;
-	uint32_t id;
+	uint32_t id, val, format_measure_addr;
 	struct cam_ife_csid_reg_offset      *csid_reg;
 	struct cam_hw_soc_info              *soc_info;
 
@@ -1797,6 +1861,24 @@
 		return -EINVAL;
 	}
 
+	format_measure_addr =
+		csid_reg->rdi_reg[id]->csid_rdi_format_measure_cfg0_addr;
+
+	if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_HBI_VBI_INFO) {
+		val = cam_io_r_mb(soc_info->reg_map[0].mem_base +
+			csid_reg->rdi_reg[id]->csid_rdi_cfg0_addr);
+		val &= ~csid_reg->cmn_reg->format_measure_en_val;
+		cam_io_w_mb(val, soc_info->reg_map[0].mem_base +
+			csid_reg->rdi_reg[id]->csid_rdi_cfg0_addr);
+
+		/* Disable the HBI/VBI counter */
+		val = cam_io_r_mb(soc_info->reg_map[0].mem_base +
+			format_measure_addr);
+		val &= ~csid_reg->cmn_reg->measure_en_hbi_vbi_cnt_mask;
+		cam_io_w_mb(val, soc_info->reg_map[0].mem_base +
+			format_measure_addr);
+	}
+
 	res->res_state = CAM_ISP_RESOURCE_STATE_RESERVED;
 	return rc;
 }
@@ -1899,6 +1981,55 @@
 	return rc;
 }
 
+static int cam_ife_csid_get_hbi_vbi(
+	struct cam_ife_csid_hw   *csid_hw,
+	struct cam_isp_resource_node *res)
+{
+	uint32_t  hbi, vbi;
+	const struct cam_ife_csid_reg_offset     *csid_reg;
+	const struct cam_ife_csid_rdi_reg_offset *rdi_reg;
+	struct cam_hw_soc_info                   *soc_info;
+
+	csid_reg = csid_hw->csid_info->csid_reg;
+	soc_info = &csid_hw->hw_info->soc_info;
+
+	if (res->res_type != CAM_ISP_RESOURCE_PIX_PATH ||
+		res->res_id >= CAM_IFE_PIX_PATH_RES_MAX) {
+		CAM_ERR(CAM_ISP, "CSID:%d Invalid res_type:%d res id%d",
+			csid_hw->hw_intf->hw_idx, res->res_type,
+			res->res_id);
+		return -EINVAL;
+	}
+
+	if (csid_hw->hw_info->hw_state != CAM_HW_STATE_POWER_UP) {
+		CAM_ERR(CAM_ISP, "CSID:%d Invalid dev state :%d",
+			csid_hw->hw_intf->hw_idx,
+			csid_hw->hw_info->hw_state);
+		return -EINVAL;
+	}
+
+	if (res->res_id == CAM_IFE_PIX_PATH_RES_IPP) {
+		hbi = cam_io_r_mb(soc_info->reg_map[0].mem_base +
+			csid_reg->ipp_reg->csid_ipp_format_measure1_addr);
+		vbi = cam_io_r_mb(soc_info->reg_map[0].mem_base +
+			csid_reg->ipp_reg->csid_ipp_format_measure2_addr);
+	} else {
+		rdi_reg = csid_reg->rdi_reg[res->res_id];
+		hbi = cam_io_r_mb(soc_info->reg_map[0].mem_base +
+			rdi_reg->csid_rdi_format_measure1_addr);
+		vbi = cam_io_r_mb(soc_info->reg_map[0].mem_base +
+			rdi_reg->csid_rdi_format_measure2_addr);
+	}
+
+	CAM_INFO_RATE_LIMIT(CAM_ISP, "Resource %u HBI: 0x%x", res->res_id,
+		hbi);
+	CAM_INFO_RATE_LIMIT(CAM_ISP, "Resource %u VBI: 0x%x", res->res_id,
+		vbi);
+
+	return 0;
+}
+
+
 static int cam_ife_csid_get_time_stamp(
 		struct cam_ife_csid_hw   *csid_hw, void *cmd_args)
 {
@@ -2552,6 +2683,7 @@
 	int rc = 0;
 	struct cam_ife_csid_hw               *csid_hw;
 	struct cam_hw_info                   *csid_hw_info;
+	struct cam_isp_resource_node         *res = NULL;
 
 	if (!hw_priv || !cmd_args) {
 		CAM_ERR(CAM_ISP, "CSID: Invalid arguments");
@@ -2564,6 +2696,11 @@
 	switch (cmd_type) {
 	case CAM_IFE_CSID_CMD_GET_TIME_STAMP:
 		rc = cam_ife_csid_get_time_stamp(csid_hw, cmd_args);
+		if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_HBI_VBI_INFO) {
+			res = ((struct cam_csid_get_time_stamp_args *)
+				cmd_args)->node_res;
+			cam_ife_csid_get_hbi_vbi(csid_hw, res);
+		}
 		break;
 	case CAM_IFE_CSID_SET_CSID_DEBUG:
 		rc = cam_ife_csid_set_csid_debug(csid_hw, cmd_args);
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.h b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.h
index 74aa199..c547f4c 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.h
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.h
@@ -76,6 +76,8 @@
 #define CSID_DEBUG_ENABLE_SHORT_PKT_CAPTURE       BIT(4)
 #define CSID_DEBUG_ENABLE_LONG_PKT_CAPTURE        BIT(5)
 #define CSID_DEBUG_ENABLE_CPHY_PKT_CAPTURE        BIT(6)
+#define CSID_DEBUG_ENABLE_HBI_VBI_INFO            BIT(7)
+#define CSID_DEBUG_DISABLE_EARLY_EOF              BIT(8)
 
 /* enum cam_csid_path_halt_mode select the path halt mode control */
 enum cam_csid_path_halt_mode {
@@ -135,6 +137,7 @@
 
 	/* configuration */
 	uint32_t  pix_store_en_shift_val;
+	uint32_t  early_eof_en_shift_val;
 };
 
 struct cam_ife_csid_rdi_reg_offset {
@@ -285,6 +288,8 @@
 	uint32_t crop_shift;
 	uint32_t ipp_irq_mask_all;
 	uint32_t rdi_irq_mask_all;
+	uint32_t measure_en_hbi_vbi_cnt_mask;
+	uint32_t format_measure_en_val;
 };
 
 /**
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/include/cam_isp_hw.h b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/include/cam_isp_hw.h
index 28cfcc8..54aa4c2 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/include/cam_isp_hw.h
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/include/cam_isp_hw.h
@@ -96,6 +96,7 @@
 	CAM_ISP_HW_CMD_STOP_BUS_ERR_IRQ,
 	CAM_ISP_HW_CMD_GET_REG_DUMP,
 	CAM_ISP_HW_CMD_SOF_IRQ_DEBUG,
+	CAM_ISP_HW_CMD_SET_CAMIF_DEBUG,
 	CAM_ISP_HW_CMD_MAX,
 };
 
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe170/cam_vfe170.h b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe170/cam_vfe170.h
index c7d3aa2..d1284d9 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe170/cam_vfe170.h
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe170/cam_vfe170.h
@@ -50,6 +50,8 @@
 	.raw_crop_width_cfg       = 0x00000CE4,
 	.raw_crop_height_cfg      = 0x00000CE8,
 	.reg_update_cmd           = 0x000004AC,
+	.vfe_diag_config          = 0x00000C48,
+	.vfe_diag_sensor_status   = 0x00000C4C,
 };
 
 static struct cam_vfe_camif_reg_data vfe_170_camif_reg_data = {
@@ -79,6 +81,7 @@
 	.eof_irq_mask                    = 0x00000002,
 	.error_irq_mask0                 = 0x0003FC00,
 	.error_irq_mask1                 = 0x0FFF7E80,
+	.enable_diagnostic_hw            = 0x1,
 };
 
 struct cam_vfe_top_ver2_reg_offset_module_ctrl lens_170_reg = {
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_camif_ver2.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_camif_ver2.c
index 1da2d2e..fc257ec 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_camif_ver2.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_camif_ver2.c
@@ -43,6 +43,7 @@
 	uint32_t                           last_line;
 	bool                               enable_sof_irq_debug;
 	uint32_t                           irq_debug_cnt;
+	uint32_t                           camif_debug;
 };
 
 static int cam_vfe_camif_validate_pix_pattern(uint32_t pattern)
@@ -309,6 +310,15 @@
 	rsrc_data->enable_sof_irq_debug = false;
 	rsrc_data->irq_debug_cnt = 0;
 
+	if (rsrc_data->camif_debug &
+		CAMIF_DEBUG_ENABLE_SENSOR_DIAG_STATUS) {
+		val = cam_io_r_mb(rsrc_data->mem_base +
+			rsrc_data->camif_reg->vfe_diag_config);
+		val |= rsrc_data->reg_data->enable_diagnostic_hw;
+		cam_io_w_mb(val, rsrc_data->mem_base +
+			rsrc_data->camif_reg->vfe_diag_config);
+	}
+
 	CAM_DBG(CAM_ISP, "Start Camif IFE %d Done", camif_res->hw_intf->hw_idx);
 	return 0;
 }
@@ -400,6 +410,14 @@
 	if (camif_res->res_state == CAM_ISP_RESOURCE_STATE_STREAMING)
 		camif_res->res_state = CAM_ISP_RESOURCE_STATE_RESERVED;
 
+	val = cam_io_r_mb(camif_priv->mem_base +
+			camif_priv->camif_reg->vfe_diag_config);
+	if (val & camif_priv->reg_data->enable_diagnostic_hw) {
+		val &= ~camif_priv->reg_data->enable_diagnostic_hw;
+		cam_io_w_mb(val, camif_priv->mem_base +
+			camif_priv->camif_reg->vfe_diag_config);
+	}
+
 	return rc;
 }
 
@@ -424,6 +442,7 @@
 	uint32_t cmd_type, void *cmd_args, uint32_t arg_size)
 {
 	int rc = -EINVAL;
+	struct cam_vfe_mux_camif_data *camif_priv = NULL;
 
 	if (!rsrc_node || !cmd_args) {
 		CAM_ERR(CAM_ISP, "Invalid input arguments");
@@ -441,6 +460,11 @@
 	case CAM_ISP_HW_CMD_SOF_IRQ_DEBUG:
 		rc = cam_vfe_camif_sof_irq_debug(rsrc_node, cmd_args);
 		break;
+	case CAM_ISP_HW_CMD_SET_CAMIF_DEBUG:
+		camif_priv =
+			(struct cam_vfe_mux_camif_data *)rsrc_node->res_priv;
+		camif_priv->camif_debug = *((uint32_t *)cmd_args);
+		break;
 	default:
 		CAM_ERR(CAM_ISP,
 			"unsupported process command:%d", cmd_type);
@@ -465,6 +489,7 @@
 	struct cam_vfe_top_irq_evt_payload   *payload;
 	uint32_t                              irq_status0;
 	uint32_t                              irq_status1;
+	uint32_t                              val;
 
 	if (!handler_priv || !evt_payload_priv) {
 		CAM_ERR(CAM_ISP, "Invalid params");
@@ -527,6 +552,14 @@
 		} else {
 			ret = CAM_ISP_HW_ERROR_NONE;
 		}
+
+		if (camif_priv->camif_debug &
+			CAMIF_DEBUG_ENABLE_SENSOR_DIAG_STATUS) {
+			val = cam_io_r(camif_priv->mem_base +
+				camif_priv->camif_reg->vfe_diag_sensor_status);
+			CAM_DBG(CAM_ISP, "VFE_DIAG_SENSOR_STATUS: 0x%x",
+				camif_priv->mem_base, val);
+		}
 		break;
 	default:
 		break;
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_camif_ver2.h b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_camif_ver2.h
index 4a73bd7..7a69589 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_camif_ver2.h
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_camif_ver2.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -16,6 +16,11 @@
 #include "cam_isp_hw.h"
 #include "cam_vfe_top.h"
 
+/*
+ * Debug values for camif module
+ */
+#define CAMIF_DEBUG_ENABLE_SENSOR_DIAG_STATUS      BIT(0)
+
 struct cam_vfe_camif_ver2_reg {
 	uint32_t     camif_cmd;
 	uint32_t     camif_config;
@@ -27,6 +32,8 @@
 	uint32_t     raw_crop_width_cfg;
 	uint32_t     raw_crop_height_cfg;
 	uint32_t     reg_update_cmd;
+	uint32_t     vfe_diag_config;
+	uint32_t     vfe_diag_sensor_status;
 };
 
 struct cam_vfe_camif_reg_data {
@@ -63,6 +70,8 @@
 	uint32_t     eof_irq_mask;
 	uint32_t     error_irq_mask0;
 	uint32_t     error_irq_mask1;
+
+	uint32_t     enable_diagnostic_hw;
 };
 
 struct cam_vfe_camif_ver2_hw_info {
diff --git a/drivers/media/platform/msm/camera/cam_jpeg/cam_jpeg_context.c b/drivers/media/platform/msm/camera/cam_jpeg/cam_jpeg_context.c
index 02334a4..287d4a4 100644
--- a/drivers/media/platform/msm/camera/cam_jpeg/cam_jpeg_context.c
+++ b/drivers/media/platform/msm/camera/cam_jpeg/cam_jpeg_context.c
@@ -20,9 +20,49 @@
 #include "cam_jpeg_context.h"
 #include "cam_context_utils.h"
 #include "cam_debug_util.h"
+#include "cam_packet_util.h"
 
 static const char jpeg_dev_name[] = "jpeg";
 
+static int cam_jpeg_context_dump_active_request(void *data, unsigned long iova,
+	uint32_t buf_info)
+{
+
+	struct cam_context *ctx = (struct cam_context *)data;
+	struct cam_ctx_request          *req = NULL;
+	struct cam_ctx_request          *req_temp = NULL;
+	struct cam_hw_mgr_dump_pf_data  *pf_dbg_entry = NULL;
+	int rc = 0;
+	int closest_port;
+	bool b_mem_found = false;
+
+
+	if (!ctx) {
+		CAM_ERR(CAM_JPEG, "Invalid ctx");
+		return -EINVAL;
+	}
+
+	CAM_INFO(CAM_JPEG, "iommu fault for jpeg ctx %d state %d",
+		ctx->ctx_id, ctx->state);
+
+	list_for_each_entry_safe(req, req_temp,
+			&ctx->active_req_list, list) {
+		pf_dbg_entry = &(req->pf_data);
+		closest_port = -1;
+		CAM_INFO(CAM_JPEG, "req_id : %lld ", req->request_id);
+
+		rc = cam_context_dump_pf_info_to_hw(ctx, pf_dbg_entry->packet,
+			iova, buf_info, &b_mem_found);
+		if (rc)
+			CAM_ERR(CAM_JPEG, "Failed to dump pf info");
+
+		if (b_mem_found)
+			CAM_ERR(CAM_JPEG, "Found page fault in req %lld %d",
+				req->request_id, rc);
+	}
+	return rc;
+}
+
 static int __cam_jpeg_ctx_acquire_dev_in_available(struct cam_context *ctx,
 	struct cam_acquire_dev_cmd *cmd)
 {
@@ -116,6 +156,7 @@
 		},
 		.crm_ops = { },
 		.irq_ops = __cam_jpeg_ctx_handle_buf_done_in_acquired,
+		.pagefault_ops = cam_jpeg_context_dump_active_request,
 	},
 };
 
diff --git a/drivers/media/platform/msm/camera/cam_jpeg/cam_jpeg_dev.c b/drivers/media/platform/msm/camera/cam_jpeg/cam_jpeg_dev.c
index 46cc08f..1489222 100644
--- a/drivers/media/platform/msm/camera/cam_jpeg/cam_jpeg_dev.c
+++ b/drivers/media/platform/msm/camera/cam_jpeg/cam_jpeg_dev.c
@@ -22,11 +22,31 @@
 #include "cam_jpeg_hw_mgr_intf.h"
 #include "cam_jpeg_dev.h"
 #include "cam_debug_util.h"
+#include "cam_smmu_api.h"
 
 #define CAM_JPEG_DEV_NAME "cam-jpeg"
 
 static struct cam_jpeg_dev g_jpeg_dev;
 
+static void cam_jpeg_dev_iommu_fault_handler(
+	struct iommu_domain *domain, struct device *dev, unsigned long iova,
+	int flags, void *token, uint32_t buf_info)
+{
+	int i = 0;
+	struct cam_node *node = NULL;
+
+	if (!token) {
+		CAM_ERR(CAM_JPEG, "invalid token in page handler cb");
+		return;
+	}
+
+	node = (struct cam_node *)token;
+
+	for (i = 0; i < node->ctx_size; i++)
+		cam_context_dump_pf_info(&(node->ctx_list[i]), iova,
+			buf_info);
+}
+
 static const struct of_device_id cam_jpeg_dt_match[] = {
 	{
 		.compatible = "qcom,cam-jpeg"
@@ -34,23 +54,50 @@
 	{ }
 };
 
-static int cam_jpeg_subdev_close(struct v4l2_subdev *sd,
+static int cam_jpeg_subdev_open(struct v4l2_subdev *sd,
 	struct v4l2_subdev_fh *fh)
 {
-	struct cam_node *node = v4l2_get_subdevdata(sd);
 
-	if (!node) {
-		CAM_ERR(CAM_JPEG, "Node ptr is NULL");
-		return -EINVAL;
-	}
-
-	cam_node_shutdown(node);
+	mutex_lock(&g_jpeg_dev.jpeg_mutex);
+	g_jpeg_dev.open_cnt++;
+	mutex_unlock(&g_jpeg_dev.jpeg_mutex);
 
 	return 0;
 }
 
+static int cam_jpeg_subdev_close(struct v4l2_subdev *sd,
+	struct v4l2_subdev_fh *fh)
+{
+	int rc = 0;
+	struct cam_node *node = v4l2_get_subdevdata(sd);
+
+
+	mutex_lock(&g_jpeg_dev.jpeg_mutex);
+	if (g_jpeg_dev.open_cnt <= 0) {
+		CAM_DBG(CAM_JPEG, "JPEG subdev is already closed");
+		rc = -EINVAL;
+		goto end;
+	}
+
+	g_jpeg_dev.open_cnt--;
+
+	if (!node) {
+		CAM_ERR(CAM_JPEG, "Node ptr is NULL");
+		rc = -EINVAL;
+		goto end;
+	}
+
+	if (g_jpeg_dev.open_cnt == 0)
+		cam_node_shutdown(node);
+
+end:
+	mutex_unlock(&g_jpeg_dev.jpeg_mutex);
+	return rc;
+}
+
 static const struct v4l2_subdev_internal_ops cam_jpeg_subdev_internal_ops = {
 	.close = cam_jpeg_subdev_close,
+	.open = cam_jpeg_subdev_open,
 };
 
 static int cam_jpeg_dev_remove(struct platform_device *pdev)
@@ -78,6 +125,7 @@
 	int i;
 	struct cam_hw_mgr_intf hw_mgr_intf;
 	struct cam_node *node;
+	int iommu_hdl = -1;
 
 	g_jpeg_dev.sd.internal_ops = &cam_jpeg_subdev_internal_ops;
 	rc = cam_subdev_probe(&g_jpeg_dev.sd, pdev, CAM_JPEG_DEV_NAME,
@@ -89,7 +137,7 @@
 	node = (struct cam_node *)g_jpeg_dev.sd.token;
 
 	rc = cam_jpeg_hw_mgr_init(pdev->dev.of_node,
-		(uint64_t *)&hw_mgr_intf);
+		(uint64_t *)&hw_mgr_intf, &iommu_hdl);
 	if (rc) {
 		CAM_ERR(CAM_JPEG, "Can not initialize JPEG HWmanager %d", rc);
 		goto unregister;
@@ -114,6 +162,9 @@
 		goto ctx_init_fail;
 	}
 
+	cam_smmu_set_client_page_fault_handler(iommu_hdl,
+		cam_jpeg_dev_iommu_fault_handler, node);
+
 	mutex_init(&g_jpeg_dev.jpeg_mutex);
 
 	CAM_INFO(CAM_JPEG, "Camera JPEG probe complete");
diff --git a/drivers/media/platform/msm/camera/cam_jpeg/cam_jpeg_dev.h b/drivers/media/platform/msm/camera/cam_jpeg/cam_jpeg_dev.h
index deab2d5..0d15ced 100644
--- a/drivers/media/platform/msm/camera/cam_jpeg/cam_jpeg_dev.h
+++ b/drivers/media/platform/msm/camera/cam_jpeg/cam_jpeg_dev.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -26,6 +26,7 @@
  * @ctx: JPEG base context storage
  * @ctx_jpeg: JPEG private context storage
  * @jpeg_mutex: Jpeg dev mutex
+ * @open_cnt: Open device count
  */
 struct cam_jpeg_dev {
 	struct cam_subdev sd;
@@ -33,5 +34,6 @@
 	struct cam_context ctx[CAM_CTX_MAX];
 	struct cam_jpeg_context ctx_jpeg[CAM_CTX_MAX];
 	struct mutex jpeg_mutex;
+	int32_t open_cnt;
 };
 #endif /* __CAM_JPEG_DEV_H__ */
diff --git a/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/cam_jpeg_hw_mgr.c b/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/cam_jpeg_hw_mgr.c
index f0913b2..a82e0d2 100644
--- a/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/cam_jpeg_hw_mgr.c
+++ b/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/cam_jpeg_hw_mgr.c
@@ -600,6 +600,74 @@
 	return rc;
 }
 
+static void cam_jpeg_mgr_print_io_bufs(struct cam_packet *packet,
+	int32_t iommu_hdl, int32_t sec_mmu_hdl, uint32_t pf_buf_info,
+	bool *mem_found)
+{
+	uint64_t   iova_addr;
+	size_t     src_buf_size;
+	int        i;
+	int        j;
+	int        rc = 0;
+	int32_t    mmu_hdl;
+	struct cam_buf_io_cfg  *io_cfg = NULL;
+
+	if (mem_found)
+		*mem_found = false;
+
+	io_cfg = (struct cam_buf_io_cfg *)((uint32_t *)&packet->payload +
+		packet->io_configs_offset / 4);
+
+	for (i = 0; i < packet->num_io_configs; i++) {
+		for (j = 0; j < CAM_PACKET_MAX_PLANES; j++) {
+			if (!io_cfg[i].mem_handle[j])
+				break;
+
+			if (GET_FD_FROM_HANDLE(io_cfg[i].mem_handle[j]) ==
+				GET_FD_FROM_HANDLE(pf_buf_info)) {
+				CAM_INFO(CAM_JPEG,
+					"Found PF at port: %d mem %x fd: %x",
+					io_cfg[i].resource_type,
+					io_cfg[i].mem_handle[j],
+					pf_buf_info);
+				if (mem_found)
+					*mem_found = true;
+			}
+
+			CAM_INFO(CAM_JPEG, "port: %d f: %u format: %d dir %d",
+				io_cfg[i].resource_type,
+				io_cfg[i].fence,
+				io_cfg[i].format,
+				io_cfg[i].direction);
+
+			mmu_hdl = cam_mem_is_secure_buf(
+				io_cfg[i].mem_handle[j]) ? sec_mmu_hdl :
+				iommu_hdl;
+			rc = cam_mem_get_io_buf(io_cfg[i].mem_handle[j],
+				mmu_hdl, &iova_addr, &src_buf_size);
+			if (rc < 0) {
+				CAM_ERR(CAM_UTIL, "get src buf address fail");
+				continue;
+			}
+			if (iova_addr >> 32) {
+				CAM_ERR(CAM_JPEG, "Invalid mapped address");
+				rc = -EINVAL;
+				continue;
+			}
+
+			CAM_INFO(CAM_JPEG,
+				"pln %d w %d h %d size %d addr 0x%x offset 0x%x memh %x",
+				j, io_cfg[i].planes[j].width,
+				io_cfg[i].planes[j].height,
+				(int32_t)src_buf_size,
+				(unsigned int)iova_addr,
+				io_cfg[i].offsets[j],
+				io_cfg[i].mem_handle[j]);
+
+			iova_addr += io_cfg[i].offsets[j];
+		}
+	}
+}
 
 static int cam_jpeg_mgr_prepare_hw_update(void *hw_mgr_priv,
 	void *prepare_hw_update_args)
@@ -675,6 +743,7 @@
 	CAM_DBG(CAM_JPEG, "packet = %pK io_cfg_ptr = %pK size = %lu",
 		(void *)packet, (void *)io_cfg_ptr,
 		sizeof(struct cam_buf_io_cfg));
+	prepare_args->pf_data->packet = packet;
 
 	prepare_args->num_out_map_entries = 0;
 
@@ -1410,7 +1479,35 @@
 	return rc;
 }
 
-int cam_jpeg_hw_mgr_init(struct device_node *of_node, uint64_t *hw_mgr_hdl)
+static int cam_jpeg_mgr_cmd(void *hw_mgr_priv, void *cmd_args)
+{
+	int rc = 0;
+	struct cam_hw_cmd_args *hw_cmd_args = cmd_args;
+	struct cam_jpeg_hw_mgr *hw_mgr = hw_mgr_priv;
+
+	if (!hw_mgr_priv || !cmd_args) {
+		CAM_ERR(CAM_JPEG, "Invalid arguments");
+		return -EINVAL;
+	}
+
+	switch (hw_cmd_args->cmd_type) {
+	case CAM_HW_MGR_CMD_DUMP_PF_INFO:
+		cam_jpeg_mgr_print_io_bufs(
+			hw_cmd_args->u.pf_args.pf_data.packet,
+			hw_mgr->iommu_hdl,
+			hw_mgr->iommu_sec_hdl,
+			hw_cmd_args->u.pf_args.buf_info,
+			hw_cmd_args->u.pf_args.mem_found);
+		break;
+	default:
+		CAM_ERR(CAM_JPEG, "Invalid cmd");
+	}
+
+	return rc;
+}
+
+int cam_jpeg_hw_mgr_init(struct device_node *of_node, uint64_t *hw_mgr_hdl,
+	int *iommu_hdl)
 {
 	int i, rc;
 	uint32_t num_dev;
@@ -1434,6 +1531,7 @@
 	hw_mgr_intf->hw_config = cam_jpeg_mgr_config_hw;
 	hw_mgr_intf->hw_flush = cam_jpeg_mgr_hw_flush;
 	hw_mgr_intf->hw_stop = cam_jpeg_mgr_hw_stop;
+	hw_mgr_intf->hw_cmd = cam_jpeg_mgr_cmd;
 
 	mutex_init(&g_jpeg_hw_mgr.hw_mgr_mutex);
 	spin_lock_init(&g_jpeg_hw_mgr.hw_mgr_lock);
@@ -1495,6 +1593,9 @@
 		goto cdm_iommu_failed;
 	}
 
+	if (iommu_hdl)
+		*iommu_hdl = g_jpeg_hw_mgr.iommu_hdl;
+
 	return rc;
 
 cdm_iommu_failed:
diff --git a/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/include/cam_jpeg_hw_mgr_intf.h b/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/include/cam_jpeg_hw_mgr_intf.h
index 5fb4e3ad..5705890 100644
--- a/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/include/cam_jpeg_hw_mgr_intf.h
+++ b/drivers/media/platform/msm/camera/cam_jpeg/jpeg_hw/include/cam_jpeg_hw_mgr_intf.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -17,8 +17,7 @@
 #include <uapi/media/cam_defs.h>
 #include <linux/of.h>
 
-
 int cam_jpeg_hw_mgr_init(struct device_node *of_node,
-	uint64_t *hw_mgr_hdl);
+	uint64_t *hw_mgr_hdl, int *iommu_hdl);
 
 #endif /* CAM_JPEG_HW_MGR_INTF_H */
diff --git a/drivers/media/platform/msm/camera/cam_lrme/cam_lrme_dev.c b/drivers/media/platform/msm/camera/cam_lrme/cam_lrme_dev.c
index a4ee104..6b1250a 100644
--- a/drivers/media/platform/msm/camera/cam_lrme/cam_lrme_dev.c
+++ b/drivers/media/platform/msm/camera/cam_lrme/cam_lrme_dev.c
@@ -81,6 +81,7 @@
 static int cam_lrme_dev_close(struct v4l2_subdev *sd,
 	struct v4l2_subdev_fh *fh)
 {
+	int rc = 0;
 	struct cam_lrme_dev *lrme_dev = g_lrme_dev;
 	struct cam_node *node = v4l2_get_subdevdata(sd);
 
@@ -90,18 +91,25 @@
 	}
 
 	mutex_lock(&lrme_dev->lock);
-	lrme_dev->open_cnt--;
-	mutex_unlock(&lrme_dev->lock);
+	if (lrme_dev->open_cnt <= 0) {
+		CAM_DBG(CAM_LRME, "LRME subdev is already closed");
+		rc = -EINVAL;
+		goto end;
+	}
 
+	lrme_dev->open_cnt--;
 	if (!node) {
 		CAM_ERR(CAM_LRME, "Node is NULL");
-		return -EINVAL;
+		rc = -EINVAL;
+		goto end;
 	}
 
 	if (lrme_dev->open_cnt == 0)
 		cam_node_shutdown(node);
 
-	return 0;
+end:
+	mutex_unlock(&lrme_dev->lock);
+	return rc;
 }
 
 static const struct v4l2_subdev_internal_ops cam_lrme_subdev_internal_ops = {
diff --git a/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_core.c b/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_core.c
index 460b3df..4c4afc1 100644
--- a/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_core.c
+++ b/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_core.c
@@ -1325,9 +1325,9 @@
 		return NULL;
 	}
 
-	if (session->num_links >= MAX_LINKS_PER_SESSION) {
+	if (session->num_links >= MAXIMUM_LINKS_PER_SESSION) {
 		CAM_ERR(CAM_CRM, "Reached max links %d per session limit %d",
-			session->num_links, MAX_LINKS_PER_SESSION);
+			session->num_links, MAXIMUM_LINKS_PER_SESSION);
 		return NULL;
 	}
 
@@ -1362,7 +1362,7 @@
 
 	mutex_lock(&session->lock);
 	/*  Loop through and find a free index */
-	for (i = 0; i < MAX_LINKS_PER_SESSION; i++) {
+	for (i = 0; i < MAXIMUM_LINKS_PER_SESSION; i++) {
 		if (!session->links[i]) {
 			CAM_DBG(CAM_CRM,
 				"Free link index %d found, num_links=%d",
@@ -1372,7 +1372,7 @@
 		}
 	}
 
-	if (i == MAX_LINKS_PER_SESSION) {
+	if (i == MAXIMUM_LINKS_PER_SESSION) {
 		CAM_ERR(CAM_CRM, "Free link index not found");
 		goto error;
 	}
@@ -1433,7 +1433,7 @@
 		return;
 	}
 
-	for (i = 0; i < MAX_LINKS_PER_SESSION; i++) {
+	for (i = 0; i < MAXIMUM_LINKS_PER_SESSION; i++) {
 		if (session->links[i] == link)
 			session->links[i] = NULL;
 	}
@@ -1445,7 +1445,7 @@
 		 * of only having 2 links in a given session
 		 */
 		session->sync_mode = CAM_REQ_MGR_SYNC_MODE_NO_SYNC;
-		for (i = 0; i < MAX_LINKS_PER_SESSION; i++) {
+		for (i = 0; i < MAXIMUM_LINKS_PER_SESSION; i++) {
 			if (session->links[i])
 				session->links[i]->sync_link = NULL;
 		}
@@ -2387,7 +2387,7 @@
 			ses_info->session_hdl,
 			cam_session->num_links);
 
-		for (i = 0; i < MAX_LINKS_PER_SESSION; i++) {
+		for (i = 0; i < MAXIMUM_LINKS_PER_SESSION; i++) {
 			link = cam_session->links[i];
 
 			if (!link)
@@ -2628,7 +2628,8 @@
 	}
 
 	if ((sync_info->num_links < 0) ||
-		(sync_info->num_links > MAX_LINKS_PER_SESSION)) {
+		(sync_info->num_links >
+		MAX_LINKS_PER_SESSION)) {
 		CAM_ERR(CAM_CRM, "Invalid num links %d", sync_info->num_links);
 		return -EINVAL;
 	}
@@ -2777,6 +2778,13 @@
 		goto end;
 	}
 
+	if (control->num_links > MAX_LINKS_PER_SESSION) {
+		CAM_ERR(CAM_CRM, "Invalid number of links %d",
+			control->num_links);
+		rc = -EINVAL;
+		goto end;
+	}
+
 	mutex_lock(&g_crm_core_dev->crm_lock);
 	for (i = 0; i < control->num_links; i++) {
 		link = (struct cam_req_mgr_core_link *)
diff --git a/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_core.h b/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_core.h
index 68ec09b..8b86931 100644
--- a/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_core.h
+++ b/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_core.h
@@ -34,6 +34,8 @@
 
 #define SYNC_LINK_SOF_CNT_MAX_LMT 1
 
+#define MAXIMUM_LINKS_PER_SESSION  4
+
 /**
  * enum crm_workq_task_type
  * @codes: to identify which type of task is present
@@ -353,7 +355,7 @@
 struct cam_req_mgr_core_session {
 	int32_t                       session_hdl;
 	uint32_t                      num_links;
-	struct cam_req_mgr_core_link *links[MAX_LINKS_PER_SESSION];
+	struct cam_req_mgr_core_link *links[MAXIMUM_LINKS_PER_SESSION];
 	struct list_head              entry;
 	struct mutex                  lock;
 	int32_t                       force_err_recovery;
diff --git a/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_dev.c b/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_dev.c
index 0d21064..f68ca06 100644
--- a/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_dev.c
+++ b/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_dev.c
@@ -153,6 +153,10 @@
 
 static int cam_req_mgr_close(struct file *filep)
 {
+	struct v4l2_subdev *sd;
+	struct v4l2_fh *vfh = filep->private_data;
+	struct v4l2_subdev_fh *subdev_fh = to_v4l2_subdev_fh(vfh);
+
 	mutex_lock(&g_dev.cam_lock);
 
 	if (g_dev.open_cnt <= 0) {
@@ -161,6 +165,17 @@
 	}
 
 	cam_req_mgr_handle_core_shutdown();
+
+	list_for_each_entry(sd, &g_dev.v4l2_dev->subdevs, list) {
+		if (!(sd->flags & V4L2_SUBDEV_FL_HAS_DEVNODE))
+			continue;
+		if (sd->internal_ops && sd->internal_ops->close) {
+			CAM_DBG(CAM_CRM, "Invoke subdev close for device %s",
+				sd->name);
+			sd->internal_ops->close(sd, subdev_fh);
+		}
+	}
+
 	g_dev.open_cnt--;
 	v4l2_fh_release(filep);
 
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_core.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_core.c
index ed0a26b..31d9d35 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_core.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_core.c
@@ -141,7 +141,7 @@
 		CAM_ERR(CAM_ACTUATOR, "failed: power_info %pK", power_info);
 		return -EINVAL;
 	}
-	rc = msm_camera_power_down(power_info, soc_info);
+	rc = cam_sensor_util_power_down(power_info, soc_info);
 	if (rc) {
 		CAM_ERR(CAM_ACTUATOR, "power down the core is failed:%d", rc);
 		return rc;
@@ -301,7 +301,7 @@
 	trace_cam_apply_req("Actuator", apply->request_id);
 
 	CAM_DBG(CAM_ACTUATOR, "Request Id: %lld", apply->request_id);
-
+	mutex_lock(&(a_ctrl->actuator_mutex));
 	if ((apply->request_id ==
 		a_ctrl->i2c_data.per_frame[request_id].request_id) &&
 		(a_ctrl->i2c_data.per_frame[request_id].is_settings_valid)
@@ -312,7 +312,7 @@
 			CAM_ERR(CAM_ACTUATOR,
 				"Failed in applying the request: %lld\n",
 				apply->request_id);
-			return rc;
+			goto release_mutex;
 		}
 	}
 	del_req_id = (request_id +
@@ -327,12 +327,14 @@
 			CAM_ERR(CAM_ACTUATOR,
 				"Fail deleting the req: %d err: %d\n",
 				del_req_id, rc);
-			return rc;
+			goto release_mutex;
 		}
 	} else {
 		CAM_DBG(CAM_ACTUATOR, "No Valid Req to clean Up");
 	}
 
+release_mutex:
+	mutex_unlock(&(a_ctrl->actuator_mutex));
 	return rc;
 }
 
@@ -352,6 +354,8 @@
 		CAM_ERR(CAM_ACTUATOR, "Device data is NULL");
 		return -EINVAL;
 	}
+
+	mutex_lock(&(a_ctrl->actuator_mutex));
 	if (link->link_enable) {
 		a_ctrl->bridge_intf.link_hdl = link->link_hdl;
 		a_ctrl->bridge_intf.crm_cb = link->crm_cb;
@@ -359,6 +363,7 @@
 		a_ctrl->bridge_intf.link_hdl = -1;
 		a_ctrl->bridge_intf.crm_cb = NULL;
 	}
+	mutex_unlock(&(a_ctrl->actuator_mutex));
 
 	return 0;
 }
@@ -891,7 +896,9 @@
 			continue;
 
 		if (i2c_set->is_settings_valid == 1) {
+			mutex_lock(&(a_ctrl->actuator_mutex));
 			rc = delete_request(i2c_set);
+			mutex_unlock(&(a_ctrl->actuator_mutex));
 			if (rc < 0)
 				CAM_ERR(CAM_ACTUATOR,
 					"delete request: %lld rc: %d",
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_core.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_core.c
index 513e717..5179fae 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_core.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_core.c
@@ -21,19 +21,23 @@
 #define SCM_SVC_CAMERASS 0x18
 #define SECURE_SYSCALL_ID 0x6
 
+#define SECURE_SYSCALL_ID_2 0x7
+
 static int csiphy_dump;
 module_param(csiphy_dump, int, 0644);
 
-static int cam_csiphy_notify_secure_mode(int phy, bool protect)
+static int cam_csiphy_notify_secure_mode(struct csiphy_device *csiphy_dev,
+	bool protect, int32_t offset)
 {
 	struct scm_desc desc = {0};
 
+	if (offset >= CSIPHY_MAX_INSTANCES)
+		return -EINVAL;
 	desc.arginfo = SCM_ARGS(2, SCM_VAL, SCM_VAL);
 	desc.args[0] = protect;
-	desc.args[1] = phy;
+	desc.args[1] = csiphy_dev->csiphy_cpas_cp_reg_mask[offset];
 
-	CAM_DBG(CAM_CSIPHY, "phy : %d, protect : %d", phy, protect);
-	if (scm_call2(SCM_SIP_FNID(SCM_SVC_CAMERASS, SECURE_SYSCALL_ID),
+	if (scm_call2(SCM_SIP_FNID(SCM_SVC_CAMERASS, SECURE_SYSCALL_ID_2),
 		&desc)) {
 		CAM_ERR(CAM_CSIPHY, "scm call to hypervisor failed");
 		return -EINVAL;
@@ -42,6 +46,27 @@
 	return 0;
 }
 
+static int32_t cam_csiphy_get_instance_offset(
+	struct csiphy_device *csiphy_dev,
+	int32_t dev_handle)
+{
+	int32_t i;
+
+	if (csiphy_dev->acquire_count >
+		CSIPHY_MAX_INSTANCES) {
+		CAM_ERR(CAM_CSIPHY, "Invalid acquire count");
+		return -EINVAL;
+	}
+
+	for (i = 0; i < csiphy_dev->acquire_count; i++) {
+		if (dev_handle ==
+			csiphy_dev->bridge_intf.device_hdl[i])
+			break;
+	}
+
+	return i;
+}
+
 void cam_csiphy_query_cap(struct csiphy_device *csiphy_dev,
 	struct cam_csiphy_query_cap *csiphy_cap)
 {
@@ -75,6 +100,51 @@
 	}
 }
 
+static int32_t cam_csiphy_update_secure_info(
+	struct csiphy_device *csiphy_dev,
+	struct cam_csiphy_info  *cam_cmd_csiphy_info,
+	struct cam_config_dev_cmd *cfg_dev)
+{
+	uint32_t clock_lane, adj_lane_mask, temp;
+	int32_t offset;
+
+	if (csiphy_dev->acquire_count >=
+		CSIPHY_MAX_INSTANCES) {
+		CAM_ERR(CAM_CSIPHY, "Invalid acquire count");
+		return -EINVAL;
+	}
+
+	offset = cam_csiphy_get_instance_offset(csiphy_dev,
+		cfg_dev->dev_handle);
+	if (offset < 0 || offset >= CSIPHY_MAX_INSTANCES) {
+		CAM_ERR(CAM_CSIPHY, "Invalid offset");
+		return -EINVAL;
+	}
+
+	if (cam_cmd_csiphy_info->combo_mode)
+		clock_lane =
+			csiphy_dev->ctrl_reg->csiphy_reg.csiphy_combo_clk_lane;
+	else
+		clock_lane =
+			csiphy_dev->ctrl_reg->csiphy_reg.csiphy_clock_lane;
+
+	adj_lane_mask = cam_cmd_csiphy_info->lane_mask & 0x1F &
+		~clock_lane;
+	temp = adj_lane_mask & (clock_lane - 1);
+	adj_lane_mask =
+		((adj_lane_mask & (~((clock_lane - 1)))) >> 1) | temp;
+
+	csiphy_dev->csiphy_info.secure_mode[offset] = 1;
+
+	csiphy_dev->csiphy_cpas_cp_reg_mask[offset] =
+		adj_lane_mask << (csiphy_dev->soc_info.index *
+		(CAM_CSIPHY_MAX_DPHY_LANES + CAM_CSIPHY_MAX_CPHY_LANES) +
+		(!cam_cmd_csiphy_info->csiphy_3phase) *
+		(CAM_CSIPHY_MAX_CPHY_LANES));
+
+	return 0;
+}
+
 int32_t cam_cmd_buf_parser(struct csiphy_device *csiphy_dev,
 	struct cam_config_dev_cmd *cfg_dev)
 {
@@ -136,7 +206,10 @@
 		csiphy_dev->csiphy_info.settle_time =
 			cam_cmd_csiphy_info->settle_time;
 	csiphy_dev->csiphy_info.data_rate = cam_cmd_csiphy_info->data_rate;
-	csiphy_dev->csiphy_info.secure_mode = cam_cmd_csiphy_info->secure_mode;
+
+	if (cam_cmd_csiphy_info->secure_mode == 1)
+		cam_csiphy_update_secure_info(csiphy_dev,
+			cam_cmd_csiphy_info, cfg_dev);
 
 	return rc;
 }
@@ -347,6 +420,7 @@
 void cam_csiphy_shutdown(struct csiphy_device *csiphy_dev)
 {
 	struct cam_hw_soc_info *soc_info;
+	int32_t i = 0;
 
 	if (csiphy_dev->csiphy_state == CAM_CSIPHY_INIT)
 		return;
@@ -354,13 +428,17 @@
 	if (csiphy_dev->csiphy_state == CAM_CSIPHY_START) {
 		soc_info = &csiphy_dev->soc_info;
 
-		if (csiphy_dev->csiphy_info.secure_mode)
-			cam_csiphy_notify_secure_mode(
-				csiphy_dev->soc_info.index,
-				CAM_SECURE_MODE_NON_SECURE);
+		for (i = 0; i < csiphy_dev->acquire_count; i++) {
+			if (csiphy_dev->csiphy_info.secure_mode[i])
+				cam_csiphy_notify_secure_mode(
+					csiphy_dev,
+					CAM_SECURE_MODE_NON_SECURE, i);
 
-		csiphy_dev->csiphy_info.secure_mode =
-			CAM_SECURE_MODE_NON_SECURE;
+			csiphy_dev->csiphy_info.secure_mode[i] =
+				CAM_SECURE_MODE_NON_SECURE;
+
+			csiphy_dev->csiphy_cpas_cp_reg_mask[i] = 0;
+		}
 
 		cam_csiphy_reset(csiphy_dev);
 		cam_soc_util_disable_platform_resource(soc_info, true, true);
@@ -551,6 +629,16 @@
 	}
 		break;
 	case CAM_STOP_DEV: {
+		int32_t offset, rc = 0;
+		struct cam_start_stop_dev_cmd config;
+
+		rc = copy_from_user(&config, (void __user *)cmd->handle,
+					sizeof(config));
+		if (rc < 0) {
+			CAM_ERR(CAM_CSIPHY, "Failed copying from User");
+			goto release_mutex;
+		}
+
 		if ((csiphy_dev->csiphy_state != CAM_CSIPHY_START) ||
 			!csiphy_dev->start_dev_count) {
 			CAM_ERR(CAM_CSIPHY, "Not in right state to stop : %d",
@@ -558,20 +646,38 @@
 			goto release_mutex;
 		}
 
-		if (--csiphy_dev->start_dev_count) {
-			CAM_DBG(CAM_CSIPHY, "Stop Dev ref Cnt: %d",
-				csiphy_dev->start_dev_count);
+		offset = cam_csiphy_get_instance_offset(csiphy_dev,
+			config.dev_handle);
+		if (offset < 0 || offset >= CSIPHY_MAX_INSTANCES) {
+			CAM_ERR(CAM_CSIPHY, "Invalid offset");
 			goto release_mutex;
 		}
 
-		if (csiphy_dev->csiphy_info.secure_mode)
-			cam_csiphy_notify_secure_mode(
-				csiphy_dev->soc_info.index,
-				CAM_SECURE_MODE_NON_SECURE);
+		if (--csiphy_dev->start_dev_count) {
+			CAM_DBG(CAM_CSIPHY, "Stop Dev ref Cnt: %d",
+				csiphy_dev->start_dev_count);
+			if (csiphy_dev->csiphy_info.secure_mode[offset])
+				cam_csiphy_notify_secure_mode(
+					csiphy_dev,
+					CAM_SECURE_MODE_NON_SECURE, offset);
 
-		csiphy_dev->csiphy_info.secure_mode =
+			csiphy_dev->csiphy_info.secure_mode[offset] =
+				CAM_SECURE_MODE_NON_SECURE;
+			csiphy_dev->csiphy_cpas_cp_reg_mask[offset] = 0;
+
+			goto release_mutex;
+		}
+
+		if (csiphy_dev->csiphy_info.secure_mode[offset])
+			cam_csiphy_notify_secure_mode(
+				csiphy_dev,
+				CAM_SECURE_MODE_NON_SECURE, offset);
+
+		csiphy_dev->csiphy_info.secure_mode[offset] =
 			CAM_SECURE_MODE_NON_SECURE;
 
+		csiphy_dev->csiphy_cpas_cp_reg_mask[offset] = 0x0;
+
 		rc = cam_csiphy_disable_hw(csiphy_dev);
 		if (rc < 0)
 			CAM_ERR(CAM_CSIPHY, "Failed in csiphy release");
@@ -645,12 +751,28 @@
 	case CAM_START_DEV: {
 		struct cam_ahb_vote ahb_vote;
 		struct cam_axi_vote axi_vote;
+		struct cam_start_stop_dev_cmd config;
+		int32_t offset;
+
+		rc = copy_from_user(&config, (void __user *)cmd->handle,
+			sizeof(config));
+		if (rc < 0) {
+			CAM_ERR(CAM_CSIPHY, "Failed copying from User");
+			goto release_mutex;
+		}
 
 		if (csiphy_dev->csiphy_state == CAM_CSIPHY_START) {
 			csiphy_dev->start_dev_count++;
 			goto release_mutex;
 		}
 
+		offset = cam_csiphy_get_instance_offset(csiphy_dev,
+			config.dev_handle);
+		if (offset < 0 || offset >= CSIPHY_MAX_INSTANCES) {
+			CAM_ERR(CAM_CSIPHY, "Invalid offset");
+			goto release_mutex;
+		}
+
 		ahb_vote.type = CAM_VOTE_ABSOLUTE;
 		ahb_vote.vote.level = CAM_SVS_VOTE;
 		axi_vote.compressed_bw = CAM_CPAS_DEFAULT_AXI_BW;
@@ -663,12 +785,12 @@
 			goto release_mutex;
 		}
 
-		if (csiphy_dev->csiphy_info.secure_mode) {
+		if (csiphy_dev->csiphy_info.secure_mode[offset] == 1) {
 			rc = cam_csiphy_notify_secure_mode(
-				csiphy_dev->soc_info.index,
-				CAM_SECURE_MODE_SECURE);
+				csiphy_dev,
+				CAM_SECURE_MODE_SECURE, offset);
 			if (rc < 0)
-				csiphy_dev->csiphy_info.secure_mode =
+				csiphy_dev->csiphy_info.secure_mode[offset] =
 					CAM_SECURE_MODE_NON_SECURE;
 		}
 
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_dev.h b/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_dev.h
index 9c85af3..ac96255 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_dev.h
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_dev.h
@@ -58,6 +58,11 @@
 #define CSIPHY_SETTLE_CNT_HIGHER_BYTE    3
 #define CSIPHY_DNP_PARAMS                4
 
+#define CSIPHY_MAX_INSTANCES     2
+
+#define CAM_CSIPHY_MAX_DPHY_LANES    4
+#define CAM_CSIPHY_MAX_CPHY_LANES    3
+
 #define ENABLE_IRQ false
 
 #undef CDBG
@@ -101,6 +106,12 @@
 	uint32_t csiphy_reset_array_size;
 	uint32_t csiphy_2ph_config_array_size;
 	uint32_t csiphy_3ph_config_array_size;
+	uint32_t csiphy_cpas_cp_bits_per_phy;
+	uint32_t csiphy_cpas_cp_is_interleaved;
+	uint32_t csiphy_cpas_cp_2ph_offset;
+	uint32_t csiphy_cpas_cp_3ph_offset;
+	uint32_t csiphy_clock_lane;
+	uint32_t csiphy_combo_clk_lane;
 };
 
 /**
@@ -111,9 +122,9 @@
  * @crm_cb: Callback API pointers
  */
 struct intf_params {
-	int32_t device_hdl[2];
-	int32_t session_hdl[2];
-	int32_t link_hdl[2];
+	int32_t device_hdl[CSIPHY_MAX_INSTANCES];
+	int32_t session_hdl[CSIPHY_MAX_INSTANCES];
+	int32_t link_hdl[CSIPHY_MAX_INSTANCES];
 	struct cam_req_mgr_kmd_ops ops;
 	struct cam_req_mgr_crm_cb *crm_cb;
 };
@@ -175,7 +186,7 @@
 	uint8_t     csiphy_3phase;
 	uint8_t     combo_mode;
 	uint8_t     lane_cnt;
-	uint8_t     secure_mode;
+	uint8_t     secure_mode[CSIPHY_MAX_INSTANCES];
 	uint64_t    settle_time;
 	uint64_t    settle_time_combo_sensor;
 	uint64_t    data_rate;
@@ -231,6 +242,7 @@
 	struct cam_hw_soc_info   soc_info;
 	uint32_t cpas_handle;
 	uint32_t config_count;
+	uint64_t csiphy_cpas_cp_reg_mask[CSIPHY_MAX_INSTANCES];
 };
 
 #endif /* _CAM_CSIPHY_DEV_H_ */
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/include/cam_csiphy_1_0_hwreg.h b/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/include/cam_csiphy_1_0_hwreg.h
index 3245093..82cff27 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/include/cam_csiphy_1_0_hwreg.h
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/include/cam_csiphy_1_0_hwreg.h
@@ -23,6 +23,8 @@
 	.csiphy_reset_array_size = 5,
 	.csiphy_2ph_config_array_size = 14,
 	.csiphy_3ph_config_array_size = 19,
+	.csiphy_clock_lane = 0x1,
+	.csiphy_combo_clk_lane = 0x10,
 };
 
 struct csiphy_reg_t csiphy_common_reg_1_0[] = {
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_core.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_core.c
index c8730ca..2e1b3cf 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_core.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_core.c
@@ -31,7 +31,8 @@
 {
 	int                                rc = 0;
 	int                                j;
-	struct cam_sensor_i2c_reg_setting  i2c_reg_settings;
+	struct cam_sensor_i2c_reg_setting  i2c_reg_settings = {
+						NULL, 0, 0, 0, 0};
 	struct cam_sensor_i2c_reg_array    i2c_reg_array;
 	struct cam_eeprom_memory_map_t    *emap = block->map;
 	struct cam_eeprom_soc_private     *eb_info;
@@ -221,7 +222,7 @@
 		CAM_ERR(CAM_EEPROM, "failed: power_info %pK", power_info);
 		return -EINVAL;
 	}
-	rc = msm_camera_power_down(power_info, soc_info);
+	rc = cam_sensor_util_power_down(power_info, soc_info);
 	if (rc) {
 		CAM_ERR(CAM_EEPROM, "power down the core is failed:%d", rc);
 		return rc;
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/Makefile b/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/Makefile
index c7889a5..4d1cbdc 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/Makefile
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/Makefile
@@ -1,10 +1,11 @@
-ccflags-y += -Idrivers/media/platform/msm/camera/cam_utils
-ccflags-y += -Idrivers/media/platform/msm/camera/cam_sync
-ccflags-y += -Idrivers/media/platform/msm/camera/cam_sensor_module/cam_res_mgr
-ccflags-y += -Idrivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils
-ccflags-y += -Idrivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io
-ccflags-y += -Idrivers/media/platform/msm/camera/cam_sensor_module/cam_cci
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_core
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_cpas/include
 ccflags-y += -Idrivers/media/platform/msm/camera/cam_req_mgr
-ccflags-y += -Idrivers/media/platform/msm/camera/cam_smmu/
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_sensor_module/cam_cci
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_sensor_module/cam_res_mgr
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_smmu
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_utils
 
 obj-$(CONFIG_SPECTRA_CAMERA) += cam_flash_dev.o cam_flash_core.o cam_flash_soc.o
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_core.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_core.c
index 2820d7e..3040cdf 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_core.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_core.c
@@ -16,7 +16,7 @@
 #include "cam_flash_core.h"
 #include "cam_res_mgr_api.h"
 
-int cam_flash_prepare(struct cam_flash_ctrl *flash_ctrl,
+static int cam_flash_prepare(struct cam_flash_ctrl *flash_ctrl,
 	bool regulator_enable)
 {
 	int rc = 0;
@@ -55,7 +55,7 @@
 	return rc;
 }
 
-static int cam_flash_flush_nrt(struct cam_flash_ctrl *fctrl)
+static int cam_flash_pmic_flush_nrt(struct cam_flash_ctrl *fctrl)
 {
 	int j = 0;
 	struct cam_flash_frame_setting *nrt_settings;
@@ -86,20 +86,187 @@
 	return 0;
 }
 
-int cam_flash_flush_request(struct cam_req_mgr_flush_request *flush)
+static int cam_flash_i2c_flush_nrt(struct cam_flash_ctrl *fctrl)
+{
+	int rc = 0;
+
+	if (fctrl->i2c_data.init_settings.is_settings_valid == true) {
+		rc = delete_request(&fctrl->i2c_data.init_settings);
+		if (rc) {
+			CAM_WARN(CAM_FLASH,
+				"Failed to delete Init i2c_setting: %d",
+				rc);
+			return rc;
+		}
+	}
+	if (fctrl->i2c_data.config_settings.is_settings_valid == true) {
+		rc = delete_request(&fctrl->i2c_data.config_settings);
+		if (rc) {
+			CAM_WARN(CAM_FLASH,
+				"Failed to delete NRT i2c_setting: %d",
+				rc);
+			return rc;
+		}
+	}
+
+	return rc;
+}
+
+static int cam_flash_construct_default_power_setting(
+	struct cam_sensor_power_ctrl_t *power_info)
+{
+	int rc = 0;
+
+	power_info->power_setting_size = 1;
+	power_info->power_setting =
+		(struct cam_sensor_power_setting *)
+		kzalloc(sizeof(struct cam_sensor_power_setting),
+			GFP_KERNEL);
+	if (!power_info->power_setting)
+		return -ENOMEM;
+
+	power_info->power_setting[0].seq_type = SENSOR_CUSTOM_REG1;
+	power_info->power_setting[0].seq_val = CAM_V_CUSTOM1;
+	power_info->power_setting[0].config_val = 0;
+	power_info->power_setting[0].delay = 2;
+
+	power_info->power_down_setting_size = 1;
+	power_info->power_down_setting =
+		(struct cam_sensor_power_setting *)
+		kzalloc(sizeof(struct cam_sensor_power_setting),
+			GFP_KERNEL);
+	if (!power_info->power_down_setting) {
+		rc = -ENOMEM;
+		goto free_power_settings;
+	}
+
+	power_info->power_down_setting[0].seq_type = SENSOR_CUSTOM_REG1;
+	power_info->power_down_setting[0].seq_val = CAM_V_CUSTOM1;
+	power_info->power_down_setting[0].config_val = 0;
+
+	return rc;
+
+free_power_settings:
+	kfree(power_info->power_setting);
+	power_info->power_setting = NULL;
+	power_info->power_setting_size = 0;
+	return rc;
+}
+
+int cam_flash_pmic_power_ops(struct cam_flash_ctrl *fctrl,
+	bool regulator_enable)
+{
+	int rc = 0;
+
+	if (!(fctrl->switch_trigger)) {
+		CAM_ERR(CAM_FLASH, "Invalid argument");
+		return -EINVAL;
+	}
+
+	if (regulator_enable) {
+		rc = cam_flash_prepare(fctrl, true);
+		if (rc) {
+			CAM_ERR(CAM_FLASH,
+				"Enable Regulator Failed rc = %d", rc);
+			return rc;
+		}
+	}
+
+	if (!regulator_enable) {
+		if ((fctrl->flash_state == CAM_FLASH_STATE_START) &&
+			(fctrl->is_regulator_enabled == true)) {
+			rc = cam_flash_prepare(fctrl, false);
+			if (rc)
+				CAM_ERR(CAM_FLASH,
+					"Disable Regulator Failed rc: %d", rc);
+		}
+	}
+
+	return rc;
+}
+
+int cam_flash_i2c_power_ops(struct cam_flash_ctrl *fctrl,
+	bool regulator_enable)
+{
+	int rc = 0;
+	struct cam_hw_soc_info *soc_info = &fctrl->soc_info;
+	struct cam_sensor_power_ctrl_t *power_info =
+		&fctrl->power_info;
+
+	if (!power_info || !soc_info) {
+		CAM_ERR(CAM_FLASH, "Power Info is NULL");
+		return -EINVAL;
+	}
+	power_info->dev = soc_info->dev;
+
+	if (regulator_enable && (fctrl->is_regulator_enabled == false)) {
+		if ((power_info->power_setting == NULL) &&
+			(power_info->power_down_setting == NULL)) {
+			CAM_INFO(CAM_FLASH,
+				"Using default power settings");
+			rc = cam_flash_construct_default_power_setting(
+					power_info);
+			if (rc < 0) {
+				CAM_ERR(CAM_FLASH,
+				"Construct default pwr setting failed rc: %d",
+				rc);
+				return rc;
+			}
+		}
+
+		rc = cam_sensor_core_power_up(power_info, soc_info);
+		if (rc) {
+			CAM_ERR(CAM_FLASH, "power up the core is failed:%d",
+				rc);
+			goto free_pwr_settings;
+		}
+
+		rc = camera_io_init(&(fctrl->io_master_info));
+		if (rc) {
+			CAM_ERR(CAM_FLASH, "cci_init failed: rc: %d", rc);
+			cam_sensor_util_power_down(power_info, soc_info);
+			goto free_pwr_settings;
+		}
+		fctrl->is_regulator_enabled = true;
+	} else if ((!regulator_enable) &&
+		(fctrl->is_regulator_enabled == true)) {
+		rc = cam_sensor_util_power_down(power_info, soc_info);
+		if (rc) {
+			CAM_ERR(CAM_FLASH, "power down the core is failed:%d",
+				rc);
+			return rc;
+		}
+		camera_io_release(&(fctrl->io_master_info));
+		fctrl->is_regulator_enabled = false;
+		goto free_pwr_settings;
+	}
+	return rc;
+
+free_pwr_settings:
+	kfree(power_info->power_setting);
+	kfree(power_info->power_down_setting);
+	power_info->power_setting = NULL;
+	power_info->power_down_setting = NULL;
+	power_info->power_setting_size = 0;
+	power_info->power_down_setting_size = 0;
+
+	return rc;
+}
+
+int cam_flash_pmic_flush_request(struct cam_flash_ctrl *fctrl,
+	enum cam_flash_flush_type type, uint64_t req_id)
 {
 	int rc = 0;
 	int i = 0, j = 0;
-	struct cam_flash_ctrl *fctrl = NULL;
 	int frame_offset = 0;
 
-	fctrl = (struct cam_flash_ctrl *) cam_get_device_priv(flush->dev_hdl);
 	if (!fctrl) {
 		CAM_ERR(CAM_FLASH, "Device data is NULL");
 		return -EINVAL;
 	}
 
-	if (flush->type == CAM_REQ_MGR_FLUSH_TYPE_ALL) {
+	if (type == FLUSH_ALL) {
+		cam_flash_off(fctrl);
 	/* flush all requests*/
 		for (i = 0; i < MAX_PER_FRAME_ARRAY; i++) {
 			fctrl->per_frame[i].cmn_attr.request_id = 0;
@@ -109,19 +276,105 @@
 				fctrl->per_frame[i].led_current_ma[j] = 0;
 		}
 
-		rc = cam_flash_flush_nrt(fctrl);
-		if (rc)
-			CAM_ERR(CAM_FLASH, "NonRealTime flush error");
-	} else if (flush->type == CAM_REQ_MGR_FLUSH_TYPE_CANCEL_REQ) {
+		cam_flash_pmic_flush_nrt(fctrl);
+	} else if ((type == FLUSH_REQ) && (req_id != 0)) {
 	/* flush request with req_id*/
-		frame_offset = flush->req_id % MAX_PER_FRAME_ARRAY;
+		frame_offset = req_id % MAX_PER_FRAME_ARRAY;
 		fctrl->per_frame[frame_offset].cmn_attr.request_id = 0;
 		fctrl->per_frame[frame_offset].cmn_attr.is_settings_valid =
 			false;
 		fctrl->per_frame[frame_offset].cmn_attr.count = 0;
 		for (i = 0; i < CAM_FLASH_MAX_LED_TRIGGERS; i++)
 			fctrl->per_frame[frame_offset].led_current_ma[i] = 0;
+	} else if ((type == FLUSH_REQ) && (req_id == 0)) {
+		/* Handels NonRealTime usecase */
+		cam_flash_pmic_flush_nrt(fctrl);
+	} else {
+		CAM_ERR(CAM_FLASH, "Invalid arguments");
+		return -EINVAL;
 	}
+
+	return rc;
+}
+
+int cam_flash_i2c_flush_request(struct cam_flash_ctrl *fctrl,
+	enum cam_flash_flush_type type, uint64_t req_id)
+{
+	int rc = 0;
+	int i = 0;
+	uint32_t cancel_req_id_found = 0;
+	struct i2c_settings_array *i2c_set = NULL;
+
+	if (!fctrl) {
+		CAM_ERR(CAM_FLASH, "Device data is NULL");
+		return -EINVAL;
+	}
+	if ((type == FLUSH_REQ) && (req_id == 0)) {
+		/* This setting will be called only when NonRealTime
+		 * settings needs to clean.
+		 */
+		cam_flash_i2c_flush_nrt(fctrl);
+	} else {
+		/* All other usecase will be handle here */
+		for (i = 0; i < MAX_PER_FRAME_ARRAY; i++) {
+			i2c_set = &(fctrl->i2c_data.per_frame[i]);
+
+			if ((type == FLUSH_REQ) &&
+				(i2c_set->request_id != req_id))
+				continue;
+
+			if (i2c_set->is_settings_valid == 1) {
+				rc = delete_request(i2c_set);
+				if (rc < 0)
+					CAM_ERR(CAM_FLASH,
+						"delete request: %lld rc: %d",
+						i2c_set->request_id, rc);
+
+				if (type == FLUSH_REQ) {
+					cancel_req_id_found = 1;
+					break;
+				}
+			}
+		}
+	}
+
+	if ((type == FLUSH_REQ) && (req_id != 0) &&
+			(!cancel_req_id_found))
+		CAM_DBG(CAM_FLASH,
+			"Flush request id:%lld not found in the pending list",
+			req_id);
+
+	return rc;
+}
+
+int cam_flash_flush_request(struct cam_req_mgr_flush_request *flush)
+{
+	int rc = 0;
+	struct cam_flash_ctrl *fctrl = NULL;
+
+	fctrl = (struct cam_flash_ctrl *) cam_get_device_priv(flush->dev_hdl);
+	if (!fctrl) {
+		CAM_ERR(CAM_FLASH, "Device data is NULL");
+		return -EINVAL;
+	}
+
+	mutex_lock(&fctrl->flash_mutex);
+	if (flush->type == CAM_REQ_MGR_FLUSH_TYPE_ALL) {
+		rc = fctrl->func_tbl.flush_req(fctrl, FLUSH_ALL, 0);
+		if (rc) {
+			CAM_ERR(CAM_FLASH, "FLUSH_TYPE_ALL failed rc: %d", rc);
+			goto end;
+		}
+	} else if (flush->type == CAM_REQ_MGR_FLUSH_TYPE_CANCEL_REQ) {
+		rc = fctrl->func_tbl.flush_req(fctrl,
+				FLUSH_REQ, flush->req_id);
+		if (rc) {
+			CAM_ERR(CAM_FLASH, "FLUSH_REQ failed rc: %d", rc);
+			goto end;
+		}
+	}
+end:
+	mutex_unlock(&fctrl->flash_mutex);
 	return rc;
 }
 
@@ -254,26 +507,51 @@
 	return rc;
 }
 
-static int delete_req(struct cam_flash_ctrl *fctrl, uint64_t req_id)
+static int cam_flash_i2c_delete_req(struct cam_flash_ctrl *fctrl,
+	uint64_t req_id)
+{
+	int i = 0, rc = 0;
+	uint64_t top = 0, del_req_id = 0;
+
+	if (req_id != 0) {
+		for (i = 0; i < MAX_PER_FRAME_ARRAY; i++) {
+			if ((req_id >=
+				fctrl->i2c_data.per_frame[i].request_id) &&
+				(top <
+				fctrl->i2c_data.per_frame[i].request_id) &&
+				(fctrl->i2c_data.per_frame[i].is_settings_valid
+					== 1)) {
+				del_req_id = top;
+				top = fctrl->i2c_data.per_frame[i].request_id;
+			}
+		}
+
+		if (top < req_id) {
+			if ((((top % MAX_PER_FRAME_ARRAY) - (req_id %
+				MAX_PER_FRAME_ARRAY)) >= BATCH_SIZE_MAX) ||
+				(((top % MAX_PER_FRAME_ARRAY) - (req_id %
+				MAX_PER_FRAME_ARRAY)) <= -BATCH_SIZE_MAX))
+				del_req_id = req_id;
+		}
+
+		if (!del_req_id)
+			return rc;
+
+		CAM_DBG(CAM_FLASH, "top: %llu, del_req_id:%llu",
+			top, del_req_id);
+	}
+	fctrl->func_tbl.flush_req(fctrl, FLUSH_REQ, del_req_id);
+	return 0;
+}
+
+static int cam_flash_pmic_delete_req(struct cam_flash_ctrl *fctrl,
+	uint64_t req_id)
 {
 	int i = 0;
 	struct cam_flash_frame_setting *flash_data = NULL;
 	uint64_t top = 0, del_req_id = 0;
 
-	if (req_id == 0) {
-		flash_data = &fctrl->nrt_info;
-		if ((fctrl->nrt_info.cmn_attr.cmd_type ==
-			CAMERA_SENSOR_FLASH_CMD_TYPE_WIDGET) ||
-			(fctrl->nrt_info.cmn_attr.cmd_type ==
-			CAMERA_SENSOR_FLASH_CMD_TYPE_RER)) {
-			flash_data->cmn_attr.is_settings_valid = false;
-			for (i = 0; i < flash_data->cmn_attr.count; i++)
-				flash_data->led_current_ma[i] = 0;
-		} else {
-			fctrl->flash_init_setting.cmn_attr.is_settings_valid
-				= false;
-		}
-	} else {
+	if (req_id != 0) {
 		for (i = 0; i < MAX_PER_FRAME_ARRAY; i++) {
 			flash_data = &fctrl->per_frame[i];
 			if (req_id >= flash_data->cmn_attr.request_id &&
@@ -305,28 +583,100 @@
 
 		CAM_DBG(CAM_FLASH, "top: %llu, del_req_id:%llu",
 			top, del_req_id);
+	}
 
-		for (i = 0; i < MAX_PER_FRAME_ARRAY; i++) {
-			flash_data = &fctrl->per_frame[i];
-			if ((del_req_id ==
-				flash_data->cmn_attr.request_id) &&
-				(flash_data->cmn_attr.
-					is_settings_valid == 1)) {
-				CAM_DBG(CAM_FLASH, "Deleting request[%d] %llu",
-					i, flash_data->cmn_attr.request_id);
-				flash_data->cmn_attr.request_id = 0;
-				flash_data->cmn_attr.is_settings_valid = false;
-				flash_data->opcode = 0;
-				for (i = 0; i < flash_data->cmn_attr.count; i++)
-					flash_data->led_current_ma[i] = 0;
+	fctrl->func_tbl.flush_req(fctrl, FLUSH_REQ, del_req_id);
+	return 0;
+}
+
+static int32_t cam_flash_slaveInfo_pkt_parser(struct cam_flash_ctrl *fctrl,
+	uint32_t *cmd_buf)
+{
+	int32_t rc = 0;
+	struct cam_cmd_i2c_info *i2c_info = (struct cam_cmd_i2c_info *)cmd_buf;
+
+	if (fctrl->io_master_info.master_type == CCI_MASTER) {
+		fctrl->io_master_info.cci_client->cci_i2c_master =
+			fctrl->cci_i2c_master;
+		fctrl->io_master_info.cci_client->i2c_freq_mode =
+			i2c_info->i2c_freq_mode;
+		fctrl->io_master_info.cci_client->sid =
+			i2c_info->slave_addr >> 1;
+		CAM_DBG(CAM_FLASH, "Slave addr: 0x%x Freq Mode: %d",
+			i2c_info->slave_addr, i2c_info->i2c_freq_mode);
+	} else if (fctrl->io_master_info.master_type == I2C_MASTER) {
+		fctrl->io_master_info.client->addr = i2c_info->slave_addr;
+		CAM_DBG(CAM_FLASH, "Slave addr: 0x%x", i2c_info->slave_addr);
+	} else {
+		CAM_ERR(CAM_FLASH, "Invalid Master type: %d",
+			fctrl->io_master_info.master_type);
+		 rc = -EINVAL;
+	}
+
+	return rc;
+}
+
+int cam_flash_i2c_apply_setting(struct cam_flash_ctrl *fctrl,
+	uint64_t req_id)
+{
+	struct i2c_settings_list *i2c_list;
+	struct i2c_settings_array *i2c_set = NULL;
+	int frame_offset = 0, rc = 0;
+
+	if (req_id == 0) {
+		/* NonRealTime Init settings*/
+		if (fctrl->i2c_data.init_settings.is_settings_valid == true) {
+			list_for_each_entry(i2c_list,
+				&(fctrl->i2c_data.init_settings.list_head),
+				list) {
+				rc = cam_sensor_util_i2c_apply_setting
+					(&(fctrl->io_master_info), i2c_list);
+				if (rc) {
+					CAM_ERR(CAM_FLASH,
+					"Failed to apply init settings: %d",
+					rc);
+					return rc;
+				}
+			}
+		}
+		/* NonRealTime (Widget/RER/INIT_FIRE settings) */
+		if (fctrl->i2c_data.config_settings.is_settings_valid == true) {
+			list_for_each_entry(i2c_list,
+				&(fctrl->i2c_data.config_settings.list_head),
+				list) {
+				rc = cam_sensor_util_i2c_apply_setting
+					(&(fctrl->io_master_info), i2c_list);
+				if (rc) {
+					CAM_ERR(CAM_FLASH,
+					"Failed to apply NRT settings: %d", rc);
+					return rc;
+				}
+			}
+		}
+	} else {
+		/* RealTime */
+		frame_offset = req_id % MAX_PER_FRAME_ARRAY;
+		i2c_set = &fctrl->i2c_data.per_frame[frame_offset];
+		if ((i2c_set->is_settings_valid == true) &&
+			(i2c_set->request_id == req_id)) {
+			list_for_each_entry(i2c_list,
+				&(i2c_set->list_head), list) {
+				rc = cam_sensor_util_i2c_apply_setting(
+					&(fctrl->io_master_info), i2c_list);
+				if (rc) {
+					CAM_ERR(CAM_FLASH,
+					"Failed to apply settings: %d", rc);
+					return rc;
+				}
 			}
 		}
 	}
 
-	return 0;
+	cam_flash_i2c_delete_req(fctrl, req_id);
+	return rc;
 }
 
-int cam_flash_apply_setting(struct cam_flash_ctrl *fctrl,
+int cam_flash_pmic_apply_setting(struct cam_flash_ctrl *fctrl,
 	uint64_t req_id)
 {
 	int rc = 0, i = 0;
@@ -428,7 +778,6 @@
 		} else if (fctrl->nrt_info.cmn_attr.cmd_type ==
 			CAMERA_SENSOR_FLASH_CMD_TYPE_RER) {
 			flash_data = &fctrl->nrt_info;
-
 			if (fctrl->flash_state != CAM_FLASH_STATE_START) {
 				rc = cam_flash_off(fctrl);
 				if (rc) {
@@ -461,8 +810,7 @@
 				rc = cam_flash_off(fctrl);
 				if (rc) {
 					CAM_ERR(CAM_FLASH,
-						"Flash off failed: %d",
-						rc);
+						"Flash off failed: %d", rc);
 					continue;
 				}
 				fctrl->flash_state = CAM_FLASH_STATE_START;
@@ -524,12 +872,321 @@
 	}
 
 nrt_del_req:
-	delete_req(fctrl, req_id);
+	cam_flash_pmic_delete_req(fctrl, req_id);
 apply_setting_err:
 	return rc;
 }
 
-int cam_flash_parser(struct cam_flash_ctrl *fctrl, void *arg)
+int cam_flash_i2c_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg)
+{
+	int rc = 0, i = 0;
+	uint64_t generic_ptr;
+	uint32_t total_cmd_buf_in_bytes = 0;
+	uint32_t processed_cmd_buf_in_bytes = 0;
+	uint16_t cmd_length_in_bytes = 0;
+	uint32_t *cmd_buf =  NULL;
+	uint32_t *offset = NULL;
+	uint32_t frm_offset = 0;
+	size_t len_of_buffer;
+	struct cam_flash_init *flash_init = NULL;
+	struct common_header  *cmn_hdr = NULL;
+	struct cam_control *ioctl_ctrl = NULL;
+	struct cam_packet *csl_packet = NULL;
+	struct cam_cmd_buf_desc *cmd_desc = NULL;
+	struct cam_config_dev_cmd config;
+	struct cam_req_mgr_add_request add_req;
+	struct i2c_data_settings *i2c_data = NULL;
+	struct i2c_settings_array *i2c_reg_settings = NULL;
+	struct cam_sensor_power_ctrl_t *power_info = NULL;
+
+	if (!fctrl || !arg) {
+		CAM_ERR(CAM_FLASH, "fctrl/arg is NULL");
+		return -EINVAL;
+	}
+	/* getting CSL Packet */
+	ioctl_ctrl = (struct cam_control *)arg;
+
+	if (copy_from_user((&config), (void __user *) ioctl_ctrl->handle,
+		sizeof(config))) {
+		CAM_ERR(CAM_FLASH, "Copy cmd handle from user failed");
+		return -EFAULT;
+	}
+
+	rc = cam_mem_get_cpu_buf(config.packet_handle,
+		(uint64_t *)&generic_ptr, &len_of_buffer);
+	if (rc) {
+		CAM_ERR(CAM_FLASH, "Failed in getting the buffer : %d", rc);
+		return rc;
+	}
+
+	if (config.offset > len_of_buffer) {
+		CAM_ERR(CAM_FLASH,
+			"offset is out of bounds: offset: %lld len: %zu",
+			config.offset, len_of_buffer);
+		return -EINVAL;
+	}
+
+	/* Add offset to the flash csl header */
+	csl_packet = (struct cam_packet *)(generic_ptr + config.offset);
+	switch (csl_packet->header.op_code & 0xFFFFFF) {
+	case CAM_FLASH_PACKET_OPCODE_INIT: {
+		/* INIT packet*/
+		offset = (uint32_t *)((uint8_t *)&csl_packet->payload +
+			csl_packet->cmd_buf_offset);
+		cmd_desc = (struct cam_cmd_buf_desc *)(offset);
+
+		/* Loop through multiple command buffers */
+		for (i = 1; i < csl_packet->num_cmd_buf; i++) {
+			total_cmd_buf_in_bytes = cmd_desc[i].length;
+			processed_cmd_buf_in_bytes = 0;
+			if (!total_cmd_buf_in_bytes)
+				continue;
+			rc = cam_mem_get_cpu_buf(cmd_desc[i].mem_handle,
+				(uint64_t *)&generic_ptr, &len_of_buffer);
+			if (rc < 0) {
+				CAM_ERR(CAM_FLASH, "Failed to get cpu buf");
+				return rc;
+			}
+			cmd_buf = (uint32_t *)generic_ptr;
+			if (!cmd_buf) {
+				CAM_ERR(CAM_FLASH, "invalid cmd buf");
+				return -EINVAL;
+			}
+			cmd_buf += cmd_desc[i].offset / sizeof(uint32_t);
+			cmn_hdr = (struct common_header *)cmd_buf;
+
+			/* Loop through cmd formats in one cmd buffer */
+			CAM_DBG(CAM_FLASH,
+				"command Type: %d,Processed: %d,Total: %d",
+				cmn_hdr->cmd_type, processed_cmd_buf_in_bytes,
+				total_cmd_buf_in_bytes);
+			switch (cmn_hdr->cmd_type) {
+			case CAMERA_SENSOR_FLASH_CMD_TYPE_INIT_INFO:
+				flash_init = (struct cam_flash_init *)cmd_buf;
+				fctrl->flash_type = flash_init->flash_type;
+				cmd_length_in_bytes =
+					sizeof(struct cam_flash_init);
+				processed_cmd_buf_in_bytes +=
+					cmd_length_in_bytes;
+				cmd_buf += cmd_length_in_bytes/
+						sizeof(uint32_t);
+				break;
+			case CAMERA_SENSOR_CMD_TYPE_I2C_INFO:
+				rc = cam_flash_slaveInfo_pkt_parser(
+					fctrl, cmd_buf);
+				if (rc < 0) {
+					CAM_ERR(CAM_FLASH,
+					"Failed parsing slave info: rc: %d",
+					rc);
+					return rc;
+				}
+				cmd_length_in_bytes =
+					sizeof(struct cam_cmd_i2c_info);
+				processed_cmd_buf_in_bytes +=
+					cmd_length_in_bytes;
+				cmd_buf += cmd_length_in_bytes/
+						sizeof(uint32_t);
+				break;
+			case CAMERA_SENSOR_CMD_TYPE_PWR_UP:
+			case CAMERA_SENSOR_CMD_TYPE_PWR_DOWN:
+				CAM_DBG(CAM_FLASH,
+					"Received power settings");
+				cmd_length_in_bytes =
+					total_cmd_buf_in_bytes;
+				rc = cam_sensor_update_power_settings(
+					cmd_buf,
+					total_cmd_buf_in_bytes,
+					&fctrl->power_info);
+				processed_cmd_buf_in_bytes +=
+					cmd_length_in_bytes;
+				cmd_buf += cmd_length_in_bytes/
+						sizeof(uint32_t);
+				if (rc) {
+					CAM_ERR(CAM_FLASH,
+					"Failed update power settings");
+					return rc;
+				}
+				break;
+			default:
+				CAM_DBG(CAM_FLASH,
+					"Received initSettings");
+				i2c_data = &(fctrl->i2c_data);
+				i2c_reg_settings =
+					&fctrl->i2c_data.init_settings;
+
+				i2c_reg_settings->request_id = 0;
+				i2c_reg_settings->is_settings_valid = 1;
+				rc = cam_sensor_i2c_command_parser(
+					&fctrl->io_master_info,
+					i2c_reg_settings,
+					&cmd_desc[i], 1);
+				if (rc < 0) {
+					CAM_ERR(CAM_FLASH,
+					"pkt parsing failed: %d", rc);
+					return rc;
+				}
+				cmd_length_in_bytes =
+					cmd_desc[i].length;
+				processed_cmd_buf_in_bytes +=
+					cmd_length_in_bytes;
+				cmd_buf += cmd_length_in_bytes/
+						sizeof(uint32_t);
+
+				break;
+			}
+		}
+		power_info = &fctrl->power_info;
+		if (!power_info) {
+			CAM_ERR(CAM_FLASH, "Power_info is NULL");
+			return -EINVAL;
+		}
+
+		/* Parse and fill vreg params for power up settings */
+		rc = msm_camera_fill_vreg_params(&fctrl->soc_info,
+			power_info->power_setting,
+			power_info->power_setting_size);
+		if (rc) {
+			CAM_ERR(CAM_FLASH,
+				"failed to fill vreg params for power up rc:%d",
+				rc);
+			return rc;
+		}
+
+		/* Parse and fill vreg params for power down settings*/
+		rc = msm_camera_fill_vreg_params(
+			&fctrl->soc_info,
+			power_info->power_down_setting,
+			power_info->power_down_setting_size);
+		if (rc) {
+			CAM_ERR(CAM_FLASH,
+				"failed to fill vreg params power down rc:%d",
+				rc);
+			return rc;
+		}
+
+		rc = fctrl->func_tbl.power_ops(fctrl, true);
+		if (rc) {
+			CAM_ERR(CAM_FLASH,
+				"Enable Regulator Failed rc = %d", rc);
+			return rc;
+		}
+
+		rc = fctrl->func_tbl.apply_setting(fctrl, 0);
+		if (rc) {
+			CAM_ERR(CAM_FLASH, "cannot apply settings rc = %d", rc);
+			return rc;
+		}
+
+		fctrl->flash_state = CAM_FLASH_STATE_CONFIG;
+		break;
+	}
+	case CAM_FLASH_PACKET_OPCODE_SET_OPS: {
+		offset = (uint32_t *)((uint8_t *)&csl_packet->payload +
+			csl_packet->cmd_buf_offset);
+		frm_offset = csl_packet->header.request_id %
+			MAX_PER_FRAME_ARRAY;
+		/* add support for handling i2c_data*/
+		i2c_reg_settings =
+			&fctrl->i2c_data.per_frame[frm_offset];
+		if (i2c_reg_settings->is_settings_valid == true) {
+			i2c_reg_settings->request_id = 0;
+			i2c_reg_settings->is_settings_valid = false;
+			goto update_req_mgr;
+		}
+		i2c_reg_settings->is_settings_valid = true;
+		i2c_reg_settings->request_id =
+			csl_packet->header.request_id;
+		cmd_desc = (struct cam_cmd_buf_desc *)(offset);
+		rc = cam_sensor_i2c_command_parser(
+			&fctrl->io_master_info,
+			i2c_reg_settings, cmd_desc, 1);
+		if (rc) {
+			CAM_ERR(CAM_FLASH,
+			"Failed in parsing i2c packets");
+			return rc;
+		}
+		break;
+	}
+	case CAM_FLASH_PACKET_OPCODE_NON_REALTIME_SET_OPS: {
+		offset = (uint32_t *)((uint8_t *)&csl_packet->payload +
+			csl_packet->cmd_buf_offset);
+
+		/* add support for handling i2c_data*/
+		i2c_reg_settings = &fctrl->i2c_data.config_settings;
+		if (i2c_reg_settings->is_settings_valid == true) {
+			i2c_reg_settings->request_id = 0;
+			i2c_reg_settings->is_settings_valid = false;
+
+			rc = delete_request(i2c_reg_settings);
+			if (rc) {
+				CAM_ERR(CAM_FLASH,
+				"Failed in Deleting the err: %d", rc);
+				return rc;
+			}
+		}
+		i2c_reg_settings->is_settings_valid = true;
+		i2c_reg_settings->request_id =
+			csl_packet->header.request_id;
+		cmd_desc = (struct cam_cmd_buf_desc *)(offset);
+		rc = cam_sensor_i2c_command_parser(
+			&fctrl->io_master_info,
+			i2c_reg_settings, cmd_desc, 1);
+		if (rc) {
+			CAM_ERR(CAM_FLASH,
+			"Failed in parsing i2c NRT packets");
+			return rc;
+		}
+		rc = fctrl->func_tbl.apply_setting(fctrl, 0);
+		if (rc)
+			CAM_ERR(CAM_FLASH,
+			"Apply setting failed: %d", rc);
+		return rc;
+	}
+	case CAM_PKT_NOP_OPCODE: {
+		if ((fctrl->flash_state == CAM_FLASH_STATE_INIT) ||
+			(fctrl->flash_state == CAM_FLASH_STATE_ACQUIRE)) {
+			CAM_WARN(CAM_FLASH,
+				"Rxed NOP packets without linking");
+			frm_offset = csl_packet->header.request_id %
+				MAX_PER_FRAME_ARRAY;
+			fctrl->i2c_data.per_frame[frm_offset].is_settings_valid
+				= false;
+			return 0;
+		}
+
+		CAM_DBG(CAM_FLASH, "NOP Packet is Received: req_id: %u",
+			csl_packet->header.request_id);
+		goto update_req_mgr;
+	}
+	default:
+		CAM_ERR(CAM_FLASH, "Wrong Opcode : %d",
+			(csl_packet->header.op_code & 0xFFFFFF));
+		return -EINVAL;
+	}
+update_req_mgr:
+	if (((csl_packet->header.op_code  & 0xFFFFF) ==
+		CAM_PKT_NOP_OPCODE) ||
+		((csl_packet->header.op_code & 0xFFFFF) ==
+		CAM_FLASH_PACKET_OPCODE_SET_OPS)) {
+		add_req.link_hdl = fctrl->bridge_intf.link_hdl;
+		add_req.req_id = csl_packet->header.request_id;
+		add_req.dev_hdl = fctrl->bridge_intf.device_hdl;
+
+		if ((csl_packet->header.op_code & 0xFFFFF) ==
+			CAM_FLASH_PACKET_OPCODE_SET_OPS)
+			add_req.skip_before_applying = 1;
+		else
+			add_req.skip_before_applying = 0;
+
+		if (fctrl->bridge_intf.crm_cb &&
+			fctrl->bridge_intf.crm_cb->add_req)
+			fctrl->bridge_intf.crm_cb->add_req(&add_req);
+		CAM_DBG(CAM_FLASH, "add req to req_mgr= %lld", add_req.req_id);
+	}
+	return rc;
+}
+
+int cam_flash_pmic_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg)
 {
 	int rc = 0, i = 0;
 	uint64_t generic_ptr;
@@ -585,8 +1242,6 @@
 		/* INIT packet*/
 		offset = (uint32_t *)((uint8_t *)&csl_packet->payload +
 			csl_packet->cmd_buf_offset);
-		fctrl->flash_init_setting.cmn_attr.request_id = 0;
-		fctrl->flash_init_setting.cmn_attr.is_settings_valid = true;
 		cmd_desc = (struct cam_cmd_buf_desc *)(offset);
 		rc = cam_mem_get_cpu_buf(cmd_desc->mem_handle,
 			(uint64_t *)&generic_ptr, &len_of_buffer);
@@ -595,40 +1250,53 @@
 		cam_flash_info = (struct cam_flash_init *)cmd_buf;
 
 		switch (cam_flash_info->cmd_type) {
-		case CAMERA_SENSOR_FLASH_CMD_TYPE_INIT_INFO:
+		case CAMERA_SENSOR_FLASH_CMD_TYPE_INIT_INFO: {
+			CAM_DBG(CAM_FLASH, "INIT_INFO CMD CALLED");
+			fctrl->flash_init_setting.cmn_attr.request_id = 0;
+			fctrl->flash_init_setting.cmn_attr.is_settings_valid =
+				true;
 			fctrl->flash_type = cam_flash_info->flash_type;
 			fctrl->is_regulator_enabled = false;
 			fctrl->nrt_info.cmn_attr.cmd_type =
 				CAMERA_SENSOR_FLASH_CMD_TYPE_INIT_INFO;
+
+			rc = fctrl->func_tbl.power_ops(fctrl, true);
+			if (rc) {
+				CAM_ERR(CAM_FLASH,
+					"Enable Regulator Failed rc = %d", rc);
+				return rc;
+			}
+
 			fctrl->flash_state =
 				CAM_FLASH_STATE_CONFIG;
 			break;
-		case CAMERA_SENSOR_FLASH_CMD_TYPE_INIT_FIRE:
-			CAM_DBG(CAM_FLASH, "INIT Fire Operation");
-				flash_operation_info =
-					(struct cam_flash_set_on_off *) cmd_buf;
-				fctrl->nrt_info.cmn_attr.count =
-					flash_operation_info->count;
-				fctrl->nrt_info.cmn_attr.request_id = 0;
-				fctrl->nrt_info.opcode =
-					flash_operation_info->opcode;
-				fctrl->nrt_info.cmn_attr.cmd_type =
-					CAMERA_SENSOR_FLASH_CMD_TYPE_INIT_FIRE;
-				for (i = 0;
-					i < flash_operation_info->count; i++)
-					fctrl->nrt_info.led_current_ma[i] =
-					flash_operation_info->led_current_ma[i];
+		}
+		case CAMERA_SENSOR_FLASH_CMD_TYPE_INIT_FIRE: {
+			CAM_DBG(CAM_FLASH, "INIT_FIRE Operation");
 
-				mutex_lock(&fctrl->flash_wq_mutex);
-				rc = cam_flash_apply_setting(fctrl, 0);
-				if (rc)
-					CAM_ERR(CAM_FLASH,
-						"Apply setting failed: %d",
-						rc);
-				mutex_unlock(&fctrl->flash_wq_mutex);
-				fctrl->flash_state =
-					CAM_FLASH_STATE_CONFIG;
+			flash_operation_info =
+				(struct cam_flash_set_on_off *) cmd_buf;
+			fctrl->nrt_info.cmn_attr.count =
+				flash_operation_info->count;
+			fctrl->nrt_info.cmn_attr.request_id = 0;
+			fctrl->nrt_info.opcode =
+				flash_operation_info->opcode;
+			fctrl->nrt_info.cmn_attr.cmd_type =
+				CAMERA_SENSOR_FLASH_CMD_TYPE_INIT_FIRE;
+			for (i = 0;
+				i < flash_operation_info->count; i++)
+				fctrl->nrt_info.led_current_ma[i] =
+				flash_operation_info->led_current_ma[i];
+
+			rc = fctrl->func_tbl.apply_setting(fctrl, 0);
+			if (rc)
+				CAM_ERR(CAM_FLASH,
+					"Apply setting failed: %d",
+					rc);
+
+			fctrl->flash_state = CAM_FLASH_STATE_CONFIG;
 			break;
+		}
 		default:
 			CAM_ERR(CAM_FLASH, "Wrong cmd_type = %d",
 				cam_flash_info->cmd_type);
@@ -666,7 +1334,7 @@
 		switch (cmn_hdr->cmd_type) {
 		case CAMERA_SENSOR_FLASH_CMD_TYPE_FIRE: {
 			CAM_DBG(CAM_FLASH,
-				"CAMERA_FLASH_CMD_TYPE_OPS case called");
+				"CAMERA_SENSOR_FLASH_CMD_TYPE_FIRE cmd called");
 			if ((fctrl->flash_state == CAM_FLASH_STATE_INIT) ||
 				(fctrl->flash_state ==
 					CAM_FLASH_STATE_ACQUIRE)) {
@@ -690,8 +1358,8 @@
 			for (i = 0; i < flash_operation_info->count; i++)
 				flash_data->led_current_ma[i]
 				= flash_operation_info->led_current_ma[i];
-			}
-			break;
+		}
+		break;
 		default:
 			CAM_ERR(CAM_FLASH, "Wrong cmd_type = %d",
 				cmn_hdr->cmd_type);
@@ -727,12 +1395,10 @@
 				fctrl->nrt_info.led_current_ma[i] =
 					flash_operation_info->led_current_ma[i];
 
-			mutex_lock(&fctrl->flash_wq_mutex);
-			rc = cam_flash_apply_setting(fctrl, 0);
+			rc = fctrl->func_tbl.apply_setting(fctrl, 0);
 			if (rc)
 				CAM_ERR(CAM_FLASH, "Apply setting failed: %d",
 					rc);
-			mutex_unlock(&fctrl->flash_wq_mutex);
 			return rc;
 		}
 		case CAMERA_SENSOR_FLASH_CMD_TYPE_QUERYCURR: {
@@ -773,12 +1439,10 @@
 					flash_rer_info->led_current_ma[i];
 
 
-			mutex_lock(&fctrl->flash_wq_mutex);
-			rc = cam_flash_apply_setting(fctrl, 0);
+			rc = fctrl->func_tbl.apply_setting(fctrl, 0);
 			if (rc)
 				CAM_ERR(CAM_FLASH, "apply_setting failed: %d",
 					rc);
-			mutex_unlock(&fctrl->flash_wq_mutex);
 			return rc;
 		}
 		default:
@@ -786,7 +1450,6 @@
 				cmn_hdr->cmd_type);
 			return -EINVAL;
 		}
-
 		break;
 	}
 	case CAM_PKT_NOP_OPCODE: {
@@ -804,7 +1467,7 @@
 		fctrl->per_frame[frm_offset].cmn_attr.is_settings_valid = false;
 		fctrl->per_frame[frm_offset].cmn_attr.request_id = 0;
 		fctrl->per_frame[frm_offset].opcode = CAM_PKT_NOP_OPCODE;
-		CAM_DBG(CAM_FLASH, "NOP Packet is Received: req_id: %u",
+		CAM_DBG(CAM_FLASH, "NOP Packet is Received: req_id: %llu",
 			csl_packet->header.request_id);
 		goto update_req_mgr;
 	}
@@ -858,7 +1521,7 @@
 		CAM_ERR(CAM_FLASH, " Device data is NULL");
 		return -EINVAL;
 	}
-
+	mutex_lock(&fctrl->flash_mutex);
 	if (link->link_enable) {
 		fctrl->bridge_intf.link_hdl = link->link_hdl;
 		fctrl->bridge_intf.crm_cb = link->crm_cb;
@@ -866,43 +1529,11 @@
 		fctrl->bridge_intf.link_hdl = -1;
 		fctrl->bridge_intf.crm_cb = NULL;
 	}
+	mutex_unlock(&fctrl->flash_mutex);
 
 	return 0;
 }
 
-
-int cam_flash_stop_dev(struct cam_flash_ctrl *fctrl)
-{
-	int rc = 0, i, j;
-
-	cam_flash_off(fctrl);
-
-	for (i = 0; i < MAX_PER_FRAME_ARRAY; i++) {
-		fctrl->per_frame[i].cmn_attr.request_id = 0;
-		fctrl->per_frame[i].cmn_attr.is_settings_valid = false;
-		fctrl->per_frame[i].cmn_attr.count = 0;
-		for (j = 0; j < CAM_FLASH_MAX_LED_TRIGGERS; j++)
-			fctrl->per_frame[i].led_current_ma[j] = 0;
-	}
-
-	rc = cam_flash_flush_nrt(fctrl);
-	if (rc) {
-		CAM_ERR(CAM_FLASH,
-			"NonRealTime Dev flush failed rc: %d", rc);
-		return rc;
-	}
-
-	if ((fctrl->flash_state == CAM_FLASH_STATE_START) &&
-		(fctrl->is_regulator_enabled == true)) {
-		rc = cam_flash_prepare(fctrl, false);
-		if (rc)
-			CAM_ERR(CAM_FLASH, "Disable Regulator Failed rc: %d",
-				rc);
-	}
-
-	return rc;
-}
-
 int cam_flash_release_dev(struct cam_flash_ctrl *fctrl)
 {
 	int rc = 0;
@@ -930,9 +1561,13 @@
 
 	if ((fctrl->flash_state == CAM_FLASH_STATE_CONFIG) ||
 		(fctrl->flash_state == CAM_FLASH_STATE_START)) {
-		rc = cam_flash_stop_dev(fctrl);
+		mutex_lock(&(fctrl->flash_mutex));
+		fctrl->func_tbl.flush_req(fctrl, FLUSH_ALL, 0);
+		mutex_unlock(&(fctrl->flash_mutex));
+		rc = fctrl->func_tbl.power_ops(fctrl, false);
 		if (rc)
-			CAM_ERR(CAM_FLASH, "Stop Failed rc: %d", rc);
+			CAM_ERR(CAM_FLASH, "Power Down Failed rc: %d",
+				rc);
 	}
 
 	rc = cam_flash_release_dev(fctrl);
@@ -956,12 +1591,12 @@
 		return -EINVAL;
 	}
 
-	mutex_lock(&fctrl->flash_wq_mutex);
-	rc = cam_flash_apply_setting(fctrl, apply->request_id);
+	mutex_lock(&fctrl->flash_mutex);
+	rc = fctrl->func_tbl.apply_setting(fctrl, apply->request_id);
 	if (rc)
 		CAM_ERR(CAM_FLASH, "apply_setting failed with rc=%d",
 			rc);
-	mutex_unlock(&fctrl->flash_wq_mutex);
+	mutex_unlock(&fctrl->flash_mutex);
 
 	return rc;
 }
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_core.h b/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_core.h
index f73409a..1bd3b31 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_core.h
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_core.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -16,20 +16,12 @@
 #include <linux/leds-qpnp-flash.h>
 #include <media/cam_sensor.h>
 #include "cam_flash_dev.h"
-#include "cam_sync_api.h"
-#include "cam_mem_mgr_api.h"
 
-int cam_flash_parser(struct cam_flash_ctrl *fctrl, void *arg);
 int cam_flash_publish_dev_info(struct cam_req_mgr_device_info *info);
 int cam_flash_establish_link(struct cam_req_mgr_core_dev_link_setup *link);
-int cam_flash_apply_setting(struct cam_flash_ctrl *fctrl, uint64_t req_id);
 int cam_flash_apply_request(struct cam_req_mgr_apply_request *apply);
 int cam_flash_process_evt(struct cam_req_mgr_link_evt_data *event_data);
 int cam_flash_flush_request(struct cam_req_mgr_flush_request *flush);
-int cam_flash_off(struct cam_flash_ctrl *fctrl);
-int cam_flash_prepare(struct cam_flash_ctrl *flash_ctrl,
-	bool regulator_enable);
-void cam_flash_shutdown(struct cam_flash_ctrl *flash_ctrl);
-int cam_flash_stop_dev(struct cam_flash_ctrl *flash_ctrl);
-int cam_flash_release_dev(struct cam_flash_ctrl *fctrl);
+
+
 #endif /*_CAM_FLASH_CORE_H_*/
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_dev.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_dev.c
index f8be3de..199b505 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_dev.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_dev.c
@@ -93,7 +93,7 @@
 		if ((fctrl->flash_state == CAM_FLASH_STATE_INIT) ||
 			(fctrl->flash_state == CAM_FLASH_STATE_START)) {
 			CAM_WARN(CAM_FLASH,
-				"Cannot apply Release dev: Prev state:%d",
+				"Wrong state for Release dev: Prev state:%d",
 				fctrl->flash_state);
 		}
 
@@ -106,11 +106,18 @@
 			rc = -EINVAL;
 			goto release_mutex;
 		}
-		rc = cam_flash_release_dev(fctrl);
-		if (rc)
-			CAM_ERR(CAM_FLASH,
-				"Failed in destroying the device Handle rc= %d",
-				rc);
+
+		if ((fctrl->flash_state == CAM_FLASH_STATE_CONFIG) ||
+			(fctrl->flash_state == CAM_FLASH_STATE_START))
+			fctrl->func_tbl.flush_req(fctrl, FLUSH_ALL, 0);
+
+		if (cam_flash_release_dev(fctrl))
+			CAM_WARN(CAM_FLASH,
+				"Failed in destroying the device Handle");
+
+		if (fctrl->func_tbl.power_ops(fctrl, false))
+			CAM_WARN(CAM_FLASH, "Power Down Failed");
+
 		fctrl->flash_state = CAM_FLASH_STATE_INIT;
 		break;
 	}
@@ -149,15 +156,6 @@
 			goto release_mutex;
 		}
 
-		if (fctrl->is_regulator_enabled == false) {
-			rc = cam_flash_prepare(fctrl, true);
-			if (rc) {
-				CAM_ERR(CAM_FLASH,
-					"Enable Regulator Failed rc = %d", rc);
-				goto release_mutex;
-			}
-		}
-
 		fctrl->flash_state = CAM_FLASH_STATE_START;
 		break;
 	}
@@ -171,18 +169,13 @@
 			goto release_mutex;
 		}
 
-		rc = cam_flash_stop_dev(fctrl);
-		if (rc) {
-			CAM_ERR(CAM_FLASH, "Stop Dev Failed rc = %d",
-				rc);
-			goto release_mutex;
-		}
+		fctrl->func_tbl.flush_req(fctrl, FLUSH_ALL, 0);
 		fctrl->flash_state = CAM_FLASH_STATE_ACQUIRE;
 		break;
 	}
 	case CAM_CONFIG_DEV: {
 		CAM_DBG(CAM_FLASH, "CAM_CONFIG_DEV");
-		rc = cam_flash_parser(fctrl, arg);
+		rc = fctrl->func_tbl.parser(fctrl, arg);
 		if (rc) {
 			CAM_ERR(CAM_FLASH, "Failed Flash Config: rc=%d\n", rc);
 			goto release_mutex;
@@ -199,6 +192,35 @@
 	return rc;
 }
 
+static int32_t cam_flash_init_default_params(struct cam_flash_ctrl *fctrl)
+{
+	/* Validate input parameters */
+	if (!fctrl) {
+		CAM_ERR(CAM_FLASH, "failed: invalid params fctrl %pK",
+			fctrl);
+		return -EINVAL;
+	}
+
+	CAM_DBG(CAM_FLASH,
+		"master_type: %d", fctrl->io_master_info.master_type);
+	/* Initialize cci_client */
+	if (fctrl->io_master_info.master_type == CCI_MASTER) {
+		fctrl->io_master_info.cci_client = kzalloc(sizeof(
+			struct cam_sensor_cci_client), GFP_KERNEL);
+		if (!(fctrl->io_master_info.cci_client))
+			return -ENOMEM;
+	} else if (fctrl->io_master_info.master_type == I2C_MASTER) {
+		if (!(fctrl->io_master_info.client))
+			return -EINVAL;
+	} else {
+		CAM_ERR(CAM_FLASH,
+			"Invalid master / Master type Not supported");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 static const struct of_device_id cam_flash_dt_match[] = {
 	{.compatible = "qcom,camera-flash", .data = NULL},
 	{}
@@ -289,20 +311,36 @@
 	return 0;
 }
 
+static int32_t cam_flash_i2c_driver_remove(struct i2c_client *client)
+{
+	int32_t rc = 0;
+	struct cam_flash_ctrl *fctrl = i2c_get_clientdata(client);
+	/* Handle I2C Devices */
+	if (!fctrl) {
+		CAM_ERR(CAM_FLASH, "Flash device is NULL");
+		return -EINVAL;
+	}
+	/*Free Allocated Mem */
+	kfree(fctrl->i2c_data.per_frame);
+	fctrl->i2c_data.per_frame = NULL;
+	kfree(fctrl);
+	return rc;
+}
+
 static int cam_flash_subdev_close(struct v4l2_subdev *sd,
 	struct v4l2_subdev_fh *fh)
 {
-	struct cam_flash_ctrl *flash_ctrl =
+	struct cam_flash_ctrl *fctrl =
 		v4l2_get_subdevdata(sd);
 
-	if (!flash_ctrl) {
+	if (!fctrl) {
 		CAM_ERR(CAM_FLASH, "Flash ctrl ptr is NULL");
 		return -EINVAL;
 	}
 
-	mutex_lock(&flash_ctrl->flash_mutex);
-	cam_flash_shutdown(flash_ctrl);
-	mutex_unlock(&flash_ctrl->flash_mutex);
+	mutex_lock(&fctrl->flash_mutex);
+	cam_flash_shutdown(fctrl);
+	mutex_unlock(&fctrl->flash_mutex);
 
 	return 0;
 }
@@ -322,10 +360,30 @@
 	.close = cam_flash_subdev_close,
 };
 
+static int cam_flash_init_subdev(struct cam_flash_ctrl *fctrl)
+{
+	int rc = 0;
+
+	fctrl->v4l2_dev_str.internal_ops =
+		&cam_flash_internal_ops;
+	fctrl->v4l2_dev_str.ops = &cam_flash_subdev_ops;
+	fctrl->v4l2_dev_str.name = CAMX_FLASH_DEV_NAME;
+	fctrl->v4l2_dev_str.sd_flags =
+		V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS;
+	fctrl->v4l2_dev_str.ent_function = CAM_FLASH_DEVICE_TYPE;
+	fctrl->v4l2_dev_str.token = fctrl;
+
+	rc = cam_register_subdev(&(fctrl->v4l2_dev_str));
+	if (rc)
+		CAM_ERR(CAM_FLASH, "Fail to create subdev with %d", rc);
+
+	return rc;
+}
+
 static int32_t cam_flash_platform_probe(struct platform_device *pdev)
 {
-	int32_t rc = 0;
-	struct cam_flash_ctrl *flash_ctrl = NULL;
+	int32_t rc = 0, i = 0;
+	struct cam_flash_ctrl *fctrl = NULL;
 
 	CAM_DBG(CAM_FLASH, "Enter");
 	if (!pdev->dev.of_node) {
@@ -333,53 +391,181 @@
 		return -EINVAL;
 	}
 
-	flash_ctrl = kzalloc(sizeof(struct cam_flash_ctrl), GFP_KERNEL);
-	if (!flash_ctrl)
+	fctrl = kzalloc(sizeof(struct cam_flash_ctrl), GFP_KERNEL);
+	if (!fctrl)
 		return -ENOMEM;
 
-	flash_ctrl->pdev = pdev;
-	flash_ctrl->soc_info.pdev = pdev;
-	flash_ctrl->soc_info.dev = &pdev->dev;
-	flash_ctrl->soc_info.dev_name = pdev->name;
+	fctrl->pdev = pdev;
+	fctrl->soc_info.pdev = pdev;
+	fctrl->soc_info.dev = &pdev->dev;
+	fctrl->soc_info.dev_name = pdev->name;
 
-	rc = cam_flash_get_dt_data(flash_ctrl, &flash_ctrl->soc_info);
+	platform_set_drvdata(pdev, fctrl);
+
+	rc = cam_flash_get_dt_data(fctrl, &fctrl->soc_info);
 	if (rc) {
 		CAM_ERR(CAM_FLASH, "cam_flash_get_dt_data failed with %d", rc);
-		kfree(flash_ctrl);
+		kfree(fctrl);
 		return -EINVAL;
 	}
 
-	flash_ctrl->v4l2_dev_str.internal_ops =
-		&cam_flash_internal_ops;
-	flash_ctrl->v4l2_dev_str.ops = &cam_flash_subdev_ops;
-	flash_ctrl->v4l2_dev_str.name = CAMX_FLASH_DEV_NAME;
-	flash_ctrl->v4l2_dev_str.sd_flags =
-		V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS;
-	flash_ctrl->v4l2_dev_str.ent_function = CAM_FLASH_DEVICE_TYPE;
-	flash_ctrl->v4l2_dev_str.token = flash_ctrl;
+	if (of_find_property(pdev->dev.of_node, "cci-master", NULL)) {
+		/* Get CCI master */
+		rc = of_property_read_u32(pdev->dev.of_node, "cci-master",
+			&fctrl->cci_i2c_master);
+		CAM_DBG(CAM_FLASH, "cci-master %d, rc %d",
+			fctrl->cci_i2c_master, rc);
+		if (rc < 0) {
+			/* Set default master 0 */
+			fctrl->cci_i2c_master = MASTER_0;
+			rc = 0;
+		}
 
-	rc = cam_register_subdev(&(flash_ctrl->v4l2_dev_str));
-	if (rc) {
-		CAM_ERR(CAM_FLASH, "Fail to create subdev with %d", rc);
-		goto free_resource;
+		fctrl->io_master_info.master_type = CCI_MASTER;
+		rc = cam_flash_init_default_params(fctrl);
+		if (rc) {
+			CAM_ERR(CAM_FLASH,
+				"failed: cam_flash_init_default_params rc %d",
+				rc);
+			return rc;
+		}
+
+		fctrl->i2c_data.per_frame = (struct i2c_settings_array *)
+			kzalloc(sizeof(struct i2c_settings_array) *
+			MAX_PER_FRAME_ARRAY, GFP_KERNEL);
+		if (fctrl->i2c_data.per_frame == NULL) {
+			CAM_ERR(CAM_FLASH, "No Memory");
+			rc = -ENOMEM;
+			goto free_cci_resource;
+		}
+
+		INIT_LIST_HEAD(&(fctrl->i2c_data.init_settings.list_head));
+		INIT_LIST_HEAD(&(fctrl->i2c_data.config_settings.list_head));
+		for (i = 0; i < MAX_PER_FRAME_ARRAY; i++)
+			INIT_LIST_HEAD(
+				&(fctrl->i2c_data.per_frame[i].list_head));
+
+		fctrl->func_tbl.parser = cam_flash_i2c_pkt_parser;
+		fctrl->func_tbl.apply_setting = cam_flash_i2c_apply_setting;
+		fctrl->func_tbl.power_ops = cam_flash_i2c_power_ops;
+		fctrl->func_tbl.flush_req = cam_flash_i2c_flush_request;
+	} else {
+		/* PMIC Flash */
+		fctrl->func_tbl.parser = cam_flash_pmic_pkt_parser;
+		fctrl->func_tbl.apply_setting = cam_flash_pmic_apply_setting;
+		fctrl->func_tbl.power_ops = cam_flash_pmic_power_ops;
+		fctrl->func_tbl.flush_req = cam_flash_pmic_flush_request;
 	}
-	flash_ctrl->bridge_intf.device_hdl = -1;
-	flash_ctrl->bridge_intf.ops.get_dev_info = cam_flash_publish_dev_info;
-	flash_ctrl->bridge_intf.ops.link_setup = cam_flash_establish_link;
-	flash_ctrl->bridge_intf.ops.apply_req = cam_flash_apply_request;
-	flash_ctrl->bridge_intf.ops.flush_req = cam_flash_flush_request;
 
-	platform_set_drvdata(pdev, flash_ctrl);
-	v4l2_set_subdevdata(&flash_ctrl->v4l2_dev_str.sd, flash_ctrl);
+	rc = cam_flash_init_subdev(fctrl);
+	if (rc) {
+		if (fctrl->io_master_info.cci_client != NULL)
+			goto free_cci_resource;
+		else
+			goto free_resource;
+	}
 
-	mutex_init(&(flash_ctrl->flash_mutex));
-	mutex_init(&(flash_ctrl->flash_wq_mutex));
+	fctrl->bridge_intf.device_hdl = -1;
+	fctrl->bridge_intf.ops.get_dev_info = cam_flash_publish_dev_info;
+	fctrl->bridge_intf.ops.link_setup = cam_flash_establish_link;
+	fctrl->bridge_intf.ops.apply_req = cam_flash_apply_request;
+	fctrl->bridge_intf.ops.flush_req = cam_flash_flush_request;
 
-	flash_ctrl->flash_state = CAM_FLASH_STATE_INIT;
+	mutex_init(&(fctrl->flash_mutex));
+
+	fctrl->flash_state = CAM_FLASH_STATE_INIT;
 	CAM_DBG(CAM_FLASH, "Probe success");
 	return rc;
+
+free_cci_resource:
+	kfree(fctrl->io_master_info.cci_client);
+	fctrl->io_master_info.cci_client = NULL;
 free_resource:
-	kfree(flash_ctrl);
+	kfree(fctrl->i2c_data.per_frame);
+	kfree(fctrl->soc_info.soc_private);
+	cam_soc_util_release_platform_resource(&fctrl->soc_info);
+	fctrl->i2c_data.per_frame = NULL;
+	fctrl->soc_info.soc_private = NULL;
+	kfree(fctrl);
+	fctrl = NULL;
+	return rc;
+}
+
+static int32_t cam_flash_i2c_driver_probe(struct i2c_client *client,
+	const struct i2c_device_id *id)
+{
+	int32_t rc = 0, i = 0;
+	struct cam_flash_ctrl *fctrl;
+
+	if (client == NULL || id == NULL) {
+		CAM_ERR(CAM_FLASH, "Invalid Args client: %pK id: %pK",
+			client, id);
+		return -EINVAL;
+	}
+
+	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
+		CAM_ERR(CAM_FLASH, "%s :: i2c_check_functionality failed",
+			 client->name);
+		return -EFAULT;
+	}
+
+	/* Create sensor control structure */
+	fctrl = kzalloc(sizeof(*fctrl), GFP_KERNEL);
+	if (!fctrl)
+		return -ENOMEM;
+
+	i2c_set_clientdata(client, fctrl);
+
+	fctrl->io_master_info.client = client;
+	fctrl->soc_info.dev = &client->dev;
+	fctrl->soc_info.dev_name = client->name;
+	fctrl->io_master_info.master_type = I2C_MASTER;
+
+	rc = cam_flash_get_dt_data(fctrl, &fctrl->soc_info);
+	if (rc) {
+		CAM_ERR(CAM_FLASH, "failed: cam_sensor_parse_dt rc %d", rc);
+		goto free_ctrl;
+	}
+
+	rc = cam_flash_init_subdev(fctrl);
+	if (rc)
+		goto free_ctrl;
+
+	fctrl->i2c_data.per_frame =
+		(struct i2c_settings_array *)
+		kzalloc(sizeof(struct i2c_settings_array) *
+		MAX_PER_FRAME_ARRAY, GFP_KERNEL);
+	if (fctrl->i2c_data.per_frame == NULL) {
+		rc = -ENOMEM;
+		goto unreg_subdev;
+	}
+
+	INIT_LIST_HEAD(&(fctrl->i2c_data.init_settings.list_head));
+	INIT_LIST_HEAD(&(fctrl->i2c_data.config_settings.list_head));
+	for (i = 0; i < MAX_PER_FRAME_ARRAY; i++)
+		INIT_LIST_HEAD(&(fctrl->i2c_data.per_frame[i].list_head));
+
+	fctrl->func_tbl.parser = cam_flash_i2c_pkt_parser;
+	fctrl->func_tbl.apply_setting = cam_flash_i2c_apply_setting;
+	fctrl->func_tbl.power_ops = cam_flash_i2c_power_ops;
+	fctrl->func_tbl.flush_req = cam_flash_i2c_flush_request;
+
+	fctrl->bridge_intf.device_hdl = -1;
+	fctrl->bridge_intf.ops.get_dev_info = cam_flash_publish_dev_info;
+	fctrl->bridge_intf.ops.link_setup = cam_flash_establish_link;
+	fctrl->bridge_intf.ops.apply_req = cam_flash_apply_request;
+	fctrl->bridge_intf.ops.flush_req = cam_flash_flush_request;
+
+	mutex_init(&(fctrl->flash_mutex));
+	fctrl->flash_state = CAM_FLASH_STATE_INIT;
+
+	return rc;
+
+unreg_subdev:
+	cam_unregister_subdev(&(fctrl->v4l2_dev_str));
+free_ctrl:
+	kfree(fctrl);
+	fctrl = NULL;
 	return rc;
 }
 
@@ -396,20 +582,40 @@
 	},
 };
 
-static int __init cam_flash_init_module(void)
+static const struct i2c_device_id i2c_id[] = {
+	{FLASH_DRIVER_I2C, (kernel_ulong_t)NULL},
+	{ }
+};
+
+static struct i2c_driver cam_flash_i2c_driver = {
+	.id_table = i2c_id,
+	.probe  = cam_flash_i2c_driver_probe,
+	.remove = cam_flash_i2c_driver_remove,
+	.driver = {
+		.name = FLASH_DRIVER_I2C,
+	},
+};
+
+static int32_t __init cam_flash_init_module(void)
 {
 	int32_t rc = 0;
 
 	rc = platform_driver_register(&cam_flash_platform_driver);
-	if (rc)
-		CAM_ERR(CAM_FLASH, "platform probe for flash failed");
+	if (rc == 0) {
+		CAM_DBG(CAM_FLASH, "platform probe success");
+		return 0;
+	}
 
+	rc = i2c_add_driver(&cam_flash_i2c_driver);
+	if (rc)
+		CAM_ERR(CAM_FLASH, "i2c_add_driver failed rc: %d", rc);
 	return rc;
 }
 
 static void __exit cam_flash_exit_module(void)
 {
 	platform_driver_unregister(&cam_flash_platform_driver);
+	i2c_del_driver(&cam_flash_i2c_driver);
 }
 
 module_init(cam_flash_init_module);
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_dev.h b/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_dev.h
index 4adc1b2..cb54239 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_dev.h
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_dev.h
@@ -33,15 +33,21 @@
 #include "cam_sensor_cmn_header.h"
 #include "cam_soc_util.h"
 #include "cam_debug_util.h"
+#include "cam_sensor_io.h"
+#include "cam_flash_core.h"
 
 #define CAMX_FLASH_DEV_NAME "cam-flash-dev"
 
 #define CAM_FLASH_PIPELINE_DELAY 1
 
+#define FLASH_DRIVER_I2C "i2c_flash"
+
 #define CAM_FLASH_PACKET_OPCODE_INIT                 0
 #define CAM_FLASH_PACKET_OPCODE_SET_OPS              1
 #define CAM_FLASH_PACKET_OPCODE_NON_REALTIME_SET_OPS 2
 
+struct cam_flash_ctrl;
+
 enum cam_flash_switch_trigger_ops {
 	LED_SWITCH_OFF = 0,
 	LED_SWITCH_ON,
@@ -54,6 +60,12 @@
 	CAM_FLASH_STATE_START,
 };
 
+enum cam_flash_flush_type {
+	FLUSH_ALL = 0,
+	FLUSH_REQ,
+	FLUSH_MAX,
+};
+
 /**
  * struct cam_flash_intf_params
  * @device_hdl   : Device Handle
@@ -136,6 +148,14 @@
 	uint32_t     torch_max_current[CAM_FLASH_MAX_LED_TRIGGERS];
 };
 
+struct cam_flash_func_tbl {
+	int (*parser)(struct cam_flash_ctrl *fctrl, void *arg);
+	int (*apply_setting)(struct cam_flash_ctrl *fctrl, uint64_t req_id);
+	int (*power_ops)(struct cam_flash_ctrl *fctrl, bool regulator_enable);
+	int (*flush_req)(struct cam_flash_ctrl *fctrl,
+		enum cam_flash_flush_type type, uint64_t req_id);
+};
+
 /**
  *  struct cam_flash_ctrl
  * @soc_info            : Soc related information
@@ -150,32 +170,57 @@
  * @flash_num_sources   : Number of flash sources
  * @torch_num_source    : Number of torch sources
  * @flash_mutex         : Mutex for flash operations
- * @flash_wq_mutex      : Mutex for flash apply setting
- * @flash_state         : Current flash state (LOW/OFF/ON/INIT)
+  * @flash_state         : Current flash state (LOW/OFF/ON/INIT)
  * @flash_type          : Flash types (PMIC/I2C/GPIO)
  * @is_regulator_enable : Regulator disable/enable notifier
+ * @func_tbl            : Function table for different HW
+ *	                      (e.g. i2c/pmic/gpio)
  * @flash_trigger       : Flash trigger ptr
  * @torch_trigger       : Torch trigger ptr
+ * @cci_i2c_master      : I2C structure
+ * @io_master_info      : Information about the communication master
+ * @i2c_data            : I2C register settings
  */
 struct cam_flash_ctrl {
-	struct cam_hw_soc_info          soc_info;
-	struct platform_device         *pdev;
-	struct cam_flash_frame_setting  per_frame[MAX_PER_FRAME_ARRAY];
-	struct cam_flash_frame_setting  nrt_info;
-	struct device_node             *of_node;
-	struct cam_subdev               v4l2_dev_str;
-	struct cam_flash_intf_params    bridge_intf;
-	struct cam_flash_init_packet    flash_init_setting;
-	struct led_trigger             *switch_trigger;
-	uint32_t                        flash_num_sources;
-	uint32_t                        torch_num_sources;
-	struct mutex                    flash_mutex;
-	struct mutex                    flash_wq_mutex;
-	enum   cam_flash_state          flash_state;
-	uint8_t                         flash_type;
-	bool                            is_regulator_enabled;
+	struct cam_hw_soc_info              soc_info;
+	struct platform_device             *pdev;
+	struct cam_sensor_power_ctrl_t      power_info;
+	struct cam_flash_frame_setting      per_frame[MAX_PER_FRAME_ARRAY];
+	struct cam_flash_frame_setting      nrt_info;
+	struct device_node                 *of_node;
+	struct cam_subdev                   v4l2_dev_str;
+	struct cam_flash_intf_params        bridge_intf;
+	struct cam_flash_init_packet        flash_init_setting;
+	struct led_trigger                 *switch_trigger;
+	uint32_t                            flash_num_sources;
+	uint32_t                            torch_num_sources;
+	struct mutex                        flash_mutex;
+	enum   cam_flash_state              flash_state;
+	uint8_t                             flash_type;
+	bool                                is_regulator_enabled;
+	struct cam_flash_func_tbl           func_tbl;
 	struct led_trigger           *flash_trigger[CAM_FLASH_MAX_LED_TRIGGERS];
 	struct led_trigger           *torch_trigger[CAM_FLASH_MAX_LED_TRIGGERS];
+/* I2C related setting */
+	enum   cci_i2c_master_t             cci_i2c_master;
+	struct camera_io_master             io_master_info;
+	struct i2c_data_settings            i2c_data;
 };
 
+int cam_flash_pmic_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg);
+int cam_flash_i2c_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg);
+int cam_flash_pmic_apply_setting(struct cam_flash_ctrl *fctrl, uint64_t req_id);
+int cam_flash_i2c_apply_setting(struct cam_flash_ctrl *fctrl, uint64_t req_id);
+int cam_flash_off(struct cam_flash_ctrl *fctrl);
+int cam_flash_pmic_power_ops(struct cam_flash_ctrl *fctrl,
+	bool regulator_enable);
+int cam_flash_i2c_power_ops(struct cam_flash_ctrl *fctrl,
+	bool regulator_enable);
+int cam_flash_i2c_flush_request(struct cam_flash_ctrl *fctrl,
+	enum cam_flash_flush_type type, uint64_t req_id);
+int cam_flash_pmic_flush_request(struct cam_flash_ctrl *fctrl,
+	enum cam_flash_flush_type, uint64_t req_id);
+void cam_flash_shutdown(struct cam_flash_ctrl *fctrl);
+int cam_flash_release_dev(struct cam_flash_ctrl *fctrl);
+
 #endif /*_CAM_FLASH_DEV_H_*/
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_soc.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_soc.c
index a195762..22a124d 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_soc.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_soc.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -193,32 +193,31 @@
 		return -EINVAL;
 	}
 
-	of_node = fctrl->pdev->dev.of_node;
-
-	rc = cam_soc_util_get_dt_properties(soc_info);
-	if (rc < 0) {
-		CAM_ERR(CAM_FLASH, "Get_dt_properties failed rc %d", rc);
-		return rc;
-	}
-
 	soc_info->soc_private =
 		kzalloc(sizeof(struct cam_flash_private_soc), GFP_KERNEL);
 	if (!soc_info->soc_private) {
 		rc = -ENOMEM;
 		goto release_soc_res;
 	}
+	of_node = fctrl->pdev->dev.of_node;
+
+	rc = cam_soc_util_get_dt_properties(soc_info);
+	if (rc) {
+		CAM_ERR(CAM_FLASH, "Get_dt_properties failed rc %d", rc);
+		goto free_soc_private;
+	}
 
 	rc = cam_get_source_node_info(of_node, fctrl, soc_info->soc_private);
-	if (rc < 0) {
+	if (rc) {
 		CAM_ERR(CAM_FLASH,
 			"cam_flash_get_pmic_source_info failed rc %d", rc);
 		goto free_soc_private;
 	}
-
 	return rc;
 
 free_soc_private:
 	kfree(soc_info->soc_private);
+	soc_info->soc_private = NULL;
 release_soc_res:
 	cam_soc_util_release_platform_resource(soc_info);
 	return rc;
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_ois/cam_ois_core.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_ois/cam_ois_core.c
index 0570655..09e8d53 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_ois/cam_ois_core.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_ois/cam_ois_core.c
@@ -193,7 +193,7 @@
 		return -EINVAL;
 	}
 
-	rc = msm_camera_power_down(power_info, soc_info);
+	rc = cam_sensor_util_power_down(power_info, soc_info);
 	if (rc) {
 		CAM_ERR(CAM_OIS, "power down the core is failed:%d", rc);
 		return rc;
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor/cam_sensor_core.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor/cam_sensor_core.c
index a2431be..4aae41e 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor/cam_sensor_core.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor/cam_sensor_core.c
@@ -62,30 +62,12 @@
 	}
 }
 
-static void cam_sensor_release_resource(
+static void cam_sensor_release_per_frame_resource(
 	struct cam_sensor_ctrl_t *s_ctrl)
 {
 	struct i2c_settings_array *i2c_set = NULL;
 	int i, rc;
 
-	i2c_set = &(s_ctrl->i2c_data.init_settings);
-	if (i2c_set->is_settings_valid == 1) {
-		i2c_set->is_settings_valid = -1;
-		rc = delete_request(i2c_set);
-		if (rc < 0)
-			CAM_ERR(CAM_SENSOR,
-				"failed while deleting Init settings");
-	}
-
-	i2c_set = &(s_ctrl->i2c_data.config_settings);
-	if (i2c_set->is_settings_valid == 1) {
-		i2c_set->is_settings_valid = -1;
-		rc = delete_request(i2c_set);
-		if (rc < 0)
-			CAM_ERR(CAM_SENSOR,
-				"failed while deleting Res settings");
-	}
-
 	if (s_ctrl->i2c_data.per_frame != NULL) {
 		for (i = 0; i < MAX_PER_FRAME_ARRAY; i++) {
 			i2c_set = &(s_ctrl->i2c_data.per_frame[i]);
@@ -503,10 +485,9 @@
 		(s_ctrl->is_probe_succeed == 0))
 		return;
 
-	cam_sensor_release_resource(s_ctrl);
 	cam_sensor_release_stream_rsc(s_ctrl);
-	if (s_ctrl->sensor_state >= CAM_SENSOR_ACQUIRE)
-		cam_sensor_power_down(s_ctrl);
+	cam_sensor_release_per_frame_resource(s_ctrl);
+	cam_sensor_power_down(s_ctrl);
 
 	rc = cam_destroy_device_hdl(s_ctrl->bridge_intf.device_hdl);
 	if (rc < 0)
@@ -731,7 +712,7 @@
 			goto release_mutex;
 		}
 
-		cam_sensor_release_resource(s_ctrl);
+		cam_sensor_release_per_frame_resource(s_ctrl);
 		cam_sensor_release_stream_rsc(s_ctrl);
 		if (s_ctrl->bridge_intf.device_hdl == -1) {
 			CAM_ERR(CAM_SENSOR,
@@ -816,7 +797,7 @@
 			}
 		}
 
-		cam_sensor_release_resource(s_ctrl);
+		cam_sensor_release_per_frame_resource(s_ctrl);
 		s_ctrl->sensor_state = CAM_SENSOR_ACQUIRE;
 		CAM_INFO(CAM_SENSOR,
 			"CAM_STOP_DEV Success, sensor_id:0x%x,sensor_slave_addr:0x%x",
@@ -918,6 +899,8 @@
 		CAM_ERR(CAM_SENSOR, "Device data is NULL");
 		return -EINVAL;
 	}
+
+	mutex_lock(&s_ctrl->cam_sensor_mutex);
 	if (link->link_enable) {
 		s_ctrl->bridge_intf.link_hdl = link->link_hdl;
 		s_ctrl->bridge_intf.crm_cb = link->crm_cb;
@@ -925,6 +908,7 @@
 		s_ctrl->bridge_intf.link_hdl = -1;
 		s_ctrl->bridge_intf.crm_cb = NULL;
 	}
+	mutex_unlock(&s_ctrl->cam_sensor_mutex);
 
 	return 0;
 }
@@ -1005,7 +989,7 @@
 		CAM_ERR(CAM_SENSOR, "failed: power_info %pK", power_info);
 		return -EINVAL;
 	}
-	rc = msm_camera_power_down(power_info, soc_info);
+	rc = cam_sensor_util_power_down(power_info, soc_info);
 	if (rc < 0) {
 		CAM_ERR(CAM_SENSOR, "power down the core is failed:%d", rc);
 		return rc;
@@ -1155,8 +1139,10 @@
 	}
 	CAM_DBG(CAM_REQ, " Sensor update req id: %lld", apply->request_id);
 	trace_cam_apply_req("Sensor", apply->request_id);
+	mutex_lock(&(s_ctrl->cam_sensor_mutex));
 	rc = cam_sensor_apply_settings(s_ctrl, apply->request_id,
 		CAM_SENSOR_PACKET_OPCODE_SENSOR_UPDATE);
+	mutex_unlock(&(s_ctrl->cam_sensor_mutex));
 	return rc;
 }
 
@@ -1190,7 +1176,9 @@
 			continue;
 
 		if (i2c_set->is_settings_valid == 1) {
+			mutex_lock(&(s_ctrl->cam_sensor_mutex));
 			rc = delete_request(i2c_set);
+			mutex_unlock(&(s_ctrl->cam_sensor_mutex));
 			if (rc < 0)
 				CAM_ERR(CAM_SENSOR,
 					"delete request: %lld rc: %d",
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils/cam_sensor_util.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils/cam_sensor_util.c
index 46bda05..c49a892 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils/cam_sensor_util.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils/cam_sensor_util.c
@@ -439,6 +439,75 @@
 	return rc;
 }
 
+int cam_sensor_util_i2c_apply_setting(
+	struct camera_io_master *io_master_info,
+	struct i2c_settings_list *i2c_list)
+{
+	int32_t rc = 0;
+	uint32_t i, size;
+
+	switch (i2c_list->op_code) {
+	case CAM_SENSOR_I2C_WRITE_RANDOM: {
+		rc = camera_io_dev_write(io_master_info,
+			&(i2c_list->i2c_settings));
+		if (rc < 0) {
+			CAM_ERR(CAM_SENSOR,
+				"Failed to random write I2C settings: %d",
+				rc);
+			return rc;
+		}
+	break;
+	}
+	case CAM_SENSOR_I2C_WRITE_SEQ: {
+		rc = camera_io_dev_write_continuous(
+			io_master_info, &(i2c_list->i2c_settings), 0);
+		if (rc < 0) {
+			CAM_ERR(CAM_SENSOR,
+				"Failed to seq write I2C settings: %d",
+				rc);
+			return rc;
+		}
+	break;
+	}
+	case CAM_SENSOR_I2C_WRITE_BURST: {
+		rc = camera_io_dev_write_continuous(
+			io_master_info, &(i2c_list->i2c_settings), 1);
+		if (rc < 0) {
+			CAM_ERR(CAM_SENSOR,
+				"Failed to burst write I2C settings: %d",
+				rc);
+			return rc;
+		}
+	break;
+	}
+	case CAM_SENSOR_I2C_POLL: {
+		size = i2c_list->i2c_settings.size;
+		for (i = 0; i < size; i++) {
+			rc = camera_io_dev_poll(
+			io_master_info,
+			i2c_list->i2c_settings.reg_setting[i].reg_addr,
+			i2c_list->i2c_settings.reg_setting[i].reg_data,
+			i2c_list->i2c_settings.reg_setting[i].data_mask,
+			i2c_list->i2c_settings.addr_type,
+			i2c_list->i2c_settings.data_type,
+			i2c_list->i2c_settings.reg_setting[i].delay);
+			if (rc < 0) {
+				CAM_ERR(CAM_SENSOR,
+					"i2c poll apply setting Fail: %d", rc);
+				return rc;
+			}
+		}
+	break;
+	}
+	default:
+		CAM_ERR(CAM_SENSOR, "Wrong Opcode: %d", i2c_list->op_code);
+		rc = -EINVAL;
+	break;
+	}
+
+	return rc;
+}
+
 int32_t msm_camera_fill_vreg_params(
 	struct cam_hw_soc_info *soc_info,
 	struct cam_sensor_power_setting *power_setting,
@@ -1710,7 +1779,7 @@
 	return ps;
 }
 
-int msm_camera_power_down(struct cam_sensor_power_ctrl_t *ctrl,
+int cam_sensor_util_power_down(struct cam_sensor_power_ctrl_t *ctrl,
 		struct cam_hw_soc_info *soc_info)
 {
 	int index = 0, ret = 0, num_vreg = 0, i;
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils/cam_sensor_util.h b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils/cam_sensor_util.h
index 6c0287e..583ddb1 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils/cam_sensor_util.h
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils/cam_sensor_util.h
@@ -39,6 +39,9 @@
 	struct i2c_settings_array *i2c_reg_settings,
 	struct cam_cmd_buf_desc *cmd_desc, int32_t num_cmd_buffers);
 
+int cam_sensor_util_i2c_apply_setting(struct camera_io_master *io_master_info,
+	struct i2c_settings_list *i2c_list);
+
 int32_t delete_request(struct i2c_settings_array *i2c_array);
 int cam_sensor_util_request_gpio_table(
 	struct cam_hw_soc_info *soc_info, int gpio_en);
@@ -49,7 +52,7 @@
 int cam_sensor_core_power_up(struct cam_sensor_power_ctrl_t *ctrl,
 		struct cam_hw_soc_info *soc_info);
 
-int msm_camera_power_down(struct cam_sensor_power_ctrl_t *ctrl,
+int cam_sensor_util_power_down(struct cam_sensor_power_ctrl_t *ctrl,
 		struct cam_hw_soc_info *soc_info);
 
 int msm_camera_fill_vreg_params(struct cam_hw_soc_info *soc_info,
diff --git a/drivers/media/platform/msm/camera/cam_smmu/Makefile b/drivers/media/platform/msm/camera/cam_smmu/Makefile
index e17dac6..96f3968 100644
--- a/drivers/media/platform/msm/camera/cam_smmu/Makefile
+++ b/drivers/media/platform/msm/camera/cam_smmu/Makefile
@@ -1,3 +1,4 @@
 ccflags-y += -Idrivers/media/platform/msm/camera/cam_utils
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_req_mgr
 
 obj-$(CONFIG_SPECTRA_CAMERA) += cam_smmu_api.o
diff --git a/drivers/media/platform/msm/camera/cam_smmu/cam_smmu_api.c b/drivers/media/platform/msm/camera/cam_smmu/cam_smmu_api.c
index 52da37f..fd1b843 100644
--- a/drivers/media/platform/msm/camera/cam_smmu/cam_smmu_api.c
+++ b/drivers/media/platform/msm/camera/cam_smmu/cam_smmu_api.c
@@ -23,6 +23,7 @@
 #include <linux/genalloc.h>
 #include <soc/qcom/scm.h>
 #include <soc/qcom/secure_buffer.h>
+#include <uapi/media/cam_req_mgr.h>
 #include "cam_smmu_api.h"
 #include "cam_debug_util.h"
 
@@ -34,11 +35,14 @@
 #define COOKIE_SIZE (BYTE_SIZE*COOKIE_NUM_BYTE)
 #define COOKIE_MASK ((1<<COOKIE_SIZE)-1)
 #define HANDLE_INIT (-1)
-#define CAM_SMMU_CB_MAX 2
+#define CAM_SMMU_CB_MAX 5
 
 #define GET_SMMU_HDL(x, y) (((x) << COOKIE_SIZE) | ((y) & COOKIE_MASK))
 #define GET_SMMU_TABLE_IDX(x) (((x) >> COOKIE_SIZE) & COOKIE_MASK)
 
+static int g_num_pf_handled = 4;
+module_param(g_num_pf_handled, int, 0644);
+
 struct firmware_alloc_info {
 	struct device *fw_dev;
 	void *fw_kva;
@@ -129,12 +133,11 @@
 	int handle;
 	enum cam_smmu_ops_param state;
 
-	void (*handler[CAM_SMMU_CB_MAX])(struct iommu_domain *,
-		struct device *, unsigned long,
-		int, void*);
+	cam_smmu_client_page_fault_handler handler[CAM_SMMU_CB_MAX];
 	void *token[CAM_SMMU_CB_MAX];
 	int cb_count;
 	int secure_count;
+	int pf_count;
 };
 
 struct cam_iommu_cb_set {
@@ -252,13 +255,14 @@
 
 static int cam_smmu_probe(struct platform_device *pdev);
 
-static void cam_smmu_check_vaddr_in_range(int idx, void *vaddr);
+static uint32_t cam_smmu_find_closest_mapping(int idx, void *vaddr);
 
 static void cam_smmu_page_fault_work(struct work_struct *work)
 {
 	int j;
 	int idx;
 	struct cam_smmu_work_payload *payload;
+	uint32_t buf_info;
 
 	mutex_lock(&iommu_cb_set.payload_list_lock);
 	if (list_empty(&iommu_cb_set.payload_list)) {
@@ -275,8 +279,11 @@
 
 	/* Dereference the payload to call the handler */
 	idx = payload->idx;
-	mutex_lock(&iommu_cb_set.cb_info[idx].lock);
-	cam_smmu_check_vaddr_in_range(idx, (void *)payload->iova);
+	buf_info = cam_smmu_find_closest_mapping(idx, (void *)payload->iova);
+	if (buf_info != 0) {
+		CAM_INFO(CAM_SMMU, "closest buf 0x%x idx %d", buf_info, idx);
+	}
+
 	for (j = 0; j < CAM_SMMU_CB_MAX; j++) {
 		if ((iommu_cb_set.cb_info[idx].handler[j])) {
 			iommu_cb_set.cb_info[idx].handler[j](
@@ -284,10 +291,10 @@
 				payload->dev,
 				payload->iova,
 				payload->flags,
-				iommu_cb_set.cb_info[idx].token[j]);
+				iommu_cb_set.cb_info[idx].token[j],
+				buf_info);
 		}
 	}
-	mutex_unlock(&iommu_cb_set.cb_info[idx].lock);
 	kfree(payload);
 }
 
@@ -333,10 +340,13 @@
 	}
 }
 
-static void cam_smmu_check_vaddr_in_range(int idx, void *vaddr)
+static uint32_t cam_smmu_find_closest_mapping(int idx, void *vaddr)
 {
-	struct cam_dma_buff_info *mapping;
+	struct cam_dma_buff_info *mapping, *closest_mapping =  NULL;
 	unsigned long start_addr, end_addr, current_addr;
+	uint32_t buf_handle = 0;
+
+	long delta = 0, lowest_delta = 0;
 
 	current_addr = (unsigned long)vaddr;
 	list_for_each_entry(mapping,
@@ -344,31 +354,51 @@
 		start_addr = (unsigned long)mapping->paddr;
 		end_addr = (unsigned long)mapping->paddr + mapping->len;
 
-		if (start_addr <= current_addr && current_addr < end_addr) {
-			CAM_ERR(CAM_SMMU,
-				"va %pK valid: range:%pK-%pK, fd = %d cb: %s",
-				vaddr, (void *)start_addr, (void *)end_addr,
-				mapping->ion_fd,
+		if (start_addr <= current_addr && current_addr <= end_addr) {
+			closest_mapping = mapping;
+			CAM_INFO(CAM_SMMU,
+				"Found va 0x%lx in:0x%lx-0x%lx, fd %d cb:%s",
+				current_addr, start_addr,
+				end_addr, mapping->ion_fd,
 				iommu_cb_set.cb_info[idx].name);
 			goto end;
 		} else {
+			if (start_addr > current_addr)
+				delta =  start_addr - current_addr;
+			else
+				delta = current_addr - end_addr - 1;
+
+			if (delta < lowest_delta || lowest_delta == 0) {
+				lowest_delta = delta;
+				closest_mapping = mapping;
+			}
 			CAM_DBG(CAM_SMMU,
-				"va %pK is not in this range: %pK-%pK, fd = %d",
-				vaddr, (void *)start_addr, (void *)end_addr,
-				mapping->ion_fd);
+				"approx va %lx not in range: %lx-%lx fd = %0x",
+				current_addr, start_addr,
+				end_addr, mapping->ion_fd);
 		}
 	}
-	CAM_ERR(CAM_SMMU,
-		"Cannot find vaddr:%pK in SMMU %s uses invalid virt address",
-		vaddr, iommu_cb_set.cb_info[idx].name);
+
 end:
-	return;
+	if (closest_mapping) {
+		buf_handle = GET_MEM_HANDLE(idx, closest_mapping->ion_fd);
+		CAM_INFO(CAM_SMMU,
+			"Closest map fd %d 0x%lx 0x%lx-0x%lx buf=%pK mem %0x",
+			closest_mapping->ion_fd, current_addr,
+			(unsigned long)closest_mapping->paddr,
+			(unsigned long)closest_mapping->paddr + mapping->len,
+			closest_mapping->buf,
+			buf_handle);
+	} else
+		CAM_INFO(CAM_SMMU,
+			"Cannot find vaddr:%lx in SMMU %s virt address",
+			current_addr, iommu_cb_set.cb_info[idx].name);
+
+	return buf_handle;
 }
 
-void cam_smmu_reg_client_page_fault_handler(int handle,
-	void (*client_page_fault_handler)(struct iommu_domain *,
-	struct device *, unsigned long,
-	int, void*), void *token)
+void cam_smmu_set_client_page_fault_handler(int handle,
+	cam_smmu_client_page_fault_handler handler_cb, void *token)
 {
 	int idx, i = 0;
 
@@ -394,7 +424,7 @@
 		return;
 	}
 
-	if (client_page_fault_handler) {
+	if (handler_cb) {
 		if (iommu_cb_set.cb_info[idx].cb_count == CAM_SMMU_CB_MAX) {
 			CAM_ERR(CAM_SMMU,
 				"%s Should not regiester more handlers",
@@ -402,12 +432,14 @@
 			mutex_unlock(&iommu_cb_set.cb_info[idx].lock);
 			return;
 		}
+
 		iommu_cb_set.cb_info[idx].cb_count++;
+
 		for (i = 0; i < iommu_cb_set.cb_info[idx].cb_count; i++) {
 			if (iommu_cb_set.cb_info[idx].token[i] == NULL) {
 				iommu_cb_set.cb_info[idx].token[i] = token;
 				iommu_cb_set.cb_info[idx].handler[i] =
-					client_page_fault_handler;
+					handler_cb;
 				break;
 			}
 		}
@@ -429,6 +461,47 @@
 	mutex_unlock(&iommu_cb_set.cb_info[idx].lock);
 }
 
+void cam_smmu_unset_client_page_fault_handler(int handle, void *token)
+{
+	int idx, i = 0;
+
+	if (!token || (handle == HANDLE_INIT)) {
+		CAM_ERR(CAM_SMMU, "Error: token is NULL or invalid handle");
+		return;
+	}
+
+	idx = GET_SMMU_TABLE_IDX(handle);
+	if (idx < 0 || idx >= iommu_cb_set.cb_num) {
+		CAM_ERR(CAM_SMMU,
+			"Error: handle or index invalid. idx = %d hdl = %x",
+			idx, handle);
+		return;
+	}
+
+	mutex_lock(&iommu_cb_set.cb_info[idx].lock);
+	if (iommu_cb_set.cb_info[idx].handle != handle) {
+		CAM_ERR(CAM_SMMU,
+			"Error: hdl is not valid, table_hdl = %x, hdl = %x",
+			iommu_cb_set.cb_info[idx].handle, handle);
+		mutex_unlock(&iommu_cb_set.cb_info[idx].lock);
+		return;
+	}
+
+	for (i = 0; i < CAM_SMMU_CB_MAX; i++) {
+		if (iommu_cb_set.cb_info[idx].token[i] == token) {
+			iommu_cb_set.cb_info[idx].token[i] = NULL;
+			iommu_cb_set.cb_info[idx].handler[i] =
+				NULL;
+			iommu_cb_set.cb_info[idx].cb_count--;
+			break;
+		}
+	}
+	if (i == CAM_SMMU_CB_MAX)
+		CAM_ERR(CAM_SMMU, "Error: hdl %x no matching tokens: %s",
+			handle, iommu_cb_set.cb_info[idx].name);
+	mutex_unlock(&iommu_cb_set.cb_info[idx].lock);
+}
+
 static int cam_smmu_iommu_fault_handler(struct iommu_domain *domain,
 	struct device *dev, unsigned long iova,
 	int flags, void *token)
@@ -459,6 +532,13 @@
 		return -EINVAL;
 	}
 
+	if (++iommu_cb_set.cb_info[idx].pf_count > g_num_pf_handled) {
+		CAM_INFO(CAM_SMMU, "PF already handled %d %d %d",
+			g_num_pf_handled, idx,
+			iommu_cb_set.cb_info[idx].pf_count);
+		return -EINVAL;
+	}
+
 	payload = kzalloc(sizeof(struct cam_smmu_work_payload), GFP_ATOMIC);
 	if (!payload)
 		return -EINVAL;
@@ -474,7 +554,7 @@
 	list_add_tail(&payload->list, &iommu_cb_set.payload_list);
 	mutex_unlock(&iommu_cb_set.payload_list_lock);
 
-	schedule_work(&iommu_cb_set.smmu_work);
+	cam_smmu_page_fault_work(&iommu_cb_set.smmu_work);
 
 	return -EINVAL;
 }
@@ -528,6 +608,7 @@
 		iommu_cb_set.cb_info[i].state = CAM_SMMU_DETACH;
 		iommu_cb_set.cb_info[i].dev = NULL;
 		iommu_cb_set.cb_info[i].cb_count = 0;
+		iommu_cb_set.cb_info[i].pf_count = 0;
 		for (j = 0; j < CAM_SMMU_CB_MAX; j++) {
 			iommu_cb_set.cb_info[i].token[j] = NULL;
 			iommu_cb_set.cb_info[i].handler[j] = NULL;
diff --git a/drivers/media/platform/msm/camera/cam_smmu/cam_smmu_api.h b/drivers/media/platform/msm/camera/cam_smmu/cam_smmu_api.h
index 254e382..6c72902 100644
--- a/drivers/media/platform/msm/camera/cam_smmu/cam_smmu_api.h
+++ b/drivers/media/platform/msm/camera/cam_smmu/cam_smmu_api.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -51,6 +51,21 @@
 };
 
 /**
+ * @brief        : Callback function type that gets called back on cam
+ *                     smmu page fault.
+ *
+ * @param domain   : Iommu domain received in iommu page fault handler
+ * @param dev      : Device received in iommu page fault handler
+ * @param iova     : IOVA where page fault occurred
+ * @param flags    : Flags received in iommu page fault handler
+ * @param token    : Userdata given during callback registration
+ * @param buf_info : Closest mapped buffer info
+ */
+typedef void (*cam_smmu_client_page_fault_handler)(struct iommu_domain *domain,
+	struct device *dev, unsigned long iova, int flags, void *token,
+	uint32_t buf_info);
+
+/**
  * @brief            : Structure to store region information
  *
  * @param iova_start : Start address of region
@@ -215,13 +230,19 @@
  * @brief       : Registers smmu fault handler for client
  *
  * @param handle: Handle to identify the CAM SMMU client (VFE, CPP, FD etc.)
- * @param client_page_fault_handler: It is triggered in IOMMU page fault
+ * @param handler_cb: It is triggered in IOMMU page fault
  * @param token: It is input param when trigger page fault handler
  */
-void cam_smmu_reg_client_page_fault_handler(int handle,
-	void (*client_page_fault_handler)(struct iommu_domain *,
-	struct device *, unsigned long,
-	int, void*), void *token);
+void cam_smmu_set_client_page_fault_handler(int handle,
+	cam_smmu_client_page_fault_handler handler_cb, void *token);
+
+/**
+ * @brief       : Unregisters smmu fault handler for client
+ *
+ * @param handle: Handle to identify the CAM SMMU client (VFE, CPP, FD etc.)
+ * @param token: It is input param when trigger page fault handler
+ */
+void cam_smmu_unset_client_page_fault_handler(int handle, void *token);
 
 /**
  * @brief Maps memory from an ION fd into IOVA space
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_buf_mgr.c b/drivers/media/platform/msm/camera_v2/isp/msm_buf_mgr.c
index 6196a8c..7a0a069 100644
--- a/drivers/media/platform/msm/camera_v2/isp/msm_buf_mgr.c
+++ b/drivers/media/platform/msm/camera_v2/isp/msm_buf_mgr.c
@@ -676,6 +676,10 @@
 		rc = 0;
 		break;
 	case MSM_ISP_BUFFER_STATE_QUEUED:
+		if (IS_ENABLED(CONFIG_MSM_ISP_V1)) {
+			rc = 0;
+			break;
+		}
 	case MSM_ISP_BUFFER_STATE_DIVERTED:
 	default:
 		WARN(1, "%s: bufq 0x%x, buf idx 0x%x, incorrect state = %d",
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_isp.c b/drivers/media/platform/msm/camera_v2/isp/msm_isp.c
index 7c55ad8..a62c465 100644
--- a/drivers/media/platform/msm/camera_v2/isp/msm_isp.c
+++ b/drivers/media/platform/msm/camera_v2/isp/msm_isp.c
@@ -450,7 +450,7 @@
 {
 	struct page *page;
 	struct vfe_device *vfe_dev = vma->vm_private_data;
-	struct isp_proc *isp_page = NULL;
+	struct isp_kstate *isp_page = NULL;
 
 	isp_page = vfe_dev->isp_page;
 
@@ -728,7 +728,7 @@
 	vfe_dev->buf_mgr->init_done = 1;
 	vfe_dev->vfe_open_cnt = 0;
 	/*Allocate a page in kernel and map it to camera user process*/
-	vfe_dev->isp_page = (struct isp_proc *)get_zeroed_page(GFP_KERNEL);
+	vfe_dev->isp_page = (struct isp_kstate *)get_zeroed_page(GFP_KERNEL);
 	if (vfe_dev->isp_page == NULL) {
 		pr_err("%s: no enough memory\n", __func__);
 		rc = -ENOMEM;
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_isp.h b/drivers/media/platform/msm/camera_v2/isp/msm_isp.h
index 4f97618..fa55d64 100644
--- a/drivers/media/platform/msm/camera_v2/isp/msm_isp.h
+++ b/drivers/media/platform/msm/camera_v2/isp/msm_isp.h
@@ -761,11 +761,6 @@
 	struct msm_vfe_common_dev_data *common_data;
 };
 
-struct isp_proc {
-	uint32_t  kernel_sofid;
-	uint32_t  vfeid;
-};
-
 struct vfe_device {
 	/* Driver private data */
 	struct platform_device *pdev;
@@ -850,7 +845,7 @@
 	uint32_t recovery_irq1_mask;
 	/* total bandwidth per vfe */
 	uint64_t total_bandwidth;
-	struct isp_proc *isp_page;
+	struct isp_kstate *isp_page;
 };
 
 struct vfe_parent_device {
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_isp40.c b/drivers/media/platform/msm/camera_v2/isp/msm_isp40.c
index c5c05d2..a2d4c4a 100644
--- a/drivers/media/platform/msm/camera_v2/isp/msm_isp40.c
+++ b/drivers/media/platform/msm/camera_v2/isp/msm_isp40.c
@@ -749,13 +749,13 @@
 		return;
 
 	if (irq_status0 & BIT(2)) {
-		msm_isp_notify(vfe_dev, ISP_EVENT_SOF, VFE_PIX_0, ts);
 		ISP_DBG("%s: EPOCH0 IRQ\n", __func__);
 		msm_isp_process_reg_upd_epoch_irq(vfe_dev, VFE_PIX_0,
 					MSM_ISP_COMP_IRQ_EPOCH, ts);
 		msm_isp_process_stats_reg_upd_epoch_irq(vfe_dev,
 					MSM_ISP_COMP_IRQ_EPOCH);
 		msm_isp_update_error_frame_count(vfe_dev);
+		msm_isp_notify(vfe_dev, ISP_EVENT_SOF, VFE_PIX_0, ts);
 		if (vfe_dev->axi_data.src_info[VFE_PIX_0].raw_stream_count > 0
 			&& vfe_dev->axi_data.src_info[VFE_PIX_0].
 			stream_count == 0) {
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util.c b/drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util.c
index 1b04e1d..1ddbb94 100644
--- a/drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util.c
+++ b/drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util.c
@@ -175,6 +175,8 @@
 			stream_info->bufq_handle[k] = 0;
 		stream_info->vfe_mask = 0;
 		stream_info->state = AVAILABLE;
+		memset(&stream_info->request_queue_cmd,
+			0, sizeof(stream_info->request_queue_cmd));
 	}
 }
 
@@ -598,7 +600,8 @@
  *
  * Returns void
  */
-static void msm_isp_update_framedrop_reg(struct msm_vfe_axi_stream *stream_info)
+static void msm_isp_update_framedrop_reg(struct msm_vfe_axi_stream *stream_info,
+		uint32_t drop_reconfig)
 {
 	if (stream_info->stream_type == BURST_STREAM) {
 		if (stream_info->runtime_num_burst_capture == 0 ||
@@ -608,7 +611,8 @@
 				MSM_VFE_STREAM_STOP_PERIOD;
 	}
 
-	if (stream_info->undelivered_request_cnt > 0)
+	if (stream_info->undelivered_request_cnt > 0 &&
+		drop_reconfig != 1)
 		stream_info->current_framedrop_period =
 			MSM_VFE_STREAM_STOP_PERIOD;
 
@@ -663,7 +667,8 @@
 			break;
 		case MSM_ISP_COMP_IRQ_EPOCH:
 			if (stream_info->state == ACTIVE)
-				msm_isp_update_framedrop_reg(stream_info);
+				msm_isp_update_framedrop_reg(stream_info,
+					vfe_dev->isp_page->drop_reconfig);
 			break;
 		default:
 			WARN(1, "Invalid irq %d\n", irq);
@@ -3543,6 +3548,14 @@
 	frame_src = SRC_TO_INTF(stream_info->stream_src);
 	pingpong_status = vfe_dev->hw_info->
 		vfe_ops.axi_ops.get_pingpong_status(vfe_dev);
+
+	/* As MCT is still processing it, need to drop the additional requests*/
+	if (vfe_dev->isp_page->drop_reconfig) {
+		pr_err("%s: MCT has not yet delayed %d drop request %d\n",
+			__func__, vfe_dev->isp_page->drop_reconfig, frame_id);
+		goto error;
+	}
+
 	/*
 	 * If PIX stream is active then RDI path uses SOF frame ID of PIX
 	 * In case of standalone RDI streaming, SOF are used from
@@ -3556,9 +3569,18 @@
 		vfe_dev->axi_data.src_info[frame_src].accept_frame == false) {
 		pr_debug("%s:%d invalid time to request frame %d\n",
 			__func__, __LINE__, frame_id);
-		goto error;
-	}
-	if ((vfe_dev->axi_data.src_info[frame_src].active && (frame_id !=
+		vfe_dev->isp_page->drop_reconfig = 1;
+	} else if ((vfe_dev->axi_data.src_info[frame_src].active) &&
+			(frame_id ==
+			vfe_dev->axi_data.src_info[frame_src].frame_id) &&
+			(stream_info->undelivered_request_cnt <=
+				MAX_BUFFERS_IN_HW)) {
+		vfe_dev->isp_page->drop_reconfig = 1;
+		pr_debug("%s: vfe_%d request_frame %d cur frame id %d pix %d\n",
+			__func__, vfe_dev->pdev->id, frame_id,
+			vfe_dev->axi_data.src_info[VFE_PIX_0].frame_id,
+			vfe_dev->axi_data.src_info[VFE_PIX_0].active);
+	} else if ((vfe_dev->axi_data.src_info[frame_src].active && (frame_id !=
 		vfe_dev->axi_data.src_info[frame_src].frame_id + vfe_dev->
 		axi_data.src_info[frame_src].sof_counter_step)) ||
 		((!vfe_dev->axi_data.src_info[frame_src].active))) {
@@ -3662,6 +3684,9 @@
 			stream_info->undelivered_request_cnt--;
 			pr_err_ratelimited("%s:%d fail to cfg HAL buffer\n",
 				__func__, __LINE__);
+			queue_req->cmd_used = 0;
+			list_del(&queue_req->list);
+			stream_info->request_q_cnt--;
 			return rc;
 		}
 
@@ -3698,6 +3723,9 @@
 						flags);
 			pr_err_ratelimited("%s:%d fail to cfg HAL buffer\n",
 				__func__, __LINE__);
+			queue_req->cmd_used = 0;
+			list_del(&queue_req->list);
+			stream_info->request_q_cnt--;
 			return rc;
 		}
 	} else {
diff --git a/drivers/media/platform/msm/camera_v2/sensor/csid/msm_csid.c b/drivers/media/platform/msm/camera_v2/sensor/csid/msm_csid.c
index 53dd371..ee659f6 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/csid/msm_csid.c
+++ b/drivers/media/platform/msm/camera_v2/sensor/csid/msm_csid.c
@@ -836,7 +836,7 @@
 		break;
 	case VIDIOC_MSM_CSID_RELEASE:
 	case MSM_SD_SHUTDOWN:
-		if (adsp_shmem_get_state() == CAMERA_STATUS_END) {
+		if (adsp_shmem_get_state() != CAMERA_STATUS_END) {
 			/* aDSP still in use */
 			rc = 0;
 			break;
diff --git a/drivers/media/platform/msm/vidc/msm_vidc_clocks.c b/drivers/media/platform/msm/vidc/msm_vidc_clocks.c
index c15a2e9..802e581 100644
--- a/drivers/media/platform/msm/vidc/msm_vidc_clocks.c
+++ b/drivers/media/platform/msm/vidc/msm_vidc_clocks.c
@@ -932,6 +932,12 @@
 			break;
 		}
 	}
+
+	if (!inst->clk_data.entry) {
+		dprintk(VIDC_ERR, "%s No match found\n", __func__);
+		rc = -EINVAL;
+	}
+
 	return rc;
 }
 
diff --git a/drivers/media/platform/msm/vidc/msm_vidc_common.c b/drivers/media/platform/msm/vidc/msm_vidc_common.c
index b878971..176b9c6 100644
--- a/drivers/media/platform/msm/vidc/msm_vidc_common.c
+++ b/drivers/media/platform/msm/vidc/msm_vidc_common.c
@@ -3138,7 +3138,11 @@
 		return -EINVAL;
 	}
 
-	msm_comm_init_clocks_and_bus_data(inst);
+	rc = msm_comm_init_clocks_and_bus_data(inst);
+	if (rc) {
+		dprintk(VIDC_ERR, "Failed to initialize clocks and bus data\n");
+		goto exit;
+	}
 
 	dprintk(VIDC_DBG, "%s: inst %pK\n", __func__, inst);
 	rc = call_hfi_op(hdev, session_init, hdev->hfi_device_data,
diff --git a/drivers/misc/qseecom.c b/drivers/misc/qseecom.c
index ef177c3..63184bf 100644
--- a/drivers/misc/qseecom.c
+++ b/drivers/misc/qseecom.c
@@ -182,6 +182,7 @@
 	size_t sb_length;
 	struct ion_handle *ihandle; /* Retrieve phy addr */
 	wait_queue_head_t          rcv_req_wq;
+	/* rcv_req_flag: -1: not ready; 0: ready and empty; 1: received req */
 	int                        rcv_req_flag;
 	int                        send_resp_flag;
 	bool                       listener_in_use;
@@ -1203,7 +1204,7 @@
 	if (!new_entry)
 		return -ENOMEM;
 	memcpy(&new_entry->svc, &rcvd_lstnr, sizeof(rcvd_lstnr));
-	new_entry->rcv_req_flag = 0;
+	new_entry->rcv_req_flag = -1;
 
 	new_entry->svc.listener_id = rcvd_lstnr.listener_id;
 	new_entry->sb_length = rcvd_lstnr.sb_size;
@@ -1639,21 +1640,20 @@
 	}
 }
 
-/* wake up listener receive request wq retry delay (ms) and max attemp count */
-#define QSEECOM_WAKE_LISTENER_RCVWQ_DELAY          10
-#define QSEECOM_WAKE_LISTENER_RCVWQ_MAX_ATTEMP     3
+/* wait listener retry delay (ms) and max attemp count */
+#define QSEECOM_WAIT_LISTENER_DELAY          10
+#define QSEECOM_WAIT_LISTENER_MAX_ATTEMP     3
 
-static int __qseecom_retry_wake_up_listener_rcv_wq(
+static int __is_listener_rcv_wq_not_ready(
 			struct qseecom_registered_listener_list *ptr_svc)
 {
 	int retry = 0;
 
-	while (ptr_svc->rcv_req_flag == 1 &&
-		retry++ < QSEECOM_WAKE_LISTENER_RCVWQ_MAX_ATTEMP) {
-		wake_up_interruptible(&ptr_svc->rcv_req_wq);
-		msleep(QSEECOM_WAKE_LISTENER_RCVWQ_DELAY);
+	while (ptr_svc->rcv_req_flag == -1 &&
+		retry++ < QSEECOM_WAIT_LISTENER_MAX_ATTEMP) {
+		msleep(QSEECOM_WAIT_LISTENER_DELAY);
 	}
-	return ptr_svc->rcv_req_flag == 1;
+	return ptr_svc->rcv_req_flag == -1;
 }
 
 static int __qseecom_process_incomplete_cmd(struct qseecom_dev_handle *data,
@@ -1684,6 +1684,8 @@
 		list_for_each_entry(ptr_svc,
 				&qseecom.registered_listener_list_head, list) {
 			if (ptr_svc->svc.listener_id == lstnr) {
+				if (__is_listener_rcv_wq_not_ready(ptr_svc))
+					break;
 				ptr_svc->listener_in_use = true;
 				ptr_svc->rcv_req_flag = 1;
 				wake_up_interruptible(&ptr_svc->rcv_req_wq);
@@ -1724,14 +1726,15 @@
 			goto err_resp;
 		}
 
-		if (ptr_svc->rcv_req_flag == 1 &&
-			__qseecom_retry_wake_up_listener_rcv_wq(ptr_svc)) {
+		if (ptr_svc->rcv_req_flag == -1) {
 			pr_err("Service %d is not ready to receive request\n",
 					lstnr);
 			rc = -ENOENT;
 			status = QSEOS_RESULT_FAILURE;
 			goto err_resp;
+
 		}
+
 		pr_debug("waking up rcv_req_wq and waiting for send_resp_wq\n");
 
 		/* initialize the new signal mask with all signals*/
@@ -2004,6 +2007,8 @@
 		list_for_each_entry(ptr_svc,
 				&qseecom.registered_listener_list_head, list) {
 			if (ptr_svc->svc.listener_id == lstnr) {
+				if (__is_listener_rcv_wq_not_ready(ptr_svc))
+					break;
 				ptr_svc->listener_in_use = true;
 				ptr_svc->rcv_req_flag = 1;
 				wake_up_interruptible(&ptr_svc->rcv_req_wq);
@@ -2044,14 +2049,15 @@
 			goto err_resp;
 		}
 
-		if (ptr_svc->rcv_req_flag == 1 &&
-			__qseecom_retry_wake_up_listener_rcv_wq(ptr_svc)) {
+		if (ptr_svc->rcv_req_flag == -1) {
 			pr_err("Service %d is not ready to receive request\n",
 					lstnr);
 			rc = -ENOENT;
 			status = QSEOS_RESULT_FAILURE;
 			goto err_resp;
+
 		}
+
 		pr_debug("waking up rcv_req_wq and waiting for send_resp_wq\n");
 
 		/* initialize the new signal mask with all signals*/
@@ -3859,7 +3865,7 @@
 {
 	int ret;
 
-	ret = (svc->rcv_req_flag != 0);
+	ret = (svc->rcv_req_flag == 1);
 	return ret || data->abort || svc->abort;
 }
 
@@ -3873,6 +3879,7 @@
 		pr_err("Invalid listener ID\n");
 		return -ENODATA;
 	}
+	this_lstnr->rcv_req_flag = 0;
 
 	while (1) {
 		if (wait_event_freezable(this_lstnr->rcv_req_wq,
diff --git a/drivers/mmc/host/cmdq_hci.c b/drivers/mmc/host/cmdq_hci.c
index 01811d9..815da18 100644
--- a/drivers/mmc/host/cmdq_hci.c
+++ b/drivers/mmc/host/cmdq_hci.c
@@ -1108,7 +1108,7 @@
 		/* read CQTCN and complete the request */
 		comp_status = cmdq_readl(cq_host, CQTCN);
 		if (!comp_status)
-			goto out;
+			goto hac;
 		/*
 		 * The CQTCN must be cleared before notifying req completion
 		 * to upper layers to avoid missing completion notification
@@ -1135,7 +1135,7 @@
 			}
 		}
 	}
-
+hac:
 	if (status & CQIS_HAC) {
 		if (cq_host->ops->post_cqe_halt)
 			cq_host->ops->post_cqe_halt(mmc);
@@ -1146,7 +1146,6 @@
 		complete(&cq_host->halt_comp);
 	}
 
-out:
 	return IRQ_HANDLED;
 }
 EXPORT_SYMBOL(cmdq_irq);
diff --git a/drivers/net/ppp/pppolac.c b/drivers/net/ppp/pppolac.c
index 3a45cf8..8ed8091 100644
--- a/drivers/net/ppp/pppolac.c
+++ b/drivers/net/ppp/pppolac.c
@@ -83,7 +83,7 @@
 
 	/* Put it back if it is a control packet. */
 	if (skb->data[sizeof(struct udphdr)] & L2TP_CONTROL_BIT)
-		return opt->backlog_rcv(sk_udp, skb);
+		return 2;
 
 	/* Skip UDP header. */
 	skb_pull(skb, sizeof(struct udphdr));
@@ -190,9 +190,10 @@
 
 static int pppolac_recv(struct sock *sk_udp, struct sk_buff *skb)
 {
+	int retval;
 	sock_hold(sk_udp);
-	sk_receive_skb(sk_udp, skb, 0);
-	return 0;
+	retval =  sk_receive_skb(sk_udp, skb, 0);
+	return (retval >> 1);
 }
 
 static struct sk_buff_head delivery_queue;
diff --git a/drivers/net/wireless/cnss2/debug.c b/drivers/net/wireless/cnss2/debug.c
index 53a4620..30e37a0 100644
--- a/drivers/net/wireless/cnss2/debug.c
+++ b/drivers/net/wireless/cnss2/debug.c
@@ -428,6 +428,82 @@
 	.llseek		= seq_lseek,
 };
 
+static ssize_t cnss_runtime_pm_debug_write(struct file *fp,
+					   const char __user *user_buf,
+					   size_t count, loff_t *off)
+{
+	struct cnss_plat_data *plat_priv =
+		((struct seq_file *)fp->private_data)->private;
+	struct cnss_pci_data *pci_priv;
+	char buf[64];
+	char *cmd;
+	unsigned int len = 0;
+	int ret = 0;
+
+	if (!plat_priv)
+		return -ENODEV;
+
+	pci_priv = plat_priv->bus_priv;
+	if (!pci_priv)
+		return -ENODEV;
+
+	len = min(count, sizeof(buf) - 1);
+	if (copy_from_user(buf, user_buf, len))
+		return -EFAULT;
+
+	buf[len] = '\0';
+	cmd = buf;
+
+	if (sysfs_streq(cmd, "usage_count")) {
+		cnss_pci_pm_runtime_show_usage_count(pci_priv);
+	} else if (sysfs_streq(cmd, "get")) {
+		ret = cnss_pci_pm_runtime_get(pci_priv);
+	} else if (sysfs_streq(cmd, "get_noresume")) {
+		cnss_pci_pm_runtime_get_noresume(pci_priv);
+	} else if (sysfs_streq(cmd, "put_autosuspend")) {
+		ret = cnss_pci_pm_runtime_put_autosuspend(pci_priv);
+	} else if (sysfs_streq(cmd, "put_noidle")) {
+		cnss_pci_pm_runtime_put_noidle(pci_priv);
+	} else if (sysfs_streq(cmd, "mark_last_busy")) {
+		cnss_pci_pm_runtime_mark_last_busy(pci_priv);
+	} else {
+		cnss_pr_err("Runtime PM debugfs command is invalid\n");
+		ret = -EINVAL;
+	}
+
+	if (ret)
+		return ret;
+
+	return count;
+}
+
+static int cnss_runtime_pm_debug_show(struct seq_file *s, void *data)
+{
+	seq_puts(s, "\nUsage: echo <action> > <debugfs_path>/cnss/runtime_pm\n");
+	seq_puts(s, "<action> can be one of below:\n");
+	seq_puts(s, "usage_count: get runtime PM usage count\n");
+	seq_puts(s, "get: do runtime PM get\n");
+	seq_puts(s, "get_noresume: do runtime PM get noresume\n");
+	seq_puts(s, "put_noidle: do runtime PM put noidle\n");
+	seq_puts(s, "put_autosuspend: do runtime PM put autosuspend\n");
+	seq_puts(s, "mark_last_busy: do runtime PM mark last busy\n");
+
+	return 0;
+}
+
+static int cnss_runtime_pm_debug_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, cnss_runtime_pm_debug_show, inode->i_private);
+}
+
+static const struct file_operations cnss_runtime_pm_debug_fops = {
+	.read		= seq_read,
+	.write		= cnss_runtime_pm_debug_write,
+	.open		= cnss_runtime_pm_debug_open,
+	.owner		= THIS_MODULE,
+	.llseek		= seq_lseek,
+};
+
 #ifdef CONFIG_CNSS2_DEBUG
 static int cnss_create_debug_only_node(struct cnss_plat_data *plat_priv)
 {
@@ -439,6 +515,8 @@
 			    &cnss_reg_read_debug_fops);
 	debugfs_create_file("reg_write", 0600, root_dentry, plat_priv,
 			    &cnss_reg_write_debug_fops);
+	debugfs_create_file("runtime_pm", 0600, root_dentry, plat_priv,
+			    &cnss_runtime_pm_debug_fops);
 
 	return 0;
 }
diff --git a/drivers/net/wireless/cnss2/main.c b/drivers/net/wireless/cnss2/main.c
index 4433ae0..e25d2cc 100644
--- a/drivers/net/wireless/cnss2/main.c
+++ b/drivers/net/wireless/cnss2/main.c
@@ -426,6 +426,7 @@
 
 	del_timer(&plat_priv->fw_boot_timer);
 	set_bit(CNSS_FW_READY, &plat_priv->driver_state);
+	clear_bit(CNSS_DEV_ERR_NOTIFY, &plat_priv->driver_state);
 
 	if (test_bit(CNSS_FW_BOOT_RECOVERY, &plat_priv->driver_state)) {
 		clear_bit(CNSS_FW_BOOT_RECOVERY, &plat_priv->driver_state);
@@ -901,7 +902,6 @@
 		break;
 	case CNSS_REASON_RDDM:
 		cnss_bus_collect_dump_info(plat_priv, false);
-		clear_bit(CNSS_DEV_ERR_NOTIFY, &plat_priv->driver_state);
 		break;
 	case CNSS_REASON_DEFAULT:
 	case CNSS_REASON_TIMEOUT:
@@ -1039,19 +1039,34 @@
 {
 	int ret = 0;
 
-	set_bit(CNSS_COLD_BOOT_CAL, &plat_priv->driver_state);
-	ret = cnss_bus_dev_powerup(plat_priv);
-	if (ret)
-		clear_bit(CNSS_COLD_BOOT_CAL, &plat_priv->driver_state);
+	if (test_bit(CNSS_FW_READY, &plat_priv->driver_state) ||
+	    test_bit(CNSS_DRIVER_LOADING, &plat_priv->driver_state) ||
+	    test_bit(CNSS_DRIVER_PROBED, &plat_priv->driver_state)) {
+		cnss_pr_dbg("Device is already active, ignore calibration\n");
+		goto out;
+	}
 
+	set_bit(CNSS_COLD_BOOT_CAL, &plat_priv->driver_state);
+	reinit_completion(&plat_priv->cal_complete);
+	ret = cnss_bus_dev_powerup(plat_priv);
+	if (ret) {
+		complete(&plat_priv->cal_complete);
+		clear_bit(CNSS_COLD_BOOT_CAL, &plat_priv->driver_state);
+	}
+
+out:
 	return ret;
 }
 
 static int cnss_cold_boot_cal_done_hdlr(struct cnss_plat_data *plat_priv)
 {
+	if (!test_bit(CNSS_COLD_BOOT_CAL, &plat_priv->driver_state))
+		return 0;
+
 	plat_priv->cal_done = true;
 	cnss_wlfw_wlan_mode_send_sync(plat_priv, CNSS_OFF);
 	cnss_bus_dev_shutdown(plat_priv);
+	complete(&plat_priv->cal_complete);
 	clear_bit(CNSS_COLD_BOOT_CAL, &plat_priv->driver_state);
 
 	return 0;
@@ -1537,6 +1552,36 @@
 	destroy_workqueue(plat_priv->event_wq);
 }
 
+static int cnss_misc_init(struct cnss_plat_data *plat_priv)
+{
+	int ret;
+
+	setup_timer(&plat_priv->fw_boot_timer, cnss_bus_fw_boot_timeout_hdlr,
+		    (unsigned long)plat_priv);
+
+	register_pm_notifier(&cnss_pm_notifier);
+
+	ret = device_init_wakeup(&plat_priv->plat_dev->dev, true);
+	if (ret)
+		cnss_pr_err("Failed to init platform device wakeup source, err = %d\n",
+			    ret);
+
+	init_completion(&plat_priv->power_up_complete);
+	init_completion(&plat_priv->cal_complete);
+	mutex_init(&plat_priv->dev_lock);
+
+	return 0;
+}
+
+static void cnss_misc_deinit(struct cnss_plat_data *plat_priv)
+{
+	complete_all(&plat_priv->cal_complete);
+	complete_all(&plat_priv->power_up_complete);
+	device_init_wakeup(&plat_priv->plat_dev->dev, false);
+	unregister_pm_notifier(&cnss_pm_notifier);
+	del_timer(&plat_priv->fw_boot_timer);
+}
+
 static const struct platform_device_id cnss_platform_id_table[] = {
 	{ .name = "qca6174", .driver_data = QCA6174_DEVICE_ID, },
 	{ .name = "qca6290", .driver_data = QCA6290_DEVICE_ID, },
@@ -1630,23 +1675,16 @@
 	if (ret)
 		goto deinit_qmi;
 
-	setup_timer(&plat_priv->fw_boot_timer, cnss_bus_fw_boot_timeout_hdlr,
-		    (unsigned long)plat_priv);
-
-	register_pm_notifier(&cnss_pm_notifier);
-
-	ret = device_init_wakeup(&plat_dev->dev, true);
+	ret = cnss_misc_init(plat_priv);
 	if (ret)
-		cnss_pr_err("Failed to init platform device wakeup source, err = %d\n",
-			    ret);
-
-	init_completion(&plat_priv->power_up_complete);
-	mutex_init(&plat_priv->dev_lock);
+		goto destroy_debugfs;
 
 	cnss_pr_info("Platform driver probed successfully.\n");
 
 	return 0;
 
+destroy_debugfs:
+	cnss_debugfs_destroy(plat_priv);
 deinit_qmi:
 	cnss_qmi_deinit(plat_priv);
 deinit_event_work:
@@ -1676,10 +1714,7 @@
 {
 	struct cnss_plat_data *plat_priv = platform_get_drvdata(plat_dev);
 
-	complete_all(&plat_priv->power_up_complete);
-	device_init_wakeup(&plat_dev->dev, false);
-	unregister_pm_notifier(&cnss_pm_notifier);
-	del_timer(&plat_priv->fw_boot_timer);
+	cnss_misc_deinit(plat_priv);
 	cnss_debugfs_destroy(plat_priv);
 	cnss_qmi_deinit(plat_priv);
 	cnss_event_work_deinit(plat_priv);
diff --git a/drivers/net/wireless/cnss2/main.h b/drivers/net/wireless/cnss2/main.h
index a2f346a..dd14bbe 100644
--- a/drivers/net/wireless/cnss2/main.h
+++ b/drivers/net/wireless/cnss2/main.h
@@ -243,6 +243,7 @@
 	atomic_t pm_count;
 	struct timer_list fw_boot_timer;
 	struct completion power_up_complete;
+	struct completion cal_complete;
 	struct mutex dev_lock; /* mutex for register access through debugfs */
 	u32 diag_reg_read_addr;
 	u32 diag_reg_read_mem_type;
diff --git a/drivers/net/wireless/cnss2/pci.c b/drivers/net/wireless/cnss2/pci.c
index 28fe137..7a163ed 100644
--- a/drivers/net/wireless/cnss2/pci.c
+++ b/drivers/net/wireless/cnss2/pci.c
@@ -693,6 +693,7 @@
 	int ret = 0;
 	struct cnss_plat_data *plat_priv = cnss_bus_dev_to_plat_priv(NULL);
 	struct cnss_pci_data *pci_priv;
+	unsigned int timeout;
 
 	if (!plat_priv) {
 		cnss_pr_err("plat_priv is NULL\n");
@@ -710,10 +711,27 @@
 		return -EEXIST;
 	}
 
+	if (!test_bit(CNSS_COLD_BOOT_CAL, &plat_priv->driver_state))
+		goto register_driver;
+
+	cnss_pr_dbg("Start to wait for calibration to complete\n");
+
+	timeout = cnss_get_boot_timeout(&pci_priv->pci_dev->dev);
+	ret = wait_for_completion_timeout(&plat_priv->cal_complete,
+					  msecs_to_jiffies(timeout) << 2);
+	if (!ret) {
+		cnss_pr_err("Timeout waiting for calibration to complete\n");
+		ret = -EAGAIN;
+		goto out;
+	}
+
+register_driver:
 	ret = cnss_driver_event_post(plat_priv,
 				     CNSS_DRIVER_EVENT_REGISTER_DRIVER,
 				     CNSS_EVENT_SYNC_UNINTERRUPTIBLE,
 				     driver_ops);
+
+out:
 	return ret;
 }
 EXPORT_SYMBOL(cnss_wlan_register_driver);
@@ -1124,6 +1142,59 @@
 }
 EXPORT_SYMBOL(cnss_wlan_pm_control);
 
+void cnss_pci_pm_runtime_show_usage_count(struct cnss_pci_data *pci_priv)
+{
+	struct device *dev;
+
+	if (!pci_priv)
+		return;
+
+	dev = &pci_priv->pci_dev->dev;
+
+	cnss_pr_dbg("Runtime PM usage count: %d\n",
+		    atomic_read(&dev->power.usage_count));
+}
+
+int cnss_pci_pm_runtime_get(struct cnss_pci_data *pci_priv)
+{
+	if (!pci_priv)
+		return -ENODEV;
+
+	return pm_runtime_get(&pci_priv->pci_dev->dev);
+}
+
+void cnss_pci_pm_runtime_get_noresume(struct cnss_pci_data *pci_priv)
+{
+	if (!pci_priv)
+		return;
+
+	return pm_runtime_get_noresume(&pci_priv->pci_dev->dev);
+}
+
+int cnss_pci_pm_runtime_put_autosuspend(struct cnss_pci_data *pci_priv)
+{
+	if (!pci_priv)
+		return -ENODEV;
+
+	return pm_runtime_put_autosuspend(&pci_priv->pci_dev->dev);
+}
+
+void cnss_pci_pm_runtime_put_noidle(struct cnss_pci_data *pci_priv)
+{
+	if (!pci_priv)
+		return;
+
+	pm_runtime_put_noidle(&pci_priv->pci_dev->dev);
+}
+
+void cnss_pci_pm_runtime_mark_last_busy(struct cnss_pci_data *pci_priv)
+{
+	if (!pci_priv)
+		return;
+
+	pm_runtime_mark_last_busy(&pci_priv->pci_dev->dev);
+}
+
 int cnss_auto_suspend(struct device *dev)
 {
 	int ret = 0;
@@ -1944,10 +2015,6 @@
 		return;
 	}
 
-	if (pci_priv->driver_ops && pci_priv->driver_ops->update_status)
-		pci_priv->driver_ops->update_status(pci_priv->pci_dev,
-						    CNSS_FW_DOWN);
-
 	switch (reason) {
 	case MHI_CB_EE_RDDM:
 		cnss_reason = CNSS_REASON_RDDM;
diff --git a/drivers/net/wireless/cnss2/pci.h b/drivers/net/wireless/cnss2/pci.h
index c8de4d7..e326aed 100644
--- a/drivers/net/wireless/cnss2/pci.h
+++ b/drivers/net/wireless/cnss2/pci.h
@@ -143,5 +143,11 @@
 int cnss_pci_unregister_driver_hdlr(struct cnss_pci_data *pci_priv);
 int cnss_pci_call_driver_modem_status(struct cnss_pci_data *pci_priv,
 				      int modem_current_status);
+void cnss_pci_pm_runtime_show_usage_count(struct cnss_pci_data *pci_priv);
+int cnss_pci_pm_runtime_get(struct cnss_pci_data *pci_priv);
+void cnss_pci_pm_runtime_get_noresume(struct cnss_pci_data *pci_priv);
+int cnss_pci_pm_runtime_put_autosuspend(struct cnss_pci_data *pci_priv);
+void cnss_pci_pm_runtime_put_noidle(struct cnss_pci_data *pci_priv);
+void cnss_pci_pm_runtime_mark_last_busy(struct cnss_pci_data *pci_priv);
 
 #endif /* _CNSS_PCI_H */
diff --git a/drivers/net/wireless/cnss2/qmi.c b/drivers/net/wireless/cnss2/qmi.c
index 2c375bb..d857b9f 100644
--- a/drivers/net/wireless/cnss2/qmi.c
+++ b/drivers/net/wireless/cnss2/qmi.c
@@ -242,6 +242,8 @@
 	req.fw_init_done_enable = 1;
 	req.pin_connect_result_enable_valid = 1;
 	req.pin_connect_result_enable = 1;
+	req.cal_done_enable_valid = 1;
+	req.cal_done_enable = 1;
 
 	req_desc.max_msg_len = WLFW_IND_REGISTER_REQ_MSG_V01_MAX_MSG_LEN;
 	req_desc.msg_id = QMI_WLFW_IND_REGISTER_REQ_V01;
@@ -1054,6 +1056,11 @@
 	case QMI_WLFW_PIN_CONNECT_RESULT_IND_V01:
 		cnss_qmi_pin_result_ind_hdlr(plat_priv, msg, msg_len);
 		break;
+	case QMI_WLFW_CAL_DONE_IND_V01:
+		cnss_driver_event_post(plat_priv,
+				       CNSS_DRIVER_EVENT_COLD_BOOT_CAL_DONE,
+				       0, NULL);
+		break;
 	default:
 		cnss_pr_err("Invalid QMI WLFW indication, msg_id: 0x%x\n",
 			    msg_id);
diff --git a/drivers/pinctrl/qcom/Kconfig b/drivers/pinctrl/qcom/Kconfig
index 9413da3..56ea1f4 100644
--- a/drivers/pinctrl/qcom/Kconfig
+++ b/drivers/pinctrl/qcom/Kconfig
@@ -139,6 +139,16 @@
 	  Technologies Inc MSM8917 platform.
 	  If unsure say N.
 
+config PINCTRL_MSM8940
+	tristate "Qualcomm Technologies Inc MSM8940 pin controller driver"
+	depends on GPIOLIB && OF
+	select PINCTRL_MSM
+	help
+	  This is the pinctrl, pinmux, pinconf and gpiolib driver for the
+	  Qualcomm Technologies Inc TLMM block found on the Qualcomm
+	  Technologies Inc MSM8940 platform.
+	  If unsure say N.
+
 config PINCTRL_SDM845
 	tristate "Qualcomm Technologies Inc SDM845 pin controller driver"
 	depends on GPIOLIB && OF
diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c
index dcfe105..aa29688 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm.c
+++ b/drivers/pinctrl/qcom/pinctrl-msm.c
@@ -1307,7 +1307,7 @@
 		pctrl = gpiochip_get_data(gc);
 		if (pctrl->spi_cfg_regs) {
 			spi_cfg_reg = pctrl->spi_cfg_regs +
-					(dir_conn_data->hwirq / 32) * 4;
+					((dir_conn_data->hwirq - 32) / 32) * 4;
 			if (spi_cfg_reg < pctrl->spi_cfg_end) {
 				spin_lock_irqsave(&pctrl->lock, flags);
 				val = scm_io_read(spi_cfg_reg);
@@ -1315,7 +1315,8 @@
 				 * Clear the respective bit for edge type
 				 * interrupt
 				 */
-				val &= ~(1 << (dir_conn_data->hwirq % 32));
+				val &= ~(1 << ((dir_conn_data->hwirq - 32)
+									% 32));
 				WARN_ON(scm_io_write(spi_cfg_reg, val));
 				spin_unlock_irqrestore(&pctrl->lock, flags);
 			} else
@@ -1392,13 +1393,13 @@
 
 	if (pctrl->spi_cfg_regs && type != IRQ_TYPE_NONE) {
 		spi_cfg_reg = pctrl->spi_cfg_regs +
-				(parent_data->hwirq / 32) * 4;
+				((parent_data->hwirq - 32) / 32) * 4;
 		if (spi_cfg_reg < pctrl->spi_cfg_end) {
 			spin_lock_irqsave(&pctrl->lock, flags);
 			val = scm_io_read(spi_cfg_reg);
-			val &= ~(1 << (parent_data->hwirq % 32));
+			val &= ~(1 << ((parent_data->hwirq - 32) % 32));
 			if (config_val)
-				val |= (1 << (parent_data->hwirq % 32));
+				val |= (1 << ((parent_data->hwirq - 32)  % 32));
 			WARN_ON(scm_io_write(spi_cfg_reg, val));
 			spin_unlock_irqrestore(&pctrl->lock, flags);
 		} else
diff --git a/drivers/platform/msm/ep_pcie/ep_pcie_com.h b/drivers/platform/msm/ep_pcie/ep_pcie_com.h
index 36d49e4..bab5b9e 100644
--- a/drivers/platform/msm/ep_pcie/ep_pcie_com.h
+++ b/drivers/platform/msm/ep_pcie/ep_pcie_com.h
@@ -55,6 +55,9 @@
 #define PCIE20_PARF_SLV_ADDR_SPACE_SIZE_HI     0x35C
 #define PCIE20_PARF_ATU_BASE_ADDR      0x634
 #define PCIE20_PARF_ATU_BASE_ADDR_HI   0x638
+#define PCIE20_PARF_BUS_DISCONNECT_CTRL          0x648
+#define PCIE20_PARF_BUS_DISCONNECT_STATUS        0x64c
+
 #define PCIE20_PARF_DEVICE_TYPE        0x1000
 
 #define PCIE20_ELBI_VERSION            0x00
diff --git a/drivers/platform/msm/ep_pcie/ep_pcie_core.c b/drivers/platform/msm/ep_pcie/ep_pcie_core.c
index 0ada0bf..778a51d 100644
--- a/drivers/platform/msm/ep_pcie/ep_pcie_core.c
+++ b/drivers/platform/msm/ep_pcie/ep_pcie_core.c
@@ -133,6 +133,63 @@
 	return true;
 }
 
+static int ep_pcie_reset_init(struct ep_pcie_dev_t *dev)
+{
+	int i, rc = 0;
+	struct ep_pcie_reset_info_t *reset_info;
+
+	for (i = 0; i < EP_PCIE_MAX_RESET; i++) {
+		reset_info = &dev->reset[i];
+		if (!reset_info->hdl)
+			continue;
+
+		rc = reset_control_assert(reset_info->hdl);
+		if (rc) {
+			if (!reset_info->required) {
+				EP_PCIE_ERR(dev,
+				"PCIe V%d: Optional reset: %s assert failed\n",
+					dev->rev, reset_info->name);
+				continue;
+			} else {
+				EP_PCIE_ERR(dev,
+				"PCIe V%d: failed to assert reset for %s\n",
+					dev->rev, reset_info->name);
+				return rc;
+			}
+		} else {
+			EP_PCIE_DBG(dev,
+			"PCIe V%d: successfully asserted reset for %s\n",
+				dev->rev, reset_info->name);
+		}
+		EP_PCIE_ERR(dev, "After Reset assert %s\n",
+						reset_info->name);
+		/* add a 1ms delay to ensure the reset is asserted */
+		usleep_range(1000, 1005);
+
+		rc = reset_control_deassert(reset_info->hdl);
+		if (rc) {
+			if (!reset_info->required) {
+				EP_PCIE_ERR(dev,
+				"PCIe V%d: Optional reset: %s deassert failed\n",
+					dev->rev, reset_info->name);
+				continue;
+			} else {
+				EP_PCIE_ERR(dev,
+				"PCIe V%d: failed to deassert reset for %s\n",
+					dev->rev, reset_info->name);
+				return rc;
+			}
+		} else {
+			EP_PCIE_DBG(dev,
+			"PCIe V%d: successfully deasserted reset for %s\n",
+				dev->rev, reset_info->name);
+		}
+		EP_PCIE_ERR(dev, "After Reset de-assert %s\n",
+						reset_info->name);
+	}
+	return 0;
+}
+
 static int ep_pcie_gpio_init(struct ep_pcie_dev_t *dev)
 {
 	int i, rc = 0;
@@ -277,7 +334,6 @@
 {
 	int i, rc = 0;
 	struct ep_pcie_clk_info_t *info;
-	struct ep_pcie_reset_info_t *reset_info;
 
 	EP_PCIE_DBG(dev, "PCIe V%d\n", dev->rev);
 
@@ -349,34 +405,6 @@
 		regulator_disable(dev->gdsc);
 	}
 
-	for (i = 0; i < EP_PCIE_MAX_RESET; i++) {
-		reset_info = &dev->reset[i];
-		if (reset_info->hdl) {
-			rc = reset_control_assert(reset_info->hdl);
-			if (rc)
-				EP_PCIE_ERR(dev,
-					"PCIe V%d: failed to assert reset for %s.\n",
-					dev->rev, reset_info->name);
-			else
-				EP_PCIE_DBG(dev,
-					"PCIe V%d: successfully asserted reset for %s.\n",
-					dev->rev, reset_info->name);
-
-			/* add a 1ms delay to ensure the reset is asserted */
-			usleep_range(1000, 1005);
-
-			rc = reset_control_deassert(reset_info->hdl);
-			if (rc)
-				EP_PCIE_ERR(dev,
-					"PCIe V%d: failed to deassert reset for %s.\n",
-					dev->rev, reset_info->name);
-			else
-				EP_PCIE_DBG(dev,
-					"PCIe V%d: successfully deasserted reset for %s.\n",
-					dev->rev, reset_info->name);
-		}
-	}
-
 	return rc;
 }
 
@@ -524,11 +552,21 @@
 
 static void ep_pcie_core_init(struct ep_pcie_dev_t *dev, bool configured)
 {
+	uint32_t val = 0;
 	EP_PCIE_DBG(dev, "PCIe V%d\n", dev->rev);
 
 	/* enable debug IRQ */
 	ep_pcie_write_mask(dev->parf + PCIE20_PARF_DEBUG_INT_EN,
 			0, BIT(3) | BIT(2) | BIT(1));
+	/* Reconnect AXI master port */
+	val = readl_relaxed(dev->parf + PCIE20_PARF_BUS_DISCONNECT_STATUS);
+	if (val & BIT(0)) {
+		EP_PCIE_DBG(dev,
+		"PCIe V%d: AXI Master port was disconnected, reconnecting...\n",
+			dev->rev);
+		ep_pcie_write_mask(dev->parf + PCIE20_PARF_BUS_DISCONNECT_CTRL,
+								0, BIT(0));
+	}
 
 	if (!configured) {
 		/* Configure PCIe to endpoint mode */
@@ -722,8 +760,8 @@
 		ep_pcie_write_mask(dev->parf + PCIE20_PARF_PM_CTRL, BIT(5), 0);
 	}
 
-	/* Configure MMIO */
-	ep_pcie_config_mmio(dev);
+	if (!configured)
+		ep_pcie_config_mmio(dev);
 }
 
 static void ep_pcie_config_inbound_iatu(struct ep_pcie_dev_t *dev)
@@ -1381,6 +1419,9 @@
 		}
 	}
 
+	ret = ep_pcie_reset_init(dev);
+	if (ret)
+		goto link_fail;
 	/* init PCIe PHY */
 	ep_pcie_phy_init(dev);
 
@@ -2727,7 +2768,7 @@
 	platform_driver_unregister(&ep_pcie_driver);
 }
 
-module_init(ep_pcie_init);
+subsys_initcall(ep_pcie_init);
 module_exit(ep_pcie_exit);
 MODULE_LICENSE("GPL v2");
 MODULE_DESCRIPTION("MSM PCIe Endpoint Driver");
diff --git a/drivers/platform/msm/ipa/ipa_v2/ipa_rt.c b/drivers/platform/msm/ipa/ipa_v2/ipa_rt.c
index 073409b..be52968 100644
--- a/drivers/platform/msm/ipa/ipa_v2/ipa_rt.c
+++ b/drivers/platform/msm/ipa/ipa_v2/ipa_rt.c
@@ -1344,6 +1344,8 @@
 	struct ipa_rt_entry *rule_next;
 	struct ipa_rt_tbl_set *rset;
 	u32 apps_start_idx;
+	struct ipa_hdr_entry *hdr_entry;
+	struct ipa_hdr_proc_ctx_entry *hdr_proc_entry;
 	int id;
 	bool tbl_user = false;
 
@@ -1397,6 +1399,27 @@
 			if (!user_only ||
 				rule->ipacm_installed) {
 				list_del(&rule->link);
+				if (rule->hdr) {
+					hdr_entry = ipa_id_find(
+						rule->rule.hdr_hdl);
+					if (!hdr_entry ||
+					hdr_entry->cookie != IPA_HDR_COOKIE) {
+						IPAERR_RL(
+						"Header already deleted\n");
+						return -EINVAL;
+					}
+				} else if (rule->proc_ctx) {
+					hdr_proc_entry =
+						ipa_id_find(
+						rule->rule.hdr_proc_ctx_hdl);
+					if (!hdr_proc_entry ||
+						hdr_proc_entry->cookie !=
+						IPA_PROC_HDR_COOKIE) {
+					IPAERR_RL(
+						"Proc entry already deleted\n");
+						return -EINVAL;
+					}
+				}
 				tbl->rule_cnt--;
 				if (rule->hdr)
 					__ipa_release_hdr(rule->hdr->id);
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_rt.c b/drivers/platform/msm/ipa/ipa_v3/ipa_rt.c
index 28454220..8a7b414 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_rt.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_rt.c
@@ -1487,6 +1487,8 @@
 	struct ipa3_rt_entry *rule;
 	struct ipa3_rt_entry *rule_next;
 	struct ipa3_rt_tbl_set *rset;
+	struct ipa3_hdr_entry *hdr_entry;
+	struct ipa3_hdr_proc_ctx_entry *hdr_proc_entry;
 	u32 apps_start_idx;
 	int id;
 	bool tbl_user = false;
@@ -1540,6 +1542,27 @@
 			if (!user_only ||
 				rule->ipacm_installed) {
 				list_del(&rule->link);
+				if (rule->hdr) {
+					hdr_entry = ipa3_id_find(
+							rule->rule.hdr_hdl);
+					if (!hdr_entry ||
+					hdr_entry->cookie != IPA_HDR_COOKIE) {
+						IPAERR_RL(
+						"Header already deleted\n");
+						return -EINVAL;
+					}
+				} else if (rule->proc_ctx) {
+					hdr_proc_entry =
+						ipa3_id_find(
+						rule->rule.hdr_proc_ctx_hdl);
+					if (!hdr_proc_entry ||
+						hdr_proc_entry->cookie !=
+							IPA_PROC_HDR_COOKIE) {
+						IPAERR_RL(
+						"Proc entry already deleted\n");
+						return -EINVAL;
+					}
+				}
 				tbl->rule_cnt--;
 				if (rule->hdr)
 					__ipa3_release_hdr(rule->hdr->id);
@@ -1547,7 +1570,9 @@
 					__ipa3_release_hdr_proc_ctx(
 						rule->proc_ctx->id);
 				rule->cookie = 0;
-				idr_remove(tbl->rule_ids, rule->rule_id);
+				if (!rule->rule_id_valid)
+					idr_remove(tbl->rule_ids,
+						rule->rule_id);
 				id = rule->id;
 				kmem_cache_free(ipa3_ctx->rt_rule_cache, rule);
 
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_uc.c b/drivers/platform/msm/ipa/ipa_v3/ipa_uc.c
index e746229..89dde7d 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_uc.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_uc.c
@@ -569,7 +569,11 @@
 		if (ipa3_ctx->uc_ctx.uc_status ==
 		    IPA_HW_PROD_DISABLE_CMD_GSI_STOP_FAILURE ||
 		    ipa3_ctx->uc_ctx.uc_status ==
-		    IPA_HW_CONS_DISABLE_CMD_GSI_STOP_FAILURE) {
+		    IPA_HW_CONS_DISABLE_CMD_GSI_STOP_FAILURE ||
+		    ipa3_ctx->uc_ctx.uc_status ==
+		    IPA_HW_CONS_STOP_FAILURE ||
+		    ipa3_ctx->uc_ctx.uc_status ==
+		    IPA_HW_PROD_STOP_FAILURE) {
 			retries++;
 			if (retries == IPA_GSI_CHANNEL_STOP_MAX_RETRY) {
 				IPAERR("Failed after %d tries\n", retries);
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_uc_offload_i.h b/drivers/platform/msm/ipa/ipa_v3/ipa_uc_offload_i.h
index 8d415a1..bda4219 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_uc_offload_i.h
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_uc_offload_i.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -92,6 +92,8 @@
  * @IPA_HW_INVALID_OPCODE : Invalid opcode sent
  * @IPA_HW_INVALID_PARAMS : Invalid params for the requested command
  * @IPA_HW_GSI_CH_NOT_EMPTY_FAILURE : GSI channel emptiness validation failed
+ * @IPA_HW_CONS_STOP_FAILURE : NTN/ETH CONS stop failed
+ * @IPA_HW_PROD_STOP_FAILURE : NTN/ETH PROD stop failed
  */
 enum ipa3_hw_errors {
 	IPA_HW_ERROR_NONE              =
@@ -111,7 +113,11 @@
 	IPA_HW_PROD_DISABLE_CMD_GSI_STOP_FAILURE =
 		FEATURE_ENUM_VAL(IPA_HW_FEATURE_COMMON, 7),
 	IPA_HW_GSI_CH_NOT_EMPTY_FAILURE =
-		FEATURE_ENUM_VAL(IPA_HW_FEATURE_COMMON, 8)
+		FEATURE_ENUM_VAL(IPA_HW_FEATURE_COMMON, 8),
+	IPA_HW_CONS_STOP_FAILURE =
+		FEATURE_ENUM_VAL(IPA_HW_FEATURE_COMMON, 9),
+	IPA_HW_PROD_STOP_FAILURE =
+		FEATURE_ENUM_VAL(IPA_HW_FEATURE_COMMON, 10)
 };
 
 /**
diff --git a/drivers/platform/msm/mhi_dev/mhi.c b/drivers/platform/msm/mhi_dev/mhi.c
index d438079..c3e4bc59 100644
--- a/drivers/platform/msm/mhi_dev/mhi.c
+++ b/drivers/platform/msm/mhi_dev/mhi.c
@@ -1278,7 +1278,7 @@
 			ring = &mhi->ring[ch_num + mhi->ch_ring_start];
 			if (ring->state == RING_STATE_UINT) {
 				pr_debug("Channel not opened for %d\n", ch_num);
-				break;
+				continue;
 			}
 			mhi_ring_set_state(ring, RING_STATE_PENDING);
 			list_add(&ring->list, &mhi->process_ring_list);
@@ -2363,6 +2363,64 @@
 }
 EXPORT_SYMBOL(mhi_dev_write_channel);
 
+static int mhi_dev_recover(struct mhi_dev *mhi)
+{
+	int rc = 0;
+	uint32_t syserr, max_cnt = 0, bhi_intvec = 0;
+	bool mhi_reset;
+	enum mhi_dev_state state;
+
+	/* Check if MHI is in syserr */
+	mhi_dev_mmio_masked_read(mhi, MHISTATUS,
+				MHISTATUS_SYSERR_MASK,
+				MHISTATUS_SYSERR_SHIFT, &syserr);
+
+	mhi_log(MHI_MSG_VERBOSE, "mhi_syserr = 0x%X\n", syserr);
+	if (syserr) {
+		rc = mhi_dev_mmio_read(mhi, BHI_INTVEC, &bhi_intvec);
+		if (rc)
+			return rc;
+
+		if (bhi_intvec != 0xffffffff) {
+			/* Indicate the host that the device is ready */
+			rc = ep_pcie_trigger_msi(mhi->phandle, bhi_intvec);
+			if (rc) {
+				pr_err("%s: error sending msi\n", __func__);
+				return rc;
+			}
+		}
+
+		/* Poll for the host to set the reset bit */
+		rc = mhi_dev_mmio_get_mhi_state(mhi, &state, &mhi_reset);
+		if (rc) {
+			pr_err("%s: get mhi state failed\n", __func__);
+			return rc;
+		}
+		while (mhi_reset != true && max_cnt < MHI_SUSPEND_TIMEOUT) {
+			/* Wait for Host to set the reset */
+			msleep(MHI_SUSPEND_MIN);
+			rc = mhi_dev_mmio_get_mhi_state(mhi, &state,
+								&mhi_reset);
+			if (rc) {
+				pr_err("%s: get mhi state failed\n", __func__);
+				return rc;
+			}
+			max_cnt++;
+		}
+
+		if (!mhi_reset) {
+			mhi_log(MHI_MSG_VERBOSE, "Host failed to set reset\n");
+			return -EINVAL;
+		}
+	}
+	/*
+	 * Now mask the interrupts so that the state machine moves
+	 * only after IPA is ready
+	 */
+	mhi_dev_mmio_mask_interrupts(mhi);
+	return 0;
+}
+
 static void mhi_dev_enable(struct work_struct *work)
 {
 	int rc = 0;
@@ -2865,6 +2923,18 @@
 	mutex_init(&mhi_ctx->mhi_event_lock);
 	mutex_init(&mhi_ctx->mhi_write_test);
 
+	mhi_ctx->phandle = ep_pcie_get_phandle(mhi_ctx->ifc_id);
+	if (!mhi_ctx->phandle) {
+		pr_err("PCIe driver get handle failed.\n");
+		return -EINVAL;
+	}
+
+	rc = mhi_dev_recover(mhi_ctx);
+	if (rc) {
+		pr_err("%s: get mhi state failed\n", __func__);
+		return rc;
+	}
+
 	rc = mhi_init(mhi_ctx);
 	if (rc)
 		return rc;
@@ -2894,13 +2964,6 @@
 		pr_err("Failed to update the MHI version\n");
 		return rc;
 	}
-
-	mhi_ctx->phandle = ep_pcie_get_phandle(mhi_ctx->ifc_id);
-	if (!mhi_ctx->phandle) {
-		pr_err("PCIe driver get handle failed.\n");
-		return -EINVAL;
-	}
-
 	mhi_ctx->event_reg.events = EP_PCIE_EVENT_PM_D3_HOT |
 		EP_PCIE_EVENT_PM_D3_COLD |
 		EP_PCIE_EVENT_PM_D0 |
@@ -3092,7 +3155,7 @@
 {
 	return platform_driver_register(&mhi_dev_driver);
 }
-module_init(mhi_dev_init);
+subsys_initcall(mhi_dev_init);
 
 static void __exit mhi_dev_exit(void)
 {
diff --git a/drivers/platform/msm/mhi_dev/mhi.h b/drivers/platform/msm/mhi_dev/mhi.h
index 6cb2d7d..fae39e0 100644
--- a/drivers/platform/msm/mhi_dev/mhi.h
+++ b/drivers/platform/msm/mhi_dev/mhi.h
@@ -906,6 +906,12 @@
 int mhi_dev_mmio_read_erdb_status_interrupts(struct mhi_dev *dev);
 
 /**
+ * mhi_dev_mmio_mask_interrupts() - Mask all MHI interrupts.
+ * @dev:	MHI device structure.
+ */
+void mhi_dev_mmio_mask_interrupts(struct mhi_dev *dev);
+
+/**
  * mhi_dev_mmio_clear_interrupts() - Clear all doorbell interrupts.
  * @dev:	MHI device structure.
  */
diff --git a/drivers/platform/msm/mhi_dev/mhi_mmio.c b/drivers/platform/msm/mhi_dev/mhi_mmio.c
index 559fa84..28d465a 100644
--- a/drivers/platform/msm/mhi_dev/mhi_mmio.c
+++ b/drivers/platform/msm/mhi_dev/mhi_mmio.c
@@ -568,7 +568,7 @@
 }
 EXPORT_SYMBOL(mhi_dev_mmio_disable_cmdb_interrupt);
 
-static void mhi_dev_mmio_mask_interrupts(struct mhi_dev *dev)
+void mhi_dev_mmio_mask_interrupts(struct mhi_dev *dev)
 {
 	int rc = 0;
 
@@ -596,6 +596,7 @@
 		return;
 	}
 }
+EXPORT_SYMBOL(mhi_dev_mmio_mask_interrupts);
 
 int mhi_dev_mmio_clear_interrupts(struct mhi_dev *dev)
 {
diff --git a/drivers/power/supply/qcom/qg-core.h b/drivers/power/supply/qcom/qg-core.h
index b0ff18c..4f0773b 100644
--- a/drivers/power/supply/qcom/qg-core.h
+++ b/drivers/power/supply/qcom/qg-core.h
@@ -50,11 +50,13 @@
 	int			delta_soc;
 	int			rbat_conn_mohm;
 	int			ignore_shutdown_soc_secs;
+	int			shutdown_temp_diff;
 	int			cold_temp_threshold;
 	int			esr_qual_i_ua;
 	int			esr_qual_v_uv;
 	int			esr_disable_soc;
 	int			esr_min_ibat_ua;
+	int			shutdown_soc_threshold;
 	bool			hold_soc_while_full;
 	bool			linearize_soc;
 	bool			cl_disable;
diff --git a/drivers/power/supply/qcom/qpnp-fg-gen3.c b/drivers/power/supply/qcom/qpnp-fg-gen3.c
index 4335600..d7ee5bd 100644
--- a/drivers/power/supply/qcom/qpnp-fg-gen3.c
+++ b/drivers/power/supply/qcom/qpnp-fg-gen3.c
@@ -5604,13 +5604,24 @@
 {
 	int i;
 
+	power_supply_unreg_notifier(&chip->nb);
+	qpnp_misc_twm_notifier_unregister(&chip->twm_nb);
+	cancel_delayed_work_sync(&chip->ttf_work);
+	cancel_delayed_work_sync(&chip->sram_dump_work);
+	if (chip->dt.use_esr_sw)
+		alarm_cancel(&chip->esr_sw_timer);
+	cancel_work_sync(&chip->esr_sw_work);
+	cancel_delayed_work_sync(&chip->profile_load_work);
+	cancel_work_sync(&chip->status_change_work);
+	cancel_work_sync(&chip->esr_filter_work);
+	cancel_delayed_work_sync(&chip->pl_enable_work);
+
 	for (i = 0; i < FG_IRQ_MAX; i++) {
 		if (fg_irqs[i].irq)
 			devm_free_irq(chip->dev, fg_irqs[i].irq, chip);
 	}
 
 	alarm_try_to_cancel(&chip->esr_filter_alarm);
-	power_supply_unreg_notifier(&chip->nb);
 	debugfs_remove_recursive(chip->dfs_root);
 	if (chip->awake_votable)
 		destroy_votable(chip->awake_votable);
@@ -5975,8 +5986,6 @@
 		if (rc < 0)
 			pr_err("Error in disabling FG resets rc=%d\n", rc);
 	}
-
-	fg_cleanup(chip);
 }
 
 static const struct of_device_id fg_gen3_match_table[] = {
diff --git a/drivers/power/supply/qcom/qpnp-qg.c b/drivers/power/supply/qcom/qpnp-qg.c
index 855e31d..97256be 100644
--- a/drivers/power/supply/qcom/qpnp-qg.c
+++ b/drivers/power/supply/qcom/qpnp-qg.c
@@ -2514,7 +2514,6 @@
 	return 0;
 }
 
-
 static struct ocv_all ocv[] = {
 	[S7_PON_OCV] = { 0, 0, "S7_PON_OCV"},
 	[S3_GOOD_OCV] = { 0, 0, "S3_GOOD_OCV"},
@@ -2528,7 +2527,7 @@
 	int rc = 0, batt_temp = 0, i;
 	bool use_pon_ocv = true;
 	unsigned long rtc_sec = 0;
-	u32 ocv_uv = 0, soc = 0, shutdown[SDAM_MAX] = {0};
+	u32 ocv_uv = 0, soc = 0, pon_soc = 0, shutdown[SDAM_MAX] = {0};
 	char ocv_type[20] = "NONE";
 
 	if (!chip->profile_loaded) {
@@ -2536,6 +2535,24 @@
 		return 0;
 	}
 
+	/* read all OCVs */
+	for (i = S7_PON_OCV; i < PON_OCV_MAX; i++) {
+		rc = qg_read_ocv(chip, &ocv[i].ocv_uv,
+					&ocv[i].ocv_raw, i);
+		if (rc < 0)
+			pr_err("Failed to read %s OCV rc=%d\n",
+					ocv[i].ocv_type, rc);
+		else
+			qg_dbg(chip, QG_DEBUG_PON, "%s OCV=%d\n",
+					ocv[i].ocv_type, ocv[i].ocv_uv);
+	}
+
+	rc = qg_get_battery_temp(chip, &batt_temp);
+	if (rc) {
+		pr_err("Failed to read BATT_TEMP at PON rc=%d\n", rc);
+		goto done;
+	}
+
 	rc = get_rtc_time(&rtc_sec);
 	if (rc < 0) {
 		pr_err("Failed to read RTC time rc=%d\n", rc);
@@ -2548,47 +2565,50 @@
 		goto use_pon_ocv;
 	}
 
-	qg_dbg(chip, QG_DEBUG_PON, "Shutdown: Valid=%d SOC=%d OCV=%duV time=%dsecs, time_now=%ldsecs\n",
+	rc = lookup_soc_ocv(&pon_soc, ocv[S7_PON_OCV].ocv_uv, batt_temp, false);
+	if (rc < 0) {
+		pr_err("Failed to lookup S7_PON SOC rc=%d\n", rc);
+		goto done;
+	}
+
+	qg_dbg(chip, QG_DEBUG_PON, "Shutdown: Valid=%d SOC=%d OCV=%duV time=%dsecs temp=%d, time_now=%ldsecs temp_now=%d S7_soc=%d\n",
 			shutdown[SDAM_VALID],
 			shutdown[SDAM_SOC],
 			shutdown[SDAM_OCV_UV],
 			shutdown[SDAM_TIME_SEC],
-			rtc_sec);
+			shutdown[SDAM_TEMP],
+			rtc_sec, batt_temp,
+			pon_soc);
 	/*
 	 * Use the shutdown SOC if
-	 * 1. The device was powered off for < ignore_shutdown_time
-	 * 2. SDAM read is a success & SDAM data is valid
+	 * 1. SDAM read is a success & SDAM data is valid
+	 * 2. The device was powered off for < ignore_shutdown_time
+	 * 2. Batt temp has not changed more than shutdown_temp_diff
 	 */
-	if (shutdown[SDAM_VALID] && is_between(0,
-			chip->dt.ignore_shutdown_soc_secs,
-			(rtc_sec - shutdown[SDAM_TIME_SEC]))) {
-		use_pon_ocv = false;
-		ocv_uv = shutdown[SDAM_OCV_UV];
-		soc = shutdown[SDAM_SOC];
-		strlcpy(ocv_type, "SHUTDOWN_SOC", 20);
-		qg_dbg(chip, QG_DEBUG_PON, "Using SHUTDOWN_SOC @ PON\n");
-	}
+	if (!shutdown[SDAM_VALID])
+		goto use_pon_ocv;
+
+	if (!is_between(0, chip->dt.ignore_shutdown_soc_secs,
+			(rtc_sec - shutdown[SDAM_TIME_SEC])))
+		goto use_pon_ocv;
+
+	if (!is_between(0, chip->dt.shutdown_temp_diff,
+			abs(shutdown[SDAM_TEMP] -  batt_temp)))
+		goto use_pon_ocv;
+
+	if ((chip->dt.shutdown_soc_threshold != -EINVAL) &&
+			!is_between(0, chip->dt.shutdown_soc_threshold,
+			abs(pon_soc - shutdown[SDAM_SOC])))
+		goto use_pon_ocv;
+
+	use_pon_ocv = false;
+	ocv_uv = shutdown[SDAM_OCV_UV];
+	soc = shutdown[SDAM_SOC];
+	strlcpy(ocv_type, "SHUTDOWN_SOC", 20);
+	qg_dbg(chip, QG_DEBUG_PON, "Using SHUTDOWN_SOC @ PON\n");
 
 use_pon_ocv:
 	if (use_pon_ocv == true) {
-		rc = qg_get_battery_temp(chip, &batt_temp);
-		if (rc) {
-			pr_err("Failed to read BATT_TEMP at PON rc=%d\n", rc);
-			goto done;
-		}
-
-		/* read all OCVs */
-		for (i = S7_PON_OCV; i < PON_OCV_MAX; i++) {
-			rc = qg_read_ocv(chip, &ocv[i].ocv_uv,
-						&ocv[i].ocv_raw, i);
-			if (rc < 0)
-				pr_err("Failed to read %s OCV rc=%d\n",
-						ocv[i].ocv_type, rc);
-			else
-				qg_dbg(chip, QG_DEBUG_PON, "%s OCV=%d\n",
-					ocv[i].ocv_type, ocv[i].ocv_uv);
-		}
-
 		if (ocv[S3_LAST_OCV].ocv_raw == FIFO_V_RESET_VAL) {
 			if (!ocv[SDAM_PON_OCV].ocv_uv) {
 				strlcpy(ocv_type, "S7_PON_SOC", 20);
@@ -3074,6 +3094,7 @@
 #define DEFAULT_CL_MAX_DEC_DECIPERC	20
 #define DEFAULT_CL_MIN_LIM_DECIPERC	500
 #define DEFAULT_CL_MAX_LIM_DECIPERC	100
+#define DEFAULT_SHUTDOWN_TEMP_DIFF	60	/* 6 degC */
 #define DEFAULT_ESR_QUAL_CURRENT_UA	130000
 #define DEFAULT_ESR_QUAL_VBAT_UV	7000
 #define DEFAULT_ESR_DISABLE_SOC		1000
@@ -3259,6 +3280,12 @@
 	else
 		chip->dt.ignore_shutdown_soc_secs = temp;
 
+	rc = of_property_read_u32(node, "qcom,shutdown-temp-diff", &temp);
+	if (rc < 0)
+		chip->dt.shutdown_temp_diff = DEFAULT_SHUTDOWN_TEMP_DIFF;
+	else
+		chip->dt.shutdown_temp_diff = temp;
+
 	chip->dt.hold_soc_while_full = of_property_read_bool(node,
 					"qcom,hold-soc-while-full");
 
@@ -3302,6 +3329,12 @@
 	else
 		chip->dt.esr_min_ibat_ua = (int)temp;
 
+	rc = of_property_read_u32(node, "qcom,shutdown_soc_threshold", &temp);
+	if (rc < 0)
+		chip->dt.shutdown_soc_threshold = -EINVAL;
+	else
+		chip->dt.shutdown_soc_threshold = temp;
+
 	chip->dt.qg_ext_sense = of_property_read_bool(node, "qcom,qg-ext-sns");
 
 	/* Capacity learning params*/
diff --git a/drivers/power/supply/qcom/qpnp-smb2.c b/drivers/power/supply/qcom/qpnp-smb2.c
index bc1855e..dd0f889 100644
--- a/drivers/power/supply/qcom/qpnp-smb2.c
+++ b/drivers/power/supply/qcom/qpnp-smb2.c
@@ -217,6 +217,9 @@
 		return -EINVAL;
 	}
 
+	chg->reddragon_ipc_wa = of_property_read_bool(node,
+				"qcom,qcs605-ipc-wa");
+
 	chg->step_chg_enabled = of_property_read_bool(node,
 				"qcom,step-charging-enable");
 
diff --git a/drivers/power/supply/qcom/qpnp-vm-bms.c b/drivers/power/supply/qcom/qpnp-vm-bms.c
index 35c155a..6faee2b 100644
--- a/drivers/power/supply/qcom/qpnp-vm-bms.c
+++ b/drivers/power/supply/qcom/qpnp-vm-bms.c
@@ -3477,8 +3477,8 @@
 		pr_err("cannot read battery id err = %lld\n", battery_id);
 		return battery_id;
 	}
-	node = of_find_node_by_name(chip->pdev->dev.of_node,
-					"qcom,battery-data");
+	node = of_parse_phandle(chip->pdev->dev.of_node,
+					"qcom,battery-data", 0);
 	if (!node) {
 		pr_err("No available batterydata\n");
 		return -EINVAL;
diff --git a/drivers/power/supply/qcom/smb-lib.c b/drivers/power/supply/qcom/smb-lib.c
index e23f13e..3671891 100644
--- a/drivers/power/supply/qcom/smb-lib.c
+++ b/drivers/power/supply/qcom/smb-lib.c
@@ -1606,7 +1606,7 @@
 
 	smblib_dbg(chg, PR_OTG, "enabling OTG\n");
 
-	if (chg->wa_flags & OTG_WA) {
+	if ((chg->wa_flags & OTG_WA) && (!chg->reddragon_ipc_wa)) {
 		rc = smblib_enable_otg_wa(chg);
 		if (rc < 0)
 			smblib_err(chg, "Couldn't enable OTG rc=%d\n", rc);
diff --git a/drivers/power/supply/qcom/smb-lib.h b/drivers/power/supply/qcom/smb-lib.h
index 4da5941..87a8303 100644
--- a/drivers/power/supply/qcom/smb-lib.h
+++ b/drivers/power/supply/qcom/smb-lib.h
@@ -369,6 +369,7 @@
 	int			qc2_max_pulses;
 	bool			non_compliant_chg_detected;
 	bool			fake_usb_insertion;
+	bool			reddragon_ipc_wa;
 
 	/* extcon for VBUS / ID notification to USB for uUSB */
 	struct extcon_dev	*extcon;
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 6c97870..e3dca8b 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -3445,6 +3445,7 @@
 	int tag;
 	struct completion wait;
 	unsigned long flags;
+	bool has_read_lock = false;
 
 	/*
 	 * May get invoked from shutdown and IOCTL contexts.
@@ -3452,8 +3453,10 @@
 	 * In error recovery context, it may come with lock acquired.
 	 */
 
-	if (!ufshcd_is_shutdown_ongoing(hba) && !ufshcd_eh_in_progress(hba))
+	if (!ufshcd_is_shutdown_ongoing(hba) && !ufshcd_eh_in_progress(hba)) {
 		down_read(&hba->lock);
+		has_read_lock = true;
+	}
 
 	/*
 	 * Get free slot, sleep if slots are unavailable.
@@ -3486,7 +3489,7 @@
 out_put_tag:
 	ufshcd_put_dev_cmd_tag(hba, tag);
 	wake_up(&hba->dev_cmd.tag_wq);
-	if (!ufshcd_is_shutdown_ongoing(hba) && !ufshcd_eh_in_progress(hba))
+	if (has_read_lock)
 		up_read(&hba->lock);
 	return err;
 }
diff --git a/drivers/soc/qcom/memory_dump_v2.c b/drivers/soc/qcom/memory_dump_v2.c
index 5912ff2..5459f35 100644
--- a/drivers/soc/qcom/memory_dump_v2.c
+++ b/drivers/soc/qcom/memory_dump_v2.c
@@ -140,7 +140,7 @@
 
 	dmac_flush_range(table, (void *)table + sizeof(struct msm_dump_table));
 
-	if (msm_dump_data_add_minidump(entry))
+	if (msm_dump_data_add_minidump(entry) < 0)
 		pr_err("Failed to add entry in Minidump table\n");
 
 	return 0;
diff --git a/drivers/soc/qcom/minidump_log.c b/drivers/soc/qcom/minidump_log.c
index 87e1700..ff4a79c 100644
--- a/drivers/soc/qcom/minidump_log.c
+++ b/drivers/soc/qcom/minidump_log.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -37,7 +37,7 @@
 	md_entry.virt_addr = (uintptr_t) (*log_bufp);
 	md_entry.phys_addr = virt_to_phys(*log_bufp);
 	md_entry.size = *log_buf_lenp;
-	if (msm_minidump_add_region(&md_entry))
+	if (msm_minidump_add_region(&md_entry) < 0)
 		pr_err("Failed to add logbuf in Minidump\n");
 }
 
@@ -53,7 +53,7 @@
 	ksec_entry.virt_addr = (uintptr_t)_sdata;
 	ksec_entry.phys_addr = virt_to_phys(_sdata);
 	ksec_entry.size = roundup((__bss_stop - _sdata), 4);
-	if (msm_minidump_add_region(&ksec_entry))
+	if (msm_minidump_add_region(&ksec_entry) < 0)
 		pr_err("Failed to add data section in Minidump\n");
 
 	/* Add percpu static sections */
@@ -66,7 +66,7 @@
 		ksec_entry.virt_addr = (uintptr_t)start;
 		ksec_entry.phys_addr = per_cpu_ptr_to_phys(start);
 		ksec_entry.size = static_size;
-		if (msm_minidump_add_region(&ksec_entry))
+		if (msm_minidump_add_region(&ksec_entry) < 0)
 			pr_err("Failed to add percpu sections in Minidump\n");
 	}
 }
@@ -87,14 +87,14 @@
 	ksp_entry.virt_addr = sp;
 	ksp_entry.phys_addr = virt_to_phys((uintptr_t *)sp);
 	ksp_entry.size = THREAD_SIZE;
-	if (msm_minidump_add_region(&ksp_entry))
+	if (msm_minidump_add_region(&ksp_entry) < 0)
 		pr_err("Failed to add stack of cpu %d in Minidump\n", cpu);
 
 	scnprintf(ktsk_entry.name, sizeof(ktsk_entry.name), "KTASK%d", cpu);
 	ktsk_entry.virt_addr = (u64)current;
 	ktsk_entry.phys_addr = virt_to_phys((uintptr_t *)current);
 	ktsk_entry.size = sizeof(struct task_struct);
-	if (msm_minidump_add_region(&ktsk_entry))
+	if (msm_minidump_add_region(&ktsk_entry) < 0)
 		pr_err("Failed to add current task %d in Minidump\n", cpu);
 }
 
diff --git a/drivers/soc/qcom/msm_minidump.c b/drivers/soc/qcom/msm_minidump.c
index 3644dd6..309af6c 100644
--- a/drivers/soc/qcom/msm_minidump.c
+++ b/drivers/soc/qcom/msm_minidump.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -40,7 +40,7 @@
 	struct md_ss_toc	*md_ss_toc;
 	struct md_global_toc	*md_gbl_toc;
 	struct md_ss_region	*md_regions;
-	struct md_region        entry[MAX_NUM_ENTRIES];
+	struct md_region	entry[MAX_NUM_ENTRIES];
 };
 
 /**
@@ -169,17 +169,10 @@
 }
 EXPORT_SYMBOL(msm_minidump_enabled);
 
-int msm_minidump_add_region(const struct md_region *entry)
+static inline int validate_region(const struct md_region *entry)
 {
-	u32 entries;
-	struct md_region *mdr;
-	int ret = 0;
-
-	if (!entry)
-		return -EINVAL;
-
-	if ((strlen(entry->name) > MAX_NAME_LENGTH) ||
-		md_check_name(entry->name) || !entry->virt_addr) {
+	if (!entry || (strlen(entry->name) > MAX_NAME_LENGTH) ||
+		!entry->virt_addr) {
 		pr_err("Invalid entry details\n");
 		return -EINVAL;
 	}
@@ -188,6 +181,55 @@
 		pr_err("size should be 4 byte aligned\n");
 		return -EINVAL;
 	}
+	return 0;
+}
+
+int msm_minidump_update_region(int regno, const struct md_region *entry)
+{
+	struct md_region *mdr;
+	struct md_ss_region *mdssr;
+	struct elfhdr *hdr = minidump_elfheader.ehdr;
+	struct elf_shdr *shdr;
+	struct elf_phdr *phdr;
+
+	if (validate_region(entry) || (regno >= MAX_NUM_ENTRIES))
+		return -EINVAL;
+
+	if (!md_check_name(entry->name)) {
+		pr_err("Region:[%s] does not exist to update.\n", entry->name);
+		return -ENOMEM;
+	}
+
+	mdr = &minidump_table.entry[regno];
+	mdr->virt_addr = entry->virt_addr;
+	mdr->phys_addr = entry->phys_addr;
+
+	mdssr = &minidump_table.md_regions[regno + 1];
+	mdssr->region_base_address = entry->phys_addr;
+
+	shdr = elf_section(hdr, regno + 4);
+	phdr = elf_program(hdr, regno + 1);
+
+	shdr->sh_addr = (elf_addr_t)entry->virt_addr;
+	phdr->p_vaddr = entry->virt_addr;
+	phdr->p_paddr = entry->phys_addr;
+
+	return 0;
+}
+EXPORT_SYMBOL(msm_minidump_update_region);
+
+int msm_minidump_add_region(const struct md_region *entry)
+{
+	u32 entries;
+	struct md_region *mdr;
+
+	if (validate_region(entry))
+		return -EINVAL;
+
+	if (md_check_name(entry->name)) {
+		pr_err("Region name [%s] already registered\n", entry->name);
+		return -EEXIST;
+	}
 
 	spin_lock(&mdt_lock);
 	entries = minidump_table.num_regions;
@@ -215,7 +257,7 @@
 
 	spin_unlock(&mdt_lock);
 
-	return ret;
+	return entries;
 }
 EXPORT_SYMBOL(msm_minidump_add_region);
 
diff --git a/drivers/soc/qcom/socinfo.c b/drivers/soc/qcom/socinfo.c
index f829eaa..e78a49a 100644
--- a/drivers/soc/qcom/socinfo.c
+++ b/drivers/soc/qcom/socinfo.c
@@ -630,6 +630,9 @@
 	[308] = {MSM_CPU_8917, "MSM8217"},
 	[309] = {MSM_CPU_8917, "MSM8617"},
 
+	/* MSM8940 IDs */
+	[313] = {MSM_CPU_8940, "MSM8940"},
+
 	/* SDM429 and SDM439 ID*/
 	[353] = {MSM_CPU_SDM439, "SDM439"},
 	[354] = {MSM_CPU_SDM429, "SDM429"},
@@ -1593,6 +1596,10 @@
 		dummy_socinfo.id = 303;
 		strlcpy(dummy_socinfo.build_id, "msm8917 - ",
 			sizeof(dummy_socinfo.build_id));
+	} else if (early_machine_is_msm8940()) {
+		dummy_socinfo.id = 313;
+		strlcpy(dummy_socinfo.build_id, "msm8940 - ",
+			sizeof(dummy_socinfo.build_id));
 	} else if (early_machine_is_sdm450()) {
 		dummy_socinfo.id = 338;
 		strlcpy(dummy_socinfo.build_id, "sdm450 - ",
diff --git a/drivers/soc/qcom/subsystem_restart.c b/drivers/soc/qcom/subsystem_restart.c
index f20eda2..4aac534 100644
--- a/drivers/soc/qcom/subsystem_restart.c
+++ b/drivers/soc/qcom/subsystem_restart.c
@@ -61,7 +61,7 @@
 
 #define setup_timeout(dest_ss, source_ss, comm_type) \
 	_setup_timeout(dest_ss, source_ss, comm_type)
-#define cancel_timeout(subsys) del_timer(&subsys->timeout_data.timer)
+#define cancel_timeout(subsys) del_timer_sync(&subsys->timeout_data.timer)
 #define init_subsys_timer(subsys) _init_subsys_timer(subsys)
 
 /* Timeout values */
diff --git a/drivers/soc/qcom/watchdog_v2.c b/drivers/soc/qcom/watchdog_v2.c
index b924bc8..30672a37 100644
--- a/drivers/soc/qcom/watchdog_v2.c
+++ b/drivers/soc/qcom/watchdog_v2.c
@@ -885,7 +885,7 @@
 	md_entry.virt_addr = (uintptr_t)wdog_dd;
 	md_entry.phys_addr = virt_to_phys(wdog_dd);
 	md_entry.size = sizeof(*wdog_dd);
-	if (msm_minidump_add_region(&md_entry))
+	if (msm_minidump_add_region(&md_entry) < 0)
 		pr_info("Failed to add Watchdog data in Minidump\n");
 
 	return 0;
diff --git a/drivers/spmi/spmi-pmic-arb.c b/drivers/spmi/spmi-pmic-arb.c
index 0f0b7ba..a26b289 100644
--- a/drivers/spmi/spmi-pmic-arb.c
+++ b/drivers/spmi/spmi-pmic-arb.c
@@ -685,19 +685,26 @@
 	if (flow_type & (IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING)) {
 		type.type |= bit_mask_irq;
 		if (flow_type & IRQF_TRIGGER_RISING)
-			type.polarity_high |= bit_mask_irq;
+			type.polarity_high |=  bit_mask_irq;
+		else
+			type.polarity_high &= ~bit_mask_irq;
 		if (flow_type & IRQF_TRIGGER_FALLING)
-			type.polarity_low  |= bit_mask_irq;
+			type.polarity_low  |=  bit_mask_irq;
+		else
+			type.polarity_low  &= ~bit_mask_irq;
 	} else {
 		if ((flow_type & (IRQF_TRIGGER_HIGH)) &&
 		    (flow_type & (IRQF_TRIGGER_LOW)))
 			return -EINVAL;
 
 		type.type &= ~bit_mask_irq; /* level trig */
-		if (flow_type & IRQF_TRIGGER_HIGH)
-			type.polarity_high |= bit_mask_irq;
-		else
-			type.polarity_low  |= bit_mask_irq;
+		if (flow_type & IRQF_TRIGGER_HIGH) {
+			type.polarity_high |=  bit_mask_irq;
+			type.polarity_low  &= ~bit_mask_irq;
+		} else {
+			type.polarity_low  |=  bit_mask_irq;
+			type.polarity_high &= ~bit_mask_irq;
+		}
 	}
 
 	qpnpint_spmi_write(d, QPNPINT_REG_SET_TYPE, &type, sizeof(type));
diff --git a/drivers/staging/android/ion/ion_page_pool.c b/drivers/staging/android/ion/ion_page_pool.c
index 38d4175..5709434 100644
--- a/drivers/staging/android/ion/ion_page_pool.c
+++ b/drivers/staging/android/ion/ion_page_pool.c
@@ -2,7 +2,7 @@
  * drivers/staging/android/ion/ion_page_pool.c
  *
  * Copyright (C) 2011 Google, Inc.
- * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016, 2018 The Linux Foundation. All rights reserved.
  *
  * This software is licensed under the terms of the GNU General Public
  * License version 2, as published by the Free Software Foundation, and
@@ -65,6 +65,9 @@
 		list_add_tail(&page->lru, &pool->low_items);
 		pool->low_count++;
 	}
+
+	mod_node_page_state(page_pgdat(page), NR_INDIRECTLY_RECLAIMABLE_BYTES,
+			    (1 << (PAGE_SHIFT + pool->order)));
 	mutex_unlock(&pool->mutex);
 	return 0;
 }
@@ -84,6 +87,8 @@
 	}
 
 	list_del(&page->lru);
+	mod_node_page_state(page_pgdat(page), NR_INDIRECTLY_RECLAIMABLE_BYTES,
+			    -(1 << (PAGE_SHIFT + pool->order)));
 	return page;
 }
 
diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c
index f05471d..5c71628 100644
--- a/drivers/staging/android/ion/ion_system_heap.c
+++ b/drivers/staging/android/ion/ion_system_heap.c
@@ -481,7 +481,7 @@
 
 err_free_sg2:
 	/* We failed to zero buffers. Bypass pool */
-	buffer->flags |= ION_PRIV_FLAG_SHRINKER_FREE;
+	buffer->private_flags |= ION_PRIV_FLAG_SHRINKER_FREE;
 
 	if (vmid > 0)
 		ion_system_secure_heap_unassign_sg(table, vmid);
diff --git a/drivers/thermal/qpnp-adc-tm.c b/drivers/thermal/qpnp-adc-tm.c
index 5d345cc..fbab52f 100644
--- a/drivers/thermal/qpnp-adc-tm.c
+++ b/drivers/thermal/qpnp-adc-tm.c
@@ -361,6 +361,7 @@
 	[SCALE_R_ABSOLUTE] = {qpnp_adc_absolute_rthr},
 	[SCALE_QRD_SKUH_RBATT_THERM] = {qpnp_adc_qrd_skuh_btm_scaler},
 	[SCALE_QRD_SKUT1_RBATT_THERM] = {qpnp_adc_qrd_skut1_btm_scaler},
+	[SCALE_QRD_215_RBATT_THERM] = {qpnp_adc_qrd_215_btm_scaler},
 };
 
 static int32_t qpnp_adc_tm_read_reg(struct qpnp_adc_tm_chip *chip,
diff --git a/drivers/usb/dwc3/dwc3-msm.c b/drivers/usb/dwc3/dwc3-msm.c
index d53dc92..dcc183d 100644
--- a/drivers/usb/dwc3/dwc3-msm.c
+++ b/drivers/usb/dwc3/dwc3-msm.c
@@ -2329,7 +2329,14 @@
 		return -EBUSY;
 	}
 
-	if (!mdwc->in_host_mode && (mdwc->vbus_active && !mdwc->suspend)) {
+	/*
+	 * Check if remote wakeup is received and pending before going
+	 * ahead with suspend routine as part of device bus suspend.
+	 */
+
+	if (!mdwc->in_host_mode && (mdwc->vbus_active &&
+		(mdwc->otg_state == OTG_STATE_B_SUSPEND ||
+		mdwc->otg_state == OTG_STATE_B_PERIPHERAL) && !mdwc->suspend)) {
 		dev_dbg(mdwc->dev,
 			"Received wakeup event before the core suspend\n");
 		mutex_unlock(&mdwc->suspend_resume_mutex);
@@ -3862,6 +3869,11 @@
 					mdwc->core_clk_rate_hs);
 				mdwc->max_rh_port_speed = USB_SPEED_HIGH;
 			} else {
+				clk_set_rate(mdwc->core_clk,
+						mdwc->core_clk_rate);
+				dev_dbg(mdwc->dev,
+					"set ss core clk rate %ld\n",
+					mdwc->core_clk_rate);
 				mdwc->max_rh_port_speed = USB_SPEED_SUPER;
 			}
 
diff --git a/drivers/usb/gadget/function/f_gsi.c b/drivers/usb/gadget/function/f_gsi.c
index 4cd3780..726b1aa 100644
--- a/drivers/usb/gadget/function/f_gsi.c
+++ b/drivers/usb/gadget/function/f_gsi.c
@@ -1395,7 +1395,7 @@
 						ctrl_device);
 	struct f_gsi *gsi;
 	struct gsi_ctrl_pkt *cpkt;
-	struct ep_info info;
+	struct ep_info info = { {0} };
 	int val, ret = 0;
 	unsigned long flags;
 
diff --git a/drivers/usb/gadget/function/f_gsi.h b/drivers/usb/gadget/function/f_gsi.h
index 5231213..683d6c5 100644
--- a/drivers/usb/gadget/function/f_gsi.h
+++ b/drivers/usb/gadget/function/f_gsi.h
@@ -39,7 +39,7 @@
 #define GSI_GPS_CTRL_NAME "gps"
 
 #define GSI_CTRL_NAME_LEN (sizeof(GSI_MBIM_CTRL_NAME)+2)
-#define GSI_MAX_CTRL_PKT_SIZE 4096
+#define GSI_MAX_CTRL_PKT_SIZE 8192
 #define GSI_CTRL_DTR (1 << 0)
 
 #define GSI_NUM_IN_RNDIS_BUFFERS 50
diff --git a/drivers/usb/phy/phy-msm-ssusb-qmp.c b/drivers/usb/phy/phy-msm-ssusb-qmp.c
index 5b734be..4360e89 100644
--- a/drivers/usb/phy/phy-msm-ssusb-qmp.c
+++ b/drivers/usb/phy/phy-msm-ssusb-qmp.c
@@ -23,6 +23,7 @@
 #include <linux/regulator/consumer.h>
 #include <linux/usb/phy.h>
 #include <linux/clk.h>
+#include <linux/extcon.h>
 #include <linux/reset.h>
 
 enum ldo_levels {
@@ -133,6 +134,8 @@
 	struct reset_control	*phy_reset;
 	struct reset_control	*phy_phy_reset;
 	struct reset_control	*global_phy_reset;
+	struct extcon_dev	*extcon_dp;
+	struct notifier_block	dp_nb;
 	bool			power_enabled;
 	bool			clk_enabled;
 	bool			cable_connected;
@@ -377,9 +380,12 @@
 	switch (phy->phy.type) {
 	case USB_PHY_TYPE_USB3_AND_DP:
 		/* override hardware control for reset of qmp phy */
-		writel_relaxed(SW_DPPHY_RESET_MUX | SW_DPPHY_RESET |
-			SW_USB3PHY_RESET_MUX | SW_USB3PHY_RESET,
-			phy->base + phy->phy_reg[USB3_DP_COM_RESET_OVRD_CTRL]);
+		if (!(phy->phy.flags & PHY_USB_DP_CONCURRENT_MODE)) {
+			writel_relaxed(SW_DPPHY_RESET_MUX | SW_DPPHY_RESET |
+				SW_USB3PHY_RESET_MUX | SW_USB3PHY_RESET,
+				phy->base +
+				phy->phy_reg[USB3_DP_COM_RESET_OVRD_CTRL]);
+		}
 
 		/* update port select */
 		if (val > 0) {
@@ -389,12 +395,16 @@
 				phy->phy_reg[USB3_DP_COM_TYPEC_CTRL]);
 		}
 
-		writel_relaxed(USB3_MODE | DP_MODE,
-			phy->base + phy->phy_reg[USB3_DP_COM_PHY_MODE_CTRL]);
+		if (!(phy->phy.flags & PHY_USB_DP_CONCURRENT_MODE)) {
+			writel_relaxed(USB3_MODE | DP_MODE,
+				phy->base +
+				phy->phy_reg[USB3_DP_COM_PHY_MODE_CTRL]);
 
-		/* bring both QMP USB and QMP DP PHYs PCS block out of reset */
-		writel_relaxed(0x00,
-			phy->base + phy->phy_reg[USB3_DP_COM_RESET_OVRD_CTRL]);
+			/* bring both USB and DP PHYs PCS block out of reset */
+			writel_relaxed(0x00,
+				phy->base +
+				phy->phy_reg[USB3_DP_COM_RESET_OVRD_CTRL]);
+		}
 		break;
 	case  USB_PHY_TYPE_USB3_OR_DP:
 		if (val > 0) {
@@ -485,7 +495,8 @@
 	}
 
 	/* perform software reset of PHY common logic */
-	if (phy->phy.type == USB_PHY_TYPE_USB3_AND_DP)
+	if (phy->phy.type == USB_PHY_TYPE_USB3_AND_DP &&
+				!(phy->phy.flags & PHY_USB_DP_CONCURRENT_MODE))
 		writel_relaxed(0x00,
 			phy->base + phy->phy_reg[USB3_DP_COM_SW_RESET]);
 
@@ -523,6 +534,25 @@
 					phy);
 	int ret = 0;
 
+	if (phy->phy.flags & PHY_USB_DP_CONCURRENT_MODE) {
+		dev_dbg(uphy->dev, "Resetting USB part of QMP phy\n");
+
+		/* Assert USB3 PHY CSR reset */
+		ret = reset_control_assert(phy->phy_reset);
+		if (ret) {
+			dev_err(uphy->dev, "phy_reset assert failed\n");
+			goto exit;
+		}
+
+		/* Deassert USB3 PHY CSR reset */
+		ret = reset_control_deassert(phy->phy_reset);
+		if (ret) {
+			dev_err(uphy->dev, "phy_reset deassert failed\n");
+			goto exit;
+		}
+		return 0;
+	}
+
 	dev_dbg(uphy->dev, "Global reset of QMP DP combo phy\n");
 	/* Assert global PHY reset */
 	ret = reset_control_assert(phy->global_phy_reset);
@@ -716,6 +746,49 @@
 	return 0;
 }
 
+static int msm_ssphy_qmp_dp_notifier(struct notifier_block *nb,
+		unsigned long dp_lane, void *ptr)
+{
+	struct msm_ssphy_qmp *phy = container_of(nb,
+			struct msm_ssphy_qmp, dp_nb);
+
+	if (dp_lane == 2 || dp_lane == 4)
+		phy->phy.flags |= PHY_USB_DP_CONCURRENT_MODE;
+	else
+		phy->phy.flags &= ~PHY_USB_DP_CONCURRENT_MODE;
+
+	return 0;
+
+}
+
+static int msm_ssphy_qmp_extcon_register(struct msm_ssphy_qmp *phy,
+				struct device *dev)
+{
+	struct device_node *node = dev->of_node;
+	struct extcon_dev *edev;
+	int ret = 0;
+
+	if (!of_property_read_bool(node, "extcon"))
+		return 0;
+
+	edev = extcon_get_edev_by_phandle(dev, 0);
+	if (IS_ERR(edev)) {
+		dev_err(dev, "failed to get phandle for msm_ssphy_qmp\n");
+		return PTR_ERR(edev);
+	}
+
+	phy->extcon_dp = edev;
+	phy->dp_nb.notifier_call = msm_ssphy_qmp_dp_notifier;
+	ret = extcon_register_blocking_notifier(edev, EXTCON_DISP_DP,
+								&phy->dp_nb);
+	if (ret < 0) {
+		dev_err(dev, "failed to register blocking notifier\n");
+		return ret;
+	}
+
+	return 0;
+}
+
 static int msm_ssphy_qmp_get_clks(struct msm_ssphy_qmp *phy, struct device *dev)
 {
 	int ret = 0;
@@ -1065,6 +1138,10 @@
 	else
 		phy->phy.reset		= msm_ssphy_qmp_reset;
 
+	ret = msm_ssphy_qmp_extcon_register(phy, dev);
+	if (ret)
+		goto err;
+
 	ret = usb_add_phy_dev(&phy->phy);
 
 err:
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 542796a..43e558b 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -4318,7 +4318,7 @@
 	INIT_DELAYED_WORK(&motg->sdp_check, check_for_sdp_connection);
 	INIT_WORK(&motg->notify_charger_work, msm_otg_notify_charger_work);
 	INIT_WORK(&motg->extcon_register_work, msm_otg_extcon_register_work);
-	motg->otg_wq = alloc_ordered_workqueue("k_otg", 0);
+	motg->otg_wq = alloc_ordered_workqueue("k_otg", WQ_FREEZABLE);
 	if (!motg->otg_wq) {
 		pr_err("%s: Unable to create workqueue otg_wq\n",
 			__func__);
diff --git a/drivers/video/fbdev/msm/mdp3_ctrl.c b/drivers/video/fbdev/msm/mdp3_ctrl.c
index 2c32a9f..defec0b 100644
--- a/drivers/video/fbdev/msm/mdp3_ctrl.c
+++ b/drivers/video/fbdev/msm/mdp3_ctrl.c
@@ -2976,14 +2976,17 @@
 		return -ENOMEM;
 	}
 
-	/* Add retire vsync handler */
-	retire_client.handler = mdp3_vsync_retire_handle_vsync;
-	retire_client.arg = mdp3_session;
+	if (mfd->panel_info->type == MIPI_CMD_PANEL) {
+		/* Add retire vsync handler */
+		retire_client.handler = mdp3_vsync_retire_handle_vsync;
+		retire_client.arg = mdp3_session;
 
-	if (mdp3_session->dma)
-		mdp3_session->dma->retire_client = retire_client;
+		if (mdp3_session->dma)
+			mdp3_session->dma->retire_client = retire_client;
 
-	INIT_WORK(&mdp3_session->retire_work, mdp3_vsync_retire_work_handler);
+		INIT_WORK(&mdp3_session->retire_work,
+			mdp3_vsync_retire_work_handler);
+	}
 
 	return 0;
 }
@@ -3162,13 +3165,10 @@
 	mdp3_session->vsync_before_commit = true;
 	mdp3_session->dyn_pu_state = mfd->panel_info->partial_update_enabled;
 
-	if (mfd->panel_info->mipi.dms_mode ||
-			mfd->panel_info->type == MIPI_CMD_PANEL) {
-		rc = mdp3_vsync_retire_setup(mfd);
-		if (IS_ERR_VALUE(rc)) {
-			pr_err("unable to create vsync timeline\n");
-			goto init_done;
-		}
+	rc = mdp3_vsync_retire_setup(mfd);
+	if (IS_ERR_VALUE(rc)) {
+		pr_err("unable to create vsync timeline\n");
+		goto init_done;
 	}
 init_done:
 	if (IS_ERR_VALUE(rc))
diff --git a/fs/crypto/fscrypt_ice.c b/fs/crypto/fscrypt_ice.c
index a76fecf..cd84469 100644
--- a/fs/crypto/fscrypt_ice.c
+++ b/fs/crypto/fscrypt_ice.c
@@ -157,16 +157,29 @@
 }
 EXPORT_SYMBOL(fscrypt_set_ice_dun);
 
+void fscrypt_set_ice_skip(struct bio *bio, int bi_crypt_skip)
+{
+#ifdef CONFIG_DM_DEFAULT_KEY
+	bio->bi_crypt_skip = bi_crypt_skip;
+#endif
+}
+EXPORT_SYMBOL(fscrypt_set_ice_skip);
+
 /*
  * This function will be used for filesystem when deciding to merge bios.
  * Basic assumption is, if inline_encryption is set, single bio has to
  * guarantee consecutive LBAs as well as ino|pg->index.
  */
-bool fscrypt_mergeable_bio(struct bio *bio, u64 dun, bool bio_encrypted)
+bool fscrypt_mergeable_bio(struct bio *bio, u64 dun, bool bio_encrypted,
+						int bi_crypt_skip)
 {
 	if (!bio)
 		return true;
 
+#ifdef CONFIG_DM_DEFAULT_KEY
+	if (bi_crypt_skip != bio->bi_crypt_skip)
+		return false;
+#endif
 	/* if both of them are not encrypted, no further check is needed */
 	if (!bio_dun(bio) && !bio_encrypted)
 		return true;
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 2a4a4fb..f7f2c13 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -450,7 +450,8 @@
 				1, is_read_io(fio->op), fio->type, fio->temp);
 
 	if (f2fs_may_encrypt_bio(inode, fio))
-	fscrypt_set_ice_dun(inode, bio, PG_DUN(inode, fio->page));
+		fscrypt_set_ice_dun(inode, bio, PG_DUN(inode, fio->page));
+	fscrypt_set_ice_skip(bio, fio->encrypted_page ? 1 : 0);
 
 	if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE) {
 		bio_put(bio);
@@ -473,6 +474,7 @@
 	struct page *bio_page;
 	struct inode *inode;
 	bool bio_encrypted;
+	int bi_crypt_skip;
 	u64 dun;
 
 	f2fs_bug_on(sbi, is_read_io(fio->op));
@@ -498,6 +500,7 @@
 	bio_page = fio->encrypted_page ? fio->encrypted_page : fio->page;
 	inode = fio->page->mapping->host;
 	dun = PG_DUN(inode, fio->page);
+	bi_crypt_skip = fio->encrypted_page ? 1 : 0;
 	bio_encrypted = f2fs_may_encrypt_bio(inode, fio);
 
 	/* set submitted = true as a return value */
@@ -511,7 +514,7 @@
 		__submit_merged_bio(io);
 
 	/* ICE support */
-	if (!fscrypt_mergeable_bio(io->bio, dun, bio_encrypted))
+	if (!fscrypt_mergeable_bio(io->bio, dun, bio_encrypted, bi_crypt_skip))
 		__submit_merged_bio(io);
 
 alloc_new:
@@ -527,7 +530,7 @@
 						fio->type, fio->temp);
 		if (bio_encrypted)
 			fscrypt_set_ice_dun(inode, io->bio, dun);
-
+		fscrypt_set_ice_skip(io->bio, bi_crypt_skip);
 		io->fio = *fio;
 	}
 
@@ -1539,7 +1542,7 @@
 
 		dun = PG_DUN(inode, page);
 		bio_encrypted = f2fs_may_encrypt_bio(inode, NULL);
-		if (!fscrypt_mergeable_bio(bio, dun, bio_encrypted)) {
+		if (!fscrypt_mergeable_bio(bio, dun, bio_encrypted, 0)) {
 			__submit_bio(F2FS_I_SB(inode), bio, DATA);
 			bio = NULL;
 		}
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 3c23418b..52e85a0 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1397,6 +1397,8 @@
 	struct discard_policy dpolicy;
 	unsigned int wait_ms = DEF_MIN_DISCARD_ISSUE_TIME;
 	int issued;
+	unsigned long interval = sbi->interval_time[REQ_TIME] * HZ;
+	long delta;
 
 	set_freezable();
 
@@ -1433,7 +1435,11 @@
 			__wait_all_discard_cmd(sbi, &dpolicy);
 			wait_ms = dpolicy.min_interval;
 		} else if (issued == -1){
-			wait_ms = dpolicy.mid_interval;
+			delta = (sbi->last_time[REQ_TIME] + interval) - jiffies;
+			if (delta > 0)
+				wait_ms = jiffies_to_msecs(delta);
+			else
+				wait_ms = dpolicy.mid_interval;
 		} else {
 			wait_ms = dpolicy.max_interval;
 		}
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index 42ad6b5..a149671 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -78,6 +78,9 @@
 	*/
 	struct inode            *bi_dio_inode;
 #endif
+#ifdef CONFIG_DM_DEFAULT_KEY
+	int bi_crypt_skip;
+#endif
 
 	unsigned short		bi_vcnt;	/* how many bio_vec's */
 
diff --git a/include/linux/fscrypt.h b/include/linux/fscrypt.h
index 1e03614..f5371c2 100644
--- a/include/linux/fscrypt.h
+++ b/include/linux/fscrypt.h
@@ -257,7 +257,9 @@
 extern int fscrypt_using_hardware_encryption(const struct inode *inode);
 extern void fscrypt_set_ice_dun(const struct inode *inode,
 	struct bio *bio, u64 dun);
-extern bool fscrypt_mergeable_bio(struct bio *bio, u64 dun, bool bio_encrypted);
+extern bool fscrypt_mergeable_bio(struct bio *bio, u64 dun, bool bio_encrypted,
+		int bi_crypt_skip);
+extern void fscrypt_set_ice_skip(struct bio *bio, int bi_crypt_skip);
 #else
 static inline int fscrypt_using_hardware_encryption(const struct inode *inode)
 {
@@ -270,8 +272,12 @@
 	return;
 }
 
+static inline void fscrypt_set_ice_skip(struct bio *bio, int bi_crypt_skip)
+{
+}
+
 static inline bool fscrypt_mergeable_bio(struct bio *bio,
-	u64 dun, bool bio_encrypted)
+	u64 dun, bool bio_encrypted, int bi_crypt_skip)
 {
 	return true;
 }
diff --git a/include/linux/iio/imu/mpu.h b/include/linux/iio/imu/mpu.h
new file mode 100644
index 0000000..4dbb86c
--- /dev/null
+++ b/include/linux/iio/imu/mpu.h
@@ -0,0 +1,124 @@
+/*
+* Copyright (C) 2012-2017 InvenSense, Inc.
+*
+* This software is licensed under the terms of the GNU General Public
+* License version 2, as published by the Free Software Foundation, and
+* may be copied, distributed, and modified under those terms.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*/
+
+#ifndef __MPU_H_
+#define __MPU_H_
+
+#ifdef __KERNEL__
+#include <linux/types.h>
+#include <linux/ioctl.h>
+#endif
+
+enum secondary_slave_type {
+	SECONDARY_SLAVE_TYPE_NONE,
+	SECONDARY_SLAVE_TYPE_ACCEL,
+	SECONDARY_SLAVE_TYPE_COMPASS,
+	SECONDARY_SLAVE_TYPE_PRESSURE,
+	SECONDARY_SLAVE_TYPE_ALS,
+
+	SECONDARY_SLAVE_TYPE_TYPES
+};
+
+enum ext_slave_id {
+	ID_INVALID = 0,
+	GYRO_ID_MPU3050,
+	GYRO_ID_MPU6050A2,
+	GYRO_ID_MPU6050B1,
+	GYRO_ID_MPU6050B1_NO_ACCEL,
+	GYRO_ID_ITG3500,
+
+	ACCEL_ID_LIS331,
+	ACCEL_ID_LSM303DLX,
+	ACCEL_ID_LIS3DH,
+	ACCEL_ID_KXSD9,
+	ACCEL_ID_KXTF9,
+	ACCEL_ID_BMA150,
+	ACCEL_ID_BMA222,
+	ACCEL_ID_BMA250,
+	ACCEL_ID_ADXL34X,
+	ACCEL_ID_MMA8450,
+	ACCEL_ID_MMA845X,
+	ACCEL_ID_MPU6050,
+
+	COMPASS_ID_AK8963,
+	COMPASS_ID_AK8975,
+	COMPASS_ID_AK8972,
+	COMPASS_ID_AMI30X,
+	COMPASS_ID_AMI306,
+	COMPASS_ID_YAS529,
+	COMPASS_ID_YAS530,
+	COMPASS_ID_HMC5883,
+	COMPASS_ID_LSM303DLH,
+	COMPASS_ID_LSM303DLM,
+	COMPASS_ID_MMC314X,
+	COMPASS_ID_HSCDTD002B,
+	COMPASS_ID_HSCDTD004A,
+	COMPASS_ID_MLX90399,
+	COMPASS_ID_AK09911,
+	COMPASS_ID_AK09912,
+	COMPASS_ID_AK09916,
+
+	PRESSURE_ID_BMP085,
+	PRESSURE_ID_BMP280,
+
+	ALS_ID_APDS_9900,
+	ALS_ID_APDS_9930,
+	ALS_ID_TSL_2772,
+};
+
+#define INV_PROD_KEY(ver, rev) (ver * 100 + rev)
+/**
+ * struct mpu_platform_data - Platform data for the mpu driver
+ * @int_config:		Bits [7:3] of the int config register.
+ * @level_shifter:	0: VLogic, 1: VDD
+ * @orientation:	Orientation matrix of the gyroscope
+ * @sec_slave_type:     secondary slave device type, can be compass, accel, etc
+ * @sec_slave_id:       id of the secondary slave device
+ * @secondary_i2c_address: secondary device's i2c address
+ * @secondary_orientation: secondary device's orientation matrix
+ * @aux_slave_type: auxiliary slave. Another slave device type
+ * @aux_slave_id: auxiliary slave ID.
+ * @aux_i2c_addr: auxiliary device I2C address.
+ * @read_only_slave_type: read only slave type.
+ * @read_only_slave_id: read only slave device ID.
+ * @read_only_i2c_addr: read only slave device address.
+ *
+ * Contains platform specific information on how to configure the MPU3050 to
+ * work on this platform.  The orientation matricies are 3x3 rotation matricies
+ * that are applied to the data to rotate from the mounting orientation to the
+ * platform orientation.  The values must be one of 0, 1, or -1 and each row and
+ * column should have exactly 1 non-zero value.
+ */
+struct mpu_platform_data {
+	__u8 int_config;
+	__u8 level_shifter;
+	__s8 orientation[9];
+	enum secondary_slave_type sec_slave_type;
+	enum ext_slave_id sec_slave_id;
+	__u16 secondary_i2c_addr;
+	__s8 secondary_orientation[9];
+	enum secondary_slave_type aux_slave_type;
+	enum ext_slave_id aux_slave_id;
+	__u16 aux_i2c_addr;
+	enum secondary_slave_type read_only_slave_type;
+	enum ext_slave_id read_only_slave_id;
+	__u16 read_only_i2c_addr;
+#ifdef CONFIG_OF
+	int (*power_on)(struct mpu_platform_data *);
+	int (*power_off)(struct mpu_platform_data *);
+	struct regulator *vdd_ana;
+	struct regulator *vdd_i2c;
+#endif
+};
+
+#endif	/* __MPU_H_ */
diff --git a/include/linux/qpnp/qpnp-adc.h b/include/linux/qpnp/qpnp-adc.h
index 48fe2e9..770cd64 100644
--- a/include/linux/qpnp/qpnp-adc.h
+++ b/include/linux/qpnp/qpnp-adc.h
@@ -455,6 +455,7 @@
 	SCALE_R_ABSOLUTE,
 	SCALE_QRD_SKUH_RBATT_THERM,
 	SCALE_QRD_SKUT1_RBATT_THERM,
+	SCALE_QRD_215_RBATT_THERM,
 	SCALE_RSCALE_NONE,
 };
 
@@ -1888,6 +1889,22 @@
 		struct qpnp_adc_tm_btm_param *param,
 		uint32_t *low_threshold, uint32_t *high_threshold);
 /**
+ * qpnp_adc_qrd_215_btm_scaler() - Performs reverse calibration on the
+ *		low/high temperature threshold values passed by the client.
+ *		The function maps the temperature to voltage and applies
+ *		ratiometric calibration on the voltage values for SKUT1 board.
+ * @dev:	Structure device for qpnp vadc
+ * @param:	The input parameters that contain the low/high temperature
+ *		values.
+ * @low_threshold: The low threshold value that needs to be updated with
+ *		the above calibrated voltage value.
+ * @high_threshold: The low threshold value that needs to be updated with
+ *		the above calibrated voltage value.
+ */
+int32_t qpnp_adc_qrd_215_btm_scaler(struct qpnp_vadc_chip *dev,
+		struct qpnp_adc_tm_btm_param *param,
+		uint32_t *low_threshold, uint32_t *high_threshold);
+/**
  * qpnp_adc_tm_scale_therm_voltage_pu2() - Performs reverse calibration
  *		and convert given temperature to voltage on supported
  *		thermistor channels using 100k pull-up.
@@ -2279,6 +2296,10 @@
 		struct qpnp_adc_tm_btm_param *param,
 		uint32_t *low_threshold, uint32_t *high_threshold)
 { return -ENXIO; }
+static inline int32_t qpnp_adc_qrd_215_btm_scaler(struct qpnp_vadc_chip *dev,
+		struct qpnp_adc_tm_btm_param *param,
+		uint32_t *low_threshold, uint32_t *high_threshold)
+{ return -ENXIO; }
 static inline int32_t qpnp_adc_scale_millidegc_pmic_voltage_thr(
 		struct qpnp_vadc_chip *dev,
 		struct qpnp_adc_tm_btm_param *param,
diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
index d999b3c..4caac13 100644
--- a/include/linux/usb/phy.h
+++ b/include/linux/usb/phy.h
@@ -22,6 +22,7 @@
 #define PHY_LANE_B		BIT(7)
 #define PHY_HSFS_MODE		BIT(8)
 #define PHY_LS_MODE		BIT(9)
+#define PHY_USB_DP_CONCURRENT_MODE	BIT(10)
 
 enum usb_phy_interface {
 	USBPHY_INTERFACE_MODE_UNKNOWN,
diff --git a/include/net/cnss2.h b/include/net/cnss2.h
index a99f10a..4e86755 100644
--- a/include/net/cnss2.h
+++ b/include/net/cnss2.h
@@ -115,6 +115,11 @@
 	u32 addr;
 };
 
+struct cnss_rri_over_ddr_cfg {
+	u32 base_addr_low;
+	u32 base_addr_high;
+};
+
 struct cnss_wlan_enable_cfg {
 	u32 num_ce_tgt_cfg;
 	struct cnss_ce_tgt_pipe_cfg *ce_tgt_cfg;
@@ -124,6 +129,8 @@
 	struct cnss_shadow_reg_cfg *shadow_reg_cfg;
 	u32 num_shadow_reg_v2_cfg;
 	struct cnss_shadow_reg_v2_cfg *shadow_reg_v2_cfg;
+	bool rri_over_ddr_cfg_valid;
+	struct cnss_rri_over_ddr_cfg rri_over_ddr_cfg;
 };
 
 enum cnss_driver_mode {
diff --git a/include/soc/qcom/minidump.h b/include/soc/qcom/minidump.h
index 5c751e8..0d43e14 100644
--- a/include/soc/qcom/minidump.h
+++ b/include/soc/qcom/minidump.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2017-18 The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -30,13 +30,22 @@
 	u64	size;
 };
 
-/* Register an entry in Minidump table
- * Returns:
- *	Zero: on successful addition
- *	Negetive error number on failures
- */
 #ifdef CONFIG_QCOM_MINIDUMP
+/*
+ * Register an entry in Minidump table
+ * Returns:
+ *	region number: entry position in minidump table.
+ *	Negetive error number on failures.
+ */
 extern int msm_minidump_add_region(const struct md_region *entry);
+/*
+ * Update registered region address in Minidump table.
+ * It does not hold any locks, so strictly serialize the region updates.
+ * Returns:
+ *	Zero: on successfully update
+ *	Negetive error number on failures.
+ */
+extern int msm_minidump_update_region(int regno, const struct md_region *entry);
 extern bool msm_minidump_enabled(void);
 extern void dump_stack_minidump(u64 sp);
 #else
diff --git a/include/soc/qcom/socinfo.h b/include/soc/qcom/socinfo.h
index e6259bc..c7dcf36 100644
--- a/include/soc/qcom/socinfo.h
+++ b/include/soc/qcom/socinfo.h
@@ -120,6 +120,8 @@
 	of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,msm8937")
 #define early_machine_is_msm8917()	\
 	of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,msm8917")
+#define early_machine_is_msm8940()	\
+	of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,msm8940")
 #define early_machine_is_mdm9607()      \
 	of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,mdm9607")
 #define early_machine_is_sdm450()	\
@@ -189,6 +191,7 @@
 #define early_machine_is_msm8953()	0
 #define early_machine_is_msm8937()	0
 #define early_machine_is_msm8917()	0
+#define early_machine_is_msm8940()	0
 #define early_machine_is_sdm450()	0
 #define early_machine_is_sda450()	0
 #define early_machine_is_sdm632()	0
@@ -273,6 +276,7 @@
 	MSM_CPU_SDA632,
 	MSM_CPU_8937,
 	MSM_CPU_8917,
+	MSM_CPU_8940,
 	MSM_CPU_9607,
 	MSM_CPU_SDM439,
 	MSM_CPU_SDMNOBELIUM,
diff --git a/include/uapi/linux/msm_ipa.h b/include/uapi/linux/msm_ipa.h
index 6cbc689..11d277f 100644
--- a/include/uapi/linux/msm_ipa.h
+++ b/include/uapi/linux/msm_ipa.h
@@ -176,6 +176,7 @@
 #define IPA_FLT_TCP_SYN_L2TP		(1ul << 24)
 #define IPA_FLT_L2TP_INNER_IP_TYPE  (1ul << 25)
 #define IPA_FLT_L2TP_INNER_IPV4_DST_ADDR (1ul << 26)
+#define IPA_FLT_IS_PURE_ACK		(1ul << 27)
 
 /**
  * maximal number of NAT PDNs in the PDN config table
diff --git a/include/uapi/linux/msm_kgsl.h b/include/uapi/linux/msm_kgsl.h
index 8ffef59..96053c6 100644
--- a/include/uapi/linux/msm_kgsl.h
+++ b/include/uapi/linux/msm_kgsl.h
@@ -65,6 +65,7 @@
 #define KGSL_CONTEXT_TYPE_CL		2
 #define KGSL_CONTEXT_TYPE_C2D		3
 #define KGSL_CONTEXT_TYPE_RS		4
+#define KGSL_CONTEXT_TYPE_VK		5
 #define KGSL_CONTEXT_TYPE_UNKNOWN	0x1E
 
 #define KGSL_CONTEXT_INVALIDATE_ON_FAULT 0x10000000
diff --git a/include/uapi/media/cam_req_mgr.h b/include/uapi/media/cam_req_mgr.h
index 841c40a..ae65649 100644
--- a/include/uapi/media/cam_req_mgr.h
+++ b/include/uapi/media/cam_req_mgr.h
@@ -262,6 +262,9 @@
 	((idx & CAM_MEM_MGR_HDL_IDX_MASK) | \
 	(fd << (CAM_MEM_MGR_HDL_FD_END_POS - CAM_MEM_MGR_HDL_FD_SIZE))) \
 
+#define GET_FD_FROM_HANDLE(hdl) \
+	(hdl >> (CAM_MEM_MGR_HDL_FD_END_POS - CAM_MEM_MGR_HDL_FD_SIZE)) \
+
 #define CAM_MEM_MGR_GET_HDL_IDX(hdl) (hdl & CAM_MEM_MGR_HDL_IDX_MASK)
 
 #define CAM_MEM_MGR_SET_SECURE_HDL(hdl, flag) \
diff --git a/include/uapi/media/msmb_isp.h b/include/uapi/media/msmb_isp.h
index 74a8d93..271a731 100644
--- a/include/uapi/media/msmb_isp.h
+++ b/include/uapi/media/msmb_isp.h
@@ -26,9 +26,16 @@
 #define ISP_STATS_STREAM_BIT  0x80000000
 
 #define VFE_HW_LIMIT 1
+#define ISP_KERNEL_STATE 1
 
 struct msm_vfe_cfg_cmd_list;
 
+struct isp_kstate {
+	uint32_t kernel_sofid;
+	uint32_t drop_reconfig;
+	uint32_t vfeid;
+};
+
 enum ISP_START_PIXEL_PATTERN {
 	ISP_BAYER_RGRGRG,
 	ISP_BAYER_GRGRGR,
diff --git a/kernel/trace/msm_rtb.c b/kernel/trace/msm_rtb.c
index d3bcd5c..6979bf0 100644
--- a/kernel/trace/msm_rtb.c
+++ b/kernel/trace/msm_rtb.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -299,7 +299,7 @@
 	md_entry.virt_addr = (uintptr_t)msm_rtb.rtb;
 	md_entry.phys_addr = msm_rtb.phys;
 	md_entry.size = msm_rtb.size;
-	if (msm_minidump_add_region(&md_entry))
+	if (msm_minidump_add_region(&md_entry) < 0)
 		pr_info("Failed to add RTB in Minidump\n");
 
 #if defined(CONFIG_QCOM_RTB_SEPARATE_CPUS)
diff --git a/mm/swap_state.c b/mm/swap_state.c
index 35f882d..2fcc719 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -17,6 +17,7 @@
 #include <linux/blkdev.h>
 #include <linux/pagevec.h>
 #include <linux/migrate.h>
+#include <linux/delay.h>
 
 #include <asm/pgtable.h>
 
@@ -350,8 +351,11 @@
 			 * busy looping, we just conditionally invoke the
 			 * scheduler here, if there are some more important
 			 * tasks to run.
+			 *
+			 * cond_resched() may not work if the process is RT.
+			 * We need a usleep_range() give up CPU to another task.
 			 */
-			cond_resched();
+			usleep_range(500, 1000);
 			continue;
 		}
 		if (err) {		/* swp entry is obsolete ? */
diff --git a/mm/util.c b/mm/util.c
index 8c755d0..6296de0 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -576,6 +576,13 @@
 		free += global_page_state(NR_SLAB_RECLAIMABLE);
 
 		/*
+		 * Part of the kernel memory, which can be released
+		 * under memory pressure.
+		 */
+		free += global_node_page_state(
+			NR_INDIRECTLY_RECLAIMABLE_BYTES) >> PAGE_SHIFT;
+
+		/*
 		 * Leave reserved pages. The pages are not for anonymous pages.
 		 */
 		if (free <= totalreserve_pages)
diff --git a/net/key/af_key.c b/net/key/af_key.c
index 3ba903f..58c045d 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -196,30 +196,22 @@
 	return 0;
 }
 
-static int pfkey_broadcast_one(struct sk_buff *skb, struct sk_buff **skb2,
-			       gfp_t allocation, struct sock *sk)
+static int pfkey_broadcast_one(struct sk_buff *skb, gfp_t allocation,
+			       struct sock *sk)
 {
 	int err = -ENOBUFS;
 
-	sock_hold(sk);
-	if (*skb2 == NULL) {
-		if (atomic_read(&skb->users) != 1) {
-			*skb2 = skb_clone(skb, allocation);
-		} else {
-			*skb2 = skb;
-			atomic_inc(&skb->users);
-		}
+	if (atomic_read(&sk->sk_rmem_alloc) > sk->sk_rcvbuf)
+		return err;
+
+	skb = skb_clone(skb, allocation);
+
+	if (skb) {
+		skb_set_owner_r(skb, sk);
+		skb_queue_tail(&sk->sk_receive_queue, skb);
+		sk->sk_data_ready(sk);
+		err = 0;
 	}
-	if (*skb2 != NULL) {
-		if (atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf) {
-			skb_set_owner_r(*skb2, sk);
-			skb_queue_tail(&sk->sk_receive_queue, *skb2);
-			sk->sk_data_ready(sk);
-			*skb2 = NULL;
-			err = 0;
-		}
-	}
-	sock_put(sk);
 	return err;
 }
 
@@ -234,7 +226,6 @@
 {
 	struct netns_pfkey *net_pfkey = net_generic(net, pfkey_net_id);
 	struct sock *sk;
-	struct sk_buff *skb2 = NULL;
 	int err = -ESRCH;
 
 	/* XXX Do we need something like netlink_overrun?  I think
@@ -253,7 +244,7 @@
 		 * socket.
 		 */
 		if (pfk->promisc)
-			pfkey_broadcast_one(skb, &skb2, GFP_ATOMIC, sk);
+			pfkey_broadcast_one(skb, GFP_ATOMIC, sk);
 
 		/* the exact target will be processed later */
 		if (sk == one_sk)
@@ -268,7 +259,7 @@
 				continue;
 		}
 
-		err2 = pfkey_broadcast_one(skb, &skb2, GFP_ATOMIC, sk);
+		err2 = pfkey_broadcast_one(skb, GFP_ATOMIC, sk);
 
 		/* Error is cleared after successful sending to at least one
 		 * registered KM */
@@ -278,9 +269,8 @@
 	rcu_read_unlock();
 
 	if (one_sk != NULL)
-		err = pfkey_broadcast_one(skb, &skb2, allocation, one_sk);
+		err = pfkey_broadcast_one(skb, allocation, one_sk);
 
-	kfree_skb(skb2);
 	kfree_skb(skb);
 	return err;
 }
diff --git a/net/wireless/db.txt b/net/wireless/db.txt
index 38fbe09..29544de 100644
--- a/net/wireless/db.txt
+++ b/net/wireless/db.txt
@@ -755,6 +755,10 @@
 	(5490 - 5730 @ 160), (30), DFS
 	(5735 - 5875 @ 80), (14)
 
+country MM:
+	(2402 - 2482 @ 40), (20)
+	(5735 - 5835 @ 80), (30)
+
 country MN: DFS-FCC
 	(2402 - 2482 @ 40), (20)
 	(5170 - 5250 @ 80), (24), AUTO-BW
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 773c66b..272edad 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -1406,6 +1406,9 @@
 		    (ut[i].family != prev_family))
 			return -EINVAL;
 
+		if (ut[i].mode >= XFRM_MODE_MAX)
+			return -EINVAL;
+
 		prev_family = ut[i].family;
 
 		switch (ut[i].family) {
diff --git a/security/pfe/pfk.c b/security/pfe/pfk.c
index f9a6292..8b0b9ce 100644
--- a/security/pfe/pfk.c
+++ b/security/pfe/pfk.c
@@ -76,7 +76,6 @@
 	struct pfk_key_info *key_info,
 	enum ice_cryto_algo_mode *algo,
 	bool *is_pfe,
-	unsigned int *data_unit,
 	const char *storage_type);
 
 typedef bool (*pfk_allow_merge_bio_type)(const struct bio *bio1,
@@ -287,27 +286,33 @@
 {
 	const struct inode *inode;
 	enum pfe_type which_pfe;
-	const struct blk_encryption_key *key;
 	char *s_type = NULL;
+	const struct blk_encryption_key *key = NULL;
 
 	inode = pfk_bio_get_inode(bio);
 	which_pfe = pfk_get_pfe_type(inode);
 	s_type = (char *)pfk_kc_get_storage_type();
 
+	if (data_unit && (bio_dun(bio) ||
+			!memcmp(s_type, "ufs", strlen("ufs"))))
+		*data_unit = 1 << ICE_CRYPTO_DATA_UNIT_4_KB;
+
 	if (which_pfe != INVALID_PFE) {
 		/* Encrypted file; override ->bi_crypt_key */
 		pr_debug("parsing inode %lu with PFE type %d\n",
 			 inode->i_ino, which_pfe);
 		return (*(pfk_parse_inode_ftable[which_pfe]))
 				(bio, inode, key_info, algo_mode, is_pfe,
-					data_unit, (const char *)s_type);
+					(const char *)s_type);
 	}
 
 	/*
 	 * bio is not for an encrypted file.  Use ->bi_crypt_key if it was set.
 	 * Otherwise, don't encrypt/decrypt the bio.
 	 */
+#ifdef CONFIG_DM_DEFAULT_KEY
 	key = bio->bi_crypt_key;
+#endif
 	if (!key) {
 		*is_pfe = false;
 		return -EINVAL;
@@ -469,13 +474,18 @@
  */
 bool pfk_allow_merge_bio(const struct bio *bio1, const struct bio *bio2)
 {
-	const struct blk_encryption_key *key1;
-	const struct blk_encryption_key *key2;
+	const struct blk_encryption_key *key1 = NULL;
+	const struct blk_encryption_key *key2 = NULL;
 	const struct inode *inode1;
 	const struct inode *inode2;
 	enum pfe_type which_pfe1;
 	enum pfe_type which_pfe2;
 
+#ifdef CONFIG_DM_DEFAULT_KEY
+	key1 = bio1->bi_crypt_key;
+	key2 = bio2->bi_crypt_key;
+#endif
+
 	if (!pfk_is_ready())
 		return false;
 
diff --git a/security/pfe/pfk_ext4.c b/security/pfe/pfk_ext4.c
index 7000b66..6d3cd4c 100644
--- a/security/pfe/pfk_ext4.c
+++ b/security/pfe/pfk_ext4.c
@@ -142,7 +142,6 @@
 	struct pfk_key_info *key_info,
 	enum ice_cryto_algo_mode *algo,
 	bool *is_pfe,
-	unsigned int *data_unit,
 	const char *storage_type)
 {
 	int ret = 0;
@@ -157,19 +156,6 @@
 	 */
 	*is_pfe = true;
 
-	/* Update dun based upon storage type.
-	 * For ext4 FS UFS has 4k dun whereas eMMC
-	 * uses 512Byte dun.
-	 */
-	if (storage_type && data_unit) {
-		if (!memcmp(storage_type, "ufs", strlen("ufs")))
-			*data_unit = 1 << ICE_CRYPTO_DATA_UNIT_4_KB;
-		else if (!memcmp(storage_type, "sdcc", strlen("sdcc")))
-			*data_unit = 1 << ICE_CRYPTO_DATA_UNIT_512_B;
-		else
-			return -EINVAL;
-	}
-
 	if (!pfk_ext4_is_ready())
 		return -ENODEV;
 
diff --git a/security/pfe/pfk_ext4.h b/security/pfe/pfk_ext4.h
index e39d04d..346027b 100644
--- a/security/pfe/pfk_ext4.h
+++ b/security/pfe/pfk_ext4.h
@@ -25,7 +25,6 @@
 	struct pfk_key_info *key_info,
 	enum ice_cryto_algo_mode *algo,
 	bool *is_pfe,
-	unsigned int *data_unit,
 	const char *storage_type);
 
 bool pfk_ext4_allow_merge_bio(const struct bio *bio1,
diff --git a/security/pfe/pfk_f2fs.c b/security/pfe/pfk_f2fs.c
index 2076267..9523c35 100644
--- a/security/pfe/pfk_f2fs.c
+++ b/security/pfe/pfk_f2fs.c
@@ -117,7 +117,6 @@
 		struct pfk_key_info *key_info,
 		enum ice_cryto_algo_mode *algo,
 		bool *is_pfe,
-		unsigned int *data_unit,
 		const char *storage_type)
 {
 	int ret = 0;
@@ -132,18 +131,6 @@
 	 */
 	*is_pfe = true;
 
-	/* Update the dun based upon storage type.
-	 * Right now both UFS and eMMC storage uses 4KB dun
-	 * for F2FS
-	 */
-	if (storage_type && data_unit) {
-		if (!memcmp(storage_type, "ufs", strlen("ufs")) ||
-			!memcmp(storage_type, "sdcc", strlen("sdcc")))
-			*data_unit = 1 << ICE_CRYPTO_DATA_UNIT_4_KB;
-		else
-			return -EINVAL;
-	}
-
 	if (!pfk_f2fs_is_ready())
 		return -ENODEV;
 
diff --git a/security/pfe/pfk_f2fs.h b/security/pfe/pfk_f2fs.h
index 2e0c21d..1b00bd8 100644
--- a/security/pfe/pfk_f2fs.h
+++ b/security/pfe/pfk_f2fs.h
@@ -25,7 +25,6 @@
 		struct pfk_key_info *key_info,
 		enum ice_cryto_algo_mode *algo,
 		bool *is_pfe,
-		unsigned int *data_unit,
 		const char *storage_type);
 
 bool pfk_f2fs_allow_merge_bio(const struct bio *bio1,