Lines Matching refs:rmi_dev

38 void rmi_free_function_list(struct rmi_device *rmi_dev)  in rmi_free_function_list()  argument
41 struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev); in rmi_free_function_list()
43 rmi_dbg(RMI_DEBUG_CORE, &rmi_dev->dev, "Freeing function list\n"); in rmi_free_function_list()
52 devm_kfree(&rmi_dev->dev, data->irq_memory); in rmi_free_function_list()
101 static int rmi_driver_process_reset_requests(struct rmi_device *rmi_dev) in rmi_driver_process_reset_requests() argument
103 struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev); in rmi_driver_process_reset_requests()
116 static int rmi_driver_process_config_requests(struct rmi_device *rmi_dev) in rmi_driver_process_config_requests() argument
118 struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev); in rmi_driver_process_config_requests()
131 static int rmi_process_interrupt_requests(struct rmi_device *rmi_dev) in rmi_process_interrupt_requests() argument
133 struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev); in rmi_process_interrupt_requests()
134 struct device *dev = &rmi_dev->dev; in rmi_process_interrupt_requests()
142 error = rmi_read_block(rmi_dev, in rmi_process_interrupt_requests()
169 void rmi_set_attn_data(struct rmi_device *rmi_dev, unsigned long irq_status, in rmi_set_attn_data() argument
172 struct rmi_driver_data *drvdata = dev_get_drvdata(&rmi_dev->dev); in rmi_set_attn_data()
193 struct rmi_device *rmi_dev = dev_id; in rmi_irq_fn() local
194 struct rmi_driver_data *drvdata = dev_get_drvdata(&rmi_dev->dev); in rmi_irq_fn()
204 ret = rmi_process_interrupt_requests(rmi_dev); in rmi_irq_fn()
206 rmi_dbg(RMI_DEBUG_CORE, &rmi_dev->dev, in rmi_irq_fn()
220 static int rmi_irq_init(struct rmi_device *rmi_dev) in rmi_irq_init() argument
222 struct rmi_device_platform_data *pdata = rmi_get_platform_data(rmi_dev); in rmi_irq_init()
223 struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev); in rmi_irq_init()
230 ret = devm_request_threaded_irq(&rmi_dev->dev, pdata->irq, NULL, in rmi_irq_init()
232 dev_driver_string(rmi_dev->xport->dev), in rmi_irq_init()
233 rmi_dev); in rmi_irq_init()
235 dev_err(&rmi_dev->dev, "Failed to register interrupt %d\n", in rmi_irq_init()
246 struct rmi_function *rmi_find_function(struct rmi_device *rmi_dev, u8 number) in rmi_find_function() argument
248 struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev); in rmi_find_function()
278 static int rmi_suspend_functions(struct rmi_device *rmi_dev) in rmi_suspend_functions() argument
280 struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev); in rmi_suspend_functions()
312 static int rmi_resume_functions(struct rmi_device *rmi_dev) in rmi_resume_functions() argument
314 struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev); in rmi_resume_functions()
327 int rmi_enable_sensor(struct rmi_device *rmi_dev) in rmi_enable_sensor() argument
331 retval = rmi_driver_process_config_requests(rmi_dev); in rmi_enable_sensor()
335 return rmi_process_interrupt_requests(rmi_dev); in rmi_enable_sensor()
345 static int rmi_driver_set_input_params(struct rmi_device *rmi_dev, in rmi_driver_set_input_params() argument
354 static void rmi_driver_set_input_name(struct rmi_device *rmi_dev, in rmi_driver_set_input_name() argument
357 struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev); in rmi_driver_set_input_name()
361 name = devm_kasprintf(&rmi_dev->dev, GFP_KERNEL, in rmi_driver_set_input_name()
369 static int rmi_driver_set_irq_bits(struct rmi_device *rmi_dev, in rmi_driver_set_irq_bits() argument
373 struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev); in rmi_driver_set_irq_bits()
374 struct device *dev = &rmi_dev->dev; in rmi_driver_set_irq_bits()
380 error = rmi_write_block(rmi_dev, in rmi_driver_set_irq_bits()
396 static int rmi_driver_clear_irq_bits(struct rmi_device *rmi_dev, in rmi_driver_clear_irq_bits() argument
400 struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev); in rmi_driver_clear_irq_bits()
401 struct device *dev = &rmi_dev->dev; in rmi_driver_clear_irq_bits()
407 error = rmi_write_block(rmi_dev, in rmi_driver_clear_irq_bits()
423 static int rmi_driver_reset_handler(struct rmi_device *rmi_dev) in rmi_driver_reset_handler() argument
425 struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev); in rmi_driver_reset_handler()
433 dev_warn(&rmi_dev->dev, in rmi_driver_reset_handler()
438 error = rmi_read_block(rmi_dev, in rmi_driver_reset_handler()
442 dev_err(&rmi_dev->dev, "%s: Failed to read current IRQ mask.\n", in rmi_driver_reset_handler()
447 error = rmi_driver_process_reset_requests(rmi_dev); in rmi_driver_reset_handler()
451 error = rmi_driver_process_config_requests(rmi_dev); in rmi_driver_reset_handler()
458 static int rmi_read_pdt_entry(struct rmi_device *rmi_dev, in rmi_read_pdt_entry() argument
464 error = rmi_read_block(rmi_dev, pdt_address, buf, RMI_PDT_ENTRY_SIZE); in rmi_read_pdt_entry()
466 dev_err(&rmi_dev->dev, "Read PDT entry at %#06x failed, code: %d.\n", in rmi_read_pdt_entry()
498 static int rmi_scan_pdt_page(struct rmi_device *rmi_dev, in rmi_scan_pdt_page() argument
502 int (*callback)(struct rmi_device *rmi_dev, in rmi_scan_pdt_page() argument
506 struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev); in rmi_scan_pdt_page()
516 error = rmi_read_pdt_entry(rmi_dev, &pdt_entry, addr); in rmi_scan_pdt_page()
523 retval = callback(rmi_dev, ctx, &pdt_entry); in rmi_scan_pdt_page()
541 int rmi_scan_pdt(struct rmi_device *rmi_dev, void *ctx, in rmi_scan_pdt() argument
542 int (*callback)(struct rmi_device *rmi_dev, in rmi_scan_pdt() argument
550 retval = rmi_scan_pdt_page(rmi_dev, page, &empty_pages, in rmi_scan_pdt()
743 static int rmi_check_bootloader_mode(struct rmi_device *rmi_dev, in rmi_check_bootloader_mode() argument
746 struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev); in rmi_check_bootloader_mode()
751 ret = rmi_read(rmi_dev, pdt->data_base_addr, &status); in rmi_check_bootloader_mode()
753 dev_err(&rmi_dev->dev, in rmi_check_bootloader_mode()
761 ret = rmi_read(rmi_dev, pdt->data_base_addr, &status); in rmi_check_bootloader_mode()
763 dev_err(&rmi_dev->dev, in rmi_check_bootloader_mode()
775 static int rmi_count_irqs(struct rmi_device *rmi_dev, in rmi_count_irqs() argument
783 ret = rmi_check_bootloader_mode(rmi_dev, pdt); in rmi_count_irqs()
790 int rmi_initial_reset(struct rmi_device *rmi_dev, void *ctx, in rmi_initial_reset() argument
799 rmi_get_platform_data(rmi_dev); in rmi_initial_reset()
801 if (rmi_dev->xport->ops->reset) { in rmi_initial_reset()
802 error = rmi_dev->xport->ops->reset(rmi_dev->xport, in rmi_initial_reset()
810 rmi_dbg(RMI_DEBUG_CORE, &rmi_dev->dev, "Sending reset\n"); in rmi_initial_reset()
811 error = rmi_write_block(rmi_dev, cmd_addr, &cmd_buf, 1); in rmi_initial_reset()
813 dev_err(&rmi_dev->dev, in rmi_initial_reset()
827 static int rmi_create_function(struct rmi_device *rmi_dev, in rmi_create_function() argument
830 struct device *dev = &rmi_dev->dev; in rmi_create_function()
852 fn->rmi_dev = rmi_dev; in rmi_create_function()
879 void rmi_enable_irq(struct rmi_device *rmi_dev, bool clear_wake) in rmi_enable_irq() argument
881 struct rmi_device_platform_data *pdata = rmi_get_platform_data(rmi_dev); in rmi_enable_irq()
882 struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev); in rmi_enable_irq()
894 if (clear_wake && device_may_wakeup(rmi_dev->xport->dev)) { in rmi_enable_irq()
897 dev_warn(&rmi_dev->dev, in rmi_enable_irq()
908 rmi_process_interrupt_requests(rmi_dev); in rmi_enable_irq()
914 void rmi_disable_irq(struct rmi_device *rmi_dev, bool enable_wake) in rmi_disable_irq() argument
916 struct rmi_device_platform_data *pdata = rmi_get_platform_data(rmi_dev); in rmi_disable_irq()
917 struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev); in rmi_disable_irq()
929 if (enable_wake && device_may_wakeup(rmi_dev->xport->dev)) { in rmi_disable_irq()
932 dev_warn(&rmi_dev->dev, in rmi_disable_irq()
948 int rmi_driver_suspend(struct rmi_device *rmi_dev, bool enable_wake) in rmi_driver_suspend() argument
952 retval = rmi_suspend_functions(rmi_dev); in rmi_driver_suspend()
954 dev_warn(&rmi_dev->dev, "Failed to suspend functions: %d\n", in rmi_driver_suspend()
957 rmi_disable_irq(rmi_dev, enable_wake); in rmi_driver_suspend()
962 int rmi_driver_resume(struct rmi_device *rmi_dev, bool clear_wake) in rmi_driver_resume() argument
966 rmi_enable_irq(rmi_dev, clear_wake); in rmi_driver_resume()
968 retval = rmi_resume_functions(rmi_dev); in rmi_driver_resume()
970 dev_warn(&rmi_dev->dev, "Failed to suspend functions: %d\n", in rmi_driver_resume()
979 struct rmi_device *rmi_dev = to_rmi_device(dev); in rmi_driver_remove() local
980 struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev); in rmi_driver_remove()
982 rmi_disable_irq(rmi_dev, false); in rmi_driver_remove()
987 rmi_f34_remove_sysfs(rmi_dev); in rmi_driver_remove()
988 rmi_free_function_list(rmi_dev); in rmi_driver_remove()
1016 struct rmi_device *rmi_dev = data->rmi_dev; in rmi_probe_interrupts() local
1017 struct device *dev = &rmi_dev->dev; in rmi_probe_interrupts()
1018 struct fwnode_handle *fwnode = rmi_dev->xport->dev->fwnode; in rmi_probe_interrupts()
1032 retval = rmi_scan_pdt(rmi_dev, &irq_count, rmi_count_irqs); in rmi_probe_interrupts()
1046 dev_err(&rmi_dev->dev, "Failed to create IRQ domain\n"); in rmi_probe_interrupts()
1070 struct rmi_device *rmi_dev = data->rmi_dev; in rmi_init_functions() local
1071 struct device *dev = &rmi_dev->dev; in rmi_init_functions()
1076 retval = rmi_scan_pdt(rmi_dev, &irq_count, rmi_create_function); in rmi_init_functions()
1089 retval = rmi_read_block(rmi_dev, in rmi_init_functions()
1101 rmi_free_function_list(rmi_dev); in rmi_init_functions()
1110 struct rmi_device *rmi_dev; in rmi_driver_probe() local
1121 rmi_dev = to_rmi_device(dev); in rmi_driver_probe()
1123 rmi_dev->driver = rmi_driver; in rmi_driver_probe()
1125 pdata = rmi_get_platform_data(rmi_dev); in rmi_driver_probe()
1127 if (rmi_dev->xport->dev->of_node) { in rmi_driver_probe()
1128 retval = rmi_driver_of_probe(rmi_dev->xport->dev, pdata); in rmi_driver_probe()
1138 data->rmi_dev = rmi_dev; in rmi_driver_probe()
1139 dev_set_drvdata(&rmi_dev->dev, data); in rmi_driver_probe()
1162 retval = rmi_scan_pdt(rmi_dev, NULL, rmi_initial_reset); in rmi_driver_probe()
1166 retval = rmi_read(rmi_dev, PDT_PROPERTIES_LOCATION, &data->pdt_props); in rmi_driver_probe()
1183 if (rmi_dev->xport->input) { in rmi_driver_probe()
1191 data->input = rmi_dev->xport->input; in rmi_driver_probe()
1200 rmi_driver_set_input_params(rmi_dev, data->input); in rmi_driver_probe()
1209 retval = rmi_f34_create_sysfs(rmi_dev); in rmi_driver_probe()
1214 rmi_driver_set_input_name(rmi_dev, data->input); in rmi_driver_probe()
1215 if (!rmi_dev->xport->input) { in rmi_driver_probe()
1224 retval = rmi_irq_init(rmi_dev); in rmi_driver_probe()
1230 retval = rmi_enable_sensor(rmi_dev); in rmi_driver_probe()
1238 rmi_disable_irq(rmi_dev, false); in rmi_driver_probe()
1240 rmi_free_function_list(rmi_dev); in rmi_driver_probe()