2 * RoboSwitch setup functions
4 * Copyright (C) 2010, Broadcom Corporation. All Rights Reserved.
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.
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,v 13.13 2009-08-14 02:45:34 Exp $
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 */
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 */
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
);
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 */
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 */
75 uint32 ss
, sck
, mosi
, miso
; /* GPIO mapping */
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 */
88 bool plc_hw
; /* PLC chip */
92 /* Power Save mode related functions */
93 extern int32
robo_power_save_mode_get(robo_info_t
*robo
, int32 phy
);
94 extern int32
robo_power_save_mode_set(robo_info_t
*robo
, int32 mode
, int32 phy
);
95 extern void robo_power_save_mode_update(robo_info_t
*robo
);
96 extern int robo_power_save_mode(robo_info_t
*robo
, int mode
, int phy
);
97 extern int robo_power_save_toggle(robo_info_t
*robo
, int normal
);
99 extern robo_info_t
*bcm_robo_attach(si_t
*sih
, void *h
, char *vars
, miird_f miird
, miiwr_f miiwr
);
100 extern void bcm_robo_detach(robo_info_t
*robo
);
101 extern int bcm_robo_enable_device(robo_info_t
*robo
);
102 extern int bcm_robo_config_vlan(robo_info_t
*robo
, uint8
*mac_addr
);
103 extern int bcm_robo_enable_switch(robo_info_t
*robo
);
106 extern void robo_dump_regs(robo_info_t
*robo
, struct bcmstrbuf
*b
);
110 extern void robo_plc_hw_init(robo_info_t
*robo
);
113 #endif /* _bcm_robo_h_ */