ce9659bba0ceef05562e8b12ef0fb9dd84ef79f3
[openwrt-10.03/.git] / package / broadcom-57xx / src / bcmrobo.h
1 /*
2  * RoboSwitch setup functions
3  *
4  * Copyright 2007, Broadcom Corporation
5  * All Rights Reserved.
6  * 
7  * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8  * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
9  * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10  * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
11  *
12  * $Id: bcmrobo.h,v 1.1.1.6 2007/05/31 08:00:41 michael Exp $
13  */
14
15 #ifndef _bcm_robo_h_
16 #define _bcm_robo_h_
17 #include <switch-core.h>
18
19 #define DEVID5325   0x25    /* 5325 (Not really be we fake it) */
20
21 /* Forward declaration */
22 typedef struct robo_info_s robo_info_t;
23
24 /* Device access/config oprands */
25 typedef struct {
26         /* low level routines */
27         void (*enable_mgmtif)(robo_info_t *robo);       /* enable mgmt i/f, optional */
28         void (*disable_mgmtif)(robo_info_t *robo);      /* disable mgmt i/f, optional */
29         int (*write_reg)(robo_info_t *robo, uint8 page, uint8 reg, void *val, int len);
30         int (*read_reg)(robo_info_t *robo, uint8 page, uint8 reg, void *val, int len);
31         /* description */
32         char *desc;
33 } dev_ops_t;
34
35
36 typedef uint16 (*miird_f)(void *h, int add, int off);
37 typedef void (*miiwr_f)(void *h, int add, int off, uint16 val);
38
39 /* Private state per RoboSwitch */
40 struct robo_info_s {
41         sb_t    *sbh;                   /* SiliconBackplane handle */
42         char    *vars;                  /* nvram variables handle */
43         void    *h;                     /* dev handle */
44         uint16  devid;                  /* Device id for the switch */
45         char    *name;                  /* Linux device name */
46         char    macaddr[6];
47
48         dev_ops_t *ops;                 /* device ops */
49         uint8   page;                   /* current page */
50
51         /* SPI */
52         uint32  ss, sck, mosi, miso;    /* GPIO mapping */
53
54         /* MII */
55         miird_f miird;
56         miiwr_f miiwr;
57 };
58
59 extern robo_info_t *bcm_robo_attach(sb_t *sbh, void *h, char *name, char *vars, miird_f miird, miiwr_f miiwr);
60 extern void bcm_robo_detach(robo_info_t *robo);
61 extern int bcm_robo_enable_device(robo_info_t *robo);
62 extern int bcm_robo_config_vlan(robo_info_t *robo, uint8 *mac_addr);
63 extern int bcm_robo_enable_switch(robo_info_t *robo);
64 extern void bcm_robo_set_macaddr(robo_info_t *robo, char *macaddr);
65
66 #ifdef BCMDBG
67 extern void robo_dump_regs(robo_info_t *robo, struct bcmstrbuf *b);
68 #endif /* BCMDBG */
69
70 #endif /* _bcm_robo_h_ */