Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755389AbdDECJQ (ORCPT ); Tue, 4 Apr 2017 22:09:16 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:53479 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752765AbdDECJN (ORCPT ); Tue, 4 Apr 2017 22:09:13 -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: Jeremy Kerr , joel@jms.id.au, linux-kernel@vger.kernel.org, andrew@aj.id.au, alistair@popple.id.au, benh@kernel.crashing.org, Chris Bostic Subject: [PATCH v5 15/23] drivers/fsi: expose direct-access slave API Date: Tue, 4 Apr 2017 21:05:59 -0500 X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20170405020607.79939-1-cbostic@linux.vnet.ibm.com> References: <20170405020607.79939-1-cbostic@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17040502-0036-0000-0000-000001CFF071 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006884; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000208; SDB=6.00843220; UDB=6.00415443; IPR=6.00621395; BA=6.00005266; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00014914; XFM=3.00000013; UTC=2017-04-05 02:09:09 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17040502-0037-0000-0000-00003F72B39B Message-Id: <20170405020607.79939-16-cbostic@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-04-05_01:,, 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-1704050018 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2953 Lines: 95 From: Jeremy Kerr Allow drivers to access the slave address ranges. Signed-off-by: Jeremy Kerr Signed-off-by: Joel Stanley Signed-off-by: Chris Bostic --- drivers/fsi/fsi-core.c | 26 ++++++++++++++++++++------ include/linux/fsi.h | 12 ++++++++++++ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index f0f0556..f7e55e7 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -76,10 +76,6 @@ static int fsi_master_read(struct fsi_master *master, int link, uint8_t slave_id, uint32_t addr, void *val, size_t size); static int fsi_master_write(struct fsi_master *master, int link, uint8_t slave_id, uint32_t addr, const void *val, size_t size); -static int fsi_slave_read(struct fsi_slave *slave, uint32_t addr, - void *val, size_t size); -static int fsi_slave_write(struct fsi_slave *slave, uint32_t addr, - const void *val, size_t size); /* FSI endpoint-device support */ @@ -181,7 +177,7 @@ static int fsi_slave_calc_addr(struct fsi_slave *slave, uint32_t *addrp, return 0; } -static int fsi_slave_read(struct fsi_slave *slave, uint32_t addr, +int fsi_slave_read(struct fsi_slave *slave, uint32_t addr, void *val, size_t size) { uint8_t id = slave->id; @@ -195,7 +191,7 @@ static int fsi_slave_read(struct fsi_slave *slave, uint32_t addr, addr, val, size); } -static int fsi_slave_write(struct fsi_slave *slave, uint32_t addr, +int fsi_slave_write(struct fsi_slave *slave, uint32_t addr, const void *val, size_t size) { uint8_t id = slave->id; @@ -209,6 +205,24 @@ static int fsi_slave_write(struct fsi_slave *slave, uint32_t addr, addr, val, size); } +extern int fsi_slave_claim_range(struct fsi_slave *slave, + uint32_t addr, uint32_t size) +{ + if (addr + size < addr) + return -EINVAL; + + if (addr + size > slave->size) + return -EINVAL; + + /* todo: check for overlapping claims */ + return 0; +} + +extern void fsi_slave_release_range(struct fsi_slave *slave, + uint32_t addr, uint32_t size) +{ +} + static int fsi_slave_scan(struct fsi_slave *slave) { uint32_t engine_addr; diff --git a/include/linux/fsi.h b/include/linux/fsi.h index 34f1e9a..141fd38 100644 --- a/include/linux/fsi.h +++ b/include/linux/fsi.h @@ -66,6 +66,18 @@ struct fsi_driver { module_driver(__fsi_driver, fsi_driver_register, \ fsi_driver_unregister) +/* direct slave API */ +extern int fsi_slave_claim_range(struct fsi_slave *slave, + uint32_t addr, uint32_t size); +extern void fsi_slave_release_range(struct fsi_slave *slave, + uint32_t addr, uint32_t size); +extern int fsi_slave_read(struct fsi_slave *slave, uint32_t addr, + void *val, size_t size); +extern int fsi_slave_write(struct fsi_slave *slave, uint32_t addr, + const void *val, size_t size); + + + extern struct bus_type fsi_bus_type; #endif /* LINUX_FSI_H */ -- 1.8.2.2