[PATCH linux dev-4.7 4/8] ipmi: add an Aspeed BT IPMI BMC driver
Cyril Bur
cyrilbur at gmail.com
Thu Nov 3 11:56:01 AEDT 2016
On Wed, 2016-10-26 at 08:57 +0200, Cédric Le Goater wrote:
> Backport from mainline of the main IPMI BMC driver patch plus fixes :
>
> - commit d94655b405ba ("ipmi/bt-bmc: remove redundant return value
> check of platform_get_resource()")
> - commit a3e6061bad62 ("ipmi/bt-bmc: add a dependency on
> ARCH_ASPEED")
> - commit 1a377a79211a ("ipmi: Fix ioremap error handling in bt-bmc")
> - commit 54f9c4d0778b ("ipmi: add an Aspeed BT IPMI BMC driver")
>
> Signed-off-by: Cédric Le Goater <clg at kaod.org>
> ---
[snip]
> +
> +static int bt_bmc_probe(struct platform_device *pdev)
> +{
> + struct bt_bmc *bt_bmc;
> + struct device *dev;
> + struct resource *res;
> + int rc;
> +
> + if (!pdev || !pdev->dev.of_node)
> + return -ENODEV;
> +
> + dev = &pdev->dev;
> + dev_info(dev, "Found bt bmc device\n");
> +
> + bt_bmc = devm_kzalloc(dev, sizeof(*bt_bmc), GFP_KERNEL);
> + if (!bt_bmc)
> + return -ENOMEM;
> +
> + dev_set_drvdata(&pdev->dev, bt_bmc);
> +
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + bt_bmc->base = devm_ioremap_resource(&pdev->dev, res);
> + if (IS_ERR(bt_bmc->base))
> + return PTR_ERR(bt_bmc->base);
> +
> + mutex_init(&bt_bmc->mutex);
> + init_waitqueue_head(&bt_bmc->queue);
> +
> + bt_bmc->miscdev.minor = MISC_DYNAMIC_MINOR,
> + bt_bmc->miscdev.name = DEVICE_NAME,
> + bt_bmc->miscdev.fops = &bt_bmc_fops,
> + bt_bmc->miscdev.parent = dev;
> + rc = misc_register(&bt_bmc->miscdev);
> + if (rc) {
> + dev_err(dev, "Unable to register misc device\n");
> + return rc;
> + }
> +
> + bt_bmc_config_irq(bt_bmc, pdev);
> +
> + if (bt_bmc->irq) {
> + dev_info(dev, "Using IRQ %d\n", bt_bmc->irq);
> + } else {
> + dev_info(dev, "No IRQ; using timer\n");
> + setup_timer(&bt_bmc->poll_timer, poll_timer,
> + (unsigned long)bt_bmc);
> + bt_bmc->poll_timer.expires = jiffies +
> msecs_to_jiffies(10);
> + add_timer(&bt_bmc->poll_timer);
> + }
> +
> + iowrite32((BT_IO_BASE << BT_CR0_IO_BASE) |
> + (BT_IRQ << BT_CR0_IRQ) |
> + BT_CR0_EN_CLR_SLV_RDP |
> + BT_CR0_EN_CLR_SLV_WRP |
> + BT_CR0_ENABLE_IBT,
> + bt_bmc->base + BT_CR0);
> +
> + clr_b_busy(bt_bmc);
> +
> + return 0;
> +}
> +
> +static int bt_bmc_remove(struct platform_device *pdev)
> +{
> + struct bt_bmc *bt_bmc = dev_get_drvdata(&pdev->dev);
> +
> + misc_deregister(&bt_bmc->miscdev);
> + if (!bt_bmc->irq)
> + del_timer_sync(&bt_bmc->poll_timer);
The old bt-host driver had:
devm_iounmap(&pdev->dev, bt_host->base);
devm_kfree(&pdev->dev, bt_host);
Is there kernel magic that means they aren't needed?
> + return 0;
> +}
> +
> +static const struct of_device_id bt_bmc_match[] = {
> + { .compatible = "aspeed,ast2400-bt-bmc" },
> + { },
> +};
> +
> +static struct platform_driver bt_bmc_driver = {
> + .driver = {
> + .name = DEVICE_NAME,
> + .of_match_table = bt_bmc_match,
> + },
> + .probe = bt_bmc_probe,
> + .remove = bt_bmc_remove,
> +};
> +
> +module_platform_driver(bt_bmc_driver);
> +
> +MODULE_DEVICE_TABLE(of, bt_bmc_match);
> +MODULE_LICENSE("GPL");
> +MODULE_AUTHOR("Alistair Popple <alistair at popple.id.au>");
> +MODULE_DESCRIPTION("Linux device interface to the BT interface");
> diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
> index ec10cfef166a..9493842de93b 100644
> --- a/include/uapi/linux/Kbuild
> +++ b/include/uapi/linux/Kbuild
> @@ -74,6 +74,7 @@ header-y += bpf_common.h
> header-y += bpf.h
> header-y += bpqether.h
> header-y += bsg.h
> +header-y += bt-bmc.h
> header-y += btrfs.h
> header-y += can.h
> header-y += capability.h
> diff --git a/include/uapi/linux/bt-bmc.h b/include/uapi/linux/bt-
> bmc.h
> new file mode 100644
> index 000000000000..d9ec766a63d0
> --- /dev/null
> +++ b/include/uapi/linux/bt-bmc.h
> @@ -0,0 +1,18 @@
> +/*
> + * Copyright (c) 2015-2016, IBM Corporation.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version
> + * 2 of the License, or (at your option) any later version.
> + */
> +
> +#ifndef _UAPI_LINUX_BT_BMC_H
> +#define _UAPI_LINUX_BT_BMC_H
> +
> +#include <linux/ioctl.h>
> +
> +#define __BT_BMC_IOCTL_MAGIC 0xb1
> +#define BT_BMC_IOCTL_SMS_ATN _IO(__BT_BMC_IOCTL_MAGIC, 0x00)
> +
> +#endif /* _UAPI_LINUX_BT_BMC_H */
More information about the openbmc
mailing list