Lines Matching refs:psp
14 #include "psp-dev.h"
25 struct psp_device *psp;
27 psp = devm_kzalloc(dev, sizeof(*psp), GFP_KERNEL);
28 if (!psp)
31 psp->dev = dev;
32 psp->sp = sp;
34 snprintf(psp->name, sizeof(psp->name), "psp-%u", sp->ord);
36 return psp;
41 struct psp_device *psp = data;
45 status = ioread32(psp->io_regs + psp->vdata->intsts_reg);
48 iowrite32(status, psp->io_regs + psp->vdata->intsts_reg);
52 if (psp->sev_irq_handler)
53 psp->sev_irq_handler(irq, psp->sev_irq_data, status);
59 static unsigned int psp_get_capability(struct psp_device *psp)
61 unsigned int val = ioread32(psp->io_regs + psp->vdata->feature_reg);
71 dev_notice(psp->dev, "psp: unable to access the device: you might be running a broken BIOS.\n");
74 psp->capability = val;
77 if (psp->capability & PSP_CAPABILITY_PSP_SECURITY_REPORTING &&
78 psp->capability & (PSP_SECURITY_TSME_STATUS << PSP_CAPABILITY_PSP_SECURITY_OFFSET) &&
80 dev_notice(psp->dev, "psp: Both TSME and SME are active, SME is unnecessary when TSME is active.\n");
85 static int psp_check_sev_support(struct psp_device *psp)
88 if (!(psp->capability & PSP_CAPABILITY_SEV)) {
89 dev_dbg(psp->dev, "psp does not support SEV\n");
96 static int psp_check_tee_support(struct psp_device *psp)
99 if (!(psp->capability & PSP_CAPABILITY_TEE)) {
100 dev_dbg(psp->dev, "psp does not support TEE\n");
107 static void psp_init_platform_access(struct psp_device *psp)
111 ret = platform_access_dev_init(psp);
113 dev_warn(psp->dev, "platform access init failed: %d\n", ret);
118 ret = dbc_dev_init(psp);
120 dev_warn(psp->dev, "failed to init dynamic boost control: %d\n",
124 static int psp_init(struct psp_device *psp)
128 if (!psp_check_sev_support(psp)) {
129 ret = sev_dev_init(psp);
134 if (!psp_check_tee_support(psp)) {
135 ret = tee_dev_init(psp);
140 if (psp->vdata->platform_access)
141 psp_init_platform_access(psp);
149 struct psp_device *psp;
153 psp = psp_alloc_struct(sp);
154 if (!psp)
157 sp->psp_data = psp;
159 psp->vdata = (struct psp_vdata *)sp->dev_vdata->psp_vdata;
160 if (!psp->vdata) {
166 psp->io_regs = sp->io_map;
168 ret = psp_get_capability(psp);
173 iowrite32(0, psp->io_regs + psp->vdata->inten_reg);
174 iowrite32(-1, psp->io_regs + psp->vdata->intsts_reg);
177 ret = sp_request_psp_irq(psp->sp, psp_irq_handler, psp->name, psp);
179 dev_err(dev, "psp: unable to allocate an IRQ\n");
184 if (psp->sp->set_psp_master_device)
185 psp->sp->set_psp_master_device(psp->sp);
187 ret = psp_init(psp);
192 iowrite32(-1, psp->io_regs + psp->vdata->inten_reg);
194 dev_notice(dev, "psp enabled\n");
202 sp_free_psp_irq(psp->sp, psp);
206 dev_notice(dev, "psp initialization failed\n");
218 struct psp_device *psp = sp->psp_data;
220 if (!psp)
223 sev_dev_destroy(psp);
225 tee_dev_destroy(psp);
227 dbc_dev_destroy(psp);
229 platform_access_dev_destroy(psp);
231 sp_free_psp_irq(sp, psp);
237 void psp_set_sev_irq_handler(struct psp_device *psp, psp_irq_handler_t handler,
240 psp->sev_irq_data = data;
241 psp->sev_irq_handler = handler;
244 void psp_clear_sev_irq_handler(struct psp_device *psp)
246 psp_set_sev_irq_handler(psp, NULL, NULL);