Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sh: Add SuperH Mobile MSTPCR bits to clock framework

Handle module stop clock bits in MSTPCRn through the clock framework.
The clocks are named after the bits in the data sheet. The association
between bit number and hardware block is processor specific.

Signed-off-by: Magnus Damm <damm@igel.co.jp>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>

authored by

Magnus Damm and committed by
Paul Mundt
aea167cb 3fec18bd

+119
+116
arch/sh/kernel/cpu/sh4a/clock-sh7722.c
··· 14 14 #include <linux/kernel.h> 15 15 #include <linux/io.h> 16 16 #include <linux/errno.h> 17 + #include <linux/stringify.h> 17 18 #include <asm/clock.h> 18 19 #include <asm/freq.h> 19 20 ··· 559 558 .ops = &sh7722_video_clk_ops, 560 559 }; 561 560 561 + static int sh7722_mstpcr_start_stop(struct clk *clk, unsigned long reg, 562 + int enable) 563 + { 564 + unsigned long bit = clk->arch_flags; 565 + unsigned long r; 566 + 567 + r = ctrl_inl(reg); 568 + 569 + if (enable) 570 + r &= ~(1 << bit); 571 + else 572 + r |= (1 << bit); 573 + 574 + ctrl_outl(r, reg); 575 + return 0; 576 + } 577 + 578 + static void sh7722_mstpcr0_enable(struct clk *clk) 579 + { 580 + sh7722_mstpcr_start_stop(clk, MSTPCR0, 1); 581 + } 582 + 583 + static void sh7722_mstpcr0_disable(struct clk *clk) 584 + { 585 + sh7722_mstpcr_start_stop(clk, MSTPCR0, 0); 586 + } 587 + 588 + static void sh7722_mstpcr1_enable(struct clk *clk) 589 + { 590 + sh7722_mstpcr_start_stop(clk, MSTPCR1, 1); 591 + } 592 + 593 + static void sh7722_mstpcr1_disable(struct clk *clk) 594 + { 595 + sh7722_mstpcr_start_stop(clk, MSTPCR1, 0); 596 + } 597 + 598 + static void sh7722_mstpcr2_enable(struct clk *clk) 599 + { 600 + sh7722_mstpcr_start_stop(clk, MSTPCR2, 1); 601 + } 602 + 603 + static void sh7722_mstpcr2_disable(struct clk *clk) 604 + { 605 + sh7722_mstpcr_start_stop(clk, MSTPCR2, 0); 606 + } 607 + 608 + static struct clk_ops sh7722_mstpcr0_clk_ops = { 609 + .enable = sh7722_mstpcr0_enable, 610 + .disable = sh7722_mstpcr0_disable, 611 + }; 612 + 613 + static struct clk_ops sh7722_mstpcr1_clk_ops = { 614 + .enable = sh7722_mstpcr1_enable, 615 + .disable = sh7722_mstpcr1_disable, 616 + }; 617 + 618 + static struct clk_ops sh7722_mstpcr2_clk_ops = { 619 + .enable = sh7722_mstpcr2_enable, 620 + .disable = sh7722_mstpcr2_disable, 621 + }; 622 + 623 + #define DECLARE_MSTPCRN(regnr, bitnr, bitstr) \ 624 + { \ 625 + .name = "mstp" __stringify(regnr) bitstr, \ 626 + .arch_flags = bitnr, \ 627 + .ops = &sh7722_mstpcr ## regnr ## _clk_ops, \ 628 + } 629 + 630 + #define DECLARE_MSTPCR(regnr) \ 631 + DECLARE_MSTPCRN(regnr, 31, "31"), \ 632 + DECLARE_MSTPCRN(regnr, 30, "30"), \ 633 + DECLARE_MSTPCRN(regnr, 29, "29"), \ 634 + DECLARE_MSTPCRN(regnr, 28, "28"), \ 635 + DECLARE_MSTPCRN(regnr, 27, "27"), \ 636 + DECLARE_MSTPCRN(regnr, 26, "26"), \ 637 + DECLARE_MSTPCRN(regnr, 25, "25"), \ 638 + DECLARE_MSTPCRN(regnr, 24, "24"), \ 639 + DECLARE_MSTPCRN(regnr, 23, "23"), \ 640 + DECLARE_MSTPCRN(regnr, 22, "22"), \ 641 + DECLARE_MSTPCRN(regnr, 21, "21"), \ 642 + DECLARE_MSTPCRN(regnr, 20, "20"), \ 643 + DECLARE_MSTPCRN(regnr, 19, "19"), \ 644 + DECLARE_MSTPCRN(regnr, 18, "18"), \ 645 + DECLARE_MSTPCRN(regnr, 17, "17"), \ 646 + DECLARE_MSTPCRN(regnr, 16, "16"), \ 647 + DECLARE_MSTPCRN(regnr, 15, "15"), \ 648 + DECLARE_MSTPCRN(regnr, 14, "14"), \ 649 + DECLARE_MSTPCRN(regnr, 13, "13"), \ 650 + DECLARE_MSTPCRN(regnr, 12, "12"), \ 651 + DECLARE_MSTPCRN(regnr, 11, "11"), \ 652 + DECLARE_MSTPCRN(regnr, 10, "10"), \ 653 + DECLARE_MSTPCRN(regnr, 9, "09"), \ 654 + DECLARE_MSTPCRN(regnr, 8, "08"), \ 655 + DECLARE_MSTPCRN(regnr, 7, "07"), \ 656 + DECLARE_MSTPCRN(regnr, 6, "06"), \ 657 + DECLARE_MSTPCRN(regnr, 5, "05"), \ 658 + DECLARE_MSTPCRN(regnr, 4, "04"), \ 659 + DECLARE_MSTPCRN(regnr, 3, "03"), \ 660 + DECLARE_MSTPCRN(regnr, 2, "02"), \ 661 + DECLARE_MSTPCRN(regnr, 1, "01"), \ 662 + DECLARE_MSTPCRN(regnr, 0, "00") 663 + 664 + static struct clk sh7722_mstpcr[] = { 665 + DECLARE_MSTPCR(0), 666 + DECLARE_MSTPCR(1), 667 + DECLARE_MSTPCR(2), 668 + }; 669 + 562 670 static struct clk *sh7722_clocks[] = { 563 671 &sh7722_umem_clock, 564 672 &sh7722_sh_clock, ··· 710 600 clk_register(sh7722_clocks[i]); 711 601 } 712 602 clk_put(master); 603 + 604 + for (i = 0; i < ARRAY_SIZE(sh7722_mstpcr); i++) { 605 + pr_debug( "Registering mstpcr '%s'\n", sh7722_mstpcr[i].name); 606 + clk_register(&sh7722_mstpcr[i]); 607 + } 608 + 713 609 return 0; 714 610 }
+3
include/asm-sh/cpu-sh4/freq.h
··· 19 19 #define SCLKACR 0xa4150008 20 20 #define SCLKBCR 0xa415000c 21 21 #define IrDACLKCR 0xa4150010 22 + #define MSTPCR0 0xa4150030 23 + #define MSTPCR1 0xa4150034 24 + #define MSTPCR2 0xa4150038 22 25 #elif defined(CONFIG_CPU_SUBTYPE_SH7763) || \ 23 26 defined(CONFIG_CPU_SUBTYPE_SH7780) 24 27 #define FRQCR 0xffc80000