Convert CONFIG_SYS_INTERLAKEN et al to Kconfig
[platform/kernel/u-boot.git] / include / clk.h
index 303b04a..138766b 100644 (file)
@@ -88,8 +88,9 @@ struct clk_bulk {
        unsigned int count;
 };
 
-#if CONFIG_IS_ENABLED(OF_CONTROL) && CONFIG_IS_ENABLED(CLK)
 struct phandle_1_arg;
+
+#if CONFIG_IS_ENABLED(OF_CONTROL) && CONFIG_IS_ENABLED(CLK)
 /**
  * clk_get_by_phandle() - Get a clock by its phandle information (of-platadata)
  * @dev: Device containing the phandle
@@ -258,12 +259,26 @@ int clk_release_all(struct clk *clk, int count);
 void devm_clk_put(struct udevice *dev, struct clk *clk);
 
 #else
+
+static inline int clk_get_by_phandle(struct udevice *dev, const
+                                    struct phandle_1_arg *cells,
+                                    struct clk *clk)
+{
+       return -ENOSYS;
+}
+
 static inline int clk_get_by_index(struct udevice *dev, int index,
                                   struct clk *clk)
 {
        return -ENOSYS;
 }
 
+static inline int clk_get_by_index_nodev(ofnode node, int index,
+                                        struct clk *clk)
+{
+       return -ENOSYS;
+}
+
 static inline int clk_get_bulk(struct udevice *dev, struct clk_bulk *bulk)
 {
        return -ENOSYS;
@@ -275,6 +290,17 @@ static inline int clk_get_by_name(struct udevice *dev, const char *name,
        return -ENOSYS;
 }
 
+static inline struct clk *devm_clk_get(struct udevice *dev, const char *id)
+{
+       return ERR_PTR(-ENOSYS);
+}
+
+static inline struct clk *devm_clk_get_optional(struct udevice *dev,
+                                               const char *id)
+{
+       return ERR_PTR(-ENOSYS);
+}
+
 static inline int
 clk_get_by_name_nodev(ofnode node, const char *name, struct clk *clk)
 {
@@ -285,9 +311,37 @@ static inline int clk_release_all(struct clk *clk, int count)
 {
        return -ENOSYS;
 }
+
+static inline void devm_clk_put(struct udevice *dev, struct clk *clk)
+{
+}
 #endif
 
 /**
+ * clk_get_by_name_optional() - Get/request a optional clock by name.
+ * @dev:       The client device.
+ * @name:      The name of the clock to request, within the client's list of
+ *             clocks.
+ * @clk:       A pointer to a clock struct to initialize.
+ *
+ * Behaves the same as clk_get_by_name(), except when there is no clock
+ * provider. In the latter case, return 0.
+ *
+ * Return: 0 if OK, or a negative error code.
+ */
+static inline int clk_get_by_name_optional(struct udevice *dev,
+                                          const char *name, struct clk *clk)
+{
+       int ret;
+
+       ret = clk_get_by_name(dev, name, clk);
+       if (ret == -ENODATA)
+               return 0;
+
+       return ret;
+}
+
+/**
  * clk_get_by_name_nodev_optional - Get/request an optinonal clock by name
  *             without a device.
  * @node:      The client ofnode.
@@ -390,9 +444,9 @@ int clk_request(struct udevice *dev, struct clk *clk);
  * @clk:       A clock struct that was previously successfully requested by
  *             clk_request/get_by_*().
  *
- * Return: 0 if OK, or a negative error code.
+ * Free resources allocated by clk_request() (or any clk_get_* function).
  */
-int clk_free(struct clk *clk);
+void clk_free(struct clk *clk);
 
 /**
  * clk_get_rate() - Get current clock rate.
@@ -420,7 +474,7 @@ struct clk *clk_get_parent(struct clk *clk);
  *
  * Return: clock rate in Hz, or -ve error code.
  */
-long long clk_get_parent_rate(struct clk *clk);
+ulong clk_get_parent_rate(struct clk *clk);
 
 /**
  * clk_round_rate() - Adjust a rate to the exact rate a clock can provide
@@ -538,9 +592,9 @@ static inline int clk_request(struct udevice *dev, struct clk *clk)
        return -ENOSYS;
 }
 
-static inline int clk_free(struct clk *clk)
+static inline void clk_free(struct clk *clk)
 {
-       return 0;
+       return;
 }
 
 static inline ulong clk_get_rate(struct clk *clk)
@@ -553,7 +607,7 @@ static inline struct clk *clk_get_parent(struct clk *clk)
        return ERR_PTR(-ENOSYS);
 }
 
-static inline long long clk_get_parent_rate(struct clk *clk)
+static inline ulong clk_get_parent_rate(struct clk *clk)
 {
        return -ENOSYS;
 }