Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753191AbdDJTsp (ORCPT ); Mon, 10 Apr 2017 15:48:45 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:56749 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753092AbdDJTsm (ORCPT ); Mon, 10 Apr 2017 15:48:42 -0400 From: Christopher Bostic To: robh+dt@kernel.org, mark.rutland@arm.com, linux@armlinux.org.uk, rostedt@goodmis.org, mingo@redhat.com, gregkh@linuxfoundation.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Chris Bostic , joel@jms.id.au, linux-kernel@vger.kernel.org, andrew@aj.id.au, alistair@popple.id.au, benh@kernel.crashing.org Subject: [PATCH v6 06/23] drivers/fsi: Set up links for slave communication Date: Mon, 10 Apr 2017 14:46:49 -0500 X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20170410194706.64280-1-cbostic@linux.vnet.ibm.com> References: <20170410194706.64280-1-cbostic@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17041019-0008-0000-0000-000001EE65C0 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006912; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000208; SDB=6.00845690; UDB=6.00417057; IPR=6.00624124; BA=6.00005281; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00014997; XFM=3.00000013; UTC=2017-04-10 19:48:19 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17041019-0009-0000-0000-000034881310 Message-Id: <20170410194706.64280-7-cbostic@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-04-10_15:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1704100156 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1614 Lines: 65 From: Chris Bostic Enable each link and send a break command, and try to detect a slave by reading from the SMODE register. Signed-off-by: Chris Bostic Signed-off-by: Joel Stanley --- drivers/fsi/fsi-core.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 32698ed..6e1cfdf 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -157,12 +157,45 @@ static int fsi_master_write(struct fsi_master *master, int link, return master->write(master, link, slave_id, addr, val, size); } +static int fsi_master_link_enable(struct fsi_master *master, int link) +{ + if (master->link_enable) + return master->link_enable(master, link); + + return 0; +} + +/* + * Issue a break command on this link + */ +static int fsi_master_break(struct fsi_master *master, int link) +{ + if (master->send_break) + return master->send_break(master, link); + + return 0; +} + static int fsi_master_scan(struct fsi_master *master) { - int link; + int link, rc; + + for (link = 0; link < master->n_links; link++) { + rc = fsi_master_link_enable(master, link); + if (rc) { + dev_dbg(&master->dev, + "enable link %d failed: %d\n", link, rc); + continue; + } + rc = fsi_master_break(master, link); + if (rc) { + dev_dbg(&master->dev, + "break to link %d failed: %d\n", link, rc); + continue; + } - for (link = 0; link < master->n_links; link++) fsi_slave_init(master, link, 0); + } return 0; } -- 1.8.2.2