mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 20:07:46 +09:00
rk30:sdk:modify i2c communication of wm8326 and modify init name and voltage
This commit is contained in:
@@ -72,7 +72,7 @@ static int wm831x_pre_init(struct wm831x *parm)
|
||||
{
|
||||
int ret;
|
||||
|
||||
printk("%s\n", __func__);
|
||||
// printk("%s\n", __func__);
|
||||
//ILIM = 900ma
|
||||
ret = wm831x_reg_read(parm, WM831X_POWER_STATE) & 0xffff;
|
||||
wm831x_reg_write(parm, WM831X_POWER_STATE, (ret & 0xfff8) | 0x04);
|
||||
@@ -81,9 +81,14 @@ static int wm831x_pre_init(struct wm831x *parm)
|
||||
wm831x_reg_write(parm, WM831X_SECURITY_KEY, 0x9716); // unlock security key
|
||||
wm831x_set_bits(parm, WM831X_RESET_CONTROL, 0x1000, 0x1000);
|
||||
ret = wm831x_reg_read(parm, WM831X_RESET_CONTROL) & 0xffff & UNLOCK_SECURITY_KEY; // enternal reset active in sleep
|
||||
printk("%s:WM831X_RESET_CONTROL=0x%x\n", __func__, ret);
|
||||
// printk("%s:WM831X_RESET_CONTROL=0x%x\n", __func__, ret);
|
||||
wm831x_reg_write(parm, WM831X_RESET_CONTROL, ret);
|
||||
|
||||
wm831x_set_bits(parm,WM831X_DC1_ON_CONFIG ,0x0300,0x0000); //set dcdc mode is FCCM
|
||||
wm831x_set_bits(parm,WM831X_DC2_ON_CONFIG ,0x0300,0x0000);
|
||||
wm831x_set_bits(parm,WM831X_DC3_ON_CONFIG ,0x0300,0x0000);
|
||||
wm831x_set_bits(parm,0x4066,0x0300,0x0000);
|
||||
|
||||
wm831x_reg_write(parm, WM831X_SECURITY_KEY, LOCK_SECURITY_KEY); // lock security key
|
||||
|
||||
return 0;
|
||||
@@ -99,7 +104,7 @@ int wm831x_post_init(struct wm831x *Wm831x)
|
||||
regulator_set_voltage(ldo, 3300000, 3300000);
|
||||
regulator_set_suspend_voltage(ldo, 3300000);
|
||||
regulator_enable(ldo);
|
||||
printk("%s set ldo6 vcc_33=%dmV end\n", __func__, regulator_get_voltage(ldo));
|
||||
// printk("%s set ldo6 vcc_33=%dmV end\n", __func__, regulator_get_voltage(ldo));
|
||||
regulator_put(ldo);
|
||||
udelay(100);
|
||||
|
||||
@@ -107,7 +112,7 @@ int wm831x_post_init(struct wm831x *Wm831x)
|
||||
regulator_set_voltage(ldo, 1100000, 1100000);
|
||||
regulator_set_suspend_voltage(ldo, 1100000);
|
||||
regulator_enable(ldo);
|
||||
printk("%s set ldo4 vdd_11=%dmV end\n", __func__, regulator_get_voltage(ldo));
|
||||
// printk("%s set ldo4 vdd_11=%dmV end\n", __func__, regulator_get_voltage(ldo));
|
||||
regulator_put(ldo);
|
||||
udelay(100);
|
||||
|
||||
@@ -115,30 +120,30 @@ int wm831x_post_init(struct wm831x *Wm831x)
|
||||
regulator_set_voltage(ldo, 1800000, 1800000);
|
||||
regulator_set_suspend_voltage(ldo, 1800000);
|
||||
regulator_enable(ldo);
|
||||
printk("%s set ldo5 vcc_25=%dmV end\n", __func__, regulator_get_voltage(ldo));
|
||||
// printk("%s set ldo5 vcc_25=%dmV end\n", __func__, regulator_get_voltage(ldo));
|
||||
regulator_put(ldo);
|
||||
|
||||
dcdc = regulator_get(NULL, "dcdc4"); // vcc_io
|
||||
regulator_set_voltage(dcdc, 3000000, 3000000);
|
||||
regulator_set_suspend_voltage(dcdc, 3000000);
|
||||
regulator_enable(dcdc);
|
||||
printk("%s set dcdc4 vcc_io=%dmV end\n", __func__, regulator_get_voltage(dcdc));
|
||||
// printk("%s set dcdc4 vcc_io=%dmV end\n", __func__, regulator_get_voltage(dcdc));
|
||||
regulator_put(dcdc);
|
||||
udelay(100);
|
||||
|
||||
dcdc = regulator_get(NULL, "dcdc2"); // vdd_arm
|
||||
dcdc = regulator_get(NULL, "vdd_cpu"); // vdd_arm
|
||||
regulator_set_voltage(dcdc, 1100000, 1100000);
|
||||
regulator_set_suspend_voltage(dcdc, 1000000);
|
||||
regulator_enable(dcdc);
|
||||
printk("%s set dcdc2 vdd_arm=%dmV end\n", __func__, regulator_get_voltage(dcdc));
|
||||
printk("%s set dcdc2 vdd_cpu(vdd_arm)=%dmV end\n", __func__, regulator_get_voltage(dcdc));
|
||||
regulator_put(dcdc);
|
||||
udelay(100);
|
||||
|
||||
dcdc = regulator_get(NULL, "dcdc1"); // vdd_log
|
||||
dcdc = regulator_get(NULL, "vdd_core"); // vdd_log
|
||||
regulator_set_voltage(dcdc, 1100000, 1100000);
|
||||
regulator_set_suspend_voltage(dcdc, 1100000);
|
||||
regulator_enable(dcdc);
|
||||
printk("%s set dcdc1 vdd_log=%dmV end\n", __func__, regulator_get_voltage(dcdc));
|
||||
printk("%s set dcdc1 vdd_core(vdd_log)=%dmV end\n", __func__, regulator_get_voltage(dcdc));
|
||||
regulator_put(dcdc);
|
||||
udelay(100);
|
||||
|
||||
@@ -146,7 +151,7 @@ int wm831x_post_init(struct wm831x *Wm831x)
|
||||
regulator_set_voltage(dcdc, 1150000, 1150000);
|
||||
regulator_set_suspend_voltage(dcdc, 1150000);
|
||||
regulator_enable(dcdc);
|
||||
printk("%s set dcdc3 vcc_ddr=%dmV end\n", __func__, regulator_get_voltage(dcdc));
|
||||
// printk("%s set dcdc3 vcc_ddr=%dmV end\n", __func__, regulator_get_voltage(dcdc));
|
||||
regulator_put(dcdc);
|
||||
udelay(100);
|
||||
|
||||
@@ -154,7 +159,7 @@ int wm831x_post_init(struct wm831x *Wm831x)
|
||||
regulator_set_voltage(ldo, 2800000, 2800000);
|
||||
regulator_set_suspend_voltage(ldo, 2800000);
|
||||
regulator_enable(ldo);
|
||||
printk("%s set ldo7 vcc28_cif=%dmV end\n", __func__, regulator_get_voltage(ldo));
|
||||
// printk("%s set ldo7 vcc28_cif=%dmV end\n", __func__, regulator_get_voltage(ldo));
|
||||
regulator_put(ldo);
|
||||
udelay(100);
|
||||
|
||||
@@ -162,7 +167,7 @@ int wm831x_post_init(struct wm831x *Wm831x)
|
||||
regulator_set_voltage(ldo, 1800000, 1800000);
|
||||
regulator_set_suspend_voltage(ldo, 1800000);
|
||||
regulator_enable(ldo);
|
||||
printk("%s set ldo1 vcc18_cif=%dmV end\n", __func__, regulator_get_voltage(ldo));
|
||||
// printk("%s set ldo1 vcc18_cif=%dmV end\n", __func__, regulator_get_voltage(ldo));
|
||||
regulator_put(ldo);
|
||||
udelay(100);
|
||||
|
||||
@@ -170,15 +175,15 @@ int wm831x_post_init(struct wm831x *Wm831x)
|
||||
regulator_set_voltage(ldo, 3300000, 3300000);
|
||||
regulator_set_suspend_voltage(ldo, 3300000);
|
||||
regulator_enable(ldo);
|
||||
printk("%s set ldo8 vcca_33=%dmV end\n", __func__, regulator_get_voltage(ldo));
|
||||
// printk("%s set ldo8 vcca_33=%dmV end\n", __func__, regulator_get_voltage(ldo));
|
||||
regulator_put(ldo);
|
||||
udelay(100);
|
||||
|
||||
ldo = regulator_get(NULL, "ldo2"); //vccio_wl
|
||||
regulator_set_voltage(ldo, 2800000, 2800000);
|
||||
regulator_set_suspend_voltage(ldo, 2800000);
|
||||
regulator_set_voltage(ldo, 1800000, 1800000);
|
||||
regulator_set_suspend_voltage(ldo, 1800000);
|
||||
regulator_enable(ldo);
|
||||
printk("%s set ldo2 vccio_wl=%dmV end\n", __func__, regulator_get_voltage(ldo));
|
||||
// printk("%s set ldo2 vccio_wl=%dmV end\n", __func__, regulator_get_voltage(ldo));
|
||||
regulator_put(ldo);
|
||||
udelay(100);
|
||||
|
||||
@@ -186,7 +191,7 @@ int wm831x_post_init(struct wm831x *Wm831x)
|
||||
regulator_set_voltage(ldo, 3300000, 3300000);
|
||||
regulator_set_suspend_voltage(ldo, 3300000);
|
||||
regulator_enable(ldo);
|
||||
printk("%s set ldo10 vcca_wl=%dmV end\n", __func__, regulator_get_voltage(ldo));
|
||||
// printk("%s set ldo10 vcca_wl=%dmV end\n", __func__, regulator_get_voltage(ldo));
|
||||
regulator_put(ldo);
|
||||
udelay(100);
|
||||
|
||||
@@ -194,7 +199,7 @@ int wm831x_post_init(struct wm831x *Wm831x)
|
||||
regulator_set_voltage(ldo, 1200000, 1200000);
|
||||
regulator_set_suspend_voltage(ldo, 1200000);
|
||||
regulator_enable(ldo);
|
||||
printk("%s set ldo3 vdd_12=%dmV end\n", __func__, regulator_get_voltage(ldo));
|
||||
// printk("%s set ldo3 vdd_12=%dmV end\n", __func__, regulator_get_voltage(ldo));
|
||||
regulator_put(ldo);
|
||||
udelay(100);
|
||||
|
||||
@@ -202,11 +207,11 @@ int wm831x_post_init(struct wm831x *Wm831x)
|
||||
regulator_set_voltage(ldo, 3300000, 3300000);
|
||||
regulator_set_suspend_voltage(ldo, 3300000);
|
||||
regulator_enable(ldo);
|
||||
printk("%s set ldo9 vcc_tp=%dmV end\n", __func__, regulator_get_voltage(ldo));
|
||||
// printk("%s set ldo9 vcc_tp=%dmV end\n", __func__, regulator_get_voltage(ldo));
|
||||
regulator_put(ldo);
|
||||
udelay(100);
|
||||
|
||||
|
||||
printk("wm831x_post_init end");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -273,17 +278,15 @@ struct wm831x_status_pdata wm831x_status_platdata[WM831X_MAX_STATUS] = {
|
||||
|
||||
static struct regulator_consumer_supply dcdc1_consumers[] = {
|
||||
{
|
||||
.supply = "dcdc1",
|
||||
.supply = "vdd_core",
|
||||
}
|
||||
};
|
||||
|
||||
static struct regulator_consumer_supply dcdc2_consumers[] = {
|
||||
{
|
||||
.supply = "dcdc2",
|
||||
},
|
||||
// {
|
||||
// .supply = "vcore",
|
||||
//}
|
||||
.supply = "vdd_cpu",
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
static struct regulator_consumer_supply dcdc3_consumers[] = {
|
||||
|
||||
@@ -1679,17 +1679,17 @@ int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)
|
||||
wm831x_otp_init(wm831x);
|
||||
|
||||
if (pdata && pdata->post_init) {
|
||||
wm831x_reg_unlock(wm831x);
|
||||
wm831x_reg_write(wm831x, WM831X_SECURITY_KEY, 0x9716); //wm831x_reg_unlock
|
||||
wm831x_set_bits(wm831x, WM831X_RESET_CONTROL,0x0010,0x0000);
|
||||
wm831x_set_bits(wm831x, WM831X_LDO_ENABLE,0Xf800,0Xf800);
|
||||
ret = pdata->post_init(wm831x);
|
||||
wm831x_reg_lock(wm831x);
|
||||
wm831x_reg_write(wm831x, WM831X_SECURITY_KEY, 0x0000); //wm831x_reg_lock
|
||||
if (ret != 0) {
|
||||
dev_err(wm831x->dev, "post_init() failed: %d\n", ret);
|
||||
goto err_irq;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
err_irq:
|
||||
@@ -1761,8 +1761,8 @@ int wm831x_device_suspend(struct wm831x *wm831x)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void wm831x_enter_sleep(void){
|
||||
#if 1//def CONFIG_RK2818_SOC_PM
|
||||
struct regulator *dcdc = regulator_get(NULL, "dcdc1");
|
||||
int i;
|
||||
struct wm831x_dcdc *dc = regulator_get_drvdata(dcdc);
|
||||
@@ -1778,12 +1778,10 @@ void wm831x_enter_sleep(void){
|
||||
printk("%s:error!",__func__);
|
||||
}
|
||||
regulator_put(dcdc);
|
||||
#endif
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(wm831x_enter_sleep);
|
||||
|
||||
void wm831x_exit_sleep(void){
|
||||
#if 1//def CONFIG_RK2818_SOC_PM
|
||||
struct regulator *dcdc = regulator_get(NULL, "dcdc1");
|
||||
struct wm831x_dcdc *dc = regulator_get_drvdata(dcdc);
|
||||
struct wm831x *wm831x = dc->wm831x;
|
||||
@@ -1795,7 +1793,6 @@ void wm831x_exit_sleep(void){
|
||||
printk("%s:error!",__func__);
|
||||
}
|
||||
regulator_put(dcdc);
|
||||
#endif
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(wm831x_exit_sleep);
|
||||
|
||||
@@ -1810,7 +1807,6 @@ int wm831x_device_shutdown(struct wm831x *wm831x)
|
||||
ret = pdata->last_deinit(wm831x);
|
||||
if (ret != 0) {
|
||||
dev_info(wm831x->dev, "last_deinit() failed: %d\n", ret);
|
||||
//goto err_irq;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,36 @@
|
||||
static int wm831x_i2c_read_device(struct wm831x *wm831x, unsigned short reg,
|
||||
int bytes, void *dest)
|
||||
{
|
||||
#if defined(CONFIG_ARCH_RK30)
|
||||
const struct i2c_client *client = wm831x->control_data;
|
||||
struct i2c_adapter *adap=client->adapter;
|
||||
struct i2c_msg msgs[2];
|
||||
int ret;
|
||||
char reg_buf[2];
|
||||
const short regs = reg;
|
||||
int scl_rate= 100 * 1000;
|
||||
short *buf = dest;
|
||||
int count = bytes/2;
|
||||
|
||||
reg_buf[0] = (regs & 0xff00) >> 8;
|
||||
reg_buf[1] = regs & 0x00ff;
|
||||
|
||||
msgs[0].addr = client->addr;
|
||||
msgs[0].flags = client->flags;
|
||||
msgs[0].len = 2;
|
||||
msgs[0].buf = reg_buf;
|
||||
msgs[0].scl_rate = scl_rate;
|
||||
|
||||
msgs[1].addr = client->addr;
|
||||
msgs[1].flags = client->flags | I2C_M_RD;
|
||||
msgs[1].len = count * 2;
|
||||
msgs[1].buf = (char *)buf;
|
||||
msgs[1].scl_rate = scl_rate;
|
||||
|
||||
ret = i2c_transfer(adap, msgs, 2);
|
||||
|
||||
return (ret == 2)? count : ret;
|
||||
#else
|
||||
struct i2c_client *i2c = wm831x->control_data;
|
||||
int ret;
|
||||
u16 r = cpu_to_be16(reg);
|
||||
@@ -42,6 +72,7 @@ static int wm831x_i2c_read_device(struct wm831x *wm831x, unsigned short reg,
|
||||
if (ret != bytes)
|
||||
return -EIO;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Currently we allocate the write buffer on the stack; this is OK for
|
||||
@@ -51,6 +82,37 @@ static int wm831x_i2c_read_device(struct wm831x *wm831x, unsigned short reg,
|
||||
static int wm831x_i2c_write_device(struct wm831x *wm831x, unsigned short reg,
|
||||
int bytes, void *src)
|
||||
{
|
||||
#if defined(CONFIG_ARCH_RK30)
|
||||
const struct i2c_client *client = wm831x->control_data;
|
||||
struct i2c_adapter *adap=client->adapter;
|
||||
struct i2c_msg msg;
|
||||
int ret;
|
||||
const short regs = reg;
|
||||
const short *buf = src;
|
||||
int count = bytes/2;
|
||||
int scl_rate = 100 * 1000;
|
||||
int i;
|
||||
|
||||
char *tx_buf = (char *)kmalloc(2 * (count + 1), GFP_KERNEL);
|
||||
if(!tx_buf)
|
||||
return -ENOMEM;
|
||||
tx_buf[0] = (regs & 0xff00) >> 8;
|
||||
tx_buf[1] = regs & 0x00ff;
|
||||
for(i = 0; i < count; i++){
|
||||
tx_buf[i*2+3] = (buf[i] & 0xff00) >> 8;
|
||||
tx_buf[i*2+2] = buf[i] & 0x00ff;
|
||||
}
|
||||
|
||||
msg.addr = client->addr;
|
||||
msg.flags = client->flags;
|
||||
msg.len = 2 * (count + 1);
|
||||
msg.buf = (char *)tx_buf;
|
||||
msg.scl_rate = scl_rate;
|
||||
|
||||
ret = i2c_transfer(adap, &msg, 1);
|
||||
kfree(tx_buf);
|
||||
return (ret == 1) ? count : ret;
|
||||
#else
|
||||
struct i2c_client *i2c = wm831x->control_data;
|
||||
unsigned char msg[bytes + 2];
|
||||
int ret;
|
||||
@@ -66,6 +128,7 @@ static int wm831x_i2c_write_device(struct wm831x *wm831x, unsigned short reg,
|
||||
return -EIO;
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int wm831x_i2c_probe(struct i2c_client *i2c,
|
||||
|
||||
@@ -914,7 +914,7 @@ static int set_machine_constraints(struct regulator_dev *rdev,
|
||||
}
|
||||
}
|
||||
|
||||
print_constraints(rdev);
|
||||
// print_constraints(rdev);
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -324,7 +324,7 @@ static __devinit int wm831x_gp_ldo_probe(struct platform_device *pdev)
|
||||
int ret, irq;
|
||||
|
||||
dev_dbg(&pdev->dev, "Probing LDO%d\n", id + 1);
|
||||
printk("Probing LDO%d\n", id + 1);
|
||||
// printk("Probing LDO%d\n", id + 1);
|
||||
if (pdata == NULL || pdata->ldo[id] == NULL)
|
||||
return -ENODEV;
|
||||
|
||||
@@ -455,7 +455,7 @@ static int wm831x_aldo_set_voltage(struct regulator_dev *rdev,
|
||||
{
|
||||
struct wm831x_ldo *ldo = rdev_get_drvdata(rdev);
|
||||
int reg = ldo->base + WM831X_LDO_ON_CONTROL;
|
||||
printk("%s base=%x,min_uV=%d,%d\n", __FUNCTION__,ldo->base,min_uV,max_uV);
|
||||
//printk("%s base=%x,min_uV=%d,%d\n", __FUNCTION__,ldo->base,min_uV,max_uV);
|
||||
return wm831x_aldo_set_voltage_int(rdev, reg, min_uV, max_uV);
|
||||
}
|
||||
|
||||
@@ -586,7 +586,7 @@ static __devinit int wm831x_aldo_probe(struct platform_device *pdev)
|
||||
int ret, irq;
|
||||
|
||||
dev_dbg(&pdev->dev, "Probing LDO%d\n", id + 1);
|
||||
printk("Probing LDO%d--\n", id + 1);
|
||||
// printk("Probing LDO%d--\n", id + 1);
|
||||
if (pdata == NULL || pdata->ldo[id] == NULL)
|
||||
return -ENODEV;
|
||||
|
||||
@@ -774,7 +774,7 @@ static __devinit int wm831x_alive_ldo_probe(struct platform_device *pdev)
|
||||
int ret;
|
||||
|
||||
dev_dbg(&pdev->dev, "Probing LDO%d\n", id + 1);
|
||||
printk("wm831x_alive_ldo_probe Probing LDO%d\n", id + 1);
|
||||
// printk("wm831x_alive_ldo_probe Probing LDO%d\n", id + 1);
|
||||
if (pdata == NULL || pdata->ldo[id] == NULL)
|
||||
return -ENODEV;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user