Received: by 10.192.165.156 with SMTP id m28csp732907imm; Mon, 16 Apr 2018 07:54:11 -0700 (PDT) X-Google-Smtp-Source: AIpwx488EQ7F36/jWT9n57QUriKCqldEzCNC+eljA+pXhjY+zUTM9yFa2uEJTrFJdqAAUWP8Gm78 X-Received: by 10.99.124.68 with SMTP id l4mr10866263pgn.67.1523890451825; Mon, 16 Apr 2018 07:54:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523890451; cv=none; d=google.com; s=arc-20160816; b=072eitDKw5T/AbeVifBsqVHf2kxn2ZpIyhqo+oC0bz93jBHirxXk4TTjPy9/X4Av31 quO1kGx4bZGiDG+usEyuqVQ/9P82lPCP3tqIgQ2sDvLoP9pk2vu9Le/HMwg1NGGUFS0m s0+1tdOJYn6vQChct5Jon5dDM3zfIxV6UZxY10pu5mKUwEteoizniOyJBr5o+K0GeM5Z NDgTtFYpb/XECS1G27sy6OY2wIZNZ8aazoHGjLA4pVl7zhyJfwbzjjSykqCIC9RKw/0G Rb7VVEi9B2rMmpLyYSJ2Ik8sOfGgRsbrK0xNgnEHWtVJ6XbYJkemcRbSs8nn58EwJRHy e6kQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :arc-authentication-results; bh=hoHb33kY8LqvSWD6q5e9xy5PZ+riVENgYrY2CMoS1N4=; b=0/DzpXLPEUuOYMQ4hyu8bB/hKwdi16zlKCHq2fgXvmfMlUiEH4P91tL4lXvRG/ApQD 7WLpEYVedKAfpo/MRL4HFXEe15H1e6Ekp1/qWF7YQy/2dbONlSCbWfwmjvsm4nrZkt/k OU5Vze8pEAq6wXpPBmoyG0wvrjuc8NX7yk4gyttKuQcvX6NOJ1lrH5l7hhPpBdyPDz7G cnQlB1L63mwzxDieM9qaRcR6V+91Nq6cj5c8Q/8iemfNwuEuXc/zeXuzQ7oeM++byap+ e0FEZc/cGLeCXQE1P7yyWbcajeFnZiNmxAscHAorc2fFsu+6C9EHYgxaRHbVDRkd5YdO c38Q== 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 y22-v6si4413716pll.366.2018.04.16.07.53.58; Mon, 16 Apr 2018 07:54:11 -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 S1753060AbeDPOwU convert rfc822-to-8bit (ORCPT + 99 others); Mon, 16 Apr 2018 10:52:20 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:45031 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751183AbeDPOwS (ORCPT ); Mon, 16 Apr 2018 10:52:18 -0400 Received: by mail-wr0-f193.google.com with SMTP id u46so26866312wrc.11; Mon, 16 Apr 2018 07:52:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=oCTdOorwKXcZt1U73YYwMM1HC2MUDfvGK4NExKmYwoU=; b=HSTQBBHWXP85CmCjl9bHz/hflkLwPc06mXzAhTcfCgpuYE7bKmrGIf+f46VZmvm4ee Y3EeXrt1/cMH2KuiSfgE3qnp7rI9/qX0UROYR+FLsByrfNOhyUHbc2MwQ3/HoLHlMoD8 qEJ+YcOemisos5nVQWkeH4R22tosYwMm2u6aSo/VNJWfnWYEZhOy14B/NQT/aSu8UqIq FJHoeqSnBjyzqh81L5ezSeWCB+b//Rh8nWX8Lu4B//WmdgXmmoMgdu6pBXB/D9TV/nVZ DIgh6fbnwUM084n0II4KRGZ1LAXzWBrY8Osvj9ixG28UOd73Ux3NepvB/rWrR4CcIk0e S8JA== X-Gm-Message-State: ALQs6tDmwl7IsgclZn9lzPtqDRPZP/ckMyudl9bCv/cCQlMgR4dNCLo/ FxPuA8f0CiVTMWfJstQYhUk6s0Ml X-Received: by 10.80.167.101 with SMTP id h92mr15986054edc.218.1523890336526; Mon, 16 Apr 2018 07:52:16 -0700 (PDT) Received: from mail-wr0-f181.google.com (mail-wr0-f181.google.com. [209.85.128.181]) by smtp.gmail.com with ESMTPSA id e3sm1150286edl.43.2018.04.16.07.52.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Apr 2018 07:52:16 -0700 (PDT) Received: by mail-wr0-f181.google.com with SMTP id q6so14777394wrd.6; Mon, 16 Apr 2018 07:52:16 -0700 (PDT) X-Received: by 10.28.15.78 with SMTP id 75mr10257365wmp.16.1523890335816; Mon, 16 Apr 2018 07:52:15 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.142.19 with HTTP; Mon, 16 Apr 2018 07:51:55 -0700 (PDT) In-Reply-To: <20180416143130.tls6xtcq3hsv7u7f@flea> References: <20180411141641.14675-1-icenowy@aosc.io> <20180411141641.14675-4-icenowy@aosc.io> <20180412145628.iaaeue2imiijwx5d@flea> <20180416143130.tls6xtcq3hsv7u7f@flea> From: Chen-Yu Tsai Date: Mon, 16 Apr 2018 22:51:55 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [linux-sunxi] Re: [PATCH 3/5] net: stmmac: dwmac-sun8i: Allow getting syscon regmap from device To: Maxime Ripard Cc: Icenowy Zheng , Rob Herring , Giuseppe Cavallaro , Corentin Labbe , netdev , devicetree , linux-arm-kernel , linux-kernel , linux-sunxi Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 16, 2018 at 10:31 PM, Maxime Ripard wrote: > On Thu, Apr 12, 2018 at 11:23:30PM +0800, Chen-Yu Tsai wrote: >> On Thu, Apr 12, 2018 at 11:11 PM, Icenowy Zheng wrote: >> > 于 2018年4月12日 GMT+08:00 下午10:56:28, Maxime Ripard 写到: >> >>On Wed, Apr 11, 2018 at 10:16:39PM +0800, Icenowy Zheng wrote: >> >>> From: Chen-Yu Tsai >> >>> >> >>> On the Allwinner R40 SoC, the "GMAC clock" register is in the CCU >> >>> address space; on the A64 SoC this register is in the SRAM controller >> >>> address space, and with a different offset. >> >>> >> >>> To access the register from another device and hide the internal >> >>> difference between the device, let it register a regmap named >> >>> "emac-clock". We can then get the device from the phandle, and >> >>> retrieve the regmap with dev_get_regmap(); in this situation the >> >>> regmap_field will be set up to access the only register in the >> >>regmap. >> >>> >> >>> Signed-off-by: Chen-Yu Tsai >> >>> [Icenowy: change to use regmaps with single register, change commit >> >>> message] >> >>> Signed-off-by: Icenowy Zheng >> >>> --- >> >>> drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 48 >> >>++++++++++++++++++++++- >> >>> 1 file changed, 46 insertions(+), 2 deletions(-) >> >>> >> >>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c >> >>b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c >> >>> index 1037f6c78bca..b61210c0d415 100644 >> >>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c >> >>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c >> >>> @@ -85,6 +85,13 @@ const struct reg_field old_syscon_reg_field = { >> >>> .msb = 31, >> >>> }; >> >>> >> >>> +/* Specially exported regmap which contains only EMAC register */ >> >>> +const struct reg_field single_reg_field = { >> >>> + .reg = 0, >> >>> + .lsb = 0, >> >>> + .msb = 31, >> >>> +}; >> >>> + >> >> >> >>I'm not sure this would be wise. If we ever need some other register >> >>exported through the regmap, will have to change all the calling sites >> >>everywhere in the kernel, which will be a pain and will break >> >>bisectability. >> > >> > In this situation the register can be exported as another >> > regmap. Currently the code will access a regmap with name >> > "emac-clock" for this register. >> > >> >> >> >>Chen-Yu's (or was it yours?) initial solution with a custom writeable >> >>hook only allowing a single register seemed like a better one. >> > >> > But I remember you mentioned that you want it to hide the >> > difference inside the device. >> >> The idea is that a device can export multiple regmaps. This one, >> the one named "gmac" (in my soon to come v2) or "emac-clock" here, >> is but one of many possible regmaps, and it only exports the register >> needed by the GMAC/EMAC. > > I'm not sure this would be wise either. There's a single register map, > and as far as I know we don't have a binding to express this in the > DT. This means that the customer and provider would have to use the > same name, but without anything actually enforcing it aside from > "someone in the community knows it". > > This is not a really good design, and I was actually preferring your > first option. We shouldn't rely on any undocumented rule. This will be > easy to break and hard to maintain. So, one regmap per device covering the whole register range, and the consumer knows which register to poke by looking at its own compatible. That sound right? ChenYu