Lines Matching +full:gpio +full:- +full:ctrl3

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2012-2016 Synaptics Incorporated
89 error = rmi_read_block(fn->rmi_dev, fn->fd.control_base_addr, in rmi_f30_read_control_parameters()
90 f30->ctrl_regs, f30->ctrl_regs_size); in rmi_f30_read_control_parameters()
92 dev_err(&fn->dev, in rmi_f30_read_control_parameters()
94 __func__, fn->fd.control_base_addr, error); in rmi_f30_read_control_parameters()
106 u16 key_code = f30->gpioled_key_map[button]; in rmi_f30_report_button()
107 bool key_down = !(f30->data_regs[reg_num] & BIT(bit_num)); in rmi_f30_report_button()
109 if (f30->trackstick_buttons && in rmi_f30_report_button()
112 rmi_f03_overwrite_button(f30->f03, key_code, key_down); in rmi_f30_report_button()
114 rmi_dbg(RMI_DEBUG_FN, &fn->dev, in rmi_f30_report_button()
118 input_report_key(f30->input, key_code, key_down); in rmi_f30_report_button()
125 struct f30_data *f30 = dev_get_drvdata(&fn->dev); in rmi_f30_attention()
126 struct rmi_driver_data *drvdata = dev_get_drvdata(&fn->rmi_dev->dev); in rmi_f30_attention()
131 if (drvdata->attn_data.data) { in rmi_f30_attention()
132 if (drvdata->attn_data.size < f30->register_count) { in rmi_f30_attention()
133 dev_warn(&fn->dev, in rmi_f30_attention()
137 memcpy(f30->data_regs, drvdata->attn_data.data, in rmi_f30_attention()
138 f30->register_count); in rmi_f30_attention()
139 drvdata->attn_data.data += f30->register_count; in rmi_f30_attention()
140 drvdata->attn_data.size -= f30->register_count; in rmi_f30_attention()
142 error = rmi_read_block(fn->rmi_dev, fn->fd.data_base_addr, in rmi_f30_attention()
143 f30->data_regs, f30->register_count); in rmi_f30_attention()
145 dev_err(&fn->dev, in rmi_f30_attention()
152 if (f30->has_gpio) { in rmi_f30_attention()
153 for (i = 0; i < f30->gpioled_count; i++) in rmi_f30_attention()
154 if (f30->gpioled_key_map[i] != KEY_RESERVED) in rmi_f30_attention()
156 if (f30->trackstick_buttons) in rmi_f30_attention()
157 rmi_f03_commit_buttons(f30->f03); in rmi_f30_attention()
165 struct f30_data *f30 = dev_get_drvdata(&fn->dev); in rmi_f30_config()
166 struct rmi_driver *drv = fn->rmi_dev->driver; in rmi_f30_config()
168 rmi_get_platform_data(fn->rmi_dev); in rmi_f30_config()
175 if (pdata->gpio_data.trackstick_buttons) { in rmi_f30_config()
176 /* Try [re-]establish link to F03. */ in rmi_f30_config()
177 f30->f03 = rmi_find_function(fn->rmi_dev, 0x03); in rmi_f30_config()
178 f30->trackstick_buttons = f30->f03 != NULL; in rmi_f30_config()
181 if (pdata->gpio_data.disable) { in rmi_f30_config()
182 drv->clear_irq_bits(fn->rmi_dev, fn->irq_mask); in rmi_f30_config()
185 error = rmi_write_block(fn->rmi_dev, fn->fd.control_base_addr, in rmi_f30_config()
186 f30->ctrl_regs, f30->ctrl_regs_size); in rmi_f30_config()
188 dev_err(&fn->dev, in rmi_f30_config()
190 __func__, fn->fd.control_base_addr, error); in rmi_f30_config()
194 drv->set_irq_bits(fn->rmi_dev, fn->irq_mask); in rmi_f30_config()
203 ctrl->address = *ctrl_addr; in rmi_f30_set_ctrl_data()
204 ctrl->length = len; in rmi_f30_set_ctrl_data()
205 ctrl->regs = *reg; in rmi_f30_set_ctrl_data()
216 * ctrl2 -> dir == 0 -> input mode in rmi_f30_is_valid_button()
217 * ctrl3 -> data == 1 -> actual button in rmi_f30_is_valid_button()
227 rmi_get_platform_data(fn->rmi_dev); in rmi_f30_map_gpios()
228 struct input_dev *input = f30->input; in rmi_f30_map_gpios()
233 int button_count = min_t(u8, f30->gpioled_count, TRACKSTICK_RANGE_END); in rmi_f30_map_gpios()
235 f30->gpioled_key_map = devm_kcalloc(&fn->dev, in rmi_f30_map_gpios()
237 sizeof(f30->gpioled_key_map[0]), in rmi_f30_map_gpios()
239 if (!f30->gpioled_key_map) { in rmi_f30_map_gpios()
240 dev_err(&fn->dev, "Failed to allocate gpioled map memory.\n"); in rmi_f30_map_gpios()
241 return -ENOMEM; in rmi_f30_map_gpios()
245 if (!rmi_f30_is_valid_button(i, f30->ctrl)) in rmi_f30_map_gpios()
248 if (pdata->gpio_data.trackstick_buttons && in rmi_f30_map_gpios()
250 f30->gpioled_key_map[i] = trackstick_button++; in rmi_f30_map_gpios()
251 } else if (!pdata->gpio_data.buttonpad || !button_mapped) { in rmi_f30_map_gpios()
252 f30->gpioled_key_map[i] = button; in rmi_f30_map_gpios()
258 input->keycode = f30->gpioled_key_map; in rmi_f30_map_gpios()
259 input->keycodesize = sizeof(f30->gpioled_key_map[0]); in rmi_f30_map_gpios()
260 input->keycodemax = f30->gpioled_count; in rmi_f30_map_gpios()
263 * Buttonpad could be also inferred from f30->has_mech_mouse_btns, in rmi_f30_map_gpios()
267 if (pdata->gpio_data.buttonpad || (button - BTN_LEFT == 1)) in rmi_f30_map_gpios()
268 __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); in rmi_f30_map_gpios()
275 u8 *ctrl_reg = f30->ctrl_regs; in rmi_f30_initialize()
276 int control_address = fn->fd.control_base_addr; in rmi_f30_initialize()
280 error = rmi_read_block(fn->rmi_dev, fn->fd.query_base_addr, in rmi_f30_initialize()
283 dev_err(&fn->dev, "Failed to read query register\n"); in rmi_f30_initialize()
287 f30->has_extended_pattern = buf[0] & RMI_F30_EXTENDED_PATTERNS; in rmi_f30_initialize()
288 f30->has_mappable_buttons = buf[0] & RMI_F30_HAS_MAPPABLE_BUTTONS; in rmi_f30_initialize()
289 f30->has_led = buf[0] & RMI_F30_HAS_LED; in rmi_f30_initialize()
290 f30->has_gpio = buf[0] & RMI_F30_HAS_GPIO; in rmi_f30_initialize()
291 f30->has_haptic = buf[0] & RMI_F30_HAS_HAPTIC; in rmi_f30_initialize()
292 f30->has_gpio_driver_control = buf[0] & RMI_F30_HAS_GPIO_DRV_CTL; in rmi_f30_initialize()
293 f30->has_mech_mouse_btns = buf[0] & RMI_F30_HAS_MECH_MOUSE_BTNS; in rmi_f30_initialize()
294 f30->gpioled_count = buf[1] & RMI_F30_GPIO_LED_COUNT; in rmi_f30_initialize()
296 f30->register_count = DIV_ROUND_UP(f30->gpioled_count, 8); in rmi_f30_initialize()
298 if (f30->has_gpio && f30->has_led) in rmi_f30_initialize()
299 rmi_f30_set_ctrl_data(&f30->ctrl[0], &control_address, in rmi_f30_initialize()
300 f30->register_count, &ctrl_reg); in rmi_f30_initialize()
302 rmi_f30_set_ctrl_data(&f30->ctrl[1], &control_address, in rmi_f30_initialize()
305 if (f30->has_gpio) { in rmi_f30_initialize()
306 rmi_f30_set_ctrl_data(&f30->ctrl[2], &control_address, in rmi_f30_initialize()
307 f30->register_count, &ctrl_reg); in rmi_f30_initialize()
309 rmi_f30_set_ctrl_data(&f30->ctrl[3], &control_address, in rmi_f30_initialize()
310 f30->register_count, &ctrl_reg); in rmi_f30_initialize()
313 if (f30->has_led) { in rmi_f30_initialize()
314 rmi_f30_set_ctrl_data(&f30->ctrl[4], &control_address, in rmi_f30_initialize()
315 f30->register_count, &ctrl_reg); in rmi_f30_initialize()
317 rmi_f30_set_ctrl_data(&f30->ctrl[5], &control_address, in rmi_f30_initialize()
318 f30->has_extended_pattern ? 6 : 2, in rmi_f30_initialize()
322 if (f30->has_led || f30->has_gpio_driver_control) { in rmi_f30_initialize()
323 /* control 6 uses a byte per gpio/led */ in rmi_f30_initialize()
324 rmi_f30_set_ctrl_data(&f30->ctrl[6], &control_address, in rmi_f30_initialize()
325 f30->gpioled_count, &ctrl_reg); in rmi_f30_initialize()
328 if (f30->has_mappable_buttons) { in rmi_f30_initialize()
329 /* control 7 uses a byte per gpio/led */ in rmi_f30_initialize()
330 rmi_f30_set_ctrl_data(&f30->ctrl[7], &control_address, in rmi_f30_initialize()
331 f30->gpioled_count, &ctrl_reg); in rmi_f30_initialize()
334 if (f30->has_haptic) { in rmi_f30_initialize()
335 rmi_f30_set_ctrl_data(&f30->ctrl[8], &control_address, in rmi_f30_initialize()
336 f30->register_count, &ctrl_reg); in rmi_f30_initialize()
338 rmi_f30_set_ctrl_data(&f30->ctrl[9], &control_address, in rmi_f30_initialize()
342 if (f30->has_mech_mouse_btns) in rmi_f30_initialize()
343 rmi_f30_set_ctrl_data(&f30->ctrl[10], &control_address, in rmi_f30_initialize()
346 f30->ctrl_regs_size = ctrl_reg - in rmi_f30_initialize()
347 f30->ctrl_regs ?: RMI_F30_CTRL_REGS_MAX_SIZE; in rmi_f30_initialize()
351 dev_err(&fn->dev, in rmi_f30_initialize()
357 if (f30->has_gpio) { in rmi_f30_initialize()
368 struct rmi_device *rmi_dev = fn->rmi_dev; in rmi_f30_probe()
371 struct rmi_driver_data *drv_data = dev_get_drvdata(&rmi_dev->dev); in rmi_f30_probe()
375 if (pdata->gpio_data.disable) in rmi_f30_probe()
378 if (!drv_data->input) { in rmi_f30_probe()
379 dev_info(&fn->dev, "F30: no input device found, ignoring\n"); in rmi_f30_probe()
380 return -ENXIO; in rmi_f30_probe()
383 f30 = devm_kzalloc(&fn->dev, sizeof(*f30), GFP_KERNEL); in rmi_f30_probe()
385 return -ENOMEM; in rmi_f30_probe()
387 f30->input = drv_data->input; in rmi_f30_probe()
393 dev_set_drvdata(&fn->dev, f30); in rmi_f30_probe()