~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/mfd/ocelot.h

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
  2 /* Copyright 2022 Innovative Advantage Inc. */
  3 
  4 #ifndef _LINUX_MFD_OCELOT_H
  5 #define _LINUX_MFD_OCELOT_H
  6 
  7 #include <linux/err.h>
  8 #include <linux/errno.h>
  9 #include <linux/ioport.h>
 10 #include <linux/platform_device.h>
 11 #include <linux/regmap.h>
 12 #include <linux/types.h>
 13 
 14 struct resource;
 15 
 16 static inline struct regmap *
 17 ocelot_regmap_from_resource_optional(struct platform_device *pdev,
 18                                      unsigned int index,
 19                                      const struct regmap_config *config)
 20 {
 21         struct device *dev = &pdev->dev;
 22         struct resource *res;
 23         void __iomem *regs;
 24 
 25         /*
 26          * Don't use _get_and_ioremap_resource() here, since that will invoke
 27          * prints of "invalid resource" which will simply add confusion.
 28          */
 29         res = platform_get_resource(pdev, IORESOURCE_MEM, index);
 30         if (res) {
 31                 regs = devm_ioremap_resource(dev, res);
 32                 if (IS_ERR(regs))
 33                         return ERR_CAST(regs);
 34                 return devm_regmap_init_mmio(dev, regs, config);
 35         }
 36 
 37         /*
 38          * Fall back to using REG and getting the resource from the parent
 39          * device, which is possible in an MFD configuration
 40          */
 41         if (dev->parent) {
 42                 res = platform_get_resource(pdev, IORESOURCE_REG, index);
 43                 if (!res)
 44                         return NULL;
 45 
 46                 return dev_get_regmap(dev->parent, res->name);
 47         }
 48 
 49         return NULL;
 50 }
 51 
 52 static inline struct regmap *
 53 ocelot_regmap_from_resource(struct platform_device *pdev, unsigned int index,
 54                             const struct regmap_config *config)
 55 {
 56         struct regmap *map;
 57 
 58         map = ocelot_regmap_from_resource_optional(pdev, index, config);
 59         return map ?: ERR_PTR(-ENOENT);
 60 }
 61 
 62 #endif
 63 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php