From patchwork Mon Mar 30 18:39:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 46529 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C1B9E214C7 for ; Mon, 30 Mar 2015 18:39:46 +0000 (UTC) Received: by wixm2 with SMTP id m2sf21471686wix.0 for ; Mon, 30 Mar 2015 11:39:46 -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:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=tw/vN+BhtxIeEvtZtpDGodxWMAdAavxipOYOPGMsY8Y=; b=mdmybT0TCJbircqGkV5a5qllI0zv9t/ALcQ2hL1C/xvEC6rXkk4X0dbnz3vGbuxfhe sHL1Ry5ele7qtMBsbOjkMoOWjXBwrwSR7OZl7fZTwYZ6Z619/KATIV0Kzi+LOtZ+eplQ HSdVxkT3ORoZgIWzSPsWEkG87DPMOWx2cKw0J+s/qJPLiSdfa7LEjC5CYYDhzfOV35ey TczXBzqIR7k/FP9/Rn6LSiDBWnU2oZnbUB0sBUA27I1ssXX5Z0FTRZqK8jz4DYaF9j6A nB3Hh4y4hGAnXgx53AQeeQVQB0FsQNKPT2aB2wVRj0GnT/+GoARgSalLmsBSq7hF5fD4 oavA== X-Gm-Message-State: ALoCoQkNyHnTOu0wcMtPHPS2PHUD8Ue+44W78TFTvH0RfpFHeXrnW3Xher5eoHKrHwFl2upoR+aU X-Received: by 10.152.8.108 with SMTP id q12mr3451710laa.6.1427740786100; Mon, 30 Mar 2015 11:39:46 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.170.198 with SMTP id ao6ls565886lac.103.gmail; Mon, 30 Mar 2015 11:39:45 -0700 (PDT) X-Received: by 10.112.155.65 with SMTP id vu1mr27583032lbb.61.1427740785890; Mon, 30 Mar 2015 11:39:45 -0700 (PDT) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com. [209.85.217.180]) by mx.google.com with ESMTPS id bf6si7587326lbc.57.2015.03.30.11.39.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Mar 2015 11:39:45 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by lbcmq2 with SMTP id mq2so101487758lbc.0 for ; Mon, 30 Mar 2015 11:39:45 -0700 (PDT) X-Received: by 10.152.178.197 with SMTP id da5mr28435105lac.56.1427740785710; Mon, 30 Mar 2015 11:39:45 -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.57.201 with SMTP id k9csp1320529lbq; Mon, 30 Mar 2015 11:39:44 -0700 (PDT) X-Received: by 10.70.47.102 with SMTP id c6mr3210621pdn.24.1427740783726; Mon, 30 Mar 2015 11:39:43 -0700 (PDT) Received: from mail-pd0-f170.google.com (mail-pd0-f170.google.com. [209.85.192.170]) by mx.google.com with ESMTPS id f6si1588077pdp.249.2015.03.30.11.39.42 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Mar 2015 11:39:43 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.192.170 as permitted sender) client-ip=209.85.192.170; Received: by pdbni2 with SMTP id ni2so183848778pdb.1 for ; Mon, 30 Mar 2015 11:39:41 -0700 (PDT) X-Received: by 10.70.61.202 with SMTP id s10mr60831056pdr.86.1427740781450; Mon, 30 Mar 2015 11:39:41 -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 qr6sm11405184pbc.64.2015.03.30.11.39.40 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 30 Mar 2015 11:39:40 -0700 (PDT) From: John Stultz To: projectara-software-dev Cc: Alex Elder , Greg Kroah-Hartman , mark greer , John Stultz Subject: [RFC][PATCH] gbsim: Add initial i2s support. Date: Mon, 30 Mar 2015 11:39:32 -0700 Message-Id: <1427740772-11203-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 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.180 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: , Add initial i2s support. This only supports SEND_DATA for now, but I'll probably start extending it for I2S mgmt functions soon. Cc: Alex Elder Cc: Greg Kroah-Hartman Cc: mark greer Signed-off-by: John Stultz --- Makefile | 2 +- cport.c | 11 ++++++++++ gbsim.h | 3 +++ i2s.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 i2s.c diff --git a/Makefile b/Makefile index ac5c593..e6fabb2 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ INCS = -I$(GBDIR) LFLAGS = LIBS = -lpthread -lusbg -lsoc -SRCS = main.c gadget.c functionfs.c inotify.c manifest.c cport.c i2c.c gpio.c pwm.c +SRCS = main.c gadget.c functionfs.c inotify.c manifest.c cport.c i2c.c gpio.c pwm.c i2s.c OBJS = $(SRCS:.c=.o) MAIN = gbsim diff --git a/cport.c b/cport.c index 71dbcdb..f7a73d7 100644 --- a/cport.c +++ b/cport.c @@ -31,6 +31,12 @@ static char *get_protocol(__le16 id) return "I2C"; case GREYBUS_PROTOCOL_PWM: return "PWM"; + case GREYBUS_PROTOCOL_I2S_MGMT: + return "I2S_MGMT"; + case GREYBUS_PROTOCOL_I2S_RECEIVER: + return "I2S_RECEIVER"; + case GREYBUS_PROTOCOL_I2S_TRANSMITTER: + return "I2S_TRANSMITTER"; } } } @@ -53,6 +59,11 @@ static void exec_subdev_handler(__le16 id, __u8 *rbuf, size_t size) case GREYBUS_PROTOCOL_PWM: pwm_handler(rbuf, size); break; + case GREYBUS_PROTOCOL_I2S_MGMT: + case GREYBUS_PROTOCOL_I2S_RECEIVER: + case GREYBUS_PROTOCOL_I2S_TRANSMITTER: + i2s_handler(rbuf, size); + break; default: gbsim_error("subdev handler not found for cport %d\n", id); diff --git a/gbsim.h b/gbsim.h index ef9c33c..3595543 100644 --- a/gbsim.h +++ b/gbsim.h @@ -286,4 +286,7 @@ void i2c_init(void); void pwm_handler(__u8 *, size_t); void pwm_init(void); +void i2s_handler(__u8 *, size_t); +void i2s_init(void); + bool manifest_parse(void *data, size_t size); diff --git a/i2s.c b/i2s.c new file mode 100644 index 0000000..604d263 --- /dev/null +++ b/i2s.c @@ -0,0 +1,68 @@ +/* + * Greybus Simulator + * + * Copyright 2014 Google Inc. + * Copyright 2014 Linaro Ltd. + * + * Provided under the three clause BSD license found in the LICENSE file. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "gbsim.h" + +#define GB_I2S_DATA_TYPE_SEND_DATA 0x02 + +void i2s_handler(__u8 *rbuf, size_t size) +{ + struct op_header *oph; + char *tbuf; + struct op_msg *op_req, *op_rsp; + struct cport_msg *cport_req, *cport_rsp; + size_t sz; + + tbuf = malloc(4 * 1024); + if (!tbuf) { + gbsim_error("failed to allocate i2s handler tx buf\n"); + return; + } + cport_req = (struct cport_msg *)rbuf; + op_req = (struct op_msg *)cport_req->data; + cport_rsp = (struct cport_msg *)tbuf; + cport_rsp->cport = cport_req->cport; + op_rsp = (struct op_msg *)cport_rsp->data; + oph = (struct op_header *)&op_req->header; + + switch (oph->type) { + case GB_I2S_DATA_TYPE_SEND_DATA: + sz = sizeof(struct op_header); + op_rsp->header.size = htole16((__u16)sz); + op_rsp->header.id = oph->id; + + op_rsp->header.type = OP_RESPONSE | GB_I2S_DATA_TYPE_SEND_DATA; + op_rsp->header.result = PROTOCOL_STATUS_SUCCESS; + + gbsim_debug("Module %d -> AP CPort %d I2S SEND_DATA response\n ", + cport_to_module_id(cport_req->cport), cport_rsp->cport); + if (verbose) + gbsim_dump((__u8 *)op_rsp, op_rsp->header.size); + write(cport_in, cport_rsp, op_rsp->header.size + 1); + break; + default: + gbsim_error("gpio operation type %02x not supported\n", oph->type); + } + + free(tbuf); +} + +void i2s_init(void) +{ + +}