Exemple #1
0
static void dummy_codec_device_init(void)
{
#ifdef CONFIG_USE_OF
	int ret;
	struct pinctrl_state *s;
	p = pinctrl_get(dummy_codec_dev);

	if (IS_ERR(p))
		return;
			
	s = pinctrl_lookup_state(p, "dummy_codec_audio");
	if (IS_ERR(s)) {
		pinctrl_put(p);
		return;
	}
		
	ret = pinctrl_select_state(p, s);
	if (ret < 0) {
		pinctrl_put(p);
		return;
	}
	printk("=%s==,dummy_codec_audio init done\n",__func__);
#else
    /* audio pinmux */
//    pinmux_set(&rt5631_pinmux_set);

    /* GPIOA_19 PULL_UP_REG0 bit19 */
//    aml_set_reg32_bits(P_PAD_PULL_UP_REG0, 1, 19, 1);
#endif
}
/******************pin ctrl*****************/
int pinctrl_cmds_tx(struct platform_device *pdev, struct pinctrl_cmd_desc *cmds, int cnt)
{
    int ret = 0;

    int i = 0;
    struct pinctrl_cmd_desc *cm = NULL;

    cm = cmds;

    for(i = 0; i < cnt; i++) {
        if(cm == NULL) {
            balongfb_loge("command %d is null!\n", i);
            continue;
        }

        if(cm->dtype == DTYPE_PINCTRL_GET) {
            cm->pctrl_data->p = pinctrl_get(&pdev->dev);
        } else if(cm->dtype == DTYPE_PINCTRL_STATE_GET) {
            /* check pinctrl pointer*/
            // TO BE DONE
            if(cm ->mode == DTYPE_PINCTRL_STATE_DEFAULT) {
                cm->pctrl_data->pinctrl_def = pinctrl_lookup_state(cm->pctrl_data->p,PINCTRL_STATE_DEFAULT);
            } else if(cm ->mode == DTYPE_PINCTRL_STATE_IDLE) {
                cm->pctrl_data->pinctrl_idle = pinctrl_lookup_state(cm->pctrl_data->p,PINCTRL_STATE_IDLE);
            } else {
                ret = -1;
                balongfb_loge("unknown pinctrl type to get!\n");
                goto err;
            }
        } else if(cm->dtype == DTYPE_PINCTRL_SET) {
            /* check pinctrl pointer*/
            // TO BE DONE
            if(cm ->mode == DTYPE_PINCTRL_STATE_DEFAULT) {
                /* check pinctrl_def pointer*/
                // TO BE DONE
                ret = pinctrl_select_state(cm->pctrl_data->p, cm->pctrl_data->pinctrl_def);
                if(ret) {
                    balongfb_loge("could not set this pin to default state!\n");
                    ret = -1;
                    goto err;
                }

            } else if(cm ->mode == DTYPE_PINCTRL_STATE_IDLE) {
                /* check pinctrl_def pointer*/
                // TO BE DONE
                ret = pinctrl_select_state(cm->pctrl_data->p, cm->pctrl_data->pinctrl_idle);
                if(ret) {
                    balongfb_loge("could not set this pin to idle state!\n");
                    ret = -1;
                    goto err;
                }
            } else {
                ret = -1;
                balongfb_loge("unknown pinctrl type to set!\n");
                goto err;
            }
        } else if(cm->dtype == DTYPE_PINCTRL_PUT) {
            pinctrl_put(cm->pctrl_data->p);
        } else {
            balongfb_loge("not supported command type!\n");
            ret = -1;
            goto err;
        }

        cm++;

    }

    return ret;

err:
    return ret;
}
int ux500_msp_i2s_init_msp(struct platform_device *pdev,
			struct ux500_msp **msp_p,
			struct msp_i2s_platform_data *platform_data)
{
	struct resource *res = NULL;
	struct i2s_controller *i2s_cont;
	struct device_node *np = pdev->dev.of_node;
	struct ux500_msp *msp;

	*msp_p = devm_kzalloc(&pdev->dev, sizeof(struct ux500_msp), GFP_KERNEL);
	msp = *msp_p;
	if (!msp)
		return -ENOMEM;

	if (np) {
		if (!platform_data) {
			platform_data = devm_kzalloc(&pdev->dev,
				sizeof(struct msp_i2s_platform_data), GFP_KERNEL);
			if (!platform_data)
				return -ENOMEM;
		}
	} else
		if (!platform_data)
			return -EINVAL;

	dev_dbg(&pdev->dev, "%s: Enter (name: %s, id: %d).\n", __func__,
		pdev->name, platform_data->id);

	msp->id = platform_data->id;
	msp->dev = &pdev->dev;
	msp->dma_cfg_rx = platform_data->msp_i2s_dma_rx;
	msp->dma_cfg_tx = platform_data->msp_i2s_dma_tx;

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (res == NULL) {
		dev_err(&pdev->dev, "%s: ERROR: Unable to get resource!\n",
			__func__);
		return -ENOMEM;
	}

	msp->registers = devm_ioremap(&pdev->dev, res->start,
				      resource_size(res));
	if (msp->registers == NULL) {
		dev_err(&pdev->dev, "%s: ERROR: ioremap failed!\n", __func__);
		return -ENOMEM;
	}

	msp->msp_state = MSP_STATE_IDLE;
	msp->loopback_enable = 0;

	/* I2S-controller is allocated and added in I2S controller class. */
	i2s_cont = devm_kzalloc(&pdev->dev, sizeof(*i2s_cont), GFP_KERNEL);
	if (!i2s_cont) {
		dev_err(&pdev->dev,
			"%s: ERROR: Failed to allocate I2S-controller!\n",
			__func__);
		return -ENOMEM;
	}
	i2s_cont->dev.parent = &pdev->dev;
	i2s_cont->data = (void *)msp;
	i2s_cont->id = (s16)msp->id;
	snprintf(i2s_cont->name, sizeof(i2s_cont->name), "ux500-msp-i2s.%04x",
		msp->id);
	dev_dbg(&pdev->dev, "I2S device-name: '%s'\n", i2s_cont->name);
	msp->i2s_cont = i2s_cont;

	msp->pinctrl_p = pinctrl_get(msp->dev);
	if (IS_ERR(msp->pinctrl_p))
		dev_err(&pdev->dev, "could not get MSP pinctrl\n");
	else {
		msp->pinctrl_def = pinctrl_lookup_state(msp->pinctrl_p,
						PINCTRL_STATE_DEFAULT);
		if (IS_ERR(msp->pinctrl_def)) {
			dev_err(&pdev->dev,
				"could not get MSP defstate (%li)\n",
				PTR_ERR(msp->pinctrl_def));
		}
		msp->pinctrl_sleep = pinctrl_lookup_state(msp->pinctrl_p,
						PINCTRL_STATE_SLEEP);
		if (IS_ERR(msp->pinctrl_sleep))
			dev_err(&pdev->dev,
				"could not get MSP idlestate (%li)\n",
				PTR_ERR(msp->pinctrl_def));
	}

	return 0;
}