1 /* 2 * Copyright (c) 2019-2020, Broadcom 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include <stdbool.h> 8 9 #include <common/debug.h> 10 #include <lib/mmio.h> 11 12 #include <ncsi.h> 13 #include <sr_def.h> 14 #include <sr_utils.h> 15 16 static const char *const io_drives[] = { 17 "2mA", "4mA", "6mA", "8mA", 18 "10mA", "12mA", "14mA", "16mA" 19 }; 20 21 void brcm_stingray_ncsi_init(void) 22 { 23 unsigned int i = 0; 24 unsigned int selx = 0; 25 26 #if NCSI_IO_DRIVE_STRENGTH_MA == 2 27 selx = 0x0; 28 #elif NCSI_IO_DRIVE_STRENGTH_MA == 4 29 selx = 0x1; 30 #elif NCSI_IO_DRIVE_STRENGTH_MA == 6 31 selx = 0x2; 32 #elif NCSI_IO_DRIVE_STRENGTH_MA == 8 33 selx = 0x3; 34 #elif NCSI_IO_DRIVE_STRENGTH_MA == 10 35 selx = 0x4; 36 #elif NCSI_IO_DRIVE_STRENGTH_MA == 12 37 selx = 0x5; 38 #elif NCSI_IO_DRIVE_STRENGTH_MA == 14 39 selx = 0x6; 40 #elif NCSI_IO_DRIVE_STRENGTH_MA == 16 41 selx = 0x7; 42 #else 43 ERROR("Unsupported NCSI_IO_DRIVE_STRENGTH_MA. Please check it.\n"); 44 return; 45 #endif 46 INFO("ncsi io drives: %s\n", io_drives[selx]); 47 48 for (i = 0; i < NITRO_NCSI_IOPAD_CONTROL_NUM; i++) { 49 mmio_clrsetbits_32((NITRO_NCSI_IOPAD_CONTROL_BASE + (i * 4)), 50 PAD_SELX_MASK, PAD_SELX_VALUE(selx)); 51 } 52 53 INFO("ncsi init done\n"); 54 } 55