From patchwork Tue Apr 7 01:59:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 46799 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 58782214BA for ; Tue, 7 Apr 2015 01:59:52 +0000 (UTC) Received: by lbcne10 with SMTP id ne10sf9546826lbc.1 for ; Mon, 06 Apr 2015 18:59:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=st2FmKckfctudzXWOb++jN6TYNHDLdHqlVoUAI+JGwg=; b=XdUc9/GrsygB1VGtEVbmH2O5CC+lFsdOTSPwEelYSaEu1eUBzs0/HG48Nob7Bd7v91 dPk4b2DJlOBQcJ72Flca8m51yuOsKnE/xjx8WQNwv/8pLS8xxq+FFoPbTXy9lwHRAgbt 10vYlibSSlrP+9mHTHuH4eTETXy2ZrXYGl2+xH4+1hl2rJNt3hTu6oeZ8ZjhfBpcpA9u 8lD2ouGQqFLFEx00dwROBsz11DAnrUXnep4ZdM2pNbpRsW33uDXeZ95gOp+/+YvrfjPF Tdc5MOwwLqz9jrf6tlO14bR+qYrrSv/gtJaqaZoYXwaQOu/C6VaMkGhvATR28B56ppf5 QKAA== X-Gm-Message-State: ALoCoQm/3NafPXAg87v80Lp315b/aNnn/n44lvZhrYnojQyRDeH+3JQklzRdvTNI86jGtFBGK8wy X-Received: by 10.112.42.236 with SMTP id r12mr3512551lbl.2.1428371991390; Mon, 06 Apr 2015 18:59:51 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.163 with SMTP id r3ls635522laj.70.gmail; Mon, 06 Apr 2015 18:59:51 -0700 (PDT) X-Received: by 10.152.207.74 with SMTP id lu10mr16004125lac.108.1428371991221; Mon, 06 Apr 2015 18:59:51 -0700 (PDT) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id eo7si4770943lac.118.2015.04.06.18.59.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Apr 2015 18:59:51 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by lagv1 with SMTP id v1so31721082lag.3 for ; Mon, 06 Apr 2015 18:59:51 -0700 (PDT) X-Received: by 10.113.10.134 with SMTP id ea6mr11331180lbd.29.1428371991135; Mon, 06 Apr 2015 18:59:51 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.67.65 with SMTP id l1csp144944lbt; Mon, 6 Apr 2015 18:59:50 -0700 (PDT) X-Received: by 10.70.17.196 with SMTP id q4mr32202077pdd.64.1428371986439; Mon, 06 Apr 2015 18:59:46 -0700 (PDT) Received: from mail-pd0-f176.google.com (mail-pd0-f176.google.com. [209.85.192.176]) by mx.google.com with ESMTPS id ik1si8995796pbb.8.2015.04.06.18.59.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Apr 2015 18:59:46 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.192.176 as permitted sender) client-ip=209.85.192.176; Received: by pdbnk13 with SMTP id nk13so62589637pdb.0 for ; Mon, 06 Apr 2015 18:59:45 -0700 (PDT) X-Received: by 10.70.47.102 with SMTP id c6mr32439665pdn.24.1428371985447; Mon, 06 Apr 2015 18:59:45 -0700 (PDT) Received: from localhost.localdomain (c-67-170-153-23.hsd1.or.comcast.net. [67.170.153.23]) by mx.google.com with ESMTPSA id xh3sm6156493pab.25.2015.04.06.18.59.44 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 Apr 2015 18:59:44 -0700 (PDT) From: John Stultz To: projectara-software-dev Cc: John Stultz , Alex Elder , Greg Kroah-Hartman Subject: [PATCH 2/3] greybus: i2c: Split structure definitions into i2c.h Date: Mon, 6 Apr 2015 18:59:38 -0700 Message-Id: <1428371979-9737-3-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1428371979-9737-1-git-send-email-john.stultz@linaro.org> References: <1428371979-9737-1-git-send-email-john.stultz@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , In order to facilitate re-use of the i2c structures, split the definitions out into i2c.h This will be a prereq to sharing these headers w/ gbsim. Cc: Alex Elder Cc: Greg Kroah-Hartman Signed-off-by: John Stultz --- i2c.c | 57 ++--------------------------------------------------- i2c.h | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 55 deletions(-) create mode 100644 i2c.h diff --git a/i2c.c b/i2c.c index 84d20e5..84d1d77 100644 --- a/i2c.c +++ b/i2c.c @@ -13,6 +13,8 @@ #include #include "greybus.h" +#include "i2c.h" + struct gb_i2c_device { struct gb_connection *connection; @@ -26,61 +28,6 @@ struct gb_i2c_device { struct i2c_adapter adapter; }; -/* Version of the Greybus i2c protocol we support */ -#define GB_I2C_VERSION_MAJOR 0x00 -#define GB_I2C_VERSION_MINOR 0x01 - -/* Greybus i2c request types */ -#define GB_I2C_TYPE_INVALID 0x00 -#define GB_I2C_TYPE_PROTOCOL_VERSION 0x01 -#define GB_I2C_TYPE_FUNCTIONALITY 0x02 -#define GB_I2C_TYPE_TIMEOUT 0x03 -#define GB_I2C_TYPE_RETRIES 0x04 -#define GB_I2C_TYPE_TRANSFER 0x05 -#define GB_I2C_TYPE_RESPONSE 0x80 /* OR'd with rest */ - -#define GB_I2C_RETRIES_DEFAULT 3 -#define GB_I2C_TIMEOUT_DEFAULT 1000 /* milliseconds */ - -/* functionality request has no payload */ -struct gb_i2c_functionality_response { - __le32 functionality; -}; - -struct gb_i2c_timeout_request { - __le16 msec; -}; -/* timeout response has no payload */ - -struct gb_i2c_retries_request { - __u8 retries; -}; -/* retries response has no payload */ - -/* - * Outgoing data immediately follows the op count and ops array. - * The data for each write (master -> slave) op in the array is sent - * in order, with no (e.g. pad) bytes separating them. - * - * Short reads cause the entire transfer request to fail So response - * payload consists only of bytes read, and the number of bytes is - * exactly what was specified in the corresponding op. Like - * outgoing data, the incoming data is in order and contiguous. - */ -struct gb_i2c_transfer_op { - __le16 addr; - __le16 flags; - __le16 size; -}; - -struct gb_i2c_transfer_request { - __le16 op_count; - struct gb_i2c_transfer_op ops[0]; /* op_count of these */ -}; -struct gb_i2c_transfer_response { - __u8 data[0]; /* inbound data */ -}; - /* Define get_version() routine */ define_get_version(gb_i2c_device, I2C); diff --git a/i2c.h b/i2c.h new file mode 100644 index 0000000..0bfee86 --- /dev/null +++ b/i2c.h @@ -0,0 +1,72 @@ +#ifndef __GB_I2C_H__ +#define __GB_I2C_H__ + +/* + * I2C header for the Greybus "generic" I2C module. + * + * Copyright 2014 Google Inc. + * Copyright 2014 Linaro Ltd. + * + * Released under the GPLv2 only. + */ + +#include "greybus.h" + +/* Version of the Greybus i2c protocol we support */ +#define GB_I2C_VERSION_MAJOR 0x00 +#define GB_I2C_VERSION_MINOR 0x01 + +/* Greybus i2c request types */ +#define GB_I2C_TYPE_INVALID 0x00 +#define GB_I2C_TYPE_PROTOCOL_VERSION 0x01 +#define GB_I2C_TYPE_FUNCTIONALITY 0x02 +#define GB_I2C_TYPE_TIMEOUT 0x03 +#define GB_I2C_TYPE_RETRIES 0x04 +#define GB_I2C_TYPE_TRANSFER 0x05 +#define GB_I2C_TYPE_RESPONSE 0x80 /* OR'd with rest */ + +#define GB_I2C_RETRIES_DEFAULT 3 +#define GB_I2C_TIMEOUT_DEFAULT 1000 /* milliseconds */ + +/* functionality request has no payload */ +struct gb_i2c_functionality_response { + __le32 functionality; +}; + +struct gb_i2c_timeout_request { + __le16 msec; +}; +/* timeout response has no payload */ + +struct gb_i2c_retries_request { + __u8 retries; +}; +/* retries response has no payload */ + +/* + * Outgoing data immediately follows the op count and ops array. + * The data for each write (master -> slave) op in the array is sent + * in order, with no (e.g. pad) bytes separating them. + * + * Short reads cause the entire transfer request to fail So response + * payload consists only of bytes read, and the number of bytes is + * exactly what was specified in the corresponding op. Like + * outgoing data, the incoming data is in order and contiguous. + */ +struct gb_i2c_transfer_op { + __le16 addr; + __le16 flags; + __le16 size; +}; + +struct gb_i2c_transfer_request { + __le16 op_count; + struct gb_i2c_transfer_op ops[0]; /* op_count of these */ +}; +struct gb_i2c_transfer_response { + __u8 data[0]; /* inbound data */ +}; + +#endif /* __GB_I2S_H__ */ + +