static int __devinit cyttsp4_spi_probe(struct spi_device *spi) { struct cyttsp4_spi *ts_spi; int rc = 0; struct device *dev = &spi->dev; char const *adap_id = dev_get_platdata(dev); char const *id; dev_dbg(dev, "%s: Probing ...\n", __func__); spi->bits_per_word = CY_SPI_BITS_PER_WORD; spi->mode = SPI_MODE_0; rc = spi_setup(spi); if (rc < 0) { dev_err(dev, "%s: SPI setup error %d\n", __func__, rc); return rc; } ts_spi = kzalloc(sizeof(*ts_spi), GFP_KERNEL); if (ts_spi == NULL) { dev_err(dev, "%s: Error, kzalloc\n", __func__); rc = -ENOMEM; goto error_alloc_data_failed; } mutex_init(&ts_spi->lock); ts_spi->client = spi; dev_set_drvdata(&spi->dev, ts_spi); if (adap_id) id = adap_id; else id = CYTTSP4_SPI_NAME; dev_dbg(dev, "%s: add adap='%s' (CYTTSP4_SPI_NAME=%s)\n", __func__, id, CYTTSP4_SPI_NAME); pm_runtime_enable(&spi->dev); rc = cyttsp4_add_adapter(id, &ops, dev); if (rc) { dev_err(dev, "%s: Error on probe %s\n", __func__, CYTTSP4_SPI_NAME); goto add_adapter_err; } dev_info(dev, "%s: Successful prob %s\n", __func__, CYTTSP4_SPI_NAME); return 0; add_adapter_err: pm_runtime_disable(&spi->dev); dev_set_drvdata(&spi->dev, NULL); kfree(ts_spi); error_alloc_data_failed: return rc; }
static int __devinit cyttsp4_i2c_probe(struct i2c_client *client, const struct i2c_device_id *i2c_id) { struct cyttsp4_i2c *ts_i2c; struct device *dev = &client->dev; char const *adap_id = dev_get_platdata(dev); char const *id; int rc; dev_info(dev, "%s: Starting %s probe...\n", __func__, CYTTSP4_I2C_NAME); dev_dbg(dev, "%s: debug on\n", __func__); dev_vdbg(dev, "%s: verbose debug on\n", __func__); if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { dev_err(dev, "%s: fail check I2C functionality\n", __func__); rc = -EIO; goto error_alloc_data_failed; } ts_i2c = kzalloc(sizeof(struct cyttsp4_i2c), GFP_KERNEL); if (ts_i2c == NULL) { dev_err(dev, "%s: Error, kzalloc.\n", __func__); rc = -ENOMEM; goto error_alloc_data_failed; } mutex_init(&ts_i2c->lock); ts_i2c->client = client; client->dev.bus = &i2c_bus_type; i2c_set_clientdata(client, ts_i2c); dev_set_drvdata(&client->dev, ts_i2c); if (adap_id) id = adap_id; else id = CYTTSP4_I2C_NAME; dev_dbg(dev, "%s: add adap='%s' (CYTTSP4_I2C_NAME=%s)\n", __func__, id, CYTTSP4_I2C_NAME); pm_runtime_enable(&client->dev); rc = cyttsp4_add_adapter(id, &ops, dev); if (rc) { dev_err(dev, "%s: Error on probe %s\n", __func__, CYTTSP4_I2C_NAME); goto add_adapter_err; } dev_info(dev, "%s: Successful probe %s\n", __func__, CYTTSP4_I2C_NAME); return 0; add_adapter_err: pm_runtime_disable(&client->dev); dev_set_drvdata(&client->dev, NULL); i2c_set_clientdata(client, NULL); kfree(ts_i2c); error_alloc_data_failed: return rc; }
static int __devinit cyttsp4_i2c_probe(struct i2c_client *client, const struct i2c_device_id *i2c_id) { struct cyttsp4_i2c *ts_i2c; struct device *dev = &client->dev; char const *adap_id = dev_get_platdata(dev); char const *id; int rc; int error; struct regulator *vdd; struct regulator *vbus; if (!hsad_get_cyttsp4_enable()) { dev_info(&client->dev, "%s: cyttsp4 device not exits\n", __func__); return -EINVAL; } dev_info(dev, "%s: Starting %s probe...\n", __func__, CYTTSP4_I2C_NAME); dev_dbg(dev, "%s: debug on\n", __func__); dev_vdbg(dev, "%s: verbose debug on\n", __func__); // huawei patch /* VDD power on */ // CYPRESS_VDD "ts-vdd" vdd = regulator_get(&client->dev, TP_ANALOG_VDD);//"ts-vdd-cypress" if (IS_ERR(vdd)) { dev_err(&client->dev, "%s: failed to get cypress vdd\n", __func__); return -EINVAL; } error = regulator_set_voltage(vdd,2800000,2800000); if(error < 0){ dev_err(&client->dev, "%s: failed to set cypress vdd\n", __func__); rc= -EINVAL; goto error_enable_vdd; } error = regulator_enable(vdd); if (error < 0) { dev_err(&client->dev, "%s: failed to enable cypress vdd\n", __func__); rc= -EINVAL; goto error_enable_vdd; } /* VBUS power on */ // CYPRESS_VBUS vbus = regulator_get(&client->dev, TP_IO_VDD);//"ts-vbus-cypress" if (IS_ERR(vbus)) { dev_err(&client->dev, "%s: failed to get cypress vbus\n", __func__); rc= -EINVAL; goto error_get_vbus; } //error = regulator_set_voltage(vbus,1800000,1800000); //if(error < 0){ // dev_err(&client->dev, "%s: failed to set cypress vbus\n", __func__); // return -EINVAL; //} error = regulator_enable(vbus); if (error < 0) { dev_err(&client->dev, "%s: failed to enable cypress vbus\n", __func__); rc= -EINVAL; goto error_enable_vbus; } cy_client.vdd = vdd; cy_client.vbus = vbus; msleep(5); // huawei patch end if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { dev_err(dev, "%s: fail check I2C functionality\n", __func__); rc = -EIO; goto error_alloc_data_failed; } ts_i2c = kzalloc(sizeof(struct cyttsp4_i2c), GFP_KERNEL); if (ts_i2c == NULL) { dev_err(dev, "%s: Error, kzalloc.\n", __func__); rc = -ENOMEM; goto error_alloc_data_failed; } mutex_init(&ts_i2c->lock); ts_i2c->client = client; client->dev.bus = &i2c_bus_type; i2c_set_clientdata(client, ts_i2c); dev_set_drvdata(&client->dev, ts_i2c); if (adap_id) id = adap_id; else id = CYTTSP4_I2C_NAME; dev_dbg(dev, "%s: add adap='%s' (CYTTSP4_I2C_NAME=%s)\n", __func__, id, CYTTSP4_I2C_NAME); pm_runtime_enable(&client->dev); rc = cyttsp4_add_adapter(id, &ops, dev); if (rc) { dev_err(dev, "%s: Error on probe %s\n", __func__, CYTTSP4_I2C_NAME); goto add_adapter_err; } dev_info(dev, "%s: Successful probe %s\n", __func__, CYTTSP4_I2C_NAME); return 0; add_adapter_err: pm_runtime_disable(&client->dev); dev_set_drvdata(&client->dev, NULL); i2c_set_clientdata(client, NULL); kfree(ts_i2c); error_alloc_data_failed: regulator_disable(vbus); error_enable_vbus: regulator_put(vbus); error_get_vbus: regulator_disable(vdd); error_enable_vdd: regulator_put(vdd); return rc; }
static int __devinit cyttsp4_spi_probe(struct spi_device *spi) { struct cyttsp4_spi *ts_spi; int rc = 0; struct device *dev = &spi->dev; const struct of_device_id *match; char const *adap_id; dev_dbg(dev, "%s: Probing ...\n", __func__); spi->bits_per_word = CY_SPI_BITS_PER_WORD; spi->mode = SPI_MODE_0; rc = spi_setup(spi); if (rc < 0) { dev_err(dev, "%s: SPI setup error %d\n", __func__, rc); return rc; } ts_spi = kzalloc(sizeof(*ts_spi), GFP_KERNEL); if (ts_spi == NULL) { dev_err(dev, "%s: Error, kzalloc\n", __func__); rc = -ENOMEM; goto error_alloc_data_failed; } match = of_match_device(of_match_ptr(cyttsp4_spi_of_match), dev); if (match) { rc = of_property_read_string(dev->of_node, "cy,adapter_id", &adap_id); if (rc) { dev_err(dev, "%s: OF error rc=%d\n", __func__, rc); goto error_free_data; } cyttsp4_devtree_register_devices(dev); } else { adap_id = dev_get_platdata(dev); } mutex_init(&ts_spi->lock); ts_spi->client = spi; ts_spi->id = (adap_id) ? adap_id : CYTTSP4_SPI_NAME; dev_set_drvdata(&spi->dev, ts_spi); dev_dbg(dev, "%s: add adap='%s' (CYTTSP4_SPI_NAME=%s)\n", __func__, ts_spi->id, CYTTSP4_SPI_NAME); pm_runtime_enable(&spi->dev); rc = cyttsp4_add_adapter(ts_spi->id, &ops, dev); if (rc) { dev_err(dev, "%s: Error on probe %s\n", __func__, CYTTSP4_SPI_NAME); goto add_adapter_err; } dev_info(dev, "%s: Successful prob %s\n", __func__, CYTTSP4_SPI_NAME); return 0; add_adapter_err: pm_runtime_disable(&spi->dev); dev_set_drvdata(&spi->dev, NULL); error_free_data: kfree(ts_spi); error_alloc_data_failed: return rc; }