Commit cc6d618f authored by Dinesh Ram's avatar Dinesh Ram Committed by Mauro Carvalho Chehab

[media] si4713: move supply list to si4713_platform_data

The supply list is needed by the platform driver, but not by the usb driver.
So this information belongs to the platform data and should not be hardcoded
in the subdevice driver.
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Tested-by: default avatarEduardo Valentin <edubezval@gmail.com>
Acked-by: default avatarEduardo Valentin <edubezval@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent 99995ded
...@@ -760,7 +760,14 @@ static struct regulator_init_data rx51_vintdig = { ...@@ -760,7 +760,14 @@ static struct regulator_init_data rx51_vintdig = {
}, },
}; };
static const char * const si4713_supply_names[] = {
"vio",
"vdd",
};
static struct si4713_platform_data rx51_si4713_i2c_data __initdata_or_module = { static struct si4713_platform_data rx51_si4713_i2c_data __initdata_or_module = {
.supplies = ARRAY_SIZE(si4713_supply_names),
.supply_names = si4713_supply_names,
.gpio_reset = RX51_FMTX_RESET_GPIO, .gpio_reset = RX51_FMTX_RESET_GPIO,
}; };
......
...@@ -44,11 +44,6 @@ MODULE_AUTHOR("Eduardo Valentin <eduardo.valentin@nokia.com>"); ...@@ -44,11 +44,6 @@ MODULE_AUTHOR("Eduardo Valentin <eduardo.valentin@nokia.com>");
MODULE_DESCRIPTION("I2C driver for Si4713 FM Radio Transmitter"); MODULE_DESCRIPTION("I2C driver for Si4713 FM Radio Transmitter");
MODULE_VERSION("0.0.1"); MODULE_VERSION("0.0.1");
static const char *si4713_supply_names[SI4713_NUM_SUPPLIES] = {
"vio",
"vdd",
};
#define DEFAULT_RDS_PI 0x00 #define DEFAULT_RDS_PI 0x00
#define DEFAULT_RDS_PTY 0x00 #define DEFAULT_RDS_PTY 0x00
#define DEFAULT_RDS_DEVIATION 0x00C8 #define DEFAULT_RDS_DEVIATION 0x00C8
...@@ -368,12 +363,13 @@ static int si4713_powerup(struct si4713_device *sdev) ...@@ -368,12 +363,13 @@ static int si4713_powerup(struct si4713_device *sdev)
if (sdev->power_state) if (sdev->power_state)
return 0; return 0;
err = regulator_bulk_enable(ARRAY_SIZE(sdev->supplies), if (sdev->supplies) {
sdev->supplies); err = regulator_bulk_enable(sdev->supplies, sdev->supply_data);
if (err) { if (err) {
v4l2_err(&sdev->sd, "Failed to enable supplies: %d\n", err); v4l2_err(&sdev->sd, "Failed to enable supplies: %d\n", err);
return err; return err;
} }
}
if (gpio_is_valid(sdev->gpio_reset)) { if (gpio_is_valid(sdev->gpio_reset)) {
udelay(50); udelay(50);
gpio_set_value(sdev->gpio_reset, 1); gpio_set_value(sdev->gpio_reset, 1);
...@@ -396,11 +392,12 @@ static int si4713_powerup(struct si4713_device *sdev) ...@@ -396,11 +392,12 @@ static int si4713_powerup(struct si4713_device *sdev)
if (client->irq) if (client->irq)
err = si4713_write_property(sdev, SI4713_GPO_IEN, err = si4713_write_property(sdev, SI4713_GPO_IEN,
SI4713_STC_INT | SI4713_CTS); SI4713_STC_INT | SI4713_CTS);
} else { return err;
}
if (gpio_is_valid(sdev->gpio_reset)) if (gpio_is_valid(sdev->gpio_reset))
gpio_set_value(sdev->gpio_reset, 0); gpio_set_value(sdev->gpio_reset, 0);
err = regulator_bulk_disable(ARRAY_SIZE(sdev->supplies), if (sdev->supplies) {
sdev->supplies); err = regulator_bulk_disable(sdev->supplies, sdev->supply_data);
if (err) if (err)
v4l2_err(&sdev->sd, v4l2_err(&sdev->sd,
"Failed to disable supplies: %d\n", err); "Failed to disable supplies: %d\n", err);
...@@ -432,11 +429,13 @@ static int si4713_powerdown(struct si4713_device *sdev) ...@@ -432,11 +429,13 @@ static int si4713_powerdown(struct si4713_device *sdev)
v4l2_dbg(1, debug, &sdev->sd, "Device in reset mode\n"); v4l2_dbg(1, debug, &sdev->sd, "Device in reset mode\n");
if (gpio_is_valid(sdev->gpio_reset)) if (gpio_is_valid(sdev->gpio_reset))
gpio_set_value(sdev->gpio_reset, 0); gpio_set_value(sdev->gpio_reset, 0);
err = regulator_bulk_disable(ARRAY_SIZE(sdev->supplies), if (sdev->supplies) {
sdev->supplies); err = regulator_bulk_disable(sdev->supplies,
sdev->supply_data);
if (err) if (err)
v4l2_err(&sdev->sd, v4l2_err(&sdev->sd,
"Failed to disable supplies: %d\n", err); "Failed to disable supplies: %d\n", err);
}
sdev->power_state = POWER_OFF; sdev->power_state = POWER_OFF;
} }
...@@ -1381,13 +1380,14 @@ static int si4713_probe(struct i2c_client *client, ...@@ -1381,13 +1380,14 @@ static int si4713_probe(struct i2c_client *client,
} }
sdev->gpio_reset = pdata->gpio_reset; sdev->gpio_reset = pdata->gpio_reset;
gpio_direction_output(sdev->gpio_reset, 0); gpio_direction_output(sdev->gpio_reset, 0);
sdev->supplies = pdata->supplies;
} }
for (i = 0; i < ARRAY_SIZE(sdev->supplies); i++) for (i = 0; i < sdev->supplies; i++)
sdev->supplies[i].supply = si4713_supply_names[i]; sdev->supply_data[i].supply = pdata->supply_names[i];
rval = regulator_bulk_get(&client->dev, ARRAY_SIZE(sdev->supplies), rval = regulator_bulk_get(&client->dev, sdev->supplies,
sdev->supplies); sdev->supply_data);
if (rval) { if (rval) {
dev_err(&client->dev, "Cannot get regulators: %d\n", rval); dev_err(&client->dev, "Cannot get regulators: %d\n", rval);
goto free_gpio; goto free_gpio;
...@@ -1500,7 +1500,7 @@ static int si4713_probe(struct i2c_client *client, ...@@ -1500,7 +1500,7 @@ static int si4713_probe(struct i2c_client *client,
free_ctrls: free_ctrls:
v4l2_ctrl_handler_free(hdl); v4l2_ctrl_handler_free(hdl);
put_reg: put_reg:
regulator_bulk_free(ARRAY_SIZE(sdev->supplies), sdev->supplies); regulator_bulk_free(sdev->supplies, sdev->supply_data);
free_gpio: free_gpio:
if (gpio_is_valid(sdev->gpio_reset)) if (gpio_is_valid(sdev->gpio_reset))
gpio_free(sdev->gpio_reset); gpio_free(sdev->gpio_reset);
...@@ -1524,7 +1524,7 @@ static int si4713_remove(struct i2c_client *client) ...@@ -1524,7 +1524,7 @@ static int si4713_remove(struct i2c_client *client)
v4l2_device_unregister_subdev(sd); v4l2_device_unregister_subdev(sd);
v4l2_ctrl_handler_free(sd->ctrl_handler); v4l2_ctrl_handler_free(sd->ctrl_handler);
regulator_bulk_free(ARRAY_SIZE(sdev->supplies), sdev->supplies); regulator_bulk_free(sdev->supplies, sdev->supply_data);
if (gpio_is_valid(sdev->gpio_reset)) if (gpio_is_valid(sdev->gpio_reset))
gpio_free(sdev->gpio_reset); gpio_free(sdev->gpio_reset);
kfree(sdev); kfree(sdev);
......
...@@ -227,7 +227,8 @@ struct si4713_device { ...@@ -227,7 +227,8 @@ struct si4713_device {
struct v4l2_ctrl *tune_ant_cap; struct v4l2_ctrl *tune_ant_cap;
}; };
struct completion work; struct completion work;
struct regulator_bulk_data supplies[SI4713_NUM_SUPPLIES]; unsigned supplies;
struct regulator_bulk_data supply_data[SI4713_NUM_SUPPLIES];
int gpio_reset; int gpio_reset;
u32 power_state; u32 power_state;
u32 rds_enabled; u32 rds_enabled;
......
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
* Platform dependent definition * Platform dependent definition
*/ */
struct si4713_platform_data { struct si4713_platform_data {
const char * const *supply_names;
unsigned supplies;
int gpio_reset; /* < 0 if not used */ int gpio_reset; /* < 0 if not used */
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment