From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ED677C001DE for ; Fri, 28 Jul 2023 08:21:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PZNRoc4tIlD6GhLBU+VPDOv+I7WljhWPVt+JcWBuz/w=; b=JKL0K71V+Ixtck oRnyYYB5w73dGftlhVD5BU8CpDXMJbHi/pDw79ND12MRwasmOk20+m2N5n9i39bWHIq0nqWu0FA0q zbkRgoo6a4yn1eVRI553J95hs0kFa+57xwmAq8oqRohu7oO5R3gm1pqdhgUaSbBx1UvfKFmUYGAVk hw4SJFZTnO7I1BxVunpKiy3OrO/5vSg3Gt/ECL7EBFJuKeRzq1+6j6rUpz6k27+M7Z5+2/Vmsv4MF ar2RBbcWItClDI0hUnMxwq95cmq/k6gVj0p8QPFSlxNvJj04yXlOwajc0QWr37c5X1dIB20MlbySP I2tRyIbjY+fXAOyuOIuA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qPIiw-002NgA-0G; Fri, 28 Jul 2023 08:21:22 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qPIir-002Nev-33 for linux-arm-kernel@lists.infradead.org; Fri, 28 Jul 2023 08:21:20 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1DC166200F; Fri, 28 Jul 2023 08:21:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98CD0C433C8; Fri, 28 Jul 2023 08:21:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690532476; bh=trDnCNuseGajeqLLAPm/8j0t94QcgtOfehlGyJyaXZE=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Mz2ko7Ol0uqzlX1AHZYCgEeua3ecSnCmo+vwwV2++dFEVO/Ao9FhTMMnDncWT/XmF WOV6p0E3iGsRa1jaRkxKFZzRDaY9z7RnRspLVZ7AsRXerPNek9iJHJNP2crriUM604 mpv6mFcyj0M6xFd5g91ru6p1Yet3TLbQPlWOZwIEcpo0+qUtgJbj7pDHE/wMY9n7uV UKY+qNnRIAXmIlxkPyZrPoSjRobrR7FJ5ZSXeE9FRhgulCMAppmWZt88EqiYBpDWRE JAp/l+VFsql+p3qFz2RsIJhrPQp+LgrYvlv5peaxevseAEE+qMcWGPi7XcSeVCGxOL DT4Aod1QyyNEw== Message-ID: Date: Fri, 28 Jul 2023 10:21:08 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH 2/2] media: i2c: imx519: Support for the Sony IMX519 sensor Content-Language: en-US To: Umang Jain , linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Lee Jackson , Mauro Carvalho Chehab , Sakari Ailus , Laurent Pinchart , Hans Verkuil , Shawn Tu , Nicholas Roth , Mikhail Rudenko , kieran.bingham@ideasonboard.com, Marco Felsch , jacopo.mondi@ideasonboard.com References: <20230727154108.308320-1-umang.jain@ideasonboard.com> <20230727154108.308320-3-umang.jain@ideasonboard.com> From: Krzysztof Kozlowski In-Reply-To: <20230727154108.308320-3-umang.jain@ideasonboard.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230728_012118_070722_1F95E233 X-CRM114-Status: GOOD ( 23.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 27/07/2023 17:41, Umang Jain wrote: > From: Lee Jackson > > Adds a driver for the 16MPix IMX519 CSI2 sensor. > Whilst the sensor supports 2 or 4 CSI2 data lanes, this driver > currently only supports 2 lanes. The driver also supports > Phase Detection Auto Focus (PDAF). Thank you for your patch. There is something to discuss/improve. > + > +error_out: > + v4l2_fwnode_endpoint_free(&ep_cfg); > + fwnode_handle_put(endpoint); > + > + return ret; > +} > + > +static const struct of_device_id imx519_dt_ids[] = { > + { .compatible = "sony,imx519"}, > + { /* sentinel */ } > +}; > + > +static int imx519_probe(struct i2c_client *client) > +{ > + struct device *dev = &client->dev; > + struct imx519 *imx519; > + const struct of_device_id *match; > + u32 xclk_freq; > + int ret; > + > + imx519 = devm_kzalloc(&client->dev, sizeof(*imx519), GFP_KERNEL); > + if (!imx519) > + return -ENOMEM; > + > + v4l2_i2c_subdev_init(&imx519->sd, client, &imx519_subdev_ops); > + > + match = of_match_device(imx519_dt_ids, dev); > + if (!match) > + return -ENODEV; > + > + /* Check the hardware configuration in device tree */ > + if (imx519_check_hwcfg(dev)) > + return -EINVAL; > + > + /* Get system clock (xclk) */ > + imx519->xclk = devm_clk_get(dev, NULL); > + if (IS_ERR(imx519->xclk)) { > + dev_err(dev, "failed to get xclk\n"); return dev_err_probe > + return PTR_ERR(imx519->xclk); > + } > + > + xclk_freq = clk_get_rate(imx519->xclk); > + if (xclk_freq != IMX519_XCLK_FREQ) { > + dev_err(dev, "xclk frequency not supported: %d Hz\n", > + xclk_freq); return dev_err_probe > + return -EINVAL; > + } > + > + ret = imx519_get_regulators(imx519); > + if (ret) { > + dev_err(dev, "failed to get regulators\n"); > + return ret; return dev_err_probe > + } > + > + /* Request optional enable pin */ > + imx519->reset_gpio = devm_gpiod_get_optional(dev, "reset", > + GPIOD_OUT_HIGH); > + > + /* > + * The sensor must be powered for imx519_identify_module() > + * to be able to read the CHIP_ID register > + */ > + ret = imx519_power_on(dev); > + if (ret) > + return ret; > + > + ret = imx519_identify_module(imx519, IMX519_CHIP_ID); > + if (ret) > + goto error_power_off; > + > + /* Set default mode to max resolution */ > + imx519->mode = &supported_modes_10bit[0]; > + imx519->fmt_code = MEDIA_BUS_FMT_SRGGB10_1X10; > + > + /* Enable runtime PM and turn off the device */ > + pm_runtime_set_active(dev); > + pm_runtime_enable(dev); > + pm_runtime_idle(dev); > + > + /* This needs the pm runtime to be registered. */ > + ret = imx519_init_controls(imx519); > + if (ret) > + goto error_power_off; > + > + /* Initialize subdev */ > + imx519->sd.internal_ops = &imx519_internal_ops; > + imx519->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | > + V4L2_SUBDEV_FL_HAS_EVENTS; > + imx519->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR; > + > + /* Initialize source pads */ > + imx519->pad[IMAGE_PAD].flags = MEDIA_PAD_FL_SOURCE; > + imx519->pad[METADATA_PAD].flags = MEDIA_PAD_FL_SOURCE; > + > + ret = media_entity_pads_init(&imx519->sd.entity, NUM_PADS, imx519->pad); > + if (ret) { > + dev_err(dev, "failed to init entity pads: %d\n", ret); > + goto error_handler_free; > + } > + > + ret = v4l2_async_register_subdev_sensor(&imx519->sd); > + if (ret < 0) { > + dev_err(dev, "failed to register sensor sub-device: %d\n", ret); > + goto error_media_entity; > + } > + > + return 0; > + > +error_media_entity: > + media_entity_cleanup(&imx519->sd.entity); > + > +error_handler_free: > + imx519_free_controls(imx519); > + > +error_power_off: > + pm_runtime_disable(&client->dev); > + pm_runtime_set_suspended(&client->dev); > + imx519_power_off(&client->dev); > + > + return ret; > +} > + > +static void imx519_remove(struct i2c_client *client) > +{ > + struct v4l2_subdev *sd = i2c_get_clientdata(client); > + struct imx519 *imx519 = to_imx519(sd); > + > + v4l2_async_unregister_subdev(sd); > + media_entity_cleanup(&sd->entity); > + imx519_free_controls(imx519); > + > + pm_runtime_disable(&client->dev); > + if (!pm_runtime_status_suspended(&client->dev)) > + imx519_power_off(&client->dev); > + pm_runtime_set_suspended(&client->dev); > +} > + > +MODULE_DEVICE_TABLE(of, imx519_dt_ids); > + > +static const struct dev_pm_ops imx519_pm_ops = { > + SET_SYSTEM_SLEEP_PM_OPS(imx519_suspend, imx519_resume) > + SET_RUNTIME_PM_OPS(imx519_power_off, imx519_power_on, NULL) > +}; > + > +static struct i2c_driver imx519_i2c_driver = { > + .driver = { > + .name = "imx519", > + .of_match_table = imx519_dt_ids, > + .pm = &imx519_pm_ops, > + }, > + .probe_new = imx519_probe, Are you sure? Wasn't i2c already converted? Best regards, Krzysztof _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel