mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-10 12:57:06 +09:00
rk31:ricoh619:modify fg and charger
This commit is contained in:
@@ -441,10 +441,31 @@ static struct regulator_init_data ricoh619_ldortc1 = {
|
||||
};
|
||||
|
||||
static struct ricoh619_battery_platform_data ricoh619_power_battery = {
|
||||
.irq = IRQ_BOARD_BASE,
|
||||
.irq = IRQ_BOARD_BASE,//INT_PMIC_BASE,
|
||||
.alarm_vol_mv = 3300,
|
||||
.multiple =0,
|
||||
.monitor_time = 1,
|
||||
.multiple = 100,
|
||||
.monitor_time = 60,
|
||||
|
||||
//4200mv type battery
|
||||
|
||||
.ch_vfchg = 0xFF, /* VFCHG = 0x0-0x4 (4.05v 4.10v 4.15v 4.20v 4.35v) 0xFF is OTP setting*/
|
||||
.ch_vrchg = 0xFF, /* VRCHG = 0x0-0x4 (3.85v 3.90v 3.95v 4.00v 4.10v) 0xFF is OTP setting*/
|
||||
.ch_vbatovset = 0xFF, /* VBATOVSET = 0 or 1 (0 : 4.38V(up)/3.95V(down) 1: 4.53V(up)/4.10V(down))
|
||||
0xFF is OTP setting*/
|
||||
.ch_ichg = 0xFF, /* ICHG = 0x0-0x1D (100mA - 3000mA) 0xFF is OTP setting*/
|
||||
.ch_icchg = 0x03, /* ICCHG = 0x0-3 (50mA 100mA 150mA 200mA) 0xFF is OTP setting*/
|
||||
.ch_ilim_adp = 0xFF, /* ILIM_ADP = 0x0-0x1D (100mA - 3000mA) */
|
||||
.ch_ilim_usb = 0xFF, /* ILIM_USB = 0x0-0x1D (100mA - 3000mA) */
|
||||
.fg_target_vsys = 3200, /* This value is the target one to DSOC=0% */
|
||||
.fg_target_ibat = 2000, /* This value is the target one to DSOC=0% */
|
||||
.jt_en = 0, /* JEITA Switch = 1:enable, 0:disable */
|
||||
.jt_hw_sw = 1, /* JEITA is controlled by 1:HW, 0:SW */
|
||||
.jt_temp_h = 50, /* degree C */
|
||||
.jt_temp_l = 12, /* degree C */
|
||||
.jt_vfchg_h = 0x03, /* VFCHG High = 0 - 0x04 (4.05, 4.10, 4.15, 4.20, 4.35V) */
|
||||
.jt_vfchg_l = 0, /* VFCHG Low = 0 - 0x04 (4.05, 4.10, 4.15, 4.20, 4.35V) */
|
||||
.jt_ichg_h = 0x0D, /* ICHG High = 0 - 0x1D (100 - 3000mA) */
|
||||
.jt_ichg_l = 0x09, /* ICHG Low = 0 - 0x1D (100 - 3000mA) */
|
||||
};
|
||||
|
||||
static struct rtc_time rk_time = { // 2012.1.1 12:00:00 Saturday
|
||||
|
||||
24
drivers/mfd/ricoh619.c
Executable file → Normal file
24
drivers/mfd/ricoh619.c
Executable file → Normal file
@@ -24,7 +24,6 @@
|
||||
*/
|
||||
/*#define DEBUG 1*/
|
||||
/*#define VERBOSE_DEBUG 1*/
|
||||
#define CONFIG_DEBUG_FS
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/irq.h>
|
||||
#include <linux/kernel.h>
|
||||
@@ -35,6 +34,7 @@
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/mfd/core.h>
|
||||
#include <linux/mfd/ricoh619.h>
|
||||
#include <linux/power/ricoh619_battery.h>
|
||||
|
||||
|
||||
struct ricoh619 *g_ricoh619;
|
||||
@@ -381,10 +381,15 @@ int ricoh619_power_off(void)
|
||||
int ret;
|
||||
uint8_t val;
|
||||
int err = -1;
|
||||
int status, charge_state;
|
||||
struct ricoh619 *ricoh619 = g_ricoh619;
|
||||
|
||||
val = g_soc;
|
||||
val &= 0x7f;
|
||||
ricoh619_read(ricoh619->dev, 0xBD, &status);
|
||||
charge_state = (status & 0x1F);
|
||||
// supply_state = ((status & 0xC0) >> 6);
|
||||
|
||||
ret = ricoh619_write(ricoh619->dev, RICOH619_PSWR, val);
|
||||
if (ret < 0)
|
||||
dev_err(ricoh619->dev, "Error in writing PSWR_REG\n");
|
||||
@@ -395,12 +400,22 @@ int ricoh619_power_off(void)
|
||||
if (ret < 0)
|
||||
dev_err(ricoh619->dev, "Error in writing FG_CTRL\n");
|
||||
}
|
||||
|
||||
/* set rapid timer 300 min */
|
||||
err = ricoh619_set_bits(ricoh619->dev, TIMSET_REG, 0x03);
|
||||
if (err < 0)
|
||||
dev_err(ricoh619->dev, "Error in writing the TIMSET_Reg\n");
|
||||
|
||||
ret = ricoh619_write(ricoh619->dev, RICOH619_INTC_INTEN, 0);
|
||||
|
||||
if (!ricoh619_i2c_client)
|
||||
return -EINVAL;
|
||||
//__ricoh618_write(ricoh618_i2c_client, RICOH618_PWR_REP_CNT, 0x0); //Not repeat power ON after power off(Power Off/N_OE)
|
||||
// __ricoh618_write(ricoh618_i2c_client, RICOH618_PWR_SLP_CNT, 0x1); //Power OFF
|
||||
ret = ricoh619_clr_bits(ricoh619->dev,RICOH619_PWR_REP_CNT,(0x1<<0));//Not repeat power ON after power off(Power Off/N_OE)
|
||||
|
||||
if(( charge_state == CHG_STATE_CHG_TRICKLE)||( charge_state == CHG_STATE_CHG_RAPID))
|
||||
ricoh619_set_bits(ricoh619->dev, RICOH619_PWR_REP_CNT,(0x1<<0));//Power OFF
|
||||
ret = ricoh619_set_bits(ricoh619->dev, RICOH619_PWR_SLP_CNT,(0x1<<0));//Power OFF
|
||||
if (ret < 0) {
|
||||
printk("ricoh619 power off error!\n");
|
||||
@@ -700,7 +715,7 @@ static int ricoh619_i2c_probe(struct i2c_client *client,
|
||||
mutex_init(&ricoh619->io_lock);
|
||||
|
||||
ret = ricoh619_read(ricoh619->dev, 0x36, &control);
|
||||
if ((control < 0) || (control == 0x00)) {
|
||||
if ((control < 0) || (control == 0xff)) {
|
||||
printk(KERN_INFO "The device is not ricoh619\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -801,11 +816,6 @@ static int ricoh619_i2c_resume(struct i2c_client *client)
|
||||
__ricoh619_write(client, RICOH619_INT_IR_SYS, 0x0); //Clear PWR_KEY IRQ
|
||||
}
|
||||
|
||||
//__ricoh619_write(client, RICOH619_INT_IR_CHGCTR, 0);
|
||||
//__ricoh619_write(client, RICOH619_INT_IR_CHGSTS1, 0);
|
||||
__ricoh619_write(client, RICOH619_INT_IR_ADCL, 0);
|
||||
__ricoh619_write(client, RICOH619_INT_IR_ADCH, 0);
|
||||
|
||||
enable_irq(client->irq);
|
||||
return 0;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -116,6 +116,7 @@
|
||||
|
||||
/* Charger Control register */
|
||||
#define RICOH619_CHG_CTL1 0xB3
|
||||
#define TIMSET_REG 0xB9
|
||||
|
||||
/* ADC Control register */
|
||||
#define RICOH619_ADC_CNT1 0x64
|
||||
|
||||
20
include/linux/power/ricoh619_battery.h
Normal file → Executable file
20
include/linux/power/ricoh619_battery.h
Normal file → Executable file
@@ -39,6 +39,7 @@
|
||||
/* 619 Register information */
|
||||
/* bank 0 */
|
||||
#define PSWR_REG 0x07
|
||||
#define VINDAC_REG 0x03
|
||||
/* for ADC */
|
||||
#define INTEN_REG 0x9D
|
||||
#define EN_ADCIR3_REG 0x8A
|
||||
@@ -53,6 +54,7 @@
|
||||
#define REGISET1_REG 0xB6
|
||||
#define REGISET2_REG 0xB7
|
||||
#define CHGISET_REG 0xB8
|
||||
#define BATSET1_REG 0xBA
|
||||
#define BATSET2_REG 0xBB
|
||||
|
||||
#define CHGSTATE_REG 0xBD
|
||||
@@ -84,6 +86,7 @@
|
||||
/* Top address for battery initial setting */
|
||||
#define BAT_INIT_TOP_REG 0xBC
|
||||
#define BAT_REL_SEL_REG 0xDA
|
||||
#define BAT_TA_SEL_REG 0xDB
|
||||
/**************************/
|
||||
|
||||
/* detailed status in CHGSTATE (0xBD) */
|
||||
@@ -116,6 +119,23 @@ struct ricoh619_battery_platform_data {
|
||||
int alarm_vol_mv;
|
||||
int multiple;
|
||||
unsigned long monitor_time;
|
||||
int ch_vfchg;
|
||||
int ch_vrchg;
|
||||
int ch_vbatovset;
|
||||
int ch_ichg;
|
||||
int ch_ilim_adp;
|
||||
int ch_ilim_usb;
|
||||
int ch_icchg;
|
||||
int fg_target_vsys;
|
||||
int fg_target_ibat;
|
||||
int jt_en;
|
||||
int jt_hw_sw;
|
||||
int jt_temp_h;
|
||||
int jt_temp_l;
|
||||
int jt_vfchg_h;
|
||||
int jt_vfchg_l;
|
||||
int jt_ichg_h;
|
||||
int jt_ichg_l;
|
||||
};
|
||||
|
||||
extern struct ricoh619 *g_ricoh619;
|
||||
|
||||
2
include/linux/power/ricoh61x_battery_init.h
Normal file → Executable file
2
include/linux/power/ricoh61x_battery_init.h
Normal file → Executable file
@@ -24,7 +24,7 @@
|
||||
#define __LINUX_POWER_RICOH61X_BATTERY_INIT_H
|
||||
|
||||
|
||||
uint8_t battery_init_para[32] = {
|
||||
uint8_t battery_init_para[][32] = {
|
||||
0x0B, 0x3F, 0x0B, 0xCB, 0x0B, 0xEE, 0x0C, 0x08, 0x0C, 0x1E, 0x0C, 0x38, 0x0C, 0x5B, 0x0C, 0x94,
|
||||
0x0C, 0xC8, 0x0D, 0x08, 0x0D, 0x55, 0x0E, 0x14, 0x00, 0x39, 0x0F, 0xC8, 0x05, 0x2C, 0x22, 0x56
|
||||
// 0x0C, 0xC8, 0x0D, 0x08, 0x0D, 0x55, 0x0E, 0x14, 0x00, 0x3E, 0x0F, 0xC8, 0x05, 0x2C, 0x22, 0x56 //150ohme
|
||||
|
||||
Reference in New Issue
Block a user