GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / include / bcmrobo.h
blob3d2b8a3e0970d2d93c28ea3cace6998beca65fa1
1 /*
2 * RoboSwitch setup functions
4 * Copyright (C) 2012, Broadcom Corporation. All Rights Reserved.
5 *
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
13 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
15 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
16 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 * $Id: bcmrobo.h 393340 2013-03-27 06:10:49Z $
21 #ifndef _bcm_robo_h_
22 #define _bcm_robo_h_
24 #define DEVID5325 0x25 /* 5325 (Not really but we fake it) */
25 #define DEVID5395 0x95 /* 5395 */
26 #define DEVID5397 0x97 /* 5397 */
27 #define DEVID5398 0x98 /* 5398 */
28 #define DEVID53115 0x3115 /* 53115 */
29 #define DEVID53125 0x3125 /* 53125 */
32 * MODELID:
33 * 0x53010: BCM4707, Select Low SKU device if SKU ID[1:0] = 01.
34 * 0x53011: BCM4708, Select Middle SKU device if SKU ID[1:0] = 10.
35 * 0x53012: BCM4709, Select High SKU device if SKU ID[1:0] = 00.
36 * Note: The SKU ID[1:0] is loaded from OTP configuration data.
38 #define DEVID53010 0x53010 /* 53010 */
39 #define DEVID53011 0x53011 /* 53011 */
40 #define DEVID53012 0x53012 /* 53012 */
41 #define DEVID53018 0x53018 /* 53018 */
42 #define DEVID53019 0x53019 /* 53019 */
43 #define ROBO_IS_BCM5301X(id) ((id) == DEVID53010 || (id) == DEVID53011 || (id) == DEVID53012 || \
44 (id) == DEVID53018 || (id) == DEVID53019)
46 /* Power save duty cycle times */
47 #define MAX_NO_PHYS 5
48 #define PWRSAVE_SLEEP_TIME 12
49 #define PWRSAVE_WAKE_TIME 3
51 /* Power save modes for the switch */
52 #define ROBO_PWRSAVE_NORMAL 0
53 #define ROBO_PWRSAVE_AUTO 1
54 #define ROBO_PWRSAVE_MANUAL 2
55 #define ROBO_PWRSAVE_AUTO_MANUAL 3
57 #define ROBO_IS_PWRSAVE_MANUAL(r) ((r)->pwrsave_mode_manual)
58 #define ROBO_IS_PWRSAVE_AUTO(r) ((r)->pwrsave_mode_auto)
60 /* SRAB interface */
61 /* Access switch registers through SRAB (Switch Register Access Bridge) */
62 #define REG_VERSION_ID 0x40
63 #define REG_CTRL_PORT0_GMIIPO 0x58 /* 53012: GMII Port0 Override register */
64 #define REG_CTRL_PORT1_GMIIPO 0x59 /* 53012: GMII Port1 Override register */
65 #define REG_CTRL_PORT2_GMIIPO 0x5a /* 53012: GMII Port2 Override register */
66 #define REG_CTRL_PORT3_GMIIPO 0x5b /* 53012: GMII Port3 Override register */
67 #define REG_CTRL_PORT4_GMIIPO 0x5c /* 53012: GMII Port4 Override register */
68 #define REG_CTRL_PORT5_GMIIPO 0x5d /* 53012: GMII Port5 Override register */
69 #define REG_CTRL_PORT7_GMIIPO 0x5f /* 53012: GMII Port7 Override register */
71 /* Command and status register of the SRAB */
72 #define CFG_F_sra_rst_MASK (1 << 2)
73 #define CFG_F_sra_write_MASK (1 << 1)
74 #define CFG_F_sra_gordyn_MASK (1 << 0)
75 #define CFG_F_sra_page_R 24
76 #define CFG_F_sra_offset_R 16
78 /* Switch interface controls */
79 #define CFG_F_sw_init_done_MASK (1 << 6)
80 #define CFG_F_rcareq_MASK (1 << 3)
81 #define CFG_F_rcagnt_MASK (1 << 4)
83 #ifndef PAD
84 #define _PADLINE(line) pad ## line
85 #define _XSTR(line) _PADLINE(line)
86 #define PAD _XSTR(__LINE__)
87 #endif /* PAD */
89 typedef volatile struct {
90 uint32 PAD[11];
91 uint32 cmdstat; /* 0x2c, command and status register of the SRAB */
92 uint32 wd_h; /* 0x30, high order word of write data to switch registe */
93 uint32 wd_l; /* 0x34, low order word of write data to switch registe */
94 uint32 rd_h; /* 0x38, high order word of read data from switch register */
95 uint32 rd_l; /* 0x3c, low order word of read data from switch register */
96 uint32 ctrls; /* 0x40, switch interface controls */
97 uint32 intr; /* 0x44, the register captures interrupt pulses from the switch */
98 } srabregs_t;
100 /* Forward declaration */
101 typedef struct robo_info_s robo_info_t;
103 /* Device access/config oprands */
104 typedef struct {
105 /* low level routines */
106 void (*enable_mgmtif)(robo_info_t *robo); /* enable mgmt i/f, optional */
107 void (*disable_mgmtif)(robo_info_t *robo); /* disable mgmt i/f, optional */
108 int (*write_reg)(robo_info_t *robo, uint8 page, uint8 reg, void *val, int len);
109 int (*read_reg)(robo_info_t *robo, uint8 page, uint8 reg, void *val, int len);
110 /* description */
111 char *desc;
112 } dev_ops_t;
115 typedef uint16 (*miird_f)(void *h, int add, int off);
116 typedef void (*miiwr_f)(void *h, int add, int off, uint16 val);
118 /* Private state per RoboSwitch */
119 struct robo_info_s {
120 si_t *sih; /* SiliconBackplane handle */
121 char *vars; /* nvram variables handle */
122 void *h; /* dev handle */
123 uint32 devid; /* Device id for the switch */
124 uint32 corerev; /* Core rev of internal switch */
126 dev_ops_t *ops; /* device ops */
127 uint8 page; /* current page */
129 /* SPI */
130 uint32 ss, sck, mosi, miso; /* GPIO mapping */
132 /* MII */
133 miird_f miird;
134 miiwr_f miiwr;
136 /* SRAB */
137 srabregs_t *srabregs;
139 uint16 prev_status; /* link status of switch ports */
140 uint32 pwrsave_mode_manual; /* bitmap of ports in manual power save */
141 uint32 pwrsave_mode_auto; /* bitmap of ports in auto power save mode */
142 uint32 pwrsave_sleep_time; /* sleep time for manual power save mode */
143 uint32 pwrsave_wake_time; /* wakeup time for manual power save mode */
144 uint8 pwrsave_phys; /* Phys that can be put into power save mode */
145 uint8 pwrsave_mode_phys[MAX_NO_PHYS]; /* Power save mode on the switch */
146 bool eee_status;
147 #ifdef PLC
148 /* PLC */
149 bool plc_hw; /* PLC chip */
150 #endif /* PLC */
153 /* Power Save mode related functions */
154 extern int32 robo_power_save_mode_get(robo_info_t *robo, int32 phy);
155 extern int32 robo_power_save_mode_set(robo_info_t *robo, int32 mode, int32 phy);
156 extern void robo_power_save_mode_update(robo_info_t *robo);
157 extern int robo_power_save_mode(robo_info_t *robo, int mode, int phy);
158 extern int robo_power_save_toggle(robo_info_t *robo, int normal);
160 extern robo_info_t *bcm_robo_attach(si_t *sih, void *h, char *vars, miird_f miird, miiwr_f miiwr);
161 extern void bcm_robo_detach(robo_info_t *robo);
162 extern int bcm_robo_enable_device(robo_info_t *robo);
163 extern int bcm_robo_config_vlan(robo_info_t *robo, uint8 *mac_addr);
164 extern int bcm_robo_enable_switch(robo_info_t *robo);
166 #ifdef BCMDBG
167 extern void robo_dump_regs(robo_info_t *robo, struct bcmstrbuf *b);
168 #endif /* BCMDBG */
170 extern void robo_watchdog(robo_info_t *robo);
171 extern void robo_eee_advertise_init(robo_info_t *robo);
173 #ifdef PLC
174 extern void robo_plc_hw_init(robo_info_t *robo);
175 #endif /* PLC */
177 #endif /* _bcm_robo_h_ */