Lines Matching refs:pdev
155 static bool renesas_check_rom(struct pci_dev *pdev) in renesas_check_rom() argument
161 retval = pci_read_config_word(pdev, RENESAS_ROM_STATUS, &rom_status); in renesas_check_rom()
167 dev_dbg(&pdev->dev, "External ROM exists\n"); in renesas_check_rom()
174 static int renesas_check_rom_state(struct pci_dev *pdev) in renesas_check_rom_state() argument
181 err = pci_read_config_dword(pdev, RENESAS_FW_VERSION, &version); in renesas_check_rom_state()
187 dev_dbg(&pdev->dev, "Found ROM version: %x\n", version); in renesas_check_rom_state()
192 err = pci_read_config_word(pdev, RENESAS_ROM_STATUS, &rom_state); in renesas_check_rom_state()
198 dev_dbg(&pdev->dev, "ROM exists\n"); in renesas_check_rom_state()
206 dev_dbg(&pdev->dev, "Unknown ROM status ...\n"); in renesas_check_rom_state()
211 dev_err(&pdev->dev, "Invalid ROM.."); in renesas_check_rom_state()
219 static int renesas_fw_check_running(struct pci_dev *pdev) in renesas_fw_check_running() argument
229 err = pci_read_config_byte(pdev, RENESAS_FW_STATUS, &fw_state); in renesas_fw_check_running()
239 dev_dbg(&pdev->dev, "FW Download Lock is engaged."); in renesas_fw_check_running()
244 dev_err(&pdev->dev, in renesas_fw_check_running()
255 dev_err(&pdev->dev, in renesas_fw_check_running()
263 dev_dbg(&pdev->dev, "FW is not ready/loaded yet."); in renesas_fw_check_running()
269 dev_dbg(&pdev->dev, "FW is ready."); in renesas_fw_check_running()
273 dev_err(&pdev->dev, in renesas_fw_check_running()
278 dev_err(&pdev->dev, in renesas_fw_check_running()
285 static int renesas_fw_download(struct pci_dev *pdev, in renesas_fw_download() argument
303 err = pci_write_config_byte(pdev, RENESAS_FW_STATUS, in renesas_fw_download()
310 err = renesas_fw_download_image(pdev, fw_data, i, false); in renesas_fw_download()
312 dev_err(&pdev->dev, in renesas_fw_download()
325 err = pci_read_config_byte(pdev, RENESAS_FW_STATUS_MSB, in renesas_fw_download()
335 dev_warn(&pdev->dev, "Final Firmware Download step timed out."); in renesas_fw_download()
341 err = pci_write_config_byte(pdev, RENESAS_FW_STATUS, 0); in renesas_fw_download()
347 err = pci_read_config_byte(pdev, RENESAS_FW_STATUS, &fw_status); in renesas_fw_download()
357 err = renesas_fw_check_running(pdev); in renesas_fw_download()
367 dev_err(&pdev->dev, "FW Load timedout"); in renesas_fw_download()
378 static void renesas_rom_erase(struct pci_dev *pdev) in renesas_rom_erase() argument
383 dev_dbg(&pdev->dev, "Performing ROM Erase...\n"); in renesas_rom_erase()
384 retval = pci_write_config_dword(pdev, RENESAS_DATA0, in renesas_rom_erase()
387 dev_err(&pdev->dev, "ROM erase, magic word write failed: %d\n", in renesas_rom_erase()
392 retval = pci_read_config_byte(pdev, RENESAS_ROM_STATUS, &status); in renesas_rom_erase()
394 dev_err(&pdev->dev, "ROM status read failed: %d\n", in renesas_rom_erase()
399 retval = pci_write_config_byte(pdev, RENESAS_ROM_STATUS, status); in renesas_rom_erase()
401 dev_err(&pdev->dev, "ROM erase set word write failed\n"); in renesas_rom_erase()
409 retval = pci_read_config_byte(pdev, RENESAS_ROM_STATUS, in renesas_rom_erase()
419 dev_dbg(&pdev->dev, "Chip erase timedout: %x\n", status); in renesas_rom_erase()
421 dev_dbg(&pdev->dev, "ROM Erase... Done success\n"); in renesas_rom_erase()
424 static bool renesas_setup_rom(struct pci_dev *pdev, const struct firmware *fw) in renesas_setup_rom() argument
431 err = pci_write_config_dword(pdev, RENESAS_DATA0, in renesas_setup_rom()
437 err = pci_write_config_byte(pdev, RENESAS_ROM_STATUS, in renesas_setup_rom()
443 err = pci_read_config_byte(pdev, RENESAS_ROM_STATUS, &status); in renesas_setup_rom()
448 dev_err(&pdev->dev, in renesas_setup_rom()
455 err = renesas_fw_download_image(pdev, fw_data, i, true); in renesas_setup_rom()
457 dev_err(&pdev->dev, in renesas_setup_rom()
468 err = pci_read_config_byte(pdev, RENESAS_ROM_STATUS_MSB, in renesas_setup_rom()
478 dev_err(&pdev->dev, "Final Firmware ROM Download step timed out\n"); in renesas_setup_rom()
483 err = pci_write_config_byte(pdev, RENESAS_ROM_STATUS, 0); in renesas_setup_rom()
491 err = pci_read_config_byte(pdev, RENESAS_ROM_STATUS, &status); in renesas_setup_rom()
493 dev_err(&pdev->dev, "Read ROM status failed:%d\n", in renesas_setup_rom()
499 dev_dbg(&pdev->dev, "Download ROM success\n"); in renesas_setup_rom()
505 dev_err(&pdev->dev, in renesas_setup_rom()
510 dev_dbg(&pdev->dev, "Download to external ROM succeeded\n"); in renesas_setup_rom()
513 err = pci_write_config_byte(pdev, RENESAS_ROM_STATUS, in renesas_setup_rom()
516 dev_err(&pdev->dev, "Set ROM execute failed: %d\n", in renesas_setup_rom()
525 err = pci_read_config_byte(pdev, RENESAS_ROM_STATUS, &status); in renesas_setup_rom()
534 dev_err(&pdev->dev, "ROM Exec timed out: %x\n", status); in renesas_setup_rom()
541 pci_write_config_byte(pdev, RENESAS_ROM_STATUS, 0); in renesas_setup_rom()
545 static int renesas_load_fw(struct pci_dev *pdev, const struct firmware *fw) in renesas_load_fw() argument
551 rom = renesas_check_rom(pdev); in renesas_load_fw()
554 renesas_rom_erase(pdev); in renesas_load_fw()
557 rom = renesas_setup_rom(pdev, fw); in renesas_load_fw()
559 dev_dbg(&pdev->dev, in renesas_load_fw()
562 dev_dbg(&pdev->dev, in renesas_load_fw()
568 err = renesas_fw_download(pdev, fw); in renesas_load_fw()
572 dev_err(&pdev->dev, "firmware failed to download (%d).", err); in renesas_load_fw()
576 int renesas_xhci_check_request_fw(struct pci_dev *pdev, in renesas_xhci_check_request_fw() argument
587 has_rom = renesas_check_rom(pdev); in renesas_xhci_check_request_fw()
589 err = renesas_check_rom_state(pdev); in renesas_xhci_check_request_fw()
596 err = renesas_fw_check_running(pdev); in renesas_xhci_check_request_fw()
605 pci_dev_get(pdev); in renesas_xhci_check_request_fw()
606 err = firmware_request_nowarn(&fw, fw_name, &pdev->dev); in renesas_xhci_check_request_fw()
607 pci_dev_put(pdev); in renesas_xhci_check_request_fw()
610 dev_info(&pdev->dev, "failed to load firmware %s, fallback to ROM\n", in renesas_xhci_check_request_fw()
614 dev_err(&pdev->dev, "failed to load firmware %s: %d\n", in renesas_xhci_check_request_fw()
623 err = renesas_load_fw(pdev, fw); in renesas_xhci_check_request_fw()