The ILimCntl name can be understood as both register name and its field
name. Therefore it is better to change macro name so it contains both
register and field name. Second field of this register will be also
utilized by this driver in the future and new code will be aligned to
this naming convention.
Signed-off-by: Lukasz Madej <l.madej@grinn-global.com>
Fix validation of `linear_range_get_index()` results.
The function can resturn both 0 or -ERANGE but -EINVAL is never
returned. Use comparison against 0 to make the validation robust.
Use valid maximum index for the linear range. The 0x0C is reserved
value and should not be used. Therefore replace it with 0x0B.
Signed-off-by: Lukasz Madej <l.madej@grinn-global.com>
`max20335_get_constant_charge_current()` and
`max20335_set_chgin_to_sys_current_limit()` functions has redundant input
values validation. Drop not important ones to make the code clean.
While on it remove `max20335_get_constant_charge_voltage()` function
since it become useless.
Signed-off-by: Lukasz Madej <l.madej@grinn-global.com>
Maximum charging current is selected with an external resistor in
the MAX20335 charger. Therefore it is not possible to configure it
with software directly. There is only a capability to limit current
set with hardware but configuration of the limiter is not
straight-forward.
To reflect real functionality, drop usage of
`constant-charge-current-max-microamp` property as an required one and
use custom `chgin-to-sys-current-limit-microamp` instead.
Use enum in binding file to signalize improper values at compile time.
Drop support for `CHARGER_PROP_CONSTANT_CHARGE_CURRENT_UA` API property
since this cannot be handled.
The `max20335_get_constant_charge_current()` function become useless so
remove it.
Signed-off-by: Lukasz Madej <l.madej@grinn-global.com>
Add support for status and online notification properties.
Fire these notifications from int_routine_handler work directly.
Such approach makes the code cleaner and does not affect overall
max20335 interrupt processing performance. However application code
processing these notifications cannot be blocking.
Signed-off-by: Lukasz Madej <l.madej@grinn-global.com>
Charger hardware configuration registers are set to zero every time
external voltage is applied. Assure proper charger configuration by
buffering properties set by application and applying them at external
voltage connection event notified via interrupt.
Signed-off-by: Lukasz Madej <l.madej@grinn-global.com>
An anonymous enum describing charger status is used only by one
function therefore reduce scope of this enum.
Signed-off-by: Lukasz Madej <l.madej@grinn-global.com>
Utilization of chip interrupt line is mandatory to assure proper
charger state control. Handle interrupt to prepare the driver for
implementation of such functionality.
Modify charger status update so the current state is fetched in the
interrupt handler.
Use level based interrupts combined with interrupt disabling for a
period of time after interrupt handling to reduce number of interrupts
triggered by the charger. There may be a case where the charger
produces burst of interrupts for a several seconds and if the code
attempts to handle every single interrupt separatery then the system
might be significantly overloaded.
Co-authored-by: Bartosz Bilas <b.bilas@grinn-global.com>
Signed-off-by: Lukasz Madej <l.madej@grinn-global.com>
Rename `current_uv` argument name to `voltage_uv` in function
max20335_get_constant_charge_voltage() to make the name aligned with
its usage.
Signed-off-by: Lukasz Madej <l.madej@grinn-global.com>
Current driver handles charger status only but the charger chip
provides plenty of different statuses. Change name of
max20335_get_status() function to max20335_get_charger_status()
to make further implementations easier.
Signed-off-by: Lukasz Madej <l.madej@grinn-global.com>
Adds use of CHARGER_PROP_DISCHARGE_CURRENT_NOTIFICATION and
CHARGER_PROP_SYSTEM_VOLTAGE_NOTIFICATION_UV to the charger
sample application.
Signed-off-by: Ricardo Rivera-Matos <rriveram@opensource.cirrus.com>
Fix missing check of the return value of `bq25180_set_charge_current`
function, resulting in logically dead code, as indicated by Coverity
CID 347197.
Signed-off-by: Gustavo Silva <gustavograzs@gmail.com>
Adds a charge_enable handler to facilitate enabling and disabling
a charge cycle. This deprecates enabling and disable the charge
cycle via the CHARGER_PROP_STATUS property.
Signed-off-by: Ricardo Rivera-Matos <ricardo.rivera-matos@cirrus.com>
Many (or almost all) drivers contain the specified prefixes
related to the driver subsys so add the missing one for the
BQ24190.
Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
Move the syscall_handler.h header, used internally only to a dedicated
internal folder that should not be used outside of Zephyr.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>