^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * nokia-modem.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * HSI client driver for Nokia N900 modem.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Copyright (C) 2014 Sebastian Reichel <sre@kernel.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/gpio/consumer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/hsi/hsi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/of.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/of_irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/of_gpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/hsi/ssi_protocol.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) static unsigned int pm = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) module_param(pm, int, 0400);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) MODULE_PARM_DESC(pm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) "Enable power management (0=disabled, 1=userland based [default])");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) struct nokia_modem_gpio {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) struct gpio_desc *gpio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) struct nokia_modem_device {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) struct tasklet_struct nokia_modem_rst_ind_tasklet;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) int nokia_modem_rst_ind_irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) struct device *device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) struct nokia_modem_gpio *gpios;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) int gpio_amount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) struct hsi_client *ssi_protocol;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) struct hsi_client *cmt_speech;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) static void do_nokia_modem_rst_ind_tasklet(unsigned long data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) struct nokia_modem_device *modem = (struct nokia_modem_device *)data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) if (!modem)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) dev_info(modem->device, "CMT rst line change detected\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) if (modem->ssi_protocol)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) ssip_reset_event(modem->ssi_protocol);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) static irqreturn_t nokia_modem_rst_ind_isr(int irq, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) struct nokia_modem_device *modem = (struct nokia_modem_device *)data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) tasklet_schedule(&modem->nokia_modem_rst_ind_tasklet);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) static void nokia_modem_gpio_unexport(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) struct nokia_modem_device *modem = dev_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) for (i = 0; i < modem->gpio_amount; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) sysfs_remove_link(&dev->kobj, modem->gpios[i].name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) gpiod_unexport(modem->gpios[i].gpio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) static int nokia_modem_gpio_probe(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) struct device_node *np = dev->of_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) struct nokia_modem_device *modem = dev_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) int gpio_count, gpio_name_count, i, err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) gpio_count = of_gpio_count(np);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) if (gpio_count < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) dev_err(dev, "missing gpios: %d\n", gpio_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) return gpio_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) gpio_name_count = of_property_count_strings(np, "gpio-names");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) if (gpio_count != gpio_name_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) dev_err(dev, "number of gpios does not equal number of gpio names\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) modem->gpios = devm_kcalloc(dev, gpio_count, sizeof(*modem->gpios),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) if (!modem->gpios)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) modem->gpio_amount = gpio_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) for (i = 0; i < gpio_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) modem->gpios[i].gpio = devm_gpiod_get_index(dev, NULL, i,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) GPIOD_OUT_LOW);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) if (IS_ERR(modem->gpios[i].gpio)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) dev_err(dev, "Could not get gpio %d\n", i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) return PTR_ERR(modem->gpios[i].gpio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) err = of_property_read_string_index(np, "gpio-names", i,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) &(modem->gpios[i].name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) dev_err(dev, "Could not get gpio name %d\n", i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) err = gpiod_export(modem->gpios[i].gpio, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) err = gpiod_export_link(dev, modem->gpios[i].name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) modem->gpios[i].gpio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) static int nokia_modem_probe(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) struct device_node *np;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) struct nokia_modem_device *modem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) struct hsi_client *cl = to_hsi_client(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) struct hsi_port *port = hsi_get_port(cl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) int irq, pflags, err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) struct hsi_board_info ssip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) struct hsi_board_info cmtspeech;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) np = dev->of_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) if (!np) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) dev_err(dev, "device tree node not found\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) return -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) modem = devm_kzalloc(dev, sizeof(*modem), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) if (!modem)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) dev_set_drvdata(dev, modem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) modem->device = dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) irq = irq_of_parse_and_map(np, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) if (!irq) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) dev_err(dev, "Invalid rst_ind interrupt (%d)\n", irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) modem->nokia_modem_rst_ind_irq = irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) pflags = irq_get_trigger_type(irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) tasklet_init(&modem->nokia_modem_rst_ind_tasklet,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) do_nokia_modem_rst_ind_tasklet, (unsigned long)modem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) err = devm_request_irq(dev, irq, nokia_modem_rst_ind_isr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) pflags, "modem_rst_ind", modem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) if (err < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) dev_err(dev, "Request rst_ind irq(%d) failed (flags %d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) irq, pflags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) enable_irq_wake(irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) if (pm) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) err = nokia_modem_gpio_probe(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) if (err < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) dev_err(dev, "Could not probe GPIOs\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) goto error1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) ssip.name = "ssi-protocol";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) ssip.tx_cfg = cl->tx_cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) ssip.rx_cfg = cl->rx_cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) ssip.platform_data = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) ssip.archdata = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) modem->ssi_protocol = hsi_new_client(port, &ssip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) if (!modem->ssi_protocol) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) dev_err(dev, "Could not register ssi-protocol device\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) err = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) goto error2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) err = device_attach(&modem->ssi_protocol->device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) if (err == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) dev_dbg(dev, "Missing ssi-protocol driver\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) err = -EPROBE_DEFER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) goto error3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) } else if (err < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) dev_err(dev, "Could not load ssi-protocol driver (%d)\n", err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) goto error3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) cmtspeech.name = "cmt-speech";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) cmtspeech.tx_cfg = cl->tx_cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) cmtspeech.rx_cfg = cl->rx_cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) cmtspeech.platform_data = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) cmtspeech.archdata = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) modem->cmt_speech = hsi_new_client(port, &cmtspeech);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) if (!modem->cmt_speech) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) dev_err(dev, "Could not register cmt-speech device\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) err = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) goto error3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) err = device_attach(&modem->cmt_speech->device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) if (err == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) dev_dbg(dev, "Missing cmt-speech driver\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) err = -EPROBE_DEFER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) goto error4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) } else if (err < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) dev_err(dev, "Could not load cmt-speech driver (%d)\n", err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) goto error4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) dev_info(dev, "Registered Nokia HSI modem\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) error4:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) hsi_remove_client(&modem->cmt_speech->device, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) error3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) hsi_remove_client(&modem->ssi_protocol->device, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) error2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) nokia_modem_gpio_unexport(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) error1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) disable_irq_wake(modem->nokia_modem_rst_ind_irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) tasklet_kill(&modem->nokia_modem_rst_ind_tasklet);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) static int nokia_modem_remove(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) struct nokia_modem_device *modem = dev_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) if (!modem)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) if (modem->cmt_speech) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) hsi_remove_client(&modem->cmt_speech->device, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) modem->cmt_speech = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) if (modem->ssi_protocol) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) hsi_remove_client(&modem->ssi_protocol->device, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) modem->ssi_protocol = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) nokia_modem_gpio_unexport(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) dev_set_drvdata(dev, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) disable_irq_wake(modem->nokia_modem_rst_ind_irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) tasklet_kill(&modem->nokia_modem_rst_ind_tasklet);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) #ifdef CONFIG_OF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) static const struct of_device_id nokia_modem_of_match[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) { .compatible = "nokia,n900-modem", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) { .compatible = "nokia,n950-modem", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) { .compatible = "nokia,n9-modem", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) {},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) MODULE_DEVICE_TABLE(of, nokia_modem_of_match);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) static struct hsi_client_driver nokia_modem_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) .driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) .name = "nokia-modem",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) .probe = nokia_modem_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) .remove = nokia_modem_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) .of_match_table = of_match_ptr(nokia_modem_of_match),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) static int __init nokia_modem_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) return hsi_register_client_driver(&nokia_modem_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) module_init(nokia_modem_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) static void __exit nokia_modem_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) hsi_unregister_client_driver(&nokia_modem_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) module_exit(nokia_modem_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) MODULE_ALIAS("hsi:nokia-modem");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) MODULE_AUTHOR("Sebastian Reichel <sre@kernel.org>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) MODULE_DESCRIPTION("HSI driver module for Nokia N900 Modem");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) MODULE_LICENSE("GPL");