diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-04-01 16:13:21 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-04-01 16:13:21 -0700 |
commit | 675c354a95d5375153b8bb80a0448cab916c7991 (patch) | |
tree | 88cbc5a5a31dd1c1016271006a8d56cfe0abf7bd /drivers/mcb/mcb-pci.c | |
parent | c70929147a10fa4538886cb23b934b509c4c0e49 (diff) | |
parent | 1b3fa22e0234d613df967445cd34807e10fa54fa (diff) |
Merge tag 'char-misc-3.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc driver patches from Greg KH:
"Here's the big char/misc driver updates for 3.15-rc1.
Lots of various things here, including the new mcb driver subsystem.
All of these have been in linux-next for a while"
* tag 'char-misc-3.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (118 commits)
extcon: Move OF helper function to extcon core and change function name
extcon: of: Remove unnecessary function call by using the name of device_node
extcon: gpio: Use SIMPLE_DEV_PM_OPS macro
extcon: palmas: Use SIMPLE_DEV_PM_OPS macro
mei: don't use deprecated DEFINE_PCI_DEVICE_TABLE macro
mei: amthif: fix checkpatch error
mei: client.h fix checkpatch errors
mei: use cl_dbg where appropriate
mei: fix Unnecessary space after function pointer name
mei: report consistently copy_from/to_user failures
mei: drop pr_fmt macros
mei: make me hw headers private to me hw.
mei: fix memory leak of pending write cb objects
mei: me: do not reset when less than expected data is received
drivers: mcb: Fix build error discovered by 0-day bot
cs5535-mfgpt: Simplify dependencies
spmi: pm: drop bus-level PM suspend/resume routines
spmi: pmic_arb: make selectable on ARCH_QCOM
Drivers: hv: vmbus: Increase the limit on the number of pfns we can handle
pch_phub: Report error writing MAC back to user
...
Diffstat (limited to 'drivers/mcb/mcb-pci.c')
-rw-r--r-- | drivers/mcb/mcb-pci.c | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/drivers/mcb/mcb-pci.c b/drivers/mcb/mcb-pci.c new file mode 100644 index 000000000000..99c742cbfb5b --- /dev/null +++ b/drivers/mcb/mcb-pci.c @@ -0,0 +1,114 @@ +/* + * MEN Chameleon Bus. + * + * Copyright (C) 2014 MEN Mikroelektronik GmbH (www.men.de) + * Author: Johannes Thumshirn <johannes.thumshirn@men.de> + * + * 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; version 2 of the License. + */ + +#include <linux/module.h> +#include <linux/pci.h> +#include <linux/mcb.h> + +#include "mcb-internal.h" + +struct priv { + struct mcb_bus *bus; + void __iomem *base; +}; + +static int mcb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) +{ + struct priv *priv; + phys_addr_t mapbase; + int ret; + int num_cells; + unsigned long flags; + + priv = devm_kzalloc(&pdev->dev, sizeof(struct priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + ret = pci_enable_device(pdev); + if (ret) { + dev_err(&pdev->dev, "Failed to enable PCI device\n"); + return -ENODEV; + } + + mapbase = pci_resource_start(pdev, 0); + if (!mapbase) { + dev_err(&pdev->dev, "No PCI resource\n"); + goto err_start; + } + + ret = pci_request_region(pdev, 0, KBUILD_MODNAME); + if (ret) { + dev_err(&pdev->dev, "Failed to request PCI BARs\n"); + goto err_start; + } + + priv->base = pci_iomap(pdev, 0, 0); + if (!priv->base) { + dev_err(&pdev->dev, "Cannot ioremap\n"); + ret = -ENOMEM; + goto err_ioremap; + } + + flags = pci_resource_flags(pdev, 0); + if (flags & IORESOURCE_IO) { + ret = -ENOTSUPP; + dev_err(&pdev->dev, + "IO mapped PCI devices are not supported\n"); + goto err_ioremap; + } + + pci_set_drvdata(pdev, priv); + + priv->bus = mcb_alloc_bus(); + + ret = chameleon_parse_cells(priv->bus, mapbase, priv->base); + if (ret < 0) + goto err_drvdata; + num_cells = ret; + + dev_dbg(&pdev->dev, "Found %d cells\n", num_cells); + + mcb_bus_add_devices(priv->bus); + +err_drvdata: + pci_iounmap(pdev, priv->base); +err_ioremap: + pci_release_region(pdev, 0); +err_start: + pci_disable_device(pdev); + return ret; +} + +static void mcb_pci_remove(struct pci_dev *pdev) +{ + struct priv *priv = pci_get_drvdata(pdev); + + mcb_release_bus(priv->bus); +} + +static const struct pci_device_id mcb_pci_tbl[] = { + { PCI_DEVICE(PCI_VENDOR_ID_MEN, PCI_DEVICE_ID_MEN_CHAMELEON) }, + { 0 }, +}; +MODULE_DEVICE_TABLE(pci, mcb_pci_tbl); + +static struct pci_driver mcb_pci_driver = { + .name = "mcb-pci", + .id_table = mcb_pci_tbl, + .probe = mcb_pci_probe, + .remove = mcb_pci_remove, +}; + +module_pci_driver(mcb_pci_driver); + +MODULE_AUTHOR("Johannes Thumshirn <johannes.thumshirn@men.de>"); +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("MCB over PCI support"); |