Lines Matching +full:isp +full:- +full:0
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2013--2024 Intel Corporation
11 #include <linux/dma-mapping.h>
26 #include "ipu6-bus.h"
27 #include "ipu6-dma.h"
28 #include "ipu6-buttress.h"
29 #include "ipu6-platform-buttress-regs.h"
31 #define BOOTLOADER_STATUS_OFFSET 0x15c
33 #define BOOTLOADER_MAGIC_KEY 0xb00710ad
63 int ipu6_buttress_ipc_reset(struct ipu6_device *isp, in ipu6_buttress_ipc_reset() argument
67 struct ipu6_buttress *b = &isp->buttress; in ipu6_buttress_ipc_reset()
68 u32 val = 0, csr_in_clr; in ipu6_buttress_ipc_reset()
70 if (!isp->secure_mode) { in ipu6_buttress_ipc_reset()
71 dev_dbg(&isp->pdev->dev, "Skip IPC reset for non-secure mode"); in ipu6_buttress_ipc_reset()
72 return 0; in ipu6_buttress_ipc_reset()
75 mutex_lock(&b->ipc_mutex); in ipu6_buttress_ipc_reset()
77 /* Clear-by-1 CSR (all bits), corresponding internal states. */ in ipu6_buttress_ipc_reset()
78 val = readl(isp->base + ipc->csr_in); in ipu6_buttress_ipc_reset()
79 writel(val, isp->base + ipc->csr_in); in ipu6_buttress_ipc_reset()
82 writel(ENTRY, isp->base + ipc->csr_out); in ipu6_buttress_ipc_reset()
84 * Clear-by-1 all CSR bits EXCEPT following in ipu6_buttress_ipc_reset()
97 val = readl(isp->base + ipc->csr_in); in ipu6_buttress_ipc_reset()
102 * 1) Clear-by-1 CSR bits in ipu6_buttress_ipc_reset()
108 writel(ENTRY | EXIT, isp->base + ipc->csr_in); in ipu6_buttress_ipc_reset()
109 writel(QUERY, isp->base + ipc->csr_out); in ipu6_buttress_ipc_reset()
114 * 1) Clear-by-1 CSR bits in ipu6_buttress_ipc_reset()
120 writel(ENTRY | QUERY, isp->base + ipc->csr_in); in ipu6_buttress_ipc_reset()
121 writel(ENTRY, isp->base + ipc->csr_out); in ipu6_buttress_ipc_reset()
126 * Clear-by-1 CSR bit in ipu6_buttress_ipc_reset()
129 * 2) Clear-by-1 all CSR bits EXCEPT following in ipu6_buttress_ipc_reset()
138 writel(EXIT, isp->base + ipc->csr_in); in ipu6_buttress_ipc_reset()
139 writel(0, isp->base + ipc->db0_in); in ipu6_buttress_ipc_reset()
140 writel(csr_in_clr, isp->base + ipc->csr_in); in ipu6_buttress_ipc_reset()
141 writel(EXIT, isp->base + ipc->csr_out); in ipu6_buttress_ipc_reset()
148 val = readl(isp->base + ipc->csr_in); in ipu6_buttress_ipc_reset()
150 dev_dbg(&isp->pdev->dev, in ipu6_buttress_ipc_reset()
154 mutex_unlock(&b->ipc_mutex); in ipu6_buttress_ipc_reset()
155 return 0; in ipu6_buttress_ipc_reset()
158 * 1) Clear-by-1 CSR bit in ipu6_buttress_ipc_reset()
163 writel(QUERY, isp->base + ipc->csr_in); in ipu6_buttress_ipc_reset()
164 writel(ENTRY, isp->base + ipc->csr_out); in ipu6_buttress_ipc_reset()
167 dev_dbg_ratelimited(&isp->pdev->dev, in ipu6_buttress_ipc_reset()
168 "Unexpected CSR 0x%x\n", val); in ipu6_buttress_ipc_reset()
171 } while (retries--); in ipu6_buttress_ipc_reset()
173 mutex_unlock(&b->ipc_mutex); in ipu6_buttress_ipc_reset()
174 dev_err(&isp->pdev->dev, "Timed out while waiting for CSE\n"); in ipu6_buttress_ipc_reset()
176 return -ETIMEDOUT; in ipu6_buttress_ipc_reset()
179 static void ipu6_buttress_ipc_validity_close(struct ipu6_device *isp, in ipu6_buttress_ipc_validity_close() argument
183 isp->base + ipc->csr_out); in ipu6_buttress_ipc_validity_close()
187 ipu6_buttress_ipc_validity_open(struct ipu6_device *isp, in ipu6_buttress_ipc_validity_open() argument
196 isp->base + ipc->csr_out); in ipu6_buttress_ipc_validity_open()
198 addr = isp->base + ipc->csr_in; in ipu6_buttress_ipc_validity_open()
202 dev_err(&isp->pdev->dev, "CSE validity timeout 0x%x\n", val); in ipu6_buttress_ipc_validity_open()
203 ipu6_buttress_ipc_validity_close(isp, ipc); in ipu6_buttress_ipc_validity_open()
209 static void ipu6_buttress_ipc_recv(struct ipu6_device *isp, in ipu6_buttress_ipc_recv() argument
213 *ipc_msg = readl(isp->base + ipc->data0_in); in ipu6_buttress_ipc_recv()
214 writel(0, isp->base + ipc->db0_in); in ipu6_buttress_ipc_recv()
217 static int ipu6_buttress_ipc_send_bulk(struct ipu6_device *isp, in ipu6_buttress_ipc_send_bulk() argument
223 struct ipu6_buttress *b = &isp->buttress; in ipu6_buttress_ipc_send_bulk()
224 struct ipu6_buttress_ipc *ipc = &b->cse; in ipu6_buttress_ipc_send_bulk()
229 mutex_lock(&b->ipc_mutex); in ipu6_buttress_ipc_send_bulk()
231 ret = ipu6_buttress_ipc_validity_open(isp, ipc); in ipu6_buttress_ipc_send_bulk()
233 dev_err(&isp->pdev->dev, "IPC validity open failed\n"); in ipu6_buttress_ipc_send_bulk()
240 for (i = 0; i < size; i++) { in ipu6_buttress_ipc_send_bulk()
241 reinit_completion(&ipc->send_complete); in ipu6_buttress_ipc_send_bulk()
243 reinit_completion(&ipc->recv_complete); in ipu6_buttress_ipc_send_bulk()
245 dev_dbg(&isp->pdev->dev, "bulk IPC command: 0x%x\n", in ipu6_buttress_ipc_send_bulk()
247 writel(msgs[i].cmd, isp->base + ipc->data0_out); in ipu6_buttress_ipc_send_bulk()
249 writel(val, isp->base + ipc->db0_out); in ipu6_buttress_ipc_send_bulk()
251 tout = wait_for_completion_timeout(&ipc->send_complete, in ipu6_buttress_ipc_send_bulk()
254 dev_err(&isp->pdev->dev, "send IPC response timeout\n"); in ipu6_buttress_ipc_send_bulk()
255 if (!retry--) { in ipu6_buttress_ipc_send_bulk()
256 ret = -ETIMEDOUT; in ipu6_buttress_ipc_send_bulk()
261 writel(0, isp->base + ipc->db0_out); in ipu6_buttress_ipc_send_bulk()
262 i--; in ipu6_buttress_ipc_send_bulk()
271 tout = wait_for_completion_timeout(&ipc->recv_complete, in ipu6_buttress_ipc_send_bulk()
274 dev_err(&isp->pdev->dev, "recv IPC response timeout\n"); in ipu6_buttress_ipc_send_bulk()
275 ret = -ETIMEDOUT; in ipu6_buttress_ipc_send_bulk()
279 if (ipc->nack_mask && in ipu6_buttress_ipc_send_bulk()
280 (ipc->recv_data & ipc->nack_mask) == ipc->nack) { in ipu6_buttress_ipc_send_bulk()
281 dev_err(&isp->pdev->dev, in ipu6_buttress_ipc_send_bulk()
282 "IPC NACK for cmd 0x%x\n", msgs[i].cmd); in ipu6_buttress_ipc_send_bulk()
283 ret = -EIO; in ipu6_buttress_ipc_send_bulk()
287 if (ipc->recv_data != msgs[i].expected_resp) { in ipu6_buttress_ipc_send_bulk()
288 dev_err(&isp->pdev->dev, in ipu6_buttress_ipc_send_bulk()
289 "expected resp: 0x%x, IPC response: 0x%x ", in ipu6_buttress_ipc_send_bulk()
290 msgs[i].expected_resp, ipc->recv_data); in ipu6_buttress_ipc_send_bulk()
291 ret = -EIO; in ipu6_buttress_ipc_send_bulk()
296 dev_dbg(&isp->pdev->dev, "bulk IPC commands done\n"); in ipu6_buttress_ipc_send_bulk()
299 ipu6_buttress_ipc_validity_close(isp, ipc); in ipu6_buttress_ipc_send_bulk()
300 mutex_unlock(&b->ipc_mutex); in ipu6_buttress_ipc_send_bulk()
305 ipu6_buttress_ipc_send(struct ipu6_device *isp, in ipu6_buttress_ipc_send() argument
316 return ipu6_buttress_ipc_send_bulk(isp, &msg, 1); in ipu6_buttress_ipc_send()
323 if (!adev || !adev->auxdrv || !adev->auxdrv_data) in ipu6_buttress_call_isr()
326 if (adev->auxdrv_data->isr) in ipu6_buttress_call_isr()
327 ret = adev->auxdrv_data->isr(adev); in ipu6_buttress_call_isr()
329 if (ret == IRQ_WAKE_THREAD && !adev->auxdrv_data->isr_threaded) in ipu6_buttress_call_isr()
337 struct ipu6_device *isp = isp_ptr; in ipu6_buttress_isr() local
338 struct ipu6_bus_device *adev[] = { isp->isys, isp->psys }; in ipu6_buttress_isr()
339 struct ipu6_buttress *b = &isp->buttress; in ipu6_buttress_isr()
342 u32 disable_irqs = 0; in ipu6_buttress_isr()
344 u32 i, count = 0; in ipu6_buttress_isr()
347 active = pm_runtime_get_if_active(&isp->pdev->dev); in ipu6_buttress_isr()
351 irq_status = readl(isp->base + reg_irq_sts); in ipu6_buttress_isr()
352 if (irq_status == 0 || WARN_ON_ONCE(irq_status == 0xffffffffu)) { in ipu6_buttress_isr()
353 if (active > 0) in ipu6_buttress_isr()
354 pm_runtime_put_noidle(&isp->pdev->dev); in ipu6_buttress_isr()
359 writel(irq_status, isp->base + BUTTRESS_REG_ISR_CLEAR); in ipu6_buttress_isr()
361 for (i = 0; i < ARRAY_SIZE(ipu6_adev_irq_mask); i++) { in ipu6_buttress_isr()
379 dev_dbg(&isp->pdev->dev, in ipu6_buttress_isr()
381 ipu6_buttress_ipc_recv(isp, &b->cse, &b->cse.recv_data); in ipu6_buttress_isr()
382 complete(&b->cse.recv_complete); in ipu6_buttress_isr()
386 dev_dbg(&isp->pdev->dev, in ipu6_buttress_isr()
388 complete(&b->cse.send_complete); in ipu6_buttress_isr()
392 ipu6_buttress_get_secure_mode(isp)) in ipu6_buttress_isr()
393 dev_err(&isp->pdev->dev, in ipu6_buttress_isr()
398 dev_err(&isp->pdev->dev, in ipu6_buttress_isr()
402 dev_err(&isp->pdev->dev, "BUTTRESS_ISR_UFI_ERROR\n"); in ipu6_buttress_isr()
405 dev_err(&isp->pdev->dev, "too many consecutive IRQs\n"); in ipu6_buttress_isr()
410 irq_status = readl(isp->base + reg_irq_sts); in ipu6_buttress_isr()
415 isp->base + BUTTRESS_REG_ISR_ENABLE); in ipu6_buttress_isr()
417 if (active > 0) in ipu6_buttress_isr()
418 pm_runtime_put(&isp->pdev->dev); in ipu6_buttress_isr()
425 struct ipu6_device *isp = isp_ptr; in ipu6_buttress_isr_threaded() local
426 struct ipu6_bus_device *adev[] = { isp->isys, isp->psys }; in ipu6_buttress_isr_threaded()
431 for (i = 0; i < ARRAY_SIZE(ipu6_adev_irq_mask) && adev[i]; i++) { in ipu6_buttress_isr_threaded()
432 drv_data = adev[i]->auxdrv_data; in ipu6_buttress_isr_threaded()
436 if (drv_data->wake_isr_thread && in ipu6_buttress_isr_threaded()
437 drv_data->isr_threaded(adev[i]) == IRQ_HANDLED) in ipu6_buttress_isr_threaded()
441 writel(BUTTRESS_IRQS, isp->base + BUTTRESS_REG_ISR_ENABLE); in ipu6_buttress_isr_threaded()
449 struct ipu6_device *isp = to_ipu6_bus_device(dev)->isp; in ipu6_buttress_power() local
454 return 0; in ipu6_buttress_power()
456 mutex_lock(&isp->buttress.power_mutex); in ipu6_buttress_power()
459 val = 0; in ipu6_buttress_power()
460 pwr_sts = ctrl->pwr_sts_off << ctrl->pwr_sts_shift; in ipu6_buttress_power()
464 ctrl->ratio) | in ipu6_buttress_power()
466 ctrl->qos_floor) | in ipu6_buttress_power()
469 pwr_sts = ctrl->pwr_sts_on << ctrl->pwr_sts_shift; in ipu6_buttress_power()
472 writel(val, isp->base + ctrl->freq_ctl); in ipu6_buttress_power()
474 ret = readl_poll_timeout(isp->base + BUTTRESS_REG_PWR_STATE, in ipu6_buttress_power()
475 val, (val & ctrl->pwr_sts_mask) == pwr_sts, in ipu6_buttress_power()
478 dev_err(&isp->pdev->dev, in ipu6_buttress_power()
479 "Change power status timeout with 0x%x\n", val); in ipu6_buttress_power()
481 ctrl->started = !ret && on; in ipu6_buttress_power()
483 mutex_unlock(&isp->buttress.power_mutex); in ipu6_buttress_power()
488 bool ipu6_buttress_get_secure_mode(struct ipu6_device *isp) in ipu6_buttress_get_secure_mode() argument
492 val = readl(isp->base + BUTTRESS_REG_SECURITY_CTL); in ipu6_buttress_get_secure_mode()
497 bool ipu6_buttress_auth_done(struct ipu6_device *isp) in ipu6_buttress_auth_done() argument
501 if (!isp->secure_mode) in ipu6_buttress_auth_done()
504 val = readl(isp->base + BUTTRESS_REG_SECURITY_CTL); in ipu6_buttress_auth_done()
511 int ipu6_buttress_reset_authentication(struct ipu6_device *isp) in ipu6_buttress_reset_authentication() argument
516 if (!isp->secure_mode) { in ipu6_buttress_reset_authentication()
517 dev_dbg(&isp->pdev->dev, "Skip auth for non-secure mode\n"); in ipu6_buttress_reset_authentication()
518 return 0; in ipu6_buttress_reset_authentication()
521 writel(BUTTRESS_FW_RESET_CTL_START, isp->base + in ipu6_buttress_reset_authentication()
524 ret = readl_poll_timeout(isp->base + BUTTRESS_REG_FW_RESET_CTL, val, in ipu6_buttress_reset_authentication()
528 dev_err(&isp->pdev->dev, in ipu6_buttress_reset_authentication()
533 dev_dbg(&isp->pdev->dev, "FW reset for authentication done\n"); in ipu6_buttress_reset_authentication()
534 writel(0, isp->base + BUTTRESS_REG_FW_RESET_CTL); in ipu6_buttress_reset_authentication()
538 return 0; in ipu6_buttress_reset_authentication()
544 bool is_vmalloc = is_vmalloc_addr(fw->data); in ipu6_buttress_map_fw_image()
545 struct pci_dev *pdev = sys->isp->pdev; in ipu6_buttress_map_fw_image()
552 if (!is_vmalloc && !virt_addr_valid(fw->data)) in ipu6_buttress_map_fw_image()
553 return -EDOM; in ipu6_buttress_map_fw_image()
555 n_pages = PFN_UP(fw->size); in ipu6_buttress_map_fw_image()
559 return -ENOMEM; in ipu6_buttress_map_fw_image()
561 addr = fw->data; in ipu6_buttress_map_fw_image()
562 for (i = 0; i < n_pages; i++) { in ipu6_buttress_map_fw_image()
567 ret = -ENOMEM; in ipu6_buttress_map_fw_image()
574 ret = sg_alloc_table_from_pages(sgt, pages, n_pages, 0, fw->size, in ipu6_buttress_map_fw_image()
577 ret = -ENOMEM; in ipu6_buttress_map_fw_image()
581 ret = dma_map_sgtable(&pdev->dev, sgt, DMA_TO_DEVICE, 0); in ipu6_buttress_map_fw_image()
587 ret = ipu6_dma_map_sgtable(sys, sgt, DMA_TO_DEVICE, 0); in ipu6_buttress_map_fw_image()
589 dma_unmap_sgtable(&pdev->dev, sgt, DMA_TO_DEVICE, 0); in ipu6_buttress_map_fw_image()
606 struct pci_dev *pdev = sys->isp->pdev; in ipu6_buttress_unmap_fw_image()
608 ipu6_dma_unmap_sgtable(sys, sgt, DMA_TO_DEVICE, 0); in ipu6_buttress_unmap_fw_image()
609 dma_unmap_sgtable(&pdev->dev, sgt, DMA_TO_DEVICE, 0); in ipu6_buttress_unmap_fw_image()
614 int ipu6_buttress_authenticate(struct ipu6_device *isp) in ipu6_buttress_authenticate() argument
616 struct ipu6_buttress *b = &isp->buttress; in ipu6_buttress_authenticate()
621 if (!isp->secure_mode) { in ipu6_buttress_authenticate()
622 dev_dbg(&isp->pdev->dev, "Skip auth for non-secure mode\n"); in ipu6_buttress_authenticate()
623 return 0; in ipu6_buttress_authenticate()
626 psys_pdata = isp->psys->pdata; in ipu6_buttress_authenticate()
628 mutex_lock(&b->auth_mutex); in ipu6_buttress_authenticate()
630 if (ipu6_buttress_auth_done(isp)) { in ipu6_buttress_authenticate()
631 ret = 0; in ipu6_buttress_authenticate()
639 data = lower_32_bits(isp->psys->pkg_dir_dma_addr); in ipu6_buttress_authenticate()
640 writel(data, isp->base + BUTTRESS_REG_FW_SOURCE_BASE_LO); in ipu6_buttress_authenticate()
642 data = upper_32_bits(isp->psys->pkg_dir_dma_addr); in ipu6_buttress_authenticate()
643 writel(data, isp->base + BUTTRESS_REG_FW_SOURCE_BASE_HI); in ipu6_buttress_authenticate()
647 * Write sizeof(boot_load) | 0x2 << CLIENT_ID to in ipu6_buttress_authenticate()
650 dev_info(&isp->pdev->dev, "Sending BOOT_LOAD to CSE\n"); in ipu6_buttress_authenticate()
652 ret = ipu6_buttress_ipc_send(isp, in ipu6_buttress_authenticate()
657 dev_err(&isp->pdev->dev, "CSE boot_load failed\n"); in ipu6_buttress_authenticate()
664 ret = readl_poll_timeout(isp->base + BUTTRESS_REG_SECURITY_CTL, data, in ipu6_buttress_authenticate()
669 dev_err(&isp->pdev->dev, "CSE boot_load timeout\n"); in ipu6_buttress_authenticate()
674 dev_err(&isp->pdev->dev, "CSE auth failed\n"); in ipu6_buttress_authenticate()
675 ret = -EINVAL; in ipu6_buttress_authenticate()
679 ret = readl_poll_timeout(psys_pdata->base + BOOTLOADER_STATUS_OFFSET, in ipu6_buttress_authenticate()
683 dev_err(&isp->pdev->dev, "Unexpected magic number 0x%x\n", in ipu6_buttress_authenticate()
690 * Write sizeof(boot_load) | 0x2 << CLIENT_ID to in ipu6_buttress_authenticate()
693 dev_info(&isp->pdev->dev, "Sending AUTHENTICATE_RUN to CSE\n"); in ipu6_buttress_authenticate()
694 ret = ipu6_buttress_ipc_send(isp, in ipu6_buttress_authenticate()
699 dev_err(&isp->pdev->dev, "CSE authenticate_run failed\n"); in ipu6_buttress_authenticate()
704 ret = readl_poll_timeout(isp->base + BUTTRESS_REG_SECURITY_CTL, data, in ipu6_buttress_authenticate()
709 dev_err(&isp->pdev->dev, "CSE authenticate timeout\n"); in ipu6_buttress_authenticate()
714 dev_err(&isp->pdev->dev, "CSE boot_load failed\n"); in ipu6_buttress_authenticate()
715 ret = -EINVAL; in ipu6_buttress_authenticate()
719 dev_info(&isp->pdev->dev, "CSE authenticate_run done\n"); in ipu6_buttress_authenticate()
722 mutex_unlock(&b->auth_mutex); in ipu6_buttress_authenticate()
727 static int ipu6_buttress_send_tsc_request(struct ipu6_device *isp) in ipu6_buttress_send_tsc_request() argument
735 isp->base + BUTTRESS_REG_FABRIC_CMD); in ipu6_buttress_send_tsc_request()
737 val = readl(isp->base + BUTTRESS_REG_PWR_STATE); in ipu6_buttress_send_tsc_request()
740 dev_err(&isp->pdev->dev, "Start tsc sync failed\n"); in ipu6_buttress_send_tsc_request()
741 return -EINVAL; in ipu6_buttress_send_tsc_request()
745 ret = readl_poll_timeout(isp->base + BUTTRESS_REG_PWR_STATE, val, in ipu6_buttress_send_tsc_request()
749 dev_err(&isp->pdev->dev, "Start tsc sync timeout\n"); in ipu6_buttress_send_tsc_request()
754 int ipu6_buttress_start_tsc_sync(struct ipu6_device *isp) in ipu6_buttress_start_tsc_sync() argument
758 for (i = 0; i < BUTTRESS_TSC_SYNC_RESET_TRIAL_MAX; i++) { in ipu6_buttress_start_tsc_sync()
762 ret = ipu6_buttress_send_tsc_request(isp); in ipu6_buttress_start_tsc_sync()
763 if (ret != -ETIMEDOUT) in ipu6_buttress_start_tsc_sync()
766 val = readl(isp->base + BUTTRESS_REG_TSW_CTL); in ipu6_buttress_start_tsc_sync()
768 writel(val, isp->base + BUTTRESS_REG_TSW_CTL); in ipu6_buttress_start_tsc_sync()
770 writel(val, isp->base + BUTTRESS_REG_TSW_CTL); in ipu6_buttress_start_tsc_sync()
773 dev_err(&isp->pdev->dev, "TSC sync failed (timeout)\n"); in ipu6_buttress_start_tsc_sync()
775 return -ETIMEDOUT; in ipu6_buttress_start_tsc_sync()
779 void ipu6_buttress_tsc_read(struct ipu6_device *isp, u64 *val) in ipu6_buttress_tsc_read() argument
785 tsc_hi_1 = readl(isp->base + BUTTRESS_REG_TSC_HI); in ipu6_buttress_tsc_read()
786 tsc_lo = readl(isp->base + BUTTRESS_REG_TSC_LO); in ipu6_buttress_tsc_read()
787 tsc_hi_2 = readl(isp->base + BUTTRESS_REG_TSC_HI); in ipu6_buttress_tsc_read()
801 u64 ipu6_buttress_tsc_ticks_to_ns(u64 ticks, const struct ipu6_device *isp) in ipu6_buttress_tsc_ticks_to_ns() argument
812 return div_u64(ns, isp->buttress.ref_clk); in ipu6_buttress_tsc_ticks_to_ns()
816 void ipu6_buttress_restore(struct ipu6_device *isp) in ipu6_buttress_restore() argument
818 struct ipu6_buttress *b = &isp->buttress; in ipu6_buttress_restore()
820 writel(BUTTRESS_IRQS, isp->base + BUTTRESS_REG_ISR_CLEAR); in ipu6_buttress_restore()
821 writel(BUTTRESS_IRQS, isp->base + BUTTRESS_REG_ISR_ENABLE); in ipu6_buttress_restore()
822 writel(b->wdt_cached_value, isp->base + BUTTRESS_REG_WDT); in ipu6_buttress_restore()
825 int ipu6_buttress_init(struct ipu6_device *isp) in ipu6_buttress_init() argument
828 struct ipu6_buttress *b = &isp->buttress; in ipu6_buttress_init()
831 mutex_init(&b->power_mutex); in ipu6_buttress_init()
832 mutex_init(&b->auth_mutex); in ipu6_buttress_init()
833 mutex_init(&b->cons_mutex); in ipu6_buttress_init()
834 mutex_init(&b->ipc_mutex); in ipu6_buttress_init()
835 init_completion(&b->cse.send_complete); in ipu6_buttress_init()
836 init_completion(&b->cse.recv_complete); in ipu6_buttress_init()
838 b->cse.nack = BUTTRESS_CSE2IUDATA0_IPC_NACK; in ipu6_buttress_init()
839 b->cse.nack_mask = BUTTRESS_CSE2IUDATA0_IPC_NACK_MASK; in ipu6_buttress_init()
840 b->cse.csr_in = BUTTRESS_REG_CSE2IUCSR; in ipu6_buttress_init()
841 b->cse.csr_out = BUTTRESS_REG_IU2CSECSR; in ipu6_buttress_init()
842 b->cse.db0_in = BUTTRESS_REG_CSE2IUDB0; in ipu6_buttress_init()
843 b->cse.db0_out = BUTTRESS_REG_IU2CSEDB0; in ipu6_buttress_init()
844 b->cse.data0_in = BUTTRESS_REG_CSE2IUDATA0; in ipu6_buttress_init()
845 b->cse.data0_out = BUTTRESS_REG_IU2CSEDATA0; in ipu6_buttress_init()
847 INIT_LIST_HEAD(&b->constraints); in ipu6_buttress_init()
849 isp->secure_mode = ipu6_buttress_get_secure_mode(isp); in ipu6_buttress_init()
850 dev_info(&isp->pdev->dev, "IPU6 in %s mode touch 0x%x mask 0x%x\n", in ipu6_buttress_init()
851 isp->secure_mode ? "secure" : "non-secure", in ipu6_buttress_init()
852 readl(isp->base + BUTTRESS_REG_SECURITY_TOUCH), in ipu6_buttress_init()
853 readl(isp->base + BUTTRESS_REG_CAMERA_MASK)); in ipu6_buttress_init()
855 b->wdt_cached_value = readl(isp->base + BUTTRESS_REG_WDT); in ipu6_buttress_init()
856 writel(BUTTRESS_IRQS, isp->base + BUTTRESS_REG_ISR_CLEAR); in ipu6_buttress_init()
857 writel(BUTTRESS_IRQS, isp->base + BUTTRESS_REG_ISR_ENABLE); in ipu6_buttress_init()
860 val = readl(isp->base + BUTTRESS_REG_BTRS_CTRL); in ipu6_buttress_init()
864 case 0x0: in ipu6_buttress_init()
865 b->ref_clk = 240; in ipu6_buttress_init()
867 case 0x1: in ipu6_buttress_init()
868 b->ref_clk = 192; in ipu6_buttress_init()
870 case 0x2: in ipu6_buttress_init()
871 b->ref_clk = 384; in ipu6_buttress_init()
874 dev_warn(&isp->pdev->dev, in ipu6_buttress_init()
876 b->ref_clk = 192; in ipu6_buttress_init()
882 ret = ipu6_buttress_ipc_reset(isp, &b->cse); in ipu6_buttress_init()
884 dev_warn(&isp->pdev->dev, in ipu6_buttress_init()
887 dev_dbg(&isp->pdev->dev, "IPC reset done\n"); in ipu6_buttress_init()
888 return 0; in ipu6_buttress_init()
890 } while (ipc_reset_retry--); in ipu6_buttress_init()
892 dev_err(&isp->pdev->dev, "IPC reset protocol failed\n"); in ipu6_buttress_init()
894 mutex_destroy(&b->power_mutex); in ipu6_buttress_init()
895 mutex_destroy(&b->auth_mutex); in ipu6_buttress_init()
896 mutex_destroy(&b->cons_mutex); in ipu6_buttress_init()
897 mutex_destroy(&b->ipc_mutex); in ipu6_buttress_init()
902 void ipu6_buttress_exit(struct ipu6_device *isp) in ipu6_buttress_exit() argument
904 struct ipu6_buttress *b = &isp->buttress; in ipu6_buttress_exit()
906 writel(0, isp->base + BUTTRESS_REG_ISR_ENABLE); in ipu6_buttress_exit()
908 mutex_destroy(&b->power_mutex); in ipu6_buttress_exit()
909 mutex_destroy(&b->auth_mutex); in ipu6_buttress_exit()
910 mutex_destroy(&b->cons_mutex); in ipu6_buttress_exit()
911 mutex_destroy(&b->ipc_mutex); in ipu6_buttress_exit()