Changeset View
Changeset View
Standalone View
Standalone View
head/sys/arm/include/platformvar.h
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | |||||
* }; | * }; | ||||
* | * | ||||
* PLATFORM_DEF(bcm2835_platform); | * PLATFORM_DEF(bcm2835_platform); | ||||
*/ | */ | ||||
#include <sys/kobj.h> | #include <sys/kobj.h> | ||||
#include <sys/linker_set.h> | #include <sys/linker_set.h> | ||||
struct platform_class { | |||||
KOBJ_CLASS_FIELDS; | |||||
/* How many times to loop to delay approximately 1us */ | |||||
int delay_count; | |||||
}; | |||||
struct platform_kobj { | struct platform_kobj { | ||||
/* | /* | ||||
* A platform instance is a kernel object | * A platform instance is a kernel object | ||||
*/ | */ | ||||
KOBJ_FIELDS; | KOBJ_FIELDS; | ||||
/* Platform class, for access to class specific data */ | /* Platform class, for access to class specific data */ | ||||
struct kobj_class *cls; | struct platform_class *cls; | ||||
}; | }; | ||||
struct platform_data { | |||||
int delay_count; | |||||
}; | |||||
typedef struct platform_kobj *platform_t; | typedef struct platform_kobj *platform_t; | ||||
typedef struct kobj_class platform_def_t; | typedef struct platform_class platform_def_t; | ||||
#define platform_method_t kobj_method_t | #define platform_method_t kobj_method_t | ||||
#define PLATFORMMETHOD KOBJMETHOD | #define PLATFORMMETHOD KOBJMETHOD | ||||
#define PLATFORMMETHOD_END KOBJMETHOD_END | #define PLATFORMMETHOD_END KOBJMETHOD_END | ||||
#define PLATFORM_DEF(name) DATA_SET(platform_set, name) | #define PLATFORM_DEF(name) DATA_SET(platform_set, name) | ||||
#ifdef FDT | #ifdef FDT | ||||
struct fdt_platform_class { | struct fdt_platform_class { | ||||
KOBJ_CLASS_FIELDS; | KOBJ_CLASS_FIELDS; | ||||
const char *fdt_compatible; | const char *fdt_compatible; | ||||
}; | }; | ||||
typedef struct fdt_platform_class fdt_platform_def_t; | typedef struct fdt_platform_class fdt_platform_def_t; | ||||
extern platform_method_t fdt_platform_methods[]; | extern platform_method_t fdt_platform_methods[]; | ||||
#define FDT_PLATFORM_DEF2(NAME, VAR_NAME, NAME_STR, size, compatible) \ | #ifdef MULTIDELAY | ||||
#define FDT_PLATFORM_CTASSERT(delay) CTASSERT(delay > 0) | |||||
#else | |||||
#define FDT_PLATFORM_CTASSERT(delay) CTASSERT(delay == 0) | |||||
#endif | |||||
#define PLATFORM_DATA(NAME, delay) \ | |||||
static struct platform_data NAME ## _platc = { \ | |||||
.delay_count = delay; \ | |||||
}; | |||||
#define FDT_PLATFORM_DEF2(NAME, VAR_NAME, NAME_STR, size, compatible, \ | |||||
delay) \ | |||||
FDT_PLATFORM_CTASSERT(delay); \ | |||||
static fdt_platform_def_t VAR_NAME ## _fdt_platform = { \ | static fdt_platform_def_t VAR_NAME ## _fdt_platform = { \ | ||||
.name = NAME_STR, \ | .name = NAME_STR, \ | ||||
.methods = fdt_platform_methods, \ | .methods = fdt_platform_methods, \ | ||||
.fdt_compatible = compatible, \ | .fdt_compatible = compatible, \ | ||||
}; \ | }; \ | ||||
static kobj_class_t VAR_NAME ## _baseclasses[] = \ | static kobj_class_t VAR_NAME ## _baseclasses[] = \ | ||||
{ (kobj_class_t)&VAR_NAME ## _fdt_platform, NULL }; \ | { (kobj_class_t)&VAR_NAME ## _fdt_platform, NULL }; \ | ||||
static platform_def_t VAR_NAME ## _platform = { \ | static platform_def_t VAR_NAME ## _platform = { \ | ||||
NAME_STR, \ | NAME_STR, \ | ||||
NAME ## _methods, \ | NAME ## _methods, \ | ||||
size, \ | size, \ | ||||
VAR_NAME ## _baseclasses, \ | VAR_NAME ## _baseclasses, \ | ||||
delay, \ | |||||
}; \ | }; \ | ||||
DATA_SET(platform_set, VAR_NAME ## _platform) | DATA_SET(platform_set, VAR_NAME ## _platform) | ||||
#define FDT_PLATFORM_DEF(NAME, NAME_STR, size, compatible) \ | #define FDT_PLATFORM_DEF(NAME, NAME_STR, size, compatible, delay) \ | ||||
FDT_PLATFORM_DEF2(NAME, NAME, NAME_STR, size, compatible) | FDT_PLATFORM_DEF2(NAME, NAME, NAME_STR, size, compatible, delay) | ||||
#endif | #endif | ||||
bool arm_tmr_timed_wait(platform_t, int); | |||||
#endif /* _MACHINE_PLATFORMVAR_H_ */ | #endif /* _MACHINE_PLATFORMVAR_H_ */ |