aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-02-01 13:31:17 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2018-02-01 13:31:17 -0500
commitf6cff79f1d122f78a4b35bf4b2f0112afcd89ea4 (patch)
treecf3a38576f9adbb3860982c25f72aebed2bb541a /include/linux
parent47fcc0360cfb3fe82e4daddacad3c1cd80b0b75d (diff)
parent9ff6576e124b1227c27c1da43fe5f8ee908263e0 (diff)
Merge tag 'char-misc-4.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc driver updates from Greg KH: "Here is the big pull request for char/misc drivers for 4.16-rc1. There's a lot of stuff in here. Three new driver subsystems were added for various types of hardware busses: - siox - slimbus - soundwire as well as a new vboxguest subsystem for the VirtualBox hypervisor drivers. There's also big updates from the FPGA subsystem, lots of Android binder fixes, the usual handful of hyper-v updates, and lots of other smaller driver updates. All of these have been in linux-next for a long time, with no reported issues" * tag 'char-misc-4.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (155 commits) char: lp: use true or false for boolean values android: binder: use VM_ALLOC to get vm area android: binder: Use true and false for boolean values lkdtm: fix handle_irq_event symbol for INT_HW_IRQ_EN EISA: Delete error message for a failed memory allocation in eisa_probe() EISA: Whitespace cleanup misc: remove AVR32 dependencies virt: vbox: Add error mapping for VERR_INVALID_NAME and VERR_NO_MORE_FILES soundwire: Fix a signedness bug uio_hv_generic: fix new type mismatch warnings uio_hv_generic: fix type mismatch warnings auxdisplay: img-ascii-lcd: add missing MODULE_DESCRIPTION/AUTHOR/LICENSE uio_hv_generic: add rescind support uio_hv_generic: check that host supports monitor page uio_hv_generic: create send and receive buffers uio: document uio_hv_generic regions doc: fix documentation about uio_hv_generic vmbus: add monitor_id and subchannel_id to sysfs per channel vmbus: fix ABI documentation uio_hv_generic: use ISR callback method ...
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/fpga/fpga-bridge.h14
-rw-r--r--include/linux/fpga/fpga-mgr.h39
-rw-r--r--include/linux/fpga/fpga-region.h40
-rw-r--r--include/linux/i7300_idle.h84
-rw-r--r--include/linux/mod_devicetable.h19
-rw-r--r--include/linux/mux/consumer.h5
-rw-r--r--include/linux/mux/driver.h5
-rw-r--r--include/linux/regmap.h18
-rw-r--r--include/linux/siox.h77
-rw-r--r--include/linux/slimbus.h164
-rw-r--r--include/linux/soundwire/sdw.h479
-rw-r--r--include/linux/soundwire/sdw_intel.h24
-rw-r--r--include/linux/soundwire/sdw_registers.h194
-rw-r--r--include/linux/soundwire/sdw_type.h19
-rw-r--r--include/linux/vbox_utils.h79
15 files changed, 1154 insertions, 106 deletions
diff --git a/include/linux/fpga/fpga-bridge.h b/include/linux/fpga/fpga-bridge.h
index aa66c87c120b..3694821a6d2d 100644
--- a/include/linux/fpga/fpga-bridge.h
+++ b/include/linux/fpga/fpga-bridge.h
@@ -1,10 +1,11 @@
1/* SPDX-License-Identifier: GPL-2.0 */ 1/* SPDX-License-Identifier: GPL-2.0 */
2#include <linux/device.h>
3#include <linux/fpga/fpga-mgr.h>
4 2
5#ifndef _LINUX_FPGA_BRIDGE_H 3#ifndef _LINUX_FPGA_BRIDGE_H
6#define _LINUX_FPGA_BRIDGE_H 4#define _LINUX_FPGA_BRIDGE_H
7 5
6#include <linux/device.h>
7#include <linux/fpga/fpga-mgr.h>
8
8struct fpga_bridge; 9struct fpga_bridge;
9 10
10/** 11/**
@@ -12,11 +13,13 @@ struct fpga_bridge;
12 * @enable_show: returns the FPGA bridge's status 13 * @enable_show: returns the FPGA bridge's status
13 * @enable_set: set a FPGA bridge as enabled or disabled 14 * @enable_set: set a FPGA bridge as enabled or disabled
14 * @fpga_bridge_remove: set FPGA into a specific state during driver remove 15 * @fpga_bridge_remove: set FPGA into a specific state during driver remove
16 * @groups: optional attribute groups.
15 */ 17 */
16struct fpga_bridge_ops { 18struct fpga_bridge_ops {
17 int (*enable_show)(struct fpga_bridge *bridge); 19 int (*enable_show)(struct fpga_bridge *bridge);
18 int (*enable_set)(struct fpga_bridge *bridge, bool enable); 20 int (*enable_set)(struct fpga_bridge *bridge, bool enable);
19 void (*fpga_bridge_remove)(struct fpga_bridge *bridge); 21 void (*fpga_bridge_remove)(struct fpga_bridge *bridge);
22 const struct attribute_group **groups;
20}; 23};
21 24
22/** 25/**
@@ -43,6 +46,8 @@ struct fpga_bridge {
43 46
44struct fpga_bridge *of_fpga_bridge_get(struct device_node *node, 47struct fpga_bridge *of_fpga_bridge_get(struct device_node *node,
45 struct fpga_image_info *info); 48 struct fpga_image_info *info);
49struct fpga_bridge *fpga_bridge_get(struct device *dev,
50 struct fpga_image_info *info);
46void fpga_bridge_put(struct fpga_bridge *bridge); 51void fpga_bridge_put(struct fpga_bridge *bridge);
47int fpga_bridge_enable(struct fpga_bridge *bridge); 52int fpga_bridge_enable(struct fpga_bridge *bridge);
48int fpga_bridge_disable(struct fpga_bridge *bridge); 53int fpga_bridge_disable(struct fpga_bridge *bridge);
@@ -50,9 +55,12 @@ int fpga_bridge_disable(struct fpga_bridge *bridge);
50int fpga_bridges_enable(struct list_head *bridge_list); 55int fpga_bridges_enable(struct list_head *bridge_list);
51int fpga_bridges_disable(struct list_head *bridge_list); 56int fpga_bridges_disable(struct list_head *bridge_list);
52void fpga_bridges_put(struct list_head *bridge_list); 57void fpga_bridges_put(struct list_head *bridge_list);
53int fpga_bridge_get_to_list(struct device_node *np, 58int fpga_bridge_get_to_list(struct device *dev,
54 struct fpga_image_info *info, 59 struct fpga_image_info *info,
55 struct list_head *bridge_list); 60 struct list_head *bridge_list);
61int of_fpga_bridge_get_to_list(struct device_node *np,
62 struct fpga_image_info *info,
63 struct list_head *bridge_list);
56 64
57int fpga_bridge_register(struct device *dev, const char *name, 65int fpga_bridge_register(struct device *dev, const char *name,
58 const struct fpga_bridge_ops *br_ops, void *priv); 66 const struct fpga_bridge_ops *br_ops, void *priv);
diff --git a/include/linux/fpga/fpga-mgr.h b/include/linux/fpga/fpga-mgr.h
index bfa14bc023fb..3c6de23aabdf 100644
--- a/include/linux/fpga/fpga-mgr.h
+++ b/include/linux/fpga/fpga-mgr.h
@@ -1,7 +1,8 @@
1/* 1/*
2 * FPGA Framework 2 * FPGA Framework
3 * 3 *
4 * Copyright (C) 2013-2015 Altera Corporation 4 * Copyright (C) 2013-2016 Altera Corporation
5 * Copyright (C) 2017 Intel Corporation
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify it 7 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License, 8 * under the terms and conditions of the GNU General Public License,
@@ -15,12 +16,12 @@
15 * You should have received a copy of the GNU General Public License along with 16 * You should have received a copy of the GNU General Public License along with
16 * this program. If not, see <http://www.gnu.org/licenses/>. 17 * this program. If not, see <http://www.gnu.org/licenses/>.
17 */ 18 */
18#include <linux/mutex.h>
19#include <linux/platform_device.h>
20
21#ifndef _LINUX_FPGA_MGR_H 19#ifndef _LINUX_FPGA_MGR_H
22#define _LINUX_FPGA_MGR_H 20#define _LINUX_FPGA_MGR_H
23 21
22#include <linux/mutex.h>
23#include <linux/platform_device.h>
24
24struct fpga_manager; 25struct fpga_manager;
25struct sg_table; 26struct sg_table;
26 27
@@ -83,12 +84,26 @@ enum fpga_mgr_states {
83 * @disable_timeout_us: maximum time to disable traffic through bridge (uSec) 84 * @disable_timeout_us: maximum time to disable traffic through bridge (uSec)
84 * @config_complete_timeout_us: maximum time for FPGA to switch to operating 85 * @config_complete_timeout_us: maximum time for FPGA to switch to operating
85 * status in the write_complete op. 86 * status in the write_complete op.
87 * @firmware_name: name of FPGA image firmware file
88 * @sgt: scatter/gather table containing FPGA image
89 * @buf: contiguous buffer containing FPGA image
90 * @count: size of buf
91 * @dev: device that owns this
92 * @overlay: Device Tree overlay
86 */ 93 */
87struct fpga_image_info { 94struct fpga_image_info {
88 u32 flags; 95 u32 flags;
89 u32 enable_timeout_us; 96 u32 enable_timeout_us;
90 u32 disable_timeout_us; 97 u32 disable_timeout_us;
91 u32 config_complete_timeout_us; 98 u32 config_complete_timeout_us;
99 char *firmware_name;
100 struct sg_table *sgt;
101 const char *buf;
102 size_t count;
103 struct device *dev;
104#ifdef CONFIG_OF
105 struct device_node *overlay;
106#endif
92}; 107};
93 108
94/** 109/**
@@ -100,6 +115,7 @@ struct fpga_image_info {
100 * @write_sg: write the scatter list of configuration data to the FPGA 115 * @write_sg: write the scatter list of configuration data to the FPGA
101 * @write_complete: set FPGA to operating state after writing is done 116 * @write_complete: set FPGA to operating state after writing is done
102 * @fpga_remove: optional: Set FPGA into a specific state during driver remove 117 * @fpga_remove: optional: Set FPGA into a specific state during driver remove
118 * @groups: optional attribute groups.
103 * 119 *
104 * fpga_manager_ops are the low level functions implemented by a specific 120 * fpga_manager_ops are the low level functions implemented by a specific
105 * fpga manager driver. The optional ones are tested for NULL before being 121 * fpga manager driver. The optional ones are tested for NULL before being
@@ -116,6 +132,7 @@ struct fpga_manager_ops {
116 int (*write_complete)(struct fpga_manager *mgr, 132 int (*write_complete)(struct fpga_manager *mgr,
117 struct fpga_image_info *info); 133 struct fpga_image_info *info);
118 void (*fpga_remove)(struct fpga_manager *mgr); 134 void (*fpga_remove)(struct fpga_manager *mgr);
135 const struct attribute_group **groups;
119}; 136};
120 137
121/** 138/**
@@ -138,14 +155,14 @@ struct fpga_manager {
138 155
139#define to_fpga_manager(d) container_of(d, struct fpga_manager, dev) 156#define to_fpga_manager(d) container_of(d, struct fpga_manager, dev)
140 157
141int fpga_mgr_buf_load(struct fpga_manager *mgr, struct fpga_image_info *info, 158struct fpga_image_info *fpga_image_info_alloc(struct device *dev);
142 const char *buf, size_t count); 159
143int fpga_mgr_buf_load_sg(struct fpga_manager *mgr, struct fpga_image_info *info, 160void fpga_image_info_free(struct fpga_image_info *info);
144 struct sg_table *sgt); 161
162int fpga_mgr_load(struct fpga_manager *mgr, struct fpga_image_info *info);
145 163
146int fpga_mgr_firmware_load(struct fpga_manager *mgr, 164int fpga_mgr_lock(struct fpga_manager *mgr);
147 struct fpga_image_info *info, 165void fpga_mgr_unlock(struct fpga_manager *mgr);
148 const char *image_name);
149 166
150struct fpga_manager *of_fpga_mgr_get(struct device_node *node); 167struct fpga_manager *of_fpga_mgr_get(struct device_node *node);
151 168
diff --git a/include/linux/fpga/fpga-region.h b/include/linux/fpga/fpga-region.h
new file mode 100644
index 000000000000..b6520318ab9c
--- /dev/null
+++ b/include/linux/fpga/fpga-region.h
@@ -0,0 +1,40 @@
1#ifndef _FPGA_REGION_H
2#define _FPGA_REGION_H
3
4#include <linux/device.h>
5#include <linux/fpga/fpga-mgr.h>
6#include <linux/fpga/fpga-bridge.h>
7
8/**
9 * struct fpga_region - FPGA Region structure
10 * @dev: FPGA Region device
11 * @mutex: enforces exclusive reference to region
12 * @bridge_list: list of FPGA bridges specified in region
13 * @mgr: FPGA manager
14 * @info: FPGA image info
15 * @priv: private data
16 * @get_bridges: optional function to get bridges to a list
17 * @groups: optional attribute groups.
18 */
19struct fpga_region {
20 struct device dev;
21 struct mutex mutex; /* for exclusive reference to region */
22 struct list_head bridge_list;
23 struct fpga_manager *mgr;
24 struct fpga_image_info *info;
25 void *priv;
26 int (*get_bridges)(struct fpga_region *region);
27 const struct attribute_group **groups;
28};
29
30#define to_fpga_region(d) container_of(d, struct fpga_region, dev)
31
32struct fpga_region *fpga_region_class_find(
33 struct device *start, const void *data,
34 int (*match)(struct device *, const void *));
35
36int fpga_region_program_fpga(struct fpga_region *region);
37int fpga_region_register(struct device *dev, struct fpga_region *region);
38int fpga_region_unregister(struct fpga_region *region);
39
40#endif /* _FPGA_REGION_H */
diff --git a/include/linux/i7300_idle.h b/include/linux/i7300_idle.h
deleted file mode 100644
index 4dbe651f71f5..000000000000
--- a/include/linux/i7300_idle.h
+++ /dev/null
@@ -1,84 +0,0 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2
3#ifndef I7300_IDLE_H
4#define I7300_IDLE_H
5
6#include <linux/pci.h>
7
8/*
9 * I/O AT controls (PCI bus 0 device 8 function 0)
10 * DIMM controls (PCI bus 0 device 16 function 1)
11 */
12#define IOAT_BUS 0
13#define IOAT_DEVFN PCI_DEVFN(8, 0)
14#define MEMCTL_BUS 0
15#define MEMCTL_DEVFN PCI_DEVFN(16, 1)
16
17struct fbd_ioat {
18 unsigned int vendor;
19 unsigned int ioat_dev;
20 unsigned int enabled;
21};
22
23/*
24 * The i5000 chip-set has the same hooks as the i7300
25 * but it is not enabled by default and must be manually
26 * manually enabled with "forceload=1" because it is
27 * only lightly validated.
28 */
29
30static const struct fbd_ioat fbd_ioat_list[] = {
31 {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_IOAT_CNB, 1},
32 {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_IOAT, 0},
33 {0, 0}
34};
35
36/* table of devices that work with this driver */
37static const struct pci_device_id pci_tbl[] = {
38 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_FBD_CNB) },
39 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_5000_ERR) },
40 { } /* Terminating entry */
41};
42
43/* Check for known platforms with I/O-AT */
44static inline int i7300_idle_platform_probe(struct pci_dev **fbd_dev,
45 struct pci_dev **ioat_dev,
46 int enable_all)
47{
48 int i;
49 struct pci_dev *memdev, *dmadev;
50
51 memdev = pci_get_bus_and_slot(MEMCTL_BUS, MEMCTL_DEVFN);
52 if (!memdev)
53 return -ENODEV;
54
55 for (i = 0; pci_tbl[i].vendor != 0; i++) {
56 if (memdev->vendor == pci_tbl[i].vendor &&
57 memdev->device == pci_tbl[i].device) {
58 break;
59 }
60 }
61 if (pci_tbl[i].vendor == 0)
62 return -ENODEV;
63
64 dmadev = pci_get_bus_and_slot(IOAT_BUS, IOAT_DEVFN);
65 if (!dmadev)
66 return -ENODEV;
67
68 for (i = 0; fbd_ioat_list[i].vendor != 0; i++) {
69 if (dmadev->vendor == fbd_ioat_list[i].vendor &&
70 dmadev->device == fbd_ioat_list[i].ioat_dev) {
71 if (!(fbd_ioat_list[i].enabled || enable_all))
72 continue;
73 if (fbd_dev)
74 *fbd_dev = memdev;
75 if (ioat_dev)
76 *ioat_dev = dmadev;
77
78 return 0;
79 }
80 }
81 return -ENODEV;
82}
83
84#endif
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index abb6dc2ebbf8..48fb2b43c35a 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -229,6 +229,12 @@ struct hda_device_id {
229 unsigned long driver_data; 229 unsigned long driver_data;
230}; 230};
231 231
232struct sdw_device_id {
233 __u16 mfg_id;
234 __u16 part_id;
235 kernel_ulong_t driver_data;
236};
237
232/* 238/*
233 * Struct used for matching a device 239 * Struct used for matching a device
234 */ 240 */
@@ -452,6 +458,19 @@ struct spi_device_id {
452 kernel_ulong_t driver_data; /* Data private to the driver */ 458 kernel_ulong_t driver_data; /* Data private to the driver */
453}; 459};
454 460
461/* SLIMbus */
462
463#define SLIMBUS_NAME_SIZE 32
464#define SLIMBUS_MODULE_PREFIX "slim:"
465
466struct slim_device_id {
467 __u16 manf_id, prod_code;
468 __u16 dev_index, instance;
469
470 /* Data private to the driver */
471 kernel_ulong_t driver_data;
472};
473
455#define SPMI_NAME_SIZE 32 474#define SPMI_NAME_SIZE 32
456#define SPMI_MODULE_PREFIX "spmi:" 475#define SPMI_MODULE_PREFIX "spmi:"
457 476
diff --git a/include/linux/mux/consumer.h b/include/linux/mux/consumer.h
index ea96d4c82be7..5fc6bb2fefad 100644
--- a/include/linux/mux/consumer.h
+++ b/include/linux/mux/consumer.h
@@ -1,13 +1,10 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * mux/consumer.h - definitions for the multiplexer consumer interface 3 * mux/consumer.h - definitions for the multiplexer consumer interface
3 * 4 *
4 * Copyright (C) 2017 Axentia Technologies AB 5 * Copyright (C) 2017 Axentia Technologies AB
5 * 6 *
6 * Author: Peter Rosin <peda@axentia.se> 7 * Author: Peter Rosin <peda@axentia.se>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */ 8 */
12 9
13#ifndef _LINUX_MUX_CONSUMER_H 10#ifndef _LINUX_MUX_CONSUMER_H
diff --git a/include/linux/mux/driver.h b/include/linux/mux/driver.h
index 35c3579c3304..627a2c6bc02d 100644
--- a/include/linux/mux/driver.h
+++ b/include/linux/mux/driver.h
@@ -1,13 +1,10 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * mux/driver.h - definitions for the multiplexer driver interface 3 * mux/driver.h - definitions for the multiplexer driver interface
3 * 4 *
4 * Copyright (C) 2017 Axentia Technologies AB 5 * Copyright (C) 2017 Axentia Technologies AB
5 * 6 *
6 * Author: Peter Rosin <peda@axentia.se> 7 * Author: Peter Rosin <peda@axentia.se>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */ 8 */
12 9
13#ifndef _LINUX_MUX_DRIVER_H 10#ifndef _LINUX_MUX_DRIVER_H
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index 20268b7d5001..6a3aeba40e9e 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -24,6 +24,7 @@ struct module;
24struct device; 24struct device;
25struct i2c_client; 25struct i2c_client;
26struct irq_domain; 26struct irq_domain;
27struct slim_device;
27struct spi_device; 28struct spi_device;
28struct spmi_device; 29struct spmi_device;
29struct regmap; 30struct regmap;
@@ -511,6 +512,10 @@ struct regmap *__regmap_init_i2c(struct i2c_client *i2c,
511 const struct regmap_config *config, 512 const struct regmap_config *config,
512 struct lock_class_key *lock_key, 513 struct lock_class_key *lock_key,
513 const char *lock_name); 514 const char *lock_name);
515struct regmap *__regmap_init_slimbus(struct slim_device *slimbus,
516 const struct regmap_config *config,
517 struct lock_class_key *lock_key,
518 const char *lock_name);
514struct regmap *__regmap_init_spi(struct spi_device *dev, 519struct regmap *__regmap_init_spi(struct spi_device *dev,
515 const struct regmap_config *config, 520 const struct regmap_config *config,
516 struct lock_class_key *lock_key, 521 struct lock_class_key *lock_key,
@@ -636,6 +641,19 @@ int regmap_attach_dev(struct device *dev, struct regmap *map,
636 i2c, config) 641 i2c, config)
637 642
638/** 643/**
644 * regmap_init_slimbus() - Initialise register map
645 *
646 * @slimbus: Device that will be interacted with
647 * @config: Configuration for register map
648 *
649 * The return value will be an ERR_PTR() on error or a valid pointer to
650 * a struct regmap.
651 */
652#define regmap_init_slimbus(slimbus, config) \
653 __regmap_lockdep_wrapper(__regmap_init_slimbus, #config, \
654 slimbus, config)
655
656/**
639 * regmap_init_spi() - Initialise register map 657 * regmap_init_spi() - Initialise register map
640 * 658 *
641 * @dev: Device that will be interacted with 659 * @dev: Device that will be interacted with
diff --git a/include/linux/siox.h b/include/linux/siox.h
new file mode 100644
index 000000000000..d79624e83134
--- /dev/null
+++ b/include/linux/siox.h
@@ -0,0 +1,77 @@
1/*
2 * Copyright (C) 2015 Pengutronix, Uwe Kleine-König <kernel@pengutronix.de>
3 *
4 * This program is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License version 2 as published by the
6 * Free Software Foundation.
7 */
8
9#include <linux/device.h>
10
11#define to_siox_device(_dev) container_of((_dev), struct siox_device, dev)
12struct siox_device {
13 struct list_head node; /* node in smaster->devices */
14 struct siox_master *smaster;
15 struct device dev;
16
17 const char *type;
18 size_t inbytes;
19 size_t outbytes;
20 u8 statustype;
21
22 u8 status_read_clean;
23 u8 status_written;
24 u8 status_written_lastcycle;
25 bool connected;
26
27 /* statistics */
28 unsigned int watchdog_errors;
29 unsigned int status_errors;
30
31 struct kernfs_node *status_errors_kn;
32 struct kernfs_node *watchdog_kn;
33 struct kernfs_node *watchdog_errors_kn;
34 struct kernfs_node *connected_kn;
35};
36
37bool siox_device_synced(struct siox_device *sdevice);
38bool siox_device_connected(struct siox_device *sdevice);
39
40struct siox_driver {
41 int (*probe)(struct siox_device *sdevice);
42 int (*remove)(struct siox_device *sdevice);
43 void (*shutdown)(struct siox_device *sdevice);
44
45 /*
46 * buf is big enough to hold sdev->inbytes - 1 bytes, the status byte
47 * is in the scope of the framework.
48 */
49 int (*set_data)(struct siox_device *sdevice, u8 status, u8 buf[]);
50 /*
51 * buf is big enough to hold sdev->outbytes - 1 bytes, the status byte
52 * is in the scope of the framework
53 */
54 int (*get_data)(struct siox_device *sdevice, const u8 buf[]);
55
56 struct device_driver driver;
57};
58
59static inline struct siox_driver *to_siox_driver(struct device_driver *driver)
60{
61 if (driver)
62 return container_of(driver, struct siox_driver, driver);
63 else
64 return NULL;
65}
66
67int __siox_driver_register(struct siox_driver *sdriver, struct module *owner);
68
69static inline int siox_driver_register(struct siox_driver *sdriver)
70{
71 return __siox_driver_register(sdriver, THIS_MODULE);
72}
73
74static inline void siox_driver_unregister(struct siox_driver *sdriver)
75{
76 return driver_unregister(&sdriver->driver);
77}
diff --git a/include/linux/slimbus.h b/include/linux/slimbus.h
new file mode 100644
index 000000000000..c36cf121d2cd
--- /dev/null
+++ b/include/linux/slimbus.h
@@ -0,0 +1,164 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2011-2017, The Linux Foundation
4 */
5
6#ifndef _LINUX_SLIMBUS_H
7#define _LINUX_SLIMBUS_H
8#include <linux/device.h>
9#include <linux/module.h>
10#include <linux/completion.h>
11#include <linux/mod_devicetable.h>
12
13extern struct bus_type slimbus_bus;
14
15/**
16 * struct slim_eaddr - Enumeration address for a SLIMbus device
17 * @manf_id: Manufacturer Id for the device
18 * @prod_code: Product code
19 * @dev_index: Device index
20 * @instance: Instance value
21 */
22struct slim_eaddr {
23 u16 manf_id;
24 u16 prod_code;
25 u8 dev_index;
26 u8 instance;
27} __packed;
28
29/**
30 * enum slim_device_status - slim device status
31 * @SLIM_DEVICE_STATUS_DOWN: Slim device is absent or not reported yet.
32 * @SLIM_DEVICE_STATUS_UP: Slim device is announced on the bus.
33 * @SLIM_DEVICE_STATUS_RESERVED: Reserved for future use.
34 */
35enum slim_device_status {
36 SLIM_DEVICE_STATUS_DOWN = 0,
37 SLIM_DEVICE_STATUS_UP,
38 SLIM_DEVICE_STATUS_RESERVED,
39};
40
41struct slim_controller;
42
43/**
44 * struct slim_device - Slim device handle.
45 * @dev: Driver model representation of the device.
46 * @e_addr: Enumeration address of this device.
47 * @status: slim device status
48 * @ctrl: slim controller instance.
49 * @laddr: 1-byte Logical address of this device.
50 * @is_laddr_valid: indicates if the laddr is valid or not
51 *
52 * This is the client/device handle returned when a SLIMbus
53 * device is registered with a controller.
54 * Pointer to this structure is used by client-driver as a handle.
55 */
56struct slim_device {
57 struct device dev;
58 struct slim_eaddr e_addr;
59 struct slim_controller *ctrl;
60 enum slim_device_status status;
61 u8 laddr;
62 bool is_laddr_valid;
63};
64
65#define to_slim_device(d) container_of(d, struct slim_device, dev)
66
67/**
68 * struct slim_driver - SLIMbus 'generic device' (slave) device driver
69 * (similar to 'spi_device' on SPI)
70 * @probe: Binds this driver to a SLIMbus device.
71 * @remove: Unbinds this driver from the SLIMbus device.
72 * @shutdown: Standard shutdown callback used during powerdown/halt.
73 * @device_status: This callback is called when
74 * - The device reports present and gets a laddr assigned
75 * - The device reports absent, or the bus goes down.
76 * @driver: SLIMbus device drivers should initialize name and owner field of
77 * this structure
78 * @id_table: List of SLIMbus devices supported by this driver
79 */
80
81struct slim_driver {
82 int (*probe)(struct slim_device *sl);
83 void (*remove)(struct slim_device *sl);
84 void (*shutdown)(struct slim_device *sl);
85 int (*device_status)(struct slim_device *sl,
86 enum slim_device_status s);
87 struct device_driver driver;
88 const struct slim_device_id *id_table;
89};
90#define to_slim_driver(d) container_of(d, struct slim_driver, driver)
91
92/**
93 * struct slim_val_inf - Slimbus value or information element
94 * @start_offset: Specifies starting offset in information/value element map
95 * @rbuf: buffer to read the values
96 * @wbuf: buffer to write
97 * @num_bytes: upto 16. This ensures that the message will fit the slicesize
98 * per SLIMbus spec
99 * @comp: completion for asynchronous operations, valid only if TID is
100 * required for transaction, like REQUEST operations.
101 * Rest of the transactions are synchronous anyway.
102 */
103struct slim_val_inf {
104 u16 start_offset;
105 u8 num_bytes;
106 u8 *rbuf;
107 const u8 *wbuf;
108 struct completion *comp;
109};
110
111/*
112 * use a macro to avoid include chaining to get THIS_MODULE
113 */
114#define slim_driver_register(drv) \
115 __slim_driver_register(drv, THIS_MODULE)
116int __slim_driver_register(struct slim_driver *drv, struct module *owner);
117void slim_driver_unregister(struct slim_driver *drv);
118
119/**
120 * module_slim_driver() - Helper macro for registering a SLIMbus driver
121 * @__slim_driver: slimbus_driver struct
122 *
123 * Helper macro for SLIMbus drivers which do not do anything special in module
124 * init/exit. This eliminates a lot of boilerplate. Each module may only
125 * use this macro once, and calling it replaces module_init() and module_exit()
126 */
127#define module_slim_driver(__slim_driver) \
128 module_driver(__slim_driver, slim_driver_register, \
129 slim_driver_unregister)
130
131static inline void *slim_get_devicedata(const struct slim_device *dev)
132{
133 return dev_get_drvdata(&dev->dev);
134}
135
136static inline void slim_set_devicedata(struct slim_device *dev, void *data)
137{
138 dev_set_drvdata(&dev->dev, data);
139}
140
141struct slim_device *slim_get_device(struct slim_controller *ctrl,
142 struct slim_eaddr *e_addr);
143int slim_get_logical_addr(struct slim_device *sbdev);
144
145/* Information Element management messages */
146#define SLIM_MSG_MC_REQUEST_INFORMATION 0x20
147#define SLIM_MSG_MC_REQUEST_CLEAR_INFORMATION 0x21
148#define SLIM_MSG_MC_REPLY_INFORMATION 0x24
149#define SLIM_MSG_MC_CLEAR_INFORMATION 0x28
150#define SLIM_MSG_MC_REPORT_INFORMATION 0x29
151
152/* Value Element management messages */
153#define SLIM_MSG_MC_REQUEST_VALUE 0x60
154#define SLIM_MSG_MC_REQUEST_CHANGE_VALUE 0x61
155#define SLIM_MSG_MC_REPLY_VALUE 0x64
156#define SLIM_MSG_MC_CHANGE_VALUE 0x68
157
158int slim_xfer_msg(struct slim_device *sbdev, struct slim_val_inf *msg,
159 u8 mc);
160int slim_readb(struct slim_device *sdev, u32 addr);
161int slim_writeb(struct slim_device *sdev, u32 addr, u8 value);
162int slim_read(struct slim_device *sdev, u32 addr, size_t count, u8 *val);
163int slim_write(struct slim_device *sdev, u32 addr, size_t count, u8 *val);
164#endif /* _LINUX_SLIMBUS_H */
diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h
new file mode 100644
index 000000000000..e91fdcf41049
--- /dev/null
+++ b/include/linux/soundwire/sdw.h
@@ -0,0 +1,479 @@
1// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
2// Copyright(c) 2015-17 Intel Corporation.
3
4#ifndef __SOUNDWIRE_H
5#define __SOUNDWIRE_H
6
7struct sdw_bus;
8struct sdw_slave;
9
10/* SDW spec defines and enums, as defined by MIPI 1.1. Spec */
11
12/* SDW Broadcast Device Number */
13#define SDW_BROADCAST_DEV_NUM 15
14
15/* SDW Enumeration Device Number */
16#define SDW_ENUM_DEV_NUM 0
17
18/* SDW Group Device Numbers */
19#define SDW_GROUP12_DEV_NUM 12
20#define SDW_GROUP13_DEV_NUM 13
21
22/* SDW Master Device Number, not supported yet */
23#define SDW_MASTER_DEV_NUM 14
24
25#define SDW_NUM_DEV_ID_REGISTERS 6
26
27#define SDW_MAX_DEVICES 11
28
29/**
30 * enum sdw_slave_status - Slave status
31 * @SDW_SLAVE_UNATTACHED: Slave is not attached with the bus.
32 * @SDW_SLAVE_ATTACHED: Slave is attached with bus.
33 * @SDW_SLAVE_ALERT: Some alert condition on the Slave
34 * @SDW_SLAVE_RESERVED: Reserved for future use
35 */
36enum sdw_slave_status {
37 SDW_SLAVE_UNATTACHED = 0,
38 SDW_SLAVE_ATTACHED = 1,
39 SDW_SLAVE_ALERT = 2,
40 SDW_SLAVE_RESERVED = 3,
41};
42
43/**
44 * enum sdw_command_response - Command response as defined by SDW spec
45 * @SDW_CMD_OK: cmd was successful
46 * @SDW_CMD_IGNORED: cmd was ignored
47 * @SDW_CMD_FAIL: cmd was NACKed
48 * @SDW_CMD_TIMEOUT: cmd timedout
49 * @SDW_CMD_FAIL_OTHER: cmd failed due to other reason than above
50 *
51 * NOTE: The enum is different than actual Spec as response in the Spec is
52 * combination of ACK/NAK bits
53 *
54 * SDW_CMD_TIMEOUT/FAIL_OTHER is defined for SW use, not in spec
55 */
56enum sdw_command_response {
57 SDW_CMD_OK = 0,
58 SDW_CMD_IGNORED = 1,
59 SDW_CMD_FAIL = 2,
60 SDW_CMD_TIMEOUT = 3,
61 SDW_CMD_FAIL_OTHER = 4,
62};
63
64/*
65 * SDW properties, defined in MIPI DisCo spec v1.0
66 */
67enum sdw_clk_stop_reset_behave {
68 SDW_CLK_STOP_KEEP_STATUS = 1,
69};
70
71/**
72 * enum sdw_p15_behave - Slave Port 15 behaviour when the Master attempts a
73 * read
74 * @SDW_P15_READ_IGNORED: Read is ignored
75 * @SDW_P15_CMD_OK: Command is ok
76 */
77enum sdw_p15_behave {
78 SDW_P15_READ_IGNORED = 0,
79 SDW_P15_CMD_OK = 1,
80};
81
82/**
83 * enum sdw_dpn_type - Data port types
84 * @SDW_DPN_FULL: Full Data Port is supported
85 * @SDW_DPN_SIMPLE: Simplified Data Port as defined in spec.
86 * DPN_SampleCtrl2, DPN_OffsetCtrl2, DPN_HCtrl and DPN_BlockCtrl3
87 * are not implemented.
88 * @SDW_DPN_REDUCED: Reduced Data Port as defined in spec.
89 * DPN_SampleCtrl2, DPN_HCtrl are not implemented.
90 */
91enum sdw_dpn_type {
92 SDW_DPN_FULL = 0,
93 SDW_DPN_SIMPLE = 1,
94 SDW_DPN_REDUCED = 2,
95};
96
97/**
98 * enum sdw_clk_stop_mode - Clock Stop modes
99 * @SDW_CLK_STOP_MODE0: Slave can continue operation seamlessly on clock
100 * restart
101 * @SDW_CLK_STOP_MODE1: Slave may have entered a deeper power-saving mode,
102 * not capable of continuing operation seamlessly when the clock restarts
103 */
104enum sdw_clk_stop_mode {
105 SDW_CLK_STOP_MODE0 = 0,
106 SDW_CLK_STOP_MODE1 = 1,
107};
108
109/**
110 * struct sdw_dp0_prop - DP0 properties
111 * @max_word: Maximum number of bits in a Payload Channel Sample, 1 to 64
112 * (inclusive)
113 * @min_word: Minimum number of bits in a Payload Channel Sample, 1 to 64
114 * (inclusive)
115 * @num_words: number of wordlengths supported
116 * @words: wordlengths supported
117 * @flow_controlled: Slave implementation results in an OK_NotReady
118 * response
119 * @simple_ch_prep_sm: If channel prepare sequence is required
120 * @device_interrupts: If implementation-defined interrupts are supported
121 *
122 * The wordlengths are specified by Spec as max, min AND number of
123 * discrete values, implementation can define based on the wordlengths they
124 * support
125 */
126struct sdw_dp0_prop {
127 u32 max_word;
128 u32 min_word;
129 u32 num_words;
130 u32 *words;
131 bool flow_controlled;
132 bool simple_ch_prep_sm;
133 bool device_interrupts;
134};
135
136/**
137 * struct sdw_dpn_audio_mode - Audio mode properties for DPn
138 * @bus_min_freq: Minimum bus frequency, in Hz
139 * @bus_max_freq: Maximum bus frequency, in Hz
140 * @bus_num_freq: Number of discrete frequencies supported
141 * @bus_freq: Discrete bus frequencies, in Hz
142 * @min_freq: Minimum sampling frequency, in Hz
143 * @max_freq: Maximum sampling bus frequency, in Hz
144 * @num_freq: Number of discrete sampling frequency supported
145 * @freq: Discrete sampling frequencies, in Hz
146 * @prep_ch_behave: Specifies the dependencies between Channel Prepare
147 * sequence and bus clock configuration
148 * If 0, Channel Prepare can happen at any Bus clock rate
149 * If 1, Channel Prepare sequence shall happen only after Bus clock is
150 * changed to a frequency supported by this mode or compatible modes
151 * described by the next field
152 * @glitchless: Bitmap describing possible glitchless transitions from this
153 * Audio Mode to other Audio Modes
154 */
155struct sdw_dpn_audio_mode {
156 u32 bus_min_freq;
157 u32 bus_max_freq;
158 u32 bus_num_freq;
159 u32 *bus_freq;
160 u32 max_freq;
161 u32 min_freq;
162 u32 num_freq;
163 u32 *freq;
164 u32 prep_ch_behave;
165 u32 glitchless;
166};
167
168/**
169 * struct sdw_dpn_prop - Data Port DPn properties
170 * @num: port number
171 * @max_word: Maximum number of bits in a Payload Channel Sample, 1 to 64
172 * (inclusive)
173 * @min_word: Minimum number of bits in a Payload Channel Sample, 1 to 64
174 * (inclusive)
175 * @num_words: Number of discrete supported wordlengths
176 * @words: Discrete supported wordlength
177 * @type: Data port type. Full, Simplified or Reduced
178 * @max_grouping: Maximum number of samples that can be grouped together for
179 * a full data port
180 * @simple_ch_prep_sm: If the port supports simplified channel prepare state
181 * machine
182 * @ch_prep_timeout: Port-specific timeout value, in milliseconds
183 * @device_interrupts: If set, each bit corresponds to support for
184 * implementation-defined interrupts
185 * @max_ch: Maximum channels supported
186 * @min_ch: Minimum channels supported
187 * @num_ch: Number of discrete channels supported
188 * @ch: Discrete channels supported
189 * @num_ch_combinations: Number of channel combinations supported
190 * @ch_combinations: Channel combinations supported
191 * @modes: SDW mode supported
192 * @max_async_buffer: Number of samples that this port can buffer in
193 * asynchronous modes
194 * @block_pack_mode: Type of block port mode supported
195 * @port_encoding: Payload Channel Sample encoding schemes supported
196 * @audio_modes: Audio modes supported
197 */
198struct sdw_dpn_prop {
199 u32 num;
200 u32 max_word;
201 u32 min_word;
202 u32 num_words;
203 u32 *words;
204 enum sdw_dpn_type type;
205 u32 max_grouping;
206 bool simple_ch_prep_sm;
207 u32 ch_prep_timeout;
208 u32 device_interrupts;
209 u32 max_ch;
210 u32 min_ch;
211 u32 num_ch;
212 u32 *ch;
213 u32 num_ch_combinations;
214 u32 *ch_combinations;
215 u32 modes;
216 u32 max_async_buffer;
217 bool block_pack_mode;
218 u32 port_encoding;
219 struct sdw_dpn_audio_mode *audio_modes;
220};
221
222/**
223 * struct sdw_slave_prop - SoundWire Slave properties
224 * @mipi_revision: Spec version of the implementation
225 * @wake_capable: Wake-up events are supported
226 * @test_mode_capable: If test mode is supported
227 * @clk_stop_mode1: Clock-Stop Mode 1 is supported
228 * @simple_clk_stop_capable: Simple clock mode is supported
229 * @clk_stop_timeout: Worst-case latency of the Clock Stop Prepare State
230 * Machine transitions, in milliseconds
231 * @ch_prep_timeout: Worst-case latency of the Channel Prepare State Machine
232 * transitions, in milliseconds
233 * @reset_behave: Slave keeps the status of the SlaveStopClockPrepare
234 * state machine (P=1 SCSP_SM) after exit from clock-stop mode1
235 * @high_PHY_capable: Slave is HighPHY capable
236 * @paging_support: Slave implements paging registers SCP_AddrPage1 and
237 * SCP_AddrPage2
238 * @bank_delay_support: Slave implements bank delay/bridge support registers
239 * SCP_BankDelay and SCP_NextFrame
240 * @p15_behave: Slave behavior when the Master attempts a read to the Port15
241 * alias
242 * @lane_control_support: Slave supports lane control
243 * @master_count: Number of Masters present on this Slave
244 * @source_ports: Bitmap identifying source ports
245 * @sink_ports: Bitmap identifying sink ports
246 * @dp0_prop: Data Port 0 properties
247 * @src_dpn_prop: Source Data Port N properties
248 * @sink_dpn_prop: Sink Data Port N properties
249 */
250struct sdw_slave_prop {
251 u32 mipi_revision;
252 bool wake_capable;
253 bool test_mode_capable;
254 bool clk_stop_mode1;
255 bool simple_clk_stop_capable;
256 u32 clk_stop_timeout;
257 u32 ch_prep_timeout;
258 enum sdw_clk_stop_reset_behave reset_behave;
259 bool high_PHY_capable;
260 bool paging_support;
261 bool bank_delay_support;
262 enum sdw_p15_behave p15_behave;
263 bool lane_control_support;
264 u32 master_count;
265 u32 source_ports;
266 u32 sink_ports;
267 struct sdw_dp0_prop *dp0_prop;
268 struct sdw_dpn_prop *src_dpn_prop;
269 struct sdw_dpn_prop *sink_dpn_prop;
270};
271
272/**
273 * struct sdw_master_prop - Master properties
274 * @revision: MIPI spec version of the implementation
275 * @master_count: Number of masters
276 * @clk_stop_mode: Bitmap for Clock Stop modes supported
277 * @max_freq: Maximum Bus clock frequency, in Hz
278 * @num_clk_gears: Number of clock gears supported
279 * @clk_gears: Clock gears supported
280 * @num_freq: Number of clock frequencies supported, in Hz
281 * @freq: Clock frequencies supported, in Hz
282 * @default_frame_rate: Controller default Frame rate, in Hz
283 * @default_row: Number of rows
284 * @default_col: Number of columns
285 * @dynamic_frame: Dynamic frame supported
286 * @err_threshold: Number of times that software may retry sending a single
287 * command
288 * @dpn_prop: Data Port N properties
289 */
290struct sdw_master_prop {
291 u32 revision;
292 u32 master_count;
293 enum sdw_clk_stop_mode clk_stop_mode;
294 u32 max_freq;
295 u32 num_clk_gears;
296 u32 *clk_gears;
297 u32 num_freq;
298 u32 *freq;
299 u32 default_frame_rate;
300 u32 default_row;
301 u32 default_col;
302 bool dynamic_frame;
303 u32 err_threshold;
304 struct sdw_dpn_prop *dpn_prop;
305};
306
307int sdw_master_read_prop(struct sdw_bus *bus);
308int sdw_slave_read_prop(struct sdw_slave *slave);
309
310/*
311 * SDW Slave Structures and APIs
312 */
313
314/**
315 * struct sdw_slave_id - Slave ID
316 * @mfg_id: MIPI Manufacturer ID
317 * @part_id: Device Part ID
318 * @class_id: MIPI Class ID, unused now.
319 * Currently a placeholder in MIPI SoundWire Spec
320 * @unique_id: Device unique ID
321 * @sdw_version: SDW version implemented
322 *
323 * The order of the IDs here does not follow the DisCo spec definitions
324 */
325struct sdw_slave_id {
326 __u16 mfg_id;
327 __u16 part_id;
328 __u8 class_id;
329 __u8 unique_id:4;
330 __u8 sdw_version:4;
331};
332
333/**
334 * struct sdw_slave_intr_status - Slave interrupt status
335 * @control_port: control port status
336 * @port: data port status
337 */
338struct sdw_slave_intr_status {
339 u8 control_port;
340 u8 port[15];
341};
342
343/**
344 * struct sdw_slave_ops - Slave driver callback ops
345 * @read_prop: Read Slave properties
346 * @interrupt_callback: Device interrupt notification (invoked in thread
347 * context)
348 * @update_status: Update Slave status
349 */
350struct sdw_slave_ops {
351 int (*read_prop)(struct sdw_slave *sdw);
352 int (*interrupt_callback)(struct sdw_slave *slave,
353 struct sdw_slave_intr_status *status);
354 int (*update_status)(struct sdw_slave *slave,
355 enum sdw_slave_status status);
356};
357
358/**
359 * struct sdw_slave - SoundWire Slave
360 * @id: MIPI device ID
361 * @dev: Linux device
362 * @status: Status reported by the Slave
363 * @bus: Bus handle
364 * @ops: Slave callback ops
365 * @prop: Slave properties
366 * @node: node for bus list
367 * @port_ready: Port ready completion flag for each Slave port
368 * @dev_num: Device Number assigned by Bus
369 */
370struct sdw_slave {
371 struct sdw_slave_id id;
372 struct device dev;
373 enum sdw_slave_status status;
374 struct sdw_bus *bus;
375 const struct sdw_slave_ops *ops;
376 struct sdw_slave_prop prop;
377 struct list_head node;
378 struct completion *port_ready;
379 u16 dev_num;
380};
381
382#define dev_to_sdw_dev(_dev) container_of(_dev, struct sdw_slave, dev)
383
384struct sdw_driver {
385 const char *name;
386
387 int (*probe)(struct sdw_slave *sdw,
388 const struct sdw_device_id *id);
389 int (*remove)(struct sdw_slave *sdw);
390 void (*shutdown)(struct sdw_slave *sdw);
391
392 const struct sdw_device_id *id_table;
393 const struct sdw_slave_ops *ops;
394
395 struct device_driver driver;
396};
397
398#define SDW_SLAVE_ENTRY(_mfg_id, _part_id, _drv_data) \
399 { .mfg_id = (_mfg_id), .part_id = (_part_id), \
400 .driver_data = (unsigned long)(_drv_data) }
401
402int sdw_handle_slave_status(struct sdw_bus *bus,
403 enum sdw_slave_status status[]);
404
405/*
406 * SDW master structures and APIs
407 */
408
409struct sdw_msg;
410
411/**
412 * struct sdw_defer - SDW deffered message
413 * @length: message length
414 * @complete: message completion
415 * @msg: SDW message
416 */
417struct sdw_defer {
418 int length;
419 struct completion complete;
420 struct sdw_msg *msg;
421};
422
423/**
424 * struct sdw_master_ops - Master driver ops
425 * @read_prop: Read Master properties
426 * @xfer_msg: Transfer message callback
427 * @xfer_msg_defer: Defer version of transfer message callback
428 * @reset_page_addr: Reset the SCP page address registers
429 */
430struct sdw_master_ops {
431 int (*read_prop)(struct sdw_bus *bus);
432
433 enum sdw_command_response (*xfer_msg)
434 (struct sdw_bus *bus, struct sdw_msg *msg);
435 enum sdw_command_response (*xfer_msg_defer)
436 (struct sdw_bus *bus, struct sdw_msg *msg,
437 struct sdw_defer *defer);
438 enum sdw_command_response (*reset_page_addr)
439 (struct sdw_bus *bus, unsigned int dev_num);
440};
441
442/**
443 * struct sdw_bus - SoundWire bus
444 * @dev: Master linux device
445 * @link_id: Link id number, can be 0 to N, unique for each Master
446 * @slaves: list of Slaves on this bus
447 * @assigned: Bitmap for Slave device numbers.
448 * Bit set implies used number, bit clear implies unused number.
449 * @bus_lock: bus lock
450 * @msg_lock: message lock
451 * @ops: Master callback ops
452 * @prop: Master properties
453 * @defer_msg: Defer message
454 * @clk_stop_timeout: Clock stop timeout computed
455 */
456struct sdw_bus {
457 struct device *dev;
458 unsigned int link_id;
459 struct list_head slaves;
460 DECLARE_BITMAP(assigned, SDW_MAX_DEVICES);
461 struct mutex bus_lock;
462 struct mutex msg_lock;
463 const struct sdw_master_ops *ops;
464 struct sdw_master_prop prop;
465 struct sdw_defer defer_msg;
466 unsigned int clk_stop_timeout;
467};
468
469int sdw_add_bus_master(struct sdw_bus *bus);
470void sdw_delete_bus_master(struct sdw_bus *bus);
471
472/* messaging and data APIs */
473
474int sdw_read(struct sdw_slave *slave, u32 addr);
475int sdw_write(struct sdw_slave *slave, u32 addr, u8 value);
476int sdw_nread(struct sdw_slave *slave, u32 addr, size_t count, u8 *val);
477int sdw_nwrite(struct sdw_slave *slave, u32 addr, size_t count, u8 *val);
478
479#endif /* __SOUNDWIRE_H */
diff --git a/include/linux/soundwire/sdw_intel.h b/include/linux/soundwire/sdw_intel.h
new file mode 100644
index 000000000000..4b37528f592d
--- /dev/null
+++ b/include/linux/soundwire/sdw_intel.h
@@ -0,0 +1,24 @@
1// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
2// Copyright(c) 2015-17 Intel Corporation.
3
4#ifndef __SDW_INTEL_H
5#define __SDW_INTEL_H
6
7/**
8 * struct sdw_intel_res - Soundwire Intel resource structure
9 * @mmio_base: mmio base of SoundWire registers
10 * @irq: interrupt number
11 * @handle: ACPI parent handle
12 * @parent: parent device
13 */
14struct sdw_intel_res {
15 void __iomem *mmio_base;
16 int irq;
17 acpi_handle handle;
18 struct device *parent;
19};
20
21void *sdw_intel_init(acpi_handle *parent_handle, struct sdw_intel_res *res);
22void sdw_intel_exit(void *arg);
23
24#endif
diff --git a/include/linux/soundwire/sdw_registers.h b/include/linux/soundwire/sdw_registers.h
new file mode 100644
index 000000000000..df472b1ab410
--- /dev/null
+++ b/include/linux/soundwire/sdw_registers.h
@@ -0,0 +1,194 @@
1// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
2// Copyright(c) 2015-17 Intel Corporation.
3
4#ifndef __SDW_REGISTERS_H
5#define __SDW_REGISTERS_H
6
7/*
8 * typically we define register and shifts but if one observes carefully,
9 * the shift can be generated from MASKS using few bit primitaives like ffs
10 * etc, so we use that and avoid defining shifts
11 */
12#define SDW_REG_SHIFT(n) (ffs(n) - 1)
13
14/*
15 * SDW registers as defined by MIPI 1.1 Spec
16 */
17#define SDW_REGADDR GENMASK(14, 0)
18#define SDW_SCP_ADDRPAGE2_MASK GENMASK(22, 15)
19#define SDW_SCP_ADDRPAGE1_MASK GENMASK(30, 23)
20
21#define SDW_REG_NO_PAGE 0x00008000
22#define SDW_REG_OPTIONAL_PAGE 0x00010000
23#define SDW_REG_MAX 0x80000000
24
25#define SDW_DPN_SIZE 0x100
26#define SDW_BANK1_OFFSET 0x10
27
28/*
29 * DP0 Interrupt register & bits
30 *
31 * Spec treats Status (RO) and Clear (WC) as separate but they are same
32 * address, so treat as same register with WC.
33 */
34
35/* both INT and STATUS register are same */
36#define SDW_DP0_INT 0x0
37#define SDW_DP0_INTMASK 0x1
38#define SDW_DP0_PORTCTRL 0x2
39#define SDW_DP0_BLOCKCTRL1 0x3
40#define SDW_DP0_PREPARESTATUS 0x4
41#define SDW_DP0_PREPARECTRL 0x5
42
43#define SDW_DP0_INT_TEST_FAIL BIT(0)
44#define SDW_DP0_INT_PORT_READY BIT(1)
45#define SDW_DP0_INT_BRA_FAILURE BIT(2)
46#define SDW_DP0_INT_IMPDEF1 BIT(5)
47#define SDW_DP0_INT_IMPDEF2 BIT(6)
48#define SDW_DP0_INT_IMPDEF3 BIT(7)
49
50#define SDW_DP0_PORTCTRL_DATAMODE GENMASK(3, 2)
51#define SDW_DP0_PORTCTRL_NXTINVBANK BIT(4)
52#define SDW_DP0_PORTCTRL_BPT_PAYLD GENMASK(7, 6)
53
54#define SDW_DP0_CHANNELEN 0x20
55#define SDW_DP0_SAMPLECTRL1 0x22
56#define SDW_DP0_SAMPLECTRL2 0x23
57#define SDW_DP0_OFFSETCTRL1 0x24
58#define SDW_DP0_OFFSETCTRL2 0x25
59#define SDW_DP0_HCTRL 0x26
60#define SDW_DP0_LANECTRL 0x28
61
62/* Both INT and STATUS register are same */
63#define SDW_SCP_INT1 0x40
64#define SDW_SCP_INTMASK1 0x41
65
66#define SDW_SCP_INT1_PARITY BIT(0)
67#define SDW_SCP_INT1_BUS_CLASH BIT(1)
68#define SDW_SCP_INT1_IMPL_DEF BIT(2)
69#define SDW_SCP_INT1_SCP2_CASCADE BIT(7)
70#define SDW_SCP_INT1_PORT0_3 GENMASK(6, 3)
71
72#define SDW_SCP_INTSTAT2 0x42
73#define SDW_SCP_INTSTAT2_SCP3_CASCADE BIT(7)
74#define SDW_SCP_INTSTAT2_PORT4_10 GENMASK(6, 0)
75
76
77#define SDW_SCP_INTSTAT3 0x43
78#define SDW_SCP_INTSTAT3_PORT11_14 GENMASK(3, 0)
79
80/* Number of interrupt status registers */
81#define SDW_NUM_INT_STAT_REGISTERS 3
82
83/* Number of interrupt clear registers */
84#define SDW_NUM_INT_CLEAR_REGISTERS 1
85
86#define SDW_SCP_CTRL 0x44
87#define SDW_SCP_CTRL_CLK_STP_NOW BIT(1)
88#define SDW_SCP_CTRL_FORCE_RESET BIT(7)
89
90#define SDW_SCP_STAT 0x44
91#define SDW_SCP_STAT_CLK_STP_NF BIT(0)
92#define SDW_SCP_STAT_HPHY_NOK BIT(5)
93#define SDW_SCP_STAT_CURR_BANK BIT(6)
94
95#define SDW_SCP_SYSTEMCTRL 0x45
96#define SDW_SCP_SYSTEMCTRL_CLK_STP_PREP BIT(0)
97#define SDW_SCP_SYSTEMCTRL_CLK_STP_MODE BIT(2)
98#define SDW_SCP_SYSTEMCTRL_WAKE_UP_EN BIT(3)
99#define SDW_SCP_SYSTEMCTRL_HIGH_PHY BIT(4)
100
101#define SDW_SCP_SYSTEMCTRL_CLK_STP_MODE0 0
102#define SDW_SCP_SYSTEMCTRL_CLK_STP_MODE1 BIT(2)
103
104#define SDW_SCP_DEVNUMBER 0x46
105#define SDW_SCP_HIGH_PHY_CHECK 0x47
106#define SDW_SCP_ADDRPAGE1 0x48
107#define SDW_SCP_ADDRPAGE2 0x49
108#define SDW_SCP_KEEPEREN 0x4A
109#define SDW_SCP_BANKDELAY 0x4B
110#define SDW_SCP_TESTMODE 0x4F
111#define SDW_SCP_DEVID_0 0x50
112#define SDW_SCP_DEVID_1 0x51
113#define SDW_SCP_DEVID_2 0x52
114#define SDW_SCP_DEVID_3 0x53
115#define SDW_SCP_DEVID_4 0x54
116#define SDW_SCP_DEVID_5 0x55
117
118/* Banked Registers */
119#define SDW_SCP_FRAMECTRL_B0 0x60
120#define SDW_SCP_FRAMECTRL_B1 (0x60 + SDW_BANK1_OFFSET)
121#define SDW_SCP_NEXTFRAME_B0 0x61
122#define SDW_SCP_NEXTFRAME_B1 (0x61 + SDW_BANK1_OFFSET)
123
124/* Both INT and STATUS register is same */
125#define SDW_DPN_INT(n) (0x0 + SDW_DPN_SIZE * (n))
126#define SDW_DPN_INTMASK(n) (0x1 + SDW_DPN_SIZE * (n))
127#define SDW_DPN_PORTCTRL(n) (0x2 + SDW_DPN_SIZE * (n))
128#define SDW_DPN_BLOCKCTRL1(n) (0x3 + SDW_DPN_SIZE * (n))
129#define SDW_DPN_PREPARESTATUS(n) (0x4 + SDW_DPN_SIZE * (n))
130#define SDW_DPN_PREPARECTRL(n) (0x5 + SDW_DPN_SIZE * (n))
131
132#define SDW_DPN_INT_TEST_FAIL BIT(0)
133#define SDW_DPN_INT_PORT_READY BIT(1)
134#define SDW_DPN_INT_IMPDEF1 BIT(5)
135#define SDW_DPN_INT_IMPDEF2 BIT(6)
136#define SDW_DPN_INT_IMPDEF3 BIT(7)
137
138#define SDW_DPN_PORTCTRL_FLOWMODE GENMASK(1, 0)
139#define SDW_DPN_PORTCTRL_DATAMODE GENMASK(3, 2)
140#define SDW_DPN_PORTCTRL_NXTINVBANK BIT(4)
141
142#define SDW_DPN_BLOCKCTRL1_WDLEN GENMASK(5, 0)
143
144#define SDW_DPN_PREPARECTRL_CH_PREP GENMASK(7, 0)
145
146#define SDW_DPN_CHANNELEN_B0(n) (0x20 + SDW_DPN_SIZE * (n))
147#define SDW_DPN_CHANNELEN_B1(n) (0x30 + SDW_DPN_SIZE * (n))
148
149#define SDW_DPN_BLOCKCTRL2_B0(n) (0x21 + SDW_DPN_SIZE * (n))
150#define SDW_DPN_BLOCKCTRL2_B1(n) (0x31 + SDW_DPN_SIZE * (n))
151
152#define SDW_DPN_SAMPLECTRL1_B0(n) (0x22 + SDW_DPN_SIZE * (n))
153#define SDW_DPN_SAMPLECTRL1_B1(n) (0x32 + SDW_DPN_SIZE * (n))
154
155#define SDW_DPN_SAMPLECTRL2_B0(n) (0x23 + SDW_DPN_SIZE * (n))
156#define SDW_DPN_SAMPLECTRL2_B1(n) (0x33 + SDW_DPN_SIZE * (n))
157
158#define SDW_DPN_OFFSETCTRL1_B0(n) (0x24 + SDW_DPN_SIZE * (n))
159#define SDW_DPN_OFFSETCTRL1_B1(n) (0x34 + SDW_DPN_SIZE * (n))
160
161#define SDW_DPN_OFFSETCTRL2_B0(n) (0x25 + SDW_DPN_SIZE * (n))
162#define SDW_DPN_OFFSETCTRL2_B1(n) (0x35 + SDW_DPN_SIZE * (n))
163
164#define SDW_DPN_HCTRL_B0(n) (0x26 + SDW_DPN_SIZE * (n))
165#define SDW_DPN_HCTRL_B1(n) (0x36 + SDW_DPN_SIZE * (n))
166
167#define SDW_DPN_BLOCKCTRL3_B0(n) (0x27 + SDW_DPN_SIZE * (n))
168#define SDW_DPN_BLOCKCTRL3_B1(n) (0x37 + SDW_DPN_SIZE * (n))
169
170#define SDW_DPN_LANECTRL_B0(n) (0x28 + SDW_DPN_SIZE * (n))
171#define SDW_DPN_LANECTRL_B1(n) (0x38 + SDW_DPN_SIZE * (n))
172
173#define SDW_DPN_SAMPLECTRL_LOW GENMASK(7, 0)
174#define SDW_DPN_SAMPLECTRL_HIGH GENMASK(15, 8)
175
176#define SDW_DPN_HCTRL_HSTART GENMASK(7, 4)
177#define SDW_DPN_HCTRL_HSTOP GENMASK(3, 0)
178
179#define SDW_NUM_CASC_PORT_INTSTAT1 4
180#define SDW_CASC_PORT_START_INTSTAT1 0
181#define SDW_CASC_PORT_MASK_INTSTAT1 0x8
182#define SDW_CASC_PORT_REG_OFFSET_INTSTAT1 0x0
183
184#define SDW_NUM_CASC_PORT_INTSTAT2 7
185#define SDW_CASC_PORT_START_INTSTAT2 4
186#define SDW_CASC_PORT_MASK_INTSTAT2 1
187#define SDW_CASC_PORT_REG_OFFSET_INTSTAT2 1
188
189#define SDW_NUM_CASC_PORT_INTSTAT3 4
190#define SDW_CASC_PORT_START_INTSTAT3 11
191#define SDW_CASC_PORT_MASK_INTSTAT3 1
192#define SDW_CASC_PORT_REG_OFFSET_INTSTAT3 2
193
194#endif /* __SDW_REGISTERS_H */
diff --git a/include/linux/soundwire/sdw_type.h b/include/linux/soundwire/sdw_type.h
new file mode 100644
index 000000000000..9fd553e553e9
--- /dev/null
+++ b/include/linux/soundwire/sdw_type.h
@@ -0,0 +1,19 @@
1// SPDX-License-Identifier: GPL-2.0
2// Copyright(c) 2015-17 Intel Corporation.
3
4#ifndef __SOUNDWIRE_TYPES_H
5#define __SOUNDWIRE_TYPES_H
6
7extern struct bus_type sdw_bus_type;
8
9#define drv_to_sdw_driver(_drv) container_of(_drv, struct sdw_driver, driver)
10
11#define sdw_register_driver(drv) \
12 __sdw_register_driver(drv, THIS_MODULE)
13
14int __sdw_register_driver(struct sdw_driver *drv, struct module *);
15void sdw_unregister_driver(struct sdw_driver *drv);
16
17int sdw_slave_modalias(const struct sdw_slave *slave, char *buf, size_t size);
18
19#endif /* __SOUNDWIRE_TYPES_H */
diff --git a/include/linux/vbox_utils.h b/include/linux/vbox_utils.h
new file mode 100644
index 000000000000..c71def6b310f
--- /dev/null
+++ b/include/linux/vbox_utils.h
@@ -0,0 +1,79 @@
1/* SPDX-License-Identifier: (GPL-2.0 OR CDDL-1.0) */
2/* Copyright (C) 2006-2016 Oracle Corporation */
3
4#ifndef __VBOX_UTILS_H__
5#define __VBOX_UTILS_H__
6
7#include <linux/printk.h>
8#include <linux/vbox_vmmdev_types.h>
9
10struct vbg_dev;
11
12/**
13 * vboxguest logging functions, these log both to the backdoor and call
14 * the equivalent kernel pr_foo function.
15 */
16__printf(1, 2) void vbg_info(const char *fmt, ...);
17__printf(1, 2) void vbg_warn(const char *fmt, ...);
18__printf(1, 2) void vbg_err(const char *fmt, ...);
19
20/* Only use backdoor logging for non-dynamic debug builds */
21#if defined(DEBUG) && !defined(CONFIG_DYNAMIC_DEBUG)
22__printf(1, 2) void vbg_debug(const char *fmt, ...);
23#else
24#define vbg_debug pr_debug
25#endif
26
27/**
28 * Allocate memory for generic request and initialize the request header.
29 *
30 * Return: the allocated memory
31 * @len: Size of memory block required for the request.
32 * @req_type: The generic request type.
33 */
34void *vbg_req_alloc(size_t len, enum vmmdev_request_type req_type);
35
36/**
37 * Perform a generic request.
38 *
39 * Return: VBox status code
40 * @gdev: The Guest extension device.
41 * @req: Pointer to the request structure.
42 */
43int vbg_req_perform(struct vbg_dev *gdev, void *req);
44
45int vbg_hgcm_connect(struct vbg_dev *gdev,
46 struct vmmdev_hgcm_service_location *loc,
47 u32 *client_id, int *vbox_status);
48
49int vbg_hgcm_disconnect(struct vbg_dev *gdev, u32 client_id, int *vbox_status);
50
51int vbg_hgcm_call(struct vbg_dev *gdev, u32 client_id, u32 function,
52 u32 timeout_ms, struct vmmdev_hgcm_function_parameter *parms,
53 u32 parm_count, int *vbox_status);
54
55int vbg_hgcm_call32(
56 struct vbg_dev *gdev, u32 client_id, u32 function, u32 timeout_ms,
57 struct vmmdev_hgcm_function_parameter32 *parm32, u32 parm_count,
58 int *vbox_status);
59
60/**
61 * Convert a VirtualBox status code to a standard Linux kernel return value.
62 * Return: 0 or negative errno value.
63 * @rc: VirtualBox status code to convert.
64 */
65int vbg_status_code_to_errno(int rc);
66
67/**
68 * Helper for the vboxsf driver to get a reference to the guest device.
69 * Return: a pointer to the gdev; or a ERR_PTR value on error.
70 */
71struct vbg_dev *vbg_get_gdev(void);
72
73/**
74 * Helper for the vboxsf driver to put a guest device reference.
75 * @gdev: Reference returned by vbg_get_gdev to put.
76 */
77void vbg_put_gdev(struct vbg_dev *gdev);
78
79#endif