setup.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * s6105 control routines
  3. *
  4. * Copyright (c) 2009 emlix GmbH
  5. */
  6. #include <linux/irq.h>
  7. #include <linux/io.h>
  8. #include <linux/gpio.h>
  9. #include <asm/bootparam.h>
  10. #include <variant/hardware.h>
  11. #include <variant/gpio.h>
  12. #include <platform/gpio.h>
  13. void platform_halt(void)
  14. {
  15. local_irq_disable();
  16. while (1)
  17. ;
  18. }
  19. void platform_power_off(void)
  20. {
  21. platform_halt();
  22. }
  23. void platform_restart(void)
  24. {
  25. platform_halt();
  26. }
  27. void __init platform_setup(char **cmdline)
  28. {
  29. unsigned long reg;
  30. reg = readl(S6_REG_GREG1 + S6_GREG1_PLLSEL);
  31. reg &= ~(S6_GREG1_PLLSEL_GMAC_MASK << S6_GREG1_PLLSEL_GMAC |
  32. S6_GREG1_PLLSEL_GMII_MASK << S6_GREG1_PLLSEL_GMII);
  33. reg |= S6_GREG1_PLLSEL_GMAC_125MHZ << S6_GREG1_PLLSEL_GMAC |
  34. S6_GREG1_PLLSEL_GMII_125MHZ << S6_GREG1_PLLSEL_GMII;
  35. writel(reg, S6_REG_GREG1 + S6_GREG1_PLLSEL);
  36. reg = readl(S6_REG_GREG1 + S6_GREG1_CLKGATE);
  37. reg &= ~(1 << S6_GREG1_BLOCK_SB);
  38. reg &= ~(1 << S6_GREG1_BLOCK_GMAC);
  39. writel(reg, S6_REG_GREG1 + S6_GREG1_CLKGATE);
  40. reg = readl(S6_REG_GREG1 + S6_GREG1_BLOCKENA);
  41. reg |= 1 << S6_GREG1_BLOCK_SB;
  42. reg |= 1 << S6_GREG1_BLOCK_GMAC;
  43. writel(reg, S6_REG_GREG1 + S6_GREG1_BLOCKENA);
  44. printk(KERN_NOTICE "S6105 on Stretch S6000 - "
  45. "Copyright (C) 2009 emlix GmbH <info@emlix.com>\n");
  46. }
  47. void __init platform_init(bp_tag_t *first)
  48. {
  49. s6_gpio_init(0);
  50. gpio_request(GPIO_LED1_NGREEN, "led1_green");
  51. gpio_request(GPIO_LED1_RED, "led1_red");
  52. gpio_direction_output(GPIO_LED1_NGREEN, 1);
  53. }
  54. void platform_heartbeat(void)
  55. {
  56. static unsigned int c;
  57. if (!(++c & 0x4F))
  58. gpio_direction_output(GPIO_LED1_RED, !(c & 0x10));
  59. }