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

TOMOYO Linux Cross Reference
Linux/arch/powerpc/platforms/pasemi/misc.c

Version: ~ [ linux-5.5 ] ~ [ linux-5.4.15 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.98 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.167 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.211 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.211 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.81 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Copyright (C) 2007 PA Semi, Inc
  3  *
  4  * Parts based on arch/powerpc/sysdev/fsl_soc.c:
  5  *
  6  * 2006 (c) MontaVista Software, Inc.
  7  *
  8  * This program is free software; you can redistribute  it and/or modify it
  9  * under  the terms of  the GNU General  Public License as published by the
 10  * Free Software Foundation;  either version 2 of the  License, or (at your
 11  * option) any later version.
 12  */
 13 
 14 #include <linux/errno.h>
 15 #include <linux/kernel.h>
 16 #include <linux/pci.h>
 17 #include <linux/of.h>
 18 #include <linux/i2c.h>
 19 
 20 #ifdef CONFIG_I2C_BOARDINFO
 21 /* The below is from fsl_soc.c.  It's copied because since there are no
 22  * official bus bindings at this time it doesn't make sense to share across
 23  * the platforms, even though they happen to be common.
 24  */
 25 struct i2c_driver_device {
 26         char    *of_device;
 27         char    *i2c_type;
 28 };
 29 
 30 static struct i2c_driver_device i2c_devices[] __initdata = {
 31         {"dallas,ds1338",  "ds1338"},
 32 };
 33 
 34 static int __init find_i2c_driver(struct device_node *node,
 35                                      struct i2c_board_info *info)
 36 {
 37         int i;
 38 
 39         for (i = 0; i < ARRAY_SIZE(i2c_devices); i++) {
 40                 if (!of_device_is_compatible(node, i2c_devices[i].of_device))
 41                         continue;
 42                 if (strlcpy(info->type, i2c_devices[i].i2c_type,
 43                             I2C_NAME_SIZE) >= I2C_NAME_SIZE)
 44                         return -ENOMEM;
 45                 return 0;
 46         }
 47         return -ENODEV;
 48 }
 49 
 50 static int __init pasemi_register_i2c_devices(void)
 51 {
 52         struct pci_dev *pdev;
 53         struct device_node *adap_node;
 54         struct device_node *node;
 55 
 56         pdev = NULL;
 57         while ((pdev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa003, pdev))) {
 58                 adap_node = pci_device_to_OF_node(pdev);
 59 
 60                 if (!adap_node)
 61                         continue;
 62 
 63                 node = NULL;
 64                 while ((node = of_get_next_child(adap_node, node))) {
 65                         struct i2c_board_info info = {};
 66                         const u32 *addr;
 67                         int len;
 68 
 69                         addr = of_get_property(node, "reg", &len);
 70                         if (!addr || len < sizeof(int) ||
 71                             *addr > (1 << 10) - 1) {
 72                                 printk(KERN_WARNING
 73                                         "pasemi_register_i2c_devices: "
 74                                         "invalid i2c device entry\n");
 75                                 continue;
 76                         }
 77 
 78                         info.irq = irq_of_parse_and_map(node, 0);
 79                         if (info.irq == NO_IRQ)
 80                                 info.irq = -1;
 81 
 82                         if (find_i2c_driver(node, &info) < 0)
 83                                 continue;
 84 
 85                         info.addr = *addr;
 86 
 87                         i2c_register_board_info(PCI_FUNC(pdev->devfn), &info,
 88                                                 1);
 89                 }
 90         }
 91         return 0;
 92 }
 93 device_initcall(pasemi_register_i2c_devices);
 94 #endif
 95 

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

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | 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.

osdn.jp