/* Unit is hundreds of uS */ #define FASTNG_MIN 23
staticint find_closest_fast(int target, int *sel, int *val)
{ int i; int window = FASTNG_MIN;
for (i = 0; i < 8 && window < target; i++)
window <<= 1;
*val = window;
*sel = i;
if (i == 8) return -EINVAL;
return 0;
}
staticint find_closest_slow_by_fast(int fast_val, int target, int *slowsel)
{ int sel; staticconstint multipliers[] = {2, 3, 7, 15};
for (sel = 0; sel < ARRAY_SIZE(multipliers) &&
multipliers[sel] * fast_val < target; sel++)
;
if (sel == ARRAY_SIZE(multipliers)) return -EINVAL;
*slowsel = sel;
return 0;
}
staticint find_closest_slow(int target, int *slow_sel, int *fast_sel)
{ staticconstint multipliers[] = {2, 3, 7, 15}; int i, j; int val = 0; int window = FASTNG_MIN;
for (i = 0; i < 8; i++) { for (j = 0; j < ARRAY_SIZE(multipliers); j++) { int slow;
staticint bd957x_set_wdt_mode(struct bd9576_wdt_priv *priv, int hw_margin, int hw_margin_min)
{ int ret, fastng, slowng, type, reg, mask; struct device *dev = priv->dev;
/* convert to 100uS */
hw_margin *= 10;
hw_margin_min *= 10; if (hw_margin_min) { int min;
type = BD957X_WDG_TYPE_WINDOW;
dev_dbg(dev, "Setting type WINDOW 0x%x\n", type);
ret = find_closest_fast(hw_margin_min, &fastng, &min); if (ret) {
dev_err(dev, "bad WDT window for fast timeout\n"); return ret;
}
ret = find_closest_slow_by_fast(min, hw_margin, &slowng); if (ret) {
dev_err(dev, "bad WDT window\n"); return ret;
}
} else {
type = BD957X_WDG_TYPE_SLOW;
dev_dbg(dev, "Setting type SLOW 0x%x\n", type);
ret = find_closest_slow(hw_margin, &slowng, &fastng); if (ret) {
dev_err(dev, "bad WDT window\n"); return ret;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.