Staging/max77533 - #3491
Conversation
5dcfc15 to
63d5be9
Compare
LLM reviewThis series adds a regulator driver and dt-bindings for the ADI/Maxim MAX77533 buck converter. run: 31792726869
|
LLM reviewThis series adds a regulator driver and dt-bindings for the ADI/Maxim MAX77533 buck converter. run: 31796333622
|
nunojsa
left a comment
There was a problem hiding this comment.
Here it goes my first pass review! Still need to look at bindings in follow up reviews! Also, is the end goal to upstream the driver?
I also wonder why we need a dedicated defconfig for a driver like this (is it just for your testing?).
Also bear in mind you need better commit messages
| @@ -0,0 +1,323 @@ | |||
| // SPDX-License-Identifier: GPL-2.0-or-later | |||
There was a problem hiding this comment.
typically GPL-2.0-only (not sure if exactly like this the string)
There was a problem hiding this comment.
It would be changed to below in the next commit.
// SPDX-License-Identifier: GPL-2.0-only
| @@ -0,0 +1,323 @@ | |||
| // SPDX-License-Identifier: GPL-2.0-or-later | |||
| /* | |||
| * Copyright (c) 2025 Analog Devices, Inc. | |||
There was a problem hiding this comment.
It would be changed to below in the next commit.
/*
- Copyright (c) 2026 Analog Devices, Inc.
- ADI regulator driver for MAX77533.
*/
| #include <linux/of.h> | ||
| #include <linux/regmap.h> | ||
| #include <linux/regulator/driver.h> | ||
| #include <linux/regulator/of_regulator.h> |
There was a problem hiding this comment.
not stating something is missing but make sure you IWYU
| static const struct i2c_device_id max77533_id[] = { | ||
| { "max77533" }, | ||
| { } | ||
| }; |
There was a problem hiding this comment.
These tale should match the above of_device_id
There was a problem hiding this comment.
i2c_device_id would be expanded in the next commit.
| return -ENOMEM; | ||
|
|
||
| max77533->dev = dev; | ||
| i2c_set_clientdata(client, max77533); |
There was a problem hiding this comment.
I don't see i2c_get_clientdata() so the above seems not needed to me
There was a problem hiding this comment.
i2c_set_clientdata() would be removed in the next commit.
| max77533->rdev = devm_regulator_register(dev, &max77533_desc, &config); | ||
| if (IS_ERR(max77533->rdev)) | ||
| return dev_err_probe(dev, PTR_ERR(max77533->rdev), | ||
| "Failed to register regulator\n"); |
There was a problem hiding this comment.
The above is typically the last thing we want to do! For example, do we somehow depende on the max77533_pok_irq_handler() on the regulator callbacks?
There was a problem hiding this comment.
Yes, max77533_pok_irq_handler() depends on max77533->rdev being valid
since it calls regulator_notifier_call_chain(). Therefore, the regulator
must be registered BEFORE requesting the IRQ, which is the current order.
The IRQ error handling has been changed to hard errors as requested.
|
|
||
| if (of_property_read_bool(np, "adi,en-logic-and")) | ||
| regmap_update_bits(max77533->regmap, MAX77533_REG_CFG, | ||
| MAX77533_BIT_EN_LOGIC, MAX77533_BIT_EN_LOGIC); |
There was a problem hiding this comment.
don't ignore return error from regmap_update_bits()
There was a problem hiding this comment.
Error handling would be added in the next commit.
| int ret; | ||
|
|
||
| if (!np) | ||
| return 0; |
There was a problem hiding this comment.
no need for the above check
There was a problem hiding this comment.
It would be removed in the next commit.
| if (!(val & MAX77533_BIT_EN)) | ||
| return REGULATOR_STATUS_OFF; | ||
|
|
||
| if (max77533->pok_gpio) { |
There was a problem hiding this comment.
Can you tell the usage of this gpio (being lazy to no check the datasheet for now :))?
There was a problem hiding this comment.
POK (Power OK) is an open-drain output that indicates the regulator
output status:
- High: Output voltage is within regulation (typically within ±8% of target)
- Low: Output voltage is below the POK threshold (under-voltage condition)
This is used to detect power-good status and under-voltage events.
When POK goes low, we notify REGULATOR_EVENT_UNDER_VOLTAGE; when it goes high, we notify REGULATOR_EVENT_VOLTAGE_CHANGE to indicate recovery.
| return REGULATOR_STATUS_OFF; | ||
|
|
||
| if (max77533->pok_gpio) { | ||
| int pok = gpiod_get_value_cansleep(max77533->pok_gpio); |
There was a problem hiding this comment.
In theory we do not need to check if an option gpio exists because gpiolib will return 0 if desc is NULL! That's why I'm wondering about this gpio usage and why we treat 0 as REGULATOR_STATUS_ERROR
There was a problem hiding this comment.
When POK is low (0), it indicates that the output voltage has dropped below the POK threshold, which is an under-voltage fault condition. This is why we return REGULATOR_STATUS_ERROR rather than REGULATOR_STATUS_OFF.
The regulator is still enabled (EN bit is set), but the output is not in regulation - this is an error state, not an intentional off state.
Regarding the NULL check: you're correct that gpiod_get_value_cansleep() returns 0 for NULL desc. However, I kept the explicit check for clarity since the logic path differs - without POK GPIO we assume the regulator is ON when enabled, while with POK GPIO we verify actual output status.
|
A defconfig is just for a testing, so I'll add REGULATOR_MAX77533 to Kconfig.adi. The ultimate goal is to upstream this driver to mainline Linux. Once the customer delivery is complete, I will address all review feedback and prepare a proper patch series for submission to |
63d5be9 to
ea878f8
Compare
Add REGULATOR_MAX77533 to KERNEL_ALL_ADI_DRIVERS config to enable building the MAX77533 regulator driver with the ADI driver collection. Signed-off-by: Sean Park <sean.park@analog.com>
Add device tree bindings documentation for the Maxim MAX77533 step-down regulator and its variants. Signed-off-by: Sean Park <sean.park@analog.com>
Add support for the Maxim MAX77533 high-efficiency step-down converter. The MAX77533 provides a configurable output voltage from 0.8V to 5.0V with 50mV steps and supports up to 3A output current. Features supported: - Output voltage regulation (0.8V - 5.0V, 50mV steps) - Enable/disable control via I2C - Peak current limit selection (500mA / 2A) - Soft-start time configuration - FPWM / Auto-PFM mode selection - Active discharge control - Power-OK GPIO monitoring with interrupt support The driver supports all device variants: - MAX77533, MAX77533A, MAX77533Q - MAX77533B-12, MAX77533B-18, MAX77533B-33 Signed-off-by: Sean Park <sean.park@analog.com>
ea878f8 to
64de809
Compare
|
Hi @nunojsa I've updated driver code regarding to your advice. Could you please confirm that again? |
PR Description
necessary to understand them. List any dependencies required for this change.
any space), or simply check them after publishing the PR.
description and try to push all related PRs simultaneously.
PR Type
PR Checklist