Rev 3192 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3192 | Rev 5078 | ||
---|---|---|---|
Line 62... | Line 62... | ||
62 | /* on hw with routers, select right port */ |
62 | /* on hw with routers, select right port */ |
63 | if (radeon_connector->router.ddc_valid) |
63 | if (radeon_connector->router.ddc_valid) |
64 | radeon_router_select_ddc_port(radeon_connector); |
64 | radeon_router_select_ddc_port(radeon_connector); |
Line 65... | Line 65... | ||
65 | 65 | ||
66 | if (use_aux) { |
- | |
67 | struct radeon_connector_atom_dig *dig = radeon_connector->con_priv; |
66 | if (use_aux) { |
68 | ret = i2c_transfer(&dig->dp_i2c_bus->adapter, msgs, 2); |
67 | ret = i2c_transfer(&radeon_connector->ddc_bus->aux.ddc, msgs, 2); |
69 | } else { |
68 | } else { |
70 | ret = i2c_transfer(&radeon_connector->ddc_bus->adapter, msgs, 2); |
69 | ret = i2c_transfer(&radeon_connector->ddc_bus->adapter, msgs, 2); |
Line 71... | Line 70... | ||
71 | } |
70 | } |
Line 93... | Line 92... | ||
93 | struct radeon_i2c_chan *i2c = i2c_get_adapdata(i2c_adap); |
92 | struct radeon_i2c_chan *i2c = i2c_get_adapdata(i2c_adap); |
94 | struct radeon_device *rdev = i2c->dev->dev_private; |
93 | struct radeon_device *rdev = i2c->dev->dev_private; |
95 | struct radeon_i2c_bus_rec *rec = &i2c->rec; |
94 | struct radeon_i2c_bus_rec *rec = &i2c->rec; |
96 | uint32_t temp; |
95 | uint32_t temp; |
Line -... | Line 96... | ||
- | 96 | ||
- | 97 | mutex_lock(&i2c->mutex); |
|
97 | 98 | ||
98 | /* RV410 appears to have a bug where the hw i2c in reset |
99 | /* RV410 appears to have a bug where the hw i2c in reset |
99 | * holds the i2c port in a bad state - switch hw i2c away before |
100 | * holds the i2c port in a bad state - switch hw i2c away before |
100 | * doing DDC - do this for all r200s/r300s/r400s for safety sake |
101 | * doing DDC - do this for all r200s/r300s/r400s for safety sake |
101 | */ |
102 | */ |
Line 169... | Line 170... | ||
169 | temp = RREG32(rec->mask_clk_reg); |
170 | temp = RREG32(rec->mask_clk_reg); |
Line 170... | Line 171... | ||
170 | 171 | ||
171 | temp = RREG32(rec->mask_data_reg) & ~rec->mask_data_mask; |
172 | temp = RREG32(rec->mask_data_reg) & ~rec->mask_data_mask; |
172 | WREG32(rec->mask_data_reg, temp); |
173 | WREG32(rec->mask_data_reg, temp); |
- | 174 | temp = RREG32(rec->mask_data_reg); |
|
- | 175 | ||
173 | temp = RREG32(rec->mask_data_reg); |
176 | mutex_unlock(&i2c->mutex); |
Line 174... | Line 177... | ||
174 | } |
177 | } |
175 | 178 | ||
176 | static int get_clock(void *i2c_priv) |
179 | static int get_clock(void *i2c_priv) |
Line 812... | Line 815... | ||
812 | struct radeon_i2c_chan *i2c = i2c_get_adapdata(i2c_adap); |
815 | struct radeon_i2c_chan *i2c = i2c_get_adapdata(i2c_adap); |
813 | struct radeon_device *rdev = i2c->dev->dev_private; |
816 | struct radeon_device *rdev = i2c->dev->dev_private; |
814 | struct radeon_i2c_bus_rec *rec = &i2c->rec; |
817 | struct radeon_i2c_bus_rec *rec = &i2c->rec; |
815 | int ret = 0; |
818 | int ret = 0; |
Line -... | Line 819... | ||
- | 819 | ||
- | 820 | mutex_lock(&i2c->mutex); |
|
816 | 821 | ||
817 | switch (rdev->family) { |
822 | switch (rdev->family) { |
818 | case CHIP_R100: |
823 | case CHIP_R100: |
819 | case CHIP_RV100: |
824 | case CHIP_RV100: |
820 | case CHIP_RS100: |
825 | case CHIP_RS100: |
Line 878... | Line 883... | ||
878 | DRM_ERROR("i2c: unhandled radeon chip\n"); |
883 | DRM_ERROR("i2c: unhandled radeon chip\n"); |
879 | ret = -EIO; |
884 | ret = -EIO; |
880 | break; |
885 | break; |
881 | } |
886 | } |
Line -... | Line 887... | ||
- | 887 | ||
- | 888 | mutex_unlock(&i2c->mutex); |
|
882 | 889 | ||
883 | return ret; |
890 | return ret; |
Line 884... | Line 891... | ||
884 | } |
891 | } |
885 | 892 | ||
Line 917... | Line 924... | ||
917 | i2c->rec = *rec; |
924 | i2c->rec = *rec; |
918 | i2c->adapter.owner = THIS_MODULE; |
925 | i2c->adapter.owner = THIS_MODULE; |
919 | i2c->adapter.class = I2C_CLASS_DDC; |
926 | i2c->adapter.class = I2C_CLASS_DDC; |
920 | i2c->dev = dev; |
927 | i2c->dev = dev; |
921 | i2c_set_adapdata(&i2c->adapter, i2c); |
928 | i2c_set_adapdata(&i2c->adapter, i2c); |
- | 929 | mutex_init(&i2c->mutex); |
|
922 | if (rec->mm_i2c || |
930 | if (rec->mm_i2c || |
923 | (rec->hw_capable && |
931 | (rec->hw_capable && |
924 | radeon_hw_i2c && |
932 | radeon_hw_i2c && |
925 | ((rdev->family <= CHIP_RS480) || |
933 | ((rdev->family <= CHIP_RS480) || |
926 | ((rdev->family >= CHIP_RV515) && (rdev->family <= CHIP_R580))))) { |
934 | ((rdev->family >= CHIP_RV515) && (rdev->family <= CHIP_R580))))) { |
Line 947... | Line 955... | ||
947 | } |
955 | } |
948 | } else { |
956 | } else { |
949 | /* set the radeon bit adapter */ |
957 | /* set the radeon bit adapter */ |
950 | snprintf(i2c->adapter.name, sizeof(i2c->adapter.name), |
958 | snprintf(i2c->adapter.name, sizeof(i2c->adapter.name), |
951 | "Radeon i2c bit bus %s", name); |
959 | "Radeon i2c bit bus %s", name); |
952 | i2c->adapter.algo_data = &i2c->algo.bit; |
960 | i2c->adapter.algo_data = &i2c->bit; |
953 | i2c->algo.bit.pre_xfer = pre_xfer; |
961 | i2c->bit.pre_xfer = pre_xfer; |
954 | i2c->algo.bit.post_xfer = post_xfer; |
962 | i2c->bit.post_xfer = post_xfer; |
955 | i2c->algo.bit.setsda = set_data; |
963 | i2c->bit.setsda = set_data; |
956 | i2c->algo.bit.setscl = set_clock; |
964 | i2c->bit.setscl = set_clock; |
957 | i2c->algo.bit.getsda = get_data; |
965 | i2c->bit.getsda = get_data; |
958 | i2c->algo.bit.getscl = get_clock; |
966 | i2c->bit.getscl = get_clock; |
959 | i2c->algo.bit.udelay = 10; |
967 | i2c->bit.udelay = 10; |
960 | i2c->algo.bit.timeout = usecs_to_jiffies(2200); /* from VESA */ |
968 | i2c->bit.timeout = usecs_to_jiffies(2200); /* from VESA */ |
961 | i2c->algo.bit.data = i2c; |
969 | i2c->bit.data = i2c; |
962 | ret = i2c_bit_add_bus(&i2c->adapter); |
970 | ret = i2c_bit_add_bus(&i2c->adapter); |
963 | if (ret) { |
971 | if (ret) { |
964 | DRM_ERROR("Failed to register bit i2c %s\n", name); |
972 | DRM_ERROR("Failed to register bit i2c %s\n", name); |
965 | goto out_free; |
973 | goto out_free; |
966 | } |
974 | } |
Line 971... | Line 979... | ||
971 | kfree(i2c); |
979 | kfree(i2c); |
972 | return NULL; |
980 | return NULL; |
Line 973... | Line 981... | ||
973 | 981 | ||
Line 974... | Line -... | ||
974 | } |
- | |
975 | - | ||
976 | struct radeon_i2c_chan *radeon_i2c_create_dp(struct drm_device *dev, |
- | |
977 | struct radeon_i2c_bus_rec *rec, |
- | |
978 | const char *name) |
- | |
979 | { |
- | |
980 | struct radeon_i2c_chan *i2c; |
- | |
981 | int ret; |
- | |
982 | - | ||
983 | i2c = kzalloc(sizeof(struct radeon_i2c_chan), GFP_KERNEL); |
- | |
984 | if (i2c == NULL) |
- | |
985 | return NULL; |
- | |
986 | - | ||
987 | i2c->rec = *rec; |
- | |
988 | i2c->adapter.owner = THIS_MODULE; |
- | |
989 | i2c->adapter.class = I2C_CLASS_DDC; |
- | |
990 | i2c->dev = dev; |
- | |
991 | snprintf(i2c->adapter.name, sizeof(i2c->adapter.name), |
- | |
992 | "Radeon aux bus %s", name); |
- | |
993 | i2c_set_adapdata(&i2c->adapter, i2c); |
- | |
994 | i2c->adapter.algo_data = &i2c->algo.dp; |
- | |
995 | i2c->algo.dp.aux_ch = radeon_dp_i2c_aux_ch; |
- | |
996 | i2c->algo.dp.address = 0; |
- | |
997 | ret = i2c_dp_aux_add_bus(&i2c->adapter); |
- | |
998 | if (ret) { |
- | |
999 | DRM_INFO("Failed to register i2c %s\n", name); |
- | |
1000 | goto out_free; |
- | |
1001 | } |
- | |
1002 | - | ||
1003 | return i2c; |
- | |
1004 | out_free: |
- | |
1005 | kfree(i2c); |
- | |
1006 | return NULL; |
- | |
1007 | - | ||
1008 | } |
982 | } |
1009 | 983 | ||
1010 | void radeon_i2c_destroy(struct radeon_i2c_chan *i2c) |
984 | void radeon_i2c_destroy(struct radeon_i2c_chan *i2c) |
1011 | { |
985 | { |
1012 | if (!i2c) |
986 | if (!i2c) |
- | 987 | return; |
|
- | 988 | i2c_del_adapter(&i2c->adapter); |
|
1013 | return; |
989 | if (i2c->has_aux) |
1014 | i2c_del_adapter(&i2c->adapter); |
990 | drm_dp_aux_unregister(&i2c->aux); |
Line 1015... | Line 991... | ||
1015 | kfree(i2c); |
991 | kfree(i2c); |
1016 | } |
992 | } |
1017 | 993 | ||
- | 994 | /* Add the default buses */ |
|
- | 995 | void radeon_i2c_init(struct radeon_device *rdev) |
|
- | 996 | { |
|
1018 | /* Add the default buses */ |
997 | if (radeon_hw_i2c) |
1019 | void radeon_i2c_init(struct radeon_device *rdev) |
998 | DRM_INFO("hw_i2c forced on, you may experience display detection problems!\n"); |
1020 | { |
999 | |
1021 | if (rdev->is_atom_bios) |
1000 | if (rdev->is_atom_bios) |
1022 | radeon_atombios_i2c_init(rdev); |
1001 | radeon_atombios_i2c_init(rdev); |