| @@ -24,7 +24,7 @@ · 23 unmodified lines |
| 24 | #define CLK_SET_RATE_PARENT BIT(2) /* propagate rate change up one level */ | 24 | #define CLK_SET_RATE_PARENT BIT(2) /* propagate rate change up one level */ |
| 25 | #define CLK_IGNORE_UNUSED BIT(3) /* do not gate even if unused */ | 25 | #define CLK_IGNORE_UNUSED BIT(3) /* do not gate even if unused */ |
| 26 | /* unused */ | 26 | /* unused */ |
| 27 | #define CLK_IS_BASIC BIT(5) /* Basic clk, can't do a to_clk_foo() */ | 27 | /* unused */ |
| 28 | #define CLK_GET_RATE_NOCACHE BIT(6) /* do not use the cached clk rate */ | 28 | #define CLK_GET_RATE_NOCACHE BIT(6) /* do not use the cached clk rate */ |
| 29 | #define CLK_SET_RATE_NO_REPARENT BIT(7) /* don't re-parent on rate change */ | 29 | #define CLK_SET_RATE_NO_REPARENT BIT(7) /* don't re-parent on rate change */ |
| 30 | #define CLK_GET_ACCURACY_NOCACHE BIT(8) /* do not use the cached clk accuracy */ | 30 | #define CLK_GET_ACCURACY_NOCACHE BIT(8) /* do not use the cached clk accuracy */ |
| @@ -250,6 +250,20 @@ struct clk_ops { · 219 unmodified lines |
| 250 | void (*debug_init)(struct clk_hw *hw, struct dentry *dentry); | 250 | void (*debug_init)(struct clk_hw *hw, struct dentry *dentry); |
| 251 | }; | 251 | }; |
| 252 | | 252 | |
| | 253 | /** |
| | 254 | * struct clk_parent_data - clk parent information |
| | 255 | * @hw: parent clk_hw pointer (used for clk providers with internal clks) |
| | 256 | * @fw_name: parent name local to provider registering clk |
| | 257 | * @name: globally unique parent name (used as a fallback) |
| | 258 | * @index: parent index local to provider registering clk (if @fw_name absent) |
| | 259 | */ |
| | 260 | struct clk_parent_data { |
| | 261 | const struct clk_hw *hw; |
| | 262 | const char *fw_name; |
| | 263 | const char *name; |
| | 264 | int index; |
| | 265 | }; |
| | 266 | |
| 253 | /** | 267 | /** |
| 254 | * struct clk_init_data - holds init data that's common to all clocks and is | 268 | * struct clk_init_data - holds init data that's common to all clocks and is |
| 255 | * shared between the clock provider and the common clock framework. | 269 | * shared between the clock provider and the common clock framework. |
| @@ -257,13 +271,20 @@ struct clk_ops { · 1 unmodified line |
| 257 | * @name: clock name | 271 | * @name: clock name |
| 258 | * @ops: operations this clock supports | 272 | * @ops: operations this clock supports |
| 259 | * @parent_names: array of string names for all possible parents | 273 | * @parent_names: array of string names for all possible parents |
| | 274 | * @parent_data: array of parent data for all possible parents (when some |
| | 275 | * parents are external to the clk controller) |
| | 276 | * @parent_hws: array of pointers to all possible parents (when all parents |
| | 277 | * are internal to the clk controller) |
| 260 | * @num_parents: number of possible parents | 278 | * @num_parents: number of possible parents |
| 261 | * @flags: framework-level hints and quirks | 279 | * @flags: framework-level hints and quirks |
| 262 | */ | 280 | */ |
| 263 | struct clk_init_data { | 281 | struct clk_init_data { |
| 264 | const char *name; | 282 | const char *name; |
| 265 | const struct clk_ops *ops; | 283 | const struct clk_ops *ops; |
| | 284 | /* Only one of the following three should be assigned */ |
| 266 | const char * const *parent_names; | 285 | const char * const *parent_names; |
| | 286 | const struct clk_parent_data *parent_data; |
| | 287 | const struct clk_hw **parent_hws; |
| 267 | u8 num_parents; | 288 | u8 num_parents; |
| 268 | unsigned long flags; | 289 | unsigned long flags; |
| 269 | }; | 290 | }; |
| @@ -307,7 +328,6 @@ struct clk_fixed_rate { · 37 unmodified lines |
| 307 | struct clk_hw hw; | 328 | struct clk_hw hw; |
| 308 | unsigned long fixed_rate; | 329 | unsigned long fixed_rate; |
| 309 | unsigned long fixed_accuracy; | 330 | unsigned long fixed_accuracy; |
| 310 | u8 flags; | | |
| 311 | }; | 331 | }; |
| 312 | | 332 | |
| 313 | #define to_clk_fixed_rate(_hw) container_of(_hw, struct clk_fixed_rate, hw) | 333 | #define to_clk_fixed_rate(_hw) container_of(_hw, struct clk_fixed_rate, hw) |
| @@ -349,6 +369,9 @@ void of_fixed_clk_setup(struct device_node *np); · 35 unmodified lines |
| 349 | * of this register, and mask of gate bits are in higher 16-bit of this | 369 | * of this register, and mask of gate bits are in higher 16-bit of this |
| 350 | * register. While setting the gate bits, higher 16-bit should also be | 370 | * register. While setting the gate bits, higher 16-bit should also be |
| 351 | * updated to indicate changing gate bits. | 371 | * updated to indicate changing gate bits. |
| | 372 | * CLK_GATE_BIG_ENDIAN - by default little endian register accesses are used for |
| | 373 | * the gate register. Setting this flag makes the register accesses big |
| | 374 | * endian. |
| 352 | */ | 375 | */ |
| 353 | struct clk_gate { | 376 | struct clk_gate { |
| 354 | struct clk_hw hw; | 377 | struct clk_hw hw; |
| @@ -362,6 +385,7 @@ struct clk_gate { · 7 unmodified lines |
| 362 | | 385 | |
| 363 | #define CLK_GATE_SET_TO_DISABLE BIT(0) | 386 | #define CLK_GATE_SET_TO_DISABLE BIT(0) |
| 364 | #define CLK_GATE_HIWORD_MASK BIT(1) | 387 | #define CLK_GATE_HIWORD_MASK BIT(1) |
| | 388 | #define CLK_GATE_BIG_ENDIAN BIT(2) |
| 365 | | 389 | |
| 366 | extern const struct clk_ops clk_gate_ops; | 390 | extern const struct clk_ops clk_gate_ops; |
| 367 | struct clk *clk_register_gate(struct device *dev, const char *name, | 391 | struct clk *clk_register_gate(struct device *dev, const char *name, |
| @@ -417,6 +441,9 @@ struct clk_div_table { · 49 unmodified lines |
| 417 | * CLK_DIVIDER_MAX_AT_ZERO - For dividers which are like CLK_DIVIDER_ONE_BASED | 441 | * CLK_DIVIDER_MAX_AT_ZERO - For dividers which are like CLK_DIVIDER_ONE_BASED |
| 418 | * except when the value read from the register is zero, the divisor is | 442 | * except when the value read from the register is zero, the divisor is |
| 419 | * 2^width of the field. | 443 | * 2^width of the field. |
| | 444 | * CLK_DIVIDER_BIG_ENDIAN - By default little endian register accesses are used |
| | 445 | * for the divider register. Setting this flag makes the register accesses |
| | 446 | * big endian. |
| 420 | */ | 447 | */ |
| 421 | struct clk_divider { | 448 | struct clk_divider { |
| 422 | struct clk_hw hw; | 449 | struct clk_hw hw; |
| @@ -438,6 +465,7 @@ struct clk_divider { · 15 unmodified lines |
| 438 | #define CLK_DIVIDER_ROUND_CLOSEST BIT(4) | 465 | #define CLK_DIVIDER_ROUND_CLOSEST BIT(4) |
| 439 | #define CLK_DIVIDER_READ_ONLY BIT(5) | 466 | #define CLK_DIVIDER_READ_ONLY BIT(5) |
| 440 | #define CLK_DIVIDER_MAX_AT_ZERO BIT(6) | 467 | #define CLK_DIVIDER_MAX_AT_ZERO BIT(6) |
| | 468 | #define CLK_DIVIDER_BIG_ENDIAN BIT(7) |
| 441 | | 469 | |
| 442 | extern const struct clk_ops clk_divider_ops; | 470 | extern const struct clk_ops clk_divider_ops; |
| 443 | extern const struct clk_ops clk_divider_ro_ops; | 471 | extern const struct clk_ops clk_divider_ro_ops; |
| @@ -499,8 +527,13 @@ void clk_hw_unregister_divider(struct clk_hw *hw); · 55 unmodified lines |
| 499 | * register, and mask of mux bits are in higher 16-bit of this register. | 527 | * register, and mask of mux bits are in higher 16-bit of this register. |
| 500 | * While setting the mux bits, higher 16-bit should also be updated to | 528 | * While setting the mux bits, higher 16-bit should also be updated to |
| 501 | * indicate changing mux bits. | 529 | * indicate changing mux bits. |
| | 530 | * CLK_MUX_READ_ONLY - The mux registers can't be written, only read in the |
| | 531 | * .get_parent clk_op. |
| 502 | * CLK_MUX_ROUND_CLOSEST - Use the parent rate that is closest to the desired | 532 | * CLK_MUX_ROUND_CLOSEST - Use the parent rate that is closest to the desired |
| 503 | * frequency. | 533 | * frequency. |
| | 534 | * CLK_MUX_BIG_ENDIAN - By default little endian register accesses are used for |
| | 535 | * the mux register. Setting this flag makes the register accesses big |
| | 536 | * endian. |
| 504 | */ | 537 | */ |
| 505 | struct clk_mux { | 538 | struct clk_mux { |
| 506 | struct clk_hw hw; | 539 | struct clk_hw hw; |
| @@ -519,6 +552,7 @@ struct clk_mux { · 12 unmodified lines |
| 519 | #define CLK_MUX_HIWORD_MASK BIT(2) | 552 | #define CLK_MUX_HIWORD_MASK BIT(2) |
| 520 | #define CLK_MUX_READ_ONLY BIT(3) /* mux can't be changed */ | 553 | #define CLK_MUX_READ_ONLY BIT(3) /* mux can't be changed */ |
| 521 | #define CLK_MUX_ROUND_CLOSEST BIT(4) | 554 | #define CLK_MUX_ROUND_CLOSEST BIT(4) |
| | 555 | #define CLK_MUX_BIG_ENDIAN BIT(5) |
| 522 | | 556 | |
| 523 | extern const struct clk_ops clk_mux_ops; | 557 | extern const struct clk_ops clk_mux_ops; |
| 524 | extern const struct clk_ops clk_mux_ro_ops; | 558 | extern const struct clk_ops clk_mux_ro_ops; |
| @@ -602,6 +636,9 @@ void clk_hw_unregister_fixed_factor(struct clk_hw *hw); · 77 unmodified lines |
| 602 | * is the value read from the register. If CLK_FRAC_DIVIDER_ZERO_BASED | 636 | * is the value read from the register. If CLK_FRAC_DIVIDER_ZERO_BASED |
| 603 | * is set then the numerator and denominator are both the value read | 637 | * is set then the numerator and denominator are both the value read |
| 604 | * plus one. | 638 | * plus one. |
| | 639 | * CLK_FRAC_DIVIDER_BIG_ENDIAN - By default little endian register accesses are |
| | 640 | * used for the divider register. Setting this flag makes the register |
| | 641 | * accesses big endian. |
| 605 | */ | 642 | */ |
| 606 | struct clk_fractional_divider { | 643 | struct clk_fractional_divider { |
| 607 | struct clk_hw hw; | 644 | struct clk_hw hw; |
| @@ -622,6 +659,7 @@ struct clk_fractional_divider { · 14 unmodified lines |
| 622 | #define to_clk_fd(_hw) container_of(_hw, struct clk_fractional_divider, hw) | 659 | #define to_clk_fd(_hw) container_of(_hw, struct clk_fractional_divider, hw) |
| 623 | | 660 | |
| 624 | #define CLK_FRAC_DIVIDER_ZERO_BASED BIT(0) | 661 | #define CLK_FRAC_DIVIDER_ZERO_BASED BIT(0) |
| | 662 | #define CLK_FRAC_DIVIDER_BIG_ENDIAN BIT(1) |
| 625 | | 663 | |
| 626 | extern const struct clk_ops clk_fractional_divider_ops; | 664 | extern const struct clk_ops clk_fractional_divider_ops; |
| 627 | struct clk *clk_register_fractional_divider(struct device *dev, | 665 | struct clk *clk_register_fractional_divider(struct device *dev, |
| @@ -654,6 +692,9 @@ void clk_hw_unregister_fractional_divider(struct clk_hw *hw); · 26 unmodified lines |
| 654 | * leaving the parent rate unmodified. | 692 | * leaving the parent rate unmodified. |
| 655 | * CLK_MULTIPLIER_ROUND_CLOSEST - Makes the best calculated divider to be | 693 | * CLK_MULTIPLIER_ROUND_CLOSEST - Makes the best calculated divider to be |
| 656 | * rounded to the closest integer instead of the down one. | 694 | * rounded to the closest integer instead of the down one. |
| | 695 | * CLK_MULTIPLIER_BIG_ENDIAN - By default little endian register accesses are |
| | 696 | * used for the multiplier register. Setting this flag makes the register |
| | 697 | * accesses big endian. |
| 657 | */ | 698 | */ |
| 658 | struct clk_multiplier { | 699 | struct clk_multiplier { |
| 659 | struct clk_hw hw; | 700 | struct clk_hw hw; |
| @@ -668,6 +709,7 @@ struct clk_multiplier { · 8 unmodified lines |
| 668 | | 709 | |
| 669 | #define CLK_MULTIPLIER_ZERO_BYPASS BIT(0) | 710 | #define CLK_MULTIPLIER_ZERO_BYPASS BIT(0) |
| 670 | #define CLK_MULTIPLIER_ROUND_CLOSEST BIT(1) | 711 | #define CLK_MULTIPLIER_ROUND_CLOSEST BIT(1) |
| | 712 | #define CLK_MULTIPLIER_BIG_ENDIAN BIT(2) |
| 671 | | 713 | |
| 672 | extern const struct clk_ops clk_multiplier_ops; | 714 | extern const struct clk_ops clk_multiplier_ops; |
| 673 | | 715 | |
| @@ -712,16 +754,19 @@ struct clk_hw *clk_hw_register_composite(struct device *dev, const char *name, · 38 unmodified lines |
| 712 | unsigned long flags); | 754 | unsigned long flags); |
| 713 | void clk_hw_unregister_composite(struct clk_hw *hw); | 755 | void clk_hw_unregister_composite(struct clk_hw *hw); |
| 714 | | 756 | |
| 715 | /*** | 757 | /** |
| 716 | * struct clk_gpio_gate - gpio gated clock | 758 | * struct clk_gpio - gpio gated clock |
| 717 | * | 759 | * |
| 718 | * @hw: handle between common and hardware-specific interfaces | 760 | * @hw: handle between common and hardware-specific interfaces |
| 719 | * @gpiod: gpio descriptor | 761 | * @gpiod: gpio descriptor |
| 720 | * | 762 | * |
| 721 | * Clock with a gpio control for enabling and disabling the parent clock. | 763 | * Clock with a gpio control for enabling and disabling the parent clock |
| 722 | * Implements .enable, .disable and .is_enabled | 764 | * or switching between two parents by asserting or deasserting the gpio. |
| | 765 | * |
| | 766 | * Implements .enable, .disable and .is_enabled or |
| | 767 | * .get_parent, .set_parent and .determine_rate depending on which clk_ops |
| | 768 | * is used. |
| 723 | */ | 769 | */ |
| 724 | | | |
| 725 | struct clk_gpio { | 770 | struct clk_gpio { |
| 726 | struct clk_hw hw; | 771 | struct clk_hw hw; |
| 727 | struct gpio_desc *gpiod; | 772 | struct gpio_desc *gpiod; |
| @@ -738,16 +783,6 @@ struct clk_hw *clk_hw_register_gpio_gate(struct device *dev, const char *name, · 10 unmodified lines |
| 738 | unsigned long flags); | 783 | unsigned long flags); |
| 739 | void clk_hw_unregister_gpio_gate(struct clk_hw *hw); | 784 | void clk_hw_unregister_gpio_gate(struct clk_hw *hw); |
| 740 | | 785 | |
| 741 | /** | | |
| 742 | * struct clk_gpio_mux - gpio controlled clock multiplexer | | |
| 743 | * | | |
| 744 | * @hw: see struct clk_gpio | | |
| 745 | * @gpiod: gpio descriptor to select the parent of this clock multiplexer | | |
| 746 | * | | |
| 747 | * Clock with a gpio control for selecting the parent clock. | | |
| 748 | * Implements .get_parent, .set_parent and .determine_rate | | |
| 749 | */ | | |
| 750 | | | |
| 751 | extern const struct clk_ops clk_gpio_mux_ops; | 786 | extern const struct clk_ops clk_gpio_mux_ops; |
| 752 | struct clk *clk_register_gpio_mux(struct device *dev, const char *name, | 787 | struct clk *clk_register_gpio_mux(struct device *dev, const char *name, |
| 753 | const char * const *parent_names, u8 num_parents, struct gpio_desc *gpiod, | 788 | const char * const *parent_names, u8 num_parents, struct gpio_desc *gpiod, |
| @@ -757,22 +792,12 @@ struct clk_hw *clk_hw_register_gpio_mux(struct device *dev, const char *name, · 3 unmodified lines |
| 757 | unsigned long flags); | 792 | unsigned long flags); |
| 758 | void clk_hw_unregister_gpio_mux(struct clk_hw *hw); | 793 | void clk_hw_unregister_gpio_mux(struct clk_hw *hw); |
| 759 | | 794 | |
| 760 | /** | | |
| 761 | * clk_register - allocate a new clock, register it and return an opaque cookie | | |
| 762 | * @dev: device that is registering this clock | | |
| 763 | * @hw: link to hardware-specific clock data | | |
| 764 | * | | |
| 765 | * clk_register is the primary interface for populating the clock tree with new | | |
| 766 | * clock nodes. It returns a pointer to the newly allocated struct clk which | | |
| 767 | * cannot be dereferenced by driver code but may be used in conjuction with the | | |
| 768 | * rest of the clock API. In the event of an error clk_register will return an | | |
| 769 | * error code; drivers must test for an error code after calling clk_register. | | |
| 770 | */ | | |
| 771 | struct clk *clk_register(struct device *dev, struct clk_hw *hw); | 795 | struct clk *clk_register(struct device *dev, struct clk_hw *hw); |
| 772 | struct clk *devm_clk_register(struct device *dev, struct clk_hw *hw); | 796 | struct clk *devm_clk_register(struct device *dev, struct clk_hw *hw); |
| 773 | | 797 | |
| 774 | int __must_check clk_hw_register(struct device *dev, struct clk_hw *hw); | 798 | int __must_check clk_hw_register(struct device *dev, struct clk_hw *hw); |
| 775 | int __must_check devm_clk_hw_register(struct device *dev, struct clk_hw *hw); | 799 | int __must_check devm_clk_hw_register(struct device *dev, struct clk_hw *hw); |
| | 800 | int __must_check of_clk_hw_register(struct device_node *node, struct clk_hw *hw); |
| 776 | | 801 | |
| 777 | void clk_unregister(struct clk *clk); | 802 | void clk_unregister(struct clk *clk); |
| 778 | void devm_clk_unregister(struct device *dev, struct clk *clk); | 803 | void devm_clk_unregister(struct device *dev, struct clk *clk); |
| @@ -993,37 +1018,6 @@ static inline int of_clk_detect_critical(struct device_node *np, int index, · 214 unmodified lines |
| 993 | } | 1018 | } |
| 994 | #endif /* CONFIG_OF */ | 1019 | #endif /* CONFIG_OF */ |
| 995 | | 1020 | |
| 996 | /* | | |
| 997 | * wrap access to peripherals in accessor routines | | |
| 998 | * for improved portability across platforms | | |
| 999 | */ | | |
| 1000 | | | |
| 1001 | #if IS_ENABLED(CONFIG_PPC) | | |
| 1002 | | | |
| 1003 | static inline u32 clk_readl(u32 __iomem *reg) | | |
| 1004 | { | | |
| 1005 | return ioread32be(reg); | | |
| 1006 | } | | |
| 1007 | | | |
| 1008 | static inline void clk_writel(u32 val, u32 __iomem *reg) | | |
| 1009 | { | | |
| 1010 | iowrite32be(val, reg); | | |
| 1011 | } | | |
| 1012 | | | |
| 1013 | #else /* platform dependent I/O accessors */ | | |
| 1014 | | | |
| 1015 | static inline u32 clk_readl(u32 __iomem *reg) | | |
| 1016 | { | | |
| 1017 | return readl(reg); | | |
| 1018 | } | | |
| 1019 | | | |
| 1020 | static inline void clk_writel(u32 val, u32 __iomem *reg) | | |
| 1021 | { | | |
| 1022 | writel(val, reg); | | |
| 1023 | } | | |
| 1024 | | | |
| 1025 | #endif /* platform dependent I/O accessors */ | | |
| 1026 | | | |
| 1027 | void clk_gate_restore_context(struct clk_hw *hw); | 1021 | void clk_gate_restore_context(struct clk_hw *hw); |
| 1028 | | 1022 | |
| 1029 | #endif /* CONFIG_COMMON_CLK */ | 1023 | #endif /* CONFIG_COMMON_CLK */ |