0001
0002
0003
0004
0005
0006
0007 #ifndef __MIPS_ASM_MACHINE_H__
0008 #define __MIPS_ASM_MACHINE_H__
0009
0010 #include <linux/libfdt.h>
0011 #include <linux/of.h>
0012
0013 struct mips_machine {
0014 const struct of_device_id *matches;
0015 const void *fdt;
0016 bool (*detect)(void);
0017 const void *(*fixup_fdt)(const void *fdt, const void *match_data);
0018 unsigned int (*measure_hpt_freq)(void);
0019 };
0020
0021 extern long __mips_machines_start;
0022 extern long __mips_machines_end;
0023
0024 #define MIPS_MACHINE(name) \
0025 static const struct mips_machine __mips_mach_##name \
0026 __used __section(".mips.machines.init")
0027
0028 #define for_each_mips_machine(mach) \
0029 for ((mach) = (struct mips_machine *)&__mips_machines_start; \
0030 (mach) < (struct mips_machine *)&__mips_machines_end; \
0031 (mach)++)
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043 static inline const struct of_device_id *
0044 mips_machine_is_compatible(const struct mips_machine *mach, const void *fdt)
0045 {
0046 const struct of_device_id *match;
0047
0048 if (!mach->matches)
0049 return NULL;
0050
0051 for (match = mach->matches; match->compatible[0]; match++) {
0052 if (fdt_node_check_compatible(fdt, 0, match->compatible) == 0)
0053 return match;
0054 }
0055
0056 return NULL;
0057 }
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068 struct mips_fdt_fixup {
0069 int (*apply)(void *fdt);
0070 const char *description;
0071 };
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086 extern int __init apply_mips_fdt_fixups(void *fdt_out, size_t fdt_out_size,
0087 const void *fdt_in,
0088 const struct mips_fdt_fixup *fixups);
0089
0090 #endif