History

platform/x86: simatic-ipc: add main driver for Siemens devices

This mainly implements detection of these devices and will allow secondary drivers to work on such machines. The identification is DMI-based with a vendor specific way to tell them apart in a reliable way. Drivers for LEDs and Watchdogs will follow to make use of that platform detection. There is also some code to allow secondary drivers to find GPIO memory, that needs to be in place because the pinctrl drivers do not come up.

Henning Schild committed 4 years ago

Commit dd123e61 parent c0518b25 files · +292 −0Browse files

Showing the changes to include/linux/platform_data (2 of 5 files). Show all

Unified · Split

2 files
  1. include/linux/platform_data/x86/simatic-ipc-base.h +29 −0
  2. include/linux/platform_data/x86/simatic-ipc.h +72 −0
include/linux/platform_data/x86/simatic-ipc-base.h+29−0
@@ -0,0 +1,29 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Siemens SIMATIC IPC drivers
4 *
5 * Copyright (c) Siemens AG, 2018-2021
6 *
7 * Authors:
8 * Henning Schild <henning.schild@siemens.com>
9 * Gerd Haeussler <gerd.haeussler.ext@siemens.com>
10 */
11
12#ifndef __PLATFORM_DATA_X86_SIMATIC_IPC_BASE_H
13#define __PLATFORM_DATA_X86_SIMATIC_IPC_BASE_H
14
15#include <linux/types.h>
16
17#define SIMATIC_IPC_DEVICE_NONE 0
18#define SIMATIC_IPC_DEVICE_227D 1
19#define SIMATIC_IPC_DEVICE_427E 2
20#define SIMATIC_IPC_DEVICE_127E 3
21#define SIMATIC_IPC_DEVICE_227E 4
22
23struct simatic_ipc_platform {
24 u8 devmode;
25};
26
27u32 simatic_ipc_get_membase0(unsigned int p2sb);
28
29#endif /* __PLATFORM_DATA_X86_SIMATIC_IPC_BASE_H */
include/linux/platform_data/x86/simatic-ipc.h+72−0
@@ -0,0 +1,72 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Siemens SIMATIC IPC drivers
4 *
5 * Copyright (c) Siemens AG, 2018-2021
6 *
7 * Authors:
8 * Henning Schild <henning.schild@siemens.com>
9 * Gerd Haeussler <gerd.haeussler.ext@siemens.com>
10 */
11
12#ifndef __PLATFORM_DATA_X86_SIMATIC_IPC_H
13#define __PLATFORM_DATA_X86_SIMATIC_IPC_H
14
15#include <linux/dmi.h>
16#include <linux/platform_data/x86/simatic-ipc-base.h>
17
18#define SIMATIC_IPC_DMI_ENTRY_OEM 129
19/* binary type */
20#define SIMATIC_IPC_DMI_TYPE 0xff
21#define SIMATIC_IPC_DMI_GROUP 0x05
22#define SIMATIC_IPC_DMI_ENTRY 0x02
23#define SIMATIC_IPC_DMI_TID 0x02
24
25enum simatic_ipc_station_ids {
26 SIMATIC_IPC_INVALID_STATION_ID = 0,
27 SIMATIC_IPC_IPC227D = 0x00000501,
28 SIMATIC_IPC_IPC427D = 0x00000701,
29 SIMATIC_IPC_IPC227E = 0x00000901,
30 SIMATIC_IPC_IPC277E = 0x00000902,
31 SIMATIC_IPC_IPC427E = 0x00000A01,
32 SIMATIC_IPC_IPC477E = 0x00000A02,
33 SIMATIC_IPC_IPC127E = 0x00000D01,
34};
35
36static inline u32 simatic_ipc_get_station_id(u8 *data, int max_len)
37{
38 struct {
39 u8 type; /* type (0xff = binary) */
40 u8 len; /* len of data entry */
41 u8 group;
42 u8 entry;
43 u8 tid;
44 __le32 station_id; /* station id (LE) */
45 } __packed * data_entry = (void *)data + sizeof(struct dmi_header);
46
47 while ((u8 *)data_entry < data + max_len) {
48 if (data_entry->type == SIMATIC_IPC_DMI_TYPE &&
49 data_entry->len == sizeof(*data_entry) &&
50 data_entry->group == SIMATIC_IPC_DMI_GROUP &&
51 data_entry->entry == SIMATIC_IPC_DMI_ENTRY &&
52 data_entry->tid == SIMATIC_IPC_DMI_TID) {
53 return le32_to_cpu(data_entry->station_id);
54 }
55 data_entry = (void *)((u8 *)(data_entry) + data_entry->len);
56 }
57
58 return SIMATIC_IPC_INVALID_STATION_ID;
59}
60
61static inline void
62simatic_ipc_find_dmi_entry_helper(const struct dmi_header *dh, void *_data)
63{
64 u32 *id = _data;
65
66 if (dh->type != SIMATIC_IPC_DMI_ENTRY_OEM)
67 return;
68
69 *id = simatic_ipc_get_station_id((u8 *)dh, dh->length);
70}
71
72#endif /* __PLATFORM_DATA_X86_SIMATIC_IPC_H */