/* 2012-09-16: File added by Sony Corporation */
/*
 * icx_pmu.h
 *
 * Copyright 2011 Sony Corporation.
 *
 * 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 program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 */

#ifndef __ICX_PMU_H__
#define __ICX_PMU_H__

/**************/
/* initialize */
/**************/
void pmu_init(void);

/*************/
/* boot mode */
/*************/
#define	BOOT_MEDIA_SD			0x00000004
#define	BOOT_MEDIA_EMMC			0x00000006
unsigned int pmu_get_boot_media(void);

/****************/
/* power supply */
/****************/
#define POWER_SUPPLY_USB		PWC_PSW_STATE_SDETUSB
#define POWER_SUPPLY_AC_ADAPTOR	PWC_PSW_STATE_SDETADP
unsigned int pmu_get_power_supply_state(void);

/***************/
/* boot factor */
/***************/
#define BOOT_FACTOR_RTC_ALARM	0x00020000
#define BOOT_FACTOR_ACCESSARY	0x00000080
#define BOOT_FACTOR_KEY_PAD		0x00000040
#define BOOT_FACTOR_HOLD_KEY	0x00000002
unsigned int pmu_get_boot_factor(void);
void		 pmu_save_boot_factor(unsigned int factor);

/***********/
/* battery */
/***********/
unsigned int pmu_get_battery_value(void);
void		 pmu_get_battery_threshold(unsigned int *low, unsigned int *very_low);

/****************/
/* battery flag */
/****************/
#define BOOT_FLAG_BATTERY		0x00000003
#define BOOT_FLAG_BATTERY_NORM	0x00000000
#define BOOT_FLAG_BATTERY_VLOW	0x00000001
#define BOOT_FLAG_BATTERY_NONE	0x00000003
#define BOOT_FLAG_RTC_INT		0x00000004
#define BOOT_FLAG_RTC_INT_OFF	0x00000000
#define BOOT_FLAG_RTC_INT_ON	0x00000004
void pmu_save_boot_flag(unsigned int target, unsigned int value);

/**************/
/* vbus limit */
/**************/
#define VBUS_LIMIT_500			500
#define VBUS_LIMIT_100			100
#define VBUS_LIMIT_0			0
void pmu_set_vbus_limit(int limit);

/**************/
/* reset flag */
/**************/
void pmu_set_reset_flag(void);
void pmu_clear_reset_flag(void);
int	 pmu_check_reset_flag(void);
	
/*************/
/* regulator */
/*************/
#define REGULATOR_R1			0x00000104
#define REGULATOR_ANA			0x00010204
#define REGULATOR_R2			0x00020404
#define REGULATOR_LOG			0x00030804
#define REGULATOR_DD2			0x00041004
#define REGULATOR_R3			0x00052004
#define REGULATOR_GP2			0x00060106
#define REGULATOR_GP3			0x00070206
#define REGULATOR_GP4			0x00080406
#define REGULATOR_USB			0x00090290
#define REGULATOR_MAX			11
int pmu_regulator_on(unsigned int regulator);
int pmu_regulator_off(unsigned int regulator);

/*************/
/* power off */
/*************/
void pmu_power_off(void);


#endif /* __ICX_PMU_H__ */

