aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Tettamanti <kronos.it@gmail.com>2012-07-30 15:16:06 -0400
committerAlex Deucher <alexander.deucher@amd.com>2012-09-20 13:10:35 -0400
commitce3cf821a31f9824eda788cbd3e710d8047e82df (patch)
treef619907dabc0db1a48f41f9b4bcc3eaf44e2f97a
parentfd64ca8a9d9d7e92fc81fe0b23dcf324246fd356 (diff)
drm/radeon: implement wrapper for GET_SYSTEM_PARAMS
Use GET_SYSTEM_PARAMS for retrieving the configuration for the system BIOS notifications. v2: packed struct (Lee, Chun-Yi <jlee@suse.com>) v3: fix enable with device specific command code Signed-off-by: Luca Tettamanti <kronos.it@gmail.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--drivers/gpu/drm/radeon/radeon_acpi.c85
1 files changed, 83 insertions, 2 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_acpi.c b/drivers/gpu/drm/radeon/radeon_acpi.c
index 2f6cef2acadc..0454eccc9c03 100644
--- a/drivers/gpu/drm/radeon/radeon_acpi.c
+++ b/drivers/gpu/drm/radeon/radeon_acpi.c
@@ -43,6 +43,18 @@ struct atif_verify_interface {
43 u32 function_bits; /* supported functions bit vector */ 43 u32 function_bits; /* supported functions bit vector */
44} __packed; 44} __packed;
45 45
46struct atif_system_params {
47 u16 size;
48 u32 valid_mask;
49 u32 flags;
50 u8 command_code;
51} __packed;
52
53#define ATIF_NOTIFY_MASK 0x3
54#define ATIF_NOTIFY_NONE 0
55#define ATIF_NOTIFY_81 1
56#define ATIF_NOTIFY_N 2
57
46/* Call the ATIF method 58/* Call the ATIF method
47 */ 59 */
48static union acpi_object *radeon_atif_call(acpi_handle handle, int function, 60static union acpi_object *radeon_atif_call(acpi_handle handle, int function,
@@ -144,10 +156,57 @@ out:
144 return err; 156 return err;
145} 157}
146 158
159static int radeon_atif_get_notification_params(acpi_handle handle,
160 struct radeon_atif_notification_cfg *n)
161{
162 union acpi_object *info;
163 struct atif_system_params params;
164 size_t size;
165 int err = 0;
166
167 info = radeon_atif_call(handle, ATIF_FUNCTION_GET_SYSTEM_PARAMETERS, NULL);
168 if (!info) {
169 err = -EIO;
170 goto out;
171 }
172
173 size = *(u16 *) info->buffer.pointer;
174 if (size < 10) {
175 err = -EINVAL;
176 goto out;
177 }
178
179 memset(&params, 0, sizeof(params));
180 size = min(sizeof(params), size);
181 memcpy(&params, info->buffer.pointer, size);
182
183 params.flags = params.flags & params.valid_mask;
184
185 if ((params.flags & ATIF_NOTIFY_MASK) == ATIF_NOTIFY_NONE) {
186 n->enabled = false;
187 n->command_code = 0;
188 } else if ((params.flags & ATIF_NOTIFY_MASK) == ATIF_NOTIFY_81) {
189 n->enabled = true;
190 n->command_code = 0x81;
191 } else {
192 if (size < 11) {
193 err = -EINVAL;
194 goto out;
195 }
196 n->enabled = true;
197 n->command_code = params.command_code;
198 }
199
200out:
201 kfree(info);
202 return err;
203}
204
147/* Call all ACPI methods here */ 205/* Call all ACPI methods here */
148int radeon_acpi_init(struct radeon_device *rdev) 206int radeon_acpi_init(struct radeon_device *rdev)
149{ 207{
150 acpi_handle handle; 208 acpi_handle handle;
209 struct radeon_atif *atif = &rdev->atif;
151 int ret; 210 int ret;
152 211
153 /* Get the device handle */ 212 /* Get the device handle */
@@ -158,10 +217,32 @@ int radeon_acpi_init(struct radeon_device *rdev)
158 return 0; 217 return 0;
159 218
160 /* Call the ATIF method */ 219 /* Call the ATIF method */
161 ret = radeon_atif_verify_interface(handle, &rdev->atif); 220 ret = radeon_atif_verify_interface(handle, atif);
162 if (ret) 221 if (ret) {
163 DRM_DEBUG_DRIVER("Call to verify_interface failed: %d\n", ret); 222 DRM_DEBUG_DRIVER("Call to verify_interface failed: %d\n", ret);
223 goto out;
224 }
225
226 if (atif->functions.sbios_requests && !atif->functions.system_params) {
227 /* XXX check this workraround, if sbios request function is
228 * present we have to see how it's configured in the system
229 * params
230 */
231 atif->functions.system_params = true;
232 }
233
234 if (atif->functions.system_params) {
235 ret = radeon_atif_get_notification_params(handle,
236 &atif->notification_cfg);
237 if (ret) {
238 DRM_DEBUG_DRIVER("Call to GET_SYSTEM_PARAMS failed: %d\n",
239 ret);
240 /* Disable notification */
241 atif->notification_cfg.enabled = false;
242 }
243 }
164 244
245out:
165 return ret; 246 return ret;
166} 247}
167 248