Lines Matching refs:ts

301 static inline void thunderstrike_send_hostcmd_request(struct thunderstrike *ts)  in thunderstrike_send_hostcmd_request()  argument
303 struct thunderstrike_hostcmd_req_report *report = ts->req_report_dmabuf; in thunderstrike_send_hostcmd_request()
304 struct shield_device *shield_dev = &ts->base; in thunderstrike_send_hostcmd_request()
308 ts->req_report_dmabuf, in thunderstrike_send_hostcmd_request()
321 struct thunderstrike *ts = in thunderstrike_hostcmd_req_work_handler() local
326 report = ts->req_report_dmabuf; in thunderstrike_hostcmd_req_work_handler()
328 if (test_and_clear_bit(THUNDERSTRIKE_FW_VERSION_UPDATE, &ts->update_flags)) { in thunderstrike_hostcmd_req_work_handler()
331 thunderstrike_send_hostcmd_request(ts); in thunderstrike_hostcmd_req_work_handler()
334 if (test_and_clear_bit(THUNDERSTRIKE_LED_UPDATE, &ts->update_flags)) { in thunderstrike_hostcmd_req_work_handler()
337 report->led.state = ts->led_value; in thunderstrike_hostcmd_req_work_handler()
338 thunderstrike_send_hostcmd_request(ts); in thunderstrike_hostcmd_req_work_handler()
341 if (test_and_clear_bit(THUNDERSTRIKE_POWER_SUPPLY_STATS_UPDATE, &ts->update_flags)) { in thunderstrike_hostcmd_req_work_handler()
344 thunderstrike_send_hostcmd_request(ts); in thunderstrike_hostcmd_req_work_handler()
348 thunderstrike_send_hostcmd_request(ts); in thunderstrike_hostcmd_req_work_handler()
351 if (test_and_clear_bit(THUNDERSTRIKE_BOARD_INFO_UPDATE, &ts->update_flags)) { in thunderstrike_hostcmd_req_work_handler()
354 thunderstrike_send_hostcmd_request(ts); in thunderstrike_hostcmd_req_work_handler()
357 if (test_and_clear_bit(THUNDERSTRIKE_HAPTICS_UPDATE, &ts->update_flags)) { in thunderstrike_hostcmd_req_work_handler()
362 spin_lock_irqsave(&ts->haptics_update_lock, flags); in thunderstrike_hostcmd_req_work_handler()
363 report->haptics.motors = ts->haptics_val; in thunderstrike_hostcmd_req_work_handler()
364 spin_unlock_irqrestore(&ts->haptics_update_lock, flags); in thunderstrike_hostcmd_req_work_handler()
366 thunderstrike_send_hostcmd_request(ts); in thunderstrike_hostcmd_req_work_handler()
370 static inline void thunderstrike_request_firmware_version(struct thunderstrike *ts) in thunderstrike_request_firmware_version() argument
372 set_bit(THUNDERSTRIKE_FW_VERSION_UPDATE, &ts->update_flags); in thunderstrike_request_firmware_version()
373 schedule_work(&ts->hostcmd_req_work); in thunderstrike_request_firmware_version()
376 static inline void thunderstrike_request_board_info(struct thunderstrike *ts) in thunderstrike_request_board_info() argument
378 set_bit(THUNDERSTRIKE_BOARD_INFO_UPDATE, &ts->update_flags); in thunderstrike_request_board_info()
379 schedule_work(&ts->hostcmd_req_work); in thunderstrike_request_board_info()
383 thunderstrike_update_haptics(struct thunderstrike *ts, in thunderstrike_update_haptics() argument
388 spin_lock_irqsave(&ts->haptics_update_lock, flags); in thunderstrike_update_haptics()
389 ts->haptics_val = *motors; in thunderstrike_update_haptics()
390 spin_unlock_irqrestore(&ts->haptics_update_lock, flags); in thunderstrike_update_haptics()
392 set_bit(THUNDERSTRIKE_HAPTICS_UPDATE, &ts->update_flags); in thunderstrike_update_haptics()
393 schedule_work(&ts->hostcmd_req_work); in thunderstrike_update_haptics()
404 struct thunderstrike *ts; in thunderstrike_play_effect() local
410 ts = container_of(shield_dev, struct thunderstrike, base); in thunderstrike_play_effect()
419 return thunderstrike_update_haptics(ts, &motors); in thunderstrike_play_effect()
427 struct thunderstrike *ts; in thunderstrike_led_get_brightness() local
429 ts = container_of(shield_dev, struct thunderstrike, base); in thunderstrike_led_get_brightness()
431 return ts->led_state; in thunderstrike_led_get_brightness()
439 struct thunderstrike *ts; in thunderstrike_led_set_brightness() local
441 ts = container_of(shield_dev, struct thunderstrike, base); in thunderstrike_led_set_brightness()
445 ts->led_value = THUNDERSTRIKE_LED_OFF; in thunderstrike_led_set_brightness()
448 ts->led_value = THUNDERSTRIKE_LED_ON; in thunderstrike_led_set_brightness()
452 set_bit(THUNDERSTRIKE_LED_UPDATE, &ts->update_flags); in thunderstrike_led_set_brightness()
453 schedule_work(&ts->hostcmd_req_work); in thunderstrike_led_set_brightness()
462 struct thunderstrike *ts; in thunderstrike_battery_get_property() local
465 ts = container_of(shield_dev, struct thunderstrike, base); in thunderstrike_battery_get_property()
466 spin_lock(&ts->psy_stats_lock); in thunderstrike_battery_get_property()
467 prop_values = ts->psy_stats; in thunderstrike_battery_get_property()
468 spin_unlock(&ts->psy_stats_lock); in thunderstrike_battery_get_property()
527 static inline void thunderstrike_request_psy_stats(struct thunderstrike *ts) in thunderstrike_request_psy_stats() argument
529 set_bit(THUNDERSTRIKE_POWER_SUPPLY_STATS_UPDATE, &ts->update_flags); in thunderstrike_request_psy_stats()
530 schedule_work(&ts->hostcmd_req_work); in thunderstrike_request_psy_stats()
535 struct thunderstrike *ts = in thunderstrike_psy_stats_timer_handler() local
538 thunderstrike_request_psy_stats(ts); in thunderstrike_psy_stats_timer_handler()
593 struct thunderstrike *ts = container_of(shield_dev, struct thunderstrike, base); in thunderstrike_parse_led_payload() local
597 ts->led_state = 0; in thunderstrike_parse_led_payload()
600 ts->led_state = 1; in thunderstrike_parse_led_payload()
611 struct thunderstrike *ts = container_of(shield_dev, struct thunderstrike, base); in thunderstrike_parse_battery_payload() local
630 spin_lock(&ts->psy_stats_lock); in thunderstrike_parse_battery_payload()
631 ts->psy_stats.voltage_boot = voltage_boot; in thunderstrike_parse_battery_payload()
632 ts->psy_stats.voltage_avg = voltage_avg; in thunderstrike_parse_battery_payload()
633 ts->psy_stats.voltage_min = voltage_min; in thunderstrike_parse_battery_payload()
634 ts->psy_stats.voltage_now = voltage_now; in thunderstrike_parse_battery_payload()
635 ts->psy_stats.capacity = capacity; in thunderstrike_parse_battery_payload()
636 ts->psy_stats.temp = temp; in thunderstrike_parse_battery_payload()
637 spin_unlock(&ts->psy_stats_lock); in thunderstrike_parse_battery_payload()
659 struct thunderstrike *ts = container_of(shield_dev, struct thunderstrike, base); in thunderstrike_parse_charger_payload() local
706 spin_lock(&ts->psy_stats_lock); in thunderstrike_parse_charger_payload()
707 ts->psy_stats.charge_type = charge_type; in thunderstrike_parse_charger_payload()
708 ts->psy_stats.status = status; in thunderstrike_parse_charger_payload()
709 spin_unlock(&ts->psy_stats_lock); in thunderstrike_parse_charger_payload()
720 struct thunderstrike *ts = in thunderstrike_device_init_info() local
724 thunderstrike_request_firmware_version(ts); in thunderstrike_device_init_info()
727 thunderstrike_request_board_info(ts); in thunderstrike_device_init_info()
731 thunderstrike_psy_stats_timer_handler(&ts->psy_stats_timer); in thunderstrike_device_init_info()
799 static inline int thunderstrike_led_create(struct thunderstrike *ts) in thunderstrike_led_create() argument
801 struct led_classdev *led = &ts->led_dev; in thunderstrike_led_create()
803 led->name = devm_kasprintf(&ts->base.hdev->dev, GFP_KERNEL, in thunderstrike_led_create()
804 "thunderstrike%d:blue:led", ts->id); in thunderstrike_led_create()
812 return led_classdev_register(&ts->base.hdev->dev, led); in thunderstrike_led_create()
817 struct thunderstrike *ts = container_of(shield_dev, struct thunderstrike, base); in thunderstrike_psy_create() local
827 ts->psy_stats.capacity = 100; in thunderstrike_psy_create()
828 ts->psy_stats.temp = 182; in thunderstrike_psy_create()
836 devm_kasprintf(&ts->base.hdev->dev, GFP_KERNEL, in thunderstrike_psy_create()
837 "thunderstrike_%d", ts->id); in thunderstrike_psy_create()
864 struct thunderstrike *ts; in thunderstrike_create() local
867 ts = devm_kzalloc(&hdev->dev, sizeof(*ts), GFP_KERNEL); in thunderstrike_create()
868 if (!ts) in thunderstrike_create()
871 ts->req_report_dmabuf = devm_kzalloc( in thunderstrike_create()
873 if (!ts->req_report_dmabuf) in thunderstrike_create()
876 shield_dev = &ts->base; in thunderstrike_create()
880 spin_lock_init(&ts->haptics_update_lock); in thunderstrike_create()
881 spin_lock_init(&ts->psy_stats_lock); in thunderstrike_create()
882 INIT_WORK(&ts->hostcmd_req_work, thunderstrike_hostcmd_req_work_handler); in thunderstrike_create()
886 ts->id = ida_alloc(&thunderstrike_ida, GFP_KERNEL); in thunderstrike_create()
887 if (ts->id < 0) in thunderstrike_create()
888 return ERR_PTR(ts->id); in thunderstrike_create()
890 ts->haptics_dev = shield_haptics_create(shield_dev, thunderstrike_play_effect); in thunderstrike_create()
891 if (IS_ERR(ts->haptics_dev)) { in thunderstrike_create()
893 ret = PTR_ERR(ts->haptics_dev); in thunderstrike_create()
903 ret = thunderstrike_led_create(ts); in thunderstrike_create()
909 timer_setup(&ts->psy_stats_timer, thunderstrike_psy_stats_timer_handler, 0); in thunderstrike_create()
917 if (ts->haptics_dev) in thunderstrike_create()
918 input_unregister_device(ts->haptics_dev); in thunderstrike_create()
920 ida_free(&thunderstrike_ida, ts->id); in thunderstrike_create()
1038 struct thunderstrike *ts; in shield_probe() local
1062 ts = container_of(shield_dev, struct thunderstrike, base); in shield_probe()
1083 power_supply_unregister(ts->base.battery_dev.psy); in shield_probe()
1084 if (ts->haptics_dev) in shield_probe()
1085 input_unregister_device(ts->haptics_dev); in shield_probe()
1086 led_classdev_unregister(&ts->led_dev); in shield_probe()
1087 ida_free(&thunderstrike_ida, ts->id); in shield_probe()
1094 struct thunderstrike *ts; in shield_remove() local
1096 ts = container_of(dev, struct thunderstrike, base); in shield_remove()
1100 if (ts->haptics_dev) in shield_remove()
1101 input_unregister_device(ts->haptics_dev); in shield_remove()
1102 led_classdev_unregister(&ts->led_dev); in shield_remove()
1103 ida_free(&thunderstrike_ida, ts->id); in shield_remove()
1104 del_timer_sync(&ts->psy_stats_timer); in shield_remove()
1105 cancel_work_sync(&ts->hostcmd_req_work); in shield_remove()