diff --git a/Documentation/devicetree/bindings/media/i2c/imx708.yaml b/Documentation/devicetree/bindings/media/i2c/imx708.yaml deleted file mode 100644 index 4b8645f6880c5f..00000000000000 --- a/Documentation/devicetree/bindings/media/i2c/imx708.yaml +++ /dev/null @@ -1,119 +0,0 @@ -# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) -%YAML 1.2 ---- -$id: http://devicetree.org/schemas/media/i2c/imx708.yaml# -$schema: http://devicetree.org/meta-schemas/core.yaml# - -title: Sony 1/2.3-Inch 12Mpixel CMOS Digital Image Sensor - -maintainers: - - Naushir Patuck - -description: |- - The Sony IMX708 is a 1/2.3-inch CMOS active pixel digital image sensor - with an active array size of 4608H x 2592V. It is programmable through - I2C interface. The I2C address is fixed to 0x1A as per sensor data sheet. - Image data is sent through MIPI CSI-2, which is configured as either 2 or - 4 data lanes. - -properties: - compatible: - const: sony,imx708 - - reg: - description: I2C device address - maxItems: 1 - - clocks: - maxItems: 1 - - VDIG-supply: - description: - Digital I/O voltage supply, 1.1 volts - - VANA1-supply: - description: - Analog1 voltage supply, 2.8 volts - - VANA2-supply: - description: - Analog2 voltage supply, 1.8 volts - - VDDL-supply: - description: - Digital core voltage supply, 1.8 volts - - reset-gpios: - description: |- - Reference to the GPIO connected to the xclr pin, if any. - Must be released (set high) after all supplies and INCK are applied. - - # See ../video-interfaces.txt for more details - port: - type: object - properties: - endpoint: - type: object - properties: - data-lanes: - description: |- - The sensor supports either two-lane, or four-lane operation. - For two-lane operation the property must be set to <1 2>. - items: - - const: 1 - - const: 2 - - clock-noncontinuous: - type: boolean - description: |- - MIPI CSI-2 clock is non-continuous if this property is present, - otherwise it's continuous. - - link-frequencies: - allOf: - - $ref: /schemas/types.yaml#/definitions/uint64-array - description: - Allowed data bus frequencies. - - required: - - link-frequencies - -required: - - compatible - - reg - - clocks - - VANA1-supply - - VANA2-supply - - VDIG-supply - - VDDL-supply - - port - -additionalProperties: false - -examples: - - | - i2c0 { - #address-cells = <1>; - #size-cells = <0>; - - imx708: sensor@1a { - compatible = "sony,imx708"; - reg = <0x1a>; - clocks = <&imx708_clk>; - VANA1-supply = <&imx708_vana1>; /* 1.8v */ - VANA2-supply = <&imx708_vana2>; /* 2.8v */ - VDIG-supply = <&imx708_vdig>; /* 1.1v */ - VDDL-supply = <&imx708_vddl>; /* 1.8v */ - - port { - imx708_0: endpoint { - remote-endpoint = <&csi1_ep>; - data-lanes = <1 2>; - clock-noncontinuous; - link-frequencies = /bits/ 64 <450000000>; - }; - }; - }; - }; - -... diff --git a/Documentation/devicetree/bindings/media/i2c/sony,imx708.yaml b/Documentation/devicetree/bindings/media/i2c/sony,imx708.yaml new file mode 100644 index 00000000000000..286aad2e8c697c --- /dev/null +++ b/Documentation/devicetree/bindings/media/i2c/sony,imx708.yaml @@ -0,0 +1,128 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/i2c/sony,imx708.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Sony 1/2.3-Inch 12Mpixel CMOS Digital Image Sensor + +maintainers: + - Raspberry Pi Kernel Maintenance + +description: |- + The Sony IMX708 is a 1/2.3-inch CMOS active pixel digital image sensor + with an active array size of 4608H x 2592V. It is programmable through + I2C interface. The I2C address is fixed to 0x1A as per sensor data sheet. + Image data is sent through MIPI CSI-2, which is configured as either 2 or + 4 data lanes. + +properties: + compatible: + const: sony,imx708 + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + clock-names: + description: Input clock (6 to 27 MHz) + items: + - const: inck + + vdig-supply: + description: + Digital I/O voltage supply, 1.1 volts + + vana1-supply: + description: + Analog1 voltage supply, 2.8 volts + + vana2-supply: + description: + Analog2 voltage supply, 1.8 volts + + vddl-supply: + description: + Digital core voltage supply, 1.8 volts + + reset-gpios: + description: Sensor reset (XCLR) GPIO + maxItems: 1 + + port: + $ref: /schemas/graph.yaml#/$defs/port-base + description: | + Video output port + + properties: + endpoint: + $ref: /schemas/media/video-interfaces.yaml# + unevaluatedProperties: false + + properties: + data-lanes: + anyOf: + - items: + - const: 1 + - const: 2 + - items: + - const: 1 + - const: 2 + - const: 3 + - const: 4 + + link-frequencies: true + + required: + - data-lanes + - link-frequencies + + additionalProperties: false + +required: + - compatible + - reg + - clocks + - clock-names + - vdig-supply + - vana1-supply + - vana2-supply + - vddl-supply + - port + +additionalProperties: false + +examples: + - | + #include + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + imx708: camera-sensor@1a { + compatible = "sony,imx708"; + reg = <0x1a>; + + clocks = <&clk 90>; + clock-names = "inck"; + + vdig-supply = <&camera_vdig>; + vana1-supply = <&camera_vana1>; + vana2-supply = <&camera_vana2>; + vddl-supply = <&camera_vddl>; + + reset-gpios = <&gpio 35 GPIO_ACTIVE_LOW>; + + port { + imx708_ep: endpoint { + data-lanes = <1 2>; + link-frequencies = /bits/ 64 <450000000>; + remote-endpoint = <&csi_ep>; + }; + }; + }; + }; +... diff --git a/MAINTAINERS b/MAINTAINERS index 548ca27e4565fb..b6a1211560275f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19330,7 +19330,7 @@ M: Raspberry Pi Kernel Maintenance L: linux-media@vger.kernel.org S: Maintained T: git git://linuxtv.org/media_tree.git -F: Documentation/devicetree/bindings/media/i2c/imx708.yaml +F: Documentation/devicetree/bindings/media/i2c/sony,imx708.yaml F: drivers/media/i2c/imx708.c SONY MEMORYSTICK SUBSYSTEM diff --git a/arch/arm/boot/dts/overlays/README b/arch/arm/boot/dts/overlays/README index 50f14e009d2fa5..875b58ab172371 100644 --- a/arch/arm/boot/dts/overlays/README +++ b/arch/arm/boot/dts/overlays/README @@ -2417,6 +2417,8 @@ Params: rotation Mounting rotation of the camera sensor (0 or configuring the sensor (default on) cam0 Adopt the default configuration for CAM0 on a Compute Module (CSI0, i2c_vc, and cam0_reg). + link-frequency Allowable link frequency values to use in Hz: + 450000000 (default), 447000000, 453000000. Name: iqaudio-codec diff --git a/arch/arm/boot/dts/overlays/imx708-overlay.dts b/arch/arm/boot/dts/overlays/imx708-overlay.dts index 9107e985c2a8f2..6efbe0943211e3 100644 --- a/arch/arm/boot/dts/overlays/imx708-overlay.dts +++ b/arch/arm/boot/dts/overlays/imx708-overlay.dts @@ -88,6 +88,7 @@ <&vcm_node>, "VDD-supply:0=",<&cam0_reg>; vcm = <&vcm_node>, "status", <0>, "=4"; + link-frequency = <&cam_endpoint>,"link-frequencies#0"; }; }; diff --git a/arch/arm/boot/dts/overlays/imx708.dtsi b/arch/arm/boot/dts/overlays/imx708.dtsi index 1381caf226681d..1558458d58ecbb 100644 --- a/arch/arm/boot/dts/overlays/imx708.dtsi +++ b/arch/arm/boot/dts/overlays/imx708.dtsi @@ -6,12 +6,12 @@ cam_node: imx708@1a { status = "disabled"; clocks = <&cam1_clk>; - clock-names = "xclk"; + clock-names = "inclk"; - VANA1-supply = <&cam1_reg>; /* 2.8v */ - VANA2-supply = <&cam_dummy_reg>;/* 1.8v */ - VDIG-supply = <&cam_dummy_reg>; /* 1.1v */ - VDDL-supply = <&cam_dummy_reg>; /* 1.8v */ + vana1-supply = <&cam1_reg>; /* 2.8v */ + vana2-supply = <&cam_dummy_reg>;/* 1.8v */ + vdig-supply = <&cam_dummy_reg>; /* 1.1v */ + vddl-supply = <&cam_dummy_reg>; /* 1.8v */ rotation = <180>; orientation = <2>; diff --git a/drivers/media/i2c/imx708.c b/drivers/media/i2c/imx708.c index 7f5f07e4e16e54..2453923a4ae3b5 100644 --- a/drivers/media/i2c/imx708.c +++ b/drivers/media/i2c/imx708.c @@ -33,9 +33,7 @@ #define IMX708_REG_ORIENTATION 0x101 -#define IMX708_XCLK_FREQ 24000000 - -#define IMX708_DEFAULT_LINK_FREQ 450000000 +#define IMX708_INCLK_FREQ 24000000 /* Default initial pixel rate, will get updated for each mode. */ #define IMX708_INITIAL_PIXEL_RATE 590000000 @@ -181,6 +179,50 @@ static const u8 pdaf_gains[2][9] = { { 0x35, 0x35, 0x35, 0x38, 0x3e, 0x46, 0x4c, 0x4c, 0x4c } }; +/* Link frequency setup */ +enum { + IMX708_LINK_FREQ_450MHZ, + IMX708_LINK_FREQ_447MHZ, + IMX708_LINK_FREQ_453MHZ, +}; + +static const s64 link_freqs[] = { + [IMX708_LINK_FREQ_450MHZ] = 450000000, + [IMX708_LINK_FREQ_447MHZ] = 447000000, + [IMX708_LINK_FREQ_453MHZ] = 453000000, +}; + +/* 450MHz is the nominal "default" link frequency */ +static const struct imx708_reg link_450Mhz_regs[] = { + {0x030E, 0x01}, + {0x030F, 0x2c}, +}; + +static const struct imx708_reg link_447Mhz_regs[] = { + {0x030E, 0x01}, + {0x030F, 0x2a}, +}; + +static const struct imx708_reg link_453Mhz_regs[] = { + {0x030E, 0x01}, + {0x030F, 0x2e}, +}; + +static const struct imx708_reg_list link_freq_regs[] = { + [IMX708_LINK_FREQ_450MHZ] = { + .regs = link_450Mhz_regs, + .num_of_regs = ARRAY_SIZE(link_450Mhz_regs) + }, + [IMX708_LINK_FREQ_447MHZ] = { + .regs = link_447Mhz_regs, + .num_of_regs = ARRAY_SIZE(link_447Mhz_regs) + }, + [IMX708_LINK_FREQ_453MHZ] = { + .regs = link_453Mhz_regs, + .num_of_regs = ARRAY_SIZE(link_453Mhz_regs) + }, +}; + static const struct imx708_reg mode_common_regs[] = { {0x0100, 0x00}, {0x0136, 0x18}, @@ -278,8 +320,6 @@ static const struct imx708_reg mode_4608x2592_regs[] = { {0x0307, 0x7C}, {0x030B, 0x02}, {0x030D, 0x04}, - {0x030E, 0x01}, - {0x030F, 0x2C}, {0x0310, 0x01}, {0x3CA0, 0x00}, {0x3CA1, 0x64}, @@ -376,8 +416,6 @@ static const struct imx708_reg mode_2x2binned_regs[] = { {0x0307, 0x7A}, {0x030B, 0x02}, {0x030D, 0x04}, - {0x030E, 0x01}, - {0x030F, 0x2C}, {0x0310, 0x01}, {0x3CA0, 0x00}, {0x3CA1, 0x3C}, @@ -472,8 +510,6 @@ static const struct imx708_reg mode_2x2binned_720p_regs[] = { {0x0307, 0x76}, {0x030B, 0x02}, {0x030D, 0x04}, - {0x030E, 0x01}, - {0x030F, 0x2C}, {0x0310, 0x01}, {0x3CA0, 0x00}, {0x3CA1, 0x3C}, @@ -568,8 +604,6 @@ static const struct imx708_reg mode_hdr_regs[] = { {0x0307, 0xA2}, {0x030B, 0x02}, {0x030D, 0x04}, - {0x030E, 0x01}, - {0x030F, 0x2C}, {0x0310, 0x01}, {0x3CA0, 0x00}, {0x3CA1, 0x00}, @@ -752,14 +786,12 @@ static const int imx708_test_pattern_val[] = { /* regulator supplies */ static const char * const imx708_supply_name[] = { /* Supplies can be enabled in any order */ - "VANA1", /* Analog1 (2.8V) supply */ - "VANA2", /* Analog2 (1.8V) supply */ - "VDIG", /* Digital Core (1.1V) supply */ - "VDDL", /* IF (1.8V) supply */ + "vana1", /* Analog1 (2.8V) supply */ + "vana2", /* Analog2 (1.8V) supply */ + "vdig", /* Digital Core (1.1V) supply */ + "vddl", /* IF (1.8V) supply */ }; -#define IMX708_NUM_SUPPLIES ARRAY_SIZE(imx708_supply_name) - /* * Initialisation delay between XCLR low->high and the moment when the sensor * can start capture (i.e. can leave software standby), given by T7 in the @@ -777,24 +809,24 @@ struct imx708 { struct v4l2_mbus_framefmt fmt; - struct clk *xclk; - u32 xclk_freq; + struct clk *inclk; + u32 inclk_freq; struct gpio_desc *reset_gpio; - struct regulator_bulk_data supplies[IMX708_NUM_SUPPLIES]; + struct regulator_bulk_data supplies[ARRAY_SIZE(imx708_supply_name)]; struct v4l2_ctrl_handler ctrl_handler; /* V4L2 Controls */ struct v4l2_ctrl *pixel_rate; struct v4l2_ctrl *exposure; - struct v4l2_ctrl *vflip; - struct v4l2_ctrl *hflip; struct v4l2_ctrl *vblank; struct v4l2_ctrl *hblank; - struct v4l2_ctrl *red_balance; - struct v4l2_ctrl *blue_balance; - struct v4l2_ctrl *notify_gains; struct v4l2_ctrl *hdr_mode; + struct v4l2_ctrl *link_freq; + struct { + struct v4l2_ctrl *hflip; + struct v4l2_ctrl *vflip; + }; /* Current mode */ const struct imx708_mode *mode; @@ -813,6 +845,8 @@ struct imx708 { /* Current long exposure factor in use. Set through V4L2_CID_VBLANK */ unsigned int long_exp_shift; + + unsigned int link_freq_idx; }; static inline struct imx708 *to_imx708(struct v4l2_subdev *_sd) @@ -901,9 +935,10 @@ static int imx708_write_regs(struct imx708 *imx708, { struct i2c_client *client = v4l2_get_subdevdata(&imx708->sd); unsigned int i; - int ret; for (i = 0; i < len; i++) { + int ret; + ret = imx708_write_reg(imx708, regs[i].address, 1, regs[i].val); if (ret) { dev_err_ratelimited(&client->dev, @@ -991,8 +1026,6 @@ static int imx708_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) static int imx708_set_exposure(struct imx708 *imx708, unsigned int val) { - int ret; - val = max(val, imx708->mode->exposure_lines_min); val -= val % imx708->mode->exposure_lines_step; @@ -1000,11 +1033,9 @@ static int imx708_set_exposure(struct imx708 *imx708, unsigned int val) * In HDR mode this will set the longest exposure. The sensor * will automatically divide the medium and short ones by 4,16. */ - ret = imx708_write_reg(imx708, IMX708_REG_EXPOSURE, - IMX708_REG_VALUE_16BIT, - val >> imx708->long_exp_shift); - - return ret; + return imx708_write_reg(imx708, IMX708_REG_EXPOSURE, + IMX708_REG_VALUE_16BIT, + val >> imx708->long_exp_shift); } static void imx708_adjust_exposure_range(struct imx708 *imx708, @@ -1037,7 +1068,7 @@ static int imx708_set_analogue_gain(struct imx708 *imx708, unsigned int val) static int imx708_set_frame_length(struct imx708 *imx708, unsigned int val) { - int ret = 0; + int ret; imx708->long_exp_shift = 0; @@ -1057,8 +1088,8 @@ static int imx708_set_frame_length(struct imx708 *imx708, unsigned int val) static void imx708_set_framing_limits(struct imx708 *imx708) { - unsigned int hblank; const struct imx708_mode *mode = imx708->mode; + unsigned int hblank; __v4l2_ctrl_modify_range(imx708->pixel_rate, mode->pixel_rate, mode->pixel_rate, @@ -1168,12 +1199,12 @@ static int imx708_set_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_NOTIFY_GAINS: ret = imx708_write_reg(imx708, IMX708_REG_COLOUR_BALANCE_BLUE, IMX708_REG_VALUE_16BIT, - imx708->notify_gains->p_new.p_u32[0]); + ctrl->p_new.p_u32[0]); if (ret) break; ret = imx708_write_reg(imx708, IMX708_REG_COLOUR_BALANCE_RED, IMX708_REG_VALUE_16BIT, - imx708->notify_gains->p_new.p_u32[3]); + ctrl->p_new.p_u32[3]); break; case V4L2_CID_WIDE_DYNAMIC_RANGE: /* Already handled above. */ @@ -1428,7 +1459,7 @@ static int imx708_get_selection(struct v4l2_subdev *sd, static int imx708_start_streaming(struct imx708 *imx708) { struct i2c_client *client = v4l2_get_subdevdata(&imx708->sd); - const struct imx708_reg_list *reg_list; + const struct imx708_reg_list *reg_list, *freq_regs; int i, ret; u32 val; @@ -1474,6 +1505,16 @@ static int imx708_start_streaming(struct imx708 *imx708) return ret; } + /* Update the link frequency registers */ + freq_regs = &link_freq_regs[imx708->link_freq_idx]; + ret = imx708_write_regs(imx708, freq_regs->regs, + freq_regs->num_of_regs); + if (ret) { + dev_err(&client->dev, "%s failed to set link frequency registers\n", + __func__); + return ret; + } + /* Apply customized values from user */ ret = __v4l2_ctrl_handler_setup(imx708->sd.ctrl_handler); if (ret) @@ -1555,7 +1596,7 @@ static int imx708_power_on(struct device *dev) struct imx708 *imx708 = to_imx708(sd); int ret; - ret = regulator_bulk_enable(IMX708_NUM_SUPPLIES, + ret = regulator_bulk_enable(ARRAY_SIZE(imx708_supply_name), imx708->supplies); if (ret) { dev_err(&client->dev, "%s: failed to enable regulators\n", @@ -1563,7 +1604,7 @@ static int imx708_power_on(struct device *dev) return ret; } - ret = clk_prepare_enable(imx708->xclk); + ret = clk_prepare_enable(imx708->inclk); if (ret) { dev_err(&client->dev, "%s: failed to enable clock\n", __func__); @@ -1577,7 +1618,8 @@ static int imx708_power_on(struct device *dev) return 0; reg_off: - regulator_bulk_disable(IMX708_NUM_SUPPLIES, imx708->supplies); + regulator_bulk_disable(ARRAY_SIZE(imx708_supply_name), + imx708->supplies); return ret; } @@ -1588,8 +1630,9 @@ static int imx708_power_off(struct device *dev) struct imx708 *imx708 = to_imx708(sd); gpiod_set_value_cansleep(imx708->reset_gpio, 0); - regulator_bulk_disable(IMX708_NUM_SUPPLIES, imx708->supplies); - clk_disable_unprepare(imx708->xclk); + regulator_bulk_disable(ARRAY_SIZE(imx708_supply_name), + imx708->supplies); + clk_disable_unprepare(imx708->inclk); /* Force reprogramming of the common registers when powered up again. */ imx708->common_regs_written = false; @@ -1635,11 +1678,11 @@ static int imx708_get_regulators(struct imx708 *imx708) struct i2c_client *client = v4l2_get_subdevdata(&imx708->sd); unsigned int i; - for (i = 0; i < IMX708_NUM_SUPPLIES; i++) + for (i = 0; i < ARRAY_SIZE(imx708_supply_name); i++) imx708->supplies[i].supply = imx708_supply_name[i]; return devm_regulator_bulk_get(&client->dev, - IMX708_NUM_SUPPLIES, + ARRAY_SIZE(imx708_supply_name), imx708->supplies); } @@ -1720,6 +1763,7 @@ static int imx708_init_controls(struct imx708 *imx708) struct v4l2_ctrl_handler *ctrl_hdlr; struct i2c_client *client = v4l2_get_subdevdata(&imx708->sd); struct v4l2_fwnode_device_properties props; + struct v4l2_ctrl *ctrl; unsigned int i; int ret; @@ -1738,6 +1782,12 @@ static int imx708_init_controls(struct imx708 *imx708) IMX708_INITIAL_PIXEL_RATE, 1, IMX708_INITIAL_PIXEL_RATE); + ctrl = v4l2_ctrl_new_int_menu(ctrl_hdlr, &imx708_ctrl_ops, + V4L2_CID_LINK_FREQ, 0, 0, + &link_freqs[imx708->link_freq_idx]); + if (ctrl) + ctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY; + /* * Create the controls here, but mode specific limits are setup * in the imx708_set_framing_limits() call below. @@ -1767,6 +1817,7 @@ static int imx708_init_controls(struct imx708 *imx708) imx708->vflip = v4l2_ctrl_new_std(ctrl_hdlr, &imx708_ctrl_ops, V4L2_CID_VFLIP, 0, 1, 1, 0); + v4l2_ctrl_cluster(2, &imx708->hflip); v4l2_ctrl_new_std_menu_items(ctrl_hdlr, &imx708_ctrl_ops, V4L2_CID_TEST_PATTERN, @@ -1788,8 +1839,7 @@ static int imx708_init_controls(struct imx708 *imx708) /* The "Solid color" pattern is white by default */ } - imx708->notify_gains = v4l2_ctrl_new_custom(ctrl_hdlr, - &imx708_notify_gains_ctrl, NULL); + v4l2_ctrl_new_custom(ctrl_hdlr, &imx708_notify_gains_ctrl, NULL); imx708->hdr_mode = v4l2_ctrl_new_std(ctrl_hdlr, &imx708_ctrl_ops, V4L2_CID_WIDE_DYNAMIC_RANGE, @@ -1833,13 +1883,14 @@ static void imx708_free_controls(struct imx708 *imx708) mutex_destroy(&imx708->mutex); } -static int imx708_check_hwcfg(struct device *dev) +static int imx708_check_hwcfg(struct device *dev, struct imx708 *imx708) { struct fwnode_handle *endpoint; struct v4l2_fwnode_endpoint ep_cfg = { .bus_type = V4L2_MBUS_CSI2_DPHY }; int ret = -EINVAL; + int i; endpoint = fwnode_graph_get_next_endpoint(dev_fwnode(dev), NULL); if (!endpoint) { @@ -1864,11 +1915,18 @@ static int imx708_check_hwcfg(struct device *dev) goto error_out; } - if (ep_cfg.nr_of_link_frequencies != 1 || - ep_cfg.link_frequencies[0] != IMX708_DEFAULT_LINK_FREQ) { + for (i = 0; i < ARRAY_SIZE(link_freqs); i++) { + if (link_freqs[i] == ep_cfg.link_frequencies[0]) { + imx708->link_freq_idx = i; + break; + } + } + + if (i == ARRAY_SIZE(link_freqs)) { dev_err(dev, "Link frequency not supported: %lld\n", ep_cfg.link_frequencies[0]); - goto error_out; + ret = -EINVAL; + goto error_out; } ret = 0; @@ -1893,28 +1951,24 @@ static int imx708_probe(struct i2c_client *client) v4l2_i2c_subdev_init(&imx708->sd, client, &imx708_subdev_ops); /* Check the hardware configuration in device tree */ - if (imx708_check_hwcfg(dev)) + if (imx708_check_hwcfg(dev, imx708)) return -EINVAL; - /* Get system clock (xclk) */ - imx708->xclk = devm_clk_get(dev, NULL); - if (IS_ERR(imx708->xclk)) { - dev_err(dev, "failed to get xclk\n"); - return PTR_ERR(imx708->xclk); - } + /* Get system clock (inclk) */ + imx708->inclk = devm_clk_get(dev, "inclk"); + if (IS_ERR(imx708->inclk)) + return dev_err_probe(dev, PTR_ERR(imx708->inclk), + "failed to get inclk\n"); - imx708->xclk_freq = clk_get_rate(imx708->xclk); - if (imx708->xclk_freq != IMX708_XCLK_FREQ) { - dev_err(dev, "xclk frequency not supported: %d Hz\n", - imx708->xclk_freq); - return -EINVAL; - } + imx708->inclk_freq = clk_get_rate(imx708->inclk); + if (imx708->inclk_freq != IMX708_INCLK_FREQ) + return dev_err_probe(dev, -EINVAL, + "inclk frequency not supported: %d Hz\n", + imx708->inclk_freq); ret = imx708_get_regulators(imx708); - if (ret) { - dev_err(dev, "failed to get regulators\n"); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "failed to get regulators\n"); /* Request optional enable pin */ imx708->reset_gpio = devm_gpiod_get_optional(dev, "reset", @@ -1943,7 +1997,7 @@ static int imx708_probe(struct i2c_client *client) /* This needs the pm runtime to be registered. */ ret = imx708_init_controls(imx708); if (ret) - goto error_power_off; + goto error_pm_runtime; /* Initialize subdev */ imx708->sd.internal_ops = &imx708_internal_ops; @@ -1975,9 +2029,11 @@ static int imx708_probe(struct i2c_client *client) error_handler_free: imx708_free_controls(imx708); -error_power_off: +error_pm_runtime: pm_runtime_disable(&client->dev); pm_runtime_set_suspended(&client->dev); + +error_power_off: imx708_power_off(&client->dev); return ret;