bgmac.h (db791eb2970bad193b1dc95a4461b222dd22cb64) bgmac.h (f6a95a24957aec5bb488c3f978c4ed508177998f)
1#ifndef _BGMAC_H
2#define _BGMAC_H
3
1#ifndef _BGMAC_H
2#define _BGMAC_H
3
4#include <linux/bcma/bcma.h>
5#include <linux/brcmphy.h>
6#include <linux/netdevice.h>
7
8#define BGMAC_DEV_CTL 0x000
9#define BGMAC_DC_TSM 0x00000002
10#define BGMAC_DC_CFCO 0x00000004
11#define BGMAC_DC_RLSS 0x00000008
12#define BGMAC_DC_MROR 0x00000010
13#define BGMAC_DC_FCM_MASK 0x00000060

--- 423 unchanged lines hidden (view full) ---

437
438struct bgmac_rx_header {
439 __le16 len;
440 __le16 flags;
441 __le16 pad[12];
442};
443
444struct bgmac {
4#include <linux/netdevice.h>
5
6#define BGMAC_DEV_CTL 0x000
7#define BGMAC_DC_TSM 0x00000002
8#define BGMAC_DC_CFCO 0x00000004
9#define BGMAC_DC_RLSS 0x00000008
10#define BGMAC_DC_MROR 0x00000010
11#define BGMAC_DC_FCM_MASK 0x00000060

--- 423 unchanged lines hidden (view full) ---

435
436struct bgmac_rx_header {
437 __le16 len;
438 __le16 flags;
439 __le16 pad[12];
440};
441
442struct bgmac {
445 struct bcma_device *core;
446 struct bcma_device *cmn; /* Reference to CMN core for BCM4706 */
443 union {
444 struct {
445 void *base;
446 void *idm_base;
447 } plat;
448 struct {
449 struct bcma_device *core;
450 /* Reference to CMN core for BCM4706 */
451 struct bcma_device *cmn;
452 } bcma;
453 };
447
448 struct device *dev;
449 struct device *dma_dev;
454
455 struct device *dev;
456 struct device *dma_dev;
457 unsigned char mac_addr[ETH_ALEN];
450 u32 feature_flags;
451
452 struct net_device *net_dev;
453 struct napi_struct napi;
454 struct mii_bus *mii_bus;
455
456 /* DMA */
457 struct bgmac_dma_ring tx_ring[BGMAC_MAX_TX_RINGS];
458 struct bgmac_dma_ring rx_ring[BGMAC_MAX_RX_RINGS];
459
460 /* Stats */
461 bool stats_grabbed;
462 u32 mib_tx_regs[BGMAC_NUM_MIB_TX_REGS];
463 u32 mib_rx_regs[BGMAC_NUM_MIB_RX_REGS];
464
465 /* Int */
458 u32 feature_flags;
459
460 struct net_device *net_dev;
461 struct napi_struct napi;
462 struct mii_bus *mii_bus;
463
464 /* DMA */
465 struct bgmac_dma_ring tx_ring[BGMAC_MAX_TX_RINGS];
466 struct bgmac_dma_ring rx_ring[BGMAC_MAX_RX_RINGS];
467
468 /* Stats */
469 bool stats_grabbed;
470 u32 mib_tx_regs[BGMAC_NUM_MIB_TX_REGS];
471 u32 mib_rx_regs[BGMAC_NUM_MIB_RX_REGS];
472
473 /* Int */
474 int irq;
466 u32 int_mask;
467
468 /* Current MAC state */
469 int mac_speed;
470 int mac_duplex;
471
472 u8 phyaddr;
473 bool has_robosw;
474
475 bool loopback;
475 u32 int_mask;
476
477 /* Current MAC state */
478 int mac_speed;
479 int mac_duplex;
480
481 u8 phyaddr;
482 bool has_robosw;
483
484 bool loopback;
485
486 u32 (*read)(struct bgmac *bgmac, u16 offset);
487 void (*write)(struct bgmac *bgmac, u16 offset, u32 value);
488 u32 (*idm_read)(struct bgmac *bgmac, u16 offset);
489 void (*idm_write)(struct bgmac *bgmac, u16 offset, u32 value);
490 bool (*clk_enabled)(struct bgmac *bgmac);
491 void (*clk_enable)(struct bgmac *bgmac, u32 flags);
492 void (*cco_ctl_maskset)(struct bgmac *bgmac, u32 offset, u32 mask,
493 u32 set);
494 u32 (*get_bus_clock)(struct bgmac *bgmac);
495 void (*cmn_maskset32)(struct bgmac *bgmac, u16 offset, u32 mask,
496 u32 set);
476};
477
497};
498
499int bgmac_enet_probe(struct bgmac *info);
500void bgmac_enet_remove(struct bgmac *bgmac);
501
478struct mii_bus *bcma_mdio_mii_register(struct bcma_device *core, u8 phyaddr);
479void bcma_mdio_mii_unregister(struct mii_bus *mii_bus);
480
481static inline u32 bgmac_read(struct bgmac *bgmac, u16 offset)
482{
502struct mii_bus *bcma_mdio_mii_register(struct bcma_device *core, u8 phyaddr);
503void bcma_mdio_mii_unregister(struct mii_bus *mii_bus);
504
505static inline u32 bgmac_read(struct bgmac *bgmac, u16 offset)
506{
483 return bcma_read32(bgmac->core, offset);
507 return bgmac->read(bgmac, offset);
484}
485
486static inline void bgmac_write(struct bgmac *bgmac, u16 offset, u32 value)
487{
508}
509
510static inline void bgmac_write(struct bgmac *bgmac, u16 offset, u32 value)
511{
488 bcma_write32(bgmac->core, offset, value);
512 bgmac->write(bgmac, offset, value);
489}
490
513}
514
515static inline u32 bgmac_idm_read(struct bgmac *bgmac, u16 offset)
516{
517 return bgmac->idm_read(bgmac, offset);
518}
519
520static inline void bgmac_idm_write(struct bgmac *bgmac, u16 offset, u32 value)
521{
522 bgmac->idm_write(bgmac, offset, value);
523}
524
525static inline bool bgmac_clk_enabled(struct bgmac *bgmac)
526{
527 return bgmac->clk_enabled(bgmac);
528}
529
530static inline void bgmac_clk_enable(struct bgmac *bgmac, u32 flags)
531{
532 bgmac->clk_enable(bgmac, flags);
533}
534
535static inline void bgmac_cco_ctl_maskset(struct bgmac *bgmac, u32 offset,
536 u32 mask, u32 set)
537{
538 bgmac->cco_ctl_maskset(bgmac, offset, mask, set);
539}
540
541static inline u32 bgmac_get_bus_clock(struct bgmac *bgmac)
542{
543 return bgmac->get_bus_clock(bgmac);
544}
545
546static inline void bgmac_cmn_maskset32(struct bgmac *bgmac, u16 offset,
547 u32 mask, u32 set)
548{
549 bgmac->cmn_maskset32(bgmac, offset, mask, set);
550}
551
491static inline void bgmac_maskset(struct bgmac *bgmac, u16 offset, u32 mask,
492 u32 set)
493{
494 bgmac_write(bgmac, offset, (bgmac_read(bgmac, offset) & mask) | set);
495}
496
497static inline void bgmac_mask(struct bgmac *bgmac, u16 offset, u32 mask)
498{
499 bgmac_maskset(bgmac, offset, mask, 0);
500}
501
502static inline void bgmac_set(struct bgmac *bgmac, u16 offset, u32 set)
503{
504 bgmac_maskset(bgmac, offset, ~0, set);
505}
506#endif /* _BGMAC_H */
552static inline void bgmac_maskset(struct bgmac *bgmac, u16 offset, u32 mask,
553 u32 set)
554{
555 bgmac_write(bgmac, offset, (bgmac_read(bgmac, offset) & mask) | set);
556}
557
558static inline void bgmac_mask(struct bgmac *bgmac, u16 offset, u32 mask)
559{
560 bgmac_maskset(bgmac, offset, mask, 0);
561}
562
563static inline void bgmac_set(struct bgmac *bgmac, u16 offset, u32 set)
564{
565 bgmac_maskset(bgmac, offset, ~0, set);
566}
567#endif /* _BGMAC_H */