Lines Matching +full:per +full:- +full:console
7 * Copyright (c) 2003-2016 Cavium, Inc.
14 * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
65 #define OCTEON_CONSOLE_POLL_INTERVAL_MS 100 /* 10 times per second */
101 /* Structure that defines a single console.
104 * The actual usable size of each console is console_buf_size -1;
201 if (!oct->bootmem_desc_addr) in __cvmx_bootmem_check_version()
202 oct->bootmem_desc_addr = 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()
221 return -1; in __cvmx_bootmem_check_version()
232 &oct->bootmem_named_block_desc; in __cvmx_bootmem_find_named_block_flags()
236 desc->base_addr = __cvmx_bootmem_desc_get( in __cvmx_bootmem_find_named_block_flags()
243 desc->size = __cvmx_bootmem_desc_get(oct, named_addr, in __cvmx_bootmem_find_named_block_flags()
250 strscpy(desc->name, name, sizeof(desc->name)); in __cvmx_bootmem_find_named_block_flags()
251 return &oct->bootmem_named_block_desc; in __cvmx_bootmem_find_named_block_flags()
267 oct, oct->bootmem_desc_addr, in cvmx_bootmem_phy_named_block_find()
273 oct, oct->bootmem_desc_addr, in cvmx_bootmem_phy_named_block_find()
280 oct, oct->bootmem_desc_addr, in cvmx_bootmem_phy_named_block_find()
343 *base_addr = named_block->base_addr; in octeon_named_block_find()
344 *size = named_block->size; in octeon_named_block_find()
365 dev_dbg(&oct->pci_dev->dev, "sending \"%s\" to bootloader\n", cmd_str); in octeon_console_send_cmd()
367 if (len > BOOTLOADER_PCI_WRITE_BUFFER_STR_LEN - 1) { in octeon_console_send_cmd()
368 dev_err(&oct->pci_dev->dev, "Command string too long, max length is: %d\n", in octeon_console_send_cmd()
369 BOOTLOADER_PCI_WRITE_BUFFER_STR_LEN - 1); in octeon_console_send_cmd()
370 return -1; in octeon_console_send_cmd()
374 dev_err(&oct->pci_dev->dev, "Bootloader not ready for command.\n"); in octeon_console_send_cmd()
375 return -1; in octeon_console_send_cmd()
392 dev_err(&oct->pci_dev->dev, "Bootloader did not accept command.\n"); in octeon_console_send_cmd()
393 return -1; in octeon_console_send_cmd()
402 dev_dbg(&oct->pci_dev->dev, "waiting %d0 ms for bootloader\n", in octeon_wait_for_bootloader()
406 return -1; in octeon_wait_for_bootloader()
412 if (--wait_time_hundredths <= 0) in octeon_wait_for_bootloader()
413 return -1; in octeon_wait_for_bootloader()
422 struct octeon_console *console; in octeon_console_handle_result() local
424 console = &oct->console[console_num]; in octeon_console_handle_result()
426 console->waiting = 0; in octeon_console_handle_result()
432 struct octeon_console *console, in output_console_line() argument
449 * having been read from the console). in output_console_line()
453 if (console->leftover[0] && in output_console_line()
454 (line != console->leftover)) { in output_console_line()
455 if (console->print) in output_console_line()
456 (*console->print)(oct, (u32)console_num, in output_console_line()
457 console->leftover, in output_console_line()
459 console->leftover[0] = '\0'; in output_console_line()
461 if (console->print) in output_console_line()
462 (*console->print)(oct, (u32)console_num, in output_console_line()
472 len = strlen(console->leftover); in output_console_line()
473 strscpy(&console->leftover[len], line, in output_console_line()
474 sizeof(console->leftover) - len + 1); in output_console_line()
482 struct octeon_console *console; in check_console() local
484 struct octeon_device *oct = (struct octeon_device *)wk->ctxptr; in check_console()
485 u32 console_num = (u32)wk->ctxul; in check_console()
488 console = &oct->console[console_num]; in check_console()
493 /* Take console output regardless of whether it will in check_console()
498 sizeof(console_buffer) - 1); in check_console()
501 if (console->waiting) in check_console()
503 if (console->print) { in check_console()
504 output_console_line(oct, console, console_num, in check_console()
508 dev_err(&oct->pci_dev->dev, "Error reading console %u, ret=%d\n", in check_console()
515 /* If nothing is read after polling the console, in check_console()
518 if (console->print && (total_read == 0) && in check_console()
519 (console->leftover[0])) { in check_console()
521 len = strlen(console->leftover); in check_console()
522 console->leftover[len] = '\n'; in check_console()
523 output_console_line(oct, console, console_num, in check_console()
524 console->leftover, (s32)(len + 1)); in check_console()
525 console->leftover[0] = '\0'; in check_console()
530 schedule_delayed_work(&wk->work, msecs_to_jiffies(delay)); in check_console()
540 dev_err(&oct->pci_dev->dev, "Memory access not okay'\n"); in octeon_init_consoles()
547 dev_err(&oct->pci_dev->dev, "Could not find console '%s'\n", in octeon_init_consoles()
553 * mapping to a region of Octeon DRAM that contains the PCI console in octeon_init_consoles()
556 oct->console_nb_info.bar1_index = BAR1_INDEX_STATIC_MAP; in octeon_init_consoles()
557 oct->fn_list.bar1_idx_setup(oct, addr, oct->console_nb_info.bar1_index, in octeon_init_consoles()
559 oct->console_nb_info.dram_region_base = addr in octeon_init_consoles()
560 & ~(OCTEON_BAR1_ENTRY_SIZE - 1ULL); in octeon_init_consoles()
565 oct->num_consoles = octeon_read_device_mem32(oct, in octeon_init_consoles()
568 oct->console_desc_addr = addr; in octeon_init_consoles()
570 dev_dbg(&oct->pci_dev->dev, "Initialized consoles. %d available\n", in octeon_init_consoles()
571 oct->num_consoles); in octeon_init_consoles()
579 struct octeon_console *console; in octeon_get_uboot_version() local
600 console = &oct->console[console_num]; in octeon_get_uboot_version()
605 /* Take console output regardless of whether it will in octeon_get_uboot_version()
611 OCTEON_UBOOT_VER_BUF_SIZE - 1 - in octeon_get_uboot_version()
617 if (console->waiting) in octeon_get_uboot_version()
620 dev_err(&oct->pci_dev->dev, "Error reading console %u, ret=%d\n", in octeon_get_uboot_version()
627 /* If nothing is read after polling the console, in octeon_get_uboot_version()
630 if ((total_read == 0) && (console->leftover[0])) { in octeon_get_uboot_version()
631 dev_dbg(&oct->pci_dev->dev, "%u: %s\n", in octeon_get_uboot_version()
632 console_num, console->leftover); in octeon_get_uboot_version()
633 console->leftover[0] = '\0'; in octeon_get_uboot_version()
636 buf[OCTEON_UBOOT_VER_BUF_SIZE - 1] = '\0'; in octeon_get_uboot_version()
638 uboot_ver = strstr(buf, "U-Boot"); in octeon_get_uboot_version()
642 p--; in octeon_get_uboot_version()
644 dev_info(&oct->pci_dev->dev, "%s\n", uboot_ver); in octeon_get_uboot_version()
659 struct octeon_console *console; in octeon_add_console() local
661 if (console_num >= oct->num_consoles) { in octeon_add_console()
662 dev_err(&oct->pci_dev->dev, in octeon_add_console()
663 "trying to read from console number %d when only 0 to %d exist\n", in octeon_add_console()
664 console_num, oct->num_consoles); in octeon_add_console()
666 console = &oct->console[console_num]; in octeon_add_console()
668 console->waiting = 0; in octeon_add_console()
670 coreaddr = oct->console_desc_addr + console_num * 8 + in octeon_add_console()
673 console->addr = octeon_read_device_mem64(oct, coreaddr); in octeon_add_console()
674 coreaddr = console->addr + offsetof(struct octeon_pci_console, in octeon_add_console()
676 console->buffer_size = octeon_read_device_mem32(oct, coreaddr); in octeon_add_console()
677 coreaddr = console->addr + offsetof(struct octeon_pci_console, in octeon_add_console()
679 console->input_base_addr = in octeon_add_console()
681 coreaddr = console->addr + offsetof(struct octeon_pci_console, in octeon_add_console()
683 console->output_base_addr = in octeon_add_console()
685 console->leftover[0] = '\0'; in octeon_add_console()
687 work = &oct->console_poll_work[console_num].work; in octeon_add_console()
692 oct->console_poll_work[console_num].ctxptr = (void *)oct; in octeon_add_console()
693 oct->console_poll_work[console_num].ctxul = console_num; in octeon_add_console()
697 /* an empty string means use default debug console enablement */ in octeon_add_console()
703 console->active = 1; in octeon_add_console()
717 struct octeon_console *console; in octeon_remove_consoles() local
719 for (i = 0; i < oct->num_consoles; i++) { in octeon_remove_consoles()
720 console = &oct->console[i]; in octeon_remove_consoles()
722 if (!console->active) in octeon_remove_consoles()
725 cancel_delayed_work_sync(&oct->console_poll_work[i]. in octeon_remove_consoles()
727 console->addr = 0; in octeon_remove_consoles()
728 console->buffer_size = 0; in octeon_remove_consoles()
729 console->input_base_addr = 0; in octeon_remove_consoles()
730 console->output_base_addr = 0; in octeon_remove_consoles()
733 oct->num_consoles = 0; in octeon_remove_consoles()
741 return -1; in octeon_console_free_bytes()
743 return ((buffer_size - 1) - (wr_idx - rd_idx)) % buffer_size; in octeon_console_free_bytes()
751 return -1; in octeon_console_avail_bytes()
753 return buffer_size - 1 - in octeon_console_avail_bytes()
762 struct octeon_console *console; in octeon_console_read() local
764 if (console_num >= oct->num_consoles) { in octeon_console_read()
765 dev_err(&oct->pci_dev->dev, "Attempted to read from disabled console %d\n", in octeon_console_read()
770 console = &oct->console[console_num]; in octeon_console_read()
773 * Maybe optimize this with 64-bit read. in octeon_console_read()
775 rd_idx = octeon_read_device_mem32(oct, console->addr + in octeon_console_read()
777 wr_idx = octeon_read_device_mem32(oct, console->addr + in octeon_console_read()
780 bytes_to_read = octeon_console_avail_bytes(console->buffer_size, in octeon_console_read()
790 if (rd_idx + bytes_to_read >= console->buffer_size) in octeon_console_read()
791 bytes_to_read = console->buffer_size - rd_idx; in octeon_console_read()
793 octeon_pci_read_core_mem(oct, console->output_base_addr + rd_idx, in octeon_console_read()
795 octeon_write_device_mem32(oct, console->addr + in octeon_console_read()
799 console->buffer_size); in octeon_console_read()
820 dev_err(&oct->pci_dev->dev, "Firmware file too small (%d < %d).\n", in octeon_download_firmware()
823 return -EINVAL; in octeon_download_firmware()
828 if (be32_to_cpu(h->magic) != LIO_NIC_MAGIC) { in octeon_download_firmware()
829 dev_err(&oct->pci_dev->dev, "Unrecognized firmware file.\n"); in octeon_download_firmware()
830 return -EINVAL; in octeon_download_firmware()
834 sizeof(struct octeon_firmware_file_header) - in octeon_download_firmware()
836 if (crc32_result != be32_to_cpu(h->crc32)) { in octeon_download_firmware()
837 dev_err(&oct->pci_dev->dev, "Firmware CRC mismatch (0x%08x != 0x%08x).\n", in octeon_download_firmware()
838 crc32_result, be32_to_cpu(h->crc32)); in octeon_download_firmware()
839 return -EINVAL; in octeon_download_firmware()
842 if (memcmp(LIQUIDIO_BASE_VERSION, h->version, in octeon_download_firmware()
844 dev_err(&oct->pci_dev->dev, "Unmatched firmware version. Expected %s.x, got %s.\n", in octeon_download_firmware()
846 h->version); in octeon_download_firmware()
847 return -EINVAL; in octeon_download_firmware()
850 if (be32_to_cpu(h->num_images) > LIO_MAX_IMAGES) { in octeon_download_firmware()
851 dev_err(&oct->pci_dev->dev, "Too many images in firmware file (%d).\n", in octeon_download_firmware()
852 be32_to_cpu(h->num_images)); in octeon_download_firmware()
853 return -EINVAL; in octeon_download_firmware()
856 dev_info(&oct->pci_dev->dev, "Firmware version: %s\n", h->version); in octeon_download_firmware()
857 snprintf(oct->fw_info.liquidio_firmware_version, 32, "LIQUIDIO: %s", in octeon_download_firmware()
858 h->version); in octeon_download_firmware()
862 dev_info(&oct->pci_dev->dev, "%s: Loading %d images\n", __func__, in octeon_download_firmware()
863 be32_to_cpu(h->num_images)); in octeon_download_firmware()
865 for (i = 0; i < be32_to_cpu(h->num_images); i++) { in octeon_download_firmware()
866 load_addr = be64_to_cpu(h->desc[i].addr); in octeon_download_firmware()
867 image_len = be32_to_cpu(h->desc[i].len); in octeon_download_firmware()
869 dev_info(&oct->pci_dev->dev, "Loading firmware %d at %llx\n", in octeon_download_firmware()
885 rem -= (u32)size; in octeon_download_firmware()
902 if ((sizeof(h->bootcmd) - strnlen(h->bootcmd, sizeof(h->bootcmd))) < in octeon_download_firmware()
904 dev_err(&oct->pci_dev->dev, "Boot command buffer too small\n"); in octeon_download_firmware()
905 return -EINVAL; in octeon_download_firmware()
907 strncat(h->bootcmd, boottime, in octeon_download_firmware()
908 sizeof(h->bootcmd) - strnlen(h->bootcmd, sizeof(h->bootcmd))); in octeon_download_firmware()
910 dev_info(&oct->pci_dev->dev, "Writing boot command: %s\n", in octeon_download_firmware()
911 h->bootcmd); in octeon_download_firmware()
914 ret = octeon_console_send_cmd(oct, h->bootcmd, 50); in octeon_download_firmware()
916 dev_info(&oct->pci_dev->dev, "Boot command send failed\n"); in octeon_download_firmware()