aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-01-12 23:25:09 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-01-12 23:25:09 -0500
commit67990608c8b95d2b8ccc29932376ae73d5818727 (patch)
tree760f66ff4a41d38d52acdbc65a526c45d1ef4f48 /include/linux
parentc17488d06666153a14dd3f21bd10eba58383f6c1 (diff)
parenta889f766dbb7d016b858e4dd157b06587fdb570f (diff)
Merge tag 'pm+acpi-4.5-rc1-1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull oower management and ACPI updates from Rafael Wysocki: "As far as the number of commits goes, ACPICA takes the lead this time, followed by cpufreq and the device properties framework changes. The most significant new feature is the debugfs-based interface to the ACPICA's AML debugger added in the previous cycle and a new user space tool for accessing it. On the cpufreq front, the core is updated to handle governors more efficiently, particularly on systems where a single cpufreq policy object is shared between multiple CPUs, and there are quite a few changes in drivers (intel_pstate, cpufreq-dt etc). The device properties framework is updated to handle built-in (ie included in the kernel itself) device properties better, among other things by adding a fallback mechanism that will allow drivers to provide default properties to be used in case the plaform firmware doesn't provide the properties expected by them. The Operating Performance Points (OPP) framework gets new DT bindings and debugfs support. A new cpufreq driver for ST platforms is added and the ACPI driver for AMD SoCs will now support the APM X-Gene ACPI I2C device. The rest is mostly fixes and cleanups all over. Specifics: - Add a debugfs-based interface for interacting with the ACPICA's AML debugger introduced in the previous cycle and a new user space tool for that, fix some bugs related to the AML debugger and clean up the code in question (Lv Zheng, Dan Carpenter, Colin Ian King, Markus Elfring). - Update ACPICA to upstream revision 20151218 including a number of fixes and cleanups in the ACPICA core (Bob Moore, Lv Zheng, Labbe Corentin, Prarit Bhargava, Colin Ian King, David E Box, Rafael Wysocki). In particular, the previously added erroneous support for the _SUB object is dropped, the concatenate operator will support all ACPI objects now, the Debug Object handling is improved, the SuperName handling of parameters being control methods is fixed, the ObjectType operator handling is updated to follow ACPI 5.0A and the handling of CondRefOf and RefOf is updated accordingly, module- level code will be executed after loading each ACPI table now (instead of being run once after all tables containing AML have been loaded), the Operation Region handlers management is updated to fix some reported problems and a the ACPICA code in the kernel is more in line with the upstream now. - Update the ACPI backlight driver to provide information on whether or not it will generate key-presses for brightness change hotkeys and update some platform drivers (dell-wmi, thinkpad_acpi) to use that information to avoid sending double key-events to users pace for these, add new ACPI backlight quirks (Hans de Goede, Aaron Lu, Adrien Schildknecht). - Improve the ACPI handling of interrupt GPIOs (Christophe Ricard). - Fix the handling of the list of device IDs of device objects found in the ACPI namespace and add a helper for checking if there is a device object for a given device ID (Lukas Wunner). - Change the logic in the ACPI namespace scanning code to create struct acpi_device objects for all ACPI device objects found in the namespace even if _STA fails for them which helps to avoid device enumeration problems on Microsoft Surface 3 (Aaron Lu). - Add support for the APM X-Gene ACPI I2C device to the ACPI driver for AMD SoCs (Loc Ho). - Fix the long-standing issue with the DMA controller on Intel SoCs where ACPI tables have no power management support for the DMA controller itself, but it can be powered off automatically when the last (other) device on the SoC is powered off via ACPI and clean up the ACPI driver for Intel SoCs (acpi-lpss) after previous attempts to fix that problem (Andy Shevchenko). - Assorted ACPI fixes and cleanups (Andy Lutomirski, Colin Ian King, Javier Martinez Canillas, Ken Xue, Mathias Krause, Rafael Wysocki, Sinan Kaya). - Update the device properties framework for better handling of built-in properties, add support for built-in properties to the platform bus type, update the MFD subsystem's handling of device properties and add support for passing default configuration data as device properties to the intel-lpss MFD drivers, convert the designware I2C driver to use the unified device properties API and add a fallback mechanism for using default built-in properties if the platform firmware fails to provide the properties as expected by drivers (Andy Shevchenko, Mika Westerberg, Heikki Krogerus, Andrew Morton). - Add new Device Tree bindings to the Operating Performance Points (OPP) framework and update the exynos4412 DT binding accordingly, introduce debugfs support for the OPP framework (Viresh Kumar, Bartlomiej Zolnierkiewicz). - Migrate the mt8173 cpufreq driver to the new OPP bindings (Pi-Cheng Chen). - Update the cpufreq core to make the handling of governors more efficient, especially on systems where policy objects are shared between multiple CPUs (Viresh Kumar, Rafael Wysocki). - Fix cpufreq governor handling on configurations with CONFIG_HZ_PERIODIC set (Chen Yu). - Clean up the cpufreq core code related to the boost sysfs knob support and update the ACPI cpufreq driver accordingly (Rafael Wysocki). - Add a new cpufreq driver for ST platforms and corresponding Device Tree bindings (Lee Jones). - Update the intel_pstate driver to allow the P-state selection algorithm used by it to depend on the CPU ID of the processor it is running on, make it use a special P-state selection algorithm (with an IO wait time compensation tweak) on Atom CPUs based on the Airmont and Silvermont cores so as to reduce their energy consumption and improve intel_pstate documentation (Philippe Longepe, Srinivas Pandruvada). - Update the cpufreq-dt driver to support registering cooling devices that use the (P * V^2 * f) dynamic power draw formula where V is the voltage, f is the frequency and P is a constant coefficient provided by Device Tree and update the arm_big_little cpufreq driver to use that support (Punit Agrawal). - Assorted cpufreq driver (cpufreq-dt, qoriq, pcc-cpufreq, blackfin-cpufreq) updates (Andrzej Hajda, Hongtao Jia, Jacob Tanenbaum, Markus Elfring). - cpuidle core tweaks related to polling and measured_us calculation (Rik van Riel). - Removal of modularity from a few cpuidle drivers (clps711x, ux500, exynos) that cannot be built as modules in practice (Paul Gortmaker). - PM core update to prevent devices from being probed during system suspend/resume which is generally problematic and may lead to inconsistent behavior (Grygorii Strashko). - Assorted updates of the PM core and related code (Julia Lawall, Manuel Pégourié-Gonnard, Maruthi Bayyavarapu, Rafael Wysocki, Ulf Hansson). - PNP bus type updates (Christophe Le Roy, Heiner Kallweit). - PCI PM code cleanups (Jarkko Nikula, Julia Lawall). - cpupower tool updates (Jacob Tanenbaum, Thomas Renninger)" * tag 'pm+acpi-4.5-rc1-1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (177 commits) PM / clk: don't leave clocks enabled when driver not bound i2c: dw: Add APM X-Gene ACPI I2C device support ACPI / APD: Add APM X-Gene ACPI I2C device support ACPI / LPSS: change 'does not have' to 'has' in comment Revert "dmaengine: dw: platform: provide platform data for Intel" dmaengine: dw: return immediately from IRQ when DMA isn't in use dmaengine: dw: platform: power on device on shutdown ACPI / LPSS: override power state for LPSS DMA device PM / OPP: Use snprintf() instead of sprintf() Documentation: cpufreq: intel_pstate: enhance documentation ACPI, PCI, irq: remove redundant check for null string pointer ACPI / video: driver must be registered before checking for keypresses cpufreq-dt: fix handling regulator_get_voltage() result cpufreq: governor: Fix negative idle_time when configured with CONFIG_HZ_PERIODIC PM / sleep: Add support for read-only sysfs attributes ACPI: Fix white space in a structure definition ACPI / SBS: fix inconsistent indenting inside if statement PNP: respect PNP_DRIVER_RES_DO_NOT_CHANGE when detaching ACPI / PNP: constify device IDs ACPI / PCI: Simplify acpi_penalize_isa_irq() ...
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/acpi.h72
-rw-r--r--include/linux/cpufreq.h6
-rw-r--r--include/linux/device.h1
-rw-r--r--include/linux/mfd/core.h5
-rw-r--r--include/linux/platform_device.h5
-rw-r--r--include/linux/pm_opp.h22
-rw-r--r--include/linux/pm_runtime.h5
-rw-r--r--include/linux/powercap.h4
-rw-r--r--include/linux/property.h107
9 files changed, 204 insertions, 23 deletions
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 1991aea2ec4c..06ed7e54033e 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -37,6 +37,8 @@
37#include <linux/list.h> 37#include <linux/list.h>
38#include <linux/mod_devicetable.h> 38#include <linux/mod_devicetable.h>
39#include <linux/dynamic_debug.h> 39#include <linux/dynamic_debug.h>
40#include <linux/module.h>
41#include <linux/mutex.h>
40 42
41#include <acpi/acpi_bus.h> 43#include <acpi/acpi_bus.h>
42#include <acpi/acpi_drivers.h> 44#include <acpi/acpi_drivers.h>
@@ -119,6 +121,75 @@ typedef int (*acpi_tbl_table_handler)(struct acpi_table_header *table);
119typedef int (*acpi_tbl_entry_handler)(struct acpi_subtable_header *header, 121typedef int (*acpi_tbl_entry_handler)(struct acpi_subtable_header *header,
120 const unsigned long end); 122 const unsigned long end);
121 123
124/* Debugger support */
125
126struct acpi_debugger_ops {
127 int (*create_thread)(acpi_osd_exec_callback function, void *context);
128 ssize_t (*write_log)(const char *msg);
129 ssize_t (*read_cmd)(char *buffer, size_t length);
130 int (*wait_command_ready)(bool single_step, char *buffer, size_t length);
131 int (*notify_command_complete)(void);
132};
133
134struct acpi_debugger {
135 const struct acpi_debugger_ops *ops;
136 struct module *owner;
137 struct mutex lock;
138};
139
140#ifdef CONFIG_ACPI_DEBUGGER
141int __init acpi_debugger_init(void);
142int acpi_register_debugger(struct module *owner,
143 const struct acpi_debugger_ops *ops);
144void acpi_unregister_debugger(const struct acpi_debugger_ops *ops);
145int acpi_debugger_create_thread(acpi_osd_exec_callback function, void *context);
146ssize_t acpi_debugger_write_log(const char *msg);
147ssize_t acpi_debugger_read_cmd(char *buffer, size_t buffer_length);
148int acpi_debugger_wait_command_ready(void);
149int acpi_debugger_notify_command_complete(void);
150#else
151static inline int acpi_debugger_init(void)
152{
153 return -ENODEV;
154}
155
156static inline int acpi_register_debugger(struct module *owner,
157 const struct acpi_debugger_ops *ops)
158{
159 return -ENODEV;
160}
161
162static inline void acpi_unregister_debugger(const struct acpi_debugger_ops *ops)
163{
164}
165
166static inline int acpi_debugger_create_thread(acpi_osd_exec_callback function,
167 void *context)
168{
169 return -ENODEV;
170}
171
172static inline int acpi_debugger_write_log(const char *msg)
173{
174 return -ENODEV;
175}
176
177static inline int acpi_debugger_read_cmd(char *buffer, u32 buffer_length)
178{
179 return -ENODEV;
180}
181
182static inline int acpi_debugger_wait_command_ready(void)
183{
184 return -ENODEV;
185}
186
187static inline int acpi_debugger_notify_command_complete(void)
188{
189 return -ENODEV;
190}
191#endif
192
122#ifdef CONFIG_ACPI_INITRD_TABLE_OVERRIDE 193#ifdef CONFIG_ACPI_INITRD_TABLE_OVERRIDE
123void acpi_initrd_override(void *data, size_t size); 194void acpi_initrd_override(void *data, size_t size);
124#else 195#else
@@ -318,6 +389,7 @@ bool acpi_dev_resource_address_space(struct acpi_resource *ares,
318bool acpi_dev_resource_ext_address_space(struct acpi_resource *ares, 389bool acpi_dev_resource_ext_address_space(struct acpi_resource *ares,
319 struct resource_win *win); 390 struct resource_win *win);
320unsigned long acpi_dev_irq_flags(u8 triggering, u8 polarity, u8 shareable); 391unsigned long acpi_dev_irq_flags(u8 triggering, u8 polarity, u8 shareable);
392unsigned int acpi_dev_get_irq_type(int triggering, int polarity);
321bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index, 393bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index,
322 struct resource *res); 394 struct resource *res);
323 395
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 177c7680c1a8..88a4215125bc 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -278,7 +278,6 @@ struct cpufreq_driver {
278 struct freq_attr **attr; 278 struct freq_attr **attr;
279 279
280 /* platform specific boost support code */ 280 /* platform specific boost support code */
281 bool boost_supported;
282 bool boost_enabled; 281 bool boost_enabled;
283 int (*set_boost)(int state); 282 int (*set_boost)(int state);
284}; 283};
@@ -574,7 +573,6 @@ ssize_t cpufreq_show_cpus(const struct cpumask *mask, char *buf);
574 573
575#ifdef CONFIG_CPU_FREQ 574#ifdef CONFIG_CPU_FREQ
576int cpufreq_boost_trigger_state(int state); 575int cpufreq_boost_trigger_state(int state);
577int cpufreq_boost_supported(void);
578int cpufreq_boost_enabled(void); 576int cpufreq_boost_enabled(void);
579int cpufreq_enable_boost_support(void); 577int cpufreq_enable_boost_support(void);
580bool policy_has_boost_freq(struct cpufreq_policy *policy); 578bool policy_has_boost_freq(struct cpufreq_policy *policy);
@@ -583,10 +581,6 @@ static inline int cpufreq_boost_trigger_state(int state)
583{ 581{
584 return 0; 582 return 0;
585} 583}
586static inline int cpufreq_boost_supported(void)
587{
588 return 0;
589}
590static inline int cpufreq_boost_enabled(void) 584static inline int cpufreq_boost_enabled(void)
591{ 585{
592 return 0; 586 return 0;
diff --git a/include/linux/device.h b/include/linux/device.h
index b8f411b57dcb..f627ba20a46c 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -191,6 +191,7 @@ extern int bus_unregister_notifier(struct bus_type *bus,
191 unbound */ 191 unbound */
192#define BUS_NOTIFY_UNBOUND_DRIVER 0x00000007 /* driver is unbound 192#define BUS_NOTIFY_UNBOUND_DRIVER 0x00000007 /* driver is unbound
193 from the device */ 193 from the device */
194#define BUS_NOTIFY_DRIVER_NOT_BOUND 0x00000008 /* driver fails to be bound */
194 195
195extern struct kset *bus_get_kset(struct bus_type *bus); 196extern struct kset *bus_get_kset(struct bus_type *bus);
196extern struct klist *bus_get_device_klist(struct bus_type *bus); 197extern struct klist *bus_get_device_klist(struct bus_type *bus);
diff --git a/include/linux/mfd/core.h b/include/linux/mfd/core.h
index 27dac3ff18b9..bc6f7e00fb3d 100644
--- a/include/linux/mfd/core.h
+++ b/include/linux/mfd/core.h
@@ -17,6 +17,7 @@
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18 18
19struct irq_domain; 19struct irq_domain;
20struct property_set;
20 21
21/* Matches ACPI PNP id, either _HID or _CID, or ACPI _ADR */ 22/* Matches ACPI PNP id, either _HID or _CID, or ACPI _ADR */
22struct mfd_cell_acpi_match { 23struct mfd_cell_acpi_match {
@@ -44,6 +45,10 @@ struct mfd_cell {
44 /* platform data passed to the sub devices drivers */ 45 /* platform data passed to the sub devices drivers */
45 void *platform_data; 46 void *platform_data;
46 size_t pdata_size; 47 size_t pdata_size;
48
49 /* device properties passed to the sub devices drivers */
50 const struct property_set *pset;
51
47 /* 52 /*
48 * Device Tree compatible string 53 * Device Tree compatible string
49 * See: Documentation/devicetree/usage-model.txt Chapter 2.2 for details 54 * See: Documentation/devicetree/usage-model.txt Chapter 2.2 for details
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 6abd019c76f8..03b755521fd9 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -18,6 +18,7 @@
18#define PLATFORM_DEVID_AUTO (-2) 18#define PLATFORM_DEVID_AUTO (-2)
19 19
20struct mfd_cell; 20struct mfd_cell;
21struct property_set;
21 22
22struct platform_device { 23struct platform_device {
23 const char *name; 24 const char *name;
@@ -71,6 +72,8 @@ struct platform_device_info {
71 const void *data; 72 const void *data;
72 size_t size_data; 73 size_t size_data;
73 u64 dma_mask; 74 u64 dma_mask;
75
76 const struct property_set *pset;
74}; 77};
75extern struct platform_device *platform_device_register_full( 78extern struct platform_device *platform_device_register_full(
76 const struct platform_device_info *pdevinfo); 79 const struct platform_device_info *pdevinfo);
@@ -168,6 +171,8 @@ extern int platform_device_add_resources(struct platform_device *pdev,
168 unsigned int num); 171 unsigned int num);
169extern int platform_device_add_data(struct platform_device *pdev, 172extern int platform_device_add_data(struct platform_device *pdev,
170 const void *data, size_t size); 173 const void *data, size_t size);
174extern int platform_device_add_properties(struct platform_device *pdev,
175 const struct property_set *pset);
171extern int platform_device_add(struct platform_device *pdev); 176extern int platform_device_add(struct platform_device *pdev);
172extern void platform_device_del(struct platform_device *pdev); 177extern void platform_device_del(struct platform_device *pdev);
173extern void platform_device_put(struct platform_device *pdev); 178extern void platform_device_put(struct platform_device *pdev);
diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h
index 9a2e50337af9..95403d2ccaf5 100644
--- a/include/linux/pm_opp.h
+++ b/include/linux/pm_opp.h
@@ -55,6 +55,11 @@ int dev_pm_opp_enable(struct device *dev, unsigned long freq);
55int dev_pm_opp_disable(struct device *dev, unsigned long freq); 55int dev_pm_opp_disable(struct device *dev, unsigned long freq);
56 56
57struct srcu_notifier_head *dev_pm_opp_get_notifier(struct device *dev); 57struct srcu_notifier_head *dev_pm_opp_get_notifier(struct device *dev);
58int dev_pm_opp_set_supported_hw(struct device *dev, const u32 *versions,
59 unsigned int count);
60void dev_pm_opp_put_supported_hw(struct device *dev);
61int dev_pm_opp_set_prop_name(struct device *dev, const char *name);
62void dev_pm_opp_put_prop_name(struct device *dev);
58#else 63#else
59static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp) 64static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp)
60{ 65{
@@ -129,6 +134,23 @@ static inline struct srcu_notifier_head *dev_pm_opp_get_notifier(
129{ 134{
130 return ERR_PTR(-EINVAL); 135 return ERR_PTR(-EINVAL);
131} 136}
137
138static inline int dev_pm_opp_set_supported_hw(struct device *dev,
139 const u32 *versions,
140 unsigned int count)
141{
142 return -EINVAL;
143}
144
145static inline void dev_pm_opp_put_supported_hw(struct device *dev) {}
146
147static inline int dev_pm_opp_set_prop_name(struct device *dev, const char *name)
148{
149 return -EINVAL;
150}
151
152static inline void dev_pm_opp_put_prop_name(struct device *dev) {}
153
132#endif /* CONFIG_PM_OPP */ 154#endif /* CONFIG_PM_OPP */
133 155
134#if defined(CONFIG_PM_OPP) && defined(CONFIG_OF) 156#if defined(CONFIG_PM_OPP) && defined(CONFIG_OF)
diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
index 3bdbb4189780..7af093d6a4dd 100644
--- a/include/linux/pm_runtime.h
+++ b/include/linux/pm_runtime.h
@@ -39,6 +39,7 @@ extern int pm_runtime_force_resume(struct device *dev);
39extern int __pm_runtime_idle(struct device *dev, int rpmflags); 39extern int __pm_runtime_idle(struct device *dev, int rpmflags);
40extern int __pm_runtime_suspend(struct device *dev, int rpmflags); 40extern int __pm_runtime_suspend(struct device *dev, int rpmflags);
41extern int __pm_runtime_resume(struct device *dev, int rpmflags); 41extern int __pm_runtime_resume(struct device *dev, int rpmflags);
42extern int pm_runtime_get_if_in_use(struct device *dev);
42extern int pm_schedule_suspend(struct device *dev, unsigned int delay); 43extern int pm_schedule_suspend(struct device *dev, unsigned int delay);
43extern int __pm_runtime_set_status(struct device *dev, unsigned int status); 44extern int __pm_runtime_set_status(struct device *dev, unsigned int status);
44extern int pm_runtime_barrier(struct device *dev); 45extern int pm_runtime_barrier(struct device *dev);
@@ -143,6 +144,10 @@ static inline int pm_schedule_suspend(struct device *dev, unsigned int delay)
143{ 144{
144 return -ENOSYS; 145 return -ENOSYS;
145} 146}
147static inline int pm_runtime_get_if_in_use(struct device *dev)
148{
149 return -EINVAL;
150}
146static inline int __pm_runtime_set_status(struct device *dev, 151static inline int __pm_runtime_set_status(struct device *dev,
147 unsigned int status) { return 0; } 152 unsigned int status) { return 0; }
148static inline int pm_runtime_barrier(struct device *dev) { return 0; } 153static inline int pm_runtime_barrier(struct device *dev) { return 0; }
diff --git a/include/linux/powercap.h b/include/linux/powercap.h
index 4e250417ee30..f0a4e6257dcc 100644
--- a/include/linux/powercap.h
+++ b/include/linux/powercap.h
@@ -208,7 +208,7 @@ struct powercap_zone_constraint_ops {
208struct powercap_zone_constraint { 208struct powercap_zone_constraint {
209 int id; 209 int id;
210 struct powercap_zone *power_zone; 210 struct powercap_zone *power_zone;
211 struct powercap_zone_constraint_ops *ops; 211 const struct powercap_zone_constraint_ops *ops;
212}; 212};
213 213
214 214
@@ -309,7 +309,7 @@ struct powercap_zone *powercap_register_zone(
309 struct powercap_zone *parent, 309 struct powercap_zone *parent,
310 const struct powercap_zone_ops *ops, 310 const struct powercap_zone_ops *ops,
311 int nr_constraints, 311 int nr_constraints,
312 struct powercap_zone_constraint_ops *const_ops); 312 const struct powercap_zone_constraint_ops *const_ops);
313 313
314/** 314/**
315* powercap_unregister_zone() - Unregister a zone device 315* powercap_unregister_zone() - Unregister a zone device
diff --git a/include/linux/property.h b/include/linux/property.h
index 0a3705a7c9f2..b51fcd36d892 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -73,8 +73,8 @@ int fwnode_property_match_string(struct fwnode_handle *fwnode,
73struct fwnode_handle *device_get_next_child_node(struct device *dev, 73struct fwnode_handle *device_get_next_child_node(struct device *dev,
74 struct fwnode_handle *child); 74 struct fwnode_handle *child);
75 75
76#define device_for_each_child_node(dev, child) \ 76#define device_for_each_child_node(dev, child) \
77 for (child = device_get_next_child_node(dev, NULL); child; \ 77 for (child = device_get_next_child_node(dev, NULL); child; \
78 child = device_get_next_child_node(dev, child)) 78 child = device_get_next_child_node(dev, child))
79 79
80void fwnode_handle_put(struct fwnode_handle *fwnode); 80void fwnode_handle_put(struct fwnode_handle *fwnode);
@@ -144,24 +144,100 @@ static inline int fwnode_property_read_u64(struct fwnode_handle *fwnode,
144/** 144/**
145 * struct property_entry - "Built-in" device property representation. 145 * struct property_entry - "Built-in" device property representation.
146 * @name: Name of the property. 146 * @name: Name of the property.
147 * @type: Type of the property. 147 * @length: Length of data making up the value.
148 * @nval: Number of items of type @type making up the value. 148 * @is_array: True when the property is an array.
149 * @value: Value of the property (an array of @nval items of type @type). 149 * @is_string: True when property is a string.
150 * @pointer: Pointer to the property (an array of items of the given type).
151 * @value: Value of the property (when it is a single item of the given type).
150 */ 152 */
151struct property_entry { 153struct property_entry {
152 const char *name; 154 const char *name;
153 enum dev_prop_type type; 155 size_t length;
154 size_t nval; 156 bool is_array;
157 bool is_string;
155 union { 158 union {
156 void *raw_data; 159 union {
157 u8 *u8_data; 160 void *raw_data;
158 u16 *u16_data; 161 u8 *u8_data;
159 u32 *u32_data; 162 u16 *u16_data;
160 u64 *u64_data; 163 u32 *u32_data;
161 const char **str; 164 u64 *u64_data;
162 } value; 165 const char **str;
166 } pointer;
167 union {
168 unsigned long long raw_data;
169 u8 u8_data;
170 u16 u16_data;
171 u32 u32_data;
172 u64 u64_data;
173 const char *str;
174 } value;
175 };
163}; 176};
164 177
178/*
179 * Note: the below four initializers for the anonymous union are carefully
180 * crafted to avoid gcc-4.4.4's problems with initialization of anon unions
181 * and structs.
182 */
183
184#define PROPERTY_ENTRY_INTEGER_ARRAY(_name_, _type_, _val_) \
185{ \
186 .name = _name_, \
187 .length = ARRAY_SIZE(_val_) * sizeof(_type_), \
188 .is_array = true, \
189 .is_string = false, \
190 { .pointer = { _type_##_data = _val_ } }, \
191}
192
193#define PROPERTY_ENTRY_U8_ARRAY(_name_, _val_) \
194 PROPERTY_ENTRY_INTEGER_ARRAY(_name_, u8, _val_)
195#define PROPERTY_ENTRY_U16_ARRAY(_name_, _val_) \
196 PROPERTY_ENTRY_INTEGER_ARRAY(_name_, u16, _val_)
197#define PROPERTY_ENTRY_U32_ARRAY(_name_, _val_) \
198 PROPERTY_ENTRY_INTEGER_ARRAY(_name_, u32, _val_)
199#define PROPERTY_ENTRY_U64_ARRAY(_name_, _val_) \
200 PROPERTY_ENTRY_INTEGER_ARRAY(_name_, u64, _val_)
201
202#define PROPERTY_ENTRY_STRING_ARRAY(_name_, _val_) \
203{ \
204 .name = _name_, \
205 .length = ARRAY_SIZE(_val_) * sizeof(const char *), \
206 .is_array = true, \
207 .is_string = true, \
208 { .pointer = { .str = _val_ } }, \
209}
210
211#define PROPERTY_ENTRY_INTEGER(_name_, _type_, _val_) \
212{ \
213 .name = _name_, \
214 .length = sizeof(_type_), \
215 .is_string = false, \
216 { .value = { ._type_##_data = _val_ } }, \
217}
218
219#define PROPERTY_ENTRY_U8(_name_, _val_) \
220 PROPERTY_ENTRY_INTEGER(_name_, u8, _val_)
221#define PROPERTY_ENTRY_U16(_name_, _val_) \
222 PROPERTY_ENTRY_INTEGER(_name_, u16, _val_)
223#define PROPERTY_ENTRY_U32(_name_, _val_) \
224 PROPERTY_ENTRY_INTEGER(_name_, u32, _val_)
225#define PROPERTY_ENTRY_U64(_name_, _val_) \
226 PROPERTY_ENTRY_INTEGER(_name_, u64, _val_)
227
228#define PROPERTY_ENTRY_STRING(_name_, _val_) \
229{ \
230 .name = _name_, \
231 .length = sizeof(_val_), \
232 .is_string = true, \
233 { .value = { .str = _val_ } }, \
234}
235
236#define PROPERTY_ENTRY_BOOL(_name_) \
237{ \
238 .name = _name_, \
239}
240
165/** 241/**
166 * struct property_set - Collection of "built-in" device properties. 242 * struct property_set - Collection of "built-in" device properties.
167 * @fwnode: Handle to be pointed to by the fwnode field of struct device. 243 * @fwnode: Handle to be pointed to by the fwnode field of struct device.
@@ -172,7 +248,8 @@ struct property_set {
172 struct property_entry *properties; 248 struct property_entry *properties;
173}; 249};
174 250
175void device_add_property_set(struct device *dev, struct property_set *pset); 251int device_add_property_set(struct device *dev, const struct property_set *pset);
252void device_remove_property_set(struct device *dev);
176 253
177bool device_dma_supported(struct device *dev); 254bool device_dma_supported(struct device *dev);
178 255