From patchwork Thu Apr 9 23:04: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: 46990 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B3444218D6 for ; Thu, 9 Apr 2015 23:04:55 +0000 (UTC) Received: by lbbqq2 with SMTP id qq2sf358762lbb.0 for ; Thu, 09 Apr 2015 16:04:54 -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=3WKGV69vFCvHx469FNFuSKXECaJK0yy8EmLbFTpzV7k=; b=Z8LVyrMoWw5Vgbv3zxpbyE6h2uKES+i3b3zYIMX4ELuT73EPwVHbMQ0ECgxeztU6CP G2a7xcFt29vIlP2B31QUVEz4pV1TKDrf17DTNa7Oc7EVbptGaOcFfHJddI/OtIpd6Z0F VOV0uM8D+qtZOwpQdMPAcGtLRMWYYW0gN3rWsp000/hCkdqCrkfF5WbvEWcOdNGQYzLo FUGJ6AWRtxwYNwF+jJTFDmXrvhpE6bus7anW0DEcS2pX4PHArsa9wsSfTO0phE/Yuv8y XMI2FBslAGSoBNI/ln+x7UpJ+sWiGOXUgc8+J133GbgVNM4T6Wqm9tJ9LVcohLQ0x6FN QVqw== X-Gm-Message-State: ALoCoQlA9F4R58Xuh7UjDOX2CLWnx3dvxGqH0MLn4DDsCbqBrMbptd+EGit71+JdNgXYCkTYpF8E X-Received: by 10.180.81.134 with SMTP id a6mr995116wiy.1.1428620694659; Thu, 09 Apr 2015 16:04:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.1.3 with SMTP id 3ls355463lai.36.gmail; Thu, 09 Apr 2015 16:04:54 -0700 (PDT) X-Received: by 10.112.162.232 with SMTP id yd8mr29601047lbb.41.1428620694496; Thu, 09 Apr 2015 16:04:54 -0700 (PDT) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com. [209.85.217.181]) by mx.google.com with ESMTPS id ba7si116893lab.50.2015.04.09.16.04.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Apr 2015 16:04:54 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) client-ip=209.85.217.181; Received: by lbbuc2 with SMTP id uc2so1405757lbb.2 for ; Thu, 09 Apr 2015 16:04:54 -0700 (PDT) X-Received: by 10.152.8.78 with SMTP id p14mr6525634laa.19.1428620694354; Thu, 09 Apr 2015 16:04:54 -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 l1csp751393lbt; Thu, 9 Apr 2015 16:04:53 -0700 (PDT) X-Received: by 10.68.132.233 with SMTP id ox9mr58820152pbb.83.1428620692358; Thu, 09 Apr 2015 16:04:52 -0700 (PDT) Received: from mail-pa0-f47.google.com (mail-pa0-f47.google.com. [209.85.220.47]) by mx.google.com with ESMTPS id sq8si198266pbc.138.2015.04.09.16.04.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Apr 2015 16:04:52 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.47 as permitted sender) client-ip=209.85.220.47; Received: by paboj16 with SMTP id oj16so2401156pab.0 for ; Thu, 09 Apr 2015 16:04:51 -0700 (PDT) X-Received: by 10.70.5.68 with SMTP id q4mr60636957pdq.9.1428620690964; Thu, 09 Apr 2015 16:04:50 -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 bs4sm105499pdb.21.2015.04.09.16.04.49 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Apr 2015 16:04:50 -0700 (PDT) From: John Stultz To: projectara-software-dev Cc: Alex Elder , Greg Kroah-Hartman , Johan Hovold , John Stultz Subject: [PATCH 2/2] gbsim: Convert to using greybus gpbrige.h header Date: Thu, 9 Apr 2015 16:04:46 -0700 Message-Id: <1428620686-9326-2-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1428620686-9326-1-git-send-email-john.stultz@linaro.org> References: <1428620686-9326-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.181 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: , Instead of duplicating the definitions, reuse the definitions in the newly split out greybus gpbridge.h header. Cc: Alex Elder Cc: Greg Kroah-Hartman CC: Johan Hovold Signed-off-by: John Stultz --- gbsim.h | 182 ++++++++++------------------------------------------------------ gpio.c | 6 +-- i2c.c | 14 ++--- pwm.c | 13 +---- 4 files changed, 38 insertions(+), 177 deletions(-) diff --git a/gbsim.h b/gbsim.h index 91e5e0b..a8b2258 100644 --- a/gbsim.h +++ b/gbsim.h @@ -15,7 +15,7 @@ #include #define __packed __attribute__((__packed__)) -#include "i2s.h" +#include "gpbridge.h" extern int bbb_backend; extern int i2c_adapter; @@ -68,165 +68,37 @@ struct protocol_version_rsp { __u8 version_minor; }; -/* GPIO */ -struct gpio_line_count_rsp { - __u8 count; -}; - -struct gpio_activate_req { - __u8 which; -}; - -struct gpio_deactivate_req { - __u8 which; -}; - -struct gpio_get_direction_req { - __u8 which; -}; - -struct gpio_get_direction_rsp { - __u8 direction; -}; - -struct gpio_direction_input_req { - __u8 which; -}; - -struct gpio_direction_output_req { - __u8 which; - __u8 value; -}; - -struct gpio_get_value_req { - __u8 which; -}; - -struct gpio_get_value_rsp { - __u8 value; -}; - -struct gpio_set_value_req { - __u8 which; - __u8 value; -}; - -struct gpio_set_debounce_req { - __u8 which; - __le16 usec __attribute__((__packed__)); -}; - -struct gpio_irq_type_request { - __u8 which; - __u8 type; -}; -/* irq type response has no payload */ - -struct gpio_irq_mask_request { - __u8 which; -}; -/* irq mask response has no payload */ - -struct gpio_irq_unmask_request { - __u8 which; -}; -/* irq unmask response has no payload */ - -struct gpio_irq_ack_request { - __u8 which; -}; -/* irq ack response has no payload */ - -/* irq event requests originate on another module and are handled on the AP */ -struct gpio_irq_event_request { - __u8 which; -}; -/* irq event response has no payload */ - - -/* I2C */ -struct i2c_functionality_rsp { - __le32 functionality; -}; - -struct i2c_transfer_desc { - __le16 addr; - __le16 flags; - __le16 size; -}; - -struct i2c_transfer_req { - __le16 op_count; - struct i2c_transfer_desc desc[0]; -}; - -struct i2c_transfer_rsp { - __u8 data[0]; -}; - -/* PWM */ -struct pwm_count_rsp { - __u8 count; -}; - -struct pwm_activate_req { - __u8 which; -}; - -struct pwm_deactivate_req { - __u8 which; -}; - -struct pwm_config_req { - __u8 which; - __le32 duty __attribute__((__packed__)); - __le32 period __attribute__((__packed__)); -}; - -struct pwm_polarity_req { - __u8 which; - __u8 polarity; -}; - -struct pwm_enable_req { - __u8 which; -}; - -struct pwm_disable_req { - __u8 which; -}; - /* Ops */ struct op_msg { struct op_header header; union { struct protocol_version_rsp pv_rsp; - struct gpio_line_count_rsp gpio_lc_rsp; - struct gpio_activate_req gpio_act_req; - struct gpio_deactivate_req gpio_deact_req; - struct gpio_get_direction_req gpio_get_dir_req; - struct gpio_get_direction_rsp gpio_get_dir_rsp; - struct gpio_direction_input_req gpio_dir_input_req; - struct gpio_direction_output_req gpio_dir_output_req; - struct gpio_get_value_req gpio_get_val_req; - struct gpio_get_value_rsp gpio_get_val_rsp; - struct gpio_set_value_req gpio_set_val_req; - struct gpio_set_debounce_req gpio_set_db_req; - struct gpio_irq_type_request gpio_irq_type_req; - struct gpio_irq_mask_request gpio_irq_mask_req; - struct gpio_irq_unmask_request gpio_irq_unmask_req; - struct gpio_irq_ack_request gpio_irq_ack_req; - struct gpio_irq_event_request gpio_irq_event_req; - struct i2c_functionality_rsp i2c_fcn_rsp; - struct i2c_transfer_req i2c_xfer_req; - struct i2c_transfer_rsp i2c_xfer_rsp; - struct pwm_count_rsp pwm_cnt_rsp; - struct pwm_activate_req pwm_act_req; - struct pwm_deactivate_req pwm_deact_req; - struct pwm_config_req pwm_cfg_req; - struct pwm_polarity_req pwm_pol_req; - struct pwm_enable_req pwm_enb_req; - struct pwm_disable_req pwm_dis_req; + struct gb_gpio_line_count_response gpio_lc_rsp; + struct gb_gpio_activate_request gpio_act_req; + struct gb_gpio_deactivate_request gpio_deact_req; + struct gb_gpio_get_direction_request gpio_get_dir_req; + struct gb_gpio_get_direction_response gpio_get_dir_rsp; + struct gb_gpio_direction_in_request gpio_dir_input_req; + struct gb_gpio_direction_out_request gpio_dir_output_req; + struct gb_gpio_get_value_request gpio_get_val_req; + struct gb_gpio_get_value_response gpio_get_val_rsp; + struct gb_gpio_set_value_request gpio_set_val_req; + struct gb_gpio_set_debounce_request gpio_set_db_req; + struct gb_gpio_irq_type_request gpio_irq_type_req; + struct gb_gpio_irq_mask_request gpio_irq_mask_req; + struct gb_gpio_irq_unmask_request gpio_irq_unmask_req; + struct gb_gpio_irq_ack_request gpio_irq_ack_req; + struct gb_gpio_irq_event_request gpio_irq_event_req; + struct gb_i2c_functionality_response i2c_fcn_rsp; + struct gb_i2c_transfer_request i2c_xfer_req; + struct gb_i2c_transfer_response i2c_xfer_rsp; + struct gb_pwm_count_response pwm_cnt_rsp; + struct gb_pwm_activate_request pwm_act_req; + struct gb_pwm_deactivate_request pwm_deact_req; + struct gb_pwm_config_request pwm_cfg_req; + struct gb_pwm_polarity_request pwm_pol_req; + struct gb_pwm_enable_request pwm_enb_req; + struct gb_pwm_disable_request pwm_dis_req; struct gb_i2s_mgmt_get_supported_configurations_response i2s_mgmt_get_sup_conf_rsp; struct gb_i2s_mgmt_get_processing_delay_response i2s_mgmt_get_proc_delay_rsp; }; diff --git a/gpio.c b/gpio.c index d9005e0..5f6a492 100644 --- a/gpio.c +++ b/gpio.c @@ -76,7 +76,7 @@ void gpio_handler(unsigned int cport, __u8 *rbuf, size_t size) break; case GB_GPIO_TYPE_LINE_COUNT: op_rsp->header.size = sizeof(struct op_header) + - sizeof(struct gpio_line_count_rsp); + sizeof(struct gb_gpio_line_count_response); op_rsp->header.id = oph->id; op_rsp->header.type = OP_RESPONSE | GB_GPIO_TYPE_LINE_COUNT; op_rsp->header.result = PROTOCOL_STATUS_SUCCESS; @@ -111,7 +111,7 @@ void gpio_handler(unsigned int cport, __u8 *rbuf, size_t size) break; case GB_GPIO_TYPE_GET_DIRECTION: op_rsp->header.size = sizeof(struct op_header) + - sizeof(struct gpio_get_direction_rsp); + sizeof(struct gb_gpio_get_direction_response); op_rsp->header.id = oph->id; op_rsp->header.type = OP_RESPONSE | GB_GPIO_TYPE_GET_DIRECTION; op_rsp->header.result = PROTOCOL_STATUS_SUCCESS; @@ -157,7 +157,7 @@ void gpio_handler(unsigned int cport, __u8 *rbuf, size_t size) break; case GB_GPIO_TYPE_GET_VALUE: op_rsp->header.size = sizeof(struct op_header) + - sizeof(struct gpio_get_value_rsp); + sizeof(struct gb_gpio_get_value_response); op_rsp->header.id = oph->id; op_rsp->header.type = OP_RESPONSE | GB_GPIO_TYPE_GET_VALUE; op_rsp->header.result = PROTOCOL_STATUS_SUCCESS; diff --git a/i2c.c b/i2c.c index 69f35ce..5e2f51d 100644 --- a/i2c.c +++ b/i2c.c @@ -72,7 +72,7 @@ void i2c_handler(unsigned int cport, __u8 *rbuf, size_t size) break; case OP_I2C_PROTOCOL_FUNCTIONALITY: sz = sizeof(struct op_header) + - sizeof(struct i2c_functionality_rsp); + sizeof(struct gb_i2c_functionality_response); op_rsp->header.size = htole16((__u16)sz); op_rsp->header.id = oph->id; op_rsp->header.type = OP_RESPONSE | OP_I2C_PROTOCOL_FUNCTIONALITY; @@ -110,18 +110,18 @@ void i2c_handler(unsigned int cport, __u8 *rbuf, size_t size) break; case OP_I2C_PROTOCOL_TRANSFER: op_count = le16toh(op_req->i2c_xfer_req.op_count); - write_data = (__u8 *)&op_req->i2c_xfer_req.desc[op_count]; + write_data = (__u8 *)&op_req->i2c_xfer_req.ops[op_count]; gbsim_debug("Number of transfer ops %d\n", op_count); for (i = 0; i < op_count; i++) { - struct i2c_transfer_desc *desc; + struct gb_i2c_transfer_op *op; __u16 addr; __u16 flags; __u16 size; - desc = &op_req->i2c_xfer_req.desc[i]; - addr = le16toh(desc->addr); - flags = le16toh(desc->flags); - size = le16toh(desc->size); + op = &op_req->i2c_xfer_req.ops[i]; + addr = le16toh(op->addr); + flags = le16toh(op->flags); + size = le16toh(op->size); read_op = (flags & I2C_M_RD) ? true : false; gbsim_debug("op %d: %s address %04x size %04x\n", i, (read_op ? "read" : "write"), diff --git a/pwm.c b/pwm.c index daac695..a300495 100644 --- a/pwm.c +++ b/pwm.c @@ -18,17 +18,6 @@ #include "gbsim.h" -#define GB_PWM_TYPE_INVALID 0x00 -#define GB_PWM_TYPE_PROTOCOL_VERSION 0x01 -#define GB_PWM_TYPE_PWM_COUNT 0x02 -#define GB_PWM_TYPE_ACTIVATE 0x03 -#define GB_PWM_TYPE_DEACTIVATE 0x04 -#define GB_PWM_TYPE_CONFIG 0x05 -#define GB_PWM_TYPE_POLARITY 0x06 -#define GB_PWM_TYPE_ENABLE 0x07 -#define GB_PWM_TYPE_DISABLE 0x08 -#define GB_PWM_TYPE_RESPONSE 0x80 - static int pwm_on[2]; static pwm *pwms[2]; @@ -72,7 +61,7 @@ void pwm_handler(unsigned int cport, __u8 *rbuf, size_t size) write(cport_in, op_rsp, sz); break; case GB_PWM_TYPE_PWM_COUNT: - sz = sizeof(struct op_header) + sizeof(struct pwm_count_rsp); + sz = sizeof(struct op_header) + sizeof(struct gb_pwm_count_response); op_rsp->header.size = htole16((__u16)sz); op_rsp->header.id = oph->id; op_rsp->header.type = OP_RESPONSE | GB_PWM_TYPE_PWM_COUNT;