2 * Greybus kernel "version" glue logic.
4 * Copyright 2014 Google Inc.
5 * Copyright 2014 Linaro Ltd.
7 * Released under the GPLv2 only.
9 * Backports of newer kernel apis to allow the code to build properly on older
10 * kernel versions. Remove this file when merging to upstream, it should not be
14 #ifndef __GREYBUS_KERNEL_VER_H
15 #define __GREYBUS_KERNEL_VER_H
17 #include <linux/kernel.h>
18 #include <linux/version.h>
20 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
21 /* Commit: 297d716 power_supply: Change ownership from driver to core */
22 #define CORE_OWNS_PSY_STRUCT
26 * The GPIO api sucks rocks in places, like removal, so work around their
27 * explicit requirements of catching the return value for kernels older than
28 * 3.17, which they explicitly changed in the 3.17 kernel. Consistency is
31 #include <linux/gpio.h>
33 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)
34 static inline void gb_gpiochip_remove(struct gpio_chip *chip)
36 gpiochip_remove(chip);
39 static inline void gb_gpiochip_remove(struct gpio_chip *chip)
43 ret = gpiochip_remove(chip);
47 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)
48 #define MMC_HS400_SUPPORTED
49 #define MMC_DDR52_DEFINED
52 #ifndef MMC_CAP2_CORE_RUNTIME_PM
53 #define MMC_CAP2_CORE_RUNTIME_PM 0
56 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)
57 #define MMC_POWER_UNDEFINED_SUPPORTED
60 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)
62 * At this time the internal API for the set brightness was changed to the async
63 * version, and one sync API was added to handle cases that need immediate
64 * effect. Also, the led class flash and lock for sysfs access was introduced.
66 #define LED_HAVE_SET_SYNC
67 #define LED_HAVE_FLASH
69 #include <linux/led-class-flash.h>
72 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
74 * New change in LED api, the set_sync operation was renamed to set_blocking and
75 * the workqueue is now handle by core. So, only one set operation is need.
77 #undef LED_HAVE_SET_SYNC
78 #define LED_HAVE_SET_BLOCKING
81 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
83 * New helper functions for registering/unregistering flash led devices as v4l2
84 * subdevices were added.
86 #define V4L2_HAVE_FLASH
87 #include <media/v4l2-flash-led-class.h>
90 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
92 * Power supply get by name need to drop reference after call
98 * General power supply properties that could be absent from various reasons,
99 * like kernel versions or vendor specific versions
101 #ifndef POWER_SUPPLY_PROP_VOLTAGE_BOOT
102 #define POWER_SUPPLY_PROP_VOLTAGE_BOOT -1
104 #ifndef POWER_SUPPLY_PROP_CURRENT_BOOT
105 #define POWER_SUPPLY_PROP_CURRENT_BOOT -1
107 #ifndef POWER_SUPPLY_PROP_CALIBRATE
108 #define POWER_SUPPLY_PROP_CALIBRATE -1
111 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
112 #define SPI_DEV_MODALIAS "spidev"
113 #define SPI_NOR_MODALIAS "spi-nor"
115 #define SPI_DEV_MODALIAS "spidev"
116 #define SPI_NOR_MODALIAS "m25p80"
119 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0)
120 /* Starting from this version, the spi core handles runtime pm automatically */
121 #define SPI_CORE_SUPPORT_PM
124 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)
126 * After commit b2b49ccbdd54 (PM: Kconfig: Set PM_RUNTIME if PM_SLEEP is
127 * selected) PM_RUNTIME is always set if PM is set, so files that are build
128 * conditionally if CONFIG_PM_RUNTIME is set may now be build if CONFIG_PM is
133 #define CONFIG_PM_RUNTIME
134 #endif /* CONFIG_PM */
137 #endif /* __GREYBUS_KERNEL_VER_H */