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

sh: Use arch_flags to simplify sh7722 siu clock code

Make use of arch_flags to simplify the SIU clock code.

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
3fec18bd 5c8f9d94

+9 -38
+9 -38
arch/sh/kernel/cpu/sh4a/clock-sh7722.c
··· 411 411 * clock ops methods for SIU A/B and IrDA clock 412 412 * 413 413 */ 414 - static int sh7722_siu_which(struct clk *clk) 415 - { 416 - if (!strcmp(clk->name, "siu_a_clk")) 417 - return 0; 418 - if (!strcmp(clk->name, "siu_b_clk")) 419 - return 1; 420 - #if defined(CONFIG_CPU_SUBTYPE_SH7722) 421 - if (!strcmp(clk->name, "irda_clk")) 422 - return 2; 423 - #endif 424 - return -EINVAL; 425 - } 426 - 427 - static unsigned long sh7722_siu_regs[] = { 428 - [0] = SCLKACR, 429 - [1] = SCLKBCR, 430 - #if defined(CONFIG_CPU_SUBTYPE_SH7722) 431 - [2] = IrDACLKCR, 432 - #endif 433 - }; 434 414 435 415 static int sh7722_siu_start_stop(struct clk *clk, int enable) 436 416 { 437 - int siu = sh7722_siu_which(clk); 438 417 unsigned long r; 439 418 440 - if (siu < 0) 441 - return siu; 442 - BUG_ON(siu > 2); 443 - r = ctrl_inl(sh7722_siu_regs[siu]); 419 + r = ctrl_inl(clk->arch_flags); 444 420 if (enable) 445 - ctrl_outl(r & ~(1 << 8), sh7722_siu_regs[siu]); 421 + ctrl_outl(r & ~(1 << 8), clk->arch_flags); 446 422 else 447 - ctrl_outl(r | (1 << 8), sh7722_siu_regs[siu]); 423 + ctrl_outl(r | (1 << 8), clk->arch_flags); 448 424 return 0; 449 425 } 450 426 ··· 472 496 473 497 static int sh7722_siu_set_rate(struct clk *clk, unsigned long rate, int algo_id) 474 498 { 475 - int siu = sh7722_siu_which(clk); 476 499 unsigned long r; 477 500 int div; 478 501 479 - if (siu < 0) 480 - return siu; 481 - BUG_ON(siu > 2); 482 - r = ctrl_inl(sh7722_siu_regs[siu]); 502 + r = ctrl_inl(clk->arch_flags); 483 503 div = sh7722_find_divisors(clk->parent->rate, rate); 484 504 if (div < 0) 485 505 return div; 486 506 r = (r & ~0xF) | div; 487 - ctrl_outl(r, sh7722_siu_regs[siu]); 507 + ctrl_outl(r, clk->arch_flags); 488 508 return 0; 489 509 } 490 510 491 511 static void sh7722_siu_recalc(struct clk *clk) 492 512 { 493 - int siu = sh7722_siu_which(clk); 494 513 unsigned long r; 495 514 496 - if (siu < 0) 497 - return /* siu */ ; 498 - BUG_ON(siu > 2); 499 - r = ctrl_inl(sh7722_siu_regs[siu]); 515 + r = ctrl_inl(clk->arch_flags); 500 516 clk->rate = clk->parent->rate * 2 / divisors2[r & 0xF]; 501 517 } 502 518 ··· 535 567 */ 536 568 static struct clk sh7722_siu_a_clock = { 537 569 .name = "siu_a_clk", 570 + .arch_flags = SCLKACR, 538 571 .ops = &sh7722_siu_clk_ops, 539 572 }; 540 573 541 574 static struct clk sh7722_siu_b_clock = { 542 575 .name = "siu_b_clk", 576 + .arch_flags = SCLKBCR, 543 577 .ops = &sh7722_siu_clk_ops, 544 578 }; 545 579 546 580 #if defined(CONFIG_CPU_SUBTYPE_SH7722) 547 581 static struct clk sh7722_irda_clock = { 548 582 .name = "irda_clk", 583 + .arch_flags = IrDACLKCR, 549 584 .ops = &sh7722_siu_clk_ops, 550 585 }; 551 586 #endif