Lines Matching +full:ctrl +full:- +full:module
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Janz CMOD-IO MODULbus Carrier Board PCI Driver
11 #include <linux/module.h>
21 #define DRV_NAME "janz-cmodio"
23 /* Size of each MODULbus module in PCI BAR4 */
26 /* Maximum number of MODULbus modules on a CMOD-IO carrier board */
29 /* Module Parameters */
46 struct janz_cmodio_onboard_regs __iomem *ctrl; member
51 /* mfd-core API */
58 * Subdevices using the mfd-core API
70 pci = priv->pdev; in cmodio_setup_subdevice()
71 cell = &priv->cells[devno]; in cmodio_setup_subdevice()
72 res = &priv->resources[devno * 3]; in cmodio_setup_subdevice()
73 pdata = &priv->pdata[devno]; in cmodio_setup_subdevice()
75 cell->name = name; in cmodio_setup_subdevice()
76 cell->resources = res; in cmodio_setup_subdevice()
77 cell->num_resources = 3; in cmodio_setup_subdevice()
79 /* Setup the subdevice ID -- must be unique */ in cmodio_setup_subdevice()
80 cell->id = cmodio_id++; in cmodio_setup_subdevice()
83 pdata->modno = modno; in cmodio_setup_subdevice()
84 cell->platform_data = pdata; in cmodio_setup_subdevice()
85 cell->pdata_size = sizeof(*pdata); in cmodio_setup_subdevice()
87 /* MODULbus registers -- PCI BAR3 is big-endian MODULbus access */ in cmodio_setup_subdevice()
88 res->flags = IORESOURCE_MEM; in cmodio_setup_subdevice()
89 res->parent = &pci->resource[3]; in cmodio_setup_subdevice()
90 res->start = pci->resource[3].start + (CMODIO_MODULBUS_SIZE * modno); in cmodio_setup_subdevice()
91 res->end = res->start + CMODIO_MODULBUS_SIZE - 1; in cmodio_setup_subdevice()
94 /* PLX Control Registers -- PCI BAR4 is interrupt and other registers */ in cmodio_setup_subdevice()
95 res->flags = IORESOURCE_MEM; in cmodio_setup_subdevice()
96 res->parent = &pci->resource[4]; in cmodio_setup_subdevice()
97 res->start = pci->resource[4].start; in cmodio_setup_subdevice()
98 res->end = pci->resource[4].end; in cmodio_setup_subdevice()
108 res->flags = IORESOURCE_IRQ; in cmodio_setup_subdevice()
109 res->parent = NULL; in cmodio_setup_subdevice()
110 res->start = 0; in cmodio_setup_subdevice()
111 res->end = 0; in cmodio_setup_subdevice()
120 struct pci_dev *pdev = priv->pdev; in cmodio_probe_submodules()
130 dev_dbg(&priv->pdev->dev, "MODULbus %d: name %s\n", i, name); in cmodio_probe_submodules()
137 dev_err(&priv->pdev->dev, "no MODULbus modules specified, " in cmodio_probe_submodules()
141 return -ENODEV; in cmodio_probe_submodules()
144 return mfd_add_devices(&pdev->dev, 0, priv->cells, in cmodio_probe_submodules()
145 num_probed, NULL, pdev->irq, NULL); in cmodio_probe_submodules()
157 return sysfs_emit(buf, "%x\n", priv->hex); in modulbus_number_show()
181 priv = devm_kzalloc(&dev->dev, sizeof(*priv), GFP_KERNEL); in cmodio_pci_probe()
183 return -ENOMEM; in cmodio_pci_probe()
186 priv->pdev = dev; in cmodio_pci_probe()
191 dev_err(&dev->dev, "unable to enable device\n"); in cmodio_pci_probe()
198 dev_err(&dev->dev, "unable to request regions\n"); in cmodio_pci_probe()
203 priv->ctrl = pci_ioremap_bar(dev, 4); in cmodio_pci_probe()
204 if (!priv->ctrl) { in cmodio_pci_probe()
205 dev_err(&dev->dev, "unable to remap onboard regs\n"); in cmodio_pci_probe()
206 ret = -ENOMEM; in cmodio_pci_probe()
211 priv->hex = ioread8(&priv->ctrl->int_enable); in cmodio_pci_probe()
214 ret = sysfs_create_group(&dev->dev.kobj, &cmodio_sysfs_attr_group); in cmodio_pci_probe()
216 dev_err(&dev->dev, "unable to create sysfs attributes\n"); in cmodio_pci_probe()
224 iowrite8(0xf, &priv->ctrl->int_disable); in cmodio_pci_probe()
229 dev_err(&dev->dev, "unable to probe submodules\n"); in cmodio_pci_probe()
236 sysfs_remove_group(&dev->dev.kobj, &cmodio_sysfs_attr_group); in cmodio_pci_probe()
238 iounmap(priv->ctrl); in cmodio_pci_probe()
251 mfd_remove_devices(&dev->dev); in cmodio_pci_remove()
252 sysfs_remove_group(&dev->dev.kobj, &cmodio_sysfs_attr_group); in cmodio_pci_remove()
253 iounmap(priv->ctrl); in cmodio_pci_remove()
260 /* The list of devices that this module will support */
282 MODULE_DESCRIPTION("Janz CMOD-IO PCI MODULbus Carrier Board Driver");