diff options
-rw-r--r-- | Documentation/laptops/thinkpad-acpi.txt | 2 | ||||
-rw-r--r-- | drivers/platform/x86/thinkpad_acpi.c | 117 |
2 files changed, 98 insertions, 21 deletions
diff --git a/Documentation/laptops/thinkpad-acpi.txt b/Documentation/laptops/thinkpad-acpi.txt index bce1d959b703..7daca0553676 100644 --- a/Documentation/laptops/thinkpad-acpi.txt +++ b/Documentation/laptops/thinkpad-acpi.txt | |||
@@ -1494,6 +1494,8 @@ to enable more than one output class, just add their values. | |||
1494 | accessing some functions of the driver | 1494 | accessing some functions of the driver |
1495 | 0x0001 Initialization and probing | 1495 | 0x0001 Initialization and probing |
1496 | 0x0002 Removal | 1496 | 0x0002 Removal |
1497 | 0x0004 RF Transmitter control (RFKILL) | ||
1498 | (bluetooth, WWAN, UWB...) | ||
1497 | 1499 | ||
1498 | There is also a kernel build option to enable more debugging | 1500 | There is also a kernel build option to enable more debugging |
1499 | information, which may be necessary to debug driver problems. | 1501 | information, which may be necessary to debug driver problems. |
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 38c34c79ff35..57ab5512c796 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c | |||
@@ -189,6 +189,7 @@ enum { | |||
189 | #define TPACPI_DBG_DISCLOSETASK 0x8000 | 189 | #define TPACPI_DBG_DISCLOSETASK 0x8000 |
190 | #define TPACPI_DBG_INIT 0x0001 | 190 | #define TPACPI_DBG_INIT 0x0001 |
191 | #define TPACPI_DBG_EXIT 0x0002 | 191 | #define TPACPI_DBG_EXIT 0x0002 |
192 | #define TPACPI_DBG_RFKILL 0x0004 | ||
192 | 193 | ||
193 | #define onoff(status, bit) ((status) & (1 << (bit)) ? "on" : "off") | 194 | #define onoff(status, bit) ((status) & (1 << (bit)) ? "on" : "off") |
194 | #define enabled(status, bit) ((status) & (1 << (bit)) ? "enabled" : "disabled") | 195 | #define enabled(status, bit) ((status) & (1 << (bit)) ? "enabled" : "disabled") |
@@ -1016,10 +1017,13 @@ static int __init tpacpi_new_rfkill(const unsigned int id, | |||
1016 | /* try to set the initial state as the default for the rfkill | 1017 | /* try to set the initial state as the default for the rfkill |
1017 | * type, since we ask the firmware to preserve it across S5 in | 1018 | * type, since we ask the firmware to preserve it across S5 in |
1018 | * NVRAM */ | 1019 | * NVRAM */ |
1019 | rfkill_set_default(rfktype, | 1020 | if (rfkill_set_default(rfktype, |
1020 | (initial_state == RFKILL_STATE_UNBLOCKED) ? | 1021 | (initial_state == RFKILL_STATE_UNBLOCKED) ? |
1021 | RFKILL_STATE_UNBLOCKED : | 1022 | RFKILL_STATE_UNBLOCKED : |
1022 | RFKILL_STATE_SOFT_BLOCKED); | 1023 | RFKILL_STATE_SOFT_BLOCKED) == -EPERM) |
1024 | vdbg_printk(TPACPI_DBG_RFKILL, | ||
1025 | "Default state for %s cannot be changed\n", | ||
1026 | name); | ||
1023 | } | 1027 | } |
1024 | 1028 | ||
1025 | *rfk = rfkill_allocate(&tpacpi_pdev->dev, rfktype); | 1029 | *rfk = rfkill_allocate(&tpacpi_pdev->dev, rfktype); |
@@ -3018,13 +3022,17 @@ enum { | |||
3018 | TP_ACPI_BLTH_SAVE_STATE = 0x05, /* Save state for S4/S5 */ | 3022 | TP_ACPI_BLTH_SAVE_STATE = 0x05, /* Save state for S4/S5 */ |
3019 | }; | 3023 | }; |
3020 | 3024 | ||
3025 | #define TPACPI_RFK_BLUETOOTH_SW_NAME "tpacpi_bluetooth_sw" | ||
3026 | |||
3021 | static struct rfkill *tpacpi_bluetooth_rfkill; | 3027 | static struct rfkill *tpacpi_bluetooth_rfkill; |
3022 | 3028 | ||
3023 | static void bluetooth_suspend(pm_message_t state) | 3029 | static void bluetooth_suspend(pm_message_t state) |
3024 | { | 3030 | { |
3025 | /* Try to make sure radio will resume powered off */ | 3031 | /* Try to make sure radio will resume powered off */ |
3026 | acpi_evalf(NULL, NULL, "\\BLTH", "vd", | 3032 | if (!acpi_evalf(NULL, NULL, "\\BLTH", "vd", |
3027 | TP_ACPI_BLTH_PWR_OFF_ON_RESUME); | 3033 | TP_ACPI_BLTH_PWR_OFF_ON_RESUME)) |
3034 | vdbg_printk(TPACPI_DBG_RFKILL, | ||
3035 | "bluetooth power down on resume request failed\n"); | ||
3028 | } | 3036 | } |
3029 | 3037 | ||
3030 | static int bluetooth_get_radiosw(void) | 3038 | static int bluetooth_get_radiosw(void) |
@@ -3062,6 +3070,10 @@ static void bluetooth_update_rfk(void) | |||
3062 | if (status < 0) | 3070 | if (status < 0) |
3063 | return; | 3071 | return; |
3064 | rfkill_force_state(tpacpi_bluetooth_rfkill, status); | 3072 | rfkill_force_state(tpacpi_bluetooth_rfkill, status); |
3073 | |||
3074 | vdbg_printk(TPACPI_DBG_RFKILL, | ||
3075 | "forced rfkill state to %d\n", | ||
3076 | status); | ||
3065 | } | 3077 | } |
3066 | 3078 | ||
3067 | static int bluetooth_set_radiosw(int radio_on, int update_rfk) | 3079 | static int bluetooth_set_radiosw(int radio_on, int update_rfk) |
@@ -3077,6 +3089,9 @@ static int bluetooth_set_radiosw(int radio_on, int update_rfk) | |||
3077 | && radio_on) | 3089 | && radio_on) |
3078 | return -EPERM; | 3090 | return -EPERM; |
3079 | 3091 | ||
3092 | vdbg_printk(TPACPI_DBG_RFKILL, | ||
3093 | "will %s bluetooth\n", radio_on ? "enable" : "disable"); | ||
3094 | |||
3080 | #ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES | 3095 | #ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES |
3081 | if (dbg_bluetoothemul) { | 3096 | if (dbg_bluetoothemul) { |
3082 | tpacpi_bluetooth_emulstate = !!radio_on; | 3097 | tpacpi_bluetooth_emulstate = !!radio_on; |
@@ -3129,6 +3144,8 @@ static ssize_t bluetooth_enable_store(struct device *dev, | |||
3129 | if (parse_strtoul(buf, 1, &t)) | 3144 | if (parse_strtoul(buf, 1, &t)) |
3130 | return -EINVAL; | 3145 | return -EINVAL; |
3131 | 3146 | ||
3147 | tpacpi_disclose_usertask("bluetooth_enable", "set to %ld\n", t); | ||
3148 | |||
3132 | res = bluetooth_set_radiosw(t, 1); | 3149 | res = bluetooth_set_radiosw(t, 1); |
3133 | 3150 | ||
3134 | return (res) ? res : count; | 3151 | return (res) ? res : count; |
@@ -3162,6 +3179,8 @@ static int tpacpi_bluetooth_rfk_get(void *data, enum rfkill_state *state) | |||
3162 | 3179 | ||
3163 | static int tpacpi_bluetooth_rfk_set(void *data, enum rfkill_state state) | 3180 | static int tpacpi_bluetooth_rfk_set(void *data, enum rfkill_state state) |
3164 | { | 3181 | { |
3182 | dbg_printk(TPACPI_DBG_RFKILL, | ||
3183 | "request to change radio state to %d\n", state); | ||
3165 | return bluetooth_set_radiosw((state == RFKILL_STATE_UNBLOCKED), 0); | 3184 | return bluetooth_set_radiosw((state == RFKILL_STATE_UNBLOCKED), 0); |
3166 | } | 3185 | } |
3167 | 3186 | ||
@@ -3172,6 +3191,9 @@ static void bluetooth_shutdown(void) | |||
3172 | TP_ACPI_BLTH_SAVE_STATE)) | 3191 | TP_ACPI_BLTH_SAVE_STATE)) |
3173 | printk(TPACPI_NOTICE | 3192 | printk(TPACPI_NOTICE |
3174 | "failed to save bluetooth state to NVRAM\n"); | 3193 | "failed to save bluetooth state to NVRAM\n"); |
3194 | else | ||
3195 | vdbg_printk(TPACPI_DBG_RFKILL, | ||
3196 | "bluestooth state saved to NVRAM\n"); | ||
3175 | } | 3197 | } |
3176 | 3198 | ||
3177 | static void bluetooth_exit(void) | 3199 | static void bluetooth_exit(void) |
@@ -3190,7 +3212,8 @@ static int __init bluetooth_init(struct ibm_init_struct *iibm) | |||
3190 | int res; | 3212 | int res; |
3191 | int status = 0; | 3213 | int status = 0; |
3192 | 3214 | ||
3193 | vdbg_printk(TPACPI_DBG_INIT, "initializing bluetooth subdriver\n"); | 3215 | vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_RFKILL, |
3216 | "initializing bluetooth subdriver\n"); | ||
3194 | 3217 | ||
3195 | TPACPI_ACPIHANDLE_INIT(hkey); | 3218 | TPACPI_ACPIHANDLE_INIT(hkey); |
3196 | 3219 | ||
@@ -3199,7 +3222,8 @@ static int __init bluetooth_init(struct ibm_init_struct *iibm) | |||
3199 | tp_features.bluetooth = hkey_handle && | 3222 | tp_features.bluetooth = hkey_handle && |
3200 | acpi_evalf(hkey_handle, &status, "GBDC", "qd"); | 3223 | acpi_evalf(hkey_handle, &status, "GBDC", "qd"); |
3201 | 3224 | ||
3202 | vdbg_printk(TPACPI_DBG_INIT, "bluetooth is %s, status 0x%02x\n", | 3225 | vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_RFKILL, |
3226 | "bluetooth is %s, status 0x%02x\n", | ||
3203 | str_supported(tp_features.bluetooth), | 3227 | str_supported(tp_features.bluetooth), |
3204 | status); | 3228 | status); |
3205 | 3229 | ||
@@ -3214,7 +3238,7 @@ static int __init bluetooth_init(struct ibm_init_struct *iibm) | |||
3214 | !(status & TP_ACPI_BLUETOOTH_HWPRESENT)) { | 3238 | !(status & TP_ACPI_BLUETOOTH_HWPRESENT)) { |
3215 | /* no bluetooth hardware present in system */ | 3239 | /* no bluetooth hardware present in system */ |
3216 | tp_features.bluetooth = 0; | 3240 | tp_features.bluetooth = 0; |
3217 | dbg_printk(TPACPI_DBG_INIT, | 3241 | dbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_RFKILL, |
3218 | "bluetooth hardware not installed\n"); | 3242 | "bluetooth hardware not installed\n"); |
3219 | } | 3243 | } |
3220 | 3244 | ||
@@ -3229,7 +3253,7 @@ static int __init bluetooth_init(struct ibm_init_struct *iibm) | |||
3229 | res = tpacpi_new_rfkill(TPACPI_RFK_BLUETOOTH_SW_ID, | 3253 | res = tpacpi_new_rfkill(TPACPI_RFK_BLUETOOTH_SW_ID, |
3230 | &tpacpi_bluetooth_rfkill, | 3254 | &tpacpi_bluetooth_rfkill, |
3231 | RFKILL_TYPE_BLUETOOTH, | 3255 | RFKILL_TYPE_BLUETOOTH, |
3232 | "tpacpi_bluetooth_sw", | 3256 | TPACPI_RFK_BLUETOOTH_SW_NAME, |
3233 | true, | 3257 | true, |
3234 | tpacpi_bluetooth_rfk_set, | 3258 | tpacpi_bluetooth_rfk_set, |
3235 | tpacpi_bluetooth_rfk_get); | 3259 | tpacpi_bluetooth_rfk_get); |
@@ -3262,19 +3286,27 @@ static int bluetooth_read(char *p) | |||
3262 | static int bluetooth_write(char *buf) | 3286 | static int bluetooth_write(char *buf) |
3263 | { | 3287 | { |
3264 | char *cmd; | 3288 | char *cmd; |
3289 | int state = -1; | ||
3265 | 3290 | ||
3266 | if (!tp_features.bluetooth) | 3291 | if (!tp_features.bluetooth) |
3267 | return -ENODEV; | 3292 | return -ENODEV; |
3268 | 3293 | ||
3269 | while ((cmd = next_cmd(&buf))) { | 3294 | while ((cmd = next_cmd(&buf))) { |
3270 | if (strlencmp(cmd, "enable") == 0) { | 3295 | if (strlencmp(cmd, "enable") == 0) { |
3271 | bluetooth_set_radiosw(1, 1); | 3296 | state = 1; |
3272 | } else if (strlencmp(cmd, "disable") == 0) { | 3297 | } else if (strlencmp(cmd, "disable") == 0) { |
3273 | bluetooth_set_radiosw(0, 1); | 3298 | state = 0; |
3274 | } else | 3299 | } else |
3275 | return -EINVAL; | 3300 | return -EINVAL; |
3276 | } | 3301 | } |
3277 | 3302 | ||
3303 | if (state != -1) { | ||
3304 | tpacpi_disclose_usertask("procfs bluetooth", | ||
3305 | "attempt to %s\n", | ||
3306 | state ? "enable" : "disable"); | ||
3307 | bluetooth_set_radiosw(state, 1); | ||
3308 | } | ||
3309 | |||
3278 | return 0; | 3310 | return 0; |
3279 | } | 3311 | } |
3280 | 3312 | ||
@@ -3299,13 +3331,17 @@ enum { | |||
3299 | off / last state */ | 3331 | off / last state */ |
3300 | }; | 3332 | }; |
3301 | 3333 | ||
3334 | #define TPACPI_RFK_WWAN_SW_NAME "tpacpi_wwan_sw" | ||
3335 | |||
3302 | static struct rfkill *tpacpi_wan_rfkill; | 3336 | static struct rfkill *tpacpi_wan_rfkill; |
3303 | 3337 | ||
3304 | static void wan_suspend(pm_message_t state) | 3338 | static void wan_suspend(pm_message_t state) |
3305 | { | 3339 | { |
3306 | /* Try to make sure radio will resume powered off */ | 3340 | /* Try to make sure radio will resume powered off */ |
3307 | acpi_evalf(NULL, NULL, "\\WGSV", "qvd", | 3341 | if (!acpi_evalf(NULL, NULL, "\\WGSV", "qvd", |
3308 | TP_ACPI_WGSV_PWR_OFF_ON_RESUME); | 3342 | TP_ACPI_WGSV_PWR_OFF_ON_RESUME)) |
3343 | vdbg_printk(TPACPI_DBG_RFKILL, | ||
3344 | "WWAN power down on resume request failed\n"); | ||
3309 | } | 3345 | } |
3310 | 3346 | ||
3311 | static int wan_get_radiosw(void) | 3347 | static int wan_get_radiosw(void) |
@@ -3343,6 +3379,10 @@ static void wan_update_rfk(void) | |||
3343 | if (status < 0) | 3379 | if (status < 0) |
3344 | return; | 3380 | return; |
3345 | rfkill_force_state(tpacpi_wan_rfkill, status); | 3381 | rfkill_force_state(tpacpi_wan_rfkill, status); |
3382 | |||
3383 | vdbg_printk(TPACPI_DBG_RFKILL, | ||
3384 | "forced rfkill state to %d\n", | ||
3385 | status); | ||
3346 | } | 3386 | } |
3347 | 3387 | ||
3348 | static int wan_set_radiosw(int radio_on, int update_rfk) | 3388 | static int wan_set_radiosw(int radio_on, int update_rfk) |
@@ -3358,6 +3398,9 @@ static int wan_set_radiosw(int radio_on, int update_rfk) | |||
3358 | && radio_on) | 3398 | && radio_on) |
3359 | return -EPERM; | 3399 | return -EPERM; |
3360 | 3400 | ||
3401 | vdbg_printk(TPACPI_DBG_RFKILL, | ||
3402 | "will %s WWAN\n", radio_on ? "enable" : "disable"); | ||
3403 | |||
3361 | #ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES | 3404 | #ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES |
3362 | if (dbg_wwanemul) { | 3405 | if (dbg_wwanemul) { |
3363 | tpacpi_wwan_emulstate = !!radio_on; | 3406 | tpacpi_wwan_emulstate = !!radio_on; |
@@ -3410,6 +3453,8 @@ static ssize_t wan_enable_store(struct device *dev, | |||
3410 | if (parse_strtoul(buf, 1, &t)) | 3453 | if (parse_strtoul(buf, 1, &t)) |
3411 | return -EINVAL; | 3454 | return -EINVAL; |
3412 | 3455 | ||
3456 | tpacpi_disclose_usertask("wwan_enable", "set to %ld\n", t); | ||
3457 | |||
3413 | res = wan_set_radiosw(t, 1); | 3458 | res = wan_set_radiosw(t, 1); |
3414 | 3459 | ||
3415 | return (res) ? res : count; | 3460 | return (res) ? res : count; |
@@ -3443,6 +3488,8 @@ static int tpacpi_wan_rfk_get(void *data, enum rfkill_state *state) | |||
3443 | 3488 | ||
3444 | static int tpacpi_wan_rfk_set(void *data, enum rfkill_state state) | 3489 | static int tpacpi_wan_rfk_set(void *data, enum rfkill_state state) |
3445 | { | 3490 | { |
3491 | dbg_printk(TPACPI_DBG_RFKILL, | ||
3492 | "request to change radio state to %d\n", state); | ||
3446 | return wan_set_radiosw((state == RFKILL_STATE_UNBLOCKED), 0); | 3493 | return wan_set_radiosw((state == RFKILL_STATE_UNBLOCKED), 0); |
3447 | } | 3494 | } |
3448 | 3495 | ||
@@ -3453,6 +3500,9 @@ static void wan_shutdown(void) | |||
3453 | TP_ACPI_WGSV_SAVE_STATE)) | 3500 | TP_ACPI_WGSV_SAVE_STATE)) |
3454 | printk(TPACPI_NOTICE | 3501 | printk(TPACPI_NOTICE |
3455 | "failed to save WWAN state to NVRAM\n"); | 3502 | "failed to save WWAN state to NVRAM\n"); |
3503 | else | ||
3504 | vdbg_printk(TPACPI_DBG_RFKILL, | ||
3505 | "WWAN state saved to NVRAM\n"); | ||
3456 | } | 3506 | } |
3457 | 3507 | ||
3458 | static void wan_exit(void) | 3508 | static void wan_exit(void) |
@@ -3471,14 +3521,16 @@ static int __init wan_init(struct ibm_init_struct *iibm) | |||
3471 | int res; | 3521 | int res; |
3472 | int status = 0; | 3522 | int status = 0; |
3473 | 3523 | ||
3474 | vdbg_printk(TPACPI_DBG_INIT, "initializing wan subdriver\n"); | 3524 | vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_RFKILL, |
3525 | "initializing wan subdriver\n"); | ||
3475 | 3526 | ||
3476 | TPACPI_ACPIHANDLE_INIT(hkey); | 3527 | TPACPI_ACPIHANDLE_INIT(hkey); |
3477 | 3528 | ||
3478 | tp_features.wan = hkey_handle && | 3529 | tp_features.wan = hkey_handle && |
3479 | acpi_evalf(hkey_handle, &status, "GWAN", "qd"); | 3530 | acpi_evalf(hkey_handle, &status, "GWAN", "qd"); |
3480 | 3531 | ||
3481 | vdbg_printk(TPACPI_DBG_INIT, "wan is %s, status 0x%02x\n", | 3532 | vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_RFKILL, |
3533 | "wan is %s, status 0x%02x\n", | ||
3482 | str_supported(tp_features.wan), | 3534 | str_supported(tp_features.wan), |
3483 | status); | 3535 | status); |
3484 | 3536 | ||
@@ -3493,7 +3545,7 @@ static int __init wan_init(struct ibm_init_struct *iibm) | |||
3493 | !(status & TP_ACPI_WANCARD_HWPRESENT)) { | 3545 | !(status & TP_ACPI_WANCARD_HWPRESENT)) { |
3494 | /* no wan hardware present in system */ | 3546 | /* no wan hardware present in system */ |
3495 | tp_features.wan = 0; | 3547 | tp_features.wan = 0; |
3496 | dbg_printk(TPACPI_DBG_INIT, | 3548 | dbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_RFKILL, |
3497 | "wan hardware not installed\n"); | 3549 | "wan hardware not installed\n"); |
3498 | } | 3550 | } |
3499 | 3551 | ||
@@ -3508,7 +3560,7 @@ static int __init wan_init(struct ibm_init_struct *iibm) | |||
3508 | res = tpacpi_new_rfkill(TPACPI_RFK_WWAN_SW_ID, | 3560 | res = tpacpi_new_rfkill(TPACPI_RFK_WWAN_SW_ID, |
3509 | &tpacpi_wan_rfkill, | 3561 | &tpacpi_wan_rfkill, |
3510 | RFKILL_TYPE_WWAN, | 3562 | RFKILL_TYPE_WWAN, |
3511 | "tpacpi_wwan_sw", | 3563 | TPACPI_RFK_WWAN_SW_NAME, |
3512 | true, | 3564 | true, |
3513 | tpacpi_wan_rfk_set, | 3565 | tpacpi_wan_rfk_set, |
3514 | tpacpi_wan_rfk_get); | 3566 | tpacpi_wan_rfk_get); |
@@ -3526,6 +3578,8 @@ static int wan_read(char *p) | |||
3526 | int len = 0; | 3578 | int len = 0; |
3527 | int status = wan_get_radiosw(); | 3579 | int status = wan_get_radiosw(); |
3528 | 3580 | ||
3581 | tpacpi_disclose_usertask("procfs wan", "read"); | ||
3582 | |||
3529 | if (!tp_features.wan) | 3583 | if (!tp_features.wan) |
3530 | len += sprintf(p + len, "status:\t\tnot supported\n"); | 3584 | len += sprintf(p + len, "status:\t\tnot supported\n"); |
3531 | else { | 3585 | else { |
@@ -3541,19 +3595,27 @@ static int wan_read(char *p) | |||
3541 | static int wan_write(char *buf) | 3595 | static int wan_write(char *buf) |
3542 | { | 3596 | { |
3543 | char *cmd; | 3597 | char *cmd; |
3598 | int state = -1; | ||
3544 | 3599 | ||
3545 | if (!tp_features.wan) | 3600 | if (!tp_features.wan) |
3546 | return -ENODEV; | 3601 | return -ENODEV; |
3547 | 3602 | ||
3548 | while ((cmd = next_cmd(&buf))) { | 3603 | while ((cmd = next_cmd(&buf))) { |
3549 | if (strlencmp(cmd, "enable") == 0) { | 3604 | if (strlencmp(cmd, "enable") == 0) { |
3550 | wan_set_radiosw(1, 1); | 3605 | state = 1; |
3551 | } else if (strlencmp(cmd, "disable") == 0) { | 3606 | } else if (strlencmp(cmd, "disable") == 0) { |
3552 | wan_set_radiosw(0, 1); | 3607 | state = 0; |
3553 | } else | 3608 | } else |
3554 | return -EINVAL; | 3609 | return -EINVAL; |
3555 | } | 3610 | } |
3556 | 3611 | ||
3612 | if (state != -1) { | ||
3613 | tpacpi_disclose_usertask("procfs wan", | ||
3614 | "attempt to %s\n", | ||
3615 | state ? "enable" : "disable"); | ||
3616 | wan_set_radiosw(state, 1); | ||
3617 | } | ||
3618 | |||
3557 | return 0; | 3619 | return 0; |
3558 | } | 3620 | } |
3559 | 3621 | ||
@@ -3576,6 +3638,8 @@ enum { | |||
3576 | TP_ACPI_UWB_RADIOSSW = 0x02, /* UWB radio enabled */ | 3638 | TP_ACPI_UWB_RADIOSSW = 0x02, /* UWB radio enabled */ |
3577 | }; | 3639 | }; |
3578 | 3640 | ||
3641 | #define TPACPI_RFK_UWB_SW_NAME "tpacpi_uwb_sw" | ||
3642 | |||
3579 | static struct rfkill *tpacpi_uwb_rfkill; | 3643 | static struct rfkill *tpacpi_uwb_rfkill; |
3580 | 3644 | ||
3581 | static int uwb_get_radiosw(void) | 3645 | static int uwb_get_radiosw(void) |
@@ -3613,6 +3677,10 @@ static void uwb_update_rfk(void) | |||
3613 | if (status < 0) | 3677 | if (status < 0) |
3614 | return; | 3678 | return; |
3615 | rfkill_force_state(tpacpi_uwb_rfkill, status); | 3679 | rfkill_force_state(tpacpi_uwb_rfkill, status); |
3680 | |||
3681 | vdbg_printk(TPACPI_DBG_RFKILL, | ||
3682 | "forced rfkill state to %d\n", | ||
3683 | status); | ||
3616 | } | 3684 | } |
3617 | 3685 | ||
3618 | static int uwb_set_radiosw(int radio_on, int update_rfk) | 3686 | static int uwb_set_radiosw(int radio_on, int update_rfk) |
@@ -3628,6 +3696,9 @@ static int uwb_set_radiosw(int radio_on, int update_rfk) | |||
3628 | && radio_on) | 3696 | && radio_on) |
3629 | return -EPERM; | 3697 | return -EPERM; |
3630 | 3698 | ||
3699 | vdbg_printk(TPACPI_DBG_RFKILL, | ||
3700 | "will %s UWB\n", radio_on ? "enable" : "disable"); | ||
3701 | |||
3631 | #ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES | 3702 | #ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES |
3632 | if (dbg_uwbemul) { | 3703 | if (dbg_uwbemul) { |
3633 | tpacpi_uwb_emulstate = !!radio_on; | 3704 | tpacpi_uwb_emulstate = !!radio_on; |
@@ -3662,6 +3733,8 @@ static int tpacpi_uwb_rfk_get(void *data, enum rfkill_state *state) | |||
3662 | 3733 | ||
3663 | static int tpacpi_uwb_rfk_set(void *data, enum rfkill_state state) | 3734 | static int tpacpi_uwb_rfk_set(void *data, enum rfkill_state state) |
3664 | { | 3735 | { |
3736 | dbg_printk(TPACPI_DBG_RFKILL, | ||
3737 | "request to change radio state to %d\n", state); | ||
3665 | return uwb_set_radiosw((state == RFKILL_STATE_UNBLOCKED), 0); | 3738 | return uwb_set_radiosw((state == RFKILL_STATE_UNBLOCKED), 0); |
3666 | } | 3739 | } |
3667 | 3740 | ||
@@ -3676,14 +3749,16 @@ static int __init uwb_init(struct ibm_init_struct *iibm) | |||
3676 | int res; | 3749 | int res; |
3677 | int status = 0; | 3750 | int status = 0; |
3678 | 3751 | ||
3679 | vdbg_printk(TPACPI_DBG_INIT, "initializing uwb subdriver\n"); | 3752 | vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_RFKILL, |
3753 | "initializing uwb subdriver\n"); | ||
3680 | 3754 | ||
3681 | TPACPI_ACPIHANDLE_INIT(hkey); | 3755 | TPACPI_ACPIHANDLE_INIT(hkey); |
3682 | 3756 | ||
3683 | tp_features.uwb = hkey_handle && | 3757 | tp_features.uwb = hkey_handle && |
3684 | acpi_evalf(hkey_handle, &status, "GUWB", "qd"); | 3758 | acpi_evalf(hkey_handle, &status, "GUWB", "qd"); |
3685 | 3759 | ||
3686 | vdbg_printk(TPACPI_DBG_INIT, "uwb is %s, status 0x%02x\n", | 3760 | vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_RFKILL, |
3761 | "uwb is %s, status 0x%02x\n", | ||
3687 | str_supported(tp_features.uwb), | 3762 | str_supported(tp_features.uwb), |
3688 | status); | 3763 | status); |
3689 | 3764 | ||
@@ -3708,7 +3783,7 @@ static int __init uwb_init(struct ibm_init_struct *iibm) | |||
3708 | res = tpacpi_new_rfkill(TPACPI_RFK_UWB_SW_ID, | 3783 | res = tpacpi_new_rfkill(TPACPI_RFK_UWB_SW_ID, |
3709 | &tpacpi_uwb_rfkill, | 3784 | &tpacpi_uwb_rfkill, |
3710 | RFKILL_TYPE_UWB, | 3785 | RFKILL_TYPE_UWB, |
3711 | "tpacpi_uwb_sw", | 3786 | TPACPI_RFK_UWB_SW_NAME, |
3712 | false, | 3787 | false, |
3713 | tpacpi_uwb_rfk_set, | 3788 | tpacpi_uwb_rfk_set, |
3714 | tpacpi_uwb_rfk_get); | 3789 | tpacpi_uwb_rfk_get); |