]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - drivers/platform/x86/intel_telemetry_pltdrv.c
platform/x86: intel_telemetry: Fix load failure info
[mirror_ubuntu-bionic-kernel.git] / drivers / platform / x86 / intel_telemetry_pltdrv.c
CommitLineData
9d16b482
SKC
1/*
2 * Intel SOC Telemetry Platform Driver: Currently supports APL
3 * Copyright (c) 2015, Intel Corporation.
4 * All Rights Reserved.
5 *
6 * 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 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * This file provides the platform specific telemetry implementation for APL.
16 * It used the PUNIT and PMC IPC interfaces for configuring the counters.
17 * The accumulated results are fetched from SRAM.
18 */
19#include <linux/module.h>
20#include <linux/init.h>
21#include <linux/device.h>
22#include <linux/debugfs.h>
23#include <linux/seq_file.h>
24#include <linux/io.h>
25#include <linux/uaccess.h>
26#include <linux/pci.h>
27#include <linux/suspend.h>
28#include <linux/platform_device.h>
29
30#include <asm/cpu_device_id.h>
678dec00 31#include <asm/intel-family.h>
9d16b482
SKC
32#include <asm/intel_pmc_ipc.h>
33#include <asm/intel_punit_ipc.h>
34#include <asm/intel_telemetry.h>
35
36#define DRIVER_NAME "intel_telemetry"
37#define DRIVER_VERSION "1.0.0"
38
39#define TELEM_TRC_VERBOSITY_MASK 0x3
40
41#define TELEM_MIN_PERIOD(x) ((x) & 0x7F0000)
42#define TELEM_MAX_PERIOD(x) ((x) & 0x7F000000)
43#define TELEM_SAMPLE_PERIOD_INVALID(x) ((x) & (BIT(7)))
44#define TELEM_CLEAR_SAMPLE_PERIOD(x) ((x) &= ~0x7F)
45
46#define TELEM_SAMPLING_DEFAULT_PERIOD 0xD
47
48#define TELEM_MAX_EVENTS_SRAM 28
9d16b482
SKC
49#define TELEM_SSRAM_STARTTIME_OFFSET 8
50#define TELEM_SSRAM_EVTLOG_OFFSET 16
51
52#define IOSS_TELEM_EVENT_READ 0x0
53#define IOSS_TELEM_EVENT_WRITE 0x1
54#define IOSS_TELEM_INFO_READ 0x2
55#define IOSS_TELEM_TRACE_CTL_READ 0x5
56#define IOSS_TELEM_TRACE_CTL_WRITE 0x6
57#define IOSS_TELEM_EVENT_CTL_READ 0x7
58#define IOSS_TELEM_EVENT_CTL_WRITE 0x8
59#define IOSS_TELEM_EVT_CTRL_WRITE_SIZE 0x4
60#define IOSS_TELEM_READ_WORD 0x1
61#define IOSS_TELEM_WRITE_FOURBYTES 0x4
62#define IOSS_TELEM_EVT_WRITE_SIZE 0x3
63
64#define TELEM_INFO_SRAMEVTS_MASK 0xFF00
65#define TELEM_INFO_SRAMEVTS_SHIFT 0x8
66#define TELEM_SSRAM_READ_TIMEOUT 10
67
68#define TELEM_INFO_NENABLES_MASK 0xFF
69#define TELEM_EVENT_ENABLE 0x8000
70
71#define TELEM_MASK_BIT 1
72#define TELEM_MASK_BYTE 0xFF
73#define BYTES_PER_LONG 8
74#define TELEM_MASK_PCS_STATE 0xF
75
76#define TELEM_DISABLE(x) ((x) &= ~(BIT(31)))
77#define TELEM_CLEAR_EVENTS(x) ((x) |= (BIT(30)))
78#define TELEM_ENABLE_SRAM_EVT_TRACE(x) ((x) &= ~(BIT(30) | BIT(24)))
79#define TELEM_ENABLE_PERIODIC(x) ((x) |= (BIT(23) | BIT(31) | BIT(7)))
80#define TELEM_EXTRACT_VERBOSITY(x, y) ((y) = (((x) >> 27) & 0x3))
81#define TELEM_CLEAR_VERBOSITY_BITS(x) ((x) &= ~(BIT(27) | BIT(28)))
82#define TELEM_SET_VERBOSITY_BITS(x, y) ((x) |= ((y) << 27))
83
84#define TELEM_CPU(model, data) \
08a24516 85 { X86_VENDOR_INTEL, 6, model, X86_FEATURE_ANY, (unsigned long)&data }
9d16b482
SKC
86
87enum telemetry_action {
88 TELEM_UPDATE = 0,
89 TELEM_ADD,
90 TELEM_RESET,
91 TELEM_ACTION_NONE
92};
93
94struct telem_ssram_region {
95 u64 timestamp;
96 u64 start_time;
97 u64 events[TELEM_MAX_EVENTS_SRAM];
98};
99
100static struct telemetry_plt_config *telm_conf;
101
102/*
103 * The following counters are programmed by default during setup.
104 * Only 20 allocated to kernel driver
105 */
106static struct telemetry_evtmap
107 telemetry_apl_ioss_default_events[TELEM_MAX_OS_ALLOCATED_EVENTS] = {
108 {"SOC_S0IX_TOTAL_RES", 0x4800},
109 {"SOC_S0IX_TOTAL_OCC", 0x4000},
110 {"SOC_S0IX_SHALLOW_RES", 0x4801},
111 {"SOC_S0IX_SHALLOW_OCC", 0x4001},
112 {"SOC_S0IX_DEEP_RES", 0x4802},
113 {"SOC_S0IX_DEEP_OCC", 0x4002},
114 {"PMC_POWER_GATE", 0x5818},
115 {"PMC_D3_STATES", 0x5819},
116 {"PMC_D0I3_STATES", 0x581A},
117 {"PMC_S0IX_WAKE_REASON_GPIO", 0x6000},
118 {"PMC_S0IX_WAKE_REASON_TIMER", 0x6001},
119 {"PMC_S0IX_WAKE_REASON_VNNREQ", 0x6002},
120 {"PMC_S0IX_WAKE_REASON_LOWPOWER", 0x6003},
121 {"PMC_S0IX_WAKE_REASON_EXTERNAL", 0x6004},
122 {"PMC_S0IX_WAKE_REASON_MISC", 0x6005},
123 {"PMC_S0IX_BLOCKING_IPS_D3_D0I3", 0x6006},
124 {"PMC_S0IX_BLOCKING_IPS_PG", 0x6007},
125 {"PMC_S0IX_BLOCKING_MISC_IPS_PG", 0x6008},
126 {"PMC_S0IX_BLOCK_IPS_VNN_REQ", 0x6009},
127 {"PMC_S0IX_BLOCK_IPS_CLOCKS", 0x600B},
128};
129
130
131static struct telemetry_evtmap
132 telemetry_apl_pss_default_events[TELEM_MAX_OS_ALLOCATED_EVENTS] = {
133 {"IA_CORE0_C6_RES", 0x0400},
134 {"IA_CORE0_C6_CTR", 0x0000},
135 {"IA_MODULE0_C7_RES", 0x0410},
136 {"IA_MODULE0_C7_CTR", 0x000E},
137 {"IA_C0_RES", 0x0805},
138 {"PCS_LTR", 0x2801},
139 {"PSTATES", 0x2802},
140 {"SOC_S0I3_RES", 0x0409},
141 {"SOC_S0I3_CTR", 0x000A},
142 {"PCS_S0I3_CTR", 0x0009},
143 {"PCS_C1E_RES", 0x041A},
144 {"PCS_IDLE_STATUS", 0x2806},
145 {"IA_PERF_LIMITS", 0x280B},
146 {"GT_PERF_LIMITS", 0x280C},
147 {"PCS_WAKEUP_S0IX_CTR", 0x0030},
148 {"PCS_IDLE_BLOCKED", 0x2C00},
149 {"PCS_S0IX_BLOCKED", 0x2C01},
150 {"PCS_S0IX_WAKE_REASONS", 0x2C02},
151 {"PCS_LTR_BLOCKING", 0x2C03},
152 {"PC2_AND_MEM_SHALLOW_IDLE_RES", 0x1D40},
153};
154
54949a60
RB
155static struct telemetry_evtmap
156 telemetry_glk_pss_default_events[TELEM_MAX_OS_ALLOCATED_EVENTS] = {
157 {"IA_CORE0_C6_RES", 0x0400},
158 {"IA_CORE0_C6_CTR", 0x0000},
159 {"IA_MODULE0_C7_RES", 0x0410},
160 {"IA_MODULE0_C7_CTR", 0x000C},
161 {"IA_C0_RES", 0x0805},
162 {"PCS_LTR", 0x2801},
163 {"PSTATES", 0x2802},
164 {"SOC_S0I3_RES", 0x0407},
165 {"SOC_S0I3_CTR", 0x0008},
166 {"PCS_S0I3_CTR", 0x0007},
167 {"PCS_C1E_RES", 0x0414},
168 {"PCS_IDLE_STATUS", 0x2806},
169 {"IA_PERF_LIMITS", 0x280B},
170 {"GT_PERF_LIMITS", 0x280C},
171 {"PCS_WAKEUP_S0IX_CTR", 0x0025},
172 {"PCS_IDLE_BLOCKED", 0x2C00},
173 {"PCS_S0IX_BLOCKED", 0x2C01},
174 {"PCS_S0IX_WAKE_REASONS", 0x2C02},
175 {"PCS_LTR_BLOCKING", 0x2C03},
176 {"PC2_AND_MEM_SHALLOW_IDLE_RES", 0x1D40},
177};
178
9d16b482
SKC
179/* APL specific Data */
180static struct telemetry_plt_config telem_apl_config = {
181 .pss_config = {
182 .telem_evts = telemetry_apl_pss_default_events,
183 },
184 .ioss_config = {
185 .telem_evts = telemetry_apl_ioss_default_events,
186 },
187};
188
54949a60
RB
189/* GLK specific Data */
190static struct telemetry_plt_config telem_glk_config = {
191 .pss_config = {
192 .telem_evts = telemetry_glk_pss_default_events,
193 },
194 .ioss_config = {
195 .telem_evts = telemetry_apl_ioss_default_events,
196 },
197};
198
9d16b482 199static const struct x86_cpu_id telemetry_cpu_ids[] = {
678dec00 200 TELEM_CPU(INTEL_FAM6_ATOM_GOLDMONT, telem_apl_config),
54949a60 201 TELEM_CPU(INTEL_FAM6_ATOM_GEMINI_LAKE, telem_glk_config),
9d16b482
SKC
202 {}
203};
204
205MODULE_DEVICE_TABLE(x86cpu, telemetry_cpu_ids);
206
207static inline int telem_get_unitconfig(enum telemetry_unit telem_unit,
208 struct telemetry_unit_config **unit_config)
209{
210 if (telem_unit == TELEM_PSS)
211 *unit_config = &(telm_conf->pss_config);
212 else if (telem_unit == TELEM_IOSS)
213 *unit_config = &(telm_conf->ioss_config);
214 else
215 return -EINVAL;
216
217 return 0;
218
219}
220
221static int telemetry_check_evtid(enum telemetry_unit telem_unit,
222 u32 *evtmap, u8 len,
223 enum telemetry_action action)
224{
225 struct telemetry_unit_config *unit_config;
226 int ret;
227
228 ret = telem_get_unitconfig(telem_unit, &unit_config);
229 if (ret < 0)
230 return ret;
231
232 switch (action) {
233 case TELEM_RESET:
234 if (len > TELEM_MAX_EVENTS_SRAM)
235 return -EINVAL;
236
237 break;
238
239 case TELEM_UPDATE:
240 if (len > TELEM_MAX_EVENTS_SRAM)
241 return -EINVAL;
242
243 if ((len > 0) && (evtmap == NULL))
244 return -EINVAL;
245
246 break;
247
248 case TELEM_ADD:
249 if ((len + unit_config->ssram_evts_used) >
250 TELEM_MAX_EVENTS_SRAM)
251 return -EINVAL;
252
253 if ((len > 0) && (evtmap == NULL))
254 return -EINVAL;
255
256 break;
257
258 default:
259 pr_err("Unknown Telemetry action Specified %d\n", action);
260 return -EINVAL;
261 }
262
263 return 0;
264}
265
266
267static inline int telemetry_plt_config_ioss_event(u32 evt_id, int index)
268{
269 u32 write_buf;
270 int ret;
271
272 write_buf = evt_id | TELEM_EVENT_ENABLE;
273 write_buf <<= BITS_PER_BYTE;
274 write_buf |= index;
275
276 ret = intel_pmc_ipc_command(PMC_IPC_PMC_TELEMTRY,
277 IOSS_TELEM_EVENT_WRITE, (u8 *)&write_buf,
278 IOSS_TELEM_EVT_WRITE_SIZE, NULL, 0);
279
280 return ret;
281}
282
283static inline int telemetry_plt_config_pss_event(u32 evt_id, int index)
284{
285 u32 write_buf;
286 int ret;
287
288 write_buf = evt_id | TELEM_EVENT_ENABLE;
289 ret = intel_punit_ipc_command(IPC_PUNIT_BIOS_WRITE_TELE_EVENT,
290 index, 0, &write_buf, NULL);
291
292 return ret;
293}
294
295static int telemetry_setup_iossevtconfig(struct telemetry_evtconfig evtconfig,
296 enum telemetry_action action)
297{
298 u8 num_ioss_evts, ioss_period;
299 int ret, index, idx;
300 u32 *ioss_evtmap;
301 u32 telem_ctrl;
302
303 num_ioss_evts = evtconfig.num_evts;
304 ioss_period = evtconfig.period;
305 ioss_evtmap = evtconfig.evtmap;
306
307 /* Get telemetry EVENT CTL */
308 ret = intel_pmc_ipc_command(PMC_IPC_PMC_TELEMTRY,
309 IOSS_TELEM_EVENT_CTL_READ, NULL, 0,
310 &telem_ctrl, IOSS_TELEM_READ_WORD);
311 if (ret) {
312 pr_err("IOSS TELEM_CTRL Read Failed\n");
313 return ret;
314 }
315
316 /* Disable Telemetry */
317 TELEM_DISABLE(telem_ctrl);
318
319 ret = intel_pmc_ipc_command(PMC_IPC_PMC_TELEMTRY,
320 IOSS_TELEM_EVENT_CTL_WRITE,
321 (u8 *)&telem_ctrl,
322 IOSS_TELEM_EVT_CTRL_WRITE_SIZE,
323 NULL, 0);
324 if (ret) {
325 pr_err("IOSS TELEM_CTRL Event Disable Write Failed\n");
326 return ret;
327 }
328
329
330 /* Reset Everything */
331 if (action == TELEM_RESET) {
332 /* Clear All Events */
333 TELEM_CLEAR_EVENTS(telem_ctrl);
334
335 ret = intel_pmc_ipc_command(PMC_IPC_PMC_TELEMTRY,
336 IOSS_TELEM_EVENT_CTL_WRITE,
337 (u8 *)&telem_ctrl,
338 IOSS_TELEM_EVT_CTRL_WRITE_SIZE,
339 NULL, 0);
340 if (ret) {
341 pr_err("IOSS TELEM_CTRL Event Disable Write Failed\n");
342 return ret;
343 }
344 telm_conf->ioss_config.ssram_evts_used = 0;
345
346 /* Configure Events */
347 for (idx = 0; idx < num_ioss_evts; idx++) {
348 if (telemetry_plt_config_ioss_event(
349 telm_conf->ioss_config.telem_evts[idx].evt_id,
350 idx)) {
351 pr_err("IOSS TELEM_RESET Fail for data: %x\n",
352 telm_conf->ioss_config.telem_evts[idx].evt_id);
353 continue;
354 }
355 telm_conf->ioss_config.ssram_evts_used++;
356 }
357 }
358
359 /* Re-Configure Everything */
360 if (action == TELEM_UPDATE) {
361 /* Clear All Events */
362 TELEM_CLEAR_EVENTS(telem_ctrl);
363
364 ret = intel_pmc_ipc_command(PMC_IPC_PMC_TELEMTRY,
365 IOSS_TELEM_EVENT_CTL_WRITE,
366 (u8 *)&telem_ctrl,
367 IOSS_TELEM_EVT_CTRL_WRITE_SIZE,
368 NULL, 0);
369 if (ret) {
370 pr_err("IOSS TELEM_CTRL Event Disable Write Failed\n");
371 return ret;
372 }
373 telm_conf->ioss_config.ssram_evts_used = 0;
374
375 /* Configure Events */
376 for (index = 0; index < num_ioss_evts; index++) {
377 telm_conf->ioss_config.telem_evts[index].evt_id =
378 ioss_evtmap[index];
379
380 if (telemetry_plt_config_ioss_event(
381 telm_conf->ioss_config.telem_evts[index].evt_id,
382 index)) {
383 pr_err("IOSS TELEM_UPDATE Fail for Evt%x\n",
384 ioss_evtmap[index]);
385 continue;
386 }
387 telm_conf->ioss_config.ssram_evts_used++;
388 }
389 }
390
391 /* Add some Events */
392 if (action == TELEM_ADD) {
393 /* Configure Events */
394 for (index = telm_conf->ioss_config.ssram_evts_used, idx = 0;
395 idx < num_ioss_evts; index++, idx++) {
396 telm_conf->ioss_config.telem_evts[index].evt_id =
397 ioss_evtmap[idx];
398
399 if (telemetry_plt_config_ioss_event(
400 telm_conf->ioss_config.telem_evts[index].evt_id,
401 index)) {
402 pr_err("IOSS TELEM_ADD Fail for Event %x\n",
403 ioss_evtmap[idx]);
404 continue;
405 }
406 telm_conf->ioss_config.ssram_evts_used++;
407 }
408 }
409
410 /* Enable Periodic Telemetry Events and enable SRAM trace */
411 TELEM_CLEAR_SAMPLE_PERIOD(telem_ctrl);
412 TELEM_ENABLE_SRAM_EVT_TRACE(telem_ctrl);
413 TELEM_ENABLE_PERIODIC(telem_ctrl);
414 telem_ctrl |= ioss_period;
415
416 ret = intel_pmc_ipc_command(PMC_IPC_PMC_TELEMTRY,
417 IOSS_TELEM_EVENT_CTL_WRITE,
418 (u8 *)&telem_ctrl,
419 IOSS_TELEM_EVT_CTRL_WRITE_SIZE, NULL, 0);
420 if (ret) {
421 pr_err("IOSS TELEM_CTRL Event Enable Write Failed\n");
422 return ret;
423 }
424
425 telm_conf->ioss_config.curr_period = ioss_period;
426
427 return 0;
428}
429
430
431static int telemetry_setup_pssevtconfig(struct telemetry_evtconfig evtconfig,
432 enum telemetry_action action)
433{
434 u8 num_pss_evts, pss_period;
435 int ret, index, idx;
436 u32 *pss_evtmap;
437 u32 telem_ctrl;
438
439 num_pss_evts = evtconfig.num_evts;
440 pss_period = evtconfig.period;
441 pss_evtmap = evtconfig.evtmap;
442
443 /* PSS Config */
444 /* Get telemetry EVENT CTL */
445 ret = intel_punit_ipc_command(IPC_PUNIT_BIOS_READ_TELE_EVENT_CTRL,
446 0, 0, NULL, &telem_ctrl);
447 if (ret) {
448 pr_err("PSS TELEM_CTRL Read Failed\n");
449 return ret;
450 }
451
452 /* Disable Telemetry */
453 TELEM_DISABLE(telem_ctrl);
454 ret = intel_punit_ipc_command(IPC_PUNIT_BIOS_WRITE_TELE_EVENT_CTRL,
455 0, 0, &telem_ctrl, NULL);
456 if (ret) {
457 pr_err("PSS TELEM_CTRL Event Disable Write Failed\n");
458 return ret;
459 }
460
461 /* Reset Everything */
462 if (action == TELEM_RESET) {
463 /* Clear All Events */
464 TELEM_CLEAR_EVENTS(telem_ctrl);
465
466 ret = intel_punit_ipc_command(
467 IPC_PUNIT_BIOS_WRITE_TELE_EVENT_CTRL,
468 0, 0, &telem_ctrl, NULL);
469 if (ret) {
470 pr_err("PSS TELEM_CTRL Event Disable Write Failed\n");
471 return ret;
472 }
473 telm_conf->pss_config.ssram_evts_used = 0;
474 /* Configure Events */
475 for (idx = 0; idx < num_pss_evts; idx++) {
476 if (telemetry_plt_config_pss_event(
477 telm_conf->pss_config.telem_evts[idx].evt_id,
478 idx)) {
479 pr_err("PSS TELEM_RESET Fail for Event %x\n",
480 telm_conf->pss_config.telem_evts[idx].evt_id);
481 continue;
482 }
483 telm_conf->pss_config.ssram_evts_used++;
484 }
485 }
486
487 /* Re-Configure Everything */
488 if (action == TELEM_UPDATE) {
489 /* Clear All Events */
490 TELEM_CLEAR_EVENTS(telem_ctrl);
491
492 ret = intel_punit_ipc_command(
493 IPC_PUNIT_BIOS_WRITE_TELE_EVENT_CTRL,
494 0, 0, &telem_ctrl, NULL);
495 if (ret) {
496 pr_err("PSS TELEM_CTRL Event Disable Write Failed\n");
497 return ret;
498 }
499 telm_conf->pss_config.ssram_evts_used = 0;
500
501 /* Configure Events */
502 for (index = 0; index < num_pss_evts; index++) {
503 telm_conf->pss_config.telem_evts[index].evt_id =
504 pss_evtmap[index];
505
506 if (telemetry_plt_config_pss_event(
507 telm_conf->pss_config.telem_evts[index].evt_id,
508 index)) {
509 pr_err("PSS TELEM_UPDATE Fail for Event %x\n",
510 pss_evtmap[index]);
511 continue;
512 }
513 telm_conf->pss_config.ssram_evts_used++;
514 }
515 }
516
517 /* Add some Events */
518 if (action == TELEM_ADD) {
519 /* Configure Events */
520 for (index = telm_conf->pss_config.ssram_evts_used, idx = 0;
521 idx < num_pss_evts; index++, idx++) {
522
523 telm_conf->pss_config.telem_evts[index].evt_id =
524 pss_evtmap[idx];
525
526 if (telemetry_plt_config_pss_event(
527 telm_conf->pss_config.telem_evts[index].evt_id,
528 index)) {
529 pr_err("PSS TELEM_ADD Fail for Event %x\n",
530 pss_evtmap[idx]);
531 continue;
532 }
533 telm_conf->pss_config.ssram_evts_used++;
534 }
535 }
536
537 /* Enable Periodic Telemetry Events and enable SRAM trace */
538 TELEM_CLEAR_SAMPLE_PERIOD(telem_ctrl);
539 TELEM_ENABLE_SRAM_EVT_TRACE(telem_ctrl);
540 TELEM_ENABLE_PERIODIC(telem_ctrl);
541 telem_ctrl |= pss_period;
542
543 ret = intel_punit_ipc_command(IPC_PUNIT_BIOS_WRITE_TELE_EVENT_CTRL,
544 0, 0, &telem_ctrl, NULL);
545 if (ret) {
546 pr_err("PSS TELEM_CTRL Event Enable Write Failed\n");
547 return ret;
548 }
549
550 telm_conf->pss_config.curr_period = pss_period;
551
552 return 0;
553}
554
555static int telemetry_setup_evtconfig(struct telemetry_evtconfig pss_evtconfig,
556 struct telemetry_evtconfig ioss_evtconfig,
557 enum telemetry_action action)
558{
559 int ret;
560
561 mutex_lock(&(telm_conf->telem_lock));
562
563 if ((action == TELEM_UPDATE) && (telm_conf->telem_in_use)) {
564 ret = -EBUSY;
565 goto out;
566 }
567
568 ret = telemetry_check_evtid(TELEM_PSS, pss_evtconfig.evtmap,
569 pss_evtconfig.num_evts, action);
570 if (ret)
571 goto out;
572
573 ret = telemetry_check_evtid(TELEM_IOSS, ioss_evtconfig.evtmap,
574 ioss_evtconfig.num_evts, action);
575 if (ret)
576 goto out;
577
578 if (ioss_evtconfig.num_evts) {
579 ret = telemetry_setup_iossevtconfig(ioss_evtconfig, action);
580 if (ret)
581 goto out;
582 }
583
584 if (pss_evtconfig.num_evts) {
585 ret = telemetry_setup_pssevtconfig(pss_evtconfig, action);
586 if (ret)
587 goto out;
588 }
589
590 if ((action == TELEM_UPDATE) || (action == TELEM_ADD))
591 telm_conf->telem_in_use = true;
592 else
593 telm_conf->telem_in_use = false;
594
595out:
596 mutex_unlock(&(telm_conf->telem_lock));
597 return ret;
598}
599
600static int telemetry_setup(struct platform_device *pdev)
601{
602 struct telemetry_evtconfig pss_evtconfig, ioss_evtconfig;
603 u32 read_buf, events, event_regs;
604 int ret;
605
606 ret = intel_pmc_ipc_command(PMC_IPC_PMC_TELEMTRY, IOSS_TELEM_INFO_READ,
607 NULL, 0, &read_buf, IOSS_TELEM_READ_WORD);
608 if (ret) {
609 dev_err(&pdev->dev, "IOSS TELEM_INFO Read Failed\n");
610 return ret;
611 }
612
613 /* Get telemetry Info */
614 events = (read_buf & TELEM_INFO_SRAMEVTS_MASK) >>
615 TELEM_INFO_SRAMEVTS_SHIFT;
616 event_regs = read_buf & TELEM_INFO_NENABLES_MASK;
617 if ((events < TELEM_MAX_EVENTS_SRAM) ||
618 (event_regs < TELEM_MAX_EVENTS_SRAM)) {
619 dev_err(&pdev->dev, "IOSS:Insufficient Space for SRAM Trace\n");
620 dev_err(&pdev->dev, "SRAM Events %d; Event Regs %d\n",
621 events, event_regs);
622 return -ENOMEM;
623 }
624
625 telm_conf->ioss_config.min_period = TELEM_MIN_PERIOD(read_buf);
626 telm_conf->ioss_config.max_period = TELEM_MAX_PERIOD(read_buf);
627
628 /* PUNIT Mailbox Setup */
629 ret = intel_punit_ipc_command(IPC_PUNIT_BIOS_READ_TELE_INFO, 0, 0,
630 NULL, &read_buf);
631 if (ret) {
632 dev_err(&pdev->dev, "PSS TELEM_INFO Read Failed\n");
633 return ret;
634 }
635
636 /* Get telemetry Info */
637 events = (read_buf & TELEM_INFO_SRAMEVTS_MASK) >>
638 TELEM_INFO_SRAMEVTS_SHIFT;
639 event_regs = read_buf & TELEM_INFO_SRAMEVTS_MASK;
640 if ((events < TELEM_MAX_EVENTS_SRAM) ||
641 (event_regs < TELEM_MAX_EVENTS_SRAM)) {
642 dev_err(&pdev->dev, "PSS:Insufficient Space for SRAM Trace\n");
643 dev_err(&pdev->dev, "SRAM Events %d; Event Regs %d\n",
644 events, event_regs);
645 return -ENOMEM;
646 }
647
648 telm_conf->pss_config.min_period = TELEM_MIN_PERIOD(read_buf);
649 telm_conf->pss_config.max_period = TELEM_MAX_PERIOD(read_buf);
650
651 pss_evtconfig.evtmap = NULL;
652 pss_evtconfig.num_evts = TELEM_MAX_OS_ALLOCATED_EVENTS;
653 pss_evtconfig.period = TELEM_SAMPLING_DEFAULT_PERIOD;
654
655 ioss_evtconfig.evtmap = NULL;
656 ioss_evtconfig.num_evts = TELEM_MAX_OS_ALLOCATED_EVENTS;
657 ioss_evtconfig.period = TELEM_SAMPLING_DEFAULT_PERIOD;
658
659 ret = telemetry_setup_evtconfig(pss_evtconfig, ioss_evtconfig,
660 TELEM_RESET);
661 if (ret) {
662 dev_err(&pdev->dev, "TELEMTRY Setup Failed\n");
663 return ret;
664 }
665 return 0;
666}
667
668static int telemetry_plt_update_events(struct telemetry_evtconfig pss_evtconfig,
669 struct telemetry_evtconfig ioss_evtconfig)
670{
671 int ret;
672
673 if ((pss_evtconfig.num_evts > 0) &&
674 (TELEM_SAMPLE_PERIOD_INVALID(pss_evtconfig.period))) {
675 pr_err("PSS Sampling Period Out of Range\n");
676 return -EINVAL;
677 }
678
679 if ((ioss_evtconfig.num_evts > 0) &&
680 (TELEM_SAMPLE_PERIOD_INVALID(ioss_evtconfig.period))) {
681 pr_err("IOSS Sampling Period Out of Range\n");
682 return -EINVAL;
683 }
684
685 ret = telemetry_setup_evtconfig(pss_evtconfig, ioss_evtconfig,
686 TELEM_UPDATE);
687 if (ret)
688 pr_err("TELEMTRY Config Failed\n");
689
690 return ret;
691}
692
693
694static int telemetry_plt_set_sampling_period(u8 pss_period, u8 ioss_period)
695{
696 u32 telem_ctrl = 0;
d0192dca 697 int ret = 0;
9d16b482
SKC
698
699 mutex_lock(&(telm_conf->telem_lock));
700 if (ioss_period) {
701 if (TELEM_SAMPLE_PERIOD_INVALID(ioss_period)) {
702 pr_err("IOSS Sampling Period Out of Range\n");
703 ret = -EINVAL;
704 goto out;
705 }
706
707 /* Get telemetry EVENT CTL */
708 ret = intel_pmc_ipc_command(PMC_IPC_PMC_TELEMTRY,
709 IOSS_TELEM_EVENT_CTL_READ, NULL, 0,
710 &telem_ctrl, IOSS_TELEM_READ_WORD);
711 if (ret) {
712 pr_err("IOSS TELEM_CTRL Read Failed\n");
713 goto out;
714 }
715
716 /* Disable Telemetry */
717 TELEM_DISABLE(telem_ctrl);
718
719 ret = intel_pmc_ipc_command(PMC_IPC_PMC_TELEMTRY,
720 IOSS_TELEM_EVENT_CTL_WRITE,
721 (u8 *)&telem_ctrl,
722 IOSS_TELEM_EVT_CTRL_WRITE_SIZE,
723 NULL, 0);
724 if (ret) {
725 pr_err("IOSS TELEM_CTRL Event Disable Write Failed\n");
726 goto out;
727 }
728
729 /* Enable Periodic Telemetry Events and enable SRAM trace */
730 TELEM_CLEAR_SAMPLE_PERIOD(telem_ctrl);
731 TELEM_ENABLE_SRAM_EVT_TRACE(telem_ctrl);
732 TELEM_ENABLE_PERIODIC(telem_ctrl);
733 telem_ctrl |= ioss_period;
734
735 ret = intel_pmc_ipc_command(PMC_IPC_PMC_TELEMTRY,
736 IOSS_TELEM_EVENT_CTL_WRITE,
737 (u8 *)&telem_ctrl,
738 IOSS_TELEM_EVT_CTRL_WRITE_SIZE,
739 NULL, 0);
740 if (ret) {
741 pr_err("IOSS TELEM_CTRL Event Enable Write Failed\n");
742 goto out;
743 }
744 telm_conf->ioss_config.curr_period = ioss_period;
745 }
746
747 if (pss_period) {
748 if (TELEM_SAMPLE_PERIOD_INVALID(pss_period)) {
749 pr_err("PSS Sampling Period Out of Range\n");
750 ret = -EINVAL;
751 goto out;
752 }
753
754 /* Get telemetry EVENT CTL */
755 ret = intel_punit_ipc_command(
756 IPC_PUNIT_BIOS_READ_TELE_EVENT_CTRL,
757 0, 0, NULL, &telem_ctrl);
758 if (ret) {
759 pr_err("PSS TELEM_CTRL Read Failed\n");
760 goto out;
761 }
762
763 /* Disable Telemetry */
764 TELEM_DISABLE(telem_ctrl);
765 ret = intel_punit_ipc_command(
766 IPC_PUNIT_BIOS_WRITE_TELE_EVENT_CTRL,
767 0, 0, &telem_ctrl, NULL);
768 if (ret) {
769 pr_err("PSS TELEM_CTRL Event Disable Write Failed\n");
770 goto out;
771 }
772
773 /* Enable Periodic Telemetry Events and enable SRAM trace */
774 TELEM_CLEAR_SAMPLE_PERIOD(telem_ctrl);
775 TELEM_ENABLE_SRAM_EVT_TRACE(telem_ctrl);
776 TELEM_ENABLE_PERIODIC(telem_ctrl);
777 telem_ctrl |= pss_period;
778
779 ret = intel_punit_ipc_command(
780 IPC_PUNIT_BIOS_WRITE_TELE_EVENT_CTRL,
781 0, 0, &telem_ctrl, NULL);
782 if (ret) {
783 pr_err("PSS TELEM_CTRL Event Enable Write Failed\n");
784 goto out;
785 }
786 telm_conf->pss_config.curr_period = pss_period;
787 }
788
789out:
790 mutex_unlock(&(telm_conf->telem_lock));
791 return ret;
792}
793
794
795static int telemetry_plt_get_sampling_period(u8 *pss_min_period,
796 u8 *pss_max_period,
797 u8 *ioss_min_period,
798 u8 *ioss_max_period)
799{
800 *pss_min_period = telm_conf->pss_config.min_period;
801 *pss_max_period = telm_conf->pss_config.max_period;
802 *ioss_min_period = telm_conf->ioss_config.min_period;
803 *ioss_max_period = telm_conf->ioss_config.max_period;
804
805 return 0;
806}
807
808
809static int telemetry_plt_reset_events(void)
810{
811 struct telemetry_evtconfig pss_evtconfig, ioss_evtconfig;
812 int ret;
813
814 pss_evtconfig.evtmap = NULL;
815 pss_evtconfig.num_evts = TELEM_MAX_OS_ALLOCATED_EVENTS;
816 pss_evtconfig.period = TELEM_SAMPLING_DEFAULT_PERIOD;
817
818 ioss_evtconfig.evtmap = NULL;
819 ioss_evtconfig.num_evts = TELEM_MAX_OS_ALLOCATED_EVENTS;
820 ioss_evtconfig.period = TELEM_SAMPLING_DEFAULT_PERIOD;
821
822 ret = telemetry_setup_evtconfig(pss_evtconfig, ioss_evtconfig,
823 TELEM_RESET);
824 if (ret)
825 pr_err("TELEMTRY Reset Failed\n");
826
827 return ret;
828}
829
830
831static int telemetry_plt_get_eventconfig(struct telemetry_evtconfig *pss_config,
832 struct telemetry_evtconfig *ioss_config,
833 int pss_len, int ioss_len)
834{
835 u32 *pss_evtmap, *ioss_evtmap;
836 u32 index;
837
838 pss_evtmap = pss_config->evtmap;
839 ioss_evtmap = ioss_config->evtmap;
840
841 mutex_lock(&(telm_conf->telem_lock));
842 pss_config->num_evts = telm_conf->pss_config.ssram_evts_used;
843 ioss_config->num_evts = telm_conf->ioss_config.ssram_evts_used;
844
845 pss_config->period = telm_conf->pss_config.curr_period;
846 ioss_config->period = telm_conf->ioss_config.curr_period;
847
848 if ((pss_len < telm_conf->pss_config.ssram_evts_used) ||
849 (ioss_len < telm_conf->ioss_config.ssram_evts_used)) {
850 mutex_unlock(&(telm_conf->telem_lock));
851 return -EINVAL;
852 }
853
854 for (index = 0; index < telm_conf->pss_config.ssram_evts_used;
855 index++) {
856 pss_evtmap[index] =
857 telm_conf->pss_config.telem_evts[index].evt_id;
858 }
859
860 for (index = 0; index < telm_conf->ioss_config.ssram_evts_used;
861 index++) {
862 ioss_evtmap[index] =
863 telm_conf->ioss_config.telem_evts[index].evt_id;
864 }
865
866 mutex_unlock(&(telm_conf->telem_lock));
867 return 0;
868}
869
870
871static int telemetry_plt_add_events(u8 num_pss_evts, u8 num_ioss_evts,
872 u32 *pss_evtmap, u32 *ioss_evtmap)
873{
874 struct telemetry_evtconfig pss_evtconfig, ioss_evtconfig;
875 int ret;
876
877 pss_evtconfig.evtmap = pss_evtmap;
878 pss_evtconfig.num_evts = num_pss_evts;
879 pss_evtconfig.period = telm_conf->pss_config.curr_period;
880
881 ioss_evtconfig.evtmap = ioss_evtmap;
882 ioss_evtconfig.num_evts = num_ioss_evts;
883 ioss_evtconfig.period = telm_conf->ioss_config.curr_period;
884
885 ret = telemetry_setup_evtconfig(pss_evtconfig, ioss_evtconfig,
886 TELEM_ADD);
887 if (ret)
888 pr_err("TELEMTRY ADD Failed\n");
889
890 return ret;
891}
892
893static int telem_evtlog_read(enum telemetry_unit telem_unit,
894 struct telem_ssram_region *ssram_region, u8 len)
895{
896 struct telemetry_unit_config *unit_config;
897 u64 timestamp_prev, timestamp_next;
898 int ret, index, timeout = 0;
899
900 ret = telem_get_unitconfig(telem_unit, &unit_config);
901 if (ret < 0)
902 return ret;
903
904 if (len > unit_config->ssram_evts_used)
905 len = unit_config->ssram_evts_used;
906
907 do {
908 timestamp_prev = readq(unit_config->regmap);
909 if (!timestamp_prev) {
910 pr_err("Ssram under update. Please Try Later\n");
911 return -EBUSY;
912 }
913
914 ssram_region->start_time = readq(unit_config->regmap +
915 TELEM_SSRAM_STARTTIME_OFFSET);
916
917 for (index = 0; index < len; index++) {
918 ssram_region->events[index] =
919 readq(unit_config->regmap + TELEM_SSRAM_EVTLOG_OFFSET +
920 BYTES_PER_LONG*index);
921 }
922
923 timestamp_next = readq(unit_config->regmap);
924 if (!timestamp_next) {
925 pr_err("Ssram under update. Please Try Later\n");
926 return -EBUSY;
927 }
928
929 if (timeout++ > TELEM_SSRAM_READ_TIMEOUT) {
930 pr_err("Timeout while reading Events\n");
931 return -EBUSY;
932 }
933
934 } while (timestamp_prev != timestamp_next);
935
936 ssram_region->timestamp = timestamp_next;
937
938 return len;
939}
940
941static int telemetry_plt_raw_read_eventlog(enum telemetry_unit telem_unit,
942 struct telemetry_evtlog *evtlog,
943 int len, int log_all_evts)
944{
945 int index, idx1, ret, readlen = len;
946 struct telem_ssram_region ssram_region;
947 struct telemetry_evtmap *evtmap;
948
949 switch (telem_unit) {
950 case TELEM_PSS:
951 evtmap = telm_conf->pss_config.telem_evts;
952 break;
953
954 case TELEM_IOSS:
955 evtmap = telm_conf->ioss_config.telem_evts;
956 break;
957
958 default:
959 pr_err("Unknown Telemetry Unit Specified %d\n", telem_unit);
960 return -EINVAL;
961 }
962
963 if (!log_all_evts)
964 readlen = TELEM_MAX_EVENTS_SRAM;
965
966 ret = telem_evtlog_read(telem_unit, &ssram_region, readlen);
967 if (ret < 0)
968 return ret;
969
970 /* Invalid evt-id array specified via length mismatch */
971 if ((!log_all_evts) && (len > ret))
972 return -EINVAL;
973
974 if (log_all_evts)
975 for (index = 0; index < ret; index++) {
976 evtlog[index].telem_evtlog = ssram_region.events[index];
977 evtlog[index].telem_evtid = evtmap[index].evt_id;
978 }
979 else
980 for (index = 0, readlen = 0; (index < ret) && (readlen < len);
981 index++) {
982 for (idx1 = 0; idx1 < len; idx1++) {
983 /* Elements matched */
984 if (evtmap[index].evt_id ==
985 evtlog[idx1].telem_evtid) {
986 evtlog[idx1].telem_evtlog =
987 ssram_region.events[index];
988 readlen++;
989
990 break;
991 }
992 }
993 }
994
995 return readlen;
996}
997
998static int telemetry_plt_read_eventlog(enum telemetry_unit telem_unit,
999 struct telemetry_evtlog *evtlog, int len, int log_all_evts)
1000{
1001 int ret;
1002
1003 mutex_lock(&(telm_conf->telem_lock));
1004 ret = telemetry_plt_raw_read_eventlog(telem_unit, evtlog,
1005 len, log_all_evts);
1006 mutex_unlock(&(telm_conf->telem_lock));
1007
1008 return ret;
1009}
1010
1011static int telemetry_plt_get_trace_verbosity(enum telemetry_unit telem_unit,
1012 u32 *verbosity)
1013{
1014 u32 temp = 0;
1015 int ret;
1016
1017 if (verbosity == NULL)
1018 return -EINVAL;
1019
1020 mutex_lock(&(telm_conf->telem_trace_lock));
1021 switch (telem_unit) {
1022 case TELEM_PSS:
1023 ret = intel_punit_ipc_command(
1024 IPC_PUNIT_BIOS_READ_TELE_TRACE_CTRL,
1025 0, 0, NULL, &temp);
1026 if (ret) {
1027 pr_err("PSS TRACE_CTRL Read Failed\n");
1028 goto out;
1029 }
1030
1031 break;
1032
1033 case TELEM_IOSS:
1034 ret = intel_pmc_ipc_command(PMC_IPC_PMC_TELEMTRY,
1035 IOSS_TELEM_TRACE_CTL_READ, NULL, 0, &temp,
1036 IOSS_TELEM_READ_WORD);
1037 if (ret) {
1038 pr_err("IOSS TRACE_CTL Read Failed\n");
1039 goto out;
1040 }
1041
1042 break;
1043
1044 default:
1045 pr_err("Unknown Telemetry Unit Specified %d\n", telem_unit);
1046 ret = -EINVAL;
1047 break;
1048 }
1049 TELEM_EXTRACT_VERBOSITY(temp, *verbosity);
1050
1051out:
1052 mutex_unlock(&(telm_conf->telem_trace_lock));
1053 return ret;
1054}
1055
1056static int telemetry_plt_set_trace_verbosity(enum telemetry_unit telem_unit,
1057 u32 verbosity)
1058{
1059 u32 temp = 0;
1060 int ret;
1061
1062 verbosity &= TELEM_TRC_VERBOSITY_MASK;
1063
1064 mutex_lock(&(telm_conf->telem_trace_lock));
1065 switch (telem_unit) {
1066 case TELEM_PSS:
479f3b62
SKC
1067 ret = intel_punit_ipc_command(
1068 IPC_PUNIT_BIOS_READ_TELE_TRACE_CTRL,
1069 0, 0, NULL, &temp);
1070 if (ret) {
1071 pr_err("PSS TRACE_CTRL Read Failed\n");
1072 goto out;
1073 }
1074
1075 TELEM_CLEAR_VERBOSITY_BITS(temp);
1076 TELEM_SET_VERBOSITY_BITS(temp, verbosity);
1077
9d16b482
SKC
1078 ret = intel_punit_ipc_command(
1079 IPC_PUNIT_BIOS_WRITE_TELE_TRACE_CTRL,
479f3b62 1080 0, 0, &temp, NULL);
9d16b482
SKC
1081 if (ret) {
1082 pr_err("PSS TRACE_CTRL Verbosity Set Failed\n");
1083 goto out;
1084 }
1085 break;
1086
1087 case TELEM_IOSS:
1088 ret = intel_pmc_ipc_command(PMC_IPC_PMC_TELEMTRY,
1089 IOSS_TELEM_TRACE_CTL_READ, NULL, 0, &temp,
1090 IOSS_TELEM_READ_WORD);
1091 if (ret) {
1092 pr_err("IOSS TRACE_CTL Read Failed\n");
1093 goto out;
1094 }
1095
1096 TELEM_CLEAR_VERBOSITY_BITS(temp);
1097 TELEM_SET_VERBOSITY_BITS(temp, verbosity);
1098
1099 ret = intel_pmc_ipc_command(PMC_IPC_PMC_TELEMTRY,
1100 IOSS_TELEM_TRACE_CTL_WRITE, (u8 *)&temp,
1101 IOSS_TELEM_WRITE_FOURBYTES, NULL, 0);
1102 if (ret) {
1103 pr_err("IOSS TRACE_CTL Verbosity Set Failed\n");
1104 goto out;
1105 }
1106 break;
1107
1108 default:
1109 pr_err("Unknown Telemetry Unit Specified %d\n", telem_unit);
1110 ret = -EINVAL;
1111 break;
1112 }
1113
1114out:
1115 mutex_unlock(&(telm_conf->telem_trace_lock));
1116 return ret;
1117}
1118
775d054a 1119static const struct telemetry_core_ops telm_pltops = {
9d16b482
SKC
1120 .get_trace_verbosity = telemetry_plt_get_trace_verbosity,
1121 .set_trace_verbosity = telemetry_plt_set_trace_verbosity,
1122 .set_sampling_period = telemetry_plt_set_sampling_period,
1123 .get_sampling_period = telemetry_plt_get_sampling_period,
1124 .raw_read_eventlog = telemetry_plt_raw_read_eventlog,
1125 .get_eventconfig = telemetry_plt_get_eventconfig,
1126 .update_events = telemetry_plt_update_events,
1127 .read_eventlog = telemetry_plt_read_eventlog,
1128 .reset_events = telemetry_plt_reset_events,
1129 .add_events = telemetry_plt_add_events,
1130};
1131
1132static int telemetry_pltdrv_probe(struct platform_device *pdev)
1133{
1134 struct resource *res0 = NULL, *res1 = NULL;
1135 const struct x86_cpu_id *id;
1136 int size, ret = -ENOMEM;
1137
1138 id = x86_match_cpu(telemetry_cpu_ids);
1139 if (!id)
1140 return -ENODEV;
1141
1142 telm_conf = (struct telemetry_plt_config *)id->driver_data;
1143
1144 res0 = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1145 if (!res0) {
1146 ret = -EINVAL;
1147 goto out;
1148 }
1149 size = resource_size(res0);
1150 if (!devm_request_mem_region(&pdev->dev, res0->start, size,
1151 pdev->name)) {
1152 ret = -EBUSY;
1153 goto out;
1154 }
1155 telm_conf->pss_config.ssram_base_addr = res0->start;
1156 telm_conf->pss_config.ssram_size = size;
1157
1158 res1 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
1159 if (!res1) {
1160 ret = -EINVAL;
1161 goto out;
1162 }
1163 size = resource_size(res1);
1164 if (!devm_request_mem_region(&pdev->dev, res1->start, size,
1165 pdev->name)) {
1166 ret = -EBUSY;
1167 goto out;
1168 }
1169
1170 telm_conf->ioss_config.ssram_base_addr = res1->start;
1171 telm_conf->ioss_config.ssram_size = size;
1172
1173 telm_conf->pss_config.regmap = ioremap_nocache(
1174 telm_conf->pss_config.ssram_base_addr,
1175 telm_conf->pss_config.ssram_size);
1176 if (!telm_conf->pss_config.regmap) {
1177 ret = -ENOMEM;
1178 goto out;
1179 }
1180
1181 telm_conf->ioss_config.regmap = ioremap_nocache(
1182 telm_conf->ioss_config.ssram_base_addr,
1183 telm_conf->ioss_config.ssram_size);
1184 if (!telm_conf->ioss_config.regmap) {
1185 ret = -ENOMEM;
1186 goto out;
1187 }
1188
1189 mutex_init(&telm_conf->telem_lock);
1190 mutex_init(&telm_conf->telem_trace_lock);
1191
1192 ret = telemetry_setup(pdev);
1193 if (ret)
1194 goto out;
1195
1196 ret = telemetry_set_pltdata(&telm_pltops, telm_conf);
1197 if (ret) {
1198 dev_err(&pdev->dev, "TELEMTRY Set Pltops Failed.\n");
1199 goto out;
1200 }
1201
1202 return 0;
1203
1204out:
1205 if (res0)
1206 release_mem_region(res0->start, resource_size(res0));
1207 if (res1)
1208 release_mem_region(res1->start, resource_size(res1));
1209 if (telm_conf->pss_config.regmap)
1210 iounmap(telm_conf->pss_config.regmap);
1211 if (telm_conf->ioss_config.regmap)
1212 iounmap(telm_conf->ioss_config.regmap);
1213 dev_err(&pdev->dev, "TELEMTRY Setup Failed.\n");
1214
1215 return ret;
1216}
1217
1218static int telemetry_pltdrv_remove(struct platform_device *pdev)
1219{
1220 telemetry_clear_pltdata();
1221 iounmap(telm_conf->pss_config.regmap);
1222 iounmap(telm_conf->ioss_config.regmap);
1223
1224 return 0;
1225}
1226
1227static struct platform_driver telemetry_soc_driver = {
1228 .probe = telemetry_pltdrv_probe,
1229 .remove = telemetry_pltdrv_remove,
1230 .driver = {
1231 .name = DRIVER_NAME,
1232 },
1233};
1234
1235static int __init telemetry_module_init(void)
1236{
9d16b482
SKC
1237 return platform_driver_register(&telemetry_soc_driver);
1238}
1239
1240static void __exit telemetry_module_exit(void)
1241{
1242 platform_driver_unregister(&telemetry_soc_driver);
1243}
1244
1245device_initcall(telemetry_module_init);
1246module_exit(telemetry_module_exit);
1247
1248MODULE_AUTHOR("Souvik Kumar Chakravarty <souvik.k.chakravarty@intel.com>");
1249MODULE_DESCRIPTION("Intel SoC Telemetry Platform Driver");
1250MODULE_VERSION(DRIVER_VERSION);
1251MODULE_LICENSE("GPL");