mfd: sta2x11-mfd: Add sta2x11_mfd_get_regs_data() function
authorDavide Ciminaghi <ciminaghi@gnudd.com>
Fri, 9 Nov 2012 14:19:54 +0000 (15:19 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 20 Nov 2012 11:21:14 +0000 (12:21 +0100)
A couple of predefined clocks (mux and gated) need to be
initialized with the virtual address of the clock's controlling
register and the address of a spinlock used to protect against
races.

This function exports such data for all the mfd cells.

Signed-off-by: Davide Ciminaghi <ciminaghi@gnudd.com>
Acked-by: Alessandro Rubini <rubini@gnudd.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/mfd/sta2x11-mfd.c
include/linux/mfd/sta2x11-mfd.h

index 0cac2013bbf6dcc87b9d5861b972d84863968ec7..6d12ab42aba3ce81f2213d6f984e9c1cf3977e68 100644 (file)
@@ -135,6 +135,28 @@ u32 __sta2x11_mfd_mask(struct pci_dev *pdev, u32 reg, u32 mask, u32 val,
 }
 EXPORT_SYMBOL(__sta2x11_mfd_mask);
 
+int sta2x11_mfd_get_regs_data(struct platform_device *dev,
+                             enum sta2x11_mfd_plat_dev index,
+                             void __iomem **regs,
+                             spinlock_t **lock)
+{
+       struct pci_dev *pdev = *(struct pci_dev **)(dev->dev.platform_data);
+       struct sta2x11_mfd *mfd;
+
+       if (!pdev)
+               return -ENODEV;
+       mfd = sta2x11_mfd_find(pdev);
+       if (!mfd)
+               return -ENODEV;
+       if (index >= sta2x11_n_mfd_plat_devs)
+               return -ENODEV;
+       *regs = mfd->regs[index];
+       *lock = &mfd->lock[index];
+       pr_debug("%s %d *regs = %p\n", __func__, __LINE__, *regs);
+       return *regs ? 0 : -ENODEV;
+}
+EXPORT_SYMBOL(sta2x11_mfd_get_regs_data);
+
 /*
  * Special sta2x11-mfd regmap lock/unlock functions
  */
index 83344304f2cf43a2f9e9075d2e2602b151796488..e813e5efbe4edf4a91ade0cc61fe898def4e3e8b 100644 (file)
@@ -474,4 +474,9 @@ u32 sta2x11_apb_soc_regs_mask(struct pci_dev *pdev, u32 reg, u32 mask, u32 val)
 #define COMPENSATION_REG3              0x3cc
 #define TEST_CTL_REG                   0x3d0
 
+extern int sta2x11_mfd_get_regs_data(struct platform_device *pdev,
+                                    enum sta2x11_mfd_plat_dev index,
+                                    void __iomem **regs,
+                                    spinlock_t **lock);
+
 #endif /* __STA2X11_MFD_H */