static int tegra_dc_rgb_init(struct tegra_dc *dc) { struct tegra_edid *edid; struct tegra_dc_edid *dc_edid; struct fb_monspecs specs; int err; if (dc->out == NULL || dc->out->dcc_bus < 0) return 0; edid = tegra_edid_create(dc->out->dcc_bus); if (IS_ERR_OR_NULL(edid)) { dev_err(&dc->ndev->dev, "rgb: can't create edid\n"); return PTR_ERR(edid); } err = tegra_edid_get_monspecs(edid, &specs); if (err < 0) { dev_err(&dc->ndev->dev, "error reading edid\n"); return err; } if (dc->pdata->default_out->n_modes > 0) { dc->mode.h_sync_width = specs.modedb->hsync_len; dc->mode.v_sync_width = specs.modedb->vsync_len; dc->mode.h_back_porch = specs.modedb->left_margin; dc->mode.v_back_porch = specs.modedb->upper_margin; dc->mode.h_active = specs.modedb->xres; dc->mode.v_active = specs.modedb->yres; dc->mode.h_front_porch = specs.modedb->right_margin; if (!machine_is_avalon() && !machine_is_titan()) dc->mode.pclk = PICOS2KHZ(specs.modedb->pixclock) * 1000; if (!machine_is_avalon()) dc->mode.v_front_porch = specs.modedb->lower_margin; } if (dc->pdata->fb) { dc->pdata->fb->xres = specs.modedb->xres; dc->pdata->fb->yres = specs.modedb->yres; } dc_edid = tegra_edid_get_data(edid); if (IS_ERR_OR_NULL(dc_edid)) return PTR_ERR(dc_edid); dc->out->width = dc_edid->buf[DTD_H_SIZE]; dc->out->height = dc_edid->buf[DTD_V_SIZE]; tegra_edid_put_data(dc_edid); if (specs.modedb->xres > specs.modedb->yres) { if (dc->out->width <= dc->out->height) dc->out->width += 0xFF; } else { if (dc->out->width > dc->out->height) dc->out->height += 0xFF; } fb_destroy_modedb(specs.modedb); return 0; }
static int ast_mt9p111_power_off(void) { if (machine_is_titan()) { if (!ast_vddio_cam || !ast_avdd_cam || !ast_vddio_1v8_cam1 || !ast_avdd_2v8_cam1 || !ast_vdd_3v3_cam1) return -ENODEV; } else { if (!ast_avdd_cam || !ast_vddio_1v8_cam1 || !ast_avdd_2v8_cam1 || !ast_vdd_2v8_cam1) return -ENODEV; } if (machine_is_titan()) { gpio_set_value(AST_CAM1_RST, 0); mdelay(1); gpio_set_value(AST_CAM1_PWDN, 1); mdelay(1); regulator_disable(ast_avdd_2v8_cam1); regulator_disable(ast_vdd_3v3_cam1); mdelay(1); regulator_disable(ast_vddio_1v8_cam1); regulator_disable(ast_avdd_cam); regulator_disable(ast_vddio_cam); ast_camera_mclk_off(); gpio_set_value(AST_CAM1_PWDN, 0); } else { gpio_set_value(AST_CAM1_RST, 0); mdelay(1); gpio_set_value(AST_CAM1_PWDN, 1); mdelay(1); regulator_disable(ast_vdd_2v8_cam1); regulator_disable(ast_avdd_2v8_cam1); mdelay(1); regulator_disable(ast_vddio_1v8_cam1); regulator_disable(ast_avdd_cam); ast_camera_mclk_off(); gpio_set_value(AST_CAM1_PWDN, 0); } return 0; }
int __init ast_panel_init(void) { if (machine_is_avalon() || machine_is_titan()) { return avalon_panel_init(); } else if (machine_is_sphinx()) { /* panel: add sphinx-specific here */ /* NOTE: sphinx LCD panel initialization is quiet different from avalon/titan */ /* We implement it in different file, board-sphinx-panel.c */ return sphinx_panel_init(); } return 0; }
/* Initialize the pins to desired state as per power/asic/system-eng * recomendation */ int __init ast_pins_state_init(void) { if (machine_is_avalon()) { set_unused_pin_gpio(&pin_lpm_avalon[0], ARRAY_SIZE(pin_lpm_avalon)); } else if (machine_is_sphinx()) { set_unused_pin_gpio(&pin_lpm_sphinx[0], ARRAY_SIZE(pin_lpm_sphinx)); } else if (machine_is_titan()) { set_unused_pin_gpio(&pin_lpm_titan[0], ARRAY_SIZE(pin_lpm_titan)); } return 0; }
int __init ast_pinmux_init(void) { ast_gpio_init_configure(); tegra_pinmux_config_table(ast_pinmux_common, ARRAY_SIZE(ast_pinmux_common)); tegra_drive_pinmux_config_table(ast_drive_pinmux, ARRAY_SIZE(ast_drive_pinmux)); if (machine_is_avalon()) { tegra_pinmux_config_table(avalon_pinmux, ARRAY_SIZE(avalon_pinmux)); } else if (machine_is_sphinx()) { tegra_pinmux_config_table(sphinx_pinmux, ARRAY_SIZE(sphinx_pinmux)); } else if (machine_is_titan()) { tegra_pinmux_config_table(titan_pinmux, ARRAY_SIZE(titan_pinmux)); } ast_pinmux_audio_init(); return 0; }
static int tegra_wm8903_jack_notifier(struct notifier_block *self, unsigned long action, void *dev) { struct snd_soc_jack *jack = dev; struct snd_soc_codec *codec = jack->codec; struct snd_soc_dapm_context *dapm = &codec->dapm; struct snd_soc_card *card = codec->card; struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card); struct tegra_wm8903_platform_data *pdata = machine->pdata; enum headset_state state = BIT_NO_HEADSET; int amic_act = 0, hp_act = 0, lineout_act = 0; #if 0 if (jack == &tegra_wm8903_hp_jack) { machine->jack_status &= ~SND_JACK_HEADPHONE; machine->jack_status |= (action & SND_JACK_HEADPHONE); } else { machine->jack_status &= ~SND_JACK_MICROPHONE; machine->jack_status |= (action & SND_JACK_MICROPHONE); } #else machine->jack_status &= ~(SND_JACK_HEADPHONE|SND_JACK_MICROPHONE|SND_JACK_LINEOUT); lineout_act = gpio_get_value(tegra_wm8903_lineout_jack_gpio.gpio) ^ tegra_wm8903_lineout_jack_gpio.invert; if(lineout_act && machine->ac_status) { machine->jack_status |= SND_JACK_LINEOUT; //printk(KERN_INFO "###### %s: %s Plug-in\n", __FUNCTION__, "Lineout"); goto JACK_DETECT_FINISH; } else { //printk(KERN_INFO "###### %s: %s Remove\n", __FUNCTION__, "Lineout"); } hp_act = gpio_get_value(tegra_wm8903_hp_jack_gpio.gpio) ^ tegra_wm8903_hp_jack_gpio.invert; if(hp_act) { machine->jack_status |= SND_JACK_HEADPHONE; if(machine_is_titan()) msleep(1000); if(machine->amic_reg) regulator_enable(machine->amic_reg); /* If we insert microphone too slow, sometimes device fail to detect mic. * because of hw issue we can't use interrupt to reconginze microphone, we increase delay time to reduce fail rate. */ msleep(550); amic_act = (!gpio_get_value(pdata->gpio_ext_mic_det))?SND_JACK_MICROPHONE:0; machine->jack_status |= amic_act; //printk(KERN_INFO "###### %s %s Plug-in\n", __FUNCTION__, amic_act?"Headset":"Headphone"); } else { //printk(KERN_INFO "###### %s %s Remove\n", __FUNCTION__, "Headphone/Headset"); } JACK_DETECT_FINISH: if(amic_act != SND_JACK_MICROPHONE) { if(machine->amic_reg && regulator_is_enabled(machine->amic_reg)) regulator_disable(machine->amic_reg); } if((machine->jack_status & SND_JACK_LINEOUT) && snd_soc_dapm_get_pin_status(dapm, "Headphone Jack")) { snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); snd_soc_dapm_enable_pin(dapm, "Line Out Jack"); snd_soc_dapm_sync(dapm); } else if(hp_act && snd_soc_dapm_get_pin_status(dapm, "Line Out Jack")) { snd_soc_dapm_enable_pin(dapm, "Headphone Jack"); snd_soc_dapm_disable_pin(dapm, "Line Out Jack"); snd_soc_dapm_sync(dapm); } #endif switch (machine->jack_status) { case SND_JACK_HEADPHONE: case SND_JACK_LINEOUT: state = BIT_HEADSET_NO_MIC; break; case SND_JACK_HEADSET: state = BIT_HEADSET; break; case SND_JACK_MICROPHONE: /* mic: would not report */ default: state = BIT_NO_HEADSET; } if(machine->switch_state != state) { machine->switch_state = state; switch_set_state(&tegra_wm8903_headset_switch, state); } return NOTIFY_OK; }
static __devinit int tegra_wm8903_driver_probe(struct platform_device *pdev) { struct snd_soc_card *card = &snd_soc_tegra_wm8903; struct tegra_wm8903 *machine; struct tegra_wm8903_platform_data *pdata; int ret; pdata = pdev->dev.platform_data; if (!pdata) { dev_err(&pdev->dev, "No platform data supplied\n"); return -EINVAL; } machine = kzalloc(sizeof(struct tegra_wm8903), GFP_KERNEL); if (!machine) { dev_err(&pdev->dev, "Can't allocate tegra_wm8903 struct\n"); return -ENOMEM; } machine->pdata = pdata; #ifdef CONFIG_SND_SOC_FM34 mutex_init(&machine->fm34_lock); #endif ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev); if (ret) goto err_free_machine; machine->spk_reg = regulator_get(&pdev->dev, "vdd_spk_amp"); if (IS_ERR(machine->spk_reg)) { dev_info(&pdev->dev, "No speaker regulator found\n"); machine->spk_reg = 0; } machine->dmic_reg = regulator_get(&pdev->dev, "vdd_dmic"); if (IS_ERR(machine->dmic_reg)) { dev_info(&pdev->dev, "No digital mic regulator found\n"); machine->dmic_reg = 0; } if(machine_is_titan()) { regulator_enable(machine->dmic_reg); } machine->amic_reg = regulator_get(&pdev->dev, "vdd_amic"); if (IS_ERR(machine->amic_reg)) { dev_info(&pdev->dev, "No analog mic regulator found\n"); machine->amic_reg = 0; } machine->codec_reg = regulator_get(&pdev->dev, "vdd_1v8_codec"); if (IS_ERR(machine->codec_reg)) { dev_info(&pdev->dev, "No audio codec regulator found\n"); machine->codec_reg = 0; } else { if (machine_is_avalon() || machine_is_titan()) { ret = regulator_set_voltage(machine->codec_reg, 1800000, 1800000); if (ret) { dev_err(&pdev->dev, "%s regulator_set_voltage failed: %d", "vdd_1v8_codec", ret); }else { regulator_enable(machine->codec_reg); } } else if (machine_is_sphinx()) { regulator_enable(machine->codec_reg); } } tegra_wm8903_dai[0].codec_name = "wm8903.0-001a"; tegra_wm8903_dai[0].cpu_dai_name = "tegra30-i2s.1"; tegra_wm8903_dai[1].cpu_dai_name = "tegra30-spdif"; tegra_wm8903_dai[2].cpu_dai_name = "tegra30-i2s.3"; #ifdef CONFIG_SWITCH /* Addd h2w swith class support */ ret = switch_dev_register(&tegra_wm8903_headset_switch); if (ret < 0) goto err_fini_utils; #endif card->dev = &pdev->dev; platform_set_drvdata(pdev, card); snd_soc_card_set_drvdata(card, machine); ret = snd_soc_register_card(card); if (ret) { dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); goto err_unregister_switch; } if (!card->instantiated) { ret = -ENODEV; dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); goto err_unregister_card; } ret = device_create_file(card->dev, &dev_attr_jack_status); if (ret) { dev_err(card->dev, "%s: add_sysfs_entry jack_status failed\n", __FUNCTION__); } ret = device_create_file(card->dev, &dev_attr_input_source); if (ret) { dev_err(card->dev, "%s: add_sysfs_entry input_source failed\n", __FUNCTION__); } ret = device_create_file(card->dev, &dev_attr_voice_call); if (ret) { dev_err(card->dev, "%s: add_sysfs_entry output_source failed\n", __FUNCTION__); } ret = device_create_file(card->dev, &dev_attr_audio_mode); if (ret) { dev_err(card->dev, "%s: add_sysfs_entry audio_mode failed\n", __FUNCTION__); } return 0; err_unregister_card: snd_soc_unregister_card(card); err_unregister_switch: #ifdef CONFIG_SWITCH switch_dev_unregister(&tegra_wm8903_headset_switch); err_fini_utils: #endif tegra_asoc_utils_fini(&machine->util_data); err_free_machine: kfree(machine); return ret; }
static int ast_mt9p111_init(void) { int err; if (!ast_avdd_cam) { ast_avdd_cam = regulator_get(NULL, "vdd_3v3_cam"); if (WARN_ON(IS_ERR(ast_avdd_cam))) { pr_err("%s: couldn't get regulator vdd_3v3_cam: %ld\n", __func__, PTR_ERR(ast_avdd_cam)); ast_avdd_cam = NULL; return -ENODEV; } } if (machine_is_titan()) { if (!ast_vddio_cam) { ast_vddio_cam = regulator_get(NULL, "vdd_gen1v8"); if (WARN_ON(IS_ERR(ast_vddio_cam))) { pr_err("%s: couldn't get regulator vdd_gen1v8: %ld\n", __func__, PTR_ERR(ast_vddio_cam)); ast_vddio_cam = NULL; return -ENODEV; } } if (!ast_vdd_3v3_cam1) { ast_vdd_3v3_cam1 = regulator_get(NULL, "vdd_3v3_cam1"); if (WARN_ON(IS_ERR(ast_vdd_3v3_cam1))) { pr_err("%s: couldn't get regulator vdd_3v3_cam1: %ld\n", __func__, PTR_ERR(ast_vdd_3v3_cam1)); ast_vdd_3v3_cam1 = NULL; return -ENODEV; } } if (!ast_avdd_2v8_cam1) { ast_avdd_2v8_cam1 = regulator_get(NULL, "avdd_2v8_cam1_titan"); if (WARN_ON(IS_ERR(ast_avdd_2v8_cam1))) { pr_err("%s: couldn't get regulator avdd_2v8_cam1: %ld\n", __func__, PTR_ERR(ast_avdd_2v8_cam1)); ast_avdd_2v8_cam1 = NULL; return -ENODEV; } } } else { if (!ast_avdd_2v8_cam1) { ast_avdd_2v8_cam1 = regulator_get(NULL, "avdd_2v8_cam1"); if (WARN_ON(IS_ERR(ast_avdd_2v8_cam1))) { pr_err("%s: couldn't get regulator avdd_2v8_cam1: %ld\n", __func__, PTR_ERR(ast_avdd_2v8_cam1)); ast_avdd_2v8_cam1 = NULL; return -ENODEV; } } if (!ast_vdd_2v8_cam1) { ast_vdd_2v8_cam1 = regulator_get(NULL, "vdd_2v8_cam1"); if (WARN_ON(IS_ERR(ast_vdd_2v8_cam1))) { pr_err("%s: couldn't get regulator vdd_2v8_cam1: %ld\n", __func__, PTR_ERR(ast_vdd_2v8_cam1)); ast_vdd_2v8_cam1 = NULL; return -ENODEV; } } } if (!ast_vddio_1v8_cam1) { ast_vddio_1v8_cam1 = regulator_get(NULL, "vddio_1v8_cam1"); if (WARN_ON(IS_ERR(ast_vddio_1v8_cam1))) { pr_err("%s: couldn't get regulator vddio_1v8_cam1: %ld\n", __func__, PTR_ERR(ast_vddio_1v8_cam1)); ast_vddio_1v8_cam1 = NULL; return -ENODEV; } } err = gpio_request(AST_CAM1_PWDN, "cam1_power_down"); if (err < 0) return err; gpio_direction_output(AST_CAM1_PWDN, 0); tegra_gpio_enable(AST_CAM1_PWDN); err = gpio_request(AST_CAM1_RST, "cam1_reset"); if (err < 0) return err; gpio_direction_output(AST_CAM1_RST, 0); tegra_gpio_enable(AST_CAM1_RST); return 0; }