Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Andy Fleming | 6743105 | 2007-04-23 02:54:25 -0500 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2007 Freescale Semiconductor. |
Andy Fleming | 6743105 | 2007-04-23 02:54:25 -0500 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
Anton Vorontsov | ad16224 | 2007-10-22 18:12:46 +0400 | [diff] [blame] | 7 | #include <asm/io.h> |
| 8 | |
Andy Fleming | 6743105 | 2007-04-23 02:54:25 -0500 | [diff] [blame] | 9 | #include "bcsr.h" |
| 10 | |
Kim Phillips | e56143e | 2012-10-29 13:34:38 +0000 | [diff] [blame] | 11 | void enable_8568mds_duart(void) |
Andy Fleming | 6743105 | 2007-04-23 02:54:25 -0500 | [diff] [blame] | 12 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 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); |
Andy Fleming | 6743105 | 2007-04-23 02:54:25 -0500 | [diff] [blame] | 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 | |
Kim Phillips | e56143e | 2012-10-29 13:34:38 +0000 | [diff] [blame] | 22 | void enable_8568mds_flash_write(void) |
Andy Fleming | 6743105 | 2007-04-23 02:54:25 -0500 | [diff] [blame] | 23 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 24 | volatile u8 *bcsr = (u8 *)(CONFIG_SYS_BCSR); |
Andy Fleming | 6743105 | 2007-04-23 02:54:25 -0500 | [diff] [blame] | 25 | |
| 26 | bcsr[9] |= 0x01; |
| 27 | } |
| 28 | |
Kim Phillips | e56143e | 2012-10-29 13:34:38 +0000 | [diff] [blame] | 29 | void disable_8568mds_flash_write(void) |
Andy Fleming | 6743105 | 2007-04-23 02:54:25 -0500 | [diff] [blame] | 30 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 31 | volatile u8 *bcsr = (u8 *)(CONFIG_SYS_BCSR); |
Andy Fleming | 6743105 | 2007-04-23 02:54:25 -0500 | [diff] [blame] | 32 | |
| 33 | bcsr[9] &= ~(0x01); |
| 34 | } |
Andy Fleming | da9d461 | 2007-08-14 00:14:25 -0500 | [diff] [blame] | 35 | |
Kim Phillips | e56143e | 2012-10-29 13:34:38 +0000 | [diff] [blame] | 36 | void enable_8568mds_qe_mdio(void) |
Andy Fleming | da9d461 | 2007-08-14 00:14:25 -0500 | [diff] [blame] | 37 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 38 | u8 *bcsr = (u8 *)(CONFIG_SYS_BCSR); |
Andy Fleming | da9d461 | 2007-08-14 00:14:25 -0500 | [diff] [blame] | 39 | |
| 40 | bcsr[7] |= 0x01; |
| 41 | } |
Anton Vorontsov | ad16224 | 2007-10-22 18:12:46 +0400 | [diff] [blame] | 42 | |
| 43 | #if defined(CONFIG_UEC_ETH1) || defined(CONFIG_UEC_ETH2) |
| 44 | void reset_8568mds_uccs(void) |
| 45 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 46 | volatile u8 *bcsr = (u8 *)(CONFIG_SYS_BCSR); |
Anton Vorontsov | ad16224 | 2007-10-22 18:12:46 +0400 | [diff] [blame] | 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 |