aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/radeon/radeon_i2c.c
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/gpu/drm/radeon/radeon_i2c.c
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'drivers/gpu/drm/radeon/radeon_i2c.c')
-rw-r--r--drivers/gpu/drm/radeon/radeon_i2c.c61
1 files changed, 49 insertions, 12 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_i2c.c b/drivers/gpu/drm/radeon/radeon_i2c.c
index 6a13ee38a5b9..781196db792f 100644
--- a/drivers/gpu/drm/radeon/radeon_i2c.c
+++ b/drivers/gpu/drm/radeon/radeon_i2c.c
@@ -53,8 +53,8 @@ bool radeon_ddc_probe(struct radeon_connector *radeon_connector)
53 }; 53 };
54 54
55 /* on hw with routers, select right port */ 55 /* on hw with routers, select right port */
56 if (radeon_connector->router.valid) 56 if (radeon_connector->router.ddc_valid)
57 radeon_router_select_port(radeon_connector); 57 radeon_router_select_ddc_port(radeon_connector);
58 58
59 ret = i2c_transfer(&radeon_connector->ddc_bus->adapter, msgs, 2); 59 ret = i2c_transfer(&radeon_connector->ddc_bus->adapter, msgs, 2);
60 if (ret == 2) 60 if (ret == 2)
@@ -888,6 +888,7 @@ struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev,
888 888
889 i2c->rec = *rec; 889 i2c->rec = *rec;
890 i2c->adapter.owner = THIS_MODULE; 890 i2c->adapter.owner = THIS_MODULE;
891 i2c->adapter.class = I2C_CLASS_DDC;
891 i2c->dev = dev; 892 i2c->dev = dev;
892 i2c_set_adapdata(&i2c->adapter, i2c); 893 i2c_set_adapdata(&i2c->adapter, i2c);
893 if (rec->mm_i2c || 894 if (rec->mm_i2c ||
@@ -896,7 +897,8 @@ struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev,
896 ((rdev->family <= CHIP_RS480) || 897 ((rdev->family <= CHIP_RS480) ||
897 ((rdev->family >= CHIP_RV515) && (rdev->family <= CHIP_R580))))) { 898 ((rdev->family >= CHIP_RV515) && (rdev->family <= CHIP_R580))))) {
898 /* set the radeon hw i2c adapter */ 899 /* set the radeon hw i2c adapter */
899 sprintf(i2c->adapter.name, "Radeon i2c hw bus %s", name); 900 snprintf(i2c->adapter.name, sizeof(i2c->adapter.name),
901 "Radeon i2c hw bus %s", name);
900 i2c->adapter.algo = &radeon_i2c_algo; 902 i2c->adapter.algo = &radeon_i2c_algo;
901 ret = i2c_add_adapter(&i2c->adapter); 903 ret = i2c_add_adapter(&i2c->adapter);
902 if (ret) { 904 if (ret) {
@@ -905,7 +907,8 @@ struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev,
905 } 907 }
906 } else { 908 } else {
907 /* set the radeon bit adapter */ 909 /* set the radeon bit adapter */
908 sprintf(i2c->adapter.name, "Radeon i2c bit bus %s", name); 910 snprintf(i2c->adapter.name, sizeof(i2c->adapter.name),
911 "Radeon i2c bit bus %s", name);
909 i2c->adapter.algo_data = &i2c->algo.bit; 912 i2c->adapter.algo_data = &i2c->algo.bit;
910 i2c->algo.bit.pre_xfer = pre_xfer; 913 i2c->algo.bit.pre_xfer = pre_xfer;
911 i2c->algo.bit.post_xfer = post_xfer; 914 i2c->algo.bit.post_xfer = post_xfer;
@@ -945,7 +948,10 @@ struct radeon_i2c_chan *radeon_i2c_create_dp(struct drm_device *dev,
945 948
946 i2c->rec = *rec; 949 i2c->rec = *rec;
947 i2c->adapter.owner = THIS_MODULE; 950 i2c->adapter.owner = THIS_MODULE;
951 i2c->adapter.class = I2C_CLASS_DDC;
948 i2c->dev = dev; 952 i2c->dev = dev;
953 snprintf(i2c->adapter.name, sizeof(i2c->adapter.name),
954 "Radeon aux bus %s", name);
949 i2c_set_adapdata(&i2c->adapter, i2c); 955 i2c_set_adapdata(&i2c->adapter, i2c);
950 i2c->adapter.algo_data = &i2c->algo.dp; 956 i2c->adapter.algo_data = &i2c->algo.dp;
951 i2c->algo.dp.aux_ch = radeon_dp_i2c_aux_ch; 957 i2c->algo.dp.aux_ch = radeon_dp_i2c_aux_ch;
@@ -1058,7 +1064,7 @@ void radeon_i2c_get_byte(struct radeon_i2c_chan *i2c_bus,
1058 *val = in_buf[0]; 1064 *val = in_buf[0];
1059 DRM_DEBUG("val = 0x%02x\n", *val); 1065 DRM_DEBUG("val = 0x%02x\n", *val);
1060 } else { 1066 } else {
1061 DRM_ERROR("i2c 0x%02x 0x%02x read failed\n", 1067 DRM_DEBUG("i2c 0x%02x 0x%02x read failed\n",
1062 addr, *val); 1068 addr, *val);
1063 } 1069 }
1064} 1070}
@@ -1080,30 +1086,61 @@ void radeon_i2c_put_byte(struct radeon_i2c_chan *i2c_bus,
1080 out_buf[1] = val; 1086 out_buf[1] = val;
1081 1087
1082 if (i2c_transfer(&i2c_bus->adapter, &msg, 1) != 1) 1088 if (i2c_transfer(&i2c_bus->adapter, &msg, 1) != 1)
1083 DRM_ERROR("i2c 0x%02x 0x%02x write failed\n", 1089 DRM_DEBUG("i2c 0x%02x 0x%02x write failed\n",
1084 addr, val); 1090 addr, val);
1085} 1091}
1086 1092
1087/* router switching */ 1093/* ddc router switching */
1088void radeon_router_select_port(struct radeon_connector *radeon_connector) 1094void radeon_router_select_ddc_port(struct radeon_connector *radeon_connector)
1089{ 1095{
1090 u8 val; 1096 u8 val;
1091 1097
1092 if (!radeon_connector->router.valid) 1098 if (!radeon_connector->router.ddc_valid)
1099 return;
1100
1101 if (!radeon_connector->router_bus)
1102 return;
1103
1104 radeon_i2c_get_byte(radeon_connector->router_bus,
1105 radeon_connector->router.i2c_addr,
1106 0x3, &val);
1107 val &= ~radeon_connector->router.ddc_mux_control_pin;
1108 radeon_i2c_put_byte(radeon_connector->router_bus,
1109 radeon_connector->router.i2c_addr,
1110 0x3, val);
1111 radeon_i2c_get_byte(radeon_connector->router_bus,
1112 radeon_connector->router.i2c_addr,
1113 0x1, &val);
1114 val &= ~radeon_connector->router.ddc_mux_control_pin;
1115 val |= radeon_connector->router.ddc_mux_state;
1116 radeon_i2c_put_byte(radeon_connector->router_bus,
1117 radeon_connector->router.i2c_addr,
1118 0x1, val);
1119}
1120
1121/* clock/data router switching */
1122void radeon_router_select_cd_port(struct radeon_connector *radeon_connector)
1123{
1124 u8 val;
1125
1126 if (!radeon_connector->router.cd_valid)
1127 return;
1128
1129 if (!radeon_connector->router_bus)
1093 return; 1130 return;
1094 1131
1095 radeon_i2c_get_byte(radeon_connector->router_bus, 1132 radeon_i2c_get_byte(radeon_connector->router_bus,
1096 radeon_connector->router.i2c_addr, 1133 radeon_connector->router.i2c_addr,
1097 0x3, &val); 1134 0x3, &val);
1098 val &= radeon_connector->router.mux_control_pin; 1135 val &= ~radeon_connector->router.cd_mux_control_pin;
1099 radeon_i2c_put_byte(radeon_connector->router_bus, 1136 radeon_i2c_put_byte(radeon_connector->router_bus,
1100 radeon_connector->router.i2c_addr, 1137 radeon_connector->router.i2c_addr,
1101 0x3, val); 1138 0x3, val);
1102 radeon_i2c_get_byte(radeon_connector->router_bus, 1139 radeon_i2c_get_byte(radeon_connector->router_bus,
1103 radeon_connector->router.i2c_addr, 1140 radeon_connector->router.i2c_addr,
1104 0x1, &val); 1141 0x1, &val);
1105 val &= radeon_connector->router.mux_control_pin; 1142 val &= ~radeon_connector->router.cd_mux_control_pin;
1106 val |= radeon_connector->router.mux_state; 1143 val |= radeon_connector->router.cd_mux_state;
1107 radeon_i2c_put_byte(radeon_connector->router_bus, 1144 radeon_i2c_put_byte(radeon_connector->router_bus,
1108 radeon_connector->router.i2c_addr, 1145 radeon_connector->router.i2c_addr,
1109 0x1, val); 1146 0x1, val);