提交 6e31c62a 编写于 作者: H Heiko Schocher

net, qe: add DM support for QE UEC ethernet

add DM/DTS support for the UEC ethernet on QUICC Engine
Block.
Signed-off-by: NHeiko Schocher <hs@denx.de>
Patch-cc: Mario Six <mario.six@gdsys.cc>
Patch-cc: Qiang Zhao <qiang.zhao@nxp.com>
Patch-cc: Holger Brunck <holger.brunck@hitachi-powergrids.com>
Patch-cc: Madalin Bucur <madalin.bucur@oss.nxp.com>

Series-changes: 3
- revert:
  commit "3374264d" ("drivers: net: qe: deselect QE when DM_ETH is enabled")
  as now qe works with DM and DM_ETH support.
- fix mailaddress from Holger

Series-changes: 2
- add comments from Qiang Zhao:
  - add device node documentation
  - I did not drop the dm_qe_uec_phy.c and use drivers/net/fsl_mdio.c
    because using drivers/net/fsl_mdio.c leads in none existent
    udevice mdio@3320
    instead boards with DM ETH support should use now this
    driver.
- remove RFC tag

Commit-notes:

- I let the old none DM based implementation in code
  so boards should work with old implementation.
  This Code should be removed if all boards are converted
  to DM/DTS.

- add the DM based qe uec driver under drivers/net/qe

- Therefore copied the files uccf.c uccf.h uec.h from
  drivers/qe. So there are a lot of Codingstyle problems
  currently. I fix them in next version if this RFC
  patch is OK or it needs some changes.

- The dm based driver code is now under drivers/net/qe/dm_qe_uec.c
  Used a lot of functions from drivers/qe/uec.c

- seperated the PHY specific code into seperate file
  drivers/net/qe/dm_qe_uec_phy.c

END
上级 5990b059
* UCC (Unified Communications Controllers)
Required properties:
- compatible : ucc_geth
- cell-index : the ucc number(1-8), corresponding to UCCx in UM.
- reg : Offset and length of the register set for the device
- rx-clock-name: the UCC receive clock source
"none": clock source is disabled
"brg1" through "brg16": clock source is BRG1-BRG16, respectively
"clk1" through "clk24": clock source is CLK1-CLK24, respectively
- tx-clock-name: the UCC transmit clock source
"none": clock source is disabled
"brg1" through "brg16": clock source is BRG1-BRG16, respectively
"clk1" through "clk24": clock source is CLK1-CLK24, respectively
The following two properties are deprecated. rx-clock has been replaced
with rx-clock-name, and tx-clock has been replaced with tx-clock-name.
Drivers that currently use the deprecated properties should continue to
do so, in order to support older device trees, but they should be updated
to check for the new properties first.
- rx-clock : represents the UCC receive clock source.
0x00 : clock source is disabled;
0x1~0x10 : clock source is BRG1~BRG16 respectively;
0x11~0x28: clock source is QE_CLK1~QE_CLK24 respectively.
- tx-clock: represents the UCC transmit clock source;
0x00 : clock source is disabled;
0x1~0x10 : clock source is BRG1~BRG16 respectively;
0x11~0x28: clock source is QE_CLK1~QE_CLK24 respectively.
- phy-handle : The phandle for the PHY connected to this controller.
- phy-connection-type : a string naming the controller/PHY interface type,
i.e., "mii" (default), "rmii", "gmii", "rgmii", "rgmii-id" (Internal
Delay), "rgmii-txid" (delay on TX only), "rgmii-rxid" (delay on RX only),
"tbi", or "rtbi".
- pio-handle : The phandle for the Parallel I/O port configuration.
Deprecated properties:
- device-id : the ucc number(1-8), corresponding to UCCx in UM.
you should use cell-index
Example:
ucc@2000 {
device_type = "network";
compatible = "ucc_geth";
cell-index = <1>;
reg = <2000 200>;
interrupts = <a0 0>;
interrupt-parent = <700>;
mac-address = [ 00 04 9f 00 23 23 ];
rx-clock = "none";
tx-clock = "clk9";
phy-handle = <212000>;
phy-connection-type = "gmii";
pio-handle = <140001>;
};
......@@ -432,6 +432,8 @@ config PCNET
This driver supports AMD PCnet series fast ethernet family of
PCI chipsets/adapters.
source "drivers/net/qe/Kconfig"
config RTL8139
bool "Realtek 8139 series Ethernet controller driver"
help
......
......@@ -78,6 +78,7 @@ obj-$(CONFIG_VSC9953) += vsc9953.o
obj-$(CONFIG_PIC32_ETH) += pic32_mdio.o pic32_eth.o
obj-$(CONFIG_DWC_ETH_QOS) += dwc_eth_qos.o
obj-$(CONFIG_FSL_PFE) += pfe_eth/
obj-y += qe/
obj-$(CONFIG_SNI_AVE) += sni_ave.o
obj-y += ti/
obj-$(CONFIG_MEDIATEK_ETH) += mtk_eth.o
......
# SPDX-License-Identifier: GPL-2.0+
#
# Copyright (C) 2020 Heiko Schocher <hs@denx.de>
config QE_UEC
bool "NXP QE UEC Ethernet controller"
depends on DM_ETH
help
This driver supports the NXP QE UEC ethernet controller
# SPDX-License-Identifier: GPL-2.0+
#
# Copyright (C) 2020 Heiko Schocher <hs@denx.de>
obj-$(CONFIG_QE_UEC) += dm_qe_uec.o dm_qe_uec_phy.o uccf.o
此差异已折叠。
/* SPDX-License-Identifier: GPL-2.0+
*
* QE UEC ethernet controller driver
*
* based on drivers/qe/uec.c from NXP
*
* Copyright (C) 2020 Heiko Schocher <hs@denx.de>
*/
#ifndef _DM_QE_UEC_H
#define _DM_QE_UEC_H
#define qe_uec_dbg(dev, fmt, args...) debug("%s:" fmt, dev->name, ##args)
#include "uec.h"
/* QE UEC private structure */
struct qe_uec_priv {
struct uec_priv *uec;
struct phy_device *phydev;
};
#endif
// SPDX-License-Identifier: GPL-2.0+
/*
* QE UEC ethernet phy controller driver
*
* based on phy parts of drivers/qe/uec.c and drivers/qe/uec_phy.c
* from NXP
*
* Copyright (C) 2020 Heiko Schocher <hs@denx.de>
*/
#include <common.h>
#include <dm.h>
#include <errno.h>
#include <miiphy.h>
#include <phy.h>
#include <asm/io.h>
#include <linux/ioport.h>
#include "dm_qe_uec.h"
struct qe_uec_mdio_priv {
struct ucc_mii_mng *base;
};
static int
qe_uec_mdio_read(struct udevice *dev, int addr, int devad, int reg)
{
struct qe_uec_mdio_priv *priv = dev_get_priv(dev);
struct ucc_mii_mng *regs = priv->base;
u32 tmp_reg;
u16 value;
debug("%s: regs: %p addr: %x devad: %x reg: %x\n", __func__, regs,
addr, devad, reg);
/* Setting up the MII management Address Register */
tmp_reg = ((u32)addr << MIIMADD_PHY_ADDRESS_SHIFT) | reg;
out_be32(&regs->miimadd, tmp_reg);
/* clear MII management command cycle */
out_be32(&regs->miimcom, 0);
sync();
/* Perform an MII management read cycle */
out_be32(&regs->miimcom, MIIMCOM_READ_CYCLE);
/* Wait till MII management write is complete */
while ((in_be32(&regs->miimind)) &
(MIIMIND_NOT_VALID | MIIMIND_BUSY))
;
/* Read MII management status */
value = (u16)in_be32(&regs->miimstat);
if (value == 0xffff)
return -EINVAL;
return value;
};
static int
qe_uec_mdio_write(struct udevice *dev, int addr, int devad, int reg,
u16 value)
{
struct qe_uec_mdio_priv *priv = dev_get_priv(dev);
struct ucc_mii_mng *regs = priv->base;
u32 tmp_reg;
debug("%s: regs: %p addr: %x devad: %x reg: %x val: %x\n", __func__,
regs, addr, devad, reg, value);
/* Stop the MII management read cycle */
out_be32(&regs->miimcom, 0);
/* Setting up the MII management Address Register */
tmp_reg = ((u32)addr << MIIMADD_PHY_ADDRESS_SHIFT) | reg;
out_be32(&regs->miimadd, tmp_reg);
/* Setting up the MII management Control Register with the value */
out_be32(&regs->miimcon, (u32)value);
sync();
/* Wait till MII management write is complete */
while ((in_be32(&regs->miimind)) & MIIMIND_BUSY)
;
return 0;
};
static const struct mdio_ops qe_uec_mdio_ops = {
.read = qe_uec_mdio_read,
.write = qe_uec_mdio_write,
};
static int qe_uec_mdio_probe(struct udevice *dev)
{
struct qe_uec_mdio_priv *priv = dev_get_priv(dev);
fdt_size_t base;
ofnode node;
u32 num = 0;
int ret = -ENODEV;
priv->base = (struct ucc_mii_mng *)dev_read_addr(dev);
base = (fdt_size_t)priv->base;
/*
* idea from linux:
* drivers/net/ethernet/freescale/fsl_pq_mdio.c
*
* Find the UCC node that controls the given MDIO node
*
* For some reason, the QE MDIO nodes are not children of the UCC
* devices that control them. Therefore, we need to scan all UCC
* nodes looking for the one that encompases the given MDIO node.
* We do this by comparing physical addresses. The 'start' and
* 'end' addresses of the MDIO node are passed, and the correct
* UCC node will cover the entire address range.
*/
node = ofnode_by_compatible(ofnode_null(), "ucc_geth");
while (ofnode_valid(node)) {
fdt_size_t size;
fdt_addr_t addr;
addr = ofnode_get_addr_index(node, 0);
ret = ofnode_get_addr_size_index(node, 0, &size);
if (addr == FDT_ADDR_T_NONE) {
node = ofnode_by_compatible(node, "ucc_geth");
continue;
}
/* check if priv->base in start end */
if (base > addr && base < (addr + size)) {
ret = ofnode_read_u32(node, "cell-index", &num);
if (ret)
ret = ofnode_read_u32(node, "device-id",
&num);
break;
}
node = ofnode_by_compatible(node, "ucc_geth");
}
if (ret) {
printf("%s: no cell-index nor device-id found!", __func__);
return ret;
}
/* Setup MII master clock source */
qe_set_mii_clk_src(num - 1);
return 0;
}
static const struct udevice_id qe_uec_mdio_ids[] = {
{ .compatible = "fsl,ucc-mdio" },
{ }
};
U_BOOT_DRIVER(mvmdio) = {
.name = "qe_uec_mdio",
.id = UCLASS_MDIO,
.of_match = qe_uec_mdio_ids,
.probe = qe_uec_mdio_probe,
.ops = &qe_uec_mdio_ops,
.priv_auto_alloc_size = sizeof(struct qe_uec_mdio_priv),
};
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2006 Freescale Semiconductor, Inc.
*
* Dave Liu <daveliu@freescale.com>
* based on source code of Shlomi Gridish
*/
#include <common.h>
#include <malloc.h>
#include <linux/errno.h>
#include <asm/io.h>
#include <linux/immap_qe.h>
#include "uccf.h"
#include <fsl_qe.h>
void ucc_fast_transmit_on_demand(struct ucc_fast_priv *uccf)
{
out_be16(&uccf->uf_regs->utodr, UCC_FAST_TOD);
}
u32 ucc_fast_get_qe_cr_subblock(int ucc_num)
{
switch (ucc_num) {
case 0:
return QE_CR_SUBBLOCK_UCCFAST1;
case 1:
return QE_CR_SUBBLOCK_UCCFAST2;
case 2:
return QE_CR_SUBBLOCK_UCCFAST3;
case 3:
return QE_CR_SUBBLOCK_UCCFAST4;
case 4:
return QE_CR_SUBBLOCK_UCCFAST5;
case 5:
return QE_CR_SUBBLOCK_UCCFAST6;
case 6:
return QE_CR_SUBBLOCK_UCCFAST7;
case 7:
return QE_CR_SUBBLOCK_UCCFAST8;
default:
return QE_CR_SUBBLOCK_INVALID;
}
}
static void ucc_get_cmxucr_reg(int ucc_num, u32 **p_cmxucr,
u8 *reg_num, u8 *shift)
{
switch (ucc_num) {
case 0: /* UCC1 */
*p_cmxucr = &qe_immr->qmx.cmxucr1;
*reg_num = 1;
*shift = 16;
break;
case 2: /* UCC3 */
*p_cmxucr = &qe_immr->qmx.cmxucr1;
*reg_num = 1;
*shift = 0;
break;
case 4: /* UCC5 */
*p_cmxucr = &qe_immr->qmx.cmxucr2;
*reg_num = 2;
*shift = 16;
break;
case 6: /* UCC7 */
*p_cmxucr = &qe_immr->qmx.cmxucr2;
*reg_num = 2;
*shift = 0;
break;
case 1: /* UCC2 */
*p_cmxucr = &qe_immr->qmx.cmxucr3;
*reg_num = 3;
*shift = 16;
break;
case 3: /* UCC4 */
*p_cmxucr = &qe_immr->qmx.cmxucr3;
*reg_num = 3;
*shift = 0;
break;
case 5: /* UCC6 */
*p_cmxucr = &qe_immr->qmx.cmxucr4;
*reg_num = 4;
*shift = 16;
break;
case 7: /* UCC8 */
*p_cmxucr = &qe_immr->qmx.cmxucr4;
*reg_num = 4;
*shift = 0;
break;
default:
break;
}
}
static int ucc_set_clk_src(int ucc_num, qe_clock_e clock, comm_dir_e mode)
{
u32 *p_cmxucr = NULL;
u8 reg_num = 0;
u8 shift = 0;
u32 clk_bits;
u32 clk_mask;
int source = -1;
/* check if the UCC number is in range. */
if ((ucc_num > UCC_MAX_NUM - 1) || ucc_num < 0)
return -EINVAL;
if (!(mode == COMM_DIR_RX || mode == COMM_DIR_TX)) {
printf("%s: bad comm mode type passed\n", __func__);
return -EINVAL;
}
ucc_get_cmxucr_reg(ucc_num, &p_cmxucr, &reg_num, &shift);
switch (reg_num) {
case 1:
switch (clock) {
case QE_BRG1:
source = 1;
break;
case QE_BRG2:
source = 2;
break;
case QE_BRG7:
source = 3;
break;
case QE_BRG8:
source = 4;
break;
case QE_CLK9:
source = 5;
break;
case QE_CLK10:
source = 6;
break;
case QE_CLK11:
source = 7;
break;
case QE_CLK12:
source = 8;
break;
case QE_CLK15:
source = 9;
break;
case QE_CLK16:
source = 10;
break;
default:
source = -1;
break;
}
break;
case 2:
switch (clock) {
case QE_BRG5:
source = 1;
break;
case QE_BRG6:
source = 2;
break;
case QE_BRG7:
source = 3;
break;
case QE_BRG8:
source = 4;
break;
case QE_CLK13:
source = 5;
break;
case QE_CLK14:
source = 6;
break;
case QE_CLK19:
source = 7;
break;
case QE_CLK20:
source = 8;
break;
case QE_CLK15:
source = 9;
break;
case QE_CLK16:
source = 10;
break;
default:
source = -1;
break;
}
break;
case 3:
switch (clock) {
case QE_BRG9:
source = 1;
break;
case QE_BRG10:
source = 2;
break;
case QE_BRG15:
source = 3;
break;
case QE_BRG16:
source = 4;
break;
case QE_CLK3:
source = 5;
break;
case QE_CLK4:
source = 6;
break;
case QE_CLK17:
source = 7;
break;
case QE_CLK18:
source = 8;
break;
case QE_CLK7:
source = 9;
break;
case QE_CLK8:
source = 10;
break;
case QE_CLK16:
source = 11;
break;
default:
source = -1;
break;
}
break;
case 4:
switch (clock) {
case QE_BRG13:
source = 1;
break;
case QE_BRG14:
source = 2;
break;
case QE_BRG15:
source = 3;
break;
case QE_BRG16:
source = 4;
break;
case QE_CLK5:
source = 5;
break;
case QE_CLK6:
source = 6;
break;
case QE_CLK21:
source = 7;
break;
case QE_CLK22:
source = 8;
break;
case QE_CLK7:
source = 9;
break;
case QE_CLK8:
source = 10;
break;
case QE_CLK16:
source = 11;
break;
default:
source = -1;
break;
}
break;
default:
source = -1;
break;
}
if (source == -1) {
printf("%s: Bad combination of clock and UCC\n", __func__);
return -ENOENT;
}
clk_bits = (u32)source;
clk_mask = QE_CMXUCR_TX_CLK_SRC_MASK;
if (mode == COMM_DIR_RX) {
clk_bits <<= 4; /* Rx field is 4 bits to left of Tx field */
clk_mask <<= 4; /* Rx field is 4 bits to left of Tx field */
}
clk_bits <<= shift;
clk_mask <<= shift;
out_be32(p_cmxucr, (in_be32(p_cmxucr) & ~clk_mask) | clk_bits);
return 0;
}
static uint ucc_get_reg_baseaddr(int ucc_num)
{
uint base = 0;
/* check if the UCC number is in range */
if ((ucc_num > UCC_MAX_NUM - 1) || ucc_num < 0) {
printf("%s: the UCC num not in ranges\n", __func__);
return 0;
}
switch (ucc_num) {
case 0:
base = 0x00002000;
break;
case 1:
base = 0x00003000;
break;
case 2:
base = 0x00002200;
break;
case 3:
base = 0x00003200;
break;
case 4:
base = 0x00002400;
break;
case 5:
base = 0x00003400;
break;
case 6:
base = 0x00002600;
break;
case 7:
base = 0x00003600;
break;
default:
break;
}
base = (uint)qe_immr + base;
return base;
}
void ucc_fast_enable(struct ucc_fast_priv *uccf, comm_dir_e mode)
{
ucc_fast_t *uf_regs;
u32 gumr;
uf_regs = uccf->uf_regs;
/* Enable reception and/or transmission on this UCC. */
gumr = in_be32(&uf_regs->gumr);
if (mode & COMM_DIR_TX) {
gumr |= UCC_FAST_GUMR_ENT;
uccf->enabled_tx = 1;
}
if (mode & COMM_DIR_RX) {
gumr |= UCC_FAST_GUMR_ENR;
uccf->enabled_rx = 1;
}
out_be32(&uf_regs->gumr, gumr);
}
void ucc_fast_disable(struct ucc_fast_priv *uccf, comm_dir_e mode)
{
ucc_fast_t *uf_regs;
u32 gumr;
uf_regs = uccf->uf_regs;
/* Disable reception and/or transmission on this UCC. */
gumr = in_be32(&uf_regs->gumr);
if (mode & COMM_DIR_TX) {
gumr &= ~UCC_FAST_GUMR_ENT;
uccf->enabled_tx = 0;
}
if (mode & COMM_DIR_RX) {
gumr &= ~UCC_FAST_GUMR_ENR;
uccf->enabled_rx = 0;
}
out_be32(&uf_regs->gumr, gumr);
}
int ucc_fast_init(struct ucc_fast_inf *uf_info,
struct ucc_fast_priv **uccf_ret)
{
struct ucc_fast_priv *uccf;
ucc_fast_t *uf_regs;
if (!uf_info)
return -EINVAL;
if (uf_info->ucc_num < 0 || (uf_info->ucc_num > UCC_MAX_NUM - 1)) {
printf("%s: Illagal UCC number!\n", __func__);
return -EINVAL;
}
uccf = (struct ucc_fast_priv *)malloc(sizeof(struct ucc_fast_priv));
if (!uccf) {
printf("%s: No memory for UCC fast data structure!\n",
__func__);
return -ENOMEM;
}
memset(uccf, 0, sizeof(struct ucc_fast_priv));
/* Save fast UCC structure */
uccf->uf_info = uf_info;
uccf->uf_regs = (ucc_fast_t *)ucc_get_reg_baseaddr(uf_info->ucc_num);
if (!uccf->uf_regs) {
printf("%s: No memory map for UCC fast controller!\n",
__func__);
return -ENOMEM;
}
uccf->enabled_tx = 0;
uccf->enabled_rx = 0;
uf_regs = uccf->uf_regs;
uccf->p_ucce = (u32 *)&uf_regs->ucce;
uccf->p_uccm = (u32 *)&uf_regs->uccm;
/* Init GUEMR register, UCC both Rx and Tx is Fast protocol */
out_8(&uf_regs->guemr, UCC_GUEMR_SET_RESERVED3 | UCC_GUEMR_MODE_FAST_RX
| UCC_GUEMR_MODE_FAST_TX);
/* Set GUMR, disable UCC both Rx and Tx, Ethernet protocol */
out_be32(&uf_regs->gumr, UCC_FAST_GUMR_ETH);
/* Set the Giga ethernet VFIFO stuff */
if (uf_info->eth_type == GIGA_ETH) {
/* Allocate memory for Tx Virtual Fifo */
uccf->ucc_fast_tx_virtual_fifo_base_offset =
qe_muram_alloc(UCC_GETH_UTFS_GIGA_INIT,
UCC_FAST_VIRT_FIFO_REGS_ALIGNMENT);
/* Allocate memory for Rx Virtual Fifo */
uccf->ucc_fast_rx_virtual_fifo_base_offset =
qe_muram_alloc(UCC_GETH_URFS_GIGA_INIT +
UCC_FAST_RX_VIRTUAL_FIFO_SIZE_PAD,
UCC_FAST_VIRT_FIFO_REGS_ALIGNMENT);
/* utfb, urfb are offsets from MURAM base */
out_be32(&uf_regs->utfb,
uccf->ucc_fast_tx_virtual_fifo_base_offset);
out_be32(&uf_regs->urfb,
uccf->ucc_fast_rx_virtual_fifo_base_offset);
/* Set Virtual Fifo registers */
out_be16(&uf_regs->urfs, UCC_GETH_URFS_GIGA_INIT);
out_be16(&uf_regs->urfet, UCC_GETH_URFET_GIGA_INIT);
out_be16(&uf_regs->urfset, UCC_GETH_URFSET_GIGA_INIT);
out_be16(&uf_regs->utfs, UCC_GETH_UTFS_GIGA_INIT);
out_be16(&uf_regs->utfet, UCC_GETH_UTFET_GIGA_INIT);
out_be16(&uf_regs->utftt, UCC_GETH_UTFTT_GIGA_INIT);
}
/* Set the Fast ethernet VFIFO stuff */
if (uf_info->eth_type == FAST_ETH) {
/* Allocate memory for Tx Virtual Fifo */
uccf->ucc_fast_tx_virtual_fifo_base_offset =
qe_muram_alloc(UCC_GETH_UTFS_INIT,
UCC_FAST_VIRT_FIFO_REGS_ALIGNMENT);
/* Allocate memory for Rx Virtual Fifo */
uccf->ucc_fast_rx_virtual_fifo_base_offset =
qe_muram_alloc(UCC_GETH_URFS_INIT +
UCC_FAST_RX_VIRTUAL_FIFO_SIZE_PAD,
UCC_FAST_VIRT_FIFO_REGS_ALIGNMENT);
/* utfb, urfb are offsets from MURAM base */
out_be32(&uf_regs->utfb,
uccf->ucc_fast_tx_virtual_fifo_base_offset);
out_be32(&uf_regs->urfb,
uccf->ucc_fast_rx_virtual_fifo_base_offset);
/* Set Virtual Fifo registers */
out_be16(&uf_regs->urfs, UCC_GETH_URFS_INIT);
out_be16(&uf_regs->urfet, UCC_GETH_URFET_INIT);
out_be16(&uf_regs->urfset, UCC_GETH_URFSET_INIT);
out_be16(&uf_regs->utfs, UCC_GETH_UTFS_INIT);
out_be16(&uf_regs->utfet, UCC_GETH_UTFET_INIT);
out_be16(&uf_regs->utftt, UCC_GETH_UTFTT_INIT);
}
/* Rx clock routing */
if (uf_info->rx_clock != QE_CLK_NONE) {
if (ucc_set_clk_src(uf_info->ucc_num,
uf_info->rx_clock, COMM_DIR_RX)) {
printf("%s: Illegal value for parameter 'RxClock'.\n",
__func__);
return -EINVAL;
}
}
/* Tx clock routing */
if (uf_info->tx_clock != QE_CLK_NONE) {
if (ucc_set_clk_src(uf_info->ucc_num,
uf_info->tx_clock, COMM_DIR_TX)) {
printf("%s: Illegal value for parameter 'TxClock'.\n",
__func__);
return -EINVAL;
}
}
/* Clear interrupt mask register to disable all of interrupts */
out_be32(&uf_regs->uccm, 0x0);
/* Writing '1' to clear all of envents */
out_be32(&uf_regs->ucce, 0xffffffff);
*uccf_ret = uccf;
return 0;
}
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright (C) 2006 Freescale Semiconductor, Inc.
*
* Dave Liu <daveliu@freescale.com>
* based on source code of Shlomi Gridish
*/
#ifndef __UCCF_H__
#define __UCCF_H__
#include "common.h"
#include "linux/immap_qe.h"
#include <fsl_qe.h>
/* Fast or Giga ethernet */
enum enet_type {
FAST_ETH,
GIGA_ETH,
};
/* General UCC Extended Mode Register */
#define UCC_GUEMR_MODE_MASK_RX 0x02
#define UCC_GUEMR_MODE_MASK_TX 0x01
#define UCC_GUEMR_MODE_FAST_RX 0x02
#define UCC_GUEMR_MODE_FAST_TX 0x01
#define UCC_GUEMR_MODE_SLOW_RX 0x00
#define UCC_GUEMR_MODE_SLOW_TX 0x00
/* Bit 3 must be set 1 */
#define UCC_GUEMR_SET_RESERVED3 0x10
/* General UCC FAST Mode Register */
#define UCC_FAST_GUMR_TCI 0x20000000
#define UCC_FAST_GUMR_TRX 0x10000000
#define UCC_FAST_GUMR_TTX 0x08000000
#define UCC_FAST_GUMR_CDP 0x04000000
#define UCC_FAST_GUMR_CTSP 0x02000000
#define UCC_FAST_GUMR_CDS 0x01000000
#define UCC_FAST_GUMR_CTSS 0x00800000
#define UCC_FAST_GUMR_TXSY 0x00020000
#define UCC_FAST_GUMR_RSYN 0x00010000
#define UCC_FAST_GUMR_RTSM 0x00002000
#define UCC_FAST_GUMR_REVD 0x00000400
#define UCC_FAST_GUMR_ENR 0x00000020
#define UCC_FAST_GUMR_ENT 0x00000010
/* GUMR [MODE] bit maps */
#define UCC_FAST_GUMR_HDLC 0x00000000
#define UCC_FAST_GUMR_QMC 0x00000002
#define UCC_FAST_GUMR_UART 0x00000004
#define UCC_FAST_GUMR_BISYNC 0x00000008
#define UCC_FAST_GUMR_ATM 0x0000000a
#define UCC_FAST_GUMR_ETH 0x0000000c
/* Transmit On Demand (UTORD) */
#define UCC_SLOW_TOD 0x8000
#define UCC_FAST_TOD 0x8000
/* Fast Ethernet (10/100 Mbps) */
/* Rx virtual FIFO size */
#define UCC_GETH_URFS_INIT 512
/* 1/2 urfs */
#define UCC_GETH_URFET_INIT 256
/* 3/4 urfs */
#define UCC_GETH_URFSET_INIT 384
/* Tx virtual FIFO size */
#define UCC_GETH_UTFS_INIT 512
/* 1/2 utfs */
#define UCC_GETH_UTFET_INIT 256
#define UCC_GETH_UTFTT_INIT 128
/* Gigabit Ethernet (1000 Mbps) */
/* Rx virtual FIFO size */
#define UCC_GETH_URFS_GIGA_INIT 4096/*2048*/
/* 1/2 urfs */
#define UCC_GETH_URFET_GIGA_INIT 2048/*1024*/
/* 3/4 urfs */
#define UCC_GETH_URFSET_GIGA_INIT 3072/*1536*/
/* Tx virtual FIFO size */
#define UCC_GETH_UTFS_GIGA_INIT 8192/*2048*/
/* 1/2 utfs */
#define UCC_GETH_UTFET_GIGA_INIT 4096/*1024*/
#define UCC_GETH_UTFTT_GIGA_INIT 0x400/*0x40*/
/* UCC fast alignment */
#define UCC_FAST_RX_ALIGN 4
#define UCC_FAST_MRBLR_ALIGNMENT 4
#define UCC_FAST_VIRT_FIFO_REGS_ALIGNMENT 8
/* Sizes */
#define UCC_FAST_RX_VIRTUAL_FIFO_SIZE_PAD 8
/* UCC fast structure. */
struct ucc_fast_inf {
int ucc_num;
qe_clock_e rx_clock;
qe_clock_e tx_clock;
enum enet_type eth_type;
};
struct ucc_fast_priv {
struct ucc_fast_inf *uf_info;
ucc_fast_t *uf_regs; /* a pointer to memory map of UCC regs */
u32 *p_ucce; /* a pointer to the event register */
u32 *p_uccm; /* a pointer to the mask register */
int enabled_tx; /* whether UCC is enabled for Tx (ENT) */
int enabled_rx; /* whether UCC is enabled for Rx (ENR) */
u32 ucc_fast_tx_virtual_fifo_base_offset;
u32 ucc_fast_rx_virtual_fifo_base_offset;
};
void ucc_fast_transmit_on_demand(struct ucc_fast_priv *uccf);
u32 ucc_fast_get_qe_cr_subblock(int ucc_num);
void ucc_fast_enable(struct ucc_fast_priv *uccf, comm_dir_e mode);
void ucc_fast_disable(struct ucc_fast_priv *uccf, comm_dir_e mode);
int ucc_fast_init(struct ucc_fast_inf *uf_info,
struct ucc_fast_priv **uccf_ret);
#endif /* __UCCF_H__ */
此差异已折叠。
......@@ -3,7 +3,7 @@
#
config QE
bool "Enable support for QUICC Engine"
depends on PPC && !DM_ETH
depends on PPC
default y if ARCH_T1040 || ARCH_T1042 || ARCH_T1024 || ARCH_P1021 \
|| ARCH_P1025
help
......
......@@ -14,6 +14,7 @@
#include "uccf.h"
#include <fsl_qe.h>
#if !defined(CONFIG_DM_ETH)
void ucc_fast_transmit_on_demand(struct ucc_fast_priv *uccf)
{
out_be16(&uccf->uf_regs->utodr, UCC_FAST_TOD);
......@@ -505,3 +506,4 @@ int ucc_fast_init(struct ucc_fast_inf *uf_info,
*uccf_ret = uccf;
return 0;
}
#endif
......@@ -20,6 +20,7 @@
#include <fsl_qe.h>
#include <phy.h>
#if !defined(CONFIG_DM_ETH)
/* Default UTBIPAR SMI address */
#ifndef CONFIG_UTBIPAR_INIT_TBIPA
#define CONFIG_UTBIPAR_INIT_TBIPA 0x1F
......@@ -1432,3 +1433,4 @@ int uec_standard_init(struct bd_info *bis)
{
return uec_eth_init(bis, uec_info, ARRAY_SIZE(uec_info));
}
#endif
......@@ -23,6 +23,8 @@
#include <fsl_qe.h>
#include <phy.h>
#if !defined(CONFIG_DM_ETH)
#define ugphy_printk(format, arg...) \
printf(format "\n", ## arg)
......@@ -925,3 +927,4 @@ void change_phy_interface_mode(struct eth_device *dev,
marvell_phy_interface_mode(dev, type, speed);
#endif
}
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册