2 * HND SiliconBackplane Gigabit Ethernet core software interface
4 * Copyright 2007, Broadcom Corporation
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.
26 * Setup the gige core.
27 * Resetting the core will lose all settings.
30 sb_gige_init(sb_t
*sbh
, uint32 unit
, bool *rgmii
)
32 volatile pci_config_regs
*pci
;
33 sbgige_pcishim_t
*ocp
;
46 idx
= sb_coreidx(sbh
);
48 /* point to the gige core registers */
49 regs
= sb_setcore(sbh
, SB_GIGETH
, unit
);
54 pci
= &((sbgige_t
*)regs
)->pcicfg
;
55 ocp
= &((sbgige_t
*)regs
)->pcishim
;
56 sb
= &((sbgige_t
*)regs
)->sbconfig
;
58 /* Enable the core clock and memory access */
59 if (!sb_iscoreup(sbh
))
60 sb_core_reset(sbh
, 0, 0);
63 * Setup the 64K memory-mapped region base address through BAR0.
64 * Leave the other BAR values alone.
66 base
= sb_base(R_REG(osh
, &sb
->sbadmatch1
));
67 W_REG(osh
, &pci
->base
[0], base
);
68 W_REG(osh
, &pci
->base
[1], 0);
71 * Enable the PCI memory access anyway. Any PCI config commands
72 * issued before the core is enabled will go to the emulation
73 * only and will not go to the real PCI config registers.
75 OR_REG(osh
, &pci
->command
, 2);
78 * Enable the posted write flush scheme as follows:
80 * - Enable flush on any core register read
81 * - Enable timeout on the flush
82 * - Disable the interrupt mask when flushing
84 * This differs from the default setting only in that interrupts are
85 * not masked. Since posted writes are not flushed on interrupt, the
86 * driver must explicitly request a flush in its interrupt handling
87 * by reading a core register.
89 W_REG(osh
, &ocp
->FlushStatusControl
, 0x68);
92 * Determine whether the GbE is in GMII or RGMII mode. This is
93 * indicated in bit 16 of the SBTMStateHigh register, which is
94 * part of the core-specific flags field.
96 * For GMII, bypass the Rx/Tx DLLs, i.e. add no delay to RXC/GTXC
97 * within the core. For RGMII, do not bypass the DLLs, resulting
98 * in added delay for RXC/GTXC. The SBTMStateLow register contains
99 * the controls for doing this in the core-specific flags field:
101 * bit 24 - Enable DLL controls
102 * bit 20 - Bypass Rx DLL
103 * bit 19 - Bypass Tx DLL
105 statelow
= R_REG(osh
, &sb
->sbtmstatelow
); /* DLL controls */
106 statehigh
= R_REG(osh
, &sb
->sbtmstatehigh
); /* GMII/RGMII mode */
107 if ((statehigh
& (1 << 16)) != 0) /* RGMII */
109 statelow
&= ~(1 << 20); /* no Rx bypass (delay) */
110 statelow
&= ~(1 << 19); /* no Tx bypass (delay) */
115 statelow
|= (1 << 20); /* Rx bypass (no delay) */
116 statelow
|= (1 << 19); /* Tx bypass (no delay) */
119 statelow
|= (1 << 24); /* enable DLL controls */
120 W_REG(osh
, &sb
->sbtmstatelow
, statelow
);
122 sb_setcoreidx(sbh
, idx
);