allow coexistance of N build and AC build.
[tomato.git] / release / src-rt-6.x / include / bcmrobo.h
blob40998e7160c7753a28e896e366740bb497876e0e
1 /*
2 * RoboSwitch setup functions
4 * Copyright (C) 2011, 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 299850 2011-12-01 03:46:38Z $
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 */
31 /* Power save duty cycle times */
32 #define MAX_NO_PHYS 5
33 #define PWRSAVE_SLEEP_TIME 12
34 #define PWRSAVE_WAKE_TIME 3
36 /* Power save modes for the switch */
37 #define ROBO_PWRSAVE_NORMAL 0
38 #define ROBO_PWRSAVE_AUTO 1
39 #define ROBO_PWRSAVE_MANUAL 2
40 #define ROBO_PWRSAVE_AUTO_MANUAL 3
42 #define ROBO_IS_PWRSAVE_MANUAL(r) ((r)->pwrsave_mode_manual)
43 #define ROBO_IS_PWRSAVE_AUTO(r) ((r)->pwrsave_mode_auto)
45 /* Forward declaration */
46 typedef struct robo_info_s robo_info_t;
48 /* Device access/config oprands */
49 typedef struct {
50 /* low level routines */
51 void (*enable_mgmtif)(robo_info_t *robo); /* enable mgmt i/f, optional */
52 void (*disable_mgmtif)(robo_info_t *robo); /* disable mgmt i/f, optional */
53 int (*write_reg)(robo_info_t *robo, uint8 page, uint8 reg, void *val, int len);
54 int (*read_reg)(robo_info_t *robo, uint8 page, uint8 reg, void *val, int len);
55 /* description */
56 char *desc;
57 } dev_ops_t;
60 typedef uint16 (*miird_f)(void *h, int add, int off);
61 typedef void (*miiwr_f)(void *h, int add, int off, uint16 val);
63 /* Private state per RoboSwitch */
64 struct robo_info_s {
65 si_t *sih; /* SiliconBackplane handle */
66 char *vars; /* nvram variables handle */
67 void *h; /* dev handle */
68 uint16 devid; /* Device id for the switch */
69 uint32 corerev; /* Core rev of internal switch */
71 dev_ops_t *ops; /* device ops */
72 uint8 page; /* current page */
74 /* SPI */
75 uint32 ss, sck, mosi, miso; /* GPIO mapping */
77 /* MII */
78 miird_f miird;
79 miiwr_f miiwr;
81 uint16 prev_status; /* link status of switch ports */
82 uint32 pwrsave_mode_manual; /* bitmap of ports in manual power save */
83 uint32 pwrsave_mode_auto; /* bitmap of ports in auto power save mode */
84 uint8 pwrsave_phys; /* Phys that can be put into power save mode */
85 uint8 pwrsave_mode_phys[MAX_NO_PHYS]; /* Power save mode on the switch */
86 bool eee_status;
89 /* Power Save mode related functions */
90 extern int32 robo_power_save_mode_get(robo_info_t *robo, int32 phy);
91 extern int32 robo_power_save_mode_set(robo_info_t *robo, int32 mode, int32 phy);
92 extern void robo_power_save_mode_update(robo_info_t *robo);
93 extern int robo_power_save_mode(robo_info_t *robo, int mode, int phy);
94 extern int robo_power_save_toggle(robo_info_t *robo, int normal);
96 extern robo_info_t *bcm_robo_attach(si_t *sih, void *h, char *vars, miird_f miird, miiwr_f miiwr);
97 extern void bcm_robo_detach(robo_info_t *robo);
98 extern int bcm_robo_enable_device(robo_info_t *robo);
99 extern int bcm_robo_config_vlan(robo_info_t *robo, uint8 *mac_addr);
100 extern int bcm_robo_enable_switch(robo_info_t *robo);
102 #ifdef BCMDBG
103 extern void robo_dump_regs(robo_info_t *robo, struct bcmstrbuf *b);
104 #endif /* BCMDBG */
106 extern void robo_watchdog(robo_info_t *robo);
107 extern void robo_eee_advertise_init(robo_info_t *robo);
109 #endif /* _bcm_robo_h_ */