Chromium Code Reviews| Index: drivers/tpm/slb9635_i2c/compatibility.h |
| diff --git a/drivers/tpm/slb9635_i2c/compatibility.h b/drivers/tpm/slb9635_i2c/compatibility.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ae2cebbda2442fc9c714a49a9e884c13fa44d7b5 |
| --- /dev/null |
| +++ b/drivers/tpm/slb9635_i2c/compatibility.h |
| @@ -0,0 +1,112 @@ |
| +/******************************************************************************* |
| +** |
| +** FILENAME: $Id$ |
| +** COPYRIGHT: Infineon Technologies |
| +** DESCRIPTION: I2C TPM - Compatibility layer to port linux driver to U-Boot |
| +** CREATION DATE: 2010/11/10 |
| +** LAST CHANGE: $Date: 2010-10-20 12:04:48 +0200 (Wed, 20 Oct 2010) $ |
| +** $Author$ |
| +** VERSION: $Revision: 59 $ |
| +** |
| +*******************************************************************************/ |
| + |
| +#ifndef _COMPATIBILITY_H_ |
| +#define _COMPATIBILITY_H_ |
| + |
| +/* all includes from U-Boot */ |
| +#include <linux/types.h> |
| +#include <asm-generic/errno.h> |
| +#include <compiler.h> |
| +#include <common.h> |
| + |
| +/* extended error numbers from linux (see errno.h) */ |
| +#define ECANCELED 125 /* Operation Canceled */ |
| + |
| +/* simple version, original from drivers/base/base.h */ |
| +struct device_private { |
| + void *driver_data; |
| +}; |
| + |
| +/* simple version, original from include/linux/device.h */ |
| +struct device { |
| + struct device *parent; |
| + struct device_private *p; |
| + void (*release) (struct device *dev); |
| +}; |
| + |
| +/* |
| + * Timing concept in u-boot driver |
| + * - jiffies is a global variable similar to linux |
| + * - instead of sleeping msleep causes delay |
| + * - jiffies is incremented inside msleep |
| + * - conversion macros are available (not all conditions work) |
| + * - tpm driver remains unchanged |
| + * |
| + * Conversion: 1 jiffie = 1/HZ seconds |
| + * 1 second = HZ jiffies |
| + * |
| + * NOTE: linux kernel configuration for ARM sets HZ to 128, |
| + * timeconst.h then contains automatically generated values for |
| + * arithmetics. |
| + */ |
| +/* global timing value */ |
| +extern unsigned long jiffies; |
| + |
| +/* conversion functions */ |
| +extern void msleep(unsigned int t); |
| +extern void msleep2(unsigned int t); |
| +extern unsigned long usecs_to_jiffies(const unsigned int u); |
| +extern unsigned long msecs_to_jiffies(const unsigned int u); |
| + |
| +#define HZ 1000 |
| + |
| +/* helper macros */ |
| +#define typecheck(type, x) \ |
| +({ type __dummy; \ |
| + typeof(x) __dummy2; \ |
| + (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
|
| + 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.
|
| +}) |
| + |
| +/* time relation ships */ |
| +#define time_after(a, b) \ |
| + (typecheck(unsigned long, a) && \ |
| + typecheck(unsigned long, b) && \ |
| + ((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.
|
| +#define time_before(a, b) time_after(b, a) |
| + |
| +/* XXX Currently, an open issue with the cortex-a8 data abort trap |
| + * prevents us from using the be32_to_cpu macros. Non-aligned data |
| + * accesses hang-up program. Casting from 8- to 32-bit pointer is not |
| + * working. |
| + */ |
| +static inline u32 switch_endian32(const u8 *buf) |
| +{ |
| + return (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | (buf[3]); |
| +} |
| + |
| +#if defined(DEBUG) |
| +# define dev_dbg(dev, format, arg...) printf(format, ##arg) |
| +#else |
| +# define dev_dbg(dev, format, arg...) while (0); |
| +#endif |
| +#define dev_err(dev, format, arg...) printf(format, ##arg) |
| +#define dev_info(dev, format, arg...) printf(format, ##arg) |
| + |
| +#if defined(DEBUG) |
| +# define dbg_printf(fmt, arg...) printf(fmt, ##arg) |
| +#else |
| +# define dbg_printf(fmt, arg...) while (0); |
| +#endif |
| + |
| +/* dummy for export */ |
| +#define EXPORT_SYMBOL_GPL(x) |
| + |
| +#define module_init(x) |
| +#define module_exit(x) |
| +#define MODULE_AUTHOR(x) |
| +#define MODULE_DESCRIPTION(x) |
| +#define MODULE_VERSION(x) |
| +#define MODULE_LICENSE(x) |
| + |
| +#endif |