forked from openSUSE/u-boot
-
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.
This PMIC can be found on H616 boards and it's very similar to AXP805 and AXP806. Signed-off-by: Jernej Skrabec <[email protected]> Reviewed-by: Andre Przywara <[email protected]> Reviewed-by: Jaehoon Chung <[email protected]> Signed-off-by: Andre Przywara <[email protected]>
- Loading branch information
Showing
7 changed files
with
129 additions
and
4 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
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,83 @@ | ||
// SPDX-License-Identifier: GPL-2.0+ | ||
/* | ||
* AXP305 driver | ||
* | ||
* (C) Copyright 2020 Jernej Skrabec <[email protected]> | ||
* | ||
* Based on axp221.c | ||
* (C) Copyright 2014 Hans de Goede <[email protected]> | ||
* (C) Copyright 2013 Oliver Schinagl <[email protected]> | ||
*/ | ||
|
||
#include <common.h> | ||
#include <command.h> | ||
#include <errno.h> | ||
#include <asm/arch/pmic_bus.h> | ||
#include <axp_pmic.h> | ||
|
||
#define AXP305_DCDC4_1600MV_OFFSET 46 | ||
|
||
static u8 axp305_mvolt_to_cfg(int mvolt, int min, int max, int div) | ||
{ | ||
if (mvolt < min) | ||
mvolt = min; | ||
else if (mvolt > max) | ||
mvolt = max; | ||
|
||
return (mvolt - min) / div; | ||
} | ||
|
||
int axp_set_dcdc4(unsigned int mvolt) | ||
{ | ||
int ret; | ||
u8 cfg; | ||
|
||
if (mvolt >= 1600) | ||
cfg = AXP305_DCDC4_1600MV_OFFSET + | ||
axp305_mvolt_to_cfg(mvolt, 1600, 3300, 100); | ||
else | ||
cfg = axp305_mvolt_to_cfg(mvolt, 600, 1500, 20); | ||
|
||
if (mvolt == 0) | ||
return pmic_bus_clrbits(AXP305_OUTPUT_CTRL1, | ||
AXP305_OUTPUT_CTRL1_DCDCD_EN); | ||
|
||
ret = pmic_bus_write(AXP305_DCDCD_VOLTAGE, cfg); | ||
if (ret) | ||
return ret; | ||
|
||
return pmic_bus_setbits(AXP305_OUTPUT_CTRL1, | ||
AXP305_OUTPUT_CTRL1_DCDCD_EN); | ||
} | ||
|
||
int axp_init(void) | ||
{ | ||
u8 axp_chip_id; | ||
int ret; | ||
|
||
ret = pmic_bus_init(); | ||
if (ret) | ||
return ret; | ||
|
||
ret = pmic_bus_read(AXP305_CHIP_VERSION, &axp_chip_id); | ||
if (ret) | ||
return ret; | ||
|
||
if ((axp_chip_id & AXP305_CHIP_VERSION_MASK) != 0x40) | ||
return -ENODEV; | ||
|
||
return ret; | ||
} | ||
|
||
#ifndef CONFIG_PSCI_RESET | ||
int do_poweroff(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) | ||
{ | ||
pmic_bus_write(AXP305_SHUTDOWN, AXP305_POWEROFF); | ||
|
||
/* infinite loop during shutdown */ | ||
while (1) {} | ||
|
||
/* not reached */ | ||
return 0; | ||
} | ||
#endif |
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,17 @@ | ||
/* SPDX-License-Identifier: GPL-2.0+ */ | ||
/* | ||
* (C) Copyright 2020 Jernej Skrabec <[email protected]> | ||
*/ | ||
|
||
enum axp305_reg { | ||
AXP305_CHIP_VERSION = 0x3, | ||
AXP305_OUTPUT_CTRL1 = 0x10, | ||
AXP305_DCDCD_VOLTAGE = 0x15, | ||
AXP305_SHUTDOWN = 0x32, | ||
}; | ||
|
||
#define AXP305_CHIP_VERSION_MASK 0xcf | ||
|
||
#define AXP305_OUTPUT_CTRL1_DCDCD_EN (1 << 3) | ||
|
||
#define AXP305_POWEROFF (1 << 7) |
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