Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: drivers/tpm/slb9635_i2c/compatibility.h

Issue 6683023: Add Infineon v05 TPM driver (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/u-boot-next.git@chromeos-v2010.09
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /*******************************************************************************
2 **
3 ** FILENAME: $Id$
4 ** COPYRIGHT: Infineon Technologies
5 ** DESCRIPTION: I2C TPM - Compatibility layer to port linux driver to U-Boot
6 ** CREATION DATE: 2010/11/10
7 ** LAST CHANGE: $Date: 2010-10-20 12:04:48 +0200 (Wed, 20 Oct 2010) $
8 ** $Author$
9 ** VERSION: $Revision: 59 $
10 **
11 *******************************************************************************/
12
13 #ifndef _COMPATIBILITY_H_
14 #define _COMPATIBILITY_H_
15
16 /* all includes from U-Boot */
17 #include <linux/types.h>
18 #include <asm-generic/errno.h>
19 #include <compiler.h>
20 #include <common.h>
21
22 /* extended error numbers from linux (see errno.h) */
23 #define ECANCELED 125 /* Operation Canceled */
24
25 /* simple version, original from drivers/base/base.h */
26 struct device_private {
27 void *driver_data;
28 };
29
30 /* simple version, original from include/linux/device.h */
31 struct device {
32 struct device *parent;
33 struct device_private *p;
34 void (*release) (struct device *dev);
35 };
36
37 /*
38 * Timing concept in u-boot driver
39 * - jiffies is a global variable similar to linux
40 * - instead of sleeping msleep causes delay
41 * - jiffies is incremented inside msleep
42 * - conversion macros are available (not all conditions work)
43 * - tpm driver remains unchanged
44 *
45 * Conversion: 1 jiffie = 1/HZ seconds
46 * 1 second = HZ jiffies
47 *
48 * NOTE: linux kernel configuration for ARM sets HZ to 128,
49 * timeconst.h then contains automatically generated values for
50 * arithmetics.
51 */
52 /* global timing value */
53 extern unsigned long jiffies;
54
55 /* conversion functions */
56 extern void msleep(unsigned int t);
57 extern void msleep2(unsigned int t);
58 extern unsigned long usecs_to_jiffies(const unsigned int u);
59 extern unsigned long msecs_to_jiffies(const unsigned int u);
60
61 #define HZ 1000
62
63 /* helper macros */
64 #define typecheck(type, x) \
65 ({ type __dummy; \
66 typeof(x) __dummy2; \
67 (void)(&__dummy == &__dummy2); \
Che-Liang Chiou 2011/03/14 08:49:54 Is it void or void*?
rongchang 2011/03/23 11:44:57 This file is provided by Infineon. Hence will be k
68 1; \
Che-Liang Chiou 2011/03/14 08:49:54 Does this mean typecheck() alway be evaluated to 1
rongchang 2011/03/23 11:44:57 Same as above.
69 })
70
71 /* time relation ships */
72 #define time_after(a, b) \
73 (typecheck(unsigned long, a) && \
74 typecheck(unsigned long, b) && \
75 ((long)(b) - (long)(a) < 0))
Che-Liang Chiou 2011/03/14 08:49:54 Why not ((unsigned long)(b) < (unsigned long)(c))
rongchang 2011/03/23 11:44:57 Same as above.
76 #define time_before(a, b) time_after(b, a)
77
78 /* XXX Currently, an open issue with the cortex-a8 data abort trap
79 * prevents us from using the be32_to_cpu macros. Non-aligned data
80 * accesses hang-up program. Casting from 8- to 32-bit pointer is not
81 * working.
82 */
83 static inline u32 switch_endian32(const u8 *buf)
84 {
85 return (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | (buf[3]);
86 }
87
88 #if defined(DEBUG)
89 # define dev_dbg(dev, format, arg...) printf(format, ##arg)
90 #else
91 # define dev_dbg(dev, format, arg...) while (0);
92 #endif
93 #define dev_err(dev, format, arg...) printf(format, ##arg)
94 #define dev_info(dev, format, arg...) printf(format, ##arg)
95
96 #if defined(DEBUG)
97 # define dbg_printf(fmt, arg...) printf(fmt, ##arg)
98 #else
99 # define dbg_printf(fmt, arg...) while (0);
100 #endif
101
102 /* dummy for export */
103 #define EXPORT_SYMBOL_GPL(x)
104
105 #define module_init(x)
106 #define module_exit(x)
107 #define MODULE_AUTHOR(x)
108 #define MODULE_DESCRIPTION(x)
109 #define MODULE_VERSION(x)
110 #define MODULE_LICENSE(x)
111
112 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698