From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Chris Morgan <macroalpha82@gmail.com>,
linux-rockchip@lists.infradead.org
Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org,
zhangqing@rock-chips.com, zyw@rock-chips.com,
jon.lin@rock-chips.com, maccraft123mc@gmail.com, sre@kernel.org,
heiko@sntech.de, krzysztof.kozlowski+dt@linaro.org,
robh+dt@kernel.org, lee@kernel.org,
Chris Morgan <macromorgan@hotmail.com>
Subject: Re: [PATCH V9 3/4] power: supply: Add charger driver for Rockchip RK817
Date: Thu, 25 Aug 2022 15:54:06 +0300 [thread overview]
Message-ID: <66b99ce4-752a-17e7-3213-26a898abd4a8@gmail.com> (raw)
In-Reply-To: <20220823193015.10229-4-macroalpha82@gmail.com>
On 8/23/22 22:30, Chris Morgan wrote:
> From: Chris Morgan <macromorgan@hotmail.com>
>
> Add support for the Rockchip rk817 battery charger integrated into the
> rk817 PMIC.
>
> Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
> Signed-off-by: Maya Matuszczyk <maccraft123mc@gmail.com>
> ---
> drivers/power/supply/Kconfig | 6 +
> drivers/power/supply/Makefile | 1 +
> drivers/power/supply/rk817_charger.c | 1157 ++++++++++++++++++++++++++
> 3 files changed, 1164 insertions(+)
> create mode 100644 drivers/power/supply/rk817_charger.c
>
> +
> +static void rk817_charging_monitor(struct work_struct *work)
> +{
> + struct rk817_charger *charger;
> +
> + charger = container_of(work, struct rk817_charger, work.work);
> +
> + rk817_read_props(charger);
> +
> + /* Run every 8 seconds like the BSP driver did. */
> + queue_delayed_work(system_wq, &charger->work, msecs_to_jiffies(8000));
> +}
I really think we would benefit from some more framework code which
could handle the periodic polling tasks and the coulomb counter drift
corrections when battery is full/relaxed. I think I might revive the
simple-gauge patch series...
> +
> +static int rk817_charger_probe(struct platform_device *pdev)
> +{
> +
> + charger->sleep_filter_current_ua = of_value;
> +
> + charger->bat_ps = devm_power_supply_register(&pdev->dev,
> + &rk817_bat_desc, &pscfg);
> +
> + charger->chg_ps = devm_power_supply_register(&pdev->dev,
> + &rk817_chg_desc, &pscfg);
Hmm. I think I should respin the patch which added interface for getting
the battery info w/o psy-device. Now we need to take into account the
situation where the psy-core accesses the driver after the registration
- and prior filling the battery details from the battery node (below) :/
> +
> + if (IS_ERR(charger->chg_ps))
> + return dev_err_probe(dev, -EINVAL,
> + "Battery failed to probe\n");
> +
> + if (IS_ERR(charger->chg_ps))
> + return dev_err_probe(dev, -EINVAL,
> + "Charger failed to probe\n");
> +
> + ret = power_supply_get_battery_info(charger->bat_ps,
> + &bat_info);
> + if (ret) {
> + return dev_err_probe(dev, ret,
> + "Unable to get battery info: %d\n", ret);
> + } > +
> + if ((!bat_info->charge_full_design_uah) ||
> + (!bat_info->voltage_min_design_uv) ||
> + (!bat_info->voltage_max_design_uv) ||
> + (!bat_info->constant_charge_voltage_max_uv) ||
> + (!bat_info->constant_charge_current_max_ua) ||
> + (!bat_info->charge_term_current_ua)) {
> + return dev_err_probe(dev, -EINVAL,
> + "Required battery info missing.\n");
> + }
Just a question - should the values be compared to -EINVAL (I think the
power_supply_get_battery_info() did internally initialize many of the
fields to -EINVAL and not to 0?). Maybe I am wrong...
> +
> + charger->bat_charge_full_design_uah = bat_info->charge_full_design_uah;
> + charger->bat_voltage_min_design_uv = bat_info->voltage_min_design_uv;
> + charger->bat_voltage_max_design_uv = bat_info->voltage_max_design_uv;
> +
Generally, I did _really_ like the proper commenting/documenting of the
driver. In my eyes this looked like one nice piece of a driver.
When the error checking of values returned by the
power_supply_get_battery_info() is checked - FWIW:
Reviewed-By: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Yours
-- Matti
--
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland
~~ When things go utterly wrong vim users can always type :help! ~~
next prev parent reply other threads:[~2022-08-25 12:54 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-23 19:30 [PATCH V9 0/4] power: supply: Add Support for RK817 Charger Chris Morgan
2022-08-23 19:30 ` [PATCH V9 1/4] dt-bindings: Add Rockchip rk817 battery charger support Chris Morgan
2022-08-24 18:59 ` Rob Herring
2022-08-23 19:30 ` [PATCH V9 2/4] mfd: " Chris Morgan
2022-08-23 19:30 ` [PATCH V9 3/4] power: supply: Add charger driver for Rockchip RK817 Chris Morgan
2022-08-25 12:54 ` Matti Vaittinen [this message]
2022-08-25 15:37 ` Chris Morgan
2022-08-26 5:52 ` Matti Vaittinen
2022-08-26 6:18 ` Maya Matuszczyk
2022-08-23 19:30 ` [PATCH V9 4/4] arm64: dts: rockchip: add rk817 chg to Odroid Go Advance Chris Morgan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=66b99ce4-752a-17e7-3213-26a898abd4a8@gmail.com \
--to=mazziesaccount@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=heiko@sntech.de \
--cc=jon.lin@rock-chips.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lee@kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=maccraft123mc@gmail.com \
--cc=macroalpha82@gmail.com \
--cc=macromorgan@hotmail.com \
--cc=robh+dt@kernel.org \
--cc=sre@kernel.org \
--cc=zhangqing@rock-chips.com \
--cc=zyw@rock-chips.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).