Commit 530a7061 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge branch 'greybus' into staging-testing

This merges the greybus branch into staging-testing.  It contains the
drivers/staging/greybus/ subsystem and related drivers and has passed
the 0-day bot tests so no builds should break.
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parents 26e9c85b 2bbadafb
...@@ -5290,6 +5290,23 @@ L: netdev@vger.kernel.org ...@@ -5290,6 +5290,23 @@ L: netdev@vger.kernel.org
S: Maintained S: Maintained
F: drivers/net/ethernet/aeroflex/ F: drivers/net/ethernet/aeroflex/
GREYBUS SUBSYSTEM
M: Johan Hovold <johan@kernel.org>
M: Alex Elder <elder@kernel.org>
M: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
S: Maintained
F: drivers/staging/greybus/
GREYBUS PROTOCOLS DRIVERS
M: Rui Miguel Silva <rmfrfs@gmail.com>
S: Maintained
F: drivers/staging/greybus/sdio.c
F: drivers/staging/greybus/light.c
F: drivers/staging/greybus/gpio.c
F: drivers/staging/greybus/power_supply.c
F: drivers/staging/greybus/spi.c
F: drivers/staging/greybus/spilib.c
GSPCA FINEPIX SUBDRIVER GSPCA FINEPIX SUBDRIVER
M: Frank Zago <frank@zago.net> M: Frank Zago <frank@zago.net>
L: linux-media@vger.kernel.org L: linux-media@vger.kernel.org
......
...@@ -102,4 +102,6 @@ source "drivers/staging/i4l/Kconfig" ...@@ -102,4 +102,6 @@ source "drivers/staging/i4l/Kconfig"
source "drivers/staging/ks7010/Kconfig" source "drivers/staging/ks7010/Kconfig"
source "drivers/staging/greybus/Kconfig"
endif # STAGING endif # STAGING
...@@ -40,3 +40,4 @@ obj-$(CONFIG_WILC1000) += wilc1000/ ...@@ -40,3 +40,4 @@ obj-$(CONFIG_WILC1000) += wilc1000/
obj-$(CONFIG_MOST) += most/ obj-$(CONFIG_MOST) += most/
obj-$(CONFIG_ISDN_I4L) += i4l/ obj-$(CONFIG_ISDN_I4L) += i4l/
obj-$(CONFIG_KS7010) += ks7010/ obj-$(CONFIG_KS7010) += ks7010/
obj-$(CONFIG_GREYBUS) += greybus/
/*
* Sample code to test CAP protocol
*
* This file is provided under a dual BSD/GPLv2 license. When using or
* redistributing this file, you may do so under either license.
*
* GPL LICENSE SUMMARY
*
* Copyright(c) 2016 Google Inc. All rights reserved.
* Copyright(c) 2016 Linaro Ltd. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License version 2 for more details.
*
* BSD LICENSE
*
* Copyright(c) 2016 Google Inc. All rights reserved.
* Copyright(c) 2016 Linaro Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. or Linaro Ltd. nor the names of
* its contributors may be used to endorse or promote products
* derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR
* LINARO LTD. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "../../greybus_authentication.h"
struct cap_ioc_get_endpoint_uid uid;
struct cap_ioc_get_ims_certificate cert = {
.certificate_class = 0,
.certificate_id = 0,
};
struct cap_ioc_authenticate authenticate = {
.auth_type = 0,
.challenge = {0},
};
int main(int argc, char *argv[])
{
unsigned int timeout = 10000;
char *capdev;
int fd, ret;
/* Make sure arguments are correct */
if (argc != 2) {
printf("\nUsage: ./firmware <Path of the gb-cap-X dev>\n");
return 0;
}
capdev = argv[1];
printf("Opening %s authentication device\n", capdev);
fd = open(capdev, O_RDWR);
if (fd < 0) {
printf("Failed to open: %s\n", capdev);
return -1;
}
/* Get UID */
printf("Get UID\n");
ret = ioctl(fd, CAP_IOC_GET_ENDPOINT_UID, &uid);
if (ret < 0) {
printf("Failed to get UID: %s (%d)\n", capdev, ret);
ret = -1;
goto close_fd;
}
printf("UID received: 0x%llx\n", *(long long unsigned int *)(uid.uid));
/* Get certificate */
printf("Get IMS certificate\n");
ret = ioctl(fd, CAP_IOC_GET_IMS_CERTIFICATE, &cert);
if (ret < 0) {
printf("Failed to get IMS certificate: %s (%d)\n", capdev, ret);
ret = -1;
goto close_fd;
}
printf("IMS Certificate size: %d\n", cert.cert_size);
/* Authenticate */
printf("Authenticate module\n");
memcpy(authenticate.uid, uid.uid, 8);
ret = ioctl(fd, CAP_IOC_AUTHENTICATE, &authenticate);
if (ret < 0) {
printf("Failed to authenticate module: %s (%d)\n", capdev, ret);
ret = -1;
goto close_fd;
}
printf("Authenticated, result (%02x), sig-size (%02x)\n",
authenticate.result_code, authenticate.signature_size);
close_fd:
close(fd);
return ret;
}
/*
* Sample code to test firmware-management protocol
*
* This file is provided under a dual BSD/GPLv2 license. When using or
* redistributing this file, you may do so under either license.
*
* GPL LICENSE SUMMARY
*
* Copyright(c) 2016 Google Inc. All rights reserved.
* Copyright(c) 2016 Linaro Ltd. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License version 2 for more details.
*
* BSD LICENSE
*
* Copyright(c) 2016 Google Inc. All rights reserved.
* Copyright(c) 2016 Linaro Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. or Linaro Ltd. nor the names of
* its contributors may be used to endorse or promote products
* derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR
* LINARO LTD. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "../../greybus_firmware.h"
#define FW_DEV_DEFAULT "/dev/gb-fw-mgmt-0"
#define FW_TAG_INT_DEFAULT "s3f"
#define FW_TAG_BCND_DEFAULT "bf_01"
#define FW_UPDATE_TYPE_DEFAULT 0
#define FW_TIMEOUT_DEFAULT 10000;
static const char *firmware_tag;
static const char *fwdev = FW_DEV_DEFAULT;
static int fw_update_type = FW_UPDATE_TYPE_DEFAULT;
static int fw_timeout = FW_TIMEOUT_DEFAULT;
static struct fw_mgmt_ioc_get_intf_version intf_fw_info;
static struct fw_mgmt_ioc_get_backend_version backend_fw_info;
static struct fw_mgmt_ioc_intf_load_and_validate intf_load;
static struct fw_mgmt_ioc_backend_fw_update backend_update;
static void usage(void)
{
printf("\nUsage: ./firmware <gb-fw-mgmt-X (default: gb-fw-mgmt-0)> <interface: 0, backend: 1 (default: 0)> <firmware-tag> (default: \"s3f\"/\"bf_01\") <timeout (default: 10000 ms)>\n");
}
static int update_intf_firmware(int fd)
{
int ret;
/* Get Interface Firmware Version */
printf("Get Interface Firmware Version\n");
ret = ioctl(fd, FW_MGMT_IOC_GET_INTF_FW, &intf_fw_info);
if (ret < 0) {
printf("Failed to get interface firmware version: %s (%d)\n",
fwdev, ret);
return -1;
}
printf("Interface Firmware tag (%s), major (%d), minor (%d)\n",
intf_fw_info.firmware_tag, intf_fw_info.major,
intf_fw_info.minor);
/* Try Interface Firmware load over Unipro */
printf("Loading Interface Firmware\n");
intf_load.load_method = GB_FW_U_LOAD_METHOD_UNIPRO;
intf_load.status = 0;
intf_load.major = 0;
intf_load.minor = 0;
strncpy((char *)&intf_load.firmware_tag, firmware_tag,
GB_FIRMWARE_U_TAG_MAX_SIZE);
ret = ioctl(fd, FW_MGMT_IOC_INTF_LOAD_AND_VALIDATE, &intf_load);
if (ret < 0) {
printf("Failed to load interface firmware: %s (%d)\n", fwdev,
ret);
return -1;
}
if (intf_load.status != GB_FW_U_LOAD_STATUS_VALIDATED &&
intf_load.status != GB_FW_U_LOAD_STATUS_UNVALIDATED) {
printf("Load status says loading failed: %d\n",
intf_load.status);
return -1;
}
printf("Interface Firmware (%s) Load done: major: %d, minor: %d, status: %d\n",
firmware_tag, intf_load.major, intf_load.minor,
intf_load.status);
/* Initiate Mode-switch to the newly loaded firmware */
printf("Initiate Mode switch\n");
ret = ioctl(fd, FW_MGMT_IOC_MODE_SWITCH);
if (ret < 0)
printf("Failed to initiate mode-switch (%d)\n", ret);
return ret;
}
static int update_backend_firmware(int fd)
{
int ret;
/* Get Backend Firmware Version */
printf("Getting Backend Firmware Version\n");
strncpy((char *)&backend_fw_info.firmware_tag, firmware_tag,
GB_FIRMWARE_U_TAG_MAX_SIZE);
retry_fw_version:
ret = ioctl(fd, FW_MGMT_IOC_GET_BACKEND_FW, &backend_fw_info);
if (ret < 0) {
printf("Failed to get backend firmware version: %s (%d)\n",
fwdev, ret);
return -1;
}
printf("Backend Firmware tag (%s), major (%d), minor (%d), status (%d)\n",
backend_fw_info.firmware_tag, backend_fw_info.major,
backend_fw_info.minor, backend_fw_info.status);
if (backend_fw_info.status == GB_FW_U_BACKEND_VERSION_STATUS_RETRY)
goto retry_fw_version;
if ((backend_fw_info.status != GB_FW_U_BACKEND_VERSION_STATUS_SUCCESS)
&& (backend_fw_info.status != GB_FW_U_BACKEND_VERSION_STATUS_NOT_AVAILABLE)) {
printf("Failed to get backend firmware version: %s (%d)\n",
fwdev, backend_fw_info.status);
return -1;
}
/* Try Backend Firmware Update over Unipro */
printf("Updating Backend Firmware\n");
strncpy((char *)&backend_update.firmware_tag, firmware_tag,
GB_FIRMWARE_U_TAG_MAX_SIZE);
retry_fw_update:
backend_update.status = 0;
ret = ioctl(fd, FW_MGMT_IOC_INTF_BACKEND_FW_UPDATE, &backend_update);
if (ret < 0) {
printf("Failed to load backend firmware: %s (%d)\n", fwdev, ret);
return -1;
}
if (backend_update.status == GB_FW_U_BACKEND_FW_STATUS_RETRY) {
printf("Retrying firmware update: %d\n", backend_update.status);
goto retry_fw_update;
}
if (backend_update.status != GB_FW_U_BACKEND_FW_STATUS_SUCCESS) {
printf("Load status says loading failed: %d\n",
backend_update.status);
} else {
printf("Backend Firmware (%s) Load done: status: %d\n",
firmware_tag, backend_update.status);
}
return 0;
}
int main(int argc, char *argv[])
{
int fd, ret;
if (argc > 1 &&
(!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))) {
usage();
return -1;
}
if (argc > 1)
fwdev = argv[1];
if (argc > 2)
sscanf(argv[2], "%u", &fw_update_type);
if (argc > 3) {
firmware_tag = argv[3];
} else if (!fw_update_type) {
firmware_tag = FW_TAG_INT_DEFAULT;
} else {
firmware_tag = FW_TAG_BCND_DEFAULT;
}
if (argc > 4)
sscanf(argv[4], "%u", &fw_timeout);
printf("Trying Firmware update: fwdev: %s, type: %s, tag: %s, timeout: %d\n",
fwdev, fw_update_type == 0 ? "interface" : "backend",
firmware_tag, fw_timeout);
printf("Opening %s firmware management device\n", fwdev);
fd = open(fwdev, O_RDWR);
if (fd < 0) {
printf("Failed to open: %s\n", fwdev);
return -1;
}
/* Set Timeout */
printf("Setting timeout to %u ms\n", fw_timeout);
ret = ioctl(fd, FW_MGMT_IOC_SET_TIMEOUT_MS, &fw_timeout);
if (ret < 0) {
printf("Failed to set timeout: %s (%d)\n", fwdev, ret);
ret = -1;
goto close_fd;
}
if (!fw_update_type)
ret = update_intf_firmware(fd);
else
ret = update_backend_firmware(fd);
close_fd:
close(fd);
return ret;
}
What: /sys/bus/greybus/devices/greybusN
Date: October 2015
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
The "root" greybus device for the Greybus device tree, or bus,
where N is a dynamically assigned 1-based id.
What: /sys/bus/greybus/devices/greybusN/bus_id
Date: April 2016
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
The ID of the "root" greybus device, or bus.
What: /sys/bus/greybus/devices/N-M
Date: March 2016
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
A Module M on the bus N, where M is the 1-byte interface
ID of the module's primary interface.
What: /sys/bus/greybus/devices/N-M/eject
Date: March 2016
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
Writing a non-zero argument to this attibute disables the
module's interfaces before physically ejecting it.
What: /sys/bus/greybus/devices/N-M/module_id
Date: March 2016
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
The ID of a Greybus module, corresponding to the ID of its
primary interface.
What: /sys/bus/greybus/devices/N-M/num_interfaces
Date: March 2016
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
The number of interfaces of a module.
What: /sys/bus/greybus/devices/N-M.I
Date: October 2015
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
An Interface I on the bus N and module N-M, where I is the
1-byte interface ID.
What: /sys/bus/greybus/devices/N-M.I/current_now
Date: March 2016
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
Current measurement of the interface in microamps (uA)
What: /sys/bus/greybus/devices/N-M.I/ddbl1_manufacturer_id
Date: October 2015
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
Unipro Device Descriptor Block Level 1 manufacturer ID for the
greybus Interface.
What: /sys/bus/greybus/devices/N-M.I/ddbl1_product_id
Date: October 2015
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
Unipro Device Descriptor Block Level 1 product ID for the
greybus Interface.
What: /sys/bus/greybus/devices/N-M.I/interface_id
Date: October 2015
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
The ID of a Greybus interface.
What: /sys/bus/greybus/devices/N-M.I/interface_type
Date: June 2016
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
The type of a Greybus interface; "dummy", "unipro", "greybus",
or "unknown".
What: /sys/bus/greybus/devices/N-M.I/power_now
Date: March 2016
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
Power measurement of the interface in microwatts (uW)
What: /sys/bus/greybus/devices/N-M.I/power_state
Date: March 2016
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
This file reflects the power state of a Greybus interface. If
the value read from it is "on", then power is currently
supplied to the interface. Otherwise it will read "off" and
power is currently not supplied to the interface.
If the value read is "off", then writing "on" (or '1', 'y',
'Y') to this file will enable power to the interface and an
attempt to boot and possibly enumerate it will be made. Note
that on errors, the interface will again be powered down.
If the value read is "on", then writing "off" (or '0', 'n',
'N') to this file will power down the interface.
What: /sys/bus/greybus/devices/N-M.I/product_id
Date: October 2015
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
Product ID of a Greybus interface.
What: /sys/bus/greybus/devices/N-M.I/serial_number
Date: October 2015
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
Serial Number of the Greybus interface, represented by a 64 bit
hexadecimal number.
What: /sys/bus/greybus/devices/N-M.I/vendor_id
Date: October 2015
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
Vendor ID of a Greybus interface.
What: /sys/bus/greybus/devices/N-M.I/voltage_now
Date: March 2016
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
Voltage measurement of the interface in microvolts (uV)
What: /sys/bus/greybus/devices/N-M.I.ctrl
Date: October 2015
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
Abstract control device for interface I that represents the
current mode of an enumerated Greybus interface.
What: /sys/bus/greybus/devices/N-M.I.ctrl/product_string
Date: October 2015
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
Product ID string of a Greybus interface.
What: /sys/bus/greybus/devices/N-M.I.ctrl/vendor_string
Date: October 2015
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
Vendor ID string of a Greybus interface.
What: /sys/bus/greybus/devices/N-M.I.B
Date: October 2015
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
A bundle B on the Interface I, B is replaced by a 1-byte
number representing the bundle.
What: /sys/bus/greybus/devices/N-M.I.B/bundle_class
Date: October 2015
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
The greybus class of the bundle B.
What: /sys/bus/greybus/devices/N-M.I.B/bundle_id
Date: October 2015
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
The interface-unique id of the bundle B.
What: /sys/bus/greybus/devices/N-M.I.B/gpbX
Date: April 2016
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
The General Purpose Bridged PHY device of the bundle B,
where X is a dynamically assigned 0-based id.
What: /sys/bus/greybus/devices/N-M.I.B/state
Date: October 2015
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
A bundle has a state that is managed by the userspace
Endo process. This file allows that Endo to signal
other Android HALs that the state of the bundle has
changed to a specific value. When written to, any
process watching the file will be woken up, and the new
value can be read. It's a "poor-man's IPC", yes, but
simplifies the Android userspace code immensely.
What: /sys/bus/greybus/devices/N-svc
Date: October 2015
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
The singleton SVC device of bus N.
What: /sys/bus/greybus/devices/N-svc/ap_intf_id
Date: October 2015
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
The AP interface ID, a 1-byte non-zero integer which
defines the position of the AP module on the frame.
The interface positions are defined in the GMP
Module Developer Kit.
What: /sys/bus/greybus/devices/N-svc/endo_id
Date: October 2015
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
The Endo ID, which is a 2-byte hexadecimal value
defined by the Endo layout scheme, documented in
the GMP Module Developer Kit.
What: /sys/bus/greybus/devices/N-svc/intf_eject
Date: October 2015
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
Write the number of the interface that you wish to
forcibly eject from the system.
What: /sys/bus/greybus/devices/N-svc/version
Date: October 2015
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
The version number of the firmware in the SVC device.
What: /sys/bus/greybus/devices/N-svc/watchdog
Date: October 2016
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
If the SVC watchdog is enabled or not. Writing 0 to this
file will disable the watchdog, writing 1 will enable it.
What: /sys/bus/greybus/devices/N-svc/watchdog_action
Date: July 2016
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
This attribute indicates the action to be performed upon SVC
watchdog bite.
The action can be one of the "reset" or "panic". Writing either
one of the "reset" or "panic" will change the behavior of SVC
watchdog bite. Default value is "reset".
"reset" means the UniPro subsystem is to be reset.
"panic" means SVC watchdog bite will cause kernel to panic.
menuconfig GREYBUS
tristate "Greybus support"
depends on SYSFS
---help---
This option enables the Greybus driver core. Greybus is an
hardware protocol that was designed to provide Unipro with a
sane application layer. It was originally designed for the
ARA project, a module phone system, but has shown up in other
phones, and can be tunneled over other busses in order to
control hardware devices.
Say Y here to enable support for these types of drivers.
To compile this code as a module, chose M here: the module
will be called greybus.ko
if GREYBUS
config GREYBUS_ES2
tristate "Greybus ES3 USB host controller"
depends on USB
---help---
Select this option if you have a Toshiba ES3 USB device that
acts as a Greybus "host controller". This device is a bridge
from a USB device to a Unipro network.
To compile this code as a module, chose M here: the module
will be called gb-es2.ko
config GREYBUS_AUDIO
tristate "Greybus Audio Class driver"
depends on SOUND
---help---
Select this option if you have a device that follows the
Greybus Audio Class specification.
To compile this code as a module, chose M here: the module
will be called gb-audio.ko
config GREYBUS_BOOTROM
tristate "Greybus Bootrom Class driver"
---help---
Select this option if you have a device that follows the
Greybus Bootrom Class specification.
To compile this code as a module, chose M here: the module
will be called gb-bootrom.ko
config GREYBUS_CAMERA
tristate "Greybus Camera Class driver"
depends on MEDIA && LEDS_CLASS_FLASH && BROKEN
---help---
Select this option if you have a device that follows the
Greybus Camera Class specification.
To compile this code as a module, chose M here: the module
will be called gb-camera.ko
config GREYBUS_FIRMWARE
tristate "Greybus Firmware Download Class driver"
depends on SPI
---help---
Select this option if you have a device that follows the
Greybus Firmware Download Class specification.
To compile this code as a module, chose M here: the module
will be called gb-firmware.ko
config GREYBUS_HID
tristate "Greybus HID Class driver"
depends on HID && INPUT
---help---
Select this option if you have a device that follows the
Greybus HID Class specification.
To compile this code as a module, chose M here: the module
will be called gb-hid.ko
config GREYBUS_LIGHT
tristate "Greybus LED Class driver"
depends on LEDS_CLASS
---help---
Select this option if you have a device that follows the
Greybus LED Class specification.
To compile this code as a module, chose M here: the module
will be called gb-light.ko
config GREYBUS_LOG
tristate "Greybus Debug Log Class driver"
---help---
Select this option if you have a device that follows the
Greybus Debug Log Class specification.
To compile this code as a module, chose M here: the module
will be called gb-log.ko
config GREYBUS_LOOPBACK
tristate "Greybus Loopback Class driver"
---help---
Select this option if you have a device that follows the
Greybus Debug Log Class specification.
To compile this code as a module, chose M here: the module
will be called gb-log.ko
config GREYBUS_POWER
tristate "Greybus Powersupply Class driver"
depends on POWER_SUPPLY
---help---
Select this option if you have a device that follows the
Greybus Powersupply Class specification.
To compile this code as a module, chose M here: the module
will be called gb-power-supply.ko
config GREYBUS_RAW
tristate "Greybus Raw Class driver"
---help---
Select this option if you have a device that follows the
Greybus Raw Class specification.
To compile this code as a module, chose M here: the module
will be called gb-raw.ko
config GREYBUS_VIBRATOR
tristate "Greybus Vibrator Motor Class driver"
---help---
Select this option if you have a device that follows the
Greybus Vibrator Motor Class specification.
To compile this code as a module, chose M here: the module
will be called gb-vibrator.ko
menuconfig GREYBUS_BRIDGED_PHY
tristate "Greybus Bridged PHY Class drivers"
---help---
Select this option to pick from a variety of Greybus Bridged
PHY class drivers. These drivers emulate a number of
different "traditional" busses by tunneling them over Greybus.
Examples of this include serial, SPI, USB, and others.
To compile this code as a module, chose M here: the module
will be called gb-phy.ko
if GREYBUS_BRIDGED_PHY
config GREYBUS_GPIO
tristate "Greybus GPIO Bridged PHY driver"
depends on GPIOLIB
---help---
Select this option if you have a device that follows the
Greybus GPIO Bridged PHY Class specification.
To compile this code as a module, chose M here: the module
will be called gb-gpio.ko
config GREYBUS_I2C
tristate "Greybus I2C Bridged PHY driver"
depends on I2C
---help---
Select this option if you have a device that follows the
Greybus I2C Bridged PHY Class specification.
To compile this code as a module, chose M here: the module
will be called gb-i2c.ko
config GREYBUS_PWM
tristate "Greybus PWM Bridged PHY driver"
depends on PWM
---help---
Select this option if you have a device that follows the
Greybus PWM Bridged PHY Class specification.
To compile this code as a module, chose M here: the module
will be called gb-pwm.ko
config GREYBUS_SDIO
tristate "Greybus SDIO Bridged PHY driver"
depends on MMC
---help---
Select this option if you have a device that follows the
Greybus SDIO Bridged PHY Class specification.
To compile this code as a module, chose M here: the module
will be called gb-sdio.ko
config GREYBUS_SPI
tristate "Greybus SPI Bridged PHY driver"
depends on SPI
---help---
Select this option if you have a device that follows the
Greybus SPI Bridged PHY Class specification.
To compile this code as a module, chose M here: the module
will be called gb-spi.ko
config GREYBUS_UART
tristate "Greybus UART Bridged PHY driver"
depends on TTY
---help---
Select this option if you have a device that follows the
Greybus UART Bridged PHY Class specification.
To compile this code as a module, chose M here: the module
will be called gb-uart.ko
config GREYBUS_USB
tristate "Greybus USB Host Bridged PHY driver"
depends on USB
---help---
Select this option if you have a device that follows the
Greybus USB Host Bridged PHY Class specification.
To compile this code as a module, chose M here: the module
will be called gb-usb.ko
endif # GREYBUS_BRIDGED_PHY
endif # GREYBUS
# Greybus core
greybus-y := core.o \
debugfs.o \
hd.o \
manifest.o \
module.o \
interface.o \
bundle.o \
connection.o \
control.o \
svc.o \
svc_watchdog.o \
operation.o \
timesync.o \
timesync_platform.o
obj-$(CONFIG_GREYBUS) += greybus.o
# needed for trace events
ccflags-y += -I$(src)
# Greybus Host controller drivers
gb-es2-y := es2.o
obj-$(CONFIG_GREYBUS_ES2) += gb-es2.o
# Greybus class drivers
gb-bootrom-y := bootrom.o
gb-camera-y := camera.o
gb-firmware-y := fw-core.o fw-download.o fw-management.o authentication.o
gb-spilib-y := spilib.o
gb-hid-y := hid.o
gb-light-y := light.o
gb-log-y := log.o
gb-loopback-y := loopback.o
gb-power-supply-y := power_supply.o
gb-raw-y := raw.o
gb-vibrator-y := vibrator.o
obj-$(CONFIG_GREYBUS_BOOTROM) += gb-bootrom.o
obj-$(CONFIG_GREYBUS_CAMERA) += gb-camera.o
obj-$(CONFIG_GREYBUS_FIRMWARE) += gb-firmware.o gb-spilib.o
obj-$(CONFIG_GREYBUS_HID) += gb-hid.o
obj-$(CONFIG_GREYBUS_LIGHT) += gb-light.o
obj-$(CONFIG_GREYBUS_LOG) += gb-log.o
obj-$(CONFIG_GREYBUS_LOOPBACK) += gb-loopback.o
obj-$(CONFIG_GREYBUS_POWER) += gb-power-supply.o
obj-$(CONFIG_GREYBUS_RAW) += gb-raw.o
obj-$(CONFIG_GREYBUS_VIBRATOR) += gb-vibrator.o
# Greybus Audio is a bunch of modules
gb-audio-module-y := audio_module.o audio_topology.o
gb-audio-codec-y := audio_codec.o
gb-audio-gb-y := audio_gb.o
gb-audio-apbridgea-y := audio_apbridgea.o
gb-audio-manager-y := audio_manager.o audio_manager_module.o
# Greybus Audio sysfs helpers can be useful when debugging
#GB_AUDIO_MANAGER_SYSFS ?= true
#ifeq ($(GB_AUDIO_MANAGER_SYSFS),true)
#gb-audio-manager-y += audio_manager_sysfs.o
#ccflags-y += -DGB_AUDIO_MANAGER_SYSFS
#endif
obj-$(CONFIG_GREYBUS_AUDIO_MSM8994) += gb-audio-codec.o
obj-$(CONFIG_GREYBUS_AUDIO_MSM8994) += gb-audio-module.o
obj-$(CONFIG_GREYBUS_AUDIO) += gb-audio-gb.o
obj-$(CONFIG_GREYBUS_AUDIO) += gb-audio-apbridgea.o
obj-$(CONFIG_GREYBUS_AUDIO) += gb-audio-manager.o
# Greybus Bridged PHY drivers
gb-gbphy-y := gbphy.o
gb-gpio-y := gpio.o
gb-i2c-y := i2c.o
gb-pwm-y := pwm.o
gb-sdio-y := sdio.o
gb-spi-y := spi.o
gb-uart-y := uart.o
gb-usb-y := usb.o
obj-$(CONFIG_GREYBUS_BRIDGED_PHY) += gb-gbphy.o
obj-$(CONFIG_GREYBUS_GPIO) += gb-gpio.o
obj-$(CONFIG_GREYBUS_I2C) += gb-i2c.o
obj-$(CONFIG_GREYBUS_PWM) += gb-pwm.o
obj-$(CONFIG_GREYBUS_SDIO) += gb-sdio.o
obj-$(CONFIG_GREYBUS_SPI) += gb-spi.o gb-spilib.o
obj-$(CONFIG_GREYBUS_UART) += gb-uart.o
obj-$(CONFIG_GREYBUS_USB) += gb-usb.o
# Greybus Platform driver
gb-arche-y := arche-platform.o arche-apb-ctrl.o
obj-$(CONFIG_USB_HSIC_USB3613) += gb-arche.o
This diff is collapsed.
This diff is collapsed.
/*
* Arche Platform driver to enable Unipro link.
*
* Copyright 2015-2016 Google Inc.
* Copyright 2015-2016 Linaro Ltd.
*
* Released under the GPLv2 only.
*/
#ifndef __ARCHE_PLATFORM_H
#define __ARCHE_PLATFORM_H
#include "timesync.h"
enum arche_platform_state {
ARCHE_PLATFORM_STATE_OFF,
ARCHE_PLATFORM_STATE_ACTIVE,
ARCHE_PLATFORM_STATE_STANDBY,
ARCHE_PLATFORM_STATE_FW_FLASHING,
ARCHE_PLATFORM_STATE_TIME_SYNC,
};
int arche_platform_change_state(enum arche_platform_state state,
struct gb_timesync_svc *pdata);
extern int (*arche_platform_change_state_cb)(enum arche_platform_state state,
struct gb_timesync_svc *pdata);
int __init arche_apb_init(void);
void __exit arche_apb_exit(void);
/* Operational states for the APB device */
int apb_ctrl_coldboot(struct device *dev);
int apb_ctrl_fw_flashing(struct device *dev);
int apb_ctrl_standby_boot(struct device *dev);
void apb_ctrl_poweroff(struct device *dev);
void apb_bootret_assert(struct device *dev);
void apb_bootret_deassert(struct device *dev);
#endif /* __ARCHE_PLATFORM_H */
/*
* This file is provided under a dual BSD/GPLv2 license. When using or
* redistributing this file, you may do so under either license.
*
* GPL LICENSE SUMMARY
*
* Copyright(c) 2016 Google Inc. All rights reserved.
* Copyright(c) 2016 Linaro Ltd. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License version 2 for more details.
*
* BSD LICENSE
*
* Copyright(c) 2016 Google Inc. All rights reserved.
* Copyright(c) 2016 Linaro Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. or Linaro Ltd. nor the names of
* its contributors may be used to endorse or promote products
* derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR
* LINARO LTD. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __ARPC_H
#define __ARPC_H
/* APBridgeA RPC (ARPC) */
enum arpc_result {
ARPC_SUCCESS = 0x00,
ARPC_NO_MEMORY = 0x01,
ARPC_INVALID = 0x02,
ARPC_TIMEOUT = 0x03,
ARPC_UNKNOWN_ERROR = 0xff,
};
struct arpc_request_message {
__le16 id; /* RPC unique id */
__le16 size; /* Size in bytes of header + payload */
__u8 type; /* RPC type */
__u8 data[0]; /* ARPC data */
} __packed;
struct arpc_response_message {
__le16 id; /* RPC unique id */
__u8 result; /* Result of RPC */
} __packed;
/* ARPC requests */
#define ARPC_TYPE_CPORT_CONNECTED 0x01
#define ARPC_TYPE_CPORT_QUIESCE 0x02
#define ARPC_TYPE_CPORT_CLEAR 0x03
#define ARPC_TYPE_CPORT_FLUSH 0x04
#define ARPC_TYPE_CPORT_SHUTDOWN 0x05
struct arpc_cport_connected_req {
__le16 cport_id;
} __packed;
struct arpc_cport_quiesce_req {
__le16 cport_id;
__le16 peer_space;
__le16 timeout;
} __packed;
struct arpc_cport_clear_req {
__le16 cport_id;
} __packed;
struct arpc_cport_flush_req {
__le16 cport_id;
} __packed;
struct arpc_cport_shutdown_req {
__le16 cport_id;
__le16 timeout;
__u8 phase;
} __packed;
#endif /* __ARPC_H */
/*
* Greybus Audio Device Class Protocol helpers
*
* Copyright 2015-2016 Google Inc.
*
* Released under the GPLv2 only.
*/
#include "greybus.h"
#include "greybus_protocols.h"
#include "audio_apbridgea.h"
#include "audio_codec.h"
int gb_audio_apbridgea_set_config(struct gb_connection *connection,
__u16 i2s_port, __u32 format, __u32 rate,
__u32 mclk_freq)
{
struct audio_apbridgea_set_config_request req;
req.hdr.type = AUDIO_APBRIDGEA_TYPE_SET_CONFIG;
req.hdr.i2s_port = cpu_to_le16(i2s_port);
req.format = cpu_to_le32(format);
req.rate = cpu_to_le32(rate);
req.mclk_freq = cpu_to_le32(mclk_freq);
return gb_hd_output(connection->hd, &req, sizeof(req),
GB_APB_REQUEST_AUDIO_CONTROL, true);
}
EXPORT_SYMBOL_GPL(gb_audio_apbridgea_set_config);
int gb_audio_apbridgea_register_cport(struct gb_connection *connection,
__u16 i2s_port, __u16 cportid,
__u8 direction)
{
struct audio_apbridgea_register_cport_request req;
int ret;
req.hdr.type = AUDIO_APBRIDGEA_TYPE_REGISTER_CPORT;
req.hdr.i2s_port = cpu_to_le16(i2s_port);
req.cport = cpu_to_le16(cportid);
req.direction = direction;
ret = gb_pm_runtime_get_sync(connection->bundle);
if (ret)
return ret;
return gb_hd_output(connection->hd, &req, sizeof(req),
GB_APB_REQUEST_AUDIO_CONTROL, true);
}
EXPORT_SYMBOL_GPL(gb_audio_apbridgea_register_cport);
int gb_audio_apbridgea_unregister_cport(struct gb_connection *connection,
__u16 i2s_port, __u16 cportid,
__u8 direction)
{
struct audio_apbridgea_unregister_cport_request req;
int ret;
req.hdr.type = AUDIO_APBRIDGEA_TYPE_UNREGISTER_CPORT;
req.hdr.i2s_port = cpu_to_le16(i2s_port);
req.cport = cpu_to_le16(cportid);
req.direction = direction;
ret = gb_hd_output(connection->hd, &req, sizeof(req),
GB_APB_REQUEST_AUDIO_CONTROL, true);
gb_pm_runtime_put_autosuspend(connection->bundle);
return ret;
}
EXPORT_SYMBOL_GPL(gb_audio_apbridgea_unregister_cport);
int gb_audio_apbridgea_set_tx_data_size(struct gb_connection *connection,
__u16 i2s_port, __u16 size)
{
struct audio_apbridgea_set_tx_data_size_request req;
req.hdr.type = AUDIO_APBRIDGEA_TYPE_SET_TX_DATA_SIZE;
req.hdr.i2s_port = cpu_to_le16(i2s_port);
req.size = cpu_to_le16(size);
return gb_hd_output(connection->hd, &req, sizeof(req),
GB_APB_REQUEST_AUDIO_CONTROL, true);
}
EXPORT_SYMBOL_GPL(gb_audio_apbridgea_set_tx_data_size);
int gb_audio_apbridgea_prepare_tx(struct gb_connection *connection,
__u16 i2s_port)
{
struct audio_apbridgea_prepare_tx_request req;
req.hdr.type = AUDIO_APBRIDGEA_TYPE_PREPARE_TX;
req.hdr.i2s_port = cpu_to_le16(i2s_port);
return gb_hd_output(connection->hd, &req, sizeof(req),
GB_APB_REQUEST_AUDIO_CONTROL, true);
}
EXPORT_SYMBOL_GPL(gb_audio_apbridgea_prepare_tx);
int gb_audio_apbridgea_start_tx(struct gb_connection *connection,
__u16 i2s_port, __u64 timestamp)
{
struct audio_apbridgea_start_tx_request req;
req.hdr.type = AUDIO_APBRIDGEA_TYPE_START_TX;
req.hdr.i2s_port = cpu_to_le16(i2s_port);
req.timestamp = cpu_to_le64(timestamp);
return gb_hd_output(connection->hd, &req, sizeof(req),
GB_APB_REQUEST_AUDIO_CONTROL, true);
}
EXPORT_SYMBOL_GPL(gb_audio_apbridgea_start_tx);
int gb_audio_apbridgea_stop_tx(struct gb_connection *connection, __u16 i2s_port)
{
struct audio_apbridgea_stop_tx_request req;
req.hdr.type = AUDIO_APBRIDGEA_TYPE_STOP_TX;
req.hdr.i2s_port = cpu_to_le16(i2s_port);
return gb_hd_output(connection->hd, &req, sizeof(req),
GB_APB_REQUEST_AUDIO_CONTROL, true);
}
EXPORT_SYMBOL_GPL(gb_audio_apbridgea_stop_tx);
int gb_audio_apbridgea_shutdown_tx(struct gb_connection *connection,
__u16 i2s_port)
{
struct audio_apbridgea_shutdown_tx_request req;
req.hdr.type = AUDIO_APBRIDGEA_TYPE_SHUTDOWN_TX;
req.hdr.i2s_port = cpu_to_le16(i2s_port);
return gb_hd_output(connection->hd, &req, sizeof(req),
GB_APB_REQUEST_AUDIO_CONTROL, true);
}
EXPORT_SYMBOL_GPL(gb_audio_apbridgea_shutdown_tx);
int gb_audio_apbridgea_set_rx_data_size(struct gb_connection *connection,
__u16 i2s_port, __u16 size)
{
struct audio_apbridgea_set_rx_data_size_request req;
req.hdr.type = AUDIO_APBRIDGEA_TYPE_SET_RX_DATA_SIZE;
req.hdr.i2s_port = cpu_to_le16(i2s_port);
req.size = cpu_to_le16(size);
return gb_hd_output(connection->hd, &req, sizeof(req),
GB_APB_REQUEST_AUDIO_CONTROL, true);
}
EXPORT_SYMBOL_GPL(gb_audio_apbridgea_set_rx_data_size);
int gb_audio_apbridgea_prepare_rx(struct gb_connection *connection,
__u16 i2s_port)
{
struct audio_apbridgea_prepare_rx_request req;
req.hdr.type = AUDIO_APBRIDGEA_TYPE_PREPARE_RX;
req.hdr.i2s_port = cpu_to_le16(i2s_port);
return gb_hd_output(connection->hd, &req, sizeof(req),
GB_APB_REQUEST_AUDIO_CONTROL, true);
}
EXPORT_SYMBOL_GPL(gb_audio_apbridgea_prepare_rx);
int gb_audio_apbridgea_start_rx(struct gb_connection *connection,
__u16 i2s_port)
{
struct audio_apbridgea_start_rx_request req;
req.hdr.type = AUDIO_APBRIDGEA_TYPE_START_RX;
req.hdr.i2s_port = cpu_to_le16(i2s_port);
return gb_hd_output(connection->hd, &req, sizeof(req),
GB_APB_REQUEST_AUDIO_CONTROL, true);
}
EXPORT_SYMBOL_GPL(gb_audio_apbridgea_start_rx);
int gb_audio_apbridgea_stop_rx(struct gb_connection *connection, __u16 i2s_port)
{
struct audio_apbridgea_stop_rx_request req;
req.hdr.type = AUDIO_APBRIDGEA_TYPE_STOP_RX;
req.hdr.i2s_port = cpu_to_le16(i2s_port);
return gb_hd_output(connection->hd, &req, sizeof(req),
GB_APB_REQUEST_AUDIO_CONTROL, true);
}
EXPORT_SYMBOL_GPL(gb_audio_apbridgea_stop_rx);
int gb_audio_apbridgea_shutdown_rx(struct gb_connection *connection,
__u16 i2s_port)
{
struct audio_apbridgea_shutdown_rx_request req;
req.hdr.type = AUDIO_APBRIDGEA_TYPE_SHUTDOWN_RX;
req.hdr.i2s_port = cpu_to_le16(i2s_port);
return gb_hd_output(connection->hd, &req, sizeof(req),
GB_APB_REQUEST_AUDIO_CONTROL, true);
}
EXPORT_SYMBOL_GPL(gb_audio_apbridgea_shutdown_rx);
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("greybus:audio-apbridgea");
MODULE_DESCRIPTION("Greybus Special APBridgeA Audio Protocol library");
MODULE_AUTHOR("Mark Greer <mgreer@animalcreek.com>");
/**
* Copyright (c) 2015-2016 Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* This is a special protocol for configuring communication over the
* I2S bus between the DSP on the MSM8994 and APBridgeA. Therefore,
* we can predefine several low-level attributes of the communication
* because we know that they are supported. In particular, the following
* assumptions are made:
* - there are two channels (i.e., stereo)
* - the low-level protocol is I2S as defined by Philips/NXP
* - the DSP on the MSM8994 is the clock master for MCLK, BCLK, and WCLK
* - WCLK changes on the falling edge of BCLK
* - WCLK low for left channel; high for right channel
* - TX data is sent on the falling edge of BCLK
* - RX data is received/latched on the rising edge of BCLK
*/
#ifndef __AUDIO_APBRIDGEA_H
#define __AUDIO_APBRIDGEA_H
#define AUDIO_APBRIDGEA_TYPE_SET_CONFIG 0x01
#define AUDIO_APBRIDGEA_TYPE_REGISTER_CPORT 0x02
#define AUDIO_APBRIDGEA_TYPE_UNREGISTER_CPORT 0x03
#define AUDIO_APBRIDGEA_TYPE_SET_TX_DATA_SIZE 0x04
/* 0x05 unused */
#define AUDIO_APBRIDGEA_TYPE_PREPARE_TX 0x06
#define AUDIO_APBRIDGEA_TYPE_START_TX 0x07
#define AUDIO_APBRIDGEA_TYPE_STOP_TX 0x08
#define AUDIO_APBRIDGEA_TYPE_SHUTDOWN_TX 0x09
#define AUDIO_APBRIDGEA_TYPE_SET_RX_DATA_SIZE 0x0a
/* 0x0b unused */
#define AUDIO_APBRIDGEA_TYPE_PREPARE_RX 0x0c
#define AUDIO_APBRIDGEA_TYPE_START_RX 0x0d
#define AUDIO_APBRIDGEA_TYPE_STOP_RX 0x0e
#define AUDIO_APBRIDGEA_TYPE_SHUTDOWN_RX 0x0f
#define AUDIO_APBRIDGEA_PCM_FMT_8 BIT(0)
#define AUDIO_APBRIDGEA_PCM_FMT_16 BIT(1)
#define AUDIO_APBRIDGEA_PCM_FMT_24 BIT(2)
#define AUDIO_APBRIDGEA_PCM_FMT_32 BIT(3)
#define AUDIO_APBRIDGEA_PCM_FMT_64 BIT(4)
#define AUDIO_APBRIDGEA_PCM_RATE_5512 BIT(0)
#define AUDIO_APBRIDGEA_PCM_RATE_8000 BIT(1)
#define AUDIO_APBRIDGEA_PCM_RATE_11025 BIT(2)
#define AUDIO_APBRIDGEA_PCM_RATE_16000 BIT(3)
#define AUDIO_APBRIDGEA_PCM_RATE_22050 BIT(4)
#define AUDIO_APBRIDGEA_PCM_RATE_32000 BIT(5)
#define AUDIO_APBRIDGEA_PCM_RATE_44100 BIT(6)
#define AUDIO_APBRIDGEA_PCM_RATE_48000 BIT(7)
#define AUDIO_APBRIDGEA_PCM_RATE_64000 BIT(8)
#define AUDIO_APBRIDGEA_PCM_RATE_88200 BIT(9)
#define AUDIO_APBRIDGEA_PCM_RATE_96000 BIT(10)
#define AUDIO_APBRIDGEA_PCM_RATE_176400 BIT(11)
#define AUDIO_APBRIDGEA_PCM_RATE_192000 BIT(12)
#define AUDIO_APBRIDGEA_DIRECTION_TX BIT(0)
#define AUDIO_APBRIDGEA_DIRECTION_RX BIT(1)
/* The I2S port is passed in the 'index' parameter of the USB request */
/* The CPort is passed in the 'value' parameter of the USB request */
struct audio_apbridgea_hdr {
__u8 type;
__le16 i2s_port;
__u8 data[0];
} __packed;
struct audio_apbridgea_set_config_request {
struct audio_apbridgea_hdr hdr;
__le32 format; /* AUDIO_APBRIDGEA_PCM_FMT_* */
__le32 rate; /* AUDIO_APBRIDGEA_PCM_RATE_* */
__le32 mclk_freq; /* XXX Remove? */
} __packed;
struct audio_apbridgea_register_cport_request {
struct audio_apbridgea_hdr hdr;
__le16 cport;
__u8 direction;
} __packed;
struct audio_apbridgea_unregister_cport_request {
struct audio_apbridgea_hdr hdr;
__le16 cport;
__u8 direction;
} __packed;
struct audio_apbridgea_set_tx_data_size_request {
struct audio_apbridgea_hdr hdr;
__le16 size;
} __packed;
struct audio_apbridgea_prepare_tx_request {
struct audio_apbridgea_hdr hdr;
} __packed;
struct audio_apbridgea_start_tx_request {
struct audio_apbridgea_hdr hdr;
__le64 timestamp;
} __packed;
struct audio_apbridgea_stop_tx_request {
struct audio_apbridgea_hdr hdr;
} __packed;
struct audio_apbridgea_shutdown_tx_request {
struct audio_apbridgea_hdr hdr;
} __packed;
struct audio_apbridgea_set_rx_data_size_request {
struct audio_apbridgea_hdr hdr;
__le16 size;
} __packed;
struct audio_apbridgea_prepare_rx_request {
struct audio_apbridgea_hdr hdr;
} __packed;
struct audio_apbridgea_start_rx_request {
struct audio_apbridgea_hdr hdr;
} __packed;
struct audio_apbridgea_stop_rx_request {
struct audio_apbridgea_hdr hdr;
} __packed;
struct audio_apbridgea_shutdown_rx_request {
struct audio_apbridgea_hdr hdr;
} __packed;
#endif /*__AUDIO_APBRIDGEA_H */
This diff is collapsed.
/*
* Greybus audio driver
* Copyright 2015 Google Inc.
* Copyright 2015 Linaro Ltd.
*
* Released under the GPLv2 only.
*/
#ifndef __LINUX_GBAUDIO_CODEC_H
#define __LINUX_GBAUDIO_CODEC_H
#include <sound/soc.h>
#include <sound/jack.h>
#include "greybus.h"
#include "greybus_protocols.h"
#define NAME_SIZE 32
#define MAX_DAIS 2 /* APB1, APB2 */
enum {
APB1_PCM = 0,
APB2_PCM,
NUM_CODEC_DAIS,
};
enum gbcodec_reg_index {
GBCODEC_CTL_REG,
GBCODEC_MUTE_REG,
GBCODEC_PB_LVOL_REG,
GBCODEC_PB_RVOL_REG,
GBCODEC_CAP_LVOL_REG,
GBCODEC_CAP_RVOL_REG,
GBCODEC_APB1_MUX_REG,
GBCODEC_APB2_MUX_REG,
GBCODEC_REG_COUNT
};
/* device_type should be same as defined in audio.h (Android media layer) */
enum {
GBAUDIO_DEVICE_NONE = 0x0,
/* reserved bits */
GBAUDIO_DEVICE_BIT_IN = 0x80000000,
GBAUDIO_DEVICE_BIT_DEFAULT = 0x40000000,
/* output devices */
GBAUDIO_DEVICE_OUT_SPEAKER = 0x2,
GBAUDIO_DEVICE_OUT_WIRED_HEADSET = 0x4,
GBAUDIO_DEVICE_OUT_WIRED_HEADPHONE = 0x8,
/* input devices */
GBAUDIO_DEVICE_IN_BUILTIN_MIC = GBAUDIO_DEVICE_BIT_IN | 0x4,
GBAUDIO_DEVICE_IN_WIRED_HEADSET = GBAUDIO_DEVICE_BIT_IN | 0x10,
};
/* bit 0-SPK, 1-HP, 2-DAC,
* 4-MIC, 5-HSMIC, 6-MIC2
*/
#define GBCODEC_CTL_REG_DEFAULT 0x00
/* bit 0,1 - APB1-PB-L/R
* bit 2,3 - APB2-PB-L/R
* bit 4,5 - APB1-Cap-L/R
* bit 6,7 - APB2-Cap-L/R
*/
#define GBCODEC_MUTE_REG_DEFAULT 0x00
/* 0-127 steps */
#define GBCODEC_PB_VOL_REG_DEFAULT 0x00
#define GBCODEC_CAP_VOL_REG_DEFAULT 0x00
/* bit 0,1,2 - PB stereo, left, right
* bit 8,9,10 - Cap stereo, left, right
*/
#define GBCODEC_APB1_MUX_REG_DEFAULT 0x00
#define GBCODEC_APB2_MUX_REG_DEFAULT 0x00
#define GBCODEC_JACK_MASK 0x0000FFFF
#define GBCODEC_JACK_BUTTON_MASK 0xFFFF0000
static const u8 gbcodec_reg_defaults[GBCODEC_REG_COUNT] = {
GBCODEC_CTL_REG_DEFAULT,
GBCODEC_MUTE_REG_DEFAULT,
GBCODEC_PB_VOL_REG_DEFAULT,
GBCODEC_PB_VOL_REG_DEFAULT,
GBCODEC_CAP_VOL_REG_DEFAULT,
GBCODEC_CAP_VOL_REG_DEFAULT,
GBCODEC_APB1_MUX_REG_DEFAULT,
GBCODEC_APB2_MUX_REG_DEFAULT,
};
enum gbaudio_codec_state {
GBAUDIO_CODEC_SHUTDOWN = 0,
GBAUDIO_CODEC_STARTUP,
GBAUDIO_CODEC_HWPARAMS,
GBAUDIO_CODEC_PREPARE,
GBAUDIO_CODEC_START,
GBAUDIO_CODEC_STOP,
};
struct gbaudio_stream_params {
int state;
uint8_t sig_bits, channels;
uint32_t format, rate;
};
struct gbaudio_codec_dai {
int id;
/* runtime params for playback/capture streams */
struct gbaudio_stream_params params[2];
struct list_head list;
};
struct gbaudio_codec_info {
struct device *dev;
struct snd_soc_codec *codec;
struct list_head module_list;
/* to maintain runtime stream params for each DAI */
struct list_head dai_list;
struct mutex lock;
u8 reg[GBCODEC_REG_COUNT];
};
struct gbaudio_widget {
__u8 id;
const char *name;
struct list_head list;
};
struct gbaudio_control {
__u8 id;
char *name;
char *wname;
const char * const *texts;
int items;
struct list_head list;
};
struct gbaudio_data_connection {
int id;
__le16 data_cport;
struct gb_connection *connection;
struct list_head list;
/* maintain runtime state for playback/capture stream */
int state[2];
};
/* stream direction */
#define GB_PLAYBACK BIT(0)
#define GB_CAPTURE BIT(1)
enum gbaudio_module_state {
GBAUDIO_MODULE_OFF = 0,
GBAUDIO_MODULE_ON,
};
struct gbaudio_module_info {
/* module info */
struct device *dev;
int dev_id; /* check if it should be bundle_id/hd_cport_id */
int vid;
int pid;
int slot;
int type;
int set_uevent;
char vstr[NAME_SIZE];
char pstr[NAME_SIZE];
struct list_head list;
/* need to share this info to above user space */
int manager_id;
char name[NAME_SIZE];
unsigned int ip_devices;
unsigned int op_devices;
/* jack related */
char jack_name[NAME_SIZE];
char button_name[NAME_SIZE];
int jack_type;
int jack_mask;
int button_mask;
int button_status;
struct snd_soc_jack headset_jack;
struct snd_soc_jack button_jack;
/* connection info */
struct gb_connection *mgmt_connection;
size_t num_data_connections;
struct list_head data_list;
/* topology related */
int num_dais;
int num_controls;
int num_dapm_widgets;
int num_dapm_routes;
unsigned long dai_offset;
unsigned long widget_offset;
unsigned long control_offset;
unsigned long route_offset;
struct snd_kcontrol_new *controls;
struct snd_soc_dapm_widget *dapm_widgets;
struct snd_soc_dapm_route *dapm_routes;
struct snd_soc_dai_driver *dais;
struct list_head widget_list;
struct list_head ctl_list;
struct list_head widget_ctl_list;
struct gb_audio_topology *topology;
};
int gbaudio_tplg_parse_data(struct gbaudio_module_info *module,
struct gb_audio_topology *tplg_data);
void gbaudio_tplg_release(struct gbaudio_module_info *module);
int gbaudio_module_update(struct gbaudio_codec_info *codec,
struct snd_soc_dapm_widget *w,
struct gbaudio_module_info *module,
int enable);
int gbaudio_register_module(struct gbaudio_module_info *module);
void gbaudio_unregister_module(struct gbaudio_module_info *module);
/* protocol related */
extern int gb_audio_gb_get_topology(struct gb_connection *connection,
struct gb_audio_topology **topology);
extern int gb_audio_gb_get_control(struct gb_connection *connection,
uint8_t control_id, uint8_t index,
struct gb_audio_ctl_elem_value *value);
extern int gb_audio_gb_set_control(struct gb_connection *connection,
uint8_t control_id, uint8_t index,
struct gb_audio_ctl_elem_value *value);
extern int gb_audio_gb_enable_widget(struct gb_connection *connection,
uint8_t widget_id);
extern int gb_audio_gb_disable_widget(struct gb_connection *connection,
uint8_t widget_id);
extern int gb_audio_gb_get_pcm(struct gb_connection *connection,
uint16_t data_cport, uint32_t *format,
uint32_t *rate, uint8_t *channels,
uint8_t *sig_bits);
extern int gb_audio_gb_set_pcm(struct gb_connection *connection,
uint16_t data_cport, uint32_t format,
uint32_t rate, uint8_t channels,
uint8_t sig_bits);
extern int gb_audio_gb_set_tx_data_size(struct gb_connection *connection,
uint16_t data_cport, uint16_t size);
extern int gb_audio_gb_activate_tx(struct gb_connection *connection,
uint16_t data_cport);
extern int gb_audio_gb_deactivate_tx(struct gb_connection *connection,
uint16_t data_cport);
extern int gb_audio_gb_set_rx_data_size(struct gb_connection *connection,
uint16_t data_cport, uint16_t size);
extern int gb_audio_gb_activate_rx(struct gb_connection *connection,
uint16_t data_cport);
extern int gb_audio_gb_deactivate_rx(struct gb_connection *connection,
uint16_t data_cport);
extern int gb_audio_apbridgea_set_config(struct gb_connection *connection,
__u16 i2s_port, __u32 format,
__u32 rate, __u32 mclk_freq);
extern int gb_audio_apbridgea_register_cport(struct gb_connection *connection,
__u16 i2s_port, __u16 cportid,
__u8 direction);
extern int gb_audio_apbridgea_unregister_cport(struct gb_connection *connection,
__u16 i2s_port, __u16 cportid,
__u8 direction);
extern int gb_audio_apbridgea_set_tx_data_size(struct gb_connection *connection,
__u16 i2s_port, __u16 size);
extern int gb_audio_apbridgea_prepare_tx(struct gb_connection *connection,
__u16 i2s_port);
extern int gb_audio_apbridgea_start_tx(struct gb_connection *connection,
__u16 i2s_port, __u64 timestamp);
extern int gb_audio_apbridgea_stop_tx(struct gb_connection *connection,
__u16 i2s_port);
extern int gb_audio_apbridgea_shutdown_tx(struct gb_connection *connection,
__u16 i2s_port);
extern int gb_audio_apbridgea_set_rx_data_size(struct gb_connection *connection,
__u16 i2s_port, __u16 size);
extern int gb_audio_apbridgea_prepare_rx(struct gb_connection *connection,
__u16 i2s_port);
extern int gb_audio_apbridgea_start_rx(struct gb_connection *connection,
__u16 i2s_port);
extern int gb_audio_apbridgea_stop_rx(struct gb_connection *connection,
__u16 i2s_port);
extern int gb_audio_apbridgea_shutdown_rx(struct gb_connection *connection,
__u16 i2s_port);
#endif /* __LINUX_GBAUDIO_CODEC_H */
/*
* Greybus Audio Device Class Protocol helpers
*
* Copyright 2015-2016 Google Inc.
*
* Released under the GPLv2 only.
*/
#include "greybus.h"
#include "greybus_protocols.h"
#include "operation.h"
#include "audio_codec.h"
/* TODO: Split into separate calls */
int gb_audio_gb_get_topology(struct gb_connection *connection,
struct gb_audio_topology **topology)
{
struct gb_audio_get_topology_size_response size_resp;
struct gb_audio_topology *topo;
uint16_t size;
int ret;
ret = gb_operation_sync(connection, GB_AUDIO_TYPE_GET_TOPOLOGY_SIZE,
NULL, 0, &size_resp, sizeof(size_resp));
if (ret)
return ret;
size = le16_to_cpu(size_resp.size);
if (size < sizeof(*topo))
return -ENODATA;
topo = kzalloc(size, GFP_KERNEL);
if (!topo)
return -ENOMEM;
ret = gb_operation_sync(connection, GB_AUDIO_TYPE_GET_TOPOLOGY, NULL, 0,
topo, size);
if (ret) {
kfree(topo);
return ret;
}
*topology = topo;
return 0;
}
EXPORT_SYMBOL_GPL(gb_audio_gb_get_topology);
int gb_audio_gb_get_control(struct gb_connection *connection,
uint8_t control_id, uint8_t index,
struct gb_audio_ctl_elem_value *value)
{
struct gb_audio_get_control_request req;
struct gb_audio_get_control_response resp;
int ret;
req.control_id = control_id;
req.index = index;
ret = gb_operation_sync(connection, GB_AUDIO_TYPE_GET_CONTROL,
&req, sizeof(req), &resp, sizeof(resp));
if (ret)
return ret;
memcpy(value, &resp.value, sizeof(*value));
return 0;
}
EXPORT_SYMBOL_GPL(gb_audio_gb_get_control);
int gb_audio_gb_set_control(struct gb_connection *connection,
uint8_t control_id, uint8_t index,
struct gb_audio_ctl_elem_value *value)
{
struct gb_audio_set_control_request req;
req.control_id = control_id;
req.index = index;
memcpy(&req.value, value, sizeof(req.value));
return gb_operation_sync(connection, GB_AUDIO_TYPE_SET_CONTROL,
&req, sizeof(req), NULL, 0);
}
EXPORT_SYMBOL_GPL(gb_audio_gb_set_control);
int gb_audio_gb_enable_widget(struct gb_connection *connection,
uint8_t widget_id)
{
struct gb_audio_enable_widget_request req;
req.widget_id = widget_id;
return gb_operation_sync(connection, GB_AUDIO_TYPE_ENABLE_WIDGET,
&req, sizeof(req), NULL, 0);
}
EXPORT_SYMBOL_GPL(gb_audio_gb_enable_widget);
int gb_audio_gb_disable_widget(struct gb_connection *connection,
uint8_t widget_id)
{
struct gb_audio_disable_widget_request req;
req.widget_id = widget_id;
return gb_operation_sync(connection, GB_AUDIO_TYPE_DISABLE_WIDGET,
&req, sizeof(req), NULL, 0);
}
EXPORT_SYMBOL_GPL(gb_audio_gb_disable_widget);
int gb_audio_gb_get_pcm(struct gb_connection *connection, uint16_t data_cport,
uint32_t *format, uint32_t *rate, uint8_t *channels,
uint8_t *sig_bits)
{
struct gb_audio_get_pcm_request req;
struct gb_audio_get_pcm_response resp;
int ret;
req.data_cport = cpu_to_le16(data_cport);
ret = gb_operation_sync(connection, GB_AUDIO_TYPE_GET_PCM,
&req, sizeof(req), &resp, sizeof(resp));
if (ret)
return ret;
*format = le32_to_cpu(resp.format);
*rate = le32_to_cpu(resp.rate);
*channels = resp.channels;
*sig_bits = resp.sig_bits;
return 0;
}
EXPORT_SYMBOL_GPL(gb_audio_gb_get_pcm);
int gb_audio_gb_set_pcm(struct gb_connection *connection, uint16_t data_cport,
uint32_t format, uint32_t rate, uint8_t channels,
uint8_t sig_bits)
{
struct gb_audio_set_pcm_request req;
req.data_cport = cpu_to_le16(data_cport);
req.format = cpu_to_le32(format);
req.rate = cpu_to_le32(rate);
req.channels = channels;
req.sig_bits = sig_bits;
return gb_operation_sync(connection, GB_AUDIO_TYPE_SET_PCM,
&req, sizeof(req), NULL, 0);
}
EXPORT_SYMBOL_GPL(gb_audio_gb_set_pcm);
int gb_audio_gb_set_tx_data_size(struct gb_connection *connection,
uint16_t data_cport, uint16_t size)
{
struct gb_audio_set_tx_data_size_request req;
req.data_cport = cpu_to_le16(data_cport);
req.size = cpu_to_le16(size);
return gb_operation_sync(connection, GB_AUDIO_TYPE_SET_TX_DATA_SIZE,
&req, sizeof(req), NULL, 0);
}
EXPORT_SYMBOL_GPL(gb_audio_gb_set_tx_data_size);
int gb_audio_gb_activate_tx(struct gb_connection *connection,
uint16_t data_cport)
{
struct gb_audio_activate_tx_request req;
req.data_cport = cpu_to_le16(data_cport);
return gb_operation_sync(connection, GB_AUDIO_TYPE_ACTIVATE_TX,
&req, sizeof(req), NULL, 0);
}
EXPORT_SYMBOL_GPL(gb_audio_gb_activate_tx);
int gb_audio_gb_deactivate_tx(struct gb_connection *connection,
uint16_t data_cport)
{
struct gb_audio_deactivate_tx_request req;
req.data_cport = cpu_to_le16(data_cport);
return gb_operation_sync(connection, GB_AUDIO_TYPE_DEACTIVATE_TX,
&req, sizeof(req), NULL, 0);
}
EXPORT_SYMBOL_GPL(gb_audio_gb_deactivate_tx);
int gb_audio_gb_set_rx_data_size(struct gb_connection *connection,
uint16_t data_cport, uint16_t size)
{
struct gb_audio_set_rx_data_size_request req;
req.data_cport = cpu_to_le16(data_cport);
req.size = cpu_to_le16(size);
return gb_operation_sync(connection, GB_AUDIO_TYPE_SET_RX_DATA_SIZE,
&req, sizeof(req), NULL, 0);
}
EXPORT_SYMBOL_GPL(gb_audio_gb_set_rx_data_size);
int gb_audio_gb_activate_rx(struct gb_connection *connection,
uint16_t data_cport)
{
struct gb_audio_activate_rx_request req;
req.data_cport = cpu_to_le16(data_cport);
return gb_operation_sync(connection, GB_AUDIO_TYPE_ACTIVATE_RX,
&req, sizeof(req), NULL, 0);
}
EXPORT_SYMBOL_GPL(gb_audio_gb_activate_rx);
int gb_audio_gb_deactivate_rx(struct gb_connection *connection,
uint16_t data_cport)
{
struct gb_audio_deactivate_rx_request req;
req.data_cport = cpu_to_le16(data_cport);
return gb_operation_sync(connection, GB_AUDIO_TYPE_DEACTIVATE_RX,
&req, sizeof(req), NULL, 0);
}
EXPORT_SYMBOL_GPL(gb_audio_gb_deactivate_rx);
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("greybus:audio-gb");
MODULE_DESCRIPTION("Greybus Audio Device Class Protocol library");
MODULE_AUTHOR("Mark Greer <mgreer@animalcreek.com>");
This diff is collapsed.
/*
* Greybus operations
*
* Copyright 2015-2016 Google Inc.
*
* Released under the GPLv2 only.
*/
#ifndef _GB_AUDIO_MANAGER_H_
#define _GB_AUDIO_MANAGER_H_
#include <linux/kobject.h>
#include <linux/list.h>
#define GB_AUDIO_MANAGER_NAME "gb_audio_manager"
#define GB_AUDIO_MANAGER_MODULE_NAME_LEN 64
#define GB_AUDIO_MANAGER_MODULE_NAME_LEN_SSCANF "63"
struct gb_audio_manager_module_descriptor {
char name[GB_AUDIO_MANAGER_MODULE_NAME_LEN];
int slot;
int vid;
int pid;
int cport;
unsigned int ip_devices;
unsigned int op_devices;
};
struct gb_audio_manager_module {
struct kobject kobj;
struct list_head list;
int id;
struct gb_audio_manager_module_descriptor desc;
};
/*
* Creates a new gb_audio_manager_module_descriptor, using the specified
* descriptor.
*
* Returns a negative result on error, or the id of the newly created module.
*
*/
int gb_audio_manager_add(struct gb_audio_manager_module_descriptor *desc);
/*
* Removes a connected gb_audio_manager_module_descriptor for the specified ID.
*
* Returns zero on success, or a negative value on error.
*/
int gb_audio_manager_remove(int id);
/*
* Removes all connected gb_audio_modules
*
* Returns zero on success, or a negative value on error.
*/
void gb_audio_manager_remove_all(void);
/*
* Retrieves a gb_audio_manager_module_descriptor for the specified id.
* Returns the gb_audio_manager_module_descriptor structure,
* or NULL if there is no module with the specified ID.
*/
struct gb_audio_manager_module *gb_audio_manager_get_module(int id);
/*
* Decreases the refcount of the module, obtained by the get function.
* Modules are removed via gb_audio_manager_remove
*/
void gb_audio_manager_put_module(struct gb_audio_manager_module *module);
/*
* Dumps the module for the specified id
* Return 0 on success
*/
int gb_audio_manager_dump_module(int id);
/*
* Dumps all connected modules
*/
void gb_audio_manager_dump_all(void);
#endif /* _GB_AUDIO_MANAGER_H_ */
This diff is collapsed.
/*
* Greybus operations
*
* Copyright 2015-2016 Google Inc.
*
* Released under the GPLv2 only.
*/
#ifndef _GB_AUDIO_MANAGER_PRIVATE_H_
#define _GB_AUDIO_MANAGER_PRIVATE_H_
#include <linux/kobject.h>
#include "audio_manager.h"
int gb_audio_manager_module_create(
struct gb_audio_manager_module **module,
struct kset *manager_kset,
int id, struct gb_audio_manager_module_descriptor *desc);
/* module destroyed via kobject_put */
void gb_audio_manager_module_dump(struct gb_audio_manager_module *module);
/* sysfs control */
void gb_audio_manager_sysfs_init(struct kobject *kobj);
#endif /* _GB_AUDIO_MANAGER_PRIVATE_H_ */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* FIXME
* move this to include/linux/mod_devicetable.h when merging
*/
#ifndef __LINUX_GREYBUS_ID_H
#define __LINUX_GREYBUS_ID_H
#include <linux/types.h>
#include <linux/mod_devicetable.h>
struct greybus_bundle_id {
__u16 match_flags;
__u32 vendor;
__u32 product;
__u8 class;
kernel_ulong_t driver_info __aligned(sizeof(kernel_ulong_t));
};
/* Used to match the greybus_bundle_id */
#define GREYBUS_ID_MATCH_VENDOR BIT(0)
#define GREYBUS_ID_MATCH_PRODUCT BIT(1)
#define GREYBUS_ID_MATCH_CLASS BIT(2)
#endif /* __LINUX_GREYBUS_ID_H */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment