misc-ep93xx.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright (C) 2006 Lennert Buytenhek <[email protected]>
  4. */
  5. #include <asm/mach-types.h>
  6. static inline unsigned int __raw_readl(unsigned int ptr)
  7. {
  8. return *((volatile unsigned int *)ptr);
  9. }
  10. static inline void __raw_writeb(unsigned char value, unsigned int ptr)
  11. {
  12. *((volatile unsigned char *)ptr) = value;
  13. }
  14. static inline void __raw_writel(unsigned int value, unsigned int ptr)
  15. {
  16. *((volatile unsigned int *)ptr) = value;
  17. }
  18. /*
  19. * Some bootloaders don't turn off DMA from the ethernet MAC before
  20. * jumping to linux, which means that we might end up with bits of RX
  21. * status and packet data scribbled over the uncompressed kernel image.
  22. * Work around this by resetting the ethernet MAC before we uncompress.
  23. */
  24. #define PHYS_ETH_SELF_CTL 0x80010020
  25. #define ETH_SELF_CTL_RESET 0x00000001
  26. static inline void ep93xx_ethernet_reset(void)
  27. {
  28. unsigned int v;
  29. /* Reset the ethernet MAC. */
  30. v = __raw_readl(PHYS_ETH_SELF_CTL);
  31. __raw_writel(v | ETH_SELF_CTL_RESET, PHYS_ETH_SELF_CTL);
  32. /* Wait for reset to finish. */
  33. while (__raw_readl(PHYS_ETH_SELF_CTL) & ETH_SELF_CTL_RESET)
  34. ;
  35. }
  36. #define TS72XX_WDT_CONTROL_PHYS_BASE 0x23800000
  37. #define TS72XX_WDT_FEED_PHYS_BASE 0x23c00000
  38. #define TS72XX_WDT_FEED_VAL 0x05
  39. static inline void __maybe_unused ts72xx_watchdog_disable(void)
  40. {
  41. __raw_writeb(TS72XX_WDT_FEED_VAL, TS72XX_WDT_FEED_PHYS_BASE);
  42. __raw_writeb(0, TS72XX_WDT_CONTROL_PHYS_BASE);
  43. }
  44. static inline void ep93xx_decomp_setup(void)
  45. {
  46. if (machine_is_ts72xx())
  47. ts72xx_watchdog_disable();
  48. if (machine_is_adssphere() ||
  49. machine_is_edb9301() ||
  50. machine_is_edb9302() ||
  51. machine_is_edb9302a() ||
  52. machine_is_edb9302a() ||
  53. machine_is_edb9307() ||
  54. machine_is_edb9307a() ||
  55. machine_is_edb9307a() ||
  56. machine_is_edb9312() ||
  57. machine_is_edb9315() ||
  58. machine_is_edb9315a() ||
  59. machine_is_edb9315a() ||
  60. machine_is_gesbc9312() ||
  61. machine_is_micro9() ||
  62. machine_is_micro9l() ||
  63. machine_is_micro9m() ||
  64. machine_is_micro9s() ||
  65. machine_is_micro9m() ||
  66. machine_is_micro9l() ||
  67. machine_is_micro9s() ||
  68. machine_is_sim_one() ||
  69. machine_is_snapper_cl15() ||
  70. machine_is_ts72xx() ||
  71. machine_is_bk3() ||
  72. machine_is_vision_ep9307())
  73. ep93xx_ethernet_reset();
  74. }