Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp329825pxu; Wed, 14 Oct 2020 02:25:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQwt0rM3fXMKBkjFNACAE4lFfVdDS/mpCeHp6HexJLzXDmxEine4WZjoG1a0m+sC6fh32s X-Received: by 2002:a17:907:382:: with SMTP id ss2mr4424456ejb.544.1602667558174; Wed, 14 Oct 2020 02:25:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602667558; cv=none; d=google.com; s=arc-20160816; b=rE2b6qBJXmE3T0V/ty2E2Ra/mGMZLe8yO8jRGU44jV9pNN1YlcxA7kFiqgaT+9EJnL A+3+dK2VOBiP0tW2K314bSXRJjDQOLOKyyRlnkMjAYlGltlH414IAcN25hka6N4hFiQZ yxxN+RdBuTTFDqON/c1XAmYSyhMQtLYQwCZ20X9AoFlGbQY3MrS70olYqXVABCwNxrtg HXFI6c5sn6SCRJucVDP+DQBbK0cQuBZSW4wgYMuHHENcHfA/iSHed81/tIlu2EStvMnQ lNEExbl/YKc07hNiNbEsLjGj1YbV2ySvO5oiucI0PQBBcTh1XD50SCZj6kGBxiEMaZMV kSLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=BQVUP6sy3PX6Q3C2BLkQ+7wHeBtTeqDYnlZeUE9CcjA=; b=YsQ7D8GgJuoSxIFtNBMUDat94PzCvqey23g5p3XBe7NVWtB1k/WsC2qGc34EJdKIbV nCxi+iNf+Uos+rmv7F8lnedNdGLuUJqU5Ffvpf+R0TXuV6CqM2fBatmCT2NuasA5aDCA 9kMYH4GSJeYuHbzrBDgxCWZqoYVKPxeDTikZYMr+iH4OS4K3kkQszAQ6/yriGHe+N0m/ 8YCR/mmRWB041RtGOIxmMOWL7jjMaz5AuCFI4Zf+PWKGFkwbtjci9KUkXgcWg8gelXQc s13735QhFcYTRAFQdalJYRVw/n/L+5MrhDPEGIEb2oENmZa3Z8O9tdkWUMphJHr6+LrX VUow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=nY30yW+W; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g5si1770587edu.447.2020.10.14.02.25.36; Wed, 14 Oct 2020 02:25:58 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=nY30yW+W; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731217AbgJNJW5 (ORCPT + 99 others); Wed, 14 Oct 2020 05:22:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731041AbgJNJUm (ORCPT ); Wed, 14 Oct 2020 05:20:42 -0400 Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 443EEC0613E3 for ; Tue, 13 Oct 2020 14:29:23 -0700 (PDT) Received: by mail-ot1-x341.google.com with SMTP id 32so1501000otm.3 for ; Tue, 13 Oct 2020 14:29:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=BQVUP6sy3PX6Q3C2BLkQ+7wHeBtTeqDYnlZeUE9CcjA=; b=nY30yW+WJ9MyaUbcO1v/mKwFDXq94hxYfbWo/1L56jEnYbDaOUoYy9nIdcUT28q/3c Uq9y09kxs8N4qWd/Ff1kdavb8TyIc6oBlU3oviAsPjgw5zqHaKMjWs85k6EGx1lxqE03 VQTguqayk1ztH//dzkEuTPpRd/rbKtMe5TYkZHhAmRaVfWU6khywIlm/eXZEB8R3YU/t RvblJocOk1w4YKITaedGGSW+l4IlsJxZKuoRhJl4WWr78Rm5iE0CXNAtN8R0QHvYHTcS E2nLmPwqNzyIxnEb9m2N39CFYlvmttezElfEknCVV0scF33M9yCSq3OfXIi84EC3hOJ5 U74Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=BQVUP6sy3PX6Q3C2BLkQ+7wHeBtTeqDYnlZeUE9CcjA=; b=IzFBKloH/THLod9ulS8IgT50WwPBrE897NWYYYYBS1Dt3pUbpFyyCJBmiX9ibRw1dQ s28jUTXMzYGDWO87b5br5K88OJ/7lz5vAe7H1/uzR4eEVN3AvPSnMrEfgk4jZ+Mws7v4 4r7J349UMOCFfrt+evafQA1tbTTmV04c7WtPmdGkhf/U04bl6N3xxbb1QY5YQoagALWx ErIuCmkf9anG/ahQkNT0aoTg2k5sGVqvxYn9bb3AhflDU/tYY/zLSnbILS8TWI/3T5Z3 LoWIWQDtqoDy6XhGRIEceUEQ7MuDhq0CZ28i8qpMeQNUgDtTZYl093t3v1+/ett3nXJR bH1g== X-Gm-Message-State: AOAM532UQsfjTX3rfsST9aiOVZ2Z3SoCCILFwlrOV4eDStlT0sD4/40v tVvN9Ju+XalmtPTV8wmHEwi9+xzoig63Q4dp7OhlxQ== X-Received: by 2002:a9d:7b59:: with SMTP id f25mr1167062oto.306.1602624562402; Tue, 13 Oct 2020 14:29:22 -0700 (PDT) MIME-Version: 1.0 References: <20201013100314.216154-1-tali.perry1@gmail.com> <20201013115023.GL4077@smile.fi.intel.com> In-Reply-To: <20201013115023.GL4077@smile.fi.intel.com> From: Alex Qiu Date: Tue, 13 Oct 2020 14:29:11 -0700 Message-ID: Subject: Re: [PATCH v2] i2c: npcm7xx: Support changing bus speed using debugfs. To: Andy Shevchenko Cc: Tali Perry , Wolfram Sang , Kun Yi , Benjamin Fair , Avi Fishman , Joel Stanley , Tomer Maimon , Linux I2C , OpenBMC Maillist , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Tested again, and the updated patch is still working. On Tue, Oct 13, 2020 at 4:49 AM Andy Shevchenko wrote: > > 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 Reviewed-by: Alex Qiu Tested-by: Alex Qiu > > --- > > ...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 > > - Alex Qiu