diff options
author | Alexander Shishkin <alexander.shishkin@linux.intel.com> | 2018-10-05 08:42:56 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-10-11 06:12:54 -0400 |
commit | a02509f301c68c9a7f01d75d7d326f7a9b81a630 (patch) | |
tree | 4e2783a20585a89abf094b38c593cb38a8472bb3 /drivers | |
parent | d279a38020d2483cb75f5f82f5e4ab5f73bc94f2 (diff) |
stm class: Factor out default framing protocol
The STP framing pattern that the stm class implicitly applies to the
data payload is, in fact, a protocol. This patch moves the relevant code
out of the stm core into its own driver module.
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Tested-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/hwtracing/stm/Kconfig | 15 | ||||
-rw-r--r-- | drivers/hwtracing/stm/Makefile | 4 | ||||
-rw-r--r-- | drivers/hwtracing/stm/p_basic.c | 48 |
3 files changed, 67 insertions, 0 deletions
diff --git a/drivers/hwtracing/stm/Kconfig b/drivers/hwtracing/stm/Kconfig index 723e2d90083d..262e7891fb97 100644 --- a/drivers/hwtracing/stm/Kconfig +++ b/drivers/hwtracing/stm/Kconfig | |||
@@ -11,6 +11,21 @@ config STM | |||
11 | 11 | ||
12 | if STM | 12 | if STM |
13 | 13 | ||
14 | config STM_PROTO_BASIC | ||
15 | tristate "Basic STM framing protocol driver" | ||
16 | default CONFIG_STM | ||
17 | help | ||
18 | This is a simple framing protocol for sending data over STM | ||
19 | devices. This was the protocol that the STM framework used | ||
20 | exclusively until the MIPI SyS-T support was added. Use this | ||
21 | driver for compatibility with your existing STM setup. | ||
22 | |||
23 | The receiving side only needs to be able to decode the MIPI | ||
24 | STP protocol in order to extract the data. | ||
25 | |||
26 | If you want to be able to use the basic protocol or want the | ||
27 | backwards compatibility for your existing setup, say Y. | ||
28 | |||
14 | config STM_DUMMY | 29 | config STM_DUMMY |
15 | tristate "Dummy STM driver" | 30 | tristate "Dummy STM driver" |
16 | help | 31 | help |
diff --git a/drivers/hwtracing/stm/Makefile b/drivers/hwtracing/stm/Makefile index effc19e5190f..1571de66eca4 100644 --- a/drivers/hwtracing/stm/Makefile +++ b/drivers/hwtracing/stm/Makefile | |||
@@ -3,6 +3,10 @@ obj-$(CONFIG_STM) += stm_core.o | |||
3 | 3 | ||
4 | stm_core-y := core.o policy.o | 4 | stm_core-y := core.o policy.o |
5 | 5 | ||
6 | obj-$(CONFIG_STM_PROTO_BASIC) += stm_p_basic.o | ||
7 | |||
8 | stm_p_basic-y := p_basic.o | ||
9 | |||
6 | obj-$(CONFIG_STM_DUMMY) += dummy_stm.o | 10 | obj-$(CONFIG_STM_DUMMY) += dummy_stm.o |
7 | 11 | ||
8 | obj-$(CONFIG_STM_SOURCE_CONSOLE) += stm_console.o | 12 | obj-$(CONFIG_STM_SOURCE_CONSOLE) += stm_console.o |
diff --git a/drivers/hwtracing/stm/p_basic.c b/drivers/hwtracing/stm/p_basic.c new file mode 100644 index 000000000000..8980a6a5fd6c --- /dev/null +++ b/drivers/hwtracing/stm/p_basic.c | |||
@@ -0,0 +1,48 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
2 | /* | ||
3 | * Basic framing protocol for STM devices. | ||
4 | * Copyright (c) 2018, Intel Corporation. | ||
5 | */ | ||
6 | |||
7 | #include <linux/module.h> | ||
8 | #include <linux/device.h> | ||
9 | #include <linux/stm.h> | ||
10 | #include "stm.h" | ||
11 | |||
12 | static ssize_t basic_write(struct stm_data *data, struct stm_output *output, | ||
13 | unsigned int chan, const char *buf, size_t count) | ||
14 | { | ||
15 | unsigned int c = output->channel + chan; | ||
16 | unsigned int m = output->master; | ||
17 | const unsigned char nil = 0; | ||
18 | ssize_t sz; | ||
19 | |||
20 | sz = stm_data_write(data, m, c, true, buf, count); | ||
21 | if (sz > 0) | ||
22 | data->packet(data, m, c, STP_PACKET_FLAG, 0, 0, &nil); | ||
23 | |||
24 | return sz; | ||
25 | } | ||
26 | |||
27 | static const struct stm_protocol_driver basic_pdrv = { | ||
28 | .owner = THIS_MODULE, | ||
29 | .name = "p_basic", | ||
30 | .write = basic_write, | ||
31 | }; | ||
32 | |||
33 | static int basic_stm_init(void) | ||
34 | { | ||
35 | return stm_register_protocol(&basic_pdrv); | ||
36 | } | ||
37 | |||
38 | static void basic_stm_exit(void) | ||
39 | { | ||
40 | stm_unregister_protocol(&basic_pdrv); | ||
41 | } | ||
42 | |||
43 | module_init(basic_stm_init); | ||
44 | module_exit(basic_stm_exit); | ||
45 | |||
46 | MODULE_LICENSE("GPL v2"); | ||
47 | MODULE_DESCRIPTION("Basic STM framing protocol driver"); | ||
48 | MODULE_AUTHOR("Alexander Shishkin <alexander.shishkin@linux.intel.com>"); | ||