From nobody Thu Dec 18 22:19:45 2025 Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 929FB243953; Tue, 8 Apr 2025 05:02:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744088552; cv=none; b=Z1P9P6RD9hl9augxApgbDcOGgdUYXmRboH7Waq89j6o2WIEoY+VZCcnbc6uFk+XG9Tw0Bmx04Xlpv1LIlHl7/DYy43eR53GCeOjQxLWK5aRQpr7l+Du24dOZLpFyPUmjdEY+j8D7R7doPIqNGcnSkFVpDTIPwHO0tD22Gb0SWWE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744088552; c=relaxed/simple; bh=LkOhOos6SsTIWVmokwBKQK+MCR4inwBdNq09QmcdbXk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WAoXkrRuqRvIhCCSNK2WFkGFfwtMVSml1uKtJG+0+bgUj3PNa4p4c2fuN/Lg+k4SS+3py8SC1/EKyinJdQ9BRZYSGTeBrsS3V+MSAQ0kABJlcW63b2HqM+8VG72pQW4SGA6uRs67y++fZabSeQpn1HkLrgNLZHdV+LGw7cpKs2E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=N+/9mnY7; arc=none smtp.client-ip=209.85.219.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="N+/9mnY7" Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-6ecfc2cb1aaso53529136d6.3; Mon, 07 Apr 2025 22:02:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744088549; x=1744693349; darn=vger.kernel.org; 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=V2OL/h5MecGrz6go7y1U0zeNfXujAsxg32wsyMhUhFc=; b=N+/9mnY79oXDiCYOdGnKEZaJC79b2g/xu0wx0ifU3Mr5PKgmX8D10AyGALeB1mugiV gPoKa7Asbeg1NA7IAM3M9w76cdB9zhFseCbJTYpJtjLGuNo/QqpZNti7kkrdnAbKoxiA +zpFaugK25zQNFfTb1ch4vUKpMlEZvxPE5+7DSBgJDyufRIL0yIBjXNg0cG3ZVse2h7W 8MATh44UjXoyW/ZQUysQJintcHx33cVTZegU6hi3oKQmnK8bhLJsO3ah4zdH/xS4dJ7Z u+nQQ1lyyg27ut9etX7PkERWj/j46dUri1IeMs75kqi/GkzvcDnkUJHskjG2gVkLYGX8 HagQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744088549; x=1744693349; 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=V2OL/h5MecGrz6go7y1U0zeNfXujAsxg32wsyMhUhFc=; b=DA03Vm4Ci7GOu/imUzsrbv1Y7nbgvg7nTPRF+yigkQ2ME2KSFU4CPJfhy+VA5mB7b8 +4uDL03Lk3Baf/1Rl4E7f6CnMfvR+MCZX6TA2eVLU2QR3aEXdoq6E1s9MbJyOqtsfDhn o9HHyrejDiowL8aGzkhatpGZPwWvHCR5U9euKTY7FMGu0Rbv649Bb0qjJsBQzo9DWbj+ Ac+BN4vRLo/wj+Tj4BBFSBp1loDNdBKrx0D3w5VNUcAkK9XdZ6XY/mtWv9LejneCUICc bUzyzPTJF+YH7wefXSsru/oH+Et2aqtFjmqWIeDrUrzrLwZHtvPNDS3ZJXjqksKooCcS VOfw== X-Forwarded-Encrypted: i=1; AJvYcCUyHQPGRJN+pRPZ3zUh5W2/tn0TKAxn8m++TmEdFX+9SUowPYzWsAJ12/ZrLkOvOMMecvk1gV/Yav+A@vger.kernel.org X-Gm-Message-State: AOJu0Yxc4b/tXmd4sLLDDS3srJgo0l7ttxgnWBp9viqPfpOH17oT3XYn JnCuXPC4yK7d97SirwnurVmjI8UrEJICfjalZA/hV+PZsn+D3WYu X-Gm-Gg: ASbGnctugL2yzZlzAjy2fQb2xfhiNGJvCzBQgn6UtQ/Kg18uMMht2gkrP+cNMdn7lse KrTmJ/Is+hcNa2PgmcRIEz+c2H9MP5dPBDicrAyaBICJT9FSJwpmwKTRpddsD4LsrnP/GWt0YbA x9xcxRmpojyko+YJWya+CyLeambz/cK2JUJCVyiWSyVE4R+bDuxDxpJxeqBmR72b7vCp9itaXG3 Joo23i586/RMcJNG5EEms9ND6DjAufIGmRj519MwUd6dfBMye2FE8iaKy/opIMePfzFsB3/wOoI T3NGTpEIBIK+0RTXGrZk X-Google-Smtp-Source: AGHT+IFudylIoJX9TM2xVCYwLnDirGDkk1XJD5I5ishPdtU9+Tos+yJgYa7KNlWI0L6fX3868MmKCQ== X-Received: by 2002:a05:6214:f63:b0:6ea:d629:f47d with SMTP id 6a1803df08f44-6f064b2888fmr249775806d6.44.1744088549391; Mon, 07 Apr 2025 22:02:29 -0700 (PDT) Received: from localhost ([2001:da8:7001:11::cb]) by smtp.gmail.com with UTF8SMTPSA id 6a1803df08f44-6ef0efc128fsm69354356d6.23.2025.04.07.22.02.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Apr 2025 22:02:29 -0700 (PDT) From: Inochi Amaoto To: Thomas Gleixner , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen Wang , Inochi Amaoto Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, sophgo@lists.linux.dev, Yixun Lan , Longbin Li , Conor Dooley Subject: [PATCH v3 1/4] dt-bindings: interrupt-controller: Add Sophgo SG2044 MSI controller Date: Tue, 8 Apr 2025 13:01:42 +0800 Message-ID: <20250408050147.774987-2-inochiama@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250408050147.774987-1-inochiama@gmail.com> References: <20250408050147.774987-1-inochiama@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Like SG2042, SG2044 also uses an external msi controller to provide MSI interrupt for PCIe controllers. The difference between these two msi controlling are summary as follows: 1. SG2044 acks the interrupt by writing 0, as on SG2042 by setting related bit. 2. SG2044 uses interrupt number mod 32 as msi message data, but SG2042 uses setting related bit. Add support for the SG2044 msi controller. Signed-off-by: Inochi Amaoto Acked-by: Conor Dooley Reviewed-by: Chen Wang --- .../bindings/interrupt-controller/sophgo,sg2042-msi.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/interrupt-controller/sophgo,= sg2042-msi.yaml b/Documentation/devicetree/bindings/interrupt-controller/so= phgo,sg2042-msi.yaml index e1ffd55fa7bf..f6b8b1d92f79 100644 --- a/Documentation/devicetree/bindings/interrupt-controller/sophgo,sg2042-= msi.yaml +++ b/Documentation/devicetree/bindings/interrupt-controller/sophgo,sg2042-= msi.yaml @@ -18,7 +18,9 @@ allOf: =20 properties: compatible: - const: sophgo,sg2042-msi + enum: + - sophgo,sg2042-msi + - sophgo,sg2044-msi =20 reg: items: --=20 2.49.0 From nobody Thu Dec 18 22:19:45 2025 Received: from mail-qv1-f53.google.com (mail-qv1-f53.google.com [209.85.219.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1408525F963; Tue, 8 Apr 2025 05:02:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744088555; cv=none; b=VvZL5hI/9nde4gdpm/kqB9IRI9U7aXUrCn2sCtvu1kBpeQVP+l6fQuiTsqxhNgiy3jUYxXNMitxjkzfogXsWElVGs0oUShIjgUkIfH7RDSSYzE4Q9Zj6CgC9sLyxbqpiWF1cmbKN1D6YdzMM7zCzogoeBiDs1+8E+IuVmrvWVYA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744088555; c=relaxed/simple; bh=WkXs5mmhFEGPv/gyC3VgcUbcfCocLQ1q+xN1K/I8jHg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AIMSVtM8ERT1BF7cQ0ZBXpFWDy/QYFGTRP7hRzGP2CbulDASWtE8ifmrTvu8COLzNnb9EA+OOnTU8IejD13zsydYItddyZTMuRQe09kgZFH6gp8zHMClelkqqD+H5j8un1V+zNbrfQodLhPhmNL57k7pStrCndb0XMJ/agNhO2s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gK5WY9Mn; arc=none smtp.client-ip=209.85.219.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gK5WY9Mn" Received: by mail-qv1-f53.google.com with SMTP id 6a1803df08f44-6e8fb83e137so47203136d6.0; Mon, 07 Apr 2025 22:02:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744088553; x=1744693353; darn=vger.kernel.org; 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=hFI4oBOICp8WPg8UKe09xaY2SH1Wj5DzXn6kXmiskgI=; b=gK5WY9MnkJs6JcVPgYsjwCyXUrWasRB9X0+v6js250fIBuPgE6qKpUKDsm7VInH/UU Vsg0YqByaJGIiwPLTr27EUqgQcMRjFYGG93UQ2w1wH4hn8UdGhZ8JlXlNttWva6MNVjZ b4DdeZKz+8Bx5R80K4fNUTUNmHbI4xfi0j/HY+1/FuipSBv+ujXZU74yxpM1kVK6863K Q3qHViUHzpj3SS8iC7LbqtAIM3ClLSZPddVM46kqsJrEwOchL88llSFvg3GBUljD4fKF 5xB3mjqnYaUaYrSHus886euEHVIfnWnwV+9A+Wf2ekgODKUI62PQb9mdkb3L9R4VKv6N AWAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744088553; x=1744693353; 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=hFI4oBOICp8WPg8UKe09xaY2SH1Wj5DzXn6kXmiskgI=; b=YTJOLBCslPDd54uaUv/dmNtwgvUCthV1iFtAksrVU60U7eisrs09BcDZFKem8UnbT7 ueY8IrciP97+KJhlvtVXepWyZzCKguXSkLc2end3SIRhmECGrUFJYndAy+brKaSmGXEH TEaRYlxgPI/OL+ZUZCVmpEXP5z9uIMXKt/EXhZtNUP5gATtBNEch3+kI6SQbghW653gX PRtft08dP5JE94yptp640okMPoyGIhOQkP7oPIcl2n+2QzvrPf6iBQiYtCm/ARcHoYIG g5EeTZJEV/3VTipXdoJXARCaItUfd1YijZCelTGxHi2v2xG7y/4Vk9bSycGsurMBgsVL qG8w== X-Forwarded-Encrypted: i=1; AJvYcCW0qG9bWiDxTCy0qjwPWS2TfpR0G124DrLXPL51L1sfA1xq+PeGywJdeDgCYd7SIcyBxxm03Fyu3IyL@vger.kernel.org X-Gm-Message-State: AOJu0YxY5tgu2lSbvhlNYY2vGrRaVLKIqVc/Tp+NhMgaFa6DDfA4CyjR QjTjo7OgGWnKLjYq4M9fuTKTPTuCC2UyNTf6heEw/3awG2BW9Byf X-Gm-Gg: ASbGnctWvjG6VWuiF1/+9tYPnB5bwMS0voXsZuifxgKgR+IWkf+VukZ0ePAhNWiCo+t 1d4FlYwz10XVcA6XwAK0KdjVyPcvbN1XYMDb9wJ/65OrWfthI+aVUVxuNPLUG54krkMiX5APwe3 IFqtXAgLDfXqUxKbOrPaLGIg4lLo79L/3ckTZjnXyiZSreT96zLi38akKV4bMvjTMn/WjRkBK5j C0jaDnef11ULIfGvp2XXRtGK0OHU2RUI4lPpQWacnGHDf0I8eV5MKzplgsZc5BLU9Mlzl7ugvN4 ULRIwMkvoDYWuzfJ/ZFR X-Google-Smtp-Source: AGHT+IGa/AWYSqVZnSUX2M3V6wUqu38PIrP+CCv9/Z5IHSzVs5zNOQUhyQ4p1L+c7R8LGhaOf+3cDA== X-Received: by 2002:ad4:5ae4:0:b0:6ed:15ce:e33e with SMTP id 6a1803df08f44-6f0b74a50ecmr224086866d6.27.1744088552936; Mon, 07 Apr 2025 22:02:32 -0700 (PDT) Received: from localhost ([2001:da8:7001:11::cb]) by smtp.gmail.com with UTF8SMTPSA id af79cd13be357-7c76eab1659sm705629885a.115.2025.04.07.22.02.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Apr 2025 22:02:32 -0700 (PDT) From: Inochi Amaoto To: Thomas Gleixner , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen Wang , Inochi Amaoto Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, sophgo@lists.linux.dev, Yixun Lan , Longbin Li Subject: [PATCH v3 2/4] irqchip/sg2042-msi: rename generic function and structure Date: Tue, 8 Apr 2025 13:01:43 +0800 Message-ID: <20250408050147.774987-3-inochiama@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250408050147.774987-1-inochiama@gmail.com> References: <20250408050147.774987-1-inochiama@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" As the driver logic can be used in both SG2042 and SG2044, it will be better to have a generic name. Signed-off-by: Inochi Amaoto --- drivers/irqchip/irq-sg2042-msi.c | 46 ++++++++++++++++---------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/drivers/irqchip/irq-sg2042-msi.c b/drivers/irqchip/irq-sg2042-= msi.c index 375b55aa0acd..c9bff7ba693d 100644 --- a/drivers/irqchip/irq-sg2042-msi.c +++ b/drivers/irqchip/irq-sg2042-msi.c @@ -21,7 +21,7 @@ =20 #define SG2042_MAX_MSI_VECTOR 32 =20 -struct sg2042_msi_chipdata { +struct sg204x_msi_chipdata { void __iomem *reg_clr; // clear reg, see TRM, 10.1.33, GP_INTR0_CLR =20 phys_addr_t doorbell_addr; // see TRM, 10.1.32, GP_INTR0_SET @@ -33,7 +33,7 @@ struct sg2042_msi_chipdata { struct mutex msi_map_lock; // lock for msi_map }; =20 -static int sg2042_msi_allocate_hwirq(struct sg2042_msi_chipdata *data, int= num_req) +static int sg204x_msi_allocate_hwirq(struct sg204x_msi_chipdata *data, int= num_req) { int first; =20 @@ -43,7 +43,7 @@ static int sg2042_msi_allocate_hwirq(struct sg2042_msi_ch= ipdata *data, int num_r return first >=3D 0 ? first : -ENOSPC; } =20 -static void sg2042_msi_free_hwirq(struct sg2042_msi_chipdata *data, int hw= irq, int num_req) +static void sg204x_msi_free_hwirq(struct sg204x_msi_chipdata *data, int hw= irq, int num_req) { guard(mutex)(&data->msi_map_lock); bitmap_release_region(data->msi_map, hwirq, get_count_order(num_req)); @@ -51,7 +51,7 @@ static void sg2042_msi_free_hwirq(struct sg2042_msi_chipd= ata *data, int hwirq, i =20 static void sg2042_msi_irq_ack(struct irq_data *d) { - struct sg2042_msi_chipdata *data =3D irq_data_get_irq_chip_data(d); + struct sg204x_msi_chipdata *data =3D irq_data_get_irq_chip_data(d); int bit_off =3D d->hwirq; =20 writel(1 << bit_off, data->reg_clr); @@ -61,7 +61,7 @@ static void sg2042_msi_irq_ack(struct irq_data *d) =20 static void sg2042_msi_irq_compose_msi_msg(struct irq_data *d, struct msi_= msg *msg) { - struct sg2042_msi_chipdata *data =3D irq_data_get_irq_chip_data(d); + struct sg204x_msi_chipdata *data =3D irq_data_get_irq_chip_data(d); =20 msg->address_hi =3D upper_32_bits(data->doorbell_addr); msg->address_lo =3D lower_32_bits(data->doorbell_addr); @@ -79,9 +79,9 @@ static const struct irq_chip sg2042_msi_middle_irq_chip = =3D { .irq_compose_msi_msg =3D sg2042_msi_irq_compose_msi_msg, }; =20 -static int sg2042_msi_parent_domain_alloc(struct irq_domain *domain, unsig= ned int virq, int hwirq) +static int sg204x_msi_parent_domain_alloc(struct irq_domain *domain, unsig= ned int virq, int hwirq) { - struct sg2042_msi_chipdata *data =3D domain->host_data; + struct sg204x_msi_chipdata *data =3D domain->host_data; struct irq_fwspec fwspec; struct irq_data *d; int ret; @@ -99,18 +99,18 @@ static int sg2042_msi_parent_domain_alloc(struct irq_do= main *domain, unsigned in return d->chip->irq_set_type(d, IRQ_TYPE_EDGE_RISING); } =20 -static int sg2042_msi_middle_domain_alloc(struct irq_domain *domain, unsig= ned int virq, +static int sg204x_msi_middle_domain_alloc(struct irq_domain *domain, unsig= ned int virq, unsigned int nr_irqs, void *args) { - struct sg2042_msi_chipdata *data =3D domain->host_data; + struct sg204x_msi_chipdata *data =3D domain->host_data; int hwirq, err, i; =20 - hwirq =3D sg2042_msi_allocate_hwirq(data, nr_irqs); + hwirq =3D sg204x_msi_allocate_hwirq(data, nr_irqs); if (hwirq < 0) return hwirq; =20 for (i =3D 0; i < nr_irqs; i++) { - err =3D sg2042_msi_parent_domain_alloc(domain, virq + i, hwirq + i); + err =3D sg204x_msi_parent_domain_alloc(domain, virq + i, hwirq + i); if (err) goto err_hwirq; =20 @@ -121,25 +121,25 @@ static int sg2042_msi_middle_domain_alloc(struct irq_= domain *domain, unsigned in return 0; =20 err_hwirq: - sg2042_msi_free_hwirq(data, hwirq, nr_irqs); + sg204x_msi_free_hwirq(data, hwirq, nr_irqs); irq_domain_free_irqs_parent(domain, virq, i); =20 return err; } =20 -static void sg2042_msi_middle_domain_free(struct irq_domain *domain, unsig= ned int virq, +static void sg204x_msi_middle_domain_free(struct irq_domain *domain, unsig= ned int virq, unsigned int nr_irqs) { struct irq_data *d =3D irq_domain_get_irq_data(domain, virq); - struct sg2042_msi_chipdata *data =3D irq_data_get_irq_chip_data(d); + struct sg204x_msi_chipdata *data =3D irq_data_get_irq_chip_data(d); =20 irq_domain_free_irqs_parent(domain, virq, nr_irqs); - sg2042_msi_free_hwirq(data, d->hwirq, nr_irqs); + sg204x_msi_free_hwirq(data, d->hwirq, nr_irqs); } =20 -static const struct irq_domain_ops sg2042_msi_middle_domain_ops =3D { - .alloc =3D sg2042_msi_middle_domain_alloc, - .free =3D sg2042_msi_middle_domain_free, +static const struct irq_domain_ops sg204x_msi_middle_domain_ops =3D { + .alloc =3D sg204x_msi_middle_domain_alloc, + .free =3D sg204x_msi_middle_domain_free, .select =3D msi_lib_irq_domain_select, }; =20 @@ -158,14 +158,14 @@ static const struct msi_parent_ops sg2042_msi_parent_= ops =3D { .init_dev_msi_info =3D msi_lib_init_dev_msi_info, }; =20 -static int sg2042_msi_init_domains(struct sg2042_msi_chipdata *data, +static int sg204x_msi_init_domains(struct sg204x_msi_chipdata *data, struct irq_domain *plic_domain, struct device *dev) { struct fwnode_handle *fwnode =3D dev_fwnode(dev); struct irq_domain *middle_domain; =20 middle_domain =3D irq_domain_create_hierarchy(plic_domain, 0, data->num_i= rqs, fwnode, - &sg2042_msi_middle_domain_ops, data); + &sg204x_msi_middle_domain_ops, data); if (!middle_domain) { pr_err("Failed to create the MSI middle domain\n"); return -ENOMEM; @@ -182,13 +182,13 @@ static int sg2042_msi_init_domains(struct sg2042_msi_= chipdata *data, static int sg2042_msi_probe(struct platform_device *pdev) { struct fwnode_reference_args args =3D { }; - struct sg2042_msi_chipdata *data; + struct sg204x_msi_chipdata *data; struct device *dev =3D &pdev->dev; struct irq_domain *plic_domain; struct resource *res; int ret; =20 - data =3D devm_kzalloc(dev, sizeof(struct sg2042_msi_chipdata), GFP_KERNEL= ); + data =3D devm_kzalloc(dev, sizeof(struct sg204x_msi_chipdata), GFP_KERNEL= ); if (!data) return -ENOMEM; =20 @@ -232,7 +232,7 @@ static int sg2042_msi_probe(struct platform_device *pde= v) =20 mutex_init(&data->msi_map_lock); =20 - return sg2042_msi_init_domains(data, plic_domain, dev); + return sg204x_msi_init_domains(data, plic_domain, dev); } =20 static const struct of_device_id sg2042_msi_of_match[] =3D { --=20 2.49.0 From nobody Thu Dec 18 22:19:45 2025 Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 91D8325F97F; Tue, 8 Apr 2025 05:02:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744088559; cv=none; b=uKlCJdXcPxwFf4WvCoGre9I1ggejamW+y/QWamI5LV4Gi4OMnqjR7qzzoFWl4RqJ6r+U80RbGcdbvedgsnOiEQ14Hb9c62plVMEoaKnasq3sD22JjogPkQLdKAkpmSUyLRev5DintvEcqtQxBKCRHdVFyqAx9ciPtWR+d+0h7Tk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744088559; c=relaxed/simple; bh=Oq1lh2FidiUj+CDMswoihJoIU0QAggXbvuD/Q3vI8iM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tD1daGVjzZBzgluvSfQj2WMKevk1TyloPSNIE5fOEq+kU8siAWR9wvi5gV1A/pwH0nKxjgpQVPmMzZEMJA9kFkP7znNpP6rmZyc36IDwpt3RsoOYbup2DKRQdeIdDS72fj5rUUVlPKIcv4ddsSdyGpysgjj83lWEvlnsDU6+Pdk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=eeYbYLqf; arc=none smtp.client-ip=209.85.160.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eeYbYLqf" Received: by mail-qt1-f169.google.com with SMTP id d75a77b69052e-47686580529so54500051cf.2; Mon, 07 Apr 2025 22:02:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744088556; x=1744693356; darn=vger.kernel.org; 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=cT2kEHZNr8vj+MYz0JWD8nBGI5CPzRybb8apCu1RJBQ=; b=eeYbYLqfxI4f19TLfOM16g3nuwdFrfHLpn93BjLjzDWoFaAB4sq8VTIO+q+lMzdklS aBJsZSGefXrHngBtKmpaUVUpO0V3NGfsG+SfEseUww1haPduUjA5AsDUiOF4w8/zyPLC gXX/VEGaLNgcLCgYrShagLieMvX96fmHW3OzBPMfvBKmX7Wx9MxyTTVSnRdXMo2BkzKh +xYmeRzzCLSPJH29MyzZeQ9q9gEK7rvthyBY7NakBzgGJlEPf/lw8gLH6vw0Pghv5j8s SDH7jwjYhlHxziVc+RnRzrGOAwVyWrqX57bw07abMkfw2uiO2v0iGNkOyIJsZjF1+T6G sH8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744088556; x=1744693356; 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=cT2kEHZNr8vj+MYz0JWD8nBGI5CPzRybb8apCu1RJBQ=; b=UZUuzk/BGvvrsuiHmw7ka9JwAVKlZzVRlg/tKZ061tmAGOsOJbElGIFUyjZepHej+N Djqhk5Y2iuV3gyVE9TQKzbQ++hXQs4f6IW3BkDdL/P2JqJjtTHuJLcEVCYAvoDqK7/op XhuFz3fMKAPveTF/mPVMwxsnRty6PEbFAXbB5Cac68p3cr5q8cQg8HR8KmnEQhaSs85z H1o+Vv/UYMQttbqIv1dc4xvDm6CQclSzmiqZauqyZ0KGpByTw88vrC4DDRwjVN8K5k0N HVK/ykCGIpd5DtjL27roZS3Kc0QqZR231btnwrhWfpuRj56fuzDF7wgGUaFySNHYzUJD g5vQ== X-Forwarded-Encrypted: i=1; AJvYcCX9LhFtBAAcViRWXaw0+cWNY1PBnv9m2hLYNKmj0iLd5v6Mj3P3xwpHfmXQ2V9/VznIBs/uNaHH185q@vger.kernel.org X-Gm-Message-State: AOJu0YyJlqiL7hDNFvItT+ckaK1avZ7KCpRvsBVXXDsOaTSuL4FO7HXW KRLcK7oyhd3DWYMKiU76F1gNjscq3oXltitmz+2BIBazygrYMjjC X-Gm-Gg: ASbGncthDH/PuaBugYvOnqHuLELuR5k6gofPhf7CH1znRfLmX5UVAIatXfVtwQ0pTGI g4b2FfviIZJ29vucmpl1h4GTiBRcEy/vHY0o7MOICXP+PSV2nOA4X1vVlW2f29xiwD1ocx/zMIR Ey+EMiBpuCrpNYlzEKMBQ1UsdXFvqAROgf1/kE8g4hxMYecgApJI10hBEWdavXkZLlDNV374AYV yelFui/NMcdrGNCNH1L7BBvcVmIgdoKVyCnE5OnYkT+tC3QcUZM/K5K7EPQHRTxiRAKkJdHvPeM xL/5Gu2ht7yywF3DHN82 X-Google-Smtp-Source: AGHT+IHKQdDyX2EWqDCC0KPGFHJefe6z6b/F493fgqH+xcZ9kE/993aaMVDs+OqtFcPoheNjVn78eA== X-Received: by 2002:ac8:5983:0:b0:476:b858:1f2d with SMTP id d75a77b69052e-47925a2b53dmr221525031cf.42.1744088556512; Mon, 07 Apr 2025 22:02:36 -0700 (PDT) Received: from localhost ([2001:da8:7001:11::cb]) by smtp.gmail.com with UTF8SMTPSA id d75a77b69052e-4791b057e6csm70841471cf.13.2025.04.07.22.02.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Apr 2025 22:02:36 -0700 (PDT) From: Inochi Amaoto To: Thomas Gleixner , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen Wang , Inochi Amaoto Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, sophgo@lists.linux.dev, Yixun Lan , Longbin Li Subject: [PATCH v3 3/4] irqchip/sg2042-msi: introduce configurable chipinfo for sg2042 Date: Tue, 8 Apr 2025 13:01:44 +0800 Message-ID: <20250408050147.774987-4-inochiama@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250408050147.774987-1-inochiama@gmail.com> References: <20250408050147.774987-1-inochiama@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" As the controller on SG2044 uses different msi_parent_ops and irq_chip, it is necessary to add a structure to hold the configuration across controllers. Add the chipinfo structure and implement necessary logic for it. Signed-off-by: Inochi Amaoto --- drivers/irqchip/irq-sg2042-msi.c | 44 ++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/drivers/irqchip/irq-sg2042-msi.c b/drivers/irqchip/irq-sg2042-= msi.c index c9bff7ba693d..30a1d2bfd474 100644 --- a/drivers/irqchip/irq-sg2042-msi.c +++ b/drivers/irqchip/irq-sg2042-msi.c @@ -21,16 +21,33 @@ =20 #define SG2042_MAX_MSI_VECTOR 32 =20 +struct sg204x_msi_chip_info { + const struct irq_chip *irqchip; + const struct msi_parent_ops *parent_ops; +}; + +/** + * struct sg204x_msi_chipdata - chip data for the SG204x MSI IRQ controller + * @reg_clr: clear reg, see TRM, 10.1.33, GP_INTR0_CLR + * @doorbell_addr: see TRM, 10.1.32, GP_INTR0_SET + * @irq_first: First vectors number that MSIs starts + * @num_irqs: Number of vectors for MSIs + * @msi_map: mapping for allocated MSI vectors. + * @msi_map_lock: Lock for msi_map + * @chip_info: chip specific infomations + */ struct sg204x_msi_chipdata { - void __iomem *reg_clr; // clear reg, see TRM, 10.1.33, GP_INTR0_CLR + void __iomem *reg_clr; =20 - phys_addr_t doorbell_addr; // see TRM, 10.1.32, GP_INTR0_SET + phys_addr_t doorbell_addr; =20 - u32 irq_first; // The vector number that MSIs starts - u32 num_irqs; // The number of vectors for MSIs + u32 irq_first; + u32 num_irqs; =20 DECLARE_BITMAP(msi_map, SG2042_MAX_MSI_VECTOR); - struct mutex msi_map_lock; // lock for msi_map + struct mutex msi_map_lock; + + const struct sg204x_msi_chip_info *chip_info; }; =20 static int sg204x_msi_allocate_hwirq(struct sg204x_msi_chipdata *data, int= num_req) @@ -115,7 +132,7 @@ static int sg204x_msi_middle_domain_alloc(struct irq_do= main *domain, unsigned in goto err_hwirq; =20 irq_domain_set_hwirq_and_chip(domain, virq + i, hwirq + i, - &sg2042_msi_middle_irq_chip, data); + data->chip_info->irqchip, data); } =20 return 0; @@ -174,7 +191,7 @@ static int sg204x_msi_init_domains(struct sg204x_msi_ch= ipdata *data, irq_domain_update_bus_token(middle_domain, DOMAIN_BUS_NEXUS); =20 middle_domain->flags |=3D IRQ_DOMAIN_FLAG_MSI_PARENT; - middle_domain->msi_parent_ops =3D &sg2042_msi_parent_ops; + middle_domain->msi_parent_ops =3D data->chip_info->parent_ops; =20 return 0; } @@ -192,6 +209,12 @@ static int sg2042_msi_probe(struct platform_device *pd= ev) if (!data) return -ENOMEM; =20 + data->chip_info =3D device_get_match_data(&pdev->dev); + if (!data->chip_info) { + dev_err(&pdev->dev, "Failed to get irqchip\n"); + return -EINVAL; + } + data->reg_clr =3D devm_platform_ioremap_resource_byname(pdev, "clr"); if (IS_ERR(data->reg_clr)) { dev_err(dev, "Failed to map clear register\n"); @@ -235,8 +258,13 @@ static int sg2042_msi_probe(struct platform_device *pd= ev) return sg204x_msi_init_domains(data, plic_domain, dev); } =20 +static const struct sg204x_msi_chip_info sg2042_chip_info =3D { + .irqchip =3D &sg2042_msi_middle_irq_chip, + .parent_ops =3D &sg2042_msi_parent_ops, +}; + static const struct of_device_id sg2042_msi_of_match[] =3D { - { .compatible =3D "sophgo,sg2042-msi" }, + { .compatible =3D "sophgo,sg2042-msi", .data =3D &sg2042_chip_info }, { } }; =20 --=20 2.49.0 From nobody Thu Dec 18 22:19:45 2025 Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3A8B25FA05; Tue, 8 Apr 2025 05:02:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744088563; cv=none; b=FsctwGXRrdkWj5eaaOIowQHwqrjCdFvwjIMhR82sRmV70CmilxF4yA/jn8O7HeyU/IcshLegVr6gS7/yQW729oluY3vmaaYgk7Tpd/ZEdYG/ECcCY8XG/prx3CaZaz0Hst6ZumiGT5zJt1QUuNWRBp7wkPPjhoPDm3nPpvFNnFs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744088563; c=relaxed/simple; bh=4l+o4OGRPWFJRjD8V+YVsupkeWNPcXnlPD7DsuUNeXs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MgA0T7konPLDxGGnFTB3XSUNsOCxPET9WssTL2Sj5HbxLsejKR/I6GoUz6lQ29BbICevrWvhF+dVHIsyWoJZCNt3mVCSdU3TQc9SUbG6rb5KSctJbzLQKi4U4cfXgQi+qjU/uTzb23lGmqUHrPXQVe953EHZceING72PtJJpits= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Wb07OsFa; arc=none smtp.client-ip=209.85.222.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Wb07OsFa" Received: by mail-qk1-f170.google.com with SMTP id af79cd13be357-7c56a3def84so486116285a.0; Mon, 07 Apr 2025 22:02:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744088561; x=1744693361; darn=vger.kernel.org; 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=0lMUff57GYX4CzxAbSN/48C3ZVAAUNRCdX4B0uVlZ+E=; b=Wb07OsFau0BYRSJ5uRzaIGV23Q8JNxrg9loBUD6pOzwmYS7AHV4TNk9BcrlYBaH5BO vWhM1RrX8iKJ/eQ/DRmqc3eD1stQR/f0XsEpiteiPh3BtRnoC62zQExVg2Ppkzh7W2Tu 1G3nIcSQF0nJZJVxBKnf0vRMo0FGoR3wPlcx04j3cvVz6qMNjeXvibXLyaSXwxoDWB1y ck5q+agfJ6vbwl0NE81FakrRT7z3QqGiwHTHBjg92GfTCOt9yD/65gkdTESCbvfqCiaQ ia/KkVMgtOgklA4CF5Efnb4cFunjTuD4ToQCjGXaKSqhnn7/4UmrhSqd5kWtJHooLBsh nGqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744088561; x=1744693361; 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=0lMUff57GYX4CzxAbSN/48C3ZVAAUNRCdX4B0uVlZ+E=; b=G94lIQ0TSwpkX/iu4oL7MffmhPii6AY9Z7MA4wsYmM8NXAfN+fCxM1o16pyCM4cdGy c0n4MHU9HM3HTfUr757WZiaF/hCGuz2vu/46GywHa/Am+/fYW+3sGlWj3sAd3CVyTGGO 1+RsM8Lgzun6NnxYuce6pje3vd7mbHFXtLGmTR9N/qAog85cv9m4tReRkrtMJCbCR6Xw LeBPpJj1gNfue3+fu6JNM9sFxCG1onVSTmcs0DaIW+qVfRmtaRyg+8/2BncbJ1gQxn2D y5vDiEpkxnO9Pm4UcJjvjPffR/hDwzUH/Wd227jixzwZFrRA+2sO3KIA8tg62kpdLAhu HOfA== X-Forwarded-Encrypted: i=1; AJvYcCXKpPSvjtSkbdlHf2Kowii18f+1fqxg7ZezD+y+b6Rb+MnJFnrtKGEJ7vWcq8+KSl9WbCisLhWoFtv2@vger.kernel.org X-Gm-Message-State: AOJu0YzrOYXZVCDmE0x1J44h26pSM0vUl5bW5BwZawa7Io2khB0TOB5a odzYkN0ogCjTN9/kmA8lPqVY+uyThvJsNxhH/EmX6edbgjHfKlLv X-Gm-Gg: ASbGncskX5elaHQCB9TYLdf5/H3XWvkADqJobLdow7WNWYGm82VY67JX0SyS0MwlFrW rbkyvvVvK8i6Vxyg5B0AHxCQ39fXxiwkIV+S1H01Y52fu0T/vZeDB/xUzNz23r7thbSOWMVkgiK 6HhTYteADHr6a9DnRhef6TM6gtmdFJbyYB9GAhzEjB/mHY2GILQGSb1hQZEEukysTuIT1HBk5ai gU+17ho7a4zNRTGDXP1OqEbYTrFhRFfVvDiSEnSDaCgovoW5+6fRfetrCqWETiYw2NARh3YLjo1 JlTPRSxnNbtWTympLXGR X-Google-Smtp-Source: AGHT+IGuSzrFyPWJt2trcansOZ3rfJX9pXHBBq4wLTrDbisJaG5tsy22yySc7YRo3G+CTYp8klrU8g== X-Received: by 2002:a05:620a:4607:b0:7c5:f696:f8e5 with SMTP id af79cd13be357-7c77dd8612cmr1566906185a.14.1744088560675; Mon, 07 Apr 2025 22:02:40 -0700 (PDT) Received: from localhost ([2001:da8:7001:11::cb]) by smtp.gmail.com with UTF8SMTPSA id af79cd13be357-7c76ea587c2sm707724085a.81.2025.04.07.22.02.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Apr 2025 22:02:39 -0700 (PDT) From: Inochi Amaoto To: Thomas Gleixner , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen Wang , Inochi Amaoto Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, sophgo@lists.linux.dev, Yixun Lan , Longbin Li Subject: [PATCH v3 4/4] irqchip/sg2042-msi: Add the Sophgo SG2044 MSI interrupt controller Date: Tue, 8 Apr 2025 13:01:45 +0800 Message-ID: <20250408050147.774987-5-inochiama@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250408050147.774987-1-inochiama@gmail.com> References: <20250408050147.774987-1-inochiama@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add support for Sophgo SG2044 MSI interrupt controller. Signed-off-by: Inochi Amaoto Reviewed-by: Chen Wang --- drivers/irqchip/irq-sg2042-msi.c | 61 ++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-sg2042-msi.c b/drivers/irqchip/irq-sg2042-= msi.c index 30a1d2bfd474..2935ca213306 100644 --- a/drivers/irqchip/irq-sg2042-msi.c +++ b/drivers/irqchip/irq-sg2042-msi.c @@ -19,8 +19,6 @@ =20 #include "irq-msi-lib.h" =20 -#define SG2042_MAX_MSI_VECTOR 32 - struct sg204x_msi_chip_info { const struct irq_chip *irqchip; const struct msi_parent_ops *parent_ops; @@ -44,7 +42,7 @@ struct sg204x_msi_chipdata { u32 irq_first; u32 num_irqs; =20 - DECLARE_BITMAP(msi_map, SG2042_MAX_MSI_VECTOR); + unsigned long *msi_map; struct mutex msi_map_lock; =20 const struct sg204x_msi_chip_info *chip_info; @@ -96,6 +94,35 @@ static const struct irq_chip sg2042_msi_middle_irq_chip = =3D { .irq_compose_msi_msg =3D sg2042_msi_irq_compose_msi_msg, }; =20 +static void sg2044_msi_irq_ack(struct irq_data *d) +{ + struct sg204x_msi_chipdata *data =3D irq_data_get_irq_chip_data(d); + + writel(0, (unsigned int *)data->reg_clr + d->hwirq); + irq_chip_ack_parent(d); +} + +static void sg2044_msi_irq_compose_msi_msg(struct irq_data *d, struct msi_= msg *msg) +{ + struct sg204x_msi_chipdata *data =3D irq_data_get_irq_chip_data(d); + phys_addr_t doorbell =3D data->doorbell_addr + 4 * (d->hwirq / 32); + + msg->address_lo =3D lower_32_bits(doorbell); + msg->address_hi =3D upper_32_bits(doorbell); + msg->data =3D d->hwirq % 32; +} + +static struct irq_chip sg2044_msi_middle_irq_chip =3D { + .name =3D "SG2044 MSI", + .irq_ack =3D sg2044_msi_irq_ack, + .irq_mask =3D irq_chip_mask_parent, + .irq_unmask =3D irq_chip_unmask_parent, +#ifdef CONFIG_SMP + .irq_set_affinity =3D irq_chip_set_affinity_parent, +#endif + .irq_compose_msi_msg =3D sg2044_msi_irq_compose_msi_msg, +}; + static int sg204x_msi_parent_domain_alloc(struct irq_domain *domain, unsig= ned int virq, int hwirq) { struct sg204x_msi_chipdata *data =3D domain->host_data; @@ -175,6 +202,22 @@ static const struct msi_parent_ops sg2042_msi_parent_o= ps =3D { .init_dev_msi_info =3D msi_lib_init_dev_msi_info, }; =20 +#define SG2044_MSI_FLAGS_REQUIRED (MSI_FLAG_USE_DEF_DOM_OPS | \ + MSI_FLAG_USE_DEF_CHIP_OPS) + +#define SG2044_MSI_FLAGS_SUPPORTED (MSI_GENERIC_FLAGS_MASK | \ + MSI_FLAG_PCI_MSIX) + +static const struct msi_parent_ops sg2044_msi_parent_ops =3D { + .required_flags =3D SG2044_MSI_FLAGS_REQUIRED, + .supported_flags =3D SG2044_MSI_FLAGS_SUPPORTED, + .chip_flags =3D MSI_CHIP_FLAG_SET_EOI | MSI_CHIP_FLAG_SET_ACK, + .bus_select_mask =3D MATCH_PCI_MSI, + .bus_select_token =3D DOMAIN_BUS_NEXUS, + .prefix =3D "SG2044-", + .init_dev_msi_info =3D msi_lib_init_dev_msi_info, +}; + static int sg204x_msi_init_domains(struct sg204x_msi_chipdata *data, struct irq_domain *plic_domain, struct device *dev) { @@ -255,6 +298,12 @@ static int sg2042_msi_probe(struct platform_device *pd= ev) =20 mutex_init(&data->msi_map_lock); =20 + data->msi_map =3D devm_bitmap_zalloc(&pdev->dev, data->num_irqs, GFP_KERN= EL); + if (!data->msi_map) { + dev_err(&pdev->dev, "Unable to allocate msi mapping\n"); + return -ENOMEM; + } + return sg204x_msi_init_domains(data, plic_domain, dev); } =20 @@ -263,8 +312,14 @@ static const struct sg204x_msi_chip_info sg2042_chip_i= nfo =3D { .parent_ops =3D &sg2042_msi_parent_ops, }; =20 +static const struct sg204x_msi_chip_info sg2044_chip_info =3D { + .irqchip =3D &sg2044_msi_middle_irq_chip, + .parent_ops =3D &sg2044_msi_parent_ops, +}; + static const struct of_device_id sg2042_msi_of_match[] =3D { { .compatible =3D "sophgo,sg2042-msi", .data =3D &sg2042_chip_info }, + { .compatible =3D "sophgo,sg2044-msi", .data =3D &sg2044_chip_info }, { } }; =20 --=20 2.49.0