* [PATCH v3 0/4] media: i2c: IMX355 for the Pixel 3a
@ 2025-09-05 21:55 Richard Acayan
2025-09-05 21:55 ` [PATCH v3 1/4] dt-bindings: media: i2c: Add Sony IMX355 Richard Acayan
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Richard Acayan @ 2025-09-05 21:55 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Bjorn Andersson, Konrad Dybcio, Sakari Ailus,
Tianshu Qiu, linux-media, devicetree, linux-arm-msm
Cc: Robert Mader, Richard Acayan
This adds support for the IMX355 in devicetree and adds support for the
Pixel 3a front camera.
Changes since v2 (https://lore.kernel.org/r/20250714210227.714841-6-mailingradian@gmail.com):
- use devm_v4l2_sensor_clk_get (2/4)
- require supplies and clock-names (1/4)
- move unevaluatedProperties down (1/4)
- disable clocks as last power-off action (2/4)
- use 0 in gpio pin power-supply (4/4)
Changes since v1 (https://lore.kernel.org/r/20250630225944.320755-7-mailingradian@gmail.com):
- too much to have a complete list (1-4/4)
- squash camera orientation patch (4/4, previously 5/5)
- squash driver changes (2/4, previously 3/5)
- remove labelled endpoint node in sdm670.dtsi (3/4, 4/4)
- change init sequence to match other similar drivers (2/4)
- retrieve clock frequency from devicetree-defined clock (4/4)
- remove clock-frequency from dt-bindings (1/4)
- remove redundant descriptions of child nodes (1/4)
- switch initial drive of the reset GPIO to low (2/4)
- set mclk frequency to 19.2 MHz (4/4)
- add vdda-pll supply for camss (4/4)
- use common power on and off functions (2/4)
- use devm_clk_get_optional (2/4)
- remove extra layer when describing mclk pin (4/4)
- rename regulators (1/4, 2/4, 4/4)
Richard Acayan (4):
dt-bindings: media: i2c: Add Sony IMX355
media: i2c: imx355: Support devicetree and power management
arm64: dts: qcom: sdm670: remove camss endpoint nodes
arm64: dts: qcom: sdm670-google-sargo: add imx355 front camera
.../bindings/media/i2c/sony,imx355.yaml | 112 +++++++++++++++
.../boot/dts/qcom/sdm670-google-sargo.dts | 116 +++++++++++++++
arch/arm64/boot/dts/qcom/sdm670.dtsi | 12 --
drivers/media/i2c/imx355.c | 135 ++++++++++++++++--
4 files changed, 350 insertions(+), 25 deletions(-)
create mode 100644 Documentation/devicetree/bindings/media/i2c/sony,imx355.yaml
--
2.51.0
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH v3 1/4] dt-bindings: media: i2c: Add Sony IMX355 2025-09-05 21:55 [PATCH v3 0/4] media: i2c: IMX355 for the Pixel 3a Richard Acayan @ 2025-09-05 21:55 ` Richard Acayan 2025-09-05 22:08 ` Sakari Ailus 2025-09-05 21:55 ` [PATCH v3 2/4] media: i2c: imx355: Support devicetree and power management Richard Acayan ` (2 subsequent siblings) 3 siblings, 1 reply; 10+ messages in thread From: Richard Acayan @ 2025-09-05 21:55 UTC (permalink / raw) To: Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Konrad Dybcio, Sakari Ailus, Tianshu Qiu, linux-media, devicetree, linux-arm-msm Cc: Robert Mader, Richard Acayan The IMX355 camera sensor is a camera sensor that can be found as the front camera in some smartphones, such as the Pixel 3, Pixel 3 XL, Pixel 3a, and Pixel 3a XL. It already has a driver, but needs support for device tree. Document the IMX355 to support defining it in device tree. Signed-off-by: Richard Acayan <mailingradian@gmail.com> --- .../bindings/media/i2c/sony,imx355.yaml | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/i2c/sony,imx355.yaml diff --git a/Documentation/devicetree/bindings/media/i2c/sony,imx355.yaml b/Documentation/devicetree/bindings/media/i2c/sony,imx355.yaml new file mode 100644 index 000000000000..d4ba918807a6 --- /dev/null +++ b/Documentation/devicetree/bindings/media/i2c/sony,imx355.yaml @@ -0,0 +1,112 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) + +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/i2c/sony,imx355.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Sony IMX355 Sensor + +maintainers: + - Richard Acayan <mailingradian@gmail.com> + +description: + The IMX355 sensor is a 3280x2464 image sensor, commonly found as the front + camera in smartphones. + +allOf: + - $ref: /schemas/media/video-interface-devices.yaml# + +properties: + compatible: + const: sony,imx355 + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + clock-names: + items: + - const: mclk + + avdd-supply: + description: Analog power supply. + + dvdd-supply: + description: Digital power supply. + + dovdd-supply: + description: Interface power supply. + + reset-gpios: + maxItems: 1 + + port: + $ref: /schemas/graph.yaml#/$defs/port-base + additionalProperties: false + + properties: + endpoint: + $ref: /schemas/media/video-interfaces.yaml + unevaluatedProperties: false + + required: + - link-frequencies + + required: + - endpoint + +required: + - compatible + - reg + - clocks + - clock-names + - avdd-supply + - dvdd-supply + - dovdd-supply + - port + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/clock/qcom,camcc-sdm845.h> + #include <dt-bindings/gpio/gpio.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + camera@1a { + compatible = "sony,imx355"; + reg = <0x1a>; + + clocks = <&camcc CAM_CC_MCLK2_CLK>; + clock-names = "mclk"; + + assigned-clocks = <&camcc CAM_CC_MCLK2_CLK>; + assigned-clock-rates = <24000000>; + + reset-gpios = <&tlmm 9 GPIO_ACTIVE_HIGH>; + + avdd-supply = <&cam_front_ldo>; + dvdd-supply = <&cam_front_ldo>; + dovdd-supply = <&cam_vio_ldo>; + + pinctrl-names = "default"; + pinctrl-0 = <&cam_front_default>; + + rotation = <270>; + orientation = <0>; + + port { + cam_front_endpoint: endpoint { + data-lanes = <0 1 2 3>; + link-frequencies = /bits/ 64 <360000000>; + remote-endpoint = <&camss_endpoint1>; + }; + }; + }; + }; -- 2.51.0 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v3 1/4] dt-bindings: media: i2c: Add Sony IMX355 2025-09-05 21:55 ` [PATCH v3 1/4] dt-bindings: media: i2c: Add Sony IMX355 Richard Acayan @ 2025-09-05 22:08 ` Sakari Ailus 0 siblings, 0 replies; 10+ messages in thread From: Sakari Ailus @ 2025-09-05 22:08 UTC (permalink / raw) To: Richard Acayan Cc: Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Konrad Dybcio, Tianshu Qiu, linux-media, devicetree, linux-arm-msm, Robert Mader Hi Richard, On Fri, Sep 05, 2025 at 05:55:18PM -0400, Richard Acayan wrote: > The IMX355 camera sensor is a camera sensor that can be found as the > front camera in some smartphones, such as the Pixel 3, Pixel 3 XL, Pixel > 3a, and Pixel 3a XL. It already has a driver, but needs support for > device tree. Document the IMX355 to support defining it in device tree. How many data lanes are there? Don't you need to specify that as well? > > Signed-off-by: Richard Acayan <mailingradian@gmail.com> > --- > .../bindings/media/i2c/sony,imx355.yaml | 112 ++++++++++++++++++ > 1 file changed, 112 insertions(+) > create mode 100644 Documentation/devicetree/bindings/media/i2c/sony,imx355.yaml > > diff --git a/Documentation/devicetree/bindings/media/i2c/sony,imx355.yaml b/Documentation/devicetree/bindings/media/i2c/sony,imx355.yaml > new file mode 100644 > index 000000000000..d4ba918807a6 > --- /dev/null > +++ b/Documentation/devicetree/bindings/media/i2c/sony,imx355.yaml > @@ -0,0 +1,112 @@ > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > + > +%YAML 1.2 > +--- > +$id: http://devicetree.org/schemas/media/i2c/sony,imx355.yaml# > +$schema: http://devicetree.org/meta-schemas/core.yaml# > + > +title: Sony IMX355 Sensor > + > +maintainers: > + - Richard Acayan <mailingradian@gmail.com> > + > +description: > + The IMX355 sensor is a 3280x2464 image sensor, commonly found as the front > + camera in smartphones. > + > +allOf: > + - $ref: /schemas/media/video-interface-devices.yaml# > + > +properties: > + compatible: > + const: sony,imx355 > + > + reg: > + maxItems: 1 > + > + clocks: > + maxItems: 1 > + > + clock-names: > + items: > + - const: mclk You can omit this as there's just a single clock. > + > + avdd-supply: > + description: Analog power supply. > + > + dvdd-supply: > + description: Digital power supply. > + > + dovdd-supply: > + description: Interface power supply. > + > + reset-gpios: > + maxItems: 1 > + > + port: > + $ref: /schemas/graph.yaml#/$defs/port-base > + additionalProperties: false > + > + properties: > + endpoint: > + $ref: /schemas/media/video-interfaces.yaml > + unevaluatedProperties: false How many data lanes are there? Don't you need to specify that as well? > + > + required: > + - link-frequencies > + > + required: > + - endpoint > + > +required: > + - compatible > + - reg > + - clocks > + - clock-names > + - avdd-supply > + - dvdd-supply > + - dovdd-supply > + - port > + > +unevaluatedProperties: false > + > +examples: > + - | > + #include <dt-bindings/clock/qcom,camcc-sdm845.h> > + #include <dt-bindings/gpio/gpio.h> > + > + i2c { > + #address-cells = <1>; > + #size-cells = <0>; > + > + camera@1a { > + compatible = "sony,imx355"; > + reg = <0x1a>; > + > + clocks = <&camcc CAM_CC_MCLK2_CLK>; > + clock-names = "mclk"; > + > + assigned-clocks = <&camcc CAM_CC_MCLK2_CLK>; > + assigned-clock-rates = <24000000>; > + > + reset-gpios = <&tlmm 9 GPIO_ACTIVE_HIGH>; > + > + avdd-supply = <&cam_front_ldo>; > + dvdd-supply = <&cam_front_ldo>; > + dovdd-supply = <&cam_vio_ldo>; > + > + pinctrl-names = "default"; > + pinctrl-0 = <&cam_front_default>; > + > + rotation = <270>; > + orientation = <0>; > + > + port { > + cam_front_endpoint: endpoint { > + data-lanes = <0 1 2 3>; > + link-frequencies = /bits/ 64 <360000000>; > + remote-endpoint = <&camss_endpoint1>; > + }; > + }; > + }; > + }; -- Kind regards, Sakari Ailus ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v3 2/4] media: i2c: imx355: Support devicetree and power management 2025-09-05 21:55 [PATCH v3 0/4] media: i2c: IMX355 for the Pixel 3a Richard Acayan 2025-09-05 21:55 ` [PATCH v3 1/4] dt-bindings: media: i2c: Add Sony IMX355 Richard Acayan @ 2025-09-05 21:55 ` Richard Acayan 2025-09-05 22:16 ` Sakari Ailus 2025-09-05 21:55 ` [PATCH v3 3/4] arm64: dts: qcom: sdm670: remove camss endpoint nodes Richard Acayan 2025-09-05 21:55 ` [PATCH v3 4/4] arm64: dts: qcom: sdm670-google-sargo: add imx355 front camera Richard Acayan 3 siblings, 1 reply; 10+ messages in thread From: Richard Acayan @ 2025-09-05 21:55 UTC (permalink / raw) To: Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Konrad Dybcio, Sakari Ailus, Tianshu Qiu, linux-media, devicetree, linux-arm-msm Cc: Robert Mader, Richard Acayan A device tree compatible makes it possible for this driver to be used on Open Firmware devices. Initialization of power-managed resources such as the reset GPIO and voltage regulators can be specified in the device tree and handled by the driver. Add support for this so the Pixel 3a can use the driver. Signed-off-by: Richard Acayan <mailingradian@gmail.com> --- drivers/media/i2c/imx355.c | 135 +++++++++++++++++++++++++++++++++---- 1 file changed, 122 insertions(+), 13 deletions(-) diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c index b2dce67c0b6b..f7c51e50113e 100644 --- a/drivers/media/i2c/imx355.c +++ b/drivers/media/i2c/imx355.c @@ -3,9 +3,14 @@ #include <linux/unaligned.h> #include <linux/acpi.h> +#include <linux/clk.h> +#include <linux/delay.h> +#include <linux/gpio/consumer.h> #include <linux/i2c.h> #include <linux/module.h> +#include <linux/of.h> #include <linux/pm_runtime.h> +#include <linux/regulator/consumer.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-device.h> #include <media/v4l2-event.h> @@ -121,6 +126,16 @@ struct imx355 { * Protect access to sensor v4l2 controls. */ struct mutex mutex; + + struct clk *mclk; + struct gpio_desc *reset_gpio; + struct regulator_bulk_data supplies[3]; +}; + +static const char * const imx355_supply_names[] = { + "avdd", + "dvdd", + "dovdd", }; static const struct imx355_reg imx355_global_regs[] = { @@ -1516,6 +1531,57 @@ static const struct v4l2_subdev_internal_ops imx355_internal_ops = { .open = imx355_open, }; +static int imx355_power_off(struct device *dev) +{ + struct i2c_client *client = container_of(dev, struct i2c_client, dev); + struct v4l2_subdev *sd = i2c_get_clientdata(client); + struct imx355 *imx355 = to_imx355(sd); + + if (imx355->reset_gpio) + gpiod_set_value_cansleep(imx355->reset_gpio, 0); + + regulator_bulk_disable(ARRAY_SIZE(imx355->supplies), imx355->supplies); + clk_disable_unprepare(imx355->mclk); + + return 0; +} + +static int imx355_power_on(struct device *dev) +{ + struct i2c_client *client = container_of(dev, struct i2c_client, dev); + struct v4l2_subdev *sd = i2c_get_clientdata(client); + struct imx355 *imx355 = to_imx355(sd); + int ret; + + ret = clk_prepare_enable(imx355->mclk); + if (ret) { + dev_err(dev, "failed to enable clocks: %d\n", ret); + return ret; + } + + ret = regulator_bulk_enable(ARRAY_SIZE(imx355->supplies), + imx355->supplies); + if (ret) { + dev_err(dev, "failed to enable regulators: %d\n", ret); + goto error_disable_clocks; + } + + if (imx355->reset_gpio) { + usleep_range(5000, 5100); + gpiod_set_value_cansleep(imx355->reset_gpio, 1); + usleep_range(8000, 8100); + } + + return 0; + +error_disable_clocks: + clk_disable_unprepare(imx355->mclk); + return ret; +} + +static DEFINE_RUNTIME_DEV_PM_OPS(imx355_pm_ops, imx355_power_off, + imx355_power_on, NULL); + /* Initialize control handlers */ static int imx355_init_controls(struct imx355 *imx355) { @@ -1623,7 +1689,7 @@ static int imx355_init_controls(struct imx355 *imx355) return ret; } -static struct imx355_hwcfg *imx355_get_hwcfg(struct device *dev) +static struct imx355_hwcfg *imx355_get_hwcfg(struct device *dev, struct imx355 *imx355) { struct imx355_hwcfg *cfg; struct v4l2_fwnode_endpoint bus_cfg = { @@ -1648,12 +1714,7 @@ static struct imx355_hwcfg *imx355_get_hwcfg(struct device *dev) if (!cfg) goto out_err; - ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency", - &cfg->ext_clk); - if (ret) { - dev_err(dev, "can't get clock frequency"); - goto out_err; - } + cfg->ext_clk = clk_get_rate(imx355->mclk); dev_dbg(dev, "ext clk: %d", cfg->ext_clk); if (cfg->ext_clk != IMX355_EXT_CLK) { @@ -1683,6 +1744,7 @@ static struct imx355_hwcfg *imx355_get_hwcfg(struct device *dev) static int imx355_probe(struct i2c_client *client) { struct imx355 *imx355; + size_t i; int ret; imx355 = devm_kzalloc(&client->dev, sizeof(*imx355), GFP_KERNEL); @@ -1694,27 +1756,59 @@ static int imx355_probe(struct i2c_client *client) /* Initialize subdev */ v4l2_i2c_subdev_init(&imx355->sd, client, &imx355_subdev_ops); - /* Check module identity */ - ret = imx355_identify_module(imx355); + for (i = 0; i < ARRAY_SIZE(imx355_supply_names); i++) + imx355->supplies[i].supply = imx355_supply_names[i]; + + ret = devm_regulator_bulk_get(&client->dev, + ARRAY_SIZE(imx355->supplies), + imx355->supplies); if (ret) { - dev_err(&client->dev, "failed to find sensor: %d", ret); + dev_err_probe(&client->dev, ret, "could not get regulators"); + goto error_probe; + } + + imx355->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset", + GPIOD_OUT_LOW); + if (IS_ERR(imx355->reset_gpio)) { + ret = dev_err_probe(&client->dev, PTR_ERR(imx355->reset_gpio), + "failed to get gpios"); + goto error_probe; + } + + imx355->mclk = devm_v4l2_sensor_clk_get(&client->dev, "mclk"); + if (IS_ERR(imx355->mclk)) { + ret = dev_err_probe(&client->dev, PTR_ERR(imx355->mclk), + "failed to get mclk"); goto error_probe; } - imx355->hwcfg = imx355_get_hwcfg(&client->dev); + imx355->hwcfg = imx355_get_hwcfg(&client->dev, imx355); if (!imx355->hwcfg) { dev_err(&client->dev, "failed to get hwcfg"); ret = -ENODEV; goto error_probe; } + ret = imx355_power_on(&client->dev); + if (ret) { + dev_err(&client->dev, "failed to power on sensor: %d", ret); + goto error_probe; + } + + /* Check module identity */ + ret = imx355_identify_module(imx355); + if (ret) { + dev_err(&client->dev, "failed to find sensor: %d", ret); + goto error_power_off; + } + /* Set default mode to max resolution */ imx355->cur_mode = &supported_modes[0]; ret = imx355_init_controls(imx355); if (ret) { dev_err(&client->dev, "failed to init controls: %d", ret); - goto error_probe; + goto error_power_off; } /* Initialize subdev */ @@ -1754,6 +1848,9 @@ static int imx355_probe(struct i2c_client *client) error_handler_free: v4l2_ctrl_handler_free(imx355->sd.ctrl_handler); +error_power_off: + imx355_power_off(&client->dev); + error_probe: mutex_destroy(&imx355->mutex); @@ -1770,7 +1867,11 @@ static void imx355_remove(struct i2c_client *client) v4l2_ctrl_handler_free(sd->ctrl_handler); pm_runtime_disable(&client->dev); - pm_runtime_set_suspended(&client->dev); + + if (!pm_runtime_status_suspended(&client->dev)) { + imx355_power_off(&client->dev); + pm_runtime_set_suspended(&client->dev); + } mutex_destroy(&imx355->mutex); } @@ -1781,10 +1882,18 @@ static const struct acpi_device_id imx355_acpi_ids[] __maybe_unused = { }; MODULE_DEVICE_TABLE(acpi, imx355_acpi_ids); +static const struct of_device_id imx355_match_table[] __maybe_unused = { + { .compatible = "sony,imx355", }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, imx355_match_table); + static struct i2c_driver imx355_i2c_driver = { .driver = { .name = "imx355", .acpi_match_table = ACPI_PTR(imx355_acpi_ids), + .of_match_table = of_match_ptr(imx355_match_table), + .pm = &imx355_pm_ops, }, .probe = imx355_probe, .remove = imx355_remove, -- 2.51.0 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v3 2/4] media: i2c: imx355: Support devicetree and power management 2025-09-05 21:55 ` [PATCH v3 2/4] media: i2c: imx355: Support devicetree and power management Richard Acayan @ 2025-09-05 22:16 ` Sakari Ailus 0 siblings, 0 replies; 10+ messages in thread From: Sakari Ailus @ 2025-09-05 22:16 UTC (permalink / raw) To: Richard Acayan Cc: Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Konrad Dybcio, Tianshu Qiu, linux-media, devicetree, linux-arm-msm, Robert Mader Hi Richard, On Fri, Sep 05, 2025 at 05:55:19PM -0400, Richard Acayan wrote: > A device tree compatible makes it possible for this driver to be used on > Open Firmware devices. Initialization of power-managed resources such as > the reset GPIO and voltage regulators can be specified in the device > tree and handled by the driver. Add support for this so the Pixel 3a can > use the driver. > > Signed-off-by: Richard Acayan <mailingradian@gmail.com> > --- > drivers/media/i2c/imx355.c | 135 +++++++++++++++++++++++++++++++++---- > 1 file changed, 122 insertions(+), 13 deletions(-) > > diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c > index b2dce67c0b6b..f7c51e50113e 100644 > --- a/drivers/media/i2c/imx355.c > +++ b/drivers/media/i2c/imx355.c > @@ -3,9 +3,14 @@ > > #include <linux/unaligned.h> > #include <linux/acpi.h> > +#include <linux/clk.h> > +#include <linux/delay.h> > +#include <linux/gpio/consumer.h> > #include <linux/i2c.h> > #include <linux/module.h> > +#include <linux/of.h> > #include <linux/pm_runtime.h> > +#include <linux/regulator/consumer.h> > #include <media/v4l2-ctrls.h> > #include <media/v4l2-device.h> > #include <media/v4l2-event.h> > @@ -121,6 +126,16 @@ struct imx355 { > * Protect access to sensor v4l2 controls. > */ > struct mutex mutex; > + > + struct clk *mclk; > + struct gpio_desc *reset_gpio; > + struct regulator_bulk_data supplies[3]; > +}; > + > +static const char * const imx355_supply_names[] = { > + "avdd", > + "dvdd", > + "dovdd", > }; > > static const struct imx355_reg imx355_global_regs[] = { > @@ -1516,6 +1531,57 @@ static const struct v4l2_subdev_internal_ops imx355_internal_ops = { > .open = imx355_open, > }; > > +static int imx355_power_off(struct device *dev) > +{ > + struct i2c_client *client = container_of(dev, struct i2c_client, dev); > + struct v4l2_subdev *sd = i2c_get_clientdata(client); > + struct imx355 *imx355 = to_imx355(sd); > + > + if (imx355->reset_gpio) > + gpiod_set_value_cansleep(imx355->reset_gpio, 0); The gpiod framework can work with NULL descriptor so I don't think you need to check for non-NULL before the calls. Same elsewhere. > + > + regulator_bulk_disable(ARRAY_SIZE(imx355->supplies), imx355->supplies); > + clk_disable_unprepare(imx355->mclk); > + > + return 0; > +} > + > +static int imx355_power_on(struct device *dev) > +{ > + struct i2c_client *client = container_of(dev, struct i2c_client, dev); > + struct v4l2_subdev *sd = i2c_get_clientdata(client); > + struct imx355 *imx355 = to_imx355(sd); > + int ret; > + > + ret = clk_prepare_enable(imx355->mclk); > + if (ret) { > + dev_err(dev, "failed to enable clocks: %d\n", ret); > + return ret; > + } > + > + ret = regulator_bulk_enable(ARRAY_SIZE(imx355->supplies), > + imx355->supplies); > + if (ret) { > + dev_err(dev, "failed to enable regulators: %d\n", ret); > + goto error_disable_clocks; > + } > + > + if (imx355->reset_gpio) { > + usleep_range(5000, 5100); > + gpiod_set_value_cansleep(imx355->reset_gpio, 1); > + usleep_range(8000, 8100); > + } > + > + return 0; > + > +error_disable_clocks: > + clk_disable_unprepare(imx355->mclk); > + return ret; > +} > + > +static DEFINE_RUNTIME_DEV_PM_OPS(imx355_pm_ops, imx355_power_off, > + imx355_power_on, NULL); > + > /* Initialize control handlers */ > static int imx355_init_controls(struct imx355 *imx355) > { > @@ -1623,7 +1689,7 @@ static int imx355_init_controls(struct imx355 *imx355) > return ret; > } > > -static struct imx355_hwcfg *imx355_get_hwcfg(struct device *dev) > +static struct imx355_hwcfg *imx355_get_hwcfg(struct device *dev, struct imx355 *imx355) > { > struct imx355_hwcfg *cfg; > struct v4l2_fwnode_endpoint bus_cfg = { > @@ -1648,12 +1714,7 @@ static struct imx355_hwcfg *imx355_get_hwcfg(struct device *dev) > if (!cfg) > goto out_err; > > - ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency", > - &cfg->ext_clk); > - if (ret) { > - dev_err(dev, "can't get clock frequency"); > - goto out_err; > - } > + cfg->ext_clk = clk_get_rate(imx355->mclk); > > dev_dbg(dev, "ext clk: %d", cfg->ext_clk); > if (cfg->ext_clk != IMX355_EXT_CLK) { > @@ -1683,6 +1744,7 @@ static struct imx355_hwcfg *imx355_get_hwcfg(struct device *dev) > static int imx355_probe(struct i2c_client *client) > { > struct imx355 *imx355; > + size_t i; > int ret; > > imx355 = devm_kzalloc(&client->dev, sizeof(*imx355), GFP_KERNEL); > @@ -1694,27 +1756,59 @@ static int imx355_probe(struct i2c_client *client) > /* Initialize subdev */ > v4l2_i2c_subdev_init(&imx355->sd, client, &imx355_subdev_ops); > > - /* Check module identity */ > - ret = imx355_identify_module(imx355); > + for (i = 0; i < ARRAY_SIZE(imx355_supply_names); i++) > + imx355->supplies[i].supply = imx355_supply_names[i]; > + > + ret = devm_regulator_bulk_get(&client->dev, > + ARRAY_SIZE(imx355->supplies), > + imx355->supplies); > if (ret) { > - dev_err(&client->dev, "failed to find sensor: %d", ret); > + dev_err_probe(&client->dev, ret, "could not get regulators"); > + goto error_probe; > + } > + > + imx355->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset", > + GPIOD_OUT_LOW); > + if (IS_ERR(imx355->reset_gpio)) { > + ret = dev_err_probe(&client->dev, PTR_ERR(imx355->reset_gpio), > + "failed to get gpios"); > + goto error_probe; > + } > + > + imx355->mclk = devm_v4l2_sensor_clk_get(&client->dev, "mclk"); > + if (IS_ERR(imx355->mclk)) { > + ret = dev_err_probe(&client->dev, PTR_ERR(imx355->mclk), > + "failed to get mclk"); > goto error_probe; > } > > - imx355->hwcfg = imx355_get_hwcfg(&client->dev); > + imx355->hwcfg = imx355_get_hwcfg(&client->dev, imx355); > if (!imx355->hwcfg) { > dev_err(&client->dev, "failed to get hwcfg"); > ret = -ENODEV; > goto error_probe; > } > > + ret = imx355_power_on(&client->dev); > + if (ret) { > + dev_err(&client->dev, "failed to power on sensor: %d", ret); > + goto error_probe; > + } > + > + /* Check module identity */ > + ret = imx355_identify_module(imx355); > + if (ret) { > + dev_err(&client->dev, "failed to find sensor: %d", ret); > + goto error_power_off; > + } > + > /* Set default mode to max resolution */ > imx355->cur_mode = &supported_modes[0]; > > ret = imx355_init_controls(imx355); > if (ret) { > dev_err(&client->dev, "failed to init controls: %d", ret); > - goto error_probe; > + goto error_power_off; > } > > /* Initialize subdev */ > @@ -1754,6 +1848,9 @@ static int imx355_probe(struct i2c_client *client) > error_handler_free: > v4l2_ctrl_handler_free(imx355->sd.ctrl_handler); > > +error_power_off: > + imx355_power_off(&client->dev); > + > error_probe: > mutex_destroy(&imx355->mutex); > > @@ -1770,7 +1867,11 @@ static void imx355_remove(struct i2c_client *client) > v4l2_ctrl_handler_free(sd->ctrl_handler); > > pm_runtime_disable(&client->dev); > - pm_runtime_set_suspended(&client->dev); > + > + if (!pm_runtime_status_suspended(&client->dev)) { > + imx355_power_off(&client->dev); > + pm_runtime_set_suspended(&client->dev); > + } > > mutex_destroy(&imx355->mutex); > } > @@ -1781,10 +1882,18 @@ static const struct acpi_device_id imx355_acpi_ids[] __maybe_unused = { > }; > MODULE_DEVICE_TABLE(acpi, imx355_acpi_ids); > > +static const struct of_device_id imx355_match_table[] __maybe_unused = { > + { .compatible = "sony,imx355", }, > + { /* sentinel */ } > +}; > +MODULE_DEVICE_TABLE(of, imx355_match_table); > + > static struct i2c_driver imx355_i2c_driver = { > .driver = { > .name = "imx355", > .acpi_match_table = ACPI_PTR(imx355_acpi_ids), > + .of_match_table = of_match_ptr(imx355_match_table), Please don't use of_match_ptr() on drivers that can also be used on ACPI -- it renders the pointer NULL if OF is disabled. > + .pm = &imx355_pm_ops, > }, > .probe = imx355_probe, > .remove = imx355_remove, -- Kind regards, Sakari Ailus ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v3 3/4] arm64: dts: qcom: sdm670: remove camss endpoint nodes 2025-09-05 21:55 [PATCH v3 0/4] media: i2c: IMX355 for the Pixel 3a Richard Acayan 2025-09-05 21:55 ` [PATCH v3 1/4] dt-bindings: media: i2c: Add Sony IMX355 Richard Acayan 2025-09-05 21:55 ` [PATCH v3 2/4] media: i2c: imx355: Support devicetree and power management Richard Acayan @ 2025-09-05 21:55 ` Richard Acayan 2025-10-08 10:05 ` Konrad Dybcio 2025-09-05 21:55 ` [PATCH v3 4/4] arm64: dts: qcom: sdm670-google-sargo: add imx355 front camera Richard Acayan 3 siblings, 1 reply; 10+ messages in thread From: Richard Acayan @ 2025-09-05 21:55 UTC (permalink / raw) To: Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Konrad Dybcio, Sakari Ailus, Tianshu Qiu, linux-media, devicetree, linux-arm-msm Cc: Robert Mader, Richard Acayan There is no need to add these by default for all of SDM670. Originally, they were added so there could be a label for each port. This is unnecessary if the endpoints are all added in a fixup to the camss node. Suggested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Link: https://lore.kernel.org/r/488281f6-5e5d-4864-8220-63e2a0b2d7f2@linaro.org Signed-off-by: Richard Acayan <mailingradian@gmail.com> --- arch/arm64/boot/dts/qcom/sdm670.dtsi | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/arch/arm64/boot/dts/qcom/sdm670.dtsi b/arch/arm64/boot/dts/qcom/sdm670.dtsi index c33f3de779f6..c275089237e4 100644 --- a/arch/arm64/boot/dts/qcom/sdm670.dtsi +++ b/arch/arm64/boot/dts/qcom/sdm670.dtsi @@ -1768,26 +1768,14 @@ ports { port@0 { reg = <0>; - - camss_endpoint0: endpoint { - status = "disabled"; - }; }; port@1 { reg = <1>; - - camss_endpoint1: endpoint { - status = "disabled"; - }; }; port@2 { reg = <2>; - - camss_endpoint2: endpoint { - status = "disabled"; - }; }; }; }; -- 2.51.0 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v3 3/4] arm64: dts: qcom: sdm670: remove camss endpoint nodes 2025-09-05 21:55 ` [PATCH v3 3/4] arm64: dts: qcom: sdm670: remove camss endpoint nodes Richard Acayan @ 2025-10-08 10:05 ` Konrad Dybcio 2025-10-08 15:51 ` Dmitry Baryshkov 0 siblings, 1 reply; 10+ messages in thread From: Konrad Dybcio @ 2025-10-08 10:05 UTC (permalink / raw) To: Richard Acayan, Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Konrad Dybcio, Sakari Ailus, Tianshu Qiu, linux-media, devicetree, linux-arm-msm Cc: Robert Mader On 9/5/25 11:55 PM, Richard Acayan wrote: > There is no need to add these by default for all of SDM670. Originally, > they were added so there could be a label for each port. This is > unnecessary if the endpoints are all added in a fixup to the camss node. > > Suggested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> > Link: https://lore.kernel.org/r/488281f6-5e5d-4864-8220-63e2a0b2d7f2@linaro.org my comment on that discussion is "????????" referring to nodes by label is the least error-prone way Konrad ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 3/4] arm64: dts: qcom: sdm670: remove camss endpoint nodes 2025-10-08 10:05 ` Konrad Dybcio @ 2025-10-08 15:51 ` Dmitry Baryshkov 0 siblings, 0 replies; 10+ messages in thread From: Dmitry Baryshkov @ 2025-10-08 15:51 UTC (permalink / raw) To: Konrad Dybcio Cc: Richard Acayan, Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Konrad Dybcio, Sakari Ailus, Tianshu Qiu, linux-media, devicetree, linux-arm-msm, Robert Mader On Wed, Oct 08, 2025 at 12:05:55PM +0200, Konrad Dybcio wrote: > On 9/5/25 11:55 PM, Richard Acayan wrote: > > There is no need to add these by default for all of SDM670. Originally, > > they were added so there could be a label for each port. This is > > unnecessary if the endpoints are all added in a fixup to the camss node. > > > > Suggested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> > > Link: https://lore.kernel.org/r/488281f6-5e5d-4864-8220-63e2a0b2d7f2@linaro.org > > my comment on that discussion is "????????" > > referring to nodes by label is the least error-prone way +1. I'd suggest keeping the empty endpoints, unless we have the actual usecase where are more than one endpoint under the port. -- With best wishes Dmitry ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v3 4/4] arm64: dts: qcom: sdm670-google-sargo: add imx355 front camera 2025-09-05 21:55 [PATCH v3 0/4] media: i2c: IMX355 for the Pixel 3a Richard Acayan ` (2 preceding siblings ...) 2025-09-05 21:55 ` [PATCH v3 3/4] arm64: dts: qcom: sdm670: remove camss endpoint nodes Richard Acayan @ 2025-09-05 21:55 ` Richard Acayan 2025-10-08 10:08 ` Konrad Dybcio 3 siblings, 1 reply; 10+ messages in thread From: Richard Acayan @ 2025-09-05 21:55 UTC (permalink / raw) To: Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Konrad Dybcio, Sakari Ailus, Tianshu Qiu, linux-media, devicetree, linux-arm-msm Cc: Robert Mader, Richard Acayan The Sony IMX355 is the front camera on the Pixel 3a, mounted in portrait mode. It is connected to CSIPHY1 and CCI I2C1, and uses MCLK2. Add support for it. Co-developed-by: Robert Mader <robert.mader@collabora.com> Signed-off-by: Robert Mader <robert.mader@collabora.com> Signed-off-by: Richard Acayan <mailingradian@gmail.com> --- .../boot/dts/qcom/sdm670-google-sargo.dts | 116 ++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/sdm670-google-sargo.dts b/arch/arm64/boot/dts/qcom/sdm670-google-sargo.dts index d01422844fbf..5980f733479d 100644 --- a/arch/arm64/boot/dts/qcom/sdm670-google-sargo.dts +++ b/arch/arm64/boot/dts/qcom/sdm670-google-sargo.dts @@ -172,6 +172,34 @@ vreg_s2b_1p05: vreg-s2b-regulator { regulator-min-microvolt = <1050000>; regulator-max-microvolt = <1050000>; }; + + cam_front_ldo: cam-front-ldo-regulator { + compatible = "regulator-fixed"; + regulator-name = "cam_front_ldo"; + regulator-min-microvolt = <1352000>; + regulator-max-microvolt = <1352000>; + regulator-enable-ramp-delay = <135>; + + gpios = <&pm660l_gpios 4 GPIO_ACTIVE_HIGH>; + enable-active-high; + + pinctrl-0 = <&cam_front_ldo_pin>; + pinctrl-names = "default"; + }; + + cam_vio_ldo: cam-vio-ldo-regulator { + compatible = "regulator-fixed"; + regulator-name = "cam_vio_ldo"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-enable-ramp-delay = <233>; + + gpios = <&pm660_gpios 13 GPIO_ACTIVE_HIGH>; + enable-active-high; + + pinctrl-0 = <&cam_vio_pin>; + pinctrl-names = "default"; + }; }; &apps_rsc { @@ -392,6 +420,64 @@ vreg_bob: bob { }; }; +&camss { + vdda-phy-supply = <&vreg_l1a_1p225>; + vdda-pll-supply = <&vreg_s6a_0p87>; + + status = "okay"; + + ports { + port@1 { + camss_endpoint1: endpoint { + clock-lanes = <7>; + data-lanes = <0 1 2 3>; + remote-endpoint = <&cam_front_endpoint>; + }; + }; + }; +}; + +&cci { + pinctrl-0 = <&cci1_default &cam_mclk_default>; + pinctrl-1 = <&cci1_sleep>; + pinctrl-names = "default", "sleep"; + + status = "okay"; +}; + +&cci_i2c1 { + camera@1a { + compatible = "sony,imx355"; + reg = <0x1a>; + + clocks = <&camcc CAM_CC_MCLK2_CLK>; + clock-names = "mclk"; + + assigned-clocks = <&camcc CAM_CC_MCLK2_CLK>; + assigned-clock-rates = <19200000>; + + reset-gpios = <&tlmm 9 GPIO_ACTIVE_HIGH>; + + avdd-supply = <&cam_front_ldo>; + dvdd-supply = <&cam_front_ldo>; + dovdd-supply = <&cam_vio_ldo>; + + pinctrl-0 = <&cam_front_default>; + pinctrl-names = "default"; + + rotation = <270>; + orientation = <0>; + + port { + cam_front_endpoint: endpoint { + data-lanes = <0 1 2 3>; + link-frequencies = /bits/ 64 <360000000>; + remote-endpoint = <&camss_endpoint1>; + }; + }; + }; +}; + &gcc { protected-clocks = <GCC_QSPI_CORE_CLK>, <GCC_QSPI_CORE_CLK_SRC>, @@ -491,6 +577,15 @@ &pm660_charger { status = "okay"; }; +&pm660_gpios { + cam_vio_pin: cam-vio-state { + pins = "gpio13"; + function = "normal"; + power-source = <0>; + output-low; + }; +}; + &pm660_rradc { status = "okay"; }; @@ -509,6 +604,13 @@ led-0 { }; &pm660l_gpios { + cam_front_ldo_pin: cam-front-state { + pins = "gpio4"; + function = "normal"; + power-source = <0>; + output-low; + }; + vol_up_pin: vol-up-state { pins = "gpio7"; function = "normal"; @@ -548,6 +650,20 @@ &sdhc_1 { &tlmm { gpio-reserved-ranges = <0 4>, <81 4>; + cam_front_default: cam-front-default-state { + pins = "gpio9"; + function = "gpio"; + drive-strength = <2>; + bias-disable; + }; + + cam_mclk_default: cam-default-state { + pins = "gpio15"; + function = "cam_mclk"; + drive-strength = <2>; + bias-disable; + }; + panel_default: panel-default-state { te-pins { pins = "gpio10"; -- 2.51.0 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v3 4/4] arm64: dts: qcom: sdm670-google-sargo: add imx355 front camera 2025-09-05 21:55 ` [PATCH v3 4/4] arm64: dts: qcom: sdm670-google-sargo: add imx355 front camera Richard Acayan @ 2025-10-08 10:08 ` Konrad Dybcio 0 siblings, 0 replies; 10+ messages in thread From: Konrad Dybcio @ 2025-10-08 10:08 UTC (permalink / raw) To: Richard Acayan, Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Konrad Dybcio, Sakari Ailus, Tianshu Qiu, linux-media, devicetree, linux-arm-msm Cc: Robert Mader On 9/5/25 11:55 PM, Richard Acayan wrote: > The Sony IMX355 is the front camera on the Pixel 3a, mounted in portrait > mode. It is connected to CSIPHY1 and CCI I2C1, and uses MCLK2. Add > support for it. > > Co-developed-by: Robert Mader <robert.mader@collabora.com> > Signed-off-by: Robert Mader <robert.mader@collabora.com> > Signed-off-by: Richard Acayan <mailingradian@gmail.com> > --- [...] > + cam_front_ldo: cam-front-ldo-regulator { > + compatible = "regulator-fixed"; > + regulator-name = "cam_front_ldo"; > + regulator-min-microvolt = <1352000>; > + regulator-max-microvolt = <1352000>; > + regulator-enable-ramp-delay = <135>; > + > + gpios = <&pm660l_gpios 4 GPIO_ACTIVE_HIGH>; > + enable-active-high; > + > + pinctrl-0 = <&cam_front_ldo_pin>; > + pinctrl-names = "default"; > + }; > + > + cam_vio_ldo: cam-vio-ldo-regulator { > + compatible = "regulator-fixed"; > + regulator-name = "cam_vio_ldo"; > + regulator-min-microvolt = <1800000>; > + regulator-max-microvolt = <1800000>; > + regulator-enable-ramp-delay = <233>; > + > + gpios = <&pm660_gpios 13 GPIO_ACTIVE_HIGH>; > + enable-active-high; You say active-high for both regulators here.. > +&cci { > + pinctrl-0 = <&cci1_default &cam_mclk_default>; mclk belongs to the camera device [...] > +&pm660_gpios { > + cam_vio_pin: cam-vio-state { > + pins = "gpio13"; > + function = "normal"; > + power-source = <0>; > + output-low; > + }; > +}; > + > &pm660_rradc { > status = "okay"; > }; > @@ -509,6 +604,13 @@ led-0 { > }; > > &pm660l_gpios { > + cam_front_ldo_pin: cam-front-state { > + pins = "gpio4"; > + function = "normal"; > + power-source = <0>; > + output-low; > + }; ..and then you set these pins to output-low drop the output- properties as they shouldn't really be used anyway and please settle on which way is "on" > + > vol_up_pin: vol-up-state { > pins = "gpio7"; > function = "normal"; > @@ -548,6 +650,20 @@ &sdhc_1 { > &tlmm { > gpio-reserved-ranges = <0 4>, <81 4>; > > + cam_front_default: cam-front-default-state { > + pins = "gpio9"; > + function = "gpio"; > + drive-strength = <2>; > + bias-disable; > + }; > + > + cam_mclk_default: cam-default-state { > + pins = "gpio15"; > + function = "cam_mclk"; > + drive-strength = <2>; > + bias-disable; > + }; this mclk definition you can push to the SoC DTSI becuase it's as common as it gets for an internal function.. Konrad ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2025-10-08 15:51 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-09-05 21:55 [PATCH v3 0/4] media: i2c: IMX355 for the Pixel 3a Richard Acayan 2025-09-05 21:55 ` [PATCH v3 1/4] dt-bindings: media: i2c: Add Sony IMX355 Richard Acayan 2025-09-05 22:08 ` Sakari Ailus 2025-09-05 21:55 ` [PATCH v3 2/4] media: i2c: imx355: Support devicetree and power management Richard Acayan 2025-09-05 22:16 ` Sakari Ailus 2025-09-05 21:55 ` [PATCH v3 3/4] arm64: dts: qcom: sdm670: remove camss endpoint nodes Richard Acayan 2025-10-08 10:05 ` Konrad Dybcio 2025-10-08 15:51 ` Dmitry Baryshkov 2025-09-05 21:55 ` [PATCH v3 4/4] arm64: dts: qcom: sdm670-google-sargo: add imx355 front camera Richard Acayan 2025-10-08 10:08 ` Konrad Dybcio
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox