bgmac.c (622a521fa46b37d3a01f2b2d59df9299dbdba16f) | bgmac.c (6df4aff972f0294f210559ce898a8a958e23b2c6) |
---|---|
1/* 2 * Driver for (BCM4706)? GBit MAC core on BCMA bus. 3 * 4 * Copyright (C) 2012 Rafał Miłecki <zajec5@gmail.com> 5 * 6 * Licensed under the GNU/GPL. See COPYING for details. 7 */ 8 --- 834 unchanged lines hidden (view full) --- 843 set |= BGMAC_CMDCFG_ES_10; 844 break; 845 case SPEED_100: 846 set |= BGMAC_CMDCFG_ES_100; 847 break; 848 case SPEED_1000: 849 set |= BGMAC_CMDCFG_ES_1000; 850 break; | 1/* 2 * Driver for (BCM4706)? GBit MAC core on BCMA bus. 3 * 4 * Copyright (C) 2012 Rafał Miłecki <zajec5@gmail.com> 5 * 6 * Licensed under the GNU/GPL. See COPYING for details. 7 */ 8 --- 834 unchanged lines hidden (view full) --- 843 set |= BGMAC_CMDCFG_ES_10; 844 break; 845 case SPEED_100: 846 set |= BGMAC_CMDCFG_ES_100; 847 break; 848 case SPEED_1000: 849 set |= BGMAC_CMDCFG_ES_1000; 850 break; |
851 case SPEED_2500: 852 set |= BGMAC_CMDCFG_ES_2500; 853 break; |
|
851 default: 852 bgmac_err(bgmac, "Unsupported speed: %d\n", bgmac->mac_speed); 853 } 854 855 if (bgmac->mac_duplex == DUPLEX_HALF) 856 set |= BGMAC_CMDCFG_HD; 857 858 bgmac_cmdcfg_maskset(bgmac, mask, set, true); 859} 860 861static void bgmac_miiconfig(struct bgmac *bgmac) 862{ | 854 default: 855 bgmac_err(bgmac, "Unsupported speed: %d\n", bgmac->mac_speed); 856 } 857 858 if (bgmac->mac_duplex == DUPLEX_HALF) 859 set |= BGMAC_CMDCFG_HD; 860 861 bgmac_cmdcfg_maskset(bgmac, mask, set, true); 862} 863 864static void bgmac_miiconfig(struct bgmac *bgmac) 865{ |
863 u8 imode = (bgmac_read(bgmac, BGMAC_DEV_STATUS) & BGMAC_DS_MM_MASK) >> 864 BGMAC_DS_MM_SHIFT; 865 if (imode == 0 || imode == 1) { 866 bgmac->mac_speed = SPEED_100; | 866 struct bcma_device *core = bgmac->core; 867 struct bcma_chipinfo *ci = &core->bus->chipinfo; 868 u8 imode; 869 870 if (ci->id == BCMA_CHIP_ID_BCM4707 || 871 ci->id == BCMA_CHIP_ID_BCM53018) { 872 bcma_awrite32(core, BCMA_IOCTL, 873 bcma_aread32(core, BCMA_IOCTL) | 0x40 | 874 BGMAC_BCMA_IOCTL_SW_CLKEN); 875 bgmac->mac_speed = SPEED_2500; |
867 bgmac->mac_duplex = DUPLEX_FULL; 868 bgmac_mac_speed(bgmac); | 876 bgmac->mac_duplex = DUPLEX_FULL; 877 bgmac_mac_speed(bgmac); |
878 } else { 879 imode = (bgmac_read(bgmac, BGMAC_DEV_STATUS) & 880 BGMAC_DS_MM_MASK) >> BGMAC_DS_MM_SHIFT; 881 if (imode == 0 || imode == 1) { 882 bgmac->mac_speed = SPEED_100; 883 bgmac->mac_duplex = DUPLEX_FULL; 884 bgmac_mac_speed(bgmac); 885 } |
|
869 } 870} 871 872/* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipreset */ 873static void bgmac_chip_reset(struct bgmac *bgmac) 874{ 875 struct bcma_device *core = bgmac->core; 876 struct bcma_bus *bus = core->bus; 877 struct bcma_chipinfo *ci = &bus->chipinfo; | 886 } 887} 888 889/* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipreset */ 890static void bgmac_chip_reset(struct bgmac *bgmac) 891{ 892 struct bcma_device *core = bgmac->core; 893 struct bcma_bus *bus = core->bus; 894 struct bcma_chipinfo *ci = &bus->chipinfo; |
878 u32 flags = 0; | 895 u32 flags; |
879 u32 iost; 880 int i; 881 882 if (bcma_core_is_enabled(core)) { 883 if (!bgmac->stats_grabbed) { 884 /* bgmac_chip_stats_update(bgmac); */ 885 bgmac->stats_grabbed = true; 886 } --- 11 unchanged lines hidden (view full) --- 898 } 899 900 iost = bcma_aread32(core, BCMA_IOST); 901 if ((ci->id == BCMA_CHIP_ID_BCM5357 && ci->pkg == BCMA_PKG_ID_BCM47186) || 902 (ci->id == BCMA_CHIP_ID_BCM4749 && ci->pkg == 10) || 903 (ci->id == BCMA_CHIP_ID_BCM53572 && ci->pkg == BCMA_PKG_ID_BCM47188)) 904 iost &= ~BGMAC_BCMA_IOST_ATTACHED; 905 | 896 u32 iost; 897 int i; 898 899 if (bcma_core_is_enabled(core)) { 900 if (!bgmac->stats_grabbed) { 901 /* bgmac_chip_stats_update(bgmac); */ 902 bgmac->stats_grabbed = true; 903 } --- 11 unchanged lines hidden (view full) --- 915 } 916 917 iost = bcma_aread32(core, BCMA_IOST); 918 if ((ci->id == BCMA_CHIP_ID_BCM5357 && ci->pkg == BCMA_PKG_ID_BCM47186) || 919 (ci->id == BCMA_CHIP_ID_BCM4749 && ci->pkg == 10) || 920 (ci->id == BCMA_CHIP_ID_BCM53572 && ci->pkg == BCMA_PKG_ID_BCM47188)) 921 iost &= ~BGMAC_BCMA_IOST_ATTACHED; 922 |
906 if (iost & BGMAC_BCMA_IOST_ATTACHED) { 907 flags = BGMAC_BCMA_IOCTL_SW_CLKEN; 908 if (!bgmac->has_robosw) 909 flags |= BGMAC_BCMA_IOCTL_SW_RESET; | 923 /* 3GMAC: for BCM4707, only do core reset at bgmac_probe() */ 924 if (ci->id != BCMA_CHIP_ID_BCM4707) { 925 flags = 0; 926 if (iost & BGMAC_BCMA_IOST_ATTACHED) { 927 flags = BGMAC_BCMA_IOCTL_SW_CLKEN; 928 if (!bgmac->has_robosw) 929 flags |= BGMAC_BCMA_IOCTL_SW_RESET; 930 } 931 bcma_core_enable(core, flags); |
910 } 911 | 932 } 933 |
912 bcma_core_enable(core, flags); 913 914 if (core->id.rev > 2) { | 934 /* Request Misc PLL for corerev > 2 */ 935 if (core->id.rev > 2 && 936 ci->id != BCMA_CHIP_ID_BCM4707 && 937 ci->id != BCMA_CHIP_ID_BCM53018) { |
915 bgmac_set(bgmac, BCMA_CLKCTLST, 916 BGMAC_BCMA_CLKCTLST_MISC_PLL_REQ); 917 bgmac_wait_value(bgmac->core, BCMA_CLKCTLST, 918 BGMAC_BCMA_CLKCTLST_MISC_PLL_ST, 919 BGMAC_BCMA_CLKCTLST_MISC_PLL_ST, 920 1000); 921 } 922 --- 121 unchanged lines hidden (view full) --- 1044 ci->id == BCMA_CHIP_ID_BCM4749 || 1045 ci->id == BCMA_CHIP_ID_BCM53572) 1046 fl_ctl = 0x2300e1; 1047 bgmac_write(bgmac, BGMAC_FLOW_CTL_THRESH, fl_ctl); 1048 bgmac_write(bgmac, BGMAC_PAUSE_CTL, 0x27fff); 1049 break; 1050 } 1051 | 938 bgmac_set(bgmac, BCMA_CLKCTLST, 939 BGMAC_BCMA_CLKCTLST_MISC_PLL_REQ); 940 bgmac_wait_value(bgmac->core, BCMA_CLKCTLST, 941 BGMAC_BCMA_CLKCTLST_MISC_PLL_ST, 942 BGMAC_BCMA_CLKCTLST_MISC_PLL_ST, 943 1000); 944 } 945 --- 121 unchanged lines hidden (view full) --- 1067 ci->id == BCMA_CHIP_ID_BCM4749 || 1068 ci->id == BCMA_CHIP_ID_BCM53572) 1069 fl_ctl = 0x2300e1; 1070 bgmac_write(bgmac, BGMAC_FLOW_CTL_THRESH, fl_ctl); 1071 bgmac_write(bgmac, BGMAC_PAUSE_CTL, 0x27fff); 1072 break; 1073 } 1074 |
1052 rxq_ctl = bgmac_read(bgmac, BGMAC_RXQ_CTL); 1053 rxq_ctl &= ~BGMAC_RXQ_CTL_MDP_MASK; 1054 bp_clk = bcma_pmu_get_bus_clock(&bgmac->core->bus->drv_cc) / 1000000; 1055 mdp = (bp_clk * 128 / 1000) - 3; 1056 rxq_ctl |= (mdp << BGMAC_RXQ_CTL_MDP_SHIFT); 1057 bgmac_write(bgmac, BGMAC_RXQ_CTL, rxq_ctl); | 1075 if (ci->id != BCMA_CHIP_ID_BCM4707 && 1076 ci->id != BCMA_CHIP_ID_BCM53018) { 1077 rxq_ctl = bgmac_read(bgmac, BGMAC_RXQ_CTL); 1078 rxq_ctl &= ~BGMAC_RXQ_CTL_MDP_MASK; 1079 bp_clk = bcma_pmu_get_bus_clock(&bgmac->core->bus->drv_cc) / 1080 1000000; 1081 mdp = (bp_clk * 128 / 1000) - 3; 1082 rxq_ctl |= (mdp << BGMAC_RXQ_CTL_MDP_SHIFT); 1083 bgmac_write(bgmac, BGMAC_RXQ_CTL, rxq_ctl); 1084 } |
1058} 1059 1060/* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipinit */ 1061static void bgmac_chip_init(struct bgmac *bgmac, bool full_init) 1062{ 1063 struct bgmac_dma_ring *ring; 1064 int i; 1065 --- 498 unchanged lines hidden --- | 1085} 1086 1087/* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipinit */ 1088static void bgmac_chip_init(struct bgmac *bgmac, bool full_init) 1089{ 1090 struct bgmac_dma_ring *ring; 1091 int i; 1092 --- 498 unchanged lines hidden --- |