コード例 #1
0
static int __init sdp4430_soc_init(void)
{
	struct i2c_adapter *adapter;
	int ret;

	if (!machine_is_omap_4430sdp() && !machine_is_omap4_panda()) {
		pr_debug("Not SDP4430 or PandaBoard!\n");
		return -ENODEV;
	}
	printk(KERN_INFO "SDP4430 SoC init\n");

	sdp4430_snd_device = platform_device_alloc("soc-audio", -1);
	if (!sdp4430_snd_device) {
		printk(KERN_ERR "Platform device allocation failed\n");
		return -ENOMEM;
	}

	snd_soc_register_dais(&sdp4430_snd_device->dev, dai, ARRAY_SIZE(dai));

	platform_set_drvdata(sdp4430_snd_device, &snd_soc_sdp4430);

	ret = platform_device_add(sdp4430_snd_device);
	if (ret)
		goto err;

        adapter = i2c_get_adapter(1);
        if (!adapter) {
                printk(KERN_ERR "can't get i2c adapter\n");
                return -ENODEV;
        }

	tps6130x_client = i2c_new_device(adapter, &tps6130x_hwmon_info);
	if (!tps6130x_client) {
                printk(KERN_ERR "can't add i2c device\n");
                return -ENODEV;
        }

	/* Only configure the TPS6130x on SDP4430 */
	if (machine_is_omap_4430sdp())
		sdp4430_tps6130x_configure();

	return 0;

err:
	printk(KERN_ERR "Unable to add platform device\n");
	platform_device_put(sdp4430_snd_device);
	return ret;
}
コード例 #2
0
static int __init sdp4430_soc_init(void)
{
	struct i2c_adapter *adapter;
	u8 gpoctl;
	int ret;

	if (!machine_is_omap_4430sdp() && !machine_is_omap4_panda() &&
		!machine_is_omap_tabletblaze()) {
		pr_debug("Not SDP4430, BlazeTablet or PandaBoard!\n");
		return -ENODEV;
	}
	printk(KERN_INFO "SDP4430 SoC init\n");
	if (machine_is_omap_4430sdp())
		snd_soc_sdp4430.name = "SDP4430";
	else if (machine_is_omap4_panda())
		snd_soc_sdp4430.name = "Panda";
	else if (machine_is_omap_tabletblaze())
		snd_soc_sdp4430.name = "Tablet44xx";

	sdp4430_snd_device = platform_device_alloc("soc-audio", -1);
	if (!sdp4430_snd_device) {
		printk(KERN_ERR "Platform device allocation failed\n");
		return -ENOMEM;
	}

	ret = snd_soc_register_dais(&sdp4430_snd_device->dev, dai, ARRAY_SIZE(dai));
	if (ret < 0)
		goto err;
	platform_set_drvdata(sdp4430_snd_device, &snd_soc_sdp4430);

	ret = platform_device_add(sdp4430_snd_device);
	if (ret)
		goto err_dev;

	twl6040_codec = snd_soc_card_get_codec(&snd_soc_sdp4430,
					"twl6040-codec");
	if(twl6040_codec <= 0) {
		printk(KERN_ERR "sdp4430: could not find `twl6040-codec`\n");
		ret = -ENODEV;
		goto err_dev;
	}

	av_switch_reg = regulator_get(&sdp4430_snd_device->dev, "av-switch");
	if (IS_ERR(av_switch_reg)) {
		ret = PTR_ERR(av_switch_reg);
		printk(KERN_ERR "couldn't get AV Switch regulator %d\n",
			ret);
		goto err_dev;
	}

	/* enable tps6130x */
	ret = twl_i2c_read_u8(TWL_MODULE_AUDIO_VOICE, &gpoctl,
		TWL6040_REG_GPOCTL);
	if (ret) {
		printk(KERN_ERR "i2c read error\n");
		goto i2c_err;
	}

	ret = twl_i2c_write_u8(TWL_MODULE_AUDIO_VOICE, gpoctl | TWL6040_GPO2,
		TWL6040_REG_GPOCTL);
	if (ret) {
		printk(KERN_ERR "i2c write error\n");
		goto i2c_err;
	}

	adapter = i2c_get_adapter(TPS6130X_I2C_ADAPTER);
	if (!adapter) {
		printk(KERN_ERR "can't get i2c adapter\n");
		ret = -ENODEV;
		goto adp_err;
	}

	tps6130x_client = i2c_new_device(adapter, &tps6130x_hwmon_info);
	if (!tps6130x_client) {
		printk(KERN_ERR "can't add i2c device\n");
		ret = -ENODEV;
		goto tps_err;
	}


	/* Only configure the TPS6130x on SDP4430 */
	if (machine_is_omap_4430sdp() || machine_is_omap_tabletblaze())
		sdp4430_tps6130x_configure();
	i2c_put_adapter(adapter);

	return ret;

tps_err:
	i2c_put_adapter(adapter);
adp_err:
	twl_i2c_write_u8(TWL_MODULE_AUDIO_VOICE, gpoctl, TWL6040_REG_GPOCTL);
i2c_err:
	regulator_put(av_switch_reg);
err_dev:
	snd_soc_unregister_dais(&sdp4430_snd_device->dev, ARRAY_SIZE(dai));
err:
	platform_device_put(sdp4430_snd_device);
	return ret;
}