get rid of $Id$ - it has never helped us and it has broken too many patches ;)
[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  */
13
14 #ifndef _bcm_robo_h_
15 #define _bcm_robo_h_
16 #include <switch-core.h>
17
18 #define DEVID5325   0x25    /* 5325 (Not really be we fake it) */
19
20 /* Forward declaration */
21 typedef struct robo_info_s robo_info_t;
22
23 /* Device access/config oprands */
24 typedef struct {
25         /* low level routines */
26         void (*enable_mgmtif)(robo_info_t *robo);       /* enable mgmt i/f, optional */
27         void (*disable_mgmtif)(robo_info_t *robo);      /* disable mgmt i/f, optional */
28         int (*write_reg)(robo_info_t *robo, uint8 page, uint8 reg, void *val, int len);
29         int (*read_reg)(robo_info_t *robo, uint8 page, uint8 reg, void *val, int len);
30         /* description */
31         char *desc;
32 } dev_ops_t;
33
34
35 typedef uint16 (*miird_f)(void *h, int add, int off);
36 typedef void (*miiwr_f)(void *h, int add, int off, uint16 val);
37
38 /* Private state per RoboSwitch */
39 struct robo_info_s {
40         sb_t    *sbh;                   /* SiliconBackplane handle */
41         char    *vars;                  /* nvram variables handle */
42         void    *h;                     /* dev handle */
43         uint16  devid;                  /* Device id for the switch */
44         char    *name;                  /* Linux device name */
45         char    macaddr[6];
46
47         dev_ops_t *ops;                 /* device ops */
48         uint8   page;                   /* current page */
49
50         /* SPI */
51         uint32  ss, sck, mosi, miso;    /* GPIO mapping */
52
53         /* MII */
54         miird_f miird;
55         miiwr_f miiwr;
56 };
57
58 extern robo_info_t *bcm_robo_attach(sb_t *sbh, void *h, char *name, char *vars, miird_f miird, miiwr_f miiwr);
59 extern void bcm_robo_detach(robo_info_t *robo);
60 extern int bcm_robo_enable_device(robo_info_t *robo);
61 extern int bcm_robo_config_vlan(robo_info_t *robo, uint8 *mac_addr);
62 extern int bcm_robo_enable_switch(robo_info_t *robo);
63 extern void bcm_robo_set_macaddr(robo_info_t *robo, char *macaddr);
64
65 #ifdef BCMDBG
66 extern void robo_dump_regs(robo_info_t *robo, struct bcmstrbuf *b);
67 #endif /* BCMDBG */
68
69 #endif /* _bcm_robo_h_ */