After commit fc0c209c147f ("clk: Allow parents to be specified without string names") we can use DT or direct clk_hw pointers to specify parents. Create a generic function that shouldn't be used very often to encode the multitude of ways of registering a divider clk with different parent information. Then add a bunch of wrapper macros that only pass down what needs to be passed down to the generic function to support this with less arguments.
Showing the changes to include/linux (1 of 2 files). Show all
Unified · Split
| @@ -626,24 +626,153 @@ int divider_get_val(unsigned long rate, unsigned long parent_rate, · 625 unmodified lines | ||
| 626 | 626 | const struct clk_div_table *table, u8 width, |
| 627 | 627 | unsigned long flags); |
| 628 | 628 | |
| 629 | −struct clk *clk_register_divider(struct device *dev, const char *name, | |
| 630 | − const char *parent_name, unsigned long flags, | |
| 631 | − void __iomem *reg, u8 shift, u8 width, | |
| 632 | − u8 clk_divider_flags, spinlock_t *lock); | |
| 633 | −struct clk_hw *clk_hw_register_divider(struct device *dev, const char *name, | |
| 634 | − const char *parent_name, unsigned long flags, | |
| 635 | − void __iomem *reg, u8 shift, u8 width, | |
| 636 | − u8 clk_divider_flags, spinlock_t *lock); | |
| 629 | +struct clk_hw *__clk_hw_register_divider(struct device *dev, | |
| 630 | + struct device_node *np, const char *name, | |
| 631 | + const char *parent_name, const struct clk_hw *parent_hw, | |
| 632 | + const struct clk_parent_data *parent_data, unsigned long flags, | |
| 633 | + void __iomem *reg, u8 shift, u8 width, u8 clk_divider_flags, | |
| 634 | + const struct clk_div_table *table, spinlock_t *lock); | |
| 637 | 635 | struct clk *clk_register_divider_table(struct device *dev, const char *name, |
| 638 | 636 | const char *parent_name, unsigned long flags, |
| 639 | 637 | void __iomem *reg, u8 shift, u8 width, |
| 640 | 638 | u8 clk_divider_flags, const struct clk_div_table *table, |
| 641 | 639 | spinlock_t *lock); |
| 642 | −struct clk_hw *clk_hw_register_divider_table(struct device *dev, | |
| 643 | − const char *name, const char *parent_name, unsigned long flags, | |
| 644 | − void __iomem *reg, u8 shift, u8 width, | |
| 645 | − u8 clk_divider_flags, const struct clk_div_table *table, | |
| 646 | − spinlock_t *lock); | |
| 640 | +/** | |
| 641 | + * clk_register_divider - register a divider clock with the clock framework | |
| 642 | + * @dev: device registering this clock | |
| 643 | + * @name: name of this clock | |
| 644 | + * @parent_name: name of clock's parent | |
| 645 | + * @flags: framework-specific flags | |
| 646 | + * @reg: register address to adjust divider | |
| 647 | + * @shift: number of bits to shift the bitfield | |
| 648 | + * @width: width of the bitfield | |
| 649 | + * @clk_divider_flags: divider-specific flags for this clock | |
| 650 | + * @lock: shared register lock for this clock | |
| 651 | + */ | |
| 652 | +#define clk_register_divider(dev, name, parent_name, flags, reg, shift, width, \ | |
| 653 | + clk_divider_flags, lock) \ | |
| 654 | + clk_register_divider_table((dev), (name), (parent_name), (flags), \ | |
| 655 | + (reg), (shift), (width), \ | |
| 656 | + (clk_divider_flags), NULL, (lock)) | |
| 657 | +/** | |
| 658 | + * clk_hw_register_divider - register a divider clock with the clock framework | |
| 659 | + * @dev: device registering this clock | |
| 660 | + * @name: name of this clock | |
| 661 | + * @parent_name: name of clock's parent | |
| 662 | + * @flags: framework-specific flags | |
| 663 | + * @reg: register address to adjust divider | |
| 664 | + * @shift: number of bits to shift the bitfield | |
| 665 | + * @width: width of the bitfield | |
| 666 | + * @clk_divider_flags: divider-specific flags for this clock | |
| 667 | + * @lock: shared register lock for this clock | |
| 668 | + */ | |
| 669 | +#define clk_hw_register_divider(dev, name, parent_name, flags, reg, shift, \ | |
| 670 | + width, clk_divider_flags, lock) \ | |
| 671 | + __clk_hw_register_divider((dev), NULL, (name), (parent_name), NULL, \ | |
| 672 | + NULL, (flags), (reg), (shift), (width), \ | |
| 673 | + (clk_divider_flags), NULL, (lock)) | |
| 674 | +/** | |
| 675 | + * clk_hw_register_divider_parent_hw - register a divider clock with the clock | |
| 676 | + * framework | |
| 677 | + * @dev: device registering this clock | |
| 678 | + * @name: name of this clock | |
| 679 | + * @parent_hw: pointer to parent clk | |
| 680 | + * @flags: framework-specific flags | |
| 681 | + * @reg: register address to adjust divider | |
| 682 | + * @shift: number of bits to shift the bitfield | |
| 683 | + * @width: width of the bitfield | |
| 684 | + * @clk_divider_flags: divider-specific flags for this clock | |
| 685 | + * @lock: shared register lock for this clock | |
| 686 | + */ | |
| 687 | +#define clk_hw_register_divider_parent_hw(dev, name, parent_hw, flags, reg, \ | |
| 688 | + shift, width, clk_divider_flags, \ | |
| 689 | + lock) \ | |
| 690 | + __clk_hw_register_divider((dev), NULL, (name), NULL, (parent_hw), \ | |
| 691 | + NULL, (flags), (reg), (shift), (width), \ | |
| 692 | + (clk_divider_flags), NULL, (lock)) | |
| 693 | +/** | |
| 694 | + * clk_hw_register_divider_parent_data - register a divider clock with the clock | |
| 695 | + * framework | |
| 696 | + * @dev: device registering this clock | |
| 697 | + * @name: name of this clock | |
| 698 | + * @parent_data: parent clk data | |
| 699 | + * @flags: framework-specific flags | |
| 700 | + * @reg: register address to adjust divider | |
| 701 | + * @shift: number of bits to shift the bitfield | |
| 702 | + * @width: width of the bitfield | |
| 703 | + * @clk_divider_flags: divider-specific flags for this clock | |
| 704 | + * @lock: shared register lock for this clock | |
| 705 | + */ | |
| 706 | +#define clk_hw_register_divider_parent_data(dev, name, parent_data, flags, \ | |
| 707 | + reg, shift, width, \ | |
| 708 | + clk_divider_flags, lock) \ | |
| 709 | + __clk_hw_register_divider((dev), NULL, (name), NULL, NULL, \ | |
| 710 | + (parent_data), (flags), (reg), (shift), \ | |
| 711 | + (width), (clk_divider_flags), NULL, (lock)) | |
| 712 | +/** | |
| 713 | + * clk_hw_register_divider_table - register a table based divider clock with | |
| 714 | + * the clock framework | |
| 715 | + * @dev: device registering this clock | |
| 716 | + * @name: name of this clock | |
| 717 | + * @parent_name: name of clock's parent | |
| 718 | + * @flags: framework-specific flags | |
| 719 | + * @reg: register address to adjust divider | |
| 720 | + * @shift: number of bits to shift the bitfield | |
| 721 | + * @width: width of the bitfield | |
| 722 | + * @clk_divider_flags: divider-specific flags for this clock | |
| 723 | + * @table: array of divider/value pairs ending with a div set to 0 | |
| 724 | + * @lock: shared register lock for this clock | |
| 725 | + */ | |
| 726 | +#define clk_hw_register_divider_table(dev, name, parent_name, flags, reg, \ | |
| 727 | + shift, width, clk_divider_flags, table, \ | |
| 728 | + lock) \ | |
| 729 | + __clk_hw_register_divider((dev), NULL, (name), (parent_name), NULL, \ | |
| 730 | + NULL, (flags), (reg), (shift), (width), \ | |
| 731 | + (clk_divider_flags), (table), (lock)) | |
| 732 | +/** | |
| 733 | + * clk_hw_register_divider_table_parent_hw - register a table based divider | |
| 734 | + * clock with the clock framework | |
| 735 | + * @dev: device registering this clock | |
| 736 | + * @name: name of this clock | |
| 737 | + * @parent_hw: pointer to parent clk | |
| 738 | + * @flags: framework-specific flags | |
| 739 | + * @reg: register address to adjust divider | |
| 740 | + * @shift: number of bits to shift the bitfield | |
| 741 | + * @width: width of the bitfield | |
| 742 | + * @clk_divider_flags: divider-specific flags for this clock | |
| 743 | + * @table: array of divider/value pairs ending with a div set to 0 | |
| 744 | + * @lock: shared register lock for this clock | |
| 745 | + */ | |
| 746 | +#define clk_hw_register_divider_table_parent_hw(dev, name, parent_hw, flags, \ | |
| 747 | + reg, shift, width, \ | |
| 748 | + clk_divider_flags, table, \ | |
| 749 | + lock) \ | |
| 750 | + __clk_hw_register_divider((dev), NULL, (name), NULL, (parent_hw), \ | |
| 751 | + NULL, (flags), (reg), (shift), (width), \ | |
| 752 | + (clk_divider_flags), (table), (lock)) | |
| 753 | +/** | |
| 754 | + * clk_hw_register_divider_table_parent_data - register a table based divider | |
| 755 | + * clock with the clock framework | |
| 756 | + * @dev: device registering this clock | |
| 757 | + * @name: name of this clock | |
| 758 | + * @parent_data: parent clk data | |
| 759 | + * @flags: framework-specific flags | |
| 760 | + * @reg: register address to adjust divider | |
| 761 | + * @shift: number of bits to shift the bitfield | |
| 762 | + * @width: width of the bitfield | |
| 763 | + * @clk_divider_flags: divider-specific flags for this clock | |
| 764 | + * @table: array of divider/value pairs ending with a div set to 0 | |
| 765 | + * @lock: shared register lock for this clock | |
| 766 | + */ | |
| 767 | +#define clk_hw_register_divider_table_parent_data(dev, name, parent_data, \ | |
| 768 | + flags, reg, shift, width, \ | |
| 769 | + clk_divider_flags, table, \ | |
| 770 | + lock) \ | |
| 771 | + __clk_hw_register_divider((dev), NULL, (name), NULL, NULL, \ | |
| 772 | + (parent_data), (flags), (reg), (shift), \ | |
| 773 | + (width), (clk_divider_flags), (table), \ | |
| 774 | + (lock)) | |
| 775 | + | |
| 647 | 776 | void clk_unregister_divider(struct clk *clk); |
| 648 | 777 | void clk_hw_unregister_divider(struct clk_hw *hw); |
| 649 | 778 | |