mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-01 08:59:33 +00:00
83d290c56f
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
91 lines
1.7 KiB
C
91 lines
1.7 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* (C) Copyright 2012
|
|
* Henrik Nordstrom <henrik@henriknordstrom.net>
|
|
*/
|
|
#include <common.h>
|
|
#include <command.h>
|
|
#include <asm/arch/pmic_bus.h>
|
|
#include <axp_pmic.h>
|
|
|
|
static u8 axp152_mvolt_to_target(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_dcdc2(unsigned int mvolt)
|
|
{
|
|
int rc;
|
|
u8 current, target;
|
|
|
|
target = axp152_mvolt_to_target(mvolt, 700, 2275, 25);
|
|
|
|
/* Do we really need to be this gentle? It has built-in voltage slope */
|
|
while ((rc = pmic_bus_read(AXP152_DCDC2_VOLTAGE, ¤t)) == 0 &&
|
|
current != target) {
|
|
if (current < target)
|
|
current++;
|
|
else
|
|
current--;
|
|
rc = pmic_bus_write(AXP152_DCDC2_VOLTAGE, current);
|
|
if (rc)
|
|
break;
|
|
}
|
|
return rc;
|
|
}
|
|
|
|
int axp_set_dcdc3(unsigned int mvolt)
|
|
{
|
|
u8 target = axp152_mvolt_to_target(mvolt, 700, 3500, 50);
|
|
|
|
return pmic_bus_write(AXP152_DCDC3_VOLTAGE, target);
|
|
}
|
|
|
|
int axp_set_dcdc4(unsigned int mvolt)
|
|
{
|
|
u8 target = axp152_mvolt_to_target(mvolt, 700, 3500, 25);
|
|
|
|
return pmic_bus_write(AXP152_DCDC4_VOLTAGE, target);
|
|
}
|
|
|
|
int axp_set_aldo2(unsigned int mvolt)
|
|
{
|
|
u8 target = axp152_mvolt_to_target(mvolt, 700, 3500, 100);
|
|
|
|
return pmic_bus_write(AXP152_LDO2_VOLTAGE, target);
|
|
}
|
|
|
|
int axp_init(void)
|
|
{
|
|
u8 ver;
|
|
int rc;
|
|
|
|
rc = pmic_bus_init();
|
|
if (rc)
|
|
return rc;
|
|
|
|
rc = pmic_bus_read(AXP152_CHIP_VERSION, &ver);
|
|
if (rc)
|
|
return rc;
|
|
|
|
if (ver != 0x05)
|
|
return -EINVAL;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int do_poweroff(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|
{
|
|
pmic_bus_write(AXP152_SHUTDOWN, AXP152_POWEROFF);
|
|
|
|
/* infinite loop during shutdown */
|
|
while (1) {}
|
|
|
|
/* not reached */
|
|
return 0;
|
|
}
|