setup.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Alchemy/AMD/RMI DB1200 board setup.
  3. *
  4. * Licensed under the terms outlined in the file COPYING in the root of
  5. * this source archive.
  6. */
  7. #include <linux/init.h>
  8. #include <linux/interrupt.h>
  9. #include <linux/io.h>
  10. #include <linux/kernel.h>
  11. #include <asm/mach-au1x00/au1000.h>
  12. #include <asm/mach-db1x00/bcsr.h>
  13. #include <asm/mach-db1x00/db1200.h>
  14. const char *get_system_type(void)
  15. {
  16. return "Alchemy Db1200";
  17. }
  18. void __init board_setup(void)
  19. {
  20. unsigned long freq0, clksrc, div, pfc;
  21. unsigned short whoami;
  22. bcsr_init(DB1200_BCSR_PHYS_ADDR,
  23. DB1200_BCSR_PHYS_ADDR + DB1200_BCSR_HEXLED_OFS);
  24. whoami = bcsr_read(BCSR_WHOAMI);
  25. printk(KERN_INFO "Alchemy/AMD/RMI DB1200 Board, CPLD Rev %d"
  26. " Board-ID %d Daughtercard ID %d\n",
  27. (whoami >> 4) & 0xf, (whoami >> 8) & 0xf, whoami & 0xf);
  28. /* SMBus/SPI on PSC0, Audio on PSC1 */
  29. pfc = __raw_readl((void __iomem *)SYS_PINFUNC);
  30. pfc &= ~(SYS_PINFUNC_P0A | SYS_PINFUNC_P0B);
  31. pfc &= ~(SYS_PINFUNC_P1A | SYS_PINFUNC_P1B | SYS_PINFUNC_FS3);
  32. pfc |= SYS_PINFUNC_P1C; /* SPI is configured later */
  33. __raw_writel(pfc, (void __iomem *)SYS_PINFUNC);
  34. wmb();
  35. /* Clock configurations: PSC0: ~50MHz via Clkgen0, derived from
  36. * CPU clock; all other clock generators off/unused.
  37. */
  38. div = (get_au1x00_speed() + 25000000) / 50000000;
  39. if (div & 1)
  40. div++;
  41. div = ((div >> 1) - 1) & 0xff;
  42. freq0 = div << SYS_FC_FRDIV0_BIT;
  43. __raw_writel(freq0, (void __iomem *)SYS_FREQCTRL0);
  44. wmb();
  45. freq0 |= SYS_FC_FE0; /* enable F0 */
  46. __raw_writel(freq0, (void __iomem *)SYS_FREQCTRL0);
  47. wmb();
  48. /* psc0_intclk comes 1:1 from F0 */
  49. clksrc = SYS_CS_MUX_FQ0 << SYS_CS_ME0_BIT;
  50. __raw_writel(clksrc, (void __iomem *)SYS_CLKSRC);
  51. wmb();
  52. }
  53. static int __init db1200_arch_init(void)
  54. {
  55. /* GPIO7 is low-level triggered CPLD cascade */
  56. set_irq_type(AU1200_GPIO7_INT, IRQF_TRIGGER_LOW);
  57. bcsr_init_irq(DB1200_INT_BEGIN, DB1200_INT_END, AU1200_GPIO7_INT);
  58. /* do not autoenable these: CPLD has broken edge int handling,
  59. * and the CD handler setup requires manual enabling to work
  60. * around that.
  61. */
  62. irq_to_desc(DB1200_SD0_INSERT_INT)->status |= IRQ_NOAUTOEN;
  63. irq_to_desc(DB1200_SD0_EJECT_INT)->status |= IRQ_NOAUTOEN;
  64. return 0;
  65. }
  66. arch_initcall(db1200_arch_init);