From patchwork Thu Apr 9 19:00:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 46980 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 828F121416 for ; Thu, 9 Apr 2015 19:01:02 +0000 (UTC) Received: by labgx2 with SMTP id gx2sf29168495lab.1 for ; Thu, 09 Apr 2015 12:01:01 -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=s7cWpb7ChfJKHJ6JOfIzwtDMISxPicUEsjr+Jg6d/H0=; b=lNpGcbXHgbb8ZMA7T+lAdvCe1CjaWavzr6gQkrl23U5k0GqKNmjD6DamD0Ld32SLuJ csIQ4XBY/3b5u3zjzDZVcT6gFElbRySD8Z4h8YbUESipjvf8nn7eLueOJlPRRK9DKV+c tcf0HvxPsEfQhbGTnoU9gT7bP0RawbL89zNMbjEDeXKCMgFwMyTExvXNOuL2GHcoZfKY H0P+crSeen9U/5rm8yn655A4bU18S63PYNH/IYXHnhbrXAi8+6MFhKycPr6o/s3LNmsR UOBrNEShwxSa1uUDGnG3byKvsISqLIqUlfnH2UEcU2Jz0d1f+T7h0rIZuURGsIFJ6QWk q1Lw== X-Gm-Message-State: ALoCoQnl41ggsy40bvEys4frqcikbFdN58CnwEFtdgO4F+xTmZCgGsb+cjfjNcCFmA9L9GxN0B1O X-Received: by 10.180.11.101 with SMTP id p5mr868806wib.3.1428606061601; Thu, 09 Apr 2015 12:01:01 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.30.37 with SMTP id p5ls365674lah.9.gmail; Thu, 09 Apr 2015 12:01:01 -0700 (PDT) X-Received: by 10.112.29.36 with SMTP id g4mr30138895lbh.56.1428606061375; Thu, 09 Apr 2015 12:01:01 -0700 (PDT) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com. [209.85.217.178]) by mx.google.com with ESMTPS id q3si1129575lbb.160.2015.04.09.12.01.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Apr 2015 12:01:01 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by lbcga7 with SMTP id ga7so48738739lbc.1 for ; Thu, 09 Apr 2015 12:01:01 -0700 (PDT) X-Received: by 10.152.23.70 with SMTP id k6mr5611581laf.76.1428606061281; Thu, 09 Apr 2015 12:01:01 -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 l1csp651369lbt; Thu, 9 Apr 2015 12:01:00 -0700 (PDT) X-Received: by 10.66.129.174 with SMTP id nx14mr57746385pab.12.1428606057356; Thu, 09 Apr 2015 12:00:57 -0700 (PDT) Received: from mail-pd0-f178.google.com (mail-pd0-f178.google.com. [209.85.192.178]) by mx.google.com with ESMTPS id og4si22369079pbb.87.2015.04.09.12.00.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Apr 2015 12:00:57 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.192.178 as permitted sender) client-ip=209.85.192.178; Received: by pdbnk13 with SMTP id nk13so162413247pdb.0 for ; Thu, 09 Apr 2015 12:00:56 -0700 (PDT) X-Received: by 10.66.55.104 with SMTP id r8mr57359694pap.75.1428606056339; Thu, 09 Apr 2015 12:00:56 -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 tm6sm15094989pbc.7.2015.04.09.12.00.55 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Apr 2015 12:00:55 -0700 (PDT) From: John Stultz To: projectara-software-dev Cc: John Stultz , Alex Elder , Greg Kroah-Hartman , Johan Hovold Subject: [PATCH 2/3] greybus: i2c: Split structure definitions into i2c.h Date: Thu, 9 Apr 2015 12:00:46 -0700 Message-Id: <1428606047-23440-3-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1428606047-23440-1-git-send-email-john.stultz@linaro.org> References: <1428606047-23440-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.217.178 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 CC: Johan Hovold 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__ */ + +