Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp10962992rwp; Fri, 21 Jul 2023 07:22:46 -0700 (PDT) X-Google-Smtp-Source: APBJJlG9VXgu+MOtVI+t5mNpGN9Eb1CdW5MSH5B9nCZy9+YNXUUKCjOhmCEHwj1HlIoUi4f5vd3i X-Received: by 2002:a05:6a00:2483:b0:67b:2eba:bed4 with SMTP id c3-20020a056a00248300b0067b2ebabed4mr238317pfv.14.1689949365673; Fri, 21 Jul 2023 07:22:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689949365; cv=none; d=google.com; s=arc-20160816; b=ZpN5LeTjT29MgqYUKADUNDfA8VVvsIKB6YvyDwg7zXJ5e0RMuQX4Y8HyUcVa7DVKZP 3Dz+efmAVSMPZLTqi3+FsAcM2/YwU3mGgDh6joxc7Bf/LQwkWLcy7U/xdW8TGdP/OVgM V88fEyjaFudj6JaQxlwamIdJ4GNo34PBlrEzCp1iDwx9wtVyAqDcdp9JR/qf97u369U2 JtMa/LzaJQFN7gEG3ZX9jpwsKTB2nMsDHPPeqWp3tRMnLvrJ+p8bsCwGP8L1QqcawiFu 1LM34UW27ScTA2UCIhdW8qUSG6cGLCvRyMJDJMHqHxBnoY7CLo2r+p2R4fDOFaoztut3 r27w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=9t8TEJHN5BPjdL0wAzGab9+uwAYqaAZLCXYeDcXuU4I=; fh=thJwGOIztJkBzixU3MCKh5ZXDkYcRa6EV7s504ufYIw=; b=zLUeko4sdo/oO1ZPErbJnVJAFD1Eimi31f7+Zks8BAUYJTQLJF9WBznTjSChHWIHHk Yy/mbJavqajs+GcU12gaRcjtKGBUPEzQCfyBBNcB3Muri5ZIdECytDnvC+OmZhNdDOvE 4arJgofF28LO+N8MqMAfjq0hZs1oFn/p3PtYwDgqg7joKbFznSxIIlpaR/lB0CjnbtXg xJ39AlpyivQzL6wt0DH+gUYssEvWa8vMGeCwvaDDHVR3B+nGEk4NgAEyx/x/gq8uOSEB IZOB147KN0+pl5v+MNUb+/KNJAWTm8sAT5Vu3r8rMCHo7sNVHtMMcv7TSnNOGFY9+AkF qznw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fa22-20020a056a002d1600b0066c64dee35csi3231021pfb.215.2023.07.21.07.22.32; Fri, 21 Jul 2023 07:22:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231701AbjGUOOW (ORCPT + 99 others); Fri, 21 Jul 2023 10:14:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231641AbjGUOOS (ORCPT ); Fri, 21 Jul 2023 10:14:18 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E5A32D45; Fri, 21 Jul 2023 07:14:14 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6600,9927,10778"; a="351909950" X-IronPort-AV: E=Sophos;i="6.01,220,1684825200"; d="scan'208";a="351909950" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2023 07:14:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10778"; a="794968734" X-IronPort-AV: E=Sophos;i="6.01,220,1684825200"; d="scan'208";a="794968734" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga004.fm.intel.com with ESMTP; 21 Jul 2023 07:13:59 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1qMqtH-007oK8-1x; Fri, 21 Jul 2023 17:13:55 +0300 Date: Fri, 21 Jul 2023 17:13:55 +0300 From: Andy Shevchenko To: nikita.shubin@maquefel.me Cc: Hartley Sweeten , Lennert Buytenhek , Alexander Sverdlin , Russell King , Lukasz Majewski , Linus Walleij , Bartosz Golaszewski , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Michael Turquette , Stephen Boyd , Daniel Lezcano , Thomas Gleixner , Alessandro Zummo , Alexandre Belloni , Wim Van Sebroeck , Guenter Roeck , Sebastian Reichel , Thierry Reding , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , Mark Brown , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vinod Koul , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Damien Le Moal , Sergey Shtylyov , Dmitry Torokhov , Arnd Bergmann , Olof Johansson , soc@kernel.org, Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Michael Peters , Kris Bahnsen , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-clk@vger.kernel.org, linux-rtc@vger.kernel.org, linux-watchdog@vger.kernel.org, linux-pm@vger.kernel.org, linux-pwm@vger.kernel.org, linux-spi@vger.kernel.org, netdev@vger.kernel.org, dmaengine@vger.kernel.org, linux-mtd@lists.infradead.org, linux-ide@vger.kernel.org, linux-input@vger.kernel.org, alsa-devel@alsa-project.org Subject: Re: [PATCH v3 07/42] soc: Add SoC driver for Cirrus ep93xx Message-ID: References: <20230605-ep93xx-v3-0-3d63a5f1103e@maquefel.me> <20230605-ep93xx-v3-7-3d63a5f1103e@maquefel.me> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230605-ep93xx-v3-7-3d63a5f1103e@maquefel.me> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_SOFTFAIL,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 Thu, Jul 20, 2023 at 02:29:07PM +0300, Nikita Shubin via B4 Relay wrote: > From: Nikita Shubin > > This adds an SoC driver for the ep93xx. Currently there > is only one thing not fitting into any other framework, > and that is the swlock setting. > > It's used for clock settings and restart. > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include ... > +#define EP93XX_SYSCON_SYSCFG_REV_MASK 0xf0000000 GENMASK() (you will need bits.h, and looking below you seem missed it anyway) ... > + spin_lock_irqsave(&ep93xx_swlock, flags); > + > + regmap_read(map, EP93XX_SYSCON_DEVCFG, &val); > + val &= ~clear_bits; > + val |= set_bits; > + regmap_write(map, EP93XX_SYSCON_SWLOCK, EP93XX_SWLOCK_MAGICK); > + regmap_write(map, EP93XX_SYSCON_DEVCFG, val); Is this sequence a must? I.o.w. can you first supply magic and then update devcfg? > + spin_unlock_irqrestore(&ep93xx_swlock, flags); ... > +void ep93xx_swlocked_update_bits(struct regmap *map, unsigned int reg, > + unsigned int mask, unsigned int val) > +{ Same Q as above. > +} ... > + int rev = ep93xx_chip_revision(map); > + > + switch (rev) { switch(ep93xx_chip_revision(map)) ? > + case EP93XX_CHIP_REV_D0: > + return "D0"; > + case EP93XX_CHIP_REV_D1: > + return "D1"; > + case EP93XX_CHIP_REV_E0: > + return "E0"; > + case EP93XX_CHIP_REV_E1: > + return "E1"; > + case EP93XX_CHIP_REV_E2: > + return "E2"; > + default: > + return "unknown"; > + } ... > +static unsigned long __init calc_pll_rate(u64 rate, u32 config_word) > +{ > + rate *= ((config_word >> 11) & GENMASK(4, 0)) + 1; /* X1FBD */ > + rate *= ((config_word >> 5) & GENMASK(5, 0)) + 1; /* X2FBD */ > + do_div(rate, (config_word & GENMASK(4, 0)) + 1); /* X2IPD */ > + rate >>= ((config_word >> 16) & 3); /* PS */ GENMASK() > + return rate; > +} ... > + /* Multiplatform guard, only proceed on ep93xx */ > + if (!of_machine_is_compatible("cirrus,ep9301")) > + return 0; Why? > + map = syscon_regmap_lookup_by_compatible("cirrus,ep9301-syscon"); > + if (IS_ERR(map)) > + return PTR_ERR(map); Is this not enough? ... > + if (!(value & EP93XX_SYSCON_CLKSET1_NBYP1)) > + clk_pll1_rate = EP93XX_EXT_CLK_RATE; > + else > + clk_pll1_rate = calc_pll_rate(EP93XX_EXT_CLK_RATE, value); Positive conditionals in if-else are easier to be read. ... > + clk_f_div = fclk_divisors[(value >> 25) & 0x7]; > + clk_h_div = hclk_divisors[(value >> 20) & 0x7]; > + clk_p_div = pclk_divisors[(value >> 18) & 0x3]; GENMASK() in all three? ... > + np = of_find_node_by_path("/"); > + of_property_read_string(np, "model", &machine); > + if (machine) > + attrs->machine = kstrdup(machine, GFP_KERNEL); No error check? > + of_node_put(np); Looks like NIH of_flat_dt_get_machine_name(). Can you rather make use of it as it's done, e.g., here arch/riscv/kernel/setup.c:251? -- With Best Regards, Andy Shevchenko