Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4693345pxu; Tue, 13 Oct 2020 05:06:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/QyfriVoyjscm1iwYLw+ODZtoKNalXE/6iS+pOR28+MMoDmSQVVW83n6dr1FH3J6WW95t X-Received: by 2002:a17:906:2191:: with SMTP id 17mr23547908eju.449.1602590806105; Tue, 13 Oct 2020 05:06:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602590806; cv=none; d=google.com; s=arc-20160816; b=03pGCTc/08Ik4CX+EB20akZBt+j8BvxZjSGuZft+4pYcsUhG9k4buZc3radPvYAXLf 82rkrXgBrouwGcV26WimIi80xXUxepTbSq2g3bROSxagYSqfBmFgbT3Kl1F4uP+zHda6 PVeLJvS9cZ9Nfk8OPqp3g5rYx7Aa0MNT+rt1/SSJs2B9R5xLqJJaMfvto85cEt8FG86O fI6qJT9HfOHTqmDB8/WhguvVRgTrHe4ChqBhEYs4m+n6XIjTkMTPvT7qLJC6dzFz4qsg 84scxTQy6Xf4OHhNCc87ddSqssnTNzG/BEIU3qyOMs8c24HfWen2CZ2zCoWit7G66NoW rhmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=XqRPMcySxjdDzv9W0C/mNDcPda0cXa1j1HBy1LwZj9w=; b=0hCkjxDNJYMuGQHXlMlf5BK0SdRYDyA08KyzlmtvlDLFq8/oJvLWy4/D+oCsopjd9u VX6Ailj/POkzSeCbmhnCIgC/BUH2pYGotHs157XfDPrALwb5hVgef+xpXh+CoifgXls9 Z7KKIFBGc+Q6rL26NwD6X0mBCMLxz1byU9W2TqNggpEpUTiR7tQshXYjsrHt6gqnwYFW mAcV7JrSz+FrCzGrtoAdgZdmi8Ui0QMfV4AsgeWpETBIaaa1L++5PGi3vknjDuCdAcnc YYmSsEfOnLCJcpX8JGg06wHj7hth/Y/PhGByjnVhUVl/y5GAYi7XQ9RjPy7w1v9yXEBo HGjg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m18si12449538eje.64.2020.10.13.05.06.20; Tue, 13 Oct 2020 05:06:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727161AbgJMLt1 (ORCPT + 99 others); Tue, 13 Oct 2020 07:49:27 -0400 Received: from mga05.intel.com ([192.55.52.43]:12818 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726388AbgJMLt0 (ORCPT ); Tue, 13 Oct 2020 07:49:26 -0400 IronPort-SDR: GIR88rKzu6XEi2xkA/TcSAv4EI3xrX9CusWWQCt+mL3VpGCod2OzSu6cZnJW9TSgoWTnU3Jm9W n0SFYCyivB6g== X-IronPort-AV: E=McAfee;i="6000,8403,9772"; a="250589292" X-IronPort-AV: E=Sophos;i="5.77,370,1596524400"; d="scan'208";a="250589292" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2020 04:49:25 -0700 IronPort-SDR: fKI1CIVL3TQGd0i33Ir236iwYH6hYmucZP/YzxKQuSuYVNcZs5we04sss9kdiEzuaA2shv9ihM IHGwFF2cH4Gg== X-IronPort-AV: E=Sophos;i="5.77,370,1596524400"; d="scan'208";a="313770836" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2020 04:49:21 -0700 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1kSIox-005n54-Sf; Tue, 13 Oct 2020 14:50:23 +0300 Date: Tue, 13 Oct 2020 14:50:23 +0300 From: Andy Shevchenko To: Tali Perry Cc: wsa@kernel.org, xqiu@google.com, kunyi@google.com, benjaminfair@google.com, avifishman70@gmail.com, joel@jms.id.au, tmaimon77@gmail.com, linux-i2c@vger.kernel.org, openbmc@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] i2c: npcm7xx: Support changing bus speed using debugfs. Message-ID: <20201013115023.GL4077@smile.fi.intel.com> References: <20201013100314.216154-1-tali.perry1@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201013100314.216154-1-tali.perry1@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 13, 2020 at 01:03:14PM +0300, Tali Perry wrote: > Systems that can dynamically add and remove slave devices > often need to change the bus speed in runtime. > This patch expose the bus frequency to the user. > This feature can also be used for test automation. > -- > v2 -> v1: > - Fix typos. > - Remove casting to u64. > > v1: initial version Above block should go after cutter '---' (see below) line... > Fixes: 56a1485b102e (i2c: npcm7xx: Add Nuvoton NPCM I2C controller driver) > Signed-off-by: Tali Perry > --- ...here. > drivers/i2c/busses/i2c-npcm7xx.c | 35 ++++++++++++++++++++++++++++++++ > 1 file changed, 35 insertions(+) As we discussed previously I'm not a fan of the functionality this gives and a way it's done, but this is debugfs and not anyhow an ABI. Also it's localized inside one driver. In the future we may come up with better approach. That said, no objections from me. > diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c > index 2ad166355ec9..633ac67153e2 100644 > --- a/drivers/i2c/busses/i2c-npcm7xx.c > +++ b/drivers/i2c/busses/i2c-npcm7xx.c > @@ -2208,6 +2208,40 @@ static const struct i2c_algorithm npcm_i2c_algo = { > /* i2c debugfs directory: used to keep health monitor of i2c devices */ > static struct dentry *npcm_i2c_debugfs_dir; > > +static int i2c_speed_get(void *data, u64 *val) > +{ > + struct npcm_i2c *bus = data; > + > + *val = bus->bus_freq; > + return 0; > +} > + > +static int i2c_speed_set(void *data, u64 val) > +{ > + struct npcm_i2c *bus = data; > + int ret; > + > + if (val < I2C_FREQ_MIN_HZ || val > I2C_FREQ_MAX_HZ) > + return -EINVAL; > + > + if (val == bus->bus_freq) > + return 0; > + > + i2c_lock_bus(&bus->adap, I2C_LOCK_ROOT_ADAPTER); > + > + npcm_i2c_int_enable(bus, false); > + > + ret = npcm_i2c_init_module(bus, I2C_MASTER, (u32)val); > + > + i2c_unlock_bus(&bus->adap, I2C_LOCK_ROOT_ADAPTER); > + > + if (ret) > + return -EAGAIN; > + > + return 0; > +} > +DEFINE_DEBUGFS_ATTRIBUTE(i2c_clock_ops, i2c_speed_get, i2c_speed_set, "%llu\n"); > + > static void npcm_i2c_init_debugfs(struct platform_device *pdev, > struct npcm_i2c *bus) > { > @@ -2223,6 +2257,7 @@ static void npcm_i2c_init_debugfs(struct platform_device *pdev, > debugfs_create_u64("rec_succ_cnt", 0444, d, &bus->rec_succ_cnt); > debugfs_create_u64("rec_fail_cnt", 0444, d, &bus->rec_fail_cnt); > debugfs_create_u64("timeout_cnt", 0444, d, &bus->timeout_cnt); > + debugfs_create_file("i2c_speed", 0644, d, bus, &i2c_clock_ops); > > bus->debugfs = d; > } > > base-commit: 865c50e1d279671728c2936cb7680eb89355eeea > -- > 2.22.0 > -- With Best Regards, Andy Shevchenko