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> |
Grant Likely | aa73832 | 2009-04-25 12:53:33 +0000 | [diff] [blame] | 20 | #include <linux/of_mdio.h> |
Pantelis Antoniou | 48257c4 | 2005-10-28 16:25:58 -0400 | [diff] [blame] | 21 | #include <asm/types.h> |
| 22 | |
| 23 | #define FS_ENET_NAME "fs_enet" |
| 24 | |
| 25 | enum fs_id { |
| 26 | fsid_fec1, |
| 27 | fsid_fec2, |
| 28 | fsid_fcc1, |
| 29 | fsid_fcc2, |
| 30 | fsid_fcc3, |
| 31 | fsid_scc1, |
| 32 | fsid_scc2, |
| 33 | fsid_scc3, |
| 34 | fsid_scc4, |
| 35 | }; |
| 36 | |
| 37 | #define FS_MAX_INDEX 9 |
| 38 | |
| 39 | static inline int fs_get_fec_index(enum fs_id id) |
| 40 | { |
| 41 | if (id >= fsid_fec1 && id <= fsid_fec2) |
| 42 | return id - fsid_fec1; |
| 43 | return -1; |
| 44 | } |
| 45 | |
| 46 | static inline int fs_get_fcc_index(enum fs_id id) |
| 47 | { |
| 48 | if (id >= fsid_fcc1 && id <= fsid_fcc3) |
| 49 | return id - fsid_fcc1; |
| 50 | return -1; |
| 51 | } |
| 52 | |
| 53 | static inline int fs_get_scc_index(enum fs_id id) |
| 54 | { |
| 55 | if (id >= fsid_scc1 && id <= fsid_scc4) |
| 56 | return id - fsid_scc1; |
| 57 | return -1; |
| 58 | } |
| 59 | |
Vitaly Bordug | 611a15a | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 60 | static inline int fs_fec_index2id(int index) |
| 61 | { |
| 62 | int id = fsid_fec1 + index - 1; |
| 63 | if (id >= fsid_fec1 && id <= fsid_fec2) |
| 64 | return id; |
| 65 | return FS_MAX_INDEX; |
| 66 | } |
| 67 | |
| 68 | static inline int fs_fcc_index2id(int index) |
| 69 | { |
| 70 | int id = fsid_fcc1 + index - 1; |
| 71 | if (id >= fsid_fcc1 && id <= fsid_fcc3) |
| 72 | return id; |
| 73 | return FS_MAX_INDEX; |
| 74 | } |
| 75 | |
| 76 | static inline int fs_scc_index2id(int index) |
| 77 | { |
| 78 | int id = fsid_scc1 + index - 1; |
| 79 | if (id >= fsid_scc1 && id <= fsid_scc4) |
| 80 | return id; |
| 81 | return FS_MAX_INDEX; |
| 82 | } |
| 83 | |
Pantelis Antoniou | 48257c4 | 2005-10-28 16:25:58 -0400 | [diff] [blame] | 84 | enum fs_mii_method { |
| 85 | fsmii_fixed, |
| 86 | fsmii_fec, |
| 87 | fsmii_bitbang, |
| 88 | }; |
| 89 | |
| 90 | enum fs_ioport { |
| 91 | fsiop_porta, |
| 92 | fsiop_portb, |
| 93 | fsiop_portc, |
| 94 | fsiop_portd, |
| 95 | fsiop_porte, |
| 96 | }; |
| 97 | |
Vitaly Bordug | 2ca2d5e | 2006-08-14 23:00:31 -0700 | [diff] [blame] | 98 | struct fs_mii_bit { |
| 99 | u32 offset; |
| 100 | u8 bit; |
| 101 | u8 polarity; |
| 102 | }; |
| 103 | struct fs_mii_bb_platform_info { |
| 104 | struct fs_mii_bit mdio_dir; |
| 105 | struct fs_mii_bit mdio_dat; |
| 106 | struct fs_mii_bit mdc_dat; |
Vitaly Bordug | 2ca2d5e | 2006-08-14 23:00:31 -0700 | [diff] [blame] | 107 | int delay; /* delay in us */ |
| 108 | int irq[32]; /* irqs per phy's */ |
Pantelis Antoniou | 48257c4 | 2005-10-28 16:25:58 -0400 | [diff] [blame] | 109 | }; |
| 110 | |
| 111 | struct fs_platform_info { |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 112 | |
| 113 | void(*init_ioports)(struct fs_platform_info *); |
Pantelis Antoniou | 48257c4 | 2005-10-28 16:25:58 -0400 | [diff] [blame] | 114 | /* device specific information */ |
| 115 | int fs_no; /* controller index */ |
Vitaly Bordug | 611a15a | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 116 | char fs_type[4]; /* controller type */ |
Pantelis Antoniou | 48257c4 | 2005-10-28 16:25:58 -0400 | [diff] [blame] | 117 | |
| 118 | u32 cp_page; /* CPM page */ |
| 119 | u32 cp_block; /* CPM sblock */ |
Scott Wood | 976de6a | 2007-10-02 10:55:58 -0500 | [diff] [blame] | 120 | u32 cp_command; /* CPM page/sblock/mcn */ |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 121 | |
Pantelis Antoniou | 48257c4 | 2005-10-28 16:25:58 -0400 | [diff] [blame] | 122 | u32 clk_trx; /* some stuff for pins & mux configuration*/ |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 123 | u32 clk_rx; |
| 124 | u32 clk_tx; |
Pantelis Antoniou | 48257c4 | 2005-10-28 16:25:58 -0400 | [diff] [blame] | 125 | u32 clk_route; |
| 126 | u32 clk_mask; |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 127 | |
Pantelis Antoniou | 48257c4 | 2005-10-28 16:25:58 -0400 | [diff] [blame] | 128 | u32 mem_offset; |
| 129 | u32 dpram_offset; |
| 130 | u32 fcc_regs_c; |
| 131 | |
| 132 | u32 device_flags; |
| 133 | |
Grant Likely | aa73832 | 2009-04-25 12:53:33 +0000 | [diff] [blame] | 134 | struct device_node *phy_node; |
Pantelis Antoniou | 48257c4 | 2005-10-28 16:25:58 -0400 | [diff] [blame] | 135 | const struct fs_mii_bus_info *bus_info; |
| 136 | |
| 137 | int rx_ring, tx_ring; /* number of buffers on rx */ |
| 138 | __u8 macaddr[6]; /* mac address */ |
| 139 | int rx_copybreak; /* limit we copy small frames */ |
| 140 | int use_napi; /* use NAPI */ |
| 141 | int napi_weight; /* NAPI weight */ |
| 142 | |
| 143 | int use_rmii; /* use RMII mode */ |
Vitaly Bordug | 2ca2d5e | 2006-08-14 23:00:31 -0700 | [diff] [blame] | 144 | int has_phy; /* if the network is phy container as well...*/ |
Pantelis Antoniou | 48257c4 | 2005-10-28 16:25:58 -0400 | [diff] [blame] | 145 | }; |
Vitaly Bordug | 2ca2d5e | 2006-08-14 23:00:31 -0700 | [diff] [blame] | 146 | struct fs_mii_fec_platform_info { |
| 147 | u32 irq[32]; |
| 148 | u32 mii_speed; |
| 149 | }; |
Vitaly Bordug | 611a15a | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 150 | |
| 151 | static inline int fs_get_id(struct fs_platform_info *fpi) |
| 152 | { |
| 153 | if(strstr(fpi->fs_type, "SCC")) |
| 154 | return fs_scc_index2id(fpi->fs_no); |
| 155 | if(strstr(fpi->fs_type, "FCC")) |
| 156 | return fs_fcc_index2id(fpi->fs_no); |
| 157 | if(strstr(fpi->fs_type, "FEC")) |
| 158 | return fs_fec_index2id(fpi->fs_no); |
| 159 | return fpi->fs_no; |
| 160 | } |
| 161 | |
Pantelis Antoniou | 48257c4 | 2005-10-28 16:25:58 -0400 | [diff] [blame] | 162 | #endif |