Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

phy: usb: Restructure in preparation for adding 7216 USB support

The driver is being restructured in preparation for adding support
for the new Synopsys USB conroller on the 7216. Since all the bugs
and work-arounds in previous STB chips are supposed to be fixed,
most of the code in phy-brcm-usb-init.c is not needed. Instead of
adding more complexity to the already complicated phy-brcm-usb-init.c
module, the driver will be restructured to use a vector table to
dispatch into different C modules for the different controllers.

There was also some general cleanup done including some ipp setup
code that was incorrect.

Signed-off-by: Al Cooper <alcooperx@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>

authored by

Al Cooper and committed by
Kishon Vijay Abraham I
94583a41 f1c0db40

+213 -122
+84 -107
drivers/phy/broadcom/phy-brcm-usb-init.c
··· 129 129 USB_CTRL_SELECTOR_COUNT, 130 130 }; 131 131 132 - #define USB_CTRL_REG(base, reg) ((void __iomem *)base + USB_CTRL_##reg) 133 - #define USB_XHCI_EC_REG(base, reg) ((void __iomem *)base + USB_XHCI_EC_##reg) 134 - #define USB_CTRL_MASK(reg, field) \ 135 - USB_CTRL_##reg##_##field##_MASK 136 132 #define USB_CTRL_MASK_FAMILY(params, reg, field) \ 137 133 (params->usb_reg_bits_map[USB_CTRL_##reg##_##field##_SELECTOR]) 138 134 ··· 138 142 #define USB_CTRL_UNSET_FAMILY(params, reg, field) \ 139 143 usb_ctrl_unset_family(params, USB_CTRL_##reg, \ 140 144 USB_CTRL_##reg##_##field##_SELECTOR) 141 - 142 - #define USB_CTRL_SET(base, reg, field) \ 143 - usb_ctrl_set(USB_CTRL_REG(base, reg), \ 144 - USB_CTRL_##reg##_##field##_MASK) 145 - #define USB_CTRL_UNSET(base, reg, field) \ 146 - usb_ctrl_unset(USB_CTRL_REG(base, reg), \ 147 - USB_CTRL_##reg##_##field##_MASK) 148 145 149 146 #define MDIO_USB2 0 150 147 #define MDIO_USB3 BIT(31) ··· 394 405 }, 395 406 }; 396 407 397 - static inline u32 brcmusb_readl(void __iomem *addr) 398 - { 399 - return readl(addr); 400 - } 401 - 402 - static inline void brcmusb_writel(u32 val, void __iomem *addr) 403 - { 404 - writel(val, addr); 405 - } 406 - 407 408 static inline 408 409 void usb_ctrl_unset_family(struct brcm_usb_init_params *params, 409 410 u32 reg_offset, u32 field) 410 411 { 411 412 u32 mask; 412 - void __iomem *reg; 413 413 414 414 mask = params->usb_reg_bits_map[field]; 415 - reg = params->ctrl_regs + reg_offset; 416 - brcmusb_writel(brcmusb_readl(reg) & ~mask, reg); 415 + brcm_usb_ctrl_unset(params->ctrl_regs + reg_offset, mask); 417 416 }; 418 417 419 418 static inline ··· 409 432 u32 reg_offset, u32 field) 410 433 { 411 434 u32 mask; 412 - void __iomem *reg; 413 435 414 436 mask = params->usb_reg_bits_map[field]; 415 - reg = params->ctrl_regs + reg_offset; 416 - brcmusb_writel(brcmusb_readl(reg) | mask, reg); 437 + brcm_usb_ctrl_set(params->ctrl_regs + reg_offset, mask); 417 438 }; 418 - 419 - static inline void usb_ctrl_set(void __iomem *reg, u32 field) 420 - { 421 - u32 value; 422 - 423 - value = brcmusb_readl(reg); 424 - brcmusb_writel(value | field, reg); 425 - } 426 - 427 - static inline void usb_ctrl_unset(void __iomem *reg, u32 field) 428 - { 429 - u32 value; 430 - 431 - value = brcmusb_readl(reg); 432 - brcmusb_writel(value & ~field, reg); 433 - } 434 439 435 440 static u32 brcmusb_usb_mdio_read(void __iomem *ctrl_base, u32 reg, int mode) 436 441 { 437 442 u32 data; 438 443 439 444 data = (reg << 16) | mode; 440 - brcmusb_writel(data, USB_CTRL_REG(ctrl_base, MDIO)); 445 + brcm_usb_writel(data, USB_CTRL_REG(ctrl_base, MDIO)); 441 446 data |= (1 << 24); 442 - brcmusb_writel(data, USB_CTRL_REG(ctrl_base, MDIO)); 447 + brcm_usb_writel(data, USB_CTRL_REG(ctrl_base, MDIO)); 443 448 data &= ~(1 << 24); 444 449 /* wait for the 60MHz parallel to serial shifter */ 445 450 usleep_range(10, 20); 446 - brcmusb_writel(data, USB_CTRL_REG(ctrl_base, MDIO)); 451 + brcm_usb_writel(data, USB_CTRL_REG(ctrl_base, MDIO)); 447 452 /* wait for the 60MHz parallel to serial shifter */ 448 453 usleep_range(10, 20); 449 454 450 - return brcmusb_readl(USB_CTRL_REG(ctrl_base, MDIO2)) & 0xffff; 455 + return brcm_usb_readl(USB_CTRL_REG(ctrl_base, MDIO2)) & 0xffff; 451 456 } 452 457 453 458 static void brcmusb_usb_mdio_write(void __iomem *ctrl_base, u32 reg, ··· 438 479 u32 data; 439 480 440 481 data = (reg << 16) | val | mode; 441 - brcmusb_writel(data, USB_CTRL_REG(ctrl_base, MDIO)); 482 + brcm_usb_writel(data, USB_CTRL_REG(ctrl_base, MDIO)); 442 483 data |= (1 << 25); 443 - brcmusb_writel(data, USB_CTRL_REG(ctrl_base, MDIO)); 484 + brcm_usb_writel(data, USB_CTRL_REG(ctrl_base, MDIO)); 444 485 data &= ~(1 << 25); 445 486 446 487 /* wait for the 60MHz parallel to serial shifter */ 447 488 usleep_range(10, 20); 448 - brcmusb_writel(data, USB_CTRL_REG(ctrl_base, MDIO)); 489 + brcm_usb_writel(data, USB_CTRL_REG(ctrl_base, MDIO)); 449 490 /* wait for the 60MHz parallel to serial shifter */ 450 491 usleep_range(10, 20); 451 492 } ··· 672 713 673 714 if (params->family_id != 0x74371000 || !xhci_ec_base) 674 715 return; 675 - brcmusb_writel(0xa20c, USB_XHCI_EC_REG(xhci_ec_base, IRAADR)); 676 - val = brcmusb_readl(USB_XHCI_EC_REG(xhci_ec_base, IRADAT)); 716 + brcm_usb_writel(0xa20c, USB_XHCI_EC_REG(xhci_ec_base, IRAADR)); 717 + val = brcm_usb_readl(USB_XHCI_EC_REG(xhci_ec_base, IRADAT)); 677 718 678 719 /* set cfg_pick_ss_lock */ 679 720 val |= (1 << 27); 680 - brcmusb_writel(val, USB_XHCI_EC_REG(xhci_ec_base, IRADAT)); 721 + brcm_usb_writel(val, USB_XHCI_EC_REG(xhci_ec_base, IRADAT)); 681 722 682 723 /* Reset USB 3.0 PHY for workaround to take effect */ 683 724 USB_CTRL_UNSET(params->ctrl_regs, USB30_CTL1, PHY3_RESETB); ··· 710 751 * - default chip/rev. 711 752 * NOTE: The minor rev is always ignored. 712 753 */ 713 - static enum brcm_family_type brcmusb_get_family_type( 754 + static enum brcm_family_type get_family_type( 714 755 struct brcm_usb_init_params *params) 715 756 { 716 757 int last_type = -1; ··· 738 779 return last_type; 739 780 } 740 781 741 - void brcm_usb_init_ipp(struct brcm_usb_init_params *params) 782 + static void usb_init_ipp(struct brcm_usb_init_params *params) 742 783 { 743 784 void __iomem *ctrl = params->ctrl_regs; 744 785 u32 reg; ··· 754 795 USB_CTRL_SET_FAMILY(params, USB30_CTL1, USB3_IPP); 755 796 } 756 797 757 - reg = brcmusb_readl(USB_CTRL_REG(ctrl, SETUP)); 798 + reg = brcm_usb_readl(USB_CTRL_REG(ctrl, SETUP)); 758 799 orig_reg = reg; 759 800 if (USB_CTRL_MASK_FAMILY(params, SETUP, STRAP_CC_DRD_MODE_ENABLE_SEL)) 760 801 /* Never use the strap, it's going away. */ ··· 762 803 SETUP, 763 804 STRAP_CC_DRD_MODE_ENABLE_SEL)); 764 805 if (USB_CTRL_MASK_FAMILY(params, SETUP, STRAP_IPP_SEL)) 806 + /* override ipp strap pin (if it exits) */ 765 807 if (params->ipp != 2) 766 - /* override ipp strap pin (if it exits) */ 767 808 reg &= ~(USB_CTRL_MASK_FAMILY(params, SETUP, 768 809 STRAP_IPP_SEL)); 769 810 ··· 771 812 reg &= ~(USB_CTRL_MASK(SETUP, IPP) | USB_CTRL_MASK(SETUP, IOC)); 772 813 if (params->ioc) 773 814 reg |= USB_CTRL_MASK(SETUP, IOC); 774 - if (params->ipp == 1 && ((reg & USB_CTRL_MASK(SETUP, IPP)) == 0)) 815 + if (params->ipp == 1) 775 816 reg |= USB_CTRL_MASK(SETUP, IPP); 776 - brcmusb_writel(reg, USB_CTRL_REG(ctrl, SETUP)); 817 + brcm_usb_writel(reg, USB_CTRL_REG(ctrl, SETUP)); 777 818 778 819 /* 779 820 * If we're changing IPP, make sure power is off long enough 780 821 * to turn off any connected devices. 781 822 */ 782 - if (reg != orig_reg) 823 + if ((reg ^ orig_reg) & USB_CTRL_MASK(SETUP, IPP)) 783 824 msleep(50); 784 825 } 785 826 786 - int brcm_usb_init_get_dual_select(struct brcm_usb_init_params *params) 787 - { 788 - void __iomem *ctrl = params->ctrl_regs; 789 - u32 reg = 0; 790 - 791 - if (USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, PORT_MODE)) { 792 - reg = brcmusb_readl(USB_CTRL_REG(ctrl, USB_DEVICE_CTL1)); 793 - reg &= USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, 794 - PORT_MODE); 795 - } 796 - return reg; 797 - } 798 - 799 - void brcm_usb_init_set_dual_select(struct brcm_usb_init_params *params, 800 - int mode) 801 - { 802 - void __iomem *ctrl = params->ctrl_regs; 803 - u32 reg; 804 - 805 - if (USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, PORT_MODE)) { 806 - reg = brcmusb_readl(USB_CTRL_REG(ctrl, USB_DEVICE_CTL1)); 807 - reg &= ~USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, 808 - PORT_MODE); 809 - reg |= mode; 810 - brcmusb_writel(reg, USB_CTRL_REG(ctrl, USB_DEVICE_CTL1)); 811 - } 812 - } 813 - 814 - void brcm_usb_init_common(struct brcm_usb_init_params *params) 827 + static void usb_init_common(struct brcm_usb_init_params *params) 815 828 { 816 829 u32 reg; 817 830 void __iomem *ctrl = params->ctrl_regs; 818 831 819 832 /* Clear any pending wake conditions */ 820 - reg = brcmusb_readl(USB_CTRL_REG(ctrl, USB_PM_STATUS)); 821 - brcmusb_writel(reg, USB_CTRL_REG(ctrl, USB_PM_STATUS)); 833 + reg = brcm_usb_readl(USB_CTRL_REG(ctrl, USB_PM_STATUS)); 834 + brcm_usb_writel(reg, USB_CTRL_REG(ctrl, USB_PM_STATUS)); 822 835 823 836 /* Take USB out of power down */ 824 837 if (USB_CTRL_MASK_FAMILY(params, PLL_CTL, PLL_IDDQ_PWRDN)) { ··· 816 885 /* Block auto PLL suspend by USB2 PHY (Sasi) */ 817 886 USB_CTRL_SET(ctrl, PLL_CTL, PLL_SUSPEND_EN); 818 887 819 - reg = brcmusb_readl(USB_CTRL_REG(ctrl, SETUP)); 888 + reg = brcm_usb_readl(USB_CTRL_REG(ctrl, SETUP)); 820 889 if (params->selected_family == BRCM_FAMILY_7364A0) 821 890 /* Suppress overcurrent indication from USB30 ports for A0 */ 822 891 reg |= USB_CTRL_MASK_FAMILY(params, SETUP, OC3_DISABLE); ··· 832 901 reg |= USB_CTRL_MASK_FAMILY(params, SETUP, SCB1_EN); 833 902 if (USB_CTRL_MASK_FAMILY(params, SETUP, SCB2_EN)) 834 903 reg |= USB_CTRL_MASK_FAMILY(params, SETUP, SCB2_EN); 835 - brcmusb_writel(reg, USB_CTRL_REG(ctrl, SETUP)); 904 + brcm_usb_writel(reg, USB_CTRL_REG(ctrl, SETUP)); 836 905 837 906 brcmusb_memc_fix(params); 838 907 839 908 if (USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, PORT_MODE)) { 840 - reg = brcmusb_readl(USB_CTRL_REG(ctrl, USB_DEVICE_CTL1)); 909 + reg = brcm_usb_readl(USB_CTRL_REG(ctrl, USB_DEVICE_CTL1)); 841 910 reg &= ~USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, 842 911 PORT_MODE); 843 912 reg |= params->mode; 844 - brcmusb_writel(reg, USB_CTRL_REG(ctrl, USB_DEVICE_CTL1)); 913 + brcm_usb_writel(reg, USB_CTRL_REG(ctrl, USB_DEVICE_CTL1)); 845 914 } 846 915 if (USB_CTRL_MASK_FAMILY(params, USB_PM, BDC_SOFT_RESETB)) { 847 916 switch (params->mode) { ··· 863 932 } 864 933 } 865 934 866 - void brcm_usb_init_eohci(struct brcm_usb_init_params *params) 935 + static void usb_init_eohci(struct brcm_usb_init_params *params) 867 936 { 868 937 u32 reg; 869 938 void __iomem *ctrl = params->ctrl_regs; ··· 879 948 USB_CTRL_SET(ctrl, EBRIDGE, ESTOP_SCB_REQ); 880 949 881 950 /* Setup the endian bits */ 882 - reg = brcmusb_readl(USB_CTRL_REG(ctrl, SETUP)); 951 + reg = brcm_usb_readl(USB_CTRL_REG(ctrl, SETUP)); 883 952 reg &= ~USB_CTRL_SETUP_ENDIAN_BITS; 884 953 reg |= USB_CTRL_MASK_FAMILY(params, SETUP, ENDIAN); 885 - brcmusb_writel(reg, USB_CTRL_REG(ctrl, SETUP)); 954 + brcm_usb_writel(reg, USB_CTRL_REG(ctrl, SETUP)); 886 955 887 956 if (params->selected_family == BRCM_FAMILY_7271A0) 888 957 /* Enable LS keep alive fix for certain keyboards */ ··· 893 962 * Make the burst size 512 bytes to fix a hardware bug 894 963 * on the 7255a0. See HW7255-24. 895 964 */ 896 - reg = brcmusb_readl(USB_CTRL_REG(ctrl, EBRIDGE)); 965 + reg = brcm_usb_readl(USB_CTRL_REG(ctrl, EBRIDGE)); 897 966 reg &= ~USB_CTRL_MASK(EBRIDGE, EBR_SCB_SIZE); 898 967 reg |= 0x800; 899 - brcmusb_writel(reg, USB_CTRL_REG(ctrl, EBRIDGE)); 968 + brcm_usb_writel(reg, USB_CTRL_REG(ctrl, EBRIDGE)); 900 969 } 901 970 } 902 971 903 - void brcm_usb_init_xhci(struct brcm_usb_init_params *params) 972 + static void usb_init_xhci(struct brcm_usb_init_params *params) 904 973 { 905 974 void __iomem *ctrl = params->ctrl_regs; 906 975 ··· 928 997 brcmusb_usb3_otp_fix(params); 929 998 } 930 999 931 - void brcm_usb_uninit_common(struct brcm_usb_init_params *params) 1000 + static void usb_uninit_common(struct brcm_usb_init_params *params) 932 1001 { 933 1002 if (USB_CTRL_MASK_FAMILY(params, USB_PM, USB_PWRDN)) 934 1003 USB_CTRL_SET_FAMILY(params, USB_PM, USB_PWRDN); ··· 937 1006 USB_CTRL_SET_FAMILY(params, PLL_CTL, PLL_IDDQ_PWRDN); 938 1007 } 939 1008 940 - void brcm_usb_uninit_eohci(struct brcm_usb_init_params *params) 1009 + static void usb_uninit_eohci(struct brcm_usb_init_params *params) 941 1010 { 942 1011 } 943 1012 944 - void brcm_usb_uninit_xhci(struct brcm_usb_init_params *params) 1013 + static void usb_uninit_xhci(struct brcm_usb_init_params *params) 945 1014 { 946 1015 brcmusb_xhci_soft_reset(params, 1); 947 1016 USB_CTRL_SET(params->ctrl_regs, USB30_PCTL, PHY3_IDDQ_OVERRIDE); 948 1017 } 949 1018 950 - void brcm_usb_wake_enable(struct brcm_usb_init_params *params, 1019 + static int usb_get_dual_select(struct brcm_usb_init_params *params) 1020 + { 1021 + void __iomem *ctrl = params->ctrl_regs; 1022 + u32 reg = 0; 1023 + 1024 + pr_debug("%s\n", __func__); 1025 + if (USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, PORT_MODE)) { 1026 + reg = brcm_usb_readl(USB_CTRL_REG(ctrl, USB_DEVICE_CTL1)); 1027 + reg &= USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, 1028 + PORT_MODE); 1029 + } 1030 + return reg; 1031 + } 1032 + 1033 + static void usb_set_dual_select(struct brcm_usb_init_params *params, int mode) 1034 + { 1035 + void __iomem *ctrl = params->ctrl_regs; 1036 + u32 reg; 1037 + 1038 + pr_debug("%s\n", __func__); 1039 + 1040 + if (USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, PORT_MODE)) { 1041 + reg = brcm_usb_readl(USB_CTRL_REG(ctrl, USB_DEVICE_CTL1)); 1042 + reg &= ~USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, 1043 + PORT_MODE); 1044 + reg |= mode; 1045 + brcm_usb_writel(reg, USB_CTRL_REG(ctrl, USB_DEVICE_CTL1)); 1046 + } 1047 + } 1048 + 1049 + static void usb_wake_enable(struct brcm_usb_init_params *params, 951 1050 int enable) 952 1051 { 953 1052 void __iomem *ctrl = params->ctrl_regs; ··· 988 1027 USB_CTRL_UNSET(ctrl, USB_PM, RMTWKUP_EN); 989 1028 } 990 1029 991 - void brcm_usb_set_family_map(struct brcm_usb_init_params *params) 1030 + static const struct brcm_usb_init_ops bcm7445_ops = { 1031 + .init_ipp = usb_init_ipp, 1032 + .init_common = usb_init_common, 1033 + .init_eohci = usb_init_eohci, 1034 + .init_xhci = usb_init_xhci, 1035 + .uninit_common = usb_uninit_common, 1036 + .uninit_eohci = usb_uninit_eohci, 1037 + .uninit_xhci = usb_uninit_xhci, 1038 + .get_dual_select = usb_get_dual_select, 1039 + .set_dual_select = usb_set_dual_select, 1040 + .wake_enable = usb_wake_enable, 1041 + }; 1042 + 1043 + void brcm_usb_dvr_init_7445(struct brcm_usb_init_params *params) 992 1044 { 993 1045 int fam; 994 1046 995 - fam = brcmusb_get_family_type(params); 1047 + pr_debug("%s\n", __func__); 1048 + 1049 + fam = get_family_type(params); 996 1050 params->selected_family = fam; 997 1051 params->usb_reg_bits_map = 998 1052 &usb_reg_bits_map_table[fam][0]; 999 1053 params->family_name = family_names[fam]; 1054 + params->ops = &bcm7445_ops; 1000 1055 }
+126 -12
drivers/phy/broadcom/phy-brcm-usb-init.h
··· 13 13 14 14 struct brcm_usb_init_params; 15 15 16 + #define USB_CTRL_REG(base, reg) ((void __iomem *)base + USB_CTRL_##reg) 17 + #define USB_XHCI_EC_REG(base, reg) ((void __iomem *)base + USB_XHCI_EC_##reg) 18 + #define USB_CTRL_MASK(reg, field) \ 19 + USB_CTRL_##reg##_##field##_MASK 20 + #define USB_CTRL_SET(base, reg, field) \ 21 + brcm_usb_ctrl_set(USB_CTRL_REG(base, reg), \ 22 + USB_CTRL_##reg##_##field##_MASK) 23 + #define USB_CTRL_UNSET(base, reg, field) \ 24 + brcm_usb_ctrl_unset(USB_CTRL_REG(base, reg), \ 25 + USB_CTRL_##reg##_##field##_MASK) 26 + 27 + struct brcm_usb_init_params; 28 + 29 + struct brcm_usb_init_ops { 30 + void (*init_ipp)(struct brcm_usb_init_params *params); 31 + void (*init_common)(struct brcm_usb_init_params *params); 32 + void (*init_eohci)(struct brcm_usb_init_params *params); 33 + void (*init_xhci)(struct brcm_usb_init_params *params); 34 + void (*uninit_common)(struct brcm_usb_init_params *params); 35 + void (*uninit_eohci)(struct brcm_usb_init_params *params); 36 + void (*uninit_xhci)(struct brcm_usb_init_params *params); 37 + int (*get_dual_select)(struct brcm_usb_init_params *params); 38 + void (*set_dual_select)(struct brcm_usb_init_params *params, int mode); 39 + void (*wake_enable)(struct brcm_usb_init_params *params, 40 + int enable); 41 + }; 42 + 16 43 struct brcm_usb_init_params { 17 44 void __iomem *ctrl_regs; 18 45 void __iomem *xhci_ec_regs; ··· 51 24 int selected_family; 52 25 const char *family_name; 53 26 const u32 *usb_reg_bits_map; 27 + const struct brcm_usb_init_ops *ops; 54 28 }; 55 29 56 - void brcm_usb_set_family_map(struct brcm_usb_init_params *params); 57 - int brcm_usb_init_get_dual_select(struct brcm_usb_init_params *params); 58 - void brcm_usb_init_set_dual_select(struct brcm_usb_init_params *params, 59 - int mode); 30 + void brcm_usb_dvr_init_7445(struct brcm_usb_init_params *params); 60 31 61 - void brcm_usb_init_ipp(struct brcm_usb_init_params *ini); 62 - void brcm_usb_init_common(struct brcm_usb_init_params *ini); 63 - void brcm_usb_init_eohci(struct brcm_usb_init_params *ini); 64 - void brcm_usb_init_xhci(struct brcm_usb_init_params *ini); 65 - void brcm_usb_uninit_common(struct brcm_usb_init_params *ini); 66 - void brcm_usb_uninit_eohci(struct brcm_usb_init_params *ini); 67 - void brcm_usb_uninit_xhci(struct brcm_usb_init_params *ini); 68 - void brcm_usb_wake_enable(struct brcm_usb_init_params *params, int enable); 32 + static inline u32 brcm_usb_readl(void __iomem *addr) 33 + { 34 + /* 35 + * MIPS endianness is configured by boot strap, which also reverses all 36 + * bus endianness (i.e., big-endian CPU + big endian bus ==> native 37 + * endian I/O). 38 + * 39 + * Other architectures (e.g., ARM) either do not support big endian, or 40 + * else leave I/O in little endian mode. 41 + */ 42 + if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(__BIG_ENDIAN)) 43 + return __raw_readl(addr); 44 + else 45 + return readl_relaxed(addr); 46 + } 47 + 48 + static inline void brcm_usb_writel(u32 val, void __iomem *addr) 49 + { 50 + /* See brcmnand_readl() comments */ 51 + if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(__BIG_ENDIAN)) 52 + __raw_writel(val, addr); 53 + else 54 + writel_relaxed(val, addr); 55 + } 56 + 57 + static inline void brcm_usb_ctrl_unset(void __iomem *reg, u32 mask) 58 + { 59 + brcm_usb_writel(brcm_usb_readl(reg) & ~(mask), reg); 60 + }; 61 + 62 + static inline void brcm_usb_ctrl_set(void __iomem *reg, u32 mask) 63 + { 64 + brcm_usb_writel(brcm_usb_readl(reg) | (mask), reg); 65 + }; 66 + 67 + static inline void brcm_usb_init_ipp(struct brcm_usb_init_params *ini) 68 + { 69 + if (ini->ops->init_ipp) 70 + ini->ops->init_ipp(ini); 71 + } 72 + 73 + static inline void brcm_usb_init_common(struct brcm_usb_init_params *ini) 74 + { 75 + if (ini->ops->init_common) 76 + ini->ops->init_common(ini); 77 + } 78 + 79 + static inline void brcm_usb_init_eohci(struct brcm_usb_init_params *ini) 80 + { 81 + if (ini->ops->init_eohci) 82 + ini->ops->init_eohci(ini); 83 + } 84 + 85 + static inline void brcm_usb_init_xhci(struct brcm_usb_init_params *ini) 86 + { 87 + if (ini->ops->init_xhci) 88 + ini->ops->init_xhci(ini); 89 + } 90 + 91 + static inline void brcm_usb_uninit_common(struct brcm_usb_init_params *ini) 92 + { 93 + if (ini->ops->uninit_common) 94 + ini->ops->uninit_common(ini); 95 + } 96 + 97 + static inline void brcm_usb_uninit_eohci(struct brcm_usb_init_params *ini) 98 + { 99 + if (ini->ops->uninit_eohci) 100 + ini->ops->uninit_eohci(ini); 101 + } 102 + 103 + static inline void brcm_usb_uninit_xhci(struct brcm_usb_init_params *ini) 104 + { 105 + if (ini->ops->uninit_xhci) 106 + ini->ops->uninit_xhci(ini); 107 + } 108 + 109 + static inline void brcm_usb_wake_enable(struct brcm_usb_init_params *ini, 110 + int enable) 111 + { 112 + if (ini->ops->wake_enable) 113 + ini->ops->wake_enable(ini, enable); 114 + } 115 + 116 + static inline int brcm_usb_get_dual_select(struct brcm_usb_init_params *ini) 117 + { 118 + if (ini->ops->get_dual_select) 119 + return ini->ops->get_dual_select(ini); 120 + return 0; 121 + } 122 + 123 + static inline void brcm_usb_set_dual_select(struct brcm_usb_init_params *ini, 124 + int mode) 125 + { 126 + if (ini->ops->set_dual_select) 127 + ini->ops->set_dual_select(ini, mode); 128 + } 69 129 70 130 #endif /* _USB_BRCM_COMMON_INIT_H */
+3 -3
drivers/phy/broadcom/phy-brcm-usb.c
··· 207 207 res = name_to_value(&brcm_dual_mode_to_name[0], 208 208 ARRAY_SIZE(brcm_dual_mode_to_name), buf, &value); 209 209 if (!res) { 210 - brcm_usb_init_set_dual_select(&priv->ini, value); 210 + brcm_usb_set_dual_select(&priv->ini, value); 211 211 res = len; 212 212 } 213 213 mutex_unlock(&sysfs_lock); ··· 222 222 int value; 223 223 224 224 mutex_lock(&sysfs_lock); 225 - value = brcm_usb_init_get_dual_select(&priv->ini); 225 + value = brcm_usb_get_dual_select(&priv->ini); 226 226 mutex_unlock(&sysfs_lock); 227 227 return sprintf(buf, "%s\n", 228 228 value_to_name(&brcm_dual_mode_to_name[0], ··· 331 331 332 332 priv->ini.family_id = brcmstb_get_family_id(); 333 333 priv->ini.product_id = brcmstb_get_product_id(); 334 - brcm_usb_set_family_map(&priv->ini); 334 + brcm_usb_dvr_init_7445(&priv->ini); 335 335 dev_dbg(dev, "Best mapping table is for %s\n", 336 336 priv->ini.family_name); 337 337 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);