Lines Matching refs:oct
35 static u64 cvmx_bootmem_phy_named_block_find(struct octeon_device *oct,
38 static int octeon_console_read(struct octeon_device *oct, u32 console_num,
147 static inline u64 __cvmx_bootmem_desc_get(struct octeon_device *oct, in __cvmx_bootmem_desc_get() argument
155 return octeon_read_device_mem32(oct, base); in __cvmx_bootmem_desc_get()
157 return octeon_read_device_mem64(oct, base); in __cvmx_bootmem_desc_get()
173 static void CVMX_BOOTMEM_NAMED_GET_NAME(struct octeon_device *oct, in CVMX_BOOTMEM_NAMED_GET_NAME() argument
179 octeon_pci_read_core_mem(oct, addr, (u8 *)str, len); in CVMX_BOOTMEM_NAMED_GET_NAME()
195 static int __cvmx_bootmem_check_version(struct octeon_device *oct, in __cvmx_bootmem_check_version() argument
201 if (!oct->bootmem_desc_addr) in __cvmx_bootmem_check_version()
202 oct->bootmem_desc_addr = in __cvmx_bootmem_check_version()
203 octeon_read_device_mem64(oct, in __cvmx_bootmem_check_version()
206 oct, oct->bootmem_desc_addr, in __cvmx_bootmem_check_version()
210 oct, oct->bootmem_desc_addr, in __cvmx_bootmem_check_version()
214 dev_dbg(&oct->pci_dev->dev, "%s: major_version=%d\n", __func__, in __cvmx_bootmem_check_version()
218 dev_err(&oct->pci_dev->dev, "bootmem ver mismatch %d.%d addr:0x%llx\n", in __cvmx_bootmem_check_version()
220 (long long)oct->bootmem_desc_addr); in __cvmx_bootmem_check_version()
228 *__cvmx_bootmem_find_named_block_flags(struct octeon_device *oct, in __cvmx_bootmem_find_named_block_flags() argument
232 &oct->bootmem_named_block_desc; in __cvmx_bootmem_find_named_block_flags()
233 u64 named_addr = cvmx_bootmem_phy_named_block_find(oct, name, flags); in __cvmx_bootmem_find_named_block_flags()
237 oct, named_addr, in __cvmx_bootmem_find_named_block_flags()
243 desc->size = __cvmx_bootmem_desc_get(oct, named_addr, in __cvmx_bootmem_find_named_block_flags()
252 return &oct->bootmem_named_block_desc; in __cvmx_bootmem_find_named_block_flags()
258 static u64 cvmx_bootmem_phy_named_block_find(struct octeon_device *oct, in cvmx_bootmem_phy_named_block_find() argument
264 if (!__cvmx_bootmem_check_version(oct, 3)) { in cvmx_bootmem_phy_named_block_find()
268 oct, oct->bootmem_desc_addr, in cvmx_bootmem_phy_named_block_find()
274 oct, oct->bootmem_desc_addr, in cvmx_bootmem_phy_named_block_find()
281 oct, oct->bootmem_desc_addr, in cvmx_bootmem_phy_named_block_find()
291 oct, named_addr, in cvmx_bootmem_phy_named_block_find()
305 CVMX_BOOTMEM_NAMED_GET_NAME(oct, named_addr, in cvmx_bootmem_phy_named_block_find()
335 static int octeon_named_block_find(struct octeon_device *oct, const char *name, in octeon_named_block_find() argument
341 named_block = __cvmx_bootmem_find_named_block_flags(oct, name, 0); in octeon_named_block_find()
361 int octeon_console_send_cmd(struct octeon_device *oct, char *cmd_str, in octeon_console_send_cmd() argument
366 dev_dbg(&oct->pci_dev->dev, "sending \"%s\" to bootloader\n", cmd_str); in octeon_console_send_cmd()
369 dev_err(&oct->pci_dev->dev, "Command string too long, max length is: %d\n", in octeon_console_send_cmd()
374 if (octeon_wait_for_bootloader(oct, wait_hundredths) != 0) { in octeon_console_send_cmd()
375 dev_err(&oct->pci_dev->dev, "Bootloader not ready for command.\n"); in octeon_console_send_cmd()
381 octeon_pci_write_core_mem(oct, BOOTLOADER_PCI_READ_BUFFER_DATA_ADDR, in octeon_console_send_cmd()
383 octeon_write_device_mem32(oct, BOOTLOADER_PCI_READ_BUFFER_LEN_ADDR, in octeon_console_send_cmd()
385 octeon_write_device_mem32(oct, BOOTLOADER_PCI_READ_BUFFER_OWNER_ADDR, in octeon_console_send_cmd()
391 if (octeon_wait_for_bootloader(oct, 200) != 0) { in octeon_console_send_cmd()
393 dev_err(&oct->pci_dev->dev, "Bootloader did not accept command.\n"); in octeon_console_send_cmd()
400 int octeon_wait_for_bootloader(struct octeon_device *oct, in octeon_wait_for_bootloader() argument
403 dev_dbg(&oct->pci_dev->dev, "waiting %d0 ms for bootloader\n", in octeon_wait_for_bootloader()
406 if (octeon_mem_access_ok(oct)) in octeon_wait_for_bootloader()
410 octeon_read_device_mem32(oct, in octeon_wait_for_bootloader()
420 static void octeon_console_handle_result(struct octeon_device *oct, in octeon_console_handle_result() argument
425 console = &oct->console[console_num]; in octeon_console_handle_result()
432 static void output_console_line(struct octeon_device *oct, in output_console_line() argument
457 (*console->print)(oct, (u32)console_num, in output_console_line()
463 (*console->print)(oct, (u32)console_num, in output_console_line()
485 struct octeon_device *oct = (struct octeon_device *)wk->ctxptr; in check_console() local
489 console = &oct->console[console_num]; in check_console()
498 octeon_console_read(oct, console_num, console_buffer, in check_console()
503 octeon_console_handle_result(oct, console_num); in check_console()
505 output_console_line(oct, console, console_num, in check_console()
509 dev_err(&oct->pci_dev->dev, "Error reading console %u, ret=%d\n", in check_console()
524 output_console_line(oct, console, console_num, in check_console()
534 int octeon_init_consoles(struct octeon_device *oct) in octeon_init_consoles() argument
539 ret = octeon_mem_access_ok(oct); in octeon_init_consoles()
541 dev_err(&oct->pci_dev->dev, "Memory access not okay'\n"); in octeon_init_consoles()
545 ret = octeon_named_block_find(oct, OCTEON_PCI_CONSOLE_BLOCK_NAME, &addr, in octeon_init_consoles()
548 dev_err(&oct->pci_dev->dev, "Could not find console '%s'\n", in octeon_init_consoles()
557 oct->console_nb_info.bar1_index = BAR1_INDEX_STATIC_MAP; in octeon_init_consoles()
558 oct->fn_list.bar1_idx_setup(oct, addr, oct->console_nb_info.bar1_index, in octeon_init_consoles()
560 oct->console_nb_info.dram_region_base = addr in octeon_init_consoles()
566 oct->num_consoles = octeon_read_device_mem32(oct, in octeon_init_consoles()
569 oct->console_desc_addr = addr; in octeon_init_consoles()
571 dev_dbg(&oct->pci_dev->dev, "Initialized consoles. %d available\n", in octeon_init_consoles()
572 oct->num_consoles); in octeon_init_consoles()
577 static void octeon_get_uboot_version(struct octeon_device *oct) in octeon_get_uboot_version() argument
591 if (octeon_console_send_cmd(oct, "setenv stdout pci\n", 50)) { in octeon_get_uboot_version()
596 if (octeon_console_send_cmd(oct, "version\n", 1)) { in octeon_get_uboot_version()
601 console = &oct->console[console_num]; in octeon_get_uboot_version()
610 octeon_console_read(oct, in octeon_get_uboot_version()
619 octeon_console_handle_result(oct, console_num); in octeon_get_uboot_version()
621 dev_err(&oct->pci_dev->dev, "Error reading console %u, ret=%d\n", in octeon_get_uboot_version()
632 dev_dbg(&oct->pci_dev->dev, "%u: %s\n", in octeon_get_uboot_version()
645 dev_info(&oct->pci_dev->dev, "%s\n", uboot_ver); in octeon_get_uboot_version()
650 octeon_console_send_cmd(oct, "setenv stdout serial\n", 50); in octeon_get_uboot_version()
653 int octeon_add_console(struct octeon_device *oct, u32 console_num, in octeon_add_console() argument
662 if (console_num >= oct->num_consoles) { in octeon_add_console()
663 dev_err(&oct->pci_dev->dev, in octeon_add_console()
665 console_num, oct->num_consoles); in octeon_add_console()
667 console = &oct->console[console_num]; in octeon_add_console()
671 coreaddr = oct->console_desc_addr + console_num * 8 + in octeon_add_console()
674 console->addr = octeon_read_device_mem64(oct, coreaddr); in octeon_add_console()
677 console->buffer_size = octeon_read_device_mem32(oct, coreaddr); in octeon_add_console()
681 octeon_read_device_mem64(oct, coreaddr); in octeon_add_console()
685 octeon_read_device_mem64(oct, coreaddr); in octeon_add_console()
688 work = &oct->console_poll_work[console_num].work; in octeon_add_console()
690 octeon_get_uboot_version(oct); in octeon_add_console()
693 oct->console_poll_work[console_num].ctxptr = (void *)oct; in octeon_add_console()
694 oct->console_poll_work[console_num].ctxul = console_num; in octeon_add_console()
702 ret = octeon_console_send_cmd(oct, dbg_enb, 2000); in octeon_add_console()
715 void octeon_remove_consoles(struct octeon_device *oct) in octeon_remove_consoles() argument
720 for (i = 0; i < oct->num_consoles; i++) { in octeon_remove_consoles()
721 console = &oct->console[i]; in octeon_remove_consoles()
726 cancel_delayed_work_sync(&oct->console_poll_work[i]. in octeon_remove_consoles()
734 oct->num_consoles = 0; in octeon_remove_consoles()
758 static int octeon_console_read(struct octeon_device *oct, u32 console_num, in octeon_console_read() argument
765 if (console_num >= oct->num_consoles) { in octeon_console_read()
766 dev_err(&oct->pci_dev->dev, "Attempted to read from disabled console %d\n", in octeon_console_read()
771 console = &oct->console[console_num]; in octeon_console_read()
776 rd_idx = octeon_read_device_mem32(oct, console->addr + in octeon_console_read()
778 wr_idx = octeon_read_device_mem32(oct, console->addr + in octeon_console_read()
794 octeon_pci_read_core_mem(oct, console->output_base_addr + rd_idx, in octeon_console_read()
796 octeon_write_device_mem32(oct, console->addr + in octeon_console_read()
808 int octeon_download_firmware(struct octeon_device *oct, const u8 *data, in octeon_download_firmware() argument
821 dev_err(&oct->pci_dev->dev, "Firmware file too small (%d < %d).\n", in octeon_download_firmware()
830 dev_err(&oct->pci_dev->dev, "Unrecognized firmware file.\n"); in octeon_download_firmware()
838 dev_err(&oct->pci_dev->dev, "Firmware CRC mismatch (0x%08x != 0x%08x).\n", in octeon_download_firmware()
845 dev_err(&oct->pci_dev->dev, "Unmatched firmware version. Expected %s.x, got %s.\n", in octeon_download_firmware()
852 dev_err(&oct->pci_dev->dev, "Too many images in firmware file (%d).\n", in octeon_download_firmware()
857 dev_info(&oct->pci_dev->dev, "Firmware version: %s\n", h->version); in octeon_download_firmware()
858 snprintf(oct->fw_info.liquidio_firmware_version, 32, "LIQUIDIO: %s", in octeon_download_firmware()
863 dev_info(&oct->pci_dev->dev, "%s: Loading %d images\n", __func__, in octeon_download_firmware()
870 dev_info(&oct->pci_dev->dev, "Loading firmware %d at %llx\n", in octeon_download_firmware()
883 octeon_pci_write_core_mem(oct, load_addr, data, (u32)size); in octeon_download_firmware()
905 dev_err(&oct->pci_dev->dev, "Boot command buffer too small\n"); in octeon_download_firmware()
911 dev_info(&oct->pci_dev->dev, "Writing boot command: %s\n", in octeon_download_firmware()
915 ret = octeon_console_send_cmd(oct, h->bootcmd, 50); in octeon_download_firmware()
917 dev_info(&oct->pci_dev->dev, "Boot command send failed\n"); in octeon_download_firmware()