44f48f6da7
Refactor driver to align a bit more with its Linux counterpart, ie, ntc_thermistor. This driver did quite a few _unconventional_ things, like using "zephyr," compatibles, a dedicated node for pre-computed compensation table (referenced by the actual pseudo-device node), etc. The comparison helper function should likely be simplified as well (to avoid the need for custom wrapper for bsearch), but this can be done later. In this refactor, each thermistor gets a compatible, e.g. "epcos,xxxx". Compatibles are known by the driver, so are compensation tables. This simplifies devicetree files. There's no need to bother about compensation tables in **every** board file if Zephyr supports a certain NTC model. In general we should respect Linux bindings, which in the end influence how drivers are implemented. In this case, this principle resulted in simplified, easier to use code. For future developers, this is how support for a new NTC can be added: 1. Add to the end of the driver: ```c #undef DT_DRV_COMPAT #define DT_DRV_COMPAT vnd_model static __unused const struct ntc_compensation comp_vnd_model[] = { { x, y }, ..., }; #define DT_INST_FOREACH_STATUS_OKAY_VARGS(NTC_THERMISTOR_DEV_INIT, DT_DRV_COMPAT, comp_vnd_model) ``` 3. In driver's Kconfig make sure it depends on DT_HAS_$DT_DRV_COMPAT$_ENABLED Note: $X$ means _value_ of X. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
9 lines
198 B
YAML
9 lines
198 B
YAML
# Copyright (c) 2023 Nordic Semiconductor ASA
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
description: EPCOS B57861S0103A039 thermistor
|
|
|
|
compatible: "epcos,b57861s0103a039"
|
|
|
|
include: ntc-thermistor.yaml
|