From nobody Tue Feb 10 23:13:50 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=htecgroup.com); dmarc=pass(p=reject dis=none) header.from=htecgroup.com ARC-Seal: i=2; a=rsa-sha256; t=1766483443; cv=pass; d=zohomail.com; s=zohoarc; b=fmv5tPDoefb0xpFRPv/qaSnv7Fm9SGYueJbBDB7sCIhdjJi/rB5ZyGOvdfZa+iNHa4EcNPwuVTb6w7AKVeNSuDQHDqwJwWVjxpy5REOcUs2HRzM+r6E1eeR18QKK/kBA5C7pp+kfQU/9mrXrRDaId6yW4kaFSS1Oa8pbFqJXy80= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1766483443; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/WYVTxE+FvymIPKyI3809k6HIt3CoHfJWvOgH09zKzU=; b=E/yDhqc8WUgz07jGmtZHlW3RZGm+h4CTAhIbrqNkCgOBNovZq6DQ2l06SIAF6fi4u28CNm+TfWkRUqqM6nlrw4r8sR4O1MBCa7TF38VE8+c0dlKEXGKlgB6C+xsxtbuT9sXLFbq2yO5lQcQWD3NvoqLhexaweAoKMAgwhFxAjIo= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=htecgroup.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1766483443015120.96151537054914; Tue, 23 Dec 2025 01:50:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vXyzs-0001V7-SN; Tue, 23 Dec 2025 04:48:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vXyzp-0001TZ-RA; Tue, 23 Dec 2025 04:48:02 -0500 Received: from mail-northeuropeazlp170110003.outbound.protection.outlook.com ([2a01:111:f403:c200::3] helo=DU2PR03CU002.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vXyzn-00025T-RF; Tue, 23 Dec 2025 04:48:01 -0500 Received: from DB8PR09MB2796.eurprd09.prod.outlook.com (2603:10a6:10:ab::30) by AS8PR09MB5758.eurprd09.prod.outlook.com (2603:10a6:20b:539::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9456.11; Tue, 23 Dec 2025 09:47:54 +0000 Received: from DB8PR09MB2796.eurprd09.prod.outlook.com ([fe80::e42:9fbc:3e58:febe]) by DB8PR09MB2796.eurprd09.prod.outlook.com ([fe80::e42:9fbc:3e58:febe%6]) with mapi id 15.20.9434.009; Tue, 23 Dec 2025 09:47:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Q6aPcLvRx7jEboQDQCbz8INVGBtrzyasc+xQUpDWmdaTJUkX00Qjit+nD45NsKEMsXwoSTtdEQMfyJeRt9C9rw/z+iKeOVcxEwlVx1F0IXx3grs6da6W6e+92ShPHf5Ewcz45qiGsCldil1pjgYpBZ8G792MJqKU9s1dgi8cZYnF1v3CkKzS5kPSKc8QCA9mucRsWqLC6TMs/QGz7Ot+QLCU40bf38Bxk5JkeMJH7RQSf8ulOLdEYQKlpFfoDJPYPJiFeltY7DddlwDE0M9uyRBs8mpOjiXjvqwOy+uz0+7Szi3ig5mG/0ZXbKufwK2pukLhcAOi+uR93lHEx0ecLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/WYVTxE+FvymIPKyI3809k6HIt3CoHfJWvOgH09zKzU=; b=v3QwxNSrPA2KKYBFBzyazr4JhjlZQ25BGg2HmJVq2gZVrwIDAbUga5f/3Fud0G96ahZVfTVv3T5oMUSKN/pWeIBZJvwVI4q1Anp6Y/xbqZTqBTVpKNUN7hSM6Q6VnWD2qIRAQOJ9b8lmGxlEcvcdakSrN0IQnWOvVkr8cvRZjWhuqq/PoTyWJMttYSc89hbtoLGGBmqmtGVgJOtz08X37qseg3AMB0Zp7MHx+kM4HzPSe1HmdLE3YeNHgJkqs0IWzujOFE08EPdGQf38x69addkSDW+kvDERtNiWpamgmcXkJ1qGxkxw18qcDtrJtznbho6TM9XhxDWXFxvhuozkPw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=htecgroup.com; dmarc=pass action=none header.from=htecgroup.com; dkim=pass header.d=htecgroup.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=htecgroup.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/WYVTxE+FvymIPKyI3809k6HIt3CoHfJWvOgH09zKzU=; b=jJYt8Ya2+ur+x09JjwsJrwRd8GpvoBj5sPT6WlwTlV44bIHTlllYzkJyAOxgaI0u8558mtc+Liqnj/4r74fM4vCcexYQoZpJU8v0cx7eyqsT5A0hoVTfX4AKugsyQfyM9gvkKwP7a+cFFuAIvv5cgGI+ljOj9VvKPIJl68EwqS/A+xqGpFWkGsoA6b5Bu8L/Z+9wMagRJ0Mh2+iRZ0fPYNhUn0u+ncxs+4ROHbvlJ0SO67OQyvfEBccWc1Lga8xaaXQp3lGuCjqaV1iF3/+MxM8ZmigU0xySTdd3vLi15wiMXyl0wEXnJdowFQ4FGE1kMKB18tHODcJ93rRB6/klZg== From: Djordje Todorovic To: "qemu-devel@nongnu.org" CC: "qemu-riscv@nongnu.org" , "cfu@mips.com" , "mst@redhat.com" , "marcel.apfelbaum@gmail.com" , "dbarboza@ventanamicro.com" , "philmd@linaro.org" , "alistair23@gmail.com" , "thuth@redhat.com" , Djordje Todorovic , Alistair Francis Subject: [PATCH v15 03/12] target/riscv: Add MIPS P8700 CSRs Thread-Topic: [PATCH v15 03/12] target/riscv: Add MIPS P8700 CSRs Thread-Index: AQHcc/E1I66sF+ox+Ee3flBWGNab7A== Date: Tue, 23 Dec 2025 09:47:53 +0000 Message-ID: <20251223094739.1983381-4-djordje.todorovic@htecgroup.com> References: <20251223094739.1983381-1-djordje.todorovic@htecgroup.com> In-Reply-To: <20251223094739.1983381-1-djordje.todorovic@htecgroup.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=htecgroup.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DB8PR09MB2796:EE_|AS8PR09MB5758:EE_ x-ms-office365-filtering-correlation-id: bb993bab-c7ef-424d-1962-08de42085853 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|7416014|376014|366016|38070700021; x-microsoft-antispam-message-info: =?iso-8859-1?Q?mw7Tc4IMps7NeyiABBK8Nilp8ES3S7B6Dj+Jy0ibChtv5voKm4s2Q7NbeB?= =?iso-8859-1?Q?AfhPpe5m1Dg12hYFEdLc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hh?= =?iso-8859-1?Q?xKQrAGn1CWJoBPx+lH/oA6JH9JvcVK8P5V+moKMwxbf9fQ6keEljkWFrU8?= =?iso-8859-1?Q?HoyhSCacT1NPVcLVdSBTNI9EkDmQ8cxC2e6a37CycHLB1NTyY+hlbBGfc0?= =?iso-8859-1?Q?+IWcNFE4okohulA/mzJWoG0wdx6c+zOGsVUnypgbY6kRGb1wIKWDpw/5Ay?= =?iso-8859-1?Q?U3vpf6dcz+KG2/BO2wXTM+PhO9OnKarGiBFheJtn+S9afbt2pfGsTLfIGd?= =?iso-8859-1?Q?AfyysWUfpkPjXBAYEorJW3cis1R513PCO5crE6jpmXxc8ofQAMhIW6vnaN?= =?iso-8859-1?Q?vPNZ1SwwabxPpzhdeLbvppuMXvzPjTimKNdrWKIkGi1HGLi0LDrsKw5HkP?= =?iso-8859-1?Q?YBsDOqd//kCxG/F07pufeYE/JZ983mG8Onk/lXh5/0fU++MbUwOIW6sVyf?= =?iso-8859-1?Q?3xdJLzTs+Ggtrljoaq0zAR1oZCxIjRGqUTMX3tYgMvsEuV9HHapWcQPHdh?= =?iso-8859-1?Q?0WIviQd7CLwby4uhHjACVZfX26pccwkYbatxCHUc1hMq13cFVaQSm6zIpC?= =?iso-8859-1?Q?kiQthcYLtEr2UmJU+ZqRQnGFoEsZQVAhsuHo5y/dTRSnhzE0tu41AJY8BM?= =?iso-8859-1?Q?enEsdtvjDL+i5am/DkQa+3uGAgJH?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB8PR09MB2796.eurprd09.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(7416014)(376014)(366016)(38070700021); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?/8RQf5FHLsnBwsszVfRy7QLNnNsRdMzmFJ0XspnywyfJvpIo7qVOKlKHVA?= =?iso-8859-1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Q8qZqo4xn9gG0hYT0K6SCYvUS9sBEir?= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: htecgroup.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DB8PR09MB2796.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: bb993bab-c7ef-424d-1962-08de42085853 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Dec 2025 09:47:53.3598 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 9f85665b-7efd-4776-9dfe-b6bfda2565ee X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: cLcpJV5UMfc8t/tODEFqtbdrBPpEaFdQ55QlEdJkmzoCoIYI53dJ3MlNiZ/0U6sGgTaVj4CHw5lN8Xmvspqeg0FpEmbhYUkrpoVUYv2rjjA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR09MB5758 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a01:111:f403:c200::3; envelope-from=Djordje.Todorovic@htecgroup.com; helo=DU2PR03CU002.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @htecgroup.com) X-ZM-MESSAGEID: 1766483444713158500 Content-Type: text/plain; charset="utf-8" Define MIPS CSRs used for P8700 CPU. Signed-off-by: Chao-ying Fu Signed-off-by: Djordje Todorovic Reviewed-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis --- target/riscv/cpu.c | 3 + target/riscv/cpu.h | 3 + target/riscv/meson.build | 1 + target/riscv/mips_csr.c | 217 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 224 insertions(+) create mode 100644 target/riscv/mips_csr.c diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index e473e36e20..0c3b8d4f83 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -3336,6 +3336,9 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { .cfg.ext_zbb =3D true, .cfg.marchid =3D 0x8000000000000201, .cfg.mvendorid =3D MIPS_VENDOR_ID, +#ifndef CONFIG_USER_ONLY + .custom_csrs =3D mips_csr_list, +#endif ), =20 #if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 7d49ec4d90..44f173b84e 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -989,5 +989,8 @@ const char *satp_mode_str(uint8_t satp_mode, bool is_32= _bit); /* In th_csr.c */ extern const RISCVCSR th_csr_list[]; =20 +/* Implemented in mips_csr.c */ +extern const RISCVCSR mips_csr_list[]; + const char *priv_spec_to_str(int priv_version); #endif /* RISCV_CPU_H */ diff --git a/target/riscv/meson.build b/target/riscv/meson.build index fdefe88ccd..25d59ef9f9 100644 --- a/target/riscv/meson.build +++ b/target/riscv/meson.build @@ -36,6 +36,7 @@ riscv_system_ss.add(files( 'debug.c', 'monitor.c', 'machine.c', + 'mips_csr.c', 'pmu.c', 'th_csr.c', 'time_helper.c', diff --git a/target/riscv/mips_csr.c b/target/riscv/mips_csr.c new file mode 100644 index 0000000000..822e25e346 --- /dev/null +++ b/target/riscv/mips_csr.c @@ -0,0 +1,217 @@ +/* + * MIPS-specific CSRs. + * + * Copyright (c) 2025 MIPS + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + */ + +#include "qemu/osdep.h" +#include "cpu.h" +#include "cpu_vendorid.h" + +/* Static MIPS CSR state storage */ +static struct { + uint64_t tvec; + uint64_t config[12]; + uint64_t pmacfg[16]; +} mips_csr_state; + +/* MIPS CSR */ +#define CSR_MIPSTVEC 0x7c0 +#define CSR_MIPSCONFIG0 0x7d0 +#define CSR_MIPSCONFIG1 0x7d1 +#define CSR_MIPSCONFIG2 0x7d2 +#define CSR_MIPSCONFIG3 0x7d3 +#define CSR_MIPSCONFIG4 0x7d4 +#define CSR_MIPSCONFIG5 0x7d5 +#define CSR_MIPSCONFIG6 0x7d6 +#define CSR_MIPSCONFIG7 0x7d7 +#define CSR_MIPSCONFIG8 0x7d8 +#define CSR_MIPSCONFIG9 0x7d9 +#define CSR_MIPSCONFIG10 0x7da +#define CSR_MIPSCONFIG11 0x7db +#define CSR_MIPSPMACFG0 0x7e0 +#define CSR_MIPSPMACFG1 0x7e1 +#define CSR_MIPSPMACFG2 0x7e2 +#define CSR_MIPSPMACFG3 0x7e3 +#define CSR_MIPSPMACFG4 0x7e4 +#define CSR_MIPSPMACFG5 0x7e5 +#define CSR_MIPSPMACFG6 0x7e6 +#define CSR_MIPSPMACFG7 0x7e7 +#define CSR_MIPSPMACFG8 0x7e8 +#define CSR_MIPSPMACFG9 0x7e9 +#define CSR_MIPSPMACFG10 0x7ea +#define CSR_MIPSPMACFG11 0x7eb +#define CSR_MIPSPMACFG12 0x7ec +#define CSR_MIPSPMACFG13 0x7ed +#define CSR_MIPSPMACFG14 0x7ee +#define CSR_MIPSPMACFG15 0x7ef + +static RISCVException any(CPURISCVState *env, int csrno) +{ + return RISCV_EXCP_NONE; +} + +static RISCVException read_mipstvec(CPURISCVState *env, int csrno, + target_ulong *val) +{ + *val =3D mips_csr_state.tvec; + return RISCV_EXCP_NONE; +} + +static RISCVException write_mipstvec(CPURISCVState *env, int csrno, + target_ulong val, uintptr_t ra) +{ + mips_csr_state.tvec =3D val; + return RISCV_EXCP_NONE; +} + +static RISCVException read_mipsconfig(CPURISCVState *env, int csrno, + target_ulong *val) +{ + *val =3D mips_csr_state.config[csrno - CSR_MIPSCONFIG0]; + return RISCV_EXCP_NONE; +} + +static RISCVException write_mipsconfig(CPURISCVState *env, int csrno, + target_ulong val, uintptr_t ra) +{ + mips_csr_state.config[csrno - CSR_MIPSCONFIG0] =3D val; + return RISCV_EXCP_NONE; +} + +static RISCVException read_mipspmacfg(CPURISCVState *env, int csrno, + target_ulong *val) +{ + *val =3D mips_csr_state.pmacfg[csrno - CSR_MIPSPMACFG0]; + return RISCV_EXCP_NONE; +} + +static RISCVException write_mipspmacfg(CPURISCVState *env, int csrno, + target_ulong val, uintptr_t ra) +{ + mips_csr_state.pmacfg[csrno - CSR_MIPSPMACFG0] =3D val; + return RISCV_EXCP_NONE; +} + +const RISCVCSR mips_csr_list[] =3D { + { + .csrno =3D CSR_MIPSTVEC, + .csr_ops =3D { "mipstvec", any, read_mipstvec, write_mipstvec } + }, + { + .csrno =3D CSR_MIPSCONFIG0, + .csr_ops =3D { "mipsconfig0", any, read_mipsconfig, write_mipsconf= ig } + }, + { + .csrno =3D CSR_MIPSCONFIG1, + .csr_ops =3D { "mipsconfig1", any, read_mipsconfig, write_mipsconf= ig } + }, + { + .csrno =3D CSR_MIPSCONFIG2, + .csr_ops =3D { "mipsconfig2", any, read_mipsconfig, write_mipsconf= ig } + }, + { + .csrno =3D CSR_MIPSCONFIG3, + .csr_ops =3D { "mipsconfig3", any, read_mipsconfig, write_mipsconf= ig } + }, + { + .csrno =3D CSR_MIPSCONFIG4, + .csr_ops =3D { "mipsconfig4", any, read_mipsconfig, write_mipsconf= ig } + }, + { + .csrno =3D CSR_MIPSCONFIG5, + .csr_ops =3D { "mipsconfig5", any, read_mipsconfig, write_mipsconf= ig } + }, + { + .csrno =3D CSR_MIPSCONFIG6, + .csr_ops =3D { "mipsconfig6", any, read_mipsconfig, write_mipsconf= ig } + }, + { + .csrno =3D CSR_MIPSCONFIG7, + .csr_ops =3D { "mipsconfig7", any, read_mipsconfig, write_mipsconf= ig } + }, + { + .csrno =3D CSR_MIPSCONFIG8, + .csr_ops =3D { "mipsconfig8", any, read_mipsconfig, write_mipsconf= ig } + }, + { + .csrno =3D CSR_MIPSCONFIG9, + .csr_ops =3D { "mipsconfig9", any, read_mipsconfig, write_mipsconf= ig } + }, + { + .csrno =3D CSR_MIPSCONFIG10, + .csr_ops =3D { "mipsconfig10", any, read_mipsconfig, write_mipscon= fig } + }, + { + .csrno =3D CSR_MIPSCONFIG11, + .csr_ops =3D { "mipsconfig11", any, read_mipsconfig, write_mipscon= fig } + }, + { + .csrno =3D CSR_MIPSPMACFG0, + .csr_ops =3D { "mipspmacfg0", any, read_mipspmacfg, write_mipspmac= fg } + }, + { + .csrno =3D CSR_MIPSPMACFG1, + .csr_ops =3D { "mipspmacfg1", any, read_mipspmacfg, write_mipspmac= fg } + }, + { + .csrno =3D CSR_MIPSPMACFG2, + .csr_ops =3D { "mipspmacfg2", any, read_mipspmacfg, write_mipspmac= fg } + }, + { + .csrno =3D CSR_MIPSPMACFG3, + .csr_ops =3D { "mipspmacfg3", any, read_mipspmacfg, write_mipspmac= fg } + }, + { + .csrno =3D CSR_MIPSPMACFG4, + .csr_ops =3D { "mipspmacfg4", any, read_mipspmacfg, write_mipspmac= fg } + }, + { + .csrno =3D CSR_MIPSPMACFG5, + .csr_ops =3D { "mipspmacfg5", any, read_mipspmacfg, write_mipspmac= fg } + }, + { + .csrno =3D CSR_MIPSPMACFG6, + .csr_ops =3D { "mipspmacfg6", any, read_mipspmacfg, write_mipspmac= fg } + }, + { + .csrno =3D CSR_MIPSPMACFG7, + .csr_ops =3D { "mipspmacfg7", any, read_mipspmacfg, write_mipspmac= fg } + }, + { + .csrno =3D CSR_MIPSPMACFG8, + .csr_ops =3D { "mipspmacfg8", any, read_mipspmacfg, write_mipspmac= fg } + }, + { + .csrno =3D CSR_MIPSPMACFG9, + .csr_ops =3D { "mipspmacfg9", any, read_mipspmacfg, write_mipspmac= fg } + }, + { + .csrno =3D CSR_MIPSPMACFG10, + .csr_ops =3D { "mipspmacfg10", any, read_mipspmacfg, write_mipspma= cfg } + }, + { + .csrno =3D CSR_MIPSPMACFG11, + .csr_ops =3D { "mipspmacfg11", any, read_mipspmacfg, write_mipspma= cfg } + }, + { + .csrno =3D CSR_MIPSPMACFG12, + .csr_ops =3D { "mipspmacfg12", any, read_mipspmacfg, write_mipspma= cfg } + }, + { + .csrno =3D CSR_MIPSPMACFG13, + .csr_ops =3D { "mipspmacfg13", any, read_mipspmacfg, write_mipspma= cfg } + }, + { + .csrno =3D CSR_MIPSPMACFG14, + .csr_ops =3D { "mipspmacfg14", any, read_mipspmacfg, write_mipspma= cfg } + }, + { + .csrno =3D CSR_MIPSPMACFG15, + .csr_ops =3D { "mipspmacfg15", any, read_mipspmacfg, write_mipspma= cfg } + }, + { }, +}; --=20 2.34.1