Pantelis Antoniou | 48257c4 | 2005-10-28 16:25:58 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Platform information definitions for the |
| 3 | * universal Freescale Ethernet driver. |
| 4 | * |
| 5 | * Copyright (c) 2003 Intracom S.A. |
| 6 | * by Pantelis Antoniou <panto@intracom.gr> |
| 7 | * |
| 8 | * 2005 (c) MontaVista Software, Inc. |
| 9 | * Vitaly Bordug <vbordug@ru.mvista.com> |
| 10 | * |
| 11 | * This file is licensed under the terms of the GNU General Public License |
| 12 | * version 2. This program is licensed "as is" without any warranty of any |
| 13 | * kind, whether express or implied. |
| 14 | */ |
| 15 | |
| 16 | #ifndef FS_ENET_PD_H |
| 17 | #define FS_ENET_PD_H |
| 18 | |
Scott Wood | b7336d3 | 2007-10-01 14:20:49 -0500 | [diff] [blame] | 19 | #include <linux/string.h> |
Pantelis Antoniou | 48257c4 | 2005-10-28 16:25:58 -0400 | [diff] [blame] | 20 | #include <asm/types.h> |
| 21 | |
| 22 | #define FS_ENET_NAME "fs_enet" |
| 23 | |
| 24 | enum fs_id { |
| 25 | fsid_fec1, |
| 26 | fsid_fec2, |
| 27 | fsid_fcc1, |
| 28 | fsid_fcc2, |
| 29 | fsid_fcc3, |
| 30 | fsid_scc1, |
| 31 | fsid_scc2, |
| 32 | fsid_scc3, |
| 33 | fsid_scc4, |
| 34 | }; |
| 35 | |
| 36 | #define FS_MAX_INDEX 9 |
| 37 | |
| 38 | static inline int fs_get_fec_index(enum fs_id id) |
| 39 | { |
| 40 | if (id >= fsid_fec1 && id <= fsid_fec2) |
| 41 | return id - fsid_fec1; |
| 42 | return -1; |
| 43 | } |
| 44 | |
| 45 | static inline int fs_get_fcc_index(enum fs_id id) |
| 46 | { |
| 47 | if (id >= fsid_fcc1 && id <= fsid_fcc3) |
| 48 | return id - fsid_fcc1; |
| 49 | return -1; |
| 50 | } |
| 51 | |
| 52 | static inline int fs_get_scc_index(enum fs_id id) |
| 53 | { |
| 54 | if (id >= fsid_scc1 && id <= fsid_scc4) |
| 55 | return id - fsid_scc1; |
| 56 | return -1; |
| 57 | } |
| 58 | |
Vitaly Bordug | 611a15a | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 59 | static inline int fs_fec_index2id(int index) |
| 60 | { |
| 61 | int id = fsid_fec1 + index - 1; |
| 62 | if (id >= fsid_fec1 && id <= fsid_fec2) |
| 63 | return id; |
| 64 | return FS_MAX_INDEX; |
| 65 | } |
| 66 | |
| 67 | static inline int fs_fcc_index2id(int index) |
| 68 | { |
| 69 | int id = fsid_fcc1 + index - 1; |
| 70 | if (id >= fsid_fcc1 && id <= fsid_fcc3) |
| 71 | return id; |
| 72 | return FS_MAX_INDEX; |
| 73 | } |
| 74 | |
| 75 | static inline int fs_scc_index2id(int index) |
| 76 | { |
| 77 | int id = fsid_scc1 + index - 1; |
| 78 | if (id >= fsid_scc1 && id <= fsid_scc4) |
| 79 | return id; |
| 80 | return FS_MAX_INDEX; |
| 81 | } |
| 82 | |
Pantelis Antoniou | 48257c4 | 2005-10-28 16:25:58 -0400 | [diff] [blame] | 83 | enum fs_mii_method { |
| 84 | fsmii_fixed, |
| 85 | fsmii_fec, |
| 86 | fsmii_bitbang, |
| 87 | }; |
| 88 | |
| 89 | enum fs_ioport { |
| 90 | fsiop_porta, |
| 91 | fsiop_portb, |
| 92 | fsiop_portc, |
| 93 | fsiop_portd, |
| 94 | fsiop_porte, |
| 95 | }; |
| 96 | |
Vitaly Bordug | 2ca2d5e | 2006-08-14 23:00:31 -0700 | [diff] [blame] | 97 | struct fs_mii_bit { |
| 98 | u32 offset; |
| 99 | u8 bit; |
| 100 | u8 polarity; |
| 101 | }; |
| 102 | struct fs_mii_bb_platform_info { |
| 103 | struct fs_mii_bit mdio_dir; |
| 104 | struct fs_mii_bit mdio_dat; |
| 105 | struct fs_mii_bit mdc_dat; |
| 106 | int mdio_port; /* port & bit for MDIO */ |
| 107 | int mdio_bit; |
| 108 | int mdc_port; /* port & bit for MDC */ |
| 109 | int mdc_bit; |
| 110 | int delay; /* delay in us */ |
| 111 | int irq[32]; /* irqs per phy's */ |
Pantelis Antoniou | 48257c4 | 2005-10-28 16:25:58 -0400 | [diff] [blame] | 112 | }; |
| 113 | |
| 114 | struct fs_platform_info { |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 115 | |
| 116 | void(*init_ioports)(struct fs_platform_info *); |
Pantelis Antoniou | 48257c4 | 2005-10-28 16:25:58 -0400 | [diff] [blame] | 117 | /* device specific information */ |
| 118 | int fs_no; /* controller index */ |
Vitaly Bordug | 611a15a | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 119 | char fs_type[4]; /* controller type */ |
Pantelis Antoniou | 48257c4 | 2005-10-28 16:25:58 -0400 | [diff] [blame] | 120 | |
| 121 | u32 cp_page; /* CPM page */ |
| 122 | u32 cp_block; /* CPM sblock */ |
Scott Wood | 976de6a | 2007-10-02 10:55:58 -0500 | [diff] [blame^] | 123 | u32 cp_command; /* CPM page/sblock/mcn */ |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 124 | |
Pantelis Antoniou | 48257c4 | 2005-10-28 16:25:58 -0400 | [diff] [blame] | 125 | u32 clk_trx; /* some stuff for pins & mux configuration*/ |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 126 | u32 clk_rx; |
| 127 | u32 clk_tx; |
Pantelis Antoniou | 48257c4 | 2005-10-28 16:25:58 -0400 | [diff] [blame] | 128 | u32 clk_route; |
| 129 | u32 clk_mask; |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 130 | |
Pantelis Antoniou | 48257c4 | 2005-10-28 16:25:58 -0400 | [diff] [blame] | 131 | u32 mem_offset; |
| 132 | u32 dpram_offset; |
| 133 | u32 fcc_regs_c; |
| 134 | |
| 135 | u32 device_flags; |
| 136 | |
| 137 | int phy_addr; /* the phy address (-1 no phy) */ |
Scott Wood | 976de6a | 2007-10-02 10:55:58 -0500 | [diff] [blame^] | 138 | #ifdef CONFIG_PPC_CPM_NEW_BINDING |
| 139 | char bus_id[16]; |
| 140 | #else |
Vitaly Bordug | 2ca2d5e | 2006-08-14 23:00:31 -0700 | [diff] [blame] | 141 | const char* bus_id; |
Scott Wood | 976de6a | 2007-10-02 10:55:58 -0500 | [diff] [blame^] | 142 | #endif |
Pantelis Antoniou | 48257c4 | 2005-10-28 16:25:58 -0400 | [diff] [blame] | 143 | int phy_irq; /* the phy irq (if it exists) */ |
| 144 | |
| 145 | const struct fs_mii_bus_info *bus_info; |
| 146 | |
| 147 | int rx_ring, tx_ring; /* number of buffers on rx */ |
| 148 | __u8 macaddr[6]; /* mac address */ |
| 149 | int rx_copybreak; /* limit we copy small frames */ |
| 150 | int use_napi; /* use NAPI */ |
| 151 | int napi_weight; /* NAPI weight */ |
| 152 | |
| 153 | int use_rmii; /* use RMII mode */ |
Vitaly Bordug | 2ca2d5e | 2006-08-14 23:00:31 -0700 | [diff] [blame] | 154 | int has_phy; /* if the network is phy container as well...*/ |
Pantelis Antoniou | 48257c4 | 2005-10-28 16:25:58 -0400 | [diff] [blame] | 155 | }; |
Vitaly Bordug | 2ca2d5e | 2006-08-14 23:00:31 -0700 | [diff] [blame] | 156 | struct fs_mii_fec_platform_info { |
| 157 | u32 irq[32]; |
| 158 | u32 mii_speed; |
| 159 | }; |
Vitaly Bordug | 611a15a | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 160 | |
| 161 | static inline int fs_get_id(struct fs_platform_info *fpi) |
| 162 | { |
| 163 | if(strstr(fpi->fs_type, "SCC")) |
| 164 | return fs_scc_index2id(fpi->fs_no); |
| 165 | if(strstr(fpi->fs_type, "FCC")) |
| 166 | return fs_fcc_index2id(fpi->fs_no); |
| 167 | if(strstr(fpi->fs_type, "FEC")) |
| 168 | return fs_fec_index2id(fpi->fs_no); |
| 169 | return fpi->fs_no; |
| 170 | } |
| 171 | |
Pantelis Antoniou | 48257c4 | 2005-10-28 16:25:58 -0400 | [diff] [blame] | 172 | #endif |