On 03.09.2010 21:51, Mike Frysinger wrote:
> yes and no.  the spi bus/cs/mode/speed is established at initialize() time,
> not init(), so you'd need to store that per-instance information somewhere.
> and how the discussion about netconsole handling falls out (not calling
> init/halt after every transaction), this base assumption may not be valid.
> -mike

/*
  * This is the only exported function.
  *
  * It may be called several times with different bus:cs combinations.
  */
int enc_initialize(int bus, int cs, int speed)
{
        enc_dev_t *enc;

        enc = malloc(sizeof(*enc));
        if (!enc) {
                return -1;
        }
        memset(enc, 0, sizeof(*enc));
        enc->slave = spi_setup_slave(bus, cs, speed, SPI_MODE_0);
        if (!enc->slave) {
                free(enc);
                return -1;
        }
        enc->netdev.init = enc_init;
        enc->netdev.halt = enc_halt;
        enc->netdev.send = enc_send;
        enc->netdev.recv = enc_recv;
        sprintf(enc->netdev.name, "enc%i.%i", bus, cs);
        eth_register(&(enc->netdev));
        return 0;
}
(not compiled yet)
not sure, however, if calling spi_setup_slave() is ok at this point.

Reinhard
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to