From patchwork Thu Jan 12 22:31:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Bostic X-Patchwork-Id: 9514331 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9761360476 for ; Thu, 12 Jan 2017 22:31:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E01728709 for ; Thu, 12 Jan 2017 22:31:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 921D828719; Thu, 12 Jan 2017 22:31:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 214AA28709 for ; Thu, 12 Jan 2017 22:31:55 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cRnuU-0008Fr-E3; Thu, 12 Jan 2017 22:31:54 +0000 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cRnuQ-0008A3-Ag for linux-arm-kernel@lists.infradead.org; Thu, 12 Jan 2017 22:31:52 +0000 Received: by mail-pf0-x243.google.com with SMTP id f144so5219048pfa.2 for ; Thu, 12 Jan 2017 14:31:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=XRB9XaZ0zR1tL/xIEacrQm1CWD9/dwmWaIQVmO8qhkM=; b=f/xWb+ilnNd/PVKmgu6fo8UCbYh5ZAqle9+f4o71t67qwYTwEhglnntfa/oEepLatB kf+omthqH5iSoPdsPY8erDYyiTC/DWaH8gT5ez+d1reO+HuHPUmyOgNiPuI2e2nMIFZd +H5VkRYbWFpUPuIvxTEn3xpbkAw2SU9uowWlskrz6qUvzAsOAePLjNn5yoBWOH/fcHO+ Kaf2fFtlpU95pMlaYo8BWEq6/L/fHy6C4NhZxcLiiRHJMBhDlWITMACdlPyaHocB7qqp ddcfA10VKPrrU7b2qzvjSDGhSxZYmVVsX5rg1DYfclIz2orXl8u1Vj/g4FtxPohxIahR qGOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=XRB9XaZ0zR1tL/xIEacrQm1CWD9/dwmWaIQVmO8qhkM=; b=LSlp3t7oDRdebV65Kz5u5r0MCt3iMkX9JJrmXhKpbrEy3qWD3qFPuOKArgwq1bdRk5 wLryQd0wwZfixztAN7WC+9ntxdpAf6+pizhQnx8XnKdgwDnpURs+iN7vjlvbXfa9YsB0 nOXnHGy6uWZp7H+Bqsz/k8DU9Tr8WPgX1X4xaHO8ftTLeXdsJivC0TAjmXKxiGLser/L ruOGU65yg3+fr8F8RXC8QahCwqpQyBzyVDZeJaJvDV801pfH9gakpz1R26RFYlBsOYOn 28k794bNrEWZtdmv1jHhVnOXnELU6c8G/Nk6ZqHjdJO2gJoBQ4nC9zUS0CjGBfVZDf9x 1uHw== X-Gm-Message-State: AIkVDXLrb9QGwXNC415eK6VQPidMe9HbuVg5gLxa6KZNEoIC8tT4nWv0p5Sn3J6gu2zbzA== X-Received: by 10.99.126.68 with SMTP id o4mr20283630pgn.66.1484260289687; Thu, 12 Jan 2017 14:31:29 -0800 (PST) Received: from Christophers-MacBook-Pro.local.com (45-20-192-79.lightspeed.austtx.sbcglobal.net. [45.20.192.79]) by smtp.gmail.com with ESMTPSA id s3sm23982496pfg.14.2017.01.12.14.31.27 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 12 Jan 2017 14:31:28 -0800 (PST) From: christopher.lee.bostic@gmail.com To: robh+dt@kernel.org, mark.rutland@arm.com, linux@armlinux.org.uk, gregkh@linuxfoundation.org, mturquette@baylibre.com, geert+renesas@glider.be, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, 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 v2 10/18] drivers/fsi: Add device read/write/peek functions Date: Thu, 12 Jan 2017 16:31:24 -0600 Message-Id: <1484260284-79797-1-git-send-email-christopher.lee.bostic@gmail.com> X-Mailer: git-send-email 2.7.4 (Apple Git-66) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170112_143150_412892_84416C93 X-CRM114-Status: GOOD ( 11.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chris Bostic MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jeremy Kerr This change introduces the fsi device API: simple read, write and peek accessors for the devices' address spaces. Includes contributions from Chris Bostic Signed-off-by: Jeremy Kerr Signed-off-by: Chris Bostic --- V2 - Clean up white space. --- drivers/fsi/fsi-core.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/fsi.h | 6 ++++++ 2 files changed, 53 insertions(+) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index f7ef993..3119aa1 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -35,6 +35,8 @@ #define FSI_SLAVE_CONF_CRC_MASK 0x0000000f #define FSI_SLAVE_CONF_DATA_BITS 28 +#define FSI_PEEK_BASE 0x410 + static const int engine_page_size = 0x400; static DEFINE_IDA(master_ida); @@ -48,8 +50,46 @@ struct fsi_slave { #define to_fsi_slave(d) container_of(d, struct fsi_slave, dev) +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 */ +int fsi_device_read(struct fsi_device *dev, uint32_t addr, void *val, + size_t size) +{ + if (addr > dev->size) + return -EINVAL; + + if (addr + size > dev->size) + return -EINVAL; + + return fsi_slave_read(dev->slave, dev->addr + addr, val, size); +} +EXPORT_SYMBOL_GPL(fsi_device_read); + +int fsi_device_write(struct fsi_device *dev, uint32_t addr, const void *val, + size_t size) +{ + if (addr > dev->size) + return -EINVAL; + + if (addr + size > dev->size) + return -EINVAL; + + return fsi_slave_write(dev->slave, dev->addr + addr, val, size); +} +EXPORT_SYMBOL_GPL(fsi_device_write); + +int fsi_device_peek(struct fsi_device *dev, void *val) +{ + uint32_t addr = FSI_PEEK_BASE + ((dev->unit - 2) * sizeof(uint32_t)); + + return fsi_slave_read(dev->slave, addr, val, sizeof(uint32_t)); +} + static void fsi_device_release(struct device *_device) { struct fsi_device *device = to_fsi_dev(_device); @@ -81,6 +121,13 @@ static int fsi_slave_read(struct fsi_slave *slave, uint32_t addr, slave->id, addr, val, size); } +static int fsi_slave_write(struct fsi_slave *slave, uint32_t addr, + const void *val, size_t size) +{ + return slave->master->write(slave->master, slave->link, + slave->id, addr, val, 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 efa55ba..273945d 100644 --- a/include/linux/fsi.h +++ b/include/linux/fsi.h @@ -27,6 +27,12 @@ struct fsi_device { uint32_t size; }; +extern int fsi_device_read(struct fsi_device *dev, uint32_t addr, + void *val, size_t size); +extern int fsi_device_write(struct fsi_device *dev, uint32_t addr, + const void *val, size_t size); +extern int fsi_device_peek(struct fsi_device *dev, void *val); + struct fsi_device_id { u8 engine_type; u8 version;