1#
es8323: es8323@10 {
compatible = "es8323";
reg = <0x11>;//dou
spk-con-gpio = <&gpio6 GPIO_B2 GPIO_ACTIVE_LOW>;//sd
hp-det-gpio = <&gpio6 GPIO_B1 GPIO_ACTIVE_LOW>;//modify HP-IN
hp-mic-only = <0>;
2#
static int es8323_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
struct es8323_priv *es8323;
int ret = -1;
unsigned long irq_flag=0;
int hp_irq = 0;
enum of_gpio_flags flags;
struct i2c_adapter *adapter = to_i2c_adapter(i2c->dev.parent);
char reg;
if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
dev_warn(&adapter->dev,
"I2C-Adapter doesn't support I2C_FUNC_I2C\n");
return -EIO;
}
es8323 = devm_kzalloc(&i2c->dev,sizeof(struct es8323_priv), GFP_KERNEL);
if (es8323 == NULL)
return -ENOMEM;
i2c_set_clientdata(i2c, es8323);
es8323->control_type = SND_SOC_I2C;
reg = ES8323_DACCONTROL18;
ret = i2c_master_recv(i2c, ®, 1);
if (ret < 0){
printk("es8323 probe error\n");
return ret;
}
es8323_private = es8323;
es8323->spk_ctl_gpio = of_get_named_gpio_flags(i2c->dev.of_node, "spk-con-gpio", 0, &flags);
if (es8323->spk_ctl_gpio < 0) {
DBG("%s() Can not read property spk codec-en-gpio\n", __FUNCTION__);
es8323->spk_ctl_gpio = INVALID_GPIO;
}
else
{
es8323->spk_gpio_level = (flags & OF_GPIO_ACTIVE_LOW)? 0:1;
ret = gpio_request(es8323->spk_ctl_gpio, NULL);
if (ret != 0) {
printk("%s request SPK_CON error", __func__);
return ret;
}
// gpio_direction_output(es8323->spk_ctl_gpio,!es8323->spk_gpio_level);
gpio_direction_output(es8323->spk_ctl_gpio,1);//rk3288_m180_v3_OK no Noise
msleep(50);
gpio_direction_output(es8323->spk_ctl_gpio,0);
msleep(50);
gpio_direction_output(es8323->spk_ctl_gpio,1);
}
es8323->hp_ctl_gpio = of_get_named_gpio_flags(i2c->dev.of_node, "hp-con-gpio", 0, &flags);
if (es8323->hp_ctl_gpio < 0) {
DBG("%s() Can not read property hp codec-en-gpio\n", __FUNCTION__);
es8323->hp_ctl_gpio = INVALID_GPIO;
}
else
{
es8323->hp_gpio_level = (flags & OF_GPIO_ACTIVE_LOW)? 0:1;
ret = gpio_request(es8323->hp_ctl_gpio, NULL);
if (ret != 0) {
printk("%s request hp_ctl error", __func__);
return ret;
}
gpio_direction_output(es8323->hp_ctl_gpio,!es8323->hp_gpio_level);
}
es8323->hp_det_gpio = of_get_named_gpio_flags(i2c->dev.of_node, "hp-det-gpio", 0, &flags);
if (es8323->hp_det_gpio < 0) {
DBG("%s() Can not read property hp_det gpio\n", __FUNCTION__);
es8323->hp_det_gpio = INVALID_GPIO;
}
else
{
es8323->hp_det_level = (flags & OF_GPIO_ACTIVE_LOW)? 0:1;
ret = gpio_request(es8323->hp_det_gpio, NULL);
if (ret != 0) {
printk("%s request HP_DET error", __func__);
return ret;
}
/* by jiangdou 2015-12-25 */
gpio_direction_output(es8323->hp_det_gpio, 0);
/* by jiangdou 2015-12-25 */
gpio_direction_input(es8323->hp_det_gpio);
irq_flag = IRQF_TRIGGER_HIGH;// |IRQF_ONESHOT; //by jiangdou 2015-12-25
hp_irq = gpio_to_irq(es8323->hp_det_gpio);
if (hp_irq){
ret = request_threaded_irq(hp_irq, NULL, hp_det_irq_handler, irq_flag, "ES8323", NULL);
if(ret == 0){
printk("%s:register ISR (irq=%d)\n", __FUNCTION__,hp_irq);
}
else
printk("request_irq hp_irq failed\n");
}
}
ret = snd_soc_register_codec(&i2c->dev,
&soc_codec_dev_es8323, &es8323_dai, 1);
if (ret < 0) {
return ret;
}
printk("es8323 probe i2c recv ok\n");
#ifdef CONFIG_MACH_RK_FAC
es8323_hdmi_ctrl=1;
#endif
return ret;
}
3#hardware_SCH
去掉电阻R200,R920,补焊R120-->>4.7K