Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753614AbcLGCJx (ORCPT ); Tue, 6 Dec 2016 21:09:53 -0500 Received: from mail-oi0-f68.google.com ([209.85.218.68]:35086 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753334AbcLGCJr (ORCPT ); Tue, 6 Dec 2016 21:09:47 -0500 From: Chris Bostic To: robh+dt@kernel.org, mark.rutland@arm.com, linux@armlinux.org.uk, gregkh@linuxfoundation.org, sre@kernel.org, mturquette@baylibre.com, geert+renesas@glider.be, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Chris Bostic , joel@jms.id.au, jk@ozlabs.org, linux-kernel@vger.kernel.org, andrew@aj.id.au, alistair@popple.id.au, benh@kernel.crashing.org Subject: [PATCH 12/16] drivers/fsi: Set up links for slave communication Date: Tue, 6 Dec 2016 20:09:34 -0600 Message-Id: <1481076574-54711-5-git-send-email-christopher.lee.bostic@gmail.com> X-Mailer: git-send-email 2.7.4 (Apple Git-66) In-Reply-To: <1481076574-54711-1-git-send-email-christopher.lee.bostic@gmail.com> References: <1481076574-54711-1-git-send-email-christopher.lee.bostic@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2174 Lines: 83 From: Chris Bostic Enable each link and send a break command in preparation for scanning each link for slaves. Signed-off-by: Chris Bostic --- drivers/fsi/fsi-core.c | 39 ++++++++++++++++++++++++++++++++++++--- drivers/fsi/fsi-master.h | 2 ++ 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 80feeb8..93de0f1 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -290,16 +290,49 @@ static int fsi_slave_init(struct fsi_master *master, /* FSI master support */ +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, slave_id; + int link, slave_id, 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 with:%d\n", link, rc); + continue; + } + rc = fsi_master_break(master, link); + if (rc) { + dev_dbg(master->dev, + "Break to link:%d failed with:%d\n", link, rc); + continue; + } - for (link = 0; link < master->n_links; link++) for (slave_id = 0; slave_id < FSI_N_SLAVES; slave_id++) fsi_slave_init(master, link, slave_id); - return 0; + } + return 0; } int fsi_master_register(struct fsi_master *master) diff --git a/drivers/fsi/fsi-master.h b/drivers/fsi/fsi-master.h index cafb433..56aad0e 100644 --- a/drivers/fsi/fsi-master.h +++ b/drivers/fsi/fsi-master.h @@ -29,6 +29,8 @@ struct fsi_master { int (*write)(struct fsi_master *, int link, uint8_t slave, uint32_t addr, const void *val, size_t size); + int (*send_break)(struct fsi_master *, int link); + int (*link_enable)(struct fsi_master *, int link); }; extern int fsi_master_register(struct fsi_master *master); -- 1.8.2.2