Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
0004  */
0005 
0006 #include <asm/mach-types.h>
0007 
0008 static inline unsigned int __raw_readl(unsigned int ptr)
0009 {
0010     return *((volatile unsigned int *)ptr);
0011 }
0012 
0013 static inline void __raw_writeb(unsigned char value, unsigned int ptr)
0014 {
0015     *((volatile unsigned char *)ptr) = value;
0016 }
0017 
0018 static inline void __raw_writel(unsigned int value, unsigned int ptr)
0019 {
0020     *((volatile unsigned int *)ptr) = value;
0021 }
0022 
0023 /*
0024  * Some bootloaders don't turn off DMA from the ethernet MAC before
0025  * jumping to linux, which means that we might end up with bits of RX
0026  * status and packet data scribbled over the uncompressed kernel image.
0027  * Work around this by resetting the ethernet MAC before we uncompress.
0028  */
0029 #define PHYS_ETH_SELF_CTL       0x80010020
0030 #define ETH_SELF_CTL_RESET      0x00000001
0031 
0032 static inline void ep93xx_ethernet_reset(void)
0033 {
0034     unsigned int v;
0035 
0036     /* Reset the ethernet MAC.  */
0037     v = __raw_readl(PHYS_ETH_SELF_CTL);
0038     __raw_writel(v | ETH_SELF_CTL_RESET, PHYS_ETH_SELF_CTL);
0039 
0040     /* Wait for reset to finish.  */
0041     while (__raw_readl(PHYS_ETH_SELF_CTL) & ETH_SELF_CTL_RESET)
0042         ;
0043 }
0044 
0045 #define TS72XX_WDT_CONTROL_PHYS_BASE    0x23800000
0046 #define TS72XX_WDT_FEED_PHYS_BASE   0x23c00000
0047 #define TS72XX_WDT_FEED_VAL     0x05
0048 
0049 static inline void __maybe_unused ts72xx_watchdog_disable(void)
0050 {
0051     __raw_writeb(TS72XX_WDT_FEED_VAL, TS72XX_WDT_FEED_PHYS_BASE);
0052     __raw_writeb(0, TS72XX_WDT_CONTROL_PHYS_BASE);
0053 }
0054 
0055 static inline void ep93xx_decomp_setup(void)
0056 {
0057     if (machine_is_ts72xx())
0058         ts72xx_watchdog_disable();
0059 
0060     if (machine_is_adssphere() ||
0061         machine_is_edb9301() ||
0062         machine_is_edb9302() ||
0063         machine_is_edb9302a() ||
0064         machine_is_edb9302a() ||
0065         machine_is_edb9307() ||
0066         machine_is_edb9307a() ||
0067         machine_is_edb9307a() ||
0068         machine_is_edb9312() ||
0069         machine_is_edb9315() ||
0070         machine_is_edb9315a() ||
0071         machine_is_edb9315a() ||
0072         machine_is_gesbc9312() ||
0073         machine_is_micro9() ||
0074         machine_is_micro9l() ||
0075         machine_is_micro9m() ||
0076         machine_is_micro9s() ||
0077         machine_is_micro9m() ||
0078         machine_is_micro9l() ||
0079         machine_is_micro9s() ||
0080         machine_is_sim_one() ||
0081         machine_is_snapper_cl15() ||
0082         machine_is_ts72xx() ||
0083         machine_is_bk3() ||
0084         machine_is_vision_ep9307())
0085         ep93xx_ethernet_reset();
0086 }