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.
Unified · Split
| @@ -58,8 +58,8 @@ struct sci_clk_provider { · 57 unmodified lines | ||
| 58 | 58 | struct sci_clk { |
| 59 | 59 | struct clk_hw hw; |
| 60 | 60 | u16 dev_id; |
| 61 | − u8 clk_id; | |
| 62 | − u8 num_parents; | |
| 61 | + u32 clk_id; | |
| 62 | + u32 num_parents; | |
| 63 | 63 | struct sci_clk_provider *provider; |
| 64 | 64 | u8 flags; |
| 65 | 65 | struct list_head node; |
| @@ -221,11 +221,11 @@ static int sci_clk_set_rate(struct clk_hw *hw, unsigned long rate, · 155 unmodified lines | ||
| 221 | 221 | static u8 sci_clk_get_parent(struct clk_hw *hw) |
| 222 | 222 | { |
| 223 | 223 | struct sci_clk *clk = to_sci_clk(hw); |
| 224 | − u8 parent_id; | |
| 224 | + u32 parent_id = 0; | |
| 225 | 225 | int ret; |
| 226 | 226 | |
| 227 | 227 | 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); | |
| 229 | 229 | if (ret) { |
| 230 | 230 | dev_err(clk->provider->dev, |
| 231 | 231 | "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 | ||
| 233 | 233 | return 0; |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | − return parent_id - clk->clk_id - 1; | |
| 236 | + parent_id = parent_id - clk->clk_id - 1; | |
| 237 | + | |
| 238 | + return (u8)parent_id; | |
| 237 | 239 | } |
| 238 | 240 | |
| 239 | 241 | /** |
| @@ -417,13 +419,14 @@ static int ti_sci_scan_clocks_from_fw(struct sci_clk_provider *provider) · 177 unmodified lines | ||
| 417 | 419 | int max_clks = 0; |
| 418 | 420 | int clk_id = 0; |
| 419 | 421 | int dev_id = 0; |
| 420 | − u8 num_parents; | |
| 422 | + u32 num_parents = 0; | |
| 421 | 423 | int gap_size = 0; |
| 422 | 424 | struct device *dev = provider->dev; |
| 423 | 425 | |
| 424 | 426 | while (1) { |
| 425 | 427 | ret = provider->ops->get_num_parents(provider->sci, dev_id, |
| 426 | − clk_id, &num_parents); | |
| 428 | + clk_id, | |
| 429 | + (void *)&num_parents); | |
| 427 | 430 | if (ret) { |
| 428 | 431 | gap_size++; |
| 429 | 432 | if (!clk_id) { |
| @@ -546,7 +549,7 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) · 116 unmodified lines | ||
| 546 | 549 | provider->ops->get_num_parents(provider->sci, |
| 547 | 550 | sci_clk->dev_id, |
| 548 | 551 | sci_clk->clk_id, |
| 549 | − &sci_clk->num_parents); | |
| 552 | + (void *)&sci_clk->num_parents); | |
| 550 | 553 | list_add_tail(&sci_clk->node, &clks); |
| 551 | 554 | |
| 552 | 555 | num_clks++; |
| @@ -555,6 +558,23 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) · 2 unmodified lines | ||
| 555 | 558 | if (num_parents == 1) |
| 556 | 559 | num_parents = 0; |
| 557 | 560 | |
| 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 | + | |
| 558 | 578 | clk_id = args.args[1] + 1; |
| 559 | 579 | |
| 560 | 580 | while (num_parents--) { |