Lines Matching +full:gpio +full:- +full:ctrl1

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2012-2020 Synaptics Incorporated
41 u16 key_code = f3a->gpio_key_map[button]; in rmi_f3a_report_button()
42 bool key_down = !(f3a->data_regs[0] & BIT(button)); in rmi_f3a_report_button()
44 if (f3a->trackstick_buttons && in rmi_f3a_report_button()
47 rmi_f03_overwrite_button(f3a->f03, key_code, key_down); in rmi_f3a_report_button()
49 rmi_dbg(RMI_DEBUG_FN, &fn->dev, in rmi_f3a_report_button()
52 input_report_key(f3a->input, key_code, key_down); in rmi_f3a_report_button()
59 struct f3a_data *f3a = dev_get_drvdata(&fn->dev); in rmi_f3a_attention()
60 struct rmi_driver_data *drvdata = dev_get_drvdata(&fn->rmi_dev->dev); in rmi_f3a_attention()
64 if (drvdata->attn_data.data) { in rmi_f3a_attention()
65 if (drvdata->attn_data.size < f3a->register_count) { in rmi_f3a_attention()
66 dev_warn(&fn->dev, in rmi_f3a_attention()
70 memcpy(f3a->data_regs, drvdata->attn_data.data, in rmi_f3a_attention()
71 f3a->register_count); in rmi_f3a_attention()
72 drvdata->attn_data.data += f3a->register_count; in rmi_f3a_attention()
73 drvdata->attn_data.size -= f3a->register_count; in rmi_f3a_attention()
75 error = rmi_read_block(fn->rmi_dev, fn->fd.data_base_addr, in rmi_f3a_attention()
76 f3a->data_regs, f3a->register_count); in rmi_f3a_attention()
78 dev_err(&fn->dev, in rmi_f3a_attention()
85 for (i = 0; i < f3a->gpio_count; i++) in rmi_f3a_attention()
86 if (f3a->gpio_key_map[i] != KEY_RESERVED) in rmi_f3a_attention()
88 if (f3a->trackstick_buttons) in rmi_f3a_attention()
89 rmi_f03_commit_buttons(f3a->f03); in rmi_f3a_attention()
96 struct f3a_data *f3a = dev_get_drvdata(&fn->dev); in rmi_f3a_config()
97 struct rmi_driver *drv = fn->rmi_dev->driver; in rmi_f3a_config()
99 rmi_get_platform_data(fn->rmi_dev); in rmi_f3a_config()
104 if (pdata->gpio_data.trackstick_buttons) { in rmi_f3a_config()
105 /* Try [re-]establish link to F03. */ in rmi_f3a_config()
106 f3a->f03 = rmi_find_function(fn->rmi_dev, 0x03); in rmi_f3a_config()
107 f3a->trackstick_buttons = f3a->f03 != NULL; in rmi_f3a_config()
110 drv->set_irq_bits(fn->rmi_dev, fn->irq_mask); in rmi_f3a_config()
118 /* gpio exist && direction input */ in rmi_f3a_is_valid_button()
126 rmi_get_platform_data(fn->rmi_dev); in rmi_f3a_map_gpios()
127 struct input_dev *input = f3a->input; in rmi_f3a_map_gpios()
132 int button_count = min_t(u8, f3a->gpio_count, TRACKSTICK_RANGE_END); in rmi_f3a_map_gpios()
134 f3a->gpio_key_map = devm_kcalloc(&fn->dev, in rmi_f3a_map_gpios()
136 sizeof(f3a->gpio_key_map[0]), in rmi_f3a_map_gpios()
138 if (!f3a->gpio_key_map) { in rmi_f3a_map_gpios()
139 dev_err(&fn->dev, "Failed to allocate gpio map memory.\n"); in rmi_f3a_map_gpios()
140 return -ENOMEM; in rmi_f3a_map_gpios()
147 if (pdata->gpio_data.trackstick_buttons && in rmi_f3a_map_gpios()
150 f3a->gpio_key_map[i] = trackstick_button++; in rmi_f3a_map_gpios()
151 } else if (!pdata->gpio_data.buttonpad || !button_mapped) { in rmi_f3a_map_gpios()
152 f3a->gpio_key_map[i] = button; in rmi_f3a_map_gpios()
157 input->keycode = f3a->gpio_key_map; in rmi_f3a_map_gpios()
158 input->keycodesize = sizeof(f3a->gpio_key_map[0]); in rmi_f3a_map_gpios()
159 input->keycodemax = f3a->gpio_count; in rmi_f3a_map_gpios()
161 if (pdata->gpio_data.buttonpad || (button - BTN_LEFT == 1)) in rmi_f3a_map_gpios()
162 __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); in rmi_f3a_map_gpios()
170 u8 ctrl1[RMI_F3A_MAX_REG_SIZE]; in rmi_f3a_initialize() local
174 error = rmi_read(fn->rmi_dev, fn->fd.query_base_addr, &buf); in rmi_f3a_initialize()
176 dev_err(&fn->dev, "Failed to read general info register: %d\n", in rmi_f3a_initialize()
178 return -ENODEV; in rmi_f3a_initialize()
181 f3a->gpio_count = buf & RMI_F3A_GPIO_COUNT; in rmi_f3a_initialize()
182 f3a->register_count = DIV_ROUND_UP(f3a->gpio_count, 8); in rmi_f3a_initialize()
184 /* Query1 -> gpio exist */ in rmi_f3a_initialize()
185 error = rmi_read_block(fn->rmi_dev, fn->fd.query_base_addr + 1, in rmi_f3a_initialize()
186 query1, f3a->register_count); in rmi_f3a_initialize()
188 dev_err(&fn->dev, "Failed to read query1 register\n"); in rmi_f3a_initialize()
192 /* Ctrl1 -> gpio direction */ in rmi_f3a_initialize()
193 error = rmi_read_block(fn->rmi_dev, fn->fd.control_base_addr + 1, in rmi_f3a_initialize()
194 ctrl1, f3a->register_count); in rmi_f3a_initialize()
196 dev_err(&fn->dev, "Failed to read control1 register\n"); in rmi_f3a_initialize()
200 error = rmi_f3a_map_gpios(fn, f3a, query1, ctrl1); in rmi_f3a_initialize()
209 struct rmi_device *rmi_dev = fn->rmi_dev; in rmi_f3a_probe()
210 struct rmi_driver_data *drv_data = dev_get_drvdata(&rmi_dev->dev); in rmi_f3a_probe()
214 if (!drv_data->input) { in rmi_f3a_probe()
215 dev_info(&fn->dev, "F3A: no input device found, ignoring\n"); in rmi_f3a_probe()
216 return -ENXIO; in rmi_f3a_probe()
219 f3a = devm_kzalloc(&fn->dev, sizeof(*f3a), GFP_KERNEL); in rmi_f3a_probe()
221 return -ENOMEM; in rmi_f3a_probe()
223 f3a->input = drv_data->input; in rmi_f3a_probe()
229 dev_set_drvdata(&fn->dev, f3a); in rmi_f3a_probe()