Rev 1630 | Rev 1986 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1630 | Rev 1963 | ||
---|---|---|---|
Line 50... | Line 50... | ||
50 | .len = 1, |
50 | .len = 1, |
51 | .buf = buf, |
51 | .buf = buf, |
52 | } |
52 | } |
53 | }; |
53 | }; |
Line -... | Line 54... | ||
- | 54 | ||
- | 55 | /* on hw with routers, select right port */ |
|
- | 56 | if (radeon_connector->router.ddc_valid) |
|
- | 57 | radeon_router_select_ddc_port(radeon_connector); |
|
54 | 58 | ||
55 | ret = i2c_transfer(&radeon_connector->ddc_bus->adapter, msgs, 2); |
59 | ret = i2c_transfer(&radeon_connector->ddc_bus->adapter, msgs, 2); |
56 | if (ret == 2) |
60 | if (ret == 2) |
Line 57... | Line 61... | ||
57 | return true; |
61 | return true; |
58 | 62 | ||
Line -... | Line 63... | ||
- | 63 | return false; |
|
Line 59... | Line 64... | ||
59 | return false; |
64 | } |
60 | } |
65 | |
61 | 66 | /* bit banging i2c */ |
|
62 | 67 | ||
Line 92... | Line 97... | ||
92 | } |
97 | } |
93 | mutex_unlock(&rdev->dc_hw_i2c_mutex); |
98 | mutex_unlock(&rdev->dc_hw_i2c_mutex); |
94 | } |
99 | } |
95 | } |
100 | } |
Line -... | Line 101... | ||
- | 101 | ||
- | 102 | /* switch the pads to ddc mode */ |
|
- | 103 | if (ASIC_IS_DCE3(rdev) && rec->hw_capable) { |
|
- | 104 | temp = RREG32(rec->mask_clk_reg); |
|
- | 105 | temp &= ~(1 << 16); |
|
- | 106 | WREG32(rec->mask_clk_reg, temp); |
|
- | 107 | } |
|
96 | 108 | ||
97 | /* clear the output pin values */ |
109 | /* clear the output pin values */ |
98 | temp = RREG32(rec->a_clk_reg) & ~rec->a_clk_mask; |
110 | temp = RREG32(rec->a_clk_reg) & ~rec->a_clk_mask; |
Line 99... | Line 111... | ||
99 | WREG32(rec->a_clk_reg, temp); |
111 | WREG32(rec->a_clk_reg, temp); |
Line 179... | Line 191... | ||
179 | val = RREG32(rec->en_data_reg) & ~rec->en_data_mask; |
191 | val = RREG32(rec->en_data_reg) & ~rec->en_data_mask; |
180 | val |= data ? 0 : rec->en_data_mask; |
192 | val |= data ? 0 : rec->en_data_mask; |
181 | WREG32(rec->en_data_reg, val); |
193 | WREG32(rec->en_data_reg, val); |
182 | } |
194 | } |
Line -... | Line 195... | ||
- | 195 | ||
- | 196 | static int pre_xfer(struct i2c_adapter *i2c_adap) |
|
- | 197 | { |
|
- | 198 | struct radeon_i2c_chan *i2c = i2c_get_adapdata(i2c_adap); |
|
- | 199 | ||
- | 200 | radeon_i2c_do_lock(i2c, 1); |
|
- | 201 | ||
- | 202 | return 0; |
|
- | 203 | } |
|
- | 204 | ||
- | 205 | static void post_xfer(struct i2c_adapter *i2c_adap) |
|
- | 206 | { |
|
- | 207 | struct radeon_i2c_chan *i2c = i2c_get_adapdata(i2c_adap); |
|
- | 208 | ||
- | 209 | radeon_i2c_do_lock(i2c, 0); |
|
- | 210 | } |
|
- | 211 | ||
- | 212 | /* hw i2c */ |
|
183 | 213 | ||
184 | static u32 radeon_get_i2c_prescale(struct radeon_device *rdev) |
214 | static u32 radeon_get_i2c_prescale(struct radeon_device *rdev) |
185 | { |
- | |
186 | struct radeon_pll *spll = &rdev->clock.spll; |
215 | { |
187 | u32 sclk = radeon_get_engine_clock(rdev); |
216 | u32 sclk = rdev->pm.current_sclk; |
188 | u32 prescale = 0; |
217 | u32 prescale = 0; |
189 | u32 n, m; |
218 | u32 nm; |
190 | u8 loop; |
219 | u8 n, m, loop; |
Line 191... | Line 220... | ||
191 | int i2c_clock; |
220 | int i2c_clock; |
192 | 221 | ||
193 | switch (rdev->family) { |
222 | switch (rdev->family) { |
Line 201... | Line 230... | ||
201 | case CHIP_RS300: |
230 | case CHIP_RS300: |
202 | case CHIP_RV280: |
231 | case CHIP_RV280: |
203 | case CHIP_R300: |
232 | case CHIP_R300: |
204 | case CHIP_R350: |
233 | case CHIP_R350: |
205 | case CHIP_RV350: |
234 | case CHIP_RV350: |
- | 235 | i2c_clock = 60; |
|
206 | n = (spll->reference_freq) / (4 * 6); |
236 | nm = (sclk * 10) / (i2c_clock * 4); |
207 | for (loop = 1; loop < 255; loop++) { |
237 | for (loop = 1; loop < 255; loop++) { |
208 | if ((loop * (loop - 1)) > n) |
238 | if ((nm / loop) < loop) |
209 | break; |
239 | break; |
210 | } |
240 | } |
- | 241 | n = loop - 1; |
|
211 | m = loop - 1; |
242 | m = loop - 2; |
212 | prescale = m | (loop << 8); |
243 | prescale = m | (n << 8); |
213 | break; |
244 | break; |
214 | case CHIP_RV380: |
245 | case CHIP_RV380: |
215 | case CHIP_RS400: |
246 | case CHIP_RS400: |
216 | case CHIP_RS480: |
247 | case CHIP_RS480: |
217 | case CHIP_R420: |
248 | case CHIP_R420: |
218 | case CHIP_R423: |
249 | case CHIP_R423: |
219 | case CHIP_RV410: |
250 | case CHIP_RV410: |
220 | sclk = radeon_get_engine_clock(rdev); |
- | |
221 | prescale = (((sclk * 10)/(4 * 128 * 100) + 1) << 8) + 128; |
251 | prescale = (((sclk * 10)/(4 * 128 * 100) + 1) << 8) + 128; |
222 | break; |
252 | break; |
223 | case CHIP_RS600: |
253 | case CHIP_RS600: |
224 | case CHIP_RS690: |
254 | case CHIP_RS690: |
225 | case CHIP_RS740: |
255 | case CHIP_RS740: |
Line 230... | Line 260... | ||
230 | case CHIP_RV530: |
260 | case CHIP_RV530: |
231 | case CHIP_RV560: |
261 | case CHIP_RV560: |
232 | case CHIP_RV570: |
262 | case CHIP_RV570: |
233 | case CHIP_R580: |
263 | case CHIP_R580: |
234 | i2c_clock = 50; |
264 | i2c_clock = 50; |
235 | sclk = radeon_get_engine_clock(rdev); |
- | |
236 | if (rdev->family == CHIP_R520) |
265 | if (rdev->family == CHIP_R520) |
237 | prescale = (127 << 8) + ((sclk * 10) / (4 * 127 * i2c_clock)); |
266 | prescale = (127 << 8) + ((sclk * 10) / (4 * 127 * i2c_clock)); |
238 | else |
267 | else |
239 | prescale = (((sclk * 10)/(4 * 128 * 100) + 1) << 8) + 128; |
268 | prescale = (((sclk * 10)/(4 * 128 * 100) + 1) << 8) + 128; |
240 | break; |
269 | break; |
Line 289... | Line 318... | ||
289 | mutex_lock(&rdev->pm.mutex); |
318 | mutex_lock(&rdev->pm.mutex); |
Line 290... | Line 319... | ||
290 | 319 | ||
Line 291... | Line 320... | ||
291 | prescale = radeon_get_i2c_prescale(rdev); |
320 | prescale = radeon_get_i2c_prescale(rdev); |
- | 321 | ||
292 | 322 | reg = ((prescale << RADEON_I2C_PRESCALE_SHIFT) | |
|
293 | reg = ((prescale << RADEON_I2C_PRESCALE_SHIFT) | |
323 | RADEON_I2C_DRIVE_EN | |
294 | RADEON_I2C_START | |
324 | RADEON_I2C_START | |
Line 295... | Line 325... | ||
295 | RADEON_I2C_STOP | |
325 | RADEON_I2C_STOP | |
Line 755... | Line 785... | ||
755 | mutex_unlock(&rdev->dc_hw_i2c_mutex); |
785 | mutex_unlock(&rdev->dc_hw_i2c_mutex); |
Line 756... | Line 786... | ||
756 | 786 | ||
757 | return ret; |
787 | return ret; |
Line 758... | Line 788... | ||
758 | } |
788 | } |
759 | - | ||
760 | static int radeon_sw_i2c_xfer(struct i2c_adapter *i2c_adap, |
- | |
761 | struct i2c_msg *msgs, int num) |
- | |
762 | { |
- | |
763 | struct radeon_i2c_chan *i2c = i2c_get_adapdata(i2c_adap); |
- | |
764 | int ret; |
- | |
765 | - | ||
766 | radeon_i2c_do_lock(i2c, 1); |
- | |
767 | ret = i2c_transfer(&i2c->algo.radeon.bit_adapter, msgs, num); |
- | |
768 | radeon_i2c_do_lock(i2c, 0); |
- | |
769 | - | ||
770 | return ret; |
- | |
771 | } |
- | |
772 | 789 | ||
773 | static int radeon_i2c_xfer(struct i2c_adapter *i2c_adap, |
790 | static int radeon_hw_i2c_xfer(struct i2c_adapter *i2c_adap, |
774 | struct i2c_msg *msgs, int num) |
791 | struct i2c_msg *msgs, int num) |
775 | { |
792 | { |
776 | struct radeon_i2c_chan *i2c = i2c_get_adapdata(i2c_adap); |
793 | struct radeon_i2c_chan *i2c = i2c_get_adapdata(i2c_adap); |
777 | struct radeon_device *rdev = i2c->dev->dev_private; |
794 | struct radeon_device *rdev = i2c->dev->dev_private; |
- | 795 | struct radeon_i2c_bus_rec *rec = &i2c->rec; |
|
- | 796 | int ret = 0; |
|
Line 778... | Line 797... | ||
778 | struct radeon_i2c_bus_rec *rec = &i2c->rec; |
797 | |
779 | int ret; |
798 | ENTER(); |
780 | 799 | ||
781 | switch (rdev->family) { |
800 | switch (rdev->family) { |
Line 795... | Line 814... | ||
795 | case CHIP_R420: |
814 | case CHIP_R420: |
796 | case CHIP_R423: |
815 | case CHIP_R423: |
797 | case CHIP_RV410: |
816 | case CHIP_RV410: |
798 | case CHIP_RS400: |
817 | case CHIP_RS400: |
799 | case CHIP_RS480: |
818 | case CHIP_RS480: |
800 | if (rec->hw_capable) |
- | |
801 | ret = r100_hw_i2c_xfer(i2c_adap, msgs, num); |
819 | ret = r100_hw_i2c_xfer(i2c_adap, msgs, num); |
802 | else |
- | |
803 | ret = radeon_sw_i2c_xfer(i2c_adap, msgs, num); |
- | |
804 | break; |
820 | break; |
805 | case CHIP_RS600: |
821 | case CHIP_RS600: |
806 | case CHIP_RS690: |
822 | case CHIP_RS690: |
807 | case CHIP_RS740: |
823 | case CHIP_RS740: |
808 | /* XXX fill in hw i2c implementation */ |
824 | /* XXX fill in hw i2c implementation */ |
809 | ret = radeon_sw_i2c_xfer(i2c_adap, msgs, num); |
- | |
810 | break; |
825 | break; |
811 | case CHIP_RV515: |
826 | case CHIP_RV515: |
812 | case CHIP_R520: |
827 | case CHIP_R520: |
813 | case CHIP_RV530: |
828 | case CHIP_RV530: |
814 | case CHIP_RV560: |
829 | case CHIP_RV560: |
815 | case CHIP_RV570: |
830 | case CHIP_RV570: |
816 | case CHIP_R580: |
831 | case CHIP_R580: |
817 | if (rec->hw_capable) { |
- | |
818 | if (rec->mm_i2c) |
832 | if (rec->mm_i2c) |
819 | ret = r100_hw_i2c_xfer(i2c_adap, msgs, num); |
833 | ret = r100_hw_i2c_xfer(i2c_adap, msgs, num); |
820 | else |
834 | else |
821 | ret = r500_hw_i2c_xfer(i2c_adap, msgs, num); |
835 | ret = r500_hw_i2c_xfer(i2c_adap, msgs, num); |
822 | } else |
- | |
823 | ret = radeon_sw_i2c_xfer(i2c_adap, msgs, num); |
- | |
824 | break; |
836 | break; |
825 | case CHIP_R600: |
837 | case CHIP_R600: |
826 | case CHIP_RV610: |
838 | case CHIP_RV610: |
827 | case CHIP_RV630: |
839 | case CHIP_RV630: |
828 | case CHIP_RV670: |
840 | case CHIP_RV670: |
829 | /* XXX fill in hw i2c implementation */ |
841 | /* XXX fill in hw i2c implementation */ |
830 | ret = radeon_sw_i2c_xfer(i2c_adap, msgs, num); |
- | |
831 | break; |
842 | break; |
832 | case CHIP_RV620: |
843 | case CHIP_RV620: |
833 | case CHIP_RV635: |
844 | case CHIP_RV635: |
834 | case CHIP_RS780: |
845 | case CHIP_RS780: |
835 | case CHIP_RS880: |
846 | case CHIP_RS880: |
836 | case CHIP_RV770: |
847 | case CHIP_RV770: |
837 | case CHIP_RV730: |
848 | case CHIP_RV730: |
838 | case CHIP_RV710: |
849 | case CHIP_RV710: |
839 | case CHIP_RV740: |
850 | case CHIP_RV740: |
840 | /* XXX fill in hw i2c implementation */ |
851 | /* XXX fill in hw i2c implementation */ |
841 | ret = radeon_sw_i2c_xfer(i2c_adap, msgs, num); |
- | |
842 | break; |
852 | break; |
843 | case CHIP_CEDAR: |
853 | case CHIP_CEDAR: |
844 | case CHIP_REDWOOD: |
854 | case CHIP_REDWOOD: |
845 | case CHIP_JUNIPER: |
855 | case CHIP_JUNIPER: |
846 | case CHIP_CYPRESS: |
856 | case CHIP_CYPRESS: |
847 | case CHIP_HEMLOCK: |
857 | case CHIP_HEMLOCK: |
848 | /* XXX fill in hw i2c implementation */ |
858 | /* XXX fill in hw i2c implementation */ |
849 | ret = radeon_sw_i2c_xfer(i2c_adap, msgs, num); |
- | |
850 | break; |
859 | break; |
851 | default: |
860 | default: |
852 | DRM_ERROR("i2c: unhandled radeon chip\n"); |
861 | DRM_ERROR("i2c: unhandled radeon chip\n"); |
853 | ret = -EIO; |
862 | ret = -EIO; |
854 | break; |
863 | break; |
855 | } |
864 | } |
- | 865 | LEAVE(); |
|
Line 856... | Line 866... | ||
856 | 866 | ||
857 | return ret; |
867 | return ret; |
Line 858... | Line 868... | ||
858 | } |
868 | } |
859 | 869 | ||
860 | static u32 radeon_i2c_func(struct i2c_adapter *adap) |
870 | static u32 radeon_hw_i2c_func(struct i2c_adapter *adap) |
861 | { |
871 | { |
Line 862... | Line 872... | ||
862 | return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; |
872 | return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; |
863 | } |
873 | } |
864 | 874 | ||
865 | static const struct i2c_algorithm radeon_i2c_algo = { |
875 | static const struct i2c_algorithm radeon_i2c_algo = { |
Line 866... | Line 876... | ||
866 | .master_xfer = radeon_i2c_xfer, |
876 | .master_xfer = radeon_hw_i2c_xfer, |
867 | .functionality = radeon_i2c_func, |
877 | .functionality = radeon_hw_i2c_func, |
868 | }; |
878 | }; |
869 | 879 | ||
- | 880 | struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev, |
|
870 | struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev, |
881 | struct radeon_i2c_bus_rec *rec, |
871 | struct radeon_i2c_bus_rec *rec, |
882 | const char *name) |
Line 872... | Line 883... | ||
872 | const char *name) |
883 | { |
873 | { |
884 | struct radeon_device *rdev = dev->dev_private; |
874 | struct radeon_i2c_chan *i2c; |
885 | struct radeon_i2c_chan *i2c; |
Line 875... | Line 886... | ||
875 | int ret; |
886 | int ret; |
876 | 887 | ||
- | 888 | i2c = kzalloc(sizeof(struct radeon_i2c_chan), GFP_KERNEL); |
|
877 | i2c = kzalloc(sizeof(struct radeon_i2c_chan), GFP_KERNEL); |
889 | if (i2c == NULL) |
- | 890 | return NULL; |
|
- | 891 | ||
- | 892 | i2c->rec = *rec; |
|
- | 893 | // i2c->adapter.owner = THIS_MODULE; |
|
- | 894 | i2c->dev = dev; |
|
- | 895 | i2c_set_adapdata(&i2c->adapter, i2c); |
|
- | 896 | if (rec->mm_i2c || |
|
- | 897 | (rec->hw_capable && |
|
- | 898 | radeon_hw_i2c && |
|
- | 899 | ((rdev->family <= CHIP_RS480) || |
|
- | 900 | ((rdev->family >= CHIP_RV515) && (rdev->family <= CHIP_R580))))) { |
|
- | 901 | /* set the radeon hw i2c adapter */ |
|
- | 902 | snprintf(i2c->adapter.name, sizeof(i2c->adapter.name), |
|
- | 903 | "Radeon i2c hw bus %s", name); |
|
- | 904 | i2c->adapter.algo = &radeon_i2c_algo; |
|
- | 905 | // ret = i2c_add_adapter(&i2c->adapter); |
|
878 | if (i2c == NULL) |
906 | // if (ret) { |
- | 907 | // DRM_ERROR("Failed to register hw i2c %s\n", name); |
|
879 | return NULL; |
908 | // goto out_free; |
- | 909 | // } |
|
- | 910 | } else { |
|
880 | 911 | /* set the radeon bit adapter */ |
|
881 | /* set the internal bit adapter */ |
912 | snprintf(i2c->adapter.name, sizeof(i2c->adapter.name), |
882 | // i2c->algo.radeon.bit_adapter.owner = THIS_MODULE; |
913 | "Radeon i2c bit bus %s", name); |
883 | i2c_set_adapdata(&i2c->algo.radeon.bit_adapter, i2c); |
914 | i2c->adapter.algo_data = &i2c->algo.bit; |
884 | // sprintf(i2c->algo.radeon.bit_adapter.name, "Radeon internal i2c bit bus %s", name); |
915 | i2c->algo.bit.pre_xfer = pre_xfer; |
885 | i2c->algo.radeon.bit_adapter.algo_data = &i2c->algo.radeon.bit_data; |
916 | i2c->algo.bit.post_xfer = post_xfer; |
886 | i2c->algo.radeon.bit_data.setsda = set_data; |
917 | i2c->algo.bit.setsda = set_data; |
887 | i2c->algo.radeon.bit_data.setscl = set_clock; |
918 | i2c->algo.bit.setscl = set_clock; |
888 | i2c->algo.radeon.bit_data.getsda = get_data; |
919 | i2c->algo.bit.getsda = get_data; |
889 | i2c->algo.radeon.bit_data.getscl = get_clock; |
920 | i2c->algo.bit.getscl = get_clock; |
890 | i2c->algo.radeon.bit_data.udelay = 20; |
921 | i2c->algo.bit.udelay = 20; |
891 | /* vesa says 2.2 ms is enough, 1 jiffy doesn't seem to always |
922 | /* vesa says 2.2 ms is enough, 1 jiffy doesn't seem to always |
892 | * make this, 2 jiffies is a lot more reliable */ |
923 | * make this, 2 jiffies is a lot more reliable */ |
893 | i2c->algo.radeon.bit_data.timeout = 2; |
924 | i2c->algo.bit.timeout = 2; |
894 | i2c->algo.radeon.bit_data.data = i2c; |
- | |
895 | ret = i2c_bit_add_bus(&i2c->algo.radeon.bit_adapter); |
925 | i2c->algo.bit.data = i2c; |
896 | if (ret) { |
- | |
897 | DRM_ERROR("Failed to register internal bit i2c %s\n", name); |
- | |
898 | goto out_free; |
- | |
899 | } |
- | |
900 | /* set the radeon i2c adapter */ |
- | |
901 | i2c->dev = dev; |
- | |
Line 902... | Line 926... | ||
902 | i2c->rec = *rec; |
926 | ret = i2c_bit_add_bus(&i2c->adapter); |
903 | // i2c->adapter.owner = THIS_MODULE; |
927 | if (ret) { |
904 | i2c_set_adapdata(&i2c->adapter, i2c); |
928 | DRM_ERROR("Failed to register bit i2c %s\n", name); |
905 | // sprintf(i2c->adapter.name, "Radeon i2c %s", name); |
929 | goto out_free; |
Line 924... | Line 948... | ||
924 | if (i2c == NULL) |
948 | if (i2c == NULL) |
925 | return NULL; |
949 | return NULL; |
Line 926... | Line 950... | ||
926 | 950 | ||
927 | i2c->rec = *rec; |
951 | i2c->rec = *rec; |
- | 952 | // i2c->adapter.owner = THIS_MODULE; |
|
928 | // i2c->adapter.owner = THIS_MODULE; |
953 | i2c->adapter.class = I2C_CLASS_DDC; |
- | 954 | i2c->dev = dev; |
|
- | 955 | snprintf(i2c->adapter.name, sizeof(i2c->adapter.name), |
|
929 | i2c->dev = dev; |
956 | "Radeon aux bus %s", name); |
930 | i2c_set_adapdata(&i2c->adapter, i2c); |
957 | i2c_set_adapdata(&i2c->adapter, i2c); |
931 | i2c->adapter.algo_data = &i2c->algo.dp; |
958 | i2c->adapter.algo_data = &i2c->algo.dp; |
932 | i2c->algo.dp.aux_ch = radeon_dp_i2c_aux_ch; |
959 | i2c->algo.dp.aux_ch = radeon_dp_i2c_aux_ch; |
933 | i2c->algo.dp.address = 0; |
960 | i2c->algo.dp.address = 0; |
Line 946... | Line 973... | ||
946 | 973 | ||
947 | void radeon_i2c_destroy(struct radeon_i2c_chan *i2c) |
974 | void radeon_i2c_destroy(struct radeon_i2c_chan *i2c) |
948 | { |
975 | { |
949 | if (!i2c) |
976 | if (!i2c) |
- | 977 | return; |
|
950 | return; |
978 | // i2c_del_adapter(&i2c->adapter); |
951 | kfree(i2c); |
979 | kfree(i2c); |
Line -... | Line 980... | ||
- | 980 | } |
|
952 | } |
981 | |
953 | 982 | /* Add the default buses */ |
|
- | 983 | void radeon_i2c_init(struct radeon_device *rdev) |
|
- | 984 | { |
|
- | 985 | if (rdev->is_atom_bios) |
|
- | 986 | radeon_atombios_i2c_init(rdev); |
|
- | 987 | else |
|
- | 988 | radeon_combios_i2c_init(rdev); |
|
- | 989 | } |
|
- | 990 | ||
- | 991 | /* remove all the buses */ |
|
954 | void radeon_i2c_destroy_dp(struct radeon_i2c_chan *i2c) |
992 | void radeon_i2c_fini(struct radeon_device *rdev) |
- | 993 | { |
|
- | 994 | int i; |
|
- | 995 | ||
- | 996 | for (i = 0; i < RADEON_MAX_I2C_BUS; i++) { |
|
- | 997 | if (rdev->i2c_bus[i]) { |
|
- | 998 | radeon_i2c_destroy(rdev->i2c_bus[i]); |
|
- | 999 | rdev->i2c_bus[i] = NULL; |
|
- | 1000 | } |
|
- | 1001 | } |
|
- | 1002 | } |
|
- | 1003 | ||
- | 1004 | /* Add additional buses */ |
|
- | 1005 | void radeon_i2c_add(struct radeon_device *rdev, |
|
- | 1006 | struct radeon_i2c_bus_rec *rec, |
|
- | 1007 | const char *name) |
|
- | 1008 | { |
|
- | 1009 | struct drm_device *dev = rdev->ddev; |
|
- | 1010 | int i; |
|
- | 1011 | ||
- | 1012 | for (i = 0; i < RADEON_MAX_I2C_BUS; i++) { |
|
955 | { |
1013 | if (!rdev->i2c_bus[i]) { |
- | 1014 | rdev->i2c_bus[i] = radeon_i2c_create(dev, rec, name); |
|
- | 1015 | return; |
|
- | 1016 | } |
|
Line -... | Line 1017... | ||
- | 1017 | } |
|
- | 1018 | } |
|
- | 1019 | ||
- | 1020 | /* looks up bus based on id */ |
|
- | 1021 | struct radeon_i2c_chan *radeon_i2c_lookup(struct radeon_device *rdev, |
|
- | 1022 | struct radeon_i2c_bus_rec *i2c_bus) |
|
- | 1023 | { |
|
- | 1024 | int i; |
|
- | 1025 | ||
- | 1026 | for (i = 0; i < RADEON_MAX_I2C_BUS; i++) { |
|
- | 1027 | if (rdev->i2c_bus[i] && |
|
- | 1028 | (rdev->i2c_bus[i]->rec.i2c_id == i2c_bus->i2c_id)) { |
|
956 | if (!i2c) |
1029 | return rdev->i2c_bus[i]; |
957 | return; |
1030 | } |
Line 958... | Line 1031... | ||
958 | 1031 | } |
|
959 | kfree(i2c); |
1032 | return NULL; |
960 | } |
1033 | } |
Line 991... | Line 1064... | ||
991 | 1064 | ||
992 | if (i2c_transfer(&i2c_bus->adapter, msgs, 2) == 2) { |
1065 | if (i2c_transfer(&i2c_bus->adapter, msgs, 2) == 2) { |
993 | *val = in_buf[0]; |
1066 | *val = in_buf[0]; |
994 | DRM_DEBUG("val = 0x%02x\n", *val); |
1067 | DRM_DEBUG("val = 0x%02x\n", *val); |
995 | } else { |
1068 | } else { |
996 | DRM_ERROR("i2c 0x%02x 0x%02x read failed\n", |
1069 | DRM_DEBUG("i2c 0x%02x 0x%02x read failed\n", |
997 | addr, *val); |
1070 | addr, *val); |
998 | } |
1071 | } |
Line 999... | Line 1072... | ||
999 | } |
1072 | } |
Line 1013... | Line 1086... | ||
1013 | 1086 | ||
1014 | out_buf[0] = addr; |
1087 | out_buf[0] = addr; |
Line 1015... | Line 1088... | ||
1015 | out_buf[1] = val; |
1088 | out_buf[1] = val; |
1016 | 1089 | ||
1017 | if (i2c_transfer(&i2c_bus->adapter, &msg, 1) != 1) |
1090 | if (i2c_transfer(&i2c_bus->adapter, &msg, 1) != 1) |
1018 | DRM_ERROR("i2c 0x%02x 0x%02x write failed\n", |
1091 | DRM_DEBUG("i2c 0x%02x 0x%02x write failed\n", |
Line -... | Line 1092... | ||
- | 1092 | addr, val); |
|
- | 1093 | } |
|
- | 1094 | ||
- | 1095 | /* ddc router switching */ |
|
- | 1096 | void radeon_router_select_ddc_port(struct radeon_connector *radeon_connector) |
|
- | 1097 | { |
|
- | 1098 | u8 val; |
|
- | 1099 | ||
- | 1100 | if (!radeon_connector->router.ddc_valid) |
|
- | 1101 | return; |
|
- | 1102 | ||
- | 1103 | if (!radeon_connector->router_bus) |
|
- | 1104 | return; |
|
- | 1105 | ||
- | 1106 | radeon_i2c_get_byte(radeon_connector->router_bus, |
|
- | 1107 | radeon_connector->router.i2c_addr, |
|
- | 1108 | 0x3, &val); |
|
- | 1109 | val &= ~radeon_connector->router.ddc_mux_control_pin; |
|
- | 1110 | radeon_i2c_put_byte(radeon_connector->router_bus, |
|
- | 1111 | radeon_connector->router.i2c_addr, |
|
- | 1112 | 0x3, val); |
|
- | 1113 | radeon_i2c_get_byte(radeon_connector->router_bus, |
|
- | 1114 | radeon_connector->router.i2c_addr, |
|
- | 1115 | 0x1, &val); |
|
- | 1116 | val &= ~radeon_connector->router.ddc_mux_control_pin; |
|
- | 1117 | val |= radeon_connector->router.ddc_mux_state; |
|
- | 1118 | radeon_i2c_put_byte(radeon_connector->router_bus, |
|
- | 1119 | radeon_connector->router.i2c_addr, |
|
- | 1120 | 0x1, val); |
|
- | 1121 | } |
|
- | 1122 | ||
- | 1123 | /* clock/data router switching */ |
|
- | 1124 | void radeon_router_select_cd_port(struct radeon_connector *radeon_connector) |
|
- | 1125 | { |
|
- | 1126 | u8 val; |
|
- | 1127 | ||
- | 1128 | if (!radeon_connector->router.cd_valid) |
|
- | 1129 | return; |
|
- | 1130 | ||
- | 1131 | if (!radeon_connector->router_bus) |
|
- | 1132 | return; |
|
- | 1133 | ||
- | 1134 | radeon_i2c_get_byte(radeon_connector->router_bus, |
|
- | 1135 | radeon_connector->router.i2c_addr, |
|
- | 1136 | 0x3, &val); |
|
- | 1137 | val &= ~radeon_connector->router.cd_mux_control_pin; |
|
- | 1138 | radeon_i2c_put_byte(radeon_connector->router_bus, |
|
- | 1139 | radeon_connector->router.i2c_addr, |
|
- | 1140 | 0x3, val); |
|
- | 1141 | radeon_i2c_get_byte(radeon_connector->router_bus, |
|
- | 1142 | radeon_connector->router.i2c_addr, |
|
- | 1143 | 0x1, &val); |
|
- | 1144 | val &= ~radeon_connector->router.cd_mux_control_pin; |
|
- | 1145 | val |= radeon_connector->router.cd_mux_state; |
|
- | 1146 | radeon_i2c_put_byte(radeon_connector->router_bus, |
|
- | 1147 | radeon_connector->router.i2c_addr, |