1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright 2007 Freescale Semiconductor.
4  */
5 
6 #include <common.h>
7 #include <asm/io.h>
8 
9 #include "bcsr.h"
10 
11 void enable_8568mds_duart(void)
12 {
13 	volatile uint* duart_mux	= (uint *)(CONFIG_SYS_CCSRBAR + 0xe0060);
14 	volatile uint* devices		= (uint *)(CONFIG_SYS_CCSRBAR + 0xe0070);
15 	volatile u8 *bcsr		= (u8 *)(CONFIG_SYS_BCSR);
16 
17 	*duart_mux = 0x80000000;	/* Set the mux to Duart on PMUXCR */
18 	*devices  = 0;			/* Enable all peripheral devices */
19 	bcsr[5] |= 0x01;		/* Enable Duart in BCSR*/
20 }
21 
22 void enable_8568mds_flash_write(void)
23 {
24 	volatile u8 *bcsr = (u8 *)(CONFIG_SYS_BCSR);
25 
26 	bcsr[9] |= 0x01;
27 }
28 
29 void disable_8568mds_flash_write(void)
30 {
31 	volatile u8 *bcsr = (u8 *)(CONFIG_SYS_BCSR);
32 
33 	bcsr[9] &= ~(0x01);
34 }
35 
36 void enable_8568mds_qe_mdio(void)
37 {
38 	u8 *bcsr = (u8 *)(CONFIG_SYS_BCSR);
39 
40 	bcsr[7] |= 0x01;
41 }
42 
43 #if defined(CONFIG_UEC_ETH1) || defined(CONFIG_UEC_ETH2)
44 void reset_8568mds_uccs(void)
45 {
46 	volatile u8 *bcsr = (u8 *)(CONFIG_SYS_BCSR);
47 
48 	/* Turn off UCC1 & UCC2 */
49 	out_8(&bcsr[8], in_8(&bcsr[8]) & ~BCSR_UCC1_GETH_EN);
50 	out_8(&bcsr[9], in_8(&bcsr[9]) & ~BCSR_UCC2_GETH_EN);
51 
52 	/* Mode is RGMII, all bits clear */
53 	out_8(&bcsr[11], in_8(&bcsr[11]) & ~(BCSR_UCC1_MODE_MSK |
54 					     BCSR_UCC2_MODE_MSK));
55 
56 	/* Turn UCC1 & UCC2 on */
57 	out_8(&bcsr[8], in_8(&bcsr[8]) | BCSR_UCC1_GETH_EN);
58 	out_8(&bcsr[9], in_8(&bcsr[9]) | BCSR_UCC2_GETH_EN);
59 }
60 #endif
61