* [PATCH 1/9] ARM: set rev instead of returning it
2012-09-30 2:50 [PATCH 0/9] archosg9: add support for tablet, second round vj
@ 2012-09-30 2:50 ` vj
2012-09-30 2:50 ` [PATCH 2/9] mmc_omap: improve error message vj
` (8 subsequent siblings)
9 siblings, 0 replies; 27+ messages in thread
From: vj @ 2012-09-30 2:50 UTC (permalink / raw)
To: barebox; +Cc: vj
---
arch/arm/lib/armlinux.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/lib/armlinux.c b/arch/arm/lib/armlinux.c
index 191274e..74d59a9 100644
--- a/arch/arm/lib/armlinux.c
+++ b/arch/arm/lib/armlinux.c
@@ -80,7 +80,7 @@ void armlinux_set_revision(unsigned int rev)
#ifdef CONFIG_ENVIRONMENT_VARIABLES
export_env_ull("armlinux_system_rev", rev);
#else
- return armlinux_system_rev;
+ armlinux_system_rev = rev;
#endif
}
--
1.7.12.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 2/9] mmc_omap: improve error message
2012-09-30 2:50 [PATCH 0/9] archosg9: add support for tablet, second round vj
2012-09-30 2:50 ` [PATCH 1/9] ARM: set rev instead of returning it vj
@ 2012-09-30 2:50 ` vj
2012-09-30 2:50 ` [PATCH 3/9] omap4: add/rename definitions to match datasheet vj
` (7 subsequent siblings)
9 siblings, 0 replies; 27+ messages in thread
From: vj @ 2012-09-30 2:50 UTC (permalink / raw)
To: barebox; +Cc: vj
---
drivers/mci/omap_hsmmc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mci/omap_hsmmc.c b/drivers/mci/omap_hsmmc.c
index e0b245b..e6f4e47 100644
--- a/drivers/mci/omap_hsmmc.c
+++ b/drivers/mci/omap_hsmmc.c
@@ -238,7 +238,7 @@ static int mmc_init_setup(struct mci_host *mci, struct device_d *dev)
start = get_time_ns();
while ((readl(&mmc_base->sysstatus) & RESETDONE) == 0) {
if (is_timeout(start, SECOND)) {
- dev_dbg(hsmmc->dev, "timedout waiting for cc2!\n");
+ dev_dbg(hsmmc->dev, "timeout waiting for reset done\n");
return -ETIMEDOUT;
}
}
--
1.7.12.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 3/9] omap4: add/rename definitions to match datasheet
2012-09-30 2:50 [PATCH 0/9] archosg9: add support for tablet, second round vj
2012-09-30 2:50 ` [PATCH 1/9] ARM: set rev instead of returning it vj
2012-09-30 2:50 ` [PATCH 2/9] mmc_omap: improve error message vj
@ 2012-09-30 2:50 ` vj
2012-09-30 2:50 ` [PATCH 4/9] twl6030: add debug info vj
` (6 subsequent siblings)
9 siblings, 0 replies; 27+ messages in thread
From: vj @ 2012-09-30 2:50 UTC (permalink / raw)
To: barebox; +Cc: vj
---
arch/arm/boards/panda/mux.c | 52 +--
arch/arm/boards/pcm049/mux.c | 44 +--
arch/arm/boards/phycard-a-xl2/mux.c | 46 +--
arch/arm/mach-omap/include/mach/omap4-mux.h | 486 +++++++++++++-----------
arch/arm/mach-omap/include/mach/omap4-silicon.h | 13 +
arch/arm/mach-omap/include/mach/xload.h | 1 +
arch/arm/mach-omap/omap4_generic.c | 2 +
arch/arm/mach-omap/xload.c | 1 +
8 files changed, 343 insertions(+), 302 deletions(-)
diff --git a/arch/arm/boards/panda/mux.c b/arch/arm/boards/panda/mux.c
index 3783006..8225aa6 100644
--- a/arch/arm/boards/panda/mux.c
+++ b/arch/arm/boards/panda/mux.c
@@ -212,31 +212,31 @@ static const struct pad_conf_entry core_padconf_array[] = {
};
static const struct pad_conf_entry wkup_padconf_array[] = {
- { PAD0_SIM_IO, IEN | M0 /* sim_io */ },
- { PAD1_SIM_CLK, M0 /* sim_clk */ },
- { PAD0_SIM_RESET, M0 /* sim_reset */ },
- { PAD1_SIM_CD, PTU | IEN | M0 /* sim_cd */ },
- { PAD0_SIM_PWRCTRL, M0 /* sim_pwrctrl */ },
- { PAD1_SR_SCL, PTU | IEN | M0 /* sr_scl */ },
- { PAD0_SR_SDA, PTU | IEN | M0 /* sr_sda */ },
- { PAD1_FREF_XTAL_IN, M0 /* # */ },
- { PAD0_FREF_SLICER_IN, M0 /* fref_slicer_in */ },
- { PAD1_FREF_CLK_IOREQ, M0 /* fref_clk_ioreq */ },
- { PAD0_FREF_CLK0_OUT, M2 /* sys_drm_msecure */ },
- { PAD1_FREF_CLK3_REQ, PTU | IEN | M0 /* # */ },
- { PAD0_FREF_CLK3_OUT, M0 /* fref_clk3_out */ },
- { PAD1_FREF_CLK4_REQ, PTU | IEN | M0 /* # */ },
- { PAD0_FREF_CLK4_OUT, M0 /* # */ },
- { PAD1_SYS_32K, IEN | M0 /* sys_32k */ },
- { PAD0_SYS_NRESPWRON, M0 /* sys_nrespwron */ },
- { PAD1_SYS_NRESWARM, M0 /* sys_nreswarm */ },
- { PAD0_SYS_PWR_REQ, PTU | M0 /* sys_pwr_req */ },
- { PAD1_SYS_PWRON_RESET, M3 /* gpio_wk29 */ },
- { PAD0_SYS_BOOT6, IEN | M3 /* gpio_wk9 */ },
- { PAD1_SYS_BOOT7, IEN | M3 /* gpio_wk10 */ },
- { PAD1_FREF_CLK3_REQ, M3 /* gpio_wk30 */ },
- { PAD1_FREF_CLK4_REQ, M3 /* gpio_wk7 */ },
- { PAD0_FREF_CLK4_OUT, M3 /* gpio_wk8 */ },
+ { GPIO_WK0, IEN | M0 /* sim_io */ },
+ { GPIO_WK1, M0 /* sim_clk */ },
+ { GPIO_WK2, M0 /* sim_reset */ },
+ { GPIO_WK3, PTU | IEN | M0 /* sim_cd */ },
+ { GPIO_WK4, M0 /* sim_pwrctrl */ },
+ { SR_SCL, PTU | IEN | M0 /* sr_scl */ },
+ { SR_SDA, PTU | IEN | M0 /* sr_sda */ },
+ { FREF_XTAL_IN, M0 /* # */ },
+ { FREF_SLICER_IN, M0 /* fref_slicer_in */ },
+ { FREF_CLK_IOREQ, M0 /* fref_clk_ioreq */ },
+ { FREF_CLK0_OUT, M2 /* sys_drm_msecure */ },
+ { FREF_CLK3_REQ, PTU | IEN | M0 /* # */ },
+ { FREF_CLK3_OUT, M0 /* fref_clk3_out */ },
+ { FREF_CLK4_REQ, PTU | IEN | M0 /* # */ },
+ { FREF_CLK4_OUT, M0 /* # */ },
+ { SYS_32K, IEN | M0 /* sys_32k */ },
+ { SYS_NRESPWRON, M0 /* sys_nrespwron */ },
+ { SYS_NRESWARM, M0 /* sys_nreswarm */ },
+ { SYS_PWR_REQ, PTU | M0 /* sys_pwr_req */ },
+ { SYS_PWRON_RESET_OUT, M3 /* gpio_wk29 */ },
+ { SYS_BOOT6, IEN | M3 /* gpio_wk9 */ },
+ { SYS_BOOT7, IEN | M3 /* gpio_wk10 */ },
+ { FREF_CLK3_REQ, M3 /* gpio_wk30 */ },
+ { FREF_CLK4_REQ, M3 /* gpio_wk7 */ },
+ { FREF_CLK4_OUT, M3 /* gpio_wk8 */ },
};
void set_muxconf_regs(void)
@@ -249,7 +249,7 @@ void set_muxconf_regs(void)
/* gpio_wk7 is used for controlling TPS on 4460 */
if (omap4_revision() >= OMAP4460_ES1_0) {
- writew(M3, OMAP44XX_CONTROL_PADCONF_WKUP + PAD1_FREF_CLK4_REQ);
+ writew(M3, OMAP44XX_CONTROL_PADCONF_WKUP + FREF_CLK4_REQ);
/* Enable GPIO-1 clocks before TPS initialization */
omap4_enable_gpio1_wup_clocks();
}
diff --git a/arch/arm/boards/pcm049/mux.c b/arch/arm/boards/pcm049/mux.c
index 04e1d67..5ea88cd 100644
--- a/arch/arm/boards/pcm049/mux.c
+++ b/arch/arm/boards/pcm049/mux.c
@@ -212,28 +212,28 @@ static const struct pad_conf_entry core_padconf_array[] = {
};
static const struct pad_conf_entry wkup_padconf_array[] = {
- {PAD0_SIM_IO, (SAFE_MODE)}, /* nc */
- {PAD1_SIM_CLK, (SAFE_MODE)}, /* nc */
- {PAD0_SIM_RESET, (SAFE_MODE)}, /* nc */
- {PAD1_SIM_CD, (SAFE_MODE)}, /* nc */
- {PAD0_SIM_PWRCTRL, (SAFE_MODE)}, /* nc */
- {PAD1_SR_SCL, (PTU | IEN | M0)}, /* sr_scl */
- {PAD0_SR_SDA, (PTU | IEN | M0)}, /* sr_sda */
- {PAD1_FREF_XTAL_IN, (M0)}, /* # */
- {PAD0_FREF_SLICER_IN, (SAFE_MODE)}, /* nc */
- {PAD1_FREF_CLK_IOREQ, (SAFE_MODE)}, /* nc */
- {PAD0_FREF_CLK0_OUT, (M2)}, /* sys_drm_msecure */
- {PAD1_FREF_CLK3_REQ, (IEN | M3)}, /* gpio_wk30 */
- {PAD0_FREF_CLK3_OUT, (M0)}, /* fref_clk3_out */
- {PAD1_FREF_CLK4_REQ, (M0)}, /* fref_clk4_req */
- {PAD0_FREF_CLK4_OUT, (M0)}, /* fref_clk4_out */
- {PAD1_SYS_32K, (IEN | M0)}, /* sys_32k */
- {PAD0_SYS_NRESPWRON, (M0)}, /* sys_nrespwron */
- {PAD1_SYS_NRESWARM, (M0)}, /* sys_nreswarm */
- {PAD0_SYS_PWR_REQ, (PTU | M0)}, /* sys_pwr_req */
- {PAD1_SYS_PWRON_RESET, (M0)}, /* sys_pwron_reset_out */
- {PAD0_SYS_BOOT6, (M0)}, /* sys_boot6 */
- {PAD1_SYS_BOOT7, (M0)}, /* sys_boot7 */
+ {GPIO_WK0, (SAFE_MODE)}, /* nc */
+ {GPIO_WK1, (SAFE_MODE)}, /* nc */
+ {GPIO_WK2, (SAFE_MODE)}, /* nc */
+ {GPIO_WK3, (SAFE_MODE)}, /* nc */
+ {GPIO_WK4, (SAFE_MODE)}, /* nc */
+ {SR_SCL, (PTU | IEN | M0)}, /* sr_scl */
+ {SR_SDA, (PTU | IEN | M0)}, /* sr_sda */
+ {FREF_XTAL_IN, (M0)}, /* # */
+ {FREF_SLICER_IN, (SAFE_MODE)}, /* nc */
+ {FREF_CLK_IOREQ, (SAFE_MODE)}, /* nc */
+ {FREF_CLK0_OUT, (M2)}, /* sys_drm_msecure */
+ {FREF_CLK3_REQ, (IEN | M3)}, /* gpio_wk30 */
+ {FREF_CLK3_OUT, (M0)}, /* fref_clk3_out */
+ {FREF_CLK4_REQ, (M0)}, /* fref_clk4_req */
+ {FREF_CLK4_OUT, (M0)}, /* fref_clk4_out */
+ {SYS_32K, (IEN | M0)}, /* sys_32k */
+ {SYS_NRESPWRON, (M0)}, /* sys_nrespwron */
+ {SYS_NRESWARM, (M0)}, /* sys_nreswarm */
+ {SYS_PWR_REQ, (PTU | M0)}, /* sys_pwr_req */
+ {SYS_PWRON_RESET_OUT, (M0)}, /* sys_pwron_reset_out */
+ {SYS_BOOT6, (M0)}, /* sys_boot6 */
+ {SYS_BOOT7, (M0)}, /* sys_boot7 */
};
void set_muxconf_regs(void)
diff --git a/arch/arm/boards/phycard-a-xl2/mux.c b/arch/arm/boards/phycard-a-xl2/mux.c
index dc605e3..e852c84 100644
--- a/arch/arm/boards/phycard-a-xl2/mux.c
+++ b/arch/arm/boards/phycard-a-xl2/mux.c
@@ -212,28 +212,28 @@ static const struct pad_conf_entry core_padconf_array[] = {
};
static const struct pad_conf_entry wkup_padconf_array[] = {
- {PAD0_SIM_IO, (SAFE_MODE)}, /* tbd */
- {PAD1_SIM_CLK, (SAFE_MODE)}, /* nc */
- {PAD0_SIM_RESET, (SAFE_MODE)}, /* nc */
- {PAD1_SIM_CD, (SAFE_MODE)}, /* nc */
- {PAD0_SIM_PWRCTRL, (SAFE_MODE)}, /* nc */
- {PAD1_SR_SCL, (PTU | IEN | M0)}, /* sr_scl */
- {PAD0_SR_SDA, (PTU | IEN | M0)}, /* sr_sda */
- {PAD1_FREF_XTAL_IN, (M0)}, /* # */
- {PAD0_FREF_SLICER_IN, (SAFE_MODE)}, /* nc */
- {PAD1_FREF_CLK_IOREQ, (SAFE_MODE)}, /* nc */
- {PAD0_FREF_CLK0_OUT, (M2)}, /* sys_drm_msecure */
- {PAD1_FREF_CLK3_REQ, (SAFE_MODE)}, /* nc */
- {PAD0_FREF_CLK3_OUT, (M0)}, /* fref_clk3_out */
- {PAD1_FREF_CLK4_REQ, (IEN | M3)}, /* gpio_wk7 */
- {PAD0_FREF_CLK4_OUT, (M0)}, /* fref_clk4_out */
- {PAD1_SYS_32K, (IEN | M0)}, /* sys_32k */
- {PAD0_SYS_NRESPWRON, (M0)}, /* sys_nrespwron */
- {PAD1_SYS_NRESWARM, (M0)}, /* sys_nreswarm */
- {PAD0_SYS_PWR_REQ, (PTU | M0)}, /* sys_pwr_req */
- {PAD1_SYS_PWRON_RESET, (M0)}, /* sys_pwron_reset_out */
- {PAD0_SYS_BOOT6, (M0)}, /* sys_boot6 */
- {PAD1_SYS_BOOT7, (M0)}, /* sys_boot7 */
+ {GPIO_WK0, (SAFE_MODE)}, /* tbd */
+ {GPIO_WK1, (SAFE_MODE)}, /* nc */
+ {GPIO_WK2, (SAFE_MODE)}, /* nc */
+ {GPIO_WK3, (SAFE_MODE)}, /* nc */
+ {GPIO_WK4, (SAFE_MODE)}, /* nc */
+ {SR_SCL, (PTU | IEN | M0)}, /* sr_scl */
+ {SR_SDA, (PTU | IEN | M0)}, /* sr_sda */
+ {FREF_XTAL_IN, (M0)}, /* # */
+ {FREF_SLICER_IN, (SAFE_MODE)}, /* nc */
+ {FREF_CLK_IOREQ, (SAFE_MODE)}, /* nc */
+ {FREF_CLK0_OUT, (M2)}, /* sys_drm_msecure */
+ {FREF_CLK3_REQ, (SAFE_MODE)}, /* nc */
+ {FREF_CLK3_OUT, (M0)}, /* fref_clk3_out */
+ {FREF_CLK4_REQ, (IEN | M3)}, /* gpio_wk7 */
+ {FREF_CLK4_OUT, (M0)}, /* fref_clk4_out */
+ {SYS_32K, (IEN | M0)}, /* sys_32k */
+ {SYS_NRESPWRON, (M0)}, /* sys_nrespwron */
+ {SYS_NRESWARM, (M0)}, /* sys_nreswarm */
+ {SYS_PWR_REQ, (PTU | M0)}, /* sys_pwr_req */
+ {SYS_PWRON_RESET_OUT, (M0)}, /* sys_pwron_reset_out */
+ {SYS_BOOT6, (M0)}, /* sys_boot6 */
+ {SYS_BOOT7, (M0)}, /* sys_boot7 */
};
void set_muxconf_regs(void)
@@ -246,7 +246,7 @@ void set_muxconf_regs(void)
/* gpio_wk7 is used for controlling TPS on 4460 */
if (omap4_revision() >= OMAP4460_ES1_0) {
- writew(M3, OMAP44XX_CONTROL_PADCONF_WKUP + PAD1_FREF_CLK4_REQ);
+ writew(M3, OMAP44XX_CONTROL_PADCONF_WKUP + FREF_CLK4_REQ);
/* Enable GPIO-1 clocks before TPS initialization */
omap4_enable_gpio1_wup_clocks();
}
diff --git a/arch/arm/mach-omap/include/mach/omap4-mux.h b/arch/arm/mach-omap/include/mach/omap4-mux.h
index d06beaa..d35ced8 100644
--- a/arch/arm/mach-omap/include/mach/omap4-mux.h
+++ b/arch/arm/mach-omap/include/mach/omap4-mux.h
@@ -36,6 +36,7 @@ struct pad_conf_entry {
} __attribute__ ((packed));
+#define WAKEUP_EN (1 << 14)
#ifdef CONFIG_OFF_PADCONF
#define OFF_PD (1 << 12)
#define OFF_PU (3 << 12)
@@ -87,209 +88,232 @@ struct pad_conf_entry {
#define CORE_REVISION 0x0000
#define CORE_HWINFO 0x0004
#define CORE_SYSCONFIG 0x0010
-#define GPMC_AD0 0x0040
-#define GPMC_AD1 0x0042
-#define GPMC_AD2 0x0044
-#define GPMC_AD3 0x0046
-#define GPMC_AD4 0x0048
-#define GPMC_AD5 0x004A
-#define GPMC_AD6 0x004C
-#define GPMC_AD7 0x004E
-#define GPMC_AD8 0x0050
-#define GPMC_AD9 0x0052
-#define GPMC_AD10 0x0054
-#define GPMC_AD11 0x0056
-#define GPMC_AD12 0x0058
-#define GPMC_AD13 0x005A
-#define GPMC_AD14 0x005C
-#define GPMC_AD15 0x005E
-#define GPMC_A16 0x0060
-#define GPMC_A17 0x0062
-#define GPMC_A18 0x0064
-#define GPMC_A19 0x0066
-#define GPMC_A20 0x0068
-#define GPMC_A21 0x006A
-#define GPMC_A22 0x006C
-#define GPMC_A23 0x006E
-#define GPMC_A24 0x0070
-#define GPMC_A25 0x0072
-#define GPMC_NCS0 0x0074
-#define GPMC_NCS1 0x0076
-#define GPMC_NCS2 0x0078
-#define GPMC_NCS3 0x007A
-#define GPMC_NWP 0x007C
-#define GPMC_CLK 0x007E
-#define GPMC_NADV_ALE 0x0080
-#define GPMC_NOE 0x0082
-#define GPMC_NWE 0x0084
-#define GPMC_NBE0_CLE 0x0086
-#define GPMC_NBE1 0x0088
-#define GPMC_WAIT0 0x008A
-#define GPMC_WAIT1 0x008C
-#define C2C_DATA11 0x008E
-#define C2C_DATA12 0x0090
-#define C2C_DATA13 0x0092
-#define C2C_DATA14 0x0094
-#define C2C_DATA15 0x0096
-#define HDMI_HPD 0x0098
-#define HDMI_CEC 0x009A
-#define HDMI_DDC_SCL 0x009C
-#define HDMI_DDC_SDA 0x009E
-#define CSI21_DX0 0x00A0
-#define CSI21_DY0 0x00A2
-#define CSI21_DX1 0x00A4
-#define CSI21_DY1 0x00A6
-#define CSI21_DX2 0x00A8
-#define CSI21_DY2 0x00AA
-#define CSI21_DX3 0x00AC
-#define CSI21_DY3 0x00AE
-#define CSI21_DX4 0x00B0
-#define CSI21_DY4 0x00B2
-#define CSI22_DX0 0x00B4
-#define CSI22_DY0 0x00B6
-#define CSI22_DX1 0x00B8
-#define CSI22_DY1 0x00BA
-#define CAM_SHUTTER 0x00BC
-#define CAM_STROBE 0x00BE
-#define CAM_GLOBALRESET 0x00C0
-#define USBB1_ULPITLL_CLK 0x00C2
-#define USBB1_ULPITLL_STP 0x00C4
-#define USBB1_ULPITLL_DIR 0x00C6
-#define USBB1_ULPITLL_NXT 0x00C8
-#define USBB1_ULPITLL_DAT0 0x00CA
-#define USBB1_ULPITLL_DAT1 0x00CC
-#define USBB1_ULPITLL_DAT2 0x00CE
-#define USBB1_ULPITLL_DAT3 0x00D0
-#define USBB1_ULPITLL_DAT4 0x00D2
-#define USBB1_ULPITLL_DAT5 0x00D4
-#define USBB1_ULPITLL_DAT6 0x00D6
-#define USBB1_ULPITLL_DAT7 0x00D8
-#define USBB1_HSIC_DATA 0x00DA
-#define USBB1_HSIC_STROBE 0x00DC
-#define USBC1_ICUSB_DP 0x00DE
-#define USBC1_ICUSB_DM 0x00E0
-#define SDMMC1_CLK 0x00E2
-#define SDMMC1_CMD 0x00E4
-#define SDMMC1_DAT0 0x00E6
-#define SDMMC1_DAT1 0x00E8
-#define SDMMC1_DAT2 0x00EA
-#define SDMMC1_DAT3 0x00EC
-#define SDMMC1_DAT4 0x00EE
-#define SDMMC1_DAT5 0x00F0
-#define SDMMC1_DAT6 0x00F2
-#define SDMMC1_DAT7 0x00F4
-#define ABE_MCBSP2_CLKX 0x00F6
-#define ABE_MCBSP2_DR 0x00F8
-#define ABE_MCBSP2_DX 0x00FA
-#define ABE_MCBSP2_FSX 0x00FC
-#define ABE_MCBSP1_CLKX 0x00FE
-#define ABE_MCBSP1_DR 0x0100
-#define ABE_MCBSP1_DX 0x0102
-#define ABE_MCBSP1_FSX 0x0104
-#define ABE_PDM_UL_DATA 0x0106
-#define ABE_PDM_DL_DATA 0x0108
-#define ABE_PDM_FRAME 0x010A
-#define ABE_PDM_LB_CLK 0x010C
-#define ABE_CLKS 0x010E
-#define ABE_DMIC_CLK1 0x0110
-#define ABE_DMIC_DIN1 0x0112
-#define ABE_DMIC_DIN2 0x0114
-#define ABE_DMIC_DIN3 0x0116
-#define UART2_CTS 0x0118
-#define UART2_RTS 0x011A
-#define UART2_RX 0x011C
-#define UART2_TX 0x011E
-#define HDQ_SIO 0x0120
-#define I2C1_SCL 0x0122
-#define I2C1_SDA 0x0124
-#define I2C2_SCL 0x0126
-#define I2C2_SDA 0x0128
-#define I2C3_SCL 0x012A
-#define I2C3_SDA 0x012C
-#define I2C4_SCL 0x012E
-#define I2C4_SDA 0x0130
-#define MCSPI1_CLK 0x0132
-#define MCSPI1_SOMI 0x0134
-#define MCSPI1_SIMO 0x0136
-#define MCSPI1_CS0 0x0138
-#define MCSPI1_CS1 0x013A
-#define MCSPI1_CS2 0x013C
-#define MCSPI1_CS3 0x013E
-#define UART3_CTS_RCTX 0x0140
-#define UART3_RTS_SD 0x0142
-#define UART3_RX_IRRX 0x0144
-#define UART3_TX_IRTX 0x0146
-#define SDMMC5_CLK 0x0148
-#define SDMMC5_CMD 0x014A
-#define SDMMC5_DAT0 0x014C
-#define SDMMC5_DAT1 0x014E
-#define SDMMC5_DAT2 0x0150
-#define SDMMC5_DAT3 0x0152
-#define MCSPI4_CLK 0x0154
-#define MCSPI4_SIMO 0x0156
-#define MCSPI4_SOMI 0x0158
-#define MCSPI4_CS0 0x015A
-#define UART4_RX 0x015C
-#define UART4_TX 0x015E
-#define USBB2_ULPITLL_CLK 0x0160
-#define USBB2_ULPITLL_STP 0x0162
-#define USBB2_ULPITLL_DIR 0x0164
-#define USBB2_ULPITLL_NXT 0x0166
-#define USBB2_ULPITLL_DAT0 0x0168
-#define USBB2_ULPITLL_DAT1 0x016A
-#define USBB2_ULPITLL_DAT2 0x016C
-#define USBB2_ULPITLL_DAT3 0x016E
-#define USBB2_ULPITLL_DAT4 0x0170
-#define USBB2_ULPITLL_DAT5 0x0172
-#define USBB2_ULPITLL_DAT6 0x0174
-#define USBB2_ULPITLL_DAT7 0x0176
-#define USBB2_HSIC_DATA 0x0178
-#define USBB2_HSIC_STROBE 0x017A
-#define UNIPRO_TX0 0x017C
-#define UNIPRO_TY0 0x017E
-#define UNIPRO_TX1 0x0180
-#define UNIPRO_TY1 0x0182
-#define UNIPRO_TX2 0x0184
-#define UNIPRO_TY2 0x0186
-#define UNIPRO_RX0 0x0188
-#define UNIPRO_RY0 0x018A
-#define UNIPRO_RX1 0x018C
-#define UNIPRO_RY1 0x018E
-#define UNIPRO_RX2 0x0190
-#define UNIPRO_RY2 0x0192
-#define USBA0_OTG_CE 0x0194
-#define USBA0_OTG_DP 0x0196
-#define USBA0_OTG_DM 0x0198
-#define FREF_CLK1_OUT 0x019A
-#define FREF_CLK2_OUT 0x019C
-#define SYS_NIRQ1 0x019E
-#define SYS_NIRQ2 0x01A0
-#define SYS_BOOT0 0x01A2
-#define SYS_BOOT1 0x01A4
-#define SYS_BOOT2 0x01A6
-#define SYS_BOOT3 0x01A8
-#define SYS_BOOT4 0x01AA
-#define SYS_BOOT5 0x01AC
-#define DPM_EMU0 0x01AE
-#define DPM_EMU1 0x01B0
-#define DPM_EMU2 0x01B2
-#define DPM_EMU3 0x01B4
-#define DPM_EMU4 0x01B6
-#define DPM_EMU5 0x01B8
-#define DPM_EMU6 0x01BA
-#define DPM_EMU7 0x01BC
-#define DPM_EMU8 0x01BE
-#define DPM_EMU9 0x01C0
-#define DPM_EMU10 0x01C2
-#define DPM_EMU11 0x01C4
-#define DPM_EMU12 0x01C6
-#define DPM_EMU13 0x01C8
-#define DPM_EMU14 0x01CA
-#define DPM_EMU15 0x01CC
-#define DPM_EMU16 0x01CE
-#define DPM_EMU17 0x01D0
-#define DPM_EMU18 0x01D2
-#define DPM_EMU19 0x01D4
+#define GPMC_AD0 0x0040
+#define GPMC_AD1 0x0042
+#define GPMC_AD2 0x0044
+#define GPMC_AD3 0x0046
+#define GPMC_AD4 0x0048
+#define GPMC_AD5 0x004A
+#define GPMC_AD6 0x004C
+#define GPMC_AD7 0x004E
+#define GPMC_AD8 0x0050
+#define GPMC_AD9 0x0052
+#define GPMC_AD10 0x0054
+#define GPMC_AD11 0x0056
+#define GPMC_AD12 0x0058
+#define GPMC_AD13 0x005A
+#define GPMC_AD14 0x005C
+#define GPMC_AD15 0x005E
+#define GPMC_A16 0x0060
+#define GPMC_A17 0x0062
+#define GPMC_A18 0x0064
+#define GPMC_A19 0x0066
+#define GPMC_A20 0x0068
+#define GPMC_A21 0x006A
+#define GPMC_A22 0x006C
+#define GPMC_A23 0x006E
+#define GPMC_A24 0x0070
+#define GPMC_A25 0x0072
+#define GPMC_NCS0 0x0074
+#define GPMC_NCS1 0x0076
+#define GPMC_NCS2 0x0078
+#define GPMC_NCS3 0x007A
+#define GPMC_NWP 0x007C
+#define GPMC_CLK 0x007E
+#define GPMC_NADV_ALE 0x0080
+#define GPMC_NOE 0x0082
+#define GPMC_NWE 0x0084
+#define GPMC_NBE0_CLE 0x0086
+#define GPMC_NBE1 0x0088
+#define GPMC_WAIT0 0x008A
+#define GPMC_WAIT1 0x008C
+#define C2C_DATA11 0x008E
+#define GPMC_WAIT2 0x008E
+#define C2C_DATA12 0x0090
+#define GPMC_NCS4 0x0090
+#define C2C_DATA13 0x0092
+#define GPMC_NCS5 0x0092
+#define C2C_DATA14 0x0094
+#define GPMC_NCS6 0x0094
+#define C2C_DATA15 0x0096
+#define GPMC_NCS7 0x0096
+#define HDMI_HPD 0x0098
+#define GPIO63 0x0098
+#define HDMI_CEC 0x009A
+#define GPIO64 0x009A
+#define HDMI_DDC_SCL 0x009C
+#define GPIO65 0x009C
+#define HDMI_DDC_SDA 0x009E
+#define GPIO66 0x009E
+#define CSI21_DX0 0x00A0
+#define CSI21_DY0 0x00A2
+#define CSI21_DX1 0x00A4
+#define CSI21_DY1 0x00A6
+#define CSI21_DX2 0x00A8
+#define CSI21_DY2 0x00AA
+#define CSI21_DX3 0x00AC
+#define CSI21_DY3 0x00AE
+#define CSI21_DX4 0x00B0
+#define CSI21_DY4 0x00B2
+#define CSI22_DX0 0x00B4
+#define CSI22_DY0 0x00B6
+#define CSI22_DX1 0x00B8
+#define CSI22_DY1 0x00BA
+#define CAM_SHUTTER 0x00BC
+#define CAM_STROBE 0x00BE
+#define CAM_GLOBALRESET 0x00C0
+#define USBB1_ULPITLL_CLK 0x00C2
+#define USBB1_ULPITLL_STP 0x00C4
+#define USBB1_ULPITLL_DIR 0x00C6
+#define USBB1_ULPITLL_NXT 0x00C8
+#define USBB1_ULPITLL_DAT0 0x00CA
+#define USBB1_ULPITLL_DAT1 0x00CC
+#define USBB1_ULPITLL_DAT2 0x00CE
+#define USBB1_ULPITLL_DAT3 0x00D0
+#define USBB1_ULPITLL_DAT4 0x00D2
+#define USBB1_ULPITLL_DAT5 0x00D4
+#define USBB1_ULPITLL_DAT6 0x00D6
+#define USBB1_ULPITLL_DAT7 0x00D8
+#define USBB1_HSIC_DATA 0x00DA
+#define USBB1_HSIC_STROBE 0x00DC
+#define USBC1_ICUSB_DP 0x00DE
+#define USBC1_ICUSB_DM 0x00E0
+#define SDMMC1_CLK 0x00E2
+#define SDMMC1_CMD 0x00E4
+#define SDMMC1_DAT0 0x00E6
+#define SDMMC1_DAT1 0x00E8
+#define SDMMC1_DAT2 0x00EA
+#define SDMMC1_DAT3 0x00EC
+#define SDMMC1_DAT4 0x00EE
+#define SDMMC1_DAT5 0x00F0
+#define SDMMC1_DAT6 0x00F2
+#define SDMMC1_DAT7 0x00F4
+#define ABE_MCBSP2_CLKX 0x00F6
+#define ABE_MCBSP2_DR 0x00F8
+#define ABE_MCBSP2_DX 0x00FA
+#define ABE_MCBSP2_FSX 0x00FC
+#define ABE_MCBSP1_CLKX 0x00FE
+#define ABE_MCBSP1_DR 0x0100
+#define ABE_MCBSP1_DX 0x0102
+#define ABE_MCBSP1_FSX 0x0104
+#define ABE_PDM_UL_DATA 0x0106
+#define ABE_PDM_DL_DATA 0x0108
+#define ABE_PDM_FRAME 0x010A
+#define ABE_PDM_LB_CLK 0x010C
+#define ABE_CLKS 0x010E
+#define ABE_DMIC_CLK1 0x0110
+#define ABE_DMIC_DIN1 0x0112
+#define ABE_DMIC_DIN2 0x0114
+#define ABE_DMIC_DIN3 0x0116
+#define UART2_CTS 0x0118
+#define UART2_RTS 0x011A
+#define UART2_RX 0x011C
+#define UART2_TX 0x011E
+#define HDQ_SIO 0x0120
+#define I2C1_SCL 0x0122
+#define I2C1_SDA 0x0124
+#define I2C2_SCL 0x0126
+#define I2C2_SDA 0x0128
+#define I2C3_SCL 0x012A
+#define I2C3_SDA 0x012C
+#define I2C4_SCL 0x012E
+#define I2C4_SDA 0x0130
+#define MCSPI1_CLK 0x0132
+#define MCSPI1_SOMI 0x0134
+#define MCSPI1_SIMO 0x0136
+#define MCSPI1_CS0 0x0138
+#define MCSPI1_CS1 0x013A
+#define MCSPI1_CS2 0x013C
+#define MCSPI1_CS3 0x013E
+#define UART3_CTS_RCTX 0x0140
+#define UART3_RTS_SD 0x0142
+#define UART3_RX_IRRX 0x0144
+#define UART3_TX_IRTX 0x0146
+#define SDMMC5_CLK 0x0148
+#define SDMMC5_CMD 0x014A
+#define SDMMC5_DAT0 0x014C
+#define SDMMC5_DAT1 0x014E
+#define SDMMC5_DAT2 0x0150
+#define SDMMC5_DAT3 0x0152
+#define MCSPI4_CLK 0x0154
+#define MCSPI4_SIMO 0x0156
+#define MCSPI4_SOMI 0x0158
+#define MCSPI4_CS0 0x015A
+#define UART4_RX 0x015C
+#define UART4_TX 0x015E
+#define USBB2_ULPITLL_CLK 0x0160
+#define USBB2_ULPITLL_STP 0x0162
+#define USBB2_ULPITLL_DIR 0x0164
+#define USBB2_ULPITLL_NXT 0x0166
+#define USBB2_ULPITLL_DAT0 0x0168
+#define USBB2_ULPITLL_DAT1 0x016A
+#define USBB2_ULPITLL_DAT2 0x016C
+#define USBB2_ULPITLL_DAT3 0x016E
+#define USBB2_ULPITLL_DAT4 0x0170
+#define USBB2_ULPITLL_DAT5 0x0172
+#define USBB2_ULPITLL_DAT6 0x0174
+#define USBB2_ULPITLL_DAT7 0x0176
+#define USBB2_HSIC_DATA 0x0178
+#define USBB2_HSIC_STROBE 0x017A
+#define UNIPRO_TX0 0x017C
+#define KPD_COL3 0x017C
+#define UNIPRO_TY0 0x017E
+#define KPD_COL4 0x017E
+#define UNIPRO_TX1 0x0180
+#define KPD_COL5 0x0180
+#define UNIPRO_TY1 0x0182
+#define KPD_COL0 0x0182
+#define UNIPRO_TX2 0x0184
+#define KPD_COL1 0x0184
+#define UNIPRO_TY2 0x0186
+#define KPD_COL2 0x0186
+#define UNIPRO_RX0 0x0188
+#define KPD_ROW3 0x0188
+#define UNIPRO_RY0 0x018A
+#define KPD_ROW4 0x018A
+#define UNIPRO_RX1 0x018C
+#define KPD_ROW5 0x018C
+#define UNIPRO_RY1 0x018E
+#define KPD_ROW0 0x018E
+#define UNIPRO_RX2 0x0190
+#define KPD_ROW1 0x0190
+#define UNIPRO_RY2 0x0192
+#define KPD_ROW2 0x0192
+#define USBA0_OTG_CE 0x0194
+#define USBA0_OTG_DP 0x0196
+#define USBA0_OTG_DM 0x0198
+#define FREF_CLK1_OUT 0x019A
+#define FREF_CLK2_OUT 0x019C
+#define SYS_NIRQ1 0x019E
+#define SYS_NIRQ2 0x01A0
+#define SYS_BOOT0 0x01A2
+#define SYS_BOOT1 0x01A4
+#define SYS_BOOT2 0x01A6
+#define SYS_BOOT3 0x01A8
+#define SYS_BOOT4 0x01AA
+#define SYS_BOOT5 0x01AC
+#define DPM_EMU0 0x01AE
+#define DPM_EMU1 0x01B0
+#define DPM_EMU2 0x01B2
+#define DPM_EMU3 0x01B4
+#define DPM_EMU4 0x01B6
+#define DPM_EMU5 0x01B8
+#define DPM_EMU6 0x01BA
+#define DPM_EMU7 0x01BC
+#define DPM_EMU8 0x01BE
+#define DPM_EMU9 0x01C0
+#define DPM_EMU10 0x01C2
+#define DPM_EMU11 0x01C4
+#define DPM_EMU12 0x01C6
+#define DPM_EMU13 0x01C8
+#define DPM_EMU14 0x01CA
+#define DPM_EMU15 0x01CC
+#define DPM_EMU16 0x01CE
+#define DPM_EMU17 0x01D0
+#define DPM_EMU18 0x01D2
+#define DPM_EMU19 0x01D4
+#define CSI22_DX2 0x01D6
+#define CSI22_DY2 0x01F4
#define WAKEUPEVENT_0 0x01D8
#define WAKEUPEVENT_1 0x01DC
#define WAKEUPEVENT_2 0x01E0
@@ -301,34 +325,34 @@ struct pad_conf_entry {
#define WKUP_REVISION 0x0000
#define WKUP_HWINFO 0x0004
#define WKUP_SYSCONFIG 0x0010
-#define PAD0_SIM_IO 0x0040
-#define PAD1_SIM_CLK 0x0042
-#define PAD0_SIM_RESET 0x0044
-#define PAD1_SIM_CD 0x0046
-#define PAD0_SIM_PWRCTRL 0x0048
-#define PAD1_SR_SCL 0x004A
-#define PAD0_SR_SDA 0x004C
-#define PAD1_FREF_XTAL_IN 0x004E
-#define PAD0_FREF_SLICER_IN 0x0050
-#define PAD1_FREF_CLK_IOREQ 0x0052
-#define PAD0_FREF_CLK0_OUT 0x0054
-#define PAD1_FREF_CLK3_REQ 0x0056
-#define PAD0_FREF_CLK3_OUT 0x0058
-#define PAD1_FREF_CLK4_REQ 0x005A
-#define PAD0_FREF_CLK4_OUT 0x005C
-#define PAD1_SYS_32K 0x005E
-#define PAD0_SYS_NRESPWRON 0x0060
-#define PAD1_SYS_NRESWARM 0x0062
-#define PAD0_SYS_PWR_REQ 0x0064
-#define PAD1_SYS_PWRON_RESET 0x0066
-#define PAD0_SYS_BOOT6 0x0068
-#define PAD1_SYS_BOOT7 0x006A
-#define PAD0_JTAG_NTRST 0x006C
-#define PAD1_JTAG_TCK 0x006D
-#define PAD0_JTAG_RTCK 0x0070
-#define PAD1_JTAG_TMS_TMSC 0x0072
-#define PAD0_JTAG_TDI 0x0074
-#define PAD1_JTAG_TDO 0x0076
+#define GPIO_WK0 0x0040
+#define GPIO_WK1 0x0042
+#define GPIO_WK2 0x0044
+#define GPIO_WK3 0x0046
+#define GPIO_WK4 0x0048
+#define SR_SCL 0x004A
+#define SR_SDA 0x004C
+#define FREF_XTAL_IN 0x004E
+#define FREF_SLICER_IN 0x0050
+#define FREF_CLK_IOREQ 0x0052
+#define FREF_CLK0_OUT 0x0054
+#define FREF_CLK3_REQ 0x0056
+#define FREF_CLK3_OUT 0x0058
+#define FREF_CLK4_REQ 0x005A
+#define FREF_CLK4_OUT 0x005C
+#define SYS_32K 0x005E
+#define SYS_NRESPWRON 0x0060
+#define SYS_NRESWARM 0x0062
+#define SYS_PWR_REQ 0x0064
+#define SYS_PWRON_RESET_OUT 0x0066
+#define SYS_BOOT6 0x0068
+#define SYS_BOOT7 0x006A
+#define JTAG_NTRST 0x006C
+#define JTAG_TCK 0x006E
+#define JTAG_RTCK 0x0070
+#define JTAG_TMS_TMSC 0x0072
+#define JTAG_TDI 0x0074
+#define JTAG_TDO 0x0076
#define PADCONF_WAKEUPEVENT_0 0x007C
#define CONTROL_SMART1NOPMIO_PADCONF_0 0x05A0
#define CONTROL_SMART1NOPMIO_PADCONF_1 0x05A4
diff --git a/arch/arm/mach-omap/include/mach/omap4-silicon.h b/arch/arm/mach-omap/include/mach/omap4-silicon.h
index 4082bac..a6b3f2b 100644
--- a/arch/arm/mach-omap/include/mach/omap4-silicon.h
+++ b/arch/arm/mach-omap/include/mach/omap4-silicon.h
@@ -76,6 +76,12 @@
#define OMAP44XX_UART2_BASE (OMAP44XX_L4_PER_BASE + 0x6c000)
#define OMAP44XX_UART3_BASE (OMAP44XX_L4_PER_BASE + 0x20000)
+/* I2C */
+#define OMAP44XX_I2C1_BASE (OMAP44XX_L4_PER_BASE + 0x070000)
+#define OMAP44XX_I2C2_BASE (OMAP44XX_L4_PER_BASE + 0x072000)
+#define OMAP44XX_I2C3_BASE (OMAP44XX_L4_PER_BASE + 0x060000)
+#define OMAP44XX_I2C4_BASE (OMAP44XX_L4_PER_BASE + 0x350000)
+
/* General Purpose Timers */
#define OMAP44XX_GPT1_BASE (OMAP44XX_L4_WKUP_BASE + 0x18000)
#define OMAP44XX_GPT2_BASE (OMAP44XX_L4_PER_BASE + 0x32000)
@@ -92,6 +98,13 @@
/* 32KTIMER */
#define OMAP_32KTIMER_BASE (OMAP44XX_L4_WKUP_BASE + 0x4000)
+/* MMC */
+#define OMAP44XX_MMC1_BASE (OMAP44XX_L4_PER_BASE + 0x09C100)
+#define OMAP44XX_MMC2_BASE (OMAP44XX_L4_PER_BASE + 0x0B4100)
+#define OMAP44XX_MMC3_BASE (OMAP44XX_L4_PER_BASE + 0x0AD100)
+#define OMAP44XX_MMC4_BASE (OMAP44XX_L4_PER_BASE + 0x0D1100)
+#define OMAP44XX_MMC5_BASE (OMAP44XX_L4_PER_BASE + 0x0D5100)
+
/* GPMC */
#define OMAP_GPMC_BASE 0x50000000
diff --git a/arch/arm/mach-omap/include/mach/xload.h b/arch/arm/mach-omap/include/mach/xload.h
index 844b57f..cfc3f68 100644
--- a/arch/arm/mach-omap/include/mach/xload.h
+++ b/arch/arm/mach-omap/include/mach/xload.h
@@ -8,6 +8,7 @@ enum omap_boot_src {
OMAP_BOOTSRC_UNKNOWN,
OMAP_BOOTSRC_MMC1,
OMAP_BOOTSRC_NAND,
+ OMAP_BOOTSRC_USB1,
};
enum omap_boot_src omap3_bootsrc(void);
diff --git a/arch/arm/mach-omap/omap4_generic.c b/arch/arm/mach-omap/omap4_generic.c
index 617d786..6562268 100644
--- a/arch/arm/mach-omap/omap4_generic.c
+++ b/arch/arm/mach-omap/omap4_generic.c
@@ -481,6 +481,8 @@ enum omap_boot_src omap4_bootsrc(void)
return OMAP_BOOTSRC_MMC1;
if (bootsrc & (1 << 3))
return OMAP_BOOTSRC_NAND;
+ if (bootsrc & (1<<20))
+ return OMAP_BOOTSRC_USB1;
return OMAP_BOOTSRC_UNKNOWN;
}
diff --git a/arch/arm/mach-omap/xload.c b/arch/arm/mach-omap/xload.c
index 13024ab..225b19a 100644
--- a/arch/arm/mach-omap/xload.c
+++ b/arch/arm/mach-omap/xload.c
@@ -77,6 +77,7 @@ int run_shell(void)
func = omap_xload_boot_mmc();
break;
case OMAP_BOOTSRC_UNKNOWN:
+ default:
printf("unknown boot source. Fall back to nand\n");
case OMAP_BOOTSRC_NAND:
printf("booting from NAND\n");
--
1.7.12.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 4/9] twl6030: add debug info
2012-09-30 2:50 [PATCH 0/9] archosg9: add support for tablet, second round vj
` (2 preceding siblings ...)
2012-09-30 2:50 ` [PATCH 3/9] omap4: add/rename definitions to match datasheet vj
@ 2012-09-30 2:50 ` vj
2012-09-30 13:50 ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-02 13:46 ` Sascha Hauer
2012-09-30 2:50 ` [PATCH 5/9] add gitignore file vj
` (5 subsequent siblings)
9 siblings, 2 replies; 27+ messages in thread
From: vj @ 2012-09-30 2:50 UTC (permalink / raw)
To: barebox; +Cc: vj
---
drivers/mfd/twl6030.c | 22 ++++++++++++++++++++++
include/mfd/twl6030.h | 8 ++++++++
2 files changed, 30 insertions(+)
diff --git a/drivers/mfd/twl6030.c b/drivers/mfd/twl6030.c
index 7ecfed8..b8b0418 100644
--- a/drivers/mfd/twl6030.c
+++ b/drivers/mfd/twl6030.c
@@ -39,6 +39,28 @@ static int twl_probe(struct device_d *dev)
devfs_create(&(twl_dev->core.cdev));
+#ifdef DEBUG
+ {
+ u8 i, jtag_rev, eprom_rev;
+ int r;
+ u64 dieid;
+ r = twl6030_reg_read(twl_dev, TWL6030_JTAG_JTAGVERNUM,
+ &jtag_rev);
+ r |= twl6030_reg_read(twl_dev, TWL6030_JTAG_EPROM_REV,
+ &eprom_rev);
+ for (i = 0; i < 8; i++)
+ r |= twl6030_reg_read(twl_dev, TWL6030_DIEID_0+i,
+ ((u8 *)(&dieid))+i);
+ if (r)
+ debug("TWL6030 Error reading ID\n");
+ else
+ debug("TWL6030 JTAG REV: 0x%02X, "
+ "EPROM REV: 0x%02X, "
+ "DIE ID: 0x%016llX\n",
+ (unsigned)jtag_rev, (unsigned)eprom_rev, dieid);
+ }
+#endif
+
return 0;
}
diff --git a/include/mfd/twl6030.h b/include/mfd/twl6030.h
index f1278d4..bb4f773 100644
--- a/include/mfd/twl6030.h
+++ b/include/mfd/twl6030.h
@@ -371,6 +371,14 @@ enum twl6030_reg {
/* JTAG */
TWL6030_JTAG_JTAGVERNUM = 0x0287,
TWL6030_JTAG_EPROM_REV = 0x02DF,
+ TWL6030_DIEID_0 = 0x02C0,
+ TWL6030_DIEID_1 = 0x02C1,
+ TWL6030_DIEID_2 = 0x02C2,
+ TWL6030_DIEID_3 = 0x02C3,
+ TWL6030_DIEID_4 = 0x02C4,
+ TWL6030_DIEID_5 = 0x02C5,
+ TWL6030_DIEID_6 = 0x02C6,
+ TWL6030_DIEID_7 = 0x02C7,
/* GPADC Trimming */
TWL6030_GPADC_TRIM1 = 0x02CD,
TWL6030_GPADC_TRIM2 = 0x02CE,
--
1.7.12.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 4/9] twl6030: add debug info
2012-09-30 2:50 ` [PATCH 4/9] twl6030: add debug info vj
@ 2012-09-30 13:50 ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-02 13:46 ` Sascha Hauer
1 sibling, 0 replies; 27+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-30 13:50 UTC (permalink / raw)
To: vj; +Cc: barebox
On 04:50 Sun 30 Sep , vj wrote:
> ---
> drivers/mfd/twl6030.c | 22 ++++++++++++++++++++++
> include/mfd/twl6030.h | 8 ++++++++
> 2 files changed, 30 insertions(+)
>
> diff --git a/drivers/mfd/twl6030.c b/drivers/mfd/twl6030.c
> index 7ecfed8..b8b0418 100644
> --- a/drivers/mfd/twl6030.c
> +++ b/drivers/mfd/twl6030.c
> @@ -39,6 +39,28 @@ static int twl_probe(struct device_d *dev)
>
> devfs_create(&(twl_dev->core.cdev));
>
> +#ifdef DEBUG
if (IS_ENABLED(DEBUG)) {
....
}
> + {
> + u8 i, jtag_rev, eprom_rev;
> + int r;
> + u64 dieid;
> + r = twl6030_reg_read(twl_dev, TWL6030_JTAG_JTAGVERNUM,
> + &jtag_rev);
> + r |= twl6030_reg_read(twl_dev, TWL6030_JTAG_EPROM_REV,
> + &eprom_rev);
> + for (i = 0; i < 8; i++)
> + r |= twl6030_reg_read(twl_dev, TWL6030_DIEID_0+i,
> + ((u8 *)(&dieid))+i);
> + if (r)
> + debug("TWL6030 Error reading ID\n");
> + else
> + debug("TWL6030 JTAG REV: 0x%02X, "
> + "EPROM REV: 0x%02X, "
> + "DIE ID: 0x%016llX\n",
> + (unsigned)jtag_rev, (unsigned)eprom_rev, dieid);
> + }
> +#endif
> +
> return 0;
> }
>
> diff --git a/include/mfd/twl6030.h b/include/mfd/twl6030.h
> index f1278d4..bb4f773 100644
> --- a/include/mfd/twl6030.h
> +++ b/include/mfd/twl6030.h
> @@ -371,6 +371,14 @@ enum twl6030_reg {
> /* JTAG */
> TWL6030_JTAG_JTAGVERNUM = 0x0287,
> TWL6030_JTAG_EPROM_REV = 0x02DF,
> + TWL6030_DIEID_0 = 0x02C0,
> + TWL6030_DIEID_1 = 0x02C1,
> + TWL6030_DIEID_2 = 0x02C2,
> + TWL6030_DIEID_3 = 0x02C3,
> + TWL6030_DIEID_4 = 0x02C4,
> + TWL6030_DIEID_5 = 0x02C5,
> + TWL6030_DIEID_6 = 0x02C6,
> + TWL6030_DIEID_7 = 0x02C7,
> /* GPADC Trimming */
> TWL6030_GPADC_TRIM1 = 0x02CD,
> TWL6030_GPADC_TRIM2 = 0x02CE,
> --
> 1.7.12.1
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 4/9] twl6030: add debug info
2012-09-30 2:50 ` [PATCH 4/9] twl6030: add debug info vj
2012-09-30 13:50 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2012-10-02 13:46 ` Sascha Hauer
1 sibling, 0 replies; 27+ messages in thread
From: Sascha Hauer @ 2012-10-02 13:46 UTC (permalink / raw)
To: vj; +Cc: barebox
On Sun, Sep 30, 2012 at 04:50:32AM +0200, vj wrote:
> ---
> drivers/mfd/twl6030.c | 22 ++++++++++++++++++++++
> include/mfd/twl6030.h | 8 ++++++++
> 2 files changed, 30 insertions(+)
>
> diff --git a/drivers/mfd/twl6030.c b/drivers/mfd/twl6030.c
> index 7ecfed8..b8b0418 100644
> --- a/drivers/mfd/twl6030.c
> +++ b/drivers/mfd/twl6030.c
> @@ -39,6 +39,28 @@ static int twl_probe(struct device_d *dev)
>
> devfs_create(&(twl_dev->core.cdev));
>
> +#ifdef DEBUG
> + {
> + u8 i, jtag_rev, eprom_rev;
> + int r;
> + u64 dieid;
> + r = twl6030_reg_read(twl_dev, TWL6030_JTAG_JTAGVERNUM,
> + &jtag_rev);
> + r |= twl6030_reg_read(twl_dev, TWL6030_JTAG_EPROM_REV,
> + &eprom_rev);
> + for (i = 0; i < 8; i++)
> + r |= twl6030_reg_read(twl_dev, TWL6030_DIEID_0+i,
> + ((u8 *)(&dieid))+i);
> + if (r)
> + debug("TWL6030 Error reading ID\n");
> + else
> + debug("TWL6030 JTAG REV: 0x%02X, "
> + "EPROM REV: 0x%02X, "
> + "DIE ID: 0x%016llX\n",
> + (unsigned)jtag_rev, (unsigned)eprom_rev, dieid);
Please use dev_dbg for driver/device related messages. dev_dbg will add
the correct context to the message.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 5/9] add gitignore file
2012-09-30 2:50 [PATCH 0/9] archosg9: add support for tablet, second round vj
` (3 preceding siblings ...)
2012-09-30 2:50 ` [PATCH 4/9] twl6030: add debug info vj
@ 2012-09-30 2:50 ` vj
2012-09-30 2:50 ` [PATCH 6/9] omap4: add usb boot support vj
` (4 subsequent siblings)
9 siblings, 0 replies; 27+ messages in thread
From: vj @ 2012-09-30 2:50 UTC (permalink / raw)
To: barebox; +Cc: vj
---
scripts/kconfig/.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/scripts/kconfig/.gitignore b/scripts/kconfig/.gitignore
index 624f650..9cd5120 100644
--- a/scripts/kconfig/.gitignore
+++ b/scripts/kconfig/.gitignore
@@ -3,6 +3,7 @@
#
config*
lex.*.c
+*.lex.c
*.tab.c
*.tab.h
zconf.hash.c
--
1.7.12.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 6/9] omap4: add usb boot support
2012-09-30 2:50 [PATCH 0/9] archosg9: add support for tablet, second round vj
` (4 preceding siblings ...)
2012-09-30 2:50 ` [PATCH 5/9] add gitignore file vj
@ 2012-09-30 2:50 ` vj
2012-09-30 12:14 ` Antony Pavlov
` (2 more replies)
2012-09-30 2:50 ` [PATCH 7/9] omap4: add serial communications over usb boot vj
` (3 subsequent siblings)
9 siblings, 3 replies; 27+ messages in thread
From: vj @ 2012-09-30 2:50 UTC (permalink / raw)
To: barebox; +Cc: vj
---
arch/arm/cpu/cpu.c | 1 +
arch/arm/mach-omap/Kconfig | 7 +
arch/arm/mach-omap/Makefile | 1 +
arch/arm/mach-omap/include/mach/omap4_rom_usb.h | 142 ++++++++
arch/arm/mach-omap/omap4_generic.c | 13 +
arch/arm/mach-omap/omap4_rom_usb.c | 186 +++++++++++
scripts/.gitignore | 1 +
scripts/Makefile | 4 +
scripts/omap4_usbboot.c | 416 ++++++++++++++++++++++++
scripts/usb.h | 61 ++++
scripts/usb_linux.c | 397 ++++++++++++++++++++++
11 files changed, 1229 insertions(+)
create mode 100644 arch/arm/mach-omap/include/mach/omap4_rom_usb.h
create mode 100644 arch/arm/mach-omap/omap4_rom_usb.c
create mode 100644 scripts/omap4_usbboot.c
create mode 100644 scripts/usb.h
create mode 100644 scripts/usb_linux.c
diff --git a/arch/arm/cpu/cpu.c b/arch/arm/cpu/cpu.c
index 71ef8c0..05343de 100644
--- a/arch/arm/cpu/cpu.c
+++ b/arch/arm/cpu/cpu.c
@@ -89,6 +89,7 @@ void arch_shutdown(void)
: "r0", "r1", "r2", "r3", "r6", "r10", "r12", "lr", "cc", "memory"
);
#endif
+ __asm__ __volatile__ ("cpsid i\n");
}
#ifdef CONFIG_THUMB2_BAREBOX
diff --git a/arch/arm/mach-omap/Kconfig b/arch/arm/mach-omap/Kconfig
index d735284..16583cb 100644
--- a/arch/arm/mach-omap/Kconfig
+++ b/arch/arm/mach-omap/Kconfig
@@ -96,6 +96,13 @@ config ARCH_TEXT_BASE
default 0x80e80000 if MACH_OMAP343xSDP
default 0x80e80000 if MACH_BEAGLE
+config OMAP4_USBBOOT
+ bool "enable booting from USB"
+ default n
+ depends on ARCH_OMAP4 && !MMU
+ help
+ Enable this to enable USB booting
+
config BOARDINFO
default "Texas Instrument's SDP343x" if MACH_OMAP343xSDP
default "Texas Instrument's Beagle" if MACH_BEAGLE
diff --git a/arch/arm/mach-omap/Makefile b/arch/arm/mach-omap/Makefile
index f087f4b..e89f6ed 100644
--- a/arch/arm/mach-omap/Makefile
+++ b/arch/arm/mach-omap/Makefile
@@ -30,4 +30,5 @@ obj-$(CONFIG_OMAP3_CLOCK_CONFIG) += omap3_clock.o
obj-$(CONFIG_OMAP_GPMC) += gpmc.o devices-gpmc-nand.o
obj-$(CONFIG_SHELL_NONE) += xload.o
obj-$(CONFIG_I2C_TWL6030) += omap4_twl6030_mmc.o
+obj-$(CONFIG_OMAP4_USBBOOT) += omap4_rom_usb.o
obj-y += gpio.o
diff --git a/arch/arm/mach-omap/include/mach/omap4_rom_usb.h b/arch/arm/mach-omap/include/mach/omap4_rom_usb.h
new file mode 100644
index 0000000..b7818df
--- /dev/null
+++ b/arch/arm/mach-omap/include/mach/omap4_rom_usb.h
@@ -0,0 +1,142 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _OMAP4_ROM_USB_H_
+#define _OMAP4_ROM_USB_H_
+
+/* public api */
+#define PUBLIC_API_BASE_4430 (0x28400)
+#define PUBLIC_API_BASE_4460 (0x30400)
+
+#define PUBLIC_GET_DRIVER_MEM_OFFSET (0x04)
+#define PUBLIC_GET_DRIVER_PER_OFFSET (0x08)
+#define PUBLIC_GET_DEVICE_MEM_OFFSET (0x80)
+#define PUBLIC_GET_DEVICE_PER_OFFSET (0x84)
+
+#define DEVICE_NULL 0x40
+#define DEVICE_UART1 0x41
+#define DEVICE_UART2 0x42
+#define DEVICE_UART3 0x43
+#define DEVICE_UART4 0x44
+#define DEVICE_USB 0x45
+#define DEVICE_USBEXT 0x46
+
+#define XFER_MODE_CPU 0
+#define XFER_MODE_DMA 1
+
+#define STATUS_OKAY 0
+#define STATUS_FAILED 1
+#define STATUS_TIMEOUT 2
+#define STATUS_BAD_PARAM 3
+#define STATUS_WAITING 4
+#define STATUS_NO_MEMORY 5
+#define STATUS_INVALID_PTR 6
+
+/* Memory ROM interface */
+struct read_desc {
+ u32 sector_start;
+ u32 sector_count;
+ void *destination;
+};
+
+struct mem_device {
+ u32 initialized;
+ u8 device_type;
+ u8 trials_count;
+ u32 xip_device;
+ u16 search_size;
+ u32 base_address;
+ u16 hs_toc_mask;
+ u16 gp_toc_mask;
+ void *device_data;
+ u16 *boot_options;
+};
+
+struct mem_driver {
+ int (*init)(struct mem_device *md);
+ int (*read)(struct mem_device *md, struct read_desc *rd);
+ int (*configure)(struct mem_device *md, void *config);
+};
+
+
+/* Peripheral ROM interface */
+struct per_handle {
+ void *set_to_null;
+ void (*callback)(struct per_handle *rh);
+ void *data;
+ u32 length;
+ u16 *options;
+ u32 xfer_mode;
+ u32 device_type;
+ u32 status;
+ u16 hs_toc_mask;
+ u16 gp_toc_mask;
+ u32 config_timeout;
+};
+
+struct per_driver {
+ int (*init)(struct per_handle *rh);
+ int (*read)(struct per_handle *rh);
+ int (*write)(struct per_handle *rh);
+ int (*close)(struct per_handle *rh);
+ int (*config)(struct per_handle *rh, void *x);
+};
+
+#define USB_SETCONFIGDESC_ATTRIBUTES (0)
+#define USB_SETCONFIGDESC_MAXPOWER (1)
+#define USB_SETSUSPEND_CALLBACK (2)
+struct per_usb_config {
+ u32 configid;
+ u32 value;
+};
+
+#define API(n) ((void *) (*((u32 *) (n))))
+/* ROM API End */
+
+struct omap4_usbboot {
+ struct per_handle dread;
+ struct per_handle dwrite;
+ struct per_driver *io;
+};
+
+int omap4_usbboot_open(void);
+void omap4_usbboot_close(void);
+
+void omap4_usbboot_queue_read(void *data, unsigned len);
+int omap4_usbboot_wait_read(void);
+int omap4_usbboot_is_read_waiting(void);
+int omap4_usbboot_is_read_ok(void);
+
+void omap4_usbboot_queue_write(void *data, unsigned len);
+int omap4_usbboot_wait_write(void);
+
+int omap4_usbboot_read(void *data, unsigned len);
+int omap4_usbboot_write(void *data, unsigned len);
+void omap4_usbboot_puts(const char *s);
+
+#endif
diff --git a/arch/arm/mach-omap/omap4_generic.c b/arch/arm/mach-omap/omap4_generic.c
index 6562268..ee62cf2 100644
--- a/arch/arm/mach-omap/omap4_generic.c
+++ b/arch/arm/mach-omap/omap4_generic.c
@@ -8,6 +8,9 @@
#include <mach/xload.h>
#include <mach/gpmc.h>
#include <mach/gpio.h>
+#ifdef CONFIG_OMAP4_USBBOOT
+#include <mach/omap4_rom_usb.h>
+#endif
/*
* The following several lines are taken from U-Boot to support
@@ -457,6 +460,15 @@ static int watchdog_init(void)
}
late_initcall(watchdog_init);
+#ifdef CONFIG_OMAP4_USBBOOT
+static int omap4_usbboot_init(void)
+{
+ omap4_usbboot_open();
+ omap4_usbboot_puts("USB communications initialized\n");
+ return 0;
+}
+postcore_initcall(omap4_usbboot_init);
+#else
static int omap_vector_init(void)
{
__asm__ __volatile__ (
@@ -470,6 +482,7 @@ static int omap_vector_init(void)
return 0;
}
core_initcall(omap_vector_init);
+#endif
#define OMAP4_TRACING_VECTOR3 0x4030d048
diff --git a/arch/arm/mach-omap/omap4_rom_usb.c b/arch/arm/mach-omap/omap4_rom_usb.c
new file mode 100644
index 0000000..741f2b7
--- /dev/null
+++ b/arch/arm/mach-omap/omap4_rom_usb.c
@@ -0,0 +1,186 @@
+/*
+ * This code is based on:
+ * git://github.com/swetland/omap4boot.git
+ */
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <common.h>
+#include <mach/omap4-silicon.h>
+#include <mach/omap4_rom_usb.h>
+
+struct omap4_usbboot *omap4_usbboot_pdata;
+
+int omap4_usbboot_open(void)
+{
+ int (*rom_get_per_driver)(struct per_driver **io, u32 device_type);
+ int (*rom_get_per_device)(struct per_handle **rh);
+ struct per_handle *boot;
+ int n;
+ u32 base;
+
+ if (omap4_revision() >= OMAP4460_ES1_0)
+ base = PUBLIC_API_BASE_4460;
+ else
+ base = PUBLIC_API_BASE_4430;
+
+ rom_get_per_driver = API(base + PUBLIC_GET_DRIVER_PER_OFFSET);
+ rom_get_per_device = API(base + PUBLIC_GET_DEVICE_PER_OFFSET);
+
+ n = rom_get_per_device(&boot);
+ if (n)
+ return n;
+
+ if ((boot->device_type != DEVICE_USB) &&
+ (boot->device_type != DEVICE_USBEXT))
+ return -1;
+
+ omap4_usbboot_pdata = xzalloc(sizeof(struct omap4_usbboot));
+ n = rom_get_per_driver(&omap4_usbboot_pdata->io, boot->device_type);
+ if (n)
+ return n;
+
+ omap4_usbboot_pdata->dread.status = -1;
+ omap4_usbboot_pdata->dread.xfer_mode = boot->xfer_mode;
+ omap4_usbboot_pdata->dread.options = boot->options;
+ omap4_usbboot_pdata->dread.device_type = boot->device_type;
+
+ omap4_usbboot_pdata->dwrite.status = -1;
+ omap4_usbboot_pdata->dwrite.xfer_mode = boot->xfer_mode;
+ omap4_usbboot_pdata->dwrite.options = boot->options;
+ omap4_usbboot_pdata->dwrite.device_type = boot->device_type;
+ __asm__ __volatile__ ("cpsie i\n");
+ return 0;
+}
+
+
+static void rom_read_callback(struct per_handle *rh)
+{
+ omap4_usbboot_pdata->dread.status = rh->status;
+ return;
+}
+
+void omap4_usbboot_queue_read(void *data, unsigned len)
+{
+ int n;
+ omap4_usbboot_pdata->dread.data = data;
+ omap4_usbboot_pdata->dread.length = len;
+ omap4_usbboot_pdata->dread.status = STATUS_WAITING;
+ omap4_usbboot_pdata->dread.xfer_mode = 1;
+ omap4_usbboot_pdata->dread.callback = rom_read_callback;
+ n = omap4_usbboot_pdata->io->read(&omap4_usbboot_pdata->dread);
+ if (n)
+ omap4_usbboot_pdata->dread.status = n;
+}
+
+int omap4_usbboot_wait_read(void)
+{
+ int ret;
+ while (omap4_usbboot_pdata->dread.status == STATUS_WAITING)
+ /* cpu_relax(); */
+ barrier();
+ ret = omap4_usbboot_pdata->dread.status;
+ omap4_usbboot_pdata->dread.status = -1;
+ return ret;
+}
+int omap4_usbboot_is_read_waiting(void)
+{
+ barrier();
+ return omap4_usbboot_pdata->dread.status == STATUS_WAITING;
+}
+int omap4_usbboot_is_read_ok(void)
+{
+ barrier();
+ return omap4_usbboot_pdata->dread.status == STATUS_OKAY;
+}
+
+static void rom_write_callback(struct per_handle *rh)
+{
+ omap4_usbboot_pdata->dwrite.status = rh->status;
+ return;
+}
+
+void omap4_usbboot_queue_write(void *data, unsigned len)
+{
+ int n;
+ omap4_usbboot_pdata->dwrite.data = data;
+ omap4_usbboot_pdata->dwrite.length = len;
+ omap4_usbboot_pdata->dwrite.status = STATUS_WAITING;
+ omap4_usbboot_pdata->dwrite.xfer_mode = 1;
+ omap4_usbboot_pdata->dwrite.callback = rom_write_callback;
+ n = omap4_usbboot_pdata->io->write(&omap4_usbboot_pdata->dwrite);
+ if (n)
+ omap4_usbboot_pdata->dwrite.status = n;
+}
+
+int omap4_usbboot_wait_write(void)
+{
+ int ret;
+ while (omap4_usbboot_pdata->dwrite.status == STATUS_WAITING)
+ /* cpu_relax(); */
+ barrier();
+ ret = omap4_usbboot_pdata->dwrite.status;
+ omap4_usbboot_pdata->dwrite.status = -1;
+ return ret;
+}
+
+#define USB_MAX_IO 65536
+int omap4_usbboot_read(void *data, unsigned len)
+{
+ unsigned xfer;
+ unsigned char *x = data;
+ int n;
+ while (len > 0) {
+ xfer = (len > USB_MAX_IO) ? USB_MAX_IO : len;
+ omap4_usbboot_queue_read(x, xfer);
+ n = omap4_usbboot_wait_read();
+ if (n)
+ return n;
+ x += xfer;
+ len -= xfer;
+ }
+ return 0;
+}
+
+int omap4_usbboot_write(void *data, unsigned len)
+{
+ omap4_usbboot_queue_write(data, len);
+ return omap4_usbboot_wait_write();
+}
+
+void omap4_usbboot_close(void)
+{
+ omap4_usbboot_pdata->io->close(&omap4_usbboot_pdata->dread);
+}
+
+void omap4_usbboot_puts(const char *s)
+{
+ u32 c;
+ while ((c = *s++))
+ omap4_usbboot_write(&c, 4);
+}
diff --git a/scripts/.gitignore b/scripts/.gitignore
index 6e63f85..4fb5a1f 100644
--- a/scripts/.gitignore
+++ b/scripts/.gitignore
@@ -5,3 +5,4 @@ kallsyms
mkimage
mkublheader
omap_signGP
+omap4_usbboot
diff --git a/scripts/Makefile b/scripts/Makefile
index 7ca5e29..6c1b113 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -4,6 +4,8 @@
# ---------------------------------------------------------------------------
# kallsyms: Find all symbols in barebox
+HOSTLDFLAGS += -lpthread
+
hostprogs-$(CONFIG_KALLSYMS) += kallsyms
hostprogs-y += bin2c
hostprogs-y += mkimage
@@ -12,6 +14,8 @@ hostprogs-$(CONFIG_ARCH_NETX) += gen_netx_image
hostprogs-$(CONFIG_ARCH_OMAP) += omap_signGP
hostprogs-$(CONFIG_ARCH_S5PCxx) += s5p_cksum
hostprogs-$(CONFIG_ARCH_DAVINCI) += mkublheader
+hostprogs-$(CONFIG_OMAP4_USBBOOT)+= omap4_usbboot
+omap4_usbboot-objs := usb_linux.o omap4_usbboot.o
always := $(hostprogs-y) $(hostprogs-m)
diff --git a/scripts/omap4_usbboot.c b/scripts/omap4_usbboot.c
new file mode 100644
index 0000000..aa11759
--- /dev/null
+++ b/scripts/omap4_usbboot.c
@@ -0,0 +1,416 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <stdint.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <pthread.h>
+#include <termios.h>
+
+#include "usb.h"
+
+#define USBBOOT_FS_MAGIC 0x5562464D
+#define USBBOOT_FS_CMD_OPEN 0x46530000
+#define USBBOOT_FS_CMD_CLOSE 0x46530001
+#define USBBOOT_FS_CMD_READ 0x46530002
+#define USBBOOT_FS_CMD_END 0x4653FFFF
+#define MAX_OPEN_FILES 1000
+
+#define RESET 0
+#define BRIGHT 1
+#define WHITE 8
+#define RED 1
+#define BLACK 0
+#define FORMAT "%c[%d;%d;%dm"
+#define TARGET_FORMAT 0x1B, BRIGHT, RED+30, BLACK+40
+#define HOST_FORMAT 0x1B, RESET, WHITE+30, BLACK+40
+#define host_print(fmt, arg...) printf(FORMAT fmt FORMAT"\n", \
+ HOST_FORMAT, ##arg, TARGET_FORMAT)
+
+struct thread_vars {
+ struct usb_handle *usb;
+ int hide;
+ struct termios to;
+};
+void *listenerTask(void *argument)
+{
+ struct thread_vars *vars = argument;
+ int c;
+ for (;;) {
+ c = getchar();
+ if (c == EOF)
+ return NULL;
+ while (vars->hide)
+ usleep(10000);
+ if (usb_write(vars->usb, &c, 4) != 4) {
+ host_print("could not send '%c' to target", c);
+ tcsetattr(STDIN_FILENO, TCSANOW, &vars->to);
+ exit(1);
+ }
+ }
+ return NULL;
+}
+struct file_data {
+ size_t size;
+ void *data;
+};
+
+int read_asic_id(struct usb_handle *usb)
+{
+#define LINEWIDTH 16
+ const uint32_t msg_getid = 0xF0030003;
+ int i, j, k, ret;
+ uint8_t id[81];
+ char line[LINEWIDTH*3+8];
+
+ printf("reading ASIC ID\n");
+ memset(id , 0xee, sizeof(id));
+ if (usb_write(usb, &msg_getid, sizeof(msg_getid)) !=
+ sizeof(msg_getid)
+ ) {
+ printf("Could not send msg_getid request\n");
+ return -1;
+ }
+ if (usb_read(usb, id, sizeof(id)) != sizeof(id)) {
+ printf("Could not read msg_getid answer\n");
+ return -1;
+ }
+ for (i = 0; i < sizeof(id); i += LINEWIDTH) {
+ sprintf(line, "%02X: ", i);
+ for (j = 0; j < LINEWIDTH && j < sizeof(id)-i; j++)
+ sprintf(line+4+j*3, "%02X ", id[i+j]);
+ line[4+j*3+0] = '\n';
+ line[4+j*3+1] = 0;
+ printf(line);
+ }
+ ret = 0;
+ for (i = 1, j = 0; i < sizeof(id) && j < id[0]; i += 2+id[i+1], j++) {
+ if (i+2+id[i+1] > sizeof(id)) {
+ printf("Truncated subblock\n");
+ ret++;
+ continue;
+ }
+ switch (id[i]) {
+ case 0x01: /* ID subblock */
+ if (id[i+1] != 0x05) {
+ printf("Unexpected ID subblock size\n");
+ ret++;
+ continue;
+ }
+ if (id[i+2] != 0x01)
+ printf("Unexpected fixed value\n");
+ k = (id[i+3]<<8) | id[i+4];
+ switch (k) {
+ case 0x4440:
+ printf("OMAP 4460 Device\n");
+ break;
+ default:
+ printf("Unknown Device\n");
+ break;
+ }
+ switch (id[i+5]) {
+ case 0x07:
+ printf("CH enabled (read from eFuse)\n");
+ break;
+ case 0x17:
+ printf("CH disabled (read from eFuse)\n");
+ break;
+ default:
+ printf("Unknown CH setting\n");
+ break;
+ }
+ printf("Rom version: %hhu\n", id[i+6]);
+ break;
+ case 0x15: /* Checksum subblock */
+ if (id[i+1] != 0x09) {
+ printf("Unexpected Checksum subblock size\n");
+ ret++;
+ continue;
+ }
+ if (id[i+2] != 0x01)
+ printf("Unexpected fixed value\n");
+ k = (id[i+3]<<24) | (id[i+4]<<16) |
+ (id[i+5]<<8) | id[i+6];
+ printf("Rom CRC: 0x%08X\n", k);
+ k = (id[i+7]<<24) | (id[i+8]<<16) |
+ (id[i+9]<<8) | id[i+10];
+ switch (k) {
+ case 0:
+ printf("A GP device\n");
+ break;
+ default:
+ printf("Unknown device\n");
+ break;
+ }
+ break;
+ }
+ }
+ if (i != sizeof(id) || j != id[0]) {
+ printf("Unexpected ASIC ID structure size.\n");
+ ret++;
+ }
+ return ret;
+}
+
+int process_file(
+ struct usb_handle *usb, const char *rootfs, struct file_data *fd_vector)
+{
+ uint32_t i, j, pos, size;
+ struct stat s;
+ int fd, ret;
+ char line[256];
+
+ if (usb_read(usb, &i, 4) != 4) {
+ host_print("USB error");
+ exit(1);
+ }
+ ret = 0;
+ switch (i) {
+ case USBBOOT_FS_CMD_OPEN:
+ for (j = 0; rootfs[j]; j++)
+ line[j] = rootfs[j];
+ for (;; j++) {
+ if (usb_read(usb, &i, 4) != 4) {
+ host_print("USB error");
+ exit(1);
+ }
+ if (i == USBBOOT_FS_CMD_END) {
+ line[j] = 0;
+ break;
+ } else if (i > 0xFF) {
+ host_print("Error in filename");
+ ret++;
+ line[j] = 0;
+ break;
+ } else
+ line[j] = i;
+ }
+ for (i = 0; i < MAX_OPEN_FILES && fd_vector[i].data; i++)
+ ;
+ if (i >= MAX_OPEN_FILES) {
+ host_print("MAX_OPEN_FILES exceeded");
+ ret++;
+ goto open_error_1;
+ }
+ fd = open(line, O_RDONLY);
+ if (fd < 0) {
+ host_print("cannot open '%s'", line);
+ ret++;
+ goto open_error_1;
+ }
+ if (fstat(fd, &s)) {
+ host_print("cannot stat '%s'", line);
+ ret++;
+ goto open_error_2;
+ }
+ fd_vector[i].data = mmap(NULL, s.st_size, PROT_READ,
+ MAP_PRIVATE, fd, 0);
+ if (fd_vector[i].data == MAP_FAILED) {
+ host_print("cannot mmap '%s'", line);
+ ret++;
+ goto open_error_2;
+ }
+ close(fd);
+ fd_vector[i].size = size = s.st_size;
+ fd = i;
+ goto open_ok;
+
+open_error_2:
+ close(fd);
+open_error_1:
+ fd_vector[i].size = size = 0;
+ fd = -1;
+open_ok:
+ if (usb_write(usb, &fd, 4) != 4 ||
+ usb_write(usb, &size, 4) != 4
+ ) {
+ host_print("could not send file size to target");
+ exit(1);
+ }
+ break;
+ case USBBOOT_FS_CMD_CLOSE:
+ if (usb_read(usb, &i, 4) != 4) {
+ host_print("USB error");
+ exit(1);
+ }
+ if (i >= MAX_OPEN_FILES || !fd_vector[i].data) {
+ host_print("invalid close index");
+ ret++;
+ break;
+ }
+ if (usb_read(usb, &j, 4) != 4) {
+ host_print("USB error");
+ exit(1);
+ }
+ if (j != USBBOOT_FS_CMD_END) {
+ host_print("invalid close");
+ ret++;
+ break;
+ }
+ munmap(fd_vector[i].data, fd_vector[i].size);
+ fd_vector[i].data = NULL;
+ break;
+ case USBBOOT_FS_CMD_READ:
+ if (usb_read(usb, &i, 4) != 4) {
+ host_print("USB error");
+ exit(1);
+ }
+ if (i >= MAX_OPEN_FILES || !fd_vector[i].data) {
+ host_print("invalid read index");
+ ret++;
+ break;
+ }
+ if (usb_read(usb, &pos, 4) != 4) {
+ host_print("USB error");
+ exit(1);
+ }
+ if (pos >= fd_vector[i].size) {
+ host_print("invalid read pos");
+ ret++;
+ break;
+ }
+ if (usb_read(usb, &size, 4) != 4) {
+ host_print("USB error");
+ exit(1);
+ }
+ if (pos+size > fd_vector[i].size) {
+ host_print("invalid read size");
+ ret++;
+ break;
+ }
+ if (usb_read(usb, &j, 4) != 4) {
+ host_print("USB error");
+ exit(1);
+ }
+ if (j != USBBOOT_FS_CMD_END) {
+ host_print("invalid read");
+ ret++;
+ break;
+ }
+ if (usb_write(usb, fd_vector[i].data+pos, size) != size) {
+ host_print("could not send file to target");
+ exit(1);
+ }
+ break;
+ case USBBOOT_FS_CMD_END:
+ default:
+ host_print("Unknown filesystem command");
+ ret++;
+ break;
+ }
+ return ret;
+}
+
+int usb_boot(
+ struct usb_handle *usb, void *data, unsigned sz, const char *rootfs)
+{
+ const uint32_t msg_boot = 0xF0030002;
+ uint32_t msg_size = sz;
+ int i;
+ pthread_t thread;
+ struct thread_vars vars;
+ struct termios tn;
+ struct file_data fd_vector[MAX_OPEN_FILES];
+
+ read_asic_id(usb);
+
+ printf("sending xload to target...\n");
+ usb_write(usb, &msg_boot, sizeof(msg_boot));
+ usb_write(usb, &msg_size, sizeof(msg_size));
+ usb_write(usb, data, sz);
+ munmap(data, msg_size);
+ for (i = 0; i < MAX_OPEN_FILES; i++)
+ fd_vector[i].data = NULL;
+
+ vars.usb = usb;
+ vars.hide = 0;
+ tcgetattr(STDIN_FILENO, &vars.to);
+ tn = vars.to;
+ tn.c_lflag &= ~(ICANON | ECHO);
+ printf(FORMAT, TARGET_FORMAT);
+ tcsetattr(STDIN_FILENO, TCSANOW, &tn);
+ if (pthread_create(&thread, NULL, listenerTask, &vars))
+ host_print("listenerTask failed");
+ for (;;) {
+ if (usb_read(usb, &i, 4) != 4)
+ break;
+ if (i == USBBOOT_FS_MAGIC) {
+ vars.hide = 1;
+ process_file(usb, rootfs, fd_vector);
+ vars.hide = 0;
+ continue;
+ }
+ printf("%c", i);
+ fflush(stdout);
+ }
+ tcsetattr(STDIN_FILENO, TCSANOW, &vars.to);
+ return 0;
+}
+
+int match_omap4_bootloader(struct usb_ifc_info *ifc)
+{
+ if (ifc->dev_vendor != 0x0451)
+ return -1;
+ if ((ifc->dev_product != 0xD010) && (ifc->dev_product != 0xD00F))
+ return -1;
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ void *data;
+ unsigned sz;
+ struct stat s;
+ int fd;
+ struct usb_handle *usb;
+ int once;
+
+ if (argc != 3) {
+ printf("usage: %s <xloader> <rootfs>\n", argv[0]);
+ return 0;
+ }
+ argv++;
+ fd = open(argv[0], O_RDONLY);
+ if (fd < 0 || fstat(fd, &s)) {
+ printf("cannot open '%s'\n", argv[0]);
+ return -1;
+ }
+ data = mmap(NULL, s.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
+ if (data == MAP_FAILED) {
+ printf("cannot mmap '%s'\n", argv[0]);
+ return -1;
+ }
+ sz = s.st_size;
+ close(fd);
+ argv++;
+ printf(FORMAT, HOST_FORMAT);
+ for (once = 1;;) {
+ usb = usb_open(match_omap4_bootloader);
+ if (usb)
+ return usb_boot(usb, data, sz, argv[0]);
+ if (once) {
+ once = 0;
+ printf("waiting for OMAP44xx device...\n");
+ }
+ usleep(250000);
+ }
+ return -1;
+}
diff --git a/scripts/usb.h b/scripts/usb.h
new file mode 100644
index 0000000..d50aa6a
--- /dev/null
+++ b/scripts/usb.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _USB_H_
+#define _USB_H_
+
+struct usb_ifc_info {
+ /* from device descriptor */
+ unsigned short dev_vendor;
+ unsigned short dev_product;
+
+ unsigned char dev_class;
+ unsigned char dev_subclass;
+ unsigned char dev_protocol;
+
+ unsigned char ifc_class;
+ unsigned char ifc_subclass;
+ unsigned char ifc_protocol;
+
+ unsigned char has_bulk_in;
+ unsigned char has_bulk_out;
+
+ unsigned char writable;
+
+ char serial_number[256];
+};
+
+typedef int (*ifc_match_func)(struct usb_ifc_info *ifc);
+
+struct usb_handle *usb_open(ifc_match_func callback);
+int usb_close(struct usb_handle *h);
+int usb_read(struct usb_handle *h, void *_data, int len);
+int usb_write(struct usb_handle *h, const void *_data, int len);
+
+
+#endif
diff --git a/scripts/usb_linux.c b/scripts/usb_linux.c
new file mode 100644
index 0000000..43529aa
--- /dev/null
+++ b/scripts/usb_linux.c
@@ -0,0 +1,397 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <pthread.h>
+#include <ctype.h>
+
+#include <linux/usbdevice_fs.h>
+#include <linux/usbdevice_fs.h>
+#include <linux/version.h>
+#include <linux/usb/ch9.h>
+#include <asm/byteorder.h>
+
+#include "usb.h"
+
+#define MAX_RETRIES 5
+
+#ifdef TRACE_USB
+#define DBG1(x...) fprintf(stderr, x)
+#define DBG(x...) fprintf(stderr, x)
+#else
+#define DBG(x...)
+#define DBG1(x...)
+#endif
+
+struct usb_handle {
+ char fname[64];
+ int desc;
+ unsigned char ep_in;
+ unsigned char ep_out;
+};
+
+static inline int badname(const char *name)
+{
+ while (*name) {
+ if (!isdigit(*name++))
+ return 1;
+ }
+ return 0;
+}
+
+static int check(void *_desc, int len, unsigned type, int size)
+{
+ unsigned char *desc = _desc;
+
+ if (len < size)
+ return -1;
+ if (desc[0] < size)
+ return -1;
+ if (desc[0] > len)
+ return -1;
+ if (desc[1] != type)
+ return -1;
+
+ return 0;
+}
+
+static int filter_usb_device(int fd, char *ptr, int len, int writable,
+ ifc_match_func callback, int *ept_in_id, int *ept_out_id, int *ifc_id)
+{
+ struct usb_device_descriptor *dev;
+ struct usb_config_descriptor *cfg;
+ struct usb_interface_descriptor *ifc;
+ struct usb_endpoint_descriptor *ept;
+ struct usb_ifc_info info;
+
+ int in, out;
+ unsigned i;
+ unsigned e;
+
+ if (check(ptr, len, USB_DT_DEVICE, USB_DT_DEVICE_SIZE))
+ return -1;
+ dev = (void *) ptr;
+ len -= dev->bLength;
+ ptr += dev->bLength;
+
+ if (check(ptr, len, USB_DT_CONFIG, USB_DT_CONFIG_SIZE))
+ return -1;
+ cfg = (void *) ptr;
+ len -= cfg->bLength;
+ ptr += cfg->bLength;
+
+ info.dev_vendor = dev->idVendor;
+ info.dev_product = dev->idProduct;
+ info.dev_class = dev->bDeviceClass;
+ info.dev_subclass = dev->bDeviceSubClass;
+ info.dev_protocol = dev->bDeviceProtocol;
+ info.writable = writable;
+
+ /* read device serial number (if there is one) */
+ info.serial_number[0] = 0;
+ if (dev->iSerialNumber) {
+ struct usbdevfs_ctrltransfer ctrl;
+ __u16 buffer[128];
+ int result;
+
+ memset(buffer, 0, sizeof(buffer));
+
+ ctrl.bRequestType = USB_DIR_IN|
+ USB_TYPE_STANDARD|USB_RECIP_DEVICE;
+ ctrl.bRequest = USB_REQ_GET_DESCRIPTOR;
+ ctrl.wValue = (USB_DT_STRING << 8) | dev->iSerialNumber;
+ ctrl.wIndex = 0;
+ ctrl.wLength = sizeof(buffer);
+ ctrl.data = buffer;
+ ctrl.timeout = 50;
+
+ result = ioctl(fd, USBDEVFS_CONTROL, &ctrl);
+ if (result > 0) {
+ int i;
+ /* skip first word, and copy the rest to the serial
+ string, changing shorts to bytes. */
+ result /= 2;
+ for (i = 1; i < result; i++)
+ info.serial_number[i - 1] = buffer[i];
+ info.serial_number[i - 1] = 0;
+ }
+ }
+
+ for (i = 0; i < cfg->bNumInterfaces; i++) {
+ if (check(ptr, len, USB_DT_INTERFACE, USB_DT_INTERFACE_SIZE))
+ return -1;
+ ifc = (void *) ptr;
+ len -= ifc->bLength;
+ ptr += ifc->bLength;
+
+ in = -1;
+ out = -1;
+ info.ifc_class = ifc->bInterfaceClass;
+ info.ifc_subclass = ifc->bInterfaceSubClass;
+ info.ifc_protocol = ifc->bInterfaceProtocol;
+
+ for (e = 0; e < ifc->bNumEndpoints; e++) {
+ if (check(ptr, len, USB_DT_ENDPOINT,
+ USB_DT_ENDPOINT_SIZE)
+ )
+ return -1;
+ ept = (void *) ptr;
+ len -= ept->bLength;
+ ptr += ept->bLength;
+
+ if ((ept->bmAttributes & 0x03) != 0x02)
+ continue;
+
+ if (ept->bEndpointAddress & 0x80)
+ in = ept->bEndpointAddress;
+ else
+ out = ept->bEndpointAddress;
+ }
+
+ info.has_bulk_in = (in != -1);
+ info.has_bulk_out = (out != -1);
+
+ if (callback(&info) == 0) {
+ *ept_in_id = in;
+ *ept_out_id = out;
+ *ifc_id = ifc->bInterfaceNumber;
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
+static struct usb_handle *find_usb_device(
+ const char *base, ifc_match_func callback)
+{
+ struct usb_handle *usb = 0;
+ char busname[64], devname[64];
+ char desc[1024];
+ int n, in, out, ifc;
+
+ DIR *busdir, *devdir;
+ struct dirent *de;
+ int fd;
+ int writable;
+
+ busdir = opendir(base);
+ if (busdir == 0)
+ return 0;
+
+ while ((de = readdir(busdir)) && (usb == 0)) {
+ if (badname(de->d_name))
+ continue;
+
+ sprintf(busname, "%s/%s", base, de->d_name);
+ devdir = opendir(busname);
+ if (devdir == 0)
+ continue;
+
+ /* DBG("[ scanning %s ]\n", busname); */
+ while ((de = readdir(devdir)) && (usb == 0)) {
+
+ if (badname(de->d_name))
+ continue;
+ sprintf(devname, "%s/%s", busname, de->d_name);
+
+ /* DBG("[ scanning %s ]\n", devname); */
+ writable = 1;
+ fd = open(devname, O_RDWR);
+ if (fd < 0) {
+ /* Check if we have read-only access,
+ so we can give a helpful diagnostic
+ like "adb devices" does. */
+ writable = 0;
+ fd = open(devname, O_RDONLY);
+ if (fd < 0)
+ continue;
+ }
+
+ n = read(fd, desc, sizeof(desc));
+
+ if (filter_usb_device(fd, desc, n, writable,
+ callback, &in, &out, &ifc) == 0
+ ) {
+ usb = calloc(1, sizeof(struct usb_handle));
+ strcpy(usb->fname, devname);
+ usb->ep_in = in;
+ usb->ep_out = out;
+ usb->desc = fd;
+
+ n = ioctl(fd, USBDEVFS_CLAIMINTERFACE, &ifc);
+ if (n != 0) {
+ close(fd);
+ free(usb);
+ usb = 0;
+ continue;
+ }
+ } else
+ close(fd);
+ }
+ closedir(devdir);
+ }
+ closedir(busdir);
+
+ return usb;
+}
+
+int usb_write(struct usb_handle *h, const void *_data, int len)
+{
+ unsigned char *data = (unsigned char *) _data;
+ unsigned count = 0;
+ struct usbdevfs_bulktransfer bulk;
+ int n;
+
+ if (h->ep_out == 0)
+ return -1;
+
+ if (len == 0) {
+ bulk.ep = h->ep_out;
+ bulk.len = 0;
+ bulk.data = data;
+ bulk.timeout = 0;
+
+ n = ioctl(h->desc, USBDEVFS_BULK, &bulk);
+ if (n != 0) {
+ fprintf(stderr, "ERROR: n = %d, errno = %d (%s)\n",
+ n, errno, strerror(errno));
+ return -1;
+ }
+ return 0;
+ }
+
+ while (len > 0) {
+ int xfer;
+ xfer = (len > 4096) ? 4096 : len;
+
+ bulk.ep = h->ep_out;
+ bulk.len = xfer;
+ bulk.data = data;
+ bulk.timeout = 0;
+
+ n = ioctl(h->desc, USBDEVFS_BULK, &bulk);
+ if (n != xfer) {
+ DBG("ERROR: n = %d, errno = %d (%s)\n",
+ n, errno, strerror(errno));
+ return -1;
+ }
+
+ count += xfer;
+ len -= xfer;
+ data += xfer;
+ }
+
+ return count;
+}
+
+int usb_read(struct usb_handle *h, void *_data, int len)
+{
+ unsigned char *data = (unsigned char *) _data;
+ unsigned count = 0;
+ struct usbdevfs_bulktransfer bulk;
+ int n, retry;
+
+ if (h->ep_in == 0)
+ return -1;
+
+ while (len > 0) {
+ int xfer = (len > 4096) ? 4096 : len;
+
+ bulk.ep = h->ep_in;
+ bulk.len = xfer;
+ bulk.data = data;
+ bulk.timeout = 0;
+ retry = 0;
+
+ do {
+ DBG("[ usb read %d fd = %d], fname=%s\n",
+ xfer, h->desc, h->fname);
+ n = ioctl(h->desc, USBDEVFS_BULK, &bulk);
+ DBG("[ usb read %d ] = %d, fname=%s, Retry %d\n",
+ xfer, n, h->fname, retry);
+
+ if (n < 0) {
+ DBG1("ERROR: n = %d, errno = %d (%s)\n",
+ n, errno, strerror(errno));
+ if (++retry > MAX_RETRIES)
+ return -1;
+ sleep(1);
+ }
+ } while (n < 0);
+
+ count += n;
+ len -= n;
+ data += n;
+
+ if (n < xfer)
+ break;
+ }
+
+ return count;
+}
+
+void usb_kick(struct usb_handle *h)
+{
+ int fd;
+
+ fd = h->desc;
+ h->desc = -1;
+ if (fd >= 0) {
+ close(fd);
+ DBG("[ usb closed %d ]\n", fd);
+ }
+}
+
+int usb_close(struct usb_handle *h)
+{
+ int fd;
+
+ fd = h->desc;
+ h->desc = -1;
+ if (fd >= 0) {
+ close(fd);
+ DBG("[ usb closed %d ]\n", fd);
+ }
+
+ return 0;
+}
+
+struct usb_handle *usb_open(ifc_match_func callback)
+{
+ return find_usb_device("/dev/bus/usb", callback);
+}
--
1.7.12.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 6/9] omap4: add usb boot support
2012-09-30 2:50 ` [PATCH 6/9] omap4: add usb boot support vj
@ 2012-09-30 12:14 ` Antony Pavlov
2012-09-30 14:02 ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-30 14:07 ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-02 13:51 ` Sascha Hauer
2 siblings, 1 reply; 27+ messages in thread
From: Antony Pavlov @ 2012-09-30 12:14 UTC (permalink / raw)
To: vj; +Cc: barebox
On 30 September 2012 06:50, vj <vicencb@gmail.com> wrote:
> ---
> arch/arm/cpu/cpu.c | 1 +
> arch/arm/mach-omap/Kconfig | 7 +
> arch/arm/mach-omap/Makefile | 1 +
> arch/arm/mach-omap/include/mach/omap4_rom_usb.h | 142 ++++++++
> arch/arm/mach-omap/omap4_generic.c | 13 +
> arch/arm/mach-omap/omap4_rom_usb.c | 186 +++++++++++
> scripts/.gitignore | 1 +
> scripts/Makefile | 4 +
> scripts/omap4_usbboot.c | 416 ++++++++++++++++++++++++
> scripts/usb.h | 61 ++++
> scripts/usb_linux.c | 397 ++++++++++++++++++++++
> 11 files changed, 1229 insertions(+)
> create mode 100644 arch/arm/mach-omap/include/mach/omap4_rom_usb.h
> create mode 100644 arch/arm/mach-omap/omap4_rom_usb.c
> create mode 100644 scripts/omap4_usbboot.c
> create mode 100644 scripts/usb.h
> create mode 100644 scripts/usb_linux.c
>
> diff --git a/arch/arm/cpu/cpu.c b/arch/arm/cpu/cpu.c
> index 71ef8c0..05343de 100644
> --- a/arch/arm/cpu/cpu.c
> +++ b/arch/arm/cpu/cpu.c
> @@ -89,6 +89,7 @@ void arch_shutdown(void)
> : "r0", "r1", "r2", "r3", "r6", "r10", "r12", "lr", "cc", "memory"
> );
> #endif
> + __asm__ __volatile__ ("cpsid i\n");
> }
>
> #ifdef CONFIG_THUMB2_BAREBOX
> diff --git a/arch/arm/mach-omap/Kconfig b/arch/arm/mach-omap/Kconfig
> index d735284..16583cb 100644
> --- a/arch/arm/mach-omap/Kconfig
> +++ b/arch/arm/mach-omap/Kconfig
> @@ -96,6 +96,13 @@ config ARCH_TEXT_BASE
> default 0x80e80000 if MACH_OMAP343xSDP
> default 0x80e80000 if MACH_BEAGLE
>
> +config OMAP4_USBBOOT
> + bool "enable booting from USB"
> + default n
> + depends on ARCH_OMAP4 && !MMU
> + help
> + Enable this to enable USB booting
> +
Can we add more detailed description here? E.g.:
Say Y here if you want to be able to boot <name of the chip family
here> from USB.
You need an utility program called <name of the program here> to boot
from USB. Please read <file name or URL here> for more information.
--
Best regards,
Antony Pavlov
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 6/9] omap4: add usb boot support
2012-09-30 12:14 ` Antony Pavlov
@ 2012-09-30 14:02 ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-30 15:02 ` vj
0 siblings, 1 reply; 27+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-30 14:02 UTC (permalink / raw)
To: Antony Pavlov; +Cc: barebox, vj
On 16:14 Sun 30 Sep , Antony Pavlov wrote:
> On 30 September 2012 06:50, vj <vicencb@gmail.com> wrote:
> > ---
> > arch/arm/cpu/cpu.c | 1 +
> > arch/arm/mach-omap/Kconfig | 7 +
> > arch/arm/mach-omap/Makefile | 1 +
> > arch/arm/mach-omap/include/mach/omap4_rom_usb.h | 142 ++++++++
> > arch/arm/mach-omap/omap4_generic.c | 13 +
> > arch/arm/mach-omap/omap4_rom_usb.c | 186 +++++++++++
> > scripts/.gitignore | 1 +
> > scripts/Makefile | 4 +
> > scripts/omap4_usbboot.c | 416 ++++++++++++++++++++++++
> > scripts/usb.h | 61 ++++
> > scripts/usb_linux.c | 397 ++++++++++++++++++++++
> > 11 files changed, 1229 insertions(+)
> > create mode 100644 arch/arm/mach-omap/include/mach/omap4_rom_usb.h
> > create mode 100644 arch/arm/mach-omap/omap4_rom_usb.c
> > create mode 100644 scripts/omap4_usbboot.c
> > create mode 100644 scripts/usb.h
> > create mode 100644 scripts/usb_linux.c
> >
> > diff --git a/arch/arm/cpu/cpu.c b/arch/arm/cpu/cpu.c
> > index 71ef8c0..05343de 100644
> > --- a/arch/arm/cpu/cpu.c
> > +++ b/arch/arm/cpu/cpu.c
> > @@ -89,6 +89,7 @@ void arch_shutdown(void)
> > : "r0", "r1", "r2", "r3", "r6", "r10", "r12", "lr", "cc", "memory"
> > );
> > #endif
> > + __asm__ __volatile__ ("cpsid i\n");
???
why do you add this?
we never enable the interrupt
and this is generic not omap4 must be in a seperate patch
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 6/9] omap4: add usb boot support
2012-09-30 14:02 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2012-09-30 15:02 ` vj
2012-09-30 15:29 ` Jean-Christophe PLAGNIOL-VILLARD
0 siblings, 1 reply; 27+ messages in thread
From: vj @ 2012-09-30 15:02 UTC (permalink / raw)
To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox
[-- Attachment #1.1: Type: text/plain, Size: 1964 bytes --]
In fact the interrupts get enabled at omap4_usbboot_open, it's required for
usb transfers.
For this reason the interrupts are disabled at barebox exit.
On Sun, Sep 30, 2012 at 4:02 PM, Jean-Christophe PLAGNIOL-VILLARD <
plagnioj@jcrosoft.com> wrote:
> On 16:14 Sun 30 Sep , Antony Pavlov wrote:
> > On 30 September 2012 06:50, vj <vicencb@gmail.com> wrote:
> > > ---
> > > arch/arm/cpu/cpu.c | 1 +
> > > arch/arm/mach-omap/Kconfig | 7 +
> > > arch/arm/mach-omap/Makefile | 1 +
> > > arch/arm/mach-omap/include/mach/omap4_rom_usb.h | 142 ++++++++
> > > arch/arm/mach-omap/omap4_generic.c | 13 +
> > > arch/arm/mach-omap/omap4_rom_usb.c | 186 +++++++++++
> > > scripts/.gitignore | 1 +
> > > scripts/Makefile | 4 +
> > > scripts/omap4_usbboot.c | 416
> ++++++++++++++++++++++++
> > > scripts/usb.h | 61 ++++
> > > scripts/usb_linux.c | 397
> ++++++++++++++++++++++
> > > 11 files changed, 1229 insertions(+)
> > > create mode 100644 arch/arm/mach-omap/include/mach/omap4_rom_usb.h
> > > create mode 100644 arch/arm/mach-omap/omap4_rom_usb.c
> > > create mode 100644 scripts/omap4_usbboot.c
> > > create mode 100644 scripts/usb.h
> > > create mode 100644 scripts/usb_linux.c
> > >
> > > diff --git a/arch/arm/cpu/cpu.c b/arch/arm/cpu/cpu.c
> > > index 71ef8c0..05343de 100644
> > > --- a/arch/arm/cpu/cpu.c
> > > +++ b/arch/arm/cpu/cpu.c
> > > @@ -89,6 +89,7 @@ void arch_shutdown(void)
> > > : "r0", "r1", "r2", "r3", "r6", "r10", "r12", "lr",
> "cc", "memory"
> > > );
> > > #endif
> > > + __asm__ __volatile__ ("cpsid i\n");
> ???
>
> why do you add this?
>
> we never enable the interrupt
>
> and this is generic not omap4 must be in a seperate patch
>
>
[-- Attachment #1.2: Type: text/html, Size: 2870 bytes --]
[-- Attachment #2: Type: text/plain, Size: 149 bytes --]
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 6/9] omap4: add usb boot support
2012-09-30 15:02 ` vj
@ 2012-09-30 15:29 ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-30 16:00 ` vj
0 siblings, 1 reply; 27+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-30 15:29 UTC (permalink / raw)
To: vj; +Cc: barebox
On 17:02 Sun 30 Sep , vj wrote:
> In fact the interrupts get enabled at omap4_usbboot_open, it's required
> for usb transfers.
> For this reason the interrupts are disabled at barebox exit.
why do you enable the interrupts?
we never use interrupts in barebox
Best Regards,
J.
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 6/9] omap4: add usb boot support
2012-09-30 15:29 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2012-09-30 16:00 ` vj
2012-10-01 12:48 ` Sascha Hauer
0 siblings, 1 reply; 27+ messages in thread
From: vj @ 2012-09-30 16:00 UTC (permalink / raw)
To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox
[-- Attachment #1.1: Type: text/plain, Size: 762 bytes --]
It's out of my control:
The OMAP4 processor has an internal ROM which is in charge of the USB port
for booting.
Once the user application is running the USB communications are not closed
and can be reused by the user application through the ROM public API.
The OMAP4 ROM is implemented in a way it requires interrupts enabled.
Regards,
Vicente.
On Sun, Sep 30, 2012 at 5:29 PM, Jean-Christophe PLAGNIOL-VILLARD <
plagnioj@jcrosoft.com> wrote:
> On 17:02 Sun 30 Sep , vj wrote:
> > In fact the interrupts get enabled at omap4_usbboot_open, it's
> required
> > for usb transfers.
> > For this reason the interrupts are disabled at barebox exit.
> why do you enable the interrupts?
>
> we never use interrupts in barebox
>
> Best Regards,
> J.
>
[-- Attachment #1.2: Type: text/html, Size: 1108 bytes --]
[-- Attachment #2: Type: text/plain, Size: 149 bytes --]
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 6/9] omap4: add usb boot support
2012-09-30 16:00 ` vj
@ 2012-10-01 12:48 ` Sascha Hauer
0 siblings, 0 replies; 27+ messages in thread
From: Sascha Hauer @ 2012-10-01 12:48 UTC (permalink / raw)
To: vj; +Cc: barebox
Please do not top post.
On Sun, Sep 30, 2012 at 06:00:06PM +0200, vj wrote:
> It's out of my control:
> The OMAP4 processor has an internal ROM which is in charge of the USB port
> for booting.
> Once the user application is running the USB communications are not closed
> and can be reused by the user application through the ROM public API.
> The OMAP4 ROM is implemented in a way it requires interrupts enabled.
That explains why changing the vector address does not work with the ROM
code.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 6/9] omap4: add usb boot support
2012-09-30 2:50 ` [PATCH 6/9] omap4: add usb boot support vj
2012-09-30 12:14 ` Antony Pavlov
@ 2012-09-30 14:07 ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-30 15:23 ` vj
` (2 more replies)
2012-10-02 13:51 ` Sascha Hauer
2 siblings, 3 replies; 27+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-30 14:07 UTC (permalink / raw)
To: vj; +Cc: barebox
On 04:50 Sun 30 Sep , vj wrote:
> ---
> arch/arm/cpu/cpu.c | 1 +
> arch/arm/mach-omap/Kconfig | 7 +
> arch/arm/mach-omap/Makefile | 1 +
> arch/arm/mach-omap/include/mach/omap4_rom_usb.h | 142 ++++++++
> arch/arm/mach-omap/omap4_generic.c | 13 +
> arch/arm/mach-omap/omap4_rom_usb.c | 186 +++++++++++
> scripts/.gitignore | 1 +
> scripts/Makefile | 4 +
> scripts/omap4_usbboot.c | 416 ++++++++++++++++++++++++
> scripts/usb.h | 61 ++++
> scripts/usb_linux.c | 397 ++++++++++++++++++++++
> 11 files changed, 1229 insertions(+)
> create mode 100644 arch/arm/mach-omap/include/mach/omap4_rom_usb.h
> create mode 100644 arch/arm/mach-omap/omap4_rom_usb.c
> create mode 100644 scripts/omap4_usbboot.c
> create mode 100644 scripts/usb.h
> create mode 100644 scripts/usb_linux.c
>
> diff --git a/arch/arm/cpu/cpu.c b/arch/arm/cpu/cpu.c
> index 71ef8c0..05343de 100644
> --- a/arch/arm/cpu/cpu.c
> +++ b/arch/arm/cpu/cpu.c
> @@ -89,6 +89,7 @@ void arch_shutdown(void)
> : "r0", "r1", "r2", "r3", "r6", "r10", "r12", "lr", "cc", "memory"
> );
> #endif
> + __asm__ __volatile__ ("cpsid i\n");
> }
>
> #ifdef CONFIG_THUMB2_BAREBOX
> diff --git a/arch/arm/mach-omap/Kconfig b/arch/arm/mach-omap/Kconfig
> index d735284..16583cb 100644
> --- a/arch/arm/mach-omap/Kconfig
> +++ b/arch/arm/mach-omap/Kconfig
> @@ -96,6 +96,13 @@ config ARCH_TEXT_BASE
> default 0x80e80000 if MACH_OMAP343xSDP
> default 0x80e80000 if MACH_BEAGLE
>
> +config OMAP4_USBBOOT
> + bool "enable booting from USB"
> + default n
> + depends on ARCH_OMAP4 && !MMU
> + help
> + Enable this to enable USB booting
> +
> config BOARDINFO
> default "Texas Instrument's SDP343x" if MACH_OMAP343xSDP
> default "Texas Instrument's Beagle" if MACH_BEAGLE
> diff --git a/arch/arm/mach-omap/Makefile b/arch/arm/mach-omap/Makefile
> index f087f4b..e89f6ed 100644
> --- a/arch/arm/mach-omap/Makefile
> +++ b/arch/arm/mach-omap/Makefile
> @@ -30,4 +30,5 @@ obj-$(CONFIG_OMAP3_CLOCK_CONFIG) += omap3_clock.o
> obj-$(CONFIG_OMAP_GPMC) += gpmc.o devices-gpmc-nand.o
> obj-$(CONFIG_SHELL_NONE) += xload.o
> obj-$(CONFIG_I2C_TWL6030) += omap4_twl6030_mmc.o
> +obj-$(CONFIG_OMAP4_USBBOOT) += omap4_rom_usb.o
> obj-y += gpio.o
> diff --git a/arch/arm/mach-omap/include/mach/omap4_rom_usb.h b/arch/arm/mach-omap/include/mach/omap4_rom_usb.h
> new file mode 100644
> index 0000000..b7818df
> --- /dev/null
> +++ b/arch/arm/mach-omap/include/mach/omap4_rom_usb.h
> @@ -0,0 +1,142 @@
> +/*
> + * Copyright (C) 2010 The Android Open Source Project
> + * All rights reserved.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + * * Redistributions of source code must retain the above copyright
> + * notice, this list of conditions and the following disclaimer.
> + * * Redistributions in binary form must reproduce the above copyright
> + * notice, this list of conditions and the following disclaimer in
> + * the documentation and/or other materials provided with the
> + * distribution.
> + *
> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
> + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
> + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
> + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
> + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
> + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
> + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
> + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
> + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
> + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> + * SUCH DAMAGE.
> + */
> +
> +#ifndef _OMAP4_ROM_USB_H_
> +#define _OMAP4_ROM_USB_H_
> +
> +/* public api */
> +#define PUBLIC_API_BASE_4430 (0x28400)
> +#define PUBLIC_API_BASE_4460 (0x30400)
> +
> +#define PUBLIC_GET_DRIVER_MEM_OFFSET (0x04)
> +#define PUBLIC_GET_DRIVER_PER_OFFSET (0x08)
> +#define PUBLIC_GET_DEVICE_MEM_OFFSET (0x80)
> +#define PUBLIC_GET_DEVICE_PER_OFFSET (0x84)
> +
> +#define DEVICE_NULL 0x40
> +#define DEVICE_UART1 0x41
> +#define DEVICE_UART2 0x42
> +#define DEVICE_UART3 0x43
> +#define DEVICE_UART4 0x44
> +#define DEVICE_USB 0x45
> +#define DEVICE_USBEXT 0x46
> +
> +#define XFER_MODE_CPU 0
> +#define XFER_MODE_DMA 1
> +
> +#define STATUS_OKAY 0
> +#define STATUS_FAILED 1
> +#define STATUS_TIMEOUT 2
> +#define STATUS_BAD_PARAM 3
> +#define STATUS_WAITING 4
> +#define STATUS_NO_MEMORY 5
> +#define STATUS_INVALID_PTR 6
> +
> +/* Memory ROM interface */
> +struct read_desc {
> + u32 sector_start;
> + u32 sector_count;
> + void *destination;
> +};
> +
> +struct mem_device {
> + u32 initialized;
> + u8 device_type;
> + u8 trials_count;
> + u32 xip_device;
> + u16 search_size;
> + u32 base_address;
> + u16 hs_toc_mask;
> + u16 gp_toc_mask;
> + void *device_data;
> + u16 *boot_options;
> +};
> +
> +struct mem_driver {
> + int (*init)(struct mem_device *md);
> + int (*read)(struct mem_device *md, struct read_desc *rd);
> + int (*configure)(struct mem_device *md, void *config);
> +};
> +
> +
> +/* Peripheral ROM interface */
> +struct per_handle {
> + void *set_to_null;
> + void (*callback)(struct per_handle *rh);
> + void *data;
> + u32 length;
> + u16 *options;
> + u32 xfer_mode;
> + u32 device_type;
> + u32 status;
> + u16 hs_toc_mask;
> + u16 gp_toc_mask;
> + u32 config_timeout;
> +};
> +
> +struct per_driver {
> + int (*init)(struct per_handle *rh);
> + int (*read)(struct per_handle *rh);
> + int (*write)(struct per_handle *rh);
> + int (*close)(struct per_handle *rh);
> + int (*config)(struct per_handle *rh, void *x);
> +};
> +
> +#define USB_SETCONFIGDESC_ATTRIBUTES (0)
> +#define USB_SETCONFIGDESC_MAXPOWER (1)
> +#define USB_SETSUSPEND_CALLBACK (2)
> +struct per_usb_config {
> + u32 configid;
> + u32 value;
> +};
> +
> +#define API(n) ((void *) (*((u32 *) (n))))
> +/* ROM API End */
> +
> +struct omap4_usbboot {
> + struct per_handle dread;
> + struct per_handle dwrite;
> + struct per_driver *io;
> +};
> +
> +int omap4_usbboot_open(void);
> +void omap4_usbboot_close(void);
> +
> +void omap4_usbboot_queue_read(void *data, unsigned len);
> +int omap4_usbboot_wait_read(void);
> +int omap4_usbboot_is_read_waiting(void);
> +int omap4_usbboot_is_read_ok(void);
> +
> +void omap4_usbboot_queue_write(void *data, unsigned len);
> +int omap4_usbboot_wait_write(void);
> +
> +int omap4_usbboot_read(void *data, unsigned len);
> +int omap4_usbboot_write(void *data, unsigned len);
> +void omap4_usbboot_puts(const char *s);
> +
> +#endif
> diff --git a/arch/arm/mach-omap/omap4_generic.c b/arch/arm/mach-omap/omap4_generic.c
> index 6562268..ee62cf2 100644
> --- a/arch/arm/mach-omap/omap4_generic.c
> +++ b/arch/arm/mach-omap/omap4_generic.c
> @@ -8,6 +8,9 @@
> #include <mach/xload.h>
> #include <mach/gpmc.h>
> #include <mach/gpio.h>
> +#ifdef CONFIG_OMAP4_USBBOOT
> +#include <mach/omap4_rom_usb.h>
> +#endif
>
> /*
> * The following several lines are taken from U-Boot to support
> @@ -457,6 +460,15 @@ static int watchdog_init(void)
> }
> late_initcall(watchdog_init);
>
> +#ifdef CONFIG_OMAP4_USBBOOT
> +static int omap4_usbboot_init(void)
> +{
> + omap4_usbboot_open();
> + omap4_usbboot_puts("USB communications initialized\n");
> + return 0;
> +}
> +postcore_initcall(omap4_usbboot_init);
> +#else
> static int omap_vector_init(void)
> {
> __asm__ __volatile__ (
> @@ -470,6 +482,7 @@ static int omap_vector_init(void)
> return 0;
> }
> core_initcall(omap_vector_init);
> +#endif
need more explanation here
>
> #define OMAP4_TRACING_VECTOR3 0x4030d048
>
> diff --git a/arch/arm/mach-omap/omap4_rom_usb.c b/arch/arm/mach-omap/omap4_rom_usb.c
> new file mode 100644
> index 0000000..741f2b7
> --- /dev/null
> +++ b/arch/arm/mach-omap/omap4_rom_usb.c
> @@ -0,0 +1,186 @@
> +/*
> + * This code is based on:
> + * git://github.com/swetland/omap4boot.git
> + */
> +/*
> + * Copyright (C) 2010 The Android Open Source Project
> + * All rights reserved.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + * * Redistributions of source code must retain the above copyright
> + * notice, this list of conditions and the following disclaimer.
> + * * Redistributions in binary form must reproduce the above copyright
> + * notice, this list of conditions and the following disclaimer in
> + * the documentation and/or other materials provided with the
> + * distribution.
> + *
> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
> + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
> + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
> + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
> + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
> + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
> + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
> + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
> + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
> + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> + * SUCH DAMAGE.
> + */
> +
> +#include <common.h>
> +#include <mach/omap4-silicon.h>
> +#include <mach/omap4_rom_usb.h>
> +
> +struct omap4_usbboot *omap4_usbboot_pdata;
> +
> +int omap4_usbboot_open(void)
> +{
> + int (*rom_get_per_driver)(struct per_driver **io, u32 device_type);
> + int (*rom_get_per_device)(struct per_handle **rh);
> + struct per_handle *boot;
> + int n;
> + u32 base;
> +
> + if (omap4_revision() >= OMAP4460_ES1_0)
> + base = PUBLIC_API_BASE_4460;
> + else
> + base = PUBLIC_API_BASE_4430;
> +
> + rom_get_per_driver = API(base + PUBLIC_GET_DRIVER_PER_OFFSET);
> + rom_get_per_device = API(base + PUBLIC_GET_DEVICE_PER_OFFSET);
> +
> + n = rom_get_per_device(&boot);
> + if (n)
> + return n;
> +
> + if ((boot->device_type != DEVICE_USB) &&
> + (boot->device_type != DEVICE_USBEXT))
> + return -1;
> +
> + omap4_usbboot_pdata = xzalloc(sizeof(struct omap4_usbboot));
> + n = rom_get_per_driver(&omap4_usbboot_pdata->io, boot->device_type);
> + if (n)
> + return n;
> +
> + omap4_usbboot_pdata->dread.status = -1;
> + omap4_usbboot_pdata->dread.xfer_mode = boot->xfer_mode;
> + omap4_usbboot_pdata->dread.options = boot->options;
> + omap4_usbboot_pdata->dread.device_type = boot->device_type;
> +
> + omap4_usbboot_pdata->dwrite.status = -1;
> + omap4_usbboot_pdata->dwrite.xfer_mode = boot->xfer_mode;
> + omap4_usbboot_pdata->dwrite.options = boot->options;
> + omap4_usbboot_pdata->dwrite.device_type = boot->device_type;
> + __asm__ __volatile__ ("cpsie i\n");
> + return 0;
> +}
> +
> +
> +static void rom_read_callback(struct per_handle *rh)
> +{
> + omap4_usbboot_pdata->dread.status = rh->status;
> + return;
> +}
> +
> +void omap4_usbboot_queue_read(void *data, unsigned len)
> +{
> + int n;
> + omap4_usbboot_pdata->dread.data = data;
> + omap4_usbboot_pdata->dread.length = len;
> + omap4_usbboot_pdata->dread.status = STATUS_WAITING;
> + omap4_usbboot_pdata->dread.xfer_mode = 1;
> + omap4_usbboot_pdata->dread.callback = rom_read_callback;
> + n = omap4_usbboot_pdata->io->read(&omap4_usbboot_pdata->dread);
> + if (n)
> + omap4_usbboot_pdata->dread.status = n;
> +}
> +
> +int omap4_usbboot_wait_read(void)
> +{
> + int ret;
> + while (omap4_usbboot_pdata->dread.status == STATUS_WAITING)
> + /* cpu_relax(); */
> + barrier();
> + ret = omap4_usbboot_pdata->dread.status;
> + omap4_usbboot_pdata->dread.status = -1;
> + return ret;
> +}
> +int omap4_usbboot_is_read_waiting(void)
> +{
> + barrier();
> + return omap4_usbboot_pdata->dread.status == STATUS_WAITING;
> +}
> +int omap4_usbboot_is_read_ok(void)
> +{
> + barrier();
> + return omap4_usbboot_pdata->dread.status == STATUS_OKAY;
> +}
> +
> +static void rom_write_callback(struct per_handle *rh)
> +{
> + omap4_usbboot_pdata->dwrite.status = rh->status;
> + return;
> +}
> +
> +void omap4_usbboot_queue_write(void *data, unsigned len)
> +{
> + int n;
> + omap4_usbboot_pdata->dwrite.data = data;
> + omap4_usbboot_pdata->dwrite.length = len;
> + omap4_usbboot_pdata->dwrite.status = STATUS_WAITING;
> + omap4_usbboot_pdata->dwrite.xfer_mode = 1;
> + omap4_usbboot_pdata->dwrite.callback = rom_write_callback;
> + n = omap4_usbboot_pdata->io->write(&omap4_usbboot_pdata->dwrite);
> + if (n)
> + omap4_usbboot_pdata->dwrite.status = n;
> +}
> +
> +int omap4_usbboot_wait_write(void)
> +{
> + int ret;
> + while (omap4_usbboot_pdata->dwrite.status == STATUS_WAITING)
> + /* cpu_relax(); */
> + barrier();
> + ret = omap4_usbboot_pdata->dwrite.status;
> + omap4_usbboot_pdata->dwrite.status = -1;
> + return ret;
> +}
> +
> +#define USB_MAX_IO 65536
> +int omap4_usbboot_read(void *data, unsigned len)
> +{
> + unsigned xfer;
> + unsigned char *x = data;
> + int n;
> + while (len > 0) {
> + xfer = (len > USB_MAX_IO) ? USB_MAX_IO : len;
> + omap4_usbboot_queue_read(x, xfer);
> + n = omap4_usbboot_wait_read();
> + if (n)
> + return n;
> + x += xfer;
> + len -= xfer;
> + }
> + return 0;
> +}
> +
> +int omap4_usbboot_write(void *data, unsigned len)
> +{
> + omap4_usbboot_queue_write(data, len);
> + return omap4_usbboot_wait_write();
> +}
> +
> +void omap4_usbboot_close(void)
> +{
> + omap4_usbboot_pdata->io->close(&omap4_usbboot_pdata->dread);
> +}
> +
> +void omap4_usbboot_puts(const char *s)
> +{
> + u32 c;
> + while ((c = *s++))
> + omap4_usbboot_write(&c, 4);
> +}
can you put a device driver for this
> diff --git a/scripts/.gitignore b/scripts/.gitignore
> index 6e63f85..4fb5a1f 100644
> --- a/scripts/.gitignore
> +++ b/scripts/.gitignore
> @@ -5,3 +5,4 @@ kallsyms
> mkimage
> mkublheader
> omap_signGP
> +omap4_usbboot
> diff --git a/scripts/Makefile b/scripts/Makefile
> index 7ca5e29..6c1b113 100644
> --- a/scripts/Makefile
> +++ b/scripts/Makefile
> @@ -4,6 +4,8 @@
> # ---------------------------------------------------------------------------
> # kallsyms: Find all symbols in barebox
>
> +HOSTLDFLAGS += -lpthread
> +
no the -lpthread is for omap4_usbboot target olny
is HOSTLOADLIBES_omap4_usbboot
and HOSTCFLAGS_omap4_usbboot.o for specifc header and lib
> hostprogs-$(CONFIG_KALLSYMS) += kallsyms
> hostprogs-y += bin2c
> hostprogs-y += mkimage
> @@ -12,6 +14,8 @@ hostprogs-$(CONFIG_ARCH_NETX) += gen_netx_image
> hostprogs-$(CONFIG_ARCH_OMAP) += omap_signGP
> hostprogs-$(CONFIG_ARCH_S5PCxx) += s5p_cksum
> hostprogs-$(CONFIG_ARCH_DAVINCI) += mkublheader
> +hostprogs-$(CONFIG_OMAP4_USBBOOT)+= omap4_usbboot
> +omap4_usbboot-objs := usb_linux.o omap4_usbboot.o
>
> always := $(hostprogs-y) $(hostprogs-m)
>
> diff --git a/scripts/omap4_usbboot.c b/scripts/omap4_usbboot.c
> new file mode 100644
> index 0000000..aa11759
> --- /dev/null
> +++ b/scripts/omap4_usbboot.c
> @@ -0,0 +1,416 @@
> +/*
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * version 2 as published by the Free Software Foundation.
> + *
> + * 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 <stdio.h>
> +#include <stdlib.h>
> +#include <unistd.h>
> +#include <sys/stat.h>
> +#include <stdint.h>
> +#include <fcntl.h>
> +#include <string.h>
> +#include <sys/mman.h>
> +#include <pthread.h>
> +#include <termios.h>
> +
> +#include "usb.h"
> +
> +#define USBBOOT_FS_MAGIC 0x5562464D
> +#define USBBOOT_FS_CMD_OPEN 0x46530000
> +#define USBBOOT_FS_CMD_CLOSE 0x46530001
> +#define USBBOOT_FS_CMD_READ 0x46530002
> +#define USBBOOT_FS_CMD_END 0x4653FFFF
> +#define MAX_OPEN_FILES 1000
> +
> +#define RESET 0
> +#define BRIGHT 1
> +#define WHITE 8
> +#define RED 1
> +#define BLACK 0
> +#define FORMAT "%c[%d;%d;%dm"
> +#define TARGET_FORMAT 0x1B, BRIGHT, RED+30, BLACK+40
> +#define HOST_FORMAT 0x1B, RESET, WHITE+30, BLACK+40
> +#define host_print(fmt, arg...) printf(FORMAT fmt FORMAT"\n", \
> + HOST_FORMAT, ##arg, TARGET_FORMAT)
> +
> +struct thread_vars {
> + struct usb_handle *usb;
> + int hide;
> + struct termios to;
> +};
> +void *listenerTask(void *argument)
> +{
> + struct thread_vars *vars = argument;
> + int c;
> + for (;;) {
> + c = getchar();
> + if (c == EOF)
> + return NULL;
> + while (vars->hide)
> + usleep(10000);
> + if (usb_write(vars->usb, &c, 4) != 4) {
> + host_print("could not send '%c' to target", c);
> + tcsetattr(STDIN_FILENO, TCSANOW, &vars->to);
> + exit(1);
> + }
> + }
> + return NULL;
> +}
> +struct file_data {
> + size_t size;
> + void *data;
> +};
> +
> +int read_asic_id(struct usb_handle *usb)
> +{
> +#define LINEWIDTH 16
> + const uint32_t msg_getid = 0xF0030003;
> + int i, j, k, ret;
> + uint8_t id[81];
> + char line[LINEWIDTH*3+8];
> +
> + printf("reading ASIC ID\n");
> + memset(id , 0xee, sizeof(id));
> + if (usb_write(usb, &msg_getid, sizeof(msg_getid)) !=
> + sizeof(msg_getid)
> + ) {
> + printf("Could not send msg_getid request\n");
> + return -1;
> + }
> + if (usb_read(usb, id, sizeof(id)) != sizeof(id)) {
> + printf("Could not read msg_getid answer\n");
> + return -1;
> + }
> + for (i = 0; i < sizeof(id); i += LINEWIDTH) {
> + sprintf(line, "%02X: ", i);
> + for (j = 0; j < LINEWIDTH && j < sizeof(id)-i; j++)
> + sprintf(line+4+j*3, "%02X ", id[i+j]);
> + line[4+j*3+0] = '\n';
> + line[4+j*3+1] = 0;
> + printf(line);
> + }
> + ret = 0;
> + for (i = 1, j = 0; i < sizeof(id) && j < id[0]; i += 2+id[i+1], j++) {
> + if (i+2+id[i+1] > sizeof(id)) {
> + printf("Truncated subblock\n");
> + ret++;
> + continue;
> + }
> + switch (id[i]) {
> + case 0x01: /* ID subblock */
> + if (id[i+1] != 0x05) {
> + printf("Unexpected ID subblock size\n");
> + ret++;
> + continue;
> + }
> + if (id[i+2] != 0x01)
> + printf("Unexpected fixed value\n");
> + k = (id[i+3]<<8) | id[i+4];
> + switch (k) {
> + case 0x4440:
> + printf("OMAP 4460 Device\n");
> + break;
> + default:
> + printf("Unknown Device\n");
> + break;
> + }
> + switch (id[i+5]) {
> + case 0x07:
> + printf("CH enabled (read from eFuse)\n");
> + break;
> + case 0x17:
> + printf("CH disabled (read from eFuse)\n");
> + break;
> + default:
> + printf("Unknown CH setting\n");
> + break;
> + }
> + printf("Rom version: %hhu\n", id[i+6]);
> + break;
> + case 0x15: /* Checksum subblock */
> + if (id[i+1] != 0x09) {
> + printf("Unexpected Checksum subblock size\n");
> + ret++;
> + continue;
> + }
> + if (id[i+2] != 0x01)
> + printf("Unexpected fixed value\n");
> + k = (id[i+3]<<24) | (id[i+4]<<16) |
> + (id[i+5]<<8) | id[i+6];
> + printf("Rom CRC: 0x%08X\n", k);
> + k = (id[i+7]<<24) | (id[i+8]<<16) |
> + (id[i+9]<<8) | id[i+10];
> + switch (k) {
> + case 0:
> + printf("A GP device\n");
> + break;
> + default:
> + printf("Unknown device\n");
> + break;
> + }
> + break;
> + }
> + }
> + if (i != sizeof(id) || j != id[0]) {
> + printf("Unexpected ASIC ID structure size.\n");
> + ret++;
> + }
> + return ret;
> +}
> +
> +int process_file(
> + struct usb_handle *usb, const char *rootfs, struct file_data *fd_vector)
> +{
> + uint32_t i, j, pos, size;
> + struct stat s;
> + int fd, ret;
> + char line[256];
> +
> + if (usb_read(usb, &i, 4) != 4) {
> + host_print("USB error");
> + exit(1);
> + }
> + ret = 0;
> + switch (i) {
> + case USBBOOT_FS_CMD_OPEN:
> + for (j = 0; rootfs[j]; j++)
> + line[j] = rootfs[j];
> + for (;; j++) {
> + if (usb_read(usb, &i, 4) != 4) {
> + host_print("USB error");
> + exit(1);
> + }
> + if (i == USBBOOT_FS_CMD_END) {
> + line[j] = 0;
> + break;
> + } else if (i > 0xFF) {
> + host_print("Error in filename");
> + ret++;
> + line[j] = 0;
> + break;
> + } else
> + line[j] = i;
> + }
> + for (i = 0; i < MAX_OPEN_FILES && fd_vector[i].data; i++)
> + ;
> + if (i >= MAX_OPEN_FILES) {
> + host_print("MAX_OPEN_FILES exceeded");
> + ret++;
> + goto open_error_1;
> + }
> + fd = open(line, O_RDONLY);
> + if (fd < 0) {
> + host_print("cannot open '%s'", line);
> + ret++;
> + goto open_error_1;
> + }
> + if (fstat(fd, &s)) {
> + host_print("cannot stat '%s'", line);
> + ret++;
> + goto open_error_2;
> + }
> + fd_vector[i].data = mmap(NULL, s.st_size, PROT_READ,
> + MAP_PRIVATE, fd, 0);
> + if (fd_vector[i].data == MAP_FAILED) {
> + host_print("cannot mmap '%s'", line);
> + ret++;
> + goto open_error_2;
> + }
> + close(fd);
> + fd_vector[i].size = size = s.st_size;
> + fd = i;
> + goto open_ok;
> +
> +open_error_2:
> + close(fd);
> +open_error_1:
> + fd_vector[i].size = size = 0;
> + fd = -1;
> +open_ok:
> + if (usb_write(usb, &fd, 4) != 4 ||
> + usb_write(usb, &size, 4) != 4
> + ) {
> + host_print("could not send file size to target");
> + exit(1);
> + }
> + break;
> + case USBBOOT_FS_CMD_CLOSE:
> + if (usb_read(usb, &i, 4) != 4) {
> + host_print("USB error");
> + exit(1);
> + }
> + if (i >= MAX_OPEN_FILES || !fd_vector[i].data) {
> + host_print("invalid close index");
> + ret++;
> + break;
> + }
> + if (usb_read(usb, &j, 4) != 4) {
> + host_print("USB error");
> + exit(1);
> + }
> + if (j != USBBOOT_FS_CMD_END) {
> + host_print("invalid close");
> + ret++;
> + break;
> + }
> + munmap(fd_vector[i].data, fd_vector[i].size);
> + fd_vector[i].data = NULL;
> + break;
> + case USBBOOT_FS_CMD_READ:
> + if (usb_read(usb, &i, 4) != 4) {
> + host_print("USB error");
> + exit(1);
> + }
> + if (i >= MAX_OPEN_FILES || !fd_vector[i].data) {
> + host_print("invalid read index");
> + ret++;
> + break;
> + }
> + if (usb_read(usb, &pos, 4) != 4) {
> + host_print("USB error");
> + exit(1);
> + }
> + if (pos >= fd_vector[i].size) {
> + host_print("invalid read pos");
> + ret++;
> + break;
> + }
> + if (usb_read(usb, &size, 4) != 4) {
> + host_print("USB error");
> + exit(1);
> + }
> + if (pos+size > fd_vector[i].size) {
> + host_print("invalid read size");
> + ret++;
> + break;
> + }
> + if (usb_read(usb, &j, 4) != 4) {
> + host_print("USB error");
> + exit(1);
> + }
> + if (j != USBBOOT_FS_CMD_END) {
> + host_print("invalid read");
> + ret++;
> + break;
> + }
> + if (usb_write(usb, fd_vector[i].data+pos, size) != size) {
> + host_print("could not send file to target");
> + exit(1);
> + }
> + break;
> + case USBBOOT_FS_CMD_END:
> + default:
> + host_print("Unknown filesystem command");
> + ret++;
> + break;
> + }
> + return ret;
> +}
> +
> +int usb_boot(
> + struct usb_handle *usb, void *data, unsigned sz, const char *rootfs)
> +{
> + const uint32_t msg_boot = 0xF0030002;
> + uint32_t msg_size = sz;
> + int i;
> + pthread_t thread;
> + struct thread_vars vars;
> + struct termios tn;
> + struct file_data fd_vector[MAX_OPEN_FILES];
> +
> + read_asic_id(usb);
> +
> + printf("sending xload to target...\n");
> + usb_write(usb, &msg_boot, sizeof(msg_boot));
> + usb_write(usb, &msg_size, sizeof(msg_size));
> + usb_write(usb, data, sz);
> + munmap(data, msg_size);
> + for (i = 0; i < MAX_OPEN_FILES; i++)
> + fd_vector[i].data = NULL;
> +
> + vars.usb = usb;
> + vars.hide = 0;
> + tcgetattr(STDIN_FILENO, &vars.to);
> + tn = vars.to;
> + tn.c_lflag &= ~(ICANON | ECHO);
> + printf(FORMAT, TARGET_FORMAT);
> + tcsetattr(STDIN_FILENO, TCSANOW, &tn);
> + if (pthread_create(&thread, NULL, listenerTask, &vars))
> + host_print("listenerTask failed");
> + for (;;) {
> + if (usb_read(usb, &i, 4) != 4)
> + break;
> + if (i == USBBOOT_FS_MAGIC) {
> + vars.hide = 1;
> + process_file(usb, rootfs, fd_vector);
> + vars.hide = 0;
> + continue;
> + }
> + printf("%c", i);
> + fflush(stdout);
> + }
> + tcsetattr(STDIN_FILENO, TCSANOW, &vars.to);
> + return 0;
> +}
> +
> +int match_omap4_bootloader(struct usb_ifc_info *ifc)
> +{
> + if (ifc->dev_vendor != 0x0451)
> + return -1;
> + if ((ifc->dev_product != 0xD010) && (ifc->dev_product != 0xD00F))
> + return -1;
> + return 0;
> +}
> +
> +int main(int argc, char **argv)
> +{
> + void *data;
> + unsigned sz;
> + struct stat s;
> + int fd;
> + struct usb_handle *usb;
> + int once;
> +
> + if (argc != 3) {
> + printf("usage: %s <xloader> <rootfs>\n", argv[0]);
> + return 0;
> + }
> + argv++;
> + fd = open(argv[0], O_RDONLY);
> + if (fd < 0 || fstat(fd, &s)) {
> + printf("cannot open '%s'\n", argv[0]);
> + return -1;
> + }
> + data = mmap(NULL, s.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
> + if (data == MAP_FAILED) {
> + printf("cannot mmap '%s'\n", argv[0]);
> + return -1;
> + }
> + sz = s.st_size;
> + close(fd);
> + argv++;
> + printf(FORMAT, HOST_FORMAT);
> + for (once = 1;;) {
> + usb = usb_open(match_omap4_bootloader);
> + if (usb)
> + return usb_boot(usb, data, sz, argv[0]);
> + if (once) {
> + once = 0;
> + printf("waiting for OMAP44xx device...\n");
> + }
> + usleep(250000);
> + }
> + return -1;
> +}
> diff --git a/scripts/usb.h b/scripts/usb.h
> new file mode 100644
> index 0000000..d50aa6a
> --- /dev/null
> +++ b/scripts/usb.h
> @@ -0,0 +1,61 @@
> +/*
> + * Copyright (C) 2008 The Android Open Source Project
> + * All rights reserved.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + * * Redistributions of source code must retain the above copyright
> + * notice, this list of conditions and the following disclaimer.
> + * * Redistributions in binary form must reproduce the above copyright
> + * notice, this list of conditions and the following disclaimer in
> + * the documentation and/or other materials provided with the
> + * distribution.
> + *
> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
> + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
> + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
> + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
> + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
> + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
> + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
> + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
> + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
> + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> + * SUCH DAMAGE.
> + */
> +
> +#ifndef _USB_H_
> +#define _USB_H_
> +
> +struct usb_ifc_info {
> + /* from device descriptor */
> + unsigned short dev_vendor;
> + unsigned short dev_product;
> +
> + unsigned char dev_class;
> + unsigned char dev_subclass;
> + unsigned char dev_protocol;
> +
> + unsigned char ifc_class;
> + unsigned char ifc_subclass;
> + unsigned char ifc_protocol;
> +
> + unsigned char has_bulk_in;
> + unsigned char has_bulk_out;
> +
> + unsigned char writable;
> +
> + char serial_number[256];
> +};
> +
> +typedef int (*ifc_match_func)(struct usb_ifc_info *ifc);
> +
> +struct usb_handle *usb_open(ifc_match_func callback);
> +int usb_close(struct usb_handle *h);
> +int usb_read(struct usb_handle *h, void *_data, int len);
> +int usb_write(struct usb_handle *h, const void *_data, int len);
> +
> +
> +#endif
> diff --git a/scripts/usb_linux.c b/scripts/usb_linux.c
> new file mode 100644
> index 0000000..43529aa
> --- /dev/null
> +++ b/scripts/usb_linux.c
> @@ -0,0 +1,397 @@
> +/*
> + * Copyright (C) 2008 The Android Open Source Project
> + * All rights reserved.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + * * Redistributions of source code must retain the above copyright
> + * notice, this list of conditions and the following disclaimer.
> + * * Redistributions in binary form must reproduce the above copyright
> + * notice, this list of conditions and the following disclaimer in
> + * the documentation and/or other materials provided with the
> + * distribution.
> + *
> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
> + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
> + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
> + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
> + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
> + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
> + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
> + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
> + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
> + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> + * SUCH DAMAGE.
> + */
> +
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <unistd.h>
> +#include <string.h>
> +
> +#include <sys/ioctl.h>
> +#include <sys/types.h>
> +#include <dirent.h>
> +#include <fcntl.h>
> +#include <errno.h>
> +#include <pthread.h>
> +#include <ctype.h>
> +
> +#include <linux/usbdevice_fs.h>
> +#include <linux/usbdevice_fs.h>
> +#include <linux/version.h>
> +#include <linux/usb/ch9.h>
> +#include <asm/byteorder.h>
> +
> +#include "usb.h"
> +
> +#define MAX_RETRIES 5
> +
> +#ifdef TRACE_USB
> +#define DBG1(x...) fprintf(stderr, x)
> +#define DBG(x...) fprintf(stderr, x)
> +#else
> +#define DBG(x...)
> +#define DBG1(x...)
> +#endif
> +
> +struct usb_handle {
> + char fname[64];
> + int desc;
> + unsigned char ep_in;
> + unsigned char ep_out;
> +};
> +
> +static inline int badname(const char *name)
> +{
> + while (*name) {
> + if (!isdigit(*name++))
> + return 1;
> + }
> + return 0;
> +}
> +
> +static int check(void *_desc, int len, unsigned type, int size)
> +{
> + unsigned char *desc = _desc;
> +
> + if (len < size)
> + return -1;
> + if (desc[0] < size)
> + return -1;
> + if (desc[0] > len)
> + return -1;
> + if (desc[1] != type)
> + return -1;
> +
> + return 0;
> +}
> +
> +static int filter_usb_device(int fd, char *ptr, int len, int writable,
> + ifc_match_func callback, int *ept_in_id, int *ept_out_id, int *ifc_id)
> +{
> + struct usb_device_descriptor *dev;
> + struct usb_config_descriptor *cfg;
> + struct usb_interface_descriptor *ifc;
> + struct usb_endpoint_descriptor *ept;
> + struct usb_ifc_info info;
> +
> + int in, out;
> + unsigned i;
> + unsigned e;
> +
> + if (check(ptr, len, USB_DT_DEVICE, USB_DT_DEVICE_SIZE))
> + return -1;
> + dev = (void *) ptr;
> + len -= dev->bLength;
> + ptr += dev->bLength;
> +
> + if (check(ptr, len, USB_DT_CONFIG, USB_DT_CONFIG_SIZE))
> + return -1;
> + cfg = (void *) ptr;
> + len -= cfg->bLength;
> + ptr += cfg->bLength;
> +
> + info.dev_vendor = dev->idVendor;
> + info.dev_product = dev->idProduct;
> + info.dev_class = dev->bDeviceClass;
> + info.dev_subclass = dev->bDeviceSubClass;
> + info.dev_protocol = dev->bDeviceProtocol;
> + info.writable = writable;
> +
> + /* read device serial number (if there is one) */
> + info.serial_number[0] = 0;
> + if (dev->iSerialNumber) {
> + struct usbdevfs_ctrltransfer ctrl;
> + __u16 buffer[128];
> + int result;
> +
> + memset(buffer, 0, sizeof(buffer));
> +
> + ctrl.bRequestType = USB_DIR_IN|
> + USB_TYPE_STANDARD|USB_RECIP_DEVICE;
> + ctrl.bRequest = USB_REQ_GET_DESCRIPTOR;
> + ctrl.wValue = (USB_DT_STRING << 8) | dev->iSerialNumber;
> + ctrl.wIndex = 0;
> + ctrl.wLength = sizeof(buffer);
> + ctrl.data = buffer;
> + ctrl.timeout = 50;
> +
> + result = ioctl(fd, USBDEVFS_CONTROL, &ctrl);
> + if (result > 0) {
> + int i;
> + /* skip first word, and copy the rest to the serial
> + string, changing shorts to bytes. */
> + result /= 2;
> + for (i = 1; i < result; i++)
> + info.serial_number[i - 1] = buffer[i];
> + info.serial_number[i - 1] = 0;
> + }
> + }
> +
> + for (i = 0; i < cfg->bNumInterfaces; i++) {
> + if (check(ptr, len, USB_DT_INTERFACE, USB_DT_INTERFACE_SIZE))
> + return -1;
> + ifc = (void *) ptr;
> + len -= ifc->bLength;
> + ptr += ifc->bLength;
> +
> + in = -1;
> + out = -1;
> + info.ifc_class = ifc->bInterfaceClass;
> + info.ifc_subclass = ifc->bInterfaceSubClass;
> + info.ifc_protocol = ifc->bInterfaceProtocol;
> +
> + for (e = 0; e < ifc->bNumEndpoints; e++) {
> + if (check(ptr, len, USB_DT_ENDPOINT,
> + USB_DT_ENDPOINT_SIZE)
> + )
> + return -1;
> + ept = (void *) ptr;
> + len -= ept->bLength;
> + ptr += ept->bLength;
> +
> + if ((ept->bmAttributes & 0x03) != 0x02)
> + continue;
> +
> + if (ept->bEndpointAddress & 0x80)
> + in = ept->bEndpointAddress;
> + else
> + out = ept->bEndpointAddress;
> + }
> +
> + info.has_bulk_in = (in != -1);
> + info.has_bulk_out = (out != -1);
> +
> + if (callback(&info) == 0) {
> + *ept_in_id = in;
> + *ept_out_id = out;
> + *ifc_id = ifc->bInterfaceNumber;
> + return 0;
> + }
> + }
> +
> + return -1;
> +}
> +
> +static struct usb_handle *find_usb_device(
> + const char *base, ifc_match_func callback)
> +{
> + struct usb_handle *usb = 0;
> + char busname[64], devname[64];
> + char desc[1024];
> + int n, in, out, ifc;
> +
> + DIR *busdir, *devdir;
> + struct dirent *de;
> + int fd;
> + int writable;
> +
> + busdir = opendir(base);
> + if (busdir == 0)
> + return 0;
> +
> + while ((de = readdir(busdir)) && (usb == 0)) {
> + if (badname(de->d_name))
> + continue;
> +
> + sprintf(busname, "%s/%s", base, de->d_name);
> + devdir = opendir(busname);
> + if (devdir == 0)
> + continue;
> +
> + /* DBG("[ scanning %s ]\n", busname); */
> + while ((de = readdir(devdir)) && (usb == 0)) {
> +
> + if (badname(de->d_name))
> + continue;
> + sprintf(devname, "%s/%s", busname, de->d_name);
> +
> + /* DBG("[ scanning %s ]\n", devname); */
> + writable = 1;
> + fd = open(devname, O_RDWR);
> + if (fd < 0) {
> + /* Check if we have read-only access,
> + so we can give a helpful diagnostic
> + like "adb devices" does. */
> + writable = 0;
> + fd = open(devname, O_RDONLY);
> + if (fd < 0)
> + continue;
> + }
> +
> + n = read(fd, desc, sizeof(desc));
> +
> + if (filter_usb_device(fd, desc, n, writable,
> + callback, &in, &out, &ifc) == 0
> + ) {
> + usb = calloc(1, sizeof(struct usb_handle));
> + strcpy(usb->fname, devname);
> + usb->ep_in = in;
> + usb->ep_out = out;
> + usb->desc = fd;
> +
> + n = ioctl(fd, USBDEVFS_CLAIMINTERFACE, &ifc);
> + if (n != 0) {
> + close(fd);
> + free(usb);
> + usb = 0;
> + continue;
> + }
> + } else
> + close(fd);
> + }
> + closedir(devdir);
> + }
> + closedir(busdir);
> +
> + return usb;
> +}
> +
> +int usb_write(struct usb_handle *h, const void *_data, int len)
> +{
> + unsigned char *data = (unsigned char *) _data;
> + unsigned count = 0;
> + struct usbdevfs_bulktransfer bulk;
> + int n;
> +
> + if (h->ep_out == 0)
> + return -1;
> +
> + if (len == 0) {
> + bulk.ep = h->ep_out;
> + bulk.len = 0;
> + bulk.data = data;
> + bulk.timeout = 0;
> +
> + n = ioctl(h->desc, USBDEVFS_BULK, &bulk);
> + if (n != 0) {
> + fprintf(stderr, "ERROR: n = %d, errno = %d (%s)\n",
> + n, errno, strerror(errno));
> + return -1;
> + }
> + return 0;
> + }
> +
> + while (len > 0) {
> + int xfer;
> + xfer = (len > 4096) ? 4096 : len;
> +
> + bulk.ep = h->ep_out;
> + bulk.len = xfer;
> + bulk.data = data;
> + bulk.timeout = 0;
> +
> + n = ioctl(h->desc, USBDEVFS_BULK, &bulk);
> + if (n != xfer) {
> + DBG("ERROR: n = %d, errno = %d (%s)\n",
> + n, errno, strerror(errno));
> + return -1;
> + }
> +
> + count += xfer;
> + len -= xfer;
> + data += xfer;
> + }
> +
> + return count;
> +}
> +
> +int usb_read(struct usb_handle *h, void *_data, int len)
> +{
> + unsigned char *data = (unsigned char *) _data;
> + unsigned count = 0;
> + struct usbdevfs_bulktransfer bulk;
> + int n, retry;
> +
> + if (h->ep_in == 0)
> + return -1;
> +
> + while (len > 0) {
> + int xfer = (len > 4096) ? 4096 : len;
> +
> + bulk.ep = h->ep_in;
> + bulk.len = xfer;
> + bulk.data = data;
> + bulk.timeout = 0;
> + retry = 0;
> +
> + do {
> + DBG("[ usb read %d fd = %d], fname=%s\n",
> + xfer, h->desc, h->fname);
> + n = ioctl(h->desc, USBDEVFS_BULK, &bulk);
> + DBG("[ usb read %d ] = %d, fname=%s, Retry %d\n",
> + xfer, n, h->fname, retry);
> +
> + if (n < 0) {
> + DBG1("ERROR: n = %d, errno = %d (%s)\n",
> + n, errno, strerror(errno));
> + if (++retry > MAX_RETRIES)
> + return -1;
> + sleep(1);
> + }
> + } while (n < 0);
> +
> + count += n;
> + len -= n;
> + data += n;
> +
> + if (n < xfer)
> + break;
> + }
> +
> + return count;
> +}
> +
> +void usb_kick(struct usb_handle *h)
> +{
> + int fd;
> +
> + fd = h->desc;
> + h->desc = -1;
> + if (fd >= 0) {
> + close(fd);
> + DBG("[ usb closed %d ]\n", fd);
> + }
> +}
> +
> +int usb_close(struct usb_handle *h)
> +{
> + int fd;
> +
> + fd = h->desc;
> + h->desc = -1;
> + if (fd >= 0) {
> + close(fd);
> + DBG("[ usb closed %d ]\n", fd);
> + }
> +
> + return 0;
> +}
> +
> +struct usb_handle *usb_open(ifc_match_func callback)
> +{
> + return find_usb_device("/dev/bus/usb", callback);
> +}
> --
> 1.7.12.1
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 6/9] omap4: add usb boot support
2012-09-30 14:07 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2012-09-30 15:23 ` vj
2012-09-30 15:30 ` vj
[not found] ` <CAAMcf8B0Qif3zVfw44zx5G813fYrMQTfUKi86Kr+JuFm=yf5rQ@mail.gmail.com>
2 siblings, 0 replies; 27+ messages in thread
From: vj @ 2012-09-30 15:23 UTC (permalink / raw)
To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox
[-- Attachment #1.1: Type: text/plain, Size: 303 bytes --]
About the "need more explanation here", see:
lists.infradead.org/pipermail/barebox/2012-September/009865.html
omap_vector_init is disabled because it breaks usb booting.
Seems to be differences between u-boot and barebox. I don't know which
behaviour is the correct, but by now disable it as in u-boot.
[-- Attachment #1.2: Type: text/html, Size: 436 bytes --]
[-- Attachment #2: Type: text/plain, Size: 149 bytes --]
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 6/9] omap4: add usb boot support
2012-09-30 14:07 ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-30 15:23 ` vj
@ 2012-09-30 15:30 ` vj
[not found] ` <CAAMcf8B0Qif3zVfw44zx5G813fYrMQTfUKi86Kr+JuFm=yf5rQ@mail.gmail.com>
2 siblings, 0 replies; 27+ messages in thread
From: vj @ 2012-09-30 15:30 UTC (permalink / raw)
To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox
[-- Attachment #1.1: Type: text/plain, Size: 216 bytes --]
About the "can you put a device driver for this":
omap4_usbboot_puts is used in the device driver serial_omap4_usbboot and
omap4_usbbootfs
or are you meaning to put the whole code for usb communications in a driver?
[-- Attachment #1.2: Type: text/html, Size: 236 bytes --]
[-- Attachment #2: Type: text/plain, Size: 149 bytes --]
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 27+ messages in thread
[parent not found: <CAAMcf8B0Qif3zVfw44zx5G813fYrMQTfUKi86Kr+JuFm=yf5rQ@mail.gmail.com>]
* Re: [PATCH 6/9] omap4: add usb boot support
[not found] ` <CAAMcf8B0Qif3zVfw44zx5G813fYrMQTfUKi86Kr+JuFm=yf5rQ@mail.gmail.com>
@ 2012-09-30 15:32 ` Jean-Christophe PLAGNIOL-VILLARD
0 siblings, 0 replies; 27+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-30 15:32 UTC (permalink / raw)
To: vj; +Cc: barebox
On 17:21 Sun 30 Sep , vj wrote:
> About the "need more explanation here", see:
> lists.infradead.org/pipermail/barebox/2012-September/009865.html
> omap_vector_init is disabled because it breaks usb booting.
> Seems to be differences between u-boot and barebox. I don't know which
> behaviour is the correct, but by now disable it as in u-boot.
no explaination in the commit or in the code
we debugging the code we do not re-read the ML we read the code or the history
and Sascha suggest tho use VBAR did you check out
Best Regards,
J.
>
> On Sun, Sep 30, 2012 at 4:07 PM, Jean-Christophe PLAGNIOL-VILLARD
> <plagnioj@jcrosoft.com> wrote:
>
> On 04:50 Sun 30 Sep A A , vj wrote:
> > ---
> > A arch/arm/cpu/cpu.c A A A A A A A A A A A A A A A | A
> 1 +
> > A arch/arm/mach-omap/Kconfig A A A A A A A A A A A | A 7 +
> > A arch/arm/mach-omap/Makefile A A A A A A A A A A | A 1 +
> > A arch/arm/mach-omap/include/mach/omap4_rom_usb.h | 142 ++++++++
> > A arch/arm/mach-omap/omap4_generic.c A A A A A A A | A 13 +
> > A arch/arm/mach-omap/omap4_rom_usb.c A A A A A A A | 186
> +++++++++++
> > A scripts/.gitignore A A A A A A A A A A A A A A A | A
> 1 +
> > A scripts/Makefile A A A A A A A A A A A A A A A A | A
> 4 +
> > A scripts/omap4_usbboot.c A A A A A A A A A A A A | 416
> ++++++++++++++++++++++++
> > A scripts/usb.h A A A A A A A A A A A A A A A A A |
> A 61 ++++
> > A scripts/usb_linux.c A A A A A A A A A A A A A A | 397
> ++++++++++++++++++++++
> > A 11 files changed, 1229 insertions(+)
> > A create mode 100644 arch/arm/mach-omap/include/mach/omap4_rom_usb.h
> > A create mode 100644 arch/arm/mach-omap/omap4_rom_usb.c
> > A create mode 100644 scripts/omap4_usbboot.c
> > A create mode 100644 scripts/usb.h
> > A create mode 100644 scripts/usb_linux.c
> >
> > diff --git a/arch/arm/cpu/cpu.c b/arch/arm/cpu/cpu.c
> > index 71ef8c0..05343de 100644
> > --- a/arch/arm/cpu/cpu.c
> > +++ b/arch/arm/cpu/cpu.c
> > @@ -89,6 +89,7 @@ void arch_shutdown(void)
> > A A A A A A A : "r0", "r1", "r2", "r3", "r6", "r10", "r12",
> "lr", "cc", "memory"
> > A A A );
> > A #endif
> > + A A __asm__ __volatile__ ("cpsid i\n");
> > A }
> >
> > A #ifdef CONFIG_THUMB2_BAREBOX
> > diff --git a/arch/arm/mach-omap/Kconfig b/arch/arm/mach-omap/Kconfig
> > index d735284..16583cb 100644
> > --- a/arch/arm/mach-omap/Kconfig
> > +++ b/arch/arm/mach-omap/Kconfig
> > @@ -96,6 +96,13 @@ config ARCH_TEXT_BASE
> > A A A default 0x80e80000 if MACH_OMAP343xSDP
> > A A A default 0x80e80000 if MACH_BEAGLE
> >
> > +config OMAP4_USBBOOT
> > + A A bool "enable booting from USB"
> > + A A default n
> > + A A depends on ARCH_OMAP4 && !MMU
> > + A A help
> > + A A A Enable this to enable USB booting
> > +
> > A config BOARDINFO
> > A A A default "Texas Instrument's SDP343x" if MACH_OMAP343xSDP
> > A A A default "Texas Instrument's Beagle" if MACH_BEAGLE
> > diff --git a/arch/arm/mach-omap/Makefile b/arch/arm/mach-omap/Makefile
> > index f087f4b..e89f6ed 100644
> > --- a/arch/arm/mach-omap/Makefile
> > +++ b/arch/arm/mach-omap/Makefile
> > @@ -30,4 +30,5 @@ obj-$(CONFIG_OMAP3_CLOCK_CONFIG) += omap3_clock.o
> > A obj-$(CONFIG_OMAP_GPMC) += gpmc.o devices-gpmc-nand.o
> > A obj-$(CONFIG_SHELL_NONE) += xload.o
> > A obj-$(CONFIG_I2C_TWL6030) += omap4_twl6030_mmc.o
> > +obj-$(CONFIG_OMAP4_USBBOOT) += omap4_rom_usb.o
> > A obj-y += gpio.o
> > diff --git a/arch/arm/mach-omap/include/mach/omap4_rom_usb.h
> b/arch/arm/mach-omap/include/mach/omap4_rom_usb.h
> > new file mode 100644
> > index 0000000..b7818df
> > --- /dev/null
> > +++ b/arch/arm/mach-omap/include/mach/omap4_rom_usb.h
> > @@ -0,0 +1,142 @@
> > +/*
> > + * Copyright (C) 2010 The Android Open Source Project
> > + * All rights reserved.
> > + *
> > + * Redistribution and use in source and binary forms, with or without
> > + * modification, are permitted provided that the following conditions
> > + * are met:
> > + * A * Redistributions of source code must retain the above copyright
> > + * A A notice, this list of conditions and the following disclaimer.
> > + * A * Redistributions in binary form must reproduce the above
> copyright
> > + * A A notice, this list of conditions and the following disclaimer
> in
> > + * A A the documentation and/or other materials provided with the
> > + * A A distribution.
> > + *
> > + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
> CONTRIBUTORS
> > + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> > + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
> > + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
> > + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
> INDIRECT,
> > + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
> (INCLUDING,
> > + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
> LOSS
> > + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
> > + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
> LIABILITY,
> > + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
> > + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> > + * SUCH DAMAGE.
> > + */
> > +
> > +#ifndef _OMAP4_ROM_USB_H_
> > +#define _OMAP4_ROM_USB_H_
> > +
> > +/* public api */
> > +#define PUBLIC_API_BASE_4430 A A A A (0x28400)
> > +#define PUBLIC_API_BASE_4460 A A A A (0x30400)
> > +
> > +#define PUBLIC_GET_DRIVER_MEM_OFFSET (0x04)
> > +#define PUBLIC_GET_DRIVER_PER_OFFSET (0x08)
> > +#define PUBLIC_GET_DEVICE_MEM_OFFSET (0x80)
> > +#define PUBLIC_GET_DEVICE_PER_OFFSET (0x84)
> > +
> > +#define DEVICE_NULL A 0x40
> > +#define DEVICE_UART1 0x41
> > +#define DEVICE_UART2 0x42
> > +#define DEVICE_UART3 0x43
> > +#define DEVICE_UART4 0x44
> > +#define DEVICE_USB A 0x45
> > +#define DEVICE_USBEXT A A A A 0x46
> > +
> > +#define XFER_MODE_CPU 0
> > +#define XFER_MODE_DMA 1
> > +
> > +#define STATUS_OKAY A A A A A 0
> > +#define STATUS_FAILED A A A A A A A A 1
> > +#define STATUS_TIMEOUT A A A A A A A 2
> > +#define STATUS_BAD_PARAM A A 3
> > +#define STATUS_WAITING A A A A A A A 4
> > +#define STATUS_NO_MEMORY A A 5
> > +#define STATUS_INVALID_PTR A 6
> > +
> > +/* Memory ROM interface */
> > +struct read_desc {
> > + A A u32 sector_start;
> > + A A u32 sector_count;
> > + A A void *destination;
> > +};
> > +
> > +struct mem_device {
> > + A A u32 initialized;
> > + A A u8 device_type;
> > + A A u8 trials_count;
> > + A A u32 xip_device;
> > + A A u16 search_size;
> > + A A u32 base_address;
> > + A A u16 hs_toc_mask;
> > + A A u16 gp_toc_mask;
> > + A A void *device_data;
> > + A A u16 *boot_options;
> > +};
> > +
> > +struct mem_driver {
> > + A A int (*init)(struct mem_device *md);
> > + A A int (*read)(struct mem_device *md, struct read_desc *rd);
> > + A A int (*configure)(struct mem_device *md, void *config);
> > +};
> > +
> > +
> > +/* Peripheral ROM interface */
> > +struct per_handle {
> > + A A void *set_to_null;
> > + A A void (*callback)(struct per_handle *rh);
> > + A A void *data;
> > + A A u32 length;
> > + A A u16 *options;
> > + A A u32 xfer_mode;
> > + A A u32 device_type;
> > + A A u32 status;
> > + A A u16 hs_toc_mask;
> > + A A u16 gp_toc_mask;
> > + A A u32 config_timeout;
> > +};
> > +
> > +struct per_driver {
> > + A A int (*init)(struct per_handle *rh);
> > + A A int (*read)(struct per_handle *rh);
> > + A A int (*write)(struct per_handle *rh);
> > + A A int (*close)(struct per_handle *rh);
> > + A A int (*config)(struct per_handle *rh, void *x);
> > +};
> > +
> > +#define USB_SETCONFIGDESC_ATTRIBUTES A A A (0)
> > +#define USB_SETCONFIGDESC_MAXPOWER A A A A (1)
> > +#define USB_SETSUSPEND_CALLBACK A A A A A (2)
> > +struct per_usb_config {
> > + A A u32 configid;
> > + A A u32 value;
> > +};
> > +
> > +#define API(n) ((void *) (*((u32 *) (n))))
> > +/* ROM API End */
> > +
> > +struct omap4_usbboot {
> > + A A struct per_handle dread;
> > + A A struct per_handle dwrite;
> > + A A struct per_driver *io;
> > +};
> > +
> > +int omap4_usbboot_open(void);
> > +void omap4_usbboot_close(void);
> > +
> > +void omap4_usbboot_queue_read(void *data, unsigned len);
> > +int omap4_usbboot_wait_read(void);
> > +int omap4_usbboot_is_read_waiting(void);
> > +int omap4_usbboot_is_read_ok(void);
> > +
> > +void omap4_usbboot_queue_write(void *data, unsigned len);
> > +int omap4_usbboot_wait_write(void);
> > +
> > +int omap4_usbboot_read(void *data, unsigned len);
> > +int omap4_usbboot_write(void *data, unsigned len);
> > +void omap4_usbboot_puts(const char *s);
> > +
> > +#endif
> > diff --git a/arch/arm/mach-omap/omap4_generic.c
> b/arch/arm/mach-omap/omap4_generic.c
> > index 6562268..ee62cf2 100644
> > --- a/arch/arm/mach-omap/omap4_generic.c
> > +++ b/arch/arm/mach-omap/omap4_generic.c
> > @@ -8,6 +8,9 @@
> > A #include <mach/xload.h>
> > A #include <mach/gpmc.h>
> > A #include <mach/gpio.h>
> > +#ifdef CONFIG_OMAP4_USBBOOT
> > +#include <mach/omap4_rom_usb.h>
> > +#endif
> >
> > A /*
> > A * A The following several lines are taken from U-Boot to support
> > @@ -457,6 +460,15 @@ static int watchdog_init(void)
> > A }
> > A late_initcall(watchdog_init);
> >
> > +#ifdef CONFIG_OMAP4_USBBOOT
> > +static int omap4_usbboot_init(void)
> > +{
> > + A A omap4_usbboot_open();
> > + A A omap4_usbboot_puts("USB communications initialized\n");
> > + A A return 0;
> > +}
> > +postcore_initcall(omap4_usbboot_init);
> > +#else
> > A static int omap_vector_init(void)
> > A {
> > A A A __asm__ __volatile__ (
> > @@ -470,6 +482,7 @@ static int omap_vector_init(void)
> > A A A return 0;
> > A }
> > A core_initcall(omap_vector_init);
> > +#endif
> need more explanation here
> >
> > A #define OMAP4_TRACING_VECTOR3 0x4030d048
> >
> > diff --git a/arch/arm/mach-omap/omap4_rom_usb.c
> b/arch/arm/mach-omap/omap4_rom_usb.c
> > new file mode 100644
> > index 0000000..741f2b7
> > --- /dev/null
> > +++ b/arch/arm/mach-omap/omap4_rom_usb.c
> > @@ -0,0 +1,186 @@
> > +/*
> > + * This code is based on:
> > + * git://github.com/swetland/omap4boot.git
> > + */
> > +/*
> > + * Copyright (C) 2010 The Android Open Source Project
> > + * All rights reserved.
> > + *
> > + * Redistribution and use in source and binary forms, with or without
> > + * modification, are permitted provided that the following conditions
> > + * are met:
> > + * A * Redistributions of source code must retain the above copyright
> > + * A A notice, this list of conditions and the following disclaimer.
> > + * A * Redistributions in binary form must reproduce the above
> copyright
> > + * A A notice, this list of conditions and the following disclaimer
> in
> > + * A A the documentation and/or other materials provided with the
> > + * A A distribution.
> > + *
> > + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
> CONTRIBUTORS
> > + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> > + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
> > + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
> > + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
> INDIRECT,
> > + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
> (INCLUDING,
> > + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
> LOSS
> > + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
> > + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
> LIABILITY,
> > + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
> > + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> > + * SUCH DAMAGE.
> > + */
> > +
> > +#include <common.h>
> > +#include <mach/omap4-silicon.h>
> > +#include <mach/omap4_rom_usb.h>
> > +
> > +struct omap4_usbboot *omap4_usbboot_pdata;
> > +
> > +int omap4_usbboot_open(void)
> > +{
> > + A A int (*rom_get_per_driver)(struct per_driver **io, u32
> device_type);
> > + A A int (*rom_get_per_device)(struct per_handle **rh);
> > + A A struct per_handle *boot;
> > + A A int n;
> > + A A u32 base;
> > +
> > + A A if (omap4_revision() >= OMAP4460_ES1_0)
> > + A A A A A A base = PUBLIC_API_BASE_4460;
> > + A A else
> > + A A A A A A base = PUBLIC_API_BASE_4430;
> > +
> > + A A rom_get_per_driver = API(base + PUBLIC_GET_DRIVER_PER_OFFSET);
> > + A A rom_get_per_device = API(base + PUBLIC_GET_DEVICE_PER_OFFSET);
> > +
> > + A A n = rom_get_per_device(&boot);
> > + A A if (n)
> > + A A A A A A return n;
> > +
> > + A A if ((boot->device_type != DEVICE_USB) &&
> > + A A A A (boot->device_type != DEVICE_USBEXT))
> > + A A A A A A return -1;
> > +
> > + A A omap4_usbboot_pdata = xzalloc(sizeof(struct omap4_usbboot));
> > + A A n = rom_get_per_driver(&omap4_usbboot_pdata->io,
> boot->device_type);
> > + A A if (n)
> > + A A A A A A return n;
> > +
> > + A A omap4_usbboot_pdata->dread.status = -1;
> > + A A omap4_usbboot_pdata->dread.xfer_mode = boot->xfer_mode;
> > + A A omap4_usbboot_pdata->dread.options = boot->options;
> > + A A omap4_usbboot_pdata->dread.device_type = boot->device_type;
> > +
> > + A A omap4_usbboot_pdata->dwrite.status = -1;
> > + A A omap4_usbboot_pdata->dwrite.xfer_mode = boot->xfer_mode;
> > + A A omap4_usbboot_pdata->dwrite.options = boot->options;
> > + A A omap4_usbboot_pdata->dwrite.device_type = boot->device_type;
> > + A A __asm__ __volatile__ ("cpsie i\n");
> > + A A return 0;
> > +}
> > +
> > +
> > +static void rom_read_callback(struct per_handle *rh)
> > +{
> > + A A omap4_usbboot_pdata->dread.status = rh->status;
> > + A A return;
> > +}
> > +
> > +void omap4_usbboot_queue_read(void *data, unsigned len)
> > +{
> > + A A int n;
> > + A A omap4_usbboot_pdata->dread.data = data;
> > + A A omap4_usbboot_pdata->dread.length = len;
> > + A A omap4_usbboot_pdata->dread.status = STATUS_WAITING;
> > + A A omap4_usbboot_pdata->dread.xfer_mode = 1;
> > + A A omap4_usbboot_pdata->dread.callback = rom_read_callback;
> > + A A n =
> omap4_usbboot_pdata->io->read(&omap4_usbboot_pdata->dread);
> > + A A if (n)
> > + A A A A A A omap4_usbboot_pdata->dread.status = n;
> > +}
> > +
> > +int omap4_usbboot_wait_read(void)
> > +{
> > + A A int ret;
> > + A A while (omap4_usbboot_pdata->dread.status == STATUS_WAITING)
> > + A A A A A A /* cpu_relax(); */
> > + A A A A A A barrier();
> > + A A ret = omap4_usbboot_pdata->dread.status;
> > + A A omap4_usbboot_pdata->dread.status = -1;
> > + A A return ret;
> > +}
> > +int omap4_usbboot_is_read_waiting(void)
> > +{
> > + A A barrier();
> > + A A return omap4_usbboot_pdata->dread.status == STATUS_WAITING;
> > +}
> > +int omap4_usbboot_is_read_ok(void)
> > +{
> > + A A barrier();
> > + A A return omap4_usbboot_pdata->dread.status == STATUS_OKAY;
> > +}
> > +
> > +static void rom_write_callback(struct per_handle *rh)
> > +{
> > + A A omap4_usbboot_pdata->dwrite.status = rh->status;
> > + A A return;
> > +}
> > +
> > +void omap4_usbboot_queue_write(void *data, unsigned len)
> > +{
> > + A A int n;
> > + A A omap4_usbboot_pdata->dwrite.data = data;
> > + A A omap4_usbboot_pdata->dwrite.length = len;
> > + A A omap4_usbboot_pdata->dwrite.status = STATUS_WAITING;
> > + A A omap4_usbboot_pdata->dwrite.xfer_mode = 1;
> > + A A omap4_usbboot_pdata->dwrite.callback = rom_write_callback;
> > + A A n =
> omap4_usbboot_pdata->io->write(&omap4_usbboot_pdata->dwrite);
> > + A A if (n)
> > + A A A A A A omap4_usbboot_pdata->dwrite.status = n;
> > +}
> > +
> > +int omap4_usbboot_wait_write(void)
> > +{
> > + A A int ret;
> > + A A while (omap4_usbboot_pdata->dwrite.status == STATUS_WAITING)
> > + A A A A A A /* cpu_relax(); */
> > + A A A A A A barrier();
> > + A A ret = omap4_usbboot_pdata->dwrite.status;
> > + A A omap4_usbboot_pdata->dwrite.status = -1;
> > + A A return ret;
> > +}
> > +
> > +#define USB_MAX_IO 65536
> > +int omap4_usbboot_read(void *data, unsigned len)
> > +{
> > + A A unsigned xfer;
> > + A A unsigned char *x = data;
> > + A A int n;
> > + A A while (len > 0) {
> > + A A A A A A xfer = (len > USB_MAX_IO) ? USB_MAX_IO : len;
> > + A A A A A A omap4_usbboot_queue_read(x, xfer);
> > + A A A A A A n = omap4_usbboot_wait_read();
> > + A A A A A A if (n)
> > + A A A A A A A A A A return n;
> > + A A A A A A x += xfer;
> > + A A A A A A len -= xfer;
> > + A A }
> > + A A return 0;
> > +}
> > +
> > +int omap4_usbboot_write(void *data, unsigned len)
> > +{
> > + A A omap4_usbboot_queue_write(data, len);
> > + A A return omap4_usbboot_wait_write();
> > +}
> > +
> > +void omap4_usbboot_close(void)
> > +{
> > + A A omap4_usbboot_pdata->io->close(&omap4_usbboot_pdata->dread);
> > +}
> > +
> > +void omap4_usbboot_puts(const char *s)
> > +{
> > + A A u32 c;
> > + A A while ((c = *s++))
> > + A A A A A A omap4_usbboot_write(&c, 4);
> > +}
> can you put a device driver for this
> > diff --git a/scripts/.gitignore b/scripts/.gitignore
> > index 6e63f85..4fb5a1f 100644
> > --- a/scripts/.gitignore
> > +++ b/scripts/.gitignore
> > @@ -5,3 +5,4 @@ kallsyms
> > A mkimage
> > A mkublheader
> > A omap_signGP
> > +omap4_usbboot
> > diff --git a/scripts/Makefile b/scripts/Makefile
> > index 7ca5e29..6c1b113 100644
> > --- a/scripts/Makefile
> > +++ b/scripts/Makefile
> > @@ -4,6 +4,8 @@
> > A #
> ---------------------------------------------------------------------------
> > A # kallsyms: A A A Find all symbols in barebox
> >
> > +HOSTLDFLAGS A += -lpthread
> > +
> no the -lpthread is for omap4_usbboot target olny
>
> is HOSTLOADLIBES_omap4_usbboot
> and HOSTCFLAGS_omap4_usbboot.o for specifc header and lib
> > A hostprogs-$(CONFIG_KALLSYMS) A A += kallsyms
> > A hostprogs-y A A A A A A A A A A A += bin2c
> > A hostprogs-y A A A A A A A A A A A += mkimage
> > @@ -12,6 +14,8 @@ hostprogs-$(CONFIG_ARCH_NETX) A A += gen_netx_image
> > A hostprogs-$(CONFIG_ARCH_OMAP) A A += omap_signGP
> > A hostprogs-$(CONFIG_ARCH_S5PCxx) A += s5p_cksum
> > A hostprogs-$(CONFIG_ARCH_DAVINCI) += mkublheader
> > +hostprogs-$(CONFIG_OMAP4_USBBOOT)+= omap4_usbboot
> > +omap4_usbboot-objs A A A A A A A := usb_linux.o
> omap4_usbboot.o
> >
> > A always A A A A A A A := $(hostprogs-y) $(hostprogs-m)
> >
> > diff --git a/scripts/omap4_usbboot.c b/scripts/omap4_usbboot.c
> > new file mode 100644
> > index 0000000..aa11759
> > --- /dev/null
> > +++ b/scripts/omap4_usbboot.c
> > @@ -0,0 +1,416 @@
> > +/*
> > + * This program is free software; you can redistribute it and/or
> > + * modify it under the terms of the GNU General Public License
> > + * version 2 as published by the Free Software Foundation.
> > + *
> > + * 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. A 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 <stdio.h>
> > +#include <stdlib.h>
> > +#include <unistd.h>
> > +#include <sys/stat.h>
> > +#include <stdint.h>
> > +#include <fcntl.h>
> > +#include <string.h>
> > +#include <sys/mman.h>
> > +#include <pthread.h>
> > +#include <termios.h>
> > +
> > +#include "usb.h"
> > +
> > +#define USBBOOT_FS_MAGIC A A 0x5562464D
> > +#define USBBOOT_FS_CMD_OPEN A 0x46530000
> > +#define USBBOOT_FS_CMD_CLOSE 0x46530001
> > +#define USBBOOT_FS_CMD_READ A 0x46530002
> > +#define USBBOOT_FS_CMD_END A 0x4653FFFF
> > +#define MAX_OPEN_FILES A A A 1000
> > +
> > +#define RESET A 0
> > +#define BRIGHT A 1
> > +#define WHITE A 8
> > +#define RED A A 1
> > +#define BLACK A 0
> > +#define FORMAT A A A A "%c[%d;%d;%dm"
> > +#define TARGET_FORMAT 0x1B, BRIGHT, RED+30, BLACK+40
> > +#define HOST_FORMAT A 0x1B, RESET, WHITE+30, BLACK+40
> > +#define host_print(fmt, arg...) A A A printf(FORMAT fmt FORMAT"\n",
> \
> > + A A A A A A A A A A A A A A A A A A HOST_FORMAT,
> ##arg, TARGET_FORMAT)
> > +
> > +struct thread_vars {
> > + A A struct usb_handle *usb;
> > + A A int hide;
> > + A A struct termios to;
> > +};
> > +void *listenerTask(void *argument)
> > +{
> > + A A struct thread_vars *vars = argument;
> > + A A int c;
> > + A A for (;;) {
> > + A A A A A A c = getchar();
> > + A A A A A A if (c == EOF)
> > + A A A A A A A A A A return NULL;
> > + A A A A A A while (vars->hide)
> > + A A A A A A A A A A usleep(10000);
> > + A A A A A A if (usb_write(vars->usb, &c, 4) != 4) {
> > + A A A A A A A A A A host_print("could not send '%c' to
> target", c);
> > + A A A A A A A A A A tcsetattr(STDIN_FILENO, TCSANOW,
> &vars->to);
> > + A A A A A A A A A A exit(1);
> > + A A A A A A }
> > + A A }
> > + A A return NULL;
> > +}
> > +struct file_data {
> > + A A size_t size;
> > + A A void *data;
> > +};
> > +
> > +int read_asic_id(struct usb_handle *usb)
> > +{
> > +#define LINEWIDTH 16
> > + A A const uint32_t msg_getid = 0xF0030003;
> > + A A int i, j, k, ret;
> > + A A uint8_t id[81];
> > + A A char line[LINEWIDTH*3+8];
> > +
> > + A A printf("reading ASIC ID\n");
> > + A A memset(id , 0xee, sizeof(id));
> > + A A if (usb_write(usb, &msg_getid, sizeof(msg_getid)) !=
> > + A A A A A A sizeof(msg_getid)
> > + A A ) {
> > + A A A A A A printf("Could not send msg_getid request\n");
> > + A A A A A A return -1;
> > + A A }
> > + A A if (usb_read(usb, id, sizeof(id)) != sizeof(id)) {
> > + A A A A A A printf("Could not read msg_getid answer\n");
> > + A A A A A A return -1;
> > + A A }
> > + A A for (i = 0; i < sizeof(id); i += LINEWIDTH) {
> > + A A A A A A sprintf(line, "%02X: ", i);
> > + A A A A A A for (j = 0; j < LINEWIDTH && j < sizeof(id)-i;
> j++)
> > + A A A A A A A A A A sprintf(line+4+j*3, "%02X ", id[i+j]);
> > + A A A A A A line[4+j*3+0] = '\n';
> > + A A A A A A line[4+j*3+1] = 0;
> > + A A A A A A printf(line);
> > + A A }
> > + A A ret = 0;
> > + A A for (i = 1, j = 0; i < sizeof(id) && j < id[0]; i +=
> 2+id[i+1], j++) {
> > + A A A A A A if (i+2+id[i+1] > sizeof(id)) {
> > + A A A A A A A A A A printf("Truncated subblock\n");
> > + A A A A A A A A A A ret++;
> > + A A A A A A A A A A continue;
> > + A A A A A A }
> > + A A A A A A switch (id[i]) {
> > + A A A A A A case 0x01: /* ID subblock */
> > + A A A A A A A A A A if (id[i+1] != 0x05) {
> > + A A A A A A A A A A A A A A printf("Unexpected ID
> subblock size\n");
> > + A A A A A A A A A A A A A A ret++;
> > + A A A A A A A A A A A A A A continue;
> > + A A A A A A A A A A }
> > + A A A A A A A A A A if (id[i+2] != 0x01)
> > + A A A A A A A A A A A A A A printf("Unexpected fixed
> value\n");
> > + A A A A A A A A A A k = (id[i+3]<<8) | id[i+4];
> > + A A A A A A A A A A switch (k) {
> > + A A A A A A A A A A case 0x4440:
> > + A A A A A A A A A A A A A A printf("OMAP 4460
> Device\n");
> > + A A A A A A A A A A A A A A break;
> > + A A A A A A A A A A default:
> > + A A A A A A A A A A A A A A printf("Unknown
> Device\n");
> > + A A A A A A A A A A A A A A break;
> > + A A A A A A A A A A }
> > + A A A A A A A A A A switch (id[i+5]) {
> > + A A A A A A A A A A case 0x07:
> > + A A A A A A A A A A A A A A printf("CH enabled (read
> from eFuse)\n");
> > + A A A A A A A A A A A A A A break;
> > + A A A A A A A A A A case 0x17:
> > + A A A A A A A A A A A A A A printf("CH disabled (read
> from eFuse)\n");
> > + A A A A A A A A A A A A A A break;
> > + A A A A A A A A A A default:
> > + A A A A A A A A A A A A A A printf("Unknown CH
> setting\n");
> > + A A A A A A A A A A A A A A break;
> > + A A A A A A A A A A }
> > + A A A A A A A A A A printf("Rom version: %hhu\n",
> id[i+6]);
> > + A A A A A A A A A A break;
> > + A A A A A A case 0x15: /* Checksum subblock */
> > + A A A A A A A A A A if (id[i+1] != 0x09) {
> > + A A A A A A A A A A A A A A printf("Unexpected
> Checksum subblock size\n");
> > + A A A A A A A A A A A A A A ret++;
> > + A A A A A A A A A A A A A A continue;
> > + A A A A A A A A A A }
> > + A A A A A A A A A A if (id[i+2] != 0x01)
> > + A A A A A A A A A A A A A A printf("Unexpected fixed
> value\n");
> > + A A A A A A A A A A k = (id[i+3]<<24) | (id[i+4]<<16) |
> > + A A A A A A A A A A A A A A (id[i+5]<<8) | id[i+6];
> > + A A A A A A A A A A printf("Rom CRC: 0x%08X\n", k);
> > + A A A A A A A A A A k = (id[i+7]<<24) | (id[i+8]<<16) |
> > + A A A A A A A A A A A A A A (id[i+9]<<8) | id[i+10];
> > + A A A A A A A A A A switch (k) {
> > + A A A A A A A A A A case A 0:
> > + A A A A A A A A A A A A A A printf("A GP device\n");
> > + A A A A A A A A A A A A A A break;
> > + A A A A A A A A A A default:
> > + A A A A A A A A A A A A A A printf("Unknown
> device\n");
> > + A A A A A A A A A A A A A A break;
> > + A A A A A A A A A A }
> > + A A A A A A A A A A break;
> > + A A A A A A }
> > + A A }
> > + A A if (i != sizeof(id) || j != id[0]) {
> > + A A A A A A printf("Unexpected ASIC ID structure size.\n");
> > + A A A A A A ret++;
> > + A A }
> > + A A return ret;
> > +}
> > +
> > +int process_file(
> > + A A struct usb_handle *usb, const char *rootfs, struct file_data
> *fd_vector)
> > +{
> > + A A uint32_t i, j, pos, size;
> > + A A struct stat s;
> > + A A int fd, ret;
> > + A A char line[256];
> > +
> > + A A if (usb_read(usb, &i, 4) != 4) {
> > + A A A A A A host_print("USB error");
> > + A A A A A A exit(1);
> > + A A }
> > + A A ret = 0;
> > + A A switch (i) {
> > + A A case USBBOOT_FS_CMD_OPEN:
> > + A A A A A A for (j = 0; rootfs[j]; j++)
> > + A A A A A A A A A A line[j] = rootfs[j];
> > + A A A A A A for (;; j++) {
> > + A A A A A A A A A A if (usb_read(usb, &i, 4) != 4) {
> > + A A A A A A A A A A A A A A host_print("USB error");
> > + A A A A A A A A A A A A A A exit(1);
> > + A A A A A A A A A A }
> > + A A A A A A A A A A if (i == USBBOOT_FS_CMD_END) {
> > + A A A A A A A A A A A A A A line[j] = 0;
> > + A A A A A A A A A A A A A A break;
> > + A A A A A A A A A A } else if (i > 0xFF) {
> > + A A A A A A A A A A A A A A host_print("Error in
> filename");
> > + A A A A A A A A A A A A A A ret++;
> > + A A A A A A A A A A A A A A line[j] = 0;
> > + A A A A A A A A A A A A A A break;
> > + A A A A A A A A A A } else
> > + A A A A A A A A A A A A A A line[j] = i;
> > + A A A A A A }
> > + A A A A A A for (i = 0; i < MAX_OPEN_FILES &&
> fd_vector[i].data; i++)
> > + A A A A A A A A A A ;
> > + A A A A A A if (i >= MAX_OPEN_FILES) {
> > + A A A A A A A A A A host_print("MAX_OPEN_FILES exceeded");
> > + A A A A A A A A A A ret++;
> > + A A A A A A A A A A goto open_error_1;
> > + A A A A A A }
> > + A A A A A A fd = open(line, O_RDONLY);
> > + A A A A A A if (fd < 0) {
> > + A A A A A A A A A A host_print("cannot open '%s'", line);
> > + A A A A A A A A A A ret++;
> > + A A A A A A A A A A goto open_error_1;
> > + A A A A A A }
> > + A A A A A A if (fstat(fd, &s)) {
> > + A A A A A A A A A A host_print("cannot stat '%s'", line);
> > + A A A A A A A A A A ret++;
> > + A A A A A A A A A A goto open_error_2;
> > + A A A A A A }
> > + A A A A A A fd_vector[i].data = mmap(NULL, s.st_size,
> PROT_READ,
> > + A A A A A A A A A A MAP_PRIVATE, fd, 0);
> > + A A A A A A if (fd_vector[i].data == MAP_FAILED) {
> > + A A A A A A A A A A host_print("cannot mmap '%s'", line);
> > + A A A A A A A A A A ret++;
> > + A A A A A A A A A A goto open_error_2;
> > + A A A A A A }
> > + A A A A A A close(fd);
> > + A A A A A A fd_vector[i].size = size = s.st_size;
> > + A A A A A A fd = i;
> > + A A A A A A goto open_ok;
> > +
> > +open_error_2:
> > + A A A A A A close(fd);
> > +open_error_1:
> > + A A A A A A fd_vector[i].size = size = 0;
> > + A A A A A A fd = -1;
> > +open_ok:
> > + A A A A A A if (usb_write(usb, &fd, 4) != 4 ||
> > + A A A A A A A A A A usb_write(usb, &size, 4) != 4
> > + A A A A A A ) {
> > + A A A A A A A A A A host_print("could not send file size
> to target");
> > + A A A A A A A A A A exit(1);
> > + A A A A A A }
> > + A A A A A A break;
> > + A A case USBBOOT_FS_CMD_CLOSE:
> > + A A A A A A if (usb_read(usb, &i, 4) != 4) {
> > + A A A A A A A A A A host_print("USB error");
> > + A A A A A A A A A A exit(1);
> > + A A A A A A }
> > + A A A A A A if (i >= MAX_OPEN_FILES || !fd_vector[i].data) {
> > + A A A A A A A A A A host_print("invalid close index");
> > + A A A A A A A A A A ret++;
> > + A A A A A A A A A A break;
> > + A A A A A A }
> > + A A A A A A if (usb_read(usb, &j, 4) != 4) {
> > + A A A A A A A A A A host_print("USB error");
> > + A A A A A A A A A A exit(1);
> > + A A A A A A }
> > + A A A A A A if (j != USBBOOT_FS_CMD_END) {
> > + A A A A A A A A A A host_print("invalid close");
> > + A A A A A A A A A A ret++;
> > + A A A A A A A A A A break;
> > + A A A A A A }
> > + A A A A A A munmap(fd_vector[i].data, fd_vector[i].size);
> > + A A A A A A fd_vector[i].data = NULL;
> > + A A A A A A break;
> > + A A case USBBOOT_FS_CMD_READ:
> > + A A A A A A if (usb_read(usb, &i, 4) != 4) {
> > + A A A A A A A A A A host_print("USB error");
> > + A A A A A A A A A A exit(1);
> > + A A A A A A }
> > + A A A A A A if (i >= MAX_OPEN_FILES || !fd_vector[i].data) {
> > + A A A A A A A A A A host_print("invalid read index");
> > + A A A A A A A A A A ret++;
> > + A A A A A A A A A A break;
> > + A A A A A A }
> > + A A A A A A if (usb_read(usb, &pos, 4) != 4) {
> > + A A A A A A A A A A host_print("USB error");
> > + A A A A A A A A A A exit(1);
> > + A A A A A A }
> > + A A A A A A if (pos >= fd_vector[i].size) {
> > + A A A A A A A A A A host_print("invalid read pos");
> > + A A A A A A A A A A ret++;
> > + A A A A A A A A A A break;
> > + A A A A A A }
> > + A A A A A A if (usb_read(usb, &size, 4) != 4) {
> > + A A A A A A A A A A host_print("USB error");
> > + A A A A A A A A A A exit(1);
> > + A A A A A A }
> > + A A A A A A if (pos+size > fd_vector[i].size) {
> > + A A A A A A A A A A host_print("invalid read size");
> > + A A A A A A A A A A ret++;
> > + A A A A A A A A A A break;
> > + A A A A A A }
> > + A A A A A A if (usb_read(usb, &j, 4) != 4) {
> > + A A A A A A A A A A host_print("USB error");
> > + A A A A A A A A A A exit(1);
> > + A A A A A A }
> > + A A A A A A if (j != USBBOOT_FS_CMD_END) {
> > + A A A A A A A A A A host_print("invalid read");
> > + A A A A A A A A A A ret++;
> > + A A A A A A A A A A break;
> > + A A A A A A }
> > + A A A A A A if (usb_write(usb, fd_vector[i].data+pos, size) !=
> size) {
> > + A A A A A A A A A A host_print("could not send file to
> target");
> > + A A A A A A A A A A exit(1);
> > + A A A A A A }
> > + A A A A A A break;
> > + A A case USBBOOT_FS_CMD_END:
> > + A A default:
> > + A A A A A A host_print("Unknown filesystem command");
> > + A A A A A A ret++;
> > + A A A A A A break;
> > + A A }
> > + A A return ret;
> > +}
> > +
> > +int usb_boot(
> > + A A struct usb_handle *usb, void *data, unsigned sz, const char
> *rootfs)
> > +{
> > + A A const uint32_t msg_boot A = 0xF0030002;
> > + A A uint32_t msg_size = sz;
> > + A A int i;
> > + A A pthread_t thread;
> > + A A struct thread_vars vars;
> > + A A struct termios tn;
> > + A A struct file_data fd_vector[MAX_OPEN_FILES];
> > +
> > + A A read_asic_id(usb);
> > +
> > + A A printf("sending xload to target...\n");
> > + A A usb_write(usb, &msg_boot, sizeof(msg_boot));
> > + A A usb_write(usb, &msg_size, sizeof(msg_size));
> > + A A usb_write(usb, data, sz);
> > + A A munmap(data, msg_size);
> > + A A for (i = 0; i < MAX_OPEN_FILES; i++)
> > + A A A A A A fd_vector[i].data = NULL;
> > +
> > + A A vars.usb = usb;
> > + A A vars.hide = 0;
> > + A A tcgetattr(STDIN_FILENO, &vars.to);
> > + A A tn = vars.to;
> > + A A tn.c_lflag &= ~(ICANON | ECHO);
> > + A A printf(FORMAT, TARGET_FORMAT);
> > + A A tcsetattr(STDIN_FILENO, TCSANOW, &tn);
> > + A A if (pthread_create(&thread, NULL, listenerTask, &vars))
> > + A A A A A A host_print("listenerTask failed");
> > + A A for (;;) {
> > + A A A A A A if (usb_read(usb, &i, 4) != 4)
> > + A A A A A A A A A A break;
> > + A A A A A A if (i == USBBOOT_FS_MAGIC) {
> > + A A A A A A A A A A vars.hide = 1;
> > + A A A A A A A A A A process_file(usb, rootfs, fd_vector);
> > + A A A A A A A A A A vars.hide = 0;
> > + A A A A A A A A A A continue;
> > + A A A A A A }
> > + A A A A A A printf("%c", i);
> > + A A A A A A fflush(stdout);
> > + A A }
> > + A A tcsetattr(STDIN_FILENO, TCSANOW, &vars.to);
> > + A A return 0;
> > +}
> > +
> > +int match_omap4_bootloader(struct usb_ifc_info *ifc)
> > +{
> > + A A if (ifc->dev_vendor != 0x0451)
> > + A A A A A A return -1;
> > + A A if ((ifc->dev_product != 0xD010) && (ifc->dev_product !=
> 0xD00F))
> > + A A A A A A return -1;
> > + A A return 0;
> > +}
> > +
> > +int main(int argc, char **argv)
> > +{
> > + A A void *data;
> > + A A unsigned sz;
> > + A A struct stat s;
> > + A A int fd;
> > + A A struct usb_handle *usb;
> > + A A int once;
> > +
> > + A A if (argc != 3) {
> > + A A A A A A printf("usage: %s <xloader> <rootfs>\n", argv[0]);
> > + A A A A A A return 0;
> > + A A }
> > + A A argv++;
> > + A A fd = open(argv[0], O_RDONLY);
> > + A A if (fd < 0 || fstat(fd, &s)) {
> > + A A A A A A printf("cannot open '%s'\n", argv[0]);
> > + A A A A A A return -1;
> > + A A }
> > + A A data = mmap(NULL, s.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
> > + A A if (data == MAP_FAILED) {
> > + A A A A A A printf("cannot mmap '%s'\n", argv[0]);
> > + A A A A A A return -1;
> > + A A }
> > + A A sz = s.st_size;
> > + A A close(fd);
> > + A A argv++;
> > + A A printf(FORMAT, HOST_FORMAT);
> > + A A for (once = 1;;) {
> > + A A A A A A usb = usb_open(match_omap4_bootloader);
> > + A A A A A A if (usb)
> > + A A A A A A A A A A return usb_boot(usb, data, sz,
> argv[0]);
> > + A A A A A A if (once) {
> > + A A A A A A A A A A once = 0;
> > + A A A A A A A A A A printf("waiting for OMAP44xx
> device...\n");
> > + A A A A A A }
> > + A A A A A A usleep(250000);
> > + A A }
> > + A A return -1;
> > +}
> > diff --git a/scripts/usb.h b/scripts/usb.h
> > new file mode 100644
> > index 0000000..d50aa6a
> > --- /dev/null
> > +++ b/scripts/usb.h
> > @@ -0,0 +1,61 @@
> > +/*
> > + * Copyright (C) 2008 The Android Open Source Project
> > + * All rights reserved.
> > + *
> > + * Redistribution and use in source and binary forms, with or without
> > + * modification, are permitted provided that the following conditions
> > + * are met:
> > + * A * Redistributions of source code must retain the above copyright
> > + * A A notice, this list of conditions and the following disclaimer.
> > + * A * Redistributions in binary form must reproduce the above
> copyright
> > + * A A notice, this list of conditions and the following disclaimer
> in
> > + * A A the documentation and/or other materials provided with the
> > + * A A distribution.
> > + *
> > + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
> CONTRIBUTORS
> > + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> > + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
> > + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
> > + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
> INDIRECT,
> > + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
> (INCLUDING,
> > + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
> LOSS
> > + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
> > + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
> LIABILITY,
> > + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
> > + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> > + * SUCH DAMAGE.
> > + */
> > +
> > +#ifndef _USB_H_
> > +#define _USB_H_
> > +
> > +struct usb_ifc_info {
> > + A A /* from device descriptor */
> > + A A unsigned short dev_vendor;
> > + A A unsigned short dev_product;
> > +
> > + A A unsigned char dev_class;
> > + A A unsigned char dev_subclass;
> > + A A unsigned char dev_protocol;
> > +
> > + A A unsigned char ifc_class;
> > + A A unsigned char ifc_subclass;
> > + A A unsigned char ifc_protocol;
> > +
> > + A A unsigned char has_bulk_in;
> > + A A unsigned char has_bulk_out;
> > +
> > + A A unsigned char writable;
> > +
> > + A A char serial_number[256];
> > +};
> > +
> > +typedef int (*ifc_match_func)(struct usb_ifc_info *ifc);
> > +
> > +struct usb_handle *usb_open(ifc_match_func callback);
> > +int usb_close(struct usb_handle *h);
> > +int usb_read(struct usb_handle *h, void *_data, int len);
> > +int usb_write(struct usb_handle *h, const void *_data, int len);
> > +
> > +
> > +#endif
> > diff --git a/scripts/usb_linux.c b/scripts/usb_linux.c
> > new file mode 100644
> > index 0000000..43529aa
> > --- /dev/null
> > +++ b/scripts/usb_linux.c
> > @@ -0,0 +1,397 @@
> > +/*
> > + * Copyright (C) 2008 The Android Open Source Project
> > + * All rights reserved.
> > + *
> > + * Redistribution and use in source and binary forms, with or without
> > + * modification, are permitted provided that the following conditions
> > + * are met:
> > + * A * Redistributions of source code must retain the above copyright
> > + * A A notice, this list of conditions and the following disclaimer.
> > + * A * Redistributions in binary form must reproduce the above
> copyright
> > + * A A notice, this list of conditions and the following disclaimer
> in
> > + * A A the documentation and/or other materials provided with the
> > + * A A distribution.
> > + *
> > + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
> CONTRIBUTORS
> > + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> > + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
> > + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
> > + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
> INDIRECT,
> > + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
> (INCLUDING,
> > + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
> LOSS
> > + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
> > + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
> LIABILITY,
> > + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
> > + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> > + * SUCH DAMAGE.
> > + */
> > +
> > +#include <stdio.h>
> > +#include <stdlib.h>
> > +#include <unistd.h>
> > +#include <string.h>
> > +
> > +#include <sys/ioctl.h>
> > +#include <sys/types.h>
> > +#include <dirent.h>
> > +#include <fcntl.h>
> > +#include <errno.h>
> > +#include <pthread.h>
> > +#include <ctype.h>
> > +
> > +#include <linux/usbdevice_fs.h>
> > +#include <linux/usbdevice_fs.h>
> > +#include <linux/version.h>
> > +#include <linux/usb/ch9.h>
> > +#include <asm/byteorder.h>
> > +
> > +#include "usb.h"
> > +
> > +#define MAX_RETRIES 5
> > +
> > +#ifdef TRACE_USB
> > +#define DBG1(x...) fprintf(stderr, x)
> > +#define DBG(x...) fprintf(stderr, x)
> > +#else
> > +#define DBG(x...)
> > +#define DBG1(x...)
> > +#endif
> > +
> > +struct usb_handle {
> > + A A char fname[64];
> > + A A int desc;
> > + A A unsigned char ep_in;
> > + A A unsigned char ep_out;
> > +};
> > +
> > +static inline int badname(const char *name)
> > +{
> > + A A while (*name) {
> > + A A A A A A if (!isdigit(*name++))
> > + A A A A A A A A A A return 1;
> > + A A }
> > + A A return 0;
> > +}
> > +
> > +static int check(void *_desc, int len, unsigned type, int size)
> > +{
> > + A A unsigned char *desc = _desc;
> > +
> > + A A if (len < size)
> > + A A A A A A return -1;
> > + A A if (desc[0] < size)
> > + A A A A A A return -1;
> > + A A if (desc[0] > len)
> > + A A A A A A return -1;
> > + A A if (desc[1] != type)
> > + A A A A A A return -1;
> > +
> > + A A return 0;
> > +}
> > +
> > +static int filter_usb_device(int fd, char *ptr, int len, int
> writable,
> > + A A ifc_match_func callback, int *ept_in_id, int *ept_out_id, int
> *ifc_id)
> > +{
> > + A A struct usb_device_descriptor *dev;
> > + A A struct usb_config_descriptor *cfg;
> > + A A struct usb_interface_descriptor *ifc;
> > + A A struct usb_endpoint_descriptor *ept;
> > + A A struct usb_ifc_info info;
> > +
> > + A A int in, out;
> > + A A unsigned i;
> > + A A unsigned e;
> > +
> > + A A if (check(ptr, len, USB_DT_DEVICE, USB_DT_DEVICE_SIZE))
> > + A A A A A A return -1;
> > + A A dev = (void *) ptr;
> > + A A len -= dev->bLength;
> > + A A ptr += dev->bLength;
> > +
> > + A A if (check(ptr, len, USB_DT_CONFIG, USB_DT_CONFIG_SIZE))
> > + A A A A A A return -1;
> > + A A cfg = (void *) ptr;
> > + A A len -= cfg->bLength;
> > + A A ptr += cfg->bLength;
> > +
> > + A A info.dev_vendor = dev->idVendor;
> > + A A info.dev_product = dev->idProduct;
> > + A A info.dev_class = dev->bDeviceClass;
> > + A A info.dev_subclass = dev->bDeviceSubClass;
> > + A A info.dev_protocol = dev->bDeviceProtocol;
> > + A A info.writable = writable;
> > +
> > + A A /* read device serial number (if there is one) */
> > + A A info.serial_number[0] = 0;
> > + A A if (dev->iSerialNumber) {
> > + A A A A A A struct usbdevfs_ctrltransfer A ctrl;
> > + A A A A A A __u16 buffer[128];
> > + A A A A A A int result;
> > +
> > + A A A A A A memset(buffer, 0, sizeof(buffer));
> > +
> > + A A A A A A ctrl.bRequestType = USB_DIR_IN|
> > + A A A A A A A A A A USB_TYPE_STANDARD|USB_RECIP_DEVICE;
> > + A A A A A A ctrl.bRequest = USB_REQ_GET_DESCRIPTOR;
> > + A A A A A A ctrl.wValue = (USB_DT_STRING << 8) |
> dev->iSerialNumber;
> > + A A A A A A ctrl.wIndex = 0;
> > + A A A A A A ctrl.wLength = sizeof(buffer);
> > + A A A A A A ctrl.data = buffer;
> > + A A A A A A ctrl.timeout = 50;
> > +
> > + A A A A A A result = ioctl(fd, USBDEVFS_CONTROL, &ctrl);
> > + A A A A A A if (result > 0) {
> > + A A A A A A A A A A int i;
> > + A A A A A A A A A A /* skip first word, and copy the rest
> to the serial
> > + A A A A A A A A A A string, changing shorts to bytes. */
> > + A A A A A A A A A A result /= 2;
> > + A A A A A A A A A A for (i = 1; i < result; i++)
> > + A A A A A A A A A A A A A A info.serial_number[i - 1]
> = buffer[i];
> > + A A A A A A A A A A info.serial_number[i - 1] = 0;
> > + A A A A A A }
> > + A A }
> > +
> > + A A for (i = 0; i < cfg->bNumInterfaces; i++) {
> > + A A A A A A if (check(ptr, len, USB_DT_INTERFACE,
> USB_DT_INTERFACE_SIZE))
> > + A A A A A A A A A A return -1;
> > + A A A A A A ifc = (void *) ptr;
> > + A A A A A A len -= ifc->bLength;
> > + A A A A A A ptr += ifc->bLength;
> > +
> > + A A A A A A in = -1;
> > + A A A A A A out = -1;
> > + A A A A A A info.ifc_class = ifc->bInterfaceClass;
> > + A A A A A A info.ifc_subclass = ifc->bInterfaceSubClass;
> > + A A A A A A info.ifc_protocol = ifc->bInterfaceProtocol;
> > +
> > + A A A A A A for (e = 0; e < ifc->bNumEndpoints; e++) {
> > + A A A A A A A A A A if (check(ptr, len, USB_DT_ENDPOINT,
> > + A A A A A A A A A A A A A A USB_DT_ENDPOINT_SIZE)
> > + A A A A A A A A A A )
> > + A A A A A A A A A A A A A A return -1;
> > + A A A A A A A A A A ept = (void *) ptr;
> > + A A A A A A A A A A len -= ept->bLength;
> > + A A A A A A A A A A ptr += ept->bLength;
> > +
> > + A A A A A A A A A A if ((ept->bmAttributes & 0x03) !=
> 0x02)
> > + A A A A A A A A A A A A A A continue;
> > +
> > + A A A A A A A A A A if (ept->bEndpointAddress & 0x80)
> > + A A A A A A A A A A A A A A in =
> ept->bEndpointAddress;
> > + A A A A A A A A A A else
> > + A A A A A A A A A A A A A A out =
> ept->bEndpointAddress;
> > + A A A A A A }
> > +
> > + A A A A A A info.has_bulk_in = (in != -1);
> > + A A A A A A info.has_bulk_out = (out != -1);
> > +
> > + A A A A A A if (callback(&info) == 0) {
> > + A A A A A A A A A A *ept_in_id = in;
> > + A A A A A A A A A A *ept_out_id = out;
> > + A A A A A A A A A A *ifc_id = ifc->bInterfaceNumber;
> > + A A A A A A A A A A return 0;
> > + A A A A A A }
> > + A A }
> > +
> > + A A return -1;
> > +}
> > +
> > +static struct usb_handle *find_usb_device(
> > + A A const char *base, ifc_match_func callback)
> > +{
> > + A A struct usb_handle *usb = 0;
> > + A A char busname[64], devname[64];
> > + A A char desc[1024];
> > + A A int n, in, out, ifc;
> > +
> > + A A DIR *busdir, *devdir;
> > + A A struct dirent *de;
> > + A A int fd;
> > + A A int writable;
> > +
> > + A A busdir = opendir(base);
> > + A A if (busdir == 0)
> > + A A A A A A return 0;
> > +
> > + A A while ((de = readdir(busdir)) && (usb == 0)) {
> > + A A A A A A if (badname(de->d_name))
> > + A A A A A A A A A A continue;
> > +
> > + A A A A A A sprintf(busname, "%s/%s", base, de->d_name);
> > + A A A A A A devdir = opendir(busname);
> > + A A A A A A if (devdir == 0)
> > + A A A A A A A A A A continue;
> > +
> > + A A A A A A /* DBG("[ scanning %s ]\n", busname); */
> > + A A A A A A while ((de = readdir(devdir)) && (usb == 0)) {
> > +
> > + A A A A A A A A A A if (badname(de->d_name))
> > + A A A A A A A A A A A A A A continue;
> > + A A A A A A A A A A sprintf(devname, "%s/%s", busname,
> de->d_name);
> > +
> > + A A A A A A A A A A /* DBG("[ scanning %s ]\n", devname);
> */
> > + A A A A A A A A A A writable = 1;
> > + A A A A A A A A A A fd = open(devname, O_RDWR);
> > + A A A A A A A A A A if (fd < 0) {
> > + A A A A A A A A A A A A A A /* Check if we have
> read-only access,
> > + A A A A A A A A A A A A A A so we can give a helpful
> diagnostic
> > + A A A A A A A A A A A A A A like "adb devices" does.
> */
> > + A A A A A A A A A A A A A A writable = 0;
> > + A A A A A A A A A A A A A A fd = open(devname,
> O_RDONLY);
> > + A A A A A A A A A A A A A A if (fd < 0)
> > + A A A A A A A A A A A A A A A A A A continue;
> > + A A A A A A A A A A }
> > +
> > + A A A A A A A A A A n = read(fd, desc, sizeof(desc));
> > +
> > + A A A A A A A A A A if (filter_usb_device(fd, desc, n,
> writable,
> > + A A A A A A A A A A A A A A callback, &in, &out, &ifc)
> == 0
> > + A A A A A A A A A A ) {
> > + A A A A A A A A A A A A A A usb = calloc(1,
> sizeof(struct usb_handle));
> > + A A A A A A A A A A A A A A strcpy(usb->fname,
> devname);
> > + A A A A A A A A A A A A A A usb->ep_in = in;
> > + A A A A A A A A A A A A A A usb->ep_out = out;
> > + A A A A A A A A A A A A A A usb->desc = fd;
> > +
> > + A A A A A A A A A A A A A A n = ioctl(fd,
> USBDEVFS_CLAIMINTERFACE, &ifc);
> > + A A A A A A A A A A A A A A if (n != 0) {
> > + A A A A A A A A A A A A A A A A A A close(fd);
> > + A A A A A A A A A A A A A A A A A A free(usb);
> > + A A A A A A A A A A A A A A A A A A usb = 0;
> > + A A A A A A A A A A A A A A A A A A continue;
> > + A A A A A A A A A A A A A A }
> > + A A A A A A A A A A } else
> > + A A A A A A A A A A A A A A close(fd);
> > + A A A A A A }
> > + A A A A A A closedir(devdir);
> > + A A }
> > + A A closedir(busdir);
> > +
> > + A A return usb;
> > +}
> > +
> > +int usb_write(struct usb_handle *h, const void *_data, int len)
> > +{
> > + A A unsigned char *data = (unsigned char *) _data;
> > + A A unsigned count = 0;
> > + A A struct usbdevfs_bulktransfer bulk;
> > + A A int n;
> > +
> > + A A if (h->ep_out == 0)
> > + A A A A A A return -1;
> > +
> > + A A if (len == 0) {
> > + A A A A A A bulk.ep = h->ep_out;
> > + A A A A A A bulk.len = 0;
> > + A A A A A A bulk.data = data;
> > + A A A A A A bulk.timeout = 0;
> > +
> > + A A A A A A n = ioctl(h->desc, USBDEVFS_BULK, &bulk);
> > + A A A A A A if (n != 0) {
> > + A A A A A A A A A A fprintf(stderr, "ERROR: n = %d, errno
> = %d (%s)\n",
> > + A A A A A A A A A A n, errno, strerror(errno));
> > + A A A A A A A A A A return -1;
> > + A A A A A A }
> > + A A A A A A return 0;
> > + A A }
> > +
> > + A A while (len > 0) {
> > + A A A A A A int xfer;
> > + A A A A A A xfer = (len > 4096) ? 4096 : len;
> > +
> > + A A A A A A bulk.ep = h->ep_out;
> > + A A A A A A bulk.len = xfer;
> > + A A A A A A bulk.data = data;
> > + A A A A A A bulk.timeout = 0;
> > +
> > + A A A A A A n = ioctl(h->desc, USBDEVFS_BULK, &bulk);
> > + A A A A A A if (n != xfer) {
> > + A A A A A A A A A A DBG("ERROR: n = %d, errno = %d
> (%s)\n",
> > + A A A A A A A A A A A A A A n, errno,
> strerror(errno));
> > + A A A A A A A A A A return -1;
> > + A A A A A A }
> > +
> > + A A A A A A count += xfer;
> > + A A A A A A len -= xfer;
> > + A A A A A A data += xfer;
> > + A A }
> > +
> > + A A return count;
> > +}
> > +
> > +int usb_read(struct usb_handle *h, void *_data, int len)
> > +{
> > + A A unsigned char *data = (unsigned char *) _data;
> > + A A unsigned count = 0;
> > + A A struct usbdevfs_bulktransfer bulk;
> > + A A int n, retry;
> > +
> > + A A if (h->ep_in == 0)
> > + A A A A A A return -1;
> > +
> > + A A while (len > 0) {
> > + A A A A A A int xfer = (len > 4096) ? 4096 : len;
> > +
> > + A A A A A A bulk.ep = h->ep_in;
> > + A A A A A A bulk.len = xfer;
> > + A A A A A A bulk.data = data;
> > + A A A A A A bulk.timeout = 0;
> > + A A A A A A retry = 0;
> > +
> > + A A A A A A do {
> > + A A A A A A A A A A DBG("[ usb read %d fd = %d],
> fname=%s\n",
> > + A A A A A A A A A A A A A A xfer, h->desc, h->fname);
> > + A A A A A A A A A A n = ioctl(h->desc, USBDEVFS_BULK,
> &bulk);
> > + A A A A A A A A A A DBG("[ usb read %d ] = %d, fname=%s,
> Retry %d\n",
> > + A A A A A A A A A A xfer, n, h->fname, retry);
> > +
> > + A A A A A A A A A A if (n < 0) {
> > + A A A A A A A A A A A A A A DBG1("ERROR: n = %d, errno
> = %d (%s)\n",
> > + A A A A A A A A A A A A A A n, errno,
> strerror(errno));
> > + A A A A A A A A A A A A A A if (++retry > MAX_RETRIES)
> > + A A A A A A A A A A A A A A A A A A return -1;
> > + A A A A A A A A A A A A A A sleep(1);
> > + A A A A A A A A A A }
> > + A A A A A A } while (n < 0);
> > +
> > + A A A A A A count += n;
> > + A A A A A A len -= n;
> > + A A A A A A data += n;
> > +
> > + A A A A A A if (n < xfer)
> > + A A A A A A A A A A break;
> > + A A }
> > +
> > + A A return count;
> > +}
> > +
> > +void usb_kick(struct usb_handle *h)
> > +{
> > + A A int fd;
> > +
> > + A A fd = h->desc;
> > + A A h->desc = -1;
> > + A A if (fd >= 0) {
> > + A A A A A A close(fd);
> > + A A A A A A DBG("[ usb closed %d ]\n", fd);
> > + A A }
> > +}
> > +
> > +int usb_close(struct usb_handle *h)
> > +{
> > + A A int fd;
> > +
> > + A A fd = h->desc;
> > + A A h->desc = -1;
> > + A A if (fd >= 0) {
> > + A A A A A A close(fd);
> > + A A A A A A DBG("[ usb closed %d ]\n", fd);
> > + A A }
> > +
> > + A A return 0;
> > +}
> > +
> > +struct usb_handle *usb_open(ifc_match_func callback)
> > +{
> > + A A return find_usb_device("/dev/bus/usb", callback);
> > +}
> > --
> > 1.7.12.1
> >
> >
> > _______________________________________________
> > barebox mailing list
> > barebox@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 6/9] omap4: add usb boot support
2012-09-30 2:50 ` [PATCH 6/9] omap4: add usb boot support vj
2012-09-30 12:14 ` Antony Pavlov
2012-09-30 14:07 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2012-10-02 13:51 ` Sascha Hauer
2 siblings, 0 replies; 27+ messages in thread
From: Sascha Hauer @ 2012-10-02 13:51 UTC (permalink / raw)
To: vj; +Cc: barebox
On Sun, Sep 30, 2012 at 04:50:34AM +0200, vj wrote:
> ---
> arch/arm/cpu/cpu.c | 1 +
> arch/arm/mach-omap/Kconfig | 7 +
> arch/arm/mach-omap/Makefile | 1 +
> arch/arm/mach-omap/include/mach/omap4_rom_usb.h | 142 ++++++++
> arch/arm/mach-omap/omap4_generic.c | 13 +
> arch/arm/mach-omap/omap4_rom_usb.c | 186 +++++++++++
> scripts/.gitignore | 1 +
> scripts/Makefile | 4 +
> scripts/omap4_usbboot.c | 416 ++++++++++++++++++++++++
> scripts/usb.h | 61 ++++
> scripts/usb_linux.c | 397 ++++++++++++++++++++++
> 11 files changed, 1229 insertions(+)
> create mode 100644 arch/arm/mach-omap/include/mach/omap4_rom_usb.h
> create mode 100644 arch/arm/mach-omap/omap4_rom_usb.c
> create mode 100644 scripts/omap4_usbboot.c
> create mode 100644 scripts/usb.h
> create mode 100644 scripts/usb_linux.c
>
> diff --git a/arch/arm/cpu/cpu.c b/arch/arm/cpu/cpu.c
> index 71ef8c0..05343de 100644
> --- a/arch/arm/cpu/cpu.c
> +++ b/arch/arm/cpu/cpu.c
> @@ -89,6 +89,7 @@ void arch_shutdown(void)
> : "r0", "r1", "r2", "r3", "r6", "r10", "r12", "lr", "cc", "memory"
> );
> #endif
> + __asm__ __volatile__ ("cpsid i\n");
This is a generic arm file. If you want to change something here, please
send a separate patch with this change and explain what it does (and why
it does it)
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 7/9] omap4: add serial communications over usb boot
2012-09-30 2:50 [PATCH 0/9] archosg9: add support for tablet, second round vj
` (5 preceding siblings ...)
2012-09-30 2:50 ` [PATCH 6/9] omap4: add usb boot support vj
@ 2012-09-30 2:50 ` vj
2012-09-30 2:50 ` [PATCH 8/9] omap4: add filesystem support " vj
` (2 subsequent siblings)
9 siblings, 0 replies; 27+ messages in thread
From: vj @ 2012-09-30 2:50 UTC (permalink / raw)
To: barebox; +Cc: vj
---
drivers/serial/Kconfig | 7 +++
drivers/serial/Makefile | 1 +
drivers/serial/serial_omap4_usbboot.c | 87 +++++++++++++++++++++++++++++++++++
3 files changed, 95 insertions(+)
create mode 100644 drivers/serial/serial_omap4_usbboot.c
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 7eb96ed..0627b6e 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -100,4 +100,11 @@ config DRIVER_SERIAL_PXA
bool "PXA serial driver"
depends on ARCH_PXA
+config DRIVER_SERIAL_OMAP4_USBBOOT
+ bool "serial driver over omap4 usb"
+ default n
+ depends on OMAP4_USBBOOT
+ help
+ Enable this to get console support over the usb bus used to boot an OMAP4
+
endmenu
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index e2d56b9..ff99e72 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -19,3 +19,4 @@ obj-$(CONFIG_DRIVER_SERIAL_S3C) += serial_s3c.o
obj-$(CONFIG_DRIVER_SERIAL_ALTERA) += serial_altera.o
obj-$(CONFIG_DRIVER_SERIAL_ALTERA_JTAG) += serial_altera_jtag.o
obj-$(CONFIG_DRIVER_SERIAL_PXA) += serial_pxa.o
+obj-$(CONFIG_DRIVER_SERIAL_OMAP4_USBBOOT) += serial_omap4_usbboot.o
diff --git a/drivers/serial/serial_omap4_usbboot.c b/drivers/serial/serial_omap4_usbboot.c
new file mode 100644
index 0000000..e1653b8
--- /dev/null
+++ b/drivers/serial/serial_omap4_usbboot.c
@@ -0,0 +1,87 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * 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 <init.h>
+#include <malloc.h>
+#include <errno.h>
+#include <mach/omap4_rom_usb.h>
+
+struct serial_omap4_usbboot_priv {
+ struct console_device cdev;
+ u32 val;
+};
+
+static void serial_omap4_usbboot_putc(struct console_device *cdev, char c)
+{
+ unsigned b = c;
+ omap4_usbboot_write(&b, 4);
+}
+
+static int serial_omap4_usbboot_tstc(struct console_device *cdev)
+{
+ struct serial_omap4_usbboot_priv *priv =
+ container_of(cdev, struct serial_omap4_usbboot_priv, cdev);
+ if (omap4_usbboot_is_read_waiting())
+ return 0;
+ else if (omap4_usbboot_is_read_ok())
+ return 1;
+ omap4_usbboot_queue_read(&priv->val, 4);
+ udelay(100);
+ if (omap4_usbboot_is_read_waiting())
+ return 0;
+ else if (omap4_usbboot_is_read_ok())
+ return 1;
+ return 0;
+}
+
+static int serial_omap4_usbboot_getc(struct console_device *cdev)
+{
+ struct serial_omap4_usbboot_priv *priv =
+ container_of(cdev, struct serial_omap4_usbboot_priv, cdev);
+ if (omap4_usbboot_is_read_waiting() || omap4_usbboot_is_read_ok()) {
+ omap4_usbboot_wait_read();
+ return priv->val;
+ }
+ omap4_usbboot_read(&priv->val, 4);
+ return priv->val;
+}
+
+static int serial_omap4_usbboot_probe(struct device_d *dev)
+{
+ struct serial_omap4_usbboot_priv *priv;
+ priv = xzalloc(sizeof(*priv));
+
+ priv->cdev.dev = dev;
+ priv->cdev.f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
+ priv->cdev.tstc = serial_omap4_usbboot_tstc;
+ priv->cdev.putc = serial_omap4_usbboot_putc;
+ priv->cdev.getc = serial_omap4_usbboot_getc;
+ priv->cdev.setbrg = NULL;
+
+ return console_register(&priv->cdev);
+}
+
+static struct driver_d serial_omap4_usbboot_driver = {
+ .name = "serial_omap4_usbboot",
+ .probe = serial_omap4_usbboot_probe,
+};
+
+static int serial_omap4_usbboot_init(void)
+{
+ return register_driver(&serial_omap4_usbboot_driver);
+}
+console_initcall(serial_omap4_usbboot_init);
--
1.7.12.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 8/9] omap4: add filesystem support over usb boot
2012-09-30 2:50 [PATCH 0/9] archosg9: add support for tablet, second round vj
` (6 preceding siblings ...)
2012-09-30 2:50 ` [PATCH 7/9] omap4: add serial communications over usb boot vj
@ 2012-09-30 2:50 ` vj
2012-09-30 13:53 ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-30 2:50 ` [PATCH 9/9] Add support for Archos G9 tablet vj
2012-10-02 17:06 ` [PATCH 0/9] archosg9: add support for tablet, second round Sascha Hauer
9 siblings, 1 reply; 27+ messages in thread
From: vj @ 2012-09-30 2:50 UTC (permalink / raw)
To: barebox; +Cc: vj
---
arch/arm/mach-omap/xload.c | 26 ++++++
fs/Kconfig | 5 +
fs/Makefile | 1 +
fs/omap4_usbbootfs.c | 223 +++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 255 insertions(+)
create mode 100644 fs/omap4_usbbootfs.c
diff --git a/arch/arm/mach-omap/xload.c b/arch/arm/mach-omap/xload.c
index 225b19a..5fda314 100644
--- a/arch/arm/mach-omap/xload.c
+++ b/arch/arm/mach-omap/xload.c
@@ -54,6 +54,26 @@ void *omap_xload_boot_mmc(void)
return buf;
}
+#ifdef CONFIG_FS_OMAP4_USBBOOT
+void *omap4_xload_boot_usb(void){
+ int ret;
+ void *buf;
+ int len;
+
+ ret = mount("omap4_usbboot", "omap4_usbbootfs", "/");
+ if (ret) {
+ printf("Unable to mount omap4_usbbootfs (%d)\n", ret);
+ return NULL;
+ }
+
+ buf = read_file("/barebox.bin", &len);
+ if (!buf)
+ printf("could not read barebox.bin from omap4_usbbootfs\n");
+
+ return buf;
+}
+#endif
+
enum omap_boot_src omap_bootsrc(void)
{
#if defined(CONFIG_ARCH_OMAP3)
@@ -76,6 +96,12 @@ int run_shell(void)
printf("booting from MMC1\n");
func = omap_xload_boot_mmc();
break;
+#ifdef CONFIG_FS_OMAP4_USBBOOT
+ case OMAP_BOOTSRC_USB1:
+ printf("booting from USB1\n");
+ func = omap4_xload_boot_usb();
+ break;
+#endif
case OMAP_BOOTSRC_UNKNOWN:
default:
printf("unknown boot source. Fall back to nand\n");
diff --git a/fs/Kconfig b/fs/Kconfig
index 4c66543..0ab69d7 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -29,6 +29,11 @@ config FS_TFTP
prompt "tftp support"
depends on NET
+config FS_OMAP4_USBBOOT
+ bool
+ prompt "Filesystem over usb boot"
+ depends on OMAP4_USBBOOT
+
config FS_NFS
depends on NET
bool
diff --git a/fs/Makefile b/fs/Makefile
index 1b52bee..ad745d9 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -5,4 +5,5 @@ obj-$(CONFIG_FS_DEVFS) += devfs.o
obj-$(CONFIG_FS_FAT) += fat/
obj-y += fs.o
obj-$(CONFIG_FS_TFTP) += tftp.o
+obj-$(CONFIG_FS_OMAP4_USBBOOT) += omap4_usbbootfs.o
obj-$(CONFIG_FS_NFS) += nfs.o
diff --git a/fs/omap4_usbbootfs.c b/fs/omap4_usbbootfs.c
new file mode 100644
index 0000000..874d530
--- /dev/null
+++ b/fs/omap4_usbbootfs.c
@@ -0,0 +1,223 @@
+/*
+ * omap4_usbbootfs.c
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * 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 <malloc.h>
+#include <fs.h>
+#include <fcntl.h>
+#include <init.h>
+#include <linux/stat.h>
+#include <linux/err.h>
+#include <mach/omap4_rom_usb.h>
+
+#define OMAP4_USBBOOT_FS_MAGIC 0x5562464D
+#define OMAP4_USBBOOT_FS_CMD_OPEN 0x46530000
+#define OMAP4_USBBOOT_FS_CMD_CLOSE 0x46530001
+#define OMAP4_USBBOOT_FS_CMD_READ 0x46530002
+#define OMAP4_USBBOOT_FS_CMD_END 0x4653FFFF
+
+struct file_priv {
+ s32 id;
+ u32 size;
+};
+/*
+static int omap4_usbbootfs_create(
+ struct device_d *dev, const char *pathname, mode_t mode)
+{
+ return -ENOSYS;
+}
+
+static int omap4_usbbootfs_unlink(struct device_d *dev, const char *pathname)
+{
+ return -ENOSYS;
+}
+
+static int omap4_usbbootfs_mkdir(struct device_d *dev, const char *pathname)
+{
+ return -ENOSYS;
+}
+
+static int omap4_usbbootfs_rmdir(struct device_d *dev, const char *pathname)
+{
+ return -ENOSYS;
+}
+
+static int omap4_usbbootfs_write(
+ struct device_d *_dev, FILE *f, const void *inbuf, size_t size)
+{
+ return -ENOSYS;
+}
+
+static int omap4_usbbootfs_truncate(struct device_d *dev, FILE *f, ulong size)
+{
+ return -ENOSYS;
+}
+*/
+
+static struct file_priv *omap4_usbbootfs_do_open(
+ struct device_d *dev, int accmode, const char *filename)
+{
+ struct file_priv *priv;
+ u32 data;
+
+ if (accmode & O_ACCMODE)
+ return ERR_PTR(-ENOSYS);
+
+ priv = xzalloc(sizeof(*priv));
+ if (!priv)
+ return ERR_PTR(-ENOMEM);
+
+ data = OMAP4_USBBOOT_FS_MAGIC ; omap4_usbboot_write(&data, 4);
+ data = OMAP4_USBBOOT_FS_CMD_OPEN; omap4_usbboot_write(&data, 4);
+ omap4_usbboot_puts(filename);
+ data = OMAP4_USBBOOT_FS_CMD_END ; omap4_usbboot_write(&data, 4);
+
+ if (omap4_usbboot_read(&priv->id, 4) ||
+ omap4_usbboot_read(&priv->size, 4)
+ ) {
+ free(priv);
+ return ERR_PTR(-EIO);
+ }
+ if (priv->id < 0) {
+ free(priv);
+ return ERR_PTR(-ENOENT);
+ }
+
+ return priv;
+}
+
+static int omap4_usbbootfs_open(
+ struct device_d *dev, FILE *file, const char *filename)
+{
+ struct file_priv *priv;
+
+ priv = omap4_usbbootfs_do_open(dev, file->flags, filename);
+ if (IS_ERR(priv))
+ return PTR_ERR(priv);
+
+ file->inode = priv;
+ file->size = priv->size;
+
+ return 0;
+}
+
+static int omap4_usbbootfs_do_close(struct file_priv *priv)
+{
+ u32 data;
+ data = OMAP4_USBBOOT_FS_MAGIC ; omap4_usbboot_write(&data, 4);
+ data = OMAP4_USBBOOT_FS_CMD_CLOSE; omap4_usbboot_write(&data, 4);
+ omap4_usbboot_write(&priv->id, 4);
+ data = OMAP4_USBBOOT_FS_CMD_END ; omap4_usbboot_write(&data, 4);
+ free(priv);
+ return 0;
+}
+
+static int omap4_usbbootfs_close(struct device_d *dev, FILE *f)
+{
+ struct file_priv *priv = f->inode;
+ return omap4_usbbootfs_do_close(priv);
+}
+
+static int omap4_usbbootfs_read(
+ struct device_d *dev, FILE *f, void *buf, size_t size)
+{
+ struct file_priv *priv = f->inode;
+ u32 data;
+
+ if (size > priv->size - f->pos)
+ size = priv->size - f->pos;
+ if (!size)
+ return 0;
+
+ data = OMAP4_USBBOOT_FS_MAGIC ; omap4_usbboot_write(&data, 4);
+ data = OMAP4_USBBOOT_FS_CMD_READ; omap4_usbboot_write(&data, 4);
+ omap4_usbboot_write(&priv->id, 4);
+ omap4_usbboot_write(&f->pos, 4);
+ omap4_usbboot_write(&size, 4);
+ data = OMAP4_USBBOOT_FS_CMD_END ; omap4_usbboot_write(&data, 4);
+
+ if (omap4_usbboot_read(buf, size))
+ return -EIO;
+
+ return size;
+}
+
+static loff_t omap4_usbbootfs_lseek(struct device_d *dev, FILE *f, loff_t pos)
+{
+ f->pos = pos;
+ return pos;
+}
+
+static DIR *omap4_usbbootfs_opendir(struct device_d *dev, const char *pathname)
+{
+ return NULL;
+}
+
+static int omap4_usbbootfs_stat(
+ struct device_d *dev, const char *filename, struct stat *s)
+{
+ struct file_priv *priv;
+
+ priv = omap4_usbbootfs_do_open(dev, O_RDONLY, filename);
+ if (IS_ERR(priv))
+ return PTR_ERR(priv);
+
+ s->st_mode = S_IFREG |
+ S_IRUSR | S_IRGRP | S_IROTH |
+ S_IXUSR | S_IXGRP | S_IXOTH ;
+ s->st_size = priv->size;
+
+ omap4_usbbootfs_do_close(priv);
+
+ return 0;
+}
+
+static int omap4_usbbootfs_probe(struct device_d *dev)
+{
+ return 0;
+}
+static void omap4_usbbootfs_remove(struct device_d *dev)
+{
+}
+
+static struct fs_driver_d omap4_usbbootfs_driver = {
+ .open = omap4_usbbootfs_open,
+ .close = omap4_usbbootfs_close,
+ .read = omap4_usbbootfs_read,
+ .lseek = omap4_usbbootfs_lseek,
+ .opendir = omap4_usbbootfs_opendir,
+ .stat = omap4_usbbootfs_stat,
+/*
+ .create = omap4_usbbootfs_create,
+ .unlink = omap4_usbbootfs_unlink,
+ .mkdir = omap4_usbbootfs_mkdir,
+ .rmdir = omap4_usbbootfs_rmdir,
+ .write = omap4_usbbootfs_write,
+ .truncate= omap4_usbbootfs_truncate,
+*/
+ .flags = 0,
+ .drv = {
+ .probe = omap4_usbbootfs_probe,
+ .remove = omap4_usbbootfs_remove,
+ .name = "omap4_usbbootfs",
+ }
+};
+
+static int omap4_usbbootfs_init(void)
+{
+ return register_fs_driver(&omap4_usbbootfs_driver);
+}
+coredevice_initcall(omap4_usbbootfs_init);
--
1.7.12.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 8/9] omap4: add filesystem support over usb boot
2012-09-30 2:50 ` [PATCH 8/9] omap4: add filesystem support " vj
@ 2012-09-30 13:53 ` Jean-Christophe PLAGNIOL-VILLARD
0 siblings, 0 replies; 27+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-30 13:53 UTC (permalink / raw)
To: vj; +Cc: barebox
On 04:50 Sun 30 Sep , vj wrote:
> ---
> arch/arm/mach-omap/xload.c | 26 ++++++
> fs/Kconfig | 5 +
> fs/Makefile | 1 +
> fs/omap4_usbbootfs.c | 223 +++++++++++++++++++++++++++++++++++++++++++++
> 4 files changed, 255 insertions(+)
> create mode 100644 fs/omap4_usbbootfs.c
>
> diff --git a/arch/arm/mach-omap/xload.c b/arch/arm/mach-omap/xload.c
> index 225b19a..5fda314 100644
> --- a/arch/arm/mach-omap/xload.c
> +++ b/arch/arm/mach-omap/xload.c
> @@ -54,6 +54,26 @@ void *omap_xload_boot_mmc(void)
> return buf;
> }
>
> +#ifdef CONFIG_FS_OMAP4_USBBOOT
drop the ifdef
> +void *omap4_xload_boot_usb(void){
> + int ret;
> + void *buf;
> + int len;
> +
> + ret = mount("omap4_usbboot", "omap4_usbbootfs", "/");
> + if (ret) {
> + printf("Unable to mount omap4_usbbootfs (%d)\n", ret);
> + return NULL;
> + }
> +
> + buf = read_file("/barebox.bin", &len);
> + if (!buf)
> + printf("could not read barebox.bin from omap4_usbbootfs\n");
> +
> + return buf;
> +}
> +#endif
> +
> enum omap_boot_src omap_bootsrc(void)
> {
> #if defined(CONFIG_ARCH_OMAP3)
> @@ -76,6 +96,12 @@ int run_shell(void)
> printf("booting from MMC1\n");
> func = omap_xload_boot_mmc();
> break;
> +#ifdef CONFIG_FS_OMAP4_USBBOOT
> + case OMAP_BOOTSRC_USB1:
if (IS_ENABLED(...) {
...
} else {
printf("booting from usb1 not enabled\n");
}
> + printf("booting from USB1\n");
> + func = omap4_xload_boot_usb();
> + break;
> +#endif
> case OMAP_BOOTSRC_UNKNOWN:
> default:
> printf("unknown boot source. Fall back to nand\n");
> diff --git a/fs/Kconfig b/fs/Kconfig
> index 4c66543..0ab69d7 100644
> --- a/fs/Kconfig
> +++ b/fs/Kconfig
> @@ -29,6 +29,11 @@ config FS_TFTP
> prompt "tftp support"
> depends on NET
>
> +config FS_OMAP4_USBBOOT
> + bool
> + prompt "Filesystem over usb boot"
> + depends on OMAP4_USBBOOT
> +
> config FS_NFS
> depends on NET
> bool
> diff --git a/fs/Makefile b/fs/Makefile
> index 1b52bee..ad745d9 100644
> --- a/fs/Makefile
> +++ b/fs/Makefile
> @@ -5,4 +5,5 @@ obj-$(CONFIG_FS_DEVFS) += devfs.o
> obj-$(CONFIG_FS_FAT) += fat/
> obj-y += fs.o
> obj-$(CONFIG_FS_TFTP) += tftp.o
> +obj-$(CONFIG_FS_OMAP4_USBBOOT) += omap4_usbbootfs.o
> obj-$(CONFIG_FS_NFS) += nfs.o
> diff --git a/fs/omap4_usbbootfs.c b/fs/omap4_usbbootfs.c
> new file mode 100644
> index 0000000..874d530
> --- /dev/null
> +++ b/fs/omap4_usbbootfs.c
> @@ -0,0 +1,223 @@
> +/*
> + * omap4_usbbootfs.c
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2
> + * as published by the Free Software Foundation.
> + *
> + * 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 <malloc.h>
> +#include <fs.h>
> +#include <fcntl.h>
> +#include <init.h>
> +#include <linux/stat.h>
> +#include <linux/err.h>
> +#include <mach/omap4_rom_usb.h>
> +
> +#define OMAP4_USBBOOT_FS_MAGIC 0x5562464D
> +#define OMAP4_USBBOOT_FS_CMD_OPEN 0x46530000
> +#define OMAP4_USBBOOT_FS_CMD_CLOSE 0x46530001
> +#define OMAP4_USBBOOT_FS_CMD_READ 0x46530002
> +#define OMAP4_USBBOOT_FS_CMD_END 0x4653FFFF
> +
> +struct file_priv {
> + s32 id;
> + u32 size;
> +};
> +/*
> +static int omap4_usbbootfs_create(
> + struct device_d *dev, const char *pathname, mode_t mode)
> +{
> + return -ENOSYS;
> +}
> +
> +static int omap4_usbbootfs_unlink(struct device_d *dev, const char *pathname)
> +{
> + return -ENOSYS;
> +}
> +
> +static int omap4_usbbootfs_mkdir(struct device_d *dev, const char *pathname)
> +{
> + return -ENOSYS;
> +}
> +
> +static int omap4_usbbootfs_rmdir(struct device_d *dev, const char *pathname)
> +{
> + return -ENOSYS;
> +}
> +
> +static int omap4_usbbootfs_write(
> + struct device_d *_dev, FILE *f, const void *inbuf, size_t size)
> +{
> + return -ENOSYS;
> +}
> +
> +static int omap4_usbbootfs_truncate(struct device_d *dev, FILE *f, ulong size)
> +{
> + return -ENOSYS;
> +}
> +*/
> +
> +static struct file_priv *omap4_usbbootfs_do_open(
> + struct device_d *dev, int accmode, const char *filename)
> +{
> + struct file_priv *priv;
> + u32 data;
> +
> + if (accmode & O_ACCMODE)
> + return ERR_PTR(-ENOSYS);
> +
> + priv = xzalloc(sizeof(*priv));
> + if (!priv)
> + return ERR_PTR(-ENOMEM);
> +
> + data = OMAP4_USBBOOT_FS_MAGIC ; omap4_usbboot_write(&data, 4);
> + data = OMAP4_USBBOOT_FS_CMD_OPEN; omap4_usbboot_write(&data, 4);
> + omap4_usbboot_puts(filename);
> + data = OMAP4_USBBOOT_FS_CMD_END ; omap4_usbboot_write(&data, 4);
> +
> + if (omap4_usbboot_read(&priv->id, 4) ||
> + omap4_usbboot_read(&priv->size, 4)
> + ) {
> + free(priv);
> + return ERR_PTR(-EIO);
> + }
> + if (priv->id < 0) {
> + free(priv);
> + return ERR_PTR(-ENOENT);
> + }
> +
> + return priv;
> +}
> +
> +static int omap4_usbbootfs_open(
> + struct device_d *dev, FILE *file, const char *filename)
> +{
> + struct file_priv *priv;
> +
> + priv = omap4_usbbootfs_do_open(dev, file->flags, filename);
> + if (IS_ERR(priv))
> + return PTR_ERR(priv);
> +
> + file->inode = priv;
> + file->size = priv->size;
> +
> + return 0;
> +}
> +
> +static int omap4_usbbootfs_do_close(struct file_priv *priv)
> +{
> + u32 data;
> + data = OMAP4_USBBOOT_FS_MAGIC ; omap4_usbboot_write(&data, 4);
> + data = OMAP4_USBBOOT_FS_CMD_CLOSE; omap4_usbboot_write(&data, 4);
> + omap4_usbboot_write(&priv->id, 4);
> + data = OMAP4_USBBOOT_FS_CMD_END ; omap4_usbboot_write(&data, 4);
> + free(priv);
> + return 0;
> +}
> +
> +static int omap4_usbbootfs_close(struct device_d *dev, FILE *f)
> +{
> + struct file_priv *priv = f->inode;
> + return omap4_usbbootfs_do_close(priv);
> +}
> +
> +static int omap4_usbbootfs_read(
> + struct device_d *dev, FILE *f, void *buf, size_t size)
> +{
> + struct file_priv *priv = f->inode;
> + u32 data;
> +
> + if (size > priv->size - f->pos)
> + size = priv->size - f->pos;
> + if (!size)
> + return 0;
> +
> + data = OMAP4_USBBOOT_FS_MAGIC ; omap4_usbboot_write(&data, 4);
> + data = OMAP4_USBBOOT_FS_CMD_READ; omap4_usbboot_write(&data, 4);
> + omap4_usbboot_write(&priv->id, 4);
> + omap4_usbboot_write(&f->pos, 4);
> + omap4_usbboot_write(&size, 4);
> + data = OMAP4_USBBOOT_FS_CMD_END ; omap4_usbboot_write(&data, 4);
> +
> + if (omap4_usbboot_read(buf, size))
> + return -EIO;
> +
> + return size;
> +}
> +
> +static loff_t omap4_usbbootfs_lseek(struct device_d *dev, FILE *f, loff_t pos)
> +{
> + f->pos = pos;
> + return pos;
> +}
> +
> +static DIR *omap4_usbbootfs_opendir(struct device_d *dev, const char *pathname)
> +{
> + return NULL;
> +}
> +
> +static int omap4_usbbootfs_stat(
> + struct device_d *dev, const char *filename, struct stat *s)
> +{
> + struct file_priv *priv;
> +
> + priv = omap4_usbbootfs_do_open(dev, O_RDONLY, filename);
> + if (IS_ERR(priv))
> + return PTR_ERR(priv);
> +
> + s->st_mode = S_IFREG |
> + S_IRUSR | S_IRGRP | S_IROTH |
> + S_IXUSR | S_IXGRP | S_IXOTH ;
> + s->st_size = priv->size;
> +
> + omap4_usbbootfs_do_close(priv);
> +
> + return 0;
> +}
> +
> +static int omap4_usbbootfs_probe(struct device_d *dev)
> +{
> + return 0;
> +}
> +static void omap4_usbbootfs_remove(struct device_d *dev)
> +{
> +}
> +
> +static struct fs_driver_d omap4_usbbootfs_driver = {
> + .open = omap4_usbbootfs_open,
> + .close = omap4_usbbootfs_close,
> + .read = omap4_usbbootfs_read,
> + .lseek = omap4_usbbootfs_lseek,
> + .opendir = omap4_usbbootfs_opendir,
> + .stat = omap4_usbbootfs_stat,
> +/*
> + .create = omap4_usbbootfs_create,
> + .unlink = omap4_usbbootfs_unlink,
> + .mkdir = omap4_usbbootfs_mkdir,
> + .rmdir = omap4_usbbootfs_rmdir,
> + .write = omap4_usbbootfs_write,
> + .truncate= omap4_usbbootfs_truncate,
> +*/
> + .flags = 0,
> + .drv = {
> + .probe = omap4_usbbootfs_probe,
> + .remove = omap4_usbbootfs_remove,
> + .name = "omap4_usbbootfs",
> + }
> +};
> +
> +static int omap4_usbbootfs_init(void)
> +{
> + return register_fs_driver(&omap4_usbbootfs_driver);
> +}
> +coredevice_initcall(omap4_usbbootfs_init);
> --
> 1.7.12.1
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 9/9] Add support for Archos G9 tablet
2012-09-30 2:50 [PATCH 0/9] archosg9: add support for tablet, second round vj
` (7 preceding siblings ...)
2012-09-30 2:50 ` [PATCH 8/9] omap4: add filesystem support " vj
@ 2012-09-30 2:50 ` vj
2012-09-30 14:00 ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-30 15:02 ` Antony Pavlov
2012-10-02 17:06 ` [PATCH 0/9] archosg9: add support for tablet, second round Sascha Hauer
9 siblings, 2 replies; 27+ messages in thread
From: vj @ 2012-09-30 2:50 UTC (permalink / raw)
To: barebox; +Cc: vj
---
arch/arm/Makefile | 1 +
arch/arm/boards/archosg9/Makefile | 3 +
arch/arm/boards/archosg9/board.c | 72 +++++
arch/arm/boards/archosg9/config.h | 1 +
arch/arm/boards/archosg9/env/bin/init | 18 ++
arch/arm/boards/archosg9/env/config | 2 +
arch/arm/boards/archosg9/lowlevel.c | 133 +++++++++
arch/arm/boards/archosg9/mux.c | 463 ++++++++++++++++++++++++++++++
arch/arm/boards/archosg9/mux.h | 6 +
arch/arm/configs/archosg9_defconfig | 69 +++++
arch/arm/configs/archosg9_xload_defconfig | 24 ++
arch/arm/mach-omap/Kconfig | 9 +
arch/arm/tools/mach-types | 1 +
13 files changed, 802 insertions(+)
create mode 100644 arch/arm/boards/archosg9/Makefile
create mode 100644 arch/arm/boards/archosg9/board.c
create mode 100644 arch/arm/boards/archosg9/config.h
create mode 100644 arch/arm/boards/archosg9/env/bin/init
create mode 100644 arch/arm/boards/archosg9/env/config
create mode 100644 arch/arm/boards/archosg9/lowlevel.c
create mode 100644 arch/arm/boards/archosg9/mux.c
create mode 100644 arch/arm/boards/archosg9/mux.h
create mode 100644 arch/arm/configs/archosg9_defconfig
create mode 100644 arch/arm/configs/archosg9_xload_defconfig
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 8e660be..8598005 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -100,6 +100,7 @@ board-$(CONFIG_MACH_OMAP343xSDP) := omap343xdsp
board-$(CONFIG_MACH_BEAGLE) := beagle
board-$(CONFIG_MACH_OMAP3EVM) := omap3evm
board-$(CONFIG_MACH_PANDA) := panda
+board-$(CONFIG_MACH_ARCHOSG9) := archosg9
board-$(CONFIG_MACH_PCM049) := pcm049
board-$(CONFIG_MACH_PCA100) := phycard-i.MX27
board-$(CONFIG_MACH_PCAAL1) := phycard-a-l1
diff --git a/arch/arm/boards/archosg9/Makefile b/arch/arm/boards/archosg9/Makefile
new file mode 100644
index 0000000..53b9d5b
--- /dev/null
+++ b/arch/arm/boards/archosg9/Makefile
@@ -0,0 +1,3 @@
+obj-y += board.o
+obj-y += lowlevel.o mux.o
+pbl-y += lowlevel.o mux.o
diff --git a/arch/arm/boards/archosg9/board.c b/arch/arm/boards/archosg9/board.c
new file mode 100644
index 0000000..5ef9126
--- /dev/null
+++ b/arch/arm/boards/archosg9/board.c
@@ -0,0 +1,72 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * 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 <init.h>
+#include <ns16550.h>
+#include <asm/armlinux.h>
+#include <generated/mach-types.h>
+#include <mach/silicon.h>
+#include <sizes.h>
+#include <i2c/i2c.h>
+#include <gpio.h>
+
+#ifdef CONFIG_DRIVER_SERIAL_NS16550
+static struct NS16550_plat serial_plat = {
+ .clock = 48000000, /* 48MHz (APLL96/2) */
+ .shift = 2,
+};
+#endif
+static int archosg9_console_init(void){
+#ifdef CONFIG_DRIVER_SERIAL_OMAP4_USBBOOT
+ add_generic_device("serial_omap4_usbboot", DEVICE_ID_DYNAMIC
+ , NULL, 0, 0, 0, NULL);
+#endif
+#if defined(CONFIG_DRIVER_SERIAL_NS16550)
+ gpio_direction_output(41, 0); /* gps_disable */
+ gpio_direction_output(34, 1); /* 1v8_pwron */
+ add_ns16550_device(DEVICE_ID_DYNAMIC, OMAP44XX_UART1_BASE, 1024,
+ IORESOURCE_MEM_8BIT, &serial_plat);
+#endif
+ return 0;
+}
+console_initcall(archosg9_console_init);
+
+static int archosg9_mem_init(void){
+ arm_add_mem_device("ram0", 0x80000000, SZ_1G);
+ return 0;
+}
+mem_initcall(archosg9_mem_init);
+
+static struct i2c_board_info i2c_devices[] = {
+ { I2C_BOARD_INFO("twl6030", 0x48), },
+};
+
+static int archosg9_devices_init(void){
+ i2c_register_board_info(0, i2c_devices, ARRAY_SIZE(i2c_devices));
+ add_generic_device("i2c-omap" , DEVICE_ID_DYNAMIC, NULL,
+ OMAP44XX_I2C1_BASE, 0x100, IORESOURCE_MEM, NULL);
+ add_generic_device("omap-hsmmc", DEVICE_ID_DYNAMIC, NULL,
+ OMAP44XX_MMC1_BASE, SZ_4K, IORESOURCE_MEM, NULL);
+ /* add_generic_device("omap-hsmmc", DEVICE_ID_DYNAMIC, NULL,
+ OMAP44XX_MMC2_BASE, SZ_4K, IORESOURCE_MEM, NULL); */
+
+ armlinux_set_bootparams((void *)0x80000100);
+ armlinux_set_architecture(MACH_TYPE_OMAP4_ARCHOSG9);
+
+ return 0;
+}
+device_initcall(archosg9_devices_init);
diff --git a/arch/arm/boards/archosg9/config.h b/arch/arm/boards/archosg9/config.h
new file mode 100644
index 0000000..da84fa5
--- /dev/null
+++ b/arch/arm/boards/archosg9/config.h
@@ -0,0 +1 @@
+/* nothing */
diff --git a/arch/arm/boards/archosg9/env/bin/init b/arch/arm/boards/archosg9/env/bin/init
new file mode 100644
index 0000000..e64ba50
--- /dev/null
+++ b/arch/arm/boards/archosg9/env/bin/init
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+PATH=/env/bin
+export PATH
+
+. /env/config
+
+if [ -n $autoboot_timeout ]; then
+ echo
+ echo -n "Hit any key to stop autoboot: "
+ timeout -a $autoboot_timeout
+ if [ $? != 0 ]; then
+ exit
+ fi
+fi
+mkdir /usb
+mount -t omap4_usbbootfs omap4_usbboot /usb
+bootm /usb/boot/zImage
diff --git a/arch/arm/boards/archosg9/env/config b/arch/arm/boards/archosg9/env/config
new file mode 100644
index 0000000..9e8c1db
--- /dev/null
+++ b/arch/arm/boards/archosg9/env/config
@@ -0,0 +1,2 @@
+autoboot_timeout=3
+bootargs="earlyprintk=serial console=ttyO1,57600n8"
diff --git a/arch/arm/boards/archosg9/lowlevel.c b/arch/arm/boards/archosg9/lowlevel.c
new file mode 100644
index 0000000..a16253c
--- /dev/null
+++ b/arch/arm/boards/archosg9/lowlevel.c
@@ -0,0 +1,133 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * 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 <io.h>
+#include <mach/omap4-mux.h>
+#include <mach/omap4-silicon.h>
+#include <mach/omap4-clock.h>
+#include <mach/syslib.h>
+#include <asm/barebox-arm.h>
+#include "mux.h"
+
+#define TPS62361_VSEL0_GPIO 7
+
+static const struct ddr_regs ddr_regs_400_mhz_2cs = {
+ .tim1 = 0x10EB0662,
+ .tim2 = 0x20370DD2,
+ .tim3 = 0x00B1C33F,
+ .phy_ctrl_1 = 0x849FF408,
+ .ref_ctrl = 0x00000618,
+ .config_init = 0x80000EB9,
+ .config_final = 0x80001AB9,
+ .zq_config = 0xD00B3215,
+ .mr1 = 0x83,
+ .mr2 = 0x4
+};
+
+/*
+static unsigned prbs(unsigned state)
+{
+ const unsigned POL = (1<<(32-1)) | (1<<(31-1)) | (1<<(20-1)) | \
+ (1<<(19-1)) | (1<<(13-1)) | (1<<(1-1));
+ unsigned i;
+ for (i = 0; i < 32; i++) {
+ if (state&1)
+ state = (state >> 1) ^ POL;
+ else
+ state = state >> 1;
+ }
+ return state;
+}
+static void memtest(void *x, unsigned count)
+{
+ unsigned *w = x;
+ unsigned n, m;
+ unsigned chk;
+ count /= 8;
+
+#define PRINT early_printf
+ PRINT("memtest write\n");
+ for (chk = 0xa5a5a5a5, n = 0, m = count; n < count; n++, m++) {
+ chk = prbs(chk);
+ w[n] = chk;
+ w[m] = ~chk;
+ }
+ PRINT("memtest read\n");
+ for (n = 0, m = count; n < count; n++, m++) {
+ if (w[n] != ~w[m]) {
+ PRINT("ERROR [%08X]%08X != [%08X]%08X\n",
+ (unsigned) (w+n), w[n],
+ (unsigned) (w+m), ~w[m]);
+ return;
+ }
+ }
+ PRINT("memtest read2\n");
+ for (chk = 0xa5a5a5a5, n = 0, m = count; n < count; n++, m++) {
+ chk = prbs(chk);
+ if (w[n] != chk || w[m] != ~chk) {
+ PRINT("ERROR [%08X]%08X != [%08X]%08X != %08X\n",
+ (unsigned) (w+n), w[n],
+ (unsigned) (w+m), ~w[m], chk);
+ return;
+ }
+ }
+ PRINT("OK!\n");
+}
+*/
+
+static noinline void archosg9_init_lowlevel(void)
+{
+ struct dpll_param core = OMAP4_CORE_DPLL_PARAM_19M2_DDR400;
+ struct dpll_param mpu = OMAP4_MPU_DPLL_PARAM_19M2_MPU600;
+ struct dpll_param iva = OMAP4_IVA_DPLL_PARAM_19M2;
+ struct dpll_param per = OMAP4_PER_DPLL_PARAM_19M2;
+ struct dpll_param abe = OMAP4_ABE_DPLL_PARAM_19M2;
+ struct dpll_param usb = OMAP4_USB_DPLL_PARAM_19M2;
+
+ writel(CM_SYS_CLKSEL_19M2, CM_SYS_CLKSEL);
+
+ /* Configure all DPLL's at 100% OPP */
+ omap4_configure_mpu_dpll(&mpu);
+ omap4_configure_iva_dpll(&iva);
+ omap4_configure_per_dpll(&per);
+ omap4_configure_abe_dpll(&abe);
+ omap4_configure_usb_dpll(&usb);
+
+ /* Enable all clocks */
+ omap4_enable_all_clocks();
+
+ set_muxconf_regs();
+
+ omap4_ddr_init(&ddr_regs_400_mhz_2cs, &core);
+ /* Memory test */
+ /*memtest((void*)0x82000000, 8*1024*1024);*/
+ /* Full memory test */
+ /*memtest((void*)0x80000000, 1024*1024*1024);*/
+
+ /* Set VCORE1 = 1.3 V, VCORE2 = VCORE3 = 1.21V */
+ omap4_scale_vcores(TPS62361_VSEL0_GPIO);
+ board_init_lowlevel_return();
+}
+
+void board_init_lowlevel(void)
+{
+ u32 r;
+
+ r = 0x4030D000;
+ __asm__ __volatile__("mov sp, %0" : : "r"(r));
+
+ archosg9_init_lowlevel();
+}
diff --git a/arch/arm/boards/archosg9/mux.c b/arch/arm/boards/archosg9/mux.c
new file mode 100644
index 0000000..af66ebb
--- /dev/null
+++ b/arch/arm/boards/archosg9/mux.c
@@ -0,0 +1,463 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * 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 <init.h>
+#include <io.h>
+#include <mach/omap4-silicon.h>
+#include <mach/omap4-mux.h>
+#include <mach/omap4-clock.h>
+#include "mux.h"
+
+static const struct pad_conf_entry core_padconf_array[] = {
+ /* sdmmc2_dat0 */ /* internal FLASH */
+ { GPMC_AD0 , IEN | PTU | M1 },
+ /* sdmmc2_dat1 */ /* internal FLASH */
+ { GPMC_AD1 , IEN | PTU | M1 },
+ /* sdmmc2_dat2 */ /* internal FLASH */
+ { GPMC_AD2 , IEN | PTU | M1 },
+ /* sdmmc2_dat3 */ /* internal FLASH */
+ { GPMC_AD3 , IEN | PTU | M1 },
+ /* sdmmc2_dat4 */ /* internal FLASH */
+ { GPMC_AD4 , IEN | PTU | M1 },
+ /* sdmmc2_dat5 */ /* internal FLASH */
+ { GPMC_AD5 , IEN | PTU | M1 },
+ /* sdmmc2_dat6 */ /* internal FLASH */
+ { GPMC_AD6 , IEN | PTU | M1 },
+ /* sdmmc2_dat7 */ /* internal FLASH */
+ { GPMC_AD7 , IEN | PTU | M1 },
+ /* gpio_32 */
+ { GPMC_AD8 , IEN | PTD | M3 },
+ /* gpmc_ad9 */
+ { GPMC_AD9 , IEN | PTU | M0 },
+ /* gpio_34 */ /* 1v8_pwron */
+ { GPMC_AD10 , IEN | PTU | M3 },
+ /* gpio_35 */ /* vcc_pwron */
+ { GPMC_AD11 , IEN | PTU | M3 },
+ /* gpio_36 */ /* 5v_pwron */
+ { GPMC_AD12 , IEN | M3 },
+ /* gpio_37 */ /* hdmi_pwr */
+ { GPMC_AD13 , IEN | M3 },
+ /* gpio_38 */ /* lcd_pwon */
+ { GPMC_AD14 , IEN | M3 },
+ /* gpio_39 */ /* lvds_en */
+ { GPMC_AD15 , IEN | M3 },
+ /* gpio_40 */ /* 3g_enable */
+ { GPMC_A16 , IEN | M3 },
+ /* gpio_41 */ /* gps_enable */
+ { GPMC_A17 , IEN | M3 },
+ /* gpio_42 */ /* ehci_enable */
+ { GPMC_A18 , IEN | M3 },
+ /* gpio_43 */ /* volume up */
+ { GPMC_A19 , IEN | M3 },
+ /* gpio_44 */ /* volume down */
+ { GPMC_A20 , IEN | M3 },
+ /* gpio_45 */ /* accel_int1 */
+ { GPMC_A21 , IEN | PTU | M3 },
+ /* kpd_col6 */
+ { GPMC_A22 , IEN | PTD | M1 },
+ /* kpd_col7 */
+ { GPMC_A23 , IEN | PTD | M1 },
+ /* gpio_48 */ /* vbus_detect */
+ { GPMC_A24 , IEN | M3 },
+ /* gpio_49 */ /* id */
+ { GPMC_A25 , IEN | PTU | M3 },
+ /* gpmc_ncs0 */
+ { GPMC_NCS0 , IEN | PTU | M0 },
+ /* gpio_51 */ /* compass_data_ready */
+ { GPMC_NCS1 , IEN | M3 },
+ /* safe_mode */
+ { GPMC_NCS2 , IEN | PTU | M7 },
+ /* gpio_53 */ /* lcd_rst */
+ { GPMC_NCS3 , IEN | M3 },
+ /* gpmc_nwp */
+ { GPMC_NWP , IEN | PTD | M0 },
+ /* gpmc_clk */
+ { GPMC_CLK , IEN | PTD | M0 },
+ /* gpmc_nadv_ale */
+ { GPMC_NADV_ALE , IEN | PTD | M0 },
+ /* sdmmc2_clk */ /* internal FLASH */
+ { GPMC_NOE , IEN | PTU | M1 },
+ /* sdmmc2_cmd */ /* internal FLASH */
+ { GPMC_NWE , IEN | PTU | M1 },
+ /* gpmc_nbe0_cle */
+ { GPMC_NBE0_CLE , IEN | PTD | M0 },
+ /* safe_mode */
+ { GPMC_NBE1 , IEN | PTD | M7 },
+ /* gpmc_wait0 */
+ { GPMC_WAIT0 , IEN | PTU | M0 },
+ /* gpio_62 */ /* camera_reset */
+ { GPMC_WAIT1 , IEN | M3 },
+ /* safe_mode */
+ { GPMC_WAIT2 , IEN | PTD | M7 },
+ /* gpio_101 */ /* lcd_stdby */
+ { GPMC_NCS4 , M3 },
+ /* gpio_102 */ /* wifi_irq */
+ { GPMC_NCS5 , IEN | M3 },
+ /* gpio_103 */ /* wifi_power */
+ { GPMC_NCS6 , M3 },
+ /* gpio_104 */ /* bt_power */
+ { GPMC_NCS7 , IEN | M3 },
+ /* gpio_63 */ /* hdmi_hpd ?? */
+ { GPIO63 , IEN | PTD | M3 },
+ /* */
+ { GPIO64 , IEN | M0 },
+ /* */
+ { GPIO65 , IEN | M0 },
+ /* */
+ { GPIO66 , IEN | M0 },
+ /* csi21_dx0 */
+ { CSI21_DX0 , IEN | M0 },
+ /* csi21_dy0 */
+ { CSI21_DY0 , IEN | M0 },
+ /* csi21_dx1 */
+ { CSI21_DX1 , IEN | M0 },
+ /* csi21_dy1 */
+ { CSI21_DY1 , IEN | M0 },
+ /* safe_mode */
+ { CSI21_DX2 , IEN | PTD | M7 },
+ /* safe_mode */
+ { CSI21_DY2 , IEN | PTD | M7 },
+ /* safe_mode */
+ { CSI21_DX3 , IEN | PTD | M7 },
+ /* safe_mode */
+ { CSI21_DY3 , IEN | PTD | M7 },
+ /* safe_mode */
+ { CSI21_DX4 , IEN | PTD | M7 },
+ /* safe_mode */
+ { CSI21_DY4 , IEN | PTD | M7 },
+ /* safe_mode */
+ { CSI22_DX0 , IEN | PTD | M7 },
+ /* safe_mode */
+ { CSI22_DY0 , IEN | PTD | M7 },
+ /* safe_mode */
+ { CSI22_DX1 , IEN | PTD | M7 },
+ /* safe_mode */
+ { CSI22_DY1 , IEN | PTD | M7 },
+ /* cam_shutter */
+ { CAM_SHUTTER , PTD | M0 },
+ /* cam_strobe */
+ { CAM_STROBE , PTD | M0 },
+ /* gpio_83 */
+ { CAM_GLOBALRESET , PTD | M3 },
+ /* usbb1_ulpiphy_clk */
+ { USBB1_ULPITLL_CLK , IEN | PTD | M4 },
+ /* usbb1_ulpiphy_stp */
+ { USBB1_ULPITLL_STP , M4 },
+ /* usbb1_ulpiphy_dir */
+ { USBB1_ULPITLL_DIR , IEN | PTD | M4 },
+ /* usbb1_ulpiphy_nxt */
+ { USBB1_ULPITLL_NXT , IEN | PTD | M4 },
+ /* usbb1_ulpiphy_dat0 */
+ { USBB1_ULPITLL_DAT0 , WAKEUP_EN | IEN | PTD | M4 },
+ /* usbb1_ulpiphy_dat1 */
+ { USBB1_ULPITLL_DAT1 , IEN | PTD | M4 },
+ /* usbb1_ulpiphy_dat2 */
+ { USBB1_ULPITLL_DAT2 , IEN | PTD | M4 },
+ /* usbb1_ulpiphy_dat3 */
+ { USBB1_ULPITLL_DAT3 , IEN | PTD | M4 },
+ /* usbb1_ulpiphy_dat4 */
+ { USBB1_ULPITLL_DAT4 , IEN | PTD | M4 },
+ /* usbb1_ulpiphy_dat5 */
+ { USBB1_ULPITLL_DAT5 , IEN | PTD | M4 },
+ /* usbb1_ulpiphy_dat6 */
+ { USBB1_ULPITLL_DAT6 , IEN | PTD | M4 },
+ /* usbb1_ulpiphy_dat7 */
+ { USBB1_ULPITLL_DAT7 , IEN | PTD | M4 },
+ /* usbb1_hsic_data */
+ { USBB1_HSIC_DATA , M0 },
+ /* usbb1_hsic_strobe */
+ { USBB1_HSIC_STROBE , M0 },
+ /* usbc1_icusb_dp */
+ { USBC1_ICUSB_DP , M0 },
+ /* usbc1_icusb_dm */
+ { USBC1_ICUSB_DM , M0 },
+ /* sdmmc1_clk */ /* SD card */
+ { SDMMC1_CLK , PTU | M0 },
+ /* sdmmc1_cmd */ /* SD card */
+ { SDMMC1_CMD , IEN | PTU | M0 },
+ /* sdmmc1_dat0 */ /* SD card */
+ { SDMMC1_DAT0 , IEN | PTU | M0 },
+ /* sdmmc1_dat1 */ /* SD card */
+ { SDMMC1_DAT1 , IEN | PTU | M0 },
+ /* sdmmc1_dat2 */ /* SD card */
+ { SDMMC1_DAT2 , IEN | PTU | M0 },
+ /* sdmmc1_dat3 */ /* SD card */
+ { SDMMC1_DAT3 , IEN | PTU | M0 },
+ /* sdmmc1_dat4 */ /* SD card */
+ { SDMMC1_DAT4 , IEN | PTU | M0 },
+ /* sdmmc1_dat5 */ /* SD card */
+ { SDMMC1_DAT5 , IEN | PTU | M0 },
+ /* sdmmc1_dat6 */ /* SD card */
+ { SDMMC1_DAT6 , IEN | PTU | M0 },
+ /* sdmmc1_dat7 */ /* SD card */
+ { SDMMC1_DAT7 , IEN | PTU | M0 },
+ /* gpio_110 */ /* tsp_pwr_gpio */
+ { ABE_MCBSP2_CLKX , M3 },
+ /* gpio_111 */ /* vbus_musb_pwron */
+ { ABE_MCBSP2_DR , IEN | M3 },
+ /* gpio_112 */ /* tsp_irq_gpio */
+ { ABE_MCBSP2_DX , WAKEUP_EN | IEN | PTU | M3 },
+ /* gpio_113 */ /* vbus_flag */
+ { ABE_MCBSP2_FSX , IEN | PTU | M3 },
+ /* safe_mode */
+ { ABE_MCBSP1_CLKX , IEN | PTD | M7 },
+ /* safe_mode */
+ { ABE_MCBSP1_DR , IEN | PTD | M7 },
+ /* abe_mcbsp1_dx */
+ { ABE_MCBSP1_DX , M0 },
+ /* abe_mcbsp1_fsx */
+ { ABE_MCBSP1_FSX , IEN | M0 },
+ /* abe_pdm_ul_data */
+ { ABE_PDM_UL_DATA , IEN | M0 },
+ /* abe_pdm_dl_data */
+ { ABE_PDM_DL_DATA , M0 },
+ /* abe_pdm_frame */
+ { ABE_PDM_FRAME , IEN | M0 },
+ /* abe_pdm_lb_clk */
+ { ABE_PDM_LB_CLK , IEN | M0 },
+ /* abe_clks */
+ { ABE_CLKS , IEN | M0 },
+ /* safe_mode */
+ { ABE_DMIC_CLK1 , IEN | PTD | M7 },
+ /* safe_mode */
+ { ABE_DMIC_DIN1 , IEN | PTD | M7 },
+ /* safe_mode */
+ { ABE_DMIC_DIN2 , IEN | PTD | M7 },
+ /* safe_mode */ /* bkl_en on gpio_122 ?? */
+ { ABE_DMIC_DIN3 , IEN | PTD | M7 },
+ /* uart2_cts */
+ { UART2_CTS , WAKEUP_EN | OFF_PU | OFF_IN | M0 },
+ /* safe_mode */
+ { UART2_RTS , OFF_PU | OFF_IN | M7 },
+ /* uart2_rx */
+ { UART2_RX , IEN | PTU | M0 },
+ /* uart2_tx */
+ { UART2_TX , M0 },
+ /* gpio_127 */ /* audio_power_on */
+ { HDQ_SIO , M3 },
+ /* i2c1_scl */
+ { I2C1_SCL , IEN | M0 },
+ /* i2c1_sda */
+ { I2C1_SDA , IEN | M0 },
+ /* i2c2_scl */
+ { I2C2_SCL , IEN | M0 },
+ /* i2c2_sda */
+ { I2C2_SDA , IEN | M0 },
+ /* i2c3_scl */
+ { I2C3_SCL , IEN | M0 },
+ /* i2c3_sda */
+ { I2C3_SDA , IEN | M0 },
+ /* i2c4_scl */
+ { I2C4_SCL , IEN | M0 },
+ /* i2c4_sda */
+ { I2C4_SDA , IEN | M0 },
+ /* mcspi1_clk */
+ { MCSPI1_CLK , IEN | M0 },
+ /* mcspi1_somi */
+ { MCSPI1_SOMI , IEN | M0 },
+ /* mcspi1_simo */
+ { MCSPI1_SIMO , IEN | M0 },
+ /* mcspi1_cs0 */
+ { MCSPI1_CS0 , IEN | PTD | M0 },
+ /* uart1_rx */
+ { MCSPI1_CS1 , WAKEUP_EN | IEN | M1 },
+ /* gpio_139 */
+ { MCSPI1_CS2 , M3 },
+ /* safe_mode */
+ { MCSPI1_CS3 , IEN | PTU | M7 },
+ /* uart1_tx */
+ { UART3_CTS_RCTX , M1 },
+ /* uart3_rts_sd */
+ { UART3_RTS_SD , M0 },
+ /* safe_mode */
+ { UART3_RX_IRRX , IEN | PTU | M7 },
+ /* safe_mode */
+ { UART3_TX_IRTX , IEN | PTD | M7 },
+ /* sdmmc5_clk */
+ { SDMMC5_CLK , PTU | M0 },
+ /* sdmmc5_cmd */
+ { SDMMC5_CMD , IEN | PTU | M0 },
+ /* sdmmc5_dat0 */
+ { SDMMC5_DAT0 , IEN | PTU | M0 },
+ /* sdmmc5_dat1 */
+ { SDMMC5_DAT1 , IEN | PTU | M0 },
+ /* sdmmc5_dat2 */
+ { SDMMC5_DAT2 , IEN | PTU | M0 },
+ /* sdmmc5_dat3 */
+ { SDMMC5_DAT3 , IEN | PTU | M0 },
+ /* sdmmc4_clk */
+ { MCSPI4_CLK , IEN | PTU | M1 },
+ /* sdmmc4_cmd */
+ { MCSPI4_SIMO , IEN | PTU | M1 },
+ /* sdmmc4_dat0 */
+ { MCSPI4_SOMI , IEN | PTU | M1 },
+ /* sdmmc4_dat3 */
+ { MCSPI4_CS0 , IEN | PTU | M1 },
+ /* sdmmc4_dat2 */
+ { UART4_RX , IEN | PTU | M1 },
+ /* sdmmc4_dat1 */
+ { UART4_TX , IEN | PTU | M1 },
+ /* gpio_157 */
+ { USBB2_ULPITLL_CLK , M3 },
+ /* dispc2_data23 */
+ { USBB2_ULPITLL_STP , M5 },
+ /* dispc2_data22 */
+ { USBB2_ULPITLL_DIR , M5 },
+ /* dispc2_data21 */
+ { USBB2_ULPITLL_NXT , M5 },
+ /* dispc2_data20 */
+ { USBB2_ULPITLL_DAT0 , M5 },
+ /* dispc2_data19 */
+ { USBB2_ULPITLL_DAT1 , M5 },
+ /* dispc2_data18 */
+ { USBB2_ULPITLL_DAT2 , M5 },
+ /* dispc2_data15 */
+ { USBB2_ULPITLL_DAT3 , M5 },
+ /* dispc2_data14 */
+ { USBB2_ULPITLL_DAT4 , M5 },
+ /* dispc2_data13 */
+ { USBB2_ULPITLL_DAT5 , M5 },
+ /* dispc2_data12 */
+ { USBB2_ULPITLL_DAT6 , M5 },
+ /* dispc2_data11 */
+ { USBB2_ULPITLL_DAT7 , M5 },
+ /* gpio_169 */
+ { USBB2_HSIC_DATA , M3 },
+ /* gpio_170 */
+ { USBB2_HSIC_STROBE , M3 },
+ /* kpd_col0 */
+ { KPD_COL3 , IEN | PTD | M1 },
+ /* kpd_col1 */
+ { KPD_COL4 , IEN | PTD | M1 },
+ /* kpd_col2 */
+ { KPD_COL5 , IEN | PTD | M1 },
+ /* gpio_174 */ /* accel_int2 */
+ { KPD_COL0 , IEN | PTU | M3 },
+ /* gpio_0 */ /* tsp_shtdwn_gpio */
+ { KPD_COL1 , IEN | PTD | M3 },
+ /* gpio_1 */
+ { KPD_COL2 , IEN | PTD | M3 },
+ /* kpd_row0 */
+ { KPD_ROW3 , IEN | PTD | M1 },
+ /* kpd_row1 */
+ { KPD_ROW4 , IEN | PTD | M1 },
+ /* kpd_row2 */
+ { KPD_ROW5 , IEN | PTD | M1 },
+ /* kpd_row3 */
+ { KPD_ROW0 , IEN | PTD | M1 },
+ /* kpd_row4 */
+ { KPD_ROW1 , IEN | PTD | M1 },
+ /* kpd_row5 */
+ { KPD_ROW2 , IEN | PTD | M1 },
+ /* usba0_otg_ce */
+ { USBA0_OTG_CE , PTU | M0 },
+ /* usba0_otg_dp */
+ { USBA0_OTG_DP , M0 },
+ /* usba0_otg_dm */
+ { USBA0_OTG_DM , M0 },
+ /* safe_mode */
+ { FREF_CLK1_OUT , IEN | PTD | M7 },
+ /* fref_clk2_out */
+ { FREF_CLK2_OUT , M0 },
+ /* sys_nirq1 */
+ { SYS_NIRQ1 , WAKEUP_EN | IEN | PTU | M0 },
+ /* sys_nirq2 */ /* audio_irq */
+ { SYS_NIRQ2 , IEN | PTU | M0 },
+ /* sys_boot0 */
+ { SYS_BOOT0 , IEN | PTD | M0 },
+ /* sys_boot1 */
+ { SYS_BOOT1 , IEN | PTD | M0 },
+ /* sys_boot2 */
+ { SYS_BOOT2 , IEN | PTD | M0 },
+ /* sys_boot3 */
+ { SYS_BOOT3 , IEN | PTD | M0 },
+ /* sys_boot4 */
+ { SYS_BOOT4 , IEN | PTD | M0 },
+ /* sys_boot5 */
+ { SYS_BOOT5 , IEN | PTD | M0 },
+ /* dpm_emu0 */
+ { DPM_EMU0 , IEN | PTU | M0 },
+ /* gpio_12 */ /* lcd_avdd_en */
+ { DPM_EMU1 , IEN | M3 },
+ /* safe_mode */
+ { DPM_EMU2 , IEN | PTD | M7 },
+ /* dispc2_data10 */
+ { DPM_EMU3 , M5 },
+ /* dispc2_data9 */
+ { DPM_EMU4 , M5 },
+ /* dispc2_data16 */
+ { DPM_EMU5 , M5 },
+ /* dispc2_data17 */
+ { DPM_EMU6 , M5 },
+ /* dispc2_hsync */
+ { DPM_EMU7 , M5 },
+ /* dispc2_pclk */
+ { DPM_EMU8 , M5 },
+ /* dispc2_vsync */
+ { DPM_EMU9 , M5 },
+ /* dispc2_de */
+ { DPM_EMU10 , M5 },
+ /* dispc2_data8 */
+ { DPM_EMU11 , M5 },
+ /* dispc2_data7 */
+ { DPM_EMU12 , M5 },
+ /* dispc2_data6 */
+ { DPM_EMU13 , M5 },
+ /* dispc2_data5 */
+ { DPM_EMU14 , M5 },
+ /* dispc2_data4 */
+ { DPM_EMU15 , M5 },
+ /* dispc2_data3 */
+ { DPM_EMU16 , M5 },
+ /* dispc2_data2 */
+ { DPM_EMU17 , M5 },
+ /* dispc2_data1 */
+ { DPM_EMU18 , M5 },
+ /* dispc2_data0 */
+ { DPM_EMU19 , M5 },
+ /* safe_mode */
+ { CSI22_DX2 , IEN | PTD | M7 },
+ /* safe_mode */
+ { CSI22_DY2 , IEN | PTD | M7 },
+};
+
+static const struct pad_conf_entry wkup_padconf_array[] = {
+ /* sr_scl */
+ { SR_SCL , IEN },
+ /* sr_sda */
+ { SR_SDA , IEN },
+ /* fref_clk0_out */
+ { FREF_CLK0_OUT , M0 },
+ /* gpio_wk30 */
+ { FREF_CLK3_REQ , M3 },
+ /* gpio_wk7 */ /* tps62361_vsel0 */
+ { FREF_CLK4_REQ , IEN | PTU | M3 },
+};
+
+void set_muxconf_regs(void){
+ omap4_do_set_mux(OMAP44XX_CONTROL_PADCONF_CORE,
+ core_padconf_array, ARRAY_SIZE(core_padconf_array));
+ omap4_do_set_mux(OMAP44XX_CONTROL_PADCONF_WKUP,
+ wkup_padconf_array, ARRAY_SIZE(wkup_padconf_array));
+
+ /* gpio_wk7 is used for controlling TPS on 4460 */
+ if (omap4_revision() >= OMAP4460_ES1_0) {
+ writew(M3, OMAP44XX_CONTROL_PADCONF_WKUP + FREF_CLK4_REQ);
+ /* Enable GPIO-1 clocks before TPS initialization */
+ omap4_enable_gpio1_wup_clocks();
+ }
+}
diff --git a/arch/arm/boards/archosg9/mux.h b/arch/arm/boards/archosg9/mux.h
new file mode 100644
index 0000000..97297b6
--- /dev/null
+++ b/arch/arm/boards/archosg9/mux.h
@@ -0,0 +1,6 @@
+#ifndef _MUX_H
+#define _MUX_H
+
+void set_muxconf_regs(void);
+
+#endif /* _MUX_H */
diff --git a/arch/arm/configs/archosg9_defconfig b/arch/arm/configs/archosg9_defconfig
new file mode 100644
index 0000000..a03b5c9
--- /dev/null
+++ b/arch/arm/configs/archosg9_defconfig
@@ -0,0 +1,69 @@
+CONFIG_MACH_ARCHOSG9=y
+CONFIG_ARCH_OMAP=y
+CONFIG_ARCH_OMAP4=y
+CONFIG_AEABI=y
+# CONFIG_MACH_DO_LOWLEVEL_INIT is not set
+CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
+CONFIG_ARM_UNWIND=y
+# CONFIG_MMU is not set
+CONFIG_OMAP4_USBBOOT=y
+CONFIG_TEXT_BASE=0x8f000000
+CONFIG_MALLOC_SIZE=0x2000000
+CONFIG_KALLSYMS=y
+CONFIG_PROMPT="barebox> "
+CONFIG_LONGHELP=y
+CONFIG_GLOB=y
+CONFIG_HUSH_FANCY_PROMPT=y
+CONFIG_CMDLINE_EDITING=y
+CONFIG_AUTO_COMPLETE=y
+# CONFIG_CONSOLE_ACTIVATE_FIRST is not set
+CONFIG_CONSOLE_ACTIVATE_ALL=y
+# CONFIG_TIMESTAMP is not set
+CONFIG_DEFAULT_ENVIRONMENT_GENERIC=y
+CONFIG_DEFAULT_ENVIRONMENT_PATH="defaultenv defaultenv-2 arch/arm/boards/archosg9/env"
+CONFIG_CMD_EDIT=y
+CONFIG_CMD_SLEEP=y
+CONFIG_CMD_SAVEENV=y
+CONFIG_CMD_EXPORT=y
+CONFIG_CMD_PRINTENV=y
+CONFIG_CMD_READLINE=y
+CONFIG_CMD_TIME=y
+CONFIG_CMD_ECHO_E=y
+CONFIG_CMD_LOADB=y
+CONFIG_CMD_IOMEM=y
+CONFIG_CMD_FLASH=y
+CONFIG_CMD_MD5SUM=y
+CONFIG_CMD_SHA1SUM=y
+CONFIG_CMD_SHA224SUM=y
+CONFIG_CMD_SHA256SUM=y
+CONFIG_CMD_BOOTM_SHOW_TYPE=y
+CONFIG_CMD_BOOTM_VERBOSE=y
+CONFIG_CMD_BOOTM_INITRD=y
+CONFIG_CMD_BOOTM_OFTREE=y
+CONFIG_CMD_BOOTM_OFTREE_UIMAGE=y
+CONFIG_CMD_BOOTM_AIMAGE=y
+CONFIG_CMD_RESET=y
+CONFIG_CMD_GO=y
+CONFIG_CMD_TIMEOUT=y
+CONFIG_CMD_PARTITION=y
+CONFIG_CMD_MAGICVAR=y
+CONFIG_CMD_MAGICVAR_HELP=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_UNCOMPRESS=y
+CONFIG_CMD_I2C=y
+CONFIG_DRIVER_SERIAL_OMAP4_USBBOOT=y
+CONFIG_DRIVER_SERIAL_NS16550=y
+CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS=y
+CONFIG_BAUDRATE=57600
+# CONFIG_SPI is not set
+CONFIG_I2C=y
+CONFIG_I2C_OMAP=y
+CONFIG_I2C_TWLCORE=y
+CONFIG_I2C_TWL6030=y
+CONFIG_MCI=y
+CONFIG_MCI_STARTUP=y
+CONFIG_MCI_OMAP_HSMMC=y
+CONFIG_FS_FAT=y
+CONFIG_FS_FAT_WRITE=y
+CONFIG_FS_FAT_LFN=y
+CONFIG_FS_OMAP4_USBBOOT=y
diff --git a/arch/arm/configs/archosg9_xload_defconfig b/arch/arm/configs/archosg9_xload_defconfig
new file mode 100644
index 0000000..6c6782f
--- /dev/null
+++ b/arch/arm/configs/archosg9_xload_defconfig
@@ -0,0 +1,24 @@
+CONFIG_MACH_ARCHOSG9=y
+CONFIG_ARCH_OMAP=y
+CONFIG_ARCH_OMAP4=y
+# CONFIG_OMAP_GPMC is not set
+CONFIG_OMAP_BUILD_IFT=y
+CONFIG_BAREBOX_MAX_IMAGE_SIZE=0xC000
+CONFIG_AEABI=y
+CONFIG_OMAP4_USBBOOT=y
+# CONFIG_CMD_ARM_CPUINFO is not set
+CONFIG_TEXT_BASE=0x40300000
+CONFIG_MEMORY_LAYOUT_FIXED=y
+CONFIG_STACK_BASE=0x8f000000
+CONFIG_MALLOC_BASE=0x84000000
+CONFIG_MALLOC_SIZE=0x2000000
+CONFIG_SHELL_NONE=y
+# CONFIG_ERRNO_MESSAGES is not set
+# CONFIG_TIMESTAMP is not set
+# CONFIG_CONSOLE_FULL is not set
+# CONFIG_DEFAULT_ENVIRONMENT is not set
+CONFIG_DRIVER_SERIAL_OMAP4_USBBOOT=y
+# CONFIG_SPI is not set
+# CONFIG_FS_RAMFS is not set
+# CONFIG_FS_DEVFS is not set
+CONFIG_FS_OMAP4_USBBOOT=y
diff --git a/arch/arm/mach-omap/Kconfig b/arch/arm/mach-omap/Kconfig
index 16583cb..d47b007 100644
--- a/arch/arm/mach-omap/Kconfig
+++ b/arch/arm/mach-omap/Kconfig
@@ -111,6 +111,7 @@ config BOARDINFO
default "Phytec phyCORE pcm049" if MACH_PCM049
default "Phytec phyCARD-A-L1" if MACH_PCAAL1
default "Phytec phyCARD-A-XL2" if MACH_PCAAXL2
+ default "Archos G9" if MACH_ARCHOSG9
choice
prompt "Select OMAP board"
@@ -146,6 +147,14 @@ config MACH_PANDA
help
Say Y here if you are using OMAP4 Panda board
+config MACH_ARCHOSG9
+ bool "Archos G9 tablets"
+ select HAVE_NOSHELL
+ select MACH_HAS_LOWLEVEL_INIT
+ depends on ARCH_OMAP4
+ help
+ Say Y here if you are using OMAP4-based Archos G9 tablet
+
config MACH_PCM049
bool "Phytec phyCORE pcm049"
select HAVE_NOSHELL
diff --git a/arch/arm/tools/mach-types b/arch/arm/tools/mach-types
index 325513f..a21da3b 100644
--- a/arch/arm/tools/mach-types
+++ b/arch/arm/tools/mach-types
@@ -4148,3 +4148,4 @@ msm8625_evt MACH_MSM8625_EVT MSM8625_EVT 4193
mx53_sellwood MACH_MX53_SELLWOOD MX53_SELLWOOD 4194
somiq_am35 MACH_SOMIQ_AM35 SOMIQ_AM35 4195
somiq_am37 MACH_SOMIQ_AM37 SOMIQ_AM37 4196
+omap4_archosg9 MACH_OMAP4_ARCHOSG9 OMAP4_ARCHOSG9 5032
--
1.7.12.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 9/9] Add support for Archos G9 tablet
2012-09-30 2:50 ` [PATCH 9/9] Add support for Archos G9 tablet vj
@ 2012-09-30 14:00 ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-30 15:02 ` Antony Pavlov
1 sibling, 0 replies; 27+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-30 14:00 UTC (permalink / raw)
To: vj; +Cc: barebox
On 04:50 Sun 30 Sep , vj wrote:
> ---
> arch/arm/Makefile | 1 +
> arch/arm/boards/archosg9/Makefile | 3 +
> arch/arm/boards/archosg9/board.c | 72 +++++
> arch/arm/boards/archosg9/config.h | 1 +
> arch/arm/boards/archosg9/env/bin/init | 18 ++
> arch/arm/boards/archosg9/env/config | 2 +
> arch/arm/boards/archosg9/lowlevel.c | 133 +++++++++
> arch/arm/boards/archosg9/mux.c | 463 ++++++++++++++++++++++++++++++
> arch/arm/boards/archosg9/mux.h | 6 +
> arch/arm/configs/archosg9_defconfig | 69 +++++
> arch/arm/configs/archosg9_xload_defconfig | 24 ++
> arch/arm/mach-omap/Kconfig | 9 +
> arch/arm/tools/mach-types | 1 +
> 13 files changed, 802 insertions(+)
> create mode 100644 arch/arm/boards/archosg9/Makefile
> create mode 100644 arch/arm/boards/archosg9/board.c
> create mode 100644 arch/arm/boards/archosg9/config.h
> create mode 100644 arch/arm/boards/archosg9/env/bin/init
> create mode 100644 arch/arm/boards/archosg9/env/config
> create mode 100644 arch/arm/boards/archosg9/lowlevel.c
> create mode 100644 arch/arm/boards/archosg9/mux.c
> create mode 100644 arch/arm/boards/archosg9/mux.h
> create mode 100644 arch/arm/configs/archosg9_defconfig
> create mode 100644 arch/arm/configs/archosg9_xload_defconfig
>
> diff --git a/arch/arm/Makefile b/arch/arm/Makefile
> index 8e660be..8598005 100644
> --- a/arch/arm/Makefile
> +++ b/arch/arm/Makefile
> @@ -100,6 +100,7 @@ board-$(CONFIG_MACH_OMAP343xSDP) := omap343xdsp
> board-$(CONFIG_MACH_BEAGLE) := beagle
> board-$(CONFIG_MACH_OMAP3EVM) := omap3evm
> board-$(CONFIG_MACH_PANDA) := panda
> +board-$(CONFIG_MACH_ARCHOSG9) := archosg9
> board-$(CONFIG_MACH_PCM049) := pcm049
> board-$(CONFIG_MACH_PCA100) := phycard-i.MX27
> board-$(CONFIG_MACH_PCAAL1) := phycard-a-l1
> diff --git a/arch/arm/boards/archosg9/Makefile b/arch/arm/boards/archosg9/Makefile
> new file mode 100644
> index 0000000..53b9d5b
> --- /dev/null
> +++ b/arch/arm/boards/archosg9/Makefile
> @@ -0,0 +1,3 @@
> +obj-y += board.o
> +obj-y += lowlevel.o mux.o
> +pbl-y += lowlevel.o mux.o
> diff --git a/arch/arm/boards/archosg9/board.c b/arch/arm/boards/archosg9/board.c
> new file mode 100644
> index 0000000..5ef9126
> --- /dev/null
> +++ b/arch/arm/boards/archosg9/board.c
> @@ -0,0 +1,72 @@
> +/*
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * version 2 as published by the Free Software Foundation.
> + *
> + * 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 <init.h>
> +#include <ns16550.h>
> +#include <asm/armlinux.h>
> +#include <generated/mach-types.h>
> +#include <mach/silicon.h>
> +#include <sizes.h>
> +#include <i2c/i2c.h>
> +#include <gpio.h>
> +
drop all the ifdef and use if (IS_ENABLED
but add a the device will not hurt
> +#ifdef CONFIG_DRIVER_SERIAL_NS16550
> +static struct NS16550_plat serial_plat = {
> + .clock = 48000000, /* 48MHz (APLL96/2) */
> + .shift = 2,
> +};
> +#endif
> +static int archosg9_console_init(void){
> +#ifdef CONFIG_DRIVER_SERIAL_OMAP4_USBBOOT
> + add_generic_device("serial_omap4_usbboot", DEVICE_ID_DYNAMIC
> + , NULL, 0, 0, 0, NULL);
> +#endif
> +#if defined(CONFIG_DRIVER_SERIAL_NS16550)
> + gpio_direction_output(41, 0); /* gps_disable */
> + gpio_direction_output(34, 1); /* 1v8_pwron */
> + add_ns16550_device(DEVICE_ID_DYNAMIC, OMAP44XX_UART1_BASE, 1024,
> + IORESOURCE_MEM_8BIT, &serial_plat);
> +#endif
> + return 0;
> +}
> +console_initcall(archosg9_console_init);
> +
> +static int archosg9_mem_init(void){
> + arm_add_mem_device("ram0", 0x80000000, SZ_1G);
> + return 0;
> +}
> +mem_initcall(archosg9_mem_init);
> +
> +static struct i2c_board_info i2c_devices[] = {
> + { I2C_BOARD_INFO("twl6030", 0x48), },
> +};
> +
> +static int archosg9_devices_init(void){
> + i2c_register_board_info(0, i2c_devices, ARRAY_SIZE(i2c_devices));
> + add_generic_device("i2c-omap" , DEVICE_ID_DYNAMIC, NULL,
> + OMAP44XX_I2C1_BASE, 0x100, IORESOURCE_MEM, NULL);
> + add_generic_device("omap-hsmmc", DEVICE_ID_DYNAMIC, NULL,
> + OMAP44XX_MMC1_BASE, SZ_4K, IORESOURCE_MEM, NULL);
> + /* add_generic_device("omap-hsmmc", DEVICE_ID_DYNAMIC, NULL,
> + OMAP44XX_MMC2_BASE, SZ_4K, IORESOURCE_MEM, NULL); */
no dead code
> +
> + armlinux_set_bootparams((void *)0x80000100);
> + armlinux_set_architecture(MACH_TYPE_OMAP4_ARCHOSG9);
> +
> + return 0;
> +}
> +device_initcall(archosg9_devices_init);
> diff --git a/arch/arm/boards/archosg9/config.h b/arch/arm/boards/archosg9/config.h
> new file mode 100644
> index 0000000..da84fa5
> --- /dev/null
> +++ b/arch/arm/boards/archosg9/config.h
> @@ -0,0 +1 @@
> +/* nothing */
> diff --git a/arch/arm/boards/archosg9/env/bin/init b/arch/arm/boards/archosg9/env/bin/init
switch to the new defaultenv-2
> new file mode 100644
> index 0000000..e64ba50
> --- /dev/null
> +++ b/arch/arm/boards/archosg9/env/bin/init
> @@ -0,0 +1,18 @@
> +#!/bin/sh
> +
> +PATH=/env/bin
> +export PATH
> +
> +. /env/config
> +
> +if [ -n $autoboot_timeout ]; then
> + echo
> + echo -n "Hit any key to stop autoboot: "
> + timeout -a $autoboot_timeout
> + if [ $? != 0 ]; then
> + exit
> + fi
> +fi
> +mkdir /usb
> +mount -t omap4_usbbootfs omap4_usbboot /usb
> +bootm /usb/boot/zImage
> diff --git a/arch/arm/boards/archosg9/env/config b/arch/arm/boards/archosg9/env/config
> new file mode 100644
> index 0000000..9e8c1db
> --- /dev/null
> +++ b/arch/arm/boards/archosg9/env/config
> @@ -0,0 +1,2 @@
> +autoboot_timeout=3
> +bootargs="earlyprintk=serial console=ttyO1,57600n8"
> diff --git a/arch/arm/boards/archosg9/lowlevel.c b/arch/arm/boards/archosg9/lowlevel.c
> new file mode 100644
> index 0000000..a16253c
> --- /dev/null
> +++ b/arch/arm/boards/archosg9/lowlevel.c
> @@ -0,0 +1,133 @@
> +/*
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * version 2 as published by the Free Software Foundation.
> + *
> + * 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 <io.h>
> +#include <mach/omap4-mux.h>
> +#include <mach/omap4-silicon.h>
> +#include <mach/omap4-clock.h>
> +#include <mach/syslib.h>
> +#include <asm/barebox-arm.h>
> +#include "mux.h"
> +
> +#define TPS62361_VSEL0_GPIO 7
> +
> +static const struct ddr_regs ddr_regs_400_mhz_2cs = {
> + .tim1 = 0x10EB0662,
> + .tim2 = 0x20370DD2,
> + .tim3 = 0x00B1C33F,
> + .phy_ctrl_1 = 0x849FF408,
> + .ref_ctrl = 0x00000618,
> + .config_init = 0x80000EB9,
> + .config_final = 0x80001AB9,
> + .zq_config = 0xD00B3215,
> + .mr1 = 0x83,
> + .mr2 = 0x4
> +};
> +
> +/*
> +static unsigned prbs(unsigned state)
> +{
> + const unsigned POL = (1<<(32-1)) | (1<<(31-1)) | (1<<(20-1)) | \
> + (1<<(19-1)) | (1<<(13-1)) | (1<<(1-1));
> + unsigned i;
> + for (i = 0; i < 32; i++) {
> + if (state&1)
missing space arround '&'
please use checkpatch.pl
> + state = (state >> 1) ^ POL;
> + else
> + state = state >> 1;
> + }
> + return state;
> +}
> +static void memtest(void *x, unsigned count)
> +{
> + unsigned *w = x;
> + unsigned n, m;
> + unsigned chk;
> + count /= 8;
> +
> +#define PRINT early_printf
??
> + PRINT("memtest write\n");
> + for (chk = 0xa5a5a5a5, n = 0, m = count; n < count; n++, m++) {
> + chk = prbs(chk);
> + w[n] = chk;
> + w[m] = ~chk;
> + }
> + PRINT("memtest read\n");
> + for (n = 0, m = count; n < count; n++, m++) {
> + if (w[n] != ~w[m]) {
> + PRINT("ERROR [%08X]%08X != [%08X]%08X\n",
> + (unsigned) (w+n), w[n],
> + (unsigned) (w+m), ~w[m]);
> + return;
> + }
> + }
> + PRINT("memtest read2\n");
> + for (chk = 0xa5a5a5a5, n = 0, m = count; n < count; n++, m++) {
> + chk = prbs(chk);
> + if (w[n] != chk || w[m] != ~chk) {
> + PRINT("ERROR [%08X]%08X != [%08X]%08X != %08X\n",
> + (unsigned) (w+n), w[n],
> + (unsigned) (w+m), ~w[m], chk);
> + return;
> + }
> + }
> + PRINT("OK!\n");
> +}
> +*/
> +
> +static noinline void archosg9_init_lowlevel(void)
> +{
> + struct dpll_param core = OMAP4_CORE_DPLL_PARAM_19M2_DDR400;
> + struct dpll_param mpu = OMAP4_MPU_DPLL_PARAM_19M2_MPU600;
> + struct dpll_param iva = OMAP4_IVA_DPLL_PARAM_19M2;
> + struct dpll_param per = OMAP4_PER_DPLL_PARAM_19M2;
> + struct dpll_param abe = OMAP4_ABE_DPLL_PARAM_19M2;
> + struct dpll_param usb = OMAP4_USB_DPLL_PARAM_19M2;
> +
> + writel(CM_SYS_CLKSEL_19M2, CM_SYS_CLKSEL);
> +
> + /* Configure all DPLL's at 100% OPP */
> + omap4_configure_mpu_dpll(&mpu);
> + omap4_configure_iva_dpll(&iva);
> + omap4_configure_per_dpll(&per);
> + omap4_configure_abe_dpll(&abe);
> + omap4_configure_usb_dpll(&usb);
> +
> + /* Enable all clocks */
> + omap4_enable_all_clocks();
> +
> + set_muxconf_regs();
> +
> + omap4_ddr_init(&ddr_regs_400_mhz_2cs, &core);
> + /* Memory test */
> + /*memtest((void*)0x82000000, 8*1024*1024);*/
> + /* Full memory test */
> + /*memtest((void*)0x80000000, 1024*1024*1024);*/
> +
> + /* Set VCORE1 = 1.3 V, VCORE2 = VCORE3 = 1.21V */
> + omap4_scale_vcores(TPS62361_VSEL0_GPIO);
> + board_init_lowlevel_return();
> +}
> +
> +void board_init_lowlevel(void)
> +{
> + u32 r;
> +
> + r = 0x4030D000;
> + __asm__ __volatile__("mov sp, %0" : : "r"(r));
> +
> + archosg9_init_lowlevel();
> +}
> diff --git a/arch/arm/boards/archosg9/mux.c b/arch/arm/boards/archosg9/mux.c
> new file mode 100644
> index 0000000..af66ebb
> --- /dev/null
> +++ b/arch/arm/boards/archosg9/mux.c
> @@ -0,0 +1,463 @@
> +/*
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * version 2 as published by the Free Software Foundation.
> + *
> + * 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 <init.h>
> +#include <io.h>
> +#include <mach/omap4-silicon.h>
> +#include <mach/omap4-mux.h>
> +#include <mach/omap4-clock.h>
> +#include "mux.h"
> +
> +static const struct pad_conf_entry core_padconf_array[] = {
> + /* sdmmc2_dat0 */ /* internal FLASH */
> + { GPMC_AD0 , IEN | PTU | M1 },
> + /* sdmmc2_dat1 */ /* internal FLASH */
> + { GPMC_AD1 , IEN | PTU | M1 },
> + /* sdmmc2_dat2 */ /* internal FLASH */
> + { GPMC_AD2 , IEN | PTU | M1 },
> + /* sdmmc2_dat3 */ /* internal FLASH */
> + { GPMC_AD3 , IEN | PTU | M1 },
> + /* sdmmc2_dat4 */ /* internal FLASH */
> + { GPMC_AD4 , IEN | PTU | M1 },
> + /* sdmmc2_dat5 */ /* internal FLASH */
> + { GPMC_AD5 , IEN | PTU | M1 },
> + /* sdmmc2_dat6 */ /* internal FLASH */
> + { GPMC_AD6 , IEN | PTU | M1 },
> + /* sdmmc2_dat7 */ /* internal FLASH */
> + { GPMC_AD7 , IEN | PTU | M1 },
> + /* gpio_32 */
> + { GPMC_AD8 , IEN | PTD | M3 },
> + /* gpmc_ad9 */
> + { GPMC_AD9 , IEN | PTU | M0 },
> + /* gpio_34 */ /* 1v8_pwron */
> + { GPMC_AD10 , IEN | PTU | M3 },
> + /* gpio_35 */ /* vcc_pwron */
> + { GPMC_AD11 , IEN | PTU | M3 },
> + /* gpio_36 */ /* 5v_pwron */
> + { GPMC_AD12 , IEN | M3 },
> + /* gpio_37 */ /* hdmi_pwr */
> + { GPMC_AD13 , IEN | M3 },
> + /* gpio_38 */ /* lcd_pwon */
> + { GPMC_AD14 , IEN | M3 },
> + /* gpio_39 */ /* lvds_en */
> + { GPMC_AD15 , IEN | M3 },
> + /* gpio_40 */ /* 3g_enable */
> + { GPMC_A16 , IEN | M3 },
> + /* gpio_41 */ /* gps_enable */
> + { GPMC_A17 , IEN | M3 },
> + /* gpio_42 */ /* ehci_enable */
> + { GPMC_A18 , IEN | M3 },
> + /* gpio_43 */ /* volume up */
> + { GPMC_A19 , IEN | M3 },
> + /* gpio_44 */ /* volume down */
> + { GPMC_A20 , IEN | M3 },
> + /* gpio_45 */ /* accel_int1 */
> + { GPMC_A21 , IEN | PTU | M3 },
> + /* kpd_col6 */
> + { GPMC_A22 , IEN | PTD | M1 },
> + /* kpd_col7 */
> + { GPMC_A23 , IEN | PTD | M1 },
> + /* gpio_48 */ /* vbus_detect */
> + { GPMC_A24 , IEN | M3 },
> + /* gpio_49 */ /* id */
> + { GPMC_A25 , IEN | PTU | M3 },
> + /* gpmc_ncs0 */
> + { GPMC_NCS0 , IEN | PTU | M0 },
> + /* gpio_51 */ /* compass_data_ready */
> + { GPMC_NCS1 , IEN | M3 },
> + /* safe_mode */
> + { GPMC_NCS2 , IEN | PTU | M7 },
> + /* gpio_53 */ /* lcd_rst */
> + { GPMC_NCS3 , IEN | M3 },
> + /* gpmc_nwp */
> + { GPMC_NWP , IEN | PTD | M0 },
> + /* gpmc_clk */
> + { GPMC_CLK , IEN | PTD | M0 },
> + /* gpmc_nadv_ale */
> + { GPMC_NADV_ALE , IEN | PTD | M0 },
> + /* sdmmc2_clk */ /* internal FLASH */
> + { GPMC_NOE , IEN | PTU | M1 },
> + /* sdmmc2_cmd */ /* internal FLASH */
> + { GPMC_NWE , IEN | PTU | M1 },
> + /* gpmc_nbe0_cle */
> + { GPMC_NBE0_CLE , IEN | PTD | M0 },
> + /* safe_mode */
> + { GPMC_NBE1 , IEN | PTD | M7 },
> + /* gpmc_wait0 */
> + { GPMC_WAIT0 , IEN | PTU | M0 },
> + /* gpio_62 */ /* camera_reset */
> + { GPMC_WAIT1 , IEN | M3 },
> + /* safe_mode */
> + { GPMC_WAIT2 , IEN | PTD | M7 },
> + /* gpio_101 */ /* lcd_stdby */
> + { GPMC_NCS4 , M3 },
> + /* gpio_102 */ /* wifi_irq */
> + { GPMC_NCS5 , IEN | M3 },
> + /* gpio_103 */ /* wifi_power */
> + { GPMC_NCS6 , M3 },
> + /* gpio_104 */ /* bt_power */
> + { GPMC_NCS7 , IEN | M3 },
> + /* gpio_63 */ /* hdmi_hpd ?? */
> + { GPIO63 , IEN | PTD | M3 },
> + /* */
> + { GPIO64 , IEN | M0 },
> + /* */
> + { GPIO65 , IEN | M0 },
> + /* */
> + { GPIO66 , IEN | M0 },
> + /* csi21_dx0 */
> + { CSI21_DX0 , IEN | M0 },
> + /* csi21_dy0 */
> + { CSI21_DY0 , IEN | M0 },
> + /* csi21_dx1 */
> + { CSI21_DX1 , IEN | M0 },
> + /* csi21_dy1 */
> + { CSI21_DY1 , IEN | M0 },
> + /* safe_mode */
> + { CSI21_DX2 , IEN | PTD | M7 },
> + /* safe_mode */
> + { CSI21_DY2 , IEN | PTD | M7 },
> + /* safe_mode */
> + { CSI21_DX3 , IEN | PTD | M7 },
> + /* safe_mode */
> + { CSI21_DY3 , IEN | PTD | M7 },
> + /* safe_mode */
> + { CSI21_DX4 , IEN | PTD | M7 },
> + /* safe_mode */
> + { CSI21_DY4 , IEN | PTD | M7 },
> + /* safe_mode */
> + { CSI22_DX0 , IEN | PTD | M7 },
> + /* safe_mode */
> + { CSI22_DY0 , IEN | PTD | M7 },
> + /* safe_mode */
> + { CSI22_DX1 , IEN | PTD | M7 },
> + /* safe_mode */
> + { CSI22_DY1 , IEN | PTD | M7 },
> + /* cam_shutter */
> + { CAM_SHUTTER , PTD | M0 },
> + /* cam_strobe */
> + { CAM_STROBE , PTD | M0 },
> + /* gpio_83 */
> + { CAM_GLOBALRESET , PTD | M3 },
> + /* usbb1_ulpiphy_clk */
> + { USBB1_ULPITLL_CLK , IEN | PTD | M4 },
> + /* usbb1_ulpiphy_stp */
> + { USBB1_ULPITLL_STP , M4 },
> + /* usbb1_ulpiphy_dir */
> + { USBB1_ULPITLL_DIR , IEN | PTD | M4 },
> + /* usbb1_ulpiphy_nxt */
> + { USBB1_ULPITLL_NXT , IEN | PTD | M4 },
> + /* usbb1_ulpiphy_dat0 */
> + { USBB1_ULPITLL_DAT0 , WAKEUP_EN | IEN | PTD | M4 },
> + /* usbb1_ulpiphy_dat1 */
> + { USBB1_ULPITLL_DAT1 , IEN | PTD | M4 },
> + /* usbb1_ulpiphy_dat2 */
> + { USBB1_ULPITLL_DAT2 , IEN | PTD | M4 },
> + /* usbb1_ulpiphy_dat3 */
> + { USBB1_ULPITLL_DAT3 , IEN | PTD | M4 },
> + /* usbb1_ulpiphy_dat4 */
> + { USBB1_ULPITLL_DAT4 , IEN | PTD | M4 },
> + /* usbb1_ulpiphy_dat5 */
> + { USBB1_ULPITLL_DAT5 , IEN | PTD | M4 },
> + /* usbb1_ulpiphy_dat6 */
> + { USBB1_ULPITLL_DAT6 , IEN | PTD | M4 },
> + /* usbb1_ulpiphy_dat7 */
> + { USBB1_ULPITLL_DAT7 , IEN | PTD | M4 },
> + /* usbb1_hsic_data */
> + { USBB1_HSIC_DATA , M0 },
> + /* usbb1_hsic_strobe */
> + { USBB1_HSIC_STROBE , M0 },
> + /* usbc1_icusb_dp */
> + { USBC1_ICUSB_DP , M0 },
> + /* usbc1_icusb_dm */
> + { USBC1_ICUSB_DM , M0 },
> + /* sdmmc1_clk */ /* SD card */
> + { SDMMC1_CLK , PTU | M0 },
> + /* sdmmc1_cmd */ /* SD card */
> + { SDMMC1_CMD , IEN | PTU | M0 },
> + /* sdmmc1_dat0 */ /* SD card */
> + { SDMMC1_DAT0 , IEN | PTU | M0 },
> + /* sdmmc1_dat1 */ /* SD card */
> + { SDMMC1_DAT1 , IEN | PTU | M0 },
> + /* sdmmc1_dat2 */ /* SD card */
> + { SDMMC1_DAT2 , IEN | PTU | M0 },
> + /* sdmmc1_dat3 */ /* SD card */
> + { SDMMC1_DAT3 , IEN | PTU | M0 },
> + /* sdmmc1_dat4 */ /* SD card */
> + { SDMMC1_DAT4 , IEN | PTU | M0 },
> + /* sdmmc1_dat5 */ /* SD card */
> + { SDMMC1_DAT5 , IEN | PTU | M0 },
> + /* sdmmc1_dat6 */ /* SD card */
> + { SDMMC1_DAT6 , IEN | PTU | M0 },
> + /* sdmmc1_dat7 */ /* SD card */
> + { SDMMC1_DAT7 , IEN | PTU | M0 },
> + /* gpio_110 */ /* tsp_pwr_gpio */
> + { ABE_MCBSP2_CLKX , M3 },
> + /* gpio_111 */ /* vbus_musb_pwron */
> + { ABE_MCBSP2_DR , IEN | M3 },
> + /* gpio_112 */ /* tsp_irq_gpio */
> + { ABE_MCBSP2_DX , WAKEUP_EN | IEN | PTU | M3 },
> + /* gpio_113 */ /* vbus_flag */
> + { ABE_MCBSP2_FSX , IEN | PTU | M3 },
> + /* safe_mode */
> + { ABE_MCBSP1_CLKX , IEN | PTD | M7 },
> + /* safe_mode */
> + { ABE_MCBSP1_DR , IEN | PTD | M7 },
> + /* abe_mcbsp1_dx */
> + { ABE_MCBSP1_DX , M0 },
> + /* abe_mcbsp1_fsx */
> + { ABE_MCBSP1_FSX , IEN | M0 },
> + /* abe_pdm_ul_data */
> + { ABE_PDM_UL_DATA , IEN | M0 },
> + /* abe_pdm_dl_data */
> + { ABE_PDM_DL_DATA , M0 },
> + /* abe_pdm_frame */
> + { ABE_PDM_FRAME , IEN | M0 },
> + /* abe_pdm_lb_clk */
> + { ABE_PDM_LB_CLK , IEN | M0 },
> + /* abe_clks */
> + { ABE_CLKS , IEN | M0 },
> + /* safe_mode */
> + { ABE_DMIC_CLK1 , IEN | PTD | M7 },
> + /* safe_mode */
> + { ABE_DMIC_DIN1 , IEN | PTD | M7 },
> + /* safe_mode */
> + { ABE_DMIC_DIN2 , IEN | PTD | M7 },
> + /* safe_mode */ /* bkl_en on gpio_122 ?? */
> + { ABE_DMIC_DIN3 , IEN | PTD | M7 },
> + /* uart2_cts */
> + { UART2_CTS , WAKEUP_EN | OFF_PU | OFF_IN | M0 },
> + /* safe_mode */
> + { UART2_RTS , OFF_PU | OFF_IN | M7 },
> + /* uart2_rx */
> + { UART2_RX , IEN | PTU | M0 },
> + /* uart2_tx */
> + { UART2_TX , M0 },
> + /* gpio_127 */ /* audio_power_on */
> + { HDQ_SIO , M3 },
> + /* i2c1_scl */
> + { I2C1_SCL , IEN | M0 },
> + /* i2c1_sda */
> + { I2C1_SDA , IEN | M0 },
> + /* i2c2_scl */
> + { I2C2_SCL , IEN | M0 },
> + /* i2c2_sda */
> + { I2C2_SDA , IEN | M0 },
> + /* i2c3_scl */
> + { I2C3_SCL , IEN | M0 },
> + /* i2c3_sda */
> + { I2C3_SDA , IEN | M0 },
> + /* i2c4_scl */
> + { I2C4_SCL , IEN | M0 },
> + /* i2c4_sda */
> + { I2C4_SDA , IEN | M0 },
> + /* mcspi1_clk */
> + { MCSPI1_CLK , IEN | M0 },
> + /* mcspi1_somi */
> + { MCSPI1_SOMI , IEN | M0 },
> + /* mcspi1_simo */
> + { MCSPI1_SIMO , IEN | M0 },
> + /* mcspi1_cs0 */
> + { MCSPI1_CS0 , IEN | PTD | M0 },
> + /* uart1_rx */
> + { MCSPI1_CS1 , WAKEUP_EN | IEN | M1 },
> + /* gpio_139 */
> + { MCSPI1_CS2 , M3 },
> + /* safe_mode */
> + { MCSPI1_CS3 , IEN | PTU | M7 },
> + /* uart1_tx */
> + { UART3_CTS_RCTX , M1 },
> + /* uart3_rts_sd */
> + { UART3_RTS_SD , M0 },
> + /* safe_mode */
> + { UART3_RX_IRRX , IEN | PTU | M7 },
> + /* safe_mode */
> + { UART3_TX_IRTX , IEN | PTD | M7 },
> + /* sdmmc5_clk */
> + { SDMMC5_CLK , PTU | M0 },
> + /* sdmmc5_cmd */
> + { SDMMC5_CMD , IEN | PTU | M0 },
> + /* sdmmc5_dat0 */
> + { SDMMC5_DAT0 , IEN | PTU | M0 },
> + /* sdmmc5_dat1 */
> + { SDMMC5_DAT1 , IEN | PTU | M0 },
> + /* sdmmc5_dat2 */
> + { SDMMC5_DAT2 , IEN | PTU | M0 },
> + /* sdmmc5_dat3 */
> + { SDMMC5_DAT3 , IEN | PTU | M0 },
> + /* sdmmc4_clk */
> + { MCSPI4_CLK , IEN | PTU | M1 },
> + /* sdmmc4_cmd */
> + { MCSPI4_SIMO , IEN | PTU | M1 },
> + /* sdmmc4_dat0 */
> + { MCSPI4_SOMI , IEN | PTU | M1 },
> + /* sdmmc4_dat3 */
> + { MCSPI4_CS0 , IEN | PTU | M1 },
> + /* sdmmc4_dat2 */
> + { UART4_RX , IEN | PTU | M1 },
> + /* sdmmc4_dat1 */
> + { UART4_TX , IEN | PTU | M1 },
> + /* gpio_157 */
> + { USBB2_ULPITLL_CLK , M3 },
> + /* dispc2_data23 */
> + { USBB2_ULPITLL_STP , M5 },
> + /* dispc2_data22 */
> + { USBB2_ULPITLL_DIR , M5 },
> + /* dispc2_data21 */
> + { USBB2_ULPITLL_NXT , M5 },
> + /* dispc2_data20 */
> + { USBB2_ULPITLL_DAT0 , M5 },
> + /* dispc2_data19 */
> + { USBB2_ULPITLL_DAT1 , M5 },
> + /* dispc2_data18 */
> + { USBB2_ULPITLL_DAT2 , M5 },
> + /* dispc2_data15 */
> + { USBB2_ULPITLL_DAT3 , M5 },
> + /* dispc2_data14 */
> + { USBB2_ULPITLL_DAT4 , M5 },
> + /* dispc2_data13 */
> + { USBB2_ULPITLL_DAT5 , M5 },
> + /* dispc2_data12 */
> + { USBB2_ULPITLL_DAT6 , M5 },
> + /* dispc2_data11 */
> + { USBB2_ULPITLL_DAT7 , M5 },
> + /* gpio_169 */
> + { USBB2_HSIC_DATA , M3 },
> + /* gpio_170 */
> + { USBB2_HSIC_STROBE , M3 },
> + /* kpd_col0 */
> + { KPD_COL3 , IEN | PTD | M1 },
> + /* kpd_col1 */
> + { KPD_COL4 , IEN | PTD | M1 },
> + /* kpd_col2 */
> + { KPD_COL5 , IEN | PTD | M1 },
> + /* gpio_174 */ /* accel_int2 */
> + { KPD_COL0 , IEN | PTU | M3 },
> + /* gpio_0 */ /* tsp_shtdwn_gpio */
> + { KPD_COL1 , IEN | PTD | M3 },
> + /* gpio_1 */
> + { KPD_COL2 , IEN | PTD | M3 },
> + /* kpd_row0 */
> + { KPD_ROW3 , IEN | PTD | M1 },
> + /* kpd_row1 */
> + { KPD_ROW4 , IEN | PTD | M1 },
> + /* kpd_row2 */
> + { KPD_ROW5 , IEN | PTD | M1 },
> + /* kpd_row3 */
> + { KPD_ROW0 , IEN | PTD | M1 },
> + /* kpd_row4 */
> + { KPD_ROW1 , IEN | PTD | M1 },
> + /* kpd_row5 */
> + { KPD_ROW2 , IEN | PTD | M1 },
> + /* usba0_otg_ce */
> + { USBA0_OTG_CE , PTU | M0 },
> + /* usba0_otg_dp */
> + { USBA0_OTG_DP , M0 },
> + /* usba0_otg_dm */
> + { USBA0_OTG_DM , M0 },
> + /* safe_mode */
> + { FREF_CLK1_OUT , IEN | PTD | M7 },
> + /* fref_clk2_out */
> + { FREF_CLK2_OUT , M0 },
> + /* sys_nirq1 */
> + { SYS_NIRQ1 , WAKEUP_EN | IEN | PTU | M0 },
> + /* sys_nirq2 */ /* audio_irq */
> + { SYS_NIRQ2 , IEN | PTU | M0 },
> + /* sys_boot0 */
> + { SYS_BOOT0 , IEN | PTD | M0 },
> + /* sys_boot1 */
> + { SYS_BOOT1 , IEN | PTD | M0 },
> + /* sys_boot2 */
> + { SYS_BOOT2 , IEN | PTD | M0 },
> + /* sys_boot3 */
> + { SYS_BOOT3 , IEN | PTD | M0 },
> + /* sys_boot4 */
> + { SYS_BOOT4 , IEN | PTD | M0 },
> + /* sys_boot5 */
> + { SYS_BOOT5 , IEN | PTD | M0 },
> + /* dpm_emu0 */
> + { DPM_EMU0 , IEN | PTU | M0 },
> + /* gpio_12 */ /* lcd_avdd_en */
> + { DPM_EMU1 , IEN | M3 },
> + /* safe_mode */
> + { DPM_EMU2 , IEN | PTD | M7 },
> + /* dispc2_data10 */
> + { DPM_EMU3 , M5 },
> + /* dispc2_data9 */
> + { DPM_EMU4 , M5 },
> + /* dispc2_data16 */
> + { DPM_EMU5 , M5 },
> + /* dispc2_data17 */
> + { DPM_EMU6 , M5 },
> + /* dispc2_hsync */
> + { DPM_EMU7 , M5 },
> + /* dispc2_pclk */
> + { DPM_EMU8 , M5 },
> + /* dispc2_vsync */
> + { DPM_EMU9 , M5 },
> + /* dispc2_de */
> + { DPM_EMU10 , M5 },
> + /* dispc2_data8 */
> + { DPM_EMU11 , M5 },
> + /* dispc2_data7 */
> + { DPM_EMU12 , M5 },
> + /* dispc2_data6 */
> + { DPM_EMU13 , M5 },
> + /* dispc2_data5 */
> + { DPM_EMU14 , M5 },
> + /* dispc2_data4 */
> + { DPM_EMU15 , M5 },
> + /* dispc2_data3 */
> + { DPM_EMU16 , M5 },
> + /* dispc2_data2 */
> + { DPM_EMU17 , M5 },
> + /* dispc2_data1 */
> + { DPM_EMU18 , M5 },
> + /* dispc2_data0 */
> + { DPM_EMU19 , M5 },
> + /* safe_mode */
> + { CSI22_DX2 , IEN | PTD | M7 },
> + /* safe_mode */
> + { CSI22_DY2 , IEN | PTD | M7 },
> +};
> +
> +static const struct pad_conf_entry wkup_padconf_array[] = {
> + /* sr_scl */
> + { SR_SCL , IEN },
> + /* sr_sda */
> + { SR_SDA , IEN },
> + /* fref_clk0_out */
> + { FREF_CLK0_OUT , M0 },
> + /* gpio_wk30 */
> + { FREF_CLK3_REQ , M3 },
> + /* gpio_wk7 */ /* tps62361_vsel0 */
> + { FREF_CLK4_REQ , IEN | PTU | M3 },
> +};
> +
> +void set_muxconf_regs(void){
> + omap4_do_set_mux(OMAP44XX_CONTROL_PADCONF_CORE,
> + core_padconf_array, ARRAY_SIZE(core_padconf_array));
> + omap4_do_set_mux(OMAP44XX_CONTROL_PADCONF_WKUP,
> + wkup_padconf_array, ARRAY_SIZE(wkup_padconf_array));
> +
> + /* gpio_wk7 is used for controlling TPS on 4460 */
> + if (omap4_revision() >= OMAP4460_ES1_0) {
> + writew(M3, OMAP44XX_CONTROL_PADCONF_WKUP + FREF_CLK4_REQ);
> + /* Enable GPIO-1 clocks before TPS initialization */
> + omap4_enable_gpio1_wup_clocks();
> + }
> +}
> diff --git a/arch/arm/boards/archosg9/mux.h b/arch/arm/boards/archosg9/mux.h
> new file mode 100644
> index 0000000..97297b6
> --- /dev/null
> +++ b/arch/arm/boards/archosg9/mux.h
> @@ -0,0 +1,6 @@
> +#ifndef _MUX_H
> +#define _MUX_H
> +
> +void set_muxconf_regs(void);
> +
> +#endif /* _MUX_H */
> diff --git a/arch/arm/configs/archosg9_defconfig b/arch/arm/configs/archosg9_defconfig
> new file mode 100644
> index 0000000..a03b5c9
> --- /dev/null
> +++ b/arch/arm/configs/archosg9_defconfig
> @@ -0,0 +1,69 @@
> +CONFIG_MACH_ARCHOSG9=y
> +CONFIG_ARCH_OMAP=y
> +CONFIG_ARCH_OMAP4=y
> +CONFIG_AEABI=y
> +# CONFIG_MACH_DO_LOWLEVEL_INIT is not set
> +CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
> +CONFIG_ARM_UNWIND=y
> +# CONFIG_MMU is not set
> +CONFIG_OMAP4_USBBOOT=y
> +CONFIG_TEXT_BASE=0x8f000000
> +CONFIG_MALLOC_SIZE=0x2000000
> +CONFIG_KALLSYMS=y
> +CONFIG_PROMPT="barebox> "
> +CONFIG_LONGHELP=y
> +CONFIG_GLOB=y
> +CONFIG_HUSH_FANCY_PROMPT=y
> +CONFIG_CMDLINE_EDITING=y
> +CONFIG_AUTO_COMPLETE=y
> +# CONFIG_CONSOLE_ACTIVATE_FIRST is not set
> +CONFIG_CONSOLE_ACTIVATE_ALL=y
> +# CONFIG_TIMESTAMP is not set
> +CONFIG_DEFAULT_ENVIRONMENT_GENERIC=y
> +CONFIG_DEFAULT_ENVIRONMENT_PATH="defaultenv defaultenv-2 arch/arm/boards/archosg9/env"
> +CONFIG_CMD_EDIT=y
> +CONFIG_CMD_SLEEP=y
> +CONFIG_CMD_SAVEENV=y
> +CONFIG_CMD_EXPORT=y
> +CONFIG_CMD_PRINTENV=y
> +CONFIG_CMD_READLINE=y
> +CONFIG_CMD_TIME=y
> +CONFIG_CMD_ECHO_E=y
> +CONFIG_CMD_LOADB=y
> +CONFIG_CMD_IOMEM=y
> +CONFIG_CMD_FLASH=y
> +CONFIG_CMD_MD5SUM=y
> +CONFIG_CMD_SHA1SUM=y
> +CONFIG_CMD_SHA224SUM=y
> +CONFIG_CMD_SHA256SUM=y
> +CONFIG_CMD_BOOTM_SHOW_TYPE=y
> +CONFIG_CMD_BOOTM_VERBOSE=y
> +CONFIG_CMD_BOOTM_INITRD=y
> +CONFIG_CMD_BOOTM_OFTREE=y
> +CONFIG_CMD_BOOTM_OFTREE_UIMAGE=y
> +CONFIG_CMD_BOOTM_AIMAGE=y
> +CONFIG_CMD_RESET=y
> +CONFIG_CMD_GO=y
> +CONFIG_CMD_TIMEOUT=y
> +CONFIG_CMD_PARTITION=y
> +CONFIG_CMD_MAGICVAR=y
> +CONFIG_CMD_MAGICVAR_HELP=y
> +CONFIG_CMD_GPIO=y
> +CONFIG_CMD_UNCOMPRESS=y
> +CONFIG_CMD_I2C=y
> +CONFIG_DRIVER_SERIAL_OMAP4_USBBOOT=y
> +CONFIG_DRIVER_SERIAL_NS16550=y
> +CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS=y
> +CONFIG_BAUDRATE=57600
57600 why nearly everyone use 115200
> +# CONFIG_SPI is not set
> +CONFIG_I2C=y
> +CONFIG_I2C_OMAP=y
> +CONFIG_I2C_TWLCORE=y
> +CONFIG_I2C_TWL6030=y
> +CONFIG_MCI=y
> +CONFIG_MCI_STARTUP=y
> +CONFIG_MCI_OMAP_HSMMC=y
> +CONFIG_FS_FAT=y
> +CONFIG_FS_FAT_WRITE=y
> +CONFIG_FS_FAT_LFN=y
> +CONFIG_FS_OMAP4_USBBOOT=y
> diff --git a/arch/arm/configs/archosg9_xload_defconfig b/arch/arm/configs/archosg9_xload_defconfig
> new file mode 100644
> index 0000000..6c6782f
> --- /dev/null
> +++ b/arch/arm/configs/archosg9_xload_defconfig
> @@ -0,0 +1,24 @@
> +CONFIG_MACH_ARCHOSG9=y
> +CONFIG_ARCH_OMAP=y
> +CONFIG_ARCH_OMAP4=y
> +# CONFIG_OMAP_GPMC is not set
> +CONFIG_OMAP_BUILD_IFT=y
> +CONFIG_BAREBOX_MAX_IMAGE_SIZE=0xC000
> +CONFIG_AEABI=y
> +CONFIG_OMAP4_USBBOOT=y
> +# CONFIG_CMD_ARM_CPUINFO is not set
> +CONFIG_TEXT_BASE=0x40300000
> +CONFIG_MEMORY_LAYOUT_FIXED=y
> +CONFIG_STACK_BASE=0x8f000000
> +CONFIG_MALLOC_BASE=0x84000000
> +CONFIG_MALLOC_SIZE=0x2000000
> +CONFIG_SHELL_NONE=y
> +# CONFIG_ERRNO_MESSAGES is not set
> +# CONFIG_TIMESTAMP is not set
> +# CONFIG_CONSOLE_FULL is not set
> +# CONFIG_DEFAULT_ENVIRONMENT is not set
> +CONFIG_DRIVER_SERIAL_OMAP4_USBBOOT=y
> +# CONFIG_SPI is not set
> +# CONFIG_FS_RAMFS is not set
> +# CONFIG_FS_DEVFS is not set
> +CONFIG_FS_OMAP4_USBBOOT=y
> diff --git a/arch/arm/mach-omap/Kconfig b/arch/arm/mach-omap/Kconfig
> index 16583cb..d47b007 100644
> --- a/arch/arm/mach-omap/Kconfig
> +++ b/arch/arm/mach-omap/Kconfig
> @@ -111,6 +111,7 @@ config BOARDINFO
> default "Phytec phyCORE pcm049" if MACH_PCM049
> default "Phytec phyCARD-A-L1" if MACH_PCAAL1
> default "Phytec phyCARD-A-XL2" if MACH_PCAAXL2
> + default "Archos G9" if MACH_ARCHOSG9
alphabetic order pelase
>
> choice
> prompt "Select OMAP board"
> @@ -146,6 +147,14 @@ config MACH_PANDA
> help
> Say Y here if you are using OMAP4 Panda board
>
> +config MACH_ARCHOSG9
> + bool "Archos G9 tablets"
> + select HAVE_NOSHELL
> + select MACH_HAS_LOWLEVEL_INIT
> + depends on ARCH_OMAP4
> + help
> + Say Y here if you are using OMAP4-based Archos G9 tablet
> +
> config MACH_PCM049
> bool "Phytec phyCORE pcm049"
> select HAVE_NOSHELL
> diff --git a/arch/arm/tools/mach-types b/arch/arm/tools/mach-types
> index 325513f..a21da3b 100644
> --- a/arch/arm/tools/mach-types
> +++ b/arch/arm/tools/mach-types
> @@ -4148,3 +4148,4 @@ msm8625_evt MACH_MSM8625_EVT MSM8625_EVT 4193
> mx53_sellwood MACH_MX53_SELLWOOD MX53_SELLWOOD 4194
> somiq_am35 MACH_SOMIQ_AM35 SOMIQ_AM35 4195
> somiq_am37 MACH_SOMIQ_AM37 SOMIQ_AM37 4196
> +omap4_archosg9 MACH_OMAP4_ARCHOSG9 OMAP4_ARCHOSG9 5032
seperate patch to update whole file
Best Regards,
J.
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 9/9] Add support for Archos G9 tablet
2012-09-30 2:50 ` [PATCH 9/9] Add support for Archos G9 tablet vj
2012-09-30 14:00 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2012-09-30 15:02 ` Antony Pavlov
1 sibling, 0 replies; 27+ messages in thread
From: Antony Pavlov @ 2012-09-30 15:02 UTC (permalink / raw)
To: vj; +Cc: barebox
On 30 September 2012 06:50, vj <vicencb@gmail.com> wrote:
> ---
> arch/arm/Makefile | 1 +
> arch/arm/boards/archosg9/Makefile | 3 +
> arch/arm/boards/archosg9/board.c | 72 +++++
> arch/arm/boards/archosg9/config.h | 1 +
> arch/arm/boards/archosg9/env/bin/init | 18 ++
> arch/arm/boards/archosg9/env/config | 2 +
> arch/arm/boards/archosg9/lowlevel.c | 133 +++++++++
> arch/arm/boards/archosg9/mux.c | 463 ++++++++++++++++++++++++++++++
> arch/arm/boards/archosg9/mux.h | 6 +
> arch/arm/configs/archosg9_defconfig | 69 +++++
> arch/arm/configs/archosg9_xload_defconfig | 24 ++
> arch/arm/mach-omap/Kconfig | 9 +
> arch/arm/tools/mach-types | 1 +
> 13 files changed, 802 insertions(+)
> create mode 100644 arch/arm/boards/archosg9/Makefile
> create mode 100644 arch/arm/boards/archosg9/board.c
> create mode 100644 arch/arm/boards/archosg9/config.h
> create mode 100644 arch/arm/boards/archosg9/env/bin/init
> create mode 100644 arch/arm/boards/archosg9/env/config
> create mode 100644 arch/arm/boards/archosg9/lowlevel.c
> create mode 100644 arch/arm/boards/archosg9/mux.c
> create mode 100644 arch/arm/boards/archosg9/mux.h
> create mode 100644 arch/arm/configs/archosg9_defconfig
> create mode 100644 arch/arm/configs/archosg9_xload_defconfig
>
> diff --git a/arch/arm/Makefile b/arch/arm/Makefile
> index 8e660be..8598005 100644
> --- a/arch/arm/Makefile
> +++ b/arch/arm/Makefile
> @@ -100,6 +100,7 @@ board-$(CONFIG_MACH_OMAP343xSDP) := omap343xdsp
> board-$(CONFIG_MACH_BEAGLE) := beagle
> board-$(CONFIG_MACH_OMAP3EVM) := omap3evm
> board-$(CONFIG_MACH_PANDA) := panda
> +board-$(CONFIG_MACH_ARCHOSG9) := archosg9
> board-$(CONFIG_MACH_PCM049) := pcm049
> board-$(CONFIG_MACH_PCA100) := phycard-i.MX27
> board-$(CONFIG_MACH_PCAAL1) := phycard-a-l1
> diff --git a/arch/arm/boards/archosg9/Makefile b/arch/arm/boards/archosg9/Makefile
> new file mode 100644
> index 0000000..53b9d5b
> --- /dev/null
> +++ b/arch/arm/boards/archosg9/Makefile
> @@ -0,0 +1,3 @@
> +obj-y += board.o
> +obj-y += lowlevel.o mux.o
> +pbl-y += lowlevel.o mux.o
> diff --git a/arch/arm/boards/archosg9/board.c b/arch/arm/boards/archosg9/board.c
> new file mode 100644
> index 0000000..5ef9126
> --- /dev/null
> +++ b/arch/arm/boards/archosg9/board.c
> @@ -0,0 +1,72 @@
> +/*
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * version 2 as published by the Free Software Foundation.
> + *
> + * 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
> + */
see the following commit in the 'next' branch:
commit 77322aa896895f4f68501a071086e432e575dcc2
Author: Sascha Hauer <s.hauer@pengutronix.de>
Date: Tue Jul 31 09:51:20 2012 +0200
Treewide: remove address of the Free Software Foundation
The FSF address has changed in the past. Instead of updating it
each time the address changes, just drop it completely treewide.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
--
Best regards,
Antony Pavlov
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 0/9] archosg9: add support for tablet, second round
2012-09-30 2:50 [PATCH 0/9] archosg9: add support for tablet, second round vj
` (8 preceding siblings ...)
2012-09-30 2:50 ` [PATCH 9/9] Add support for Archos G9 tablet vj
@ 2012-10-02 17:06 ` Sascha Hauer
9 siblings, 0 replies; 27+ messages in thread
From: Sascha Hauer @ 2012-10-02 17:06 UTC (permalink / raw)
To: vj; +Cc: barebox
Hi,
On Sun, Sep 30, 2012 at 04:50:28AM +0200, vj wrote:
> Hello,
> here is the second round of patches including all the modifications suggested by your comments, which are greatly appreciated.
>
> There are also some improvements wrt the previous round of patches:
> 1.- Now there is no need to pass data from first to second stage.
> The second stage reopens the usb port and that works.
> 2.- The usb scripts have been splitted in several files.
>
> vj (9):
> ARM: set rev instead of returning it
> mmc_omap: improve error message
> omap4: add/rename definitions to match datasheet
> twl6030: add debug info
> add gitignore file
> omap4: add usb boot support
> omap4: add serial communications over usb boot
> omap4: add filesystem support over usb boot
> Add support for Archos G9 tablet
I applied 1/9, 2/9 and 5/9 as obvious bugfix/cleanups
Thanks
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 27+ messages in thread