All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sebastian Reichel <sebastian.reichel@collabora.com>
To: Chris Morgan <macroalpha82@gmail.com>
Cc: linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org,
	 xsf@rock-chips.com, simona@ffwll.ch, airlied@gmail.com,
	tzimmermann@suse.de,  mripard@kernel.org,
	maarten.lankhorst@linux.intel.com, jesszhan0024@gmail.com,
	 neil.armstrong@linaro.org, heiko@sntech.de, conor+dt@kernel.org,
	krzk+dt@kernel.org,  robh@kernel.org,
	Chris Morgan <macromorgan@hotmail.com>
Subject: Re: [PATCH V6 2/6] power: supply: sgm41542: Add SG Micro sgm41542 charger
Date: Mon, 8 Jun 2026 23:19:54 +0200	[thread overview]
Message-ID: <aicv4neDA5Ke0FAB@venus> (raw)
In-Reply-To: <20260608175521.67449-3-macroalpha82@gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 1406 bytes --]

Hi,

On Mon, Jun 08, 2026 at 12:55:17PM -0500, Chris Morgan wrote:
> Add support for the SG Micro SGM41542 charger/boost converter.
> Driver was adapted from Rockchip BSP driver [1] and confirmed
> with vendor datasheet [2].
> 
> [1] https://github.com/rockchip-linux/kernel/blob/develop-6.6/drivers/power/supply/sgm41542_charger.c
> [2] https://www.sg-micro.de/rect/assets/1e8de70b-657e-4156-be68-a64fdbe8e418/SGM41541_SGM41542.pdf
> 
> Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
> ---
>  drivers/power/supply/Kconfig            |    8 +
>  drivers/power/supply/Makefile           |    1 +
>  drivers/power/supply/sgm41542_charger.c | 1057 +++++++++++++++++++++++
>  3 files changed, 1066 insertions(+)
>  create mode 100644 drivers/power/supply/sgm41542_charger.c
> [...]
> +static int sgm4154x_set_recharge_volt_ua(struct sgm4154x_device *sgm, int recharge_volt)
> +{
> +	int reg_val;
> +	int ret;
> +
> +	recharge_volt = recharge_volt / 1000;
> +
> +	reg_val = (recharge_volt - SGM4154X_VRECHRG_OFFSET_MV) / SGM4154X_VRECHRG_STEP_MV;

These are the only millivolt offset/steps, so drop the 1000 divison
and simply do:

#define SGM4154X_VRECHRG_OFFSET_UV      100000
#define SGM4154X_VRECHRG_STEP_UV        100000

reg_val = (recharge_volt - SGM4154X_VRECHRG_OFFSET_UV) / SGM4154X_VRECHRG_STEP_UV;

Otherwise LGTM.

> [...]

Greetings,

-- Sebastian

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

WARNING: multiple messages have this Message-ID (diff)
From: Sebastian Reichel <sebastian.reichel@collabora.com>
To: Chris Morgan <macroalpha82@gmail.com>
Cc: linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org,
	 xsf@rock-chips.com, simona@ffwll.ch, airlied@gmail.com,
	tzimmermann@suse.de,  mripard@kernel.org,
	maarten.lankhorst@linux.intel.com, jesszhan0024@gmail.com,
	 neil.armstrong@linaro.org, heiko@sntech.de, conor+dt@kernel.org,
	krzk+dt@kernel.org,  robh@kernel.org,
	Chris Morgan <macromorgan@hotmail.com>
Subject: Re: [PATCH V6 2/6] power: supply: sgm41542: Add SG Micro sgm41542 charger
Date: Mon, 8 Jun 2026 23:19:54 +0200	[thread overview]
Message-ID: <aicv4neDA5Ke0FAB@venus> (raw)
In-Reply-To: <20260608175521.67449-3-macroalpha82@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1406 bytes --]

Hi,

On Mon, Jun 08, 2026 at 12:55:17PM -0500, Chris Morgan wrote:
> Add support for the SG Micro SGM41542 charger/boost converter.
> Driver was adapted from Rockchip BSP driver [1] and confirmed
> with vendor datasheet [2].
> 
> [1] https://github.com/rockchip-linux/kernel/blob/develop-6.6/drivers/power/supply/sgm41542_charger.c
> [2] https://www.sg-micro.de/rect/assets/1e8de70b-657e-4156-be68-a64fdbe8e418/SGM41541_SGM41542.pdf
> 
> Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
> ---
>  drivers/power/supply/Kconfig            |    8 +
>  drivers/power/supply/Makefile           |    1 +
>  drivers/power/supply/sgm41542_charger.c | 1057 +++++++++++++++++++++++
>  3 files changed, 1066 insertions(+)
>  create mode 100644 drivers/power/supply/sgm41542_charger.c
> [...]
> +static int sgm4154x_set_recharge_volt_ua(struct sgm4154x_device *sgm, int recharge_volt)
> +{
> +	int reg_val;
> +	int ret;
> +
> +	recharge_volt = recharge_volt / 1000;
> +
> +	reg_val = (recharge_volt - SGM4154X_VRECHRG_OFFSET_MV) / SGM4154X_VRECHRG_STEP_MV;

These are the only millivolt offset/steps, so drop the 1000 divison
and simply do:

#define SGM4154X_VRECHRG_OFFSET_UV      100000
#define SGM4154X_VRECHRG_STEP_UV        100000

reg_val = (recharge_volt - SGM4154X_VRECHRG_OFFSET_UV) / SGM4154X_VRECHRG_STEP_UV;

Otherwise LGTM.

> [...]

Greetings,

-- Sebastian

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2026-06-08 21:20 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-08 17:55 [PATCH V6 0/6] Add Anbernic RG Vita-Pro Chris Morgan
2026-06-08 17:55 ` Chris Morgan
2026-06-08 17:55 ` [PATCH V6 1/6] dt-bindings: power: supply: sgm41542: document sgm41542 Chris Morgan
2026-06-08 17:55   ` Chris Morgan
2026-06-08 17:55 ` [PATCH V6 2/6] power: supply: sgm41542: Add SG Micro sgm41542 charger Chris Morgan
2026-06-08 17:55   ` Chris Morgan
2026-06-08 18:09   ` sashiko-bot
2026-06-08 21:19   ` Sebastian Reichel [this message]
2026-06-08 21:19     ` Sebastian Reichel
2026-06-08 17:55 ` [PATCH V6 3/6] dt-bindings: display: panel: Add Anbernic TD4310 panel Chris Morgan
2026-06-08 17:55   ` Chris Morgan
2026-06-08 17:55 ` [PATCH V6 4/6] drm/panel: anbernic-td4310: Add RG Vita Pro panel Chris Morgan
2026-06-08 17:55   ` Chris Morgan
2026-06-08 18:06   ` sashiko-bot
2026-06-08 17:55 ` [PATCH V6 5/6] dt-bindings: arm: rockchip: Add Anbernic RG Vita-Pro Chris Morgan
2026-06-08 17:55   ` Chris Morgan
2026-06-08 17:55 ` [PATCH V6 6/6] arm64: dts: " Chris Morgan
2026-06-08 17:55   ` Chris Morgan
2026-06-08 18:12   ` sashiko-bot

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=aicv4neDA5Ke0FAB@venus \
    --to=sebastian.reichel@collabora.com \
    --cc=airlied@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=heiko@sntech.de \
    --cc=jesszhan0024@gmail.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=macroalpha82@gmail.com \
    --cc=macromorgan@hotmail.com \
    --cc=mripard@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=robh@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    --cc=xsf@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.