Example #1
0
static int i2s_gpio_set(struct snd_soc_card *card)
{
    struct aml_audio_private_data *p_aml_audio;
    const char *str=NULL;
    int ret;
    

    p_aml_audio = snd_soc_card_get_drvdata(card);
    if(p_aml_audio->pin_ctl)
        devm_pinctrl_put(p_aml_audio->pin_ctl);
    ret = of_property_read_string(card->dev->of_node, "I2S_MCLK", &str);
    if (ret < 0) {
        printk("I2S_MCLK: faild to get gpio I2S_MCLK!\n");
    }else{
        p_aml_audio->gpio_i2s_m = amlogic_gpio_name_map_num(str);
        amlogic_gpio_request_one(p_aml_audio->gpio_i2s_m,GPIOF_OUT_INIT_LOW,"low_mclk");
        amlogic_set_value(p_aml_audio->gpio_i2s_m, 0, "low_mclk");
    }

    ret = of_property_read_string(card->dev->of_node, "I2S_SCLK", &str);
    if (ret < 0) {
        printk("I2S_SCLK: faild to get gpio I2S_SCLK!\n");
    }else{
        p_aml_audio->gpio_i2s_s = amlogic_gpio_name_map_num(str);
        amlogic_gpio_request_one(p_aml_audio->gpio_i2s_s,GPIOF_OUT_INIT_LOW,"low_sclk");
        amlogic_set_value(p_aml_audio->gpio_i2s_s, 0, "low_sclk");
    }

    ret = of_property_read_string(card->dev->of_node, "I2S_LRCLK", &str);
    if (ret < 0) {
        printk("I2S_LRCLK: faild to get gpio I2S_LRCLK!\n");
    }else{
        p_aml_audio->gpio_i2s_r = amlogic_gpio_name_map_num(str);
        amlogic_gpio_request_one(p_aml_audio->gpio_i2s_r,GPIOF_OUT_INIT_LOW,"low_lrclk");
        amlogic_set_value(p_aml_audio->gpio_i2s_r, 0, "low_lrclk");
    }

    ret = of_property_read_string(card->dev->of_node, "I2S_ODAT", &str);
    if (ret < 0) {
        printk("I2S_ODAT: faild to get gpio I2S_ODAT!\n");
    }else{
        p_aml_audio->gpio_i2s_o = amlogic_gpio_name_map_num(str);
        amlogic_gpio_request_one(p_aml_audio->gpio_i2s_o,GPIOF_OUT_INIT_LOW,"low_odata");
        amlogic_set_value(p_aml_audio->gpio_i2s_o, 0, "low_odata");
    }
    //mute spk
    amlogic_set_value(p_aml_audio->gpio_mute, 0, "mute_spk");
    return 0;
}
Example #2
0
static void aml_m8_pinmux_init(struct snd_soc_card *card)
{
    struct aml_audio_private_data *p_aml_audio;
    const char *str=NULL;
    int ret;
    p_aml_audio = snd_soc_card_get_drvdata(card);
    p_aml_audio->pin_ctl = devm_pinctrl_get_select(card->dev, "aml_snd_m8");



#if USE_EXTERNAL_DAC
#ifndef CONFIG_MESON_TRUSTZONE
    //aml_write_reg32(P_AO_SECURE_REG1,0x00000000);
    aml_clr_reg32_mask(P_AO_SECURE_REG1, ((1<<8) | (1<<1)));
#else
    /* Secure reg can only be accessed in Secure World if TrustZone enabled. */
    //meson_secure_reg_write(P_AO_SECURE_REG1, 0x00000000);
	meson_secure_reg_write(P_AO_SECURE_REG1, meson_secure_reg_read(P_AO_SECURE_REG1) & (~((1<<8) | (1<<1))));
#endif /* CONFIG_MESON_TRUSTZONE */
#endif
    ret = of_property_read_string(card->dev->of_node, "mute_gpio", &str);
    if (ret < 0) {
        printk("aml_snd_m8: faild to get mute_gpio!\n");
    }else{
        p_aml_audio->gpio_mute = amlogic_gpio_name_map_num(str);
        p_aml_audio->mute_inv = of_property_read_bool(card->dev->of_node,"mute_inv");
        amlogic_gpio_request_one(p_aml_audio->gpio_mute,GPIOF_OUT_INIT_HIGH,"mute_spk");
        amlogic_set_value(p_aml_audio->gpio_mute, 0, "mute_spk");

        spk_gpio_mute = p_aml_audio->gpio_mute;
        printk(KERN_INFO"pinmux set : spk_gpio_mute=%d\n",spk_gpio_mute);
    }

    printk("=%s==,aml_m8_pinmux_init done,---%d\n",__func__,p_aml_audio->det_pol_inv);
}
Example #3
0
static int __init meson_reboot_setup(void)
{
	po_gpio = amlogic_gpio_name_map_num("GPIOAO_2");
	amlogic_gpio_request_one(po_gpio, GPIOF_OUT_INIT_HIGH, "gpio_poweroff");

	pm_power_off_prepare = meson_power_off_prepare;
	pm_power_off = meson_power_off;
//	pm_idle = meson_power_idle;
	return 0;
}
int amlogic_gpio_request_array(const struct gpio *array, size_t num)
{
	int i, err;
	for (i = 0; i < num; i++, array++) {
		err = amlogic_gpio_request_one(array->gpio, array->flags, array->label);
		if (err)
			goto err_free;
	}
	return 0;

err_free:
	while (i--)
		gpio_free((--array)->gpio);
	return err;
}
Example #5
0
static void aml_m6_pinmux_init(struct snd_soc_card *card)
{
    struct aml_audio_private_data *p_aml_audio;
    const char *str;
    int ret;
    p_aml_audio = snd_soc_card_get_drvdata(card);
    p_aml_audio->pin_ctl = devm_pinctrl_get_select(card->dev, "wm8960_audio");
#if HP_DET
    //p_aml_audio->gpio_hp_det = of_get_named_gpio(card->dev->of_node,"wm8960_gpio",0);
    ret = of_property_read_string(card->dev->of_node, "wm8960_gpio", &str);
    if (ret) {
        printk("wm8960: faild to get gpio!\n");
    }
    p_aml_audio->gpio_hp_det = amlogic_gpio_name_map_num(str);
    p_aml_audio->det_pol_inv = of_property_read_bool(card->dev->of_node,"hp_det_inv");
    amlogic_gpio_request_one(p_aml_audio->gpio_hp_det,GPIOF_IN,"wm8960");
#endif
    printk("=%s==,aml_m6_pinmux_init done,---%d\n",__func__,p_aml_audio->det_pol_inv);
}
Example #6
0
int meson_cvbs_init(struct drm_device *dev)
{
	struct device *d = dev->dev;
	const char *str;
	int ret;

	ret = of_property_read_string(d->of_node, "cvbs_pal_gpio", &str);
	if (ret < 0) {
		dev_warn(d, "Failed to read property \"cvbs_pal_gpio\"\n");
		goto out;
	}
	gpio_pal = amlogic_gpio_name_map_num(str);
	if (gpio_pal < 0) {
		dev_warn(d, "Failed to map cvbs_pal_gpio to a GPIO number\n");
		goto out;
	}
	ret = amlogic_gpio_request_one(gpio_pal, GPIOF_IN,
			"mesondrm pal");
	if (ret < 0) {
		dev_warn(d, "Failed to request cvbs_pal_gpio\n");
		goto out;
	}
	ret = amlogic_set_pull_up_down(gpio_pal, 1, "mesondrm pal");
	if (ret < 0) {
		dev_warn(d, "Failed to up-down cvbs_pal_gpio\n");
		goto out;
	}

	ret = of_property_read_string(d->of_node, "cvbs_ntsc_gpio", &str);
	if (ret < 0) {
		dev_warn(d, "Failed to read property \"cvbs_ntsc_gpio\"\n");
		goto out;
	}
	gpio_ntsc = amlogic_gpio_name_map_num(str);
	if (gpio_pal < 0) {
		dev_warn(d, "Failed to map cvbs_ntsc_gpio to a GPIO number\n");
		goto out;
	}
	ret = amlogic_gpio_request_one(gpio_ntsc, GPIOF_IN,
				       "mesondrm ntsc");
	if (ret < 0) {
		dev_warn(d, "Failed to request cvbs_ntsc_gpio\n");
		goto out;
	}
	ret = amlogic_set_pull_up_down(gpio_ntsc, 1, "mesondrm ntsc");
	if (ret < 0) {
		dev_warn(d, "Failed to up-down cvbs_ntsc_gpio\n");
		goto out;
	}

	ret = amlogic_gpio_to_irq(gpio_pal, "mesondrm pal",
				  AML_GPIO_IRQ(2, FILTER_NUM7,
					       GPIO_IRQ_RISING));
	if (ret < 0) {
		dev_warn(d,
			 "Failed to get IRQ line for cvbs_pal_gpio rising\n");
		goto out;
	}
	ret = amlogic_gpio_to_irq(gpio_pal, "mesondrm pal",
				  AML_GPIO_IRQ(1, FILTER_NUM7,
					       GPIO_IRQ_FALLING));
	if (ret < 0) {
		dev_warn(d,
			 "Failed to get IRQ line for cvbs_pal_gpio falling\n");
		goto out;
	}

	meson_cvbs_work.dev = dev;
	INIT_DELAYED_WORK(&meson_cvbs_work.work, cvbs_switch_work_func);

	ret = devm_request_threaded_irq(d, INT_GPIO_2, NULL,
					cvbs_switch_intr_handler, IRQF_ONESHOT,
					"mesondrm pal", &meson_cvbs_work);
	if (ret < 0) {
		dev_warn(d, "Failed to claim cvbs_pal_gpio rising IRQ\n");
		goto out;
	}
	ret = devm_request_threaded_irq(d, INT_GPIO_1, NULL,
					cvbs_switch_intr_handler, IRQF_ONESHOT,
					"mesondrm pal", &meson_cvbs_work);
	if (ret < 0) {
		dev_warn(d, "Failed to claim cvbs_pal_gpio falling IRQ\n");
		goto out;
	}

out:
	return ret;
}