diff options
author | Trepák Vilmos <trepo@netcomga.sk> | 2012-10-11 06:51:00 -0400 |
---|---|---|
committer | Matthew Garrett <matthew.garrett@nebula.com> | 2013-02-24 17:49:56 -0500 |
commit | 4fca7ce39f57517a31c911d8f66931355a39457e (patch) | |
tree | 85f3f60be3ffe097a280c78848c4f4eeffb0ceda /drivers/platform/x86 | |
parent | 5f3511d2a61e7874730d3ccc1a32d418259133be (diff) |
Platform: hp-wmi: add rfkill support for integrated GPS
Add rfkill support for the GPS radio found in HP laptops (HP Elitebook 2170p and the like)
using the Ericsson F5321/H5321 Mobile Broadband Module.
Signed-off-by: Viliam Trepák <trepo@netcomga.sk>
Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>
Diffstat (limited to 'drivers/platform/x86')
-rw-r--r-- | drivers/platform/x86/hp-wmi.c | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c index 1dde7accf27c..2179c03b94de 100644 --- a/drivers/platform/x86/hp-wmi.c +++ b/drivers/platform/x86/hp-wmi.c | |||
@@ -60,6 +60,7 @@ enum hp_wmi_radio { | |||
60 | HPWMI_WIFI = 0, | 60 | HPWMI_WIFI = 0, |
61 | HPWMI_BLUETOOTH = 1, | 61 | HPWMI_BLUETOOTH = 1, |
62 | HPWMI_WWAN = 2, | 62 | HPWMI_WWAN = 2, |
63 | HPWMI_GPS = 3, | ||
63 | }; | 64 | }; |
64 | 65 | ||
65 | enum hp_wmi_event_ids { | 66 | enum hp_wmi_event_ids { |
@@ -147,6 +148,7 @@ static struct platform_device *hp_wmi_platform_dev; | |||
147 | static struct rfkill *wifi_rfkill; | 148 | static struct rfkill *wifi_rfkill; |
148 | static struct rfkill *bluetooth_rfkill; | 149 | static struct rfkill *bluetooth_rfkill; |
149 | static struct rfkill *wwan_rfkill; | 150 | static struct rfkill *wwan_rfkill; |
151 | static struct rfkill *gps_rfkill; | ||
150 | 152 | ||
151 | struct rfkill2_device { | 153 | struct rfkill2_device { |
152 | u8 id; | 154 | u8 id; |
@@ -543,6 +545,10 @@ static void hp_wmi_notify(u32 value, void *context) | |||
543 | rfkill_set_states(wwan_rfkill, | 545 | rfkill_set_states(wwan_rfkill, |
544 | hp_wmi_get_sw_state(HPWMI_WWAN), | 546 | hp_wmi_get_sw_state(HPWMI_WWAN), |
545 | hp_wmi_get_hw_state(HPWMI_WWAN)); | 547 | hp_wmi_get_hw_state(HPWMI_WWAN)); |
548 | if (gps_rfkill) | ||
549 | rfkill_set_states(gps_rfkill, | ||
550 | hp_wmi_get_sw_state(HPWMI_GPS), | ||
551 | hp_wmi_get_hw_state(HPWMI_GPS)); | ||
546 | break; | 552 | break; |
547 | case HPWMI_CPU_BATTERY_THROTTLE: | 553 | case HPWMI_CPU_BATTERY_THROTTLE: |
548 | pr_info("Unimplemented CPU throttle because of 3 Cell battery event detected\n"); | 554 | pr_info("Unimplemented CPU throttle because of 3 Cell battery event detected\n"); |
@@ -670,7 +676,7 @@ static int hp_wmi_rfkill_setup(struct platform_device *device) | |||
670 | (void *) HPWMI_WWAN); | 676 | (void *) HPWMI_WWAN); |
671 | if (!wwan_rfkill) { | 677 | if (!wwan_rfkill) { |
672 | err = -ENOMEM; | 678 | err = -ENOMEM; |
673 | goto register_bluetooth_error; | 679 | goto register_gps_error; |
674 | } | 680 | } |
675 | rfkill_init_sw_state(wwan_rfkill, | 681 | rfkill_init_sw_state(wwan_rfkill, |
676 | hp_wmi_get_sw_state(HPWMI_WWAN)); | 682 | hp_wmi_get_sw_state(HPWMI_WWAN)); |
@@ -681,10 +687,33 @@ static int hp_wmi_rfkill_setup(struct platform_device *device) | |||
681 | goto register_wwan_err; | 687 | goto register_wwan_err; |
682 | } | 688 | } |
683 | 689 | ||
690 | if (wireless & 0x8) { | ||
691 | gps_rfkill = rfkill_alloc("hp-gps", &device->dev, | ||
692 | RFKILL_TYPE_GPS, | ||
693 | &hp_wmi_rfkill_ops, | ||
694 | (void *) HPWMI_GPS); | ||
695 | if (!gps_rfkill) { | ||
696 | err = -ENOMEM; | ||
697 | goto register_bluetooth_error; | ||
698 | } | ||
699 | rfkill_init_sw_state(gps_rfkill, | ||
700 | hp_wmi_get_sw_state(HPWMI_GPS)); | ||
701 | rfkill_set_hw_state(bluetooth_rfkill, | ||
702 | hp_wmi_get_hw_state(HPWMI_GPS)); | ||
703 | err = rfkill_register(gps_rfkill); | ||
704 | if (err) | ||
705 | goto register_gps_error; | ||
706 | } | ||
707 | |||
684 | return 0; | 708 | return 0; |
685 | register_wwan_err: | 709 | register_wwan_err: |
686 | rfkill_destroy(wwan_rfkill); | 710 | rfkill_destroy(wwan_rfkill); |
687 | wwan_rfkill = NULL; | 711 | wwan_rfkill = NULL; |
712 | if (gps_rfkill) | ||
713 | rfkill_unregister(gps_rfkill); | ||
714 | register_gps_error: | ||
715 | rfkill_destroy(gps_rfkill); | ||
716 | gps_rfkill = NULL; | ||
688 | if (bluetooth_rfkill) | 717 | if (bluetooth_rfkill) |
689 | rfkill_unregister(bluetooth_rfkill); | 718 | rfkill_unregister(bluetooth_rfkill); |
690 | register_bluetooth_error: | 719 | register_bluetooth_error: |
@@ -729,6 +758,10 @@ static int hp_wmi_rfkill2_setup(struct platform_device *device) | |||
729 | type = RFKILL_TYPE_WWAN; | 758 | type = RFKILL_TYPE_WWAN; |
730 | name = "hp-wwan"; | 759 | name = "hp-wwan"; |
731 | break; | 760 | break; |
761 | case HPWMI_GPS: | ||
762 | type = RFKILL_TYPE_GPS; | ||
763 | name = "hp-gps"; | ||
764 | break; | ||
732 | default: | 765 | default: |
733 | pr_warn("unknown device type 0x%x\n", | 766 | pr_warn("unknown device type 0x%x\n", |
734 | state.device[i].radio_type); | 767 | state.device[i].radio_type); |
@@ -786,6 +819,7 @@ static int hp_wmi_bios_setup(struct platform_device *device) | |||
786 | wifi_rfkill = NULL; | 819 | wifi_rfkill = NULL; |
787 | bluetooth_rfkill = NULL; | 820 | bluetooth_rfkill = NULL; |
788 | wwan_rfkill = NULL; | 821 | wwan_rfkill = NULL; |
822 | gps_rfkill = NULL; | ||
789 | rfkill2_count = 0; | 823 | rfkill2_count = 0; |
790 | 824 | ||
791 | if (hp_wmi_rfkill_setup(device)) | 825 | if (hp_wmi_rfkill_setup(device)) |
@@ -835,6 +869,10 @@ static int __exit hp_wmi_bios_remove(struct platform_device *device) | |||
835 | rfkill_unregister(wwan_rfkill); | 869 | rfkill_unregister(wwan_rfkill); |
836 | rfkill_destroy(wwan_rfkill); | 870 | rfkill_destroy(wwan_rfkill); |
837 | } | 871 | } |
872 | if (gps_rfkill) { | ||
873 | rfkill_unregister(gps_rfkill); | ||
874 | rfkill_destroy(gps_rfkill); | ||
875 | } | ||
838 | 876 | ||
839 | return 0; | 877 | return 0; |
840 | } | 878 | } |
@@ -870,6 +908,10 @@ static int hp_wmi_resume_handler(struct device *device) | |||
870 | rfkill_set_states(wwan_rfkill, | 908 | rfkill_set_states(wwan_rfkill, |
871 | hp_wmi_get_sw_state(HPWMI_WWAN), | 909 | hp_wmi_get_sw_state(HPWMI_WWAN), |
872 | hp_wmi_get_hw_state(HPWMI_WWAN)); | 910 | hp_wmi_get_hw_state(HPWMI_WWAN)); |
911 | if (gps_rfkill) | ||
912 | rfkill_set_states(gps_rfkill, | ||
913 | hp_wmi_get_sw_state(HPWMI_GPS), | ||
914 | hp_wmi_get_hw_state(HPWMI_GPS)); | ||
873 | 915 | ||
874 | return 0; | 916 | return 0; |
875 | } | 917 | } |