From mboxrd@z Thu Jan 1 00:00:00 1970 From: Masahiro Yamada Date: Tue, 29 Dec 2015 02:05:09 +0900 Subject: [U-Boot] [RESEND PATCH 3/5] clk: add function to get peripheral ID In-Reply-To: References: <1450778671-21134-1-git-send-email-yamada.masahiro@socionext.com> <1450778671-21134-4-git-send-email-yamada.masahiro@socionext.com> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Simon, 2015-12-28 23:20 GMT+09:00 Simon Glass : >> index 371784a..1efbaf2 100644 >> --- a/include/clk.h >> +++ b/include/clk.h >> @@ -49,6 +49,16 @@ struct clk_ops { >> * @return new clock rate in Hz, or -ve error code >> */ >> ulong (*set_periph_rate)(struct udevice *dev, int periph, ulong rate); >> + >> + /** >> + * get_id() - Get peripheral ID >> + * >> + * @dev: clock provider >> + * @args_count: number of arguments >> + * @args: arguments. The meaning is driver specific. >> + * @return peripheral ID, or -ve error code >> + */ >> + int (*get_id)(struct udevice *dev, int args_count, uint32_t *args); > > What are the arguments for? Who will use them? I wonder if the simple > case you have is the only useful case for now? > > I think it would be better for the device tree parsing to happen > within the uclass rather than requiring the caller to understand how > it works. Here, we must obtain the arguments after the phandle and > pass them to this function. My intention was to make the interface as generic as possible. It is true that most of drivers have '#clock-cells = <1>', but I found some have '#clock-cells = <2>'. Under linux/Documentation: devicetree/bindings/clock/qoriq-clock.txt:When the clockgen node is a clock provider, #clock-cells = <2>. devicetree/bindings/clock/qoriq-clock.txt: #clock-cells = <2>; devicetree/bindings/clock/renesas,cpg-mssr.txt: #clock-cells = <2>; devicetree/bindings/clock/st,stm32-rcc.txt: #clock-cells = <2> devicetree/bindings/clock/ux500.txt: #clock-cells = <2>; devicetree/bindings/clock/ux500.txt: #clock-cells = <2>; So, my idea was to cover the simple case with clk_get_id_simple(), but still allow such rare-case drivers to have their own .get_id() callback. However, U-Boot might never be hit by such a case, and your simple one meets our demand well enough. -- Best Regards Masahiro Yamada