mirror of
https://github.com/Rockbox/rockbox.git
synced 2026-01-22 01:30:35 -05:00
echoplayer: add function to enable 1V8 regulator
This supply is shared by the USB PHY and the audio codec, so it needs to be reference counted to allow them to be powered up & down independently (and not just leave the 1V8 regulator enabled all the time). Change-Id: Ib99b41c2a94b9f0c378153b33c6f91b4370ee998
This commit is contained in:
parent
80e1c2b27e
commit
d15ccd771d
2 changed files with 53 additions and 0 deletions
|
|
@ -19,6 +19,11 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
#include "power.h"
|
||||
#include "mutex.h"
|
||||
#include "gpio-stm32h7.h"
|
||||
|
||||
static struct mutex power_1v8_lock;
|
||||
static int power_1v8_refcount;
|
||||
|
||||
unsigned short battery_level_disksafe = 3500;
|
||||
unsigned short battery_level_shutoff = 3400;
|
||||
|
|
@ -35,9 +40,29 @@ unsigned short percent_to_volt_charge[11] =
|
|||
3485, 3780, 3836, 3857, 3890, 3930, 3986, 4062, 4158, 4185, 4196
|
||||
};
|
||||
|
||||
/* API for enabling 1V8 regulator */
|
||||
void echoplayer_enable_1v8_regulator(bool enable)
|
||||
{
|
||||
mutex_lock(&power_1v8_lock);
|
||||
|
||||
if (enable)
|
||||
{
|
||||
if (power_1v8_refcount++ == 0)
|
||||
gpio_set_level(GPIO_POWER_1V8, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (--power_1v8_refcount == 0)
|
||||
gpio_set_level(GPIO_POWER_1V8, 0);
|
||||
}
|
||||
|
||||
mutex_unlock(&power_1v8_lock);
|
||||
}
|
||||
|
||||
/* Power management */
|
||||
void power_init(void)
|
||||
{
|
||||
mutex_init(&power_1v8_lock);
|
||||
}
|
||||
|
||||
void power_off(void)
|
||||
|
|
|
|||
28
firmware/target/arm/stm32/echoplayer/power-echoplayer.h
Normal file
28
firmware/target/arm/stm32/echoplayer/power-echoplayer.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2026 by Aidan MacDonald
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef __POWER_ECHOPLAYER_H__
|
||||
#define __POWER_ECHOPLAYER_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
void echoplayer_enable_1v8_regulator(bool enable);
|
||||
|
||||
#endif /* __POWER_ECHOPLAYER_H__ */
|
||||
Loading…
Add table
Add a link
Reference in a new issue