From: linux@armlinux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv3 2/7] clk: ti: add clkdev get helper
Date: Tue, 12 Jul 2016 16:34:18 +0100 [thread overview]
Message-ID: <20160712153418.GF5783@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <57850A29.4010806@ti.com>
On Tue, Jul 12, 2016 at 06:18:01PM +0300, Tero Kristo wrote:
> On 12/07/16 13:22, Russell King - ARM Linux wrote:
> >On Thu, Jun 30, 2016 at 05:13:33PM +0300, Tero Kristo wrote:
> >> /**
> >>+ * ti_clk_get - lookup a TI clock handle
> >>+ * @dev_id: device to lookup clock for
> >>+ * @con_id: connection ID to find
> >>+ *
> >>+ * Searches for a TI clock handle based on the DT node name.
> >>+ * Returns the pointer to the clock handle, or ERR_PTR in failure.
> >>+ */
> >>+static struct clk *ti_clk_get(const char *dev_id, const char *con_id)
> >>+{
> >>+ struct of_phandle_args clkspec;
> >>+ struct device_node *node;
> >>+ struct clk *clk;
> >>+
> >>+ /* Only check for cases of type clk_get_sys(NULL, "xyz") */
> >>+ if (dev_id || !con_id)
> >>+ return ERR_PTR(-ENOENT);
> >>+
> >>+ if (of_have_populated_dt()) {
> >>+ node = of_find_node_by_name(NULL, con_id);
> >>+ clkspec.np = node;
> >>+ clk = of_clk_get_from_provider(&clkspec);
> >>+
> >>+ if (!IS_ERR(clk))
> >>+ return clk;
> >>+ }
> >>+
> >>+ return ERR_PTR(-ENOENT);
> >>+}
> >
> >I _really_ don't like this. This takes us back to the totally broken
> >idea, that's already been proven to be greatly harmful in OMAP land,
> >that the "con_id" is not a _DEVICE SPECIFIC CONNECTION NAME_ but is a
> >CLOCK NAME. The connection ID is supposed to be a static string in
> >the requestor of the clock, not some random string picked out from
> >DT.
>
> What is the harm in that actually? I have most likely missed some discussion
> but please educate me.
The problem is that we end up with drivers that we end up needing platform
information to know what clocks they should get, and what "connection names"
to use to get their clocks.
We've been there before with OMAP, pre-DT times, and I fixed it up by
creating clkdev and converting much of OMAP over to clkdev, doing
everything the right way. Now, we're heading around the same mistake
that I already solved several years ago.
It's _well_ documented that the _connection id_ is a connection id and
not a clock name. It's been documented that way ever since the clk API
was first published, and I'm on record for having brought up this point
_many_ times.
So, when I see something reintroducing ways to persist with this crap,
I'm just not going to allow it. This is 2016 after all, it's a full
_ten_ years after this API was created.
> The problem is, we are already using this convention
> all over the place in the kernel (not only OMAPs), and trying to clean up
> the kernel requires some intermediate steps being taken, otherwise we end up
> doing all the clean-ups in a single massive patch I fear (change all the
> hwmod data + clock data + any implementations related to these at the same
> time.)
This isn't an intermediate step if you're having to put stuff into DT
in order to support it. Anything you throw into DT needs to be supported
for years by the kernel, since we have the requirement that newer kernels
are bootable with older DT files without regression. That effectively
means we'll never be able to remove this, and we'll end up fighting other
people abusing the hook.
> That is true, it will end up adding new DT nodes. However, as OMAP already
> is doing this extensively, I wonder what would be the alternative. Maybe
> move all the clock data back to kernel space to increase the size of
> multi-v7 builds?
Why can't you use:
clocks = <&clk_provider fck_index>, <&clk_provider ick_index>, ...;
clock-names = "fck", "ick", ...;
when describing the hardware? If you don't have a struct device, but
only a struct device_node, you can use of_clk_get(), which allows you
to omit the connection ID and look up by index in the clocks property.
--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
next prev parent reply other threads:[~2016-07-12 15:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-30 14:13 [PATCHv3 0/7] clk: ti add support for hwmod clk type Tero Kristo
2016-06-30 14:13 ` [PATCHv3 1/7] clkdev: add helper registration API Tero Kristo
2016-06-30 14:13 ` [PATCHv3 2/7] clk: ti: add clkdev get helper Tero Kristo
2016-07-12 10:22 ` Russell King - ARM Linux
2016-07-12 15:18 ` Tero Kristo
2016-07-12 15:34 ` Russell King - ARM Linux [this message]
2016-07-12 15:49 ` Tero Kristo
2016-07-12 17:40 ` Michael Turquette
2016-06-30 14:13 ` [PATCHv3 3/7] clk: ti: remove un-used definitions from public clk_hw_omap struct Tero Kristo
2016-06-30 14:13 ` [PATCHv3 4/7] clk: ti: mux: export mux clock APIs locally Tero Kristo
2016-06-30 14:13 ` [PATCHv3 5/7] clk: ti: am33xx: fix timer3/6 init time setup for module clocks Tero Kristo
2016-06-30 14:13 ` [PATCHv3 6/7] dt-bindings: clk: ti: Document module clock type Tero Kristo
2016-06-30 14:13 ` [PATCHv3 7/7] clk: ti: add support for omap4 module clocks Tero Kristo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160712153418.GF5783@n2100.arm.linux.org.uk \
--to=linux@armlinux.org.uk \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).