ad5820: Define entity function
Subsystems (3)
PATCH 3/4 ad5820: DT new optional field enable-gpios
In reply to Ricardo Ribalda DelgadoDocument new enable-gpio field. It can be used to disable the part without turning down its regulator.
--- Documentation/devicetree/bindings/media/i2c/ad5820.txt | 6 ++++++ 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/media/i2c/ad5820.txt +6 -0
@@ -8,6 +8,11 @@ Required Properties: - VANA-supply: supply of voltage for VANA pin +Optional properties: + + - enable-gpios : GPIO spec for the XSHUTDOWN pin. If specified, it will be + asserted when VANA-supply is enabled. + Example: ad5820: coil@c {
@@ -15,5 +20,6 @@ Example: reg = <0x0c>; VANA-supply = <&vaux4>; + enable-gpios = <&msmgpio 26 GPIO_ACTIVE_HIGH>; };
Signature · 1 line
2.18.0
PATCH 1/4 ad5820: Define entity function
Without this patch, media_device_register_entity throws a warning:
dev_warn(mdev->dev,
"Entity type for entity %s was not initialized!\n", entity->name);
--- drivers/media/i2c/ad5820.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/i2c/ad5820.c +1 -0
@@ -317,6 +317,7 @@ static int ad5820_probe(struct i2c_client *client,v4l2_i2c_subdev_init (&coil->subdev, client, &ad5820_ops); coil->subdev.flags |=V4L2_SUBDEV_FL_HAS_DEVNODE ; coil->subdev.internal_ops = &ad5820_internal_ops; + coil->subdev.entity.function =MEDIA_ENT_F_LENS ;strscpy (coil->subdev.name,"ad5820 focus" ,sizeof (coil->subdev.name)); ret =media_entity_pads_init (&coil->subdev.entity,0 ,NULL );
Signature · 1 line
2.18.0
PATCH 2/4 ad5820: Add support for enable pin
This patch adds support for a programmable enable pin. It can be used in situations where the ANA-vcc is not configurable (dummy-regulator), or just to have a more fine control of the power saving.
The use of the enable pin is optional
--- drivers/media/i2c/Kconfig | 2 +- drivers/media/i2c/ad5820.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-)
drivers/media/i2c/Kconfig +1 -1
@@ -321,7 +321,7 @@ config VIDEO_ML86V7667 config VIDEO_AD5820 tristate "AD5820 lens voice coil support" - depends on I2C && VIDEO_V4L2 && MEDIA_CONTROLLER + depends on GPIOLIB && I2C && VIDEO_V4L2 && MEDIA_CONTROLLER ---help--- This is a driver for the AD5820 camera lens voice coil. It is used for example in Nokia N900 (RX-51).
drivers/media/i2c/ad5820.c +20 -0
@@ -27,6 +27,7 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/regulator/consumer.h> +#include <linux/gpio/consumer.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-device.h>
@@ -55,6 +56,8 @@ struct ad5820_device {u32 focus_ramp_time;u32 focus_ramp_mode; +struct gpio_desc *enable_gpio; +struct mutex power_lock;int power_count;
@@ -122,6 +125,9 @@ static int ad5820_power_off(struct ad5820_device *coil, bool standby) ret =ad5820_update_hw (coil); } +if (coil->enable_gpio) +gpiod_set_value_cansleep (coil->enable_gpio,0 ); + ret2 =regulator_disable (coil->vana);if (ret)return ret;
@@ -136,6 +142,9 @@ static int ad5820_power_on(struct ad5820_device *coil, bool restore)if (ret <0 )return ret; +if (coil->enable_gpio) +gpiod_set_value_cansleep (coil->enable_gpio,1 ); +if (restore) {/* Restore the hardware settings. */ coil->standby = false;
@@ -146,6 +155,8 @@ static int ad5820_power_on(struct ad5820_device *coil, bool restore)return 0 ; fail: +if (coil->enable_gpio) +gpiod_set_value_cansleep (coil->enable_gpio,0 ); coil->standby = true;regulator_disable (coil->vana);
@@ -312,6 +323,15 @@ static int ad5820_probe(struct i2c_client *client,return ret; } + coil->enable_gpio =devm_gpiod_get_optional (&client->dev,"enable" , +GPIOD_OUT_LOW ); +if (IS_ERR (coil->enable_gpio)) { + ret =PTR_ERR (coil->enable_gpio); +if (ret == -EPROBE_DEFER ) +dev_err (&client->dev,"could not get enable gpio\n" ); +return ret; + } +mutex_init (&coil->power_lock);v4l2_i2c_subdev_init (&coil->subdev, client, &ad5820_ops);
Signature · 1 line
2.18.0
PATCH 4/4 ad5820: Add support for of-autoload
In reply to Ricardo Ribalda DelgadoSince kernel 4.16, i2c devices with DT compatible tag are modprobed using their DT modalias.
Without this patch, if this driver is build as module it would never be autoprobed.
--- drivers/media/i2c/ad5820.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/media/i2c/ad5820.c +7 -0
@@ -375,12 +375,19 @@ static const struct i2c_device_id ad5820_id_table[] = { };MODULE_DEVICE_TABLE (i2c, ad5820_id_table); +static const struct of_device_id ad5820_of_table[] = { + { .compatible ="adi" AD5820_NAME }, + { } +}; +MODULE_DEVICE_TABLE (of, ad5820_of_table); + static SIMPLE_DEV_PM_OPS(ad5820_pm, ad5820_suspend, ad5820_resume);static struct i2c_driver ad5820_i2c_driver = { .driver = { .name =AD5820_NAME , .pm = &ad5820_pm, + .of_match_table = ad5820_of_table, }, .probe = ad5820_probe, .remove = ad5820_remove,
Signature · 1 line
2.18.0
PATCH v2 4/4 ad5820: Add support for of-autoload
Since kernel 4.16, i2c devices with DT compatible tag are modprobed using their DT modalias.
Without this patch, if this driver is build as module it would never be autoprobed.
--- drivers/media/i2c/ad5820.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/media/i2c/ad5820.c +7 -0
@@ -375,12 +375,19 @@ static const struct i2c_device_id ad5820_id_table[] = { };MODULE_DEVICE_TABLE (i2c, ad5820_id_table); +static const struct of_device_id ad5820_of_table[] = { + { .compatible ="adi," AD5820_NAME }, + { } +}; +MODULE_DEVICE_TABLE (of, ad5820_of_table); + static SIMPLE_DEV_PM_OPS(ad5820_pm, ad5820_suspend, ad5820_resume);static struct i2c_driver ad5820_i2c_driver = { .driver = { .name =AD5820_NAME , .pm = &ad5820_pm, + .of_match_table = ad5820_of_table, }, .probe = ad5820_probe, .remove = ad5820_remove,
Signature · 1 line
2.18.0
Sakari Ailus
maintainerRe: [PATCH 2/4] [media] ad5820: Add support for enable pin
In reply to Ricardo Ribalda DelgadoHi Ricardo,
Thanks for the set! A few comments below...
Quoted 5 lines · Ricardo Ribalda Delgado
This patch adds support for a programmable enable pin. It can be used in situations where the ANA-vcc is not configurable (dummy-regulator), or just to have a more fine control of the power saving.
The use of the enable pin is optional
Missing period at the end of the sentence.
Quoted 42 lines
Signed-off-by Ricardo Ribalda Delgado <[email protected]>--- drivers/media/i2c/Kconfig | 2 +- drivers/media/i2c/ad5820.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-)drivers/media/i2c/Kconfig +1
-1@@ -321,7 +321,7 @@ config VIDEO_ML86V7667 config VIDEO_AD5820 tristate "AD5820 lens voice coil support" - depends on I2C && VIDEO_V4L2 && MEDIA_CONTROLLER + depends on GPIOLIB && I2C && VIDEO_V4L2 && MEDIA_CONTROLLER ---help--- This is a driver for the AD5820 camera lens voice coil. It is used for example in Nokia N900 (RX-51).drivers/media/i2c/ad5820.c +3
-0@@ -27,6 +27,7 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/regulator/consumer.h> +#include <linux/gpio/consumer.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-device.h> @@ -55,6 +56,8 @@ struct ad5820_device {u32 focus_ramp_time;u32 focus_ramp_mode; +struct gpio_desc *enable_gpio; +struct mutex power_lock;int power_count;
drivers/media/i2c/ad5820.c static int ad5820_power_off(struct ad5820_device *coil, bool standby) · line 129
Quoted 5 lines
drivers/media/i2c/ad5820.c +2
-0@@ -122,6 +125,9 @@ static int ad5820_power_off(struct ad5820_device *coil, bool standby) ret =ad5820_update_hw (coil); } +if (coil->enable_gpio) +gpiod_set_value_cansleep (coil->enable_gpio,0 );
gpiod_set_value_cansleep(), as I think most (or all?) similar functions, are happy with NULL gpio descriptor. You can thus drop the NULL check here and below.
Quoted 39 lines
drivers/media/i2c/ad5820.c +15
-0+ ret2 =regulator_disable (coil->vana);if (ret)return ret;@@ -136,6 +142,9 @@ static int ad5820_power_on(struct ad5820_device *coil, bool restore)if (ret <0 )return ret; +if (coil->enable_gpio) +gpiod_set_value_cansleep (coil->enable_gpio,1 ); +if (restore) {/* Restore the hardware settings. */ coil->standby = false;@@ -146,6 +155,8 @@ static int ad5820_power_on(struct ad5820_device *coil, bool restore)return 0 ; fail: +if (coil->enable_gpio) +gpiod_set_value_cansleep (coil->enable_gpio,0 ); coil->standby = true;regulator_disable (coil->vana);@@ -312,6 +323,15 @@ static int ad5820_probe(struct i2c_client *client,return ret; } + coil->enable_gpio =devm_gpiod_get_optional (&client->dev,"enable" , +GPIOD_OUT_LOW ); +if (IS_ERR (coil->enable_gpio)) { + ret =PTR_ERR (coil->enable_gpio); +if (ret == -EPROBE_DEFER ) +dev_err (&client->dev,"could not get enable gpio\n" ); +return ret; + } +mutex_init (&coil->power_lock);v4l2_i2c_subdev_init (&coil->subdev, client, &ad5820_ops);
Signature · 4 lines
Regards, Sakari Ailus e-mail: [email protected]
PATCH v2 2/4 ad5820: Add support for enable pin
In reply to Ricardo Ribalda DelgadoThis patch adds support for a programmable enable pin. It can be used in situations where the ANA-vcc is not configurable (dummy-regulator), or just to have a more fine control of the power saving.
The use of the enable pin is optional.
--- drivers/media/i2c/Kconfig | 2 +- drivers/media/i2c/ad5820.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-)
drivers/media/i2c/Kconfig +1 -1
@@ -321,7 +321,7 @@ config VIDEO_ML86V7667 config VIDEO_AD5820 tristate "AD5820 lens voice coil support" - depends on I2C && VIDEO_V4L2 && MEDIA_CONTROLLER + depends on GPIOLIB && I2C && VIDEO_V4L2 && MEDIA_CONTROLLER ---help--- This is a driver for the AD5820 camera lens voice coil. It is used for example in Nokia N900 (RX-51).
drivers/media/i2c/ad5820.c +17 -0
@@ -27,6 +27,7 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/regulator/consumer.h> +#include <linux/gpio/consumer.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-device.h>
@@ -55,6 +56,8 @@ struct ad5820_device {u32 focus_ramp_time;u32 focus_ramp_mode; +struct gpio_desc *enable_gpio; +struct mutex power_lock;int power_count;
@@ -122,6 +125,8 @@ static int ad5820_power_off(struct ad5820_device *coil, bool standby) ret =ad5820_update_hw (coil); } +gpiod_set_value_cansleep (coil->enable_gpio,0 ); + ret2 =regulator_disable (coil->vana);if (ret)return ret;
@@ -136,6 +141,8 @@ static int ad5820_power_on(struct ad5820_device *coil, bool restore)if (ret <0 )return ret; +gpiod_set_value_cansleep (coil->enable_gpio,1 ); +if (restore) {/* Restore the hardware settings. */ coil->standby = false;
@@ -146,6 +153,7 @@ static int ad5820_power_on(struct ad5820_device *coil, bool restore)return 0 ; fail: +gpiod_set_value_cansleep (coil->enable_gpio,0 ); coil->standby = true;regulator_disable (coil->vana);
@@ -312,6 +320,15 @@ static int ad5820_probe(struct i2c_client *client,return ret; } + coil->enable_gpio =devm_gpiod_get_optional (&client->dev,"enable" , +GPIOD_OUT_LOW ); +if (IS_ERR (coil->enable_gpio)) { + ret =PTR_ERR (coil->enable_gpio); +if (ret == -EPROBE_DEFER ) +dev_err (&client->dev,"could not get enable gpio\n" ); +return ret; + } +mutex_init (&coil->power_lock);v4l2_i2c_subdev_init (&coil->subdev, client, &ad5820_ops);
Signature · 1 line
2.18.0
Re: [PATCH 2/4] [media] ad5820: Add support for enable pin
In reply to Sakari AilusHi Sakari
Quoted 5 lines · Sakari Ailus
Hi Ricardo,
Thanks for the set! A few comments below...
Quoted 9 lines
Quoted 5 lines · Ricardo Ribalda Delgado
This patch adds support for a programmable enable pin. It can be used in situations where the ANA-vcc is not configurable (dummy-regulator), or just to have a more fine control of the power saving.
The use of the enable pin is optional
Missing period at the end of the sentence.
Thanks for the superfast response.
I have just sent a patch with your comments and also resend 4/4. I was missing a comma.
Thanks!
Quoted 1 line
Quoted 1 line
Re: [PATCH v2 2/4] [media] ad5820: Add support for enable pin
In reply to Ricardo Ribalda DelgadoQuoted 7 lines · Ricardo Ribalda Delgado
This patch adds support for a programmable enable pin. It can be used in situations where the ANA-vcc is not configurable (dummy-regulator), or just to have a more fine control of the power saving.
The use of the enable pin is optional.
Signed-off-by Ricardo Ribalda Delgado <[email protected]>
Do we really want to do that?
Would it make more sense to add gpio-regulator and connect ad5820 to it in such case?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCH v2 4/4] [media] ad5820: Add support for of-autoload
In reply to Ricardo Ribalda DelgadoQuoted 6 lines · Ricardo Ribalda Delgado
Since kernel 4.16, i2c devices with DT compatible tag are modprobed using their DT modalias.
Without this patch, if this driver is build as module it would never be autoprobed.Signed-off-by Ricardo Ribalda Delgado <[email protected]>
1,4: Acked-by: Pavel Machek <[email protected]>
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCH v2 2/4] [media] ad5820: Add support for enable pin
In reply to Pavel MachekHi Pavel
Quoted 6 lines · Pavel Machek
Quoted 4 lines · Ricardo Ribalda Delgado
This patch adds support for a programmable enable pin. It can be used in situations where the ANA-vcc is not configurable (dummy-regulator), or just to have a more fine control of the power saving.
Quoted 9 lines
Quoted 3 lines
The use of the enable pin is optional.
Signed-off-by Ricardo Ribalda Delgado <[email protected]>Do we really want to do that?
Would it make more sense to add gpio-regulator and connect ad5820 to it in such case?
My board (based on db820c) has both:
ad5820: dac@0c {
compatible = "adi,ad5820";
reg = <0x0c>;
VANA-supply = <&pm8994_l23>;
enable-gpios = <&msmgpio 26 GPIO_ACTIVE_HIGH>;
};
Quoted 5 lines
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Signature · 1 line
Ricardo Ribalda
Re: [PATCH v2 2/4] [media] ad5820: Add support for enable pin
Quoted 21 lines · Ricardo Ribalda Delgado
Hi Pavel
Quoted 6 lines · Pavel Machek
Quoted 4 lines · Ricardo Ribalda Delgado
This patch adds support for a programmable enable pin. It can be used in situations where the ANA-vcc is not configurable (dummy-regulator), or just to have a more fine control of the power saving.
Quoted 9 lines
Quoted 3 lines
The use of the enable pin is optional.
Signed-off-by Ricardo Ribalda Delgado <[email protected]>Do we really want to do that?
Would it make more sense to add gpio-regulator and connect ad5820 to it in such case?
My board (based on db820c) has both:
Quoted 7 lines
ad5820: dac@0c {
compatible = "adi,ad5820";
reg = <0x0c>;
VANA-supply = <&pm8994_l23>;
enable-gpios = <&msmgpio 26 GPIO_ACTIVE_HIGH>;
};Well, I'm sure you could have gpio-based regulator powered from pm8994_l23, and outputting to ad5820.
Does ad5820 chip have a gpio input for enable?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCH v2 2/4] [media] ad5820: Add support for enable pin
Quoted 27 lines · Pavel Machek
Quoted 25 lines · Ricardo Ribalda Delgado
Hi Pavel
Quoted 6 lines · Pavel Machek
Quoted 4 lines · Ricardo Ribalda Delgado
This patch adds support for a programmable enable pin. It can be used in situations where the ANA-vcc is not configurable (dummy-regulator), or just to have a more fine control of the power saving.
Quoted 9 lines
Quoted 3 lines
The use of the enable pin is optional.
Signed-off-by Ricardo Ribalda Delgado <[email protected]>Do we really want to do that?
Would it make more sense to add gpio-regulator and connect ad5820 to it in such case?
My board (based on db820c) has both:
ad5820: dac@0c { compatible = "adi,ad5820"; reg = <0x0c>;
Quoted 8 lines
Quoted 3 lines
VANA-supply = <&pm8994_l23>; enable-gpios = <&msmgpio 26 GPIO_ACTIVE_HIGH>; };Well, I'm sure you could have gpio-based regulator powered from
pm8994_l23, and outputting to ad5820.Does ad5820 chip have a gpio input for enable?
xshutdown pin:
http://www.analog.com/media/en/technical-documentation/data-sheets/AD5821.pdf
(AD5820,AD5821, and AD5823 are compatibles, or at least that is waht the module manufacturer says :)
Quoted 4 lines
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
Ricardo Ribalda
Re: [PATCH v2 2/4] [media] ad5820: Add support for enable pin
Hi Ricardo,
Quoted 30 lines · On Thursday, 20 September 2018 22:12:44 EEST Ricardo Ribalda Delgado wrote:
Quoted 29 lines · Pavel Machek
Quoted 17 lines · Ricardo Ribalda Delgado
Quoted 5 lines · Pavel Machek
Quoted 4 lines · Ricardo Ribalda Delgado
This patch adds support for a programmable enable pin. It can be used in situations where the ANA-vcc is not configurable (dummy- regulator), or just to have a more fine control of the power saving.
Quoted 8 lines
Quoted 3 lines
The use of the enable pin is optional.
Signed-off-by Ricardo Ribalda Delgado <[email protected]>Do we really want to do that?
Would it make more sense to add gpio-regulator and connect ad5820 to it in such case?
My board (based on db820c) has both:
Quoted 7 lines
ad5820: dac@0c { compatible = "adi,ad5820"; reg = <0x0c>; VANA-supply = <&pm8994_l23>; enable-gpios = <&msmgpio 26 GPIO_ACTIVE_HIGH>; };Well, I'm sure you could have gpio-based regulator powered from
pm8994_l23, and outputting to ad5820.
Quoted 8 lines
Quoted 1 line
Does ad5820 chip have a gpio input for enable?
xshutdown pin:
http://www.analog.com/media/en/technical-documentation/data-sheets/AD5821.pd
f(AD5820,AD5821, and AD5823 are compatibles, or at least that is waht the module manufacturer says :)
Is that the pin that msmgpio 26 is connected to on your board ?
I'd argue that the GPIO should be called xshutdown in that case, as DT usually uses the pin name, but there's precedent of using well-known names for pins with the same functionality. In any case you should update the DT bindings to document the new property, and clearly explain that it describes the GPIO connected to the xshutdown pin. Please CC the [email protected] mailing list on the bindings change (they usually like bindings changes to be split to a separate patch).
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH v2 2/4] [media] ad5820: Add support for enable pin
Quoted 46 lines · On Thursday, 20 September 2018 23:04:21 EEST Laurent Pinchart wrote:
Hi Ricardo,
Quoted 32 lines · On Thursday, 20 September 2018 22:12:44 EEST Ricardo Ribalda Delgado wrote:
Quoted 31 lines · Pavel Machek
Quoted 19 lines · Ricardo Ribalda Delgado
Quoted 5 lines · Pavel Machek
Quoted 4 lines · Ricardo Ribalda Delgado
This patch adds support for a programmable enable pin. It can be used in situations where the ANA-vcc is not configurable (dummy- regulator), or just to have a more fine control of the power saving.
Quoted 8 lines
Quoted 3 lines
The use of the enable pin is optional.
Signed-off-by Ricardo Ribalda Delgado <[email protected]>Do we really want to do that?
Would it make more sense to add gpio-regulator and connect ad5820 to it in such case?
My board (based on db820c) has both:
ad5820: dac@0c {
Quoted 7 lines
compatible = "adi,ad5820"; reg = <0x0c>; VANA-supply = <&pm8994_l23>; enable-gpios = <&msmgpio 26 GPIO_ACTIVE_HIGH>;};
Well, I'm sure you could have gpio-based regulator powered from
pm8994_l23, and outputting to ad5820.Quoted 8 lines
Quoted 1 line
Does ad5820 chip have a gpio input for enable?
xshutdown pin:
http://www.analog.com/media/en/technical-documentation/data-sheets/AD5821.
pd f(AD5820,AD5821, and AD5823 are compatibles, or at least that is waht the module manufacturer says :)
Is that the pin that msmgpio 26 is connected to on your board ?
Quoted 7 lines
I'd argue that the GPIO should be called xshutdown in that case, as DT usually uses the pin name, but there's precedent of using well-known names for pins with the same functionality. In any case you should update the DT bindings to document the new property, and clearly explain that it describes the GPIO connected to the xshutdown pin. Please CC the [email protected] mailing list on the bindings change (they usually like bindings changes to be split to a separate patch).
And now I've noticed patch 3/4 :-/ Please scratch this.
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH v2 4/4] [media] ad5820: Add support for of-autoload
In reply to Ricardo Ribalda DelgadoHi Ricardo,
Thank you for the patch.
Quoted 15 lines · On Thursday, 20 September 2018 21:31:51 EEST Ricardo Ribalda Delgado wrote:
Since kernel 4.16, i2c devices with DT compatible tag are modprobed using their DT modalias.
Without this patch, if this driver is build as module it would never be autoprobed.Signed-off-by Ricardo Ribalda Delgado <[email protected]>--- drivers/media/i2c/ad5820.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/media/i2c/ad5820.c +0
-0
drivers/media/i2c/ad5820.c static const struct i2c_device_id ad5820_id_table[] = · line 379
Quoted 5 lines
drivers/media/i2c/ad5820.c +2
-0@@ -375,12 +375,19 @@ static const struct i2c_device_id ad5820_id_table[] = { };MODULE_DEVICE_TABLE (i2c, ad5820_id_table); +static const struct of_device_id ad5820_of_table[] = { + { .compatible ="adi," AD5820_NAME },
I'd spell this out explicitly, to make it easier to grep for the compatible string.
drivers/media/i2c/ad5820.c static const struct i2c_device_id ad5820_id_table[] = { · line 390
Quoted 11 lines
drivers/media/i2c/ad5820.c +5
-0+ { } +}; +MODULE_DEVICE_TABLE (of, ad5820_of_table); + static SIMPLE_DEV_PM_OPS(ad5820_pm, ad5820_suspend, ad5820_resume);static struct i2c_driver ad5820_i2c_driver = { .driver = { .name =AD5820_NAME , .pm = &ad5820_pm, + .of_match_table = ad5820_of_table,
As the driver doesn't depend on CONFIG_OF, would it make sense to use of_config_ptr() (and to compile the of table conditionally on CONFIG_OF) ?
Quoted 3 lines
drivers/media/i2c/ad5820.c +0
-0}, .probe = ad5820_probe, .remove = ad5820_remove,
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH v2 2/4] [media] ad5820: Add support for enable pin
In reply to Ricardo Ribalda DelgadoQuoted 35 lines · Ricardo Ribalda Delgado
Quoted 34 lines · Pavel Machek
Quoted 21 lines · Ricardo Ribalda Delgado
Hi Pavel
Quoted 6 lines · Pavel Machek
Quoted 4 lines · Ricardo Ribalda Delgado
This patch adds support for a programmable enable pin. It can be used in situations where the ANA-vcc is not configurable (dummy-regulator), or just to have a more fine control of the power saving.
Quoted 9 lines
Quoted 3 lines
The use of the enable pin is optional.
Signed-off-by Ricardo Ribalda Delgado <[email protected]>Do we really want to do that?
Would it make more sense to add gpio-regulator and connect ad5820 to it in such case?
My board (based on db820c) has both:
Quoted 7 lines
ad5820: dac@0c { compatible = "adi,ad5820"; reg = <0x0c>; VANA-supply = <&pm8994_l23>; enable-gpios = <&msmgpio 26 GPIO_ACTIVE_HIGH>; };Well, I'm sure you could have gpio-based regulator powered from
pm8994_l23, and outputting to ad5820.
Quoted 7 lines
Quoted 1 line
Does ad5820 chip have a gpio input for enable?
xshutdown pin:
http://www.analog.com/media/en/technical-documentation/data-sheets/AD5821.pdf(AD5820,AD5821, and AD5823 are compatibles, or at least that is waht the module manufacturer says :)
Aha, sorry for the noise.
2,3: Acked-by: Pavel Machek <[email protected]>
Thanks,
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Sakari Ailus
maintainerRe: [PATCH v2 4/4] [media] ad5820: Add support for of-autoload
In reply to Laurent PinchartHi Laurent,
Quoted 4 lines · Laurent Pinchart
Quoted 4 lines
drivers/media/i2c/ad5820.c +2
-0+MODULE_DEVICE_TABLE (of, ad5820_of_table); + static SIMPLE_DEV_PM_OPS(ad5820_pm, ad5820_suspend, ad5820_resume);
Quoted 8 lines
drivers/media/i2c/ad5820.c static const struct i2c_device_id ad5820_id_table[] = { · line 390
Quoted 5 lines
static struct
i2c_driverad5820_i2c_driver= {drivers/media/i2c/ad5820.c +1
-0.driver = { .name = AD5820_NAME, .pm = &ad5820_pm, + .of_match_table = ad5820_of_table,As the driver doesn't depend on
CONFIG_OF, would it make sense to useof_config_ptr()(and to compile the of table conditionally onCONFIG_OF) ?
You get ACPI support as a bonus if you don't use of_config_ptr(). :-) Other changes could be needed but this enables probing the driver for a device.
In this case the probability of anyone using this device on an ACPI system could be pretty low though.
Signature · 4 lines
Regards, Sakari Ailus e-mail: [email protected]
Re: [PATCH 3/4] [media] ad5820: DT new optional field enable-gpios
In reply to Ricardo Ribalda DelgadoHi Ricardo,
Thank you for the patch.
Quoted 15 lines · On Thursday, 20 September 2018 19:19:11 EEST Ricardo Ribalda Delgado wrote:
Document new enable-gpio field. It can be used to disable the part without turning down its regulator.
Signed-off-by Ricardo Ribalda Delgado <[email protected]>--- Documentation/devicetree/bindings/media/i2c/ad5820.txt | 6 ++++++ 1 file changed, 6 insertions(+)(quoted diff) +0
-0
b/Documentation/devicetree/bindings/media/i2c/ad5820.txtindex5940ca11c021..07d577bb37f7100644
Documentation/devicetree/bindings/media/i2c/ad5820.txt Required Properties: · line 13
Quoted 6 lines
Documentation/devicetree/bindings/media/i2c/ad5820.txt +3
-0@@ -8,6 +8,11 @@ Required Properties: - VANA-supply: supply of voltage for VANA pin +Optional properties: + + - enable-gpios : GPIO spec for the XSHUTDOWN pin.
xshutdown is active-low, so enable is active-high. Should this be documented explicitly, to avoid polarity errors ? Maybe something along the lines of
- enable-gpios: GPIO spec for the XSHUTDOWN pin. Note that the polarity of the enable GPIO is the opposite of the XSHUTDOWN pin (asserting the enable GPIO deasserts the XSHUTDOWN signal and vice versa).
Quoted 2 lines
If specified, it will be
+ asserted when VANA-supply is enabled.
That documents a driver behaviour, is it needed in DT ?
Quoted 9 lines
Example:
ad5820: coil@c {Documentation/devicetree/bindings/media/i2c/ad5820.txt +1
-0@@ -15,5 +20,6 @@ Example: reg = <0x0c>; VANA-supply = <&vaux4>; + enable-gpios = <&msmgpio 26 GPIO_ACTIVE_HIGH>; };
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH v2 2/4] [media] ad5820: Add support for enable pin
In reply to Pavel MachekHi!
Quoted 16 lines
Quoted 16 lines
Quoted 4 lines
Quoted 4 lines
ad5820: dac@0c { compatible = "adi,ad5820"; reg = <0x0c>;Quoted 8 lines
Quoted 3 lines
VANA-supply = <&pm8994_l23>; enable-gpios = <&msmgpio 26 GPIO_ACTIVE_HIGH>; };Well, I'm sure you could have gpio-based regulator powered from
pm8994_l23, and outputting to ad5820.Does ad5820 chip have a gpio input for enable?
xshutdown pin:
http://www.analog.com/media/en/technical-documentation/data-sheets/AD5821.pdf
Quoted 6 lines
Quoted 2 lines
(AD5820,AD5821, and AD5823 are compatibles, or at least that is waht the module manufacturer says :)
Aha, sorry for the noise.
2,3: Acked-by: Pavel Machek <[email protected]>
And I forgot to mention. If ad5821 and ad5823 are compatible, it would be good to mention it somewhere where it is easy to find... That can save quite a bit of work to someone.
Thanks,
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hi Ricardo,
Thank you for the patch.
Quoted 7 lines · On Thursday, 20 September 2018 19:19:09 EEST Ricardo Ribalda Delgado wrote:
Without this patch,
media_device_register_entitythrows a warning:dev_warn(mdev->dev,
"Entity type for entity %s was not initialized!\n", entity->name);Signed-off-by Ricardo Ribalda Delgado <[email protected]>
Quoted 16 lines
--- drivers/media/i2c/ad5820.c | 1 + 1 file changed, 1 insertion(+)drivers/media/i2c/ad5820.c +1
-0@@ -317,6 +317,7 @@ static int ad5820_probe(struct i2c_client *client,v4l2_i2c_subdev_init (&coil->subdev, client, &ad5820_ops); coil->subdev.flags |=V4L2_SUBDEV_FL_HAS_DEVNODE ; coil->subdev.internal_ops = &ad5820_internal_ops; + coil->subdev.entity.function =MEDIA_ENT_F_LENS ;strscpy (coil->subdev.name,"ad5820 focus" ,sizeof (coil->subdev.name)); ret =media_entity_pads_init (&coil->subdev.entity,0 ,NULL );
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH 3/4] [media] ad5820: DT new optional field enable-gpios
In reply to Laurent PinchartQuoted 31 lines · On Thursday, 20 September 2018 23:21:28 EEST Laurent Pinchart wrote:
Hi Ricardo,
Thank you for the patch.
Quoted 17 lines · On Thursday, 20 September 2018 19:19:11 EEST Ricardo Ribalda Delgado wrote:
Document new enable-gpio field. It can be used to disable the part without turning down its regulator.
Signed-off-by Ricardo Ribalda Delgado <[email protected]>---
Documentation/devicetree/bindings/media/i2c/ad5820.txt | 6 ++++++ 1 file changed, 6 insertions(+)(quoted diff) +0
-0
b/Documentation/devicetree/bindings/media/i2c/ad5820.txtindex5940ca11c021..07d577bb37f7100644Documentation/devicetree/bindings/media/i2c/ad5820.txt Required Properties: · line 12
Quoted 5 lines
Documentation/devicetree/bindings/media/i2c/ad5820.txt +3
-0@@ -8,6 +8,11 @@ Required Properties: - VANA-supply: supply of voltage for VANA pin +Optional properties: + + - enable-gpios : GPIO spec for the XSHUTDOWN pin.xshutdown is active-low, so enable is active-high. Should this be documented explicitly, to avoid polarity errors ? Maybe something along the lines of
Quoted 3 lines
- enable-gpios: GPIO spec for the XSHUTDOWN pin. Note that the polarity of the enable GPIO is the opposite of the XSHUTDOWN pin (asserting the enable GPIO deasserts the XSHUTDOWN signal and vice versa).
Or alternatively you could name the property xshutdown-gpios, as explained in my (incorrect) review of 2/4.
Quoted 14 lines
Quoted 2 lines
If specified, it will be
+ asserted when VANA-supply is enabled.That documents a driver behaviour, is it needed in DT ?
Quoted 9 lines
Example:
ad5820: coil@c {Documentation/devicetree/bindings/media/i2c/ad5820.txt +1
-0@@ -15,5 +20,6 @@ Example: reg = <0x0c>; VANA-supply = <&vaux4>; + enable-gpios = <&msmgpio 26 GPIO_ACTIVE_HIGH>; };
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH 3/4] [media] ad5820: DT new optional field enable-gpios
Hi
Quoted 33 lines · Laurent Pinchart
Quoted 31 lines · On Thursday, 20 September 2018 23:21:28 EEST Laurent Pinchart wrote:
Hi Ricardo,
Thank you for the patch.
Quoted 17 lines · On Thursday, 20 September 2018 19:19:11 EEST Ricardo Ribalda Delgado wrote:
Document new enable-gpio field. It can be used to disable the part without turning down its regulator.
Signed-off-by Ricardo Ribalda Delgado <[email protected]>---
Documentation/devicetree/bindings/media/i2c/ad5820.txt | 6 ++++++ 1 file changed, 6 insertions(+)(quoted diff) +0
-0
b/Documentation/devicetree/bindings/media/i2c/ad5820.txtindex5940ca11c021..07d577bb37f7100644Documentation/devicetree/bindings/media/i2c/ad5820.txt Required Properties: · line 12
Quoted 5 lines
Documentation/devicetree/bindings/media/i2c/ad5820.txt +3
-0@@ -8,6 +8,11 @@ Required Properties: - VANA-supply: supply of voltage for VANA pin +Optional properties: + + - enable-gpios : GPIO spec for the XSHUTDOWN pin.xshutdown is active-low, so enable is active-high. Should this be documented explicitly, to avoid polarity errors ? Maybe something along the lines of
Quoted 3 lines
Quoted 3 lines
- enable-gpios: GPIO spec for the XSHUTDOWN pin. Note that the polarity of the enable GPIO is the opposite of the XSHUTDOWN pin (asserting the enable GPIO deasserts the XSHUTDOWN signal and vice versa).
Agreed
Quoted 3 lines
Or alternatively you could name the property xshutdown-gpios, as explained in my (incorrect) review of 2/4.
I have double negatives :). If there is no other option I will rename it xshutdown, but I want to give it a try to enable.
Quoted 24 lines
Quoted 9 lines
Quoted 3 lines
If specified, it will be
+ asserted when VANA-supply is enabled.That documents a driver behaviour, is it needed in DT ?
Quoted 3 lines
Example:
ad5820: coil@c {Quoted 6 lines
Documentation/devicetree/bindings/media/i2c/ad5820.txt Example: · line 24
Quoted 6 lines
Documentation/devicetree/bindings/media/i2c/ad5820.txt +1
-0@@ -15,5 +20,6 @@ Example: reg = <0x0c>; VANA-supply = <&vaux4>; + enable-gpios = <&msmgpio 26 GPIO_ACTIVE_HIGH>; };--
Regards,Laurent Pinchart
Signature · 1 line
Ricardo Ribalda
Re: [PATCH 3/4] [media] ad5820: DT new optional field enable-gpios
Quoted 40 lines · Ricardo Ribalda Delgado
Hi
Quoted 33 lines · Laurent Pinchart
Quoted 31 lines · On Thursday, 20 September 2018 23:21:28 EEST Laurent Pinchart wrote:
Hi Ricardo,
Thank you for the patch.
Quoted 17 lines · On Thursday, 20 September 2018 19:19:11 EEST Ricardo Ribalda Delgado wrote:
Document new enable-gpio field. It can be used to disable the part without turning down its regulator.
Signed-off-by Ricardo Ribalda Delgado <[email protected]>---
Documentation/devicetree/bindings/media/i2c/ad5820.txt | 6 ++++++ 1 file changed, 6 insertions(+)(quoted diff) +0
-0
b/Documentation/devicetree/bindings/media/i2c/ad5820.txtindex5940ca11c021..07d577bb37f7100644Documentation/devicetree/bindings/media/i2c/ad5820.txt Required Properties: · line 12
Quoted 5 lines
Documentation/devicetree/bindings/media/i2c/ad5820.txt +3
-0@@ -8,6 +8,11 @@ Required Properties: - VANA-supply: supply of voltage for VANA pin +Optional properties: + + - enable-gpios : GPIO spec for the XSHUTDOWN pin.xshutdown is active-low, so enable is active-high. Should this be documented explicitly, to avoid polarity errors ? Maybe something along the lines of
Quoted 3 lines
Quoted 3 lines
- enable-gpios: GPIO spec for the XSHUTDOWN pin. Note that the polarity of the enable GPIO is the opposite of the XSHUTDOWN pin (asserting the enable GPIO deasserts the XSHUTDOWN signal and vice versa).
Quoted 8 lines
Agreed
Quoted 3 lines
Or alternatively you could name the property xshutdown-gpios, as explained in my (incorrect) review of 2/4.
I have double negatives :). If there is no other option I will rename it xshutdown, but I want to give it a try to enable.
I think enable is fine.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCH v2 2/4] [media] ad5820: Add support for enable pin
In reply to Pavel MachekHi
Quoted 22 lines · Pavel Machek
Hi!
Quoted 19 lines
Quoted 18 lines
Quoted 4 lines
Quoted 4 lines
ad5820: dac@0c { compatible = "adi,ad5820"; reg = <0x0c>;Quoted 8 lines
Quoted 3 lines
VANA-supply = <&pm8994_l23>; enable-gpios = <&msmgpio 26 GPIO_ACTIVE_HIGH>; };Well, I'm sure you could have gpio-based regulator powered from
pm8994_l23, and outputting to ad5820.Does ad5820 chip have a gpio input for enable?
xshutdown pin:
http://www.analog.com/media/en/technical-documentation/data-sheets/AD5821.pdf(AD5820,AD5821, and AD5823 are compatibles, or at least that is waht the module manufacturer says :)
Quoted 8 lines
Quoted 3 lines
Aha, sorry for the noise.
2,3: Acked-by: Pavel Machek <[email protected]>
And I forgot to mention. If ad5821 and ad5823 are compatible, it would be good to mention it somewhere where it is easy to find... That can save quite a bit of work to someone.
For the ad5821 I have the datasheet and I would not mind adding it For the ad5823 I have no datasheet, just a schematic from a camera module saying: you can replace ad5823 with ad5821.
I think I will add this as an extra patch
Quoted 7 lines
Thanks,
Pavel--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Signature · 1 line
Ricardo Ribalda