Lines Matching +full:ast2500 +full:- +full:lpc +full:- +full:host
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2015-2018, Intel Corporation.
6 #define pr_fmt(fmt) "aspeed-kcs-bmc: " fmt
27 #define DEVICE_NAME "ast-kcs-bmc"
34 * LPCyE Enable LPC channel y
35 * IBFIEy Input Buffer Full IRQ Enable for LPC channel y
36 * IRQxEy Assert SerIRQ x for LPC channel y (Deprecated, use IDyIRQX, IRQXEy)
37 * IDyIRQX Use the specified 4-bit SerIRQ for LPC channel y
38 * SELyIRQX SerIRQ polarity for LPC channel y (low: 0, high: 1)
39 * IRQXEy Assert the SerIRQ specified in IDyIRQX for LPC channel y
141 rc = regmap_read(priv->map, reg, &val); in aspeed_kcs_inb()
152 rc = regmap_write(priv->map, reg, data); in aspeed_kcs_outb()
167 if (priv->upstream_irq.mode != aspeed_kcs_irq_serirq) in aspeed_kcs_outb()
170 switch (kcs_bmc->channel) { in aspeed_kcs_outb()
172 switch (priv->upstream_irq.id) { in aspeed_kcs_outb()
174 regmap_update_bits(priv->map, LPC_SIRQCR0, LPC_SIRQCR0_IRQ12E1, in aspeed_kcs_outb()
178 regmap_update_bits(priv->map, LPC_SIRQCR0, LPC_SIRQCR0_IRQ1E1, in aspeed_kcs_outb()
186 regmap_update_bits(priv->map, LPC_HICR5, LPC_HICR5_IRQXE2, LPC_HICR5_IRQXE2); in aspeed_kcs_outb()
189 regmap_update_bits(priv->map, LPC_HICR5, LPC_HICR5_IRQXE3, LPC_HICR5_IRQXE3); in aspeed_kcs_outb()
192 regmap_update_bits(priv->map, LPC_HICRC, LPC_HICRC_IRQXE4, LPC_HICRC_IRQXE4); in aspeed_kcs_outb()
204 rc = regmap_update_bits(priv->map, reg, mask, val); in aspeed_kcs_updateb()
233 return -EINVAL; in aspeed_kcs_set_address()
235 switch (priv->kcs_bmc.channel) { in aspeed_kcs_set_address()
237 regmap_update_bits(priv->map, LPC_HICR4, LPC_HICR4_LADR12AS, 0); in aspeed_kcs_set_address()
238 regmap_write(priv->map, LPC_LADR12H, addrs[0] >> 8); in aspeed_kcs_set_address()
239 regmap_write(priv->map, LPC_LADR12L, addrs[0] & 0xFF); in aspeed_kcs_set_address()
241 regmap_update_bits(priv->map, LPC_LSADR12, LPC_LSADR12_LSADR1_MASK, in aspeed_kcs_set_address()
244 regmap_update_bits(priv->map, LPC_HICRB, LPC_HICRB_EN16LADR1, in aspeed_kcs_set_address()
250 regmap_update_bits(priv->map, LPC_HICR4, LPC_HICR4_LADR12AS, LPC_HICR4_LADR12AS); in aspeed_kcs_set_address()
251 regmap_write(priv->map, LPC_LADR12H, addrs[0] >> 8); in aspeed_kcs_set_address()
252 regmap_write(priv->map, LPC_LADR12L, addrs[0] & 0xFF); in aspeed_kcs_set_address()
254 regmap_update_bits(priv->map, LPC_LSADR12, LPC_LSADR12_LSADR2_MASK, in aspeed_kcs_set_address()
257 regmap_update_bits(priv->map, LPC_HICRB, LPC_HICRB_EN16LADR2, in aspeed_kcs_set_address()
264 dev_err(priv->kcs_bmc.dev, in aspeed_kcs_set_address()
266 return -EINVAL; in aspeed_kcs_set_address()
269 regmap_write(priv->map, LPC_LADR3H, addrs[0] >> 8); in aspeed_kcs_set_address()
270 regmap_write(priv->map, LPC_LADR3L, addrs[0] & 0xFF); in aspeed_kcs_set_address()
275 regmap_write(priv->map, LPC_LADR4, ((addrs[0] + 1) << 16) | addrs[0]); in aspeed_kcs_set_address()
277 regmap_write(priv->map, LPC_LADR4, (addrs[1] << 16) | addrs[0]); in aspeed_kcs_set_address()
282 return -EINVAL; in aspeed_kcs_set_address()
298 return -EINVAL; in aspeed_kcs_map_serirq_type()
308 return -EINVAL; in aspeed_kcs_config_upstream_irq()
315 priv->upstream_irq.mode = aspeed_kcs_irq_serirq; in aspeed_kcs_config_upstream_irq()
316 priv->upstream_irq.id = id; in aspeed_kcs_config_upstream_irq()
318 switch (priv->kcs_bmc.channel) { in aspeed_kcs_config_upstream_irq()
324 return -EINVAL; in aspeed_kcs_config_upstream_irq()
329 regmap_update_bits(priv->map, LPC_HICR5, mask, val); in aspeed_kcs_config_upstream_irq()
334 return -EINVAL; in aspeed_kcs_config_upstream_irq()
339 regmap_update_bits(priv->map, LPC_HICR5, mask, val); in aspeed_kcs_config_upstream_irq()
345 regmap_update_bits(priv->map, LPC_HICRC, mask, val); in aspeed_kcs_config_upstream_irq()
348 dev_warn(priv->kcs_bmc.dev, in aspeed_kcs_config_upstream_irq()
350 priv->kcs_bmc.channel); in aspeed_kcs_config_upstream_irq()
351 return -EINVAL; in aspeed_kcs_config_upstream_irq()
361 switch (kcs_bmc->channel) { in aspeed_kcs_enable_channel()
363 regmap_update_bits(priv->map, LPC_HICR0, LPC_HICR0_LPC1E, enable * LPC_HICR0_LPC1E); in aspeed_kcs_enable_channel()
366 regmap_update_bits(priv->map, LPC_HICR0, LPC_HICR0_LPC2E, enable * LPC_HICR0_LPC2E); in aspeed_kcs_enable_channel()
369 regmap_update_bits(priv->map, LPC_HICR0, LPC_HICR0_LPC3E, enable * LPC_HICR0_LPC3E); in aspeed_kcs_enable_channel()
370 regmap_update_bits(priv->map, LPC_HICR4, in aspeed_kcs_enable_channel()
374 regmap_update_bits(priv->map, LPC_HICRB, LPC_HICRB_LPC4E, enable * LPC_HICRB_LPC4E); in aspeed_kcs_enable_channel()
377 pr_warn("%s: Unsupported channel: %d", __func__, kcs_bmc->channel); in aspeed_kcs_enable_channel()
388 spin_lock_irqsave(&priv->obe.lock, flags); in aspeed_kcs_check_obe()
389 if (priv->obe.remove) { in aspeed_kcs_check_obe()
390 spin_unlock_irqrestore(&priv->obe.lock, flags); in aspeed_kcs_check_obe()
394 str = aspeed_kcs_inb(&priv->kcs_bmc, priv->kcs_bmc.ioreg.str); in aspeed_kcs_check_obe()
397 spin_unlock_irqrestore(&priv->obe.lock, flags); in aspeed_kcs_check_obe()
400 spin_unlock_irqrestore(&priv->obe.lock, flags); in aspeed_kcs_check_obe()
402 kcs_bmc_handle_event(&priv->kcs_bmc); in aspeed_kcs_check_obe()
421 * The onus is on the client to perform a race-free check that it hasn't in aspeed_kcs_irq_mask_update()
426 &priv->kcs_bmc, priv->kcs_bmc.ioreg.str); in aspeed_kcs_irq_mask_update()
428 if (rc == -ETIMEDOUT) in aspeed_kcs_irq_mask_update()
429 mod_timer(&priv->obe.timer, jiffies + OBE_POLL_PERIOD); in aspeed_kcs_irq_mask_update()
431 del_timer(&priv->obe.timer); in aspeed_kcs_irq_mask_update()
438 switch (kcs_bmc->channel) { in aspeed_kcs_irq_mask_update()
440 regmap_update_bits(priv->map, LPC_HICR2, LPC_HICR2_IBFIE1, in aspeed_kcs_irq_mask_update()
444 regmap_update_bits(priv->map, LPC_HICR2, LPC_HICR2_IBFIE2, in aspeed_kcs_irq_mask_update()
448 regmap_update_bits(priv->map, LPC_HICR2, LPC_HICR2_IBFIE3, in aspeed_kcs_irq_mask_update()
452 regmap_update_bits(priv->map, LPC_HICRB, LPC_HICRB_IBFIE4, in aspeed_kcs_irq_mask_update()
456 pr_warn("%s: Unsupported channel: %d", __func__, kcs_bmc->channel); in aspeed_kcs_irq_mask_update()
479 struct device *dev = &pdev->dev; in aspeed_kcs_config_downstream_irq()
504 np = pdev->dev.of_node; in aspeed_kcs_of_get_channel()
509 return -EINVAL; in aspeed_kcs_of_get_channel()
514 return -EINVAL; in aspeed_kcs_of_get_channel()
519 return -EINVAL; in aspeed_kcs_of_get_channel()
526 return -EINVAL; in aspeed_kcs_of_get_channel()
534 rc = of_property_read_variable_u32_array(pdev->dev.of_node, in aspeed_kcs_of_get_io_address()
535 "aspeed,lpc-io-reg", in aspeed_kcs_of_get_io_address()
538 dev_err(&pdev->dev, "No valid 'aspeed,lpc-io-reg' configured\n"); in aspeed_kcs_of_get_io_address()
543 dev_err(&pdev->dev, "Invalid data address in 'aspeed,lpc-io-reg'\n"); in aspeed_kcs_of_get_io_address()
544 return -EINVAL; in aspeed_kcs_of_get_io_address()
548 dev_err(&pdev->dev, "Invalid status address in 'aspeed,lpc-io-reg'\n"); in aspeed_kcs_of_get_io_address()
549 return -EINVAL; in aspeed_kcs_of_get_io_address()
566 np = pdev->dev.of_node->parent; in aspeed_kcs_probe()
567 if (!of_device_is_compatible(np, "aspeed,ast2400-lpc-v2") && in aspeed_kcs_probe()
568 !of_device_is_compatible(np, "aspeed,ast2500-lpc-v2") && in aspeed_kcs_probe()
569 !of_device_is_compatible(np, "aspeed,ast2600-lpc-v2")) { in aspeed_kcs_probe()
570 dev_err(&pdev->dev, "unsupported LPC device binding\n"); in aspeed_kcs_probe()
571 return -ENODEV; in aspeed_kcs_probe()
582 np = pdev->dev.of_node; in aspeed_kcs_probe()
583 rc = of_property_read_u32_array(np, "aspeed,lpc-interrupts", upstream_irq, 2); in aspeed_kcs_probe()
584 if (rc && rc != -EINVAL) in aspeed_kcs_probe()
585 return -EINVAL; in aspeed_kcs_probe()
589 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in aspeed_kcs_probe()
591 return -ENOMEM; in aspeed_kcs_probe()
593 kcs_bmc = &priv->kcs_bmc; in aspeed_kcs_probe()
594 kcs_bmc->dev = &pdev->dev; in aspeed_kcs_probe()
595 kcs_bmc->channel = channel; in aspeed_kcs_probe()
596 kcs_bmc->ioreg = ast_kcs_bmc_ioregs[channel - 1]; in aspeed_kcs_probe()
597 kcs_bmc->ops = &aspeed_kcs_ops; in aspeed_kcs_probe()
599 priv->map = syscon_node_to_regmap(pdev->dev.parent->of_node); in aspeed_kcs_probe()
600 if (IS_ERR(priv->map)) { in aspeed_kcs_probe()
601 dev_err(&pdev->dev, "Couldn't get regmap\n"); in aspeed_kcs_probe()
602 return -ENODEV; in aspeed_kcs_probe()
605 spin_lock_init(&priv->obe.lock); in aspeed_kcs_probe()
606 priv->obe.remove = false; in aspeed_kcs_probe()
607 timer_setup(&priv->obe.timer, aspeed_kcs_check_obe, 0); in aspeed_kcs_probe()
613 /* Host to BMC IRQ */ in aspeed_kcs_probe()
618 /* BMC to Host IRQ */ in aspeed_kcs_probe()
624 priv->upstream_irq.mode = aspeed_kcs_irq_none; in aspeed_kcs_probe()
632 rc = kcs_bmc_add_device(&priv->kcs_bmc); in aspeed_kcs_probe()
634 dev_warn(&pdev->dev, "Failed to register channel %d: %d\n", kcs_bmc->channel, rc); in aspeed_kcs_probe()
638 dev_info(&pdev->dev, "Initialised channel %d at 0x%x\n", in aspeed_kcs_probe()
639 kcs_bmc->channel, addrs[0]); in aspeed_kcs_probe()
647 struct kcs_bmc_device *kcs_bmc = &priv->kcs_bmc; in aspeed_kcs_remove()
655 spin_lock_irq(&priv->obe.lock); in aspeed_kcs_remove()
656 priv->obe.remove = true; in aspeed_kcs_remove()
657 spin_unlock_irq(&priv->obe.lock); in aspeed_kcs_remove()
658 del_timer_sync(&priv->obe.timer); in aspeed_kcs_remove()
664 { .compatible = "aspeed,ast2400-kcs-bmc-v2" },
665 { .compatible = "aspeed,ast2500-kcs-bmc-v2" },
666 { .compatible = "aspeed,ast2600-kcs-bmc" },