falcon.c (20e7dce255e96a4d58168cf48e20210146dacf23) | falcon.c (d972d6247628054f4a9f05c084a1f52de9df209d) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Copyright (c) 2015, NVIDIA Corporation. 4 */ 5 6#include <linux/platform_device.h> 7#include <linux/dma-mapping.h> 8#include <linux/firmware.h> --- 44 unchanged lines hidden (view full) --- 53 falcon_writel(falcon, cmd, FALCON_DMATRFCMD); 54 55 return falcon_dma_wait_idle(falcon); 56} 57 58static void falcon_copy_firmware_image(struct falcon *falcon, 59 const struct firmware *firmware) 60{ | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Copyright (c) 2015, NVIDIA Corporation. 4 */ 5 6#include <linux/platform_device.h> 7#include <linux/dma-mapping.h> 8#include <linux/firmware.h> --- 44 unchanged lines hidden (view full) --- 53 falcon_writel(falcon, cmd, FALCON_DMATRFCMD); 54 55 return falcon_dma_wait_idle(falcon); 56} 57 58static void falcon_copy_firmware_image(struct falcon *falcon, 59 const struct firmware *firmware) 60{ |
61 u32 *firmware_vaddr = falcon->firmware.vaddr; | 61 u32 *virt = falcon->firmware.virt; |
62 size_t i; 63 64 /* copy the whole thing taking into account endianness */ 65 for (i = 0; i < firmware->size / sizeof(u32); i++) | 62 size_t i; 63 64 /* copy the whole thing taking into account endianness */ 65 for (i = 0; i < firmware->size / sizeof(u32); i++) |
66 firmware_vaddr[i] = le32_to_cpu(((u32 *)firmware->data)[i]); | 66 virt[i] = le32_to_cpu(((u32 *)firmware->data)[i]); |
67} 68 69static int falcon_parse_firmware_image(struct falcon *falcon) 70{ | 67} 68 69static int falcon_parse_firmware_image(struct falcon *falcon) 70{ |
71 struct falcon_fw_bin_header_v1 *bin = (void *)falcon->firmware.vaddr; | 71 struct falcon_fw_bin_header_v1 *bin = (void *)falcon->firmware.virt; |
72 struct falcon_fw_os_header_v1 *os; 73 74 /* endian problems would show up right here */ 75 if (bin->magic != PCI_VENDOR_ID_NVIDIA) { 76 dev_err(falcon->dev, "incorrect firmware magic\n"); 77 return -EINVAL; 78 } 79 --- 4 unchanged lines hidden (view full) --- 84 } 85 86 /* check that the firmware size is consistent */ 87 if (bin->size > falcon->firmware.size) { 88 dev_err(falcon->dev, "firmware image size inconsistency\n"); 89 return -EINVAL; 90 } 91 | 72 struct falcon_fw_os_header_v1 *os; 73 74 /* endian problems would show up right here */ 75 if (bin->magic != PCI_VENDOR_ID_NVIDIA) { 76 dev_err(falcon->dev, "incorrect firmware magic\n"); 77 return -EINVAL; 78 } 79 --- 4 unchanged lines hidden (view full) --- 84 } 85 86 /* check that the firmware size is consistent */ 87 if (bin->size > falcon->firmware.size) { 88 dev_err(falcon->dev, "firmware image size inconsistency\n"); 89 return -EINVAL; 90 } 91 |
92 os = falcon->firmware.vaddr + bin->os_header_offset; | 92 os = falcon->firmware.virt + bin->os_header_offset; |
93 94 falcon->firmware.bin_data.size = bin->os_size; 95 falcon->firmware.bin_data.offset = bin->os_data_offset; 96 falcon->firmware.code.offset = os->code_offset; 97 falcon->firmware.code.size = os->code_size; 98 falcon->firmware.data.offset = os->data_offset; 99 falcon->firmware.data.size = os->data_size; 100 --- 32 unchanged lines hidden (view full) --- 133 release_firmware(firmware); 134 falcon->firmware.firmware = NULL; 135 136 return 0; 137} 138 139int falcon_init(struct falcon *falcon) 140{ | 93 94 falcon->firmware.bin_data.size = bin->os_size; 95 falcon->firmware.bin_data.offset = bin->os_data_offset; 96 falcon->firmware.code.offset = os->code_offset; 97 falcon->firmware.code.size = os->code_size; 98 falcon->firmware.data.offset = os->data_offset; 99 falcon->firmware.data.size = os->data_size; 100 --- 32 unchanged lines hidden (view full) --- 133 release_firmware(firmware); 134 falcon->firmware.firmware = NULL; 135 136 return 0; 137} 138 139int falcon_init(struct falcon *falcon) 140{ |
141 falcon->firmware.vaddr = NULL; | 141 falcon->firmware.virt = NULL; |
142 143 return 0; 144} 145 146void falcon_exit(struct falcon *falcon) 147{ 148 if (falcon->firmware.firmware) 149 release_firmware(falcon->firmware.firmware); 150} 151 152int falcon_boot(struct falcon *falcon) 153{ 154 unsigned long offset; 155 u32 value; 156 int err; 157 | 142 143 return 0; 144} 145 146void falcon_exit(struct falcon *falcon) 147{ 148 if (falcon->firmware.firmware) 149 release_firmware(falcon->firmware.firmware); 150} 151 152int falcon_boot(struct falcon *falcon) 153{ 154 unsigned long offset; 155 u32 value; 156 int err; 157 |
158 if (!falcon->firmware.vaddr) | 158 if (!falcon->firmware.virt) |
159 return -EINVAL; 160 161 err = readl_poll_timeout(falcon->regs + FALCON_DMACTL, value, 162 (value & (FALCON_DMACTL_IMEM_SCRUBBING | 163 FALCON_DMACTL_DMEM_SCRUBBING)) == 0, 164 10, 10000); 165 if (err < 0) 166 return err; 167 168 falcon_writel(falcon, 0, FALCON_DMACTL); 169 170 /* setup the address of the binary data so Falcon can access it later */ | 159 return -EINVAL; 160 161 err = readl_poll_timeout(falcon->regs + FALCON_DMACTL, value, 162 (value & (FALCON_DMACTL_IMEM_SCRUBBING | 163 FALCON_DMACTL_DMEM_SCRUBBING)) == 0, 164 10, 10000); 165 if (err < 0) 166 return err; 167 168 falcon_writel(falcon, 0, FALCON_DMACTL); 169 170 /* setup the address of the binary data so Falcon can access it later */ |
171 falcon_writel(falcon, (falcon->firmware.paddr + | 171 falcon_writel(falcon, (falcon->firmware.iova + |
172 falcon->firmware.bin_data.offset) >> 8, 173 FALCON_DMATRFBASE); 174 175 /* copy the data segment into Falcon internal memory */ 176 for (offset = 0; offset < falcon->firmware.data.size; offset += 256) 177 falcon_copy_chunk(falcon, 178 falcon->firmware.data.offset + offset, 179 offset, FALCON_MEMORY_DATA); --- 43 unchanged lines hidden --- | 172 falcon->firmware.bin_data.offset) >> 8, 173 FALCON_DMATRFBASE); 174 175 /* copy the data segment into Falcon internal memory */ 176 for (offset = 0; offset < falcon->firmware.data.size; offset += 256) 177 falcon_copy_chunk(falcon, 178 falcon->firmware.data.offset + offset, 179 offset, FALCON_MEMORY_DATA); --- 43 unchanged lines hidden --- |