/*! * This function is called whenever the SPI slave device is detected. * * @param spi the SPI slave device * * @return Returns 0 on SUCCESS and error on FAILURE. */ static int __devinit pmic_probe(struct spi_device *spi) { int ret = 0; if (!strcmp(spi->dev.bus_id, PMIC_ARBITRATION)) { if (PMIC_SUCCESS != pmic_fix_arbitration(spi)) { dev_err((struct device *)spi, "Unable to fix arbitration!! Access Failed\n"); return -EACCES; } return PMIC_SUCCESS; } /* Initialize the PMIC parameters */ ret = pmic_spi_setup(spi); if (ret != PMIC_SUCCESS) { return PMIC_ERROR; } /* Initialize the PMIC event handling */ pmic_event_list_init(); /* Initialize GPIO for PMIC Interrupt */ gpio_pmic_active(); /* Get the PMIC Version */ pmic_get_revision(&mxc_pmic_version); if (mxc_pmic_version.revision < 0) { dev_err((struct device *)spi, "PMIC not detected!!! Access Failed\n"); return -ENODEV; } else { dev_dbg((struct device *)spi, "Detected pmic core IC version number is %d\n", mxc_pmic_version.revision); } /* Initialize the PMIC parameters */ ret = pmic_init_registers(); if (ret != PMIC_SUCCESS) { return PMIC_ERROR; } /* Set and install PMIC IRQ handler */ set_irq_type(spi->irq, IRQF_TRIGGER_RISING); ret = request_irq(spi->irq, pmic_irq_handler, 0, "PMIC_IRQ", 0); if (ret) { dev_err((struct device *)spi, "gpio1: irq%d error.", spi->irq); return ret; } power_ldm.dev.platform_data = spi->dev.platform_data; pmic_pdev_register(); printk(KERN_INFO "Device %s probed\n", spi->dev.bus_id); return PMIC_SUCCESS; }
static int __devinit pmic_probe(struct i2c_client *client, const struct i2c_device_id *id) { int ret = 0; struct mc34704 *mc34704; struct mc34704_platform_data *plat_data = client->dev.platform_data; if (!plat_data || !plat_data->init) return -ENODEV; ret = is_chip_onboard(client); if (ret == -1) return -ENODEV; mc34704 = kzalloc(sizeof(struct mc34704), GFP_KERNEL); if (mc34704 == NULL) return -ENOMEM; i2c_set_clientdata(client, mc34704); mc34704->dev = &client->dev; mc34704->i2c_client = client; mc34704_client = client; /* Initialize the PMIC event handling */ pmic_event_list_init(); /* Initialize PMI registers */ if (pmic_init_registers() != PMIC_SUCCESS) return PMIC_ERROR; ret = plat_data->init(mc34704); if (ret != 0) return PMIC_ERROR; dev_info(&client->dev, "Loaded\n"); return PMIC_SUCCESS; }
static int __devinit pmic_probe(struct i2c_client *client, const struct i2c_device_id *id) { int ret = 0; int pmic_irq; struct pmic_platform_data *plat_data = client->dev.platform_data; const char *name; int pmic_index; ret = is_chip_onboard(client); if (ret == -1) return -ENODEV; name = get_chipname(client); if (!name) return PMIC_ERROR; pmic_index = get_index_pmic_internal(name); if (pmic_index == PMIC_ID_INVALID) return PMIC_ERROR; adc_ldm.name = get_client_device_name(name, "%s_adc"); battery_ldm.name = get_client_device_name(name, "%s_battery"); light_ldm.name = get_client_device_name(name, "%s_light"); rtc_ldm.name = get_client_device_name(name, "%s_rtc"); i2c_set_clientdata(client, pmic_internal[pmic_index].pmic_alloc_data(&client->dev)); /* so far, we got matched chip on board */ pmic_i2c_setup(client); /* Initialize the PMIC event handling */ pmic_event_list_init(); /* Initialize GPIO for PMIC Interrupt */ gpio_pmic_active(); /* Get the PMIC Version */ pmic_internal[pmic_index].pmic_get_revision(&mxc_pmic_version); if (mxc_pmic_version.revision < 0) { dev_err((struct device *)client, "PMIC not detected!!! Access Failed\n"); return -ENODEV; } else { dev_dbg((struct device *)client, "Detected pmic core IC version number is %d\n", mxc_pmic_version.revision); } /* Initialize the PMIC parameters */ ret = pmic_internal[pmic_index].pmic_init_registers(); if (ret != PMIC_SUCCESS) return PMIC_ERROR; pmic_irq = (int)(client->irq); if (pmic_irq == 0) return PMIC_ERROR; ret = pmic_start_event_thread(pmic_irq); if (ret) { pr_err("pmic driver init: \ fail to start event thread\n"); return PMIC_ERROR; } /* Set and install PMIC IRQ handler */ set_irq_type(pmic_irq, IRQF_TRIGGER_HIGH); ret = request_irq(pmic_irq, pmic_irq_handler, 0, "PMIC_IRQ", 0); if (ret) { dev_err(&client->dev, "request irq %d error!\n", pmic_irq); return ret; } enable_irq_wake(pmic_irq); if (plat_data && plat_data->init) { ret = plat_data->init(i2c_get_clientdata(client)); if (ret != 0) return PMIC_ERROR; } ret = device_create_file(&client->dev, &pmic_dev_attr); if (ret) dev_err(&client->dev, "create device file failed!\n"); pmic_pdev_register(&client->dev); dev_info(&client->dev, "Loaded\n"); return PMIC_SUCCESS; }
/*! * This function is called whenever the SPI slave device is detected. * * @param spi the SPI slave device * * @return Returns 0 on SUCCESS and error on FAILURE. */ static int __devinit pmic_probe(struct spi_device *spi) { int ret = 0; struct pmic_platform_data *plat_data = spi->dev.platform_data; /* Initialize the PMIC parameters */ ret = pmic_spi_setup(spi); if (ret != PMIC_SUCCESS) { return PMIC_ERROR; } /* Initialize the PMIC event handling */ pmic_event_list_init(); /* Initialize GPIO for PMIC Interrupt */ gpio_pmic_active(); /* Get the PMIC Version */ pmic_get_revision(&mxc_pmic_version); if (mxc_pmic_version.revision < 0) { dev_err((struct device *)spi, "PMIC not detected!!! Access Failed\n"); return -ENODEV; } else { dev_dbg((struct device *)spi, "Detected pmic core IC version number is %d\n", mxc_pmic_version.revision); } spi_set_drvdata(spi, pmic_alloc_data(&(spi->dev))); /* Initialize the PMIC parameters */ ret = pmic_init_registers(); if (ret != PMIC_SUCCESS) { kfree(spi_get_drvdata(spi)); spi_set_drvdata(spi, NULL); return PMIC_ERROR; } ret = pmic_start_event_thread(spi->irq); if (ret) { pr_err("mc13892 pmic driver init: \ fail to start event thread\n"); kfree(spi_get_drvdata(spi)); spi_set_drvdata(spi, NULL); return PMIC_ERROR; } /* Set and install PMIC IRQ handler */ set_irq_type(spi->irq, IRQF_TRIGGER_HIGH); ret = request_irq(spi->irq, pmic_irq_handler, 0, "PMIC_IRQ", 0); if (ret) { kfree(spi_get_drvdata(spi)); spi_set_drvdata(spi, NULL); dev_err((struct device *)spi, "gpio1: irq%d error.", spi->irq); return ret; } enable_irq_wake(spi->irq); if (plat_data && plat_data->init) { ret = plat_data->init(spi_get_drvdata(spi)); if (ret != 0) { kfree(spi_get_drvdata(spi)); spi_set_drvdata(spi, NULL); return PMIC_ERROR; } } power_ldm.dev.platform_data = spi->dev.platform_data; pmic_pdev_register(); printk(KERN_INFO "Device %s probed\n", dev_name(&spi->dev)); return PMIC_SUCCESS; }
static int __devinit pmic_probe(struct i2c_client *client, const struct i2c_device_id *id) { int ret = 0; int pmic_irq; struct mc13892 *mc13892; struct mc13892_platform_data *plat_data = client->dev.platform_data; ret = is_chip_onboard(client); if (ret == -1) return -ENODEV; mc13892 = kzalloc(sizeof(struct mc13892), GFP_KERNEL); if (mc13892 == NULL) return -ENOMEM; i2c_set_clientdata(client, mc13892); mc13892->dev = &client->dev; mc13892->i2c_client = client; /* so far, we got matched chip on board */ mc13892_client = client; /* Initialize the PMIC event handling */ pmic_event_list_init(); /* Initialize GPIO for PMIC Interrupt */ gpio_pmic_active(); /* Get the PMIC Version */ pmic_get_revision(&mxc_pmic_version); if (mxc_pmic_version.revision < 0) { dev_err((struct device *)client, "PMIC not detected!!! Access Failed\n"); return -ENODEV; } else { dev_dbg((struct device *)client, "Detected pmic core IC version number is %d\n", mxc_pmic_version.revision); } /* Initialize the PMIC parameters */ ret = pmic_init_registers(); if (ret != PMIC_SUCCESS) return PMIC_ERROR; pmic_event_wq = create_workqueue("mc13892"); if (!pmic_event_wq) { pr_err("mc13892 pmic driver init: fail to create work queue"); return -EFAULT; } /* Set and install PMIC IRQ handler */ pmic_irq = (int)(client->irq); if (pmic_irq == 0) return PMIC_ERROR; set_irq_type(pmic_irq, IRQF_TRIGGER_RISING); ret = request_irq(pmic_irq, pmic_irq_handler, 0, "PMIC_IRQ", 0); if (ret) { dev_err(&client->dev, "request irq %d error!\n", pmic_irq); return ret; } enable_irq_wake(pmic_irq); if (plat_data && plat_data->init) { ret = plat_data->init(mc13892); if (ret != 0) return PMIC_ERROR; } ret = device_create_file(&client->dev, &mc13892_dev_attr); if (ret) dev_err(&client->dev, "create device file failed!\n"); pmic_pdev_register(&client->dev); dev_info(&client->dev, "Loaded\n"); return PMIC_SUCCESS; }
/*! * This function is called whenever the SPI slave device is detected. * * @param spi the SPI slave device * * @return Returns 0 on SUCCESS and error on FAILURE. */ static int __devinit pmic_probe(struct spi_device *spi) { int ret = 0; struct pmic_platform_data *plat_data = spi->dev.platform_data; const char *name; int pmic_index; /* Initialize the PMIC parameters */ ret = pmic_spi_setup(spi); if (ret != PMIC_SUCCESS) { return PMIC_ERROR; } name = get_chipname(spi); if (!name) return PMIC_ERROR; pmic_index = get_index_pmic_internal(name); if (pmic_index == PMIC_ID_INVALID) return PMIC_ERROR; pmic_spi_adc_ldm.name = get_client_device_name(name, "%s_adc"); pmic_spi_battery_ldm.name = get_client_device_name(name, "%s_battery"); pmic_spi_light_ldm.name = get_client_device_name(name, "%s_light"); pmic_spi_rtc_ldm.name = get_client_device_name(name, "%s_rtc"); //wen add //pmic_spi_rleds_ldm.name = get_client_device_name(name,"%s_leds"); //pmic_spi_gleds_ldm.name = get_client_device_name(name,"%s_leds"); //pmic_spi_bleds_ldm.name = get_client_device_name(name,"%s_leds"); //printk("%s %s %d adc_ldm.name =%s\n",__FILE__,__func__,__LINE__,pmic_spi_adc_ldm.name); //printk("%s %s %d battery_ldm.name =%s\n",__FILE__,__func__,__LINE__,pmic_spi_battery_ldm.name); //printk("%s %s %d light_ldm.name =%s\n",__FILE__,__func__,__LINE__,pmic_spi_light_ldm.name); //printk("%s %s %d rtc_ldm.name =%s\n",__FILE__,__func__,__LINE__,pmic_spi_rtc_ldm.name); //printk("%s %s %d pmic_spi_rleds_ldm.name =%s\n",__FILE__,__func__,__LINE__,pmic_spi_rleds_ldm.name); //printk("%s %s %d pmic_spi_gleds_ldm.name =%s\n",__FILE__,__func__,__LINE__,pmic_spi_gleds_ldm.name); //printk("%s %s %d pmic_spi_bleds_ldm.name =%s\n",__FILE__,__func__,__LINE__,pmic_spi_bleds_ldm.name); /* Initialize the PMIC event handling */ pmic_event_list_init(); /* Initialize GPIO for PMIC Interrupt */ gpio_pmic_active(); /* Get the PMIC Version */ pmic_internal[pmic_index].pmic_get_revision(&mxc_pmic_version); if (mxc_pmic_version.revision < 0) { dev_err((struct device *)spi, "PMIC not detected!!! Access Failed\n"); return -ENODEV; } else { dev_dbg((struct device *)spi, "Detected pmic core IC version number is %d\n", mxc_pmic_version.revision); } spi_set_drvdata(spi, pmic_internal[pmic_index].pmic_alloc_data(&(spi->dev))); /* Initialize the PMIC parameters */ ret = pmic_internal[pmic_index].pmic_init_registers(); if (ret != PMIC_SUCCESS) { kfree(spi_get_drvdata(spi)); spi_set_drvdata(spi, NULL); return PMIC_ERROR; } ret = pmic_start_event_thread(spi->irq); if (ret) { pr_err("pmic driver init: \ fail to start event thread\n"); kfree(spi_get_drvdata(spi)); spi_set_drvdata(spi, NULL); return PMIC_ERROR; } /* Set and install PMIC IRQ handler */ set_irq_type(spi->irq, IRQF_TRIGGER_HIGH); ret = request_irq(spi->irq, pmic_irq_handler, 0, "PMIC_IRQ", 0); if (ret) { kfree(spi_get_drvdata(spi)); spi_set_drvdata(spi, NULL); dev_err((struct device *)spi, "gpio1: irq%d error.", spi->irq); return ret; } enable_irq_wake(spi->irq); if (plat_data && plat_data->init) { ret = plat_data->init(spi_get_drvdata(spi)); if (ret != 0) { kfree(spi_get_drvdata(spi)); spi_set_drvdata(spi, NULL); return PMIC_ERROR; } } pmic_spi_power_ldm.dev.platform_data = spi->dev.platform_data; pmic_pdev_register(); printk(KERN_INFO "Device %s probed\n", dev_name(&spi->dev)); return PMIC_SUCCESS; }