Merge tag 'u-boot-rockchip-20200501' of https://gitlab.denx.de/u-boot/custodians...
[platform/kernel/u-boot.git] / drivers / net / fm / fm.h
index ba581e9..2379b3a 100644 (file)
@@ -1,29 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * Copyright 2009-2011 Freescale Semiconductor, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
  */
 
 #ifndef __FM_H__
 #define __FM_H__
 
 #include <common.h>
+#include <phy.h>
 #include <fm_eth.h>
-#include <asm/fsl_enet.h>
-#include <asm/fsl_fman.h>
+#include <fsl_fman.h>
 
 /* Port ID */
 #define OH_PORT_ID_BASE                0x01
 #define RX_PORT_1G_BASE                0x08
 #define MAX_NUM_RX_PORT_1G     CONFIG_SYS_NUM_FM1_DTSEC
 #define RX_PORT_10G_BASE       0x10
+#define RX_PORT_10G_BASE2      0x08
 #define TX_PORT_1G_BASE                0x28
 #define MAX_NUM_TX_PORT_1G     CONFIG_SYS_NUM_FM1_DTSEC
 #define TX_PORT_10G_BASE       0x30
+#define TX_PORT_10G_BASE2      0x28
+#define MIIM_TIMEOUT    0xFFFF
 
 struct fm_muram {
-       u32 base;
-       u32 top;
-       u32 size;
-       u32 alloc;
+       void *base;
+       void *top;
+       size_t size;
+       void *alloc;
 };
 #define FM_MURAM_RES_SIZE      0x01000
 
@@ -68,6 +57,18 @@ struct fm_port_bd {
 #define TxBD_READY             0x8000
 #define TxBD_LAST              BD_LAST
 
+#ifdef CONFIG_DM_ETH
+enum fm_mac_type {
+#ifdef CONFIG_SYS_FMAN_V3
+       FM_MEMAC,
+#else
+       FM_DTSEC,
+       FM_TGEC,
+#endif
+};
+#endif
+
+/* Fman ethernet private struct */
 /* Rx/Tx queue descriptor */
 struct fm_port_qd {
        u16 gen;
@@ -98,19 +99,25 @@ struct fm_port_global_pram {
 #define PRAM_MODE_GLOBAL       0x20000000
 #define PRAM_MODE_GRACEFUL_STOP        0x00800000
 
-#if defined(CONFIG_P1017) || defined(CONFIG_P1023)
+#if defined(CONFIG_ARCH_P1023)
 #define FM_FREE_POOL_SIZE      0x2000 /* 8K bytes */
 #else
 #define FM_FREE_POOL_SIZE      0x20000 /* 128K bytes */
 #endif
 #define FM_FREE_POOL_ALIGN     256
 
-u32 fm_muram_alloc(int fm_idx, u32 size, u32 align);
-u32 fm_muram_base(int fm_idx);
+void *fm_muram_alloc(int fm_idx, size_t size, ulong align);
+void *fm_muram_base(int fm_idx);
 int fm_init_common(int index, struct ccsr_fman *reg);
 int fm_eth_initialize(struct ccsr_fman *reg, struct fm_eth_info *info);
 phy_interface_t fman_port_enet_if(enum fm_port port);
 void fman_disable_port(enum fm_port port);
+void fman_enable_port(enum fm_port port);
+int fman_id(struct udevice *dev);
+void *fman_port(struct udevice *dev, int num);
+#ifdef CONFIG_DM_ETH
+void *fman_mdio(struct udevice *dev, enum fm_mac_type type, int num);
+#endif
 
 struct fsl_enet_mac {
        void *base; /* MAC controller registers base address */
@@ -136,7 +143,13 @@ struct fm_eth {
        struct mii_dev *bus;
        struct phy_device *phydev;
        int phyaddr;
+#ifndef CONFIG_DM_ETH
        struct eth_device *dev;
+#else
+       enum fm_mac_type mac_type;
+       struct udevice *dev;
+       struct udevice *pcs_mdio;
+#endif
        int max_rx_len;
        struct fm_port_global_pram *rx_pram; /* Rx parameter table */
        struct fm_port_global_pram *tx_pram; /* Tx parameter table */
@@ -152,6 +165,7 @@ struct fm_eth {
 #define MAX_RXBUF_LOG2         11
 #define MAX_RXBUF_LEN          (1 << MAX_RXBUF_LOG2)
 
-#define PORT_IS_ENABLED(port)  fm_info[fm_port_to_index(port)].enabled
+#define PORT_IS_ENABLED(port)  (fm_port_to_index(port) == -1 ? \
+       0 : fm_info[fm_port_to_index(port)].enabled)
 
 #endif /* __FM_H__ */