Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1688770pxb; Wed, 9 Feb 2022 02:14:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJw6F3hlUS/PjEHi/Uyp3mDzZoyUWESFzf3CAt0C9c63wUh6JJnQcfQlRNbXq6m81oCsN9GM X-Received: by 2002:a63:8948:: with SMTP id v69mr1329413pgd.550.1644401681828; Wed, 09 Feb 2022 02:14:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644401681; cv=none; d=google.com; s=arc-20160816; b=gkr2EGX16zfAJwTA/4P7w/0nVVznkt2AtduOPRzuB5Kdf+4Z0uyVvmpjb3CUqF+WO/ xE3ePZKaYdmTYrRdwOQk9uwDKEqEr4NT1+yMdTSeh96dSgEQkskj4wZT+7C0NueBpsnt uNuunJsG9LSMsjStLe+8Ro5CsO8olNajD/1mfIk/hpPTBbqGEN/E0P70+Lj3HXf5Mh1q 7c4zVfdRnol+PMNh0gRZRPpoSkU/FuSPeC92VU9ttf3gA6JizOWHtSTQ75ikaiM3jf6i Qmb2Gc7F9o+TUO62KmoDgXQdjShZzLPRn1VIMYKJVXzZ/DZnGpjtS69uO0lqpzBRDpYe Ol/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=Ui/6owStfQRYY+YD9HVYrRMZ2Sy2yY8RPY3JJ3hVfCQ=; b=bO7lKU129o00cC7KKTs0UIhwej8GU2uX9T/3a0cc9Z00v73LIPJzlYtILp9BAP57jN k6YBEhEki18r+ZbcJ0ThNAmnjtoRfVJFKN3HV6nue9PPgi/XM1itIKION5qbzNxwUiLA a2zRQYaCVbuGebylqFDdPt3saoSyyCrCbCocaGa75mzOBQKrub+TIaFb2fCzdY19YBV5 kg1Ph5i4HxlgI9REAt8XJTgqADFPaxNtlGnwhWrhySt4yiyigwhu45NVnl5nUxDmRj5s 8rBzZ7gdar6kXELrY6c2wV+hAtJMrN37/vncnHV28VZzuuTv2UcLedD+mxqHH3JjVRpc 3Sjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=aMkxK1uE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id l7si14286025pfd.246.2022.02.09.02.14.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 02:14:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=aMkxK1uE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C6226E04AD92; Wed, 9 Feb 2022 01:16:32 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354742AbiBHJ3z (ORCPT + 99 others); Tue, 8 Feb 2022 04:29:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237653AbiBHJ3w (ORCPT ); Tue, 8 Feb 2022 04:29:52 -0500 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2FF9C03FEC0 for ; Tue, 8 Feb 2022 01:29:51 -0800 (PST) Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id E0F873F17B for ; Tue, 8 Feb 2022 09:29:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1644312588; bh=Ui/6owStfQRYY+YD9HVYrRMZ2Sy2yY8RPY3JJ3hVfCQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=aMkxK1uEQsxaK/7peR0onjb7Mhj24OibpC4DvgujfsMwY/l52Oc+se79O1LC3ojFz fvxCN3K2wdSM02R86k/YaREQrx6i780bs4DSjUL0SuW4YXnLAAz/uPOa1EB+AS+auZ cF5Bvd6Sf6MSIdH4mGzG2PFtmEIgNunZzbFZIfCagfKW8bYCPqP2sjIwmvE0fy+r2O if+PgMwWZDgLCcwdXVXp+JTly0/8tR6du/djkZPKtCoH8xoN+3iPXRpFmwOzyZPz2n ypLTzX1ibGYumwvOoKdN/9M0WNQSyDSMELOyr5034rN+wtudwvMzwF1x+NykFJ9E37 1b9SD9oNNCiTQ== Received: by mail-ed1-f69.google.com with SMTP id w3-20020a50c443000000b0040696821132so9342223edf.22 for ; Tue, 08 Feb 2022 01:29:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=Ui/6owStfQRYY+YD9HVYrRMZ2Sy2yY8RPY3JJ3hVfCQ=; b=Hl3Y7PxNu61sJ0ecmdFPSSTclR16Tp3/C0AlBma3s0GoVdzBTqCKEtz8djfMrUlRuT uIVAyIFFBz3VkJKVuvQx2s6V45BPdKRG9Row352nrXo/GER4zk4DZ6YMFOsGtVTnprrs Vf0DgA4jr3OTQp6zpzAyDz0T05TneHMV2mGCXapODwlVwndeQRcFQLjJ7mZlrvIZ/f0S FOuHlojHiwuKtC0R3I0PQ3gbtsk9ZI82ECiH8K+BxA4GLwnr2Hpgs0iga9h9pZdw5Vsr 3XF5LZuXiujB3gwFs21SyzPpBiYq8240dHEnEcl1Gk9EqR7lyZ6vL2cLEiW9AMjw2DwK Mfqg== X-Gm-Message-State: AOAM531dZgI2hd/bqWeykmK9wNSzXniBJ5SyNC4ALwoPD1gNtKps7wFV lU0GpaGVJMiGC1GHgjS83GBYKwoufTyDIBFtLY70yoyfnF11e9bbx8T3oM/YLYx5VCO3valH8Y7 stuaQ69wuFi3IX/BMcUvut/Y5N316aBz7MKoTOcgU7g== X-Received: by 2002:a17:907:7246:: with SMTP id ds6mr2993404ejc.762.1644312588570; Tue, 08 Feb 2022 01:29:48 -0800 (PST) X-Received: by 2002:a17:907:7246:: with SMTP id ds6mr2993375ejc.762.1644312588328; Tue, 08 Feb 2022 01:29:48 -0800 (PST) Received: from [192.168.0.93] (xdsl-188-155-168-84.adslplus.ch. [188.155.168.84]) by smtp.gmail.com with ESMTPSA id t22sm6339403edv.105.2022.02.08.01.29.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 08 Feb 2022 01:29:47 -0800 (PST) Message-ID: <36cc734d-2120-5834-27a9-5bd37e14d862@canonical.com> Date: Tue, 8 Feb 2022 10:29:46 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v1 6/6] i2c: npcm: Support NPCM845 Content-Language: en-US To: Tali Perry , Tyrone Ting Cc: avifishman70@gmail.com, Tomer Maimon , Patrick Venture , Nancy Yuen , Benjamin Fair , Rob Herring , semen.protsenko@linaro.org, yangyicong@hisilicon.com, Wolfram Sang , jie.deng@intel.com, sven@svenpeter.dev, bence98@sch.bme.hu, lukas.bulwahn@gmail.com, arnd@arndb.de, olof@lixom.net, Andy Shevchenko , Tali Perry , Avi Fishman , tomer.maimon@nuvoton.com, KWLIU@nuvoton.com, JJLIU0@nuvoton.com, kfting@nuvoton.com, OpenBMC Maillist , Linux I2C , devicetree , Linux Kernel Mailing List References: <20220207063338.6570-1-warp5tw@gmail.com> <20220207063338.6570-7-warp5tw@gmail.com> From: Krzysztof Kozlowski In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/02/2022 10:22, Tali Perry wrote: >> On 08/02/2022 09:51, Tali Perry wrote: >>>> On 08/02/2022 08:14, Tali Perry wrote: >>>>>> Subject: Re: [PATCH v1 6/6] i2c: npcm: Support NPCM845 >>>>>> >>>>>> On 07/02/2022 13:00, Jonathan Neuschäfer wrote: >>>>>>> Hello, >>>>>>> >>>>>>> On Mon, Feb 07, 2022 at 02:33:38PM +0800, Tyrone Ting wrote: >>>>>>>> From: Tyrone Ting >>>>>>>> >>>>>>>> NPCM8XX uses a similar i2c module as NPCM7XX. >>>>>>>> The only difference is that the internal HW FIFO is larger. >>>>>>>> >>>>>>>> Related Makefile and Kconfig files are modified to support as well. >>>>>>>> >>>>>>>> Fixes: 56a1485b102e ("i2c: npcm7xx: Add Nuvoton NPCM I2C controller >>>>>>>> driver") >>>>>>> >>>>>>> It's not really a bug fix, but rather an additional feature. >>>>>>> Therefore, I suggest removing the Fixes tag from this patch. >>>>>>> >>>>>>>> Signed-off-by: Tyrone Ting >>>>>>>> Signed-off-by: Tali Perry >>>>>>>> --- >>>>>>> [...] >>>>>>>> /* init register and default value required to enable module */ >>>>>>>> #define NPCM_I2CSEGCTL 0xE4 >>>>>>>> +#ifdef CONFIG_ARCH_NPCM7XX >>>>>>>> #define NPCM_I2CSEGCTL_INIT_VAL 0x0333F000 >>>>>>>> +#else >>>>>>>> +#define NPCM_I2CSEGCTL_INIT_VAL 0x9333F000 >>>>>>>> +#endif >>>>>>> >>>>>>> This is going to cause problems when someone tries to compile a kernel >>>>>>> that runs on both NPCM7xx and NPCM8xx (because the driver will then >>>>>>> only work on NPCM7xx). >>>>>> >>>>>> Yes, good catch. >>>>>> >>>>>> The NPCM7XX is multiplatform, I guess NPCM8xx will be as well, so this looks like an invalid code. How such code is supposed to work on multiplatform kernel? >>>>>> >>>>> >>>>> NPCM7xx and NPCM8xx are very different devices. >>>>> They share same driver sources for some of the modules but it's not ABI. >>>>> Users cannot compile a single kernel with two separate DTS. >>>>> In case of the i2c controller, the npcm7xx has a 16 byte HW FIFO, >>>>> and the NPCM8xx has 32 bytes HW FIFO. >>>>> This also means that registers fields are slightly different. >>>>> For init data we can move it to the DTS, but register field sizes >>>>> can't be handled with this approach. >>>>> >>>> >>>> What do you mean they cannot compile a kernel with different DTS? Of >>>> course they can - when we talk about multiplatform sub-architectures! >>>> Maybe there is something specific in NPCMxxx which stops it but then it >>>> should not be marked multiplatform. >>>> >>> >>> >>> NCPM7xx is ARM32 bit (dual core Cortex A9) >>> NPCM8xx is ARM64 bit (quad core Cortex A35) >>> >>> They have completely different architecture so not ABI compliant. >>> I2C module is similar, but the devices are quite different and have >>> separate architectures. >> >> OK, in such case usually you indeed can't have both. :) >> >>> Sorry for the confusion. >>> This is the first patch we try to upstream for NPCM8xx. >>> In the coming weeks we will upstream the architecture of NPCM8xx as well. >> >> Still, ARCH_XXX should not be hard-coded in the drivers to change the >> driver's behavior, even if driver won't be used simultaneously. It >> breaks all design principles and prevents any further re-use if a new >> use case appears. >> >> You can use "ifdef ARCH_XXX" to skip building of some parts of the >> driver, but it's not the case here. >> > > Correct, the main change is in FIFO size: > +#ifdef CONFIG_ARCH_NPCM7XX > #define I2C_HW_FIFO_SIZE 16 > +#else > +#define I2C_HW_FIFO_SIZE 32 > +#endif /* CONFIG_ARCH_NPCM7XX */ > > NPCM7XX will always have 16 bytes, all the next gens will have 32. > > This impact some registers sizes, like this one: > > +#ifdef CONFIG_ARCH_NPCM7XX > #define NPCM_I2CRXF_STS_RX_BYTES GENMASK(4, 0) > +#else > +#define NPCM_I2CRXF_STS_RX_BYTES GENMASK(5, 0) > +#endif /*CONFIG_ARCH_NPCM7XX*/ > > For this, the FIFO size should be defined before compilation. No, it does not have to. We solved it numerous time with quirks or per-chip-drvdata. It's common. > I also don't want to let users select FIFO size per architecture. > NPCM7XX has 16, NPCM8XX has 32. This is not a user selection. > It's part of the arch. I understand it is part of the architecture but why Nuvoton is different than other architectures and requires special treatment here? With most of the drivers, regardless of possibility of running same build on different hardware, we strive to make it ifdef-independent. Please run: git grep ARCH -- drivers/i2c/busses/*c and see how many of such ifdef patterns you see. You also won't find them if you grep for CONFIG... The driver should be designed in portable way. The driver should not have architecture-dependent code. Best regards, Krzysztof