summaryrefslogtreecommitdiffstats
path: root/drivers/scsi/arcmsr/arcmsr_hba.c
AgeCommit message (Expand)Author
2020-10-23Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsiLinus Torvalds
2020-10-07scsi: arcmsr: Add support for ARC-1886 series RAID controllersching Huang
2020-10-07scsi: arcmsr: Fix device hot-plug monitoring timer stopching Huang
2020-10-07scsi: arcmsr: Remove unnecessary syntaxching Huang
2020-08-23treewide: Use fallthrough pseudo-keywordGustavo A. R. Silva
2020-07-24scsi: arcmsr: arcmsr_hba: Remove statement with no effectLee Jones
2020-07-15scsi: arcmsr: Remove some set but unused variablesLee Jones
2020-04-02Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsiLinus Torvalds
2020-03-24scsi: simplify scsi_partsizeChristoph Hellwig
2020-03-11scsi: docs: convert arcmsr_spec.txt to ReSTMauro Carvalho Chehab
2020-01-06remove ioremap_nocache and devm_ioremap_nocacheChristoph Hellwig
2019-11-19scsi: arcmsr: fix indentation issuesColin Ian King
2019-01-22scsi: arcmsr: Fix suspend/resume of ACB_ADAPTER_TYPE_B part 2Ching Huang
2019-01-22scsi: arcmsr: Use dma_alloc_coherent to replace dma_zalloc_coherentChing Huang
2019-01-08scsi: arcmsr: Fix suspend/resume of ACB_ADAPTER_TYPE_BChing Huang
2019-01-08scsi: arcmsr: Separate 'set dma mask' as a functionChing Huang
2019-01-08scsi: arcmsr: Add an option of set dma_mask_64 for ACB_ADAPTER_TYPE_AChing Huang
2019-01-08scsi: arcmsr: Update ACB_ADAPTER_TYPE_D for >4GB ccb addressingChing Huang
2019-01-08scsi: arcmsr: Update ACB_ADAPTER_TYPE_C for >4GB ccb addressingChing Huang
2019-01-08scsi: arcmsr: Update ACB_ADAPTER_TYPE_B for >4GB ccb addressingChing Huang
2019-01-08scsi: arcmsr: Update ACB_ADAPTER_TYPE_A for >4GB ccb addressingChing Huang
2019-01-08scsi: arcmsr: Update arcmsr_alloc_ccb_pool for ccb buffer address above 4GBChing Huang
2019-01-08scsi: arcmsr: Merge arcmsr_alloc_io_queue to arcmsr_alloc_ccb_poolChing Huang
2019-01-08scsi: arcmsr: Rename arcmsr_free_mu to arcmsr_free_io_queueChing Huang
2019-01-08scsi: arcmsr: Rename acb structure member roundup_ccbsize to ioqueue_sizeChing Huang
2018-12-18scsi: flip the default on use_clusteringChristoph Hellwig
2018-11-15scsi: arcmsr: use dma_set_maskChristoph Hellwig
2018-10-16scsi: arcmsr: Remove set but not used variables 'id, lun'YueHaibing
2018-10-10scsi: arcmsr: clean up clang warning on extraneous parenthesesColin Ian King
2018-09-11scsi: arcmsr: Spelling s/rebulid/rebuild/Geert Uytterhoeven
2018-07-12scsi: arcmsr: Fix error of resuming from hibernation for adapter type EChing Huang
2018-03-21scsi: arcmsr: Sleep to avoid CPU stuck too long for waiting adapter readyChing Huang
2018-03-21scsi: arcmsr: Handle adapter removed due to thunderbolt cable disconnection.Ching Huang
2018-01-22scsi: arcmsr: avoid do_gettimeofdayArnd Bergmann
2017-12-20scsi: arcmsr: simplify arcmsr_request_device_map routineChing Huang
2017-12-20scsi: arcmsr: simplify all arcmsr_hbaX_get_config routine by call a new get_a...Ching Huang
2017-12-20scsi: arcmsr: simplify arcmsr_hbaE_get_config functionChing Huang
2017-12-20scsi: arcmsr: waiting for iop firmware ready before issue get_config command ...Ching Huang
2017-12-20scsi: arcmsr: simplify arcmsr_hbaC_get_config functionChing Huang
2017-12-11scsi: arcmsr: remove redundant check for secs < 0Colin Ian King
2017-12-06scsi: arcmsr: Fix command result for CHECK_CONDITIONChing Huang
2017-12-06scsi: arcmsr: Add driver module parameter msix_enableChing Huang
2017-12-06scsi: arcmsr: Add driver module parameter msi_enableChing Huang
2017-12-06scsi: arcmsr: Fix grammarChing Huang
2017-12-06scsi: arcmsr: Adjust whitespaceChing Huang
2017-12-06scsi: arcmsr: Spin off duplicate codeChing Huang
2017-12-06scsi: arcmsr: Fix clear doorbell queue on ACB_ADAPTER_TYPE_BChing Huang
2017-12-06scsi: arcmsr: Add a function to set date and time to firmwareChing Huang
2017-12-06scsi: arcmsr: Add ACB_F_MSG_GET_CONFIG to acb->acb_flagsChing Huang
2017-12-06scsi: arcmsr: Add driver option cmd_per_lunChing Huang
n421'>421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915
#define pr_fmt(fmt)	"OF: " fmt

#include <linux/device.h>
#include <linux/io.h>
#include <linux/ioport.h>
#include <linux/module.h>
#include <linux/of_address.h>
#include <linux/pci.h>
#include <linux/pci_regs.h>
#include <linux/sizes.h>
#include <linux/slab.h>
#include <linux/string.h>

/* Max address size we deal with */
#define OF_MAX_ADDR_CELLS	4
#define OF_CHECK_ADDR_COUNT(na)	((na) > 0 && (na) <= OF_MAX_ADDR_CELLS)
#define OF_CHECK_COUNTS(na, ns)	(OF_CHECK_ADDR_COUNT(na) && (ns) > 0)

static struct of_bus *of_match_bus(struct device_node *np);
static int __of_address_to_resource(struct device_node *dev,
		const __be32 *addrp, u64 size, unsigned int flags,
		const char *name, struct resource *r);

/* Debug utility */
#ifdef DEBUG
static void of_dump_addr(const char *s, const __be32 *addr, int na)
{
	pr_debug("%s", s);
	while (na--)
		pr_cont(" %08x", be32_to_cpu(*(addr++)));
	pr_cont("\n");
}
#else
static void of_dump_addr(const char *s, const __be32 *addr, int na) { }
#endif

/* Callbacks for bus specific translators */
struct of_bus {
	const char	*name;
	const char	*addresses;
	int		(*match)(struct device_node *parent);
	void		(*count_cells)(struct device_node *child,
				       int *addrc, int *sizec);
	u64		(*map)(__be32 *addr, const __be32 *range,
				int na, int ns, int pna);
	int		(*translate)(__be32 *addr, u64 offset, int na);
	unsigned int	(*get_flags)(const __be32 *addr);
};

/*
 * Default translator (generic bus)
 */

static void of_bus_default_count_cells(struct device_node *dev,
				       int *addrc, int *sizec)
{
	if (addrc)
		*addrc = of_n_addr_cells(dev);
	if (sizec)
		*sizec = of_n_size_cells(dev);
}

static u64 of_bus_default_map(__be32 *addr, const __be32 *range,
		int na, int ns, int pna)
{
	u64 cp, s, da;

	cp = of_read_number(range, na);
	s  = of_read_number(range + na + pna, ns);
	da = of_read_number(addr, na);

	pr_debug("default map, cp=%llx, s=%llx, da=%llx\n",
		 (unsigned long long)cp, (unsigned long long)s,
		 (unsigned long long)da);

	if (da < cp || da >= (cp + s))
		return OF_BAD_ADDR;
	return da - cp;
}

static int of_bus_default_translate(__be32 *addr, u64 offset, int na)
{
	u64 a = of_read_number(addr, na);
	memset(addr, 0, na * 4);
	a += offset;
	if (na > 1)
		addr[na - 2] = cpu_to_be32(a >> 32);
	addr[na - 1] = cpu_to_be32(a & 0xffffffffu);

	return 0;
}

static unsigned int of_bus_default_get_flags(const __be32 *addr)
{
	return IORESOURCE_MEM;
}

#ifdef CONFIG_OF_ADDRESS_PCI
/*
 * PCI bus specific translator
 */

static int of_bus_pci_match(struct device_node *np)
{
	/*
 	 * "pciex" is PCI Express
	 * "vci" is for the /chaos bridge on 1st-gen PCI powermacs
	 * "ht" is hypertransport
	 */
	return !strcmp(np->type, "pci") || !strcmp(np->type, "pciex") ||
		!strcmp(np->type, "vci") || !strcmp(np->type, "ht");
}

static void of_bus_pci_count_cells(struct device_node *np,
				   int *addrc, int *sizec)
{
	if (addrc)
		*addrc = 3;
	if (sizec)
		*sizec = 2;
}

static unsigned int of_bus_pci_get_flags(const __be32 *addr)
{
	unsigned int flags = 0;
	u32 w = be32_to_cpup(addr);

	switch((w >> 24) & 0x03) {
	case 0x01:
		flags |= IORESOURCE_IO;
		break;
	case 0x02: /* 32 bits */
	case 0x03: /* 64 bits */
		flags |= IORESOURCE_MEM;
		break;
	}
	if (w & 0x40000000)
		flags |= IORESOURCE_PREFETCH;
	return flags;
}

static u64 of_bus_pci_map(__be32 *addr, const __be32 *range, int