]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - include/fm_eth.h
Merge branch 'master' of git://git.denx.de/u-boot-video
[karo-tx-uboot.git] / include / fm_eth.h
1 /*
2  * Copyright 2009-2011 Freescale Semiconductor, Inc.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of
7  * the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
17  * MA 02111-1307 USA
18  */
19
20 #ifndef __FM_ETH_H__
21 #define __FM_ETH_H__
22
23 #include <common.h>
24 #include <asm/types.h>
25 #include <asm/fsl_enet.h>
26
27 enum fm_port {
28         FM1_DTSEC1,
29         FM1_DTSEC2,
30         FM1_DTSEC3,
31         FM1_DTSEC4,
32         FM1_DTSEC5,
33         FM1_10GEC1,
34         FM2_DTSEC1,
35         FM2_DTSEC2,
36         FM2_DTSEC3,
37         FM2_DTSEC4,
38         FM2_DTSEC5,
39         FM2_10GEC1,
40         NUM_FM_PORTS,
41 };
42
43 enum fm_eth_type {
44         FM_ETH_1G_E,
45         FM_ETH_10G_E,
46 };
47
48 #define CONFIG_SYS_FM1_DTSEC1_MDIO_ADDR (CONFIG_SYS_FSL_FM1_ADDR + 0xe1120)
49 #define CONFIG_SYS_FM1_TGEC_MDIO_ADDR   (CONFIG_SYS_FSL_FM1_ADDR + 0xf1000)
50
51 #define DEFAULT_FM_MDIO_NAME "FSL_MDIO0"
52 #define DEFAULT_FM_TGEC_MDIO_NAME "FM_TGEC_MDIO"
53
54 /* Fman ethernet info struct */
55 #define FM_ETH_INFO_INITIALIZER(idx, pregs) \
56         .fm             = idx,                                          \
57         .phy_regs       = (void *)pregs,                                \
58         .enet_if        = PHY_INTERFACE_MODE_NONE,                      \
59
60 #define FM_DTSEC_INFO_INITIALIZER(idx, n) \
61 {                                                                       \
62         FM_ETH_INFO_INITIALIZER(idx, CONFIG_SYS_FM1_DTSEC1_MDIO_ADDR)   \
63         .index          = idx,                                          \
64         .num            = n - 1,                                        \
65         .type           = FM_ETH_1G_E,                                  \
66         .port           = FM##idx##_DTSEC##n,                           \
67         .rx_port_id     = RX_PORT_1G_BASE + n - 1,                      \
68         .tx_port_id     = TX_PORT_1G_BASE + n - 1,                      \
69         .compat_offset  = CONFIG_SYS_FSL_FM##idx##_OFFSET +             \
70                                 offsetof(struct ccsr_fman, mac_1g[n-1]),\
71 }
72
73 #define FM_TGEC_INFO_INITIALIZER(idx, n) \
74 {                                                                       \
75         FM_ETH_INFO_INITIALIZER(idx, CONFIG_SYS_FM1_TGEC_MDIO_ADDR)     \
76         .index          = idx,                                          \
77         .num            = n - 1,                                        \
78         .type           = FM_ETH_10G_E,                                 \
79         .port           = FM##idx##_10GEC##n,                           \
80         .rx_port_id     = RX_PORT_10G_BASE + n - 1,                     \
81         .tx_port_id     = TX_PORT_10G_BASE + n - 1,                     \
82         .compat_offset  = CONFIG_SYS_FSL_FM##idx##_OFFSET +             \
83                                 offsetof(struct ccsr_fman, mac_10g[n-1]),\
84 }
85
86 struct fm_eth_info {
87         u8 enabled;
88         u8 fm;
89         u8 num;
90         u8 phy_addr;
91         int index;
92         u16 rx_port_id;
93         u16 tx_port_id;
94         enum fm_port port;
95         enum fm_eth_type type;
96         void *phy_regs;
97         phy_interface_t enet_if;
98         u32 compat_offset;
99         struct mii_dev *bus;
100 };
101
102 struct tgec_mdio_info {
103         struct tgec_mdio_controller *regs;
104         char *name;
105 };
106
107 int fm_tgec_mdio_init(bd_t *bis, struct tgec_mdio_info *info);
108 int fm_standard_init(bd_t *bis);
109 void fman_enet_init(void);
110 void fdt_fixup_fman_ethernet(void *fdt);
111 phy_interface_t fm_info_get_enet_if(enum fm_port port);
112 void fm_info_set_phy_address(enum fm_port port, int address);
113 int fm_info_get_phy_address(enum fm_port port);
114 void fm_info_set_mdio(enum fm_port port, struct mii_dev *bus);
115 void fm_disable_port(enum fm_port port);
116
117 #endif