forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/arch/parisc/kernel/firmware.c
....@@ -1,9 +1,11 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * arch/parisc/kernel/firmware.c - safe PDC access routines
34 *
45 * PDC == Processor Dependent Code
56 *
6
- * See http://www.parisc-linux.org/documentation/index.html
7
+ * See PDC documentation at
8
+ * https://parisc.wiki.kernel.org/index.php/Technical_Documentation
79 * for documentation describing the entry points and calling
810 * conventions defined below.
911 *
....@@ -12,12 +14,6 @@
1214 * Copyright 2003 Grant Grundler <grundler parisc-linux org>
1315 * Copyright 2003,2004 Ryan Bradetich <rbrad@parisc-linux.org>
1416 * Copyright 2004,2006 Thibaut VARENE <varenet@parisc-linux.org>
15
- *
16
- * This program is free software; you can redistribute it and/or modify
17
- * it under the terms of the GNU General Public License as published by
18
- * the Free Software Foundation; either version 2 of the License, or
19
- * (at your option) any later version.
20
- *
2117 */
2218
2319 /* I think it would be in everyone's best interest to follow this
....@@ -87,7 +83,7 @@
8783
8884 /* Firmware needs to be initially set to narrow to determine the
8985 * actual firmware width. */
90
-int parisc_narrow_firmware __read_mostly = 1;
86
+int parisc_narrow_firmware __ro_after_init = 1;
9187 #endif
9288
9389 /* On most currently-supported platforms, IODC I/O calls are 32-bit calls
....@@ -315,6 +311,19 @@
315311
316312 return retval;
317313 }
314
+
315
+/**
316
+ * pdc_cpu_rendenzvous - Stop currently executing CPU
317
+ * @retval: -1 on error, 0 on success
318
+ */
319
+int __pdc_cpu_rendezvous(void)
320
+{
321
+ if (is_pdc_pat())
322
+ return mem_pdc_call(PDC_PAT_CPU, PDC_PAT_CPU_RENDEZVOUS);
323
+ else
324
+ return mem_pdc_call(PDC_PROC, 1, 0);
325
+}
326
+
318327
319328 /**
320329 * pdc_chassis_warn - Fetches chassis warnings
....@@ -566,6 +575,30 @@
566575 spin_unlock_irqrestore(&pdc_lock, flags);
567576
568577 return retval;
578
+}
579
+
580
+/**
581
+ * pdc_model_platform_info - Returns machine product and serial number.
582
+ * @orig_prod_num: Return buffer for original product number.
583
+ * @current_prod_num: Return buffer for current product number.
584
+ * @serial_no: Return buffer for serial number.
585
+ *
586
+ * Returns strings containing the original and current product numbers and the
587
+ * serial number of the system.
588
+ */
589
+int pdc_model_platform_info(char *orig_prod_num, char *current_prod_num,
590
+ char *serial_no)
591
+{
592
+ int retval;
593
+ unsigned long flags;
594
+
595
+ spin_lock_irqsave(&pdc_lock, flags);
596
+ retval = mem_pdc_call(PDC_MODEL, PDC_MODEL_GET_PLATFORM_INFO,
597
+ __pa(orig_prod_num), __pa(current_prod_num), __pa(serial_no));
598
+ convert_to_wide(pdc_result);
599
+ spin_unlock_irqrestore(&pdc_lock, flags);
600
+
601
+ return retval;
569602 }
570603
571604 /**
....@@ -1326,6 +1359,36 @@
13261359 }
13271360
13281361 /**
1362
+ * pdc_pat_cell_info - Retrieve the cell's information.
1363
+ * @info: The pointer to a struct pdc_pat_cell_info_rtn_block.
1364
+ * @actcnt: The number of bytes which should be written to info.
1365
+ * @offset: offset of the structure.
1366
+ * @cell_number: The cell number which should be asked, or -1 for current cell.
1367
+ *
1368
+ * This PDC call returns information about the given cell (or all cells).
1369
+ */
1370
+int pdc_pat_cell_info(struct pdc_pat_cell_info_rtn_block *info,
1371
+ unsigned long *actcnt, unsigned long offset,
1372
+ unsigned long cell_number)
1373
+{
1374
+ int retval;
1375
+ unsigned long flags;
1376
+ struct pdc_pat_cell_info_rtn_block result;
1377
+
1378
+ spin_lock_irqsave(&pdc_lock, flags);
1379
+ retval = mem_pdc_call(PDC_PAT_CELL, PDC_PAT_CELL_GET_INFO,
1380
+ __pa(pdc_result), __pa(&result), *actcnt,
1381
+ offset, cell_number);
1382
+ if (!retval) {
1383
+ *actcnt = pdc_result[0];
1384
+ memcpy(info, &result, *actcnt);
1385
+ }
1386
+ spin_unlock_irqrestore(&pdc_lock, flags);
1387
+
1388
+ return retval;
1389
+}
1390
+
1391
+/**
13291392 * pdc_pat_cpu_get_number - Retrieve the cpu number.
13301393 * @cpu_info: The return buffer.
13311394 * @hpa: The Hard Physical Address of the CPU.
....@@ -1413,6 +1476,33 @@
14131476 }
14141477
14151478 /**
1479
+ * pdc_pat_pd_get_PDC_interface_revisions - Retrieve PDC interface revisions.
1480
+ * @legacy_rev: The legacy revision.
1481
+ * @pat_rev: The PAT revision.
1482
+ * @pdc_cap: The PDC capabilities.
1483
+ *
1484
+ */
1485
+int pdc_pat_pd_get_pdc_revisions(unsigned long *legacy_rev,
1486
+ unsigned long *pat_rev, unsigned long *pdc_cap)
1487
+{
1488
+ int retval;
1489
+ unsigned long flags;
1490
+
1491
+ spin_lock_irqsave(&pdc_lock, flags);
1492
+ retval = mem_pdc_call(PDC_PAT_PD, PDC_PAT_PD_GET_PDC_INTERF_REV,
1493
+ __pa(pdc_result));
1494
+ if (retval == PDC_OK) {
1495
+ *legacy_rev = pdc_result[0];
1496
+ *pat_rev = pdc_result[1];
1497
+ *pdc_cap = pdc_result[2];
1498
+ }
1499
+ spin_unlock_irqrestore(&pdc_lock, flags);
1500
+
1501
+ return retval;
1502
+}
1503
+
1504
+
1505
+/**
14161506 * pdc_pat_io_pci_cfg_read - Read PCI configuration space.
14171507 * @pci_addr: PCI configuration space address for which the read request is being made.
14181508 * @pci_size: Size of read in bytes. Valid values are 1, 2, and 4.