diff options
Diffstat (limited to 'drivers')
34 files changed, 210 insertions, 228 deletions
diff --git a/drivers/bios_emulator/Makefile b/drivers/bios_emulator/Makefile index feba4da758..d94a144292 100644 --- a/drivers/bios_emulator/Makefile +++ b/drivers/bios_emulator/Makefile @@ -1,6 +1,6 @@ include $(TOPDIR)/config.mk -LIB := $(obj)libatibiosemu.a +LIB := $(obj)libatibiosemu.o X86DIR = x86emu @@ -28,7 +28,7 @@ CPPFLAGS += $(EXTRA_CFLAGS) all: $(LIB) $(LIB): $(obj).depend $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) + $(call cmd_link_o_target, $(OBJS)) ######################################################################### diff --git a/drivers/block/Makefile b/drivers/block/Makefile index 64dcf4e245..e27175bb4b 100644 --- a/drivers/block/Makefile +++ b/drivers/block/Makefile @@ -23,7 +23,7 @@ include $(TOPDIR)/config.mk -LIB := $(obj)libblock.a +LIB := $(obj)libblock.o COBJS-$(CONFIG_SCSI_AHCI) += ahci.o COBJS-$(CONFIG_ATA_PIIX) += ata_piix.o @@ -45,7 +45,7 @@ OBJS := $(addprefix $(obj),$(COBJS)) all: $(LIB) $(LIB): $(obj).depend $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) + $(call cmd_link_o_target, $(OBJS)) ######################################################################### diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile index 36d99f9b11..9d945a042a 100644 --- a/drivers/dma/Makefile +++ b/drivers/dma/Makefile @@ -23,7 +23,7 @@ include $(TOPDIR)/config.mk -LIB := $(obj)libdma.a +LIB := $(obj)libdma.o COBJS-$(CONFIG_FSLDMAFEC) += MCD_tasksInit.o MCD_dmaApi.o MCD_tasks.o COBJS-$(CONFIG_FSL_DMA) += fsl_dma.o @@ -35,7 +35,7 @@ OBJS := $(addprefix $(obj),$(COBJS)) all: $(LIB) $(LIB): $(obj).depend $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) + $(call cmd_link_o_target, $(OBJS)) ######################################################################### diff --git a/drivers/fpga/Makefile b/drivers/fpga/Makefile index 9ecdc5ef10..b48f623c18 100644 --- a/drivers/fpga/Makefile +++ b/drivers/fpga/Makefile @@ -23,7 +23,7 @@ include $(TOPDIR)/config.mk -LIB := $(obj)libfpga.a +LIB := $(obj)libfpga.o ifdef CONFIG_FPGA COBJS-y += fpga.o @@ -47,7 +47,7 @@ OBJS := $(addprefix $(obj),$(COBJS)) all: $(LIB) $(LIB): $(obj).depend $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) + $(call cmd_link_o_target, $(OBJS)) ######################################################################### diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index a0f455223b..398024c7bc 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -23,7 +23,7 @@ include $(TOPDIR)/config.mk -LIB := $(obj)libgpio.a +LIB := $(obj)libgpio.o COBJS-$(CONFIG_AT91_GPIO) += at91_gpio.o COBJS-$(CONFIG_KIRKWOOD_GPIO) += kw_gpio.o @@ -38,7 +38,7 @@ OBJS := $(addprefix $(obj),$(COBJS)) all: $(LIB) $(LIB): $(obj).depend $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) + $(call cmd_link_o_target, $(OBJS)) ######################################################################### diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 59302fa4d2..f04cd6983e 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -28,7 +28,7 @@ include $(TOPDIR)/config.mk #CFLAGS += -DDEBUG -LIB = $(obj)libhwmon.a +LIB = $(obj)libhwmon.o COBJS-$(CONFIG_DTT_ADM1021) += adm1021.o COBJS-$(CONFIG_DTT_ADT7460) += adt7460.o @@ -47,7 +47,7 @@ OBJS := $(addprefix $(obj),$(COBJS)) all: $(LIB) $(LIB): $(obj).depend $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) + $(call cmd_link_o_target, $(OBJS)) ######################################################################### diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile index 8921ff914e..052fe360c0 100644 --- a/drivers/i2c/Makefile +++ b/drivers/i2c/Makefile @@ -23,7 +23,7 @@ include $(TOPDIR)/config.mk -LIB := $(obj)libi2c.a +LIB := $(obj)libi2c.o COBJS-$(CONFIG_BFIN_TWI_I2C) += bfin-twi_i2c.o COBJS-$(CONFIG_DRIVER_DAVINCI_I2C) += davinci_i2c.o @@ -48,7 +48,7 @@ OBJS := $(addprefix $(obj),$(COBJS)) all: $(LIB) $(LIB): $(obj).depend $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) + $(call cmd_link_o_target, $(OBJS)) ######################################################################### diff --git a/drivers/input/Makefile b/drivers/input/Makefile index 9a14407399..1f4dad35b5 100644 --- a/drivers/input/Makefile +++ b/drivers/input/Makefile @@ -23,7 +23,7 @@ include $(TOPDIR)/config.mk -LIB := $(obj)libinput.a +LIB := $(obj)libinput.o COBJS-$(CONFIG_I8042_KBD) += i8042.o ifdef CONFIG_PS2KBD @@ -38,7 +38,7 @@ OBJS := $(addprefix $(obj),$(COBJS)) all: $(LIB) $(LIB): $(obj).depend $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) + $(call cmd_link_o_target, $(OBJS)) ######################################################################### diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 5d668f8222..a76bd4e58a 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -23,7 +23,7 @@ include $(TOPDIR)/config.mk -LIB := $(obj)libmisc.a +LIB := $(obj)libmisc.o COBJS-$(CONFIG_ALI152X) += ali512x.o COBJS-$(CONFIG_DS4510) += ds4510.o @@ -42,7 +42,7 @@ OBJS := $(addprefix $(obj),$(COBJS)) all: $(LIB) $(LIB): $(obj).depend $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) + $(call cmd_link_o_target, $(OBJS)) ######################################################################### diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile index 2ead634486..68afd30ef0 100644 --- a/drivers/mmc/Makefile +++ b/drivers/mmc/Makefile @@ -23,7 +23,7 @@ include $(TOPDIR)/config.mk -LIB := $(obj)libmmc.a +LIB := $(obj)libmmc.o COBJS-$(CONFIG_ATMEL_MCI) += atmel_mci.o COBJS-$(CONFIG_BFIN_SDH) += bfin_sdh.o @@ -43,7 +43,7 @@ OBJS := $(addprefix $(obj),$(COBJS)) all: $(LIB) $(LIB): $(obj).depend $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) + $(call cmd_link_o_target, $(OBJS)) ######################################################################### diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index eb7bfb39e9..6805b33f7a 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -82,12 +82,9 @@ mmc_write_blocks(struct mmc *mmc, ulong start, lbaint_t blkcnt, const void*src) { struct mmc_cmd cmd; struct mmc_data data; - int blklen, err; - - blklen = mmc->write_bl_len; if ((start + blkcnt) > mmc->block_dev.lba) { - printf("MMC: block number 0x%lx exceeds max(0x%lx)", + printf("MMC: block number 0x%lx exceeds max(0x%lx)\n", start + blkcnt, mmc->block_dev.lba); return 0; } @@ -100,21 +97,19 @@ mmc_write_blocks(struct mmc *mmc, ulong start, lbaint_t blkcnt, const void*src) if (mmc->high_capacity) cmd.cmdarg = start; else - cmd.cmdarg = start * blklen; + cmd.cmdarg = start * mmc->write_bl_len; cmd.resp_type = MMC_RSP_R1; cmd.flags = 0; data.src = src; data.blocks = blkcnt; - data.blocksize = blklen; + data.blocksize = mmc->write_bl_len; data.flags = MMC_DATA_WRITE; - err = mmc_send_cmd(mmc, &cmd, &data); - - if (err) { - printf("mmc write failed\n\r"); - return err; + if (mmc_send_cmd(mmc, &cmd, &data)) { + printf("mmc write failed\n"); + return 0; } if (blkcnt > 1) { @@ -122,10 +117,9 @@ mmc_write_blocks(struct mmc *mmc, ulong start, lbaint_t blkcnt, const void*src) cmd.cmdarg = 0; cmd.resp_type = MMC_RSP_R1b; cmd.flags = 0; - err = mmc_send_cmd(mmc, &cmd, NULL); - if (err) { - printf("mmc fail to send stop cmd\n\r"); - return err; + if (mmc_send_cmd(mmc, &cmd, NULL)) { + printf("mmc fail to send stop cmd\n"); + return 0; } } @@ -135,18 +129,14 @@ mmc_write_blocks(struct mmc *mmc, ulong start, lbaint_t blkcnt, const void*src) static ulong mmc_bwrite(int dev_num, ulong start, lbaint_t blkcnt, const void*src) { - int err; - struct mmc *mmc = find_mmc_device(dev_num); lbaint_t cur, blocks_todo = blkcnt; + struct mmc *mmc = find_mmc_device(dev_num); if (!mmc) - return -1; + return 0; - err = mmc_set_blocklen(mmc, mmc->write_bl_len); - if (err) { - printf("set write bl len failed\n\r"); - return err; - } + if (mmc_set_blocklen(mmc, mmc->write_bl_len)) + return 0; do { /* @@ -155,7 +145,7 @@ mmc_bwrite(int dev_num, ulong start, lbaint_t blkcnt, const void*src) */ cur = (blocks_todo > 65535) ? 65535 : blocks_todo; if(mmc_write_blocks(mmc, start, cur, src) != cur) - return -1; + return 0; blocks_todo -= cur; start += cur; src += cur * mmc->write_bl_len; @@ -164,110 +154,78 @@ mmc_bwrite(int dev_num, ulong start, lbaint_t blkcnt, const void*src) return blkcnt; } -int mmc_read_block(struct mmc *mmc, void *dst, uint blocknum) +int mmc_read_blocks(struct mmc *mmc, void *dst, ulong start, lbaint_t blkcnt) { struct mmc_cmd cmd; struct mmc_data data; - cmd.cmdidx = MMC_CMD_READ_SINGLE_BLOCK; + if (blkcnt > 1) + cmd.cmdidx = MMC_CMD_READ_MULTIPLE_BLOCK; + else + cmd.cmdidx = MMC_CMD_READ_SINGLE_BLOCK; if (mmc->high_capacity) - cmd.cmdarg = blocknum; + cmd.cmdarg = start; else - cmd.cmdarg = blocknum * mmc->read_bl_len; + cmd.cmdarg = start * mmc->read_bl_len; cmd.resp_type = MMC_RSP_R1; cmd.flags = 0; data.dest = dst; - data.blocks = 1; + data.blocks = blkcnt; data.blocksize = mmc->read_bl_len; data.flags = MMC_DATA_READ; - return mmc_send_cmd(mmc, &cmd, &data); -} - -int mmc_read(struct mmc *mmc, u64 src, uchar *dst, int size) -{ - char *buffer; - int i; - int blklen = mmc->read_bl_len; - int startblock = lldiv(src, mmc->read_bl_len); - int endblock = lldiv(src + size - 1, mmc->read_bl_len); - int err = 0; - - /* Make a buffer big enough to hold all the blocks we might read */ - buffer = malloc(blklen); - - if (!buffer) { - printf("Could not allocate buffer for MMC read!\n"); - return -1; - } - - /* We always do full block reads from the card */ - err = mmc_set_blocklen(mmc, mmc->read_bl_len); - - if (err) - goto free_buffer; - - for (i = startblock; i <= endblock; i++) { - int segment_size; - int offset; - - err = mmc_read_block(mmc, buffer, i); - - if (err) - goto free_buffer; - - /* - * The first block may not be aligned, so we - * copy from the desired point in the block - */ - offset = (src & (blklen - 1)); - segment_size = MIN(blklen - offset, size); - - memcpy(dst, buffer + offset, segment_size); + if (mmc_send_cmd(mmc, &cmd, &data)) + return 0; - dst += segment_size; - src += segment_size; - size -= segment_size; + if (blkcnt > 1) { + cmd.cmdidx = MMC_CMD_STOP_TRANSMISSION; + cmd.cmdarg = 0; + cmd.resp_type = MMC_RSP_R1b; + cmd.flags = 0; + if (mmc_send_cmd(mmc, &cmd, NULL)) { + printf("mmc fail to send stop cmd\n"); + return 0; + } } -free_buffer: - free(buffer); - - return err; + return blkcnt; } static ulong mmc_bread(int dev_num, ulong start, lbaint_t blkcnt, void *dst) { - int err; - int i; - struct mmc *mmc = find_mmc_device(dev_num); + lbaint_t cur, blocks_todo = blkcnt; + + if (blkcnt == 0) + return 0; + struct mmc *mmc = find_mmc_device(dev_num); if (!mmc) return 0; if ((start + blkcnt) > mmc->block_dev.lba) { - printf("MMC: block number 0x%lx exceeds max(0x%lx)", + printf("MMC: block number 0x%lx exceeds max(0x%lx)\n", start + blkcnt, mmc->block_dev.lba); return 0; } - /* We always do full block reads from the card */ - err = mmc_set_blocklen(mmc, mmc->read_bl_len); - if (err) { + if (mmc_set_blocklen(mmc, mmc->read_bl_len)) return 0; - } - - for (i = start; i < start + blkcnt; i++, dst += mmc->read_bl_len) { - err = mmc_read_block(mmc, dst, i); - if (err) { - printf("block read failed: %d\n", err); - return i - start; - } - } + do { + /* + * The 65535 constraint comes from some hardware has + * only 16 bit width block number counter + */ + cur = (blocks_todo > 65535) ? 65535 : blocks_todo; + if(mmc_read_blocks(mmc, dst, start, cur) != cur) + return 0; + blocks_todo -= cur; + start += cur; + dst += cur * mmc->read_bl_len; + } while (blocks_todo > 0); return blkcnt; } diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile index cbf6f156b4..999431c3c0 100644 --- a/drivers/mtd/Makefile +++ b/drivers/mtd/Makefile @@ -23,7 +23,7 @@ include $(TOPDIR)/config.mk -LIB := $(obj)libmtd.a +LIB := $(obj)libmtd.o COBJS-$(CONFIG_MTD_DEVICE) += mtdcore.o COBJS-$(CONFIG_MTD_PARTITIONS) += mtdpart.o @@ -43,7 +43,7 @@ OBJS := $(addprefix $(obj),$(COBJS)) all: $(LIB) $(LIB): $(obj).depend $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) + $(call cmd_link_o_target, $(OBJS)) ######################################################################### diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile index 28f27da7a7..8b598f6bfe 100644 --- a/drivers/mtd/nand/Makefile +++ b/drivers/mtd/nand/Makefile @@ -23,7 +23,7 @@ include $(TOPDIR)/config.mk -LIB := $(obj)libnand.a +LIB := $(obj)libnand.o ifdef CONFIG_CMD_NAND COBJS-y += nand.o @@ -59,7 +59,7 @@ OBJS := $(addprefix $(obj),$(COBJS)) all: $(LIB) $(LIB): $(obj).depend $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) + $(call cmd_link_o_target, $(OBJS)) ######################################################################### diff --git a/drivers/mtd/onenand/Makefile b/drivers/mtd/onenand/Makefile index 2571df0163..b984bd4a2b 100644 --- a/drivers/mtd/onenand/Makefile +++ b/drivers/mtd/onenand/Makefile @@ -23,7 +23,7 @@ include $(TOPDIR)/config.mk -LIB := $(obj)libonenand.a +LIB := $(obj)libonenand.o COBJS-$(CONFIG_CMD_ONENAND) := onenand_uboot.o onenand_base.o onenand_bbt.o COBJS-$(CONFIG_SAMSUNG_ONENAND) += samsung.o @@ -35,7 +35,7 @@ OBJS := $(addprefix $(obj),$(COBJS)) all: $(LIB) $(LIB): $(obj).depend $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) + $(call cmd_link_o_target, $(OBJS)) ######################################################################### diff --git a/drivers/mtd/spi/Makefile b/drivers/mtd/spi/Makefile index a082ca7d53..3d607c06d3 100644 --- a/drivers/mtd/spi/Makefile +++ b/drivers/mtd/spi/Makefile @@ -23,7 +23,7 @@ include $(TOPDIR)/config.mk -LIB := $(obj)libspi_flash.a +LIB := $(obj)libspi_flash.o COBJS-$(CONFIG_SPI_FLASH) += spi_flash.o COBJS-$(CONFIG_SPI_FLASH_ATMEL) += atmel.o @@ -42,7 +42,7 @@ OBJS := $(addprefix $(obj),$(COBJS)) all: $(LIB) $(LIB): $(obj).depend $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) + $(call cmd_link_o_target, $(OBJS)) ######################################################################### diff --git a/drivers/mtd/ubi/Makefile b/drivers/mtd/ubi/Makefile index 8bd82c353d..b2e601439d 100644 --- a/drivers/mtd/ubi/Makefile +++ b/drivers/mtd/ubi/Makefile @@ -23,7 +23,7 @@ include $(TOPDIR)/config.mk -LIB := $(obj)libubi.a +LIB := $(obj)libubi.o ifdef CONFIG_CMD_UBI COBJS-y += build.o vtbl.o vmt.o upd.o kapi.o eba.o io.o wl.o scan.o crc32.o @@ -39,7 +39,7 @@ OBJS := $(addprefix $(obj),$(COBJS)) all: $(LIB) $(LIB): $(obj).depend $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) + $(call cmd_link_o_target, $(OBJS)) ######################################################################### diff --git a/drivers/net/Makefile b/drivers/net/Makefile index 79eb66b267..5393955879 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile @@ -23,7 +23,7 @@ include $(TOPDIR)/config.mk -LIB := $(obj)libnet.a +LIB := $(obj)libnet.o COBJS-$(CONFIG_DRIVER_3C589) += 3c589.o COBJS-$(CONFIG_PPC4xx_EMAC) += 4xx_enet.o @@ -87,7 +87,7 @@ OBJS := $(addprefix $(obj),$(COBJS)) all: $(LIB) $(LIB): $(obj).depend $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) + $(call cmd_link_o_target, $(OBJS)) ######################################################################### diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c index 18584efdd5..60b04c267c 100644 --- a/drivers/net/e1000.c +++ b/drivers/net/e1000.c @@ -5189,7 +5189,7 @@ e1000_initialize(bd_t * bis) return 0; } - memset(nic, 0, sizeof(*dev)); + memset(nic, 0, sizeof(*nic)); memset(hw, 0, sizeof(*hw)); hw->pdev = devno; diff --git a/drivers/net/greth.c b/drivers/net/greth.c index 79bc4d9d26..6c32226946 100644 --- a/drivers/net/greth.c +++ b/drivers/net/greth.c @@ -24,6 +24,8 @@ * MA 02111-1307 USA */ +/* #define DEBUG */ + #include <common.h> #include <command.h> #include <net.h> @@ -33,8 +35,6 @@ #include <ambapp.h> #include <asm/leon.h> -/* #define DEBUG */ - #include "greth.h" /* Default to 3s timeout on autonegotiation */ @@ -42,10 +42,17 @@ #define GRETH_PHY_TIMEOUT_MS 3000 #endif +/* Default to PHY adrress 0 not not specified */ +#ifdef CONFIG_SYS_GRLIB_GRETH_PHYADDR +#define GRETH_PHY_ADR_DEFAULT CONFIG_SYS_GRLIB_GRETH_PHYADDR +#else +#define GRETH_PHY_ADR_DEFAULT 0 +#endif + /* ByPass Cache when reading regs */ #define GRETH_REGLOAD(addr) SPARC_NOCACHE_READ(addr) /* Write-through cache ==> no bypassing needed on writes */ -#define GRETH_REGSAVE(addr,data) (*(unsigned int *)(addr) = (data)) +#define GRETH_REGSAVE(addr,data) (*(volatile unsigned int *)(addr) = (data)) #define GRETH_REGORIN(addr,data) GRETH_REGSAVE(addr,GRETH_REGLOAD(addr)|data) #define GRETH_REGANDIN(addr,data) GRETH_REGSAVE(addr,GRETH_REGLOAD(addr)&data) @@ -102,12 +109,12 @@ typedef struct { } greth_priv; /* Read MII register 'addr' from core 'regs' */ -static int read_mii(int addr, volatile greth_regs * regs) +static int read_mii(int phyaddr, int regaddr, volatile greth_regs * regs) { while (GRETH_REGLOAD(®s->mdio) & GRETH_MII_BUSY) { } - GRETH_REGSAVE(®s->mdio, (0 << 11) | ((addr & 0x1F) << 6) | 2); + GRETH_REGSAVE(®s->mdio, ((phyaddr & 0x1F) << 11) | ((regaddr & 0x1F) << 6) | 2); while (GRETH_REGLOAD(®s->mdio) & GRETH_MII_BUSY) { } @@ -119,14 +126,14 @@ static int read_mii(int addr, volatile greth_regs * regs) } } -static void write_mii(int addr, int data, volatile greth_regs * regs) +static void write_mii(int phyaddr, int regaddr, int data, volatile greth_regs * regs) { while (GRETH_REGLOAD(®s->mdio) & GRETH_MII_BUSY) { } GRETH_REGSAVE(®s->mdio, - ((data & 0xFFFF) << 16) | (0 << 11) | ((addr & 0x1F) << 6) - | 1); + ((data & 0xFFFF) << 16) | ((phyaddr & 0x1F) << 11) | + ((regaddr & 0x1F) << 6) | 1); while (GRETH_REGLOAD(®s->mdio) & GRETH_MII_BUSY) { } @@ -142,11 +149,18 @@ int greth_init(struct eth_device *dev, bd_t * bis) greth_priv *greth = dev->priv; greth_regs *regs = greth->regs; -#ifdef DEBUG - printf("greth_init\n"); -#endif - GRETH_REGSAVE(®s->control, 0); + debug("greth_init\n"); + + /* Reset core */ + GRETH_REGSAVE(®s->control, (GRETH_RESET | (greth->gb << 8) | + (greth->sp << 7) | (greth->fd << 4))); + + /* Wait for Reset to complete */ + while ( GRETH_REGLOAD(®s->control) & GRETH_RESET) ; + + GRETH_REGSAVE(®s->control, + ((greth->gb << 8) | (greth->sp << 7) | (greth->fd << 4))); if (!greth->rxbd_base) { @@ -154,7 +168,7 @@ int greth_init(struct eth_device *dev, bd_t * bis) greth->rxbd_base = (greth_bd *) memalign(0x1000, GRETH_RXBD_CNT * sizeof(greth_bd)); greth->txbd_base = (greth_bd *) - memalign(0x1000, GRETH_RXBD_CNT * sizeof(greth_bd)); + memalign(0x1000, GRETH_TXBD_CNT * sizeof(greth_bd)); /* allocate buffers to all descriptors */ greth->rxbuf_base = @@ -186,7 +200,7 @@ int greth_init(struct eth_device *dev, bd_t * bis) for (i = 0; i < GRETH_TXBD_CNT; i++) { greth->txbd_base[i].addr = 0; /* enable desciptor & set wrap bit if last descriptor */ - if (i >= (GRETH_RXBD_CNT - 1)) { + if (i >= (GRETH_TXBD_CNT - 1)) { greth->txbd_base[i].stat = GRETH_BD_WR; } else { greth->txbd_base[i].stat = 0; @@ -201,9 +215,7 @@ int greth_init(struct eth_device *dev, bd_t * bis) /* Enable Transmitter, GRETH will now scan descriptors for packets * to transmitt */ -#ifdef DEBUG - printf("greth_init: enabling receiver\n"); -#endif + debug("greth_init: enabling receiver\n"); GRETH_REGORIN(®s->control, GRETH_RXEN); return 0; @@ -219,6 +231,26 @@ int greth_init_phy(greth_priv * dev, bd_t * bis) greth_regs *regs = dev->regs; int tmp, tmp1, tmp2, i; unsigned int start, timeout; + int phyaddr = GRETH_PHY_ADR_DEFAULT; + +#ifndef CONFIG_SYS_GRLIB_GRETH_PHYADDR + /* If BSP doesn't provide a hardcoded PHY address the driver will + * try to autodetect PHY address by stopping the search on the first + * PHY address which has REG0 implemented. + */ + for (i=0; i<32; i++) { + tmp = read_mii(i, 0, regs); + if ( (tmp != 0) && (tmp != 0xffff) ) { + phyaddr = i; + break; + } + } +#endif + + /* Save PHY Address */ + dev->phyaddr = phyaddr; + + debug("GRETH PHY ADDRESS: %d\n", phyaddr); /* X msecs to ticks */ timeout = usec2ticks(GRETH_PHY_TIMEOUT_MS * 1000); @@ -230,17 +262,21 @@ int greth_init_phy(greth_priv * dev, bd_t * bis) /* get phy control register default values */ - while ((tmp = read_mii(0, regs)) & 0x8000) { - if (get_timer(start) > timeout) + while ((tmp = read_mii(phyaddr, 0, regs)) & 0x8000) { + if (get_timer(start) > timeout) { + debug("greth_init_phy: PHY read 1 failed\n"); return 1; /* Fail */ + } } /* reset PHY and wait for completion */ - write_mii(0, 0x8000 | tmp, regs); + write_mii(phyaddr, 0, 0x8000 | tmp, regs); - while (((tmp = read_mii(0, regs))) & 0x8000) { - if (get_timer(start) > timeout) + while (((tmp = read_mii(phyaddr, 0, regs))) & 0x8000) { + if (get_timer(start) > timeout) { + debug("greth_init_phy: PHY read 2 failed\n"); return 1; /* Fail */ + } } /* Check if PHY is autoneg capable and then determine operating @@ -251,16 +287,16 @@ int greth_init_phy(greth_priv * dev, bd_t * bis) dev->sp = 0; dev->auto_neg = 0; if (!((tmp >> 12) & 1)) { - write_mii(0, 0, regs); + write_mii(phyaddr, 0, 0, regs); } else { /* wait for auto negotiation to complete and then check operating mode */ dev->auto_neg = 1; i = 0; - while (!(((tmp = read_mii(1, regs)) >> 5) & 1)) { + while (!(((tmp = read_mii(phyaddr, 1, regs)) >> 5) & 1)) { if (get_timer(start) > timeout) { printf("Auto negotiation timed out. " "Selecting default config\n"); - tmp = read_mii(0, regs); + tmp = read_mii(phyaddr, 0, regs); dev->gb = ((tmp >> 6) & 1) && !((tmp >> 13) & 1); dev->sp = !((tmp >> 6) & 1) @@ -270,8 +306,8 @@ int greth_init_phy(greth_priv * dev, bd_t * bis) } } if ((tmp >> 8) & 1) { - tmp1 = read_mii(9, regs); - tmp2 = read_mii(10, regs); + tmp1 = read_mii(phyaddr, 9, regs); + tmp2 = read_mii(phyaddr, 10, regs); if ((tmp1 & GRETH_MII_EXTADV_1000FD) && (tmp2 & GRETH_MII_EXTPRT_1000FD)) { dev->gb = 1; @@ -284,8 +320,8 @@ int greth_init_phy(greth_priv * dev, bd_t * bis) } } if ((dev->gb == 0) || ((dev->gb == 1) && (dev->gbit_mac == 0))) { - tmp1 = read_mii(4, regs); - tmp2 = read_mii(5, regs); + tmp1 = read_mii(phyaddr, 4, regs); + tmp2 = read_mii(phyaddr, 5, regs); if ((tmp1 & GRETH_MII_100TXFD) && (tmp2 & GRETH_MII_100TXFD)) { dev->sp = 1; @@ -302,28 +338,24 @@ int greth_init_phy(greth_priv * dev, bd_t * bis) if ((dev->gb == 1) && (dev->gbit_mac == 0)) { dev->gb = 0; dev->fd = 0; - write_mii(0, dev->sp << 13, regs); + write_mii(phyaddr, 0, dev->sp << 13, regs); } } } auto_neg_done: -#ifdef DEBUG - printf("%s GRETH Ethermac at [0x%x] irq %d. Running \ + debug("%s GRETH Ethermac at [0x%x] irq %d. Running \ %d Mbps %s duplex\n", dev->gbit_mac ? "10/100/1000" : "10/100", (unsigned int)(regs), (unsigned int)(dev->irq), dev->gb ? 1000 : (dev->sp ? 100 : 10), dev->fd ? "full" : "half"); -#endif /* Read out PHY info if extended registers are available */ if (tmp & 1) { - tmp1 = read_mii(2, regs); - tmp2 = read_mii(3, regs); + tmp1 = read_mii(phyaddr, 2, regs); + tmp2 = read_mii(phyaddr, 3, regs); tmp1 = (tmp1 << 6) | ((tmp2 >> 10) & 0x3F); tmp = tmp2 & 0xF; tmp2 = (tmp2 >> 4) & 0x3F; -#ifdef DEBUG - printf("PHY: Vendor %x Device %x Revision %d\n", tmp1, + debug("PHY: Vendor %x Device %x Revision %d\n", tmp1, tmp2, tmp); -#endif } else { printf("PHY info not available\n"); } @@ -340,9 +372,9 @@ void greth_halt(struct eth_device *dev) greth_priv *greth; greth_regs *regs; int i; -#ifdef DEBUG - printf("greth_halt\n"); -#endif + + debug("greth_halt\n"); + if (!dev || !dev->priv) return; @@ -378,9 +410,9 @@ int greth_send(struct eth_device *dev, volatile void *eth_data, int data_length) greth_bd *txbd; void *txbuf; unsigned int status; -#ifdef DEBUG - printf("greth_send\n"); -#endif + + debug("greth_send\n"); + /* send data, wait for data to be sent, then return */ if (((unsigned int)eth_data & (GRETH_BUF_ALIGN - 1)) && !greth->gbit_mac) { @@ -389,9 +421,6 @@ int greth_send(struct eth_device *dev, volatile void *eth_data, int data_length) */ if (!greth->txbuf) { greth->txbuf = malloc(GRETH_RXBUF_SIZE); -#ifdef DEBUG - printf("GRETH: allocated aligned tx-buf\n"); -#endif } txbuf = greth->txbuf; @@ -457,9 +486,7 @@ int greth_recv(struct eth_device *dev) unsigned char *d; int enable = 0; int i; -#ifdef DEBUG -/* printf("greth_recv\n"); */ -#endif + /* Receive One packet only, but clear as many error packets as there are * available. */ @@ -476,10 +503,9 @@ int greth_recv(struct eth_device *dev) if (status & GRETH_BD_EN) { goto done; } -#ifdef DEBUG - printf("greth_recv: packet 0x%lx, 0x%lx, len: %d\n", + + debug("greth_recv: packet 0x%lx, 0x%lx, len: %d\n", (unsigned int)rxbd, status, status & GRETH_BD_LEN); -#endif /* Check status for errors. */ @@ -507,19 +533,18 @@ int greth_recv(struct eth_device *dev) for (i = 0; i < GRETH_RXBD_CNT; i++) { printf("[%d]: Stat=0x%lx, Addr=0x%lx\n", i, GRETH_REGLOAD(&greth->rxbd_base[i].stat), - GRETH_REGLOAD(&greth->rxbd_base[i]. - addr)); + GRETH_REGLOAD(&greth->rxbd_base[i].addr)); } } else { /* Process the incoming packet. */ len = status & GRETH_BD_LEN; d = (char *)rxbd->addr; -#ifdef DEBUG - printf + + debug ("greth_recv: new packet, length: %d. data: %x %x %x %x %x %x %x %x\n", len, d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7]); -#endif + /* flush all data cache to make sure we're not reading old packet data */ sparc_dcache_flush_all(); @@ -545,7 +570,7 @@ int greth_recv(struct eth_device *dev) (unsigned int)greth->rxbd_max) ? greth-> rxbd_base : (greth->rxbd_curr + 1); - }; + } if (enable) { GRETH_REGORIN(®s->control, GRETH_RXEN); @@ -567,10 +592,9 @@ void greth_set_hwaddr(greth_priv * greth, unsigned char *mac) greth->regs->esa_msb = (mac[0] << 8) | mac[1]; greth->regs->esa_lsb = (mac[2] << 24) | (mac[3] << 16) | (mac[4] << 8) | mac[5]; -#ifdef DEBUG - printf("GRETH: New MAC address: %02x:%02x:%02x:%02x:%02x:%02x\n", + + debug("GRETH: New MAC address: %02x:%02x:%02x:%02x:%02x:%02x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); -#endif } int greth_initialize(bd_t * bis) @@ -581,9 +605,9 @@ int greth_initialize(bd_t * bis) int i; char *addr_str, *end; unsigned char addr[6]; -#ifdef DEBUG - printf("Scanning for GRETH\n"); -#endif + + debug("Scanning for GRETH\n"); + /* Find Device & IRQ via AMBA Plug&Play information */ if (ambapp_apb_first(VENDOR_GAISLER, GAISLER_ETHMAC, &apbdev) != 1) { return -1; /* GRETH not found */ @@ -596,9 +620,7 @@ int greth_initialize(bd_t * bis) greth->regs = (greth_regs *) apbdev.address; greth->irq = apbdev.irq; -#ifdef DEBUG - printf("Found GRETH at 0x%lx, irq %d\n", greth->regs, greth->irq); -#endif + debug("Found GRETH at 0x%lx, irq %d\n", greth->regs, greth->irq); dev->priv = (void *)greth; dev->iobase = (unsigned int)greth->regs; dev->init = greth_init; @@ -622,14 +644,15 @@ int greth_initialize(bd_t * bis) /* Make descriptor string */ if (greth->gbit_mac) { - sprintf(dev->name, "GRETH 10/100/GB"); + sprintf(dev->name, "GRETH_10/100/GB"); } else { - sprintf(dev->name, "GRETH 10/100"); + sprintf(dev->name, "GRETH_10/100"); } /* initiate PHY, select speed/duplex depending on connected PHY */ if (greth_init_phy(greth, bis)) { /* Failed to init PHY (timedout) */ + debug("GRETH[0x%08x]: Failed to init PHY\n", greth->regs); return -1; } @@ -658,5 +681,6 @@ int greth_initialize(bd_t * bis) /* set and remember MAC address */ greth_set_hwaddr(greth, addr); + debug("GRETH[0x%08x]: Initialized successfully\n", greth->regs); return 0; } diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile index 3b92614ac7..bba890189a 100644 --- a/drivers/net/phy/Makefile +++ b/drivers/net/phy/Makefile @@ -23,7 +23,7 @@ include $(TOPDIR)/config.mk -LIB := $(obj)libphy.a +LIB := $(obj)libphy.o COBJS-$(CONFIG_BITBANGMII) += miiphybb.o COBJS-$(CONFIG_MV88E61XX_SWITCH) += mv88e61xx.o @@ -35,7 +35,7 @@ OBJS := $(addprefix $(obj),$(COBJS)) all: $(LIB) $(LIB): $(obj).depend $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) + $(call cmd_link_o_target, $(OBJS)) ######################################################################### diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile index 0c4fa802a3..ee0c64d135 100644 --- a/drivers/pci/Makefile +++ b/drivers/pci/Makefile @@ -23,7 +23,7 @@ include $(TOPDIR)/config.mk -LIB := $(obj)libpci.a +LIB := $(obj)libpci.o COBJS-$(CONFIG_FSL_PCI_INIT) += fsl_pci_init.o COBJS-$(CONFIG_PCI) += pci.o pci_auto.o pci_indirect.o @@ -41,7 +41,7 @@ OBJS := $(addprefix $(obj),$(COBJS)) all: $(LIB) $(LIB): $(obj).depend $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) + $(call cmd_link_o_target, $(OBJS)) ######################################################################### diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile index babe3ecad7..03495087dc 100644 --- a/drivers/pcmcia/Makefile +++ b/drivers/pcmcia/Makefile @@ -23,7 +23,7 @@ include $(TOPDIR)/config.mk -LIB := $(obj)libpcmcia.a +LIB := $(obj)libpcmcia.o COBJS-$(CONFIG_I82365) += i82365.o COBJS-$(CONFIG_8xx) += mpc8xx_pcmcia.o @@ -40,7 +40,7 @@ OBJS := $(addprefix $(obj),$(COBJS)) all: $(LIB) $(LIB): $(obj).depend $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) + $(call cmd_link_o_target, $(OBJS)) ######################################################################### diff --git a/drivers/power/Makefile b/drivers/power/Makefile index db53173837..c9ba1aef86 100644 --- a/drivers/power/Makefile +++ b/drivers/power/Makefile @@ -23,7 +23,7 @@ include $(TOPDIR)/config.mk -LIB := $(obj)libpower.a +LIB := $(obj)libpower.o COBJS-$(CONFIG_TWL4030_POWER) += twl4030.o COBJS-$(CONFIG_TWL6030_POWER) += twl6030.o @@ -35,7 +35,7 @@ OBJS := $(addprefix $(obj),$(COBJS)) all: $(LIB) $(LIB): $(obj).depend $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) + $(call cmd_link_o_target, $(OBJS)) ######################################################################### diff --git a/drivers/qe/Makefile b/drivers/qe/Makefile index 18fe9ce614..8e9a035e92 100644 --- a/drivers/qe/Makefile +++ b/drivers/qe/Makefile @@ -22,7 +22,7 @@ include $(TOPDIR)/config.mk -LIB := $(obj)qe.a +LIB := $(obj)libqe.o COBJS-$(CONFIG_OF_LIBFDT) += fdt.o COBJS-$(CONFIG_QE) += qe.o uccf.o uec.o uec_phy.o @@ -34,7 +34,7 @@ OBJS := $(addprefix $(obj),$(COBJS)) all: $(LIB) $(LIB): $(obj).depend $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) + $(call cmd_link_o_target, $(OBJS)) ######################################################################### diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index 98734db77f..f810fca090 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile @@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk #CFLAGS += -DDEBUG -LIB = $(obj)librtc.a +LIB = $(obj)librtc.o COBJS-$(CONFIG_RTC_AT91SAM9_RTT) += at91sam9_rtt.o COBJS-$(CONFIG_RTC_BFIN) += bfin_rtc.o @@ -71,7 +71,7 @@ OBJS := $(addprefix $(obj),$(COBJS)) all: $(LIB) $(LIB): $(obj).depend $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) + $(call cmd_link_o_target, $(OBJS)) ######################################################################### diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile index 6d45a8ef55..7d221fc40d 100644 --- a/drivers/serial/Makefile +++ b/drivers/serial/Makefile @@ -23,7 +23,7 @@ include $(TOPDIR)/config.mk -LIB := $(obj)libserial.a +LIB := $(obj)libserial.o COBJS-$(CONFIG_ALTERA_UART) += altera_uart.o COBJS-$(CONFIG_ALTERA_JTAG_UART) += altera_jtag_uart.o @@ -64,7 +64,7 @@ OBJS := $(addprefix $(obj),$(COBJS)) all: $(LIB) $(LIB): $(obj).depend $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) + $(call cmd_link_o_target, $(OBJS)) ######################################################################### diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile index dfcbb8b46f..117ab1988d 100644 --- a/drivers/spi/Makefile +++ b/drivers/spi/Makefile @@ -23,7 +23,7 @@ include $(TOPDIR)/config.mk -LIB := $(obj)libspi.a +LIB := $(obj)libspi.o COBJS-$(CONFIG_ALTERA_SPI) += altera_spi.o COBJS-$(CONFIG_ATMEL_DATAFLASH_SPI) += atmel_dataflash_spi.o @@ -44,7 +44,7 @@ OBJS := $(addprefix $(obj),$(COBJS)) all: $(LIB) $(LIB): $(obj).depend $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) + $(call cmd_link_o_target, $(OBJS)) ######################################################################### diff --git a/drivers/twserial/Makefile b/drivers/twserial/Makefile index 0b059f312b..6c9a987e8f 100644 --- a/drivers/twserial/Makefile +++ b/drivers/twserial/Makefile @@ -23,7 +23,7 @@ include $(TOPDIR)/config.mk -LIB := $(obj)libtws.a +LIB := $(obj)libtws.o COBJS-$(CONFIG_SOFT_TWS) += soft_tws.o @@ -34,7 +34,7 @@ OBJS := $(addprefix $(obj),$(COBJS)) all: $(LIB) $(LIB): $(obj).depend $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) + $(call cmd_link_o_target, $(OBJS)) ######################################################################### diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile index 8e6b26e261..f137817391 100644 --- a/drivers/usb/gadget/Makefile +++ b/drivers/usb/gadget/Makefile @@ -23,7 +23,7 @@ include $(TOPDIR)/config.mk -LIB := $(obj)libusb_gadget.a +LIB := $(obj)libusb_gadget.o # new USB gadget layer dependencies ifdef CONFIG_USB_ETHER @@ -48,7 +48,7 @@ OBJS := $(addprefix $(obj),$(COBJS)) all: $(LIB) $(LIB): $(obj).depend $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) + $(call cmd_link_o_target, $(OBJS)) ######################################################################### diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index 0e7c9db9dc..51b2494328 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile @@ -23,7 +23,7 @@ include $(TOPDIR)/config.mk -LIB := $(obj)libusb_host.a +LIB := $(obj)libusb_host.o # ohci COBJS-$(CONFIG_USB_OHCI_NEW) += ohci-hcd.o @@ -54,7 +54,7 @@ OBJS := $(addprefix $(obj),$(COBJS)) all: $(LIB) $(LIB): $(obj).depend $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) + $(call cmd_link_o_target, $(OBJS)) ######################################################################### diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile index 7d23e06a58..20b5503c90 100644 --- a/drivers/usb/musb/Makefile +++ b/drivers/usb/musb/Makefile @@ -23,7 +23,7 @@ include $(TOPDIR)/config.mk -LIB := $(obj)libusb_musb.a +LIB := $(obj)libusb_musb.o COBJS-$(CONFIG_MUSB_HCD) += musb_hcd.o musb_core.o COBJS-$(CONFIG_MUSB_UDC) += musb_udc.o musb_core.o @@ -40,7 +40,7 @@ OBJS := $(addprefix $(obj),$(COBJS)) all: $(LIB) $(LIB): $(obj).depend $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) + $(call cmd_link_o_target, $(OBJS)) ######################################################################### diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile index f09e55fd4c..55475709f5 100644 --- a/drivers/usb/phy/Makefile +++ b/drivers/usb/phy/Makefile @@ -20,7 +20,7 @@ include $(TOPDIR)/config.mk -LIB := $(obj)libusb_phy.a +LIB := $(obj)libusb_phy.o COBJS-$(CONFIG_TWL4030_USB) += twl4030.o @@ -31,7 +31,7 @@ OBJS := $(addprefix $(obj),$(COBJS)) all: $(LIB) $(LIB): $(obj).depend $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) + $(call cmd_link_o_target, $(OBJS)) ######################################################################### diff --git a/drivers/video/Makefile b/drivers/video/Makefile index 5b7b261268..83274c3d7e 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile @@ -23,7 +23,7 @@ include $(TOPDIR)/config.mk -LIB := $(obj)libvideo.a +LIB := $(obj)libvideo.o COBJS-$(CONFIG_ATI_RADEON_FB) += ati_radeon_fb.o videomodes.o COBJS-$(CONFIG_ATMEL_LCD) += atmel_lcdfb.o @@ -48,7 +48,7 @@ OBJS := $(addprefix $(obj),$(COBJS)) all: $(LIB) $(LIB): $(obj).depend $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) + $(call cmd_link_o_target, $(OBJS)) ######################################################################### diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index 200968de4e..6ab4d52d9c 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -23,7 +23,7 @@ include $(TOPDIR)/config.mk -LIB := $(obj)libwatchdog.a +LIB := $(obj)libwatchdog.o COBJS-$(CONFIG_AT91SAM9_WATCHDOG) += at91sam9_wdt.o @@ -34,7 +34,7 @@ OBJS := $(addprefix $(obj),$(COBJS)) all: $(LIB) $(LIB): $(obj).depend $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) + $(call cmd_link_o_target, $(OBJS)) ######################################################################### |