Lines Matching +full:ast2500 +full:- +full:lpc
1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Provides a simple driver to control the ASPEED LPC snoop interface which
7 * the host to an arbitrary LPC I/O port.
26 #define DEVICE_NAME "aspeed-lpc-snoop"
55 /* The ast2400 has bits 14 and 15 as reserved, whereas the ast2500
75 return container_of(file->private_data, in snoop_file_to_chan()
87 if (kfifo_is_empty(&chan->fifo)) { in snoop_file_read()
88 if (file->f_flags & O_NONBLOCK) in snoop_file_read()
89 return -EAGAIN; in snoop_file_read()
90 ret = wait_event_interruptible(chan->wq, in snoop_file_read()
91 !kfifo_is_empty(&chan->fifo)); in snoop_file_read()
92 if (ret == -ERESTARTSYS) in snoop_file_read()
93 return -EINTR; in snoop_file_read()
95 ret = kfifo_to_user(&chan->fifo, buffer, count, &copied); in snoop_file_read()
105 poll_wait(file, &chan->wq, pt); in snoop_file_poll()
106 return !kfifo_is_empty(&chan->fifo) ? EPOLLIN : 0; in snoop_file_poll()
119 if (!kfifo_initialized(&chan->fifo)) in put_fifo_with_discard()
121 if (kfifo_is_full(&chan->fifo)) in put_fifo_with_discard()
122 kfifo_skip(&chan->fifo); in put_fifo_with_discard()
123 kfifo_put(&chan->fifo, val); in put_fifo_with_discard()
124 wake_up_interruptible(&chan->wq); in put_fifo_with_discard()
132 if (regmap_read(lpc_snoop->regmap, HICR6, ®)) in aspeed_lpc_snoop_irq()
141 regmap_write(lpc_snoop->regmap, HICR6, reg); in aspeed_lpc_snoop_irq()
144 regmap_read(lpc_snoop->regmap, SNPWDR, &data); in aspeed_lpc_snoop_irq()
149 put_fifo_with_discard(&lpc_snoop->chan[0], val); in aspeed_lpc_snoop_irq()
154 put_fifo_with_discard(&lpc_snoop->chan[1], val); in aspeed_lpc_snoop_irq()
163 struct device *dev = &pdev->dev; in aspeed_lpc_snoop_config_irq()
166 lpc_snoop->irq = platform_get_irq(pdev, 0); in aspeed_lpc_snoop_config_irq()
167 if (!lpc_snoop->irq) in aspeed_lpc_snoop_config_irq()
168 return -ENODEV; in aspeed_lpc_snoop_config_irq()
170 rc = devm_request_irq(dev, lpc_snoop->irq, in aspeed_lpc_snoop_config_irq()
174 dev_warn(dev, "Unable to request IRQ %d\n", lpc_snoop->irq); in aspeed_lpc_snoop_config_irq()
175 lpc_snoop->irq = 0; in aspeed_lpc_snoop_config_irq()
191 init_waitqueue_head(&lpc_snoop->chan[channel].wq); in aspeed_lpc_enable_snoop()
193 rc = kfifo_alloc(&lpc_snoop->chan[channel].fifo, in aspeed_lpc_enable_snoop()
198 lpc_snoop->chan[channel].miscdev.minor = MISC_DYNAMIC_MINOR; in aspeed_lpc_enable_snoop()
199 lpc_snoop->chan[channel].miscdev.name = in aspeed_lpc_enable_snoop()
201 lpc_snoop->chan[channel].miscdev.fops = &snoop_fops; in aspeed_lpc_enable_snoop()
202 lpc_snoop->chan[channel].miscdev.parent = dev; in aspeed_lpc_enable_snoop()
203 rc = misc_register(&lpc_snoop->chan[channel].miscdev); in aspeed_lpc_enable_snoop()
207 /* Enable LPC snoop channel at requested port */ in aspeed_lpc_enable_snoop()
222 return -EINVAL; in aspeed_lpc_enable_snoop()
225 regmap_update_bits(lpc_snoop->regmap, HICR5, hicr5_en, hicr5_en); in aspeed_lpc_enable_snoop()
226 regmap_update_bits(lpc_snoop->regmap, SNPWADR, snpwadr_mask, in aspeed_lpc_enable_snoop()
228 if (model_data->has_hicrb_ensnp) in aspeed_lpc_enable_snoop()
229 regmap_update_bits(lpc_snoop->regmap, HICRB, in aspeed_lpc_enable_snoop()
240 regmap_update_bits(lpc_snoop->regmap, HICR5, in aspeed_lpc_disable_snoop()
245 regmap_update_bits(lpc_snoop->regmap, HICR5, in aspeed_lpc_disable_snoop()
253 kfifo_free(&lpc_snoop->chan[channel].fifo); in aspeed_lpc_disable_snoop()
254 misc_deregister(&lpc_snoop->chan[channel].miscdev); in aspeed_lpc_disable_snoop()
264 dev = &pdev->dev; in aspeed_lpc_snoop_probe()
268 return -ENOMEM; in aspeed_lpc_snoop_probe()
270 lpc_snoop->regmap = syscon_node_to_regmap( in aspeed_lpc_snoop_probe()
271 pdev->dev.parent->of_node); in aspeed_lpc_snoop_probe()
272 if (IS_ERR(lpc_snoop->regmap)) { in aspeed_lpc_snoop_probe()
274 return -ENODEV; in aspeed_lpc_snoop_probe()
277 dev_set_drvdata(&pdev->dev, lpc_snoop); in aspeed_lpc_snoop_probe()
279 rc = of_property_read_u32_index(dev->of_node, "snoop-ports", 0, &port); in aspeed_lpc_snoop_probe()
282 return -ENODEV; in aspeed_lpc_snoop_probe()
294 if (of_property_read_u32_index(dev->of_node, "snoop-ports", in aspeed_lpc_snoop_probe()
306 struct aspeed_lpc_snoop *lpc_snoop = dev_get_drvdata(&pdev->dev); in aspeed_lpc_snoop_remove()
324 { .compatible = "aspeed,ast2400-lpc-snoop",
326 { .compatible = "aspeed,ast2500-lpc-snoop",
345 MODULE_DESCRIPTION("Linux driver to control Aspeed LPC snoop functionality");