Subject: Re: SiS 630E audio support?
To: Stephen Borrill <netbsd@precedence.co.uk>
From: Jason R Thorpe <thorpej@wasabisystems.com>
List: port-i386
Date: 12/19/2001 19:31:09
--Q59ABw34pTSIagmi
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
On Wed, Dec 19, 2001 at 12:46:07PM +0000, Stephen Borrill wrote:
> Jason, as the original author of if_sip.c, could you have a look at
> PR#14655?
I'm going to commit the following patch. Please verify that it
does the correct thing for you, and I will have it pulled up
into netbsd-1-5.
--
-- Jason R. Thorpe <thorpej@wasabisystems.com>
--Q59ABw34pTSIagmi
Content-Type: text/plain; charset=us-ascii
Content-Description: sis.patch
Content-Disposition: attachment; filename=foo
Index: if_sip.c
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/pci/if_sip.c,v
retrieving revision 1.43
diff -c -r1.43 if_sip.c
*** if_sip.c 2001/11/13 07:48:44 1.43
--- if_sip.c 2001/12/20 03:25:48
***************
*** 388,397 ****
void SIP_DECL(dp83815_set_filter)(struct sip_softc *);
#if defined(DP83820)
! void SIP_DECL(dp83820_read_macaddr)(struct sip_softc *, u_int8_t *);
#else
! void SIP_DECL(sis900_read_macaddr)(struct sip_softc *, u_int8_t *);
! void SIP_DECL(dp83815_read_macaddr)(struct sip_softc *, u_int8_t *);
#endif /* DP83820 */
int SIP_DECL(intr)(void *);
--- 388,400 ----
void SIP_DECL(dp83815_set_filter)(struct sip_softc *);
#if defined(DP83820)
! void SIP_DECL(dp83820_read_macaddr)(struct sip_softc *,
! const struct pci_attach_args *, u_int8_t *);
#else
! void SIP_DECL(sis900_read_macaddr)(struct sip_softc *,
! const struct pci_attach_args *, u_int8_t *);
! void SIP_DECL(dp83815_read_macaddr)(struct sip_softc *,
! const struct pci_attach_args *, u_int8_t *);
#endif /* DP83820 */
int SIP_DECL(intr)(void *);
***************
*** 432,438 ****
void (*sipv_mii_writereg)(struct device *, int, int, int);
void (*sipv_mii_statchg)(struct device *);
void (*sipv_set_filter)(struct sip_softc *);
! void (*sipv_read_macaddr)(struct sip_softc *, u_int8_t *);
};
#if defined(DP83820)
--- 435,442 ----
void (*sipv_mii_writereg)(struct device *, int, int, int);
void (*sipv_mii_statchg)(struct device *);
void (*sipv_set_filter)(struct sip_softc *);
! void (*sipv_read_macaddr)(struct sip_softc *,
! const struct pci_attach_args *, u_int8_t *);
};
#if defined(DP83820)
***************
*** 724,730 ****
* in the softc.
*/
sc->sc_cfg = 0;
! (*sip->sip_variant->sipv_read_macaddr)(sc, enaddr);
printf("%s: Ethernet address %s\n", sc->sc_dev.dv_xname,
ether_sprintf(enaddr));
--- 728,734 ----
* in the softc.
*/
sc->sc_cfg = 0;
! (*sip->sip_variant->sipv_read_macaddr)(sc, pa, enaddr);
printf("%s: Ethernet address %s\n", sc->sc_dev.dv_xname,
ether_sprintf(enaddr));
***************
*** 2934,2940 ****
#if defined(DP83820)
void
! SIP_DECL(dp83820_read_macaddr)(struct sip_softc *sc, u_int8_t *enaddr)
{
u_int16_t eeprom_data[SIP_DP83820_EEPROM_LENGTH / 2];
u_int8_t cksum, *e, match;
--- 2938,2945 ----
#if defined(DP83820)
void
! SIP_DECL(dp83820_read_macaddr)(struct sip_softc *sc,
! const struct pci_attach_args *pa, u_int8_t *enaddr)
{
u_int16_t eeprom_data[SIP_DP83820_EEPROM_LENGTH / 2];
u_int8_t cksum, *e, match;
***************
*** 2978,2989 ****
}
#else /* ! DP83820 */
void
! SIP_DECL(sis900_read_macaddr)(struct sip_softc *sc, u_int8_t *enaddr)
{
u_int16_t myea[ETHER_ADDR_LEN / 2];
! SIP_DECL(read_eeprom)(sc, SIP_EEPROM_ETHERNET_ID0 >> 1,
! sizeof(myea) / sizeof(myea[0]), myea);
enaddr[0] = myea[0] & 0xff;
enaddr[1] = myea[0] >> 8;
--- 2983,3025 ----
}
#else /* ! DP83820 */
void
! SIP_DECL(sis900_read_macaddr)(struct sip_softc *sc,
! const struct pci_attach_args *pa, u_int8_t *enaddr)
{
u_int16_t myea[ETHER_ADDR_LEN / 2];
! switch (PCI_REVISION(pa->pa_class)) {
! case SIS_REV_630S:
! case SIS_REV_630E:
! case SIS_REV_630EA1:
! /*
! * The MAC address for the on-board Ethernet of
! * the SiS 630 chipset is in the NVRAM. Kick
! * the chip into re-loading it from NVRAM, and
! * read the MAC address out of the filter registers.
! */
! bus_space_write_4(sc->sc_st, sc->sc_sh, SIP_CR, CR_RLD);
!
! bus_space_write_4(sc->sc_st, sc->sc_sh, SIP_RFCR,
! RFCR_RFADDR_NODE0);
! myea[0] = bus_space_read_4(sc->sc_st, sc->sc_sh, SIP_RFDR) &
! 0xffff;
!
! bus_space_write_4(sc->sc_st, sc->sc_sh, SIP_RFCR,
! RFCR_RFADDR_NODE2);
! myea[1] = bus_space_read_4(sc->sc_st, sc->sc_sh, SIP_RFDR) &
! 0xffff;
!
! bus_space_write_4(sc->sc_st, sc->sc_sh, SIP_RFCR,
! RFCR_RFADDR_NODE4);
! myea[2] = bus_space_read_4(sc->sc_st, sc->sc_sh, SIP_RFDR) &
! 0xffff;
! break;
!
! default:
! SIP_DECL(read_eeprom)(sc, SIP_EEPROM_ETHERNET_ID0 >> 1,
! sizeof(myea) / sizeof(myea[0]), myea);
! }
enaddr[0] = myea[0] & 0xff;
enaddr[1] = myea[0] >> 8;
***************
*** 2998,3004 ****
#define bbr(v) ((bbr4[(v)&0xf] << 4) | bbr4[((v)>>4) & 0xf])
void
! SIP_DECL(dp83815_read_macaddr)(struct sip_softc *sc, u_int8_t *enaddr)
{
u_int16_t eeprom_data[SIP_DP83815_EEPROM_LENGTH / 2], *ea;
u_int8_t cksum, *e, match;
--- 3034,3041 ----
#define bbr(v) ((bbr4[(v)&0xf] << 4) | bbr4[((v)>>4) & 0xf])
void
! SIP_DECL(dp83815_read_macaddr)(struct sip_softc *sc,
! const struct pci_attach_args *pa, u_int8_t *enaddr)
{
u_int16_t eeprom_data[SIP_DP83815_EEPROM_LENGTH / 2], *ea;
u_int8_t cksum, *e, match;
Index: if_sipreg.h
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/pci/if_sipreg.h,v
retrieving revision 1.7
diff -c -r1.7 if_sipreg.h
*** if_sipreg.h 2001/05/18 02:03:54 1.7
--- if_sipreg.h 2001/12/20 03:25:52
***************
*** 204,209 ****
--- 204,210 ----
#define CR_TXPRI1 0x00000400 /* Tx priority queue select */
#define CR_TXPRI0 0x00000200 /* Tx priority queue select */
#endif /* DP83820 */
+ #define CR_RLD 0x00000400 /* reload from NVRAM */
#define CR_RST 0x00000100 /* software reset */
#define CR_SWI 0x00000080 /* software interrupt */
#define CR_RXR 0x00000020 /* receiver reset */
***************
*** 686,691 ****
--- 687,699 ----
#define SIP_WAKEMASK6 0xe8
#define SIP_WAKEMASK7 0xec
#endif /* DP83820 */
+
+ /*
+ * Revision codes for the SiS 630 chipset built-in Ethernet.
+ */
+ #define SIS_REV_630E 0x81
+ #define SIS_REV_630S 0x82
+ #define SIS_REV_630EA1 0x83
/*
* Serial EEPROM opcodes, including the start bit.
--Q59ABw34pTSIagmi--