static int __init msm8960_audio_init(void) { int ret; if (!cpu_is_msm8960() && !cpu_is_msm8930()) { pr_err("%s: Not the right machine type\n", __func__); return -ENODEV ; } mbhc_cfg.calibration = def_tabla_mbhc_cal(); if (!mbhc_cfg.calibration) { pr_err("Calibration data allocation failed\n"); return -ENOMEM; } msm8960_snd_device = platform_device_alloc("soc-audio", 0); if (!msm8960_snd_device) { pr_err("Platform device allocation failed\n"); kfree(mbhc_cfg.calibration); return -ENOMEM; } memcpy(msm8960_dai, msm8960_dai_common, sizeof(msm8960_dai_common)); memcpy(msm8960_dai + ARRAY_SIZE(msm8960_dai_common), msm8960_dai_delta_tabla2x, sizeof(msm8960_dai_delta_tabla2x)); platform_set_drvdata(msm8960_snd_device, &snd_soc_card_msm8960); ret = platform_device_add(msm8960_snd_device); if (ret) { platform_device_put(msm8960_snd_device); kfree(mbhc_cfg.calibration); return ret; } msm8960_snd_tabla1x_device = platform_device_alloc("soc-audio", 1); if (!msm8960_snd_tabla1x_device) { pr_err("Platform device allocation failed\n"); kfree(mbhc_cfg.calibration); return -ENOMEM; } memcpy(msm8960_tabla1x_dai, msm8960_dai_common, sizeof(msm8960_dai_common)); memcpy(msm8960_tabla1x_dai + ARRAY_SIZE(msm8960_dai_common), msm8960_dai_delta_tabla1x, sizeof(msm8960_dai_delta_tabla1x)); platform_set_drvdata(msm8960_snd_tabla1x_device, &snd_soc_tabla1x_card_msm8960); ret = platform_device_add(msm8960_snd_tabla1x_device); if (ret) { platform_device_put(msm8960_snd_tabla1x_device); kfree(mbhc_cfg.calibration); return -ENOMEM; return ret; } mutex_init(&cdc_mclk_mutex); return ret; }
static int msm8960_configure_headset_mic_gpios(void) { int ret; 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(PM8921_GPIO_PM_TO_SYS(23), "AV_SWITCH"); if (ret) { pr_err("%s: Failed to request gpio %d\n", __func__, PM8921_GPIO_PM_TO_SYS(23)); return ret; } ret = pm8xxx_gpio_config(PM8921_GPIO_PM_TO_SYS(23), ¶m); if (ret) pr_err("%s: Failed to configure gpio %d\n", __func__, PM8921_GPIO_PM_TO_SYS(23)); else gpio_direction_output(PM8921_GPIO_PM_TO_SYS(23), 0); ret = gpio_request(PM8921_GPIO_PM_TO_SYS(35), "US_EURO_SWITCH"); if (ret) { pr_err("%s: Failed to request gpio %d\n", __func__, PM8921_GPIO_PM_TO_SYS(35)); gpio_free(PM8921_GPIO_PM_TO_SYS(23)); return ret; } ret = pm8xxx_gpio_config(PM8921_GPIO_PM_TO_SYS(35), ¶m); if (ret) pr_err("%s: Failed to configure gpio %d\n", __func__, PM8921_GPIO_PM_TO_SYS(35)); else gpio_direction_output(PM8921_GPIO_PM_TO_SYS(35), 0); return 0; } static void msm8960_free_headset_mic_gpios(void) { if (msm8960_headset_gpios_configured) { gpio_free(PM8921_GPIO_PM_TO_SYS(23)); gpio_free(PM8921_GPIO_PM_TO_SYS(35)); } } static int __init msm8960_audio_init(void) { int ret; if (!cpu_is_msm8960() && !cpu_is_msm8930()) { pr_err("%s: Not the right machine type\n", __func__); return -ENODEV ; } mbhc_cfg.calibration = def_tabla_mbhc_cal(); if (!mbhc_cfg.calibration) { pr_err("Calibration data allocation failed\n"); return -ENOMEM; } msm8960_snd_device = platform_device_alloc("soc-audio", 0); if (!msm8960_snd_device) { pr_err("Platform device allocation failed\n"); kfree(mbhc_cfg.calibration); return -ENOMEM; } memcpy(msm8960_dai, msm8960_dai_common, sizeof(msm8960_dai_common)); memcpy(msm8960_dai + ARRAY_SIZE(msm8960_dai_common), msm8960_dai_delta_tabla2x, sizeof(msm8960_dai_delta_tabla2x)); platform_set_drvdata(msm8960_snd_device, &snd_soc_card_msm8960); ret = platform_device_add(msm8960_snd_device); if (ret) { platform_device_put(msm8960_snd_device); kfree(mbhc_cfg.calibration); return ret; } msm8960_snd_tabla1x_device = platform_device_alloc("soc-audio", 1); if (!msm8960_snd_tabla1x_device) { pr_err("Platform device allocation failed\n"); kfree(mbhc_cfg.calibration); return -ENOMEM; } memcpy(msm8960_tabla1x_dai, msm8960_dai_common, sizeof(msm8960_dai_common)); memcpy(msm8960_tabla1x_dai + ARRAY_SIZE(msm8960_dai_common), msm8960_dai_delta_tabla1x, sizeof(msm8960_dai_delta_tabla1x)); platform_set_drvdata(msm8960_snd_tabla1x_device, &snd_soc_tabla1x_card_msm8960); ret = platform_device_add(msm8960_snd_tabla1x_device); if (ret) { platform_device_put(msm8960_snd_tabla1x_device); kfree(mbhc_cfg.calibration); return -ENOMEM; return ret; } if (msm8960_configure_headset_mic_gpios()) { pr_err("%s Fail to configure headset mic gpios\n", __func__); msm8960_headset_gpios_configured = 0; } else msm8960_headset_gpios_configured = 1; mutex_init(&cdc_mclk_mutex); return ret; }
static int msm_configure_headset_mic_gpios(void) { int ret; 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(PM8921_GPIO_PM_TO_SYS(23), "AV_SWITCH"); if (ret) { pr_err("%s: Failed to request gpio %d\n", __func__, PM8921_GPIO_PM_TO_SYS(23)); return ret; } ret = pm8xxx_gpio_config(PM8921_GPIO_PM_TO_SYS(23), ¶m); if (ret) pr_err("%s: Failed to configure gpio %d\n", __func__, PM8921_GPIO_PM_TO_SYS(23)); else gpio_direction_output(PM8921_GPIO_PM_TO_SYS(23), 0); 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); gpio_free(PM8921_GPIO_PM_TO_SYS(23)); 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); return 0; } static void msm_free_headset_mic_gpios(void) { if (msm_headset_gpios_configured) { gpio_free(PM8921_GPIO_PM_TO_SYS(23)); gpio_free(us_euro_sel_gpio); } } static int __init msm_fighter_audio_init(void) { int ret; if (!soc_class_is_msm8960()) { pr_debug("%s: Not the right machine type\n", __func__); return -ENODEV ; } mbhc_cfg.calibration = def_tabla_mbhc_cal(); if (!mbhc_cfg.calibration) { pr_err("Calibration data allocation failed\n"); return -ENOMEM; } msm_snd_device = platform_device_alloc("soc-audio", 0); if (!msm_snd_device) { pr_err("Platform device allocation failed\n"); kfree(mbhc_cfg.calibration); return -ENOMEM; } platform_set_drvdata(msm_snd_device, &snd_soc_card_msm8960); ret = platform_device_add(msm_snd_device); if (ret) { platform_device_put(msm_snd_device); kfree(mbhc_cfg.calibration); return ret; } if (cpu_is_msm8960()) { if (msm_configure_headset_mic_gpios()) { pr_err("%s Fail to configure headset mic gpios\n", __func__); msm_headset_gpios_configured = 0; } else msm_headset_gpios_configured = 1; } else { msm_headset_gpios_configured = 0; pr_debug("%s headset GPIO 23 and 35 not configured msm960ab", __func__); } mutex_init(&cdc_mclk_mutex); atomic_set(&auxpcm_rsc_ref, 0); return ret; }
static int msm_configure_headset_mic_gpios(void) { int ret; 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(PM8921_GPIO_PM_TO_SYS(23), "AV_SWITCH"); if (ret) { pr_err("%s: Failed to request gpio %d\n", __func__, PM8921_GPIO_PM_TO_SYS(23)); return ret; } ret = pm8xxx_gpio_config(PM8921_GPIO_PM_TO_SYS(23), ¶m); if (ret) pr_err("%s: Failed to configure gpio %d\n", __func__, PM8921_GPIO_PM_TO_SYS(23)); else gpio_direction_output(PM8921_GPIO_PM_TO_SYS(23), 0); ret = gpio_request(PM8921_GPIO_PM_TO_SYS(35), "US_EURO_SWITCH"); if (ret) { pr_err("%s: Failed to request gpio %d\n", __func__, PM8921_GPIO_PM_TO_SYS(35)); gpio_free(PM8921_GPIO_PM_TO_SYS(23)); return ret; } ret = pm8xxx_gpio_config(PM8921_GPIO_PM_TO_SYS(35), ¶m); if (ret) pr_err("%s: Failed to configure gpio %d\n", __func__, PM8921_GPIO_PM_TO_SYS(35)); else gpio_direction_output(PM8921_GPIO_PM_TO_SYS(35), 0); return 0; } static void msm_free_headset_mic_gpios(void) { if (msm_headset_gpios_configured) { gpio_free(PM8921_GPIO_PM_TO_SYS(23)); gpio_free(PM8921_GPIO_PM_TO_SYS(35)); } } static int __init msm_audio_init(void) { int ret; if (!cpu_is_apq8064() || (socinfo_get_id() == 130)) { pr_err("%s: Not the right machine type\n", __func__); return -ENODEV; } mbhc_cfg.calibration = def_tabla_mbhc_cal(); if (!mbhc_cfg.calibration) { pr_err("Calibration data allocation failed\n"); return -ENOMEM; } msm_snd_device = platform_device_alloc("soc-audio", 0); if (!msm_snd_device) { pr_err("Platform device allocation failed\n"); kfree(mbhc_cfg.calibration); return -ENOMEM; } platform_set_drvdata(msm_snd_device, &snd_soc_card_msm); ret = platform_device_add(msm_snd_device); if (ret) { platform_device_put(msm_snd_device); kfree(mbhc_cfg.calibration); return ret; } if (msm_configure_headset_mic_gpios()) { pr_err("%s Fail to configure headset mic gpios\n", __func__); msm_headset_gpios_configured = 0; } else msm_headset_gpios_configured = 1; return ret; }