Received: by 10.192.165.156 with SMTP id m28csp2092285imm; Thu, 12 Apr 2018 08:29:20 -0700 (PDT) X-Google-Smtp-Source: AIpwx487feuwdIZcqQ3RscXyC3sLAc7hgTgds21gwzPEshQK7RksDAQROHsr+BVcO46qjqkzbFUL X-Received: by 2002:a17:902:5381:: with SMTP id c1-v6mr1532721pli.234.1523546960610; Thu, 12 Apr 2018 08:29:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523546960; cv=none; d=google.com; s=arc-20160816; b=0KqNyHUichN8bNTQQgqVQGHpptSKiakhnL3j+oB9XumXSnnuLGRAgOXeD0Ts23md/e WgxklrmElMJ2gbHs/u0u2Kkc6KqckVeGeIIdZlDNCAyo2ggGIhLtwFXH/964IWZ3gVBs DGWIxLH9H6rB8R+g8e8NmxES9ST2zdt3P2lLningvlctcsVtAhEvOP4kEhBjKafpZFcG 0QGfdhinGDSnD2AYFlWA+iSgyZio2L9PdNiSoU5wgUp7NvH+yKHo7V6IXfDBO9+seKs9 TxctsoHKEoifEhpNZsMjh/wUxe353q7V+6ZON6Rvo+/6En+CqC2fbpf/yZK9vbZkJZwb adgQ== 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=sXoyho6ka0QmVZzLhuLSz/qWiQMRtGajISGqL8sQep8=; b=QCKifapV0cru1UzHNeCowMatdy5UMXU5QkPX9I5ldle7EQQD2b9O/nC3vOdhRIMN+i pIjt687d1ifK7UYd20pt6n15EAlAKJstDqddqFseGf48CIfW2eCSnY6sfWAAc3HVy4v5 p1ubE+d4l59DYI90qdixWONn9U9G1D916FTrdyLjSJSX6q9C0e+jL25bVqcBKJhVKSF0 a7rxVdtLjjue2tFxDwu7eK0u207Oah0yxw23IGtfvyseRxc5mTMdL6jhBowosOM1WTEj 2clzWJCrK42ix7ATgOScEMjWa3kV83zhVhGPyvxVQBXoFPp7i2OPHMaDhbOEeNT6y4/H 97kA== 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 f1si2337610pgq.806.2018.04.12.08.28.43; Thu, 12 Apr 2018 08:29:20 -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 S1753966AbeDLPX4 convert rfc822-to-8bit (ORCPT + 99 others); Thu, 12 Apr 2018 11:23:56 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:54420 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753051AbeDLPXx (ORCPT ); Thu, 12 Apr 2018 11:23:53 -0400 Received: by mail-wm0-f65.google.com with SMTP id r191so12400444wmg.4; Thu, 12 Apr 2018 08:23:52 -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=r1/NCcNvP9E3hopNFHJAXVxH1eecrwBVPfyTQ3WKd+Y=; b=k9EjBQ0t0dFaVsocu9KHMZv4RbPm3FYNx3dG4fpj7Y6tyqkPNHYbeGVtTvdYb9Qm2K 8N7R1e0gx81jPYxk+QApPlm+7FZP4Nm10FjBs5FSMEN39Efls0hbr7AUYv6oYiKrXm++ vT6ugu2UfYO5o9/AioyjlN8Unr7Tz0oG6gTPhnjjTqYGEqqRDEo4CWvTJIe8YuLt/I+b q7vQg+ji0TEHDuKCeJG+w4FumwUYPXDKOBJJgB03+EN6ANdJ5F/IbKbHM+hAe3DB6TTe hmOmuyE3nIwCR7tr0Ev8pXv6jB4DqXmHebGxrtYIw49i4qvf14xnTHgeU5Mdukxy2kfI q7SQ== X-Gm-Message-State: ALQs6tD5d+EFZAdheY3aTpZbK91a+7cYPqjeSC3AX9tgNBJ1TCUFj4VM gECA587sP86OlcZaZMJQDZFnbsJY X-Received: by 10.80.154.34 with SMTP id o31mr14996449edb.161.1523546631796; Thu, 12 Apr 2018 08:23:51 -0700 (PDT) Received: from mail-wr0-f176.google.com (mail-wr0-f176.google.com. [209.85.128.176]) by smtp.gmail.com with ESMTPSA id b36sm2250593edd.81.2018.04.12.08.23.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Apr 2018 08:23:51 -0700 (PDT) Received: by mail-wr0-f176.google.com with SMTP id u46so5513625wrc.11; Thu, 12 Apr 2018 08:23:50 -0700 (PDT) X-Received: by 10.223.184.135 with SMTP id i7mr1134702wrf.105.1523546630665; Thu, 12 Apr 2018 08:23:50 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.142.19 with HTTP; Thu, 12 Apr 2018 08:23:30 -0700 (PDT) In-Reply-To: References: <20180411141641.14675-1-icenowy@aosc.io> <20180411141641.14675-4-icenowy@aosc.io> <20180412145628.iaaeue2imiijwx5d@flea> From: Chen-Yu Tsai Date: Thu, 12 Apr 2018 23:23:30 +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: Icenowy Zheng Cc: Maxime Ripard , 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 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. Hi, 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. IMHO it is highly unlikely the same piece of hardware would need a second register from the same device. A more likely situation would be it needs another register from a different device, like on the H6 where the "internal PHY" is not so internal from a system bus point of view. ChenYu