예제 #1
0
static int max97236_i2c_probe(struct i2c_client *i2c,
				 const struct i2c_device_id *id)
{
	struct max97236_priv *max97236;
	int ret;

	max97236 = kzalloc(sizeof(struct max97236_priv), GFP_KERNEL);
	if (max97236 == NULL)
		return -ENOMEM;

	max97236->devtype = id->driver_data;
	i2c_set_clientdata(i2c, max97236);
	max97236->control_data = i2c;
	max97236->pdata = i2c->dev.platform_data;
	max97236->irq = i2c->irq;

	if (!max97236->pdata && i2c->dev.of_node)
		max97236->pdata = max97236_of_pdata(i2c);

	max97236->regmap = regmap_init_i2c(i2c, &max97236_regmap);
	if (IS_ERR(max97236->regmap)) {
		ret = PTR_ERR(max97236->regmap);
		dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret);
		goto err_enable;
	}

	ret = snd_soc_register_codec(&i2c->dev,
			&soc_codec_dev_max97236, max97236_dai,
			ARRAY_SIZE(max97236_dai));

	if (ret < 0)
		regmap_exit(max97236->regmap);

	tegra_get_board_info(&board_info);

        #ifdef CONFIG_SWITCH
	/* Add linebtn switch class support */         //add by wuhai 
	ret = switch_dev_register(&tegra_max97236_button_switch);
	if (ret < 0) {
		dev_err(&i2c->dev, "not able to register switch device\n");
	}
        #endif

err_enable:
	return ret;
}
예제 #2
0
static int max97236_i2c_probe(struct i2c_client *i2c,
				 const struct i2c_device_id *id)
{
	struct max97236_priv *max97236;
	int ret;

	max97236 = kzalloc(sizeof(struct max97236_priv), GFP_KERNEL);
	if (max97236 == NULL)
		return -ENOMEM;

	max97236->devtype = id->driver_data;
	i2c_set_clientdata(i2c, max97236);
	max97236->control_data = i2c;
	max97236->pdata = i2c->dev.platform_data;

	if (!max97236->pdata && i2c->dev.of_node)
		max97236->pdata = max97236_of_pdata(i2c);

	max97236->regmap = regmap_init_i2c(i2c, &max97236_regmap);
	if (IS_ERR(max97236->regmap)) {
		ret = PTR_ERR(max97236->regmap);
		dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret);
		goto err_enable;
	}

	regcache_cache_bypass(max97236->regmap, false);

	ret = snd_soc_register_codec(&i2c->dev,
			&soc_codec_dev_max97236, max97236_dai,
			ARRAY_SIZE(max97236_dai));

	if (ret < 0)
		regmap_exit(max97236->regmap);

err_enable:
	return ret;
}