summaryrefslogtreecommitdiff
path: root/firmware/target/mips/ingenic_x1000/fiiom3k/power-fiiom3k.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/mips/ingenic_x1000/fiiom3k/power-fiiom3k.c')
-rw-r--r--firmware/target/mips/ingenic_x1000/fiiom3k/power-fiiom3k.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/firmware/target/mips/ingenic_x1000/fiiom3k/power-fiiom3k.c b/firmware/target/mips/ingenic_x1000/fiiom3k/power-fiiom3k.c
index c346d16890..a7f6165980 100644
--- a/firmware/target/mips/ingenic_x1000/fiiom3k/power-fiiom3k.c
+++ b/firmware/target/mips/ingenic_x1000/fiiom3k/power-fiiom3k.c
@@ -26,7 +26,7 @@
26#ifdef HAVE_USB_CHARGING_ENABLE 26#ifdef HAVE_USB_CHARGING_ENABLE
27# include "usb_core.h" 27# include "usb_core.h"
28#endif 28#endif
29#include "axp173.h" 29#include "axp-pmu.h"
30#include "i2c-x1000.h" 30#include "i2c-x1000.h"
31#include "gpio-x1000.h" 31#include "gpio-x1000.h"
32 32
@@ -53,32 +53,32 @@ const unsigned short percent_to_volt_charge[11] =
53 3485, 3780, 3836, 3857, 3890, 3930, 3986, 4062, 4158, 4185, 4196 53 3485, 3780, 3836, 3857, 3890, 3930, 3986, 4062, 4158, 4185, 4196
54}; 54};
55 55
56#define AXP173_IRQ_PORT GPIO_B 56#define AXP_IRQ_PORT GPIO_B
57#define AXP173_IRQ_PIN (1 << 10) 57#define AXP_IRQ_PIN (1 << 10)
58 58
59void power_init(void) 59void power_init(void)
60{ 60{
61 /* Initialize driver */ 61 /* Initialize driver */
62 i2c_x1000_set_freq(2, I2C_FREQ_400K); 62 i2c_x1000_set_freq(2, I2C_FREQ_400K);
63 axp173_init(); 63 axp_init();
64 64
65 /* Set lowest sample rate */ 65 /* Set lowest sample rate */
66 axp173_adc_set_rate(AXP173_ADC_RATE_25HZ); 66 axp_adc_set_rate(AXP_ADC_RATE_25HZ);
67 67
68 /* Ensure battery voltage ADC is enabled */ 68 /* Ensure battery voltage ADC is enabled */
69 int bits = axp173_adc_get_enabled(); 69 int bits = axp_adc_get_enabled();
70 bits |= (1 << ADC_BATTERY_VOLTAGE); 70 bits |= (1 << ADC_BATTERY_VOLTAGE);
71 axp173_adc_set_enabled(bits); 71 axp_adc_set_enabled(bits);
72 72
73 /* Turn on all power outputs */ 73 /* Turn on all power outputs */
74 i2c_reg_modify1(AXP173_BUS, AXP173_ADDR, 74 i2c_reg_modify1(AXP_PMU_BUS, AXP_PMU_ADDR,
75 AXP173_REG_PWROUTPUTCTRL, 0, 0x5f, NULL); 75 AXP_REG_PWROUTPUTCTRL2, 0, 0x5f, NULL);
76 i2c_reg_modify1(AXP173_BUS, AXP173_ADDR, 76 i2c_reg_modify1(AXP_PMU_BUS, AXP_PMU_ADDR,
77 AXP173_REG_DCDCWORKINGMODE, 0, 0xc0, NULL); 77 AXP_REG_DCDCWORKINGMODE, 0, 0xc0, NULL);
78 78
79 /* Set the default charging current. This is the same as the 79 /* Set the default charging current. This is the same as the
80 * OF's setting, although it's not strictly within the USB spec. */ 80 * OF's setting, although it's not strictly within the USB spec. */
81 axp173_set_charge_current(780); 81 axp_set_charge_current(780);
82 82
83 /* Short delay to give power outputs time to stabilize */ 83 /* Short delay to give power outputs time to stabilize */
84 mdelay(5); 84 mdelay(5);
@@ -87,7 +87,7 @@ void power_init(void)
87#ifdef HAVE_USB_CHARGING_ENABLE 87#ifdef HAVE_USB_CHARGING_ENABLE
88void usb_charging_maxcurrent_change(int maxcurrent) 88void usb_charging_maxcurrent_change(int maxcurrent)
89{ 89{
90 axp173_set_charge_current(maxcurrent); 90 axp_set_charge_current(maxcurrent);
91} 91}
92#endif 92#endif
93 93
@@ -97,18 +97,16 @@ void adc_init(void)
97 97
98void power_off(void) 98void power_off(void)
99{ 99{
100 /* Set the shutdown bit */ 100 axp_power_off();
101 i2c_reg_setbit1(AXP173_BUS, AXP173_ADDR,
102 AXP173_REG_SHUTDOWNLEDCTRL, 7, 1, NULL);
103 while(1); 101 while(1);
104} 102}
105 103
106bool charging_state(void) 104bool charging_state(void)
107{ 105{
108 return axp173_battery_status() == AXP173_BATT_CHARGING; 106 return axp_battery_status() == AXP_BATT_CHARGING;
109} 107}
110 108
111int _battery_voltage(void) 109int _battery_voltage(void)
112{ 110{
113 return axp173_adc_read(ADC_BATTERY_VOLTAGE); 111 return axp_adc_read(ADC_BATTERY_VOLTAGE);
114} 112}