2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2008-03-24 14:40:32 +00:00
|
|
|
/*
|
|
|
|
* Freescale SerDes initialization routine
|
|
|
|
*
|
2012-06-19 00:11:34 +00:00
|
|
|
* Copyright 2007,2011 Freescale Semiconductor, Inc.
|
2009-09-02 13:58:48 +00:00
|
|
|
* Copyright (C) 2008 MontaVista Software, Inc.
|
2008-03-24 14:40:32 +00:00
|
|
|
*
|
|
|
|
* Author: Li Yang <leoli@freescale.com>
|
|
|
|
*/
|
|
|
|
|
2018-08-06 08:23:46 +00:00
|
|
|
#ifndef CONFIG_MPC83XX_SERDES
|
|
|
|
|
2008-03-24 14:40:32 +00:00
|
|
|
#include <config.h>
|
|
|
|
#include <common.h>
|
|
|
|
#include <asm/io.h>
|
2010-04-20 15:02:24 +00:00
|
|
|
#include <asm/fsl_mpc83xx_serdes.h>
|
2020-05-10 17:40:11 +00:00
|
|
|
#include <linux/delay.h>
|
2008-03-24 14:40:32 +00:00
|
|
|
|
|
|
|
/* SerDes registers */
|
|
|
|
#define FSL_SRDSCR0_OFFS 0x0
|
|
|
|
#define FSL_SRDSCR0_DPP_1V2 0x00008800
|
2011-11-17 02:15:38 +00:00
|
|
|
#define FSL_SRDSCR0_TXEQA_MASK 0x00007000
|
|
|
|
#define FSL_SRDSCR0_TXEQA_SATA 0x00001000
|
|
|
|
#define FSL_SRDSCR0_TXEQE_MASK 0x00000700
|
|
|
|
#define FSL_SRDSCR0_TXEQE_SATA 0x00000100
|
2008-03-24 14:40:32 +00:00
|
|
|
#define FSL_SRDSCR1_OFFS 0x4
|
|
|
|
#define FSL_SRDSCR1_PLLBW 0x00000040
|
|
|
|
#define FSL_SRDSCR2_OFFS 0x8
|
|
|
|
#define FSL_SRDSCR2_VDD_1V2 0x00800000
|
|
|
|
#define FSL_SRDSCR2_SEIC_MASK 0x00001c1c
|
|
|
|
#define FSL_SRDSCR2_SEIC_SATA 0x00001414
|
|
|
|
#define FSL_SRDSCR2_SEIC_PEX 0x00001010
|
|
|
|
#define FSL_SRDSCR2_SEIC_SGMII 0x00000101
|
|
|
|
#define FSL_SRDSCR3_OFFS 0xc
|
|
|
|
#define FSL_SRDSCR3_KFR_SATA 0x10100000
|
|
|
|
#define FSL_SRDSCR3_KPH_SATA 0x04040000
|
|
|
|
#define FSL_SRDSCR3_SDFM_SATA_PEX 0x01010000
|
|
|
|
#define FSL_SRDSCR3_SDTXL_SATA 0x00000505
|
|
|
|
#define FSL_SRDSCR4_OFFS 0x10
|
|
|
|
#define FSL_SRDSCR4_PROT_SATA 0x00000808
|
|
|
|
#define FSL_SRDSCR4_PROT_PEX 0x00000101
|
|
|
|
#define FSL_SRDSCR4_PROT_SGMII 0x00000505
|
|
|
|
#define FSL_SRDSCR4_PLANE_X2 0x01000000
|
|
|
|
#define FSL_SRDSRSTCTL_OFFS 0x20
|
|
|
|
#define FSL_SRDSRSTCTL_RST 0x80000000
|
|
|
|
#define FSL_SRDSRSTCTL_SATA_RESET 0xf
|
|
|
|
|
2008-10-02 14:31:56 +00:00
|
|
|
void fsl_setup_serdes(u32 offset, char proto, u32 rfcks, char vdd)
|
2008-03-24 14:40:32 +00:00
|
|
|
{
|
2008-10-16 13:01:15 +00:00
|
|
|
void *regs = (void *)CONFIG_SYS_IMMR + offset;
|
2008-03-24 14:40:32 +00:00
|
|
|
u32 tmp;
|
|
|
|
|
|
|
|
/* 1.0V corevdd */
|
|
|
|
if (vdd) {
|
|
|
|
/* DPPE/DPPA = 0 */
|
|
|
|
tmp = in_be32(regs + FSL_SRDSCR0_OFFS);
|
|
|
|
tmp &= ~FSL_SRDSCR0_DPP_1V2;
|
|
|
|
out_be32(regs + FSL_SRDSCR0_OFFS, tmp);
|
|
|
|
|
|
|
|
/* VDD = 0 */
|
|
|
|
tmp = in_be32(regs + FSL_SRDSCR2_OFFS);
|
|
|
|
tmp &= ~FSL_SRDSCR2_VDD_1V2;
|
|
|
|
out_be32(regs + FSL_SRDSCR2_OFFS, tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* protocol specific configuration */
|
|
|
|
switch (proto) {
|
|
|
|
case FSL_SERDES_PROTO_SATA:
|
|
|
|
/* Set and clear reset bits */
|
|
|
|
tmp = in_be32(regs + FSL_SRDSRSTCTL_OFFS);
|
|
|
|
tmp |= FSL_SRDSRSTCTL_SATA_RESET;
|
|
|
|
out_be32(regs + FSL_SRDSRSTCTL_OFFS, tmp);
|
|
|
|
udelay(1000);
|
|
|
|
tmp &= ~FSL_SRDSRSTCTL_SATA_RESET;
|
|
|
|
out_be32(regs + FSL_SRDSRSTCTL_OFFS, tmp);
|
|
|
|
|
2011-11-17 02:15:38 +00:00
|
|
|
/* Configure SRDSCR0 */
|
|
|
|
clrsetbits_be32(regs + FSL_SRDSCR0_OFFS,
|
|
|
|
FSL_SRDSCR0_TXEQA_MASK | FSL_SRDSCR0_TXEQE_MASK,
|
|
|
|
FSL_SRDSCR0_TXEQA_SATA | FSL_SRDSCR0_TXEQE_SATA);
|
|
|
|
|
2008-03-24 14:40:32 +00:00
|
|
|
/* Configure SRDSCR1 */
|
|
|
|
tmp = in_be32(regs + FSL_SRDSCR1_OFFS);
|
|
|
|
tmp &= ~FSL_SRDSCR1_PLLBW;
|
|
|
|
out_be32(regs + FSL_SRDSCR1_OFFS, tmp);
|
|
|
|
|
|
|
|
/* Configure SRDSCR2 */
|
|
|
|
tmp = in_be32(regs + FSL_SRDSCR2_OFFS);
|
|
|
|
tmp &= ~FSL_SRDSCR2_SEIC_MASK;
|
|
|
|
tmp |= FSL_SRDSCR2_SEIC_SATA;
|
|
|
|
out_be32(regs + FSL_SRDSCR2_OFFS, tmp);
|
|
|
|
|
|
|
|
/* Configure SRDSCR3 */
|
|
|
|
tmp = FSL_SRDSCR3_KFR_SATA | FSL_SRDSCR3_KPH_SATA |
|
|
|
|
FSL_SRDSCR3_SDFM_SATA_PEX |
|
|
|
|
FSL_SRDSCR3_SDTXL_SATA;
|
|
|
|
out_be32(regs + FSL_SRDSCR3_OFFS, tmp);
|
|
|
|
|
|
|
|
/* Configure SRDSCR4 */
|
|
|
|
tmp = rfcks | FSL_SRDSCR4_PROT_SATA;
|
|
|
|
out_be32(regs + FSL_SRDSCR4_OFFS, tmp);
|
|
|
|
break;
|
|
|
|
case FSL_SERDES_PROTO_PEX:
|
|
|
|
case FSL_SERDES_PROTO_PEX_X2:
|
|
|
|
/* Configure SRDSCR1 */
|
|
|
|
tmp = in_be32(regs + FSL_SRDSCR1_OFFS);
|
|
|
|
tmp |= FSL_SRDSCR1_PLLBW;
|
|
|
|
out_be32(regs + FSL_SRDSCR1_OFFS, tmp);
|
|
|
|
|
|
|
|
/* Configure SRDSCR2 */
|
|
|
|
tmp = in_be32(regs + FSL_SRDSCR2_OFFS);
|
|
|
|
tmp &= ~FSL_SRDSCR2_SEIC_MASK;
|
|
|
|
tmp |= FSL_SRDSCR2_SEIC_PEX;
|
|
|
|
out_be32(regs + FSL_SRDSCR2_OFFS, tmp);
|
|
|
|
|
|
|
|
/* Configure SRDSCR3 */
|
|
|
|
tmp = FSL_SRDSCR3_SDFM_SATA_PEX;
|
|
|
|
out_be32(regs + FSL_SRDSCR3_OFFS, tmp);
|
|
|
|
|
|
|
|
/* Configure SRDSCR4 */
|
|
|
|
tmp = rfcks | FSL_SRDSCR4_PROT_PEX;
|
|
|
|
if (proto == FSL_SERDES_PROTO_PEX_X2)
|
|
|
|
tmp |= FSL_SRDSCR4_PLANE_X2;
|
|
|
|
out_be32(regs + FSL_SRDSCR4_OFFS, tmp);
|
|
|
|
break;
|
|
|
|
case FSL_SERDES_PROTO_SGMII:
|
|
|
|
/* Configure SRDSCR1 */
|
|
|
|
tmp = in_be32(regs + FSL_SRDSCR1_OFFS);
|
|
|
|
tmp &= ~FSL_SRDSCR1_PLLBW;
|
|
|
|
out_be32(regs + FSL_SRDSCR1_OFFS, tmp);
|
|
|
|
|
|
|
|
/* Configure SRDSCR2 */
|
|
|
|
tmp = in_be32(regs + FSL_SRDSCR2_OFFS);
|
|
|
|
tmp &= ~FSL_SRDSCR2_SEIC_MASK;
|
|
|
|
tmp |= FSL_SRDSCR2_SEIC_SGMII;
|
|
|
|
out_be32(regs + FSL_SRDSCR2_OFFS, tmp);
|
|
|
|
|
|
|
|
/* Configure SRDSCR3 */
|
|
|
|
out_be32(regs + FSL_SRDSCR3_OFFS, 0);
|
|
|
|
|
|
|
|
/* Configure SRDSCR4 */
|
|
|
|
tmp = rfcks | FSL_SRDSCR4_PROT_SGMII;
|
|
|
|
out_be32(regs + FSL_SRDSCR4_OFFS, tmp);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Do a software reset */
|
|
|
|
tmp = in_be32(regs + FSL_SRDSRSTCTL_OFFS);
|
|
|
|
tmp |= FSL_SRDSRSTCTL_RST;
|
|
|
|
out_be32(regs + FSL_SRDSRSTCTL_OFFS, tmp);
|
|
|
|
}
|
2018-08-06 08:23:46 +00:00
|
|
|
|
|
|
|
#endif /* !CONFIG_MPC83XX_SERDES */
|