Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp164993ybt; Thu, 18 Jun 2020 21:50:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/Y41XXjTq6pAaNe9c8G4fRzdOmzKbqcsBWXR21vw8g1qTYDBz48kdCKTy0B65axfYtRR7 X-Received: by 2002:a17:906:7103:: with SMTP id x3mr1790042ejj.363.1592542237314; Thu, 18 Jun 2020 21:50:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592542237; cv=none; d=google.com; s=arc-20160816; b=XwaH1HBd1IVoXeoWhKRZApvuZKpXqc2pPU30Sij207nzwxfyApPvNz25DR9s0CwI3U oKcBDuMVHiMhwGqZdSfa+aHD2d6whphXhiDZCj9U0ShsMoi5QmSwhj6KSgGXP7jE80Uw uSB5mNTemcCcPNp4ZJnU4otyigkqbgoIvA1cS2aeJBzpOwlUQS/kDDLYuDBs9URvAY7l W8TSYFiWUo70T7ajV8rkrBcRZttXQjWEwRW+7YFIy3rHKXi3+OPPxoJxp9bcM7zeoy3r yn4BCH5liRR81R9mOtciQieWd4ihNM+61GR4pyE2ueoX4BgRJb+q76IsRWY/DVFfoSjf R7zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=awnW1HDdKkXqr3pmsww12Gi5t0wx02y4wFBXBavwwok=; b=SE2OzByJrXcxewVRt25oaRLYTjhtweuGIebQtVn+Mr5ekgZDhK1A+vfukWD1XpS5Mh 8XA0uy5MIex7MuqzG2epza7MnKwrgM9OiGp1L4JNh7HZ+1+2FGPirnqB2iIvidxD/iIC 6u1MxLODMnzwtoa8OUTxfNJTaRUJnLNrqc5uGVYzniB5Dcf4krHlrrgUJjHDi6lRbX4S Q5Czuo4gEsl0fBoevKescXCXoppoSm3KyLD7wGCEZmN0/7fKn7yzWemyBojVFsaly3oV 1Q3NLnu4ZhkSVwLmj0UHk4A/P+J2BiWZLemnsg+0QhVqVvlv6ydTUCPBtkCuxMFxdBVV 3UMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="iPpKgB/1"; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i17si3057278eja.574.2020.06.18.21.50.15; Thu, 18 Jun 2020 21:50:37 -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=@kernel.org header.s=default header.b="iPpKgB/1"; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729158AbgFSDDq (ORCPT + 99 others); Thu, 18 Jun 2020 23:03:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:41968 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727814AbgFSDDn (ORCPT ); Thu, 18 Jun 2020 23:03:43 -0400 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3B01020899; Fri, 19 Jun 2020 03:03:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592535822; bh=cKmkcpfwXu1EEI1wr7eaNKoi2kDhEga2lWfhy3FeS4U=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=iPpKgB/117h3Y6qYN+jag1kQRFU7Sl9dl/4pWbUk0ct8ldUZD+/4PxSfo+rAbJWlH m4k4zuL0YLAxx4WDNSwZp4MJtinDuBUGlCcFOamlv/9KvkGw0tgSydY9CgiyyG7rUi wa3229W8qrw8OGIm8qgdDy3QglaO8gZga9tJmCOk= Received: by mail-lj1-f175.google.com with SMTP id e4so9765457ljn.4; Thu, 18 Jun 2020 20:03:42 -0700 (PDT) X-Gm-Message-State: AOAM5306lweGZvO8DYHdToZmXLaLeOjodhOL8o+o66vMkFwBIOJDf82u 7qu5ziDrEQOnnmfcWfNfhAO9uZyA/j5vpmF+SIY= X-Received: by 2002:a2e:9eca:: with SMTP id h10mr708200ljk.273.1592535820451; Thu, 18 Jun 2020 20:03:40 -0700 (PDT) MIME-Version: 1.0 References: <20200618080223.951737-1-lee.jones@linaro.org> <20200618100704.GC954398@dell> In-Reply-To: <20200618100704.GC954398@dell> From: Chen-Yu Tsai Date: Fri, 19 Jun 2020 11:03:28 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 1/1] mfd: Add I2C based System Configuaration (SYSCON) access To: Lee Jones Cc: Arnd Bergmann , DTML , gregkh , Mark Brown , "linux-kernel@vger.kernel.org" , Bartosz Golaszewski , michael@walle.cc, Rob Herring , Andy Shevchenko , Linus Walleij , Linux ARM Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 18, 2020 at 6:07 PM Lee Jones wrote: > > On Thu, 18 Jun 2020, Arnd Bergmann wrote: > > > On Thu, Jun 18, 2020 at 10:03 AM Lee Jones wrote: > > > > > > The existing SYSCON implementation only supports MMIO (memory mapped) > > > accesses, facilitated by Regmap. This extends support for registers > > > held behind I2C busses. > > > > > > Signed-off-by: Lee Jones > > > > The implementation looks fine to me, but can you explain how this is going to > > be used, and what the advantage is over open-coding the devm_regmap_init_i2c() > > in each driver that would use this? > > Does Regmap let you register/initialise an I2C address more than once? > > When I attempt it, I get: > > [ 0.522988] i2c i2c-0: Failed to register i2c client tmp105 at 0x32 (-16) > [ 0.523341] i2c i2c-0: of_i2c: Failure registering /bus@4000000/motherboard/iofpga@7,00000000/i2c@16000/temp@32 > [ 0.523691] i2c i2c-0: Failed to create I2C device for /bus@4000000/motherboard/iofpga@7,00000000/i2c@16000/temp@32 > > > Is this about using proper locking through the regmap framework for > > shared i2c clients, or to reduce memory consumption when lots of drivers > > access the same regmap? > > All of those things are valid. > > My use-case is regarding MFDs sharing an I2C interfaced address space > with their children. Is that an issue with the standard mfd + regmap pattern? For the AXP20x PMICs, we register the regmap in the parent mfd driver [1], and store that in dev_data for child drivers to fetch [2]. You could easily just fetch the regmap with dev_get_regmap() and a pointer to the parent device. > > My impression of the existing syscon code is that the main value-add over > > other ways of doing the same is the syscon_regmap_lookup_by_phandle() > > interface that gives other drivers a much simpler way of getting the > > regmap just based on the DT node. Are you planning to add something > > like that here as well? An ideal driver interface might allow > > syscon_regmap_lookup_by_phandle() to work for both mmio and i2c > > based syscons, or additional ones as well, but implementing this would > > be rather tricky when the i2c core is a loadable module. The current MMIO syscon is decoupled from the DM, and there is no way for drivers to export or register a syscon, meaning I have to open code syscon_regmap_lookup_by_phandle() [3] if I want to only expose certain registers and not the full address range, or if I want to share the regmap with the existing driver (for locking purposes), or both [4]. Maybe there's room for improvement here? The same applies to the new I2C case, and likely any other future syscon variants. IMHO people are getting it wrong if they have both a syscon and a driver for the same device. > I expect the API would be expanded to cover other use-cases. This is > a bare bones implementation which has been kept as atomic as possible > for ease of review. Regards ChenYu [1] https://elixir.bootlin.com/linux/latest/source/drivers/mfd/axp20x-i2c.c#L43 [2] https://elixir.bootlin.com/linux/latest/source/drivers/pinctrl/pinctrl-axp209.c#L433 [3] https://elixir.bootlin.com/linux/latest/source/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c#L1093 [4] https://elixir.bootlin.com/linux/latest/source/drivers/clk/sunxi-ng/ccu-sun8i-r40.c#L1333