Skip to content

Commit d1f6be5

Browse files
committed
Merge tag 'cpufreq-arm-updates-6.7-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm
Merge ARM cpufreq updates for 6.7 (part 2) from Viresh kumar: "- Add support for several Qualcomm SoC versions (Robert Marko and Varadarajan Narayanan)." * tag 'cpufreq-arm-updates-6.7-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm: cpufreq: qcom-nvmem: Introduce cpufreq for ipq95xx cpufreq: qcom-nvmem: Enable cpufreq for ipq53xx cpufreq: qcom-nvmem: add support for IPQ8074 soc: qcom: socinfo: Add IDs for IPQ8174 family dt-bindings: arm: qcom,ids: Add IDs for IPQ8174 family dt-bindings: qcom: geni-se: Allow dma-coherent soc: qcom: socinfo: Add SoC ID for QCM6490 dt-bindings: arm: qcom,ids: Add SoC ID for QCM6490 soc: qcom: socinfo: Add SM8550-adjacent PMICs soc: qcom: wcnss_ctrl: Remove redundant initialization owner in wcnss_ctrl_driver soc: qcom: socinfo: Add Soc ID for SM7150P dt-bindings: arm: qcom,ids: Add Soc ID for SM7150P firmware: Add support for Qualcomm UEFI Secure Application firmware: qcom_scm: Add support for Qualcomm Secure Execution Environment SCM interface lib/ucs2_string: Add UCS-2 strscpy function
2 parents ad1871a + 5b5b580 commit d1f6be5

File tree

16 files changed

+1633
-1
lines changed

16 files changed

+1633
-1
lines changed

Documentation/devicetree/bindings/soc/qcom/qcom,geni-se.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ properties:
5252
iommus:
5353
maxItems: 1
5454

55+
dma-coherent: true
56+
5557
required:
5658
- compatible
5759
- reg

MAINTAINERS

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17844,6 +17844,18 @@ S: Maintained
1784417844
F: Documentation/devicetree/bindings/mtd/qcom,nandc.yaml
1784517845
F: drivers/mtd/nand/raw/qcom_nandc.c
1784617846

17847+
QUALCOMM QSEECOM DRIVER
17848+
M: Maximilian Luz <[email protected]>
17849+
17850+
S: Maintained
17851+
F: drivers/firmware/qcom_qseecom.c
17852+
17853+
QUALCOMM QSEECOM UEFISECAPP DRIVER
17854+
M: Maximilian Luz <[email protected]>
17855+
17856+
S: Maintained
17857+
F: drivers/firmware/qcom_qseecom_uefisecapp.c
17858+
1784717859
QUALCOMM RMNET DRIVER
1784817860
M: Subash Abhinov Kasiviswanathan <[email protected]>
1784917861
M: Sean Tranchetti <[email protected]>

drivers/cpufreq/cpufreq-dt-platdev.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,11 @@ static const struct of_device_id blocklist[] __initconst = {
180180
{ .compatible = "ti,am62a7", },
181181
{ .compatible = "ti,am62p5", },
182182

183+
{ .compatible = "qcom,ipq5332", },
183184
{ .compatible = "qcom,ipq6018", },
184185
{ .compatible = "qcom,ipq8064", },
186+
{ .compatible = "qcom,ipq8074", },
187+
{ .compatible = "qcom,ipq9574", },
185188
{ .compatible = "qcom,apq8064", },
186189
{ .compatible = "qcom,msm8974", },
187190
{ .compatible = "qcom,msm8960", },

drivers/cpufreq/qcom-cpufreq-nvmem.c

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ enum ipq806x_versions {
3838

3939
#define IPQ6000_VERSION BIT(2)
4040

41+
enum ipq8074_versions {
42+
IPQ8074_HAWKEYE_VERSION = 0,
43+
IPQ8074_ACORN_VERSION,
44+
};
45+
4146
struct qcom_cpufreq_drv;
4247

4348
struct qcom_cpufreq_match_data {
@@ -178,6 +183,16 @@ static int qcom_cpufreq_kryo_name_version(struct device *cpu_dev,
178183
switch (msm_id) {
179184
case QCOM_ID_MSM8996:
180185
case QCOM_ID_APQ8096:
186+
case QCOM_ID_IPQ5332:
187+
case QCOM_ID_IPQ5322:
188+
case QCOM_ID_IPQ5312:
189+
case QCOM_ID_IPQ5302:
190+
case QCOM_ID_IPQ5300:
191+
case QCOM_ID_IPQ9514:
192+
case QCOM_ID_IPQ9550:
193+
case QCOM_ID_IPQ9554:
194+
case QCOM_ID_IPQ9570:
195+
case QCOM_ID_IPQ9574:
181196
drv->versions = 1 << (unsigned int)(*speedbin);
182197
break;
183198
case QCOM_ID_MSM8996SG:
@@ -338,6 +353,44 @@ static int qcom_cpufreq_ipq6018_name_version(struct device *cpu_dev,
338353
return 0;
339354
}
340355

356+
static int qcom_cpufreq_ipq8074_name_version(struct device *cpu_dev,
357+
struct nvmem_cell *speedbin_nvmem,
358+
char **pvs_name,
359+
struct qcom_cpufreq_drv *drv)
360+
{
361+
u32 msm_id;
362+
int ret;
363+
*pvs_name = NULL;
364+
365+
ret = qcom_smem_get_soc_id(&msm_id);
366+
if (ret)
367+
return ret;
368+
369+
switch (msm_id) {
370+
case QCOM_ID_IPQ8070A:
371+
case QCOM_ID_IPQ8071A:
372+
case QCOM_ID_IPQ8172:
373+
case QCOM_ID_IPQ8173:
374+
case QCOM_ID_IPQ8174:
375+
drv->versions = BIT(IPQ8074_ACORN_VERSION);
376+
break;
377+
case QCOM_ID_IPQ8072A:
378+
case QCOM_ID_IPQ8074A:
379+
case QCOM_ID_IPQ8076A:
380+
case QCOM_ID_IPQ8078A:
381+
drv->versions = BIT(IPQ8074_HAWKEYE_VERSION);
382+
break;
383+
default:
384+
dev_err(cpu_dev,
385+
"SoC ID %u is not part of IPQ8074 family, limiting to 1.4GHz!\n",
386+
msm_id);
387+
drv->versions = BIT(IPQ8074_ACORN_VERSION);
388+
break;
389+
}
390+
391+
return 0;
392+
}
393+
341394
static const char *generic_genpd_names[] = { "perf", NULL };
342395

343396
static const struct qcom_cpufreq_match_data match_data_kryo = {
@@ -367,6 +420,10 @@ static const struct qcom_cpufreq_match_data match_data_ipq8064 = {
367420
.get_version = qcom_cpufreq_ipq8064_name_version,
368421
};
369422

423+
static const struct qcom_cpufreq_match_data match_data_ipq8074 = {
424+
.get_version = qcom_cpufreq_ipq8074_name_version,
425+
};
426+
370427
static int qcom_cpufreq_probe(struct platform_device *pdev)
371428
{
372429
struct qcom_cpufreq_drv *drv;
@@ -494,9 +551,12 @@ static const struct of_device_id qcom_cpufreq_match_list[] __initconst = {
494551
{ .compatible = "qcom,msm8909", .data = &match_data_msm8909 },
495552
{ .compatible = "qcom,msm8996", .data = &match_data_kryo },
496553
{ .compatible = "qcom,qcs404", .data = &match_data_qcs404 },
554+
{ .compatible = "qcom,ipq5332", .data = &match_data_kryo },
497555
{ .compatible = "qcom,ipq6018", .data = &match_data_ipq6018 },
498556
{ .compatible = "qcom,ipq8064", .data = &match_data_ipq8064 },
557+
{ .compatible = "qcom,ipq8074", .data = &match_data_ipq8074 },
499558
{ .compatible = "qcom,apq8064", .data = &match_data_krait },
559+
{ .compatible = "qcom,ipq9574", .data = &match_data_kryo },
500560
{ .compatible = "qcom,msm8974", .data = &match_data_krait },
501561
{ .compatible = "qcom,msm8960", .data = &match_data_krait },
502562
{},

drivers/firmware/Kconfig

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,38 @@ config QCOM_SCM_DOWNLOAD_MODE_DEFAULT
226226

227227
Say Y here to enable "download mode" by default.
228228

229+
config QCOM_QSEECOM
230+
bool "Qualcomm QSEECOM interface driver"
231+
depends on QCOM_SCM=y
232+
help
233+
Various Qualcomm SoCs have a Secure Execution Environment (SEE) running
234+
in the Trust Zone. This module provides an interface to that via the
235+
QSEECOM mechanism, using SCM calls.
236+
237+
The QSEECOM interface allows, among other things, access to applications
238+
running in the SEE. An example of such an application is 'uefisecapp',
239+
which is required to access UEFI variables on certain systems. If
240+
selected, the interface will also attempt to detect and register client
241+
devices for supported applications.
242+
243+
Select Y here to enable the QSEECOM interface driver.
244+
245+
config QCOM_QSEECOM_UEFISECAPP
246+
bool "Qualcomm SEE UEFI Secure App client driver"
247+
depends on QCOM_QSEECOM
248+
depends on EFI
249+
help
250+
Various Qualcomm SoCs do not allow direct access to EFI variables.
251+
Instead, these need to be accessed via the UEFI Secure Application
252+
(uefisecapp), residing in the Secure Execution Environment (SEE).
253+
254+
This module provides a client driver for uefisecapp, installing efivar
255+
operations to allow the kernel accessing EFI variables, and via that also
256+
provide user-space with access to EFI variables via efivarfs.
257+
258+
Select Y here to provide access to EFI variables on the aforementioned
259+
platforms.
260+
229261
config SYSFB
230262
bool
231263
select BOOT_VESA_SUPPORT

drivers/firmware/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ obj-$(CONFIG_RASPBERRYPI_FIRMWARE) += raspberrypi.o
2020
obj-$(CONFIG_FW_CFG_SYSFS) += qemu_fw_cfg.o
2121
obj-$(CONFIG_QCOM_SCM) += qcom-scm.o
2222
qcom-scm-objs += qcom_scm.o qcom_scm-smc.o qcom_scm-legacy.o
23+
obj-$(CONFIG_QCOM_QSEECOM) += qcom_qseecom.o
24+
obj-$(CONFIG_QCOM_QSEECOM_UEFISECAPP) += qcom_qseecom_uefisecapp.o
2325
obj-$(CONFIG_SYSFB) += sysfb.o
2426
obj-$(CONFIG_SYSFB_SIMPLEFB) += sysfb_simplefb.o
2527
obj-$(CONFIG_TI_SCI_PROTOCOL) += ti_sci.o

drivers/firmware/qcom_qseecom.c

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
/*
3+
* Driver for Qualcomm Secure Execution Environment (SEE) interface (QSEECOM).
4+
* Responsible for setting up and managing QSEECOM client devices.
5+
*
6+
* Copyright (C) 2023 Maximilian Luz <[email protected]>
7+
*/
8+
#include <linux/auxiliary_bus.h>
9+
#include <linux/module.h>
10+
#include <linux/platform_device.h>
11+
#include <linux/slab.h>
12+
#include <linux/types.h>
13+
14+
#include <linux/firmware/qcom/qcom_qseecom.h>
15+
#include <linux/firmware/qcom/qcom_scm.h>
16+
17+
struct qseecom_app_desc {
18+
const char *app_name;
19+
const char *dev_name;
20+
};
21+
22+
static void qseecom_client_release(struct device *dev)
23+
{
24+
struct qseecom_client *client;
25+
26+
client = container_of(dev, struct qseecom_client, aux_dev.dev);
27+
kfree(client);
28+
}
29+
30+
static void qseecom_client_remove(void *data)
31+
{
32+
struct qseecom_client *client = data;
33+
34+
auxiliary_device_delete(&client->aux_dev);
35+
auxiliary_device_uninit(&client->aux_dev);
36+
}
37+
38+
static int qseecom_client_register(struct platform_device *qseecom_dev,
39+
const struct qseecom_app_desc *desc)
40+
{
41+
struct qseecom_client *client;
42+
u32 app_id;
43+
int ret;
44+
45+
/* Try to find the app ID, skip device if not found */
46+
ret = qcom_scm_qseecom_app_get_id(desc->app_name, &app_id);
47+
if (ret)
48+
return ret == -ENOENT ? 0 : ret;
49+
50+
dev_info(&qseecom_dev->dev, "setting up client for %s\n", desc->app_name);
51+
52+
/* Allocate and set-up the client device */
53+
client = kzalloc(sizeof(*client), GFP_KERNEL);
54+
if (!client)
55+
return -ENOMEM;
56+
57+
client->aux_dev.name = desc->dev_name;
58+
client->aux_dev.dev.parent = &qseecom_dev->dev;
59+
client->aux_dev.dev.release = qseecom_client_release;
60+
client->app_id = app_id;
61+
62+
ret = auxiliary_device_init(&client->aux_dev);
63+
if (ret) {
64+
kfree(client);
65+
return ret;
66+
}
67+
68+
ret = auxiliary_device_add(&client->aux_dev);
69+
if (ret) {
70+
auxiliary_device_uninit(&client->aux_dev);
71+
return ret;
72+
}
73+
74+
ret = devm_add_action_or_reset(&qseecom_dev->dev, qseecom_client_remove, client);
75+
if (ret)
76+
return ret;
77+
78+
return 0;
79+
}
80+
81+
/*
82+
* List of supported applications. One client device will be created per entry,
83+
* assuming the app has already been loaded (usually by firmware bootloaders)
84+
* and its ID can be queried successfully.
85+
*/
86+
static const struct qseecom_app_desc qcom_qseecom_apps[] = {
87+
{ "qcom.tz.uefisecapp", "uefisecapp" },
88+
};
89+
90+
static int qcom_qseecom_probe(struct platform_device *qseecom_dev)
91+
{
92+
int ret;
93+
int i;
94+
95+
/* Set up client devices for each base application */
96+
for (i = 0; i < ARRAY_SIZE(qcom_qseecom_apps); i++) {
97+
ret = qseecom_client_register(qseecom_dev, &qcom_qseecom_apps[i]);
98+
if (ret)
99+
return ret;
100+
}
101+
102+
return 0;
103+
}
104+
105+
static struct platform_driver qcom_qseecom_driver = {
106+
.driver = {
107+
.name = "qcom_qseecom",
108+
},
109+
.probe = qcom_qseecom_probe,
110+
};
111+
112+
static int __init qcom_qseecom_init(void)
113+
{
114+
return platform_driver_register(&qcom_qseecom_driver);
115+
}
116+
subsys_initcall(qcom_qseecom_init);
117+
118+
MODULE_AUTHOR("Maximilian Luz <[email protected]>");
119+
MODULE_DESCRIPTION("Driver for the Qualcomm SEE (QSEECOM) interface");
120+
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)