Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4871892imm; Mon, 14 May 2018 14:52:19 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqLmAy/7Ozz65jqCOyrQ2URLEGmBnJXghsFXSg7yDvbhpE7w/smujO0J2sup79KxtcH7DcN X-Received: by 2002:a63:9512:: with SMTP id p18-v6mr9596010pgd.183.1526334739871; Mon, 14 May 2018 14:52:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526334739; cv=none; d=google.com; s=arc-20160816; b=y3rARk6EvYGpqNzlIlR0/6wt5LO4FmglnDNrDUJFCOXMl4CPg5N9/lMDp5Ojuy+P2M sAuuAdWcMM6EU8NBjxEKgqlW3C6oIh43zVk21xkiNEnXh9ZtO/XEMDLvwDCPrdX9NS87 hDDuHeo6jztFx9qzxH6B5YaScm68TOA5bnd6v4PE7QVzlxi07AaQt/UHbuGqAQf/clRR XuaHH/nZmNvj3T3iA6Y7AyJYRGmkZjd89nyllv8fGWdJb63UGeApnP2ulQPSEWJsgtSx SEp4L47sbVNz5rYtPMUMtRpKFMofxKTAvGtHZzgUGuyRMV/E9FxPoNgceWl5ITyMBX+y LS3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=cBQYV6AbMXaKPP4+zj5Gn69OfB6KwubkeF5c5VSauso=; b=fkE+o3v3r6MMo4FdtOThbhihAouHUQdYuSsIApff4ztky/mI74uEYYoKoCpVfpm0Gz sLXSW68sYfglPS6hgLg0i/PfOnctEy62FiZwJZPZrz9ZSHcrShlLvQg/ShOyBkIxzqcn Ipj1RqgzGG/jkQy/NCVme4jMK/Jk8qoAZ2jghraZKh4ywXU04mus0Ox/a3q1sU75ec1D ReuSi7UWf3zKLNxu2PGVUHn0016DzRHx7JuSn1mwN75IGxzAKmZBzSZPFY9Ik8peFNsC XutpxpsAsveO9azEwC1IG1nM/GkdJIBZvoo+RyT35a/4jZSV4blgxAjjR8RanUIjsV8b /4TQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d65-v6si10553550pfa.263.2018.05.14.14.52.04; Mon, 14 May 2018 14:52:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752368AbeENVuJ (ORCPT + 99 others); Mon, 14 May 2018 17:50:09 -0400 Received: from nblzone-211-213.nblnetworks.fi ([83.145.211.213]:40732 "EHLO hillosipuli.retiisi.org.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752038AbeENVuH (ORCPT ); Mon, 14 May 2018 17:50:07 -0400 Received: from valkosipuli.localdomain (valkosipuli.retiisi.org.uk [IPv6:2001:1bc8:1a6:d3d5::80:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by hillosipuli.retiisi.org.uk (Postfix) with ESMTPS id 3C64D634C7D; Tue, 15 May 2018 00:50:05 +0300 (EEST) Received: from sakke by valkosipuli.localdomain with local (Exim 4.89) (envelope-from ) id 1fILM5-0000an-0V; Tue, 15 May 2018 00:50:05 +0300 Date: Tue, 15 May 2018 00:50:04 +0300 From: Sakari Ailus To: jacopo mondi Cc: Jacopo Mondi , hans.verkuil@cisco.com, mchehab@kernel.org, robh+dt@kernel.org, linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] media: i2c: mt9t112: Add device tree support Message-ID: <20180514215004.5oy6jr7f32jpfhx2@valkosipuli.retiisi.org.uk> References: <1524654014-17852-1-git-send-email-jacopo+renesas@jmondi.org> <1524654014-17852-3-git-send-email-jacopo+renesas@jmondi.org> <20180507093219.hrhaliadccaytenj@valkosipuli.retiisi.org.uk> <20180514143044.GK5956@w540> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180514143044.GK5956@w540> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jacopo, On Mon, May 14, 2018 at 04:30:44PM +0200, jacopo mondi wrote: > Hi Sakari, > > On Mon, May 07, 2018 at 12:32:19PM +0300, Sakari Ailus wrote: > > Hi Jacopo, > > > > On Wed, Apr 25, 2018 at 01:00:14PM +0200, Jacopo Mondi wrote: > > [snip] > > > > static int mt9t112_probe(struct i2c_client *client, > > > const struct i2c_device_id *did) > > > { > > > struct mt9t112_priv *priv; > > > int ret; > > > > > > - if (!client->dev.platform_data) { > > > + if (!client->dev.of_node && !client->dev.platform_data) { > > > dev_err(&client->dev, "mt9t112: missing platform data!\n"); > > > return -EINVAL; > > > } > > > @@ -1081,23 +1118,39 @@ static int mt9t112_probe(struct i2c_client *client, > > > if (!priv) > > > return -ENOMEM; > > > > > > - priv->info = client->dev.platform_data; > > > priv->init_done = false; > > > - > > > - v4l2_i2c_subdev_init(&priv->subdev, client, &mt9t112_subdev_ops); > > > - > > > - priv->clk = devm_clk_get(&client->dev, "extclk"); > > > - if (PTR_ERR(priv->clk) == -ENOENT) { > > > + priv->dev = &client->dev; > > > + > > > + if (client->dev.platform_data) { > > > + priv->info = client->dev.platform_data; > > > + > > > + priv->clk = devm_clk_get(&client->dev, "extclk"); > > > > extclk needs to be documented in DT binding documentation. > > > > > + if (PTR_ERR(priv->clk) == -ENOENT) { > > > + priv->clk = NULL; > > > + } else if (IS_ERR(priv->clk)) { > > > + dev_err(&client->dev, > > > + "Unable to get clock \"extclk\"\n"); > > > + return PTR_ERR(priv->clk); > > > + } > > > + } else { > > > + /* > > > + * External clock frequencies != 24MHz are only supported > > > + * for non-OF systems. > > > + */ > > > > Shouldn't you actually set the frequency? Or perhaps even better to check > > it, and use assigned-clocks and assigned-clock-rates properties? > > > > I might be confused, but my intention was to use an external clock > reference, with a configurable frequency only in the platform data use > case. As you can see in this 'else' branch, in OF case, the priv->clk > field is null, and all the PLL and clock computations are performed > assuming a 24MHz input clock. > > In my opinion, as the driver when running on OF systems does not > get any reference to 'extclk' clock, it should not be documented in > bindings. Do you agree? Uh, isn't the clock generally controlled by the driver on OF-based systems? You could assign the frequency in DT though, and not in the driver, but that should be documented in binding documentation. The register configuration the driver does not appear to be dependent on the clock frequency, which suggests that it is only applicable to a particular frequency --- 24 MHz? > > Thanks > j > > > > priv->clk = NULL; > > > - } else if (IS_ERR(priv->clk)) { > > > - dev_err(&client->dev, "Unable to get clock \"extclk\"\n"); > > > - return PTR_ERR(priv->clk); > > > + priv->info = &mt9t112_default_pdata_24MHz; > > > + > > > + ret = mt9t112_parse_dt(priv); > > > + if (ret) > > > + return ret; > > > } > > > > > > - priv->standby_gpio = devm_gpiod_get_optional(&client->dev, "standby", > > > + v4l2_i2c_subdev_init(&priv->subdev, client, &mt9t112_subdev_ops); > > > + > > > + priv->standby_gpio = devm_gpiod_get_optional(&client->dev, "powerdown", > > > GPIOD_OUT_HIGH); > > > if (IS_ERR(priv->standby_gpio)) { > > > - dev_err(&client->dev, "Unable to get gpio \"standby\"\n"); > > > + dev_err(&client->dev, "Unable to get gpio \"powerdown\"\n"); > > > return PTR_ERR(priv->standby_gpio); > > > } > > > > > > @@ -1124,9 +1177,19 @@ static const struct i2c_device_id mt9t112_id[] = { > > > }; > > > MODULE_DEVICE_TABLE(i2c, mt9t112_id); > > > > > > +#if IS_ENABLED(CONFIG_OF) > > > +static const struct of_device_id mt9t112_of_match[] = { > > > + { .compatible = "micron,mt9t111", }, > > > + { .compatible = "micron,mt9t112", }, > > > + { /* sentinel */ }, > > > +}; > > > +MODULE_DEVICE_TABLE(of, mt9t112_of_match); > > > +#endif > > > + > > > static struct i2c_driver mt9t112_i2c_driver = { > > > .driver = { > > > .name = "mt9t112", > > > + .of_match_table = of_match_ptr(mt9t112_of_match), > > > > No need to use of_match_ptr(). > > > > > }, > > > .probe = mt9t112_probe, > > > .remove = mt9t112_remove, > > > > -- > > Sakari Ailus > > e-mail: sakari.ailus@iki.fi -- Sakari Ailus e-mail: sakari.ailus@iki.fi