Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B628BC25B4E for ; Tue, 24 Jan 2023 08:01:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232559AbjAXIBD (ORCPT ); Tue, 24 Jan 2023 03:01:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232620AbjAXIBA (ORCPT ); Tue, 24 Jan 2023 03:01:00 -0500 Received: from sender4-op-o14.zoho.com (sender4-op-o14.zoho.com [136.143.188.14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4291130292 for ; Tue, 24 Jan 2023 00:00:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674547182; cv=none; d=zohomail.com; s=zohoarc; b=SGeRpqUb/UpVpw5MIvNg/ttxmx+6Pu+9GzMy2XQfGXWrE0Ru6MZAyb7KxdSMFUWKcY/43++6qWYpVN9yN2xd1/QXO6ZDxpL8wiwJEErLkle2VSC9Hqt3nhUN8QdGxk8u7bkGP9ZWD+A1m8oLYruHLYdXnQGQx5V3+1iirAqzUdA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674547182; h=Content-Type:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=/fyEdHbRGpDWfMEi9dn8qZpRjYXX/Uzc+C+RYtUDkZU=; b=Yv3K8uJnzyr4axYNc2IKs6qiDgi5Xr73tmAPP142f03UdkJhx2igZWQoLbtDhJipLLFQTGz4PKKJ6s9aRmYSNaZVb43Rit99uCigtSxXDrwTDbN3E6QiU8RCmBpCCenvBGAqe86DKDB47S6PoPjlc1s16E5STKFzZ1FianiQ0cc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=linux.beauty; spf=pass smtp.mailfrom=me@linux.beauty; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1674547182; s=zmail; d=linux.beauty; i=me@linux.beauty; h=Date:Date:Message-ID:From:From:To:To:Cc:Cc:Subject:Subject:In-Reply-To:References:MIME-Version:Content-Type:Message-Id:Reply-To; bh=/fyEdHbRGpDWfMEi9dn8qZpRjYXX/Uzc+C+RYtUDkZU=; b=URNYEPcx5AjbBGkQupZzLgmTsXmhut5q3OXcQVl+bc0ACsjaRefNgmEIVk0G1pTO ttaBDRPc1U9xi3DGMMxBOO8LyAViJVw+U0ogS0NRkGrjNSuQkzZv7Fh1zrQGIP7mgDw WTqwDU0UgjzzwbrgqG1N2UWb9moMLzlbzEzSU+aY= Received: from lchen-xiaoxin.linux.beauty (122.96.40.54 [122.96.40.54]) by mx.zohomail.com with SMTPS id 1674547180315174.69971912538972; Mon, 23 Jan 2023 23:59:40 -0800 (PST) Date: Tue, 24 Jan 2023 15:58:53 +0800 Message-ID: <871qnkicsi.wl-me@linux.beauty> From: Li Chen To: "Arnd Bergmann" Cc: "Li Chen" , Heiko =?ISO-8859-1?Q?St=FCbner?= , "Lubomir Rintel" , "Conor.Dooley" , "Robert Jarzmik" , "Sven Peter" , "Yinbo Zhu" , "Brian Norris" , "Hitomi Hasegawa" , "open list" , "moderated list:ARM/Ambarella SoC support" Subject: Re: [PATCH 06/15] soc: add Ambarella driver In-Reply-To: <85b86d06-c63c-4481-a3dd-16b72572a5ee@app.fastmail.com> References: <20230123073305.149940-1-lchen@ambarella.com> <20230123073305.149940-7-lchen@ambarella.com> <85b86d06-c63c-4481-a3dd-16b72572a5ee@app.fastmail.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-ZohoMailClient: External Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Arnd, On Mon, 23 Jan 2023 16:29:06 +0800, Arnd Bergmann wrote: > > On Mon, Jan 23, 2023, at 08:32, Li Chen wrote: > > This driver add soc_id support for Ambarella, > > which is stored inside "cpuid" AXI address mapping. > > > > Also provide sys_config(POC, aka power on configuration) > > for other drivers. > > > > Signed-off-by: Li Chen > > The soc_id support looks ok > > > Change-Id: I4869a3497366ac7779e792835f8e0309239036a8 > > Please drop these lines in the submission, the IDs are > not reachable outside of your own git, so we don't want > these to show up in the public history. Sorry, I forgot to remove this. > > +static struct ambarella_soc_id { > > + unsigned int id; > > + const char *name; > > + const char *family; > > +} soc_ids[] = { > > + { 0x00483245, "s6lm", "10nm", }, > > +}; > > I would suggest something more descriptive in the "family" > field to let users know they are on an Ambarella SoC. > > Maybe just "Ambarella 10nm". There is a "pr_info("Ambarella SoC %s detected\n", soc_dev_attr->soc_id);" in this file, I think this should be enough, right? > > +static int __init ambarella_socinfo_init(void) > > +{ > > + struct soc_device_attribute *soc_dev_attr; > > + struct soc_device *soc_dev; > > + struct device_node *np; > > + struct regmap *cpuid_regmap; > > + unsigned int soc_id; > > + > > + cpuid_regmap = syscon_regmap_lookup_by_compatible("ambarella,cpuid"); > > + if (IS_ERR(cpuid_regmap)) > > + return PTR_ERR(cpuid_regmap); > > Is there anything else in this syscon node? If the block > of registers only contains the identification bits, you > could just make this file a platform_driver that binds to > the node instead of using a syscon. > > If there are other unrelated registers in there, the compatible > string should probably be changed to better describe the > entire area based on the name in the datasheet. Yeah, this block is only used for identification bits. In datasheet, it is also named "CPU ID". Other than cpuid_regmap, this driver also looks for "model" name as soc machine name: of_property_read_string(np, "model", &soc_dev_attr->machine); So I think it is not a good idea to conver it to into a platform driver. As for "syscon", I think it is still very helpful to get regmap easily. Generally speaking, I prefer regmap over void*, because it has debugfs support, so I can get its value more easily. > > +static unsigned int ambsys_config; > > + > > +unsigned int ambarella_sys_config(void) > > +{ > > + return ambsys_config; > > +} > > +EXPORT_SYMBOL(ambarella_sys_config); > > Which drivers use this bit? Can they be changed to > use soc_device_match() instead to avoid the export? sys_config is used by our nand and sd drivers. I also don't want to export, but struct soc_device_attribute/soc_device don't have private data to store it, I think there is no better way. > > +static int __init ambarella_soc_init(void) > > +{ > > + struct regmap *rct_regmap; > > + int ret; > > + > > + rct_regmap = syscon_regmap_lookup_by_compatible("ambarella,rct"); > > + if (IS_ERR(rct_regmap)) { > > + pr_err("failed to get ambarella rct regmap\n"); > > + return PTR_ERR(rct_regmap); > > + } > ... > > +arch_initcall(ambarella_soc_init); > > It is not an error to use a chip from another manufacturer, > please drop the pr_err() and return success here. Ok, good to know, thanks. But we don't have other manufacturers at least for now, and rct_regmap is need to be updated here, like sys_config and soft reboot. So I think this rct regmap is still needed. > > +#ifndef __SOC_AMBARELLA_MISC_H__ > > +#define __SOC_AMBARELLA_MISC_H__ > > + > > +extern unsigned int ambarella_sys_config(void); > > +extern struct proc_dir_entry *ambarella_proc_dir(void); > > + > > The ambarella_proc_dir looks like a stale entry that should be > removed. Ideally you should not need a private header at all. Oops, my bad. I will remove proc dir in v2. Regards, Li