-
Notifications
You must be signed in to change notification settings - Fork 882
Staging/max77840 device driver #2815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
2522e7e
to
ac38438
Compare
ac38438
to
2e29b07
Compare
Add device tree bindings to support the MAX77840 PMIC and its submodules, enabling configuration and control through device tree. Signed-off-by: joan-na-good <joan.na@analog.com>
Implement basic support for the MAX77840 PMIC core, including initialization, power management, and core functions necessary for submodules. Signed-off-by: joan-na-good <joan.na@analog.com>
…uel gauge This patch adds driver support for the MAX77840 charger, charger-detect, and fuel gauge functionalities, enabling proper battery management and monitoring on supported platforms. Signed-off-by: joan-na-good <joan.na@analog.com>
Add regulator support for the MAX77840 PMIC to control voltage and current regulation. This enables proper power management features required for various submodules dependent on this regulator. Signed-off-by: joan-na-good <joan.na@analog.com>
2e29b07
to
8cf13d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some general notes from me but this needs a lot of rework before I can do a proper review. This seems like a very old, out of tree, driver which is using a lot of questionable things. Please look at another upstream examples in:
https://elixir.bootlin.com/linux/v6.15/source/drivers/mfd
and rework the drivers so they are modern. Otherwise it gets very time consuming (and difficult) for me to review this.
Also bear in mind that the goal is to send this upstream and get it accepted before merging it in our tree.
@@ -77,6 +77,7 @@ obj-$(CONFIG_CHARGER_MAX14577) += max14577_charger.o | |||
obj-$(CONFIG_CHARGER_DETECTOR_MAX14656) += max14656_charger_detector.o | |||
obj-$(CONFIG_CHARGER_MAX77650) += max77650-charger.o | |||
obj-$(CONFIG_CHARGER_MAX77693) += max77693_charger.o | |||
obj-$(CONFIG_CHARGER_MAX77840) += max77840-charger.o max77840-charger-detect.o max77840-battery.o |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This adds three different drivers all as part of the supply subsystem? Can't we have just one driver?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The MAX77840 is a single chip, it integrates multiple functional blocks — charger, regulator, and fuel gauge.
Therefore, if possible, I’d prefer to maintain the current structure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The MAX77840 is a single chip, it integrates multiple functional blocks — charger, regulator, and fuel gauge.
Therefore, if possible, I’d prefer to maintain the current structure.
Yes, but it is three drivers in the same subsystem... Anyways, if the maintainer accepts this, fine by me. But at least for this review add a driver per commit and not three drivers in one single commit.
int restart_threshold; | ||
int termination_voltage; | ||
int input_current_limit; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop the above header files if they are only used by the respective source file.
CHG_INT_CHG_I, | ||
CHG_INT_TOPOFF_I, | ||
CHG_INT_CHGIN_I, | ||
CHG_INT_AICL_CHGINI_I, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typically, all the defines, enum, etc, are prefixed with the driver name
// SPDX-License-Identifier: GPL-2.0 | ||
/* | ||
* Copyright (c) 2020 Maxim Integrated Products, Inc. | ||
* Copyright (C) 2024 Analog Devices, Inc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess 2025 will also be needed
#ifndef __MAX77840_MFD_H__ | ||
#define __MAX77840_MFD_H__ | ||
|
||
#define __TEST_DEVICE_NODE__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
#define I2C_ADDR_FUEL_GAUGE (0x6C >> 1) /* Fuel Gauge */ | ||
|
||
#define __lock(_me) mutex_lock(&(_me)->lock) | ||
#define __unlock(_me) mutex_unlock(&(_me)->lock) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drop the above lock defines. In fact, look at the cleanup.h header
{ | ||
return regmap_bulk_write(regmap, (unsigned int)addr, src, (size_t)len); | ||
} | ||
EXPORT_SYMBOL(max77840_bulk_write); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drop the above
/* PMIC */ | ||
#define REG_PMICID 0x00 | ||
|
||
/* Declare Interrupt */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please drop all the unneeded comments
pr_err("<%s> failed to set up interrupt\n", | ||
client->name); | ||
pr_err("<%s> and add sub-device [%d]\n", | ||
client->name, rc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no pr_err(). Use dev_err()
} | ||
|
||
module_init(max77840_init); | ||
module_exit(max77840_exit); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The above is not how it should be done
Thank you for the feedback. |
@nuno should a mirror for git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git (for-mfd-next) be added to the cron.yml? I did a manual at mirror/lee/mfd/for-mfd-next meanwhile |
Yes, the background story is that 99.9% of the times the driver will change after being upstreamed (due to review comments) and then we would need to backport those changes to sync the driver with upstream. Or, in some other cases, we would just forget to sync and then I would get tons of conflicts while updating to a new kernel version. This way, it makes it easier. |
PR Description
This PR introduces initial support for the MAX77840 PMIC device driver.
The changes include:
All code has been built successfully, passed checkpatch.pl in strict mode. No external dependencies are required.
PR Type
PR Checklist