1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 /* 3 * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org> 4 */ 5 6 /* 7 * These machine IDs are no longer used by the kernel since EP93xx was converted 8 * to DT booting, but they are still passed in by bootloaders, so we use our own 9 * local definitions of the relevant macros. 10 */ 11 #define machine_is_bk3() (__machine_arch_type == 1880) 12 #define machine_is_edb9301() (__machine_arch_type == 462) 13 #define machine_is_edb9302a() (__machine_arch_type == 1127) 14 #define machine_is_edb9302() (__machine_arch_type == 538) 15 #define machine_is_edb9307a() (__machine_arch_type == 1128) 16 #define machine_is_edb9307() (__machine_arch_type == 607) 17 #define machine_is_edb9312() (__machine_arch_type == 451) 18 #define machine_is_edb9315a() (__machine_arch_type == 772) 19 #define machine_is_edb9315() (__machine_arch_type == 463) 20 #define machine_is_ts72xx() (__machine_arch_type == 673) 21 #define machine_is_vision_ep9307() (__machine_arch_type == 1578) 22 23 static inline unsigned int __raw_readl(unsigned int ptr) 24 { 25 return *((volatile unsigned int *)ptr); 26 } 27 28 static inline void __raw_writeb(unsigned char value, unsigned int ptr) 29 { 30 *((volatile unsigned char *)ptr) = value; 31 } 32 33 static inline void __raw_writel(unsigned int value, unsigned int ptr) 34 { 35 *((volatile unsigned int *)ptr) = value; 36 } 37 38 /* 39 * Some bootloaders don't turn off DMA from the ethernet MAC before 40 * jumping to linux, which means that we might end up with bits of RX 41 * status and packet data scribbled over the uncompressed kernel image. 42 * Work around this by resetting the ethernet MAC before we uncompress. 43 */ 44 #define PHYS_ETH_SELF_CTL 0x80010020 45 #define ETH_SELF_CTL_RESET 0x00000001 46 47 static inline void ep93xx_ethernet_reset(void) 48 { 49 unsigned int v; 50 51 /* Reset the ethernet MAC. */ 52 v = __raw_readl(PHYS_ETH_SELF_CTL); 53 __raw_writel(v | ETH_SELF_CTL_RESET, PHYS_ETH_SELF_CTL); 54 55 /* Wait for reset to finish. */ 56 while (__raw_readl(PHYS_ETH_SELF_CTL) & ETH_SELF_CTL_RESET) 57 ; 58 } 59 60 #define TS72XX_WDT_CONTROL_PHYS_BASE 0x23800000 61 #define TS72XX_WDT_FEED_PHYS_BASE 0x23c00000 62 #define TS72XX_WDT_FEED_VAL 0x05 63 64 static inline void __maybe_unused ts72xx_watchdog_disable(void) 65 { 66 __raw_writeb(TS72XX_WDT_FEED_VAL, TS72XX_WDT_FEED_PHYS_BASE); 67 __raw_writeb(0, TS72XX_WDT_CONTROL_PHYS_BASE); 68 } 69 70 static inline void ep93xx_decomp_setup(void) 71 { 72 if (machine_is_ts72xx()) 73 ts72xx_watchdog_disable(); 74 75 if (machine_is_edb9301() || 76 machine_is_edb9302() || 77 machine_is_edb9302a() || 78 machine_is_edb9307() || 79 machine_is_edb9307a() || 80 machine_is_edb9312() || 81 machine_is_edb9315() || 82 machine_is_edb9315a() || 83 machine_is_ts72xx() || 84 machine_is_bk3() || 85 machine_is_vision_ep9307()) 86 ep93xx_ethernet_reset(); 87 } 88