+
static int sii902x_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct device *dev = &client->dev;
- unsigned int status = 0;
struct sii902x *sii902x;
- u8 chipid[4];
int ret;
ret = i2c_check_functionality(client->adapter,
@@ -989,6 +992,43 @@ static int sii902x_probe(struct i2c_client *client,
mutex_init(&sii902x->mutex);
+ sii902x->iovcc = devm_regulator_get(dev, "iovcc");
+ if (IS_ERR(sii902x->iovcc))
+ return PTR_ERR(sii902x->iovcc);
+
+ sii902x->cvcc12 = devm_regulator_get(dev, "cvcc12");
+ if (IS_ERR(sii902x->cvcc12))
+ return PTR_ERR(sii902x->cvcc12);
+
+ ret = regulator_enable(sii902x->iovcc);
+ if (ret < 0) {
+ dev_err_probe(dev, ret, "Failed to enable iovcc supply");
+ return ret;
+ }
+
+ ret = regulator_enable(sii902x->cvcc12);
+ if (ret < 0) {
+ dev_err_probe(dev, ret, "Failed to enable cvcc12 supply");
+ regulator_disable(sii902x->iovcc);
+ return ret;
+ }
+
+ ret = sii902x_init(sii902x);
+ if (ret < 0) {
+ regulator_disable(sii902x->cvcc12);
+ regulator_disable(sii902x->iovcc);
+ }
+
+ return ret;
+}
+
+static int sii902x_init(struct sii902x *sii902x)
+{
+ struct device *dev = &sii902x->i2c->dev;
+ unsigned int status = 0;
+ u8 chipid[4];
+ int ret;
+
sii902x_reset(sii902x);
ret = regmap_write(sii902x->regmap, SII902X_REG_TPI_RQB, 0x0);
@@ -1012,11 +1052,11 @@ static int sii902x_probe(struct i2c_client *client,
regmap_read(sii902x->regmap, SII902X_INT_STATUS, &status);
regmap_write(sii902x->regmap, SII902X_INT_STATUS, status);
- if (client->irq > 0) {
+ if (sii902x->i2c->irq > 0) {
regmap_write(sii902x->regmap, SII902X_INT_ENABLE,
SII902X_HOTPLUG_EVENT);
- ret = devm_request_threaded_irq(dev, client->irq, NULL,
+ ret = devm_request_threaded_irq(dev, sii902x->i2c->irq, NULL,
sii902x_interrupt,
IRQF_ONESHOT, dev_name(dev),
sii902x);
@@ -1031,9 +1071,9 @@ static int sii902x_probe(struct i2c_client *client,
sii902x_audio_codec_init(sii902x, dev);
- i2c_set_clientdata(client, sii902x);
+ i2c_set_clientdata(sii902x->i2c, sii902x);
- sii902x->i2cmux = i2c_mux_alloc(client->adapter, dev,
+ sii902x->i2cmux = i2c_mux_alloc(sii902x->i2c->adapter, dev,
1, 0, I2C_MUX_GATE,
sii902x_i2c_bypass_select,
sii902x_i2c_bypass_deselect);
@@ -1051,6 +1091,8 @@ static int sii902x_remove(struct i2c_client *client)
i2c_mux_del_adapters(sii902x->i2cmux);
drm_bridge_remove(&sii902x->bridge);
+ regulator_disable(sii902x->cvcc12);
+ regulator_disable(sii902x->iovcc);
return 0;
}