U-Boot
Threads by month
- ----- 2025 -----
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2000 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
December 2008
- 172 participants
- 485 discussions
USB changes the speed according to the port status
Signed-off-by: Michael Trimarchi <trimarchimichael(a)yahoo.it>
---
diff --git a/common/usb.c b/common/usb.c
index 3138452..0c11746 100644
--- a/common/usb.c
+++ b/common/usb.c
@@ -1061,10 +1061,12 @@ static int hub_port_reset(struct usb_device *dev, int port,
}
portstatus = le16_to_cpu(portsts.wPortStatus);
portchange = le16_to_cpu(portsts.wPortChange);
+
USB_HUB_PRINTF("portstatus %x, change %x, %s\n",
portstatus, portchange,
- portstatus&(1<<USB_PORT_FEAT_LOWSPEED) ? \
+ portstatus & (1 << USB_PORT_FEAT_LOWSPEED) ? \
"Low Speed" : "High Speed");
+
USB_HUB_PRINTF("STAT_C_CONNECTION = %d STAT_CONNECTION = %d" \
" USB_PORT_STAT_ENABLE %d\n",
(portchange & USB_PORT_STAT_C_CONNECTION) ? 1 : 0,
@@ -1136,7 +1138,13 @@ void usb_hub_port_connect_change(struct usb_device *dev, int port)
/* Allocate a new device struct for it */
usb = usb_alloc_new_device();
- usb->speed = (portstatus & USB_PORT_STAT_LOW_SPEED) ? 1 : 0;
+
+ if (portstatus & USB_PORT_STAT_HIGH_SPEED)
+ usb->speed = USB_SPEED_HIGH;
+ else if (portstatus & USB_PORT_STAT_LOW_SPEED)
+ usb->speed = USB_SPEED_LOW;
+ else
+ usb->speed = USB_SPEED_FULL;
dev->children[port] = usb;
usb->parent = dev;
2
1

[U-Boot] [USB EHCI V2 PATCH 0/2] Add initial support for USB ehci pci
by Michael Trimarchi 04 Jan '09
by Michael Trimarchi 04 Jan '09
04 Jan '09
Add USB ehci pci support. This patch doesn't include any
pci_ids and it is not tested on real hardware.
Signed-off-by: Michael Trimarchi <trimarchimichael(a)yahoo.it>
---
drivers/usb/Makefile | 1 +
drivers/usb/usb_ehci_pci.c | 64 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 65 insertions(+), 0 deletions(-)
create mode 100644 drivers/usb/usb_ehci_pci.c
diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
index 6ba154b..26189b6 100644
--- a/drivers/usb/Makefile
+++ b/drivers/usb/Makefile
@@ -35,6 +35,7 @@ COBJS-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o
COBJS-$(CONFIG_USB_R8A66597_HCD) += r8a66597-hcd.o
COBJS-$(CONFIG_USB_SL811HS) += sl811_usb.o
COBJS-$(CONFIG_USB_EHCI_FSL) += usb_ehci_fsl.o
+COBJS-$(CONFIG_USB_EHCI_PCI) += usb_ehci_pci.o
# device
ifdef CONFIG_USB_DEVICE
diff --git a/drivers/usb/usb_ehci_pci.c b/drivers/usb/usb_ehci_pci.c
new file mode 100644
index 0000000..3e7143c
--- /dev/null
+++ b/drivers/usb/usb_ehci_pci.c
@@ -0,0 +1,64 @@
+/*-
+ * Copyright (c) 2007-2008, Juniper Networks, Inc.
+ * All rights reserved.
+ *
+ * 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 version 2 of
+ * the License.
+ *
+ * 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 <pci.h>
+#include <usb.h>
+#include "usb_ehci.h"
+#include "usb_ehci_core.h"
+
+#ifdef CONFIG_PCI_EHCI_DEVICE
+static struct pci_device_id ehci_pci_ids[] = {
+ /* Please add supported PCI EHCI controller ids here */
+ {0, 0}
+};
+#endif
+
+/*
+ * Create the appropriate control structures to manage
+ * a new EHCI host controller.
+ */
+int ehci_hcd_init(void)
+{
+ pci_dev_t pdev;
+ uint32_t addr;
+
+ pdev = pci_find_devices(ehci_pci_ids, CONFIG_PCI_EHCI_DEVICE);
+ if (pdev == -1) {
+ printf("EHCI host controller not found\n");
+ return -1;
+ }
+
+ pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &addr);
+ hccr = (struct ehci_hccr *)addr;
+ hcor = (struct ehci_hcor *)((uint32_t) hccr +
+ HC_LENGTH(ehci_readl(&hccr->cr_capbase)));
+
+ return 0;
+}
+
+/*
+ * Destroy the appropriate control structures corresponding
+ * the the EHCI host controller.
+ */
+int ehci_hcd_stop(void)
+{
+ return 0;
+}
--
1.5.6.5
3
3

04 Jan '09
Fixing the get_timer function to return time in miliseconds instead of
ticks. Also fixed PXA boards to use the conventional value of 1000 for
CONFIG_SYS_HZ.
Signed-off-by: Micha Kalfon <smichak.uv(a)gmail.com>
---
cpu/pxa/interrupts.c | 25 ++++++++++++++++++-------
include/configs/cerf250.h | 2 +-
include/configs/cradle.h | 2 +-
include/configs/csb226.h | 2 +-
include/configs/delta.h | 2 +-
include/configs/innokom.h | 2 +-
include/configs/logodl.h | 2 +-
include/configs/lubbock.h | 2 +-
include/configs/pleb2.h | 2 +-
include/configs/pxa255_idp.h | 2 +-
include/configs/trizepsiv.h | 2 +-
include/configs/wepep250.h | 2 +-
include/configs/xaeniax.h | 2 +-
include/configs/xm250.h | 2 +-
include/configs/xsengine.h | 5 +----
include/configs/zylonite.h | 2 +-
16 files changed, 33 insertions(+), 25 deletions(-)
diff --git a/cpu/pxa/interrupts.c b/cpu/pxa/interrupts.c
index ec8fb9e..38af850 100644
--- a/cpu/pxa/interrupts.c
+++ b/cpu/pxa/interrupts.c
@@ -33,6 +33,14 @@
#error: interrupts not implemented yet
#endif
+#if defined(CONFIG_PXA27X) || defined(CONFIG_CPU_MONAHANS)
+#define TIMER_FREQ_HZ 3250000
+#elif defined(CONFIG_PXA250)
+#define TIMER_FREQ_HZ 3686400
+#else
+#error "Timer frequency unknown - please config PXA CPU type"
+#endif
+
int interrupt_init (void)
{
/* nothing happens here - we don't setup any IRQs */
@@ -67,7 +75,10 @@ void reset_timer_masked (void)
ulong get_timer_masked (void)
{
- return OSCR;
+ unsigned long long ticks = get_ticks();
+
+ return (((ticks / TIMER_FREQ_HZ) * 1000) +
+ ((ticks % TIMER_FREQ_HZ) * 1000) / TIMER_FREQ_HZ);
}
void udelay_masked (unsigned long usec)
@@ -78,17 +89,17 @@ void udelay_masked (unsigned long usec)
if (usec >= 1000) {
tmo = usec / 1000;
- tmo *= CONFIG_SYS_HZ;
+ tmo *= TIMER_FREQ_HZ;
tmo /= 1000;
} else {
- tmo = usec * CONFIG_SYS_HZ;
+ tmo = usec * TIMER_FREQ_HZ;
tmo /= (1000*1000);
}
- endtime = get_timer_masked () + tmo;
+ endtime = get_ticks() + tmo;
do {
- ulong now = get_timer_masked ();
+ ulong now = get_ticks();
diff = endtime - now;
} while (diff >= 0);
}
@@ -99,7 +110,7 @@ void udelay_masked (unsigned long usec)
*/
unsigned long long get_ticks(void)
{
- return get_timer(0);
+ return OSCR;
}
/*
@@ -109,6 +120,6 @@ unsigned long long get_ticks(void)
ulong get_tbclk (void)
{
ulong tbclk;
- tbclk = CONFIG_SYS_HZ;
+ tbclk = TIMER_FREQ_HZ;
return tbclk;
}
diff --git a/include/configs/cerf250.h b/include/configs/cerf250.h
index 71e5b58..376d3bf 100644
--- a/include/configs/cerf250.h
+++ b/include/configs/cerf250.h
@@ -117,7 +117,7 @@
#define CONFIG_SYS_LOAD_ADDR 0xa2000000 /* default load address */
-#define CONFIG_SYS_HZ 3686400 /* incrementer freq: 3.6864 MHz */
+#define CONFIG_SYS_HZ 1000 /* incrementer freq: 3.6864 MHz */
#define CONFIG_SYS_CPUSPEED 0x141 /* set core clock to 400/200/100 MHz */
#define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 }
diff --git a/include/configs/cradle.h b/include/configs/cradle.h
index e80504a..c15d13c 100644
--- a/include/configs/cradle.h
+++ b/include/configs/cradle.h
@@ -103,7 +103,7 @@
#define CONFIG_SYS_LOAD_ADDR 0xa2000000 /* default load address */
-#define CONFIG_SYS_HZ 3686400 /* incrementer freq: 3.6864 MHz */
+#define CONFIG_SYS_HZ 1000
#define CONFIG_SYS_CPUSPEED 0x141 /* set core clock to 200/200/100 MHz */
/* valid baudrates */
diff --git a/include/configs/csb226.h b/include/configs/csb226.h
index a24e34a..2e39925 100644
--- a/include/configs/csb226.h
+++ b/include/configs/csb226.h
@@ -131,7 +131,7 @@
/* RS: is this where U-Boot is */
/* RS: relocated to in RAM? */
-#define CONFIG_SYS_HZ 3686400 /* incrementer freq: 3.6864 MHz */
+#define CONFIG_SYS_HZ 1000
/* RS: the oscillator is actually 3680130?? */
#define CONFIG_SYS_CPUSPEED 0x141 /* set core clock to 200/200/100 MHz */
/* 0101000001 */
diff --git a/include/configs/delta.h b/include/configs/delta.h
index 08b28ca..c520106 100644
--- a/include/configs/delta.h
+++ b/include/configs/delta.h
@@ -173,7 +173,7 @@
#define CONFIG_SYS_LOAD_ADDR (CONFIG_SYS_DRAM_BASE + 0x8000) /* default load address */
-#define CONFIG_SYS_HZ 3250000 /* incrementer freq: 3.25 MHz */
+#define CONFIG_SYS_HZ 1000
/* Monahans Core Frequency */
#define CONFIG_SYS_MONAHANS_RUN_MODE_OSC_RATIO 16 /* valid values: 8, 16, 24, 31 */
diff --git a/include/configs/innokom.h b/include/configs/innokom.h
index 1b05b80..0e178ab 100644
--- a/include/configs/innokom.h
+++ b/include/configs/innokom.h
@@ -119,7 +119,7 @@
#define CONFIG_SYS_LOAD_ADDR 0xa3000000 /* load kernel to this address */
-#define CONFIG_SYS_HZ 3686400 /* incrementer freq: 3.6864 MHz */
+#define CONFIG_SYS_HZ 1000
/* RS: the oscillator is actually 3680130?? */
#define CONFIG_SYS_CPUSPEED 0x141 /* set core clock to 200/200/100 MHz */
diff --git a/include/configs/logodl.h b/include/configs/logodl.h
index bb6f943..34f92d0 100644
--- a/include/configs/logodl.h
+++ b/include/configs/logodl.h
@@ -112,7 +112,7 @@
#define CONFIG_SYS_LOAD_ADDR 0x08000000 /* load kernel to this address */
-#define CONFIG_SYS_HZ 3686400 /* incrementer freq: 3.6864 MHz */
+#define CONFIG_SYS_HZ 1000
/* RS: the oscillator is actually 3680130?? */
#define CONFIG_SYS_CPUSPEED 0x141 /* set core clock to 200/200/100 MHz */
diff --git a/include/configs/lubbock.h b/include/configs/lubbock.h
index 208910e..80cf44f 100644
--- a/include/configs/lubbock.h
+++ b/include/configs/lubbock.h
@@ -127,7 +127,7 @@
#define CONFIG_SYS_LOAD_ADDR (CONFIG_SYS_DRAM_BASE + 0x8000) /* default load address */
-#define CONFIG_SYS_HZ 3686400 /* incrementer freq: 3.6864 MHz */
+#define CONFIG_SYS_HZ 1000
#define CONFIG_SYS_CPUSPEED 0x161 /* set core clock to 400/200/100 MHz */
/* valid baudrates */
diff --git a/include/configs/pleb2.h b/include/configs/pleb2.h
index 14f8917..23398e3 100644
--- a/include/configs/pleb2.h
+++ b/include/configs/pleb2.h
@@ -126,7 +126,7 @@
#define CONFIG_SYS_LOAD_ADDR 0xa2000000 /* default load address */
-#define CONFIG_SYS_HZ 3686400 /* incrementer freq: 3.6864 MHz */
+#define CONFIG_SYS_HZ 1000
#define CONFIG_SYS_CPUSPEED 0x141 /* set core clock to 200/200/100 MHz */
/* valid baudrates */
diff --git a/include/configs/pxa255_idp.h b/include/configs/pxa255_idp.h
index f81103b..fa53cf4 100644
--- a/include/configs/pxa255_idp.h
+++ b/include/configs/pxa255_idp.h
@@ -241,7 +241,7 @@
#define CONFIG_SYS_LOAD_ADDR 0xa0800000 /* default load address */
-#define CONFIG_SYS_HZ 3686400 /* incrementer freq: 3.6864 MHz */
+#define CONFIG_SYS_HZ 1000
#define CONFIG_SYS_CPUSPEED 0x161 /* set core clock to 400/200/100 MHz */
#define RTC 1 /* enable 32KHz osc */
diff --git a/include/configs/trizepsiv.h b/include/configs/trizepsiv.h
index b2065ee..93e4215 100644
--- a/include/configs/trizepsiv.h
+++ b/include/configs/trizepsiv.h
@@ -170,7 +170,7 @@
#define CONFIG_SYS_LOAD_ADDR 0xa1000000 /* default load address */
-#define CONFIG_SYS_HZ 3686400 /* incrementer freq: 3.6864 MHz */
+#define CONFIG_SYS_HZ 1000
#define CONFIG_SYS_CPUSPEED 0x207 /* need to look more closely, I think this is Turbo = 2x, L=91Mhz */
/* valid baudrates */
diff --git a/include/configs/wepep250.h b/include/configs/wepep250.h
index b70a531..a8e2829 100644
--- a/include/configs/wepep250.h
+++ b/include/configs/wepep250.h
@@ -81,7 +81,7 @@
#undef CONFIG_SYS_CLKS_IN_HZ /* use HZ for freq. display */
-#define CONFIG_SYS_HZ 3686400 /* incrementer freq: 3.6864 MHz */
+#define CONFIG_SYS_HZ 1000
#define CONFIG_SYS_CPUSPEED 0x141 /* core clock - register value */
#define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 }
diff --git a/include/configs/xaeniax.h b/include/configs/xaeniax.h
index 324f03e..250247c 100644
--- a/include/configs/xaeniax.h
+++ b/include/configs/xaeniax.h
@@ -138,7 +138,7 @@
#define CONFIG_SYS_LOAD_ADDR 0xa1000000 /* default load address */
-#define CONFIG_SYS_HZ 3686400 /* incrementer freq: 3.6864 MHz */
+#define CONFIG_SYS_HZ 1000
#define CONFIG_SYS_CPUSPEED 0x141 /* set core clock to 400/200/100 MHz */
/*
diff --git a/include/configs/xm250.h b/include/configs/xm250.h
index 16af845..8e9d5ab 100644
--- a/include/configs/xm250.h
+++ b/include/configs/xm250.h
@@ -121,7 +121,7 @@
#define CONFIG_SYS_LOAD_ADDR 0xa3000000 /* default load address */
-#define CONFIG_SYS_HZ 3686400 /* incrementer freq: 3.6864 MHz */
+#define CONFIG_SYS_HZ 1000
#define CONFIG_SYS_CPUSPEED 0x161 /* set core clock to 400/400/100 MHz */
/* valid baudrates */
diff --git a/include/configs/xsengine.h b/include/configs/xsengine.h
index b727413..2fca956 100644
--- a/include/configs/xsengine.h
+++ b/include/configs/xsengine.h
@@ -35,10 +35,7 @@
#define CONFIG_DOS_PARTITION 1
#define BOARD_LATE_INIT 1
#undef CONFIG_USE_IRQ /* we don't need IRQ/FIQ stuff */
-#define CONFIG_SYS_HZ 3686400 /* incrementer freq: 3.6864 MHz */
-
-#undef CONFIG_USE_IRQ /* we don't need IRQ/FIQ stuff */
-#define CONFIG_SYS_HZ 3686400 /* incrementer freq: 3.6864 MHz */
+#define CONFIG_SYS_HZ 1000
#define CONFIG_SYS_CPUSPEED 0x161 /* set core clock to 400/200/100 MHz */
#define CONFIG_NR_DRAM_BANKS 1 /* we have 1 bank of DRAM */
diff --git a/include/configs/zylonite.h b/include/configs/zylonite.h
index 53397d8..5ab71a7 100644
--- a/include/configs/zylonite.h
+++ b/include/configs/zylonite.h
@@ -143,7 +143,7 @@
#define CONFIG_SYS_LOAD_ADDR (CONFIG_SYS_DRAM_BASE + 0x8000) /* default load address */
-#define CONFIG_SYS_HZ 3250000 /* incrementer freq: 3.25 MHz */
+#define CONFIG_SYS_HZ 1000
/* Monahans Core Frequency */
#define CONFIG_SYS_MONAHANS_RUN_MODE_OSC_RATIO 16 /* valid values: 8, 16, 24, 31 */
--
1.5.6.4
2
1

[U-Boot] [PATCH] IXP425: make cmd_go handle caches correctly Part 1/1
by Stefan Althoefer 04 Jan '09
by Stefan Althoefer 04 Jan '09
04 Jan '09
[PATCH] IXP425: make cmd_go handle caches correctly
This patch adds icache_invalidate() and dcache_flush() to
cpu/ixp/cpu.c.
Also it adds do_go_exec() which is called from do_go().
This private implementation performs cache handling
before jumping into the code.
Without this cache handling, you will jump into stale
code if you download a program several times.
The patch is against "latest" u-boot git-repository
Please (still) be patient if style of submission or patches are
offending.
Signed-off-by: Stefan Althoefer <stefan.althoefer(a)web.de>
----
diff -uprN u-boot-orig//cpu/ixp/cpu.c u-boot/cpu/ixp/cpu.c
--- u-boot-orig//cpu/ixp/cpu.c 2008-12-02 17:25:31.000000000 +0100
+++ u-boot/cpu/ixp/cpu.c 2008-12-03 11:35:37.000000000 +0100
@@ -171,6 +207,22 @@ int icache_status (void)
return (i & 0x1000);
}
+void icache_invalidate (void)
+{
+ register u32 i;
+
+ /* FIXME: Required to check if icache is enabled before we do this? */
+
+ /* invalidate I-cache (i is ignored)*/
+ i = 0;
+ asm ("mcr p15, 0, %0, c7, c5, 0": :"r" (i));
+
+ /* cpwait */
+ asm ("mrc p15,0,%0,c2,c0,0;\
+ mov %0,%0;\
+ sub pc,pc,#4" : : "r" (i) );
+}
+
/* we will never enable dcache, because we have to setup MMU first */
void dcache_enable (void)
{
@@ -187,6 +239,11 @@ int dcache_status (void)
return 0; /* always off */
}
+void dcache_flush (void)
+{
+ return;
+}
+
/* FIXME */
/*
void pci_init(void)
@@ -195,6 +252,17 @@ void pci_init(void)
}
*/
+/* With IXP (and ARM generally) we need to handle caches to avoid
+ stale data. */
+unsigned long do_go_exec (ulong (*entry)(int, char *[]), int argc, char *argv[])
+{
+ dcache_flush();
+ icache_invalidate();
+
+ return entry (argc, argv);
+}
+
+
#ifdef CONFIG_BOOTCOUNT_LIMIT
void bootcount_store (ulong a)
3
3

04 Jan '09
[PATCH] IDE: Improving speed on reading data
This patch improves the speed when reading blocks from
IDE devices by reading more than one block at a time. Up to
128 blocks are requested in one read command.
On my testplatform (Janz emPC-A400 with CompactFLASH card)
this nearly doubled speed.
Also the ide_wait() code was rewritten to have lower latency
by polling more frequently for status.
The patch is against "latest" u-boot git-repository
Please (still) be patient if style of submission or patches are
offending.
Signed-off-by: Stefan Althoefer <stefan.althoefer(a)web.de>
----
diff -uprN u-boot-orig//common/cmd_ide.c u-boot/common/cmd_ide.c
--- u-boot-orig//common/cmd_ide.c 2008-12-02 17:25:31.000000000 +0100
+++ u-boot/common/cmd_ide.c 2008-12-03 09:22:29.000000000 +0100
@@ -1302,6 +1361,7 @@ ulong ide_read (int device, lbaint_t blk
ulong n = 0;
unsigned char c;
unsigned char pwrsave=0; /* power save */
+ ulong scnt;
#ifdef CONFIG_LBA48
unsigned char lba48 = 0;
@@ -1346,7 +1406,7 @@ ulong ide_read (int device, lbaint_t blk
}
- while (blkcnt-- > 0) {
+ while (blkcnt > 0) {
c = ide_wait (device, IDE_TIME_OUT);
@@ -1368,7 +1428,8 @@ ulong ide_read (int device, lbaint_t blk
#endif
}
#endif
- ide_outb (device, ATA_SECT_CNT, 1);
+ scnt = (blkcnt > 128) ? 128 : blkcnt;
+ ide_outb (device, ATA_SECT_CNT, scnt);
ide_outb (device, ATA_LBA_LOW, (blknr >> 0) & 0xFF);
ide_outb (device, ATA_LBA_MID, (blknr >> 8) & 0xFF);
ide_outb (device, ATA_LBA_HIGH, (blknr >> 16) & 0xFF);
@@ -1387,32 +1448,36 @@ ulong ide_read (int device, lbaint_t blk
ide_outb (device, ATA_COMMAND, ATA_CMD_READ);
}
- udelay (50);
+ while (scnt > 0) {
+ udelay (50);
- if(pwrsave) {
- c = ide_wait (device, IDE_SPIN_UP_TIME_OUT); /* may take up to 4 sec */
- pwrsave=0;
- } else {
- c = ide_wait (device, IDE_TIME_OUT); /* can't take over 500 ms */
- }
+ if(pwrsave) {
+ c = ide_wait (device, IDE_SPIN_UP_TIME_OUT); /* may take up to 4 sec */
+ pwrsave=0;
+ } else {
+ c = ide_wait (device, IDE_TIME_OUT); /* can't take over 500 ms */
+ }
- if ((c&(ATA_STAT_DRQ|ATA_STAT_BUSY|ATA_STAT_ERR)) != ATA_STAT_DRQ) {
+ if ((c&(ATA_STAT_DRQ|ATA_STAT_BUSY|ATA_STAT_ERR)) != ATA_STAT_DRQ) {
#if defined(CONFIG_SYS_64BIT_LBA) && defined(CONFIG_SYS_64BIT_VSPRINTF)
- printf ("Error (no IRQ) dev %d blk %qd: status 0x%02x\n",
- device, blknr, c);
+ printf ("Error (no IRQ) dev %d blk %qd: status 0x%02x\n",
+ device, blknr, c);
#else
- printf ("Error (no IRQ) dev %d blk %ld: status 0x%02x\n",
- device, (ulong)blknr, c);
+ printf ("Error (no IRQ) dev %d blk %ld: status 0x%02x\n",
+ device, (ulong)blknr, c);
#endif
- break;
- }
+ break;
+ }
- input_data (device, buffer, ATA_SECTORWORDS);
- (void) ide_inb (device, ATA_STATUS); /* clear IRQ */
-
- ++n;
- ++blknr;
- buffer += ATA_BLOCKSIZE;
+ input_data (device, buffer, ATA_SECTORWORDS);
+ (void) ide_inb (device, ATA_STATUS); /* clear IRQ */
+
+ ++n;
+ ++blknr;
+ --blkcnt;
+ --scnt;
+ buffer += ATA_BLOCKSIZE;
+ }
}
IDE_READ_E:
ide_led (DEVICE_LED(device), 0); /* LED off */
@@ -1548,11 +1613,11 @@ OUT:
*/
static uchar ide_wait (int dev, ulong t)
{
- ulong delay = 10 * t; /* poll every 100 us */
+ ulong delay = (1000/5) * t; /* poll every 5 us */
uchar c;
while ((c = ide_inb(dev, ATA_STATUS)) & ATA_STAT_BUSY) {
- udelay (100);
+ udelay (5);
if (delay-- == 0) {
break;
}
3
3
[PATCH] IXP425: Fixing timer code
The non-interrupted timer code is inaccurate.
I found that the timing error of udelay() is caused by
to much looping overhead. The actual timing routine
was called repeatedly for each microsecond. When
I used bigger slices it became more accurate.
Some IXP425 ports have this line in their config file:
#define CONFIG_SYS_HZ 3333333 /* spec says 66.666 MHz,
but it appears to be 33 */
With this patch, this is nonsense. Instead you should use:
#ifdef CONFIG_USE_IRQ
/* Interrupt driven timer wants system tick here */
#define CONFIG_SYS_HZ 1000
#else
/* The code in cpu/ixp/timer.c needs timer clock tick in HZ */
#define CONFIG_SYS_HZ 66666666
#endif
The patch is against "latest" u-boot git-repository
Please (still) be patient if style of submission or patches are
offending.
Signed-off-by: Stefan Althoefer <stefan.althoefer(a)web.de>
----
diff -uprN u-boot-orig//cpu/ixp/timer.c u-boot/cpu/ixp/timer.c
--- u-boot-orig//cpu/ixp/timer.c 2008-12-02 17:25:31.000000000 +0100
+++ u-boot/cpu/ixp/timer.c 2008-12-02 22:27:22.000000000 +0100
@@ -46,6 +46,8 @@ void ixp425_udelay(unsigned long usec)
*/
unsigned long usecs = CONFIG_SYS_HZ/1000000L & ~IXP425_OST_RELOAD_MASK;
+ usecs *= usec;
+
*IXP425_OSST = IXP425_OSST_TIMER_1_PEND;
usecs |= IXP425_OST_ONE_SHOT | IXP425_OST_ENABLE;
*IXP425_OSRT1 = usecs;
@@ -54,7 +56,13 @@ void ixp425_udelay(unsigned long usec)
void udelay (unsigned long usec)
{
- while (usec--) ixp425_udelay(1);
+ /* ipx425_udelay has big overhead, so call it in bigger slices */
+ while (usec>1000){
+ ixp425_udelay(1000);
+ usec -= 1000;
+ }
+ /* and now the rest */
+ ixp425_udelay(usec);
}
static ulong reload_constant = 0xfffffff0;
3
4
V2 NAND_SPL support for phycore imx31
Changelog:
* Added bad block verify and skip;
* Correct code to codestyle;
* Added few comments;
Signed-off-by: Maxim Artamonov <scn1874 at yandex.ru>
---
MAKEALL | 1 +
Makefile | 9 ++-
board/imx31_phycore/config.mk | 10 ++
board/imx31_phycore/lowlevel_init.S | 27 ++++-
board/imx31_phycore/u-boot-nand.lds | 62 ++++++++++
cpu/arm1136/start.S | 36 +++++--
include/asm-arm/arch-mx31/mx31-regs.h | 96 ++++++++++++++++
include/configs/imx31_phycore.h | 59 ++++++++--
nand_spl/board/imx31_phycore/Makefile | 95 +++++++++++++++
nand_spl/board/imx31_phycore/config.mk | 33 ++++++
nand_spl/board/imx31_phycore/u-boot.lds | 65 +++++++++++
nand_spl/nand_boot_mx31.c | 190 +++++++++++++++++++++++++++++++
12 files changed, 661 insertions(+), 22 deletions(-)
create mode 100644 board/imx31_phycore/u-boot-nand.lds
create mode 100644 nand_spl/board/imx31_phycore/Makefile
create mode 100644 nand_spl/board/imx31_phycore/config.mk
create mode 100644 nand_spl/board/imx31_phycore/u-boot.lds
create mode 100644 nand_spl/nand_boot_mx31.c
diff --git a/MAKEALL b/MAKEALL
index 9ccb9ac..1f639a8 100755
--- a/MAKEALL
+++ b/MAKEALL
@@ -522,6 +522,7 @@ LIST_ARM11=" \
apollon \
imx31_litekit \
imx31_phycore \
+ imx31_phycore_nand \
mx31ads \
smdk6400 \
"
diff --git a/Makefile b/Makefile
index 58b8331..7519dfe 100644
--- a/Makefile
+++ b/Makefile
@@ -353,7 +353,7 @@ $(NAND_SPL): $(VERSION_FILE) $(obj)include/autoconf.mk
$(MAKE) -C nand_spl/board/$(BOARDDIR) all
$(U_BOOT_NAND): $(NAND_SPL) $(obj)u-boot.bin $(obj)include/autoconf.mk
- cat $(obj)nand_spl/u-boot-spl-16k.bin $(obj)u-boot.bin > $(obj)u-boot-nand.bin
+ cat $(obj)nand_spl/u-boot-spl-aligned.bin $(obj)u-boot.bin > $(obj)u-boot-nand.bin
$(ONENAND_IPL): $(VERSION_FILE) $(obj)include/autoconf.mk
$(MAKE) -C onenand_ipl/board/$(BOARDDIR) all
@@ -2805,6 +2805,13 @@ imx31_litekit_config : unconfig
imx31_phycore_config : unconfig
@$(MKCONFIG) $(@:_config=) arm arm1136 imx31_phycore NULL mx31
+imx31_phycore_nand_config : unconfig
+ @mkdir -p $(obj)include $(obj)board/imx31_phycore
+ @mkdir -p $(obj)nand_spl/board/imx31_phycore
+ @echo "#define CONFIG_NAND_U_BOOT" > $(obj)include/config.h
+ @$(MKCONFIG) -n $@ -a imx31_phycore arm arm1136 imx31_phycore NULL mx31
+ @echo "CONFIG_NAND_U_BOOT = y" >> $(obj)include/config.mk
+
mx31ads_config : unconfig
@$(MKCONFIG) $(@:_config=) arm arm1136 mx31ads freescale mx31
diff --git a/board/imx31_phycore/config.mk b/board/imx31_phycore/config.mk
index d34dc02..412defc 100644
--- a/board/imx31_phycore/config.mk
+++ b/board/imx31_phycore/config.mk
@@ -1 +1,11 @@
+#
+# (C) Copyright 2008
+# was changed by Maxim Artamonov, <scn1874 at yandex.ru>
+#
+
+ifndef CONFIG_NAND_SPL
TEXT_BASE = 0x87f00000
+else
+TEXT_BASE = 0x87ec0000
+endif
+
diff --git a/board/imx31_phycore/lowlevel_init.S b/board/imx31_phycore/lowlevel_init.S
index c5d6eb0..afae317 100644
--- a/board/imx31_phycore/lowlevel_init.S
+++ b/board/imx31_phycore/lowlevel_init.S
@@ -1,5 +1,7 @@
/*
- *
+ * (C) Copyright 2008
+ * Maxim Artamonov, <scn1874 at yandex.ru>
+ *
* (c) 2007 Pengutronix, Sascha Hauer <s.hauer(a)pengutronix.de>
*
* See file CREDITS for list of people who contributed to this
@@ -43,6 +45,20 @@
bcs 1b
.endm
+#ifdef CONFIG_NAND_SPL
+/* somewhat macro to reduce bin size for CONFIG_NAND_SPL*/
+.macro FILLREGS begreg, val, count, step
+ ldr r2, =\begreg
+ ldr r3, =\val
+ ldr r4, =\count
+2:
+ str r3, [r2]
+ add r2, r2, #\step
+ subs r4, r4, #1
+ bcs 2b
+.endm
+#endif
+
.globl lowlevel_init
lowlevel_init:
@@ -60,10 +76,18 @@ lowlevel_init:
REG CCM_SPCTL, PLL_PD(1) | PLL_MFD(0x43) | PLL_MFI(12) | PLL_MFN(1)
+#ifdef CONFIG_NAND_SPL
+ FILLREGS 0x43FAC26C, 0, 0x3, 0x4
+#else
REG 0x43FAC26C, 0 /* SDCLK */
REG 0x43FAC270, 0 /* CAS */
REG 0x43FAC274, 0 /* RAS */
+#endif /* CONFIG_NAND_SPL */
REG 0x43FAC27C, 0x1000 /* CS2 (CSD0) */
+
+#ifdef CONFIG_NAND_SPL
+ FILLREGS 0x43FAC284, 0, 0x17, 0x4
+#else
REG 0x43FAC284, 0 /* DQM3 */
REG 0x43FAC288, 0 /* DQM2, DQM1, DQM0, SD31-SD0, A25-A0, MA10 (0x288..0x2DC) */
REG 0x43FAC28C, 0
@@ -87,6 +111,7 @@ lowlevel_init:
REG 0x43FAC2D4, 0
REG 0x43FAC2D8, 0
REG 0x43FAC2DC, 0
+#endif /* CONFIG_NAND_SPL */
REG 0xB8001010, 0x00000004
REG 0xB8001004, 0x006ac73a
REG 0xB8001000, 0x92100000
diff --git a/board/imx31_phycore/u-boot-nand.lds b/board/imx31_phycore/u-boot-nand.lds
new file mode 100644
index 0000000..bd09a8d
--- /dev/null
+++ b/board/imx31_phycore/u-boot-nand.lds
@@ -0,0 +1,62 @@
+/*
+ * (C) Copyright 2008
+ * Maxim Artamonov, <scn1874 at yandex.ru>
+ *
+ * January 2004 - Changed to support H4 device
+ * Copyright (c) 2004 Texas Instruments
+ *
+ * (C) Copyright 2002
+ * Gary Jennejohn, DENX Software Engineering, <gj(a)denx.de>
+ *
+ * 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
+ */
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(_start)
+SECTIONS
+{
+ . = 0x00000000;
+
+ . = ALIGN(4);
+ .text :
+ {
+ cpu/arm1136/start.o (.text)
+ *(.text)
+ }
+
+ . = ALIGN(4);
+ .rodata : { *(.rodata) }
+
+ . = ALIGN(4);
+ .data : { *(.data) }
+
+ . = ALIGN(4);
+ .got : { *(.got) }
+
+ . = .;
+ __u_boot_cmd_start = .;
+ .u_boot_cmd : { *(.u_boot_cmd) }
+ __u_boot_cmd_end = .;
+
+ . = ALIGN(4);
+ __bss_start = .;
+ .bss : { *(.bss) }
+ _end = .;
+}
diff --git a/cpu/arm1136/start.S b/cpu/arm1136/start.S
index 51b664d..596efe9 100644
--- a/cpu/arm1136/start.S
+++ b/cpu/arm1136/start.S
@@ -1,6 +1,9 @@
/*
* armboot - Startup Code for OMP2420/ARM1136 CPU-core
*
+ *
+ * Copyright (c) 2008 Maxim Artamonov, <scn1874 at yandex.ru>
+ *
* Copyright (c) 2004 Texas Instruments <r-woodruff2(a)ti.com>
*
* Copyright (c) 2001 Marius Gr�ger <mag(a)sysgo.de>
@@ -32,6 +35,15 @@
#include <version.h>
.globl _start
_start: b reset
+#ifdef CONFIG_NAND_SPL
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+#else
#ifdef CONFIG_ONENAND_IPL
ldr pc, _hang
ldr pc, _hang
@@ -68,6 +80,7 @@ _irq: .word irq
_fiq: .word fiq
_pad: .word 0x12345678 /* now 16*4=64 */
#endif /* CONFIG_ONENAND_IPL */
+#endif /* CONFIG_NAND_SPL */
.global _end_vect
_end_vect:
@@ -156,9 +169,9 @@ relocate: /* relocate U-Boot to RAM */
adr r0, _start /* r0 <- current position of code */
ldr r1, _TEXT_BASE /* test if we run from flash or RAM */
cmp r0, r1 /* don't reloc during debug */
-#ifndef CONFIG_ONENAND_IPL
+#if !defined(CONFIG_ONENAND_IPL) && !defined(CONFIG_NAND_SPL)
beq stack_setup
-#endif /* CONFIG_ONENAND_IPL */
+#endif /* !CONFIG_ONENAND_IPL && !CONFIG_NAND_SPL*/
ldr r2, _armboot_start
ldr r3, _bss_start
@@ -175,7 +188,7 @@ copy_loop:
/* Set up the stack */
stack_setup:
ldr r0, _TEXT_BASE /* upper 128 KiB: relocated uboot */
-#ifdef CONFIG_ONENAND_IPL
+#if defined(CONFIG_ONENAND_IPL) || defined (CONFIG_NAND_SPL)
sub sp, r0, #128 /* leave 32 words for abort-stack */
#else
sub r0, r0, #CFG_MALLOC_LEN /* malloc area */
@@ -184,14 +197,14 @@ stack_setup:
sub r0, r0, #(CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ)
#endif
sub sp, r0, #12 /* leave 3 words for abort-stack */
-#endif /* CONFIG_ONENAND_IPL */
+#endif /* CONFIG_ONENAND_IPL || CONFIG_NAND_SPL*/
clear_bss:
ldr r0, _bss_start /* find start of bss segment */
ldr r1, _bss_end /* stop here */
mov r2, #0x00000000 /* clear */
-#ifndef CONFIG_ONENAND_IPL
+#if !defined(CONFIG_ONENAND_IPL) && !defined(CONFIG_NAND_SPL)
clbss_l:str r2, [r0] /* clear loop... */
add r0, r0, #4
cmp r0, r1
@@ -200,12 +213,15 @@ clbss_l:str r2, [r0] /* clear loop... */
ldr pc, _start_armboot
+#ifdef CONFIG_NAND_SPL
+_start_armboot: .word nand_boot
+#else
#ifdef CONFIG_ONENAND_IPL
_start_armboot: .word start_oneboot
#else
_start_armboot: .word start_armboot
-#endif
-
+#endif /* CONFIG_ONENAND_IPL */
+#endif /* CONFIG_NAND_SPL */
/*
*************************************************************************
@@ -244,7 +260,7 @@ cpu_init_crit:
mov lr, ip /* restore link */
mov pc, lr /* back to my caller */
-#ifndef CONFIG_ONENAND_IPL
+#if !defined(CONFIG_ONENAND_IPL) && !defined(CONFIG_NAND_SPL)
/*
*************************************************************************
*
@@ -357,11 +373,12 @@ cpu_init_crit:
.macro get_fiq_stack @ setup FIQ stack
ldr sp, FIQ_STACK_START
.endm
-#endif /* CONFIG_ONENAND_IPL */
+#endif /* !CONFIG_ONENAND_IPL && !CONFIG_NAND_SPL*/
/*
* exception handlers
*/
+#ifndef CONFIG_NAND_SPL
#ifdef CONFIG_ONENAND_IPL
.align 5
do_hang:
@@ -436,3 +453,4 @@ arm1136_cache_flush:
mcr p15, 0, r1, c7, c5, 0 @ invalidate I cache
mov pc, lr @ back to caller
#endif /* CONFIG_ONENAND_IPL */
+#endif /* !CONFIG_NAND_SPL*/
diff --git a/include/asm-arm/arch-mx31/mx31-regs.h b/include/asm-arm/arch-mx31/mx31-regs.h
index b04a718..78825f5 100644
--- a/include/asm-arm/arch-mx31/mx31-regs.h
+++ b/include/asm-arm/arch-mx31/mx31-regs.h
@@ -168,4 +168,100 @@
#define CS5_BASE 0xB6000000
#define PCMCIA_MEM_BASE 0xC0000000
+/*
+ * NAND controller
+ */
+#define NFC_BASE_ADDR 0xB8000000
+
+/*
+ * Addresses for NFC registers
+ */
+#define NFC_BUF_SIZE (*((volatile u16 *)(NFC_BASE_ADDR + 0xE00)))
+#define NFC_BUF_ADDR (*((volatile u16 *)(NFC_BASE_ADDR + 0xE04)))
+#define NFC_FLASH_ADDR (*((volatile u16 *)(NFC_BASE_ADDR + 0xE06)))
+#define NFC_FLASH_CMD (*((volatile u16 *)(NFC_BASE_ADDR + 0xE08)))
+#define NFC_CONFIG (*((volatile u16 *)(NFC_BASE_ADDR + 0xE0A)))
+#define NFC_ECC_STATUS_RESULT (*((volatile u16 *)(NFC_BASE_ADDR + 0xE0C)))
+#define NFC_RSLTMAIN_AREA (*((volatile u16 *)(NFC_BASE_ADDR + 0xE0E)))
+#define NFC_RSLTSPARE_AREA (*((volatile u16 *)(NFC_BASE_ADDR + 0xE10)))
+#define NFC_WRPROT (*((volatile u16 *)(NFC_BASE_ADDR + 0xE12)))
+#define NFC_UNLOCKSTART_BLKADDR (*((volatile u16 *)(NFC_BASE_ADDR + 0xE14)))
+#define NFC_UNLOCKEND_BLKADDR (*((volatile u16 *)(NFC_BASE_ADDR + 0xE16)))
+#define NFC_NF_WRPRST (*((volatile u16 *)(NFC_BASE_ADDR + 0xE18)))
+#define NFC_CONFIG1 (*((volatile u16 *)(NFC_BASE_ADDR + 0xE1A)))
+#define NFC_CONFIG2 (*((volatile u16 *)(NFC_BASE_ADDR + 0xE1C)))
+
+/*
+ * Addresses for NFC RAM BUFFER Main area 0
+ */
+#define MAIN_AREA0 (volatile u16 *)(NFC_BASE_ADDR + 0x000)
+#define MAIN_AREA1 (volatile u16 *)(NFC_BASE_ADDR + 0x200)
+#define MAIN_AREA2 (volatile u16 *)(NFC_BASE_ADDR + 0x400)
+#define MAIN_AREA3 (volatile u16 *)(NFC_BASE_ADDR + 0x600)
+
+/*
+ * Addresses for NFC SPARE BUFFER Spare area 0
+ */
+#define SPARE_AREA0 (volatile u16 *)(NFC_BASE_ADDR + 0x800)
+#define SPARE_AREA1 (volatile u16 *)(NFC_BASE_ADDR + 0x810)
+#define SPARE_AREA2 (volatile u16 *)(NFC_BASE_ADDR + 0x820)
+#define SPARE_AREA3 (volatile u16 *)(NFC_BASE_ADDR + 0x830)
+
+/*
+ * Set INT to 0, FCMD to 1, rest to 0 in NFC_CONFIG2 Register for Command
+ * operation
+ */
+#define NFC_CMD 0x1
+
+/*
+ * Set INT to 0, FADD to 1, rest to 0 in NFC_CONFIG2 Register for Address
+ * operation
+ */
+#define NFC_ADDR 0x2
+
+/*
+ * Set INT to 0, FDI to 1, rest to 0 in NFC_CONFIG2 Register for Input
+ * operation
+ */
+#define NFC_INPUT 0x4
+
+/*
+ * Set INT to 0, FDO to 001, rest to 0 in NFC_CONFIG2 Register for Data
+ * Output operation
+ */
+#define NFC_OUTPUT 0x8
+
+/*
+ * Set INT to 0, FD0 to 010, rest to 0 in NFC_CONFIG2 Register for Read ID
+ * operation
+ */
+#define NFC_ID 0x10
+
+/*
+ * Set INT to 0, FDO to 100, rest to 0 in NFC_CONFIG2 Register for Read
+ * Status operation
+ */
+#define NFC_STATUS 0x20
+
+/*
+ * Set INT to 1, rest to 0 in NFC_CONFIG2 Register for Read Status
+ * operation
+ */
+#define NFC_INT 0x8000
+
+#define NFC_SP_EN (1 << 2)
+#define NFC_ECC_EN (1 << 3)
+#define NFC_INT_MSK (1 << 4)
+#define NFC_BIG (1 << 5)
+#define NFC_RST (1 << 6)
+#define NFC_CE (1 << 7)
+#define NFC_ONE_CYCLE (1 << 8)
+
+/*
+ * NFMS bit in RCSR register for pagesize of nandflash
+ */
+#define NFMS (*((volatile u32 *)CCM_RCSR))
+#define NFMS_BIT 30
+
#endif /* __ASM_ARCH_MX31_REGS_H */
+
diff --git a/include/configs/imx31_phycore.h b/include/configs/imx31_phycore.h
index 1540203..946fd19 100644
--- a/include/configs/imx31_phycore.h
+++ b/include/configs/imx31_phycore.h
@@ -1,4 +1,7 @@
/*
+ * (C) Copyright 2008
+ * Maxim Artamonov, <scn1874 at yandex.ru>
+ *
* (C) Copyright 2004
* Texas Instruments.
* Richard Woodruff <r-woodruff2(a)ti.com>
@@ -34,6 +37,11 @@
#define CONFIG_MX31_HCLK_FREQ 26000000
#define CONFIG_MX31_CLK32 32000
+#if defined(CONFIG_NAND_U_BOOT) && !defined(CONFIG_NAND_SPL)
+#define CONFIG_SKIP_LOWLEVEL_INIT
+#define CONFIG_SKIP_RELOCATE_UBOOT
+#endif
+
#define CONFIG_DISPLAY_CPUINFO
#define CONFIG_DISPLAY_BOARDINFO
@@ -85,26 +93,30 @@
#define CONFIG_BOOTDELAY 3
-#define MTDPARTS_DEFAULT "mtdparts=physmap-flash.0:128k(uboot)ro,1536k(kernel),-(root)"
+#define MTDPARTS_DEFAULT "mtdparts=phys_mapped_flash.0:128k(uboot)ro,128k(env),1792k(kernel),-(root)"
#define CONFIG_NETMASK 255.255.255.0
-#define CONFIG_IPADDR 192.168.23.168
-#define CONFIG_SERVERIP 192.168.23.2
+#define CONFIG_IPADDR 192.168.3.11
+#define CONFIG_SERVERIP 192.168.3.10
#define CONFIG_EXTRA_ENV_SETTINGS \
- "bootargs_base=setenv bootargs console=ttySMX0,115200\0" \
- "bootargs_nfs=setenv bootargs $(bootargs) root=/dev/nfs ip=dhcp nfsroot=$(serverip):$(nfsrootfs),v3,tcp\0" \
- "bootargs_flash=setenv bootargs $(bootargs) root=/dev/mtdblock2 rootfstype=jffs2" \
- "bootargs_mtd=setenv bootargs $(bootargs) $(mtdparts)" \
+ "jffs2=root-pcm037.jffs2\0" \
+ "uimage=uImage-pcm037\0" \
+ "nfsrootfs=/nfsroot\0" \
"bootcmd=run bootcmd_net\0" \
+ "mtdids=nor0=phys_mapped_flash\0" \
+ "bootargs_base=setenv bootargs console=ttymxc0,115200\0" \
+ "bootargs_nfs=setenv bootargs $(bootargs) root=/dev/nfs ip=dhcp nfsroot=$(serverip):$(nfsrootfs),v3,tcp\0" \
+ "bootargs_mtd=setenv bootargs $(bootargs) $(mtdparts)\0" \
+ "bootargs_flash=setenv bootargs $(bootargs) root=/dev/mtdblock3 rootfstype=jffs2\0" \
"bootcmd_net=run bootargs_base bootargs_mtd bootargs_nfs; tftpboot 0x80000000 $(uimage); bootm\0" \
- "bootcmd_flash=run bootargs_base bootargs_mtd bootargs_flash; bootm 0x80000000\0" \
+ "bootcmd_flash=run bootargs_base bootargs_mtd bootargs_flash; bootm 0xa0040000\0" \
+ "bootcmd_netflash=run bootargs_base bootargs_mtd bootargs_flash; tftpboot 0x80000000 $(uimage); bootm\0" \
"unlock=yes\0" \
"mtdparts=" MTDPARTS_DEFAULT "\0" \
"prg_uboot=tftpboot 0x80000000 $(uboot); protect off 0xa0000000 +0x20000; erase 0xa0000000 +0x20000; cp.b 0x80000000 0xa0000000 $(filesize)\0" \
- "prg_kernel=tftpboot 0x80000000 $(uimage); erase 0xa0040000 +0x180000; cp.b 0x80000000 0xa0040000 $(filesize)\0" \
- "prg_jffs2=tftpboot 0x80000000 $(jffs2); erase 0xa01c0000 0xa1ffffff; cp.b 0x80000000 0xa01c0000 $(filesize)\0"
-
+ "prg_kernel=tftpboot 0x80000000 $(uimage); erase 0xa0040000 +0x1C0000; cp.b 0x80000000 0xa0040000 $(filesize)\0" \
+ "prg_jffs2=tftpboot 0x80000000 $(jffs2); erase 0xa0200000 0xa1ffffff; cp.b 0x80000000 0xa0200000 $(filesize)\0"
#define CONFIG_DRIVER_SMC911X 1
#define CONFIG_DRIVER_SMC911X_BASE 0xa8000000
@@ -172,6 +184,31 @@
#define CFG_FLASH_ERASE_TOUT (100*CFG_HZ) /* Timeout for Flash Erase */
#define CFG_FLASH_WRITE_TOUT (100*CFG_HZ) /* Timeout for Flash Write */
+/*-----------------------------------------------------------------------
+ * NAND flash
+ */
+
+#define NAND_MAX_CHIPS 1
+#define CFG_MAX_NAND_DEVICE 1
+#define CFG_NAND_BASE 0x40000000
+
+/*
+ * Because of small buffer size of NFC in iMX31, SPL has to fit into 2kB.
+ */
+
+/*CFG_NAND_U_BOOT_OFFS and CFG_NAND_U_BOOT_SIZE must be align to full pages*/
+#define CFG_NAND_U_BOOT_OFFS 0x800
+#define CFG_NAND_U_BOOT_SIZE 0x30000
+#define CFG_NAND_U_BOOT_DST 0x87f00000 /* Load big U-Boot to this addr */
+#define CFG_NAND_U_BOOT_START CFG_NAND_U_BOOT_DST /* Start big U-Boot from */
+#define CFG_NAND_SPL_DST CFG_NAND_U_BOOT_DST-0x40000 /* Relocate NAND_SPL to this adress*/
+
+#define CFG_NAND_PAGE_SIZE 0x200
+#define CFG_NAND_BLOCK_SIZE 0x4000
+#define CFG_NAND_PAGE_COUNT 0x20
+/*for NAND_SPL*/
+#define CFG_NAND_CHIP_SIZE 0x4000000
+
/*
* JFFS2 partitions
*/
diff --git a/nand_spl/board/imx31_phycore/Makefile b/nand_spl/board/imx31_phycore/Makefile
new file mode 100644
index 0000000..0aabea3
--- /dev/null
+++ b/nand_spl/board/imx31_phycore/Makefile
@@ -0,0 +1,95 @@
+#
+# (C) Copyright 2008
+# Maxim Artamonov, <scn1874 at yandex.ru>
+#
+# (C) Copyright 2006-2007
+# Stefan Roese, DENX Software Engineering, sr(a)denx.de.
+#
+# (C) Copyright 2008
+# Guennadi Liakhovetki, DENX Software Engineering, <lg(a)denx.de>
+#
+# 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
+#
+
+CONFIG_NAND_SPL = y
+
+include $(TOPDIR)/config.mk
+include $(TOPDIR)/nand_spl/board/$(BOARDDIR)/config.mk
+
+LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
+LDFLAGS = -Bstatic -T $(LDSCRIPT) -Ttext $(TEXT_BASE) $(PLATFORM_LDFLAGS)
+AFLAGS += -DCONFIG_NAND_SPL
+CFLAGS += -DCONFIG_NAND_SPL
+
+SOBJS = start.o lowlevel_init.o
+COBJS = nand_boot_mx31.o
+
+SRCS := $(addprefix $(obj),$(SOBJS:.o=.S) $(COBJS:.o=.c))
+OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
+__OBJS := $(SOBJS) $(COBJS)
+LNDIR := $(OBJTREE)/nand_spl/board/$(BOARDDIR)
+
+nandobj := $(OBJTREE)/nand_spl/
+
+ALL = $(nandobj)u-boot-spl $(nandobj)u-boot-spl.bin $(nandobj)u-boot-spl-aligned.bin
+
+all: $(obj).depend $(ALL)
+
+$(nandobj)u-boot-spl-aligned.bin: $(nandobj)u-boot-spl
+ $(OBJCOPY) ${OBJCFLAGS} --pad-to=$(PAD_TO) -O binary $< $@
+
+$(nandobj)u-boot-spl.bin: $(nandobj)u-boot-spl
+ $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
+
+$(nandobj)u-boot-spl: $(OBJS)
+ cd $(LNDIR) && $(LD) $(LDFLAGS) $(__OBJS) \
+ -Map $(nandobj)u-boot-spl.map \
+ -o $(nandobj)u-boot-spl
+
+# create symbolic links for common files
+
+# from cpu directory
+$(obj)start.S:
+ @rm -f $@
+ @ln -s $(TOPDIR)/cpu/arm1136/start.S $@
+
+# from board directory
+$(obj)lowlevel_init.S:
+ @rm -f $@
+ @ln -s $(TOPDIR)/board/imx31_phycore/lowlevel_init.S $@
+
+# from nand_spl directory
+$(obj)nand_boot_mx31.c:
+ @rm -f $@
+ @ln -s $(TOPDIR)/nand_spl/nand_boot_mx31.c $@
+
+#########################################################################
+
+$(obj)%.o: $(obj)%.S
+ $(CC) $(AFLAGS) -c -o $@ $<
+
+$(obj)%.o: $(obj)%.c
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/nand_spl/board/imx31_phycore/config.mk b/nand_spl/board/imx31_phycore/config.mk
new file mode 100644
index 0000000..4c271c5
--- /dev/null
+++ b/nand_spl/board/imx31_phycore/config.mk
@@ -0,0 +1,33 @@
+#
+# (C) Copyright 2008
+# Maxim Artamonov, <scn1874 at yandex.ru>
+#
+# 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
+#
+# phyCORE-i.MX31 - PHYTEC’s phyCORE Single Board Computer module
+
+# TEXT_BASE for SPL: = CFG_NAND_U_BOOT_DST-0x40000 is set in board/imx31_phycore/config.mk
+
+# PAD_TO used to generate a 2kByte binary needed for the combined image
+# -> PAD_TO = TEXT_BASE + 2048
+PAD_TO := $(shell expr $$[$(TEXT_BASE) + 2048])
+
+ifeq ($(debug),1)
+PLATFORM_CPPFLAGS += -DDEBUG
+endif
diff --git a/nand_spl/board/imx31_phycore/u-boot.lds b/nand_spl/board/imx31_phycore/u-boot.lds
new file mode 100644
index 0000000..d25abf8
--- /dev/null
+++ b/nand_spl/board/imx31_phycore/u-boot.lds
@@ -0,0 +1,65 @@
+/*
+ *
+ * (C) Copyright 2008
+ * Maxim Artamonov, <scn1874 at yandex.ru>
+ *
+ * January 2004 - Changed to support H4 device
+ * Copyright (c) 2004 Texas Instruments
+ *
+ * (C) Copyright 2002
+ * Gary Jennejohn, DENX Software Engineering, <gj(a)denx.de>
+ *
+ * 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
+ */
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(_start)
+SECTIONS
+{
+ . = 0x00000000;
+
+ . = ALIGN(4);
+ .text :
+ {
+ start.o (.text)
+ lowlevel_init.o (.text)
+ nand_boot_mx31.o (.text)
+ *(.text)
+ }
+
+ . = ALIGN(4);
+ .rodata : { *(.rodata) }
+
+ . = ALIGN(4);
+ .data : { *(.data) }
+
+ . = ALIGN(4);
+ .got : { *(.got) }
+
+ . = .;
+ __u_boot_cmd_start = .;
+ .u_boot_cmd : { *(.u_boot_cmd) }
+ __u_boot_cmd_end = .;
+
+ . = ALIGN(4);
+ __bss_start = .;
+ .bss : { *(.bss) }
+ _end = .;
+}
diff --git a/nand_spl/nand_boot_mx31.c b/nand_spl/nand_boot_mx31.c
new file mode 100644
index 0000000..1cd7232
--- /dev/null
+++ b/nand_spl/nand_boot_mx31.c
@@ -0,0 +1,190 @@
+/*
+ * (C) Copyright 2008
+ * Maxim Artamonov, <scn1874 at yandex.ru>
+ *
+ * (C) Copyright 2006-2008
+ * Stefan Roese, DENX Software Engineering, sr(a)denx.de.
+ *
+ * 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 <nand.h>
+#include <asm-arm/arch/mx31-regs.h>
+
+static void mx31_wait_ready(void)
+{
+ while (1)
+ if (NFC_CONFIG2 & NFC_INT){
+ NFC_CONFIG2 = NFC_CONFIG2 & (~NFC_INT);/*int flag reset*/
+ break;
+ }
+}
+
+static void mx31_nand_init(void)
+{
+ /*unlocking RAM Buff*/
+ NFC_CONFIG = 0x2;
+
+ /*hardware ECC checking and correct*/
+ NFC_CONFIG1 = NFC_ECC_EN;
+}
+
+static void mx31_nand_command(unsigned short command)
+{
+ NFC_FLASH_CMD = command;
+ NFC_CONFIG2 = NFC_CMD;
+ mx31_wait_ready();
+}
+
+static void mx31_nand_page_address(unsigned int page_address)
+{
+ unsigned int page_count;
+
+ NFC_FLASH_ADDR = 0x00;
+ NFC_CONFIG2 = NFC_ADDR;
+ mx31_wait_ready();
+
+ /*code only for 2kb flash*/
+ if (CFG_NAND_PAGE_SIZE == 0x800){
+ NFC_FLASH_ADDR = 0x00;
+ NFC_CONFIG2 = NFC_ADDR;
+ mx31_wait_ready();
+ };
+
+ page_count = CFG_NAND_CHIP_SIZE / CFG_NAND_PAGE_SIZE;
+
+ if (page_address <= page_count){
+ page_count--;/* transform 0x01000000 to 0x00ffffff */
+ do{
+ NFC_FLASH_ADDR = (unsigned short)(page_address & 0xff);
+ NFC_CONFIG2 = NFC_ADDR;
+ mx31_wait_ready();
+ page_address = page_address >> 8;
+ page_count = page_count >> 8;
+ }while (page_count);
+ }
+}
+
+static void mx31_nand_data_output(void)
+{
+ NFC_CONFIG1 = NFC_ECC_EN;
+ NFC_BUF_ADDR = 0; /* read in first 0 buffer*/
+ NFC_CONFIG2 = NFC_OUTPUT;
+ mx31_wait_ready();
+}
+
+static int mx31_nand_check_ecc(void)
+{
+ unsigned short ecc_status_registr;
+
+ ecc_status_registr = NFC_ECC_STATUS_RESULT;
+
+ if (ecc_status_registr != 0)
+ return 1;/*error*/
+ return 0;
+}
+
+static int mx31_read_page(unsigned int page_address, unsigned char *buf)
+{
+ int i;
+ volatile u32 *p1, *p2, a;
+
+ mx31_nand_init ();
+ NFC_BUF_ADDR = 0; /* read in first 0 buffer*/
+ mx31_nand_command (NAND_CMD_READ0);
+ mx31_nand_page_address (page_address);
+
+ if (CFG_NAND_CHIP_SIZE >= 0x08000000)
+ mx31_nand_command (NAND_CMD_READSTART);
+
+ mx31_nand_data_output ();/*fill the main buffer 0*/
+
+ if (mx31_nand_check_ecc ())
+ while (1){
+ break;}; /*!!!!!*/
+
+ p1 = (u32 *)MAIN_AREA0;
+ p2 = (u32 *)buf;
+
+ /*main copy loop from NAND-buffer to SDRAM memory*/
+ for (i=0; i < (CFG_NAND_PAGE_SIZE / 4); i++){
+ *p2 = *p1;
+ p1++;
+ p2++;
+ }
+
+ p1 = (u32 *)SPARE_AREA0;
+
+ /*it is hardware specific code for 8-bit 512kB NAND-flash spare area*/
+ p1++;
+ a = *p1;
+ a = (a & 0x0000ff00) >> 8;
+
+ if (a != 0xff) /*bad block marker verify*/
+ return 1;/*potential bad block*/
+
+ return 0;
+}
+
+static int nand_load(unsigned int from, unsigned int size, unsigned char *buf)
+{
+ int i, bb;
+
+ mx31_nand_init ();
+
+ /*conver from to page number*/
+ from = from / CFG_NAND_PAGE_SIZE;
+
+ i = 0;
+
+ while (i < (size/CFG_NAND_PAGE_SIZE)){
+
+ if ((from*CFG_NAND_PAGE_SIZE) >= CFG_NAND_CHIP_SIZE)
+ return 2;/*memory segment violation*/
+
+ bb = mx31_read_page (from, buf);
+
+ /*checking first page of each block*/
+ /*if this page has bb marker, then skip whole block*/
+ if ((!(from % CFG_NAND_PAGE_COUNT)) && bb){
+ from = from + CFG_NAND_PAGE_COUNT;
+ }
+ else{
+ i++;
+ from++;
+ buf = buf + CFG_NAND_PAGE_SIZE;
+ }
+ }
+ return 0;
+}
+
+/*
+ * The main entry for NAND booting. It's necessary that SDRAM is already
+ * configured and available since this code loads the main U-Boot image
+ * from NAND into SDRAM and starts it from there.
+ */
+void nand_boot(void)
+{
+ __attribute__((noreturn)) void (*uboot)(void);
+
+ /*CFG_NAND_U_BOOT_OFFS and CFG_NAND_U_BOOT_SIZE must*/
+ /* be align to full pages*/
+ nand_load (CFG_NAND_U_BOOT_OFFS, CFG_NAND_U_BOOT_SIZE, \
+ (uchar *)CFG_NAND_U_BOOT_DST);
+
+ uboot = (void *)CFG_NAND_U_BOOT_START;
+ uboot ();
+}
--
1.5.2.4
3
2
Cleanup usb storage
Signed-off-by: Michael Trimarchi <trimarchimichael(a)yahoo.it>
---
diff --git a/common/usb_storage.c b/common/usb_storage.c
index 94f659f..973d82f 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -63,9 +63,9 @@
#undef BBB_XPORT_TRACE
#ifdef USB_STOR_DEBUG
-#define USB_STOR_PRINTF(fmt,args...) printf (fmt ,##args)
+#define USB_STOR_PRINTF(fmt, args...) printf(fmt , ##args)
#else
-#define USB_STOR_PRINTF(fmt,args...)
+#define USB_STOR_PRINTF(fmt, args...)
#endif
#include <scsi.h>
@@ -110,7 +110,7 @@ typedef struct {
__u8 CBWCDB[CBWCDBLENGTH];
} umass_bbb_cbw_t;
#define UMASS_BBB_CBW_SIZE 31
-static __u32 CBWTag = 0;
+static __u32 CBWTag;
/* Command Status Wrapper */
typedef struct {
@@ -126,34 +126,35 @@ typedef struct {
#define UMASS_BBB_CSW_SIZE 13
#define USB_MAX_STOR_DEV 5
-static int usb_max_devs = 0; /* number of highest available usb device */
+static int usb_max_devs; /* number of highest available usb device */
static block_dev_desc_t usb_dev_desc[USB_MAX_STOR_DEV];
struct us_data;
-typedef int (*trans_cmnd)(ccb*, struct us_data*);
-typedef int (*trans_reset)(struct us_data*);
+typedef int (*trans_cmnd)(ccb *cb, struct us_data *data);
+typedef int (*trans_reset)(struct us_data *data);
struct us_data {
- struct usb_device *pusb_dev; /* this usb_device */
- unsigned int flags; /* from filter initially */
- unsigned char ifnum; /* interface number */
- unsigned char ep_in; /* in endpoint */
- unsigned char ep_out; /* out ....... */
- unsigned char ep_int; /* interrupt . */
- unsigned char subclass; /* as in overview */
- unsigned char protocol; /* .............. */
- unsigned char attention_done; /* force attn on first cmd */
- unsigned short ip_data; /* interrupt data */
- int action; /* what to do */
- int ip_wanted; /* needed */
- int *irq_handle; /* for USB int requests */
- unsigned int irqpipe; /* pipe for release_irq */
- unsigned char irqmaxp; /* max packed for irq Pipe */
- unsigned char irqinterval; /* Intervall for IRQ Pipe */
- ccb *srb; /* current srb */
- trans_reset transport_reset; /* reset routine */
- trans_cmnd transport; /* transport routine */
+ struct usb_device *pusb_dev; /* this usb_device */
+
+ unsigned int flags; /* from filter initially */
+ unsigned char ifnum; /* interface number */
+ unsigned char ep_in; /* in endpoint */
+ unsigned char ep_out; /* out ....... */
+ unsigned char ep_int; /* interrupt . */
+ unsigned char subclass; /* as in overview */
+ unsigned char protocol; /* .............. */
+ unsigned char attention_done; /* force attn on first cmd */
+ unsigned short ip_data; /* interrupt data */
+ int action; /* what to do */
+ int ip_wanted; /* needed */
+ int *irq_handle; /* for USB int requests */
+ unsigned int irqpipe; /* pipe for release_irq */
+ unsigned char irqmaxp; /* max packed for irq Pipe */
+ unsigned char irqinterval; /* Intervall for IRQ Pipe */
+ ccb *srb; /* current srb */
+ trans_reset transport_reset; /* reset routine */
+ trans_cmnd transport; /* transport routine */
};
static struct us_data usb_stor[USB_MAX_STOR_DEV];
@@ -163,10 +164,12 @@ static struct us_data usb_stor[USB_MAX_STOR_DEV];
#define USB_STOR_TRANSPORT_FAILED -1
#define USB_STOR_TRANSPORT_ERROR -2
-
-int usb_stor_get_info(struct usb_device *dev, struct us_data *us, block_dev_desc_t *dev_desc);
-int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,struct us_data *ss);
-unsigned long usb_stor_read(int device, unsigned long blknr, unsigned long blkcnt, void *buffer);
+int usb_stor_get_info(struct usb_device *dev, struct us_data *us,
+ block_dev_desc_t *dev_desc);
+int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,
+ struct us_data *ss);
+unsigned long usb_stor_read(int device, unsigned long blknr,
+ unsigned long blkcnt, void *buffer);
struct usb_device * usb_get_dev_index(int index);
void uhci_show_temp_int_td(void);
@@ -181,7 +184,7 @@ void usb_show_progress(void)
printf(".");
}
-/*********************************************************************************
+/*******************************************************************************
* show info on storage devices; 'usb start/init' must be invoked earlier
* as we only retrieve structures populated during devices initialization
*/
@@ -191,7 +194,7 @@ int usb_stor_info(void)
if (usb_max_devs > 0) {
for (i = 0; i < usb_max_devs; i++) {
- printf (" Device %d: ", i);
+ printf(" Device %d: ", i);
dev_print(&usb_dev_desc[i]);
}
return 0;
@@ -201,7 +204,7 @@ int usb_stor_info(void)
return 1;
}
-/*********************************************************************************
+/*******************************************************************************
* scan the usb and reports device info
* to the user if mode = 1
* returns current device or -1 if no
@@ -214,67 +217,69 @@ int usb_stor_scan(int mode)
/* GJ */
memset(usb_stor_buf, 0, sizeof(usb_stor_buf));
- if(mode==1) {
+ if (mode == 1)
printf(" scanning bus for storage devices... ");
- }
+
usb_disable_asynch(1); /* asynch transfer not allowed */
- for(i=0;i<USB_MAX_STOR_DEV;i++) {
- memset(&usb_dev_desc[i],0,sizeof(block_dev_desc_t));
- usb_dev_desc[i].target=0xff;
- usb_dev_desc[i].if_type=IF_TYPE_USB;
- usb_dev_desc[i].dev=i;
- usb_dev_desc[i].part_type=PART_TYPE_UNKNOWN;
- usb_dev_desc[i].block_read=usb_stor_read;
+ for (i = 0; i < USB_MAX_STOR_DEV; i++) {
+ memset(&usb_dev_desc[i], 0, sizeof(block_dev_desc_t));
+ usb_dev_desc[i].target = 0xff;
+ usb_dev_desc[i].if_type = IF_TYPE_USB;
+ usb_dev_desc[i].dev = i;
+ usb_dev_desc[i].part_type = PART_TYPE_UNKNOWN;
+ usb_dev_desc[i].block_read = usb_stor_read;
}
- usb_max_devs=0;
- for(i=0;i<USB_MAX_DEVICE;i++) {
- dev=usb_get_dev_index(i); /* get device */
- USB_STOR_PRINTF("i=%d\n",i);
- if(dev==NULL) {
+ usb_max_devs = 0;
+ for (i = 0; i < USB_MAX_DEVICE; i++) {
+ dev = usb_get_dev_index(i); /* get device */
+ USB_STOR_PRINTF("i=%d\n", i);
+ if (dev == NULL)
break; /* no more devices avaiable */
- }
- if(usb_storage_probe(dev,0,&usb_stor[usb_max_devs])) { /* ok, it is a storage devices */
- /* get info and fill it in */
- if(usb_stor_get_info(dev, &usb_stor[usb_max_devs], &usb_dev_desc[usb_max_devs]))
+
+ if (usb_storage_probe(dev, 0, &usb_stor[usb_max_devs])) {
+ /* ok, it is a storage devices
+ * get info and fill it in
+ */
+ if (usb_stor_get_info(dev, &usb_stor[usb_max_devs],
+ &usb_dev_desc[usb_max_devs]))
usb_max_devs++;
- } /* if storage device */
- if(usb_max_devs==USB_MAX_STOR_DEV) {
- printf("max USB Storage Device reached: %d stopping\n",usb_max_devs);
+ }
+ /* if storage device */
+ if (usb_max_devs == USB_MAX_STOR_DEV) {
+ printf("max USB Storage Device reached: %d stopping\n",
+ usb_max_devs);
break;
}
} /* for */
usb_disable_asynch(0); /* asynch transfer allowed */
printf("%d Storage Device(s) found\n", usb_max_devs);
- if(usb_max_devs>0)
+ if (usb_max_devs > 0)
return 0;
- else
- return-1;
+ return -1;
}
static int usb_stor_irq(struct usb_device *dev)
{
struct us_data *us;
- us=(struct us_data *)dev->privptr;
+ us = (struct us_data *)dev->privptr;
- if(us->ip_wanted) {
- us->ip_wanted=0;
- }
+ if (us->ip_wanted)
+ us->ip_wanted = 0;
return 0;
}
#ifdef USB_STOR_DEBUG
-static void usb_show_srb(ccb * pccb)
+static void usb_show_srb(ccb *pccb)
{
int i;
- printf("SRB: len %d datalen 0x%lX\n ",pccb->cmdlen,pccb->datalen);
- for(i=0;i<12;i++) {
- printf("%02X ",pccb->cmd[i]);
- }
+ printf("SRB: len %d datalen 0x%lX\n ", pccb->cmdlen, pccb->datalen);
+ for (i = 0; i < 12; i++)
+ printf("%02X ", pccb->cmd[i]);
printf("\n");
}
@@ -322,11 +327,14 @@ static int us_one_transfer(struct us_data *us, int pipe, char *buf, int length)
USB_STOR_PRINTF("Bulk xfer 0x%x(%d) try #%d\n",
(unsigned int)buf, this_xfer, 11 - maxtry);
result = usb_bulk_msg(us->pusb_dev, pipe, buf,
- this_xfer, &partial, USB_CNTL_TIMEOUT*5);
+ this_xfer, &partial,
+ USB_CNTL_TIMEOUT * 5);
USB_STOR_PRINTF("bulk_msg returned %d xferred %d/%d\n",
result, partial, this_xfer);
- if(us->pusb_dev->status!=0) {
- /* if we stall, we need to clear it before we go on */
+ if (us->pusb_dev->status != 0) {
+ /* if we stall, we need to clear it before
+ * we go on
+ */
#ifdef USB_STOR_DEBUG
display_int_status(us->pusb_dev->status);
#endif
@@ -334,9 +342,9 @@ static int us_one_transfer(struct us_data *us, int pipe, char *buf, int length)
USB_STOR_PRINTF("stalled ->clearing endpoint halt for pipe 0x%x\n", pipe);
stat = us->pusb_dev->status;
usb_clear_halt(us->pusb_dev, pipe);
- us->pusb_dev->status=stat;
- if(this_xfer == partial) {
- USB_STOR_PRINTF("bulk transferred with error %X, but data ok\n",us->pusb_dev->status);
+ us->pusb_dev->status = stat;
+ if (this_xfer == partial) {
+ USB_STOR_PRINTF("bulk transferred with error %X, but data ok\n", us->pusb_dev->status);
return 0;
}
else
@@ -346,12 +354,15 @@ static int us_one_transfer(struct us_data *us, int pipe, char *buf, int length)
USB_STOR_PRINTF("Device NAKed bulk_msg\n");
return result;
}
- if(this_xfer == partial) {
- USB_STOR_PRINTF("bulk transferred with error %d, but data ok\n",us->pusb_dev->status);
+ USB_STOR_PRINTF("bulk transferred with error");
+ if (this_xfer == partial) {
+ USB_STOR_PRINTF(" %d, but data ok\n",
+ us->pusb_dev->status);
return 0;
}
/* if our try counter reaches 0, bail out */
- USB_STOR_PRINTF("bulk transferred with error %d, data %d\n",us->pusb_dev->status,partial);
+ USB_STOR_PRINTF(" %d, data %d\n",
+ us->pusb_dev->status, partial);
if (!maxtry--)
return result;
}
@@ -359,7 +370,7 @@ static int us_one_transfer(struct us_data *us, int pipe, char *buf, int length)
this_xfer -= partial;
buf += partial;
/* continue until this transfer is done */
- } while ( this_xfer );
+ } while (this_xfer);
}
/* if we get here, we're done and successful */
@@ -386,29 +397,33 @@ static int usb_stor_BBB_reset(struct us_data *us)
* This comment stolen from FreeBSD's /sys/dev/usb/umass.c.
*/
USB_STOR_PRINTF("BBB_reset\n");
- result = usb_control_msg(us->pusb_dev, usb_sndctrlpipe(us->pusb_dev,0),
- US_BBB_RESET, USB_TYPE_CLASS | USB_RECIP_INTERFACE,
- 0, us->ifnum, 0, 0, USB_CNTL_TIMEOUT*5);
+ result = usb_control_msg(us->pusb_dev, usb_sndctrlpipe(us->pusb_dev, 0),
+ US_BBB_RESET,
+ USB_TYPE_CLASS | USB_RECIP_INTERFACE,
+ 0, us->ifnum, 0, 0, USB_CNTL_TIMEOUT * 5);
- if((result < 0) && (us->pusb_dev->status & USB_ST_STALLED))
- {
+ if ((result < 0) && (us->pusb_dev->status & USB_ST_STALLED)) {
USB_STOR_PRINTF("RESET:stall\n");
return -1;
}
/* long wait for reset */
wait_ms(150);
- USB_STOR_PRINTF("BBB_reset result %d: status %X reset\n",result,us->pusb_dev->status);
+ USB_STOR_PRINTF("BBB_reset result %d: status %X reset\n", result,
+ us->pusb_dev->status);
pipe = usb_rcvbulkpipe(us->pusb_dev, us->ep_in);
result = usb_clear_halt(us->pusb_dev, pipe);
/* long wait for reset */
wait_ms(150);
- USB_STOR_PRINTF("BBB_reset result %d: status %X clearing IN endpoint\n",result,us->pusb_dev->status);
+ USB_STOR_PRINTF("BBB_reset result %d: status %X clearing IN endpoint\n",
+ result, us->pusb_dev->status);
/* long wait for reset */
pipe = usb_sndbulkpipe(us->pusb_dev, us->ep_out);
result = usb_clear_halt(us->pusb_dev, pipe);
wait_ms(150);
- USB_STOR_PRINTF("BBB_reset result %d: status %X clearing OUT endpoint\n",result,us->pusb_dev->status);
+ USB_STOR_PRINTF("BBB_reset result %d: status %X"
+ " clearing OUT endpoint\n", result,
+ us->pusb_dev->status);
USB_STOR_PRINTF("BBB_reset done\n");
return 0;
}
@@ -423,16 +438,20 @@ static int usb_stor_CB_reset(struct us_data *us)
int result;
USB_STOR_PRINTF("CB_reset\n");
- memset(cmd, 0xFF, sizeof(cmd));
+ memset(cmd, 0xff, sizeof(cmd));
cmd[0] = SCSI_SEND_DIAG;
cmd[1] = 4;
- result = usb_control_msg(us->pusb_dev, usb_sndctrlpipe(us->pusb_dev,0),
- US_CBI_ADSC, USB_TYPE_CLASS | USB_RECIP_INTERFACE,
- 0, us->ifnum, cmd, sizeof(cmd), USB_CNTL_TIMEOUT*5);
+ result = usb_control_msg(us->pusb_dev, usb_sndctrlpipe(us->pusb_dev, 0),
+ US_CBI_ADSC,
+ USB_TYPE_CLASS | USB_RECIP_INTERFACE,
+ 0, us->ifnum, cmd, sizeof(cmd),
+ USB_CNTL_TIMEOUT * 5);
/* long wait for reset */
wait_ms(1500);
- USB_STOR_PRINTF("CB_reset result %d: status %X clearing endpoint halt\n",result,us->pusb_dev->status);
+ USB_STOR_PRINTF("CB_reset result %d: status %X"
+ " clearing endpoint halt\n", result,
+ us->pusb_dev->status);
usb_clear_halt(us->pusb_dev, usb_rcvbulkpipe(us->pusb_dev, us->ep_in));
usb_clear_halt(us->pusb_dev, usb_rcvbulkpipe(us->pusb_dev, us->ep_out));
@@ -455,9 +474,11 @@ int usb_stor_BBB_comdat(ccb *srb, struct us_data *us)
dir_in = US_DIRECTION(srb->cmd[0]);
#ifdef BBB_COMDAT_TRACE
- printf("dir %d lun %d cmdlen %d cmd %p datalen %d pdata %p\n", dir_in, srb->lun, srb->cmdlen, srb->cmd, srb->datalen, srb->pdata);
+ printf("dir %d lun %d cmdlen %d cmd %p datalen %d pdata %p\n",
+ dir_in, srb->lun, srb->cmdlen, srb->cmd, srb->datalen,
+ srb->pdata);
if (srb->cmdlen) {
- for(result = 0;result < srb->cmdlen;result++)
+ for (result = 0; result < srb->cmdlen; result++)
printf("cmd[%d] %#x ", result, srb->cmd[result]);
printf("\n");
}
@@ -474,13 +495,14 @@ int usb_stor_BBB_comdat(ccb *srb, struct us_data *us)
cbw.dCBWSignature = cpu_to_le32(CBWSIGNATURE);
cbw.dCBWTag = cpu_to_le32(CBWTag++);
cbw.dCBWDataTransferLength = cpu_to_le32(srb->datalen);
- cbw.bCBWFlags = (dir_in? CBWFLAGS_IN : CBWFLAGS_OUT);
+ cbw.bCBWFlags = (dir_in ? CBWFLAGS_IN : CBWFLAGS_OUT);
cbw.bCBWLUN = srb->lun;
cbw.bCDBLength = srb->cmdlen;
/* copy the command data into the CBW command data buffer */
/* DST SRC LEN!!! */
memcpy(cbw.CBWCDB, srb->cmd, srb->cmdlen);
- result = usb_bulk_msg(us->pusb_dev, pipe, &cbw, UMASS_BBB_CBW_SIZE, &actlen, USB_CNTL_TIMEOUT*5);
+ result = usb_bulk_msg(us->pusb_dev, pipe, &cbw, UMASS_BBB_CBW_SIZE,
+ &actlen, USB_CNTL_TIMEOUT * 5);
if (result < 0)
USB_STOR_PRINTF("usb_stor_BBB_comdat:usb_bulk_msg error\n");
return result;
@@ -492,46 +514,61 @@ int usb_stor_BBB_comdat(ccb *srb, struct us_data *us)
int usb_stor_CB_comdat(ccb *srb, struct us_data *us)
{
int result = 0;
- int dir_in,retry;
+ int dir_in, retry;
unsigned int pipe;
unsigned long status;
- retry=5;
- dir_in=US_DIRECTION(srb->cmd[0]);
+ retry = 5;
+ dir_in = US_DIRECTION(srb->cmd[0]);
- if(dir_in)
- pipe=usb_rcvbulkpipe(us->pusb_dev, us->ep_in);
- else
- pipe=usb_sndbulkpipe(us->pusb_dev, us->ep_out);
- while(retry--) {
- USB_STOR_PRINTF("CBI gets a command: Try %d\n",5-retry);
+ if (dir_in)
+ pipe = usb_rcvbulkpipe(us->pusb_dev, us->ep_in);
+ else
+ pipe = usb_sndbulkpipe(us->pusb_dev, us->ep_out);
+
+ while (retry--) {
+ USB_STOR_PRINTF("CBI gets a command: Try %d\n", 5 - retry);
#ifdef USB_STOR_DEBUG
usb_show_srb(srb);
#endif
/* let's send the command via the control pipe */
- result = usb_control_msg(us->pusb_dev, usb_sndctrlpipe(us->pusb_dev,0),
- US_CBI_ADSC, USB_TYPE_CLASS | USB_RECIP_INTERFACE,
+ result = usb_control_msg(us->pusb_dev,
+ usb_sndctrlpipe(us->pusb_dev , 0),
+ US_CBI_ADSC,
+ USB_TYPE_CLASS | USB_RECIP_INTERFACE,
0, us->ifnum,
- srb->cmd, srb->cmdlen, USB_CNTL_TIMEOUT*5);
- USB_STOR_PRINTF("CB_transport: control msg returned %d, status %X\n",result,us->pusb_dev->status);
+ srb->cmd, srb->cmdlen,
+ USB_CNTL_TIMEOUT * 5);
+ USB_STOR_PRINTF("CB_transport: control msg returned %d,"
+ " status %X\n", result, us->pusb_dev->status);
/* check the return code for the command */
if (result < 0) {
- if(us->pusb_dev->status & USB_ST_STALLED) {
- status=us->pusb_dev->status;
- USB_STOR_PRINTF(" stall during command found, clear pipe\n");
- usb_clear_halt(us->pusb_dev, usb_sndctrlpipe(us->pusb_dev,0));
- us->pusb_dev->status=status;
+ if (us->pusb_dev->status & USB_ST_STALLED) {
+ status = us->pusb_dev->status;
+ USB_STOR_PRINTF(" stall during command found,"
+ " clear pipe\n");
+ usb_clear_halt(us->pusb_dev,
+ usb_sndctrlpipe(us->pusb_dev, 0));
+ us->pusb_dev->status = status;
}
- USB_STOR_PRINTF(" error during command %02X Stat = %X\n",srb->cmd[0],us->pusb_dev->status);
+ USB_STOR_PRINTF(" error during command %02X"
+ " Stat = %X\n", srb->cmd[0],
+ us->pusb_dev->status);
return result;
}
/* transfer the data payload for this command, if one exists*/
- USB_STOR_PRINTF("CB_transport: control msg returned %d, direction is %s to go 0x%lx\n",result,dir_in ? "IN" : "OUT",srb->datalen);
+ USB_STOR_PRINTF("CB_transport: control msg returned %d,"
+ " direction is %s to go 0x%lx\n", result,
+ dir_in ? "IN" : "OUT", srb->datalen);
if (srb->datalen) {
- result = us_one_transfer(us, pipe, (char *)srb->pdata,srb->datalen);
- USB_STOR_PRINTF("CBI attempted to transfer data, result is %d status %lX, len %d\n", result,us->pusb_dev->status,us->pusb_dev->act_len);
- if(!(us->pusb_dev->status & USB_ST_NAK_REC))
+ result = us_one_transfer(us, pipe, (char *)srb->pdata,
+ srb->datalen);
+ USB_STOR_PRINTF("CBI attempted to transfer data,"
+ " result is %d status %lX, len %d\n",
+ result, us->pusb_dev->status,
+ us->pusb_dev->act_len);
+ if (!(us->pusb_dev->status & USB_ST_NAK_REC))
break;
} /* if (srb->datalen) */
else
@@ -543,21 +580,21 @@ int usb_stor_CB_comdat(ccb *srb, struct us_data *us)
}
-int usb_stor_CBI_get_status (ccb * srb, struct us_data *us)
+int usb_stor_CBI_get_status(ccb *srb, struct us_data *us)
{
int timeout;
us->ip_wanted = 1;
- submit_int_msg (us->pusb_dev, us->irqpipe,
+ submit_int_msg(us->pusb_dev, us->irqpipe,
(void *) &us->ip_data, us->irqmaxp, us->irqinterval);
timeout = 1000;
while (timeout--) {
if ((volatile int *) us->ip_wanted == 0)
break;
- wait_ms (10);
+ wait_ms(10);
}
if (us->ip_wanted) {
- printf (" Did not get interrupt on CBI\n");
+ printf(" Did not get interrupt on CBI\n");
us->ip_wanted = 0;
return USB_STOR_TRANSPORT_ERROR;
}
@@ -596,9 +633,9 @@ int usb_stor_BBB_clear_endpt_stall(struct us_data *us, __u8 endpt)
int result;
/* ENDPOINT_HALT = 0, so set value to 0 */
- result = usb_control_msg(us->pusb_dev, usb_sndctrlpipe(us->pusb_dev,0),
+ result = usb_control_msg(us->pusb_dev, usb_sndctrlpipe(us->pusb_dev, 0),
USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT,
- 0, endpt, 0, 0, USB_CNTL_TIMEOUT*5);
+ 0, endpt, 0, 0, USB_CNTL_TIMEOUT * 5);
return result;
}
@@ -638,12 +675,14 @@ int usb_stor_BBB_transport(ccb *srb, struct us_data *us)
pipe = pipein;
else
pipe = pipeout;
- result = usb_bulk_msg(us->pusb_dev, pipe, srb->pdata, srb->datalen, &data_actlen, USB_CNTL_TIMEOUT*5);
+ result = usb_bulk_msg(us->pusb_dev, pipe, srb->pdata, srb->datalen,
+ &data_actlen, USB_CNTL_TIMEOUT * 5);
/* special handling of STALL in DATA phase */
- if((result < 0) && (us->pusb_dev->status & USB_ST_STALLED)) {
+ if ((result < 0) && (us->pusb_dev->status & USB_ST_STALLED)) {
USB_STOR_PRINTF("DATA:stall\n");
/* clear the STALL on the endpoint */
- result = usb_stor_BBB_clear_endpt_stall(us, dir_in? us->ep_in : us->ep_out);
+ result = usb_stor_BBB_clear_endpt_stall(us,
+ dir_in ? us->ep_in : us->ep_out);
if (result >= 0)
/* continue on to STATUS phase */
goto st;
@@ -660,15 +699,16 @@ int usb_stor_BBB_transport(ccb *srb, struct us_data *us)
printf("\n");
#endif
/* STATUS phase + error handling */
- st:
+st:
retry = 0;
- again:
+again:
USB_STOR_PRINTF("STATUS phase\n");
result = usb_bulk_msg(us->pusb_dev, pipein, &csw, UMASS_BBB_CSW_SIZE,
&actlen, USB_CNTL_TIMEOUT*5);
/* special handling of STALL in STATUS phase */
- if((result < 0) && (retry < 1) && (us->pusb_dev->status & USB_ST_STALLED)) {
+ if ((result < 0) && (retry < 1) &&
+ (us->pusb_dev->status & USB_ST_STALLED)) {
USB_STOR_PRINTF("STATUS:stall\n");
/* clear the STALL on the endpoint */
result = usb_stor_BBB_clear_endpt_stall(us, us->ep_in);
@@ -722,32 +762,33 @@ int usb_stor_BBB_transport(ccb *srb, struct us_data *us)
int usb_stor_CB_transport(ccb *srb, struct us_data *us)
{
- int result,status;
+ int result, status;
ccb *psrb;
ccb reqsrb;
- int retry,notready;
+ int retry, notready;
psrb = &reqsrb;
- status=USB_STOR_TRANSPORT_GOOD;
- retry=0;
- notready=0;
+ status = USB_STOR_TRANSPORT_GOOD;
+ retry = 0;
+ notready = 0;
/* issue the command */
do_retry:
- result=usb_stor_CB_comdat(srb,us);
- USB_STOR_PRINTF("command / Data returned %d, status %X\n",result,us->pusb_dev->status);
+ result = usb_stor_CB_comdat(srb, us);
+ USB_STOR_PRINTF("command / Data returned %d, status %X\n",
+ result, us->pusb_dev->status);
/* if this is an CBI Protocol, get IRQ */
- if(us->protocol==US_PR_CBI) {
- status=usb_stor_CBI_get_status(srb,us);
+ if (us->protocol == US_PR_CBI) {
+ status = usb_stor_CBI_get_status(srb, us);
/* if the status is error, report it */
- if(status==USB_STOR_TRANSPORT_ERROR) {
+ if (status == USB_STOR_TRANSPORT_ERROR) {
USB_STOR_PRINTF(" USB CBI Command Error\n");
return status;
}
- srb->sense_buf[12]=(unsigned char)(us->ip_data>>8);
- srb->sense_buf[13]=(unsigned char)(us->ip_data&0xff);
- if(!us->ip_data) {
- /* if the status is good, report it */
- if(status==USB_STOR_TRANSPORT_GOOD) {
+ srb->sense_buf[12] = (unsigned char)(us->ip_data >> 8);
+ srb->sense_buf[13] = (unsigned char)(us->ip_data & 0xff);
+ if (!us->ip_data) {
+ /* if the status is good, report it */
+ if (status == USB_STOR_TRANSPORT_GOOD) {
USB_STOR_PRINTF(" USB CBI Command Good\n");
return status;
}
@@ -755,51 +796,62 @@ do_retry:
}
/* do we have to issue an auto request? */
/* HERE we have to check the result */
- if((result<0) && !(us->pusb_dev->status & USB_ST_STALLED)) {
- USB_STOR_PRINTF("ERROR %X\n",us->pusb_dev->status);
+ if ((result < 0) && !(us->pusb_dev->status & USB_ST_STALLED)) {
+ USB_STOR_PRINTF("ERROR %X\n", us->pusb_dev->status);
us->transport_reset(us);
return USB_STOR_TRANSPORT_ERROR;
}
- if((us->protocol==US_PR_CBI) &&
- ((srb->cmd[0]==SCSI_REQ_SENSE) ||
- (srb->cmd[0]==SCSI_INQUIRY))) { /* do not issue an autorequest after request sense */
+ if ((us->protocol == US_PR_CBI) &&
+ ((srb->cmd[0] == SCSI_REQ_SENSE) ||
+ (srb->cmd[0] == SCSI_INQUIRY))) {
+ /* do not issue an autorequest after request sense */
USB_STOR_PRINTF("No auto request and good\n");
return USB_STOR_TRANSPORT_GOOD;
}
/* issue an request_sense */
- memset(&psrb->cmd[0],0,12);
- psrb->cmd[0]=SCSI_REQ_SENSE;
- psrb->cmd[1]=srb->lun<<5;
- psrb->cmd[4]=18;
- psrb->datalen=18;
+ memset(&psrb->cmd[0], 0, 12);
+ psrb->cmd[0] = SCSI_REQ_SENSE;
+ psrb->cmd[1] = srb->lun << 5;
+ psrb->cmd[4] = 18;
+ psrb->datalen = 18;
psrb->pdata = &srb->sense_buf[0];
- psrb->cmdlen=12;
+ psrb->cmdlen = 12;
/* issue the command */
- result=usb_stor_CB_comdat(psrb,us);
- USB_STOR_PRINTF("auto request returned %d\n",result);
+ result = usb_stor_CB_comdat(psrb, us);
+ USB_STOR_PRINTF("auto request returned %d\n", result);
/* if this is an CBI Protocol, get IRQ */
- if(us->protocol==US_PR_CBI) {
- status=usb_stor_CBI_get_status(psrb,us);
- }
- if((result<0)&&!(us->pusb_dev->status & USB_ST_STALLED)) {
- USB_STOR_PRINTF(" AUTO REQUEST ERROR %d\n",us->pusb_dev->status);
+ if (us->protocol == US_PR_CBI)
+ status = usb_stor_CBI_get_status(psrb, us);
+
+ if ((result < 0) && !(us->pusb_dev->status & USB_ST_STALLED)) {
+ USB_STOR_PRINTF(" AUTO REQUEST ERROR %d\n",
+ us->pusb_dev->status);
return USB_STOR_TRANSPORT_ERROR;
}
- USB_STOR_PRINTF("autorequest returned 0x%02X 0x%02X 0x%02X 0x%02X\n",srb->sense_buf[0],srb->sense_buf[2],srb->sense_buf[12],srb->sense_buf[13]);
+ USB_STOR_PRINTF("autorequest returned 0x%02X 0x%02X 0x%02X 0x%02X\n",
+ srb->sense_buf[0], srb->sense_buf[2],
+ srb->sense_buf[12], srb->sense_buf[13]);
/* Check the auto request result */
- if((srb->sense_buf[2]==0) &&
- (srb->sense_buf[12]==0) &&
- (srb->sense_buf[13]==0)) /* ok, no sense */
+ if ((srb->sense_buf[2] == 0) &&
+ (srb->sense_buf[12] == 0) &&
+ (srb->sense_buf[13] == 0)) {
+ /* ok, no sense */
return USB_STOR_TRANSPORT_GOOD;
+ }
+
/* Check the auto request result */
- switch(srb->sense_buf[2]) {
- case 0x01: /* Recovered Error */
+ switch (srb->sense_buf[2]) {
+ case 0x01:
+ /* Recovered Error */
return USB_STOR_TRANSPORT_GOOD;
break;
- case 0x02: /* Not Ready */
- if(notready++ > USB_TRANSPORT_NOT_READY_RETRY) {
- printf("cmd 0x%02X returned 0x%02X 0x%02X 0x%02X 0x%02X (NOT READY)\n",
- srb->cmd[0],srb->sense_buf[0],srb->sense_buf[2],srb->sense_buf[12],srb->sense_buf[13]);
+ case 0x02:
+ /* Not Ready */
+ if (notready++ > USB_TRANSPORT_NOT_READY_RETRY) {
+ printf("cmd 0x%02X returned 0x%02X 0x%02X 0x%02X"
+ " 0x%02X (NOT READY)\n", srb->cmd[0],
+ srb->sense_buf[0], srb->sense_buf[2],
+ srb->sense_buf[12], srb->sense_buf[13]);
return USB_STOR_TRANSPORT_FAILED;
} else {
wait_ms(100);
@@ -807,113 +859,116 @@ do_retry:
}
break;
default:
- if(retry++ > USB_TRANSPORT_UNKNOWN_RETRY) {
- printf("cmd 0x%02X returned 0x%02X 0x%02X 0x%02X 0x%02X\n",
- srb->cmd[0],srb->sense_buf[0],srb->sense_buf[2],srb->sense_buf[12],srb->sense_buf[13]);
+ if (retry++ > USB_TRANSPORT_UNKNOWN_RETRY) {
+ printf("cmd 0x%02X returned 0x%02X 0x%02X 0x%02X"
+ " 0x%02X\n", srb->cmd[0], srb->sense_buf[0],
+ srb->sense_buf[2], srb->sense_buf[12],
+ srb->sense_buf[13]);
return USB_STOR_TRANSPORT_FAILED;
- } else {
+ } else
goto do_retry;
- }
break;
}
return USB_STOR_TRANSPORT_FAILED;
}
-static int usb_inquiry(ccb *srb,struct us_data *ss)
+static int usb_inquiry(ccb *srb, struct us_data *ss)
{
- int retry,i;
- retry=5;
+ int retry, i;
+ retry = 5;
do {
- memset(&srb->cmd[0],0,12);
- srb->cmd[0]=SCSI_INQUIRY;
- srb->cmd[1]=srb->lun<<5;
- srb->cmd[4]=36;
- srb->datalen=36;
- srb->cmdlen=12;
- i=ss->transport(srb,ss);
- USB_STOR_PRINTF("inquiry returns %d\n",i);
- if(i==0)
+ memset(&srb->cmd[0], 0, 12);
+ srb->cmd[0] = SCSI_INQUIRY;
+ srb->cmd[1] = srb->lun<<5;
+ srb->cmd[4] = 36;
+ srb->datalen = 36;
+ srb->cmdlen = 12;
+ i = ss->transport(srb, ss);
+ USB_STOR_PRINTF("inquiry returns %d\n", i);
+ if (i == 0)
break;
- } while(retry--);
+ } while (retry--);
- if(!retry) {
+ if (!retry) {
printf("error in inquiry\n");
return -1;
}
return 0;
}
-static int usb_request_sense(ccb *srb,struct us_data *ss)
+static int usb_request_sense(ccb *srb, struct us_data *ss)
{
char *ptr;
- ptr=(char *)srb->pdata;
- memset(&srb->cmd[0],0,12);
- srb->cmd[0]=SCSI_REQ_SENSE;
- srb->cmd[1]=srb->lun<<5;
- srb->cmd[4]=18;
- srb->datalen=18;
+ ptr = (char *)srb->pdata;
+ memset(&srb->cmd[0], 0, 12);
+ srb->cmd[0] = SCSI_REQ_SENSE;
+ srb->cmd[1] = srb->lun << 5;
+ srb->cmd[4] = 18;
+ srb->datalen = 18;
srb->pdata = &srb->sense_buf[0];
- srb->cmdlen=12;
- ss->transport(srb,ss);
- USB_STOR_PRINTF("Request Sense returned %02X %02X %02X\n",srb->sense_buf[2],srb->sense_buf[12],srb->sense_buf[13]);
- srb->pdata=(uchar *)ptr;
+ srb->cmdlen = 12;
+ ss->transport(srb, ss);
+ USB_STOR_PRINTF("Request Sense returned %02X %02X %02X\n",
+ srb->sense_buf[2], srb->sense_buf[12],
+ srb->sense_buf[13]);
+ srb->pdata = (uchar *)ptr;
return 0;
}
-static int usb_test_unit_ready(ccb *srb,struct us_data *ss)
+static int usb_test_unit_ready(ccb *srb, struct us_data *ss)
{
int retries = 10;
do {
- memset(&srb->cmd[0],0,12);
- srb->cmd[0]=SCSI_TST_U_RDY;
- srb->cmd[1]=srb->lun<<5;
- srb->datalen=0;
- srb->cmdlen=12;
- if(ss->transport(srb,ss)==USB_STOR_TRANSPORT_GOOD) {
+ memset(&srb->cmd[0], 0, 12);
+ srb->cmd[0] = SCSI_TST_U_RDY;
+ srb->cmd[1] = srb->lun << 5;
+ srb->datalen = 0;
+ srb->cmdlen = 12;
+ if (ss->transport(srb, ss) == USB_STOR_TRANSPORT_GOOD)
return 0;
- }
- usb_request_sense (srb, ss);
- wait_ms (100);
- } while(retries--);
+ usb_request_sense(srb, ss);
+ wait_ms(100);
+ } while (retries--);
return -1;
}
-static int usb_read_capacity(ccb *srb,struct us_data *ss)
+static int usb_read_capacity(ccb *srb, struct us_data *ss)
{
int retry;
- retry = 3; /* retries */
+ /* XXX retries */
+ retry = 3;
do {
- memset(&srb->cmd[0],0,12);
- srb->cmd[0]=SCSI_RD_CAPAC;
- srb->cmd[1]=srb->lun<<5;
- srb->datalen=8;
- srb->cmdlen=12;
- if(ss->transport(srb,ss)==USB_STOR_TRANSPORT_GOOD) {
+ memset(&srb->cmd[0], 0, 12);
+ srb->cmd[0] = SCSI_RD_CAPAC;
+ srb->cmd[1] = srb->lun << 5;
+ srb->datalen = 8;
+ srb->cmdlen = 12;
+ if (ss->transport(srb, ss) == USB_STOR_TRANSPORT_GOOD)
return 0;
- }
- } while(retry--);
+ } while (retry--);
return -1;
}
-static int usb_read_10(ccb *srb,struct us_data *ss, unsigned long start, unsigned short blocks)
+static int usb_read_10(ccb *srb, struct us_data *ss, unsigned long start,
+ unsigned short blocks)
{
- memset(&srb->cmd[0],0,12);
- srb->cmd[0]=SCSI_READ10;
- srb->cmd[1]=srb->lun<<5;
- srb->cmd[2]=((unsigned char) (start>>24))&0xff;
- srb->cmd[3]=((unsigned char) (start>>16))&0xff;
- srb->cmd[4]=((unsigned char) (start>>8))&0xff;
- srb->cmd[5]=((unsigned char) (start))&0xff;
- srb->cmd[7]=((unsigned char) (blocks>>8))&0xff;
- srb->cmd[8]=(unsigned char) blocks & 0xff;
- srb->cmdlen=12;
- USB_STOR_PRINTF("read10: start %lx blocks %x\n",start,blocks);
- return ss->transport(srb,ss);
+ memset(&srb->cmd[0], 0, 12);
+ srb->cmd[0] = SCSI_READ10;
+ srb->cmd[1] = srb->lun << 5;
+ srb->cmd[2] = ((unsigned char) (start >> 24)) & 0xff;
+ srb->cmd[3] = ((unsigned char) (start >> 16)) & 0xff;
+ srb->cmd[4] = ((unsigned char) (start >> 8)) & 0xff;
+ srb->cmd[5] = ((unsigned char) (start)) & 0xff;
+ srb->cmd[7] = ((unsigned char) (blocks >> 8)) & 0xff;
+ srb->cmd[8] = (unsigned char) blocks & 0xff;
+ srb->cmdlen = 12;
+ USB_STOR_PRINTF("read10: start %lx blocks %x\n", start, blocks);
+ return ss->transport(srb, ss);
}
@@ -933,85 +988,94 @@ static void usb_bin_fixup(struct usb_device_descriptor descriptor,
const unsigned char max_vendor_len = 40;
const unsigned char max_product_len = 20;
if (descriptor.idVendor == 0x0424 && descriptor.idProduct == 0x223a) {
- strncpy ((char *)vendor, "SMSC", max_vendor_len);
- strncpy ((char *)product, "Flash Media Cntrller", max_product_len);
+ strncpy((char *)vendor, "SMSC", max_vendor_len);
+ strncpy((char *)product, "Flash Media Cntrller",
+ max_product_len);
}
}
#endif /* CONFIG_USB_BIN_FIXUP */
#define USB_MAX_READ_BLK 20
-unsigned long usb_stor_read(int device, unsigned long blknr, unsigned long blkcnt, void *buffer)
+unsigned long usb_stor_read(int device, unsigned long blknr,
+ unsigned long blkcnt, void *buffer)
{
- unsigned long start,blks, buf_addr;
+ unsigned long start, blks, buf_addr;
unsigned short smallblks;
struct usb_device *dev;
- int retry,i;
+ int retry, i;
ccb *srb = &usb_ccb;
if (blkcnt == 0)
return 0;
device &= 0xff;
- /* Setup device
- */
- USB_STOR_PRINTF("\nusb_read: dev %d \n",device);
- dev=NULL;
- for(i=0;i<USB_MAX_DEVICE;i++) {
- dev=usb_get_dev_index(i);
- if(dev==NULL) {
+ /* Setup device */
+ USB_STOR_PRINTF("\nusb_read: dev %d \n", device);
+ dev = NULL;
+ for (i = 0; i < USB_MAX_DEVICE; i++) {
+ dev = usb_get_dev_index(i);
+ if (dev == NULL)
return 0;
- }
- if(dev->devnum==usb_dev_desc[device].target)
+ if (dev->devnum == usb_dev_desc[device].target)
break;
}
usb_disable_asynch(1); /* asynch transfer not allowed */
- srb->lun=usb_dev_desc[device].lun;
- buf_addr=(unsigned long)buffer;
- start=blknr;
- blks=blkcnt;
- if(usb_test_unit_ready(srb,(struct us_data *)dev->privptr)) {
- printf("Device NOT ready\n Request Sense returned %02X %02X %02X\n",
- srb->sense_buf[2],srb->sense_buf[12],srb->sense_buf[13]);
+ srb->lun = usb_dev_desc[device].lun;
+ buf_addr = (unsigned long)buffer;
+ start = blknr;
+ blks = blkcnt;
+ if (usb_test_unit_ready(srb, (struct us_data *)dev->privptr)) {
+ printf("Device NOT ready\n Request Sense returned %02X %02X"
+ " %02X\n", srb->sense_buf[2], srb->sense_buf[12],
+ srb->sense_buf[13]);
return 0;
}
- USB_STOR_PRINTF("\nusb_read: dev %d startblk %lx, blccnt %lx buffer %lx\n",device,start,blks, buf_addr);
+
+ USB_STOR_PRINTF("\nusb_read: dev %d startblk %lx, blccnt %lx"
+ " buffer %lx\n", device, start, blks, buf_addr);
+
do {
- retry=2;
- srb->pdata=(unsigned char *)buf_addr;
- if(blks>USB_MAX_READ_BLK) {
- smallblks=USB_MAX_READ_BLK;
- } else {
- smallblks=(unsigned short) blks;
- }
+ /* XXX need some comment here */
+ retry = 2;
+ srb->pdata = (unsigned char *)buf_addr;
+ if (blks > USB_MAX_READ_BLK)
+ smallblks = USB_MAX_READ_BLK;
+ else
+ smallblks = (unsigned short) blks;
retry_it:
- if(smallblks==USB_MAX_READ_BLK)
+ if (smallblks == USB_MAX_READ_BLK)
usb_show_progress();
- srb->datalen=usb_dev_desc[device].blksz * smallblks;
- srb->pdata=(unsigned char *)buf_addr;
- if(usb_read_10(srb,(struct us_data *)dev->privptr, start, smallblks)) {
+ srb->datalen = usb_dev_desc[device].blksz * smallblks;
+ srb->pdata = (unsigned char *)buf_addr;
+ if (usb_read_10(srb, (struct us_data *)dev->privptr, start,
+ smallblks)) {
USB_STOR_PRINTF("Read ERROR\n");
- usb_request_sense(srb,(struct us_data *)dev->privptr);
- if(retry--)
+ usb_request_sense(srb, (struct us_data *)dev->privptr);
+ if (retry--)
goto retry_it;
- blkcnt-=blks;
+ blkcnt -= blks;
break;
}
- start+=smallblks;
- blks-=smallblks;
- buf_addr+=srb->datalen;
- } while(blks!=0);
- USB_STOR_PRINTF("usb_read: end startblk %lx, blccnt %x buffer %lx\n",start,smallblks,buf_addr);
+ start += smallblks;
+ blks -= smallblks;
+ buf_addr += srb->datalen;
+ } while (blks != 0);
+
+ USB_STOR_PRINTF("usb_read: end startblk %lx, blccnt %x buffer %lx\n",
+ start, smallblks, buf_addr);
+
usb_disable_asynch(0); /* asynch transfer allowed */
- if(blkcnt>=USB_MAX_READ_BLK)
+ if (blkcnt >= USB_MAX_READ_BLK)
printf("\n");
- return(blkcnt);
+ return blkcnt;
}
/* Probe to see if a new device is actually a Storage device */
-int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,struct us_data *ss)
+int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,
+ struct us_data *ss)
{
struct usb_interface_descriptor *iface;
int i;
@@ -1025,8 +1089,11 @@ int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,struct us_data
#if 0
/* this is the place to patch some storage devices */
- USB_STOR_PRINTF("iVendor %X iProduct %X\n",dev->descriptor.idVendor,dev->descriptor.idProduct);
- if ((dev->descriptor.idVendor) == 0x066b && (dev->descriptor.idProduct) == 0x0103) {
+ USB_STOR_PRINTF("iVendor %X iProduct %X\n", dev->descriptor.idVendor,
+ dev->descriptor.idProduct);
+
+ if ((dev->descriptor.idVendor) == 0x066b &&
+ (dev->descriptor.idProduct) == 0x0103) {
USB_STOR_PRINTF("patched for E-USB\n");
protocol = US_PR_CB;
subclass = US_SC_UFI; /* an assumption */
@@ -1095,19 +1162,20 @@ int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,struct us_data
*/
for (i = 0; i < iface->bNumEndpoints; i++) {
/* is it an BULK endpoint? */
- if ((iface->ep_desc[i].bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
- == USB_ENDPOINT_XFER_BULK) {
+ if ((iface->ep_desc[i].bmAttributes &
+ USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK) {
if (iface->ep_desc[i].bEndpointAddress & USB_DIR_IN)
ss->ep_in = iface->ep_desc[i].bEndpointAddress &
USB_ENDPOINT_NUMBER_MASK;
else
- ss->ep_out = iface->ep_desc[i].bEndpointAddress &
+ ss->ep_out =
+ iface->ep_desc[i].bEndpointAddress &
USB_ENDPOINT_NUMBER_MASK;
}
/* is it an interrupt endpoint? */
- if ((iface->ep_desc[i].bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
- == USB_ENDPOINT_XFER_INT) {
+ if ((iface->ep_desc[i].bmAttributes &
+ USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT) {
ss->ep_int = iface->ep_desc[i].bEndpointAddress &
USB_ENDPOINT_NUMBER_MASK;
ss->irqinterval = iface->ep_desc[i].bInterval;
@@ -1130,26 +1198,28 @@ int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,struct us_data
*/
if (ss->subclass != US_SC_UFI && ss->subclass != US_SC_SCSI &&
ss->subclass != US_SC_8070) {
- printf("Sorry, protocol %d not yet supported.\n",ss->subclass);
+ printf("Sorry, protocol %d not yet supported.\n", ss->subclass);
return 0;
}
- if(ss->ep_int) { /* we had found an interrupt endpoint, prepare irq pipe */
- /* set up the IRQ pipe and handler */
-
+ if (ss->ep_int) {
+ /* we had found an interrupt endpoint, prepare irq pipe
+ * set up the IRQ pipe and handler
+ */
ss->irqinterval = (ss->irqinterval > 0) ? ss->irqinterval : 255;
ss->irqpipe = usb_rcvintpipe(ss->pusb_dev, ss->ep_int);
ss->irqmaxp = usb_maxpacket(dev, ss->irqpipe);
- dev->irq_handle=usb_stor_irq;
+ dev->irq_handle = usb_stor_irq;
}
- dev->privptr=(void *)ss;
+ dev->privptr = (void *)ss;
return 1;
}
-int usb_stor_get_info(struct usb_device *dev,struct us_data *ss,block_dev_desc_t *dev_desc)
+int usb_stor_get_info(struct usb_device *dev, struct us_data *ss,
+ block_dev_desc_t *dev_desc)
{
- unsigned char perq,modi;
+ unsigned char perq, modi;
unsigned long cap[2];
- unsigned long *capacity,*blksz;
+ unsigned long *capacity, *blksz;
ccb *pccb = &usb_ccb;
/* for some reasons a couple of devices would not survive this reset */
@@ -1157,7 +1227,6 @@ int usb_stor_get_info(struct usb_device *dev,struct us_data *ss,block_dev_desc_t
/* Sony USM256E */
(dev->descriptor.idVendor == 0x054c &&
dev->descriptor.idProduct == 0x019e)
-
||
/* USB007 Mini-USB2 Flash Drive */
(dev->descriptor.idVendor == 0x066f &&
@@ -1175,17 +1244,20 @@ int usb_stor_get_info(struct usb_device *dev,struct us_data *ss,block_dev_desc_t
dev_desc->target = dev->devnum;
pccb->lun = dev_desc->lun;
- USB_STOR_PRINTF(" address %d\n",dev_desc->target);
+ USB_STOR_PRINTF(" address %d\n", dev_desc->target);
- if(usb_inquiry(pccb,ss))
+ if (usb_inquiry(pccb, ss))
return -1;
perq = usb_stor_buf[0];
modi = usb_stor_buf[1];
- if((perq & 0x1f) == 0x1f) {
- return 0; /* skip unknown devices */
+
+ if ((perq & 0x1f) == 0x1f) {
+ /* skip unknown devices */
+ return 0;
}
- if((modi&0x80) == 0x80) {/* drive is removable */
+ if ((modi&0x80) == 0x80) {
+ /* drive is removable */
dev_desc->removable = 1;
}
memcpy(&dev_desc->vendor[0], &usb_stor_buf[8], 8);
@@ -1195,29 +1267,34 @@ int usb_stor_get_info(struct usb_device *dev,struct us_data *ss,block_dev_desc_t
dev_desc->product[16] = 0;
dev_desc->revision[4] = 0;
#ifdef CONFIG_USB_BIN_FIXUP
- usb_bin_fixup(dev->descriptor, (uchar *)dev_desc->vendor, (uchar *)dev_desc->product);
+ usb_bin_fixup(dev->descriptor, (uchar *)dev_desc->vendor,
+ (uchar *)dev_desc->product);
#endif /* CONFIG_USB_BIN_FIXUP */
- USB_STOR_PRINTF("ISO Vers %X, Response Data %X\n",usb_stor_buf[2],usb_stor_buf[3]);
- if(usb_test_unit_ready(pccb,ss)) {
- printf("Device NOT ready\n Request Sense returned %02X %02X %02X\n",pccb->sense_buf[2],pccb->sense_buf[12],pccb->sense_buf[13]);
- if(dev_desc->removable == 1) {
+ USB_STOR_PRINTF("ISO Vers %X, Response Data %X\n", usb_stor_buf[2],
+ usb_stor_buf[3]);
+ if (usb_test_unit_ready(pccb, ss)) {
+ printf("Device NOT ready\n"
+ " Request Sense returned %02X %02X %02X\n",
+ pccb->sense_buf[2], pccb->sense_buf[12],
+ pccb->sense_buf[13]);
+ if (dev_desc->removable == 1) {
dev_desc->type = perq;
return 1;
}
- else
- return 0;
+ return 0;
}
pccb->pdata = (unsigned char *)&cap[0];
- memset(pccb->pdata,0,8);
- if(usb_read_capacity(pccb,ss) != 0) {
+ memset(pccb->pdata, 0, 8);
+ if (usb_read_capacity(pccb, ss) != 0) {
printf("READ_CAP ERROR\n");
cap[0] = 2880;
cap[1] = 0x200;
}
- USB_STOR_PRINTF("Read Capacity returns: 0x%lx, 0x%lx\n",cap[0],cap[1]);
+ USB_STOR_PRINTF("Read Capacity returns: 0x%lx, 0x%lx\n", cap[0],
+ cap[1]);
#if 0
- if(cap[0]>(0x200000 * 10)) /* greater than 10 GByte */
- cap[0]>>=16;
+ if (cap[0] > (0x200000 * 10)) /* greater than 10 GByte */
+ cap[0] >>= 16;
#endif
cap[0] = cpu_to_be32(cap[0]);
cap[1] = cpu_to_be32(cap[1]);
@@ -1226,15 +1303,16 @@ int usb_stor_get_info(struct usb_device *dev,struct us_data *ss,block_dev_desc_t
cap[0] += 1;
capacity = &cap[0];
blksz = &cap[1];
- USB_STOR_PRINTF("Capacity = 0x%lx, blocksz = 0x%lx\n",*capacity,*blksz);
+ USB_STOR_PRINTF("Capacity = 0x%lx, blocksz = 0x%lx\n",
+ *capacity, *blksz);
dev_desc->lba = *capacity;
dev_desc->blksz = *blksz;
dev_desc->type = perq;
- USB_STOR_PRINTF(" address %d\n",dev_desc->target);
- USB_STOR_PRINTF("partype: %d\n",dev_desc->part_type);
+ USB_STOR_PRINTF(" address %d\n", dev_desc->target);
+ USB_STOR_PRINTF("partype: %d\n", dev_desc->part_type);
init_part(dev_desc);
- USB_STOR_PRINTF("partype: %d\n",dev_desc->part_type);
+ USB_STOR_PRINTF("partype: %d\n", dev_desc->part_type);
return 1;
}
2
1

01 Jan '09
Hello,
I'm not sure if this is the proper way to submit a patch - please feel
free to let me know what needs to be changed, if anything.
Thanks,
Daniel Schuler
===================
The current SBC-2410A board from Embest ships with 2MiB of NOR FLASH,
for which CONFIG_AMD_LV160 has been defined in include/configs/sbc2410x.h
Also, CONFIG_ENV_ADDR has been made more generic by making it depend on
CONFIG_ENV_SIZE, so that only the latter needs to be changed to modify
the size of the environment.
In board/sbc2410x/flash.c, the appropriate #elif and case statements have
been added to support this chip.
Signed-off-by: Daniel Schuler <dbschuler(a)gmail.com>
---
board/sbc2410x/flash.c | 6 ++++++
include/configs/sbc2410x.h | 20 +++++++++++++-------
2 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/board/sbc2410x/flash.c b/board/sbc2410x/flash.c
index abb0935..81aa9e8 100644
--- a/board/sbc2410x/flash.c
+++ b/board/sbc2410x/flash.c
@@ -69,6 +69,9 @@ ulong flash_init (void)
#elif defined(CONFIG_AMD_LV800)
(AMD_MANUFACT & FLASH_VENDMASK) |
(AMD_ID_LV800B & FLASH_TYPEMASK);
+#elif defined(CONFIG_AMD_LV160)
+ (AMD_MANUFACT & FLASH_VENDMASK) |
+ (AMD_ID_LV160B & FLASH_TYPEMASK);
#else
#error "Unknown flash configured"
#endif
@@ -142,6 +145,9 @@ void flash_print_info (flash_info_t * info)
case (AMD_ID_LV800B & FLASH_TYPEMASK):
printf ("1x Amd29LV800BB (8Mbit)\n");
break;
+ case (AMD_ID_LV160B & FLASH_TYPEMASK):
+ printf ("1x Amd29LV160DB (16Mbit)\n");
+ break;
default:
printf ("Unknown Chip Type\n");
goto Done;
diff --git a/include/configs/sbc2410x.h b/include/configs/sbc2410x.h
index d7a6ae4..4d6038d 100644
--- a/include/configs/sbc2410x.h
+++ b/include/configs/sbc2410x.h
@@ -139,7 +139,7 @@
#define CONFIG_SYS_LOAD_ADDR 0x33000000 /* default load address */
-/* the PWM TImer 4 uses a counter of 15625 for 10 ms, so we need */
+/* the PWM Timer 4 uses a counter of 15625 for 10 ms, so we need */
/* it to wrap 100 times (total 1562500) to get 1 sec. */
#define CONFIG_SYS_HZ 1562500
@@ -173,29 +173,35 @@
*/
/* #define CONFIG_AMD_LV400 1 /\* uncomment this if you have a LV400
flash *\/ */
-#define CONFIG_AMD_LV800 1 /* uncomment this if you have a LV800 flash */
+/* #define CONFIG_AMD_LV800 1 /\* uncomment this if you have a LV800
flash *\/ */
+
+#define CONFIG_AMD_LV160 1 /* uncomment this if you have a LV160 flash */
#define CONFIG_SYS_MAX_FLASH_BANKS 1 /* max number of memory banks */
+#ifdef CONFIG_AMD_LV160
+#define PHYS_FLASH_SIZE 0x00200000 /* 2MB */
+#define CONFIG_SYS_MAX_FLASH_SECT (35) /* max number of sectors
on one chip */
+#endif
+
#ifdef CONFIG_AMD_LV800
#define PHYS_FLASH_SIZE 0x00100000 /* 1MB */
#define CONFIG_SYS_MAX_FLASH_SECT (19) /* max number of sectors on one chip */
-#define CONFIG_ENV_ADDR (CONFIG_SYS_FLASH_BASE + 0x0F0000) /* addr
of environment */
#endif
#ifdef CONFIG_AMD_LV400
#define PHYS_FLASH_SIZE 0x00080000 /* 512KB */
#define CONFIG_SYS_MAX_FLASH_SECT (11) /* max number of sectors on one chip */
-#define CONFIG_ENV_ADDR (CONFIG_SYS_FLASH_BASE + 0x070000) /* addr
of environment */
#endif
+#define CONFIG_ENV_IS_IN_FLASH 1
+#define CONFIG_ENV_SIZE 0x10000 /* Total Size of Environment Sector */
+#define CONFIG_ENV_ADDR (CONFIG_SYS_FLASH_BASE + PHYS_FLASH_SIZE -
CONFIG_ENV_SIZE) /* starting addr of environment */
+
/* timeout values are in ticks */
#define CONFIG_SYS_FLASH_ERASE_TOUT (5*CONFIG_SYS_HZ) /* Timeout for
Flash Erase */
#define CONFIG_SYS_FLASH_WRITE_TOUT (5*CONFIG_SYS_HZ) /* Timeout for
Flash Write */
-#define CONFIG_ENV_IS_IN_FLASH 1
-#define CONFIG_ENV_SIZE 0x10000 /* Total Size of Environment Sector */
-
/*-----------------------------------------------------------------------
* NAND flash settings
*/
--
1.5.6.3
2
1

[U-Boot] [USB EHCI V2 PATCH 1/2] USB ehci remove infinite loop and use handshake function
by Michael Trimarchi 31 Dec '08
by Michael Trimarchi 31 Dec '08
31 Dec '08
USB ehci code cleanup. Use handshake instead of infinite while loop
to check the STD_ASS status
Signed-off-by: Michael Trimarchi <trimarchimichael(a)yahoo.it>
---
drivers/usb/usb_ehci_core.c | 49 ++++++++++++++++++++++---------------------
1 files changed, 25 insertions(+), 24 deletions(-)
diff --git a/drivers/usb/usb_ehci_core.c b/drivers/usb/usb_ehci_core.c
index 07e9a6b..9736707 100644
--- a/drivers/usb/usb_ehci_core.c
+++ b/drivers/usb/usb_ehci_core.c
@@ -28,7 +28,7 @@
#include "usb_ehci.h"
int rootdev;
-struct ehci_hccr *hccr; /* R/O registers, not need for volatile */
+struct ehci_hccr *hccr; /* R/O registers, not need for volatile */
volatile struct ehci_hcor *hcor;
static uint16_t portreset;
@@ -106,20 +106,19 @@ static struct descriptor {
#define ehci_is_TDI() (0)
#endif
-static int handshake(uint32_t *ptr, uint32_t mask, uint32_t done, int msec)
+static int handshake(uint32_t *ptr, uint32_t mask, uint32_t done, int usec)
{
uint32_t result;
do {
result = ehci_readl(ptr);
- debug("handshake read reg(%x)=%x\n", (uint32_t)ptr, result);
if (result == ~(uint32_t)0)
return -1;
result &= mask;
if (result == done)
return 0;
- wait_ms(1);
- msec--;
- } while (msec > 0);
+ udelay(1);
+ usec--;
+ } while (usec > 0);
return -1;
}
@@ -138,21 +137,21 @@ static int ehci_reset(void)
cmd = ehci_readl(&hcor->or_usbcmd);
cmd |= CMD_RESET;
ehci_writel(&hcor->or_usbcmd, cmd);
- ret = handshake((uint32_t *)&hcor->or_usbcmd, CMD_RESET, 0, 250);
+ ret = handshake((uint32_t *)&hcor->or_usbcmd, CMD_RESET, 0, 250 * 1000);
if (ret < 0) {
printf("EHCI fail to reset\n");
goto out;
}
-#if defined(CONFIG_EHCI_IS_TDI)
- reg_ptr = (uint32_t *)((u8 *)hcor + USBMODE);
- tmp = ehci_readl(reg_ptr);
- tmp |= USBMODE_CM_HC;
+ if (ehci_is_TDI()) {
+ reg_ptr = (uint32_t *)((u8 *)hcor + USBMODE);
+ tmp = ehci_readl(reg_ptr);
+ tmp |= USBMODE_CM_HC;
#if defined(CONFIG_EHCI_MMIO_BIG_ENDIAN)
- tmp |= USBMODE_BE;
-#endif
- ehci_writel(reg_ptr, tmp);
+ tmp |= USBMODE_BE;
#endif
+ ehci_writel(reg_ptr, tmp);
+ }
out:
return ret;
}
@@ -224,7 +223,7 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,
uint32_t endpt, token, usbsts;
uint32_t c, toggle;
uint32_t cmd;
- uint32_t sts;
+ int ret = 0;
debug("dev=%p, pipe=%lx, buffer=%p, length=%d, req=%p\n", dev, pipe,
buffer, length, req);
@@ -340,10 +339,11 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,
cmd |= CMD_ASE;
ehci_writel(&hcor->or_usbcmd, cmd);
- sts = ehci_readl(&hcor->or_usbsts);
- while ((sts & STD_ASS) == 0) {
- sts = ehci_readl(&hcor->or_usbsts);
- udelay(10);
+ ret = handshake((uint32_t *)&hcor->or_usbsts, STD_ASS, STD_ASS,
+ 100 * 1000);
+ if (ret < 0) {
+ printf("EHCI fail timeout STD_ASS set\n");
+ goto fail;
}
/* Wait for TDs to be processed. */
@@ -360,10 +360,11 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,
cmd &= ~CMD_ASE;
ehci_writel(&hcor->or_usbcmd, cmd);
- sts = ehci_readl(&hcor->or_usbsts);
- while ((sts & STD_ASS) != 0) {
- sts = ehci_readl(&hcor->or_usbsts);
- udelay(10);
+ ret = handshake((uint32_t *)&hcor->or_usbsts, STD_ASS, 0,
+ 100 * 1000);
+ if (ret < 0) {
+ printf("EHCI fail timeout STD_ASS reset\n");
+ goto fail;
}
qh_list.qh_link = cpu_to_hc32((uint32_t)&qh_list | QH_LINK_TYPE_QH);
@@ -536,7 +537,7 @@ ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
/* force reset to complete */
reg = reg & ~(EHCI_PS_PR | EHCI_PS_CLEAR);
ehci_writel(status_reg, reg);
- ret = handshake(status_reg, EHCI_PS_PR, 0, 2);
+ ret = handshake(status_reg, EHCI_PS_PR, 0, 2 * 1000);
if (!ret)
tmpbuf[0] |= USB_PORT_STAT_RESET;
else
--
1.5.6.5
1
0