From patchwork Mon Feb 27 10:57:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Paracuellos X-Patchwork-Id: 61906 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2348923wrd; Mon, 27 Feb 2023 03:01:23 -0800 (PST) X-Google-Smtp-Source: AK7set8N4SM+m5vT04UrCoNWmrOstEWFGpLaaQlFflLVTIg+SJoJXzjJeAZxisvwR0sEeHxsKETF X-Received: by 2002:a17:903:70e:b0:19c:bcae:b45d with SMTP id kk14-20020a170903070e00b0019cbcaeb45dmr12049692plb.43.1677495682874; Mon, 27 Feb 2023 03:01:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677495682; cv=none; d=google.com; s=arc-20160816; b=Qs9mujXgLHsL6qsR6GvlExCIwQBEHCLv6G42Iw5kz5Lte/02psfVohg+ieE9ER4ois FeybmPSwT3SfPjcHvePX7E0B70+huLfHJs7Cnyb0so5jn3w3NEOoJW4zptiI9BJkUkCp XppEDXftDYRYEGtrv/tBZGRd8zan020XO0v8DWEkk8bR0ri9tlSvkMPgEeWfU2exMxBX MAAsPpjA05NR2jMJmem8XtR6xvriiBAwkOBOT04HgPJYqNei4oNmT18K0DV4ip6k1oKA bHtyMmx8gyVcVkbMlccdJFOX6w+ktu0D2kw+blvIBAVUgfL/iPKUOr6B7pLo4tB3o23P sw6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tnZe77O04Wi6t00vWipQfVmBBAx1Is2ZWNAespWbpaw=; b=BuMklbh7fFgcXdRLT27RgtrRyDFftNpUl6FRc1JJBgDTsn1kMmzYPp/CqIWnVexFJ2 +3K2aDZZYqJecjE4HPUkmpl/CoXeXT7mFb9ow3DtxDJ0Y0T1KOSlOL5BfVRUfEz72Evq DMnGGmbf4Hmxnysz64f1xx93QZoLHGgJ51eiA6KqsT3Mfr/f3xRg6dmQ/WcQFpkuMuCf 1wUQgeZoe27WOrNnB91g1X28ZnHMWrp6wrXrLJ+IO8mSI3HR35KbBJFNy0zrph5ZVGAx TvDgaHEFRK1Ts544qFqGEOVgRAns4BILjELxEA5S08MeoI2gqdF+GyYQ0ucyQfhJ98Pd oteA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=gMaVrmBN; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jb1-20020a170903258100b001964122ab23si7056555plb.49.2023.02.27.03.01.10; Mon, 27 Feb 2023 03:01:22 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=gMaVrmBN; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230087AbjB0K6T (ORCPT + 99 others); Mon, 27 Feb 2023 05:58:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229874AbjB0K6M (ORCPT ); Mon, 27 Feb 2023 05:58:12 -0500 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6D529EE4; Mon, 27 Feb 2023 02:58:10 -0800 (PST) Received: by mail-wr1-x430.google.com with SMTP id bv17so5737300wrb.5; Mon, 27 Feb 2023 02:58:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tnZe77O04Wi6t00vWipQfVmBBAx1Is2ZWNAespWbpaw=; b=gMaVrmBNFyZA3PKVfkLWgfaalbAd8Iy1p5KsCpUsbm85PHastzbtDAl8dn+P55Y2/N groYWNXgCK8nz7t8AfZmBuqs9doqafgO3UCw/xy8SmtKIxcaWg0OmvVB2fyCDqqqDwNQ fFjfLswzGYYBKIZ4XFWn1ddhu6rhz6vGgmiG1738foG6NDlEbyfmRySI8TuRwknXTz4x BDUbR6S7ggOtMroz9hPVKPkiiVVrcWFyAEhCYML+HCZaR/GNaL14oFe9g3LrkPBlh3/U j2Pl9Ez6zH7ipZVs41BIyN81tEPAGN56gRzHsdQiVZjvp0/RoZZ4yMLs353NEJdIkPCY 9CLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tnZe77O04Wi6t00vWipQfVmBBAx1Is2ZWNAespWbpaw=; b=y0BELKDvHiJ1LeHHnXDDDdPcgSu6QJITBjw+wDjb0rvlnpPNHx6IbZdkwh54W3fsEi ZjFjAHt4AJjAPFuUhAbW2znaKdm8ankPKKNX69zoGyryGLNJC1QoZSQKn4QIwAUX6ym0 vZRacu6CV2KTl4m+LbmawWJV3e2sSQbUjuZFUw//Rcs5ixal4bqYSCTPaB1BHgNNpkbC 325Wcg+ovUo+9UsahC+gM9wKS03cRRSmSlJd9bk5dX7aii3Kh4I6d4uRO66yj/+YYEDa kMG3qcp4J1xGcQqcISuRv/KtkUI7AC2ybZ3kzjohtLoBuNx274GeQXvhM+kggIOh8ChJ BVzg== X-Gm-Message-State: AO0yUKVtuqIvAipHLQKS+sCv3XcJv+ZbhT41et+ZnP5TplmqSLDMAXQ5 Hhwjdo/K131S6ImuvMAMlMXmR2xLhW4= X-Received: by 2002:adf:f247:0:b0:2c7:1e00:d514 with SMTP id b7-20020adff247000000b002c71e00d514mr11484247wrp.38.1677495489091; Mon, 27 Feb 2023 02:58:09 -0800 (PST) Received: from localhost.localdomain (106.red-88-13-29.dynamicip.rima-tde.net. [88.13.29.106]) by smtp.gmail.com with ESMTPSA id a4-20020a5d5704000000b002c559843748sm6806122wrv.10.2023.02.27.02.58.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 02:58:08 -0800 (PST) From: Sergio Paracuellos To: linux-mips@vger.kernel.org Cc: tsbogend@alpha.franken.de, john@phrozen.org, linux-kernel@vger.kernel.org, git@johnthomson.fastmail.com.au Subject: [PATCH 01/12] mips: ralink: rt305x: define RT305X_SYSC_BASE with __iomem Date: Mon, 27 Feb 2023 11:57:55 +0100 Message-Id: <20230227105806.2394101-2-sergio.paracuellos@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230227105806.2394101-1-sergio.paracuellos@gmail.com> References: <20230227105806.2394101-1-sergio.paracuellos@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758981713240008315?= X-GMAIL-MSGID: =?utf-8?q?1758981713240008315?= So that RT305X_SYSC_BASE can be used later in multiple functions without needing to repeat this __iomem declaration each time Signed-off-by: Sergio Paracuellos --- arch/mips/include/asm/mach-ralink/rt305x.h | 3 ++- arch/mips/ralink/rt305x.c | 8 +++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/arch/mips/include/asm/mach-ralink/rt305x.h b/arch/mips/include/asm/mach-ralink/rt305x.h index 4d8e8c8d83ce..ef58f7bff957 100644 --- a/arch/mips/include/asm/mach-ralink/rt305x.h +++ b/arch/mips/include/asm/mach-ralink/rt305x.h @@ -43,7 +43,8 @@ static inline int soc_is_rt5350(void) return ralink_soc == RT305X_SOC_RT5350; } -#define RT305X_SYSC_BASE 0x10000000 +#define IOMEM(x) ((void __iomem *)(KSEG1ADDR(x))) +#define RT305X_SYSC_BASE IOMEM(0x10000000) #define SYSC_REG_CHIP_NAME0 0x00 #define SYSC_REG_CHIP_NAME1 0x04 diff --git a/arch/mips/ralink/rt305x.c b/arch/mips/ralink/rt305x.c index 8b095a9dcb15..135a46517763 100644 --- a/arch/mips/ralink/rt305x.c +++ b/arch/mips/ralink/rt305x.c @@ -21,11 +21,10 @@ static unsigned long rt5350_get_mem_size(void) { - void __iomem *sysc = (void __iomem *) KSEG1ADDR(RT305X_SYSC_BASE); unsigned long ret; u32 t; - t = __raw_readl(sysc + SYSC_REG_SYSTEM_CONFIG); + t = __raw_readl(RT305X_SYSC_BASE + SYSC_REG_SYSTEM_CONFIG); t = (t >> RT5350_SYSCFG0_DRAM_SIZE_SHIFT) & RT5350_SYSCFG0_DRAM_SIZE_MASK; @@ -142,14 +141,13 @@ void __init ralink_of_remap(void) void __init prom_soc_init(struct ralink_soc_info *soc_info) { - void __iomem *sysc = (void __iomem *) KSEG1ADDR(RT305X_SYSC_BASE); unsigned char *name; u32 n0; u32 n1; u32 id; - n0 = __raw_readl(sysc + SYSC_REG_CHIP_NAME0); - n1 = __raw_readl(sysc + SYSC_REG_CHIP_NAME1); + n0 = __raw_readl(RT305X_SYSC_BASE + SYSC_REG_CHIP_NAME0); + n1 = __raw_readl(RT305X_SYSC_BASE + SYSC_REG_CHIP_NAME1); if (n0 == RT3052_CHIP_NAME0 && n1 == RT3052_CHIP_NAME1) { unsigned long icache_sets; From patchwork Mon Feb 27 10:57:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Paracuellos X-Patchwork-Id: 61907 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2349224wrd; Mon, 27 Feb 2023 03:01:55 -0800 (PST) X-Google-Smtp-Source: AK7set9/q8Rl8/d4GSzIkNYZBMnBr58JmAPSHSZQajHGMkbJ3TpRJCmqA6C9iuQHJspqEPfl6lqh X-Received: by 2002:a62:1b01:0:b0:5a8:cb5f:94d4 with SMTP id b1-20020a621b01000000b005a8cb5f94d4mr22508123pfb.32.1677495714867; Mon, 27 Feb 2023 03:01:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677495714; cv=none; d=google.com; s=arc-20160816; b=UL3sSNwioPeyXtdvnZECBtXdxANzBG9GEs+IGBM7WEjJqbfRfP8txxyyoVuzL+lipa JGHGmtbHUF+ZRTq6LXZEoSjJpZoTV+hjlvGwmPrVpj7y7o+alQGQIudFQhwI/MS3uq9h Lyny2nbJlRstTDDwww7aA9R949I7CO6t3AxW2UH9hxpsqIJF97He6qVPta0dYOE+UmbX BOKpj7AoR9BeCiz552fkvmM2A09cqWoKxN9ace7iqSLm9l9ODmU1RvJF52jsMiRfaBsd gjzpxC1EWmi5w4w0H9efj6qSLf05l+5yN908eniBVkrbVIMN9BJvK73HEB75lyrcPRNK CIeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tHJ28rGYoNleFVDOkHjpHIMUmWDA43thW23nuYI9tAQ=; b=QKCnY9pzAuz3IblXFGHSCT0etqTaH4LoY/M4Hz1KguDf8YQmsh/rIvRB8vVtl3Hh6x 1yB/QqjDX620zTHZ4t1fDk+1nDg3OagM7eqo2xG0f9XsAU2rkJze6JjV4lxdJ78KQprO OYrpvSDTMIqI7Ju6Vyf2m7jwJ94KbVoxumdYeOZAnzhvURctYr5OFkOQ/5KZ3PVmheBF ruPREJ2o62gs3A0+YrayjVw3Q0Ur2DqvvNnPcbie1BAu2tiy1lBVxyILrQPuuxFjRtAv Ty/NYLysqE/lgNrqXDGVlHAzM66v4KgXBVjqyufVABhiDQN6qyH0S7oOlt71Tb8h9wOY SwmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=EK9YaRCT; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o6-20020aa79786000000b0058d8e5bbbc2si6651716pfp.146.2023.02.27.03.01.23; Mon, 27 Feb 2023 03:01:54 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=EK9YaRCT; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230060AbjB0K6Y (ORCPT + 99 others); Mon, 27 Feb 2023 05:58:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229998AbjB0K6N (ORCPT ); Mon, 27 Feb 2023 05:58:13 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AC565FC3; Mon, 27 Feb 2023 02:58:12 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id l1so2679988wry.12; Mon, 27 Feb 2023 02:58:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tHJ28rGYoNleFVDOkHjpHIMUmWDA43thW23nuYI9tAQ=; b=EK9YaRCT3GX41yW7xA+KEywd62d/Cd7kjaiaMgDyGKVCGCpmpccGv1GzezuqgCxvYv MYyIMxpt4ok71jEdzRDaAIl3ZZ/i7La22i5z7kgJSGPkBCWPa3hP5Hq0Y/eFkRRwy90h CEZdUfnZH5xkDEaOCD/bICbSng0wtPMtR/PEZxZHlObzwCE6pR7WgxBGyi40SaWmgBvw LXTgQ40vBwnwoI3PvgZnN7rgqZgTLK56i46MCDAFuKzcY/IVpOzMGHsAg7/dTKpgFMDP aku+jzeDUuurA3ykbafPss8fZFFdDFwUXMOT+IeCYyscMOfum16bW362FselW0BJl3RV +h/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tHJ28rGYoNleFVDOkHjpHIMUmWDA43thW23nuYI9tAQ=; b=45K6gcXU5JVK/yIXSc9BAXZP39zTCw1gaDuBQiy5zKeeZjNS+cfG5xBoWXDcgaVle3 GX+eZFowHigWAlKeUckFYoocQRoyWTJ3LDnckrYxcScdgNWEIJ+WMw17CK8FuFfrQ2nM +nPQAqM3bJh7d8tGjx1pe4eXItZUUr+/hEOpIDhsR2VIoSlaIyWw4Pc35iQneLTnxAPf L7kxbByegHVW90ZdxVg+xJ2rg8551g7CODG2tTEgJ7zVxV/6ZETGC2wP36ZH4yg+UXLR P1XW+ZVtjYKlh8UBqkW/QlFM43wDmW/BPjWNAU3XtYiBXJdiP9V54Pn9h4RyvRKQt5nj 5v6Q== X-Gm-Message-State: AO0yUKVMrvIe9Ghu9vmmv6LmvVcTJZrzscpmPAei5PrThaJ19lvSc5fQ 1zRaXlsVZ/r7cydkwChd2OtC4Ao4Pvc= X-Received: by 2002:a5d:48c6:0:b0:2c5:58fc:e1bb with SMTP id p6-20020a5d48c6000000b002c558fce1bbmr21073847wrs.10.1677495490197; Mon, 27 Feb 2023 02:58:10 -0800 (PST) Received: from localhost.localdomain (106.red-88-13-29.dynamicip.rima-tde.net. [88.13.29.106]) by smtp.gmail.com with ESMTPSA id a4-20020a5d5704000000b002c559843748sm6806122wrv.10.2023.02.27.02.58.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 02:58:09 -0800 (PST) From: Sergio Paracuellos To: linux-mips@vger.kernel.org Cc: tsbogend@alpha.franken.de, john@phrozen.org, linux-kernel@vger.kernel.org, git@johnthomson.fastmail.com.au Subject: [PATCH 02/12] mips: ralink: rt305x: soc queries and tests as functions Date: Mon, 27 Feb 2023 11:57:56 +0100 Message-Id: <20230227105806.2394101-3-sergio.paracuellos@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230227105806.2394101-1-sergio.paracuellos@gmail.com> References: <20230227105806.2394101-1-sergio.paracuellos@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758981746823529128?= X-GMAIL-MSGID: =?utf-8?q?1758981746823529128?= Move the SoC register value queries and tests to specific functions, to remove repetition of logic. No functional changes intended Signed-off-by: Sergio Paracuellos --- arch/mips/ralink/rt305x.c | 97 +++++++++++++++++++++++++++++++-------- 1 file changed, 77 insertions(+), 20 deletions(-) diff --git a/arch/mips/ralink/rt305x.c b/arch/mips/ralink/rt305x.c index 135a46517763..a24143c739ee 100644 --- a/arch/mips/ralink/rt305x.c +++ b/arch/mips/ralink/rt305x.c @@ -139,52 +139,109 @@ void __init ralink_of_remap(void) panic("Failed to remap core resources"); } -void __init prom_soc_init(struct ralink_soc_info *soc_info) +static unsigned int __init rt305x_get_soc_name0(void) +{ + return __raw_readl(RT305X_SYSC_BASE + SYSC_REG_CHIP_NAME0); +} + +static unsigned int __init rt305x_get_soc_name1(void) { - unsigned char *name; - u32 n0; - u32 n1; - u32 id; + return __raw_readl(RT305X_SYSC_BASE + SYSC_REG_CHIP_NAME1); +} - n0 = __raw_readl(RT305X_SYSC_BASE + SYSC_REG_CHIP_NAME0); - n1 = __raw_readl(RT305X_SYSC_BASE + SYSC_REG_CHIP_NAME1); +static bool __init rt3052_soc_valid(void) +{ + if (rt305x_get_soc_name0() == RT3052_CHIP_NAME0 && + rt305x_get_soc_name1() == RT3052_CHIP_NAME1) + return true; + else + return false; +} - if (n0 == RT3052_CHIP_NAME0 && n1 == RT3052_CHIP_NAME1) { +static bool __init rt3350_soc_valid(void) +{ + if (rt305x_get_soc_name0() == RT3350_CHIP_NAME0 && + rt305x_get_soc_name1() == RT3350_CHIP_NAME1) + return true; + else + return false; +} + +static bool __init rt3352_soc_valid(void) +{ + if (rt305x_get_soc_name0() == RT3352_CHIP_NAME0 && + rt305x_get_soc_name1() == RT3352_CHIP_NAME1) + return true; + else + return false; +} + +static bool __init rt5350_soc_valid(void) +{ + if (rt305x_get_soc_name0() == RT5350_CHIP_NAME0 && + rt305x_get_soc_name1() == RT5350_CHIP_NAME1) + return true; + else + return false; +} + +static const char __init *rt305x_get_soc_name(struct ralink_soc_info *soc_info) +{ + if (rt3052_soc_valid()) { unsigned long icache_sets; icache_sets = (read_c0_config1() >> 22) & 7; if (icache_sets == 1) { ralink_soc = RT305X_SOC_RT3050; - name = "RT3050"; soc_info->compatible = "ralink,rt3050-soc"; + return "RT3050"; } else { ralink_soc = RT305X_SOC_RT3052; - name = "RT3052"; soc_info->compatible = "ralink,rt3052-soc"; + return "RT3052"; } - } else if (n0 == RT3350_CHIP_NAME0 && n1 == RT3350_CHIP_NAME1) { + } else if (rt3350_soc_valid()) { ralink_soc = RT305X_SOC_RT3350; - name = "RT3350"; soc_info->compatible = "ralink,rt3350-soc"; - } else if (n0 == RT3352_CHIP_NAME0 && n1 == RT3352_CHIP_NAME1) { + return "RT3350"; + } else if (rt3352_soc_valid()) { ralink_soc = RT305X_SOC_RT3352; - name = "RT3352"; soc_info->compatible = "ralink,rt3352-soc"; - } else if (n0 == RT5350_CHIP_NAME0 && n1 == RT5350_CHIP_NAME1) { + return "RT3352"; + } else if (rt5350_soc_valid()) { ralink_soc = RT305X_SOC_RT5350; - name = "RT5350"; soc_info->compatible = "ralink,rt5350-soc"; + return "RT5350"; } else { - panic("rt305x: unknown SoC, n0:%08x n1:%08x", n0, n1); + panic("rt305x: unknown SoC, n0:%08x n1:%08x", + rt305x_get_soc_name0(), rt305x_get_soc_name1()); } +} + +static unsigned int __init rt305x_get_soc_id(void) +{ + return __raw_readl(RT305X_SYSC_BASE + SYSC_REG_CHIP_ID); +} + +static unsigned int __init rt305x_get_soc_ver(void) +{ + return (rt305x_get_soc_id() >> CHIP_ID_ID_SHIFT) & CHIP_ID_ID_MASK; +} - id = __raw_readl(sysc + SYSC_REG_CHIP_ID); +static unsigned int __init rt305x_get_soc_rev(void) +{ + return (rt305x_get_soc_id() & CHIP_ID_REV_MASK); +} + +void __init prom_soc_init(struct ralink_soc_info *soc_info) +{ + const char *name = rt305x_get_soc_name(soc_info); snprintf(soc_info->sys_type, RAMIPS_SYS_TYPE_LEN, "Ralink %s id:%u rev:%u", name, - (id >> CHIP_ID_ID_SHIFT) & CHIP_ID_ID_MASK, - (id & CHIP_ID_REV_MASK)); + rt305x_get_soc_ver(), + rt305x_get_soc_rev()); soc_info->mem_base = RT305X_SDRAM_BASE; if (soc_is_rt5350()) { From patchwork Mon Feb 27 10:57:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Paracuellos X-Patchwork-Id: 61908 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2349262wrd; Mon, 27 Feb 2023 03:01:59 -0800 (PST) X-Google-Smtp-Source: AK7set9/SnaPzCBo+e70pZkuI816uN8ErV3XwZIbHJgA+MU7llO/D/V3r1c7WPIWJaiurZB6l3oq X-Received: by 2002:a17:902:7484:b0:19c:9fa5:af00 with SMTP id h4-20020a170902748400b0019c9fa5af00mr18165606pll.2.1677495719470; Mon, 27 Feb 2023 03:01:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677495719; cv=none; d=google.com; s=arc-20160816; b=EhZ8VpvR3vW8zDIgUgts0Wg+B6NvVud/ueV/dC4SeBC1z2eoyAnM2OOWTSu0WAsN5r pmPyEyNL6UlJey/8X9j+NoEFlf9eqcCNDdc6NsLPAR/I7T+AmT6iZ4OakqLbqVtLeZ7O Jk1Y6apAdhD+NGUCyD02YzdEh/Pvqn636xq6sg9bXTV7MXcK1+0SmTjU0QRD01ATU/ja 89y0O7aMOYRfALU8UvuKAY2TFxfInfPKekQoDHEH4gx8/ny1IblH9wo9RKxME4gpbYMI ETlaNGsO7ClyVhvdOKboRqwX1RnqN4SFxIF2XioiGCBcUgG6XmXnCbZoUr/9peUmbbxo K3xA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kfZlvyD8rTZQbpQrkIlLlvAbU21XIuea0Ob/RtnHs1U=; b=bce+f6e6JoxPOwHHr2hRZ1tfZu5F9O0Fs1SWKscZ39P6XpxTSRCHnKo5AqbvneqyZD ZeLlKM0QeegKmx3RNsrFUD2YLm+1qRWQSLXbIeK9V5qKQYLJlJLdW81ho1JZ0VnUSWOC ItdNT9b0LIh/Bz71N2Hsb833w1ODUENw8pSRKsfe/SnlGWIG2ATJ+cR+dhKJA+DDGSQa qTYH2tTk2GiU8YGkfGGziDtVB6CkeRWk1U1pZWR61c/3q9pPwsjPeNFtsEE13fJiMm9o 13+sV6RIPVz2O2WJEdXJVIj9c/WG06zDZ6FUg6HCwakOJ6Sbr6Ry2Mj+IebNLtSBRaK8 p5TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=kif3rjC5; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kn13-20020a170903078d00b0019ce7a02573si6660139plb.613.2023.02.27.03.01.27; Mon, 27 Feb 2023 03:01:59 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=kif3rjC5; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230151AbjB0K63 (ORCPT + 99 others); Mon, 27 Feb 2023 05:58:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230059AbjB0K6O (ORCPT ); Mon, 27 Feb 2023 05:58:14 -0500 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E969CCA37; Mon, 27 Feb 2023 02:58:12 -0800 (PST) Received: by mail-wr1-x431.google.com with SMTP id t15so5728593wrz.7; Mon, 27 Feb 2023 02:58:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kfZlvyD8rTZQbpQrkIlLlvAbU21XIuea0Ob/RtnHs1U=; b=kif3rjC5DZzlITC9ZiIlLLV1GPEFuq0QTF4KSI0Pap7DXwFdqaW0rTfovI/5Y99mzT Yt+TbxPB+blULAQNX3feY4zpOdFl2aK5lbsxmXcXOP8Z+0J5u+il/lP4iRXWXd4GxK3N GuUr8ZCoztrHQdovCqWGLWgRfdATvAKh8BkJAKiZoZTq/lwewdbcvRjNB3w5hPQaablF mAfT6Lq7jH3wCaJS4nN/2bdZny9GEpCUegYb7aS1ucnrg+8m/S7pGEq9ag0/KGHChXvw KLS9oy1N6xQZaqiM6Rm5sfWELjVnWl56Nxa+g8xZOTsuaeKsaLqGqjHEeenlkwWjileC 1oOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kfZlvyD8rTZQbpQrkIlLlvAbU21XIuea0Ob/RtnHs1U=; b=Vs/kuNGd046+aQ/fcCvQ2ssztVz6SCJRmB6IvP3w+nBtB2MVtL0sGmyPPWuUKN6DrD U7trAyTaZ+EXu0vHDPITI+Wt7jVvpeHgIDsGlrdtZejq7enzutyIPQttmQQA4oVy4rT7 IebLT761Ryqk1+iXSqWrGX1HL5gl/uWALgiZ72s8PKPqmER61EP/+tZAe4VN4IhVY64k JM1iAvqqTDgw1OfexJaN2Rs8EzA6arn1Nm0J0iOybFjuHLMGj8UbkA7Lct40V5pyu9jU PAHlDe5KRkoS08BEAV59T+BHUqN1GJRik19khqX0PaIYipJoL9IMuaxMVQijDhmydU+9 NirQ== X-Gm-Message-State: AO0yUKVCt8t/uvD/VEsKwFICOms1uzvyVCiWmDrOdjuo2PWWxFfj8Mlu l1x9eBOgHjoYVfQ1Ez/xLGYSmMmqajM= X-Received: by 2002:adf:e58f:0:b0:2c5:a07e:4bb6 with SMTP id l15-20020adfe58f000000b002c5a07e4bb6mr20110631wrm.33.1677495491221; Mon, 27 Feb 2023 02:58:11 -0800 (PST) Received: from localhost.localdomain (106.red-88-13-29.dynamicip.rima-tde.net. [88.13.29.106]) by smtp.gmail.com with ESMTPSA id a4-20020a5d5704000000b002c559843748sm6806122wrv.10.2023.02.27.02.58.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 02:58:10 -0800 (PST) From: Sergio Paracuellos To: linux-mips@vger.kernel.org Cc: tsbogend@alpha.franken.de, john@phrozen.org, linux-kernel@vger.kernel.org, git@johnthomson.fastmail.com.au Subject: [PATCH 03/12] mips: ralink: rt305x: introduce 'soc_device' initialization Date: Mon, 27 Feb 2023 11:57:57 +0100 Message-Id: <20230227105806.2394101-4-sergio.paracuellos@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230227105806.2394101-1-sergio.paracuellos@gmail.com> References: <20230227105806.2394101-1-sergio.paracuellos@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758981751926739001?= X-GMAIL-MSGID: =?utf-8?q?1758981751926739001?= RT305x SoCs have their own 'ralink_soc_info' structure with some information about the soc itself. In order to be able to retrieve this information from driver code and avoid architecture dependencies for retrieving these details introduce this 'soc_device'. Set 'data' pointer points to the struct 'ralink_soc_info' to be able to export also current soc information using this mechanism. We need to select 'SOC_BUS' in Kconfig configuration for these SoCs. Signed-off-by: Sergio Paracuellos --- arch/mips/ralink/Kconfig | 1 + arch/mips/ralink/rt305x.c | 46 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/arch/mips/ralink/Kconfig b/arch/mips/ralink/Kconfig index 06031796c87b..658e12b34ccc 100644 --- a/arch/mips/ralink/Kconfig +++ b/arch/mips/ralink/Kconfig @@ -32,6 +32,7 @@ choice config SOC_RT305X bool "RT305x" + select SOC_BUS config SOC_RT3883 bool "RT3883" diff --git a/arch/mips/ralink/rt305x.c b/arch/mips/ralink/rt305x.c index a24143c739ee..d8dcc5cc66cc 100644 --- a/arch/mips/ralink/rt305x.c +++ b/arch/mips/ralink/rt305x.c @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include #include @@ -19,6 +21,8 @@ #include "common.h" +static struct ralink_soc_info *soc_info_ptr; + static unsigned long rt5350_get_mem_size(void) { unsigned long ret; @@ -233,6 +237,46 @@ static unsigned int __init rt305x_get_soc_rev(void) return (rt305x_get_soc_id() & CHIP_ID_REV_MASK); } +static const char __init *rt305x_get_soc_id_name(void) +{ + if (soc_is_rt3050()) + return "rt3050"; + else if (soc_is_rt3052()) + return "rt3052"; + else if (soc_is_rt3350()) + return "rt3350"; + else if (soc_is_rt3352()) + return "rt3352"; + else if (soc_is_rt5350()) + return "rt5350"; + else + return "invalid"; +} + +static int __init rt305x_soc_dev_init(void) +{ + struct soc_device *soc_dev; + struct soc_device_attribute *soc_dev_attr; + + soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); + if (!soc_dev_attr) + return -ENOMEM; + + soc_dev_attr->family = "Ralink"; + soc_dev_attr->soc_id = rt305x_get_soc_id_name(); + + soc_dev_attr->data = soc_info_ptr; + + soc_dev = soc_device_register(soc_dev_attr); + if (IS_ERR(soc_dev)) { + kfree(soc_dev_attr); + return PTR_ERR(soc_dev); + } + + return 0; +} +device_initcall(rt305x_soc_dev_init); + void __init prom_soc_init(struct ralink_soc_info *soc_info) { const char *name = rt305x_get_soc_name(soc_info); @@ -253,4 +297,6 @@ void __init prom_soc_init(struct ralink_soc_info *soc_info) soc_info->mem_size_min = RT3352_MEM_SIZE_MIN; soc_info->mem_size_max = RT3352_MEM_SIZE_MAX; } + + soc_info_ptr = soc_info; } From patchwork Mon Feb 27 10:57:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Paracuellos X-Patchwork-Id: 61910 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2349422wrd; Mon, 27 Feb 2023 03:02:14 -0800 (PST) X-Google-Smtp-Source: AK7set96AgDZ2Oy1rtI/TAwDAi0sOg79oedQKlMBleqNbTiY08rlVC2pxDPKOCSzbVDG9w6oCfov X-Received: by 2002:a17:90b:2248:b0:235:31e9:e793 with SMTP id hk8-20020a17090b224800b0023531e9e793mr9131184pjb.13.1677495734553; Mon, 27 Feb 2023 03:02:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677495734; cv=none; d=google.com; s=arc-20160816; b=wyiFbZlOEX78XLbedk0vlby9JnSWCKozGj0e3bc31Z3HrF6On0x5cVdJmDm8o+aZef sbrWK0scjzpAVn+m9PR8NJG9wLbo9LoL1/xnIJqvB4idoB2dhDO+wPkAYcjcOzVaTptE I247BD1Yn99w69F40tXxW6QInPS7ihIol/qiIX0ZgqjJGMxg56ryKq3YN/hr/MohpCnX WKPfjXk2qv3EsP/4Wlp9taqXtQ2almQeqBn8M8XRylFfxmMROYa2yapptsaFI1MZspv1 SRhD7TpEBbhgP44qLejggZPw93x8dz6AE0xAcI9ISir3GgOAPBbDMcd/11rYDE5bpMe7 zLZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=q66bHBctBFwEmexbcNsZu9cAPfXaFAcm9g/elou8jLA=; b=DiTngzQbOqgn27laldOe6Rj7FL4UI5+gSmqeyce5KuMeqoRZG3/12i3I+2J3sKuAT2 N5IZK3+cBoTQnV1ucH5nlSiXl7z+zRuVyzzC46N0tcPrzgr4dWxDs+C1o1CmKR94G99i Vd6r8wJF6akwVoNilHgQOE2WdGjc4NCBYmDH7DY1a5W8vDOwQ70NxZKoImF9eOWrdRYc vxPuKGuCxwcrax0Ro4grjB3gnjDGJqbfI1IKD45uBKudax7ha0iVmLkE9uUUh7vO85Qt +XIcFNKYiEJgmPCjH6ayKZCybtW5P5pihtSn4qxTQXmM6JkFqAhlkHsbxFHGQmwzbf4a ZO2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Xpgb9y8i; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h23-20020a17090aa89700b00233e937fef2si6839289pjq.64.2023.02.27.03.01.45; Mon, 27 Feb 2023 03:02:14 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Xpgb9y8i; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229977AbjB0K6d (ORCPT + 99 others); Mon, 27 Feb 2023 05:58:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230025AbjB0K6P (ORCPT ); Mon, 27 Feb 2023 05:58:15 -0500 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0ACC9EB54; Mon, 27 Feb 2023 02:58:14 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id l25so5743642wrb.3; Mon, 27 Feb 2023 02:58:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=q66bHBctBFwEmexbcNsZu9cAPfXaFAcm9g/elou8jLA=; b=Xpgb9y8iqSWjnhj+rVJyKp+DC9qju+tBwbsyml1lWuUdzchm8yoV7Rb5E6WymIpjOQ 5h2PYNVcBxHRo8GDrcNDNs3rCbrtx147rxajFPpgCWy4g5bPq7QtMWIg/VoeXrh+h+dP BC8u3IVaj9Mq8TdUB4vu3M7rSGviM2GehrHw0S8NOr7DksC483B9ui51ejMQes/vwtQl oj2w3Dw1Kjt3GelIam/yASEiYsDeJl3k96PlxnKO6aN8bJNQyGltP4PZcBTGgvT4dL5+ r1xt7l3aWOCSla56cqJ32dcWgEH06HlPEi264qmNswEust4aSMaE0zaUFsD+HJihGYsl KFag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q66bHBctBFwEmexbcNsZu9cAPfXaFAcm9g/elou8jLA=; b=BebraczbNfGGnAMYAme7w4vScdbX4na4Zbnx2CEPpLxCpn8aKx9TKQYSjfVTXFNA6h gBOfY54e33GztPju/e762nWJaS/ZO5wc+E8vdZNgeI6dL0Ea0G2Sdfbt0+mtTuixIRt8 JcGB6yCHypt22LN3gUioAB7q3/S+oHRMM+3JNeJFF2dEjuzJ4/dXmOWQKE02gjX67kl2 A2mA1w2E1gbpTT0JecEVYEa+6+fY2mPrh21JukfXgF4q8ZbSdfLrtPa2uOVNudgAtncS 5hdVYsfEfdkXFmLJ9vx2PnNasjUDj8f5UyVP2JvFsN+LqV+9JxvXIeGpF9eAtCAnKdPN 2kjQ== X-Gm-Message-State: AO0yUKWIK8xa9byYrcmPeKnGkwe6/AR5clKryhg/cBWs+Um2cndv66WY VHpaiCWEwaqlmi0VocLAgF9o2vk5Z3Y= X-Received: by 2002:a5d:604a:0:b0:2c7:16c3:175e with SMTP id j10-20020a5d604a000000b002c716c3175emr9900360wrt.64.1677495492145; Mon, 27 Feb 2023 02:58:12 -0800 (PST) Received: from localhost.localdomain (106.red-88-13-29.dynamicip.rima-tde.net. [88.13.29.106]) by smtp.gmail.com with ESMTPSA id a4-20020a5d5704000000b002c559843748sm6806122wrv.10.2023.02.27.02.58.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 02:58:11 -0800 (PST) From: Sergio Paracuellos To: linux-mips@vger.kernel.org Cc: tsbogend@alpha.franken.de, john@phrozen.org, linux-kernel@vger.kernel.org, git@johnthomson.fastmail.com.au Subject: [PATCH 04/12] mips: ralink: rt3883: define RT3883_SYSC_BASE with __iomem Date: Mon, 27 Feb 2023 11:57:58 +0100 Message-Id: <20230227105806.2394101-5-sergio.paracuellos@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230227105806.2394101-1-sergio.paracuellos@gmail.com> References: <20230227105806.2394101-1-sergio.paracuellos@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758981767354571322?= X-GMAIL-MSGID: =?utf-8?q?1758981767354571322?= So that RT3883_SYSC_BASE can be used later in multiple functions without needing to repeat this __iomem declaration each time Signed-off-by: Sergio Paracuellos --- arch/mips/include/asm/mach-ralink/rt3883.h | 4 +++- arch/mips/ralink/rt3883.c | 7 +++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/mips/include/asm/mach-ralink/rt3883.h b/arch/mips/include/asm/mach-ralink/rt3883.h index f250de9c055b..ad25d5e8d2dc 100644 --- a/arch/mips/include/asm/mach-ralink/rt3883.h +++ b/arch/mips/include/asm/mach-ralink/rt3883.h @@ -10,8 +10,10 @@ #include +#define IOMEM(x) ((void __iomem *)(KSEG1ADDR(x))) + #define RT3883_SDRAM_BASE 0x00000000 -#define RT3883_SYSC_BASE 0x10000000 +#define RT3883_SYSC_BASE IOMEM(0x10000000) #define RT3883_TIMER_BASE 0x10000100 #define RT3883_INTC_BASE 0x10000200 #define RT3883_MEMC_BASE 0x10000300 diff --git a/arch/mips/ralink/rt3883.c b/arch/mips/ralink/rt3883.c index d9875f146d66..fa215c07558d 100644 --- a/arch/mips/ralink/rt3883.c +++ b/arch/mips/ralink/rt3883.c @@ -72,15 +72,14 @@ void __init ralink_of_remap(void) void __init prom_soc_init(struct ralink_soc_info *soc_info) { - void __iomem *sysc = (void __iomem *) KSEG1ADDR(RT3883_SYSC_BASE); const char *name; u32 n0; u32 n1; u32 id; - n0 = __raw_readl(sysc + RT3883_SYSC_REG_CHIPID0_3); - n1 = __raw_readl(sysc + RT3883_SYSC_REG_CHIPID4_7); - id = __raw_readl(sysc + RT3883_SYSC_REG_REVID); + n0 = __raw_readl(RT3883_SYSC_BASE + RT3883_SYSC_REG_CHIPID0_3); + n1 = __raw_readl(RT3883_SYSC_BASE + RT3883_SYSC_REG_CHIPID4_7); + id = __raw_readl(RT3883_SYSC_BASE + RT3883_SYSC_REG_REVID); if (n0 == RT3883_CHIP_NAME0 && n1 == RT3883_CHIP_NAME1) { soc_info->compatible = "ralink,rt3883-soc"; From patchwork Mon Feb 27 10:57:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Paracuellos X-Patchwork-Id: 61909 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2349384wrd; Mon, 27 Feb 2023 03:02:11 -0800 (PST) X-Google-Smtp-Source: AK7set+TRrp+UyDkDUoHVbWN1y9IfEST9zHBYicD5t9B4IWmd9PTfYIoliDrdLtl+hKw+V7M9rvF X-Received: by 2002:a17:903:11d2:b0:19c:be03:d1ba with SMTP id q18-20020a17090311d200b0019cbe03d1bamr17432708plh.6.1677495731430; Mon, 27 Feb 2023 03:02:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677495731; cv=none; d=google.com; s=arc-20160816; b=V7cC5ytChdyIiT/TwDVdXgetBPDbHnOgAUxM+nPVSoDRug6YqC87Sm2pTM0L6LLHiN n7Up0ScUJSZC7e04X3IxQy0zKGjHFgmCNpDhX1vs8FGaB0zYi1jkxf1DHngxzwUBklIs ES07sGhKEb2S56KsiByTi/0cRwO1PTJIsHu4YOW20XndgJgVf2M0eELOk3D0uvuB1pVs Xa0qWX0Dc4qegEs5j1ian/mP8F3clGSXuzeYN5H9OcJ6nJwyRvwjV15VCkBZRMPAgjRg tttI2CsyHBVRJmAcb4cS9wRkdXpDoN3cB0hYNgiJ0g5Pq4wXZmxXaH97OhhafV6UOL6x H5HQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=i9SGqf47sYexP4KDD8i5u1pt87QH5U1h+xP3iiJeOMw=; b=D5b6Tzfa/sJTPbzXtuOd0ubK0W3YKEGR59yj2fPaN8wrhYqzswbi2UftS1RJdT5Pdd Usf0Ps17DyTaclWuGGsh35VDICSgcWXoDQOCgwW0WIuv5UO3E/tbwoFtKCLnpyOGfdB/ PBX5FYdwzEhOx7cYftiTyM8IMlG1bt6nMnqp+rSqiajWTg/gf5ghcuNSf0RIgojJc5Ik FS1afbVZwpk83zArtRg3eQjpy0b5vZMXQrdstEtIXhkmFOnG32keq8S3ZtokboGSxS8a hjxgDwguV1QlgiGO2Mz1T+p80N/mQki7hrShcwN/zP0jgTKWpsQZzfkmGhRqTnejlL2P lcyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HFIqa8q0; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lh14-20020a170903290e00b0019afac78059si6609155plb.603.2023.02.27.03.01.59; Mon, 27 Feb 2023 03:02:11 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HFIqa8q0; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230059AbjB0K6f (ORCPT + 99 others); Mon, 27 Feb 2023 05:58:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230050AbjB0K6P (ORCPT ); Mon, 27 Feb 2023 05:58:15 -0500 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA5E615CAB; Mon, 27 Feb 2023 02:58:14 -0800 (PST) Received: by mail-wm1-x32c.google.com with SMTP id az36so3966357wmb.1; Mon, 27 Feb 2023 02:58:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=i9SGqf47sYexP4KDD8i5u1pt87QH5U1h+xP3iiJeOMw=; b=HFIqa8q05zIgTCCwkryZi+hCLVkH/xf9Bxogc+r4MkJyv6T8wLfUNv3ZcQOMpLJEfk H3fi+mzu3ucuJVmW23xRnYXtVXcAScE0Lzw6lYf8SfyT4stI7Y9XSVqFV8rX3Zxg/OH8 tdskHzTbWkd1BT5mBKyRLe7d0vrBC8JZxMvbJUzE6Hv51G/6Cq22azMocNVT/V2IL9ji Inr/4zvbec/ZP90nqZ3SqoTjb8nhjSpgpBwMG4m5KHCP2CS9XYWAch7Nu0wYhQT2gkH8 La6eibI2m+HtjawvSRgMhET+dGB+UL7yx6pfsys/E2nAbGX/C7aAkQKHMHdQFcqh5XhL MzqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i9SGqf47sYexP4KDD8i5u1pt87QH5U1h+xP3iiJeOMw=; b=xJoquucfLW/yhdf+oz2c2Jm+TQi/3KvO+IkjvfMGJSn5jaC7fyBP4wtvpSEJsgdW0S VGNjiavUXWrx2VHbw6e9IZ3QCDOu9uQW3Qujl0PBxhQ783G20D0D83cCqft/IEHH6pDU 0RIX36tHDCrFD/lfdErpO8REvIeYsO77JHjP9VmJKIrJAst5MkcHMqra+syKwcEnAuZz bMdFeqAsLvChv4NCaGHyY5KBLeHvCO+gcfdHajy+w33ItIm1wr3Sy/8YEmEUb8UDlEVF 5pEda5JcKnHowuZ78aNmrIKejPqml+JHNmUlpm7a97qbJ9XPfZ7V/d9vcaR9BNidzc+g CpPQ== X-Gm-Message-State: AO0yUKU6LtB25u/G6QZUcALsQQZjoKoKPIXoc+jZmJCm/oexJ7rkEhCR JWl5W5vUi5AsAlpgt0bmoyxE+aIxSuQ= X-Received: by 2002:a05:600c:44d3:b0:3da:fc30:bfc5 with SMTP id f19-20020a05600c44d300b003dafc30bfc5mr17749497wmo.13.1677495493031; Mon, 27 Feb 2023 02:58:13 -0800 (PST) Received: from localhost.localdomain (106.red-88-13-29.dynamicip.rima-tde.net. [88.13.29.106]) by smtp.gmail.com with ESMTPSA id a4-20020a5d5704000000b002c559843748sm6806122wrv.10.2023.02.27.02.58.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 02:58:12 -0800 (PST) From: Sergio Paracuellos To: linux-mips@vger.kernel.org Cc: tsbogend@alpha.franken.de, john@phrozen.org, linux-kernel@vger.kernel.org, git@johnthomson.fastmail.com.au Subject: [PATCH 05/12] mips: ralink: rt3883: soc queries and tests as functions Date: Mon, 27 Feb 2023 11:57:59 +0100 Message-Id: <20230227105806.2394101-6-sergio.paracuellos@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230227105806.2394101-1-sergio.paracuellos@gmail.com> References: <20230227105806.2394101-1-sergio.paracuellos@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758981764244026893?= X-GMAIL-MSGID: =?utf-8?q?1758981764244026893?= Move the SoC register value queries and tests to specific functions, to remove repetition of logic. No functional changes intended Signed-off-by: Sergio Paracuellos --- arch/mips/ralink/rt3883.c | 64 +++++++++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 16 deletions(-) diff --git a/arch/mips/ralink/rt3883.c b/arch/mips/ralink/rt3883.c index fa215c07558d..6f8541a4bc8e 100644 --- a/arch/mips/ralink/rt3883.c +++ b/arch/mips/ralink/rt3883.c @@ -70,29 +70,61 @@ void __init ralink_of_remap(void) panic("Failed to remap core resources"); } -void __init prom_soc_init(struct ralink_soc_info *soc_info) +static unsigned int __init rt3883_get_soc_name0(void) +{ + return __raw_readl(RT3883_SYSC_BASE + RT3883_SYSC_REG_CHIPID0_3); +} + +static unsigned int __init rt3883_get_soc_name1(void) +{ + return __raw_readl(RT3883_SYSC_BASE + RT3883_SYSC_REG_CHIPID4_7); +} + +static bool __init rt3883_soc_valid(void) +{ + if (rt3883_get_soc_name0() == RT3883_CHIP_NAME0 && + rt3883_get_soc_name1() == RT3883_CHIP_NAME1) + return true; + else + return false; +} + +static const char __init *rt3883_get_soc_name(void) +{ + if (rt3883_soc_valid()) + return "RT3883"; + else + return "invalid"; +} + +static unsigned int __init rt3883_get_soc_id(void) { - const char *name; - u32 n0; - u32 n1; - u32 id; + return __raw_readl(RT3883_SYSC_BASE + RT3883_SYSC_REG_REVID); +} - n0 = __raw_readl(RT3883_SYSC_BASE + RT3883_SYSC_REG_CHIPID0_3); - n1 = __raw_readl(RT3883_SYSC_BASE + RT3883_SYSC_REG_CHIPID4_7); - id = __raw_readl(RT3883_SYSC_BASE + RT3883_SYSC_REG_REVID); +static unsigned int __init rt3883_get_soc_ver(void) +{ + return (rt3883_get_soc_id() >> RT3883_REVID_VER_ID_SHIFT) & RT3883_REVID_VER_ID_MASK; +} - if (n0 == RT3883_CHIP_NAME0 && n1 == RT3883_CHIP_NAME1) { +static unsigned int __init rt3883_get_soc_rev(void) +{ + return (rt3883_get_soc_id() & RT3883_REVID_ECO_ID_MASK); +} + +void __init prom_soc_init(struct ralink_soc_info *soc_info) +{ + if (rt3883_soc_valid()) soc_info->compatible = "ralink,rt3883-soc"; - name = "RT3883"; - } else { - panic("rt3883: unknown SoC, n0:%08x n1:%08x", n0, n1); - } + else + panic("rt3883: unknown SoC, n0:%08x n1:%08x", + rt3883_get_soc_name0(), rt3883_get_soc_name1()); snprintf(soc_info->sys_type, RAMIPS_SYS_TYPE_LEN, "Ralink %s ver:%u eco:%u", - name, - (id >> RT3883_REVID_VER_ID_SHIFT) & RT3883_REVID_VER_ID_MASK, - (id & RT3883_REVID_ECO_ID_MASK)); + rt3883_get_soc_name(), + rt3883_get_soc_ver(), + rt3883_get_soc_rev()); soc_info->mem_base = RT3883_SDRAM_BASE; soc_info->mem_size_min = RT3883_MEM_SIZE_MIN; From patchwork Mon Feb 27 10:58:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Paracuellos X-Patchwork-Id: 61917 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2350056wrd; Mon, 27 Feb 2023 03:03:34 -0800 (PST) X-Google-Smtp-Source: AK7set9hq2oqd/UVdC0WIfLMHolNlOqBPVgG9tzIIH7ergb7jXU5Vn5Dgq1a8lVpeU/AxysXw++1 X-Received: by 2002:a62:1946:0:b0:5e2:434d:1167 with SMTP id 67-20020a621946000000b005e2434d1167mr11309522pfz.9.1677495814281; Mon, 27 Feb 2023 03:03:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677495814; cv=none; d=google.com; s=arc-20160816; b=uqNoWYdI1eTyitYz12kyHIOvsRLvYe2Bwkbxf9CADdHngzeLY7A80GTqbFgN21B2JL bUlkPXs9JTGWWLniSkA/3GZIrGj1SvRBCRwDKwmbq1LyvzR0WgRBOMoreXgPn7h5qOsa GQ0PTdYBK3g9+1z2wqe1AkUo/eeKfoWXqjsfddrtvE1Fr+Sj3TjWIFG7YCbjCH6E3LfN uOUdFXOFBKt0Z2QhEdPiRSnmlX/U+rfWZD4McnihY781sq105W/lyEMo/ILQqAx26/sf +iGLVVPmWnC5ye6OVroJxQEo2A8YYXW9rTR5/YObQ5K303YRo+sgkGs5gxOY8v9GnTDw XJDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kdLIQJlJWnELjON9nBGeYOy/CiIIUc1Jm+enmEwgejU=; b=UHRHHAfq+XUoXBt+drFKVeecGvylLjY8WOntFF94TE0Q5t7crOXE8+JCG4mellY/kR NbGjz6/C2X41ygWTrmNjk2HD2RFKvFLiu/YpyQhUUdFTXu/IJSVF8NgGTE7o8aPXbJbf s6HO72K8AgISopinjrJ0Tu8c+LHHIuH1rCN9hM14K75+Qx5i+DSFRibc3jhDpYCCyTfq MLhxybUl8SgIODg/TGpFoQ2S2Z92XSCC2VjnNRQjD89GblWkfijzAb4p6TY3FXvs9s/X Cvnvg6TKt+V4ol0VQK8fbf3S69s4Xh/NxkXbtK5PleWi5CcCeFjchFvgE5oHLWp/Tggv oN+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Si7wHOgx; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 2-20020a621802000000b005e7dc5d1b1bsi6489938pfy.82.2023.02.27.03.03.22; Mon, 27 Feb 2023 03:03:34 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Si7wHOgx; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230190AbjB0K6i (ORCPT + 99 others); Mon, 27 Feb 2023 05:58:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230071AbjB0K6R (ORCPT ); Mon, 27 Feb 2023 05:58:17 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E470CBBA4; Mon, 27 Feb 2023 02:58:15 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id h14so5736855wru.4; Mon, 27 Feb 2023 02:58:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kdLIQJlJWnELjON9nBGeYOy/CiIIUc1Jm+enmEwgejU=; b=Si7wHOgxp7FKgb9sqtCU1ATOpyTMrA1JejnS6/GufE3c0dXf/ZfUdByyAeIn6RjlHQ D+XpFSaQSRB25ckaKlcYMvYcRHJH3gG8MvNzrsazoOQppT4QCjcpIScWMBV/r6brqBY6 D+N5tgu9Xqg25Vr1S4kLm0yP1ARusLMwD3AR4FF18mPypZO6BgrMgNh9LyVZSRFDaQqM P8g8fx1LJTW3luvJcwWIjWVRzCWpyvNhrBMGNK+kW3gZLkz7mxWNtSf18BBC6lIgojTU Hq+vGV4Fw2e6qAzyhXofOa/azwN98tEPjMWwmkIMPoBTCzBUlfVoKZE+GtXdU/mGXJg+ kTPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kdLIQJlJWnELjON9nBGeYOy/CiIIUc1Jm+enmEwgejU=; b=xK/ORg/PhaTN3/OpvvTtq2ZwrXGLWUQFhI0K31Pjal9V7q/xDvA4a/F631hUp+xiZc Cq/2T2iT7gZfNVmbERnhYaSyCsT6zFGMWfhhbKtKM9y0yRaCwqxCzj9Ak1YhbWCd2j9V 9wsD55WiODAOjhgkbQhS8S3CPKUPceVcASWZ2gJCUrALMmWITgKaGBCrL79hIS+Tv+0y xx4SvSH8iPefSU7ge+6QooGm1aDNuXNvzOKZJ/AVcuJEhCh97mSsevp0JgD9E5vrSY0v CFMPsa4l9fF+uCNTZZo2R71hgOEKqzHKJEpgEQlxL9AxNGIo/6T6SrPboM3vIpVvGNT+ 4UIA== X-Gm-Message-State: AO0yUKVFxUnYv7iV90W4pFJqbVTXjdEXMRmHRKdaToZtA5PjAd/Bz0xW O6fSBRN6G6dZiuwlrMZjUYowgC667aQ= X-Received: by 2002:a05:6000:1287:b0:2c7:a39:6e2e with SMTP id f7-20020a056000128700b002c70a396e2emr15365864wrx.15.1677495493991; Mon, 27 Feb 2023 02:58:13 -0800 (PST) Received: from localhost.localdomain (106.red-88-13-29.dynamicip.rima-tde.net. [88.13.29.106]) by smtp.gmail.com with ESMTPSA id a4-20020a5d5704000000b002c559843748sm6806122wrv.10.2023.02.27.02.58.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 02:58:13 -0800 (PST) From: Sergio Paracuellos To: linux-mips@vger.kernel.org Cc: tsbogend@alpha.franken.de, john@phrozen.org, linux-kernel@vger.kernel.org, git@johnthomson.fastmail.com.au Subject: [PATCH 06/12] mips: ralink: rt3883: introduce 'soc_device' initialization Date: Mon, 27 Feb 2023 11:58:00 +0100 Message-Id: <20230227105806.2394101-7-sergio.paracuellos@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230227105806.2394101-1-sergio.paracuellos@gmail.com> References: <20230227105806.2394101-1-sergio.paracuellos@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758981851346581687?= X-GMAIL-MSGID: =?utf-8?q?1758981851346581687?= RT3883 SoC have its own 'ralink_soc_info' structure with some information about the soc itself. In order to be able to retrieve this information from driver code and avoid architecture dependencies for retrieving these details introduce this 'soc_device'. Set 'data' pointer points to the struct 'ralink_soc_info' to be able to export also current soc information using this mechanism. We need to select 'SOC_BUS' in Kconfig configuration for these SoCs. Signed-off-by: Sergio Paracuellos --- arch/mips/ralink/Kconfig | 1 + arch/mips/ralink/rt3883.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/arch/mips/ralink/Kconfig b/arch/mips/ralink/Kconfig index 658e12b34ccc..f657e55b10b7 100644 --- a/arch/mips/ralink/Kconfig +++ b/arch/mips/ralink/Kconfig @@ -37,6 +37,7 @@ choice config SOC_RT3883 bool "RT3883" select HAVE_PCI + select SOC_BUS config SOC_MT7620 bool "MT7620/8" diff --git a/arch/mips/ralink/rt3883.c b/arch/mips/ralink/rt3883.c index 6f8541a4bc8e..cca887af378f 100644 --- a/arch/mips/ralink/rt3883.c +++ b/arch/mips/ralink/rt3883.c @@ -10,6 +10,8 @@ #include #include +#include +#include #include #include @@ -17,6 +19,8 @@ #include "common.h" +static struct ralink_soc_info *soc_info_ptr; + void __init ralink_clk_init(void) { unsigned long cpu_rate, sys_rate; @@ -112,6 +116,30 @@ static unsigned int __init rt3883_get_soc_rev(void) return (rt3883_get_soc_id() & RT3883_REVID_ECO_ID_MASK); } +static int __init rt3883_soc_dev_init(void) +{ + struct soc_device *soc_dev; + struct soc_device_attribute *soc_dev_attr; + + soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); + if (!soc_dev_attr) + return -ENOMEM; + + soc_dev_attr->family = "Ralink"; + soc_dev_attr->soc_id = rt3883_get_soc_name(); + + soc_dev_attr->data = soc_info_ptr; + + soc_dev = soc_device_register(soc_dev_attr); + if (IS_ERR(soc_dev)) { + kfree(soc_dev_attr); + return PTR_ERR(soc_dev); + } + + return 0; +} +device_initcall(rt3883_soc_dev_init); + void __init prom_soc_init(struct ralink_soc_info *soc_info) { if (rt3883_soc_valid()) @@ -131,4 +159,5 @@ void __init prom_soc_init(struct ralink_soc_info *soc_info) soc_info->mem_size_max = RT3883_MEM_SIZE_MAX; ralink_soc = RT3883_SOC; + soc_info_ptr = soc_info; } From patchwork Mon Feb 27 10:58:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Paracuellos X-Patchwork-Id: 61911 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2349555wrd; Mon, 27 Feb 2023 03:02:30 -0800 (PST) X-Google-Smtp-Source: AK7set/lul5AnzE0EE9Qu2oKlh42qXDXkfeLePCbaNpxHlmmtbHZp6acvqgWeLMzknBvJhgdRfUU X-Received: by 2002:a05:6a20:9898:b0:c7:249:cd8c with SMTP id jk24-20020a056a20989800b000c70249cd8cmr19714452pzb.5.1677495750548; Mon, 27 Feb 2023 03:02:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677495750; cv=none; d=google.com; s=arc-20160816; b=E1ULWtwwDwBSyi4e2F/NpQuJrNL0QiVIumvJIO7tX2AUSnsKXAf9HtIG0+SIXVd3k2 TAeuTihOY2NFGYPdL0bOrIAIExZ13X8/rfGe4J19xj4eWphYhzbkg9O9Kf8DoWsu5QIx DINymIFNx+XLV/wmTer9BkJN+9ZKckm5sPG3Q6Ihg+2VLbuFbXXyLw4nfirLOMjFMnuL tV4ZprWxpIZFKzCuJsBCUu5zTIQB247Nfio6R3gRnSkUrOOk1VCTMmoFTWvTRS27o030 Jxjou761hc7wpk0BEJpFFg7o2jIb/EsO8Qvg0zh0XmvZiSqpfIlT//jOIlIJz4QrYSw1 a9Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=job8OjNMmgGAToT54F6bhg5jAGzIyUdmtqvbHKYK1dE=; b=b2wWRCYEmgGyGxwSL0bI+nE6Wx0SqyC+dholO97OxGoIg9hcD+t91dpmcryehXti28 2yIRXkbBLpdYsrVXk8xEoiqZ0fUEWkxfcgxBbR8gSmhwu2zWThCVrXSMd1KCbZiTl6EI Ou1UjvffTcltyjvVAXtyGfH0iRtl1zKbhVpJnaPiR6+P1UHJihtsU8Azn91J5p+gPSVk RZWJVLXsEhIZ8JbO3lIdL3Cu6gVyxxmtuiVrJu9xzLmUWpsn6HUt0YqtcII2aoNr8W4A txvbmBoHHiz3ec2XM4D6cwYuKNTkSq7M4v8e3g8np05y+U/9AZGzbsDvroM9QBredAfJ EdeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Dq5nTkrv; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h63-20020a638342000000b004fb3547c61bsi6937499pge.735.2023.02.27.03.02.17; Mon, 27 Feb 2023 03:02:30 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Dq5nTkrv; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230220AbjB0K6o (ORCPT + 99 others); Mon, 27 Feb 2023 05:58:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229944AbjB0K6S (ORCPT ); Mon, 27 Feb 2023 05:58:18 -0500 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97449CA37; Mon, 27 Feb 2023 02:58:16 -0800 (PST) Received: by mail-wr1-x434.google.com with SMTP id h14so5736883wru.4; Mon, 27 Feb 2023 02:58:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=job8OjNMmgGAToT54F6bhg5jAGzIyUdmtqvbHKYK1dE=; b=Dq5nTkrv4NsOu2ZhEiH1eT4O+XdbX5EPH3rS+KF0eEt3F/81ZXxFmNFQOVZSALlAbq KU95NDES7wkBgmUbjb9L2pypbQEQvxcdzXecOKm9UWRgfX0VIhkyu80qHvsyCIvVLV4K vJ/FGhO9baaKJlebaeWrSy1VxmyGE3QifeWyG1gsA+jDFjKmUQiPg59SHa+UQWqoSIfa HzvEUCH9W3bzthq9VohIkQlC2KnVbw8hkrGPxW+JCaWpnsC3coovH82rka3IW/OiQHws ERWZwoDxByiQzvBAIn83vg2mSZJWNucimNzaAU28m12qTF11a3vVsZlYBf+MMmk14PM+ hX6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=job8OjNMmgGAToT54F6bhg5jAGzIyUdmtqvbHKYK1dE=; b=XegnYYCYggxx4JefFIEekLRz4DyNSQcE26LenCniAgNuYqbYbsYBYYAzmV1fKAw5Lb RoRncQZAVTxvr46VL5rwN1lPPKeJJ3a3GHRMC5PhtNXjRfTqXczfJKS9UCjFqYXIvUzS o790suGamS/OLx5FwaY+fb4dkTBEsa4zBUhkmubGBAH0kgcbxHdD1+XUa6TFpJ5QZcSb LzDP55MRlLRdV9dLr+zS6QjNZiwF7HDWKdsnFsg0vheAL1upqHz4Gt5JMRgtjRPvU9OG fwwz6w6LxzXrPSxMGz52cdSGI3n31uK7AMO9dN4+b/ieA5RILMoog01hmKaDvlhE0UV4 Iypg== X-Gm-Message-State: AO0yUKVmKiMKbOUFUofWoT8JIY+Ju2f0s65mUDEmoshZ+A0pBWzqZ07r S8cM36mI6Mogpz4U8FR7GOiibtVVG7g= X-Received: by 2002:adf:eacd:0:b0:2c7:107c:e172 with SMTP id o13-20020adfeacd000000b002c7107ce172mr11744605wrn.41.1677495494879; Mon, 27 Feb 2023 02:58:14 -0800 (PST) Received: from localhost.localdomain (106.red-88-13-29.dynamicip.rima-tde.net. [88.13.29.106]) by smtp.gmail.com with ESMTPSA id a4-20020a5d5704000000b002c559843748sm6806122wrv.10.2023.02.27.02.58.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 02:58:14 -0800 (PST) From: Sergio Paracuellos To: linux-mips@vger.kernel.org Cc: tsbogend@alpha.franken.de, john@phrozen.org, linux-kernel@vger.kernel.org, git@johnthomson.fastmail.com.au Subject: [PATCH 07/12] mips: ralink: rt288x: define RT2880_SYSC_BASE with __iomem Date: Mon, 27 Feb 2023 11:58:01 +0100 Message-Id: <20230227105806.2394101-8-sergio.paracuellos@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230227105806.2394101-1-sergio.paracuellos@gmail.com> References: <20230227105806.2394101-1-sergio.paracuellos@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758981783844320361?= X-GMAIL-MSGID: =?utf-8?q?1758981783844320361?= So that RT2880_SYSC_BASE can be used later in multiple functions without needing to repeat this __iomem declaration each time Signed-off-by: Sergio Paracuellos --- arch/mips/include/asm/mach-ralink/rt288x.h | 3 ++- arch/mips/ralink/rt288x.c | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/mips/include/asm/mach-ralink/rt288x.h b/arch/mips/include/asm/mach-ralink/rt288x.h index 5f213534f0f5..66a999cd1d80 100644 --- a/arch/mips/include/asm/mach-ralink/rt288x.h +++ b/arch/mips/include/asm/mach-ralink/rt288x.h @@ -11,7 +11,8 @@ #ifndef _RT288X_REGS_H_ #define _RT288X_REGS_H_ -#define RT2880_SYSC_BASE 0x00300000 +#define IOMEM(x) ((void __iomem *)(KSEG1ADDR(x))) +#define RT2880_SYSC_BASE IOMEM(0x00300000) #define SYSC_REG_CHIP_NAME0 0x00 #define SYSC_REG_CHIP_NAME1 0x04 diff --git a/arch/mips/ralink/rt288x.c b/arch/mips/ralink/rt288x.c index 493335db2fe1..12f339138c4c 100644 --- a/arch/mips/ralink/rt288x.c +++ b/arch/mips/ralink/rt288x.c @@ -59,15 +59,14 @@ void __init ralink_of_remap(void) void __init prom_soc_init(struct ralink_soc_info *soc_info) { - void __iomem *sysc = (void __iomem *) KSEG1ADDR(RT2880_SYSC_BASE); const char *name; u32 n0; u32 n1; u32 id; - n0 = __raw_readl(sysc + SYSC_REG_CHIP_NAME0); - n1 = __raw_readl(sysc + SYSC_REG_CHIP_NAME1); - id = __raw_readl(sysc + SYSC_REG_CHIP_ID); + n0 = __raw_readl(RT2880_SYSC_BASE + SYSC_REG_CHIP_NAME0); + n1 = __raw_readl(RT2880_SYSC_BASE + SYSC_REG_CHIP_NAME1); + id = __raw_readl(RT2880_SYSC_BASE + SYSC_REG_CHIP_ID); if (n0 == RT2880_CHIP_NAME0 && n1 == RT2880_CHIP_NAME1) { soc_info->compatible = "ralink,r2880-soc"; From patchwork Mon Feb 27 10:58:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Paracuellos X-Patchwork-Id: 61913 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2349712wrd; Mon, 27 Feb 2023 03:02:51 -0800 (PST) X-Google-Smtp-Source: AK7set8Y56MPijPSic3ScrJIKfVkMRW1WbaOzm0GjQDf8EtxczZv6BtR2Ie2zMtl79M2YS3BEQay X-Received: by 2002:a62:19cc:0:b0:5e2:434d:116b with SMTP id 195-20020a6219cc000000b005e2434d116bmr10197402pfz.23.1677495770624; Mon, 27 Feb 2023 03:02:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677495770; cv=none; d=google.com; s=arc-20160816; b=B+/QPspAXOJcPMas3093o4O2YGlN9+wnWEJCFzm+N4CNcMe0BogH7T+hS8xB/fY8w9 cr73uxihrzcMEHqg7D6mjO696h1NAlZBLPWAdKpbgm0TtStbKNu18k+M9CuKcxS2bXKv Up0MBoKjm/QXzKCy5c5WR/l+S6HiBd/vVrCyBj7FMgrLu3aYPcb2P32uH+vlfo19bnbe VbR0E3QnvEoyFEY9tB41Vhg9T3gjKjWadVQyuLYAK9cJ+DtbbyLQ5ADfzb9kWgHJ+nIR DSrF2SoNWbZHx0hnforJ/W1eBFG7GagVMeGuyYq03fdNDjfAc674l38daRD2x8VYCbJc uCtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pyFswsU5blBWB3R8zkCeMIKub72woh5mwnj70Smv9S8=; b=jTSzMAgtUllt6ADEm/+LysR3Mq6lbW3ijlzntr83Te7zHdXr44yU4k9Uat7cPLfY89 /TdEAZWE6lWFgYc0U64z7r56WnJlTEipwSYme/e4aQXJSl6q8rUYhOMq6BLsFjJOSqkF jixjOYM7M/S91olcXs2ayyJOwdzpO12J+iok4y+XY7+rkvRt4lcEHMGGCGHzoMp5/sZL tk+nXCcdKxljPFGvIcxsqpZn8MLGWVbUpK19sUKCQHH7aN07HjajPRDkRquPET1Hr2E6 5PikFf5j7MY2owdbOKpBdCXcDLUwxXOi1ja7nXTzo2l3aOvdsyiQU+Myg9S0NSfTrHq6 DkQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=WrKoEYCR; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u191-20020a6385c8000000b004f2456fee90si6379934pgd.752.2023.02.27.03.02.38; Mon, 27 Feb 2023 03:02:50 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=WrKoEYCR; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230205AbjB0K6l (ORCPT + 99 others); Mon, 27 Feb 2023 05:58:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230107AbjB0K6T (ORCPT ); Mon, 27 Feb 2023 05:58:19 -0500 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7881BDE7; Mon, 27 Feb 2023 02:58:17 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id bt28so5724382wrb.8; Mon, 27 Feb 2023 02:58:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pyFswsU5blBWB3R8zkCeMIKub72woh5mwnj70Smv9S8=; b=WrKoEYCRoiuoijz+5EgwT0GCDCgA7OStrdV3smFUHQPZHv89J9KydYSzFCcjbWc3ST rWKZNxQ9M8HXJ/7V4vjSou7rLCtQB3oK+u+I+Eszd4VmqmpfrmIMYnYe0Y5VZOP5sPqS N/m774P7238e0xWhOp7Oys5nMIc3HGnCla9xlYT2MDb0NFcfEWApHmLF7knEPSmizOtO BFd9KoeDqhFkzWmNmlEKvpWr82nbI+5RhDPGvaTm+/O9qA4j06K+GQ6YkP3ulflPART/ p+MNtPZt6cH70sca6IszV+jkXWftMpacM15tQSW/S6sSODBevCcBnQ1B9jqlxW6srYrD TFpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pyFswsU5blBWB3R8zkCeMIKub72woh5mwnj70Smv9S8=; b=vfnNAfpHhbkp87viNB8GPAerV3nYV1Evt2QcLo4bVdPaCUoDMg7OkvjMyTF/xn1aRv Pmq8d/TDPD+/1X9bOK/12gAJvSXBEjDY5XFHC3EKS51QaG91zSsbdTpPFU3vt29Xccp2 Kmk94Eru44Uz1JCaYdWXHTWZ7fNYliaAEhPyrD4Zb/kDXur9MpzeLwWnRbcaWgrWDY0L 4/d1Rh6e/+qHT1Gvksv2vDG2gepZBAomH2SSssbDzuyyVWugJj5PYJ5YXPF0CTesVSCu aW+RK+iTzXRBgoyhsxnFO5f8jONjVC1wSwuyPb/BVJCl/mv9Q75Sp9Go3VRdTTODm2GG GYbg== X-Gm-Message-State: AO0yUKUOGAjMyWjLcxbD5qO6cKFn0tHbBeEtn7zB4rkdEd4c29kdAia2 pE2GTOejlmxUhaIhdRoJo4dEmUWMseg= X-Received: by 2002:adf:dd4e:0:b0:2c7:148c:b054 with SMTP id u14-20020adfdd4e000000b002c7148cb054mr12471021wrm.29.1677495495851; Mon, 27 Feb 2023 02:58:15 -0800 (PST) Received: from localhost.localdomain (106.red-88-13-29.dynamicip.rima-tde.net. [88.13.29.106]) by smtp.gmail.com with ESMTPSA id a4-20020a5d5704000000b002c559843748sm6806122wrv.10.2023.02.27.02.58.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 02:58:15 -0800 (PST) From: Sergio Paracuellos To: linux-mips@vger.kernel.org Cc: tsbogend@alpha.franken.de, john@phrozen.org, linux-kernel@vger.kernel.org, git@johnthomson.fastmail.com.au Subject: [PATCH 08/12] mips: ralink: rt288x: soc queries and tests as functions Date: Mon, 27 Feb 2023 11:58:02 +0100 Message-Id: <20230227105806.2394101-9-sergio.paracuellos@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230227105806.2394101-1-sergio.paracuellos@gmail.com> References: <20230227105806.2394101-1-sergio.paracuellos@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758981805154660815?= X-GMAIL-MSGID: =?utf-8?q?1758981805154660815?= Move the SoC register value queries and tests to specific functions, to remove repetition of logic. No functional changes intended Signed-off-by: Sergio Paracuellos --- arch/mips/ralink/rt288x.c | 63 +++++++++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 16 deletions(-) diff --git a/arch/mips/ralink/rt288x.c b/arch/mips/ralink/rt288x.c index 12f339138c4c..a417b8b89b94 100644 --- a/arch/mips/ralink/rt288x.c +++ b/arch/mips/ralink/rt288x.c @@ -57,29 +57,60 @@ void __init ralink_of_remap(void) panic("Failed to remap core resources"); } -void __init prom_soc_init(struct ralink_soc_info *soc_info) +static unsigned int __init rt2880_get_soc_name0(void) { - const char *name; - u32 n0; - u32 n1; - u32 id; + return __raw_readl(RT2880_SYSC_BASE + SYSC_REG_CHIP_NAME0); +} - n0 = __raw_readl(RT2880_SYSC_BASE + SYSC_REG_CHIP_NAME0); - n1 = __raw_readl(RT2880_SYSC_BASE + SYSC_REG_CHIP_NAME1); - id = __raw_readl(RT2880_SYSC_BASE + SYSC_REG_CHIP_ID); +static unsigned int __init rt2880_get_soc_name1(void) +{ + return __raw_readl(RT2880_SYSC_BASE + SYSC_REG_CHIP_NAME1); +} - if (n0 == RT2880_CHIP_NAME0 && n1 == RT2880_CHIP_NAME1) { +static bool __init rt2880_soc_valid(void) +{ + if (rt2880_get_soc_name0() == RT2880_CHIP_NAME0 && + rt2880_get_soc_name1() == RT2880_CHIP_NAME1) + return true; + else + return false; +} + +static const char __init *rt2880_get_soc_name(void) +{ + if (rt2880_soc_valid()) + return "RT2880"; + else + return "invalid"; +} + +static unsigned int __init rt2880_get_soc_id(void) +{ + return __raw_readl(RT2880_SYSC_BASE + SYSC_REG_CHIP_ID); +} + +static unsigned int __init rt2880_get_soc_ver(void) +{ + return (rt2880_get_soc_id() >> CHIP_ID_ID_SHIFT) & CHIP_ID_ID_MASK; +} + +static unsigned int __init rt2880_get_soc_rev(void) +{ + return (rt2880_get_soc_id() & CHIP_ID_REV_MASK); +} +void __init prom_soc_init(struct ralink_soc_info *soc_info) +{ + if (rt2880_soc_valid()) soc_info->compatible = "ralink,r2880-soc"; - name = "RT2880"; - } else { - panic("rt288x: unknown SoC, n0:%08x n1:%08x", n0, n1); - } + else + panic("rt288x: unknown SoC, n0:%08x n1:%08x", + rt2880_get_soc_name0(), rt2880_get_soc_name1()); snprintf(soc_info->sys_type, RAMIPS_SYS_TYPE_LEN, "Ralink %s id:%u rev:%u", - name, - (id >> CHIP_ID_ID_SHIFT) & CHIP_ID_ID_MASK, - (id & CHIP_ID_REV_MASK)); + rt2880_get_soc_name(), + rt2880_get_soc_ver(), + rt2880_get_soc_rev()); soc_info->mem_base = RT2880_SDRAM_BASE; soc_info->mem_size_min = RT2880_MEM_SIZE_MIN; From patchwork Mon Feb 27 10:58:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Paracuellos X-Patchwork-Id: 61912 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2349573wrd; Mon, 27 Feb 2023 03:02:32 -0800 (PST) X-Google-Smtp-Source: AK7set8r8SDgv+0dpvVtFjRzKkouitBeu6M4/gfIAOH3dpAwiNFBPdDbIR0eHtONRW5+Q0CRIWeA X-Received: by 2002:a17:90b:1d0f:b0:233:cc4c:2945 with SMTP id on15-20020a17090b1d0f00b00233cc4c2945mr25199572pjb.38.1677495752207; Mon, 27 Feb 2023 03:02:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677495752; cv=none; d=google.com; s=arc-20160816; b=vk2OJQzXMsBhzzqefCNtH+fQpXUTDycfRp8NiItIodfZpUNOS1WmUm5W7qvxxM//0G LdCvywunzD9Sjm5k6Rla844G95/adD1NxamR4I5bV+orGf35W2w3AuQElsbHPM2+g6SP z0/D6x6hz10Cuvp2BdT1wQ7rsaTv1v1ZKqRsi0C50k++rflbIxeH0WeJ6l3id/2n8tHc 072q4kl0z0nKjCYK3O5s0Q+aNstL3G5xmH+azKseodzNMRXW9H8aj+F6qcThz2WuJIg8 B3BlGgGkDgDgBvAASJN8ThNKVpdu1yc6sjkO4d6s6DdG1zSALPGYpXG/h/5D9ge7zEIw bwRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=S+BgnLruvamK2++KZsoFKmP2nKS18Ke5ejpmduGAEa8=; b=wp1Ac/jM0JYu3yzAeLn6WDeD7EzJdA4cwXLPW8HIehu6XcJeFA/2+/6LSydpX0Dara 0QXhqE5g8h3vqFj7PG9t3J5gqWPjb9C0J06LGowdqRaHY0Y/Mmz8IUduiT7dHVYm3OP5 VloavVVvb4jftOokMfLFz4Cok65AU3+lfEBSnKoNwTxkc1+YX7O1TcKVeluIeyrmT9FQ 50rG78FHMxeAyAdpgcvJAzWkRHuBtBf4nS5tPVKN4eT2LrWC7+tLhUFAGtFCModVc2fM 0F6XIo4RWyEYu76RJEadO3B21/GVUSI2+260BfUewBw74qY6EufBP7zlbQtCNXeqrxQp fUXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=bsA9jGba; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u8-20020a17090a400800b00232cb5c9b23si9631968pjc.180.2023.02.27.03.02.19; Mon, 27 Feb 2023 03:02:32 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=bsA9jGba; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230230AbjB0K6q (ORCPT + 99 others); Mon, 27 Feb 2023 05:58:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229874AbjB0K6W (ORCPT ); Mon, 27 Feb 2023 05:58:22 -0500 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2259199DC; Mon, 27 Feb 2023 02:58:18 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id v16so2929834wrn.0; Mon, 27 Feb 2023 02:58:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=S+BgnLruvamK2++KZsoFKmP2nKS18Ke5ejpmduGAEa8=; b=bsA9jGbaN8/IzJibEXpIpiU+I4jQ5MyTYNC5aKwo5JfsIU+U+UpYJkku4o75VITbfT ztIb5Gt7dd3veZMIBVrtHFRL5U68PzSuNGSGf2lo1InFqhgU19onwegovG3b95B9eV0y QYhE/dUY2xQvT6LYHaQzIJWhAgnZNMKKAuRbGpISLFJLdhbMGgY0YUjCemXH9KkOgGbH 2G7qMOHCT6Aj+ZJZwml/a3UjFgmE99SF/k4/qaZmXajqVJBIe82pYjQbtsHluxO7vq6l 9qUeC5enc6s54FrGL6i9I3h2G//xTCIcsNdMbKwKYuFyhQRMDBOb1gbidWZGzBO4f/Sf ov5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=S+BgnLruvamK2++KZsoFKmP2nKS18Ke5ejpmduGAEa8=; b=Ao3EKhMqdjtOb/lK93CTfSO7F9CR73BDrOpHqAQ+fuiLk69ueWgXinMXc2jRXjF5Wf hT/IcSaEM6TjK5fHkPviT8OVWjQv7biu8qzQRYiLO9Yrj3tkf3j0VvHfY41ekArMt3fz 0A5inTBffaLoESpAJKCX97pZnjp6gNiEmHkGK00FX6sHK5yZ5WU747QXSyyATaV6/Hdj dSB78543jPJvW/iDjK/E41Xw44OZFl681XTyAqPrOOz/nMVp5vnevepBCHe/S3DnDNje aQZ8jrI3/YMgPvI3odr6Bg1W61wCsHnEWKbHG8hkEpr1dlEZgp7Uui6YPOdx0FN7ztzD sJ2g== X-Gm-Message-State: AO0yUKU5K+iv7BVcWUjlrqF0O2QmE5rl8y1/JcLXf79GXixhcBUNmRDU J7Hmj4R/+Tw+DmMJo9APR9aaF4DVDbI= X-Received: by 2002:adf:f0cd:0:b0:2c7:d75:373a with SMTP id x13-20020adff0cd000000b002c70d75373amr14358125wro.1.1677495496839; Mon, 27 Feb 2023 02:58:16 -0800 (PST) Received: from localhost.localdomain (106.red-88-13-29.dynamicip.rima-tde.net. [88.13.29.106]) by smtp.gmail.com with ESMTPSA id a4-20020a5d5704000000b002c559843748sm6806122wrv.10.2023.02.27.02.58.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 02:58:16 -0800 (PST) From: Sergio Paracuellos To: linux-mips@vger.kernel.org Cc: tsbogend@alpha.franken.de, john@phrozen.org, linux-kernel@vger.kernel.org, git@johnthomson.fastmail.com.au Subject: [PATCH 09/12] mips: ralink: rt288x: introduce 'soc_device' initialization Date: Mon, 27 Feb 2023 11:58:03 +0100 Message-Id: <20230227105806.2394101-10-sergio.paracuellos@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230227105806.2394101-1-sergio.paracuellos@gmail.com> References: <20230227105806.2394101-1-sergio.paracuellos@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758981785859836895?= X-GMAIL-MSGID: =?utf-8?q?1758981785859836895?= RT288X SoCs have their own 'ralink_soc_info' structure with some information about the soc itself. In order to be able to retrieve this information from driver code and avoid architecture dependencies for retrieving these details introduce this 'soc_device'. Set 'data' pointer points to the struct 'ralink_soc_info' to be able to export also current soc information using this mechanism. We need to select 'SOC_BUS' in Kconfig configuration for these SoCs. Signed-off-by: Sergio Paracuellos --- arch/mips/ralink/Kconfig | 1 + arch/mips/ralink/rt288x.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/arch/mips/ralink/Kconfig b/arch/mips/ralink/Kconfig index f657e55b10b7..3e01e2df96b0 100644 --- a/arch/mips/ralink/Kconfig +++ b/arch/mips/ralink/Kconfig @@ -29,6 +29,7 @@ choice select MIPS_AUTO_PFN_OFFSET select MIPS_L1_CACHE_SHIFT_4 select HAVE_PCI + select SOC_BUS config SOC_RT305X bool "RT305x" diff --git a/arch/mips/ralink/rt288x.c b/arch/mips/ralink/rt288x.c index a417b8b89b94..456ba0b2599e 100644 --- a/arch/mips/ralink/rt288x.c +++ b/arch/mips/ralink/rt288x.c @@ -10,6 +10,8 @@ #include #include +#include +#include #include #include @@ -17,6 +19,8 @@ #include "common.h" +static struct ralink_soc_info *soc_info_ptr; + void __init ralink_clk_init(void) { unsigned long cpu_rate, wmac_rate = 40000000; @@ -98,6 +102,31 @@ static unsigned int __init rt2880_get_soc_rev(void) { return (rt2880_get_soc_id() & CHIP_ID_REV_MASK); } + +static int __init rt2880_soc_dev_init(void) +{ + struct soc_device *soc_dev; + struct soc_device_attribute *soc_dev_attr; + + soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); + if (!soc_dev_attr) + return -ENOMEM; + + soc_dev_attr->family = "Ralink"; + soc_dev_attr->soc_id = rt2880_get_soc_name(); + + soc_dev_attr->data = soc_info_ptr; + + soc_dev = soc_device_register(soc_dev_attr); + if (IS_ERR(soc_dev)) { + kfree(soc_dev_attr); + return PTR_ERR(soc_dev); + } + + return 0; +} +device_initcall(rt2880_soc_dev_init); + void __init prom_soc_init(struct ralink_soc_info *soc_info) { if (rt2880_soc_valid()) @@ -117,4 +146,5 @@ void __init prom_soc_init(struct ralink_soc_info *soc_info) soc_info->mem_size_max = RT2880_MEM_SIZE_MAX; ralink_soc = RT2880_SOC; + soc_info_ptr = soc_info; } From patchwork Mon Feb 27 10:58:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Paracuellos X-Patchwork-Id: 61918 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2350095wrd; Mon, 27 Feb 2023 03:03:39 -0800 (PST) X-Google-Smtp-Source: AK7set/9cV6ZxRT02E38iwbzBlY4bVyPNjlL0UB0zjC7mYuNuwM7k+mg3dQW1M0P/SaTafmi9f/d X-Received: by 2002:a17:90b:5109:b0:237:ae98:a47f with SMTP id sc9-20020a17090b510900b00237ae98a47fmr8665589pjb.1.1677495819312; Mon, 27 Feb 2023 03:03:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677495819; cv=none; d=google.com; s=arc-20160816; b=rgP3uhjm84pv8gynoHfMogUb+aQSetTv7YoIEEZPD3h/7MVPUuBK+gshqdWnIov6oQ yvOpYHLFxLerDjC/voLPaqvAbEPztsAIp/N+gJ2Q4sDdTuVJl8ZMDK04zTIzafhFIhBo F4rSd9ux/6Q/4oezMPAkplOfU3pM4VaWumDLMnA+vL05gBtCBv+D2TbFSb5nVGT2DvQq hLUrPF3XJD9N/P4SQkhI8EKJ5iBuiYuV3nRGWOM3vpGNCYUVp7F1hRHiaIyva/zGedWi JKvbxPR3s+rqliHDAPnqPDYTPiLONEKvY1KsGTdS3oT7QJdsEGWfRVITF/h2nIKYr021 kRfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=brrg22pJXALLuqjwL3ofKoGSohLv11kyaas+ufZNm48=; b=TguJ7l6fnEMgtiQOUPixnkq5m1+wY1K2zyJp3DxIM/MZmyfWI16ErZ2jxplvxatXxl mSn9O9LvFOJiIT0i6ZkzDJBEA3cz+EZu/0QRK8UiIaidRvgRRYFlAuj18lsC5c+UsMRg wLVTvibTHdtoQ5fRWU6yLSdYdPy1UIGGYiaClkmhUyBVd7HYsrDcOZYtgqoKSWZvS+ll KF74oIuDi58N4kQrwqFCe/dyCEBRjbto187qUFmK57s8z3CF9vxiY6PArr4u0a/7IgcP eoEzdzbrGzg8MI+Y+e3VJi94ewQY8TWv4MhD0XLpEDvEUsrtJrGUZLgovnf62abbwMPc DQfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="RIhWaol/"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i8-20020a17090adc0800b002376d8568e1si10166615pjv.114.2023.02.27.03.03.26; Mon, 27 Feb 2023 03:03:39 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20210112 header.b="RIhWaol/"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230242AbjB0K6r (ORCPT + 99 others); Mon, 27 Feb 2023 05:58:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230118AbjB0K6X (ORCPT ); Mon, 27 Feb 2023 05:58:23 -0500 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73D7E1B572; Mon, 27 Feb 2023 02:58:19 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id q16so5750438wrw.2; Mon, 27 Feb 2023 02:58:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=brrg22pJXALLuqjwL3ofKoGSohLv11kyaas+ufZNm48=; b=RIhWaol/uA/GNrRqyAErinRj1oB4C/GL0DLtY0DOT2EJ+VVYsUi/YSlfPHNlwGpN1x FGP8CNWcKOnQjKERksMLpDjk0u+4UGV3ExIzToMCsEKTR5Maapq5t4cXkvxT9iYSWLAG ritysr5OvqfRTuwE97V4/8yaRrBWX06n11KuQtEz/Dd9IJCLwReXZ9HZtn+2PwYU76+f O7ACNKJl2yFoFOnKoFtQ/KhGM94bTFMP9i5HLXWkgSe/L/M5Fpq2uumH747ryXgM9B4g dG5k5YpxI7VmMcb/m6md6KDLFFSc/We4MJCGDadidjJ8li4dxHUJGINPO5G8youlnUD1 QphA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=brrg22pJXALLuqjwL3ofKoGSohLv11kyaas+ufZNm48=; b=bY+RwKuCz7eFPQu60J5atcamzns9BRkQmRsqgsNu3ZR33sn2pqk3IauVo3itX+qlgr f12AwV+C7ScrO1UEnou01px36fWZtZeAojI488qgHon0uxk7t2632meMXlvzvbdM+KFf c+8VcP3URM71xmXOCubzTZGgYWkUkPkuCaliIhbyIzbbUvUAcNMjYiUFlyEP35GmjKcm 9HOlBLyZr/lQGbtjoR/UvICUJNNzm9XJx04wHnWI11st1vr2EVuF2zaEs4uNxYeKIf4P VtGCfORvWMmbtAxtqPbolHEc6viQbZOjs/U9G9pRtEM8F9ANEawE/NyqGdrUdFIJxv0v dOAQ== X-Gm-Message-State: AO0yUKV3XtGBBqZ79RK6X+4Dct8xWxOr8PNELzWoXfrkM+j+bFkNb5pK hmoWhV6QaTkSttWw9wV0VH1UWLonLY4= X-Received: by 2002:adf:dd45:0:b0:2c7:a55:bef5 with SMTP id u5-20020adfdd45000000b002c70a55bef5mr14150209wrm.23.1677495497782; Mon, 27 Feb 2023 02:58:17 -0800 (PST) Received: from localhost.localdomain (106.red-88-13-29.dynamicip.rima-tde.net. [88.13.29.106]) by smtp.gmail.com with ESMTPSA id a4-20020a5d5704000000b002c559843748sm6806122wrv.10.2023.02.27.02.58.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 02:58:17 -0800 (PST) From: Sergio Paracuellos To: linux-mips@vger.kernel.org Cc: tsbogend@alpha.franken.de, john@phrozen.org, linux-kernel@vger.kernel.org, git@johnthomson.fastmail.com.au Subject: [PATCH 10/12] mips: ralink: mt7620: define MT7620_SYSC_BASE with __iomem Date: Mon, 27 Feb 2023 11:58:04 +0100 Message-Id: <20230227105806.2394101-11-sergio.paracuellos@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230227105806.2394101-1-sergio.paracuellos@gmail.com> References: <20230227105806.2394101-1-sergio.paracuellos@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758981856606669446?= X-GMAIL-MSGID: =?utf-8?q?1758981856606669446?= So that MT7620_SYSC_BASE can be used later in multiple functions without needing to repeat this __iomem declaration each time Signed-off-by: Sergio Paracuellos --- arch/mips/include/asm/mach-ralink/mt7620.h | 3 ++- arch/mips/ralink/mt7620.c | 15 +++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/arch/mips/include/asm/mach-ralink/mt7620.h b/arch/mips/include/asm/mach-ralink/mt7620.h index d51dfad8f543..3e37705ea9cf 100644 --- a/arch/mips/include/asm/mach-ralink/mt7620.h +++ b/arch/mips/include/asm/mach-ralink/mt7620.h @@ -11,7 +11,8 @@ #ifndef _MT7620_REGS_H_ #define _MT7620_REGS_H_ -#define MT7620_SYSC_BASE 0x10000000 +#define IOMEM(x) ((void __iomem *)(KSEG1ADDR(x))) +#define MT7620_SYSC_BASE IOMEM(0x10000000) #define SYSC_REG_CHIP_NAME0 0x00 #define SYSC_REG_CHIP_NAME1 0x04 diff --git a/arch/mips/ralink/mt7620.c b/arch/mips/ralink/mt7620.c index ae1fa0391c88..c13b73b6ee3f 100644 --- a/arch/mips/ralink/mt7620.c +++ b/arch/mips/ralink/mt7620.c @@ -326,7 +326,6 @@ mt7628_dram_init(struct ralink_soc_info *soc_info) void __init prom_soc_init(struct ralink_soc_info *soc_info) { - void __iomem *sysc = (void __iomem *) KSEG1ADDR(MT7620_SYSC_BASE); unsigned char *name = NULL; u32 n0; u32 n1; @@ -336,9 +335,9 @@ void __init prom_soc_init(struct ralink_soc_info *soc_info) u32 pmu1; u32 bga; - n0 = __raw_readl(sysc + SYSC_REG_CHIP_NAME0); - n1 = __raw_readl(sysc + SYSC_REG_CHIP_NAME1); - rev = __raw_readl(sysc + SYSC_REG_CHIP_REV); + n0 = __raw_readl(MT7620_SYSC_BASE + SYSC_REG_CHIP_NAME0); + n1 = __raw_readl(MT7620_SYSC_BASE + SYSC_REG_CHIP_NAME1); + rev = __raw_readl(MT7620_SYSC_BASE + SYSC_REG_CHIP_REV); bga = (rev >> CHIP_REV_PKG_SHIFT) & CHIP_REV_PKG_MASK; if (n0 == MT7620_CHIP_NAME0 && n1 == MT7620_CHIP_NAME1) { @@ -352,7 +351,7 @@ void __init prom_soc_init(struct ralink_soc_info *soc_info) soc_info->compatible = "ralink,mt7620n-soc"; } } else if (n0 == MT7620_CHIP_NAME0 && n1 == MT7628_CHIP_NAME1) { - u32 efuse = __raw_readl(sysc + SYSC_REG_EFUSE_CFG); + u32 efuse = __raw_readl(MT7620_SYSC_BASE + SYSC_REG_EFUSE_CFG); if (efuse & EFUSE_MT7688) { ralink_soc = MT762X_SOC_MT7688; @@ -372,7 +371,7 @@ void __init prom_soc_init(struct ralink_soc_info *soc_info) (rev >> CHIP_REV_VER_SHIFT) & CHIP_REV_VER_MASK, (rev & CHIP_REV_ECO_MASK)); - cfg0 = __raw_readl(sysc + SYSC_REG_SYSTEM_CONFIG0); + cfg0 = __raw_readl(MT7620_SYSC_BASE + SYSC_REG_SYSTEM_CONFIG0); if (is_mt76x8()) { dram_type = cfg0 & DRAM_TYPE_MT7628_MASK; } else { @@ -388,8 +387,8 @@ void __init prom_soc_init(struct ralink_soc_info *soc_info) else mt7620_dram_init(soc_info); - pmu0 = __raw_readl(sysc + PMU0_CFG); - pmu1 = __raw_readl(sysc + PMU1_CFG); + pmu0 = __raw_readl(MT7620_SYSC_BASE + PMU0_CFG); + pmu1 = __raw_readl(MT7620_SYSC_BASE + PMU1_CFG); pr_info("Analog PMU set to %s control\n", (pmu0 & PMU_SW_SET) ? ("sw") : ("hw")); From patchwork Mon Feb 27 10:58:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Paracuellos X-Patchwork-Id: 61915 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2350004wrd; Mon, 27 Feb 2023 03:03:24 -0800 (PST) X-Google-Smtp-Source: AK7set+3WJuALBntLN9K/e6Hyb2eFlqHTeWkhQIlnF91gLgF2I3NIjVTGZAXUyxDU0W4ML9VUJCj X-Received: by 2002:a17:907:608a:b0:8de:acd1:90f0 with SMTP id ht10-20020a170907608a00b008deacd190f0mr29352815ejc.3.1677495804683; Mon, 27 Feb 2023 03:03:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677495804; cv=none; d=google.com; s=arc-20160816; b=GhgmbhfOH+k/FZSbAMmrx7VwQrUEDIgL+xLPVDp8DvHzPS+CGIf+ACoWBom/EiNiAX TWL9CAL3EI03oy7kmhGuQY8VPTtq0KnUHeLtzUpiniVA+mjl86MTNKwd9ilHtvNlQKYY +4bcOrJnqQXHI4KuokjzXKv66YCdowVehRwYNKJx4sgh2Dz6pVMT6R6Tfr9UhrBfCmEv FT0a0W0okraYYUzPrbB3B9K6IjceerO/kSP+8mXvcQYbvNu5dWiKBDzDwBtqOkwvkVP1 z+PwfG/WJnURVbwzc2h5P6D5TVLMfLg+yg9MtW+7whTA3qskK9Kgv4BCVkJCYj7rdjQB 4tsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sUV9hLKOdU18pBMiDrMjFGutWffcfv1IB6gkYAwpmlw=; b=YpPyosfArSIlt54H4msNTQgglDyfLVPK+2SY7ZVzmYWASgdUZNxcRayDBxlA8yl6+Y SutYAo+IhwFkZ0KfmeLteNL2BdEpJ5yPFlzaNGe8wBtiyM9rtCbzKvkrYo5wEuAMRt3a +LSajUY+doyjXOkT8dLHcdQtix5eUbShR+GUMT68/kego0NR6fMjrqA2eY9FFBf2Eg9H 2bNr5w6H4L9yl9RQ6Add5vhmKHxhSdyGND+3C/C7OtN9QOrkFW07nH9pGzLZOxeZ9ZN8 xi/v+h1z44NhUaMjXyiKIJ2wr8b8gitt3qp1RZMYDQ3M3DtJCqR5UTSjIgG0zrB5NwJp BETA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="Ur6w/ahw"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t8-20020a05640203c800b004acc030698dsi383675edw.513.2023.02.27.03.03.02; Mon, 27 Feb 2023 03:03:24 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20210112 header.b="Ur6w/ahw"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229777AbjB0K7K (ORCPT + 99 others); Mon, 27 Feb 2023 05:59:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230139AbjB0K6Y (ORCPT ); Mon, 27 Feb 2023 05:58:24 -0500 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D57812BF8; Mon, 27 Feb 2023 02:58:20 -0800 (PST) Received: by mail-wr1-x429.google.com with SMTP id j2so5715324wrh.9; Mon, 27 Feb 2023 02:58:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sUV9hLKOdU18pBMiDrMjFGutWffcfv1IB6gkYAwpmlw=; b=Ur6w/ahwqv/lj3FjKNGY7RbDcan7PvkgloTbDyYRRh1gpj8KzbA6Cmb/d4LIRKLjUs MJineUYEOjpaR6vbOXl5TblUDJfBPY+BiNhXfhK6B1aoZimRLaXWLFjzRtf6UlnGn+lM IB9kUKCSF7RpIaG2//IlpXEh+ZaMkaTBdDKylIyBlhFFJgy1Zpk4PAAYTaxWy5ku7Ly4 Lrb8VHOmhzoDVpr6cIND+rwszj80mOfEy1qelMInJv8ynnDmDCZyRqsFSp4c4aI2zEFd NAglJ5HfohCpioezXfvPVgytrnC/+pdsf5FNcamWme1fJ3C7+GlMzQuhn0ARd1knGz4Q os0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sUV9hLKOdU18pBMiDrMjFGutWffcfv1IB6gkYAwpmlw=; b=6G92hDgRd5sGLbVa90gbh40znFX/kMZuI2G7DtoMnSITVk4STCZn+EoQNZr0SHdudC HrA1fnKm5UmOcYVsdBBIoOGrXnTKfWfulk8HBTT9QG6U7YvN4C03HL+slQG9ijS9gYGd miiCDQY5jM5ASly6vGO3FTJDTChm9xUmDMkgdLpCQPvKDsO3YeiASTHIxqoGAbVpdzBQ ss4Ta12V70g5pRUiU9f0Gf1dDl0SZk+0kOe0QCldX81vlwn9raqeGmRgFuTNE3SDnaaO NGQ3V46/8+p5onzsveCM6rCiISacb4oSR+C+v7ujHoWEx9HrS4EKy9wWJG7A8PbYUzyF mx8Q== X-Gm-Message-State: AO0yUKVb9ceEVAwH+5mkElZ7Tml/kz31VFbEOhNEqycJkClvttbTcwkg 2JoUQJKZqBFlNKBKbHef8hRuxadHhxA= X-Received: by 2002:adf:fbc8:0:b0:2c5:5ff8:93e5 with SMTP id d8-20020adffbc8000000b002c55ff893e5mr18944881wrs.44.1677495498702; Mon, 27 Feb 2023 02:58:18 -0800 (PST) Received: from localhost.localdomain (106.red-88-13-29.dynamicip.rima-tde.net. [88.13.29.106]) by smtp.gmail.com with ESMTPSA id a4-20020a5d5704000000b002c559843748sm6806122wrv.10.2023.02.27.02.58.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 02:58:18 -0800 (PST) From: Sergio Paracuellos To: linux-mips@vger.kernel.org Cc: tsbogend@alpha.franken.de, john@phrozen.org, linux-kernel@vger.kernel.org, git@johnthomson.fastmail.com.au Subject: [PATCH 11/12] mips: ralink: mt7620: soc queries and tests as functions Date: Mon, 27 Feb 2023 11:58:05 +0100 Message-Id: <20230227105806.2394101-12-sergio.paracuellos@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230227105806.2394101-1-sergio.paracuellos@gmail.com> References: <20230227105806.2394101-1-sergio.paracuellos@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758981840627412901?= X-GMAIL-MSGID: =?utf-8?q?1758981840627412901?= Move the SoC register value queries and tests to specific functions, to remove repetition of logic. No functional changes intended Signed-off-by: Sergio Paracuellos --- arch/mips/ralink/mt7620.c | 94 ++++++++++++++++++++++++++++++--------- 1 file changed, 72 insertions(+), 22 deletions(-) diff --git a/arch/mips/ralink/mt7620.c b/arch/mips/ralink/mt7620.c index c13b73b6ee3f..8604d91f3375 100644 --- a/arch/mips/ralink/mt7620.c +++ b/arch/mips/ralink/mt7620.c @@ -324,34 +324,76 @@ mt7628_dram_init(struct ralink_soc_info *soc_info) } } -void __init prom_soc_init(struct ralink_soc_info *soc_info) +static unsigned int __init mt7620_get_soc_name0(void) { - unsigned char *name = NULL; - u32 n0; - u32 n1; - u32 rev; - u32 cfg0; - u32 pmu0; - u32 pmu1; - u32 bga; + return __raw_readl(MT7620_SYSC_BASE + SYSC_REG_CHIP_NAME0); +} + +static unsigned int __init mt7620_get_soc_name1(void) +{ + return __raw_readl(MT7620_SYSC_BASE + SYSC_REG_CHIP_NAME1); +} + +static bool __init mt7620_soc_valid(void) +{ + if (mt7620_get_soc_name0() == MT7620_CHIP_NAME0 && + mt7620_get_soc_name1() == MT7620_CHIP_NAME1) + return true; + else + return false; +} + +static bool __init mt7628_soc_valid(void) +{ + if (mt7620_get_soc_name0() == MT7620_CHIP_NAME0 && + mt7620_get_soc_name1() == MT7628_CHIP_NAME1) + return true; + else + return false; +} - n0 = __raw_readl(MT7620_SYSC_BASE + SYSC_REG_CHIP_NAME0); - n1 = __raw_readl(MT7620_SYSC_BASE + SYSC_REG_CHIP_NAME1); - rev = __raw_readl(MT7620_SYSC_BASE + SYSC_REG_CHIP_REV); - bga = (rev >> CHIP_REV_PKG_SHIFT) & CHIP_REV_PKG_MASK; +static unsigned int __init mt7620_get_rev(void) +{ + return __raw_readl(MT7620_SYSC_BASE + SYSC_REG_CHIP_REV); +} + +static unsigned int __init mt7620_get_bga(void) +{ + return (mt7620_get_rev() >> CHIP_REV_PKG_SHIFT) & CHIP_REV_PKG_MASK; +} + +static unsigned int __init mt7620_get_efuse(void) +{ + return __raw_readl(MT7620_SYSC_BASE + SYSC_REG_EFUSE_CFG); +} + +static unsigned int __init mt7620_get_soc_ver(void) +{ + return (mt7620_get_rev() >> CHIP_REV_VER_SHIFT) & CHIP_REV_VER_MASK; +} + +static unsigned int __init mt7620_get_soc_eco(void) +{ + return (mt7620_get_rev() & CHIP_REV_ECO_MASK); +} + +static const char __init *mt7620_get_soc_name(struct ralink_soc_info *soc_info) +{ + if (mt7620_soc_valid()) { + u32 bga = mt7620_get_bga(); - if (n0 == MT7620_CHIP_NAME0 && n1 == MT7620_CHIP_NAME1) { if (bga) { ralink_soc = MT762X_SOC_MT7620A; - name = "MT7620A"; soc_info->compatible = "ralink,mt7620a-soc"; + return "MT7620A"; } else { ralink_soc = MT762X_SOC_MT7620N; - name = "MT7620N"; soc_info->compatible = "ralink,mt7620n-soc"; + return "MT7620N"; } - } else if (n0 == MT7620_CHIP_NAME0 && n1 == MT7628_CHIP_NAME1) { - u32 efuse = __raw_readl(MT7620_SYSC_BASE + SYSC_REG_EFUSE_CFG); + } else if (mt7628_soc_valid()) { + u32 efuse = mt7620_get_efuse(); + unsigned char *name = NULL; if (efuse & EFUSE_MT7688) { ralink_soc = MT762X_SOC_MT7688; @@ -361,15 +403,23 @@ void __init prom_soc_init(struct ralink_soc_info *soc_info) name = "MT7628AN"; } soc_info->compatible = "ralink,mt7628an-soc"; + return name; } else { - panic("mt762x: unknown SoC, n0:%08x n1:%08x\n", n0, n1); + panic("mt762x: unknown SoC, n0:%08x n1:%08x\n", + mt7620_get_soc_name0(), mt7620_get_soc_name1()); } +} + +void __init prom_soc_init(struct ralink_soc_info *soc_info) +{ + const char *name = mt7620_get_soc_name(soc_info); + u32 cfg0; + u32 pmu0; + u32 pmu1; snprintf(soc_info->sys_type, RAMIPS_SYS_TYPE_LEN, "MediaTek %s ver:%u eco:%u", - name, - (rev >> CHIP_REV_VER_SHIFT) & CHIP_REV_VER_MASK, - (rev & CHIP_REV_ECO_MASK)); + name, mt7620_get_soc_ver(), mt7620_get_soc_eco()); cfg0 = __raw_readl(MT7620_SYSC_BASE + SYSC_REG_SYSTEM_CONFIG0); if (is_mt76x8()) { From patchwork Mon Feb 27 10:58:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Paracuellos X-Patchwork-Id: 61914 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2350003wrd; Mon, 27 Feb 2023 03:03:24 -0800 (PST) X-Google-Smtp-Source: AK7set+/AblQun4C0EDyIwNSFxblxdADWlz36nOOP6U/WTCUf0uILIZmesogUvZRp3VumqO6/Bks X-Received: by 2002:a17:906:6a27:b0:8e3:da5c:56f7 with SMTP id qw39-20020a1709066a2700b008e3da5c56f7mr25715080ejc.76.1677495804459; Mon, 27 Feb 2023 03:03:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677495804; cv=none; d=google.com; s=arc-20160816; b=PxSTqV/C0EkYbN1PL/6sn5lq4wS8LqMsrpkvCQw1Gt29VQTioGiEm8yKTIkW9WMnD3 0yK6e7AOUMupJ15gRBttqiWBwSc6aDIGwhoKifrx9q7qM6qAdCP/2WhMqNRjvVex8Wu8 wLtwAhi+P6X3P26diM6BGYNBG9rIURfwb5RxbP4JdnluUacfOiMxlrV6hOzL/VxHfrZ6 kxu4hDuYjizGmSiGqhxfnjcGgAFWzH91WzBcHWiIBHvTK3dUVzMjCZtiDmrFHPvghyxu 4U7NwRTgVjudVAT0fUBoF7xaZYaiWICkNIKB2sPFzvMr/3R4Yj8m5qp4KV48ud181rmX 6t3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LUIj51PNz0xKbBS1KQE1NGFBEuNj+zGXmUx8EwDrEEo=; b=n4Zu+u+lAJUnGztmTrMk31TtuVDf701us4T4CCfnVlCLAhN8ji/Mo5W3V5RP6LJyo8 /hgLfJpxzaSDFVUycKhDaEJDMEE3zjIqmqGR4rMHnwiGVwv19MaT32ksMySEvoZhs3Dk 4q6S+wZkNBecET5dWzMu7Kf0jC/3YOas1+1jCfTFCjQvJz+BR47Cl2Si6qn+LkKBvUHK i4opu1rPxohWWp/FVB2ylF6Pv2X9+qb0+RNESTu6qIxQoLTp0TwmPrYbqsxEWZEyFsYd ShXC/3/QMzgofDt1M/PEw2F3UH+d3fPlT5NzHmAyFvrvyXJipBZu4yy7dqG3xOqD6m2I RGrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=TJYUtDgq; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k18-20020a1709061c1200b008ceed901431si154007ejg.360.2023.02.27.03.03.01; Mon, 27 Feb 2023 03:03:24 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=TJYUtDgq; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229773AbjB0K7G (ORCPT + 99 others); Mon, 27 Feb 2023 05:59:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230147AbjB0K6Z (ORCPT ); Mon, 27 Feb 2023 05:58:25 -0500 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7155D10AAE; Mon, 27 Feb 2023 02:58:21 -0800 (PST) Received: by mail-wm1-x32d.google.com with SMTP id l7-20020a05600c4f0700b003e79fa98ce1so3559817wmq.2; Mon, 27 Feb 2023 02:58:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LUIj51PNz0xKbBS1KQE1NGFBEuNj+zGXmUx8EwDrEEo=; b=TJYUtDgqq9fjYccEW/VNEByBE9lmodlqJVkF6UoDUTECzXGQdVxmSRkGnC4sgATJ3C OpV7BIvpnGMbb7e69N6ba26mdPG9o4UWaAMeMFP2M3c7urK3w3RT4ftZBgAHY1V+DMIL 90aS0fgh3JohfkogcQBFi2Kt1DY36wNdY9iOzRZ31CUkyzQUPnOEeNrFkdr7ka54XUaM /lZ/W9DlOkXM50U25a06s5tX4JAh5Ns5MfDkuDmNC2zWOc7ZgXQJHYBppp5RdzzqQzqe EL2rlrcA8QcuAJ6JpAQOpbNh5q4gGhhrZ1/sGnin3kTYE7H/Ixh1OpS0h6FtvSQLqwNs NSnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LUIj51PNz0xKbBS1KQE1NGFBEuNj+zGXmUx8EwDrEEo=; b=18PhZNM2JKTkS/imc+fwP4Icb9490dJYlWjPDcXIMJTSq8hvuPk0cTGOzdgUdvMeCR 7Ma0pJTxVzgMYd49b3V6AWeBzRY9CoZ1bfpFMcYVZ5bGl7qeEe9SSXCcsye4FvRdXdyj ZIViPWG2/Q9+mAywtdzBKxS6BufswwBFsddlL674h268vaIpVtiDEZXPJw8kQXjUONdV t/eWrpt2ZaTnpvZvq76mXe/BQeDKpWx6uQQcQPSJHDzRKpoC9t1B6RTOpu7lYTkzrlSM SuAhTov+6dBUX9nLKRpprZwcGaxFfw4L6GPzXTFEzBVCvIjklC8eJGXiX7AIzY+otZ4g yGNw== X-Gm-Message-State: AO0yUKV5zaTt/40pIH9i7PCG7AXJI7Fol1kyeWlpQBs1oQjjEiADwC10 UWVGm25s3s9Hszu31V1XThmJbllWpiI= X-Received: by 2002:a05:600c:19cb:b0:3eb:4cb5:e13 with SMTP id u11-20020a05600c19cb00b003eb4cb50e13mr386314wmq.31.1677495499660; Mon, 27 Feb 2023 02:58:19 -0800 (PST) Received: from localhost.localdomain (106.red-88-13-29.dynamicip.rima-tde.net. [88.13.29.106]) by smtp.gmail.com with ESMTPSA id a4-20020a5d5704000000b002c559843748sm6806122wrv.10.2023.02.27.02.58.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 02:58:19 -0800 (PST) From: Sergio Paracuellos To: linux-mips@vger.kernel.org Cc: tsbogend@alpha.franken.de, john@phrozen.org, linux-kernel@vger.kernel.org, git@johnthomson.fastmail.com.au Subject: [PATCH 12/12] mips: ralink: mt7620: introduce 'soc_device' initialization Date: Mon, 27 Feb 2023 11:58:06 +0100 Message-Id: <20230227105806.2394101-13-sergio.paracuellos@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230227105806.2394101-1-sergio.paracuellos@gmail.com> References: <20230227105806.2394101-1-sergio.paracuellos@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758981840761144743?= X-GMAIL-MSGID: =?utf-8?q?1758981840761144743?= MT7620 SoCs have their own 'ralink_soc_info' structure with some information about the soc itself. In order to be able to retrieve this information from driver code and avoid architecture dependencies for retrieving these details introduce this 'soc_device'. Set 'data' pointer points to the struct 'ralink_soc_info' to be able to export also current soc information using this mechanism. We need to select 'SOC_BUS' in Kconfig configuration for these SoCs. Signed-off-by: Sergio Paracuellos --- arch/mips/ralink/Kconfig | 1 + arch/mips/ralink/mt7620.c | 44 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/arch/mips/ralink/Kconfig b/arch/mips/ralink/Kconfig index 3e01e2df96b0..088d46f16800 100644 --- a/arch/mips/ralink/Kconfig +++ b/arch/mips/ralink/Kconfig @@ -44,6 +44,7 @@ choice bool "MT7620/8" select CPU_MIPSR2_IRQ_VI select HAVE_PCI + select SOC_BUS config SOC_MT7621 bool "MT7621" diff --git a/arch/mips/ralink/mt7620.c b/arch/mips/ralink/mt7620.c index 8604d91f3375..4435f50b8d24 100644 --- a/arch/mips/ralink/mt7620.c +++ b/arch/mips/ralink/mt7620.c @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include #include @@ -49,6 +51,8 @@ /* does the board have sdram or ddram */ static int dram_type; +static struct ralink_soc_info *soc_info_ptr; + static __init u32 mt7620_calc_rate(u32 ref_rate, u32 mul, u32 div) { @@ -410,6 +414,44 @@ static const char __init *mt7620_get_soc_name(struct ralink_soc_info *soc_info) } } +static const char __init *mt7620_get_soc_id_name(void) +{ + if (ralink_soc == MT762X_SOC_MT7620A) + return "mt7620a"; + else if (ralink_soc == MT762X_SOC_MT7620N) + return "mt7620n"; + else if (ralink_soc == MT762X_SOC_MT7688) + return "mt7688"; + else if (ralink_soc == MT762X_SOC_MT7628AN) + return "mt7628n"; + else + return "invalid"; +} + +static int __init mt7620_soc_dev_init(void) +{ + struct soc_device *soc_dev; + struct soc_device_attribute *soc_dev_attr; + + soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); + if (!soc_dev_attr) + return -ENOMEM; + + soc_dev_attr->family = "Ralink"; + soc_dev_attr->soc_id = mt7620_get_soc_id_name(); + + soc_dev_attr->data = soc_info_ptr; + + soc_dev = soc_device_register(soc_dev_attr); + if (IS_ERR(soc_dev)) { + kfree(soc_dev_attr); + return PTR_ERR(soc_dev); + } + + return 0; +} +device_initcall(mt7620_soc_dev_init); + void __init prom_soc_init(struct ralink_soc_info *soc_info) { const char *name = mt7620_get_soc_name(soc_info); @@ -444,4 +486,6 @@ void __init prom_soc_init(struct ralink_soc_info *soc_info) (pmu0 & PMU_SW_SET) ? ("sw") : ("hw")); pr_info("Digital PMU set to %s control\n", (pmu1 & DIG_SW_SEL) ? ("sw") : ("hw")); + + soc_info_ptr = soc_info; }