You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/11/30 04:30:30 UTC

[GitHub] [incubator-nuttx] zhuyanlinzyl opened a new pull request #4918: driver: add clk framework

zhuyanlinzyl opened a new pull request #4918:
URL: https://github.com/apache/incubator-nuttx/pull/4918


   N/A
   
   Signed-off-by: zhuyanlin <zh...@xiaomi.com>
   
   ## Summary
   
   ## Impact
   
   ## Testing
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #4918: driver: add clk framework

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on pull request #4918:
URL: https://github.com/apache/incubator-nuttx/pull/4918#issuecomment-984567271


   @Ouss4 do you think the description is enough?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] davids5 edited a comment on pull request #4918: driver: add clk framework

Posted by GitBox <gi...@apache.org>.
davids5 edited a comment on pull request #4918:
URL: https://github.com/apache/incubator-nuttx/pull/4918#issuecomment-984628675


   @xiaoxiang781216 Is this code original? I found it verbatim in many GPL implementations. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #4918: driver: add clk framework

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #4918:
URL: https://github.com/apache/incubator-nuttx/pull/4918#discussion_r761098388



##########
File path: drivers/clk/clk-divider.c
##########
@@ -0,0 +1,383 @@
+/****************************************************************************
+ * drivers/clk/clk-divider.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/clk/clk.h>
+#include <nuttx/clk/clk-provider.h>
+
+#include <debug.h>
+#include <stdlib.h>
+
+#include "clk.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define to_clk_divider(_clk) (struct clk_divider *)(_clk->private_data)

Review comment:
       ```suggestion
   #define to_clk_divider(_clk) (FAR struct clk_divider *)(_clk->private_data)
   ```
   Missing `FAR` qualifier, required to be used in generic code.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #4918: driver: add clk framework

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on pull request #4918:
URL: https://github.com/apache/incubator-nuttx/pull/4918#issuecomment-984835116


   The idea come from Linux kernel, @zhuyanlinzyl and me are already very familiar with Linux clk framework before we start working on how to do the similar thing on NuttX. But Linux kernel driver model(e.g. bus/driver/device, device tree...) is fundamental different from NuttX, so the implementation is written from the scratch. I don't whether this is forbid from license perspective.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] patacongo commented on pull request #4918: driver: add clk framework

Posted by GitBox <gi...@apache.org>.
patacongo commented on pull request #4918:
URL: https://github.com/apache/incubator-nuttx/pull/4918#issuecomment-984725520


   > t is important that the people who implements the code never had looked the source code of Linux, otherwise he could bring instinctively things from there. I strongly suggest to change the functions name and the file name to avoid Linux litigation in the future, same thing that happened about Linux and Unix in the past and IBM had the pay a lot to finally settle things down.
   
   Do you consider simply obfuscating the origin of files derived from GPL code to be ethical?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #4918: driver: add clk framework

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on pull request #4918:
URL: https://github.com/apache/incubator-nuttx/pull/4918#issuecomment-984632536


   > @xiaoxiang781216 Is this code original? I found it verbatim in many GPL implementations.
   
   Yes, we write from scratch, only the function prototype keep same.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] Ouss4 commented on pull request #4918: driver: add clk framework

Posted by GitBox <gi...@apache.org>.
Ouss4 commented on pull request #4918:
URL: https://github.com/apache/incubator-nuttx/pull/4918#issuecomment-982637024


   @xiaoxiang781216 @zhuyanlinzyl can you please fill the PR template and add a small description.   This is a new module and we would need that for the release notes of the next release.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #4918: driver: add clk framework

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #4918:
URL: https://github.com/apache/incubator-nuttx/pull/4918#discussion_r761102433



##########
File path: include/nuttx/clk/clk-provider.h
##########
@@ -0,0 +1,277 @@
+/****************************************************************************
+ * include/nuttx/clk/clk-provider.h
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __INCLUDE_NUTTX_CLK_CLK_PROVIDER_H
+#define __INCLUDE_NUTTX_CLK_CLK_PROVIDER_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/list.h>
+
+#include <stdint.h>
+#include <stddef.h>
+
+#ifdef CONFIG_CLK
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define CLK_SET_RATE_GATE               0x01
+#define CLK_SET_PARENT_GATE             0x02
+#define CLK_SET_RATE_PARENT             0x04
+#define CLK_SET_RATE_NO_REPARENT        0x08
+#define CLK_GET_RATE_NOCACHE            0x10
+#define CLK_NAME_IS_STATIC              0x20
+#define CLK_PARENT_NAME_IS_STATIC       0x40
+#define CLK_IS_CRITICAL                 0x80
+
+#define CLK_GATE_SET_TO_DISABLE         0x01
+#define CLK_GATE_HIWORD_MASK            0x02
+
+#define CLK_DIVIDER_ONE_BASED           0x01
+#define CLK_DIVIDER_HIWORD_MASK         0x02
+#define CLK_DIVIDER_ROUND_CLOSEST       0x04
+#define CLK_DIVIDER_READ_ONLY           0x08
+#define CLK_DIVIDER_MAX_HALF            0x10
+#define CLK_DIVIDER_DIV_NEED_EVEN       0x20
+#define CLK_DIVIDER_POWER_OF_TWO        0x40
+#define CLK_DIVIDER_MINDIV_OFF          8
+#define CLK_DIVIDER_MINDIV_MSK          0xff00
+
+#define CLK_FRAC_MUL_NEED_EVEN          0x01
+#define CLK_FRAC_DIV_DOUBLE             0x02
+
+#define CLK_MULT_ONE_BASED              0x01
+#define CLK_MULT_ALLOW_ZERO             0x02
+#define CLK_MULT_HIWORD_MASK            0x04
+#define CLK_MULT_MAX_HALF               0x08
+#define CLK_MULT_ROUND_CLOSEST          0x10
+
+#define CLK_MUX_HIWORD_MASK             0x01
+#define CLK_MUX_READ_ONLY               0x02
+#define CLK_MUX_ROUND_CLOSEST           0x04
+
+#define CLK_PHASE_HIWORD_MASK           0x01
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+#undef EXTERN
+#if defined(__cplusplus)
+#  define EXTERN extern "C"
+extern "C"
+{
+#else
+#  define EXTERN extern
+#endif
+
+struct clk_rate
+{
+  const char *name;
+  uint32_t   rate;
+};
+
+struct clk
+{
+  const char              *name;
+  const struct clk_ops    *ops;
+  struct clk              *parent;
+  uint8_t                 num_parents;
+  uint8_t                 new_parent_index;
+  uint8_t                 enable_count;
+  uint8_t                 flags;
+  uint32_t                rate;
+  uint32_t                new_rate;
+  struct clk              *new_parent;
+  struct clk              *new_child;
+  void                    *private_data;
+  struct list_node        children;
+  struct list_node        node;
+  const char              *parent_names[0];
+};
+
+struct clk_ops
+{
+  int       (*enable)(struct clk *clk);

Review comment:
       ```suggestion
     CODE int       (*enable)(struct clk *clk);
   ```
   Missing `CODE` qualifier on pointer to code, required for generic code on NuttX




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] zhuyanlinzyl commented on pull request #4918: driver: add clk framework

Posted by GitBox <gi...@apache.org>.
zhuyanlinzyl commented on pull request #4918:
URL: https://github.com/apache/incubator-nuttx/pull/4918#issuecomment-985173820


   The nuttx clk core framework is inspired by Linux clk framework, but I implemented in Nuttx driver model, and use Nuttx procfs to show the clk note.
   Some basic clocks name are some with Linux's, but I think those clocks name is commonly used  by hardware design, such as gate, divider, multiplier.  it's not a question to use those name.
   Also the clk-rpmsg is a completely new clock design by me,  and based on Nuttx openamp  framework.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #4918: driver: add clk framework

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #4918:
URL: https://github.com/apache/incubator-nuttx/pull/4918#discussion_r761099787



##########
File path: include/nuttx/clk/clk-provider.h
##########
@@ -0,0 +1,277 @@
+/****************************************************************************
+ * include/nuttx/clk/clk-provider.h
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __INCLUDE_NUTTX_CLK_CLK_PROVIDER_H
+#define __INCLUDE_NUTTX_CLK_CLK_PROVIDER_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/list.h>
+
+#include <stdint.h>
+#include <stddef.h>
+
+#ifdef CONFIG_CLK
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define CLK_SET_RATE_GATE               0x01
+#define CLK_SET_PARENT_GATE             0x02
+#define CLK_SET_RATE_PARENT             0x04
+#define CLK_SET_RATE_NO_REPARENT        0x08
+#define CLK_GET_RATE_NOCACHE            0x10
+#define CLK_NAME_IS_STATIC              0x20
+#define CLK_PARENT_NAME_IS_STATIC       0x40
+#define CLK_IS_CRITICAL                 0x80
+
+#define CLK_GATE_SET_TO_DISABLE         0x01
+#define CLK_GATE_HIWORD_MASK            0x02
+
+#define CLK_DIVIDER_ONE_BASED           0x01
+#define CLK_DIVIDER_HIWORD_MASK         0x02
+#define CLK_DIVIDER_ROUND_CLOSEST       0x04
+#define CLK_DIVIDER_READ_ONLY           0x08
+#define CLK_DIVIDER_MAX_HALF            0x10
+#define CLK_DIVIDER_DIV_NEED_EVEN       0x20
+#define CLK_DIVIDER_POWER_OF_TWO        0x40
+#define CLK_DIVIDER_MINDIV_OFF          8
+#define CLK_DIVIDER_MINDIV_MSK          0xff00
+
+#define CLK_FRAC_MUL_NEED_EVEN          0x01
+#define CLK_FRAC_DIV_DOUBLE             0x02
+
+#define CLK_MULT_ONE_BASED              0x01
+#define CLK_MULT_ALLOW_ZERO             0x02
+#define CLK_MULT_HIWORD_MASK            0x04
+#define CLK_MULT_MAX_HALF               0x08
+#define CLK_MULT_ROUND_CLOSEST          0x10
+
+#define CLK_MUX_HIWORD_MASK             0x01
+#define CLK_MUX_READ_ONLY               0x02
+#define CLK_MUX_ROUND_CLOSEST           0x04
+
+#define CLK_PHASE_HIWORD_MASK           0x01
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+#undef EXTERN
+#if defined(__cplusplus)
+#  define EXTERN extern "C"
+extern "C"
+{
+#else
+#  define EXTERN extern
+#endif
+
+struct clk_rate

Review comment:
       ```suggestion
   struct clk_rate_s
   ```
   Struct names not compliant to NuttX coding standard




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] zhuyanlinzyl commented on pull request #4918: driver: add clk framework

Posted by GitBox <gi...@apache.org>.
zhuyanlinzyl commented on pull request #4918:
URL: https://github.com/apache/incubator-nuttx/pull/4918#issuecomment-983270811


   @Ouss4  @gustavonihei  please review again


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #4918: driver: add clk framework

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #4918:
URL: https://github.com/apache/incubator-nuttx/pull/4918#discussion_r761098388



##########
File path: drivers/clk/clk-divider.c
##########
@@ -0,0 +1,383 @@
+/****************************************************************************
+ * drivers/clk/clk-divider.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/clk/clk.h>
+#include <nuttx/clk/clk-provider.h>
+
+#include <debug.h>
+#include <stdlib.h>
+
+#include "clk.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define to_clk_divider(_clk) (struct clk_divider *)(_clk->private_data)

Review comment:
       ```suggestion
   #define to_clk_divider(_clk) (FAR struct clk_divider *)(_clk->private_data)
   ```
   Missing `FAR` qualifier on pointer to data, required to be used in generic code.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 edited a comment on pull request #4918: driver: add clk framework

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 edited a comment on pull request #4918:
URL: https://github.com/apache/incubator-nuttx/pull/4918#issuecomment-984835116


   The idea come from Linux kernel, @zhuyanlinzyl and me are already very familiar with Linux clk framework before we start working on how to do the similar thing on NuttX. But Linux kernel driver model(e.g. bus/driver/device, device tree...) is fundamental different from NuttX, so the implementation is written from the scratch. I don't know whether this is forbid from license perspective.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] acassis commented on a change in pull request #4918: driver: add clk framework

Posted by GitBox <gi...@apache.org>.
acassis commented on a change in pull request #4918:
URL: https://github.com/apache/incubator-nuttx/pull/4918#discussion_r761896335



##########
File path: include/nuttx/clk/clk_provider.h
##########
@@ -0,0 +1,262 @@
+/****************************************************************************
+ * include/nuttx/clk/clk_provider.h
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __INCLUDE_NUTTX_CLK_CLK_PROVIDER_H
+#define __INCLUDE_NUTTX_CLK_CLK_PROVIDER_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/list.h>
+
+#include <stdint.h>
+#include <stddef.h>
+
+#ifdef CONFIG_CLK
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define CLK_SET_RATE_GATE               0x01
+#define CLK_SET_PARENT_GATE             0x02
+#define CLK_SET_RATE_PARENT             0x04
+#define CLK_SET_RATE_NO_REPARENT        0x08
+#define CLK_GET_RATE_NOCACHE            0x10
+#define CLK_NAME_IS_STATIC              0x20
+#define CLK_PARENT_NAME_IS_STATIC       0x40
+#define CLK_IS_CRITICAL                 0x80
+
+#define CLK_GATE_SET_TO_DISABLE         0x01
+#define CLK_GATE_HIWORD_MASK            0x02
+
+#define CLK_DIVIDER_ONE_BASED           0x01
+#define CLK_DIVIDER_HIWORD_MASK         0x02
+#define CLK_DIVIDER_ROUND_CLOSEST       0x04
+#define CLK_DIVIDER_READ_ONLY           0x08
+#define CLK_DIVIDER_MAX_HALF            0x10
+#define CLK_DIVIDER_DIV_NEED_EVEN       0x20
+#define CLK_DIVIDER_POWER_OF_TWO        0x40
+#define CLK_DIVIDER_MINDIV_OFF          8
+#define CLK_DIVIDER_MINDIV_MSK          0xff00
+
+#define CLK_FRAC_MUL_NEED_EVEN          0x01
+#define CLK_FRAC_DIV_DOUBLE             0x02
+
+#define CLK_MULT_ONE_BASED              0x01
+#define CLK_MULT_ALLOW_ZERO             0x02
+#define CLK_MULT_HIWORD_MASK            0x04
+#define CLK_MULT_MAX_HALF               0x08
+#define CLK_MULT_ROUND_CLOSEST          0x10
+
+#define CLK_MUX_HIWORD_MASK             0x01
+#define CLK_MUX_READ_ONLY               0x02
+#define CLK_MUX_ROUND_CLOSEST           0x04
+
+#define CLK_PHASE_HIWORD_MASK           0x01
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+#undef EXTERN
+#if defined(__cplusplus)
+#  define EXTERN extern "C"
+extern "C"
+{
+#else
+#  define EXTERN extern
+#endif
+
+struct clk_s
+{
+  FAR const char             *name;
+  FAR const struct clk_ops_s *ops;
+  FAR struct clk_s           *parent;
+  uint8_t                     num_parents;
+  uint8_t                     new_parent_index;
+  uint8_t                     enable_count;
+  uint8_t                     flags;
+  uint32_t                    rate;
+  uint32_t                    new_rate;
+  FAR struct clk_s           *new_parent;
+  FAR struct clk_s           *new_child;
+  FAR void                   *private_data;
+  struct list_node            children;
+  struct list_node            node;
+  FAR const char             *parent_names[0];
+};
+
+struct clk_ops_s
+{
+  CODE int       (*enable)(FAR struct clk_s *clk);
+  CODE void      (*disable)(FAR struct clk_s *clk);
+  CODE int       (*is_enabled)(FAR struct clk_s *clk);
+  CODE uint32_t  (*recalc_rate)(FAR struct clk_s *clk, uint32_t parent_rate);
+  CODE uint32_t  (*round_rate)(FAR struct clk_s *clk,
+                               uint32_t rate, uint32_t *parent_rate);
+  CODE uint32_t  (*determine_rate)(FAR struct clk_s *clk, uint32_t rate,
+                                   uint32_t *best_parent_rate,
+                                   struct clk_s **best_parent_clk);
+  CODE int       (*set_parent)(FAR struct clk_s *clk, uint8_t index);
+  CODE uint8_t   (*get_parent)(FAR struct clk_s *clk);
+  CODE int       (*set_rate)(FAR struct clk_s *clk, uint32_t rate,
+                             uint32_t parent_rate);
+  CODE int       (*set_rate_and_parent)(FAR struct clk_s *clk, uint32_t rate,
+                                        uint32_t parent_rate,
+                                        uint8_t index);
+  CODE int       (*get_phase)(FAR struct clk_s *clk);
+  CODE int       (*set_phase)(FAR struct clk_s *clk, int degrees);
+};
+
+struct clk_gate_s
+{
+  uint32_t            reg;
+  uint8_t             bit_idx;
+  uint8_t             flags;
+};
+
+struct clk_fixed_rate_s
+{
+  uint32_t            fixed_rate;
+  uint8_t             flags;
+};
+
+struct clk_fixed_factor_s
+{
+  uint8_t             mult;
+  uint8_t             div;
+};
+
+struct clk_divider_s
+{
+  uint32_t            reg;
+  uint8_t             shift;
+  uint8_t             width;
+  uint16_t            flags;
+};
+
+struct clk_phase_s
+{
+  uint32_t            reg;
+  uint8_t             shift;
+  uint8_t             width;
+  uint8_t             flags;
+};
+
+struct clk_fractional_divider_s
+{
+  uint32_t            reg;
+  uint8_t             mwidth;
+  uint8_t             nwidth;
+  uint8_t             mshift;
+  uint8_t             nshift;
+  uint8_t             flags;
+};
+
+struct clk_multiplier_s
+{
+  uint32_t            reg;
+  uint8_t             shift;
+  uint8_t             width;
+  uint8_t             flags;
+};
+
+struct clk_mux_s
+{
+  uint32_t            reg;
+  uint8_t             width;
+  uint8_t             shift;
+  uint8_t             flags;
+};
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+FAR struct clk_s *clk_register(FAR const char *name,

Review comment:
       Where is clk_register() implemented? It is declared here, called in some places but I didn't see it implemented anywhere. It cannot be a Generic selection because we support C11 on NuttX :-)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #4918: driver: add clk framework

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #4918:
URL: https://github.com/apache/incubator-nuttx/pull/4918#discussion_r761900205



##########
File path: include/nuttx/clk/clk_provider.h
##########
@@ -0,0 +1,262 @@
+/****************************************************************************
+ * include/nuttx/clk/clk_provider.h
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __INCLUDE_NUTTX_CLK_CLK_PROVIDER_H
+#define __INCLUDE_NUTTX_CLK_CLK_PROVIDER_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/list.h>
+
+#include <stdint.h>
+#include <stddef.h>
+
+#ifdef CONFIG_CLK
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define CLK_SET_RATE_GATE               0x01
+#define CLK_SET_PARENT_GATE             0x02
+#define CLK_SET_RATE_PARENT             0x04
+#define CLK_SET_RATE_NO_REPARENT        0x08
+#define CLK_GET_RATE_NOCACHE            0x10
+#define CLK_NAME_IS_STATIC              0x20
+#define CLK_PARENT_NAME_IS_STATIC       0x40
+#define CLK_IS_CRITICAL                 0x80
+
+#define CLK_GATE_SET_TO_DISABLE         0x01
+#define CLK_GATE_HIWORD_MASK            0x02
+
+#define CLK_DIVIDER_ONE_BASED           0x01
+#define CLK_DIVIDER_HIWORD_MASK         0x02
+#define CLK_DIVIDER_ROUND_CLOSEST       0x04
+#define CLK_DIVIDER_READ_ONLY           0x08
+#define CLK_DIVIDER_MAX_HALF            0x10
+#define CLK_DIVIDER_DIV_NEED_EVEN       0x20
+#define CLK_DIVIDER_POWER_OF_TWO        0x40
+#define CLK_DIVIDER_MINDIV_OFF          8
+#define CLK_DIVIDER_MINDIV_MSK          0xff00
+
+#define CLK_FRAC_MUL_NEED_EVEN          0x01
+#define CLK_FRAC_DIV_DOUBLE             0x02
+
+#define CLK_MULT_ONE_BASED              0x01
+#define CLK_MULT_ALLOW_ZERO             0x02
+#define CLK_MULT_HIWORD_MASK            0x04
+#define CLK_MULT_MAX_HALF               0x08
+#define CLK_MULT_ROUND_CLOSEST          0x10
+
+#define CLK_MUX_HIWORD_MASK             0x01
+#define CLK_MUX_READ_ONLY               0x02
+#define CLK_MUX_ROUND_CLOSEST           0x04
+
+#define CLK_PHASE_HIWORD_MASK           0x01
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+#undef EXTERN
+#if defined(__cplusplus)
+#  define EXTERN extern "C"
+extern "C"
+{
+#else
+#  define EXTERN extern
+#endif
+
+struct clk_s
+{
+  FAR const char             *name;
+  FAR const struct clk_ops_s *ops;
+  FAR struct clk_s           *parent;
+  uint8_t                     num_parents;
+  uint8_t                     new_parent_index;
+  uint8_t                     enable_count;
+  uint8_t                     flags;
+  uint32_t                    rate;
+  uint32_t                    new_rate;
+  FAR struct clk_s           *new_parent;
+  FAR struct clk_s           *new_child;
+  FAR void                   *private_data;
+  struct list_node            children;
+  struct list_node            node;
+  FAR const char             *parent_names[0];
+};
+
+struct clk_ops_s
+{
+  CODE int       (*enable)(FAR struct clk_s *clk);
+  CODE void      (*disable)(FAR struct clk_s *clk);
+  CODE int       (*is_enabled)(FAR struct clk_s *clk);
+  CODE uint32_t  (*recalc_rate)(FAR struct clk_s *clk, uint32_t parent_rate);
+  CODE uint32_t  (*round_rate)(FAR struct clk_s *clk,
+                               uint32_t rate, uint32_t *parent_rate);
+  CODE uint32_t  (*determine_rate)(FAR struct clk_s *clk, uint32_t rate,
+                                   uint32_t *best_parent_rate,
+                                   struct clk_s **best_parent_clk);
+  CODE int       (*set_parent)(FAR struct clk_s *clk, uint8_t index);
+  CODE uint8_t   (*get_parent)(FAR struct clk_s *clk);
+  CODE int       (*set_rate)(FAR struct clk_s *clk, uint32_t rate,
+                             uint32_t parent_rate);
+  CODE int       (*set_rate_and_parent)(FAR struct clk_s *clk, uint32_t rate,
+                                        uint32_t parent_rate,
+                                        uint8_t index);
+  CODE int       (*get_phase)(FAR struct clk_s *clk);
+  CODE int       (*set_phase)(FAR struct clk_s *clk, int degrees);
+};
+
+struct clk_gate_s
+{
+  uint32_t            reg;
+  uint8_t             bit_idx;
+  uint8_t             flags;
+};
+
+struct clk_fixed_rate_s
+{
+  uint32_t            fixed_rate;
+  uint8_t             flags;
+};
+
+struct clk_fixed_factor_s
+{
+  uint8_t             mult;
+  uint8_t             div;
+};
+
+struct clk_divider_s
+{
+  uint32_t            reg;
+  uint8_t             shift;
+  uint8_t             width;
+  uint16_t            flags;
+};
+
+struct clk_phase_s
+{
+  uint32_t            reg;
+  uint8_t             shift;
+  uint8_t             width;
+  uint8_t             flags;
+};
+
+struct clk_fractional_divider_s
+{
+  uint32_t            reg;
+  uint8_t             mwidth;
+  uint8_t             nwidth;
+  uint8_t             mshift;
+  uint8_t             nshift;
+  uint8_t             flags;
+};
+
+struct clk_multiplier_s
+{
+  uint32_t            reg;
+  uint8_t             shift;
+  uint8_t             width;
+  uint8_t             flags;
+};
+
+struct clk_mux_s
+{
+  uint32_t            reg;
+  uint8_t             width;
+  uint8_t             shift;
+  uint8_t             flags;
+};
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+FAR struct clk_s *clk_register(FAR const char *name,

Review comment:
       It's here:
   https://github.com/apache/incubator-nuttx/pull/4918/files#diff-fa5c6e68e529521e8d1eb81aa3d6fcd208f686db83c964cafb417ecb8bd62832R1132-R1208




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #4918: driver: add clk framework

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on pull request #4918:
URL: https://github.com/apache/incubator-nuttx/pull/4918#issuecomment-986458514


   @gustavonihei @acassis @acassis I think all concern and suggestion has been addressed, do you have more?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] acassis commented on pull request #4918: driver: add clk framework

Posted by GitBox <gi...@apache.org>.
acassis commented on pull request #4918:
URL: https://github.com/apache/incubator-nuttx/pull/4918#issuecomment-984888265


   > > t is important that the people who implements the code never had looked the source code of Linux, otherwise he could bring instinctively things from there. I strongly suggest to change the functions name and the file name to avoid Linux litigation in the future, same thing that happened about Linux and Unix in the past and IBM had the pay a lot to finally settle things down.
   > 
   > Do you consider simply obfuscating the origin of files derived from GPL code to be ethical?
   
   The code does not derive from GPL code, but before someone look that name of the files, the name of the functions and say it is a verbatim copy of GPL code (ok, David already did it), it is a good idea to use other names to avoid such wrong assumption.
   
   NuttX is a Linux-like RTOS, but we cannot have any piece of code copied from Linux, unless its license allow it, as the SocketCAN that was BSD license.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] davids5 commented on pull request #4918: driver: add clk framework

Posted by GitBox <gi...@apache.org>.
davids5 commented on pull request #4918:
URL: https://github.com/apache/incubator-nuttx/pull/4918#issuecomment-984628675


   @xiaoxiang781216 Is this code original? I found it verbatim in may GPL implementations. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] acassis commented on pull request #4918: driver: add clk framework

Posted by GitBox <gi...@apache.org>.
acassis commented on pull request #4918:
URL: https://github.com/apache/incubator-nuttx/pull/4918#issuecomment-984657263


   > > @xiaoxiang781216 Is this code original? I found it verbatim in many GPL implementations.
   > 
   > Yes, we write from scratch, only the function prototype keep same.
   
   @xiaoxiang781216 I compared the functions and in fact they are not implemented exactly like the Linux kernel, but seams inspired by the Linux kernel implementation. Also the fact that you guys used the same name of the files and same functions' name contribute to this vision. It is important that the people who implements the code never had looked the source code of Linux, otherwise he could bring instinctively things from there. I strongly suggest to change the functions name and the file name to avoid Linux litigation in the future, same thing that happened about Linux and Unix in the past and IBM had the pay a lot to finally settle things down.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 merged pull request #4918: driver: add clk framework

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 merged pull request #4918:
URL: https://github.com/apache/incubator-nuttx/pull/4918


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org