dt-binding: add header to define types and conversion
Laxman Dewangan [Tue, 31 Dec 2013 10:25:23 +0000 (15:25 +0530)]
Add a header file to define the macros for type conversion
to be used by DTS file.

Add macro for the S32 to U32 conversion by using 2's complement.

Change-Id: Ia788e50b916b24c350293af4fef41efd25beba11
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: http://git-master/r/350994
Reviewed-by: Kerwin Wan <kerwinw@nvidia.com>

include/dt-bindings/types.h [new file with mode: 0644]

diff --git a/include/dt-bindings/types.h b/include/dt-bindings/types.h
new file mode 100644 (file)
index 0000000..d91fcae
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * This header provides macros for different types and conversions
+ */
+
+#ifndef _DT_BINDINGS_TYPES_H_
+#define _DT_BINDINGS_TYPES_H_
+
+/*
+ * S32_TO_U32: This macro converts the signed number to 2's complement
+ * unisgned number. E.g. S32_TO_U32(-3) will be 0xfffffffd and
+ * S32_TO_U32(3) will be 0x3;
+ * Use of_property_read_s32() for getting back the correct signed value
+ * in driver.
+ */
+#define S32_TO_U32(x) (((x) < 0) ? (((-(x)) ^ 0xFFFFFFFFU) + 1) : (x))
+
+#endif
+