History

clk: keystone: sci-clk: extend clock IDs to 32 bits

Currently, the clock identifiers are limited to 255. To support future SoCs, this muse be extended to 32 bits, which should provide way more than enough space. Basic support for extending the clock API is going to be implemented in the firmware driver, but there are some minor changes that need to be done on the clock driver side first.

Tero Kristo committed 7 years ago

Commit 3f1f22d1 parent 8e48b331 file · +28 −8Browse files

Unified · Split

drivers/clk/keystone/sci-clk.c+28−8
@@ -58,8 +58,8 @@ struct sci_clk_provider { · 57 unmodified lines
5858 struct sci_clk {
5959 struct clk_hw hw;
6060 u16 dev_id;
61− u8 clk_id;
62− u8 num_parents;
61+ u32 clk_id;
62+ u32 num_parents;
6363 struct sci_clk_provider *provider;
6464 u8 flags;
6565 struct list_head node;
@@ -221,11 +221,11 @@ static int sci_clk_set_rate(struct clk_hw *hw, unsigned long rate, · 155 unmodified lines
221221 static u8 sci_clk_get_parent(struct clk_hw *hw)
222222 {
223223 struct sci_clk *clk = to_sci_clk(hw);
224− u8 parent_id;
224+ u32 parent_id = 0;
225225 int ret;
226226
227227 ret = clk->provider->ops->get_parent(clk->provider->sci, clk->dev_id,
228− clk->clk_id, &parent_id);
228+ clk->clk_id, (void *)&parent_id);
229229 if (ret) {
230230 dev_err(clk->provider->dev,
231231 "get-parent failed for dev=%d, clk=%d, ret=%d\n",
@@ -233,7 +233,9 @@ static u8 sci_clk_get_parent(struct clk_hw *hw) · 1 unmodified line
233233 return 0;
234234 }
235235
236− return parent_id - clk->clk_id - 1;
236+ parent_id = parent_id - clk->clk_id - 1;
237+
238+ return (u8)parent_id;
237239 }
238240
239241 /**
@@ -417,13 +419,14 @@ static int ti_sci_scan_clocks_from_fw(struct sci_clk_provider *provider) · 177 unmodified lines
417419 int max_clks = 0;
418420 int clk_id = 0;
419421 int dev_id = 0;
420− u8 num_parents;
422+ u32 num_parents = 0;
421423 int gap_size = 0;
422424 struct device *dev = provider->dev;
423425
424426 while (1) {
425427 ret = provider->ops->get_num_parents(provider->sci, dev_id,
426− clk_id, &num_parents);
428+ clk_id,
429+ (void *)&num_parents);
427430 if (ret) {
428431 gap_size++;
429432 if (!clk_id) {
@@ -546,7 +549,7 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) · 116 unmodified lines
546549 provider->ops->get_num_parents(provider->sci,
547550 sci_clk->dev_id,
548551 sci_clk->clk_id,
549− &sci_clk->num_parents);
552+ (void *)&sci_clk->num_parents);
550553 list_add_tail(&sci_clk->node, &clks);
551554
552555 num_clks++;
@@ -555,6 +558,23 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) · 2 unmodified lines
555558 if (num_parents == 1)
556559 num_parents = 0;
557560
561+ /*
562+ * Linux kernel has inherent limitation
563+ * of 255 clock parents at the moment.
564+ * Right now, it is not expected that
565+ * any mux clock from sci-clk driver
566+ * would exceed that limit either, but
567+ * the ABI basically provides that
568+ * possibility. Print out a warning if
569+ * this happens for any clock.
570+ */
571+ if (num_parents >= 255) {
572+ dev_warn(dev, "too many parents for dev=%d, clk=%d (%d), cropping to 255.\n",
573+ sci_clk->dev_id,
574+ sci_clk->clk_id, num_parents);
575+ num_parents = 255;
576+ }
577+
558578 clk_id = args.args[1] + 1;
559579
560580 while (num_parents--) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t