at v4.13 4.1 kB view raw
1#ifndef _LINUX_OF_PLATFORM_H 2#define _LINUX_OF_PLATFORM_H 3/* 4 * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corp. 5 * <benh@kernel.crashing.org> 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 10 * 2 of the License, or (at your option) any later version. 11 * 12 */ 13 14#include <linux/device.h> 15#include <linux/mod_devicetable.h> 16#include <linux/pm.h> 17#include <linux/of_device.h> 18#include <linux/platform_device.h> 19 20/** 21 * struct of_dev_auxdata - lookup table entry for device names & platform_data 22 * @compatible: compatible value of node to match against node 23 * @phys_addr: Start address of registers to match against node 24 * @name: Name to assign for matching nodes 25 * @platform_data: platform_data to assign for matching nodes 26 * 27 * This lookup table allows the caller of of_platform_populate() to override 28 * the names of devices when creating devices from the device tree. The table 29 * should be terminated with an empty entry. It also allows the platform_data 30 * pointer to be set. 31 * 32 * The reason for this functionality is that some Linux infrastructure uses 33 * the device name to look up a specific device, but the Linux-specific names 34 * are not encoded into the device tree, so the kernel needs to provide specific 35 * values. 36 * 37 * Note: Using an auxdata lookup table should be considered a last resort when 38 * converting a platform to use the DT. Normally the automatically generated 39 * device name will not matter, and drivers should obtain data from the device 40 * node instead of from an anonymous platform_data pointer. 41 */ 42struct of_dev_auxdata { 43 char *compatible; 44 resource_size_t phys_addr; 45 char *name; 46 void *platform_data; 47}; 48 49/* Macro to simplify populating a lookup table */ 50#define OF_DEV_AUXDATA(_compat,_phys,_name,_pdata) \ 51 { .compatible = _compat, .phys_addr = _phys, .name = _name, \ 52 .platform_data = _pdata } 53 54extern const struct of_device_id of_default_bus_match_table[]; 55 56/* Platform drivers register/unregister */ 57extern struct platform_device *of_device_alloc(struct device_node *np, 58 const char *bus_id, 59 struct device *parent); 60extern struct platform_device *of_find_device_by_node(struct device_node *np); 61 62/* Platform devices and busses creation */ 63extern struct platform_device *of_platform_device_create(struct device_node *np, 64 const char *bus_id, 65 struct device *parent); 66 67extern int of_platform_device_destroy(struct device *dev, void *data); 68extern int of_platform_bus_probe(struct device_node *root, 69 const struct of_device_id *matches, 70 struct device *parent); 71#ifdef CONFIG_OF_ADDRESS 72extern int of_platform_populate(struct device_node *root, 73 const struct of_device_id *matches, 74 const struct of_dev_auxdata *lookup, 75 struct device *parent); 76extern int of_platform_default_populate(struct device_node *root, 77 const struct of_dev_auxdata *lookup, 78 struct device *parent); 79extern void of_platform_depopulate(struct device *parent); 80 81extern int devm_of_platform_populate(struct device *dev); 82 83extern void devm_of_platform_depopulate(struct device *dev); 84#else 85static inline int of_platform_populate(struct device_node *root, 86 const struct of_device_id *matches, 87 const struct of_dev_auxdata *lookup, 88 struct device *parent) 89{ 90 return -ENODEV; 91} 92static inline int of_platform_default_populate(struct device_node *root, 93 const struct of_dev_auxdata *lookup, 94 struct device *parent) 95{ 96 return -ENODEV; 97} 98static inline void of_platform_depopulate(struct device *parent) { } 99 100static inline int devm_of_platform_populate(struct device *dev) 101{ 102 return -ENODEV; 103} 104 105static inline void devm_of_platform_depopulate(struct device *dev) { } 106#endif 107 108#if defined(CONFIG_OF_DYNAMIC) && defined(CONFIG_OF_ADDRESS) 109extern void of_platform_register_reconfig_notifier(void); 110#else 111static inline void of_platform_register_reconfig_notifier(void) { } 112#endif 113 114#endif /* _LINUX_OF_PLATFORM_H */