Lines Matching +full:fw +full:- +full:gpios

1 // SPDX-License-Identifier: GPL-2.0-or-later
35 mutex_lock(&phy->common.mutex); in s3fwrn5_i2c_set_mode()
37 if (s3fwrn5_phy_power_ctrl(&phy->common, mode) == false) in s3fwrn5_i2c_set_mode()
40 phy->irq_skip = true; in s3fwrn5_i2c_set_mode()
43 mutex_unlock(&phy->common.mutex); in s3fwrn5_i2c_set_mode()
51 mutex_lock(&phy->common.mutex); in s3fwrn5_i2c_write()
53 phy->irq_skip = false; in s3fwrn5_i2c_write()
55 ret = i2c_master_send(phy->i2c_dev, skb->data, skb->len); in s3fwrn5_i2c_write()
56 if (ret == -EREMOTEIO) { in s3fwrn5_i2c_write()
59 ret = i2c_master_send(phy->i2c_dev, skb->data, skb->len); in s3fwrn5_i2c_write()
62 mutex_unlock(&phy->common.mutex); in s3fwrn5_i2c_write()
67 if (ret != skb->len) in s3fwrn5_i2c_write()
68 return -EREMOTEIO; in s3fwrn5_i2c_write()
88 hdr_size = (phy->common.mode == S3FWRN5_MODE_NCI) ? in s3fwrn5_i2c_read()
90 ret = i2c_master_recv(phy->i2c_dev, hdr, hdr_size); in s3fwrn5_i2c_read()
95 return -EBADMSG; in s3fwrn5_i2c_read()
97 data_len = (phy->common.mode == S3FWRN5_MODE_NCI) ? in s3fwrn5_i2c_read()
98 ((struct nci_ctrl_hdr *)hdr)->plen : in s3fwrn5_i2c_read()
99 ((struct s3fwrn5_fw_header *)hdr)->len; in s3fwrn5_i2c_read()
103 return -ENOMEM; in s3fwrn5_i2c_read()
110 ret = i2c_master_recv(phy->i2c_dev, skb_put(skb, data_len), data_len); in s3fwrn5_i2c_read()
113 return -EBADMSG; in s3fwrn5_i2c_read()
117 return s3fwrn5_recv_frame(phy->common.ndev, skb, phy->common.mode); in s3fwrn5_i2c_read()
124 if (!phy || !phy->common.ndev) { in s3fwrn5_i2c_irq_thread_fn()
129 mutex_lock(&phy->common.mutex); in s3fwrn5_i2c_irq_thread_fn()
131 if (phy->irq_skip) in s3fwrn5_i2c_irq_thread_fn()
134 switch (phy->common.mode) { in s3fwrn5_i2c_irq_thread_fn()
144 mutex_unlock(&phy->common.mutex); in s3fwrn5_i2c_irq_thread_fn()
152 struct device_node *np = client->dev.of_node; in s3fwrn5_i2c_parse_dt()
155 return -ENODEV; in s3fwrn5_i2c_parse_dt()
157 phy->common.gpio_en = of_get_named_gpio(np, "en-gpios", 0); in s3fwrn5_i2c_parse_dt()
158 if (!gpio_is_valid(phy->common.gpio_en)) { in s3fwrn5_i2c_parse_dt()
160 phy->common.gpio_en = of_get_named_gpio(np, in s3fwrn5_i2c_parse_dt()
161 "s3fwrn5,en-gpios", in s3fwrn5_i2c_parse_dt()
163 if (!gpio_is_valid(phy->common.gpio_en)) in s3fwrn5_i2c_parse_dt()
164 return -ENODEV; in s3fwrn5_i2c_parse_dt()
167 phy->common.gpio_fw_wake = of_get_named_gpio(np, "wake-gpios", 0); in s3fwrn5_i2c_parse_dt()
168 if (!gpio_is_valid(phy->common.gpio_fw_wake)) { in s3fwrn5_i2c_parse_dt()
170 phy->common.gpio_fw_wake = of_get_named_gpio(np, in s3fwrn5_i2c_parse_dt()
171 "s3fwrn5,fw-gpios", in s3fwrn5_i2c_parse_dt()
173 if (!gpio_is_valid(phy->common.gpio_fw_wake)) in s3fwrn5_i2c_parse_dt()
174 return -ENODEV; in s3fwrn5_i2c_parse_dt()
185 phy = devm_kzalloc(&client->dev, sizeof(*phy), GFP_KERNEL); in s3fwrn5_i2c_probe()
187 return -ENOMEM; in s3fwrn5_i2c_probe()
189 mutex_init(&phy->common.mutex); in s3fwrn5_i2c_probe()
190 phy->common.mode = S3FWRN5_MODE_COLD; in s3fwrn5_i2c_probe()
191 phy->irq_skip = true; in s3fwrn5_i2c_probe()
193 phy->i2c_dev = client; in s3fwrn5_i2c_probe()
200 ret = devm_gpio_request_one(&phy->i2c_dev->dev, phy->common.gpio_en, in s3fwrn5_i2c_probe()
205 ret = devm_gpio_request_one(&phy->i2c_dev->dev, in s3fwrn5_i2c_probe()
206 phy->common.gpio_fw_wake, in s3fwrn5_i2c_probe()
213 * Depending on the hardware configuration this could be an always-on in s3fwrn5_i2c_probe()
217 phy->clk = devm_clk_get_optional_enabled(&client->dev, NULL); in s3fwrn5_i2c_probe()
218 if (IS_ERR(phy->clk)) in s3fwrn5_i2c_probe()
219 return dev_err_probe(&client->dev, PTR_ERR(phy->clk), in s3fwrn5_i2c_probe()
222 ret = s3fwrn5_probe(&phy->common.ndev, phy, &phy->i2c_dev->dev, in s3fwrn5_i2c_probe()
227 ret = devm_request_threaded_irq(&client->dev, phy->i2c_dev->irq, NULL, in s3fwrn5_i2c_probe()
236 s3fwrn5_remove(phy->common.ndev); in s3fwrn5_i2c_probe()
244 s3fwrn5_remove(phy->common.ndev); in s3fwrn5_i2c_remove()
254 { .compatible = "samsung,s3fwrn5-i2c", },