65 lines
2.2 KiB
C

/*
* Copyright (C) 2012 TomTom International BV
* Written by Domenico Andreoli <domenico.andreoli@tomtom.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
*/
#ifndef TOMTOM_MFD_FEAT_H
#define TOMTOM_MFD_FEAT_H
#define MFD_VARIANT_STRASBOURG_A2 0x10
#define MFD_VARIANT_STRASBOURG_B1 0x11
#define MFD_VARIANT_STRASBOURG_B2 0x12
#define MFD_VARIANT_RENNES_A1 0x13
#define MFD_VARIANT_RENNES_B1 0x14
#define MFD_VARIANT_STUTTGART_B1 0x15
/*
* Helper struct to hold a TomTom MFD board specific feature in form
* of a pointer. Specific features are selected in base of the mach and
* rev fields.
*/
struct mfd_feat {
unsigned int mach;
unsigned int rev;
void *priv;
};
/* Helper macros to init arrays of MFD features */
#define MFD_FEAT_INIT(_mach, _rev, _feat) { \
.mach = _mach, \
.rev = _rev, \
.priv = _feat, \
}
/*
* The default entry is mandatory, it grants that mfd_lookup() is not
* an infinite loop. Entries after the default are ignored so normally
* it is last. It also provides a means to return a possibly meaningful
* value in case no MFD cadidate is found.
*/
#define MFD_DEFAULT(_feat) MFD_FEAT_INIT(0, 0, _feat)
#define MFD_1_0_A1(_feat) MFD_FEAT_INIT(MACH_TYPE_STRASBOURG, 0, _feat)
#define MFD_1_0_A2(_feat) MFD_FEAT_INIT(MACH_TYPE_STRASBOURG_A2, MFD_VARIANT_STRASBOURG_A2, _feat)
#define MFD_1_0_B1(_feat) MFD_FEAT_INIT(MACH_TYPE_STRASBOURG_A2, MFD_VARIANT_STRASBOURG_B1, _feat)
#define MFD_1_0_B2(_feat) MFD_FEAT_INIT(MACH_TYPE_STRASBOURG_A2, MFD_VARIANT_STRASBOURG_B2, _feat)
#define MFD_1_05(_feat) MFD_FEAT_INIT(MACH_TYPE_STRASBOURG_A2, MFD_VARIANT_RENNES_A1, _feat)
#define MFD_1_1(_feat) MFD_FEAT_INIT(MACH_TYPE_STRASBOURG_A2, MFD_VARIANT_RENNES_B1, _feat)
#define MFD_2_0(_feat) MFD_FEAT_INIT(MACH_TYPE_STRASBOURG_A2, MFD_VARIANT_STUTTGART_B1, _feat)
/* Lookup functions to find the first matching MFD feature */
const struct mfd_feat *mfd_lookup(const struct mfd_feat *feat);
static inline void *mfd_feature(const struct mfd_feat *feat)
{
const struct mfd_feat *_f = mfd_lookup(feat);
return _f ? _f->priv : 0;
}
#endif /* TOMTOM_MFD_FEAT_H */