aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/bios_emulator/Makefile4
-rw-r--r--drivers/block/Makefile4
-rw-r--r--drivers/dma/Makefile4
-rw-r--r--drivers/fpga/Makefile4
-rw-r--r--drivers/gpio/Makefile4
-rw-r--r--drivers/hwmon/Makefile4
-rw-r--r--drivers/i2c/Makefile4
-rw-r--r--drivers/input/Makefile4
-rw-r--r--drivers/misc/Makefile4
-rw-r--r--drivers/mmc/Makefile4
-rw-r--r--drivers/mmc/gen_atmel_mci.c1
-rw-r--r--drivers/mmc/mmc.c148
-rw-r--r--drivers/mmc/omap_hsmmc.c107
-rw-r--r--drivers/mtd/Makefile4
-rw-r--r--drivers/mtd/cfi_flash.c7
-rw-r--r--drivers/mtd/nand/Makefile4
-rw-r--r--drivers/mtd/nand/ndfc.c4
-rw-r--r--drivers/mtd/nand/s3c2410_nand.c12
-rw-r--r--drivers/mtd/onenand/Makefile4
-rw-r--r--drivers/mtd/spi/Makefile4
-rw-r--r--drivers/mtd/ubi/Makefile4
-rw-r--r--drivers/net/Makefile14
-rw-r--r--drivers/net/e1000.c5
-rw-r--r--drivers/net/greth.c164
-rw-r--r--drivers/net/phy/Makefile4
-rw-r--r--drivers/pci/Makefile4
-rw-r--r--drivers/pci/tsi108_pci.c3
-rw-r--r--drivers/pcmcia/Makefile4
-rw-r--r--drivers/power/Makefile4
-rw-r--r--drivers/qe/Makefile6
-rw-r--r--drivers/qe/fdt.c2
-rw-r--r--drivers/rtc/Makefile4
-rw-r--r--drivers/serial/Makefile4
-rw-r--r--drivers/spi/Makefile4
-rw-r--r--drivers/twserial/Makefile4
-rw-r--r--drivers/usb/gadget/Makefile4
-rw-r--r--drivers/usb/host/Makefile4
-rw-r--r--drivers/usb/host/ehci-hcd.c6
-rw-r--r--drivers/usb/host/ehci-ppc4xx.c1
-rw-r--r--drivers/usb/musb/Makefile4
-rw-r--r--drivers/usb/phy/Makefile4
-rw-r--r--drivers/video/Makefile5
-rw-r--r--drivers/video/fsl_diu_fb.c513
-rw-r--r--drivers/watchdog/Makefile4
44 files changed, 839 insertions, 271 deletions
diff --git a/drivers/bios_emulator/Makefile b/drivers/bios_emulator/Makefile
index feba4da7589..d94a1442929 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 64dcf4e2454..e27175bb4b5 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 36d99f9b111..9d945a042a9 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 9ecdc5ef109..b48f623c180 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 a0f455223b3..398024c7bc3 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 59302fa4d2d..f04cd6983ea 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 8921ff914e1..052fe360c07 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 9a144073999..1f4dad35b53 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 5d668f8222b..a76bd4e58aa 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 2ead6344868..68afd30ef02 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/gen_atmel_mci.c b/drivers/mmc/gen_atmel_mci.c
index fa4df9943a7..2984d645c9d 100644
--- a/drivers/mmc/gen_atmel_mci.c
+++ b/drivers/mmc/gen_atmel_mci.c
@@ -308,6 +308,7 @@ static int mci_init(struct mmc *mmc)
writel(MMCI_BIT(SWRST), &mci->cr); /* soft reset */
writel(MMCI_BIT(PWSDIS), &mci->cr); /* disable power save */
writel(MMCI_BIT(MCIEN), &mci->cr); /* enable mci */
+ writel(MMCI_BF(SCDSEL, MCI_BUS), &mci->sdcr); /* select port */
/* Initial Time-outs */
writel(0x5f, &mci->dtor);
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index eb7bfb39e92..6805b33f7a1 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/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c
index c7f76209f33..6f2280abff9 100644
--- a/drivers/mmc/omap_hsmmc.c
+++ b/drivers/mmc/omap_hsmmc.c
@@ -31,6 +31,9 @@
#include <asm/io.h>
#include <asm/arch/mmc_host_def.h>
+/* If we fail after 1 second wait, something is really bad */
+#define MAX_RETRY_MS 1000
+
static int mmc_read_data(hsmmc_t *mmc_base, char *buf, unsigned int size);
static int mmc_write_data(hsmmc_t *mmc_base, const char *buf, unsigned int siz);
static struct mmc hsmmc_dev[2];
@@ -70,18 +73,29 @@ unsigned char mmc_board_init(hsmmc_t *mmc_base)
void mmc_init_stream(hsmmc_t *mmc_base)
{
+ ulong start;
writel(readl(&mmc_base->con) | INIT_INITSTREAM, &mmc_base->con);
writel(MMC_CMD0, &mmc_base->cmd);
- while (!(readl(&mmc_base->stat) & CC_MASK))
- ;
+ start = get_timer(0);
+ while (!(readl(&mmc_base->stat) & CC_MASK)) {
+ if (get_timer(0) - start > MAX_RETRY_MS) {
+ printf("%s: timedout waiting for cc!\n", __func__);
+ return;
+ }
+ }
writel(CC_MASK, &mmc_base->stat)
;
writel(MMC_CMD0, &mmc_base->cmd)
;
- while (!(readl(&mmc_base->stat) & CC_MASK))
- ;
+ start = get_timer(0);
+ while (!(readl(&mmc_base->stat) & CC_MASK)) {
+ if (get_timer(0) - start > MAX_RETRY_MS) {
+ printf("%s: timedout waiting for cc2!\n", __func__);
+ return;
+ }
+ }
writel(readl(&mmc_base->con) & ~INIT_INITSTREAM, &mmc_base->con);
}
@@ -91,16 +105,28 @@ static int mmc_init_setup(struct mmc *mmc)
hsmmc_t *mmc_base = (hsmmc_t *)mmc->priv;
unsigned int reg_val;
unsigned int dsor;
+ ulong start;
mmc_board_init(mmc_base);
writel(readl(&mmc_base->sysconfig) | MMC_SOFTRESET,
&mmc_base->sysconfig);
- while ((readl(&mmc_base->sysstatus) & RESETDONE) == 0)
- ;
+ start = get_timer(0);
+ while ((readl(&mmc_base->sysstatus) & RESETDONE) == 0) {
+ if (get_timer(0) - start > MAX_RETRY_MS) {
+ printf("%s: timedout waiting for cc2!\n", __func__);
+ return TIMEOUT;
+ }
+ }
writel(readl(&mmc_base->sysctl) | SOFTRESETALL, &mmc_base->sysctl);
- while ((readl(&mmc_base->sysctl) & SOFTRESETALL) != 0x0)
- ;
+ start = get_timer(0);
+ while ((readl(&mmc_base->sysctl) & SOFTRESETALL) != 0x0) {
+ if (get_timer(0) - start > MAX_RETRY_MS) {
+ printf("%s: timedout waiting for softresetall!\n",
+ __func__);
+ return TIMEOUT;
+ }
+ }
writel(DTW_1_BITMODE | SDBP_PWROFF | SDVS_3V0, &mmc_base->hctl);
writel(readl(&mmc_base->capa) | VS30_3V0SUP | VS18_1V8SUP,
&mmc_base->capa);
@@ -116,8 +142,13 @@ static int mmc_init_setup(struct mmc *mmc)
(ICE_STOP | DTO_15THDTO | CEN_DISABLE));
mmc_reg_out(&mmc_base->sysctl, ICE_MASK | CLKD_MASK,
(dsor << CLKD_OFFSET) | ICE_OSCILLATE);
- while ((readl(&mmc_base->sysctl) & ICS_MASK) == ICS_NOTREADY)
- ;
+ start = get_timer(0);
+ while ((readl(&mmc_base->sysctl) & ICS_MASK) == ICS_NOTREADY) {
+ if (get_timer(0) - start > MAX_RETRY_MS) {
+ printf("%s: timedout waiting for ics!\n", __func__);
+ return TIMEOUT;
+ }
+ }
writel(readl(&mmc_base->sysctl) | CEN_ENABLE, &mmc_base->sysctl);
writel(readl(&mmc_base->hctl) | SDBP_PWRON, &mmc_base->hctl);
@@ -137,14 +168,23 @@ static int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
{
hsmmc_t *mmc_base = (hsmmc_t *)mmc->priv;
unsigned int flags, mmc_stat;
- unsigned int retry = 0x100000;
+ ulong start;
-
- while ((readl(&mmc_base->pstate) & DATI_MASK) == DATI_CMDDIS)
- ;
+ start = get_timer(0);
+ while ((readl(&mmc_base->pstate) & DATI_MASK) == DATI_CMDDIS) {
+ if (get_timer(0) - start > MAX_RETRY_MS) {
+ printf("%s: timedout waiting for cmddis!\n", __func__);
+ return TIMEOUT;
+ }
+ }
writel(0xFFFFFFFF, &mmc_base->stat);
- while (readl(&mmc_base->stat))
- ;
+ start = get_timer(0);
+ while (readl(&mmc_base->stat)) {
+ if (get_timer(0) - start > MAX_RETRY_MS) {
+ printf("%s: timedout waiting for stat!\n", __func__);
+ return TIMEOUT;
+ }
+ }
/*
* CMDREG
* CMDIDX[13:8] : Command index
@@ -200,15 +240,14 @@ static int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
writel(cmd->cmdarg, &mmc_base->arg);
writel((cmd->cmdidx << 24) | flags, &mmc_base->cmd);
+ start = get_timer(0);
do {
mmc_stat = readl(&mmc_base->stat);
- retry--;
- } while ((mmc_stat == 0) && (retry > 0));
-
- if (retry == 0) {
- printf("%s : timeout: No status update\n", __func__);
- return TIMEOUT;
- }
+ if (get_timer(0) - start > MAX_RETRY_MS) {
+ printf("%s : timeout: No status update\n", __func__);
+ return TIMEOUT;
+ }
+ } while (!mmc_stat);
if ((mmc_stat & IE_CTO) != 0)
return TIMEOUT;
@@ -253,8 +292,14 @@ static int mmc_read_data(hsmmc_t *mmc_base, char *buf, unsigned int size)
count /= 4;
while (size) {
+ ulong start = get_timer(0);
do {
mmc_stat = readl(&mmc_base->stat);
+ if (get_timer(0) - start > MAX_RETRY_MS) {
+ printf("%s: timedout waiting for status!\n",
+ __func__);
+ return TIMEOUT;
+ }
} while (mmc_stat == 0);
if ((mmc_stat & ERRI_MASK) != 0)
@@ -298,8 +343,14 @@ static int mmc_write_data(hsmmc_t *mmc_base, const char *buf, unsigned int size)
count /= 4;
while (size) {
+ ulong start = get_timer(0);
do {
mmc_stat = readl(&mmc_base->stat);
+ if (get_timer(0) - start > MAX_RETRY_MS) {
+ printf("%s: timedout waiting for status!\n",
+ __func__);
+ return TIMEOUT;
+ }
} while (mmc_stat == 0);
if ((mmc_stat & ERRI_MASK) != 0)
@@ -334,6 +385,7 @@ static void mmc_set_ios(struct mmc *mmc)
{
hsmmc_t *mmc_base = (hsmmc_t *)mmc->priv;
unsigned int dsor = 0;
+ ulong start;
/* configue bus width */
switch (mmc->bus_width) {
@@ -372,8 +424,13 @@ static void mmc_set_ios(struct mmc *mmc)
mmc_reg_out(&mmc_base->sysctl, ICE_MASK | CLKD_MASK,
(dsor << CLKD_OFFSET) | ICE_OSCILLATE);
- while ((readl(&mmc_base->sysctl) & ICS_MASK) == ICS_NOTREADY)
- ;
+ start = get_timer(0);
+ while ((readl(&mmc_base->sysctl) & ICS_MASK) == ICS_NOTREADY) {
+ if (get_timer(0) - start > MAX_RETRY_MS) {
+ printf("%s: timedout waiting for ics!\n", __func__);
+ return;
+ }
+ }
writel(readl(&mmc_base->sysctl) | CEN_ENABLE, &mmc_base->sysctl);
}
diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile
index cbf6f156b45..999431c3c0d 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/cfi_flash.c b/drivers/mtd/cfi_flash.c
index c92c7a7a490..39c235ebc26 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -1837,7 +1837,7 @@ static void flash_fixup_stm(flash_info_t *info, struct cfi_qry *qry)
* The following code cannot be run from FLASH!
*
*/
-ulong flash_get_size (phys_addr_t base, int banknum, unsigned long max_size)
+ulong flash_get_size (phys_addr_t base, int banknum)
{
flash_info_t *info = &flash_info[banknum];
int i, j;
@@ -1849,6 +1849,7 @@ ulong flash_get_size (phys_addr_t base, int banknum, unsigned long max_size)
int erase_region_size;
int erase_region_count;
struct cfi_qry qry;
+ unsigned long max_size;
memset(&qry, 0, sizeof(qry));
@@ -1929,6 +1930,7 @@ ulong flash_get_size (phys_addr_t base, int banknum, unsigned long max_size)
info->size = 1 << qry.dev_size;
/* multiply the size by the number of chips */
info->size *= size_ratio;
+ max_size = cfi_flash_bank_size(banknum);
if (max_size && (info->size > max_size)) {
debug("[truncated from %ldMiB]", info->size >> 20);
info->size = max_size;
@@ -2043,8 +2045,7 @@ unsigned long flash_init (void)
flash_info[i].flash_id = FLASH_UNKNOWN;
if (!flash_detect_legacy(cfi_flash_bank_addr(i), i))
- flash_get_size(cfi_flash_bank_addr(i), i,
- cfi_flash_bank_size(i));
+ flash_get_size(cfi_flash_bank_addr(i), i);
size += flash_info[i].size;
if (flash_info[i].flash_id == FLASH_UNKNOWN) {
#ifndef CONFIG_SYS_FLASH_QUIET_TEST
diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile
index 28f27da7a71..8b598f6bfef 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/nand/ndfc.c b/drivers/mtd/nand/ndfc.c
index 3ca13a979c7..0729e0c9c02 100644
--- a/drivers/mtd/nand/ndfc.c
+++ b/drivers/mtd/nand/ndfc.c
@@ -201,6 +201,8 @@ int board_nand_init(struct nand_chip *nand)
#ifndef CONFIG_NAND_SPL
nand->write_buf = ndfc_write_buf;
nand->verify_buf = ndfc_verify_buf;
+
+ chip++;
#else
/*
* Setup EBC (CS0 only right now)
@@ -211,7 +213,5 @@ int board_nand_init(struct nand_chip *nand)
mtebc(PB0AP, CONFIG_SYS_EBC_PB0AP);
#endif
- chip++;
-
return 0;
}
diff --git a/drivers/mtd/nand/s3c2410_nand.c b/drivers/mtd/nand/s3c2410_nand.c
index f70daefbfe1..27351fb7a05 100644
--- a/drivers/mtd/nand/s3c2410_nand.c
+++ b/drivers/mtd/nand/s3c2410_nand.c
@@ -133,9 +133,15 @@ int board_nand_init(struct nand_chip *nand)
writel(readl(&clk_power->clkcon) | (1 << 4), &clk_power->clkcon);
/* initialize hardware */
- twrph0 = 3;
- twrph1 = 0;
- tacls = 0;
+#if defined(CONFIG_S3C24XX_CUSTOM_NAND_TIMING)
+ tacls = CONFIG_S3C24XX_TACLS;
+ twrph0 = CONFIG_S3C24XX_TWRPH0;
+ twrph1 = CONFIG_S3C24XX_TWRPH1;
+#else
+ tacls = 4;
+ twrph0 = 8;
+ twrph1 = 8;
+#endif
cfg = S3C2410_NFCONF_EN;
cfg |= S3C2410_NFCONF_TACLS(tacls - 1);
diff --git a/drivers/mtd/onenand/Makefile b/drivers/mtd/onenand/Makefile
index 2571df01638..b984bd4a2be 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 a082ca7d53a..3d607c06d39 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 8bd82c353df..b2e601439d8 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 79eb66b2674..b605eea7d2d 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -23,14 +23,16 @@
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
COBJS-$(CONFIG_ALTERA_TSE) += altera_tse.o
COBJS-$(CONFIG_DRIVER_AT91EMAC) += at91_emac.o
COBJS-$(CONFIG_DRIVER_AX88180) += ax88180.o
-COBJS-$(CONFIG_BCM570x) += bcm570x.o bcm570x_autoneg.o 5701rls.o
+COBJS-$(CONFIG_BCM570x) += bcm570x.o
+COBJS-$(CONFIG_BCM570x) += bcm570x_autoneg.o
+COBJS-$(CONFIG_BCM570x) += 5701rls.o
COBJS-$(CONFIG_BFIN_MAC) += bfin_mac.o
COBJS-$(CONFIG_CS8900) += cs8900.o
COBJS-$(CONFIG_TULIP) += dc2114x.o
@@ -72,7 +74,9 @@ COBJS-$(CONFIG_DRIVER_S3C4510_ETH) += s3c4510b_eth.o
COBJS-$(CONFIG_SH_ETHER) += sh_eth.o
COBJS-$(CONFIG_SMC91111) += smc91111.o
COBJS-$(CONFIG_SMC911X) += smc911x.o
-COBJS-$(CONFIG_TIGON3) += tigon3.o bcm570x_autoneg.o 5701rls.o
+COBJS-$(CONFIG_TIGON3) += tigon3.o
+COBJS-$(CONFIG_TIGON3) += bcm570x_autoneg.o
+COBJS-$(CONFIG_TIGON3) += 5701rls.o
COBJS-$(CONFIG_DRIVER_TI_EMAC) += davinci_emac.o
COBJS-$(CONFIG_TSEC_ENET) += tsec.o
COBJS-$(CONFIG_TSI108_ETH) += tsi108_eth.o
@@ -80,14 +84,14 @@ COBJS-$(CONFIG_ULI526X) += uli526x.o
COBJS-$(CONFIG_VSC7385_ENET) += vsc7385.o
COBJS-$(CONFIG_XILINX_EMACLITE) += xilinx_emaclite.o
-COBJS := $(COBJS-y)
+COBJS := $(sort $(COBJS-y))
SRCS := $(COBJS:.o=.c)
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 18584efdd53..5f390bddbdb 100644
--- a/drivers/net/e1000.c
+++ b/drivers/net/e1000.c
@@ -5018,6 +5018,7 @@ TRANSMIT - Transmit a frame
static int
e1000_transmit(struct eth_device *nic, volatile void *packet, int length)
{
+ void * nv_packet = (void *)packet;
struct e1000_hw *hw = nic->priv;
struct e1000_tx_desc *txp;
int i = 0;
@@ -5025,7 +5026,7 @@ e1000_transmit(struct eth_device *nic, volatile void *packet, int length)
txp = tx_base + tx_tail;
tx_tail = (tx_tail + 1) % 8;
- txp->buffer_addr = cpu_to_le64(virt_to_bus(hw->pdev, packet));
+ txp->buffer_addr = cpu_to_le64(virt_to_bus(hw->pdev, nv_packet));
txp->lower.data = cpu_to_le32(hw->txd_cmd | length);
txp->upper.data = 0;
E1000_WRITE_REG(hw, TDT, tx_tail);
@@ -5189,7 +5190,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 79bc4d9d26b..6c322269464 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(&regs->mdio) & GRETH_MII_BUSY) {
}
- GRETH_REGSAVE(&regs->mdio, (0 << 11) | ((addr & 0x1F) << 6) | 2);
+ GRETH_REGSAVE(&regs->mdio, ((phyaddr & 0x1F) << 11) | ((regaddr & 0x1F) << 6) | 2);
while (GRETH_REGLOAD(&regs->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(&regs->mdio) & GRETH_MII_BUSY) {
}
GRETH_REGSAVE(&regs->mdio,
- ((data & 0xFFFF) << 16) | (0 << 11) | ((addr & 0x1F) << 6)
- | 1);
+ ((data & 0xFFFF) << 16) | ((phyaddr & 0x1F) << 11) |
+ ((regaddr & 0x1F) << 6) | 1);
while (GRETH_REGLOAD(&regs->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(&regs->control, 0);
+ debug("greth_init\n");
+
+ /* Reset core */
+ GRETH_REGSAVE(&regs->control, (GRETH_RESET | (greth->gb << 8) |
+ (greth->sp << 7) | (greth->fd << 4)));
+
+ /* Wait for Reset to complete */
+ while ( GRETH_REGLOAD(&regs->control) & GRETH_RESET) ;
+
+ GRETH_REGSAVE(&regs->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(&regs->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(&regs->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 3b92614ac74..bba890189a2 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 0c4fa802a3b..ee0c64d1354 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/pci/tsi108_pci.c b/drivers/pci/tsi108_pci.c
index 627e8a07929..c568bf9bc7d 100644
--- a/drivers/pci/tsi108_pci.c
+++ b/drivers/pci/tsi108_pci.c
@@ -94,7 +94,8 @@ unsigned int __get_pci_config_dword (u32 addr)
".section __ex_table,\"a\"\n"
" .align 2\n"
" .long 1b,3b\n"
- ".text":"=r"(retval):"r"(addr));
+ ".section .text.__get_pci_config_dword"
+ : "=r"(retval) : "r"(addr));
return (retval);
}
diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile
index babe3ecad76..03495087dc9 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 db531738379..c9ba1aef86c 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 18fe9ce614a..ef4bdf8b24e 100644
--- a/drivers/qe/Makefile
+++ b/drivers/qe/Makefile
@@ -22,9 +22,9 @@
include $(TOPDIR)/config.mk
-LIB := $(obj)qe.a
+LIB := $(obj)libqe.o
-COBJS-$(CONFIG_OF_LIBFDT) += fdt.o
+COBJS-$(and $(CONFIG_QE),$(CONFIG_OF_LIBFDT)) += fdt.o
COBJS-$(CONFIG_QE) += qe.o uccf.o uec.o uec_phy.o
COBJS := $(COBJS-y)
@@ -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/qe/fdt.c b/drivers/qe/fdt.c
index d7c7d13cab5..73e9060d572 100644
--- a/drivers/qe/fdt.c
+++ b/drivers/qe/fdt.c
@@ -74,7 +74,6 @@ error:
void ft_qe_setup(void *blob)
{
-#ifdef CONFIG_QE
do_fixup_by_prop_u32(blob, "device_type", "qe", 4,
"bus-frequency", gd->qe_clk, 1);
do_fixup_by_prop_u32(blob, "device_type", "qe", 4,
@@ -88,5 +87,4 @@ void ft_qe_setup(void *blob)
do_fixup_by_compat_u32(blob, "fsl,qe-gtm",
"clock-frequency", gd->qe_clk / 2, 1);
fdt_fixup_qe_firmware(blob);
-#endif
}
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 98734db77f6..f810fca0907 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 6d45a8ef554..7d221fc40d9 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 dfcbb8b46f4..117ab1988d2 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 0b059f312bd..6c9a987e8f6 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 8e6b26e2610..f1378173910 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 0e7c9db9dcb..51b24943282 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/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 982f96e8b8f..6eb38a4131f 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -25,6 +25,7 @@
#include <usb.h>
#include <asm/io.h>
#include <malloc.h>
+#include <watchdog.h>
#include "ehci.h"
@@ -229,7 +230,7 @@ static int ehci_reset(void)
int ret = 0;
cmd = ehci_readl(&hcor->or_usbcmd);
- cmd |= CMD_RESET;
+ cmd = (cmd & ~CMD_RUN) | CMD_RESET;
ehci_writel(&hcor->or_usbcmd, cmd);
ret = handshake((uint32_t *)&hcor->or_usbcmd, CMD_RESET, 0, 250 * 1000);
if (ret < 0) {
@@ -452,6 +453,7 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,
token = hc32_to_cpu(vtd->qt_token);
if (!(token & 0x80))
break;
+ WATCHDOG_RESET();
} while (get_timer(ts) < CONFIG_SYS_HZ);
/* Disable async schedule. */
@@ -491,6 +493,8 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,
break;
default:
dev->status = USB_ST_CRC_ERR;
+ if ((token & 0x40) == 0x40)
+ dev->status |= USB_ST_STALLED;
break;
}
dev->act_len = length - ((token >> 16) & 0x7fff);
diff --git a/drivers/usb/host/ehci-ppc4xx.c b/drivers/usb/host/ehci-ppc4xx.c
index 946a0a07efa..11799199871 100644
--- a/drivers/usb/host/ehci-ppc4xx.c
+++ b/drivers/usb/host/ehci-ppc4xx.c
@@ -34,7 +34,6 @@ int ehci_hcd_init(void)
hccr = (struct ehci_hccr *)(CONFIG_SYS_PPC4XX_USB_ADDR);
hcor = (struct ehci_hcor *)((uint32_t) hccr +
HC_LENGTH(ehci_readl(&hccr->cr_capbase)));
- usb_dev_init();
return 0;
}
diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile
index 7d23e06a58c..20b5503c901 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 f09e55fd4c3..55475709f5d 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 5b7b2612686..2c53a6f3e33 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -23,11 +23,12 @@
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
COBJS-$(CONFIG_CFB_CONSOLE) += cfb_console.o
+COBJS-$(CONFIG_FSL_DIU_FB) += fsl_diu_fb.o
COBJS-$(CONFIG_S6E63D6) += s6e63d6.o
COBJS-$(CONFIG_VIDEO_AMBA) += amba.o
COBJS-$(CONFIG_VIDEO_CT69000) += ct69000.o videomodes.o
@@ -48,7 +49,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/fsl_diu_fb.c b/drivers/video/fsl_diu_fb.c
new file mode 100644
index 00000000000..35ed938befb
--- /dev/null
+++ b/drivers/video/fsl_diu_fb.c
@@ -0,0 +1,513 @@
+/*
+ * Copyright 2007, 2010 Freescale Semiconductor, Inc.
+ * York Sun <yorksun@freescale.com>
+ *
+ * FSL DIU Framebuffer driver
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <i2c.h>
+#include <malloc.h>
+#include <asm/io.h>
+
+#include <fsl_diu_fb.h>
+
+struct fb_videomode {
+ const char *name; /* optional */
+ unsigned int refresh; /* optional */
+ unsigned int xres;
+ unsigned int yres;
+ unsigned int pixclock;
+ unsigned int left_margin;
+ unsigned int right_margin;
+ unsigned int upper_margin;
+ unsigned int lower_margin;
+ unsigned int hsync_len;
+ unsigned int vsync_len;
+ unsigned int sync;
+ unsigned int vmode;
+ unsigned int flag;
+};
+
+#define FB_SYNC_VERT_HIGH_ACT 2 /* vertical sync high active */
+#define FB_SYNC_COMP_HIGH_ACT 8 /* composite sync high active */
+#define FB_VMODE_NONINTERLACED 0 /* non interlaced */
+
+/* This setting is used for the ifm pdm360ng with PRIMEVIEW PM070WL3 */
+static struct fb_videomode fsl_diu_mode_800 = {
+ .refresh = 60,
+ .xres = 800,
+ .yres = 480,
+ .pixclock = 31250,
+ .left_margin = 86,
+ .right_margin = 42,
+ .upper_margin = 33,
+ .lower_margin = 10,
+ .hsync_len = 128,
+ .vsync_len = 2,
+ .sync = 0,
+ .vmode = FB_VMODE_NONINTERLACED
+};
+
+/*
+ * These parameters give default parameters
+ * for video output 1024x768,
+ * FIXME - change timing to proper amounts
+ * hsync 31.5kHz, vsync 60Hz
+ */
+static struct fb_videomode fsl_diu_mode_1024 = {
+ .refresh = 60,
+ .xres = 1024,
+ .yres = 768,
+ .pixclock = 15385,
+ .left_margin = 160,
+ .right_margin = 24,
+ .upper_margin = 29,
+ .lower_margin = 3,
+ .hsync_len = 136,
+ .vsync_len = 6,
+ .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
+ .vmode = FB_VMODE_NONINTERLACED
+};
+
+static struct fb_videomode fsl_diu_mode_1280 = {
+ .name = "1280x1024-60",
+ .refresh = 60,
+ .xres = 1280,
+ .yres = 1024,
+ .pixclock = 9375,
+ .left_margin = 38,
+ .right_margin = 128,
+ .upper_margin = 2,
+ .lower_margin = 7,
+ .hsync_len = 216,
+ .vsync_len = 37,
+ .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
+ .vmode = FB_VMODE_NONINTERLACED
+};
+
+/*
+ * These are the fields of area descriptor(in DDR memory) for every plane
+ */
+struct diu_ad {
+ /* Word 0(32-bit) in DDR memory */
+ unsigned int pix_fmt; /* hard coding pixel format */
+ /* Word 1(32-bit) in DDR memory */
+ unsigned int addr;
+ /* Word 2(32-bit) in DDR memory */
+ unsigned int src_size_g_alpha;
+ /* Word 3(32-bit) in DDR memory */
+ unsigned int aoi_size;
+ /* Word 4(32-bit) in DDR memory */
+ unsigned int offset_xyi;
+ /* Word 5(32-bit) in DDR memory */
+ unsigned int offset_xyd;
+ /* Word 6(32-bit) in DDR memory */
+ unsigned int ckmax_r:8;
+ unsigned int ckmax_g:8;
+ unsigned int ckmax_b:8;
+ unsigned int res9:8;
+ /* Word 7(32-bit) in DDR memory */
+ unsigned int ckmin_r:8;
+ unsigned int ckmin_g:8;
+ unsigned int ckmin_b:8;
+ unsigned int res10:8;
+ /* Word 8(32-bit) in DDR memory */
+ unsigned int next_ad;
+ /* Word 9(32-bit) in DDR memory, just for 64-bit aligned */
+ unsigned int res1;
+ unsigned int res2;
+ unsigned int res3;
+}__attribute__ ((packed));
+
+/*
+ * DIU register map
+ */
+struct diu {
+ unsigned int desc[3];
+ unsigned int gamma;
+ unsigned int pallete;
+ unsigned int cursor;
+ unsigned int curs_pos;
+ unsigned int diu_mode;
+ unsigned int bgnd;
+ unsigned int bgnd_wb;
+ unsigned int disp_size;
+ unsigned int wb_size;
+ unsigned int wb_mem_addr;
+ unsigned int hsyn_para;
+ unsigned int vsyn_para;
+ unsigned int syn_pol;
+ unsigned int thresholds;
+ unsigned int int_status;
+ unsigned int int_mask;
+ unsigned int colorbar[8];
+ unsigned int filling;
+ unsigned int plut;
+} __attribute__ ((packed));
+
+struct diu_hw {
+ struct diu *diu_reg;
+ volatile unsigned int mode; /* DIU operation mode */
+};
+
+struct diu_addr {
+ unsigned char * paddr; /* Virtual address */
+ unsigned int offset;
+};
+
+/*
+ * Modes of operation of DIU
+ */
+#define MFB_MODE0 0 /* DIU off */
+#define MFB_MODE1 1 /* All three planes output to display */
+#define MFB_MODE2 2 /* Plane 1 to display,
+ * planes 2+3 written back to memory */
+#define MFB_MODE3 3 /* All three planes written back to memory */
+#define MFB_MODE4 4 /* Color bar generation */
+
+#define MAX_CURS 32
+
+static struct fb_info fsl_fb_info;
+static struct diu_addr gamma, cursor;
+static struct diu_ad fsl_diu_fb_ad __attribute__ ((aligned(32)));
+static struct diu_ad dummy_ad __attribute__ ((aligned(32)));
+static unsigned char *dummy_fb;
+static struct diu_hw dr = {
+ .mode = MFB_MODE1,
+};
+
+int fb_enabled = 0;
+int fb_initialized = 0;
+const int default_xres = 1280;
+const int default_pixel_format = 0x88882317;
+
+static int map_video_memory(struct fb_info *info, unsigned long bytes_align);
+static void enable_lcdc(void);
+static void disable_lcdc(void);
+static int fsl_diu_enable_panel(struct fb_info *info);
+static int fsl_diu_disable_panel(struct fb_info *info);
+static int allocate_buf(struct diu_addr *buf, u32 size, u32 bytes_align);
+void diu_set_pixel_clock(unsigned int pixclock);
+
+int fsl_diu_init(int xres, unsigned int pixel_format, int gamma_fix)
+{
+ struct fb_videomode *fsl_diu_mode_db;
+ struct diu_ad *ad = &fsl_diu_fb_ad;
+ struct diu *hw;
+ struct fb_info *info = &fsl_fb_info;
+ struct fb_var_screeninfo *var = &info->var;
+ unsigned char *gamma_table_base;
+ unsigned int i, j;
+
+ debug("Enter fsl_diu_init\n");
+ dr.diu_reg = (struct diu *) (CONFIG_SYS_DIU_ADDR);
+ hw = (struct diu *) dr.diu_reg;
+
+ disable_lcdc();
+
+ switch (xres) {
+ case 800:
+ fsl_diu_mode_db = &fsl_diu_mode_800;
+ break;
+ case 1280:
+ fsl_diu_mode_db = &fsl_diu_mode_1280;
+ break;
+ default:
+ fsl_diu_mode_db = &fsl_diu_mode_1024;
+ }
+
+ if (0 == fb_initialized) {
+ allocate_buf(&gamma, 768, 32);
+ debug("gamma is allocated @ 0x%x\n",
+ (unsigned int)gamma.paddr);
+ allocate_buf(&cursor, MAX_CURS * MAX_CURS * 2, 32);
+ debug("curosr is allocated @ 0x%x\n",
+ (unsigned int)cursor.paddr);
+
+ /* create a dummy fb and dummy ad */
+ dummy_fb = malloc(64);
+ if (NULL == dummy_fb) {
+ printf("Cannot allocate dummy fb\n");
+ return -1;
+ }
+ dummy_ad.addr = cpu_to_le32((unsigned int)dummy_fb);
+ dummy_ad.pix_fmt = 0x88882317;
+ dummy_ad.src_size_g_alpha = 0x04400000; /* alpha = 0 */
+ dummy_ad.aoi_size = 0x02000400;
+ dummy_ad.offset_xyi = 0;
+ dummy_ad.offset_xyd = 0;
+ dummy_ad.next_ad = 0;
+ /* Memory allocation for framebuffer */
+ if (map_video_memory(info, 32)) {
+ printf("Unable to allocate fb memory 1\n");
+ return -1;
+ }
+ }
+
+ memset(info->screen_base, 0, info->smem_len);
+
+ out_be32(&dr.diu_reg->desc[0], (int)&dummy_ad);
+ out_be32(&dr.diu_reg->desc[1], (int)&dummy_ad);
+ out_be32(&dr.diu_reg->desc[2], (int)&dummy_ad);
+ debug("dummy dr.diu_reg->desc[0] = 0x%x\n", dr.diu_reg->desc[0]);
+ debug("dummy desc[0] = 0x%x\n", hw->desc[0]);
+
+ /* read mode info */
+ var->xres = fsl_diu_mode_db->xres;
+ var->yres = fsl_diu_mode_db->yres;
+ var->bits_per_pixel = 32;
+ var->pixclock = fsl_diu_mode_db->pixclock;
+ var->left_margin = fsl_diu_mode_db->left_margin;
+ var->right_margin = fsl_diu_mode_db->right_margin;
+ var->upper_margin = fsl_diu_mode_db->upper_margin;
+ var->lower_margin = fsl_diu_mode_db->lower_margin;
+ var->hsync_len = fsl_diu_mode_db->hsync_len;
+ var->vsync_len = fsl_diu_mode_db->vsync_len;
+ var->sync = fsl_diu_mode_db->sync;
+ var->vmode = fsl_diu_mode_db->vmode;
+ info->line_length = var->xres * var->bits_per_pixel / 8;
+
+ ad->pix_fmt = pixel_format;
+ ad->addr = cpu_to_le32((unsigned int)info->screen_base);
+ ad->src_size_g_alpha
+ = cpu_to_le32((var->yres << 12) | var->xres);
+ /* fix me. AOI should not be greater than display size */
+ ad->aoi_size = cpu_to_le32(( var->yres << 16) | var->xres);
+ ad->offset_xyi = 0;
+ ad->offset_xyd = 0;
+
+ /* Disable chroma keying function */
+ ad->ckmax_r = 0;
+ ad->ckmax_g = 0;
+ ad->ckmax_b = 0;
+
+ ad->ckmin_r = 255;
+ ad->ckmin_g = 255;
+ ad->ckmin_b = 255;
+
+ gamma_table_base = gamma.paddr;
+ debug("gamma_table_base is allocated @ 0x%x\n",
+ (unsigned int)gamma_table_base);
+
+ /* Prep for DIU init - gamma table */
+
+ for (i = 0; i <= 2; i++)
+ for (j = 0; j <= 255; j++)
+ *gamma_table_base++ = j;
+
+ if (gamma_fix == 1) { /* fix the gamma */
+ debug("Fix gamma table\n");
+ gamma_table_base = gamma.paddr;
+ for (i = 0; i < 256*3; i++) {
+ gamma_table_base[i] = (gamma_table_base[i] << 2)
+ | ((gamma_table_base[i] >> 6) & 0x03);
+ }
+ }
+
+ debug("update-lcdc: HW - %p\n Disabling DIU\n", hw);
+
+ /* Program DIU registers */
+
+ out_be32(&hw->gamma, (int)gamma.paddr);
+ out_be32(&hw->cursor, (int)cursor.paddr);
+ out_be32(&hw->bgnd, 0x007F7F7F);
+ out_be32(&hw->bgnd_wb, 0); /* BGND_WB */
+ out_be32(&hw->disp_size, var->yres << 16 | var->xres); /* DISP SIZE */
+ out_be32(&hw->wb_size, 0); /* WB SIZE */
+ out_be32(&hw->wb_mem_addr, 0); /* WB MEM ADDR */
+ out_be32(&hw->hsyn_para, var->left_margin << 22 | /* BP_H */
+ var->hsync_len << 11 | /* PW_H */
+ var->right_margin); /* FP_H */
+
+ out_be32(&hw->vsyn_para, var->upper_margin << 22 | /* BP_V */
+ var->vsync_len << 11 | /* PW_V */
+ var->lower_margin); /* FP_V */
+
+ out_be32(&hw->syn_pol, 0); /* SYNC SIGNALS POLARITY */
+ out_be32(&hw->thresholds, 0x00037800); /* The Thresholds */
+ out_be32(&hw->int_status, 0); /* INTERRUPT STATUS */
+ out_be32(&hw->int_mask, 0); /* INT MASK */
+ out_be32(&hw->plut, 0x01F5F666);
+ /* Pixel Clock configuration */
+ debug("DIU pixclock in ps - %d\n", var->pixclock);
+ diu_set_pixel_clock(var->pixclock);
+
+ fb_initialized = 1;
+
+ /* Enable the DIU */
+ fsl_diu_enable_panel(info);
+ enable_lcdc();
+
+ return 0;
+}
+
+char *fsl_fb_open(struct fb_info **info)
+{
+ *info = &fsl_fb_info;
+ return fsl_fb_info.screen_base;
+}
+
+void fsl_diu_close(void)
+{
+ struct fb_info *info = &fsl_fb_info;
+ fsl_diu_disable_panel(info);
+}
+
+static int fsl_diu_enable_panel(struct fb_info *info)
+{
+ struct diu *hw = dr.diu_reg;
+ struct diu_ad *ad = &fsl_diu_fb_ad;
+
+ debug("Entered: enable_panel\n");
+ if (in_be32(&hw->desc[0]) != (unsigned)ad)
+ out_be32(&hw->desc[0], (unsigned)ad);
+ debug("desc[0] = 0x%x\n", hw->desc[0]);
+ return 0;
+}
+
+static int fsl_diu_disable_panel(struct fb_info *info)
+{
+ struct diu *hw = dr.diu_reg;
+
+ debug("Entered: disable_panel\n");
+ if (in_be32(&hw->desc[0]) != (unsigned)&dummy_ad)
+ out_be32(&hw->desc[0], (unsigned)&dummy_ad);
+ return 0;
+}
+
+static int map_video_memory(struct fb_info *info, unsigned long bytes_align)
+{
+ unsigned long offset;
+ unsigned long mask;
+
+ debug("Entered: map_video_memory\n");
+ /* allocate maximum 1280*1024 with 32bpp */
+ info->smem_len = 1280 * 4 *1024 + bytes_align;
+ debug("MAP_VIDEO_MEMORY: smem_len = %d\n", info->smem_len);
+ info->screen_base = malloc(info->smem_len);
+ if (info->screen_base == NULL) {
+ printf("Unable to allocate fb memory\n");
+ return -1;
+ }
+ info->smem_start = (unsigned int) info->screen_base;
+ mask = bytes_align - 1;
+ offset = (unsigned long)info->screen_base & mask;
+ if (offset) {
+ info->screen_base += (bytes_align - offset);
+ info->smem_len = info->smem_len - (bytes_align - offset);
+ } else
+ info->smem_len = info->smem_len - bytes_align;
+
+ info->screen_size = info->smem_len;
+
+ debug("Allocated fb @ 0x%08lx, size=%d.\n",
+ info->smem_start, info->smem_len);
+
+ return 0;
+}
+
+static void enable_lcdc(void)
+{
+ struct diu *hw = dr.diu_reg;
+
+ debug("Entered: enable_lcdc, fb_enabled = %d\n", fb_enabled);
+ if (!fb_enabled) {
+ out_be32(&hw->diu_mode, dr.mode);
+ fb_enabled++;
+ }
+ debug("diu_mode = %d\n", hw->diu_mode);
+}
+
+static void disable_lcdc(void)
+{
+ struct diu *hw = dr.diu_reg;
+
+ debug("Entered: disable_lcdc, fb_enabled = %d\n", fb_enabled);
+ if (fb_enabled) {
+ out_be32(&hw->diu_mode, 0);
+ fb_enabled = 0;
+ }
+}
+
+/*
+ * Align to 64-bit(8-byte), 32-byte, etc.
+ */
+static int allocate_buf(struct diu_addr *buf, u32 size, u32 bytes_align)
+{
+ u32 offset, ssize;
+ u32 mask;
+
+ debug("Entered: allocate_buf\n");
+ ssize = size + bytes_align;
+ buf->paddr = malloc(ssize);
+ if (!buf->paddr)
+ return -1;
+
+ memset(buf->paddr, 0, ssize);
+ mask = bytes_align - 1;
+ offset = (u32)buf->paddr & mask;
+ if (offset) {
+ buf->offset = bytes_align - offset;
+ buf->paddr = (unsigned char *) ((u32)buf->paddr + offset);
+ } else
+ buf->offset = 0;
+ return 0;
+}
+
+#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
+#include <stdio_dev.h>
+#include <video_fb.h>
+/*
+ * The Graphic Device
+ */
+static GraphicDevice ctfb;
+
+void *video_hw_init(void)
+{
+ struct fb_info *info;
+
+ if (platform_diu_init(&ctfb.winSizeX, &ctfb.winSizeY) < 0)
+ return NULL;
+
+ /* fill in Graphic device struct */
+ sprintf(ctfb.modeIdent, "%ix%ix%i %ikHz %iHz",
+ ctfb.winSizeX, ctfb.winSizeY, 32, 64, 60);
+
+ ctfb.frameAdrs = (unsigned int)fsl_fb_open(&info);
+ ctfb.plnSizeX = ctfb.winSizeX;
+ ctfb.plnSizeY = ctfb.winSizeY;
+
+ ctfb.gdfBytesPP = 4;
+ ctfb.gdfIndex = GDF_32BIT_X888RGB;
+
+ ctfb.isaBase = 0;
+ ctfb.pciBase = 0;
+ ctfb.memSize = info->screen_size;
+
+ /* Cursor Start Address */
+ ctfb.dprBase = 0;
+ ctfb.vprBase = 0;
+ ctfb.cprBase = 0;
+
+ return &ctfb;
+}
+#endif /* defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) */
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 200968de4e2..6ab4d52d9c6 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))
#########################################################################