From patchwork Tue Feb 21 21:26:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 60265 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp230638wrd; Tue, 21 Feb 2023 13:28:05 -0800 (PST) X-Google-Smtp-Source: AK7set8IDsuCMb2QqUrpN9KKrZiAFZRPtOR+OFPP1vVwP4VK3xwQRqiIOXyfvzuYeT2nR/fOdoWx X-Received: by 2002:a17:907:8c06:b0:8e3:86ef:505b with SMTP id ta6-20020a1709078c0600b008e386ef505bmr2488881ejc.21.1677014885609; Tue, 21 Feb 2023 13:28:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677014885; cv=none; d=google.com; s=arc-20160816; b=LtGJfAwxn/Lul/ltRsGdNHbRZpKkmmCCmJCGgy+a3alyrMHhxeVeAIHVT4qi0i6Ng8 13hCgYfDc5Le2oajv3KZ/AR4CqkVh2xFBx7xRd0HH+MNbV9a+6CtXymRKtDjoDMZJAXI dNrEnMVhN38Hzyrsi4oyYSrizm7Dz5unNXQhnKINlCDL2bpwFpFoZTGjH7I928740CeG 2ltr27AV/77zrWXT8/CTrqGVcwAQ8I2bbQUO2x6JugUbaa3VTdQzxvgRpbBkfw+QoxP1 8aF0zngi+ZO/0+wFbDnAcoKqC8mzIHTt7pPjdm6fPxZKVGMViO/IqWuRmOoUgG3xSP+0 faDA== 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=Qyn+EWnxFstxyTndS+aBZAkYcNiZRJK1wB+Dw0C3Hw8=; b=GIH5Nh/6PDiD9fragUWS0ks3r8/WS+tTCU3e8BeYWCL0ZxYfOq4r08GVG/MGfDDNUL Iq8iEv4yh2824927pLOwb4SNXqqC1m2STlwztyZML6ANndL9FbMGCkqLYjwWA7/CBLpr DHOo9xfdQm+xj5BQhMSuU8VrXCXQ9kx0yiUsc0TtWHZ8JiPAyd4NgiZurBHq43TVp5/1 cw8MAblfwEufXPMuWLXCtASmDx8P+3E1HfdClHyLBW0Ca8Q6suYzbrIRp5LtlqDXS1Sa /66Q0Ej2d1BqSgnzSb2HOSwGDnNrFC1Ng7MWmRFhpyEgoznkXlI23rhT5otR063VbAYS YukA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=U5nDySRs; 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=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id om25-20020a170907a19900b008da51485086si5068282ejc.81.2023.02.21.13.27.42; Tue, 21 Feb 2023 13:28:05 -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=@ibm.com header.s=pp1 header.b=U5nDySRs; 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=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229683AbjBUV0x (ORCPT + 99 others); Tue, 21 Feb 2023 16:26:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229930AbjBUV0t (ORCPT ); Tue, 21 Feb 2023 16:26:49 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD28F2E82D; Tue, 21 Feb 2023 13:26:47 -0800 (PST) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31LLHOIS023384; Tue, 21 Feb 2023 21:26:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=Qyn+EWnxFstxyTndS+aBZAkYcNiZRJK1wB+Dw0C3Hw8=; b=U5nDySRsuRNC1pN32z9Rnv7yFXz+gxsWc5PqGFEaHGlnGQW1911IhihVaXblAxsoPQ+4 GoCAPwTMo4sYDJUbuWIW8kpI1gNlVVHq9PD97BdQhJ//8MKIVYKQv3RmmHGhgWwfcS22 Is76opS1dCChaEjTYBIOy0mgVdd+6qfFgzrZ1CkLBTaqA2DCWS2KESz1kozDTHWYFc8N OxeHZYVDcs1J65hmVxlLtRHfGg5de5eSUvn8q05kWue40SV0SgQ7VFyEF5RTHJ8Nh0dN hwm3kTZG8Aw+Z6ybqVleHBHVpuICw+l+BNnn2TGxTM1yxNm11h00r9bobhf9VF7kFrvQ pw== Received: from ppma05wdc.us.ibm.com (1b.90.2fa9.ip4.static.sl-reverse.com [169.47.144.27]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3nw5he0f21-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Feb 2023 21:26:28 +0000 Received: from pps.filterd (ppma05wdc.us.ibm.com [127.0.0.1]) by ppma05wdc.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 31LLDV6f015920; Tue, 21 Feb 2023 21:26:28 GMT Received: from smtprelay01.wdc07v.mail.ibm.com ([9.208.129.119]) by ppma05wdc.us.ibm.com (PPS) with ESMTPS id 3ntpa6vuy5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Feb 2023 21:26:28 +0000 Received: from smtpav02.wdc07v.mail.ibm.com (smtpav02.wdc07v.mail.ibm.com [10.39.53.229]) by smtprelay01.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 31LLQRGU41288080 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 21 Feb 2023 21:26:27 GMT Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EA3CC58058; Tue, 21 Feb 2023 21:26:26 +0000 (GMT) Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 24CAC58059; Tue, 21 Feb 2023 21:26:25 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.65.223.120]) by smtpav02.wdc07v.mail.ibm.com (Postfix) with ESMTP; Tue, 21 Feb 2023 21:26:24 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: rostedt@goodmis.org, linux-trace-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, mhiramat@kernel.org, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, andrew@aj.id.au, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, eajames@linux.ibm.com Subject: [PATCH v5 1/6] fsi: Move fsi_slave structure definition to header Date: Tue, 21 Feb 2023 15:26:17 -0600 Message-Id: <20230221212622.3897097-2-eajames@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230221212622.3897097-1-eajames@linux.ibm.com> References: <20230221212622.3897097-1-eajames@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: soZPrvsKpj-x7P2i25deSYAtonnUn0eJ X-Proofpoint-GUID: soZPrvsKpj-x7P2i25deSYAtonnUn0eJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-21_12,2023-02-20_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 suspectscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 spamscore=0 clxscore=1015 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302210182 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,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?1758477560793592177?= X-GMAIL-MSGID: =?utf-8?q?1758477560793592177?= Some FSI drivers may have need of the slave definition, so move it to a header file. Also use one macro for obtaining a pointer to the fsi_master structure. Signed-off-by: Eddie James --- drivers/fsi/fsi-core.c | 24 ++++-------------------- drivers/fsi/fsi-master-aspeed.c | 2 +- drivers/fsi/fsi-master-ast-cf.c | 2 +- drivers/fsi/fsi-master-gpio.c | 2 +- drivers/fsi/fsi-master-hub.c | 2 +- drivers/fsi/fsi-master.h | 2 +- drivers/fsi/fsi-slave.h | 28 ++++++++++++++++++++++++++++ 7 files changed, 37 insertions(+), 25 deletions(-) create mode 100644 drivers/fsi/fsi-slave.h diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 0b927c9f4267..d591e68afd11 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -23,6 +23,10 @@ #include #include "fsi-master.h" +#include "fsi-slave.h" + +#define CREATE_TRACE_POINTS +#include #define FSI_SLAVE_CONF_NEXT_MASK GENMASK(31, 31) #define FSI_SLAVE_CONF_SLOTS_MASK GENMASK(23, 16) @@ -78,26 +82,6 @@ static const int engine_page_size = 0x400; static DEFINE_IDA(master_ida); -struct fsi_slave { - struct device dev; - struct fsi_master *master; - struct cdev cdev; - int cdev_idx; - int id; /* FSI address */ - int link; /* FSI link# */ - u32 cfam_id; - int chip_id; - uint32_t size; /* size of slave address space */ - u8 t_send_delay; - u8 t_echo_delay; -}; - -#define CREATE_TRACE_POINTS -#include - -#define to_fsi_master(d) container_of(d, struct fsi_master, dev) -#define to_fsi_slave(d) container_of(d, struct fsi_slave, dev) - static const int slave_retries = 2; static int discard_errors; diff --git a/drivers/fsi/fsi-master-aspeed.c b/drivers/fsi/fsi-master-aspeed.c index 7cec1772820d..437f87b4a6a3 100644 --- a/drivers/fsi/fsi-master-aspeed.c +++ b/drivers/fsi/fsi-master-aspeed.c @@ -376,7 +376,7 @@ static int aspeed_master_break(struct fsi_master *master, int link) static void aspeed_master_release(struct device *dev) { struct fsi_master_aspeed *aspeed = - to_fsi_master_aspeed(dev_to_fsi_master(dev)); + to_fsi_master_aspeed(to_fsi_master(dev)); kfree(aspeed); } diff --git a/drivers/fsi/fsi-master-ast-cf.c b/drivers/fsi/fsi-master-ast-cf.c index 5f608ef8b53c..6124978305eb 100644 --- a/drivers/fsi/fsi-master-ast-cf.c +++ b/drivers/fsi/fsi-master-ast-cf.c @@ -1190,7 +1190,7 @@ static int fsi_master_acf_gpio_release(void *data) static void fsi_master_acf_release(struct device *dev) { - struct fsi_master_acf *master = to_fsi_master_acf(dev_to_fsi_master(dev)); + struct fsi_master_acf *master = to_fsi_master_acf(to_fsi_master(dev)); /* Cleanup, stop coprocessor */ mutex_lock(&master->lock); diff --git a/drivers/fsi/fsi-master-gpio.c b/drivers/fsi/fsi-master-gpio.c index 7d5f29b4b595..ed03da4f2447 100644 --- a/drivers/fsi/fsi-master-gpio.c +++ b/drivers/fsi/fsi-master-gpio.c @@ -761,7 +761,7 @@ static DEVICE_ATTR(external_mode, 0664, static void fsi_master_gpio_release(struct device *dev) { - struct fsi_master_gpio *master = to_fsi_master_gpio(dev_to_fsi_master(dev)); + struct fsi_master_gpio *master = to_fsi_master_gpio(to_fsi_master(dev)); of_node_put(dev_of_node(master->dev)); diff --git a/drivers/fsi/fsi-master-hub.c b/drivers/fsi/fsi-master-hub.c index 01f0a796111e..6d8b6e8854e5 100644 --- a/drivers/fsi/fsi-master-hub.c +++ b/drivers/fsi/fsi-master-hub.c @@ -105,7 +105,7 @@ static int hub_master_link_enable(struct fsi_master *master, int link, static void hub_master_release(struct device *dev) { - struct fsi_master_hub *hub = to_fsi_master_hub(dev_to_fsi_master(dev)); + struct fsi_master_hub *hub = to_fsi_master_hub(to_fsi_master(dev)); kfree(hub); } diff --git a/drivers/fsi/fsi-master.h b/drivers/fsi/fsi-master.h index 4762315a46ba..967622c1cabf 100644 --- a/drivers/fsi/fsi-master.h +++ b/drivers/fsi/fsi-master.h @@ -136,7 +136,7 @@ struct fsi_master { u8 t_send_delay, u8 t_echo_delay); }; -#define dev_to_fsi_master(d) container_of(d, struct fsi_master, dev) +#define to_fsi_master(d) container_of(d, struct fsi_master, dev) /** * fsi_master registration & lifetime: the fsi_master_register() and diff --git a/drivers/fsi/fsi-slave.h b/drivers/fsi/fsi-slave.h new file mode 100644 index 000000000000..1d63a585829d --- /dev/null +++ b/drivers/fsi/fsi-slave.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright (C) IBM Corporation 2023 */ + +#ifndef DRIVERS_FSI_SLAVE_H +#define DRIVERS_FSI_SLAVE_H + +#include +#include + +struct fsi_master; + +struct fsi_slave { + struct device dev; + struct fsi_master *master; + struct cdev cdev; + int cdev_idx; + int id; /* FSI address */ + int link; /* FSI link# */ + u32 cfam_id; + int chip_id; + uint32_t size; /* size of slave address space */ + u8 t_send_delay; + u8 t_echo_delay; +}; + +#define to_fsi_slave(d) container_of(d, struct fsi_slave, dev) + +#endif /* DRIVERS_FSI_SLAVE_H */ From patchwork Tue Feb 21 21:26:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 60264 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp230581wrd; Tue, 21 Feb 2023 13:27:57 -0800 (PST) X-Google-Smtp-Source: AK7set9HbSosXf36HVao1yIJsWDwCumNKzdqW/Xl3TCmS3ZDisBPM0gjEMH+uCCuMCmnaN8qQwaq X-Received: by 2002:a05:6402:1653:b0:4ae:eab6:9ff8 with SMTP id s19-20020a056402165300b004aeeab69ff8mr9609845edx.13.1677014877386; Tue, 21 Feb 2023 13:27:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677014877; cv=none; d=google.com; s=arc-20160816; b=hJ6zEYzfzUx0YzP6FyKQ83cjIXYkkR/yGKUnhEAIdkS7ifJDDiUHYktxVsStBV4HuM d3YnmHibAtWiJzeHCyE4FaHH2FMvxSdeiVbxwguIVQLbunydX53MKPDsYaFPQcRPr5eh etx7f+LloQJkE/SD9xuPcdD4Z/qpi/3lRrHH7hSPhKVlvVCtiHuMSUpNuN2pt+7Ma9kn pFc3ifzktxgyoRy/eqJTyachkQIDX5Gf2nrG53AdYAUdJD7lQbjL61m0MU+O2BpRy94/ dpSz5uuhvMSNtdwqF49gAZm3mW/4tViToV7VEw48ZsZShx4Y6QRLhtyrwkSZUMEZSXjx O8AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kX3Vl11fgpbcRT2Yp+QxdfAbvT5CTTbsQ0eGJvC1rnw=; b=jpBAxPHXu2S7tYKQpOfMhFw1orwP6JoTULY0h/Hfa028/NUwI0OhU/uT6wZOPKG+ym /21g0vlVpr/r2MUKLoikP0zKgGTxdeFRYeMu7lB21y3ViR1mInWNlEl6gGASMXhSk7ko rdok+Qkx9m/YHnDM1vGTOhcIjH+264Bq1jJ4f4whjtHl3Ui8plLT+aAq42mb9daciYIn LD6krXbSbiE5Hee6t1bk5xFiR0cY7n3QFMxe9/vF514FXENWitMLCFXmWgmOBiKiskA7 gwHC0EBhhNMT22oxor1GX1qbKIHoIakhGN7Vtj9oi2cwr9mUJGNEOwstDcVwLMl0kyrF O+nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=kBuwO5Fh; 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=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f9-20020a056402004900b004ab4d025978si1104550edu.245.2023.02.21.13.27.33; Tue, 21 Feb 2023 13:27:57 -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=@ibm.com header.s=pp1 header.b=kBuwO5Fh; 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=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229817AbjBUV0s (ORCPT + 99 others); Tue, 21 Feb 2023 16:26:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229739AbjBUV0q (ORCPT ); Tue, 21 Feb 2023 16:26:46 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF7312E830; Tue, 21 Feb 2023 13:26:45 -0800 (PST) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31LLHOs9016319; Tue, 21 Feb 2023 21:26:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : mime-version; s=pp1; bh=kX3Vl11fgpbcRT2Yp+QxdfAbvT5CTTbsQ0eGJvC1rnw=; b=kBuwO5Fh3n0Vh/+ltapVI4SzWoZwAZXDRqE0hd7EKO+gTdRWCerCczGKY1ZlOFfskcpe MSpM1tnCuvPDCnY+AXHehfEqekKc9ONr74dVAyXJ4vHeJl3vFCvVA7wMz5bJp5wR+H81 frLxbgHRcKIj7azrSFgqqaLnelnVRJ3EUwFy7u7ZReuVD1IsXDb3JO7PM3ZFaNND7/bk 8cvs9wxBBYX2zFZYuv6pgKy5g6BK02zzakWcjiuTHZ6CV2s3Mt2nWIjrxgiI2+Ldxcjv 3oFYh6XjBppzSUt0QgDdYmEvXhc0qiG+lXHlZJ6Zdz9153jrI+09Un639Y2u3w6VOS7d XQ== Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nw5ngra04-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Feb 2023 21:26:31 +0000 Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 31LHoPrH016291; Tue, 21 Feb 2023 21:26:30 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([9.208.129.113]) by ppma02wdc.us.ibm.com (PPS) with ESMTPS id 3ntpa7cvdq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Feb 2023 21:26:30 +0000 Received: from smtpav02.wdc07v.mail.ibm.com (smtpav02.wdc07v.mail.ibm.com [10.39.53.229]) by smtprelay03.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 31LLQToA5374546 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 21 Feb 2023 21:26:29 GMT Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0C49758059; Tue, 21 Feb 2023 21:26:29 +0000 (GMT) Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3062758058; Tue, 21 Feb 2023 21:26:27 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.65.223.120]) by smtpav02.wdc07v.mail.ibm.com (Postfix) with ESMTP; Tue, 21 Feb 2023 21:26:27 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: rostedt@goodmis.org, linux-trace-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, mhiramat@kernel.org, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, andrew@aj.id.au, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, eajames@linux.ibm.com Subject: [PATCH v5 2/6] dt-bindings: fsi: Document the IBM I2C Responder virtual FSI master Date: Tue, 21 Feb 2023 15:26:18 -0600 Message-Id: <20230221212622.3897097-3-eajames@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230221212622.3897097-1-eajames@linux.ibm.com> References: <20230221212622.3897097-1-eajames@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: u5hwisiqOr9pdrpO0dc1676o-PZKdTTy X-Proofpoint-ORIG-GUID: u5hwisiqOr9pdrpO0dc1676o-PZKdTTy X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-21_12,2023-02-20_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 clxscore=1015 priorityscore=1501 spamscore=0 mlxscore=0 phishscore=0 bulkscore=0 lowpriorityscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302210182 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,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?1758477552310286790?= X-GMAIL-MSGID: =?utf-8?q?1758477552310286790?= The I2C Responder translates I2C commands to CFAM or SCOM operations, effectively implementing an FSI master. Signed-off-by: Eddie James Reviewed-by: Andrew Jeffery Reviewed-by: Krzysztof Kozlowski --- .../bindings/fsi/ibm,i2cr-fsi-master.yaml | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Documentation/devicetree/bindings/fsi/ibm,i2cr-fsi-master.yaml diff --git a/Documentation/devicetree/bindings/fsi/ibm,i2cr-fsi-master.yaml b/Documentation/devicetree/bindings/fsi/ibm,i2cr-fsi-master.yaml new file mode 100644 index 000000000000..442cecdc57cb --- /dev/null +++ b/Documentation/devicetree/bindings/fsi/ibm,i2cr-fsi-master.yaml @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/fsi/ibm,i2cr-fsi-master.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: IBM I2C Responder virtual FSI master + +maintainers: + - Eddie James + +description: | + The I2C Responder (I2CR) is a an I2C device that's connected to an FSI CFAM + (see fsi.txt). The I2CR translates I2C bus operations to FSI CFAM reads and + writes or SCOM operations, thereby acting as an FSI master. + +properties: + compatible: + enum: + - ibm,i2cr-fsi-master + + reg: + maxItems: 1 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + i2cr@20 { + compatible = "ibm,i2cr-fsi-master"; + reg = <0x20>; + }; + }; From patchwork Tue Feb 21 21:26:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 60268 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp231161wrd; Tue, 21 Feb 2023 13:29:51 -0800 (PST) X-Google-Smtp-Source: AK7set/vxJTyHhv8riclrzai3KqaEvBAy3dN8eXfrHnX7cjXX1aR8MyqWwqXSlHmWS2lbWv0mfiP X-Received: by 2002:aa7:d794:0:b0:4ad:7224:ce9f with SMTP id s20-20020aa7d794000000b004ad7224ce9fmr6918819edq.17.1677014990854; Tue, 21 Feb 2023 13:29:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677014990; cv=none; d=google.com; s=arc-20160816; b=zX2rkKa7gaF3PJ/n4126GQPBBFV2FnJ6YQk3X5xz8PhkMxQYUCsc2KxhVKC8uztyat pHcmCVNqIC9oFFuRgN9R1Q6BXcJrWtVUE1BGVw2mBCdsJMyg5xOzwwxcbd0mSeSOYWhW uTX+yYjQL/0I7oNpsbZmy9wQbYKR6Zsu9atAMWKIUDPWEbB9BnuENs8nX5B3L5BHsyl5 3w4mgEGdck0k+AAsfPvTDNLO5LyRydY6v+tAS0zGbOpXRoQ9tD0GXaPHmA0CjZGO3JV7 ji2aDDd2voZ8uU9JBbny0j8SXkO/faEiK/k2pxK6vTQGr99iEj+0oRV7WPWBWCCUkFQl mgXw== 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=iewubdbzkMpFrlnBQmvRr1ZguaKXzO3tk5NYbvu+Gak=; b=jvOCFTDYPe3NDLd9mR5N/usU2wZB+Ma9h8QYlXfPmRXu3QXsBnRpFf2RLr5oJ2ISAa LBX/cAn+rjlFCtvR03x7Zez+LHrmX7BYaoKTfGSSg9GDnXPt9P/SHAioXa3Q1usjNfKC Ospici3jyux6ybKM9T0lWG/WtWBUYYfP9YmrEntUy9O8Fp3TpsEtWQGJRZN68X9P4dqm PqXjWJBup8MA+SDCpuodc11C7J34Qw6A//da3sV+vzTrTF9jgZ4gR9EQA33wgihmjl4g Wkfgb+VRy0OXI/MvsudvAm8tSApeLqgtr6TpEeATq9tx8Cv82/wld0ng89ejRP0p4iiu r+WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=WdYUcd1h; 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=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j8-20020aa7c408000000b004acc60f2adbsi20608289edq.231.2023.02.21.13.29.27; Tue, 21 Feb 2023 13:29: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=@ibm.com header.s=pp1 header.b=WdYUcd1h; 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=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229462AbjBUV1D (ORCPT + 99 others); Tue, 21 Feb 2023 16:27:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229939AbjBUV0w (ORCPT ); Tue, 21 Feb 2023 16:26:52 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30440311E3; Tue, 21 Feb 2023 13:26:49 -0800 (PST) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31LLHOhM022447; Tue, 21 Feb 2023 21:26:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=iewubdbzkMpFrlnBQmvRr1ZguaKXzO3tk5NYbvu+Gak=; b=WdYUcd1hcdnHjcwd3OqcwPNFOjA1h8eRqnzJkNEXCXCZjrLlFm1nVsIslzVHKTmzMOtW +4dl4/AXD3buFQpIZOBMlL/o8+K9fzHOKJ6UG78oFfGUJMqd/5u/T34N3AmGHrgnkwjL 17t6dLB2zhU9ipi2PrMTattfZt34uGL4kH6MjirBo1chAqwK/D+FdQnEuM1MrfMid3nb mtguhuKPQMA4RkwuzAsPq7Rk4kj8kJ1fxvAezJ9uZag1/gb4rg785pZ4sd79JjI82UnE DvNWw0Ik/VgUuJTDYSabrxMEYbqbb/fbZjeUBQjQVrDAaGM2a968tB2BfOZR9iE71mM2 WA== Received: from ppma05wdc.us.ibm.com (1b.90.2fa9.ip4.static.sl-reverse.com [169.47.144.27]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3nw4ma9sph-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Feb 2023 21:26:32 +0000 Received: from pps.filterd (ppma05wdc.us.ibm.com [127.0.0.1]) by ppma05wdc.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 31LHmTvR015944; Tue, 21 Feb 2023 21:26:32 GMT Received: from smtprelay05.wdc07v.mail.ibm.com ([9.208.129.117]) by ppma05wdc.us.ibm.com (PPS) with ESMTPS id 3ntpa6vuye-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Feb 2023 21:26:32 +0000 Received: from smtpav02.wdc07v.mail.ibm.com (smtpav02.wdc07v.mail.ibm.com [10.39.53.229]) by smtprelay05.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 31LLQV6I262848 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 21 Feb 2023 21:26:31 GMT Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 139A558059; Tue, 21 Feb 2023 21:26:31 +0000 (GMT) Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 45FAC58058; Tue, 21 Feb 2023 21:26:29 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.65.223.120]) by smtpav02.wdc07v.mail.ibm.com (Postfix) with ESMTP; Tue, 21 Feb 2023 21:26:29 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: rostedt@goodmis.org, linux-trace-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, mhiramat@kernel.org, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, andrew@aj.id.au, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, eajames@linux.ibm.com Subject: [PATCH v5 3/6] fsi: Add IBM I2C Responder virtual FSI master Date: Tue, 21 Feb 2023 15:26:19 -0600 Message-Id: <20230221212622.3897097-4-eajames@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230221212622.3897097-1-eajames@linux.ibm.com> References: <20230221212622.3897097-1-eajames@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: vP79WBBjLuxHXwliBQGRDaZAIIZh9eZ0 X-Proofpoint-GUID: vP79WBBjLuxHXwliBQGRDaZAIIZh9eZ0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-21_12,2023-02-20_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 malwarescore=0 mlxscore=0 priorityscore=1501 phishscore=0 impostorscore=0 lowpriorityscore=0 clxscore=1015 suspectscore=0 spamscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302210182 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,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?1758477528620088614?= X-GMAIL-MSGID: =?utf-8?q?1758477670668835340?= The I2C Responder (I2CR) is an I2C device that translates I2C commands to CFAM or SCOM operations, effectively implementing an FSI master and bus. Signed-off-by: Eddie James --- Changes since v4: - Split the read/write functions into the FSI master register access functions and generic functions that can do the SCOMs - Rework the trace events to handle variable data size and fix the trace structure alignment/padding - Add a check on the status register during probe to avoid registering the FSI master if the device isn't there drivers/fsi/Kconfig | 9 + drivers/fsi/Makefile | 1 + drivers/fsi/fsi-master-i2cr.c | 228 +++++++++++++++++++++++++ drivers/fsi/fsi-master-i2cr.h | 24 +++ drivers/fsi/fsi-master.h | 1 + include/trace/events/fsi_master_i2cr.h | 109 ++++++++++++ 6 files changed, 372 insertions(+) create mode 100644 drivers/fsi/fsi-master-i2cr.c create mode 100644 drivers/fsi/fsi-master-i2cr.h create mode 100644 include/trace/events/fsi_master_i2cr.h diff --git a/drivers/fsi/Kconfig b/drivers/fsi/Kconfig index e6668a869913..999be82720c5 100644 --- a/drivers/fsi/Kconfig +++ b/drivers/fsi/Kconfig @@ -62,6 +62,15 @@ config FSI_MASTER_ASPEED Enable it for your BMC kernel in an OpenPower or IBM Power system. +config FSI_MASTER_I2CR + tristate "IBM I2C Responder virtual FSI master" + depends on I2C + help + This option enables a virtual FSI master in order to access a CFAM + behind an IBM I2C Responder (I2CR) chip. The I2CR is an I2C device + that translates I2C commands to CFAM or SCOM operations, effectively + implementing an FSI master and bus. + config FSI_SCOM tristate "SCOM FSI client device driver" help diff --git a/drivers/fsi/Makefile b/drivers/fsi/Makefile index da218a1ad8e1..34dbaa1c452e 100644 --- a/drivers/fsi/Makefile +++ b/drivers/fsi/Makefile @@ -4,6 +4,7 @@ obj-$(CONFIG_FSI) += fsi-core.o obj-$(CONFIG_FSI_MASTER_HUB) += fsi-master-hub.o obj-$(CONFIG_FSI_MASTER_ASPEED) += fsi-master-aspeed.o obj-$(CONFIG_FSI_MASTER_GPIO) += fsi-master-gpio.o +obj-$(CONFIG_FSI_MASTER_I2CR) += fsi-master-i2cr.o obj-$(CONFIG_FSI_MASTER_AST_CF) += fsi-master-ast-cf.o obj-$(CONFIG_FSI_SCOM) += fsi-scom.o obj-$(CONFIG_FSI_SBEFIFO) += fsi-sbefifo.o diff --git a/drivers/fsi/fsi-master-i2cr.c b/drivers/fsi/fsi-master-i2cr.c new file mode 100644 index 000000000000..d4ea41cde1ae --- /dev/null +++ b/drivers/fsi/fsi-master-i2cr.c @@ -0,0 +1,228 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (C) IBM Corporation 2023 */ + +#include +#include +#include +#include +#include +#include + +#include "fsi-master-i2cr.h" + +#define CREATE_TRACE_POINTS +#include + +#define I2CR_ADDRESS_CFAM(a) ((a) >> 2) +#define I2CR_STATUS 0x30001 +#define I2CR_STATUS_ERR BIT_ULL(61) +#define I2CR_ERROR 0x30002 + +static bool i2cr_check_parity(u32 v, bool parity) +{ + u32 i; + + for (i = 0; i < 32; ++i) { + if (v & (1 << i)) + parity = !parity; + } + + return parity; +} + +static __be32 i2cr_get_command(u32 address, bool parity) +{ + address <<= 1; + + if (i2cr_check_parity(address, parity)) + address |= 1; + + return cpu_to_be32(address); +} + +static int i2cr_transfer(struct i2c_client *client, u32 address, __be64 *data) +{ + struct i2c_msg msgs[2]; + __be32 command; + int ret; + + command = i2cr_get_command(address, true); + msgs[0].addr = client->addr; + msgs[0].flags = 0; + msgs[0].len = sizeof(command); + msgs[0].buf = (__u8 *)&command; + msgs[1].addr = client->addr; + msgs[1].flags = I2C_M_RD; + msgs[1].len = sizeof(*data); + msgs[1].buf = (__u8 *)data; + + ret = i2c_transfer(client->adapter, msgs, 2); + if (ret == 2) + return 0; + + trace_i2cr_i2c_error(client, command, ret); + + if (ret < 0) + return ret; + + return -EIO; +} + +static int i2cr_check_status(struct i2c_client *client) +{ + __be64 status_be = 0; + u64 status; + int ret; + + ret = i2cr_transfer(client, I2CR_STATUS, &status_be); + if (ret) + return ret; + + status = be64_to_cpu(status_be); + if (status & I2CR_STATUS_ERR) { + __be64 error_be = 0; + u64 error; + + i2cr_transfer(client, I2CR_ERROR, &error_be); + error = be64_to_cpu(error_be); + trace_i2cr_status_error(client, status, error); + + dev_err(&client->dev, "status:%016llx error:%016llx\n", status, error); + return -EREMOTEIO; + } + + trace_i2cr_status(client, status); + return 0; +} + +int fsi_master_i2cr_read(struct fsi_master_i2cr *i2cr, u32 addr, void *data, size_t size) +{ + __be64 buf; + int ret; + + mutex_lock(&i2cr->lock); + + ret = i2cr_transfer(i2cr->client, addr, &buf); + if (ret) + goto unlock; + + ret = i2cr_check_status(i2cr->client); + if (ret) + goto unlock; + + memcpy(data, &buf, size); + trace_i2cr_read(i2cr->client, addr, data, size); + +unlock: + mutex_unlock(&i2cr->lock); + return ret; +} + +int fsi_master_i2cr_write(struct fsi_master_i2cr *i2cr, u32 addr, const void *data, size_t size) +{ + u32 buf[3] = { 0 }; + __be32 command; + int ret; + + memcpy(&buf[1], data, size); + command = i2cr_get_command(addr, i2cr_check_parity(buf[1], true)); + memcpy(&buf[0], &command, sizeof(u32)); + + mutex_lock(&i2cr->lock); + + ret = i2c_master_send(i2cr->client, (const char *)buf, sizeof(buf)); + if (ret == sizeof(buf)) { + ret = i2cr_check_status(i2cr->client); + if (!ret) + trace_i2cr_write(i2cr->client, addr, data, size); + } else { + trace_i2cr_i2c_error(i2cr->client, command, ret); + + if (ret >= 0) + ret = -EIO; + } + + mutex_unlock(&i2cr->lock); + return ret; +} + +static int i2cr_read(struct fsi_master *master, int link, uint8_t id, uint32_t addr, void *val, + size_t size) +{ + struct fsi_master_i2cr *i2cr = container_of(master, struct fsi_master_i2cr, master); + + if (link || id || (addr & 0xffff0000) || !(size == 1 || size == 2 || size == 4)) + return -EINVAL; + + return fsi_master_i2cr_read(i2cr, I2CR_ADDRESS_CFAM(addr), val, size); +} + +static int i2cr_write(struct fsi_master *master, int link, uint8_t id, uint32_t addr, + const void *val, size_t size) +{ + struct fsi_master_i2cr *i2cr = container_of(master, struct fsi_master_i2cr, master); + + if (link || id || (addr & 0xffff0000) || !(size == 1 || size == 2 || size == 4)) + return -EINVAL; + + return fsi_master_i2cr_write(i2cr, I2CR_ADDRESS_CFAM(addr), val, size); +} + +static int i2cr_probe(struct i2c_client *client) +{ + struct fsi_master_i2cr *i2cr; + int ret; + + if (i2cr_check_status(client)) + return -ENODEV; + + i2cr = devm_kzalloc(&client->dev, sizeof(*i2cr), GFP_KERNEL); + if (!i2cr) + return -ENOMEM; + + i2cr->master.dev.parent = &client->dev; + i2cr->master.dev.of_node = of_node_get(dev_of_node(&client->dev)); + + i2cr->master.n_links = 1; + i2cr->master.flags = FSI_MASTER_FLAG_I2CR; + i2cr->master.read = i2cr_read; + i2cr->master.write = i2cr_write; + + mutex_init(&i2cr->lock); + i2cr->client = client; + + ret = fsi_master_register(&i2cr->master); + if (ret) + return ret; + + i2c_set_clientdata(client, i2cr); + return 0; +} + +static void i2cr_remove(struct i2c_client *client) +{ + struct fsi_master_i2cr *i2cr = i2c_get_clientdata(client); + + fsi_master_unregister(&i2cr->master); +} + +static const struct of_device_id i2cr_ids[] = { + { .compatible = "ibm,i2cr-fsi-master" }, + { } +}; +MODULE_DEVICE_TABLE(of, i2cr_ids); + +static struct i2c_driver i2cr_driver = { + .probe_new = i2cr_probe, + .remove = i2cr_remove, + .driver = { + .name = "fsi-master-i2cr", + .of_match_table = i2cr_ids, + }, +}; + +module_i2c_driver(i2cr_driver) + +MODULE_AUTHOR("Eddie James "); +MODULE_DESCRIPTION("IBM I2C Responder virtual FSI master driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/fsi/fsi-master-i2cr.h b/drivers/fsi/fsi-master-i2cr.h new file mode 100644 index 000000000000..0e164b3c6d3c --- /dev/null +++ b/drivers/fsi/fsi-master-i2cr.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright (C) IBM Corporation 2023 */ + +#ifndef DRIVERS_FSI_MASTER_I2CR_H +#define DRIVERS_FSI_MASTER_I2CR_H + +#include + +#include "fsi-master.h" + +struct i2c_client; + +struct fsi_master_i2cr { + struct fsi_master master; + struct mutex lock; /* protect HW access */ + struct i2c_client *client; +}; + +#define to_fsi_master_i2cr(m) container_of(m, struct fsi_master_i2cr, master) + +int fsi_master_i2cr_read(struct fsi_master_i2cr *i2cr, u32 addr, void *data, size_t size); +int fsi_master_i2cr_write(struct fsi_master_i2cr *i2cr, u32 addr, const void *data, size_t size); + +#endif /* DRIVERS_FSI_MASTER_I2CR_H */ diff --git a/drivers/fsi/fsi-master.h b/drivers/fsi/fsi-master.h index 967622c1cabf..a1fa315849d2 100644 --- a/drivers/fsi/fsi-master.h +++ b/drivers/fsi/fsi-master.h @@ -111,6 +111,7 @@ /* fsi-master definition and flags */ #define FSI_MASTER_FLAG_SWCLOCK 0x1 +#define FSI_MASTER_FLAG_I2CR 0x2 /* * Structures and function prototypes diff --git a/include/trace/events/fsi_master_i2cr.h b/include/trace/events/fsi_master_i2cr.h new file mode 100644 index 000000000000..bbd7875ee5a6 --- /dev/null +++ b/include/trace/events/fsi_master_i2cr.h @@ -0,0 +1,109 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM fsi_master_i2cr + +#if !defined(_TRACE_FSI_MASTER_I2CR_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_FSI_MASTER_I2CR_H + +#include + +TRACE_EVENT(i2cr_i2c_error, + TP_PROTO(const struct i2c_client *client, __be32 command, int rc), + TP_ARGS(client, command, rc), + TP_STRUCT__entry( + __field(int, bus) + __field(int, rc) + __array(unsigned char, command, sizeof(__be32)) + __field(unsigned short, addr) + ), + TP_fast_assign( + __entry->bus = client->adapter->nr; + __entry->addr = client->addr; + memcpy(__entry->command, &command, sizeof(__be32)); + __entry->rc = rc; + ), + TP_printk("%d-%02x command:{ %*ph } rc:%d", __entry->bus, __entry->addr, + (int)sizeof(__be32), __entry->command, __entry->rc) +); + +TRACE_EVENT(i2cr_read, + TP_PROTO(const struct i2c_client *client, uint32_t address, const void *data, size_t size), + TP_ARGS(client, address, data, size), + TP_STRUCT__entry( + __field(size_t, size) + __field(int, bus) + __field(uint32_t, address) + __array(unsigned char, data, 8) + __field(unsigned short, addr) + ), + TP_fast_assign( + __entry->bus = client->adapter->nr; + __entry->addr = client->addr; + __entry->address = address; + __entry->size = size > 8 ? 8 : size; + memcpy(__entry->data, data, __entry->size); + ), + TP_printk("%d-%02x address:%08x size:%zu { %*ph }", __entry->bus, __entry->addr, + __entry->address, __entry->size, (int)__entry->size, __entry->data) +); + +TRACE_EVENT(i2cr_status, + TP_PROTO(const struct i2c_client *client, uint64_t status), + TP_ARGS(client, status), + TP_STRUCT__entry( + __field(uint64_t, status) + __field(int, bus) + __field(unsigned short, addr) + ), + TP_fast_assign( + __entry->bus = client->adapter->nr; + __entry->addr = client->addr; + __entry->status = status; + ), + TP_printk("%d-%02x %016llx", __entry->bus, __entry->addr, __entry->status) +); + +TRACE_EVENT(i2cr_status_error, + TP_PROTO(const struct i2c_client *client, uint64_t status, uint64_t error), + TP_ARGS(client, status, error), + TP_STRUCT__entry( + __field(uint64_t, error) + __field(uint64_t, status) + __field(int, bus) + __field(unsigned short, addr) + ), + TP_fast_assign( + __entry->bus = client->adapter->nr; + __entry->addr = client->addr; + __entry->error = error; + __entry->status = status; + ), + TP_printk("%d-%02x status:%016llx error:%016llx", __entry->bus, __entry->addr, + __entry->status, __entry->error) +); + +TRACE_EVENT(i2cr_write, + TP_PROTO(const struct i2c_client *client, uint32_t address, const void *data, size_t size), + TP_ARGS(client, address, data, size), + TP_STRUCT__entry( + __field(size_t, size) + __field(int, bus) + __field(uint32_t, address) + __array(unsigned char, data, 8) + __field(unsigned short, addr) + ), + TP_fast_assign( + __entry->bus = client->adapter->nr; + __entry->addr = client->addr; + __entry->address = address; + __entry->size = size > 8 ? 8 : size; + memcpy(__entry->data, data, __entry->size); + ), + TP_printk("%d-%02x address:%08x size:%zu { %*ph }", __entry->bus, __entry->addr, + __entry->address, __entry->size, (int)__entry->size, __entry->data) +); + +#endif + +#include From patchwork Tue Feb 21 21:26:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 60266 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp230823wrd; Tue, 21 Feb 2023 13:28:46 -0800 (PST) X-Google-Smtp-Source: AK7set9GIrRr5pr+clY7EqzOinufTXnd3t5D6YrmwCTMQCpYOp864pH4E0xygxUunKFcdK2uo/LX X-Received: by 2002:a17:906:895:b0:8b1:16b3:303e with SMTP id n21-20020a170906089500b008b116b3303emr12694173eje.65.1677014926288; Tue, 21 Feb 2023 13:28:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677014926; cv=none; d=google.com; s=arc-20160816; b=MEYjIG5+mdLR8aLrZZ2EXalPS8ps1+KbZTCSwlhY99+ishPn3HFeASHuu/+Dy3y9Wg 9lkpqYtLKri+1gDdEP+SWBCtTY0F9fSWspfuyoV7Pm6vv59hquGJPgriWgkJkchJ8x1D HxW35vyABHw3N37XsNi3+y0VR/3Z9YvcHCM4ZYMY2fKMAYa2f4i5fDkPs7vEW6+Cn6dC LN0jb/JPt1ruV6TCZutvI51+9Jf1FPT4qPtC9u3EZU4qa21vC3rtSlEwV5OYTWhMlK0E 9sZnUyLv5HrBXSieM7VmF8cRkpWGVqL0CBHRkOYS3xvpqhRuUQztlpJXOOswvMTX7sM6 fctg== 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=5xWbYPcgc3bQ0wvnr2TBCu4KGyKaVhhsaKawXrsKrGU=; b=VIH+B1NLGRaJxOgCSxRTJWmrk/aSIQiuk20y0lE8iXko46I4rBH7zVGJNG6fwJUT3f 8K1sCjKVBT0u25fWAh4qz7K3MWK7YxatIh8eaS8Qi/RMYKc8RqrUETVKpcq/Cu08KHOR DCPMCFeXWTURRl4tKgrLXkxP69x7jrNnVjIUMAxsQcz3Rx76THpTpPI6urRCZFmrtFu2 D20LSuy0CsJGcRA3h+mC6I1+te4pFAkIxcqBG3+a5OYhGOr2AJVm6eQG6mNEIO3e5tFQ OjjS7cX3bR6vm8zXKJw3a4XgwBMeVzlfgHnqbXeUdVcAw7S1W5aEn3zgt6Hgv2Sy8ROR QAHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=GRbpKUMk; 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=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fq38-20020a1709069da600b008dfead50664si2917422ejc.114.2023.02.21.13.28.23; Tue, 21 Feb 2023 13:28:46 -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=@ibm.com header.s=pp1 header.b=GRbpKUMk; 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=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230010AbjBUV06 (ORCPT + 99 others); Tue, 21 Feb 2023 16:26:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229940AbjBUV0w (ORCPT ); Tue, 21 Feb 2023 16:26:52 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A64E2ED4C; Tue, 21 Feb 2023 13:26:50 -0800 (PST) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31LLHNqq023254; Tue, 21 Feb 2023 21:26:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=5xWbYPcgc3bQ0wvnr2TBCu4KGyKaVhhsaKawXrsKrGU=; b=GRbpKUMka62Zv1MOGZApY6Wd9QdEvmVygEWa3gNhFLbigXF4v9PLv6SvYGw+K1Q1Lotd Qg2CDLthN6bFMh5n0wZn0VuEfl+koClVsw0o4xNlWt46JL/Ph3mgbcEIyRzIYSnwU1nJ 3zNlX7gFhA2UNDHrmJNSAuYdoUIja9Z4JP60e+zxhbZg7IHoh2flezOnQ6HdJuK9Wm/S sQP8GyUNYLSc/vDQAyTdpJ2REzqfIW5VyQEbjzWDEl2mnDSXFJ8sOgyqU7Lr/7fQ1Y9b hHOpVHDcm3beVOxMa6k2aLtIBZQQt63/ss/zsLTKvxKGyDZhkqvs+FVZaC1AfReE+R/w Zw== Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3nw5he0f3r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Feb 2023 21:26:35 +0000 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 31LITOfF019805; Tue, 21 Feb 2023 21:26:34 GMT Received: from smtprelay03.dal12v.mail.ibm.com ([9.208.130.98]) by ppma02dal.us.ibm.com (PPS) with ESMTPS id 3ntpa7a035-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Feb 2023 21:26:34 +0000 Received: from smtpav02.wdc07v.mail.ibm.com (smtpav02.wdc07v.mail.ibm.com [10.39.53.229]) by smtprelay03.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 31LLQXKk1770158 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 21 Feb 2023 21:26:33 GMT Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1AF0C5805C; Tue, 21 Feb 2023 21:26:33 +0000 (GMT) Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4CC7758058; Tue, 21 Feb 2023 21:26:31 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.65.223.120]) by smtpav02.wdc07v.mail.ibm.com (Postfix) with ESMTP; Tue, 21 Feb 2023 21:26:31 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: rostedt@goodmis.org, linux-trace-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, mhiramat@kernel.org, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, andrew@aj.id.au, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, eajames@linux.ibm.com Subject: [PATCH v5 4/6] fsi: Add I2C Responder SCOM driver Date: Tue, 21 Feb 2023 15:26:20 -0600 Message-Id: <20230221212622.3897097-5-eajames@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230221212622.3897097-1-eajames@linux.ibm.com> References: <20230221212622.3897097-1-eajames@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: rCHA6uGqnlQ9G7oA-E6CktJEwHqQ-v51 X-Proofpoint-GUID: rCHA6uGqnlQ9G7oA-E6CktJEwHqQ-v51 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-21_12,2023-02-20_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 suspectscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 spamscore=0 clxscore=1015 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302210182 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,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?1758477603130033831?= X-GMAIL-MSGID: =?utf-8?q?1758477603130033831?= The I2CR has the capability to directly perform SCOM operations, circumventing the need to drive the FSI2PIB engine. Add a new driver to perform SCOM operations through the I2CR. Signed-off-by: Eddie James --- drivers/fsi/Kconfig | 12 +++ drivers/fsi/Makefile | 1 + drivers/fsi/i2cr-scom.c | 158 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 171 insertions(+) create mode 100644 drivers/fsi/i2cr-scom.c diff --git a/drivers/fsi/Kconfig b/drivers/fsi/Kconfig index 999be82720c5..09a8285d4bdc 100644 --- a/drivers/fsi/Kconfig +++ b/drivers/fsi/Kconfig @@ -71,6 +71,18 @@ config FSI_MASTER_I2CR that translates I2C commands to CFAM or SCOM operations, effectively implementing an FSI master and bus. +if FSI_MASTER_I2CR + +config I2CR_SCOM + tristate "IBM I2C Responder SCOM driver" + default y + help + This option enables an I2C Responder based SCOM device driver. The + I2CR has the capability to directly perform SCOM operations instead + of using the FSI2PIB engine. + +endif + config FSI_SCOM tristate "SCOM FSI client device driver" help diff --git a/drivers/fsi/Makefile b/drivers/fsi/Makefile index 34dbaa1c452e..5550aa15e0b1 100644 --- a/drivers/fsi/Makefile +++ b/drivers/fsi/Makefile @@ -9,3 +9,4 @@ obj-$(CONFIG_FSI_MASTER_AST_CF) += fsi-master-ast-cf.o obj-$(CONFIG_FSI_SCOM) += fsi-scom.o obj-$(CONFIG_FSI_SBEFIFO) += fsi-sbefifo.o obj-$(CONFIG_FSI_OCC) += fsi-occ.o +obj-$(CONFIG_I2CR_SCOM) += i2cr-scom.o diff --git a/drivers/fsi/i2cr-scom.c b/drivers/fsi/i2cr-scom.c new file mode 100644 index 000000000000..7e1c7b93c32f --- /dev/null +++ b/drivers/fsi/i2cr-scom.c @@ -0,0 +1,158 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (C) IBM Corporation 2023 */ + +#include +#include +#include +#include +#include +#include + +#include "fsi-master-i2cr.h" +#include "fsi-slave.h" + +struct i2cr_scom { + struct device dev; + struct cdev cdev; + struct fsi_master_i2cr *i2cr; +}; + +static loff_t i2cr_scom_llseek(struct file *file, loff_t offset, int whence) +{ + switch (whence) { + case SEEK_CUR: + break; + case SEEK_SET: + file->f_pos = offset; + break; + default: + return -EINVAL; + } + + return offset; +} + +static ssize_t i2cr_scom_read(struct file *filep, char __user *buf, size_t len, loff_t *offset) +{ + struct i2cr_scom *scom = filep->private_data; + __be64 data_be; + u64 data; + int ret; + + if (len != sizeof(data)) + return -EINVAL; + + ret = fsi_master_i2cr_read(scom->i2cr, (u32)*offset, &data_be, sizeof(data_be)); + if (ret) + return ret; + + data = be64_to_cpu(data_be); + ret = copy_to_user(buf, &data, len); + if (ret) + return ret; + + return len; +} + +static ssize_t i2cr_scom_write(struct file *filep, const char __user *buf, size_t len, + loff_t *offset) +{ + struct i2cr_scom *scom = filep->private_data; + __be64 data_be; + u64 data; + int ret; + + if (len != sizeof(data)) + return -EINVAL; + + ret = copy_from_user(&data, buf, len); + if (ret) + return ret; + + data_be = cpu_to_be64(data); + ret = fsi_master_i2cr_write(scom->i2cr, (u32)*offset, &data_be, sizeof(data_be)); + if (ret) + return ret; + + return len; +} + +static const struct file_operations i2cr_scom_fops = { + .owner = THIS_MODULE, + .open = simple_open, + .llseek = i2cr_scom_llseek, + .read = i2cr_scom_read, + .write = i2cr_scom_write, +}; + +static int i2cr_scom_probe(struct device *dev) +{ + struct fsi_device *fsi_dev = to_fsi_dev(dev); + struct i2cr_scom *scom; + int didx; + int ret; + + if (!(fsi_dev->slave->master->flags & FSI_MASTER_FLAG_I2CR)) + return -ENODEV; + + scom = devm_kzalloc(dev, sizeof(*scom), GFP_KERNEL); + if (!scom) + return -ENOMEM; + + scom->i2cr = to_fsi_master_i2cr(fsi_dev->slave->master); + dev_set_drvdata(dev, scom); + + scom->dev.type = &fsi_cdev_type; + scom->dev.parent = dev; + device_initialize(&scom->dev); + + ret = fsi_get_new_minor(fsi_dev, fsi_dev_scom, &scom->dev.devt, &didx); + if (ret) + return ret; + + dev_set_name(&scom->dev, "scom%d", didx); + cdev_init(&scom->cdev, &i2cr_scom_fops); + ret = cdev_device_add(&scom->cdev, &scom->dev); + if (ret) + fsi_free_minor(scom->dev.devt); + + return ret; +} + +static int i2cr_scom_remove(struct device *dev) +{ + struct i2cr_scom *scom = dev_get_drvdata(dev); + + cdev_device_del(&scom->cdev, &scom->dev); + fsi_free_minor(scom->dev.devt); + + return 0; +} + +static const struct of_device_id i2cr_scom_of_ids[] = { + { .compatible = "ibm,i2cr-scom" }, + { } +}; +MODULE_DEVICE_TABLE(of, i2cr_scom_of_ids); + +static const struct fsi_device_id i2cr_scom_ids[] = { + { 0x5, FSI_VERSION_ANY }, + { } +}; + +static struct fsi_driver i2cr_scom_driver = { + .id_table = i2cr_scom_ids, + .drv = { + .name = "i2cr_scom", + .bus = &fsi_bus_type, + .of_match_table = i2cr_scom_of_ids, + .probe = i2cr_scom_probe, + .remove = i2cr_scom_remove, + } +}; + +module_fsi_driver(i2cr_scom_driver); + +MODULE_AUTHOR("Eddie James "); +MODULE_DESCRIPTION("IBM I2C Responder SCOM driver"); +MODULE_LICENSE("GPL"); From patchwork Tue Feb 21 21:26:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 60267 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp230909wrd; Tue, 21 Feb 2023 13:29:06 -0800 (PST) X-Google-Smtp-Source: AK7set/2lEEcRHjXurb9SbRWHBLCd7I7hMRRPhyFpbjGjjdvEqQMC/wB0w9XdKvEgHoJ/q/VX5lE X-Received: by 2002:aa7:c54a:0:b0:4ac:c137:4848 with SMTP id s10-20020aa7c54a000000b004acc1374848mr5950483edr.22.1677014946486; Tue, 21 Feb 2023 13:29:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677014946; cv=none; d=google.com; s=arc-20160816; b=dWIxFAV8qC9JjPiNnz9nHhfjH9/pF+3i4NFGV8zRpxdIts16ZpeeRddKrW0ONQZ+OR IxWIguVhXze6g+JuOpYSa3SV6S0YI25I2WPWzMEOU3SVqHnF4wGH9H0lQOiqEVFteOII Sckkb14WnU6CBLePWeH9gI0htvcvyyG3TDEzXGwc+TxET590gRXaVD6FocqDkjzXUSEm jT0/Ag3gYQy6Ka7CC+DZm2JVyjxdyBJEm2FreECrnSEmU5/1mtDc2sWoUmNWv48Cz1ru NO3j9RarugdmiWVdodzjv0IcRrBzzRciiHKon1y9MfgllLWG8EN+OeqNMrANdi0WaSYd Kojg== 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=tlmEo/kVrmSoI+f5eQKxgmNkhnCo7i/A1GBB4psqyLY=; b=wNU92+i+9xnJ8QnZq+ZxLcwg36HAkqnVuLNF3ymGLxoBiM0BmHwzpIhTJmcAVS7s3+ m+RMPzYuhK2mto4UgG4tlpnuF0ucQ6wcS31v6IK5Xwr8G6vZI91/uGsDqwYkr4kTgNOv N3kFUI7XRysdV6HYK3XRA4r8YWQsu9S111x7hqCqP6HXUJHSTINN2epnW68jD6Yy0oIW wyTa+ZQDwtIB576+srEr4x2kMqiZjke0pbjU2kc+nK88eEPbg00yc7+2Y1xTLbZ9YZIn 3hEF04wMumha69LlUA+f9628XPpa5GEf5T4PON0ShOEALdRS9IiUjoQBR+R2Vpw7gssd icHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=OBl7OMbK; 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=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o25-20020a056402039900b004acb480f45dsi4962937edv.263.2023.02.21.13.28.43; Tue, 21 Feb 2023 13:29:06 -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=@ibm.com header.s=pp1 header.b=OBl7OMbK; 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=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229966AbjBUV1G (ORCPT + 99 others); Tue, 21 Feb 2023 16:27:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229930AbjBUV0z (ORCPT ); Tue, 21 Feb 2023 16:26:55 -0500 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D01F31E2E; Tue, 21 Feb 2023 13:26:52 -0800 (PST) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31LLHNOo021477; Tue, 21 Feb 2023 21:26:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=tlmEo/kVrmSoI+f5eQKxgmNkhnCo7i/A1GBB4psqyLY=; b=OBl7OMbKnNLv4HIVMcac0weSE79GaNK7Nh9Sz0ZxWNFD3kdTzhit0RhVj5DOEqFtOEdg h8TONH3PEKly282q5v9oEQFEGE+IuMRK5azooUB+KV0eh4WhEqk3hhTHv+9/OkyvqDcE cJGRzFZ5M370zF07F8G4y5UFTgPV1fTrPLed9jcCuyio3gLzDZ4G+m8qxx4NQQoMwtu4 Z92h7DUSYNH01wjJ1Yi1iVFZD9XP33TrOHk21ws6vybkfWjM8EFZesc2E6+uuAwkwMx7 juEMzy/0ZPQYQX9OfVGvXuVZa/f1927hwSYsYqI+nb/hiuj5vOBnIrPkr5/7KRsX9LpO Jg== Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nw408anp9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Feb 2023 21:26:37 +0000 Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 31LHk5Fk016332; Tue, 21 Feb 2023 21:26:36 GMT Received: from smtprelay07.wdc07v.mail.ibm.com ([9.208.129.116]) by ppma02wdc.us.ibm.com (PPS) with ESMTPS id 3ntpa7cve1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Feb 2023 21:26:36 +0000 Received: from smtpav02.wdc07v.mail.ibm.com (smtpav02.wdc07v.mail.ibm.com [10.39.53.229]) by smtprelay07.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 31LLQZR78913528 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 21 Feb 2023 21:26:35 GMT Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2A46858058; Tue, 21 Feb 2023 21:26:35 +0000 (GMT) Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 53F3658059; Tue, 21 Feb 2023 21:26:33 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.65.223.120]) by smtpav02.wdc07v.mail.ibm.com (Postfix) with ESMTP; Tue, 21 Feb 2023 21:26:33 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: rostedt@goodmis.org, linux-trace-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, mhiramat@kernel.org, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, andrew@aj.id.au, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, eajames@linux.ibm.com Subject: [PATCH v5 5/6] fsi: Add aliased device numbering Date: Tue, 21 Feb 2023 15:26:21 -0600 Message-Id: <20230221212622.3897097-6-eajames@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230221212622.3897097-1-eajames@linux.ibm.com> References: <20230221212622.3897097-1-eajames@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: HAWDVR9h4wuQ3VjHjodaFyZzJAigu9dU X-Proofpoint-ORIG-GUID: HAWDVR9h4wuQ3VjHjodaFyZzJAigu9dU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-21_12,2023-02-20_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 mlxscore=0 suspectscore=0 impostorscore=0 spamscore=0 lowpriorityscore=0 mlxlogscore=999 adultscore=0 clxscore=1015 malwarescore=0 priorityscore=1501 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302210182 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,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?1758477624801450482?= X-GMAIL-MSGID: =?utf-8?q?1758477624801450482?= The I2C and SPI subsystems can use an aliased name to number the device. Add similar support to the FSI subsystem for any device type. Signed-off-by: Eddie James --- drivers/fsi/fsi-core.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index d591e68afd11..b77013b9d8a7 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -955,9 +955,34 @@ static int __fsi_get_new_minor(struct fsi_slave *slave, enum fsi_dev_type type, return 0; } +static const char *const fsi_dev_type_names[] = { + "cfam", + "sbefifo", + "scom", + "occ", +}; + int fsi_get_new_minor(struct fsi_device *fdev, enum fsi_dev_type type, dev_t *out_dev, int *out_index) { + if (fdev->dev.of_node) { + int aid = of_alias_get_id(fdev->dev.of_node, fsi_dev_type_names[type]); + + if (aid >= 0) { + int id = (aid << 4) | type; + + id = ida_simple_get(&fsi_minor_ida, id, id + 1, GFP_KERNEL); + if (id >= 0) { + *out_index = aid; + *out_dev = fsi_base_dev + id; + return 0; + } + + if (id != -ENOSPC) + return id; + } + } + return __fsi_get_new_minor(fdev->slave, type, out_dev, out_index); } EXPORT_SYMBOL_GPL(fsi_get_new_minor); From patchwork Tue Feb 21 21:26:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 60269 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp231319wrd; Tue, 21 Feb 2023 13:30:10 -0800 (PST) X-Google-Smtp-Source: AK7set/JavOjsQZR+aFynz5IutgBWqNLgRiGXWK2d1QIo0onmfX4bmlo2IvvUjFJ4jSqAbhCnen4 X-Received: by 2002:a17:906:6a2a:b0:8aa:b866:af5a with SMTP id qw42-20020a1709066a2a00b008aab866af5amr17554467ejc.36.1677015010238; Tue, 21 Feb 2023 13:30:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677015010; cv=none; d=google.com; s=arc-20160816; b=AXIQeBOq9uVeIbEHdyp4NbldgY32aNtMVS9Z3tuN5KrCmzvEqAv/xKCgTHG3/2z6Se +2wRCfgQntsBoa4km2yyOCvn4RHBX4sN6qlJC2PUk41u/LJidQGfkPY1m10tzc0LAHwq IqiFky6C1jwFRbyfOL+haVHOYG+qRf7mZ5ydC/W2JgA1jut3H7m6N/4MwvwkhSlYP5kK NNRDdO3n5DYtZZ+O8LZmV4PgtsysuC/I4dGfDgopCS5urNm1TUJS73Z5YdDrxcEKn6Ef uGYatbvEWWUYtyY913XVeKA05GH9SO8A0Vcq82X6unIkU6V97ERsqHSEKQ4GORxKOWll ZqpQ== 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=s4kIBTdwHgvnp0JR5GqHrVoFL9IUarVdZp5dipeTXo0=; b=ZgFiQvefgO2jgAcKqAcnc/Wlp5Ia14MyJUKZU85Pbaiy/6vKTR0y7L0jMZb6JSh3WU X0lw1gFt31g1a4o+tX7e5yRNpeIxQ5aGH5/t4lkSqt1A/bw9fuMTApj3t2bpRf0hVnDu bYy81flfgtAps1Q/kmPiElFLQfKW9HMS8qZVXbzlOvE+k05/PerzSEgvZ8MFqPfSsaGI JtNmsdzrnnOimJSvLZjaN82SW123RIrbQs5t5SeBu/MpodHB0nw+in6sN0NLClBi9s+D TaFhfY8/olwvDfH6neqyKIBagn1G34mhKT04CPiu3kJUZtHzbRcLkrgE/h8GFOe//870 lGmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=DluUQDQW; 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=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ui39-20020a170907c92700b008b178585b00si17304602ejc.144.2023.02.21.13.29.47; Tue, 21 Feb 2023 13:30:10 -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=@ibm.com header.s=pp1 header.b=DluUQDQW; 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=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230049AbjBUV1K (ORCPT + 99 others); Tue, 21 Feb 2023 16:27:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230011AbjBUV07 (ORCPT ); Tue, 21 Feb 2023 16:26:59 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AD872F7B4; Tue, 21 Feb 2023 13:26:54 -0800 (PST) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31LLHN7G023259; Tue, 21 Feb 2023 21:26:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=s4kIBTdwHgvnp0JR5GqHrVoFL9IUarVdZp5dipeTXo0=; b=DluUQDQWj2sgykOJqjN8JGeE5QqY6md6BHJyyXvwm/IMFOb79NtUVqm8M0O+HAsOSS+K ba5GvHZE1BcPtdcojbx17V5A7ufMq4k9yTUaBpyj3CqYA2IP0zztzqDS1FoIKgB/dfH6 fTMJJPCYmFxURZawQPa4EdoSZqYYZ/JwDACdOzLAmcvHMME97u0N0rlY2TmpcvyJ2ug1 3sFpfvwPdbZI2IFgS5p/qpNu1mEnEAFpxi/uPXnymbXtXxy3ti2SGblkkFYZTZ11slRd peHXUl8UdLSF/JVjSItm9jtA5dPRNWhoGJcUs3EuL8/i+hpJKQJRjBF5oEFUQrUII9Np 3g== Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3nw5he0f4y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Feb 2023 21:26:39 +0000 Received: from pps.filterd (ppma04dal.us.ibm.com [127.0.0.1]) by ppma04dal.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 31LIV1Qr000567; Tue, 21 Feb 2023 21:26:38 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([9.208.130.101]) by ppma04dal.us.ibm.com (PPS) with ESMTPS id 3ntpa79y63-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Feb 2023 21:26:38 +0000 Received: from smtpav02.wdc07v.mail.ibm.com (smtpav02.wdc07v.mail.ibm.com [10.39.53.229]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 31LLQb5f58065286 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 21 Feb 2023 21:26:37 GMT Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3081D58059; Tue, 21 Feb 2023 21:26:37 +0000 (GMT) Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6374658058; Tue, 21 Feb 2023 21:26:35 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.65.223.120]) by smtpav02.wdc07v.mail.ibm.com (Postfix) with ESMTP; Tue, 21 Feb 2023 21:26:35 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: rostedt@goodmis.org, linux-trace-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, mhiramat@kernel.org, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, andrew@aj.id.au, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, eajames@linux.ibm.com Subject: [PATCH v5 6/6] fsi: Use of_match_table for bus matching if specified Date: Tue, 21 Feb 2023 15:26:22 -0600 Message-Id: <20230221212622.3897097-7-eajames@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230221212622.3897097-1-eajames@linux.ibm.com> References: <20230221212622.3897097-1-eajames@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: KdM53zcmLUr04hQaxmdWtxUPecESYjsk X-Proofpoint-GUID: KdM53zcmLUr04hQaxmdWtxUPecESYjsk X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-21_12,2023-02-20_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 suspectscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 spamscore=0 clxscore=1015 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302210182 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,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?1758477691305138826?= X-GMAIL-MSGID: =?utf-8?q?1758477691305138826?= Since we have two scom drivers, use the standard of matching if the driver specifies a table so that the right devices go to the right driver. Signed-off-by: Eddie James --- drivers/fsi/fsi-core.c | 11 +++++++++-- drivers/fsi/fsi-scom.c | 8 ++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index b77013b9d8a7..ca4a9634fbc3 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -1375,8 +1376,14 @@ static int fsi_bus_match(struct device *dev, struct device_driver *drv) if (id->engine_type != fsi_dev->engine_type) continue; if (id->version == FSI_VERSION_ANY || - id->version == fsi_dev->version) - return 1; + id->version == fsi_dev->version) { + if (drv->of_match_table) { + if (of_driver_match_device(dev, drv)) + return 1; + } else { + return 1; + } + } } return 0; diff --git a/drivers/fsi/fsi-scom.c b/drivers/fsi/fsi-scom.c index bcb756dc9866..61dbda9dbe2b 100644 --- a/drivers/fsi/fsi-scom.c +++ b/drivers/fsi/fsi-scom.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -587,6 +588,12 @@ static int scom_remove(struct device *dev) return 0; } +static const struct of_device_id scom_of_ids[] = { + { .compatible = "ibm,fsi2pib" }, + { } +}; +MODULE_DEVICE_TABLE(of, scom_of_ids); + static const struct fsi_device_id scom_ids[] = { { .engine_type = FSI_ENGID_SCOM, @@ -600,6 +607,7 @@ static struct fsi_driver scom_drv = { .drv = { .name = "scom", .bus = &fsi_bus_type, + .of_match_table = scom_of_ids, .probe = scom_probe, .remove = scom_remove, }