Lines Matching +full:lpc +full:- +full:interrupts
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2015-2018, Intel Corporation.
6 #define pr_fmt(fmt) "aspeed-kcs-bmc: " fmt
28 #define DEVICE_NAME "ast-kcs-bmc"
35 * LPCyE Enable LPC channel y
36 * IBFIEy Input Buffer Full IRQ Enable for LPC channel y
37 * IRQxEy Assert SerIRQ x for LPC channel y (Deprecated, use IDyIRQX, IRQXEy)
38 * IDyIRQX Use the specified 4-bit SerIRQ for LPC channel y
39 * SELyIRQX SerIRQ polarity for LPC channel y (low: 0, high: 1)
40 * IRQXEy Assert the SerIRQ specified in IDyIRQX for LPC channel y
142 rc = regmap_read(priv->map, reg, &val); in aspeed_kcs_inb()
153 rc = regmap_write(priv->map, reg, data); in aspeed_kcs_outb()
168 if (priv->upstream_irq.mode != aspeed_kcs_irq_serirq) in aspeed_kcs_outb()
171 switch (kcs_bmc->channel) { in aspeed_kcs_outb()
173 switch (priv->upstream_irq.id) { in aspeed_kcs_outb()
175 regmap_update_bits(priv->map, LPC_SIRQCR0, LPC_SIRQCR0_IRQ12E1, in aspeed_kcs_outb()
179 regmap_update_bits(priv->map, LPC_SIRQCR0, LPC_SIRQCR0_IRQ1E1, in aspeed_kcs_outb()
187 regmap_update_bits(priv->map, LPC_HICR5, LPC_HICR5_IRQXE2, LPC_HICR5_IRQXE2); in aspeed_kcs_outb()
190 regmap_update_bits(priv->map, LPC_HICR5, LPC_HICR5_IRQXE3, LPC_HICR5_IRQXE3); in aspeed_kcs_outb()
193 regmap_update_bits(priv->map, LPC_HICRC, LPC_HICRC_IRQXE4, LPC_HICRC_IRQXE4); in aspeed_kcs_outb()
205 rc = regmap_update_bits(priv->map, reg, mask, val); in aspeed_kcs_updateb()
234 return -EINVAL; in aspeed_kcs_set_address()
236 switch (priv->kcs_bmc.channel) { in aspeed_kcs_set_address()
238 regmap_update_bits(priv->map, LPC_HICR4, LPC_HICR4_LADR12AS, 0); in aspeed_kcs_set_address()
239 regmap_write(priv->map, LPC_LADR12H, addrs[0] >> 8); in aspeed_kcs_set_address()
240 regmap_write(priv->map, LPC_LADR12L, addrs[0] & 0xFF); in aspeed_kcs_set_address()
242 regmap_update_bits(priv->map, LPC_LSADR12, LPC_LSADR12_LSADR1_MASK, in aspeed_kcs_set_address()
245 regmap_update_bits(priv->map, LPC_HICRB, LPC_HICRB_EN16LADR1, in aspeed_kcs_set_address()
251 regmap_update_bits(priv->map, LPC_HICR4, LPC_HICR4_LADR12AS, LPC_HICR4_LADR12AS); in aspeed_kcs_set_address()
252 regmap_write(priv->map, LPC_LADR12H, addrs[0] >> 8); in aspeed_kcs_set_address()
253 regmap_write(priv->map, LPC_LADR12L, addrs[0] & 0xFF); in aspeed_kcs_set_address()
255 regmap_update_bits(priv->map, LPC_LSADR12, LPC_LSADR12_LSADR2_MASK, in aspeed_kcs_set_address()
258 regmap_update_bits(priv->map, LPC_HICRB, LPC_HICRB_EN16LADR2, in aspeed_kcs_set_address()
265 dev_err(priv->kcs_bmc.dev, in aspeed_kcs_set_address()
267 return -EINVAL; in aspeed_kcs_set_address()
270 regmap_write(priv->map, LPC_LADR3H, addrs[0] >> 8); in aspeed_kcs_set_address()
271 regmap_write(priv->map, LPC_LADR3L, addrs[0] & 0xFF); in aspeed_kcs_set_address()
276 regmap_write(priv->map, LPC_LADR4, ((addrs[0] + 1) << 16) | addrs[0]); in aspeed_kcs_set_address()
278 regmap_write(priv->map, LPC_LADR4, (addrs[1] << 16) | addrs[0]); in aspeed_kcs_set_address()
283 return -EINVAL; in aspeed_kcs_set_address()
299 return -EINVAL; in aspeed_kcs_map_serirq_type()
309 return -EINVAL; in aspeed_kcs_config_upstream_irq()
316 priv->upstream_irq.mode = aspeed_kcs_irq_serirq; in aspeed_kcs_config_upstream_irq()
317 priv->upstream_irq.id = id; in aspeed_kcs_config_upstream_irq()
319 switch (priv->kcs_bmc.channel) { in aspeed_kcs_config_upstream_irq()
325 return -EINVAL; in aspeed_kcs_config_upstream_irq()
330 regmap_update_bits(priv->map, LPC_HICR5, mask, val); in aspeed_kcs_config_upstream_irq()
335 return -EINVAL; in aspeed_kcs_config_upstream_irq()
340 regmap_update_bits(priv->map, LPC_HICR5, mask, val); in aspeed_kcs_config_upstream_irq()
346 regmap_update_bits(priv->map, LPC_HICRC, mask, val); in aspeed_kcs_config_upstream_irq()
349 dev_warn(priv->kcs_bmc.dev, in aspeed_kcs_config_upstream_irq()
351 priv->kcs_bmc.channel); in aspeed_kcs_config_upstream_irq()
352 return -EINVAL; in aspeed_kcs_config_upstream_irq()
362 switch (kcs_bmc->channel) { in aspeed_kcs_enable_channel()
364 regmap_update_bits(priv->map, LPC_HICR0, LPC_HICR0_LPC1E, enable * LPC_HICR0_LPC1E); in aspeed_kcs_enable_channel()
367 regmap_update_bits(priv->map, LPC_HICR0, LPC_HICR0_LPC2E, enable * LPC_HICR0_LPC2E); in aspeed_kcs_enable_channel()
370 regmap_update_bits(priv->map, LPC_HICR0, LPC_HICR0_LPC3E, enable * LPC_HICR0_LPC3E); in aspeed_kcs_enable_channel()
371 regmap_update_bits(priv->map, LPC_HICR4, in aspeed_kcs_enable_channel()
375 regmap_update_bits(priv->map, LPC_HICRB, LPC_HICRB_LPC4E, enable * LPC_HICRB_LPC4E); in aspeed_kcs_enable_channel()
378 pr_warn("%s: Unsupported channel: %d", __func__, kcs_bmc->channel); in aspeed_kcs_enable_channel()
389 spin_lock_irqsave(&priv->obe.lock, flags); in aspeed_kcs_check_obe()
390 if (priv->obe.remove) { in aspeed_kcs_check_obe()
391 spin_unlock_irqrestore(&priv->obe.lock, flags); in aspeed_kcs_check_obe()
395 str = aspeed_kcs_inb(&priv->kcs_bmc, priv->kcs_bmc.ioreg.str); in aspeed_kcs_check_obe()
398 spin_unlock_irqrestore(&priv->obe.lock, flags); in aspeed_kcs_check_obe()
401 spin_unlock_irqrestore(&priv->obe.lock, flags); in aspeed_kcs_check_obe()
403 kcs_bmc_handle_event(&priv->kcs_bmc); in aspeed_kcs_check_obe()
413 mod_timer(&priv->obe.timer, jiffies + OBE_POLL_PERIOD); in aspeed_kcs_irq_mask_update()
415 del_timer(&priv->obe.timer); in aspeed_kcs_irq_mask_update()
421 switch (kcs_bmc->channel) { in aspeed_kcs_irq_mask_update()
423 regmap_update_bits(priv->map, LPC_HICR2, LPC_HICR2_IBFIE1, in aspeed_kcs_irq_mask_update()
427 regmap_update_bits(priv->map, LPC_HICR2, LPC_HICR2_IBFIE2, in aspeed_kcs_irq_mask_update()
431 regmap_update_bits(priv->map, LPC_HICR2, LPC_HICR2_IBFIE3, in aspeed_kcs_irq_mask_update()
435 regmap_update_bits(priv->map, LPC_HICRB, LPC_HICRB_IBFIE4, in aspeed_kcs_irq_mask_update()
439 pr_warn("%s: Unsupported channel: %d", __func__, kcs_bmc->channel); in aspeed_kcs_irq_mask_update()
462 struct device *dev = &pdev->dev; in aspeed_kcs_config_downstream_irq()
487 np = pdev->dev.of_node; in aspeed_kcs_of_get_channel()
492 return -EINVAL; in aspeed_kcs_of_get_channel()
497 return -EINVAL; in aspeed_kcs_of_get_channel()
502 return -EINVAL; in aspeed_kcs_of_get_channel()
509 return -EINVAL; in aspeed_kcs_of_get_channel()
517 rc = of_property_read_variable_u32_array(pdev->dev.of_node, in aspeed_kcs_of_get_io_address()
518 "aspeed,lpc-io-reg", in aspeed_kcs_of_get_io_address()
521 dev_err(&pdev->dev, "No valid 'aspeed,lpc-io-reg' configured\n"); in aspeed_kcs_of_get_io_address()
526 dev_err(&pdev->dev, "Invalid data address in 'aspeed,lpc-io-reg'\n"); in aspeed_kcs_of_get_io_address()
527 return -EINVAL; in aspeed_kcs_of_get_io_address()
531 dev_err(&pdev->dev, "Invalid status address in 'aspeed,lpc-io-reg'\n"); in aspeed_kcs_of_get_io_address()
532 return -EINVAL; in aspeed_kcs_of_get_io_address()
549 np = pdev->dev.of_node->parent; in aspeed_kcs_probe()
550 if (!of_device_is_compatible(np, "aspeed,ast2400-lpc-v2") && in aspeed_kcs_probe()
551 !of_device_is_compatible(np, "aspeed,ast2500-lpc-v2") && in aspeed_kcs_probe()
552 !of_device_is_compatible(np, "aspeed,ast2600-lpc-v2")) { in aspeed_kcs_probe()
553 dev_err(&pdev->dev, "unsupported LPC device binding\n"); in aspeed_kcs_probe()
554 return -ENODEV; in aspeed_kcs_probe()
565 np = pdev->dev.of_node; in aspeed_kcs_probe()
566 rc = of_property_read_u32_array(np, "aspeed,lpc-interrupts", upstream_irq, 2); in aspeed_kcs_probe()
567 if (rc && rc != -EINVAL) in aspeed_kcs_probe()
568 return -EINVAL; in aspeed_kcs_probe()
572 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in aspeed_kcs_probe()
574 return -ENOMEM; in aspeed_kcs_probe()
576 kcs_bmc = &priv->kcs_bmc; in aspeed_kcs_probe()
577 kcs_bmc->dev = &pdev->dev; in aspeed_kcs_probe()
578 kcs_bmc->channel = channel; in aspeed_kcs_probe()
579 kcs_bmc->ioreg = ast_kcs_bmc_ioregs[channel - 1]; in aspeed_kcs_probe()
580 kcs_bmc->ops = &aspeed_kcs_ops; in aspeed_kcs_probe()
582 priv->map = syscon_node_to_regmap(pdev->dev.parent->of_node); in aspeed_kcs_probe()
583 if (IS_ERR(priv->map)) { in aspeed_kcs_probe()
584 dev_err(&pdev->dev, "Couldn't get regmap\n"); in aspeed_kcs_probe()
585 return -ENODEV; in aspeed_kcs_probe()
588 spin_lock_init(&priv->obe.lock); in aspeed_kcs_probe()
589 priv->obe.remove = false; in aspeed_kcs_probe()
590 timer_setup(&priv->obe.timer, aspeed_kcs_check_obe, 0); in aspeed_kcs_probe()
607 priv->upstream_irq.mode = aspeed_kcs_irq_none; in aspeed_kcs_probe()
615 rc = kcs_bmc_add_device(&priv->kcs_bmc); in aspeed_kcs_probe()
617 dev_warn(&pdev->dev, "Failed to register channel %d: %d\n", kcs_bmc->channel, rc); in aspeed_kcs_probe()
621 dev_info(&pdev->dev, "Initialised channel %d at 0x%x\n", in aspeed_kcs_probe()
622 kcs_bmc->channel, addrs[0]); in aspeed_kcs_probe()
630 struct kcs_bmc_device *kcs_bmc = &priv->kcs_bmc; in aspeed_kcs_remove()
638 spin_lock_irq(&priv->obe.lock); in aspeed_kcs_remove()
639 priv->obe.remove = true; in aspeed_kcs_remove()
640 spin_unlock_irq(&priv->obe.lock); in aspeed_kcs_remove()
641 del_timer_sync(&priv->obe.timer); in aspeed_kcs_remove()
647 { .compatible = "aspeed,ast2400-kcs-bmc-v2" },
648 { .compatible = "aspeed,ast2500-kcs-bmc-v2" },
649 { .compatible = "aspeed,ast2600-kcs-bmc" },