/* * The original translation formulae of the temperature (in degrees of Celsius) * are as follows: * * T = -3.4627e-11*(N^4) + 1.1023e-7*(N^3) + -1.9165e-4*(N^2) + * 3.0604e-1*(N^1) + -5.6197e1 * * where [-56.197, 136.402]C and N = [0, 1023]. * * They must be accordingly altered to be suitable for the integer arithmetics. * The technique is called 'factor redistribution', which just makes sure the * multiplications and divisions are made so to have a result of the operations * within the integer numbers limit. In addition we need to translate the * formulae to accept millidegrees of Celsius. Here what it looks like after * the alterations: * * T = -34627e-12*(N^4) + 110230e-9*(N^3) + -191650e-6*(N^2) + * 306040e-3*(N^1) + -56197 * * where T = [-56197, 136402]mC and N = [0, 1023].
*/
/* enable continuous mode */
val = SENSOR_CFG_SAMPLE_ENA | SENSOR_CFG_CONTINIOUS_MODE;
/* set PVT clock to be between 1.15 and 1.25 MHz */
div = DIV_ROUND_CLOSEST(hwmon->clk_rate, LAN966X_PVT_CLK);
val |= FIELD_PREP(SENSOR_CFG_CLK_CFG, div);
ret = regmap_update_bits(hwmon->regmap_pvt, PVT_SENSOR_CFG,
mask, val); if (ret) return ret;
hwmon = devm_kzalloc(dev, sizeof(*hwmon), GFP_KERNEL); if (!hwmon) return -ENOMEM;
hwmon->clk = devm_clk_get_enabled(dev, NULL); if (IS_ERR(hwmon->clk)) return dev_err_probe(dev, PTR_ERR(hwmon->clk), "failed to get clock\n");
hwmon->clk_rate = clk_get_rate(hwmon->clk);
hwmon->regmap_pvt = lan966x_init_regmap(pdev, "pvt"); if (IS_ERR(hwmon->regmap_pvt)) return dev_err_probe(dev, PTR_ERR(hwmon->regmap_pvt), "failed to get regmap for PVT registers\n");
hwmon->regmap_fan = lan966x_init_regmap(pdev, "fan"); if (IS_ERR(hwmon->regmap_fan)) return dev_err_probe(dev, PTR_ERR(hwmon->regmap_fan), "failed to get regmap for fan registers\n");
ret = lan966x_hwmon_enable(dev, hwmon); if (ret) return dev_err_probe(dev, ret, "failed to enable sensor\n");
hwmon_dev = devm_hwmon_device_register_with_info(&pdev->dev, "lan966x_hwmon", hwmon,
&lan966x_hwmon_chip_info, NULL); if (IS_ERR(hwmon_dev)) return dev_err_probe(dev, PTR_ERR(hwmon_dev), "failed to register hwmon device\n");
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.