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