static int __init msm8930_audio_init(void) { int ret; if (!cpu_is_msm8930() && !cpu_is_msm8930aa() && !cpu_is_msm8627()) { pr_err("%s: Not the right machine type\n", __func__); return -ENODEV ; } mbhc_cfg.calibration = def_sitar_mbhc_cal(); if (!mbhc_cfg.calibration) { pr_err("Calibration data allocation failed\n"); return -ENOMEM; } msm8930_snd_device = platform_device_alloc("soc-audio", 0); if (!msm8930_snd_device) { pr_err("Platform device allocation failed\n"); kfree(mbhc_cfg.calibration); return -ENOMEM; } platform_set_drvdata(msm8930_snd_device, &snd_soc_card_msm8930); ret = platform_device_add(msm8930_snd_device); if (ret) { platform_device_put(msm8930_snd_device); kfree(mbhc_cfg.calibration); return ret; } if (msm8930_configure_headset_mic_gpios()) { pr_err("%s Fail to configure headset mic gpios\n", __func__); msm8930_headset_gpios_configured = 0; } else msm8930_headset_gpios_configured = 1; atomic_set(&auxpcm_rsc_ref, 0); return ret; }
/* ZTE_Audio_LCX_130325, lichaoxia, 2013-03-25, end */ static int msm8930_configure_headset_mic_gpios(void) { int ret; /* ZTE_Audio_LCX_130325, lichaoxia, 2013-03-25, start */ #if defined(CONFIG_US_EURO_SWITCH) struct pm_gpio param = { .direction = PM_GPIO_DIR_OUT, .output_buffer = PM_GPIO_OUT_BUF_CMOS, .output_value = 1, .pull = PM_GPIO_PULL_NO, .vin_sel = PM_GPIO_VIN_S4, .out_strength = PM_GPIO_STRENGTH_MED, .function = PM_GPIO_FUNC_NORMAL, }; ret = gpio_request(us_euro_sel_gpio, "US_EURO_SWITCH"); if (ret) { pr_err("%s: Failed to request gpio %d\n", __func__, us_euro_sel_gpio); return ret; } ret = pm8xxx_gpio_config(us_euro_sel_gpio, ¶m); if (ret) pr_err("%s: Failed to configure gpio %d\n", __func__, us_euro_sel_gpio); else gpio_direction_output(us_euro_sel_gpio, 0); #else if (!us_euro_gpio) return 0; ret = gpio_request(80, "US_EURO_SWITCH"); if (ret) { pr_err("%s: Failed to request gpio 80\n", __func__); return ret; } ret = gpio_direction_output(80, 0); if (ret) { pr_err("%s: Unable to set direction\n", __func__); gpio_free(80); return ret; } #endif /* ZTE_Audio_LCX_130325, lichaoxia, 2013-03-25, end */ msm8930_useuro_gpio_requested = 1; return 0; } static void msm8930_free_headset_mic_gpios(void) { if (msm8930_useuro_gpio_requested) { /* ZTE_Audio_LCX_130325, lichaoxia, 2013-03-25, start */ #if defined(CONFIG_US_EURO_SWITCH) gpio_free(us_euro_sel_gpio); #else gpio_free(80); #endif /* ZTE_Audio_LCX_130325, lichaoxia, 2013-03-25, end */ msm8930_useuro_gpio_requested = 0; } } static int __init msm8930_audio_init(void) { int ret; if (!soc_class_is_msm8930()) { pr_err("%s: Not the right machine type\n", __func__); return -ENODEV ; } mbhc_cfg.calibration = def_sitar_mbhc_cal(); if (!mbhc_cfg.calibration) { pr_err("Calibration data allocation failed\n"); return -ENOMEM; } msm8930_snd_device = platform_device_alloc("soc-audio", 0); if (!msm8930_snd_device) { pr_err("Platform device allocation failed\n"); kfree(mbhc_cfg.calibration); return -ENOMEM; } platform_set_drvdata(msm8930_snd_device, &snd_soc_card_msm8930); ret = platform_device_add(msm8930_snd_device); if (ret) { platform_device_put(msm8930_snd_device); kfree(mbhc_cfg.calibration); return ret; } if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE) us_euro_gpio = GPIO_HS_US_EURO_SEL_GPIO_SGLTE; else us_euro_gpio = GPIO_HS_US_EURO_SEL_GPIO; if (msm8930_configure_headset_mic_gpios()) pr_err("%s Fail to configure headset mic gpios\n", __func__); atomic_set(&auxpcm_rsc_ref, 0); mutex_init(&cdc_mclk_mutex); return ret; }