aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/radeon/radeon_atombios.c
diff options
context:
space:
mode:
authorAlex Deucher <alexdeucher@gmail.com>2010-08-05 21:21:16 -0400
committerDave Airlie <airlied@redhat.com>2010-08-09 20:46:48 -0400
commitf376b94fbc0a313a606748206340cbef6c2adf6b (patch)
tree79687e8c214bf70251c242f8042bc46d6fc61020 /drivers/gpu/drm/radeon/radeon_atombios.c
parent1729dd33d20bddf1b3f371f3090f0cfd6be50b7a (diff)
drm/radeon/kms: unify i2c handling
Previously we added i2c buses as needed when enumerating connectors power management, etc. This only exposed the actual buses used and could have lead to the same buse getting created more than once if one buses was used for more than one purpose. This patch sets up all i2c buses on the card in one place and users of the buses just point back to the one instance. Signed-off-by: Alex Deucher <alexdeucher@gmail.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/radeon/radeon_atombios.c')
-rw-r--r--drivers/gpu/drm/radeon/radeon_atombios.c67
1 files changed, 64 insertions, 3 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c
index 3bc2bcdf530..a841adead1a 100644
--- a/drivers/gpu/drm/radeon/radeon_atombios.c
+++ b/drivers/gpu/drm/radeon/radeon_atombios.c
@@ -114,7 +114,8 @@ static inline struct radeon_i2c_bus_rec radeon_lookup_i2c_gpio(struct radeon_dev
114 114
115 i2c.i2c_id = gpio->sucI2cId.ucAccess; 115 i2c.i2c_id = gpio->sucI2cId.ucAccess;
116 116
117 i2c.valid = true; 117 if (i2c.mask_clk_reg)
118 i2c.valid = true;
118 break; 119 break;
119 } 120 }
120 } 121 }
@@ -123,6 +124,66 @@ static inline struct radeon_i2c_bus_rec radeon_lookup_i2c_gpio(struct radeon_dev
123 return i2c; 124 return i2c;
124} 125}
125 126
127void radeon_atombios_i2c_init(struct radeon_device *rdev)
128{
129 struct atom_context *ctx = rdev->mode_info.atom_context;
130 ATOM_GPIO_I2C_ASSIGMENT *gpio;
131 struct radeon_i2c_bus_rec i2c;
132 int index = GetIndexIntoMasterTable(DATA, GPIO_I2C_Info);
133 struct _ATOM_GPIO_I2C_INFO *i2c_info;
134 uint16_t data_offset, size;
135 int i, num_indices;
136 char stmp[32];
137
138 memset(&i2c, 0, sizeof(struct radeon_i2c_bus_rec));
139
140 if (atom_parse_data_header(ctx, index, &size, NULL, NULL, &data_offset)) {
141 i2c_info = (struct _ATOM_GPIO_I2C_INFO *)(ctx->bios + data_offset);
142
143 num_indices = (size - sizeof(ATOM_COMMON_TABLE_HEADER)) /
144 sizeof(ATOM_GPIO_I2C_ASSIGMENT);
145
146 for (i = 0; i < num_indices; i++) {
147 gpio = &i2c_info->asGPIO_Info[i];
148 i2c.valid = false;
149 i2c.mask_clk_reg = le16_to_cpu(gpio->usClkMaskRegisterIndex) * 4;
150 i2c.mask_data_reg = le16_to_cpu(gpio->usDataMaskRegisterIndex) * 4;
151 i2c.en_clk_reg = le16_to_cpu(gpio->usClkEnRegisterIndex) * 4;
152 i2c.en_data_reg = le16_to_cpu(gpio->usDataEnRegisterIndex) * 4;
153 i2c.y_clk_reg = le16_to_cpu(gpio->usClkY_RegisterIndex) * 4;
154 i2c.y_data_reg = le16_to_cpu(gpio->usDataY_RegisterIndex) * 4;
155 i2c.a_clk_reg = le16_to_cpu(gpio->usClkA_RegisterIndex) * 4;
156 i2c.a_data_reg = le16_to_cpu(gpio->usDataA_RegisterIndex) * 4;
157 i2c.mask_clk_mask = (1 << gpio->ucClkMaskShift);
158 i2c.mask_data_mask = (1 << gpio->ucDataMaskShift);
159 i2c.en_clk_mask = (1 << gpio->ucClkEnShift);
160 i2c.en_data_mask = (1 << gpio->ucDataEnShift);
161 i2c.y_clk_mask = (1 << gpio->ucClkY_Shift);
162 i2c.y_data_mask = (1 << gpio->ucDataY_Shift);
163 i2c.a_clk_mask = (1 << gpio->ucClkA_Shift);
164 i2c.a_data_mask = (1 << gpio->ucDataA_Shift);
165
166 if (gpio->sucI2cId.sbfAccess.bfHW_Capable)
167 i2c.hw_capable = true;
168 else
169 i2c.hw_capable = false;
170
171 if (gpio->sucI2cId.ucAccess == 0xa0)
172 i2c.mm_i2c = true;
173 else
174 i2c.mm_i2c = false;
175
176 i2c.i2c_id = gpio->sucI2cId.ucAccess;
177
178 if (i2c.mask_clk_reg) {
179 i2c.valid = true;
180 sprintf(stmp, "0x%x", i2c.i2c_id);
181 rdev->i2c_bus[i] = radeon_i2c_create(rdev->ddev, &i2c, stmp);
182 }
183 }
184 }
185}
186
126static inline struct radeon_gpio_rec radeon_lookup_gpio(struct radeon_device *rdev, 187static inline struct radeon_gpio_rec radeon_lookup_gpio(struct radeon_device *rdev,
127 u8 id) 188 u8 id)
128{ 189{
@@ -1521,7 +1582,7 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev)
1521 thermal_controller_names[power_info->info.ucOverdriveThermalController], 1582 thermal_controller_names[power_info->info.ucOverdriveThermalController],
1522 power_info->info.ucOverdriveControllerAddress >> 1); 1583 power_info->info.ucOverdriveControllerAddress >> 1);
1523 i2c_bus = radeon_lookup_i2c_gpio(rdev, power_info->info.ucOverdriveI2cLine); 1584 i2c_bus = radeon_lookup_i2c_gpio(rdev, power_info->info.ucOverdriveI2cLine);
1524 rdev->pm.i2c_bus = radeon_i2c_create(rdev->ddev, &i2c_bus, "Thermal"); 1585 rdev->pm.i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus);
1525 if (rdev->pm.i2c_bus) { 1586 if (rdev->pm.i2c_bus) {
1526 struct i2c_board_info info = { }; 1587 struct i2c_board_info info = { };
1527 const char *name = thermal_controller_names[power_info->info. 1588 const char *name = thermal_controller_names[power_info->info.
@@ -1814,7 +1875,7 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev)
1814 (controller->ucFanParameters & 1875 (controller->ucFanParameters &
1815 ATOM_PP_FANPARAMETERS_NOFAN) ? "without" : "with"); 1876 ATOM_PP_FANPARAMETERS_NOFAN) ? "without" : "with");
1816 i2c_bus = radeon_lookup_i2c_gpio(rdev, controller->ucI2cLine); 1877 i2c_bus = radeon_lookup_i2c_gpio(rdev, controller->ucI2cLine);
1817 rdev->pm.i2c_bus = radeon_i2c_create(rdev->ddev, &i2c_bus, "Thermal"); 1878 rdev->pm.i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus);
1818 if (rdev->pm.i2c_bus) { 1879 if (rdev->pm.i2c_bus) {
1819 struct i2c_board_info info = { }; 1880 struct i2c_board_info info = { };
1820 const char *name = pp_lib_thermal_controller_names[controller->ucType]; 1881 const char *name = pp_lib_thermal_controller_names[controller->ucType];