forked from zephyrproject-rtos/zephyr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
drivers: mfd: add Maxim MAX20335 MFD driver
Maxim MAX20335 is a PMIC with Ultra-Low IQ Voltage Regulators and Battery Chargers for Small Lithium Ion Systems. Signed-off-by: Bartosz Bilas <[email protected]>
- Loading branch information
1 parent
e07ded1
commit 4a39740
Showing
6 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Copyright (c) 2023 Grinn | ||
# SPDX -License-Identifier: Apache-2.0 | ||
|
||
config MFD_MAX20335 | ||
bool "MAX20335 PMIC multi-function device driver" | ||
default y | ||
depends on DT_HAS_MAXIM_MAX20335_ENABLED | ||
select I2C | ||
help | ||
Enable the Maxim MAX20335 PMIC multi-function device driver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (c) 2023 Grinn | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#define DT_DRV_COMPAT maxim_max20335 | ||
|
||
#include <errno.h> | ||
|
||
#include <zephyr/drivers/i2c.h> | ||
#include <zephyr/sys/util.h> | ||
|
||
#define MAX20335_REG_CHIP_ID 0x00 | ||
#define MAX20335_CHIP_ID_VAL 0x04 | ||
|
||
struct mfd_max20335_config { | ||
struct i2c_dt_spec bus; | ||
}; | ||
|
||
static int mfd_max20335_init(const struct device *dev) | ||
{ | ||
const struct mfd_max20335_config *config = dev->config; | ||
uint8_t val; | ||
int ret; | ||
|
||
if (!i2c_is_ready_dt(&config->bus)) { | ||
return -ENODEV; | ||
} | ||
|
||
ret = i2c_reg_read_byte_dt(&config->bus, MAX20335_REG_CHIP_ID, &val); | ||
if (ret < 0) { | ||
return ret; | ||
} | ||
|
||
if (val != MAX20335_CHIP_ID_VAL) { | ||
return -ENODEV; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
#define MFD_MA20335_DEFINE(inst) \ | ||
static const struct mfd_max20335_config mfd_max20335_config##inst = { \ | ||
.bus = I2C_DT_SPEC_INST_GET(inst), \ | ||
}; \ | ||
\ | ||
DEVICE_DT_INST_DEFINE(inst, mfd_max20335_init, NULL, NULL, \ | ||
&mfd_max20335_config##inst, POST_KERNEL, \ | ||
CONFIG_MFD_INIT_PRIORITY, NULL); | ||
|
||
DT_INST_FOREACH_STATUS_OKAY(MFD_MA20335_DEFINE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Copyright (c) 2023 Grinn | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
description: Maxim MAX20335 | ||
|
||
compatible: "maxim,max20335" | ||
|
||
include: i2c-device.yaml | ||
|
||
properties: | ||
reg: | ||
required: true |