Ejemplo n.º 1
0
static void
cpsw_attach(device_t parent, device_t self, void *aux)
{
	struct obio_attach_args * const oa = aux;
	struct cpsw_softc * const sc = device_private(self);
	prop_dictionary_t dict = device_properties(self);
	struct ethercom * const ec = &sc->sc_ec;
	struct ifnet * const ifp = &ec->ec_if;
	int error;
	u_int i;

	KERNHIST_INIT(cpswhist, 4096);

	sc->sc_dev = self;

	aprint_normal(": TI CPSW Ethernet\n");
	aprint_naive("\n");

	callout_init(&sc->sc_tick_ch, 0);
	callout_setfunc(&sc->sc_tick_ch, cpsw_tick, sc);

	prop_data_t eaprop = prop_dictionary_get(dict, "mac-address");
	if (eaprop == NULL) {
		/* grab mac_id0 from AM335x control module */
		uint32_t reg_lo, reg_hi;

		if (sitara_cm_reg_read_4(OMAP2SCM_MAC_ID0_LO, &reg_lo) == 0 &&
		    sitara_cm_reg_read_4(OMAP2SCM_MAC_ID0_HI, &reg_hi) == 0) {
			sc->sc_enaddr[0] = (reg_hi >>  0) & 0xff;
			sc->sc_enaddr[1] = (reg_hi >>  8) & 0xff;
			sc->sc_enaddr[2] = (reg_hi >> 16) & 0xff;
			sc->sc_enaddr[3] = (reg_hi >> 24) & 0xff;
			sc->sc_enaddr[4] = (reg_lo >>  0) & 0xff;
			sc->sc_enaddr[5] = (reg_lo >>  8) & 0xff;
		} else {
Ejemplo n.º 2
0
static void
sitara_cm_attach(device_t parent, device_t self, void *opaque)
{
	struct sitara_cm_softc *sc = device_private(self);
	struct obio_attach_args *obio = opaque;
	uint32_t rev;

	aprint_naive("\n");

	if (sitara_cm_sc)
		panic("sitara_cm_attach: already attached");

	sc->sc_dev = self;
	sc->sc_iot = obio->obio_iot;

	if (bus_space_map(obio->obio_iot, obio->obio_addr, obio->obio_size,
	    0, &sc->sc_ioh) != 0) {
		aprint_error(": couldn't map address space\n");
		return ;
	}

	sitara_cm_sc = sc;

	if (sitara_cm_reg_read_4(OMAP2SCM_REVISION, &rev) != 0)
		panic("sitara_cm_attach: read revision");
	aprint_normal(": control module, rev %d.%d\n",
	    SCM_REVISION_MAJOR(rev), SCM_REVISION_MINOR(rev));
}
Ejemplo n.º 3
0
void
cpsw_get_mac_addr(struct cpsw_softc *sc)
{
	struct arpcom *ac = &sc->sc_ac;
	u_int32_t	mac_lo = 0, mac_hi = 0;

	sitara_cm_reg_read_4(OMAP2SCM_MAC_ID0_LO, &mac_lo);
	sitara_cm_reg_read_4(OMAP2SCM_MAC_ID0_HI, &mac_hi);

	if ((mac_lo == 0) && (mac_hi == 0))
		printf("%s: invalid ethernet address\n", DEVNAME(sc));
	else {
		ac->ac_enaddr[0] = (mac_hi >>  0) & 0xff;
		ac->ac_enaddr[1] = (mac_hi >>  8) & 0xff;
		ac->ac_enaddr[2] = (mac_hi >> 16) & 0xff;
		ac->ac_enaddr[3] = (mac_hi >> 24) & 0xff;
		ac->ac_enaddr[4] = (mac_lo >>  0) & 0xff;
		ac->ac_enaddr[5] = (mac_lo >>  8) & 0xff;
	}
}
Ejemplo n.º 4
0
void
sitara_cm_attach(struct device *parent, struct device *self, void *aux)
{
	struct sitara_cm_softc *sc = (struct sitara_cm_softc *)self;
	struct omap_attach_args *oa = aux;
	uint32_t rev;

	if (sitara_cm_sc)
		panic("sitara_cm_attach: already attached");

	sc->sc_iot = oa->oa_iot;

	if (bus_space_map(oa->oa_iot, oa->oa_dev->mem[0].addr,
	    oa->oa_dev->mem[0].size, 0, &sc->sc_ioh) != 0)
		panic("%s: bus_space_map failed!\n", __func__);

	sitara_cm_sc = sc;

	if (sitara_cm_reg_read_4(OMAP2SCM_REVISION, &rev) != 0)
		panic("sitara_cm_attach: read revision");
	printf(": control module, rev %d.%d\n",
	    SCM_REVISION_MAJOR(rev), SCM_REVISION_MINOR(rev));
}