static int __devinit pm860x_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct pm860x_platform_data *pdata = client->dev.platform_data; struct pm860x_chip *chip; int ret; if (!pdata) { pr_info("No platform data in %s!\n", __func__); return -EINVAL; } chip = kzalloc(sizeof(struct pm860x_chip), GFP_KERNEL); if (chip == NULL) return -ENOMEM; chip->id = verify_addr(client); chip->regmap = regmap_init_i2c(client, &pm860x_regmap_config); if (IS_ERR(chip->regmap)) { ret = PTR_ERR(chip->regmap); dev_err(&client->dev, "Failed to allocate register map: %d\n", ret); kfree(chip); return ret; } chip->client = client; i2c_set_clientdata(client, chip); chip->dev = &client->dev; dev_set_drvdata(chip->dev, chip); /* * Both client and companion client shares same platform driver. * Driver distinguishes them by pdata->companion_addr. * pdata->companion_addr is only assigned if companion chip exists. * At the same time, the companion_addr shouldn't equal to client * address. */ if (pdata->companion_addr && (pdata->companion_addr != client->addr)) { chip->companion_addr = pdata->companion_addr; chip->companion = i2c_new_dummy(chip->client->adapter, chip->companion_addr); chip->regmap_companion = regmap_init_i2c(chip->companion, &pm860x_regmap_config); if (IS_ERR(chip->regmap_companion)) { ret = PTR_ERR(chip->regmap_companion); dev_err(&chip->companion->dev, "Failed to allocate register map: %d\n", ret); return ret; } i2c_set_clientdata(chip->companion, chip); } pm860x_device_init(chip, pdata); return 0; }
static int wm8994_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct wm8994 *wm8994; int ret; wm8994 = kzalloc(sizeof(struct wm8994), GFP_KERNEL); if (wm8994 == NULL) return -ENOMEM; i2c_set_clientdata(i2c, wm8994); wm8994->dev = &i2c->dev; wm8994->irq = i2c->irq; wm8994->type = id->driver_data; wm8994->regmap = regmap_init_i2c(i2c, &wm8994_regmap_config); if (IS_ERR(wm8994->regmap)) { ret = PTR_ERR(wm8994->regmap); dev_err(wm8994->dev, "Failed to allocate register map: %d\n", ret); kfree(wm8994); return ret; } return wm8994_device_init(wm8994, i2c->irq); }
static int tps65910_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct tps65910 *tps65910; struct tps65910_board *pmic_plat_data; struct tps65910_platform_data *init_data; int ret = 0; pmic_plat_data = dev_get_platdata(&i2c->dev); if (!pmic_plat_data) return -EINVAL; init_data = kzalloc(sizeof(struct tps65910_platform_data), GFP_KERNEL); if (init_data == NULL) return -ENOMEM; tps65910 = kzalloc(sizeof(struct tps65910), GFP_KERNEL); if (tps65910 == NULL) { kfree(init_data); return -ENOMEM; } i2c_set_clientdata(i2c, tps65910); tps65910->dev = &i2c->dev; tps65910->i2c_client = i2c; tps65910->id = id->driver_data; tps65910->read = tps65910_i2c_read; tps65910->write = tps65910_i2c_write; mutex_init(&tps65910->io_mutex); tps65910->regmap = regmap_init_i2c(i2c, &tps65910_regmap_config); if (IS_ERR(tps65910->regmap)) { ret = PTR_ERR(tps65910->regmap); dev_err(&i2c->dev, "regmap initialization failed: %d\n", ret); goto regmap_err; } ret = mfd_add_devices(tps65910->dev, -1, tps65910s, ARRAY_SIZE(tps65910s), NULL, 0); if (ret < 0) goto err; init_data->irq = pmic_plat_data->irq; init_data->irq_base = pmic_plat_data->irq_base; tps65910_gpio_init(tps65910, pmic_plat_data->gpio_base); tps65910_irq_init(tps65910, init_data->irq, init_data); kfree(init_data); return ret; err: regmap_exit(tps65910->regmap); regmap_err: kfree(tps65910); kfree(init_data); return ret; }
static __devinit int wm8988_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct wm8988_priv *wm8988; int ret; wm8988 = devm_kzalloc(&i2c->dev, sizeof(struct wm8988_priv), GFP_KERNEL); if (wm8988 == NULL) return -ENOMEM; i2c_set_clientdata(i2c, wm8988); wm8988->regmap = regmap_init_i2c(i2c, &wm8988_regmap); if (IS_ERR(wm8988->regmap)) { ret = PTR_ERR(wm8988->regmap); dev_err(&i2c->dev, "Failed to init regmap: %d\n", ret); return ret; } ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_wm8988, &wm8988_dai, 1); if (ret != 0) regmap_exit(wm8988->regmap); return ret; }
static int wm8400_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct wm8400 *wm8400; int ret; wm8400 = kzalloc(sizeof(struct wm8400), GFP_KERNEL); if (wm8400 == NULL) { ret = -ENOMEM; goto err; } wm8400->regmap = regmap_init_i2c(i2c, &wm8400_regmap_config); if (IS_ERR(wm8400->regmap)) { ret = PTR_ERR(wm8400->regmap); goto struct_err; } wm8400->dev = &i2c->dev; i2c_set_clientdata(i2c, wm8400); ret = wm8400_init(wm8400, i2c->dev.platform_data); if (ret != 0) goto map_err; return 0; map_err: regmap_exit(wm8400->regmap); struct_err: kfree(wm8400); err: return ret; }
static __devinit int wm8731_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct wm8731_priv *wm8731; int ret; wm8731 = kzalloc(sizeof(struct wm8731_priv), GFP_KERNEL); if (wm8731 == NULL) return -ENOMEM; wm8731->regmap = regmap_init_i2c(i2c, &wm8731_regmap); if (IS_ERR(wm8731->regmap)) { ret = PTR_ERR(wm8731->regmap); dev_err(&i2c->dev, "Failed to allocate register map: %d\n", ret); goto err; } i2c_set_clientdata(i2c, wm8731); ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_wm8731, &wm8731_dai, 1); if (ret != 0) { dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); goto err_regmap; } return 0; err_regmap: regmap_exit(wm8731->regmap); err: kfree(wm8731); return ret; }
static int __devinit ad193x_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct ad193x_priv *ad193x; int ret; ad193x = devm_kzalloc(&client->dev, sizeof(struct ad193x_priv), GFP_KERNEL); if (ad193x == NULL) return -ENOMEM; ad193x->regmap = regmap_init_i2c(client, &ad193x_i2c_regmap_config); if (IS_ERR(ad193x->regmap)) { ret = PTR_ERR(ad193x->regmap); goto err_out; } i2c_set_clientdata(client, ad193x); ret = snd_soc_register_codec(&client->dev, &soc_codec_dev_ad193x, &ad193x_dai, 1); if (ret < 0) goto err_regmap_exit; return 0; err_regmap_exit: regmap_exit(ad193x->regmap); err_out: return ret; }
static int s2abb01_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct s2abb01_platform_data *pdata = i2c->dev.platform_data; struct s2abb01_dev *s2abb01; int ret = 0; if (pdata == NULL) { pr_err("%s: no pdata\n", __func__); return -ENODEV; } s2abb01 = kzalloc(sizeof(struct s2abb01_dev), GFP_KERNEL); if (s2abb01 == NULL) return -ENOMEM; i2c_set_clientdata(i2c, s2abb01); s2abb01->dev = &i2c->dev; s2abb01->i2c = i2c; s2abb01->suspend_on_ctrl = pdata->suspend_on_ctrl; s2abb01->regmap = regmap_init_i2c(i2c, &s2abb01_regmap_config); if (IS_ERR(s2abb01->regmap)) { ret = PTR_ERR(s2abb01->regmap); dev_err(&i2c->dev, "Failed to allocate register map: %d\n", ret); goto err; } return ret; err: kfree(s2abb01); return ret; }
static __devinit int ak4535_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct ak4535_priv *ak4535; int ret; ak4535 = devm_kzalloc(&i2c->dev, sizeof(struct ak4535_priv), GFP_KERNEL); if (ak4535 == NULL) return -ENOMEM; ak4535->regmap = regmap_init_i2c(i2c, &ak4535_regmap); if (IS_ERR(ak4535->regmap)) { ret = PTR_ERR(ak4535->regmap); dev_err(&i2c->dev, "Failed to init regmap: %d\n", ret); return ret; } i2c_set_clientdata(i2c, ak4535); ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_ak4535, &ak4535_dai, 1); if (ret != 0) regmap_exit(ak4535->regmap); return ret; }
static int max98925_i2c_probe(struct i2c_client *i2c_l, const struct i2c_device_id *id) { int ret; pr_err("%s: enter, device '%s'\n", __func__, id->name); max98925_data = kzalloc(sizeof(struct max98925_priv), GFP_KERNEL); if (max98925_data == NULL) return -ENOMEM; max98925_data->devtype = id->driver_data; max98925_data->control_data = i2c_l; //max98925_data->pdata = i2c_l->dev.platform_data; max98925_data->regmapL = regmap_init_i2c(i2c_l, &max98925_regmap); if (IS_ERR(max98925_data->regmapL)) { ret = PTR_ERR(max98925_data->regmapL); dev_err(&i2c_l->dev, "Failed to allocate regmapL: %d\n", ret); goto err_out; } /* ret = of_property_read_u32(i2c_l->dev.of_node, "irq-gpio", &max98925_data->irq_gpio); if (ret) { dev_err(&i2c_l->dev, "DT has no property named irq_gpio\n"); goto err_out; } ret = request_threaded_irq(gpio_to_irq(max98925_data->irq_gpio), NULL, max98925_irq_handler, IRQF_TRIGGER_HIGH | IRQF_ONESHOT, "MAX98925", max98925_data); if (ret < 0) { dev_err(&i2c_l->dev, "Failed to register IRQ for GPIO %d, error = %d\n", max98925_data->irq_gpio, ret); goto err_out; } */ ret = sysfs_create_file(&i2c_l->dev.kobj, &dev_attr_register_list.attr); ret |= misc_register(&max98925_ctrl_miscdev); pr_info("%s: ret %d\n", __func__, ret); if(!max98925_dclient){ max98925_dclient = dsm_register_client(&dsm_maxim_smartpa); } err_out: if (ret < 0) { if (max98925_data->regmapL) regmap_exit(max98925_data->regmapL); kfree(max98925_data); } return ret; }
static int wm9090_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct wm9090_priv *wm9090; unsigned int reg; int ret; wm9090 = devm_kzalloc(&i2c->dev, sizeof(*wm9090), GFP_KERNEL); if (wm9090 == NULL) { dev_err(&i2c->dev, "Can not allocate memory\n"); return -ENOMEM; } wm9090->regmap = regmap_init_i2c(i2c, &wm9090_regmap); if (IS_ERR(wm9090->regmap)) { ret = PTR_ERR(wm9090->regmap); dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret); return ret; } ret = regmap_read(wm9090->regmap, WM9090_SOFTWARE_RESET, ®); if (ret < 0) goto err; if (reg != 0x9093) { dev_err(&i2c->dev, "Device is not a WM9090, ID=%x\n", reg); ret = -ENODEV; goto err; } ret = regmap_write(wm9090->regmap, WM9090_SOFTWARE_RESET, 0); if (ret < 0) goto err; if (i2c->dev.platform_data) memcpy(&wm9090->pdata, i2c->dev.platform_data, sizeof(wm9090->pdata)); i2c_set_clientdata(i2c, wm9090); ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_wm9090, NULL, 0); if (ret != 0) { dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); goto err; } return 0; err: regmap_exit(wm9090->regmap); return ret; }
/** * snd_soc_codec_set_cache_io: Set up standard I/O functions. * * @codec: CODEC to configure. * @addr_bits: Number of bits of register address data. * @data_bits: Number of bits of data per register. * @control: Control bus used. * * Register formats are frequently shared between many I2C and SPI * devices. In order to promote code reuse the ASoC core provides * some standard implementations of CODEC read and write operations * which can be set up using this function. * * The caller is responsible for allocating and initialising the * actual cache. * * Note that at present this code cannot be used by CODECs with * volatile registers. */ int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, int addr_bits, int data_bits, enum snd_soc_control_type control) { struct regmap_config config; int ret; memset(&config, 0, sizeof(config)); codec->write = hw_write; codec->read = hw_read; config.reg_bits = addr_bits; config.val_bits = data_bits; switch (control) { #if IS_ENABLED(CONFIG_REGMAP_I2C) case SND_SOC_I2C: codec->control_data = regmap_init_i2c(to_i2c_client(codec->dev), &config); break; #endif #if IS_ENABLED(CONFIG_REGMAP_SPI) case SND_SOC_SPI: codec->control_data = regmap_init_spi(to_spi_device(codec->dev), &config); break; #endif case SND_SOC_REGMAP: /* Device has made its own regmap arrangements */ codec->using_regmap = true; if (!codec->control_data) codec->control_data = dev_get_regmap(codec->dev, NULL); if (codec->control_data) { ret = regmap_get_val_bytes(codec->control_data); /* Errors are legitimate for non-integer byte * multiples */ if (ret > 0) codec->val_bytes = ret; } break; default: return -EINVAL; } return PTR_ERR_OR_ZERO(codec->control_data); }
int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, int addr_bits, int data_bits, enum snd_soc_control_type control) { struct regmap_config config; int ret; memset(&config, 0, sizeof(config)); codec->write = hw_write; codec->read = hw_read; codec->bulk_write_raw = snd_soc_hw_bulk_write_raw; config.reg_bits = addr_bits; config.val_bits = data_bits; switch (control) { #if defined(CONFIG_REGMAP_I2C) || defined(CONFIG_REGMAP_I2C_MODULE) case SND_SOC_I2C: codec->control_data = regmap_init_i2c(to_i2c_client(codec->dev), &config); break; #endif #if defined(CONFIG_REGMAP_SPI) || defined(CONFIG_REGMAP_SPI_MODULE) case SND_SOC_SPI: codec->control_data = regmap_init_spi(to_spi_device(codec->dev), &config); break; #endif case SND_SOC_REGMAP: codec->using_regmap = true; ret = regmap_get_val_bytes(codec->control_data); if (ret > 0) codec->val_bytes = ret; break; default: return -EINVAL; } if (IS_ERR(codec->control_data)) return PTR_ERR(codec->control_data); return 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; }
static int max98505_i2c_probe(struct i2c_client *i2c_l, const struct i2c_device_id *id) { struct max98505_priv *max98505; int ret; pr_info("%s: enter, device '%s'\n", __func__, id->name); #ifdef SUPPORT_DEVICE_TREE max98505_regulator_config(i2c_l, of_property_read_bool(i2c_l->dev.of_node, "max98505,i2c-pull-up"), 1); #endif max98505 = kzalloc(sizeof(struct max98505_priv), GFP_KERNEL); if (max98505 == NULL) return -ENOMEM; max98505->devtype = id->driver_data; i2c_set_clientdata(i2c_l, max98505); max98505->control_data = i2c_l; max98505->pdata = i2c_l->dev.platform_data; max98505->regmap = regmap_init_i2c(i2c_l, &max98505_regmap); if (IS_ERR(max98505->regmap)) { ret = PTR_ERR(max98505->regmap); dev_err(&i2c_l->dev, "Failed to allocate regmap: %d\n", ret); goto err_out; } ret = snd_soc_register_codec(&i2c_l->dev, &soc_codec_dev_max98505, max98505_dai, ARRAY_SIZE(max98505_dai)); err_out: if (ret < 0) { if (max98505->regmap) regmap_exit(max98505->regmap); kfree(max98505); } dsm_misc_device_init(); pr_info("%s: ret %d\n", __func__, ret); return ret; }
static int max98925_i2c_probe(struct i2c_client *i2c_l, const struct i2c_device_id *id) { struct max98925_priv *max98925; int ret; msg_maxim("%s: enter, device '%s'\n", __func__, id->name); max98925 = kzalloc(sizeof(struct max98925_priv), GFP_KERNEL); if (max98925 == NULL) return -ENOMEM; max98925->devtype = id->driver_data; i2c_set_clientdata(i2c_l, max98925); max98925->control_data = i2c_l; max98925->pdata = i2c_l->dev.platform_data; max98925->regmap = regmap_init_i2c(i2c_l, &max98925_regmap); if (IS_ERR(max98925->regmap)) { ret = PTR_ERR(max98925->regmap); dev_err(&i2c_l->dev, "Failed to allocate regmap: %d\n", ret); goto err_out; } ret = snd_soc_register_codec(&i2c_l->dev, &soc_codec_dev_max98925, max98925_dai, ARRAY_SIZE(max98925_dai)); err_out: if (ret < 0) { if (max98925->regmap) regmap_exit(max98925->regmap); kfree(max98925); } #ifdef CONFIG_SND_SOC_MAXIM_DSM maxdsm_init(); #endif msg_maxim("%s: ret %d\n", __func__, ret); return ret; }
static int mc13xxx_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { const struct of_device_id *of_id; struct i2c_driver *idrv = to_i2c_driver(client->dev.driver); struct mc13xxx *mc13xxx; struct mc13xxx_platform_data *pdata = dev_get_platdata(&client->dev); int ret; of_id = of_match_device(mc13xxx_dt_ids, &client->dev); if (of_id) idrv->id_table = (const struct i2c_device_id*) of_id->data; mc13xxx = kzalloc(sizeof(*mc13xxx), GFP_KERNEL); if (!mc13xxx) return -ENOMEM; dev_set_drvdata(&client->dev, mc13xxx); mc13xxx->dev = &client->dev; mutex_init(&mc13xxx->lock); mc13xxx->regmap = regmap_init_i2c(client, &mc13xxx_regmap_i2c_config); if (IS_ERR(mc13xxx->regmap)) { ret = PTR_ERR(mc13xxx->regmap); dev_err(mc13xxx->dev, "Failed to initialize register map: %d\n", ret); dev_set_drvdata(&client->dev, NULL); kfree(mc13xxx); return ret; } ret = mc13xxx_common_init(mc13xxx, pdata, client->irq); if (ret == 0 && (id->driver_data != mc13xxx->ictype)) dev_warn(mc13xxx->dev, "device id doesn't match auto detection!\n"); return ret; }
/** * snd_soc_codec_set_cache_io: Set up standard I/O functions. * * @codec: CODEC to configure. * @addr_bits: Number of bits of register address data. * @data_bits: Number of bits of data per register. * @control: Control bus used. * * Register formats are frequently shared between many I2C and SPI * devices. In order to promote code reuse the ASoC core provides * some standard implementations of CODEC read and write operations * which can be set up using this function. * * The caller is responsible for allocating and initialising the * actual cache. * * Note that at present this code cannot be used by CODECs with * volatile registers. */ int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, int addr_bits, int data_bits, enum snd_soc_control_type control) { struct regmap_config config; memset(&config, 0, sizeof(config)); codec->write = hw_write; codec->read = hw_read; codec->bulk_write_raw = snd_soc_hw_bulk_write_raw; config.reg_bits = addr_bits; config.val_bits = data_bits; switch (control) { case SND_SOC_I2C: codec->control_data = regmap_init_i2c(to_i2c_client(codec->dev), &config); break; #if defined(CONFIG_REGMAP_SPI) || defined(CONFIG_REGMAP_SPI_MODULE) case SND_SOC_SPI: codec->control_data = regmap_init_spi(to_spi_device(codec->dev), &config); break; #endif case SND_SOC_REGMAP: /* Device has made its own regmap arrangements */ break; default: return -EINVAL; } if (IS_ERR(codec->control_data)) return PTR_ERR(codec->control_data); return 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; }
static int s5m87xx_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct s5m_platform_data *pdata = i2c->dev.platform_data; struct s5m87xx_dev *s5m87xx; int ret; s5m87xx = devm_kzalloc(&i2c->dev, sizeof(struct s5m87xx_dev), GFP_KERNEL); if (s5m87xx == NULL) return -ENOMEM; i2c_set_clientdata(i2c, s5m87xx); s5m87xx->dev = &i2c->dev; s5m87xx->i2c = i2c; s5m87xx->irq = i2c->irq; s5m87xx->type = id->driver_data; if (pdata) { s5m87xx->device_type = pdata->device_type; s5m87xx->ono = pdata->ono; s5m87xx->irq_base = pdata->irq_base; s5m87xx->wakeup = pdata->wakeup; } s5m87xx->regmap = regmap_init_i2c(i2c, &s5m_regmap_config); if (IS_ERR(s5m87xx->regmap)) { ret = PTR_ERR(s5m87xx->regmap); dev_err(&i2c->dev, "Failed to allocate register map: %d\n", ret); goto err; } s5m87xx->rtc = i2c_new_dummy(i2c->adapter, RTC_I2C_ADDR); i2c_set_clientdata(s5m87xx->rtc, s5m87xx); if (pdata && pdata->cfg_pmic_irq) pdata->cfg_pmic_irq(); s5m_irq_init(s5m87xx); pm_runtime_set_active(s5m87xx->dev); switch (s5m87xx->device_type) { case S5M8751X: ret = mfd_add_devices(s5m87xx->dev, -1, s5m8751_devs, ARRAY_SIZE(s5m8751_devs), NULL, 0); break; case S5M8763X: ret = mfd_add_devices(s5m87xx->dev, -1, s5m8763_devs, ARRAY_SIZE(s5m8763_devs), NULL, 0); break; case S5M8767X: ret = mfd_add_devices(s5m87xx->dev, -1, s5m8767_devs, ARRAY_SIZE(s5m8767_devs), NULL, 0); break; default: /* If this happens the probe function is problem */ BUG(); } if (ret < 0) goto err; return ret; err: mfd_remove_devices(s5m87xx->dev); s5m_irq_exit(s5m87xx); i2c_unregister_device(s5m87xx->rtc); regmap_exit(s5m87xx->regmap); return ret; }
static int max98506_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct max98506_priv *max98506; struct max98506_pdata *pdata; struct max98506_volume_step_info *vstep; int ret; int pinfo_status = 0; msg_maxim("enter, device '%s'", id->name); max98506 = devm_kzalloc(&i2c->dev, sizeof(struct max98506_priv), GFP_KERNEL); if (!max98506) { ret = -ENOMEM; goto err_allocate_priv; } max98506->pdata = devm_kzalloc(&i2c->dev, sizeof(struct max98506_pdata), GFP_KERNEL); if (!max98506->pdata) { ret = -ENOMEM; goto err_allocate_pdata; } i2c_set_clientdata(i2c, max98506); pdata = max98506->pdata; vstep = &max98506->vstep; if (i2c->dev.of_node) { /* Read system clock */ ret = of_property_read_u32(i2c->dev.of_node, "maxim,sysclk", &pdata->sysclk); if (ret) { dev_err(&i2c->dev, "There is no sysclk property."); pdata->sysclk = 12288000; } /* Read speaker volume */ ret = of_property_read_u32(i2c->dev.of_node, "maxim,spk-gain", &pdata->spk_gain); if (ret) { dev_err(&i2c->dev, "There is no spk_gain property."); pdata->spk_gain = 0x14; } /* Read VMON slot info.*/ ret = of_property_read_u32(i2c->dev.of_node, "maxim,vmon_slot", &pdata->vmon_slot); if (ret) { dev_err(&i2c->dev, "There is no vmon_slot property."); pdata->vmon_slot = 0; } /* Regulator status */ pdata->i2c_pull_up = of_property_read_bool( i2c->dev.of_node, "maxim,i2c-pull-up"); if (pdata->i2c_pull_up) max98506_regulator_config(&i2c->dev); #ifdef USE_MAX98506_IRQ pdata->irq = of_get_named_gpio_flags( i2c->dev.of_node, "maxim,irq-gpio", 0, NULL); #endif /* USE_MAX98506_IRQ */ /* Read information related to DSM */ ret = of_property_read_u32_array(i2c->dev.of_node, "maxim,platform_info", (u32 *) &pdata->pinfo, sizeof(pdata->pinfo)/sizeof(uint32_t)); if (ret) dev_err(&i2c->dev, "There is no platform info. property.\n"); else pinfo_status = 1; ret = of_property_read_u32_array(i2c->dev.of_node, "maxim,boost_step", (uint32_t *) &vstep->boost_step, sizeof(vstep->boost_step)/sizeof(uint32_t)); if (ret) { dev_err(&i2c->dev, "There is no boost_step property.\n"); for (ret = 0; ret < MAX98506_VSTEP_14; ret++) vstep->boost_step[ret] = 0x0F; vstep->boost_step[MAX98506_VSTEP_14] = 0x02; vstep->boost_step[MAX98506_VSTEP_15] = 0x00; } ret = of_property_read_u32(i2c->dev.of_node, "maxim,adc_threshold", &vstep->adc_thres); if (ret) { dev_err(&i2c->dev, "There is no adc_threshold property."); vstep->adc_thres = MAX98506_VSTEP_7; } pdata->reg_arr = of_get_property(i2c->dev.of_node, "maxim,registers-of-amp", &pdata->reg_arr_len); if (pdata->reg_arr == NULL) dev_err(&i2c->dev, "There is no registers-diff property."); #ifdef USE_DSM_LOG ret = of_property_read_string(i2c->dev.of_node, "maxim,log_class", &class_name_log); if (ret) { dev_err(&i2c->dev, "There is no log_class property.\n"); class_name_log = DEFAULT_LOG_CLASS_NAME; } #endif /* USE_DSM_LOG */ } else { pdata->sysclk = 12288000; pdata->spk_gain = 0x14; pdata->vmon_slot = 0; } #ifdef USE_MAX98506_IRQ if (pdata != NULL && gpio_is_valid(pdata->irq)) { ret = gpio_request(pdata->irq, "max98506_irq_gpio"); if (ret) { dev_err(&i2c->dev, "unable to request gpio [%d]", pdata->irq); goto err_irq_gpio_req; } ret = gpio_direction_input(pdata->irq); if (ret) { dev_err(&i2c->dev, "unable to set direction for gpio [%d]", pdata->irq); goto err_irq_gpio_req; } i2c->irq = gpio_to_irq(pdata->irq); ret = request_threaded_irq(i2c->irq, NULL, max98506_interrupt, IRQF_TRIGGER_FALLING | IRQF_ONESHOT, "max98506_interrupt", max98506); if (ret) dev_err(&i2c->dev, "Failed to register interrupt"); } else { dev_err(&i2c->dev, "irq gpio not provided\n"); } dev_dbg(&i2c->dev, "requested irq for max98506"); goto go_ahead_next_step; err_irq_gpio_req: if (gpio_is_valid(pdata->irq)) gpio_free(pdata->irq); go_ahead_next_step: #endif /* USE_MAX98506_IRQ */ #ifdef CONFIG_SND_SOC_MAXIM_DSM maxdsm_init(); if (pinfo_status) #ifdef CONFIG_MACH_KACTIVELTE_KOR maxdsm_update_info(pdata->pinfo); #else dev_info(&i2c->dev, "pinfo will be ignored.\n"); #endif /* CONFIG_MACH_KACTIVELTE_KOR */ #endif /* CONFIG_SND_SOC_MAXIM_DSM */ ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_max98506, max98506_dai, ARRAY_SIZE(max98506_dai)); if (ret) { dev_err(&i2c->dev, "Failed to register codec"); goto err_register_codec; } max98506->regmap = regmap_init_i2c(i2c, &max98506_regmap); if (IS_ERR(max98506->regmap)) { ret = PTR_ERR(max98506->regmap); dev_err(&i2c->dev, "Failed to initialize regmap: %d", ret); goto err_regmap; } msg_maxim("exit, device '%s'", id->name); return 0; err_regmap: snd_soc_unregister_codec(&i2c->dev); if (max98506->regmap) regmap_exit(max98506->regmap); err_register_codec: #ifdef CONFIG_SND_SOC_MAXIM_DSM maxdsm_deinit(); #endif /* CONFIG_SND_SOC_MAXIM_DSM */ devm_kfree(&i2c->dev, max98506->pdata); err_allocate_pdata: devm_kfree(&i2c->dev, max98506); err_allocate_priv: msg_maxim("exit with errors. ret=%d", ret); return ret; }
static int __devinit palmas_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct palmas *palmas; struct palmas_platform_data *mfd_platform_data; int ret = 0, i; unsigned int reg, addr; int slave; char *rname; mfd_platform_data = dev_get_platdata(&i2c->dev); if (!mfd_platform_data) return -EINVAL; palmas = kzalloc(sizeof(struct palmas), GFP_KERNEL); if (palmas == NULL) return -ENOMEM; i2c_set_clientdata(i2c, palmas); palmas->dev = &i2c->dev; palmas->id = id->driver_data; ret = irq_alloc_descs(-1, 0, PALMAS_NUM_IRQ, 0); if (ret < 0) { dev_err(&i2c->dev, "failed to allocate IRQ descs\n"); goto err; } palmas->irq = i2c->irq; palmas->irq_base = ret; palmas->irq_end = ret + PALMAS_NUM_IRQ; for (i = 0; i < PALMAS_NUM_CLIENTS; i++) { if (i == 0) palmas->i2c_clients[i] = i2c; else { palmas->i2c_clients[i] = i2c_new_dummy(i2c->adapter, i2c->addr + i); if (!palmas->i2c_clients[i]) { dev_err(palmas->dev, "can't attach client %d\n", i); ret = -ENOMEM; goto err; } } palmas->regmap[i] = regmap_init_i2c(palmas->i2c_clients[i], &palmas_regmap_config[i]); if (IS_ERR(palmas->regmap[i])) { ret = PTR_ERR(palmas->regmap[i]); dev_err(palmas->dev, "Failed to allocate register map " "No: %d, because: %d\n", i, ret); goto err; } } ret = palmas_irq_init(palmas); if (ret < 0) goto err; slave = PALMAS_BASE_TO_SLAVE(PALMAS_DESIGNREV_BASE); addr = PALMAS_BASE_TO_REG(PALMAS_DESIGNREV_BASE, 0); /* * Revision either * PALMAS_REV_ES1_0 or * PALMAS_REV_ES2_0 or * PALMAS_REV_ES2_1 */ ret = regmap_read(palmas->regmap[slave], addr, ®); if (ret) goto err; palmas->revision = reg; switch (palmas->revision) { case PALMAS_REV_ES1_0: rname = "ES 1.0"; break; case PALMAS_REV_ES2_0: rname = "ES 2.0"; break; case PALMAS_REV_ES2_1: rname = "ES 2.1"; break; default: rname = "unknown"; break; } dev_info(palmas->dev, "%s %s detected\n", id->name, rname); slave = PALMAS_BASE_TO_SLAVE(PALMAS_PU_PD_OD_BASE); addr = PALMAS_BASE_TO_REG(PALMAS_PU_PD_OD_BASE, PALMAS_PRIMARY_SECONDARY_PAD1); if (mfd_platform_data->mux_from_pdata) { reg = mfd_platform_data->pad1; ret = regmap_write(palmas->regmap[slave], addr, reg); if (ret) goto err; } else { ret = regmap_read(palmas->regmap[slave], addr, ®); if (ret) goto err; } if (!(reg & PRIMARY_SECONDARY_PAD1_GPIO_0)) palmas->gpio_muxed |= PALMAS_GPIO_0_MUXED; if (!(reg & PRIMARY_SECONDARY_PAD1_GPIO_1_MASK)) palmas->gpio_muxed |= PALMAS_GPIO_1_MUXED; else if ((reg & PRIMARY_SECONDARY_PAD1_GPIO_1_MASK) == (2 << PRIMARY_SECONDARY_PAD1_GPIO_1_SHIFT)) palmas->led_muxed |= PALMAS_LED1_MUXED; else if ((reg & PRIMARY_SECONDARY_PAD1_GPIO_1_MASK) == (3 << PRIMARY_SECONDARY_PAD1_GPIO_1_SHIFT)) palmas->pwm_muxed |= PALMAS_PWM1_MUXED; if (!(reg & PRIMARY_SECONDARY_PAD1_GPIO_2_MASK)) palmas->gpio_muxed |= PALMAS_GPIO_2_MUXED; else if ((reg & PRIMARY_SECONDARY_PAD1_GPIO_2_MASK) == (2 << PRIMARY_SECONDARY_PAD1_GPIO_2_SHIFT)) palmas->led_muxed |= PALMAS_LED2_MUXED; else if ((reg & PRIMARY_SECONDARY_PAD1_GPIO_2_MASK) == (3 << PRIMARY_SECONDARY_PAD1_GPIO_2_SHIFT)) palmas->pwm_muxed |= PALMAS_PWM2_MUXED; if (!(reg & PRIMARY_SECONDARY_PAD1_GPIO_3)) palmas->gpio_muxed |= PALMAS_GPIO_3_MUXED; addr = PALMAS_BASE_TO_REG(PALMAS_PU_PD_OD_BASE, PALMAS_PRIMARY_SECONDARY_PAD2); if (mfd_platform_data->mux_from_pdata) { reg = mfd_platform_data->pad2; ret = regmap_write(palmas->regmap[slave], addr, reg); if (ret) goto err; } else { ret = regmap_read(palmas->regmap[slave], addr, ®); if (ret) goto err; } if (!(reg & PRIMARY_SECONDARY_PAD2_GPIO_4)) palmas->gpio_muxed |= PALMAS_GPIO_4_MUXED; if (!(reg & PRIMARY_SECONDARY_PAD2_GPIO_5_MASK)) palmas->gpio_muxed |= PALMAS_GPIO_5_MUXED; if (!(reg & PRIMARY_SECONDARY_PAD2_GPIO_6)) palmas->gpio_muxed |= PALMAS_GPIO_6_MUXED; if (!(reg & PRIMARY_SECONDARY_PAD2_GPIO_7_MASK)) palmas->gpio_muxed |= PALMAS_GPIO_7_MUXED; dev_info(palmas->dev, "Muxing GPIO %x, PWM %x, LED %x\n", palmas->gpio_muxed, palmas->pwm_muxed, palmas->led_muxed); reg = mfd_platform_data->power_ctrl; slave = PALMAS_BASE_TO_SLAVE(PALMAS_PMU_CONTROL_BASE); addr = PALMAS_BASE_TO_REG(PALMAS_PMU_CONTROL_BASE, PALMAS_POWER_CTRL); ret = regmap_write(palmas->regmap[slave], addr, reg); if (ret) goto err; palmas_rtc_init(palmas); ret = mfd_add_devices(palmas->dev, -1, palmas_children, ARRAY_SIZE(palmas_children), NULL, palmas->irq_base); if (ret < 0) goto err; return ret; err: mfd_remove_devices(palmas->dev); kfree(palmas); return ret; }
static int __devinit wm2000_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *i2c_id) { struct wm2000_priv *wm2000; struct wm2000_platform_data *pdata; const char *filename; const struct firmware *fw = NULL; int ret; int reg; u16 id; #ifdef WM2000_GPIO_ENABLE wm2000_gpio_request(); #endif wm2000 = devm_kzalloc(&i2c->dev, sizeof(struct wm2000_priv), GFP_KERNEL); if (wm2000 == NULL) { dev_err(&i2c->dev, "Unable to allocate private data\n"); return -ENOMEM; } dev_set_drvdata(&i2c->dev, wm2000); mutex_init(&wm2000->anc_lock); wm2000->regmap = regmap_init_i2c(i2c, &wm2000_regmap); if (IS_ERR(wm2000->regmap)) { ret = PTR_ERR(wm2000->regmap); dev_err(&i2c->dev, "Failed to allocate register map: %d\n", ret); goto err; } /* when the system reboot, the power supply of wm2000 is always supplied, * so there is the bug solution below, powerdown and powerup the module before * probed! */ ret=wm2000_write(i2c, WM2000_REG_SYS_CTL1, 0); ret=wm2000_write(i2c, WM2000_REG_ANA_VMID_PU_TIME, 1); ret=wm2000_write(i2c, WM2000_REG_SYS_MODE_CNTRL, WM2000_MODE_ANA_SEQ_INCLUDE | WM2000_MODE_THERMAL_ENABLE | WM2000_MODE_MOUSE_ENABLE); /* Verify that this is a WM2000 */ reg = wm2000_read(i2c, WM2000_REG_ID1); id = reg << 8; reg = wm2000_read(i2c, WM2000_REG_ID2); id |= reg & 0xff; if (id != 0x2000) { dev_err(&i2c->dev, "Device is not a WM2000 - ID %x\n", id); wm2000_id = 0; ret = -ENODEV; goto out_regmap_exit; } else wm2000_id = 2000; printk("wm2000_id = 0x%x\n", id); reg = wm2000_read(i2c, WM2000_REG_REVISON); dev_info(&i2c->dev, "revision %c\n", reg + 'A'); filename = "wm2000_anc.bin"; pdata = dev_get_platdata(&i2c->dev); wm2000->mclk_div = 1; wm2000->speech_clarity = 0; if (pdata) { wm2000->mclk_div = pdata->mclkdiv2; wm2000->speech_clarity = !pdata->speech_enh_disable; if (pdata->download_file) filename = pdata->download_file; } ret = request_firmware(&fw, filename, &i2c->dev); if (ret != 0) { dev_err(&i2c->dev, "Failed to acquire ANC data: %d\n", ret); goto out; } /* Pre-cook the concatenation of the register address onto the image */ wm2000->anc_download_size = fw->size + 2; wm2000->anc_download = devm_kzalloc(&i2c->dev, wm2000->anc_download_size, GFP_KERNEL); if (wm2000->anc_download == NULL) { dev_err(&i2c->dev, "Out of memory\n"); ret = -ENOMEM; goto out; } wm2000->anc_download[0] = 0x80; wm2000->anc_download[1] = 0x00; memcpy(wm2000->anc_download + 2, fw->data, fw->size); wm2000->anc_eng_ena = 0; wm2000->anc_active = 0; wm2000->spk_ena = 1; wm2000->incall_mode =0; wm2000->i2c = i2c; wm2000_reset(wm2000); ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_wm2000, NULL, 0); if (!ret) { release_firmware(fw); return ret; } out: release_firmware(fw); out_regmap_exit: regmap_exit(wm2000->regmap); err: devm_kfree(&i2c->dev, wm2000); return ret; }
static int __devinit tps_65023_probe(struct i2c_client *client, const struct i2c_device_id *id) { const struct tps_driver_data *drv_data = (void *)id->driver_data; const struct tps_info *info = drv_data->info; struct regulator_init_data *init_data; struct regulator_dev *rdev; struct tps_pmic *tps; int i; int error; if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) return -EIO; /** * init_data points to array of regulator_init structures * coming from the board-evm file. */ init_data = client->dev.platform_data; if (!init_data) return -EIO; tps = kzalloc(sizeof(*tps), GFP_KERNEL); if (!tps) return -ENOMEM; tps->regmap = regmap_init_i2c(client, &tps65023_regmap_config); if (IS_ERR(tps->regmap)) { error = PTR_ERR(tps->regmap); dev_err(&client->dev, "Failed to allocate register map: %d\n", error); goto fail_alloc; } /* common for all regulators */ tps->client = client; tps->core_regulator = drv_data->core_regulator; for (i = 0; i < TPS65023_NUM_REGULATOR; i++, info++, init_data++) { /* Store regulator specific information */ tps->info[i] = info; tps->desc[i].name = info->name; tps->desc[i].id = i; tps->desc[i].n_voltages = info->table_len; tps->desc[i].ops = (i > TPS65023_DCDC_3 ? &tps65023_ldo_ops : &tps65023_dcdc_ops); tps->desc[i].type = REGULATOR_VOLTAGE; tps->desc[i].owner = THIS_MODULE; /* Register the regulators */ rdev = regulator_register(&tps->desc[i], &client->dev, init_data, tps, NULL); if (IS_ERR(rdev)) { dev_err(&client->dev, "failed to register %s\n", id->name); error = PTR_ERR(rdev); goto fail; } /* Save regulator for cleanup */ tps->rdev[i] = rdev; } i2c_set_clientdata(client, tps); /* Enable setting output voltage by I2C */ regmap_update_bits(tps->regmap, TPS65023_REG_CON_CTRL2, TPS65023_REG_CTRL2_CORE_ADJ, TPS65023_REG_CTRL2_CORE_ADJ); return 0; fail: while (--i >= 0) regulator_unregister(tps->rdev[i]); regmap_exit(tps->regmap); fail_alloc: kfree(tps); return error; }
static int __devinit tps65217_probe(struct i2c_client *client, const struct i2c_device_id *ids) { struct tps65217 *tps; struct tps65217_board *pdata = client->dev.platform_data; int i, ret; unsigned int version; tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); if (!tps) return -ENOMEM; tps->pdata = pdata; tps->regmap = regmap_init_i2c(client, &tps65217_regmap_config); if (IS_ERR(tps->regmap)) { ret = PTR_ERR(tps->regmap); dev_err(tps->dev, "Failed to allocate register map: %d\n", ret); return ret; } i2c_set_clientdata(client, tps); tps->dev = &client->dev; ret = tps65217_reg_read(tps, TPS65217_REG_CHIPID, &version); if (ret < 0) { dev_err(tps->dev, "Failed to read revision" " register: %d\n", ret); goto err_regmap; } /* Set the PMIC to shutdown on PWR_EN toggle */ if (pdata->status_off) { ret = tps65217_set_bits(tps, TPS65217_REG_STATUS, TPS65217_STATUS_OFF, TPS65217_STATUS_OFF, TPS65217_PROTECT_NONE); if (ret) { dev_err(tps->dev, "Failed to set the status OFF\n"); goto err_regmap; } } dev_info(tps->dev, "TPS65217 ID %#x version 1.%d\n", (version & TPS65217_CHIPID_CHIP_MASK) >> 4, version & TPS65217_CHIPID_REV_MASK); for (i = 0; i < TPS65217_NUM_REGULATOR; i++) { struct platform_device *pdev; pdev = platform_device_alloc("tps65217-pmic", i); if (!pdev) { dev_err(tps->dev, "Cannot create regulator %d\n", i); continue; } pdev->dev.parent = tps->dev; platform_device_add_data(pdev, &pdata->tps65217_init_data[i], sizeof(pdata->tps65217_init_data[i])); tps->regulator_pdev[i] = pdev; platform_device_add(pdev); } return 0; err_regmap: regmap_exit(tps->regmap); return ret; }
static __devinit int alc5632_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct alc5632_priv *alc5632; int ret, ret1, ret2; unsigned int vid1, vid2; alc5632 = devm_kzalloc(&client->dev, sizeof(struct alc5632_priv), GFP_KERNEL); if (alc5632 == NULL) return -ENOMEM; i2c_set_clientdata(client, alc5632); alc5632->regmap = regmap_init_i2c(client, &alc5632_regmap); if (IS_ERR(alc5632->regmap)) { ret = PTR_ERR(alc5632->regmap); dev_err(&client->dev, "regmap_init() failed: %d\n", ret); return ret; } ret1 = regmap_read(alc5632->regmap, ALC5632_VENDOR_ID1, &vid1); ret2 = regmap_read(alc5632->regmap, ALC5632_VENDOR_ID2, &vid2); if (ret1 != 0 || ret2 != 0) { dev_err(&client->dev, "Failed to read chip ID: ret1=%d, ret2=%d\n", ret1, ret2); regmap_exit(alc5632->regmap); return -EIO; } vid2 >>= 8; if ((vid1 != 0x10EC) || (vid2 != id->driver_data)) { dev_err(&client->dev, "Device is not a ALC5632: VID1=0x%x, VID2=0x%x\n", vid1, vid2); regmap_exit(alc5632->regmap); return -EINVAL; } ret = alc5632_reset(alc5632->regmap); if (ret < 0) { dev_err(&client->dev, "Failed to issue reset\n"); regmap_exit(alc5632->regmap); return ret; } alc5632->id = vid2; switch (alc5632->id) { case 0x5c: alc5632_dai.name = "alc5632-hifi"; break; default: return -EINVAL; } ret = snd_soc_register_codec(&client->dev, &soc_codec_device_alc5632, &alc5632_dai, 1); if (ret < 0) { dev_err(&client->dev, "Failed to register codec: %d\n", ret); regmap_exit(alc5632->regmap); return ret; } return ret; }
static int __devinit pcf50633_probe(struct i2c_client *client, const struct i2c_device_id *ids) { struct pcf50633 *pcf; struct pcf50633_platform_data *pdata = client->dev.platform_data; int i, ret; int version, variant; if (!client->irq) { dev_err(&client->dev, "Missing IRQ\n"); return -ENOENT; } pcf = kzalloc(sizeof(*pcf), GFP_KERNEL); if (!pcf) return -ENOMEM; pcf->pdata = pdata; mutex_init(&pcf->lock); pcf->regmap = regmap_init_i2c(client, &pcf50633_regmap_config); if (IS_ERR(pcf->regmap)) { ret = PTR_ERR(pcf->regmap); dev_err(pcf->dev, "Failed to allocate register map: %d\n", ret); goto err_free; } i2c_set_clientdata(client, pcf); pcf->dev = &client->dev; version = pcf50633_reg_read(pcf, 0); variant = pcf50633_reg_read(pcf, 1); if (version < 0 || variant < 0) { dev_err(pcf->dev, "Unable to probe pcf50633\n"); ret = -ENODEV; goto err_regmap; } dev_info(pcf->dev, "Probed device version %d variant %d\n", version, variant); pcf50633_irq_init(pcf, client->irq); pcf50633_client_dev_register(pcf, "pcf50633-input", &pcf->input_pdev); pcf50633_client_dev_register(pcf, "pcf50633-rtc", &pcf->rtc_pdev); pcf50633_client_dev_register(pcf, "pcf50633-mbc", &pcf->mbc_pdev); pcf50633_client_dev_register(pcf, "pcf50633-adc", &pcf->adc_pdev); pcf50633_client_dev_register(pcf, "pcf50633-backlight", &pcf->bl_pdev); for (i = 0; i < PCF50633_NUM_REGULATORS; i++) { struct platform_device *pdev; pdev = platform_device_alloc("pcf50633-regltr", i); if (!pdev) { dev_err(pcf->dev, "Cannot create regulator %d\n", i); continue; } pdev->dev.parent = pcf->dev; platform_device_add_data(pdev, &pdata->reg_init_data[i], sizeof(pdata->reg_init_data[i])); pcf->regulator_pdev[i] = pdev; platform_device_add(pdev); } ret = sysfs_create_group(&client->dev.kobj, &pcf_attr_group); if (ret) dev_err(pcf->dev, "error creating sysfs entries\n"); if (pdata->probe_done) pdata->probe_done(pcf); return 0; err_regmap: regmap_exit(pcf->regmap); err_free: kfree(pcf); return ret; }
static int __devinit wm2000_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *i2c_id) { struct wm2000_priv *wm2000; struct wm2000_platform_data *pdata; const char *filename; const struct firmware *fw = NULL; int ret; int reg; u16 id; wm2000 = devm_kzalloc(&i2c->dev, sizeof(struct wm2000_priv), GFP_KERNEL); if (wm2000 == NULL) { dev_err(&i2c->dev, "Unable to allocate private data\n"); return -ENOMEM; } dev_set_drvdata(&i2c->dev, wm2000); wm2000->regmap = regmap_init_i2c(i2c, &wm2000_regmap); if (IS_ERR(wm2000->regmap)) { ret = PTR_ERR(wm2000->regmap); dev_err(&i2c->dev, "Failed to allocate register map: %d\n", ret); goto out; } /* Verify that this is a WM2000 */ reg = wm2000_read(i2c, WM2000_REG_ID1); id = reg << 8; reg = wm2000_read(i2c, WM2000_REG_ID2); id |= reg & 0xff; if (id != 0x2000) { dev_err(&i2c->dev, "Device is not a WM2000 - ID %x\n", id); ret = -ENODEV; goto out_regmap_exit; } reg = wm2000_read(i2c, WM2000_REG_REVISON); dev_info(&i2c->dev, "revision %c\n", reg + 'A'); filename = "wm2000_anc.bin"; pdata = dev_get_platdata(&i2c->dev); if (pdata) { wm2000->mclk_div = pdata->mclkdiv2; wm2000->speech_clarity = !pdata->speech_enh_disable; if (pdata->download_file) filename = pdata->download_file; } ret = request_firmware(&fw, filename, &i2c->dev); if (ret != 0) { dev_err(&i2c->dev, "Failed to acquire ANC data: %d\n", ret); goto out_regmap_exit; } /* Pre-cook the concatenation of the register address onto the image */ wm2000->anc_download_size = fw->size + 2; wm2000->anc_download = devm_kzalloc(&i2c->dev, wm2000->anc_download_size, GFP_KERNEL); if (wm2000->anc_download == NULL) { dev_err(&i2c->dev, "Out of memory\n"); ret = -ENOMEM; goto out_regmap_exit; } wm2000->anc_download[0] = 0x80; wm2000->anc_download[1] = 0x00; memcpy(wm2000->anc_download + 2, fw->data, fw->size); wm2000->anc_eng_ena = 1; wm2000->anc_active = 1; wm2000->spk_ena = 1; wm2000->i2c = i2c; wm2000_reset(wm2000); ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_wm2000, NULL, 0); if (!ret) goto out; out_regmap_exit: regmap_exit(wm2000->regmap); out: release_firmware(fw); return ret; }
static int max77686_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct max77686_dev *max77686 = NULL; struct max77686_platform_data *pdata = i2c->dev.platform_data; unsigned int data; int ret = 0; if (i2c->dev.of_node) pdata = max77686_i2c_parse_dt_pdata(&i2c->dev); if (!pdata) { ret = -EIO; dev_err(&i2c->dev, "No platform data found.\n"); goto err; } max77686 = kzalloc(sizeof(struct max77686_dev), GFP_KERNEL); if (max77686 == NULL) return -ENOMEM; max77686->regmap = regmap_init_i2c(i2c, &max77686_regmap_config); if (IS_ERR(max77686->regmap)) { ret = PTR_ERR(max77686->regmap); dev_err(max77686->dev, "Failed to allocate register map: %d\n", ret); kfree(max77686); return ret; } i2c_set_clientdata(i2c, max77686); max77686->dev = &i2c->dev; max77686->i2c = i2c; max77686->type = id->driver_data; max77686->wakeup = pdata->wakeup; max77686->irq_gpio = pdata->irq_gpio; max77686->irq = i2c->irq; if (regmap_read(max77686->regmap, MAX77686_REG_DEVICE_ID, &data) < 0) { dev_err(max77686->dev, "device not found on this channel (this is not an error)\n"); ret = -ENODEV; goto err; } else dev_info(max77686->dev, "device found\n"); max77686->rtc = i2c_new_dummy(i2c->adapter, I2C_ADDR_RTC); i2c_set_clientdata(max77686->rtc, max77686); max77686_irq_init(max77686); ret = mfd_add_devices(max77686->dev, -1, max77686_devs, ARRAY_SIZE(max77686_devs), NULL, 0, NULL); if (ret < 0) goto err_mfd; return ret; err_mfd: mfd_remove_devices(max77686->dev); i2c_unregister_device(max77686->rtc); err: kfree(max77686); return ret; }
static int __devinit max98504_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct max98504_priv *max98504; struct max98504_pdata *pdata; int ret = 0; const char *of_class_name = DEFAULT_LOG_CLASS_NAME; #ifdef CONFIG_SND_SOC_MAXIM_DSM_A const char *class_name_log; #endif msg_maxim("\n"); max98504 = kzalloc(sizeof(struct max98504_priv), GFP_KERNEL); if (max98504 == NULL) return -ENOMEM; max98504->devtype = id->driver_data; i2c_set_clientdata(i2c, max98504); max98504->control_data = i2c; if (i2c->dev.of_node) { max98504->pdata = devm_kzalloc(&i2c->dev, sizeof(struct max98504_pdata), GFP_KERNEL); if (!max98504->pdata) { dev_err(&i2c->dev, "Failed to allocate memory\n"); return -ENOMEM; } else pdata = max98504->pdata; #ifdef USE_MAX98504_IRQ pdata->irq = of_get_named_gpio_flags(i2c->dev.of_node, "max98504,irq-gpio", 0, NULL); #endif ret = of_property_read_u32(i2c->dev.of_node, "max98504,rx_mode", &pdata->rx_mode); if (ret) { dev_err(&i2c->dev, "Failed to read rx_mode.\n"); return -EINVAL; } ret = of_property_read_u32(i2c->dev.of_node, "max98504,tx_mode", &pdata->tx_mode); if (ret) { dev_err(&i2c->dev, "Failed to read tx_mode.\n"); return -EINVAL; } ret = of_property_read_u32_array(i2c->dev.of_node, "max98504,cfg_data", (u32 *) &pdata->cfg_data, sizeof(struct max98504_cfg_data)/sizeof(u32)); if (ret) { dev_err(&i2c->dev, "Failed to read cfg_data.\n"); return -EINVAL; } #ifdef CONFIG_SND_SOC_MAXIM_DSM_A ret = of_property_read_string(i2c->dev.of_node, "max98504,log_class", &of_class_name); if (ret) { dev_err(&i2c->dev, "Failed to read log_class.\n"); of_class_name = DEFAULT_LOG_CLASS_NAME; } #endif msg_maxim("rx_mode:%d, tx_mode:%d, tx_dither_en:%d"\ ", rx_dither_en:%d, meas_dc_block_en:%d"\ ", rx_flt_mode:%d, rx_ch_en:%d\n", pdata->rx_mode, pdata->tx_mode, pdata->cfg_data.tx_dither_en, pdata->cfg_data.rx_dither_en, pdata->cfg_data.meas_dc_block_en, pdata->cfg_data.rx_flt_mode, pdata->cfg_data.rx_ch_en); msg_maxim("tx_ch_en:%d, tx_hiz_ch_en:%d"\ ", tx_ch_src:%d, auth_en:%d, wdog_time_out:%d\n", pdata->cfg_data.tx_ch_en, pdata->cfg_data.tx_hiz_ch_en, pdata->cfg_data.tx_ch_src, pdata->cfg_data.auth_en, pdata->cfg_data.wdog_time_out); } else { max98504->pdata = i2c->dev.platform_data; pdata = max98504->pdata; } max98504_regulator_config(i2c, of_property_read_bool(i2c->dev.of_node, "max98504,i2c-pull-up"), 1); max98504->regmap = regmap = regmap_init_i2c(i2c, &max98504_regmap); if (IS_ERR(max98504->regmap)) { ret = PTR_ERR(max98504->regmap); dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret); goto err_out; } max98504_probe(max98504); #ifdef CONFIG_SND_SOC_MAXIM_DSM_A class_name_log = of_class_name; max98504->dev_log_class = class_create(THIS_MODULE, class_name_log); if (max98504->dev_log_class == NULL) { pr_err("%s: class_create fail.\n", __func__); } else { max98504->dev_log = device_create(max98504->dev_log_class, NULL, 1, NULL, "max98504"); if (IS_ERR(max98504->dev_log)) { ret = sysfs_create_group(&i2c->dev.kobj, &max98504_attribute_group); if (ret) msg_maxim(\ "failed to create sysfs group [%d]", ret); } else { ret = sysfs_create_group(&max98504->dev_log->kobj, &max98504_attribute_group); if (ret) msg_maxim("failed to create sysfs group [%d]", ret); } } #endif #ifdef USE_MAX98504_IRQ if (pdata != NULL && gpio_is_valid(pdata->irq)) { ret = gpio_request(pdata->irq, "max98504_irq_gpio"); if (ret) { dev_err(&i2c->dev, "unable to request gpio [%d]\n", pdata->irq); goto err_irq_gpio_req; } ret = gpio_direction_input(pdata->irq); if (ret) { dev_err(&i2c->dev, "unable to set direction for gpio [%d]\n", pdata->irq); goto err_irq_gpio_req; } i2c->irq = gpio_to_irq(pdata->irq); ret = request_threaded_irq(i2c->irq, NULL, max98504_interrupt, IRQF_TRIGGER_FALLING | IRQF_ONESHOT, "max98504_interrupt", max98504); if (ret) dev_err(&i2c->dev, "Failed to register interrupt\n"); } else { dev_err(&i2c->dev, "irq gpio not provided\n"); } return 0; err_irq_gpio_req: if (gpio_is_valid(pdata->irq)) gpio_free(pdata->irq); return 0; #endif err_out: if (ret < 0) { if (max98504->regmap) regmap_exit(max98504->regmap); kfree(max98504); } return 0; }