Lines Matching +full:request +full:- +full:gpios
1 // SPDX-License-Identifier: GPL-2.0-only
3 * nokia-modem.c
32 struct nokia_modem_gpio *gpios; member
45 dev_info(modem->device, "CMT rst line change detected\n"); in do_nokia_modem_rst_ind_tasklet()
47 if (modem->ssi_protocol) in do_nokia_modem_rst_ind_tasklet()
48 ssip_reset_event(modem->ssi_protocol); in do_nokia_modem_rst_ind_tasklet()
55 tasklet_schedule(&modem->nokia_modem_rst_ind_tasklet); in nokia_modem_rst_ind_isr()
65 for (i = 0; i < modem->gpio_amount; i++) { in nokia_modem_gpio_unexport()
66 sysfs_remove_link(&dev->kobj, modem->gpios[i].name); in nokia_modem_gpio_unexport()
67 gpiod_unexport(modem->gpios[i].gpio); in nokia_modem_gpio_unexport()
73 struct device_node *np = dev->of_node; in nokia_modem_gpio_probe()
79 dev_err(dev, "missing gpios: %d\n", gpio_count); in nokia_modem_gpio_probe()
83 gpio_name_count = of_property_count_strings(np, "gpio-names"); in nokia_modem_gpio_probe()
86 dev_err(dev, "number of gpios does not equal number of gpio names\n"); in nokia_modem_gpio_probe()
87 return -EINVAL; in nokia_modem_gpio_probe()
90 modem->gpios = devm_kcalloc(dev, gpio_count, sizeof(*modem->gpios), in nokia_modem_gpio_probe()
92 if (!modem->gpios) in nokia_modem_gpio_probe()
93 return -ENOMEM; in nokia_modem_gpio_probe()
95 modem->gpio_amount = gpio_count; in nokia_modem_gpio_probe()
98 modem->gpios[i].gpio = devm_gpiod_get_index(dev, NULL, i, in nokia_modem_gpio_probe()
100 if (IS_ERR(modem->gpios[i].gpio)) { in nokia_modem_gpio_probe()
102 return PTR_ERR(modem->gpios[i].gpio); in nokia_modem_gpio_probe()
105 err = of_property_read_string_index(np, "gpio-names", i, in nokia_modem_gpio_probe()
106 &(modem->gpios[i].name)); in nokia_modem_gpio_probe()
112 err = gpiod_export(modem->gpios[i].gpio, 0); in nokia_modem_gpio_probe()
116 err = gpiod_export_link(dev, modem->gpios[i].name, in nokia_modem_gpio_probe()
117 modem->gpios[i].gpio); in nokia_modem_gpio_probe()
135 np = dev->of_node; in nokia_modem_probe()
138 return -ENXIO; in nokia_modem_probe()
143 return -ENOMEM; in nokia_modem_probe()
146 modem->device = dev; in nokia_modem_probe()
151 return -EINVAL; in nokia_modem_probe()
153 modem->nokia_modem_rst_ind_irq = irq; in nokia_modem_probe()
156 tasklet_init(&modem->nokia_modem_rst_ind_tasklet, in nokia_modem_probe()
161 dev_err(dev, "Request rst_ind irq(%d) failed (flags %d)\n", in nokia_modem_probe()
170 dev_err(dev, "Could not probe GPIOs\n"); in nokia_modem_probe()
175 ssip.name = "ssi-protocol"; in nokia_modem_probe()
176 ssip.tx_cfg = cl->tx_cfg; in nokia_modem_probe()
177 ssip.rx_cfg = cl->rx_cfg; in nokia_modem_probe()
181 modem->ssi_protocol = hsi_new_client(port, &ssip); in nokia_modem_probe()
182 if (!modem->ssi_protocol) { in nokia_modem_probe()
183 dev_err(dev, "Could not register ssi-protocol device\n"); in nokia_modem_probe()
184 err = -ENOMEM; in nokia_modem_probe()
188 err = device_attach(&modem->ssi_protocol->device); in nokia_modem_probe()
190 dev_dbg(dev, "Missing ssi-protocol driver\n"); in nokia_modem_probe()
191 err = -EPROBE_DEFER; in nokia_modem_probe()
194 dev_err(dev, "Could not load ssi-protocol driver (%d)\n", err); in nokia_modem_probe()
198 cmtspeech.name = "cmt-speech"; in nokia_modem_probe()
199 cmtspeech.tx_cfg = cl->tx_cfg; in nokia_modem_probe()
200 cmtspeech.rx_cfg = cl->rx_cfg; in nokia_modem_probe()
204 modem->cmt_speech = hsi_new_client(port, &cmtspeech); in nokia_modem_probe()
205 if (!modem->cmt_speech) { in nokia_modem_probe()
206 dev_err(dev, "Could not register cmt-speech device\n"); in nokia_modem_probe()
207 err = -ENOMEM; in nokia_modem_probe()
211 err = device_attach(&modem->cmt_speech->device); in nokia_modem_probe()
213 dev_dbg(dev, "Missing cmt-speech driver\n"); in nokia_modem_probe()
214 err = -EPROBE_DEFER; in nokia_modem_probe()
217 dev_err(dev, "Could not load cmt-speech driver (%d)\n", err); in nokia_modem_probe()
226 hsi_remove_client(&modem->cmt_speech->device, NULL); in nokia_modem_probe()
228 hsi_remove_client(&modem->ssi_protocol->device, NULL); in nokia_modem_probe()
232 disable_irq_wake(modem->nokia_modem_rst_ind_irq); in nokia_modem_probe()
233 tasklet_kill(&modem->nokia_modem_rst_ind_tasklet); in nokia_modem_probe()
245 if (modem->cmt_speech) { in nokia_modem_remove()
246 hsi_remove_client(&modem->cmt_speech->device, NULL); in nokia_modem_remove()
247 modem->cmt_speech = NULL; in nokia_modem_remove()
250 if (modem->ssi_protocol) { in nokia_modem_remove()
251 hsi_remove_client(&modem->ssi_protocol->device, NULL); in nokia_modem_remove()
252 modem->ssi_protocol = NULL; in nokia_modem_remove()
257 disable_irq_wake(modem->nokia_modem_rst_ind_irq); in nokia_modem_remove()
258 tasklet_kill(&modem->nokia_modem_rst_ind_tasklet); in nokia_modem_remove()
265 { .compatible = "nokia,n900-modem", },
266 { .compatible = "nokia,n950-modem", },
267 { .compatible = "nokia,n9-modem", },
275 .name = "nokia-modem",
295 MODULE_ALIAS("hsi:nokia-modem");