U-Boot
Threads by month
- ----- 2025 -----
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2000 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
May 2008
- 200 participants
- 467 discussions

21 May '08
This patch adds the OMAP3 pin-mux register defines.
Signed-off-by: Nishanth Menon<x0nishan(a)ti.com>
---
include/asm-arm/arch-omap/omap3-mux.h | 423 ++++++++++++++++++++++++++++++++++
1 file changed, 423 insertions(+)
Index: u-boot-v2.git/include/asm-arm/arch-omap/omap3-mux.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ u-boot-v2.git/include/asm-arm/arch-omap/omap3-mux.h 2008-05-20 18:13:44.000000000 -0500
@@ -0,0 +1,423 @@
+/**
+ * @file
+ * @brief Mux Configuration Register defines for OMAP3
+ *
+ * FileName: include/asm-arm/arch-omap/omap3-mux.h
+ *
+ * This file defines the various Pin Mux registers
+ * @see include/asm-arm/arch-omap/control.h
+ * The @ref MUX_VAL macro uses the defines from this file
+ *
+ * Originally from http://linux.omap.com/pub/bootloader/3430sdp/u-boot-v1.tar.gz
+ */
+/*
+ * (C) Copyright 2006-2008
+ * Texas Instruments, <www.ti.com>
+ * Syed Mohammed Khasim <x0khasim(a)ti.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+#ifndef _ASM_ARCH_OMAP3_MUX_H_
+#define _ASM_ARCH_OMAP3_MUX_H_
+
+/**
+ * Pin Mux Enable Defines
+ *
+ * IEN - Input Enable
+ * IDIS - Input Disable
+ * PTD - Pull type Down
+ * PTU - Pull type Up
+ * DIS - Pull type selection is inactive
+ * EN - Pull type selection is active
+ * M0-7 - Mode 0-7
+ *
+ * @see MUX_VAL
+ */
+#define IEN (1 << 8)
+
+#define IDIS (0 << 8)
+#define PTU (1 << 4)
+#define PTD (0 << 4)
+#define EN (1 << 3)
+#define DIS (0 << 3)
+
+#define M0 0
+#define M1 1
+#define M2 2
+#define M3 3
+#define M4 4
+#define M5 5
+#define M6 6
+#define M7 7
+
+/*
+ * To get the actual address the offset has to added
+ * with OMAP_CTRL_BASE to get the actual address
+ */
+
+/* SDRC */
+#define CONTROL_PADCONF_SDRC_D0 0x0030
+#define CONTROL_PADCONF_SDRC_D1 0x0032
+#define CONTROL_PADCONF_SDRC_D2 0x0034
+#define CONTROL_PADCONF_SDRC_D3 0x0036
+#define CONTROL_PADCONF_SDRC_D4 0x0038
+#define CONTROL_PADCONF_SDRC_D5 0x003A
+#define CONTROL_PADCONF_SDRC_D6 0x003C
+#define CONTROL_PADCONF_SDRC_D7 0x003E
+#define CONTROL_PADCONF_SDRC_D8 0x0040
+#define CONTROL_PADCONF_SDRC_D9 0x0042
+#define CONTROL_PADCONF_SDRC_D10 0x0044
+#define CONTROL_PADCONF_SDRC_D11 0x0046
+#define CONTROL_PADCONF_SDRC_D12 0x0048
+#define CONTROL_PADCONF_SDRC_D13 0x004A
+#define CONTROL_PADCONF_SDRC_D14 0x004C
+#define CONTROL_PADCONF_SDRC_D15 0x004E
+#define CONTROL_PADCONF_SDRC_D16 0x0050
+#define CONTROL_PADCONF_SDRC_D17 0x0052
+#define CONTROL_PADCONF_SDRC_D18 0x0054
+#define CONTROL_PADCONF_SDRC_D19 0x0056
+#define CONTROL_PADCONF_SDRC_D20 0x0058
+#define CONTROL_PADCONF_SDRC_D21 0x005A
+#define CONTROL_PADCONF_SDRC_D22 0x005C
+#define CONTROL_PADCONF_SDRC_D23 0x005E
+#define CONTROL_PADCONF_SDRC_D24 0x0060
+#define CONTROL_PADCONF_SDRC_D25 0x0062
+#define CONTROL_PADCONF_SDRC_D26 0x0064
+#define CONTROL_PADCONF_SDRC_D27 0x0066
+#define CONTROL_PADCONF_SDRC_D28 0x0068
+#define CONTROL_PADCONF_SDRC_D29 0x006A
+#define CONTROL_PADCONF_SDRC_D30 0x006C
+#define CONTROL_PADCONF_SDRC_D31 0x006E
+#define CONTROL_PADCONF_SDRC_CLK 0x0070
+#define CONTROL_PADCONF_SDRC_DQS0 0x0072
+#define CONTROL_PADCONF_SDRC_DQS1 0x0074
+#define CONTROL_PADCONF_SDRC_DQS2 0x0076
+#define CONTROL_PADCONF_SDRC_DQS3 0x0078
+/* GPMC */
+#define CONTROL_PADCONF_GPMC_A1 0x007A
+#define CONTROL_PADCONF_GPMC_A2 0x007C
+#define CONTROL_PADCONF_GPMC_A3 0x007E
+#define CONTROL_PADCONF_GPMC_A4 0x0080
+#define CONTROL_PADCONF_GPMC_A5 0x0082
+#define CONTROL_PADCONF_GPMC_A6 0x0084
+#define CONTROL_PADCONF_GPMC_A7 0x0086
+#define CONTROL_PADCONF_GPMC_A8 0x0088
+#define CONTROL_PADCONF_GPMC_A9 0x008A
+#define CONTROL_PADCONF_GPMC_A10 0x008C
+#define CONTROL_PADCONF_GPMC_D0 0x008E
+#define CONTROL_PADCONF_GPMC_D1 0x0090
+#define CONTROL_PADCONF_GPMC_D2 0x0092
+#define CONTROL_PADCONF_GPMC_D3 0x0094
+#define CONTROL_PADCONF_GPMC_D4 0x0096
+#define CONTROL_PADCONF_GPMC_D5 0x0098
+#define CONTROL_PADCONF_GPMC_D6 0x009A
+#define CONTROL_PADCONF_GPMC_D7 0x009C
+#define CONTROL_PADCONF_GPMC_D8 0x009E
+#define CONTROL_PADCONF_GPMC_D9 0x00A0
+#define CONTROL_PADCONF_GPMC_D10 0x00A2
+#define CONTROL_PADCONF_GPMC_D11 0x00A4
+#define CONTROL_PADCONF_GPMC_D12 0x00A6
+#define CONTROL_PADCONF_GPMC_D13 0x00A8
+#define CONTROL_PADCONF_GPMC_D14 0x00AA
+#define CONTROL_PADCONF_GPMC_D15 0x00AC
+#define CONTROL_PADCONF_GPMC_NCS0 0x00AE
+#define CONTROL_PADCONF_GPMC_NCS1 0x00B0
+#define CONTROL_PADCONF_GPMC_NCS2 0x00B2
+#define CONTROL_PADCONF_GPMC_NCS3 0x00B4
+#define CONTROL_PADCONF_GPMC_NCS4 0x00B6
+#define CONTROL_PADCONF_GPMC_NCS5 0x00B8
+#define CONTROL_PADCONF_GPMC_NCS6 0x00BA
+#define CONTROL_PADCONF_GPMC_NCS7 0x00BC
+#define CONTROL_PADCONF_GPMC_CLK 0x00BE
+#define CONTROL_PADCONF_GPMC_NADV_ALE 0x00C0
+#define CONTROL_PADCONF_GPMC_NOE 0x00C2
+#define CONTROL_PADCONF_GPMC_NWE 0x00C4
+#define CONTROL_PADCONF_GPMC_NBE0_CLE 0x00C6
+#define CONTROL_PADCONF_GPMC_NBE1 0x00C8
+#define CONTROL_PADCONF_GPMC_NWP 0x00CA
+#define CONTROL_PADCONF_GPMC_WAIT0 0x00CC
+#define CONTROL_PADCONF_GPMC_WAIT1 0x00CE
+#define CONTROL_PADCONF_GPMC_WAIT2 0x00D0
+#define CONTROL_PADCONF_GPMC_WAIT3 0x00D2
+/* DSS */
+#define CONTROL_PADCONF_DSS_PCLK 0x00D4
+#define CONTROL_PADCONF_DSS_HSYNC 0x00D6
+#define CONTROL_PADCONF_DSS_VSYNC 0x00D8
+#define CONTROL_PADCONF_DSS_ACBIAS 0x00DA
+#define CONTROL_PADCONF_DSS_DATA0 0x00DC
+#define CONTROL_PADCONF_DSS_DATA1 0x00DE
+#define CONTROL_PADCONF_DSS_DATA2 0x00E0
+#define CONTROL_PADCONF_DSS_DATA3 0x00E2
+#define CONTROL_PADCONF_DSS_DATA4 0x00E4
+#define CONTROL_PADCONF_DSS_DATA5 0x00E6
+#define CONTROL_PADCONF_DSS_DATA6 0x00E8
+#define CONTROL_PADCONF_DSS_DATA7 0x00EA
+#define CONTROL_PADCONF_DSS_DATA8 0x00EC
+#define CONTROL_PADCONF_DSS_DATA9 0x00EE
+#define CONTROL_PADCONF_DSS_DATA10 0x00F0
+#define CONTROL_PADCONF_DSS_DATA11 0x00F2
+#define CONTROL_PADCONF_DSS_DATA12 0x00F4
+#define CONTROL_PADCONF_DSS_DATA13 0x00F6
+#define CONTROL_PADCONF_DSS_DATA14 0x00F8
+#define CONTROL_PADCONF_DSS_DATA15 0x00FA
+#define CONTROL_PADCONF_DSS_DATA16 0x00FC
+#define CONTROL_PADCONF_DSS_DATA17 0x00FE
+#define CONTROL_PADCONF_DSS_DATA18 0x0100
+#define CONTROL_PADCONF_DSS_DATA19 0x0102
+#define CONTROL_PADCONF_DSS_DATA20 0x0104
+#define CONTROL_PADCONF_DSS_DATA21 0x0106
+#define CONTROL_PADCONF_DSS_DATA22 0x0108
+#define CONTROL_PADCONF_DSS_DATA23 0x010A
+/* CAMERA */
+#define CONTROL_PADCONF_CAM_HS 0x010C
+#define CONTROL_PADCONF_CAM_VS 0x010E
+#define CONTROL_PADCONF_CAM_XCLKA 0x0110
+#define CONTROL_PADCONF_CAM_PCLK 0x0112
+#define CONTROL_PADCONF_CAM_FLD 0x0114
+#define CONTROL_PADCONF_CAM_D0 0x0116
+#define CONTROL_PADCONF_CAM_D1 0x0118
+#define CONTROL_PADCONF_CAM_D2 0x011A
+#define CONTROL_PADCONF_CAM_D3 0x011C
+#define CONTROL_PADCONF_CAM_D4 0x011E
+#define CONTROL_PADCONF_CAM_D5 0x0120
+#define CONTROL_PADCONF_CAM_D6 0x0122
+#define CONTROL_PADCONF_CAM_D7 0x0124
+#define CONTROL_PADCONF_CAM_D8 0x0126
+#define CONTROL_PADCONF_CAM_D9 0x0128
+#define CONTROL_PADCONF_CAM_D10 0x012A
+#define CONTROL_PADCONF_CAM_D11 0x012C
+#define CONTROL_PADCONF_CAM_XCLKB 0x012E
+#define CONTROL_PADCONF_CAM_WEN 0x0130
+#define CONTROL_PADCONF_CAM_STROBE 0x0132
+#define CONTROL_PADCONF_CSI2_DX0 0x0134
+#define CONTROL_PADCONF_CSI2_DY0 0x0136
+#define CONTROL_PADCONF_CSI2_DX1 0x0138
+#define CONTROL_PADCONF_CSI2_DY1 0x013A
+/* Audio Interface */
+#define CONTROL_PADCONF_MCBSP2_FSX 0x013C
+#define CONTROL_PADCONF_MCBSP2_CLKX 0x013E
+#define CONTROL_PADCONF_MCBSP2_DR 0x0140
+#define CONTROL_PADCONF_MCBSP2_DX 0x0142
+#define CONTROL_PADCONF_
+#define CONTROL_PADCONF_MMC1_CLK 0x0144
+#define CONTROL_PADCONF_MMC1_CMD 0x0146
+#define CONTROL_PADCONF_MMC1_DAT0 0x0148
+#define CONTROL_PADCONF_MMC1_DAT1 0x014A
+#define CONTROL_PADCONF_MMC1_DAT2 0x014C
+#define CONTROL_PADCONF_MMC1_DAT3 0x014E
+#define CONTROL_PADCONF_MMC1_DAT4 0x0150
+#define CONTROL_PADCONF_MMC1_DAT5 0x0152
+#define CONTROL_PADCONF_MMC1_DAT6 0x0154
+#define CONTROL_PADCONF_MMC1_DAT7 0x0156
+/* WirelesS LAN */
+#define CONTROL_PADCONF_MMC2_CLK 0x0158
+#define CONTROL_PADCONF_MMC2_CMD 0x015A
+#define CONTROL_PADCONF_MMC2_DAT0 0x015C
+#define CONTROL_PADCONF_MMC2_DAT1 0x015E
+#define CONTROL_PADCONF_MMC2_DAT2 0x0160
+#define CONTROL_PADCONF_MMC2_DAT3 0x0162
+#define CONTROL_PADCONF_MMC2_DAT4 0x0164
+#define CONTROL_PADCONF_MMC2_DAT5 0x0166
+#define CONTROL_PADCONF_MMC2_DAT6 0x0168
+#define CONTROL_PADCONF_MMC2_DAT7 0x016A
+/* Bluetooth */
+#define CONTROL_PADCONF_MCBSP3_DX 0x016C
+#define CONTROL_PADCONF_MCBSP3_DR 0x016E
+#define CONTROL_PADCONF_MCBSP3_CLKX 0x0170
+#define CONTROL_PADCONF_MCBSP3_FSX 0x0172
+#define CONTROL_PADCONF_UART2_CTS 0x0174
+#define CONTROL_PADCONF_UART2_RTS 0x0176
+#define CONTROL_PADCONF_UART2_TX 0x0178
+#define CONTROL_PADCONF_UART2_RX 0x017A
+/* Modem Interface */
+#define CONTROL_PADCONF_UART1_TX 0x017C
+#define CONTROL_PADCONF_UART1_RTS 0x017E
+#define CONTROL_PADCONF_UART1_CTS 0x0180
+#define CONTROL_PADCONF_UART1_RX 0x0182
+#define CONTROL_PADCONF_MCBSP4_CLKX 0x0184
+#define CONTROL_PADCONF_MCBSP4_DR 0x0186
+#define CONTROL_PADCONF_MCBSP4_DX 0x0188
+#define CONTROL_PADCONF_MCBSP4_FSX 0x018A
+#define CONTROL_PADCONF_MCBSP1_CLKR 0x018C
+#define CONTROL_PADCONF_MCBSP1_FSR 0x018E
+#define CONTROL_PADCONF_MCBSP1_DX 0x0190
+#define CONTROL_PADCONF_MCBSP1_DR 0x0192
+#define CONTROL_PADCONF_MCBSP_CLKS 0x0194
+#define CONTROL_PADCONF_MCBSP1_FSX 0x0196
+#define CONTROL_PADCONF_MCBSP1_CLKX 0x0198
+/* Serial Interface */
+#define CONTROL_PADCONF_UART3_CTS_RCTX 0x019A
+#define CONTROL_PADCONF_UART3_RTS_SD 0x019C
+#define CONTROL_PADCONF_UART3_RX_IRRX 0x019E
+#define CONTROL_PADCONF_UART3_TX_IRTX 0x01A0
+#define CONTROL_PADCONF_HSUSB0_CLK 0x01A2
+#define CONTROL_PADCONF_HSUSB0_STP 0x01A4
+#define CONTROL_PADCONF_HSUSB0_DIR 0x01A6
+#define CONTROL_PADCONF_HSUSB0_NXT 0x01A8
+#define CONTROL_PADCONF_HSUSB0_DATA0 0x01AA
+#define CONTROL_PADCONF_HSUSB0_DATA1 0x01AC
+#define CONTROL_PADCONF_HSUSB0_DATA2 0x01AE
+#define CONTROL_PADCONF_HSUSB0_DATA3 0x01B0
+#define CONTROL_PADCONF_HSUSB0_DATA4 0x01B2
+#define CONTROL_PADCONF_HSUSB0_DATA5 0x01B4
+#define CONTROL_PADCONF_HSUSB0_DATA6 0x01B6
+#define CONTROL_PADCONF_HSUSB0_DATA7 0x01B8
+#define CONTROL_PADCONF_I2C1_SCL 0x01BA
+#define CONTROL_PADCONF_I2C1_SDA 0x01BC
+#define CONTROL_PADCONF_I2C2_SCL 0x01BE
+#define CONTROL_PADCONF_I2C2_SDA 0x01C0
+#define CONTROL_PADCONF_I2C3_SCL 0x01C2
+#define CONTROL_PADCONF_I2C3_SDA 0x01C4
+#define CONTROL_PADCONF_I2C4_SCL 0x0A00
+#define CONTROL_PADCONF_I2C4_SDA 0x0A02
+#define CONTROL_PADCONF_HDQ_SIO 0x01C6
+#define CONTROL_PADCONF_MCSPI1_CLK 0x01C8
+#define CONTROL_PADCONF_MCSPI1_SIMO 0x01CA
+#define CONTROL_PADCONF_MCSPI1_SOMI 0x01CC
+#define CONTROL_PADCONF_MCSPI1_CS0 0x01CE
+#define CONTROL_PADCONF_MCSPI1_CS1 0x01D0
+#define CONTROL_PADCONF_MCSPI1_CS2 0x01D2
+#define CONTROL_PADCONF_MCSPI1_CS3 0x01D4
+#define CONTROL_PADCONF_MCSPI2_CLK 0x01D6
+#define CONTROL_PADCONF_MCSPI2_SIMO 0x01D8
+#define CONTROL_PADCONF_MCSPI2_SOMI 0x01DA
+#define CONTROL_PADCONF_MCSPI2_CS0 0x01DC
+#define CONTROL_PADCONF_MCSPI2_CS1 0x01DE
+/* Control and debug */
+#define CONTROL_PADCONF_SYS_32K 0x0A04
+#define CONTROL_PADCONF_SYS_CLKREQ 0x0A06
+#define CONTROL_PADCONF_SYS_NIRQ 0x01E0
+#define CONTROL_PADCONF_SYS_BOOT0 0x0A0A
+#define CONTROL_PADCONF_SYS_BOOT1 0x0A0C
+#define CONTROL_PADCONF_SYS_BOOT2 0x0A0E
+#define CONTROL_PADCONF_SYS_BOOT3 0x0A10
+#define CONTROL_PADCONF_SYS_BOOT4 0x0A12
+#define CONTROL_PADCONF_SYS_BOOT5 0x0A14
+#define CONTROL_PADCONF_SYS_BOOT6 0x0A16
+#define CONTROL_PADCONF_SYS_OFF_MODE 0x0A18
+#define CONTROL_PADCONF_SYS_CLKOUT1 0x0A1A
+#define CONTROL_PADCONF_SYS_CLKOUT2 0x01E2
+#define CONTROL_PADCONF_JTAG_NTRST 0x0A1C
+#define CONTROL_PADCONF_JTAG_TCK 0x0A1E
+#define CONTROL_PADCONF_JTAG_TMS 0x0A20
+#define CONTROL_PADCONF_JTAG_TDI 0x0A22
+#define CONTROL_PADCONF_JTAG_EMU0 0x0A24
+#define CONTROL_PADCONF_JTAG_EMU1 0x0A26
+#define CONTROL_PADCONF_ETK_CLK 0x0A28
+#define CONTROL_PADCONF_ETK_CTL 0x0A2A
+#define CONTROL_PADCONF_ETK_D0 0x0A2C
+#define CONTROL_PADCONF_ETK_D1 0x0A2E
+#define CONTROL_PADCONF_ETK_D2 0x0A30
+#define CONTROL_PADCONF_ETK_D3 0x0A32
+#define CONTROL_PADCONF_ETK_D4 0x0A34
+#define CONTROL_PADCONF_ETK_D5 0x0A36
+#define CONTROL_PADCONF_ETK_D6 0x0A38
+#define CONTROL_PADCONF_ETK_D7 0x0A3A
+#define CONTROL_PADCONF_ETK_D8 0x0A3C
+#define CONTROL_PADCONF_ETK_D9 0x0A3E
+#define CONTROL_PADCONF_ETK_D10 0x0A40
+#define CONTROL_PADCONF_ETK_D11 0x0A42
+#define CONTROL_PADCONF_ETK_D12 0x0A44
+#define CONTROL_PADCONF_ETK_D13 0x0A46
+#define CONTROL_PADCONF_ETK_D14 0x0A48
+#define CONTROL_PADCONF_ETK_D15 0x0A4A
+#define CONTROL_PADCONF_ETK_CLK_ES2 0x05D8
+#define CONTROL_PADCONF_ETK_CTL_ES2 0x05DA
+#define CONTROL_PADCONF_ETK_D0_ES2 0x05DC
+#define CONTROL_PADCONF_ETK_D1_ES2 0x05DE
+#define CONTROL_PADCONF_ETK_D2_ES2 0x05E0
+#define CONTROL_PADCONF_ETK_D3_ES2 0x05E2
+#define CONTROL_PADCONF_ETK_D4_ES2 0x05E4
+#define CONTROL_PADCONF_ETK_D5_ES2 0x05E6
+#define CONTROL_PADCONF_ETK_D6_ES2 0x05E8
+#define CONTROL_PADCONF_ETK_D7_ES2 0x05EA
+#define CONTROL_PADCONF_ETK_D8_ES2 0x05EC
+#define CONTROL_PADCONF_ETK_D9_ES2 0x05EE
+#define CONTROL_PADCONF_ETK_D10_ES2 0x05F0
+#define CONTROL_PADCONF_ETK_D11_ES2 0x05F2
+#define CONTROL_PADCONF_ETK_D12_ES2 0x05F4
+#define CONTROL_PADCONF_ETK_D13_ES2 0x05F6
+#define CONTROL_PADCONF_ETK_D14_ES2 0x05F8
+#define CONTROL_PADCONF_ETK_D15_ES2 0x05FA
+/* Die to die */
+#define CONTROL_PADCONF_D2D_MCAD0 0x01E4
+#define CONTROL_PADCONF_D2D_MCAD1 0x01E6
+#define CONTROL_PADCONF_D2D_MCAD2 0x01E8
+#define CONTROL_PADCONF_D2D_MCAD3 0x01EA
+#define CONTROL_PADCONF_D2D_MCAD4 0x01EC
+#define CONTROL_PADCONF_D2D_MCAD5 0x01EE
+#define CONTROL_PADCONF_D2D_MCAD6 0x01F0
+#define CONTROL_PADCONF_D2D_MCAD7 0x01F2
+#define CONTROL_PADCONF_D2D_MCAD8 0x01F4
+#define CONTROL_PADCONF_D2D_MCAD9 0x01F6
+#define CONTROL_PADCONF_D2D_MCAD10 0x01F8
+#define CONTROL_PADCONF_D2D_MCAD11 0x01FA
+#define CONTROL_PADCONF_D2D_MCAD12 0x01FC
+#define CONTROL_PADCONF_D2D_MCAD13 0x01FE
+#define CONTROL_PADCONF_D2D_MCAD14 0x0200
+#define CONTROL_PADCONF_D2D_MCAD15 0x0202
+#define CONTROL_PADCONF_D2D_MCAD16 0x0204
+#define CONTROL_PADCONF_D2D_MCAD17 0x0206
+#define CONTROL_PADCONF_D2D_MCAD18 0x0208
+#define CONTROL_PADCONF_D2D_MCAD19 0x020A
+#define CONTROL_PADCONF_D2D_MCAD20 0x020C
+#define CONTROL_PADCONF_D2D_MCAD21 0x020E
+#define CONTROL_PADCONF_D2D_MCAD22 0x0210
+#define CONTROL_PADCONF_D2D_MCAD23 0x0212
+#define CONTROL_PADCONF_D2D_MCAD24 0x0214
+#define CONTROL_PADCONF_D2D_MCAD25 0x0216
+#define CONTROL_PADCONF_D2D_MCAD26 0x0218
+#define CONTROL_PADCONF_D2D_MCAD27 0x021A
+#define CONTROL_PADCONF_D2D_MCAD28 0x021C
+#define CONTROL_PADCONF_D2D_MCAD29 0x021E
+#define CONTROL_PADCONF_D2D_MCAD30 0x0220
+#define CONTROL_PADCONF_D2D_MCAD31 0x0222
+#define CONTROL_PADCONF_D2D_MCAD32 0x0224
+#define CONTROL_PADCONF_D2D_MCAD33 0x0226
+#define CONTROL_PADCONF_D2D_MCAD34 0x0228
+#define CONTROL_PADCONF_D2D_MCAD35 0x022A
+#define CONTROL_PADCONF_D2D_MCAD36 0x022C
+#define CONTROL_PADCONF_D2D_CLK26MI 0x022E
+#define CONTROL_PADCONF_D2D_NRESPWRON 0x0230
+#define CONTROL_PADCONF_D2D_NRESWARM 0x0232
+#define CONTROL_PADCONF_D2D_ARM9NIRQ 0x0234
+#define CONTROL_PADCONF_D2D_UMA2P6FIQ 0x0236
+#define CONTROL_PADCONF_D2D_SPINT 0x0238
+#define CONTROL_PADCONF_D2D_FRINT 0x023A
+#define CONTROL_PADCONF_D2D_DMAREQ0 0x023C
+#define CONTROL_PADCONF_D2D_DMAREQ1 0x023E
+#define CONTROL_PADCONF_D2D_DMAREQ2 0x0240
+#define CONTROL_PADCONF_D2D_DMAREQ3 0x0242
+#define CONTROL_PADCONF_D2D_N3GTRST 0x0244
+#define CONTROL_PADCONF_D2D_N3GTDI 0x0246
+#define CONTROL_PADCONF_D2D_N3GTDO 0x0248
+#define CONTROL_PADCONF_D2D_N3GTMS 0x024A
+#define CONTROL_PADCONF_D2D_N3GTCK 0x024C
+#define CONTROL_PADCONF_D2D_N3GRTCK 0x024E
+#define CONTROL_PADCONF_D2D_MSTDBY 0x0250
+#define CONTROL_PADCONF_D2D_SWAKEUP 0x0A4C
+#define CONTROL_PADCONF_D2D_IDLEREQ 0x0252
+#define CONTROL_PADCONF_D2D_IDLEACK 0x0254
+#define CONTROL_PADCONF_D2D_MWRITE 0x0256
+#define CONTROL_PADCONF_D2D_SWRITE 0x0258
+#define CONTROL_PADCONF_D2D_MREAD 0x025A
+#define CONTROL_PADCONF_D2D_SREAD 0x025C
+#define CONTROL_PADCONF_D2D_MBUSFLAG 0x025E
+#define CONTROL_PADCONF_D2D_SBUSFLAG 0x0260
+#define CONTROL_PADCONF_SDRC_CKE0 0x0262
+#define CONTROL_PADCONF_SDRC_CKE1 0x0264
+
+#endif /* _ASM_ARCH_OMAP3_MUX_H_ */
1
0

[U-Boot-Users] [Patch 07/17] U-Boot-V2:Common: Make partitions configurable
by Menon, Nishanth 21 May '08
by Menon, Nishanth 21 May '08
21 May '08
Not all configurations of Uboot require partitions. This patch modifies partition compilation as configurable parameters.
Signed-off-by: Nishanth Menon<x0nishan(a)ti.com>
---
common/Kconfig | 4 ++++
common/Makefile | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
Index: u-boot-v2.git/common/Kconfig
===================================================================
--- u-boot-v2.git.orig/common/Kconfig 2008-05-20 17:26:30.000000000 -0500
+++ u-boot-v2.git/common/Kconfig 2008-05-20 17:26:35.000000000 -0500
@@ -205,6 +205,10 @@
bool
prompt "Open Firmware flat device tree support"
+config PARTITION
+ bool
+ prompt "Enable Partitions"
+
config DEFAULT_ENVIRONMENT
bool
default y
Index: u-boot-v2.git/common/Makefile
===================================================================
--- u-boot-v2.git.orig/common/Makefile 2008-05-20 17:19:41.000000000 -0500
+++ u-boot-v2.git/common/Makefile 2008-05-20 17:26:35.000000000 -0500
@@ -11,7 +11,7 @@
obj-y += clock.o
obj-y += command.o
obj-y += console.o
-obj-y += partition.o
+obj-$(CONFIG_PARTITION) += partition.o
obj-y += env.o
obj-y += startup.o
obj-y += misc.o
1
0
sizes.h is a nice little header useful in many cases. This is a move of the same from U-Boot V1 to here.
Signed-off-by: Nishanth Menon<x0nishan(a)ti.com>
---
include/asm-arm/sizes.h | 58 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
Index: u-boot-v2.git/include/asm-arm/sizes.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ u-boot-v2.git/include/asm-arm/sizes.h 2008-05-20 17:26:35.000000000 -0500
@@ -0,0 +1,58 @@
+/**
+ * @file
+ * @brief ARM specific size definitions
+ *
+ * FileName: include/asm-arm/sizes.h
+ */
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+/* DO NOT EDIT!! - this file automatically generated
+ * from .s file by awk -f s2h.awk
+ */
+/* Size defintions
+ * Copyright (C) ARM Limited 1998. All rights reserved.
+ */
+
+#ifndef __ASM_ARM_SIZES_H
+#define __ASM_ARM_SIZES_H
+
+/* handy sizes */
+#define SZ_1K 0x00000400
+#define SZ_4K 0x00001000
+#define SZ_8K 0x00002000
+#define SZ_16K 0x00004000
+#define SZ_64K 0x00010000
+#define SZ_128K 0x00020000
+#define SZ_256K 0x00040000
+#define SZ_512K 0x00080000
+
+#define SZ_1M 0x00100000
+#define SZ_2M 0x00200000
+#define SZ_4M 0x00400000
+#define SZ_8M 0x00800000
+#define SZ_16M 0x01000000
+#define SZ_32M 0x02000000
+#define SZ_64M 0x04000000
+#define SZ_128M 0x08000000
+#define SZ_256M 0x10000000
+#define SZ_512M 0x20000000
+
+#define SZ_1G 0x40000000
+#define SZ_2G 0x80000000
+
+#endif /*__ASM_ARM_SIZES_H */
+
+/* END */
1
0

[U-Boot-Users] [Patch 03/17] U-Boot-V2:ARM: Fix lds file for multiple section enable
by Menon, Nishanth 21 May '08
by Menon, Nishanth 21 May '08
21 May '08
By enabling -fdata-sections -ffunction-sections in arch/arm/Makefile, gcc splits the code into multiple sections. By using * wildcard we can bunch them into the areas we want them to be.
Signed-off-by: Nishanth Menon<x0nishan(a)ti.com>
---
arch/arm/lib/u-boot.lds.S | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
Index: u-boot-v2.git/arch/arm/lib/u-boot.lds.S
===================================================================
--- u-boot-v2.git.orig/arch/arm/lib/u-boot.lds.S 2008-05-20 17:19:43.000000000 -0500
+++ u-boot-v2.git/arch/arm/lib/u-boot.lds.S 2008-05-20 17:26:32.000000000 -0500
@@ -36,20 +36,20 @@
{
_stext = .;
_text = .;
- *(.text_entry)
- *(.text)
+ *(.text_entry*)
+ *(.text*)
}
. = ALIGN(4);
- .rodata : { *(.rodata) }
+ .rodata : { *(.rodata*) }
_etext = .; /* End of text and rodata section */
. = ALIGN(4);
- .data : { *(.data) }
+ .data : { *(.data*) }
. = ALIGN(4);
- .got : { *(.got) }
+ .got : { *(.got*) }
. = .;
__u_boot_cmd_start = .;
@@ -66,6 +66,6 @@
. = ALIGN(4);
__bss_start = .;
- .bss : { *(.bss) }
+ .bss : { *(.bss*) }
_end = .;
}
1
0

[U-Boot-Users] [Patch 01/17] U-Boot-V2: ARM: Add ARCH lowlevel Init[Try 3]
by Menon, Nishanth 21 May '08
by Menon, Nishanth 21 May '08
21 May '08
This Patch adds CONFIG_ARCH_HAS_LOWLEVEL_INIT as discussed in thread
http://www.nabble.com/-Patch--U-Boot-V2%3A-Introduce-CONFIG_ARCH_HAS_INIT_L…
Signed-off-by: Nishanth Menon<x0nishan(a)ti.com>
---
arch/arm/cpu/start-arm.S | 2 +-
arch/m68k/cpu/start-mcfv4e.S | 2 +-
common/Kconfig | 3 +++
3 files changed, 5 insertions(+), 2 deletions(-)
Index: u-boot-v2.git/arch/arm/cpu/start-arm.S
===================================================================
--- u-boot-v2.git.orig/arch/arm/cpu/start-arm.S 2008-05-20 17:19:44.000000000 -0500
+++ u-boot-v2.git/arch/arm/cpu/start-arm.S 2008-05-20 17:26:30.000000000 -0500
@@ -131,7 +131,7 @@
orr r0,r0,#0xd3
msr cpsr,r0
-#ifdef ARCH_HAS_INIT_LOWLEVEL
+#ifdef CONFIG_ARCH_HAS_LOWLEVEL_INIT
bl arch_init_lowlevel
#endif
/*
Index: u-boot-v2.git/arch/m68k/cpu/start-mcfv4e.S
===================================================================
--- u-boot-v2.git.orig/arch/m68k/cpu/start-mcfv4e.S 2008-05-20 17:19:44.000000000 -0500
+++ u-boot-v2.git/arch/m68k/cpu/start-mcfv4e.S 2008-05-20 17:26:30.000000000 -0500
@@ -406,7 +406,7 @@
* standard reset vector file, but also do some special things
* required only on their specific CPU.
*/
-#ifdef ARCH_HAS_INIT_LOWLEVEL
+#ifdef CONFIG_ARCH_HAS_LOWLEVEL_INIT
bsr.l arch_init_lowlevel
nop
#endif
Index: u-boot-v2.git/common/Kconfig
===================================================================
--- u-boot-v2.git.orig/common/Kconfig 2008-05-20 17:19:44.000000000 -0500
+++ u-boot-v2.git/common/Kconfig 2008-05-20 17:26:30.000000000 -0500
@@ -77,6 +77,9 @@
on many platforms. Disabling this option allows configurations to use
U-boot as a second stage boot loader.
+config ARCH_HAS_LOWLEVEL_INIT
+ bool
+
config PROMPT
string
prompt "U-Boot command prompt"
1
0
Hi all,
I am newbie. I am trying to port u-boot to my board. I did these things:
1. copy a existing board directory, say m5445evb, to a new one "mercury"
2. copy the M5445X_config section and rename it to "MERCURY_config"
3. change board name "m5445evb" in the "@mkconfig -a ..." line
to mercury
but when I try to compile u-boot make says "no rule to make target
.depend", needed by lib_mercury.a in the board/freescale/mercury
directory.
I can compile u-boot for m5445evb normally.
What's the matter?
2
2
Be the Tasmanian Lovemaking Devil and blow through the ladies http://www.nuterest.com/
1
0
Howdy,
I have a board PPC405GP DHT-Walnut. It has
# two pci slots, keyed for 5V only cards
# Promise Technologies PDC20265 IDE
After attaching an IDE driver to the slot, uboot recognizes it:
IDE: Bus 0: OK
Device 0: Model: SanDisk SDCFJ-2048 Firm: HDX 4.03 Ser#: 003405D2697E4543
Type: Removable Hard Disk
Capacity: 1953.9 MB = 1.9 GB (4001760 x 512)
Device 1: not available
Well. Then I load linux kernel 2.6.24 which compiled against
the default configuration for Walnut board. From the boot log,
it seems the kernel fails to recognize IDE drive. It tells nothing
about IDE.
Next, I recompile the kernel by selecting ATA, SATA... (all
IDE related options) in "make xconfig". However, the new kernel
still fails for IDE. And in the shell:
# fdisk -l // displays nothing
# fdisk /dev/hda // can't open /dev/hda. But the nodes in /dev
// have been created properly by using
// ELDK_MAKEDEV script.
My question is how to let linux kernel recognize my IDE? I think
it should be easy since uboot gets success, why not kernel?
For your information, I list the boot log here:
Linux version 2.6.24.2 (root@lily) (gcc version 4.2.2) #3 Wed May 21
16:17:26 CST 2008
IBM Walnut port (C) 2000-2002 MontaVista Software, Inc. (source(a)mvista.com)
Zone PFN ranges:
DMA 0 -> 8192
Normal 8192 -> 8192
Movable zone start PFN for each node
early_node_map[1] active PFN ranges
0: 0 -> 8192
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 8128
Kernel command line: root=/dev/nfs rw
nfsroot=192.168.1.102:/work/eldk/usr/src/rootfs
ip=192.168.1.200:192.168.1.100:::walnut:eth0:off panic=1
console=ttyS0,115200
PID hash table entries: 128 (order: 7, 512 bytes)
Warning: real time clock seems stuck!
console [ttyS0] enabled
Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
Memory: 29872k available (1976k kernel code, 480k data, 132k init, 0k highmem)
SLUB: Genslabs=11, HWalign=32, Order=0-1, MinObjects=4, CPUs=1, Nodes=1
Mount-cache hash table entries: 512
net_namespace: 64 bytes
NET: Registered protocol family 16
PCI: Probing PCI hardware
PCI: Cannot allocate resource region 4 of device 0000:00:04.0
SCSI subsystem initialized
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 1024 (order: 1, 8192 bytes)
TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
TCP: Hash tables configured (established 1024 bind 1024)
TCP reno registered
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
Generic RTC Driver v1.07
Serial: 8250/16550 driver $Revision: 1.90 $ 4 ports, IRQ sharing disabled
serial8250: ttyS0 at MMIO 0x0 (irq = 0) is a 16550A
serial8250: ttyS1 at MMIO 0x0 (irq = 1) is a 16550A
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: module loaded
PPC 4xx OCP EMAC driver, version 3.54
mal0: initialized, 1 TX channels, 1 RX channels
eth0: emac0, MAC de:ad:be:ef:00:00
eth0: found Generic MII PHY (0x09)
Found: AMD AM29LV040B
PPC40x-flash: Found 1 x8 devices at 0x0 in 8-bit bank
number of JEDEC chips: 1
cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness.
Creating 3 MTD partitions on "PPC40x-flash":
0x00000000-0x00020000 : "reserved"
0x00020000-0x00040000 : "env"
0x00040000-0x00080000 : "u-boot"
TCP cubic registered
NET: Registered protocol family 1
NET: Registered protocol family 17
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
eth0: link is down
eth0: link is up, 100 FDX
IP-Config: Guessing netmask 255.255.255.0
IP-Config: Complete:
device=eth0, addr=192.168.1.200, mask=255.255.255.0, gw=255.255.255.255,
host=walnut, domain=, nis-domain=(none),
bootserver=192.168.1.100, rootserver=192.168.1.102, rootpath=
Looking up port of RPC 100003/2 on 192.168.1.102
Looking up port of RPC 100005/1 on 192.168.1.102
VFS: Mounted root (nfs filesystem).
Freeing unused kernel memory: 132k init
init started: BusyBox v1.10.2 (2008-05-20 19:17:04 CST)
#
Thank you in advance!
---
ShenLei
1
2

21 May '08
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj(a)jcrosoft.com>
---
common/cmd_usb.c | 261 ++++++++++++++++++++-----------------
common/usb.c | 385 ++++++++++++++++++++++++++++--------------------------
common/usb_kbd.c | 317 +++++++++++++++++++++++----------------------
3 files changed, 506 insertions(+), 457 deletions(-)
diff --git a/common/cmd_usb.c b/common/cmd_usb.c
index 23413b5..b7d3d14 100644
--- a/common/cmd_usb.c
+++ b/common/cmd_usb.c
@@ -32,7 +32,7 @@
#include <usb.h>
#ifdef CONFIG_USB_STORAGE
-static int usb_stor_curr_dev=-1; /* current device */
+static int usb_stor_curr_dev = -1; /* current device */
#endif
/* some display routines (info command) */
@@ -62,7 +62,7 @@ char * usb_get_class_desc(unsigned char dclass)
}
}
-void usb_display_class_sub(unsigned char dclass,unsigned char subclass,unsigned char proto)
+void usb_display_class_sub(unsigned char dclass, unsigned char subclass, unsigned char proto)
{
switch(dclass) {
case USB_CLASS_PER_INTERFACE:
@@ -139,32 +139,41 @@ void usb_display_class_sub(unsigned char dclass,unsigned char subclass,unsigned
}
}
-void usb_display_string(struct usb_device *dev,int index)
+void usb_display_string(struct usb_device *dev, int index)
{
char buffer[256];
- if (index!=0) {
- if (usb_string(dev,index,&buffer[0],256)>0);
- printf("String: \"%s\"",buffer);
+
+ if (index != 0) {
+ if (usb_string(dev, index, &buffer[0], 256) > 0);
+ printf("String: \"%s\"", buffer);
}
}
void usb_display_desc(struct usb_device *dev)
{
- if (dev->descriptor.bDescriptorType==USB_DT_DEVICE) {
- printf("%d: %s, USB Revision %x.%x\n",dev->devnum,usb_get_class_desc(dev->config.if_desc[0].bInterfaceClass),
- (dev->descriptor.bcdUSB>>8) & 0xff,dev->descriptor.bcdUSB & 0xff);
+ if (dev->descriptor.bDescriptorType == USB_DT_DEVICE) {
+ printf("%d: %s, USB Revision %x.%x\n", dev->devnum,
+ usb_get_class_desc(dev->config.if_desc[0].bInterfaceClass),
+ (dev->descriptor.bcdUSB>>8) & 0xff ,dev->descriptor.bcdUSB & 0xff);
if (strlen(dev->mf) || strlen(dev->prod) || strlen(dev->serial))
- printf(" - %s %s %s\n",dev->mf,dev->prod,dev->serial);
+ printf(" - %s %s %s\n", dev->mf, dev->prod, dev->serial);
if (dev->descriptor.bDeviceClass) {
printf(" - Class: ");
- usb_display_class_sub(dev->descriptor.bDeviceClass,dev->descriptor.bDeviceSubClass,dev->descriptor.bDeviceProtocol);
+ usb_display_class_sub(dev->descriptor.bDeviceClass,
+ dev->descriptor.bDeviceSubClass,
+ dev->descriptor.bDeviceProtocol);
printf("\n");
}
else {
- printf(" - Class: (from Interface) %s\n",usb_get_class_desc(dev->config.if_desc[0].bInterfaceClass));
+ printf(" - Class: (from Interface) %s\n",
+ usb_get_class_desc(dev->config.if_desc[0].bInterfaceClass));
}
- printf(" - PacketSize: %d Configurations: %d\n",dev->descriptor.bMaxPacketSize0,dev->descriptor.bNumConfigurations);
- printf(" - Vendor: 0x%04x Product 0x%04x Version %d.%d\n",dev->descriptor.idVendor,dev->descriptor.idProduct,(dev->descriptor.bcdDevice>>8) & 0xff,dev->descriptor.bcdDevice & 0xff);
+ printf(" - PacketSize: %d Configurations: %d\n",
+ dev->descriptor.bMaxPacketSize0,dev->descriptor.bNumConfigurations);
+ printf(" - Vendor: 0x%04x Product 0x%04x Version %d.%d\n",
+ dev->descriptor.idVendor, dev->descriptor.idProduct,
+ (dev->descriptor.bcdDevice >> 8) & 0xff,
+ dev->descriptor.bcdDevice & 0xff);
}
}
@@ -172,42 +181,54 @@ void usb_display_desc(struct usb_device *dev)
void usb_display_conf_desc(struct usb_config_descriptor *config,struct usb_device *dev)
{
printf(" Configuration: %d\n",config->bConfigurationValue);
- printf(" - Interfaces: %d %s%s%dmA\n",config->bNumInterfaces,(config->bmAttributes & 0x40) ? "Self Powered " : "Bus Powered ",
- (config->bmAttributes & 0x20) ? "Remote Wakeup " : "",config->MaxPower*2);
+ printf(" - Interfaces: %d %s%s%dmA\n", config->bNumInterfaces,
+ (config->bmAttributes & 0x40) ? "Self Powered " : "Bus Powered ",
+ (config->bmAttributes & 0x20) ? "Remote Wakeup " : "", config->MaxPower * 2);
if (config->iConfiguration) {
printf(" - ");
- usb_display_string(dev,config->iConfiguration);
+ usb_display_string(dev, config->iConfiguration);
printf("\n");
}
}
-void usb_display_if_desc(struct usb_interface_descriptor *ifdesc,struct usb_device *dev)
+void usb_display_if_desc(struct usb_interface_descriptor *ifdesc, struct usb_device *dev)
{
printf(" Interface: %d\n",ifdesc->bInterfaceNumber);
- printf(" - Alternate Setting %d, Endpoints: %d\n",ifdesc->bAlternateSetting,ifdesc->bNumEndpoints);
+ printf(" - Alternate Setting %d, Endpoints: %d\n",
+ ifdesc->bAlternateSetting, ifdesc->bNumEndpoints);
printf(" - Class ");
- usb_display_class_sub(ifdesc->bInterfaceClass,ifdesc->bInterfaceSubClass,ifdesc->bInterfaceProtocol);
+ usb_display_class_sub(ifdesc->bInterfaceClass, ifdesc->bInterfaceSubClass,
+ ifdesc->bInterfaceProtocol);
printf("\n");
if (ifdesc->iInterface) {
printf(" - ");
- usb_display_string(dev,ifdesc->iInterface);
+ usb_display_string(dev, ifdesc->iInterface);
printf("\n");
}
}
void usb_display_ep_desc(struct usb_endpoint_descriptor *epdesc)
{
- printf(" - Endpoint %d %s ",epdesc->bEndpointAddress & 0xf,(epdesc->bEndpointAddress & 0x80) ? "In" : "Out");
+ printf(" - Endpoint %d %s ", epdesc->bEndpointAddress & 0xf,
+ (epdesc->bEndpointAddress & 0x80) ? "In" : "Out");
switch((epdesc->bmAttributes & 0x03))
{
- case 0: printf("Control"); break;
- case 1: printf("Isochronous"); break;
- case 2: printf("Bulk"); break;
- case 3: printf("Interrupt"); break;
+ case 0:
+ printf("Control");
+ break;
+ case 1:
+ printf("Isochronous");
+ break;
+ case 2:
+ printf("Bulk");
+ break;
+ case 3:
+ printf("Interrupt");
+ break;
}
- printf(" MaxPacket %d",epdesc->wMaxPacketSize);
- if ((epdesc->bmAttributes & 0x03)==0x3)
- printf(" Interval %dms",epdesc->bInterval);
+ printf(" MaxPacket %d", epdesc->wMaxPacketSize);
+ if ((epdesc->bmAttributes & 0x03) == 0x3)
+ printf(" Interval %dms", epdesc->bInterval);
printf("\n");
}
@@ -217,15 +238,15 @@ void usb_display_config(struct usb_device *dev)
struct usb_config_descriptor *config;
struct usb_interface_descriptor *ifdesc;
struct usb_endpoint_descriptor *epdesc;
- int i,ii;
+ int i, ii;
- config= &dev->config;
+ config = &dev->config;
usb_display_conf_desc(config,dev);
- for(i=0;i<config->no_of_if;i++) {
- ifdesc= &config->if_desc[i];
+ for(i = 0; i < config->no_of_if; i++) {
+ ifdesc = &config->if_desc[i];
usb_display_if_desc(ifdesc,dev);
- for(ii=0;ii<ifdesc->no_of_ep;ii++) {
- epdesc= &ifdesc->ep_desc[ii];
+ for(ii = 0; ii < ifdesc->no_of_ep; ii++) {
+ epdesc = &ifdesc->ep_desc[ii];
usb_display_ep_desc(epdesc);
}
}
@@ -233,31 +254,31 @@ void usb_display_config(struct usb_device *dev)
}
/* shows the device tree recursively */
-void usb_show_tree_graph(struct usb_device *dev,char *pre)
+void usb_show_tree_graph(struct usb_device *dev, char *pre)
{
int i,index;
- int has_child,last_child,port;
+ int has_child, last_child, port;
- index=strlen(pre);
+ index = strlen(pre);
printf(" %s",pre);
/* check if the device has connected children */
- has_child=0;
- for(i=0;i<dev->maxchild;i++) {
- if (dev->children[i]!=NULL)
- has_child=1;
+ has_child = 0;
+ for(i = 0; i < dev->maxchild; i++) {
+ if (dev->children[i] != NULL)
+ has_child = 1;
}
/* check if we are the last one */
- last_child=1;
- if (dev->parent!=NULL) {
- for(i=0;i<dev->parent->maxchild;i++) {
+ last_child = 1;
+ if (dev->parent != NULL) {
+ for(i = 0; i < dev->parent->maxchild; i++) {
/* search for children */
- if (dev->parent->children[i]==dev) {
+ if (dev->parent->children[i] == dev) {
/* found our pointer, see if we have a little sister */
- port=i;
- while(i++<dev->parent->maxchild) {
- if (dev->parent->children[i]!=NULL) {
+ port = i;
+ while(i++ < dev->parent->maxchild) {
+ if (dev->parent->children[i] != NULL) {
/* found a sister */
- last_child=0;
+ last_child = 0;
break;
} /* if */
} /* while */
@@ -265,28 +286,28 @@ void usb_show_tree_graph(struct usb_device *dev,char *pre)
} /* for all children of the parent */
printf("\b+-");
/* correct last child */
- if (last_child) {
- pre[index-1]=' ';
- }
+ if (last_child)
+ pre[index-1] =' ';
} /* if not root hub */
- else
+ else {
printf(" ");
- printf("%d ",dev->devnum);
- pre[index++]=' ';
- pre[index++]= has_child ? '|' : ' ';
- pre[index]=0;
- printf(" %s (%s, %dmA)\n",usb_get_class_desc(dev->config.if_desc[0].bInterfaceClass),
- dev->slow ? "1.5MBit/s" : "12MBit/s",dev->config.MaxPower * 2);
- if (strlen(dev->mf) ||
- strlen(dev->prod) ||
- strlen(dev->serial))
- printf(" %s %s %s %s\n",pre,dev->mf,dev->prod,dev->serial);
- printf(" %s\n",pre);
- if (dev->maxchild>0) {
- for(i=0;i<dev->maxchild;i++) {
- if (dev->children[i]!=NULL) {
- usb_show_tree_graph(dev->children[i],pre);
- pre[index]=0;
+ }
+ printf("%d ", dev->devnum);
+ pre[index++] = ' ';
+ pre[index++] = has_child ? '|' : ' ';
+ pre[index] = 0;
+ printf(" %s (%s, %dmA)\n", usb_get_class_desc(dev->config.if_desc[0].bInterfaceClass),
+ dev->slow ? "1.5MBit/s" : "12MBit/s", dev->config.MaxPower * 2);
+
+ if (strlen(dev->mf) || strlen(dev->prod) || strlen(dev->serial))
+ printf(" %s %s %s %s\n", pre, dev->mf, dev->prod, dev->serial);
+
+ printf(" %s\n", pre);
+ if (dev->maxchild > 0) {
+ for(i = 0; i < dev->maxchild; i++) {
+ if (dev->children[i] != NULL) {
+ usb_show_tree_graph(dev->children[i], pre);
+ pre[index] = 0;
}
}
}
@@ -297,8 +318,8 @@ void usb_show_tree(struct usb_device *dev)
{
char preamble[32];
- memset(preamble,0,32);
- usb_show_tree_graph(dev,&preamble[0]);
+ memset(preamble, 0, 32);
+ usb_show_tree_graph(dev, &preamble[0]);
}
@@ -310,7 +331,8 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
char *boot_device = NULL;
char *ep;
- int dev, part=1, rcode;
+ int dev, rcode;
+ int part = 1;
ulong addr, cnt;
disk_partition_t info;
image_header_t *hdr;
@@ -348,7 +370,7 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
printf ("\n** Device %d not available\n", dev);
return 1;
}
- if (stor_dev->block_read==NULL) {
+ if (stor_dev->block_read == NULL) {
printf("storage device not initialized. Use usb scan\n");
return 1;
}
@@ -364,13 +386,13 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
/* try to boot raw .... */
strncpy((char *)&info.type[0], BOOT_PART_TYPE, sizeof(BOOT_PART_TYPE));
strncpy((char *)&info.name[0], "Raw", 4);
- info.start=0;
- info.blksz=0x200;
- info.size=2880;
+ info.start = 0;
+ info.blksz = 0x200;
+ info.size = 2880;
printf("error reading partinfo...try to boot raw\n");
}
if ((strncmp((char *)info.type, BOOT_PART_TYPE, sizeof(info.type)) != 0) &&
- (strncmp((char *)info.type, BOOT_PART_COMP, sizeof(info.type)) != 0)) {
+ (strncmp((char *)info.type, BOOT_PART_COMP, sizeof(info.type)) != 0)) {
printf ("\n** Invalid partition type \"%.32s\""
" (expect \"" BOOT_PART_TYPE "\")\n",
info.type);
@@ -422,8 +444,8 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
cnt /= info.blksz;
cnt -= 1;
- if (stor_dev->block_read (dev, info.start+1, cnt,
- (ulong *)(addr+info.blksz)) != cnt) {
+ if (stor_dev->block_read (dev, info.start + 1, cnt,
+ (ulong *)(addr+info.blksz)) != cnt) {
printf ("\n** Read error on %d:%d\n", dev, part);
return 1;
}
@@ -437,23 +459,23 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
/* Loading ok, update default load address */
load_addr = addr;
- flush_cache (addr, (cnt+1)*info.blksz);
+ flush_cache (addr, (cnt + 1) * info.blksz);
/* Check if we should attempt an auto-start */
- if (((ep = getenv("autostart")) != NULL) && (strcmp(ep,"yes") == 0)) {
+ if (((ep = getenv("autostart")) != NULL) && (strcmp(ep, "yes") == 0)) {
char *local_args[2];
extern int do_bootm (cmd_tbl_t *, int, int, char *[]);
+
local_args[0] = argv[0];
local_args[1] = NULL;
printf ("Automatic boot of image at addr 0x%08lX ...\n", addr);
- rcode=do_bootm (cmdtp, 0, 1, local_args);
+ rcode = do_bootm (cmdtp, 0, 1, local_args);
return rcode;
}
return 0;
}
#endif /* CONFIG_USB_STORAGE */
-
/*********************************************************************************
* usb command intepreter
*/
@@ -475,14 +497,14 @@ int do_usb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
#ifdef CONFIG_USB_STORAGE
/* try to recognize storage devices immediately */
if (i >= 0)
- usb_stor_curr_dev = usb_stor_scan(1);
+ usb_stor_curr_dev = usb_stor_scan(1);
#endif
return 0;
}
- if (strncmp(argv[1],"stop",4) == 0) {
+ if (strncmp(argv[1], "stop", 4) == 0) {
#ifdef CONFIG_USB_KEYBOARD
- if (argc==2) {
- if (usb_kbd_deregister()!=0) {
+ if (argc == 2) {
+ if (usb_kbd_deregister() != 0) {
printf("USB not stopped: usbkbd still using USB\n");
return 1;
}
@@ -500,17 +522,18 @@ int do_usb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
printf("USB is stopped. Please issue 'usb start' first.\n");
return 1;
}
- if (strncmp(argv[1],"tree",4) == 0) {
+ if (strncmp(argv[1], "tree", 4) == 0) {
printf("\nDevice Tree:\n");
usb_show_tree(usb_get_dev_index(0));
return 0;
}
- if (strncmp(argv[1],"inf",3) == 0) {
+ if (strncmp(argv[1], "inf", 3) == 0) {
int d;
- if (argc==2) {
- for(d=0;d<USB_MAX_DEVICE;d++) {
- dev=usb_get_dev_index(d);
- if (dev==NULL)
+
+ if (argc == 2) {
+ for(d = 0; d < USB_MAX_DEVICE; d++) {
+ dev = usb_get_dev_index(d);
+ if (dev == NULL)
break;
usb_display_desc(dev);
usb_display_config(dev);
@@ -518,18 +541,16 @@ int do_usb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
return 0;
}
else {
- int d;
-
- i=simple_strtoul(argv[2], NULL, 16);
- printf("config for device %d\n",i);
- for(d=0;d<USB_MAX_DEVICE;d++) {
- dev=usb_get_dev_index(d);
- if (dev==NULL)
+ i = simple_strtoul(argv[2], NULL, 16);
+ printf("config for device %d\n", i);
+ for(d = 0; d < USB_MAX_DEVICE; d++) {
+ dev = usb_get_dev_index(d);
+ if (dev == NULL)
break;
- if (dev->devnum==i)
+ if (dev->devnum == i)
break;
}
- if (dev==NULL) {
+ if (dev == NULL) {
printf("*** NO Device avaiable ***\n");
return 0;
}
@@ -548,19 +569,19 @@ int do_usb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
return 0;
}
- if (strncmp(argv[1], "stor", 4) == 0) {
+ if (strncmp(argv[1], "stor", 4) == 0)
return usb_stor_info();
- }
- if (strncmp(argv[1],"part",4) == 0) {
+ if (strncmp(argv[1], "part", 4) == 0) {
int devno, ok;
- for (ok=0, devno=0; devno<USB_MAX_STOR_DEV; ++devno) {
- stor_dev=usb_stor_get_dev(devno);
- if (stor_dev->type!=DEV_TYPE_UNKNOWN) {
+
+ for (ok = 0, devno = 0; devno < USB_MAX_STOR_DEV; ++devno) {
+ stor_dev = usb_stor_get_dev(devno);
+ if (stor_dev->type != DEV_TYPE_UNKNOWN) {
ok++;
if (devno)
printf("\n");
- printf("print_part of %x\n",devno);
+ printf("print_part of %x\n", devno);
print_part(stor_dev);
}
}
@@ -570,22 +591,23 @@ int do_usb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
}
return 0;
}
- if (strcmp(argv[1],"read") == 0) {
- if (usb_stor_curr_dev<0) {
+ if (strcmp(argv[1], "read") == 0) {
+ if (usb_stor_curr_dev < 0) {
printf("no current device selected\n");
return 1;
}
- if (argc==5) {
+ if (argc == 5) {
unsigned long addr = simple_strtoul(argv[2], NULL, 16);
- unsigned long blk = simple_strtoul(argv[3], NULL, 16);
- unsigned long cnt = simple_strtoul(argv[4], NULL, 16);
+ unsigned long blk = simple_strtoul(argv[3], NULL, 16);
+ unsigned long cnt = simple_strtoul(argv[4], NULL, 16);
unsigned long n;
+
printf ("\nUSB read: device %d block # %ld, count %ld ... ",
usb_stor_curr_dev, blk, cnt);
- stor_dev=usb_stor_get_dev(usb_stor_curr_dev);
+ stor_dev = usb_stor_get_dev(usb_stor_curr_dev);
n = stor_dev->block_read(usb_stor_curr_dev, blk, cnt, (ulong *)addr);
printf ("%ld blocks read: %s\n",n,(n==cnt) ? "OK" : "ERROR");
- if (n==cnt)
+ if (n == cnt)
return 0;
return 1;
}
@@ -593,13 +615,14 @@ int do_usb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
if (strncmp(argv[1], "dev", 3) == 0) {
if (argc == 3) {
int dev = (int)simple_strtoul(argv[2], NULL, 10);
+
printf ("\nUSB device %d: ", dev);
if (dev >= USB_MAX_STOR_DEV) {
printf("unknown device\n");
return 1;
}
printf ("\n Device %d: ", dev);
- stor_dev=usb_stor_get_dev(dev);
+ stor_dev = usb_stor_get_dev(dev);
dev_print(stor_dev);
if (stor_dev->type == DEV_TYPE_UNKNOWN) {
return 1;
@@ -610,7 +633,7 @@ int do_usb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
}
else {
printf ("\nUSB device %d: ", usb_stor_curr_dev);
- stor_dev=usb_stor_get_dev(usb_stor_curr_dev);
+ stor_dev = usb_stor_get_dev(usb_stor_curr_dev);
dev_print(stor_dev);
if (stor_dev->type == DEV_TYPE_UNKNOWN) {
return 1;
diff --git a/common/usb.c b/common/usb.c
index 4df01ea..6c10282 100644
--- a/common/usb.c
+++ b/common/usb.c
@@ -1,5 +1,4 @@
/*
- *
* Most of this source has been derived from the Linux USB
* project:
* (C) Copyright Linus Torvalds 1999
@@ -10,7 +9,7 @@
* (C) Copyright Randy Dunlap 2000
* (C) Copyright David Brownell 2000 (kernel hotplug, usb_device_id)
* (C) Copyright Yggdrasil Computing, Inc. 2000
- * (usb_device_id matching changes by Adam J. Richter)
+ * (usb_device_id matching changes by Adam J. Richter)
*
* Adapted for U-Boot:
* (C) Copyright 2001 Denis Peter, MPL AG Switzerland
@@ -82,7 +81,6 @@ void usb_scan_devices(void);
int usb_hub_probe(struct usb_device *dev, int ifnum);
void usb_hub_reset(void);
-
/***********************************************************************
* wait_ms
*/
@@ -100,17 +98,17 @@ int usb_init(void)
{
int result;
- running=0;
- dev_index=0;
- asynch_allowed=1;
+ running = 0;
+ dev_index = 0;
+ asynch_allowed = 1;
usb_hub_reset();
/* init low_level USB */
printf("USB: ");
result = usb_lowlevel_init();
/* if lowlevel init is OK, scan the bus for devices i.e. search HUBs and configure them */
- if(result==0) {
+ if(result == 0) {
printf("scanning bus for devices... ");
- running=1;
+ running = 1;
usb_scan_devices();
usb_started = 1;
return 0;
@@ -127,7 +125,7 @@ int usb_init(void)
*/
int usb_stop(void)
{
- asynch_allowed=1;
+ asynch_allowed = 1;
usb_started = 0;
usb_hub_reset();
return usb_lowlevel_stop();
@@ -139,10 +137,9 @@ int usb_stop(void)
*/
void usb_disable_asynch(int disable)
{
- asynch_allowed=!disable;
+ asynch_allowed = !disable;
}
-
/*-------------------------------------------------------------------
* Message wrappers.
*
@@ -154,11 +151,11 @@ void usb_disable_asynch(int disable)
int usb_submit_int_msg(struct usb_device *dev, unsigned long pipe,
void *buffer,int transfer_len, int interval)
{
- return submit_int_msg(dev,pipe,buffer,transfer_len,interval);
+ return submit_int_msg(dev, pipe, buffer, transfer_len, interval);
}
/*
- * submits a control message and waits for comletion (at least timeout * 1ms)
+ * submits a control message and waits for completion (at least timeout * 1ms)
* If timeout is 0, we don't wait for completion (used as example to set and
* clear keyboards LEDs). For data transfers, (storage transfers) we don't
* allow control messages with 0 timeout, by previousely resetting the flag
@@ -171,7 +168,7 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe,
unsigned short value, unsigned short index,
void *data, unsigned short size, int timeout)
{
- if((timeout==0)&&(!asynch_allowed)) /* request for a asynch control pipe is not allowed */
+ if((timeout == 0) && (!asynch_allowed)) /* request for a asynch control pipe is not allowed */
return -1;
/* set setup command */
@@ -180,12 +177,12 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe,
setup_packet.value = swap_16(value);
setup_packet.index = swap_16(index);
setup_packet.length = swap_16(size);
- USB_PRINTF("usb_control_msg: request: 0x%X, requesttype: 0x%X\nvalue 0x%X index 0x%X length 0x%X\n",
+ USB_PRINTF("usb_control_msg: request: 0x%X, requesttype: 0x%X\nvalue 0x%X index 0x%X length 0x%X\n",
request,requesttype,value,index,size);
- dev->status=USB_ST_NOT_PROC; /*not yet processed */
+ dev->status = USB_ST_NOT_PROC; /*not yet processed */
- submit_control_msg(dev,pipe,data,size,&setup_packet);
- if(timeout==0) {
+ submit_control_msg(dev, pipe, data, size, &setup_packet);
+ if(timeout == 0) {
return (int)size;
}
while(timeout--) {
@@ -193,11 +190,10 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe,
break;
wait_ms(1);
}
- if(dev->status==0)
+ if(dev->status == 0)
return dev->act_len;
- else {
- return -1;
- }
+
+ return -1;
}
/*-------------------------------------------------------------------
@@ -210,20 +206,19 @@ int usb_bulk_msg(struct usb_device *dev, unsigned int pipe,
{
if (len < 0)
return -1;
- dev->status=USB_ST_NOT_PROC; /*not yet processed */
- submit_bulk_msg(dev,pipe,data,len);
+ dev->status = USB_ST_NOT_PROC; /*not yet processed */
+ submit_bulk_msg(dev, pipe, data, len);
while(timeout--) {
if(!((volatile unsigned long)dev->status & USB_ST_NOT_PROC))
break;
wait_ms(1);
}
- *actual_length=dev->act_len;
- if(dev->status==0)
+ *actual_length = dev->act_len;
+ if(dev->status == 0)
return 0;
- else
- return -1;
-}
+ return -1;
+}
/*-------------------------------------------------------------------
* Max Packet stuff
@@ -236,9 +231,9 @@ int usb_bulk_msg(struct usb_device *dev, unsigned int pipe,
int usb_maxpacket(struct usb_device *dev,unsigned long pipe)
{
if((pipe & USB_DIR_IN)==0) /* direction is out -> use emaxpacket out */
- return(dev->epmaxpacketout[((pipe>>15) & 0xf)]);
+ return(dev->epmaxpacketout[((pipe >> 15) & 0xf)]);
else
- return(dev->epmaxpacketin[((pipe>>15) & 0xf)]);
+ return(dev->epmaxpacketin[((pipe >> 15) & 0xf)]);
}
/*
@@ -249,27 +244,31 @@ int usb_set_maxpacket(struct usb_device *dev)
int i,ii,b;
struct usb_endpoint_descriptor *ep;
- for(i=0; i<dev->config.bNumInterfaces;i++) {
- for(ii=0; ii<dev->config.if_desc[i].bNumEndpoints; ii++) {
- ep=&dev->config.if_desc[i].ep_desc[ii];
- b=ep->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
+ for(i = 0; i < dev->config.bNumInterfaces; i++) {
+ for(ii = 0; ii < dev->config.if_desc[i].bNumEndpoints; ii++) {
+ ep = &dev->config.if_desc[i].ep_desc[ii];
+ b = ep->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
- if((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)==USB_ENDPOINT_XFER_CONTROL) { /* Control => bidirectional */
+ if((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
+ USB_ENDPOINT_XFER_CONTROL) { /* Control => bidirectional */
dev->epmaxpacketout[b] = ep->wMaxPacketSize;
dev->epmaxpacketin [b] = ep->wMaxPacketSize;
- USB_PRINTF("##Control EP epmaxpacketout/in[%d] = %d\n",b,dev->epmaxpacketin[b]);
+ USB_PRINTF("##Control EP epmaxpacketout/in[%d] = %d\n",
+ b, dev->epmaxpacketin[b]);
}
else {
- if ((ep->bEndpointAddress & 0x80)==0) { /* OUT Endpoint */
+ if ((ep->bEndpointAddress & 0x80) == 0) { /* OUT Endpoint */
if(ep->wMaxPacketSize > dev->epmaxpacketout[b]) {
dev->epmaxpacketout[b] = ep->wMaxPacketSize;
- USB_PRINTF("##EP epmaxpacketout[%d] = %d\n",b,dev->epmaxpacketout[b]);
+ USB_PRINTF("##EP epmaxpacketout[%d] = %d\n",
+ b, dev->epmaxpacketout[b]);
}
}
- else { /* IN Endpoint */
+ else { /* IN Endpoint */
if(ep->wMaxPacketSize > dev->epmaxpacketin[b]) {
dev->epmaxpacketin[b] = ep->wMaxPacketSize;
- USB_PRINTF("##EP epmaxpacketin[%d] = %d\n",b,dev->epmaxpacketin[b]);
+ USB_PRINTF("##EP epmaxpacketin[%d] = %d\n",
+ b, dev->epmaxpacketin[b]);
}
} /* if out */
} /* if control */
@@ -294,7 +293,7 @@ int usb_parse_config(struct usb_device *dev, unsigned char *buffer, int cfgno)
curr_if_num = -1;
dev->configno = cfgno;
- head = (struct usb_descriptor_header *) &buffer[0];
+ head = (struct usb_descriptor_header *)&buffer[0];
if(head->bDescriptorType != USB_DT_CONFIG) {
printf(" ERROR: NOT USB_CONFIG_DESC %x\n", head->bDescriptorType);
return -1;
@@ -305,11 +304,11 @@ int usb_parse_config(struct usb_device *dev, unsigned char *buffer, int cfgno)
index = dev->config.bLength;
/* Ok the first entry must be a configuration entry, now process the others */
- head = (struct usb_descriptor_header *) &buffer[index];
+ head = (struct usb_descriptor_header *)&buffer[index];
while(index + 1 < dev->config.wTotalLength) {
switch(head->bDescriptorType) {
case USB_DT_INTERFACE:
- if(((struct usb_interface_descriptor *) &buffer[index])->
+ if(((struct usb_interface_descriptor *)&buffer[index])->
bInterfaceNumber != curr_if_num) {
/* this is a new interface, copy new desc */
ifno = dev->config.no_of_if;
@@ -359,10 +358,11 @@ int usb_parse_config(struct usb_device *dev, unsigned char *buffer, int cfgno)
int usb_clear_halt(struct usb_device *dev, int pipe)
{
int result;
- int endp = usb_pipeendpoint(pipe)|(usb_pipein(pipe)<<7);
+ int endp = usb_pipeendpoint(pipe) | (usb_pipein(pipe) << 7);
result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
- USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT, 0, endp, NULL, 0, USB_CNTL_TIMEOUT * 3);
+ USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT, 0, endp, NULL,
+ 0, USB_CNTL_TIMEOUT * 3);
/* don't clear if failed */
if (result < 0)
@@ -384,10 +384,11 @@ int usb_clear_halt(struct usb_device *dev, int pipe)
/**********************************************************************
* get_descriptor type
*/
-int usb_get_descriptor(struct usb_device *dev, unsigned char type, unsigned char index, void *buf, int size)
+int usb_get_descriptor(struct usb_device *dev, unsigned char type, unsigned char index,
+ void *buf, int size)
{
int res;
- res = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
+ res = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
USB_REQ_GET_DESCRIPTOR, USB_DIR_IN,
(type << 8) + index, 0,
buf, size, USB_CNTL_TIMEOUT);
@@ -399,18 +400,17 @@ int usb_get_descriptor(struct usb_device *dev, unsigned char type, unsigned char
*/
int usb_get_configuration_no(struct usb_device *dev,unsigned char *buffer,int cfgno)
{
- int result;
+ int result;
unsigned int tmp;
struct usb_config_descriptor *config;
-
- config=(struct usb_config_descriptor *)&buffer[0];
+ config = (struct usb_config_descriptor *)&buffer[0];
result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, buffer, 8);
if (result < 8) {
if (result < 0)
- printf("unable to get descriptor, error %lX\n",dev->status);
+ printf("unable to get descriptor, error %lX\n", dev->status);
else
- printf("config descriptor too short (expected %i, got %i)\n",8,result);
+ printf("config descriptor too short (expected %i, got %i)\n", 8, result);
return -1;
}
tmp=swap_16(config->wTotalLength);
@@ -422,7 +422,7 @@ int usb_get_configuration_no(struct usb_device *dev,unsigned char *buffer,int cf
}
result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, buffer, tmp);
- USB_PRINTF("get_conf_no %d Result %d, wLength %d\n",cfgno,result,tmp);
+ USB_PRINTF("get_conf_no %d Result %d, wLength %d\n", cfgno, result, tmp);
return result;
}
@@ -435,10 +435,10 @@ int usb_set_address(struct usb_device *dev)
int res;
USB_PRINTF("set address %d\n",dev->devnum);
- res=usb_control_msg(dev, usb_snddefctrl(dev),
+ res = usb_control_msg(dev, usb_snddefctrl(dev),
USB_REQ_SET_ADDRESS, 0,
- (dev->devnum),0,
- NULL,0, USB_CNTL_TIMEOUT);
+ (dev->devnum), 0,
+ NULL, 0, USB_CNTL_TIMEOUT);
return res;
}
@@ -470,8 +470,8 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
return 0;
if ((ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
- USB_REQ_SET_INTERFACE, USB_RECIP_INTERFACE, alternate,
- interface, NULL, 0, USB_CNTL_TIMEOUT * 5)) < 0)
+ USB_REQ_SET_INTERFACE, USB_RECIP_INTERFACE, alternate,
+ interface, NULL, 0, USB_CNTL_TIMEOUT * 5)) < 0)
return ret;
return 0;
@@ -483,19 +483,20 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
int usb_set_configuration(struct usb_device *dev, int configuration)
{
int res;
- USB_PRINTF("set configuration %d\n",configuration);
+
+ USB_PRINTF("set configuration %d\n", configuration);
/* set setup command */
- res=usb_control_msg(dev, usb_sndctrlpipe(dev,0),
+ res = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
USB_REQ_SET_CONFIGURATION, 0,
- configuration,0,
- NULL,0, USB_CNTL_TIMEOUT);
- if(res==0) {
+ configuration, 0,
+ NULL, 0, USB_CNTL_TIMEOUT);
+ if(res == 0) {
dev->toggle[0] = 0;
dev->toggle[1] = 0;
return 0;
}
- else
- return -1;
+
+ return -1;
}
/********************************************************************
@@ -521,7 +522,8 @@ int usb_set_idle(struct usb_device *dev, int ifnum, int duration, int report_id)
/********************************************************************
* get report
*/
-int usb_get_report(struct usb_device *dev, int ifnum, unsigned char type, unsigned char id, void *buf, int size)
+int usb_get_report(struct usb_device *dev, int ifnum, unsigned char type,
+ unsigned char id, void *buf, int size)
{
return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
USB_REQ_GET_REPORT, USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
@@ -542,7 +544,8 @@ int usb_get_class_descriptor(struct usb_device *dev, int ifnum,
/********************************************************************
* get string index in buffer
*/
-int usb_get_string(struct usb_device *dev, unsigned short langid, unsigned char index, void *buf, int size)
+int usb_get_string(struct usb_device *dev, unsigned short langid,
+ unsigned char index, void *buf, int size)
{
int i;
int result;
@@ -561,10 +564,10 @@ int usb_get_string(struct usb_device *dev, unsigned short langid, unsigned char
return result;
}
-
static void usb_try_string_workarounds(unsigned char *buf, int *length)
{
- int newlength, oldlength = *length;
+ int newlength;
+ int oldlength = *length;
for (newlength = 2; newlength + 1 < oldlength; newlength += 2)
if (!isprint(buf[newlength]) || buf[newlength + 1])
@@ -576,7 +579,6 @@ static void usb_try_string_workarounds(unsigned char *buf, int *length)
}
}
-
static int usb_string_sub(struct usb_device *dev, unsigned int langid,
unsigned int index, unsigned char *buf)
{
@@ -611,7 +613,6 @@ static int usb_string_sub(struct usb_device *dev, unsigned int langid,
return rc;
}
-
/********************************************************************
* usb_string:
* Get string index and translate it to ascii.
@@ -627,20 +628,21 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
if (size <= 0 || !buf || !index)
return -1;
buf[0] = 0;
- tbuf=&mybuf[0];
+ tbuf = &mybuf[0];
/* get langid for strings if it's not yet known */
if (!dev->have_langid) {
err = usb_string_sub(dev, 0, 0, tbuf);
if (err < 0) {
- USB_PRINTF("error getting string descriptor 0 (error=%x)\n",dev->status);
+ USB_PRINTF("error getting string descriptor 0 (error=%x)\n",
+ dev->status);
return -1;
} else if (tbuf[0] < 4) {
USB_PRINTF("string descriptor 0 too short\n");
return -1;
} else {
dev->have_langid = -1;
- dev->string_langid = tbuf[2] | (tbuf[3]<< 8);
+ dev->string_langid = tbuf[2] | (tbuf[3] << 8);
/* always use the first langid listed */
USB_PRINTF("USB device number %d default language ID 0x%x\n",
dev->devnum, dev->string_langid);
@@ -655,8 +657,8 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
for (idx = 0, u = 2; u < err; u += 2) {
if (idx >= size)
break;
- if (tbuf[u+1]) /* high byte */
- buf[idx++] = '?'; /* non-ASCII character */
+ if (tbuf[u + 1]) /* high byte */
+ buf[idx++] = '?'; /* non-ASCII character */
else
buf[idx++] = tbuf[u];
}
@@ -665,70 +667,47 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
return err;
}
-
/********************************************************************
* USB device handling:
* the USB device are static allocated [USB_MAX_DEVICE].
*/
-
/* returns a pointer to the device with the index [index].
* if the device is not assigned (dev->devnum==-1) returns NULL
*/
struct usb_device * usb_get_dev_index(int index)
{
- if(usb_dev[index].devnum==-1)
+ if(usb_dev[index].devnum == -1)
return NULL;
- else
- return &usb_dev[index];
-}
+ return &usb_dev[index];
+}
/* returns a pointer of a new device structure or NULL, if
* no device struct is available
*/
-struct usb_device * usb_alloc_new_device(void)
+struct usb_device* usb_alloc_new_device(void)
{
int i;
+
USB_PRINTF("New Device %d\n",dev_index);
- if(dev_index==USB_MAX_DEVICE) {
- printf("ERROR, too many USB Devices, max=%d\n",USB_MAX_DEVICE);
+ if(dev_index == USB_MAX_DEVICE) {
+ printf("ERROR, too many USB Devices, max=%d\n", USB_MAX_DEVICE);
return NULL;
}
- usb_dev[dev_index].devnum=dev_index+1; /* default Address is 0, real addresses start with 1 */
- usb_dev[dev_index].maxchild=0;
- for(i=0;i<USB_MAXCHILDREN;i++)
- usb_dev[dev_index].children[i]=NULL;
- usb_dev[dev_index].parent=NULL;
+ usb_dev[dev_index].devnum = dev_index + 1; /* default Address is 0, real addresses start with 1 */
+ usb_dev[dev_index].maxchild = 0;
+ for(i = 0; i < USB_MAXCHILDREN; i++)
+ usb_dev[dev_index].children[i] = NULL;
+ usb_dev[dev_index].parent = NULL;
dev_index++;
- return &usb_dev[dev_index-1];
+ return &usb_dev[dev_index - 1];
}
-
-/*
- * By the time we get here, the device has gotten a new device ID
- * and is in the default state. We need to identify the thing and
- * get the ball rolling..
- *
- * Returns 0 for success, != 0 for error.
- */
-int usb_new_device(struct usb_device *dev)
-{
- int addr, err;
- int tmp;
- unsigned char tmpbuf[USB_BUFSIZ];
-
- dev->descriptor.bMaxPacketSize0 = 8; /* Start off at 8 bytes */
- dev->maxpacketsize = 0; /* Default to 8 byte max packet size */
- dev->epmaxpacketin [0] = 8;
- dev->epmaxpacketout[0] = 8;
-
- /* We still haven't set the Address yet */
- addr = dev->devnum;
- dev->devnum = 0;
-
#undef NEW_INIT_SEQ
#ifdef NEW_INIT_SEQ
+static inline init_sec(struct usb_device *dev)
+{
/* this is a Windows scheme of initialization sequence, with double
* reset of the device. Some equipment is said to work only with such
* init sequence; this patch is based on the work by Alan Stern:
@@ -740,8 +719,8 @@ int usb_new_device(struct usb_device *dev)
struct usb_device *parent = dev->parent;
unsigned short portstatus;
- /* send 64-byte GET-DEVICE-DESCRIPTOR request. Since the descriptor is
- * only 18 bytes long, this will terminate with a short packet. But if
+ /* send 64-byte GET-DEVICE-DESCRIPTOR request. Since the descriptor is
+ * only 18 bytes long, this will terminate with a short packet. But if
* the maxpacket size is 8 or 16 the device may be waiting to transmit
* some more. */
@@ -777,22 +756,65 @@ int usb_new_device(struct usb_device *dev)
return 1;
}
}
+
+ return 0;
+}
#else
+int init_sec(struct usb_device *dev)
+{
+ int err;
+
/* and this is the old and known way of initializing devices */
err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, &dev->descriptor, 8);
if (err < 8) {
printf("\n USB device not responding, giving up (status=%lX)\n",dev->status);
return 1;
}
+
+ return 0;
+}
#endif
+/*
+ * By the time we get here, the device has gotten a new device ID
+ * and is in the default state. We need to identify the thing and
+ * get the ball rolling..
+ *
+ * Returns 0 for success, != 0 for error.
+ */
+int usb_new_device(struct usb_device *dev)
+{
+ int addr, err;
+ int tmp;
+ unsigned char tmpbuf[USB_BUFSIZ];
+
+ dev->descriptor.bMaxPacketSize0 = 8; /* Start off at 8 bytes */
+ dev->maxpacketsize = 0; /* Default to 8 byte max packet size */
+ dev->epmaxpacketin [0] = 8;
+ dev->epmaxpacketout[0] = 8;
+
+ /* We still haven't set the Address yet */
+ addr = dev->devnum;
+ dev->devnum = 0;
+
+ err = init_sec(dev);
+ if(err)
+ return err;
dev->epmaxpacketin [0] = dev->descriptor.bMaxPacketSize0;
dev->epmaxpacketout[0] = dev->descriptor.bMaxPacketSize0;
switch (dev->descriptor.bMaxPacketSize0) {
- case 8: dev->maxpacketsize = 0; break;
- case 16: dev->maxpacketsize = 1; break;
- case 32: dev->maxpacketsize = 2; break;
- case 64: dev->maxpacketsize = 3; break;
+ case 8:
+ dev->maxpacketsize = 0;
+ break;
+ case 16:
+ dev->maxpacketsize = 1;
+ break;
+ case 32:
+ dev->maxpacketsize = 2;
+ break;
+ case 64:
+ dev->maxpacketsize = 3;
+ break;
}
dev->devnum = addr;
@@ -812,21 +834,21 @@ int usb_new_device(struct usb_device *dev)
if (err < 0)
printf("unable to get device descriptor (error=%d)\n",err);
else
- printf("USB device descriptor short read (expected %i, got %i)\n",tmp,err);
+ printf("USB device descriptor short read (expected %i, got %i)\n", tmp, err);
return 1;
}
/* correct le values */
- dev->descriptor.bcdUSB=swap_16(dev->descriptor.bcdUSB);
- dev->descriptor.idVendor=swap_16(dev->descriptor.idVendor);
- dev->descriptor.idProduct=swap_16(dev->descriptor.idProduct);
- dev->descriptor.bcdDevice=swap_16(dev->descriptor.bcdDevice);
+ dev->descriptor.bcdUSB = swap_16(dev->descriptor.bcdUSB);
+ dev->descriptor.idVendor = swap_16(dev->descriptor.idVendor);
+ dev->descriptor.idProduct = swap_16(dev->descriptor.idProduct);
+ dev->descriptor.bcdDevice = swap_16(dev->descriptor.bcdDevice);
/* only support for one config for now */
- usb_get_configuration_no(dev,&tmpbuf[0],0);
- usb_parse_config(dev,&tmpbuf[0],0);
+ usb_get_configuration_no(dev, &tmpbuf[0], 0);
+ usb_parse_config(dev, &tmpbuf[0], 0);
usb_set_maxpacket(dev);
/* we set the default configuration here */
if (usb_set_configuration(dev, dev->config.bConfigurationValue)) {
- printf("failed to set default configuration len %d, status %lX\n",dev->act_len,dev->status);
+ printf("failed to set default configuration len %d, status %lX\n", dev->act_len, dev->status);
return -1;
}
USB_PRINTF("new device strings: Mfr=%d, Product=%d, SerialNumber=%d\n",
@@ -848,22 +870,22 @@ int usb_new_device(struct usb_device *dev)
return 0;
}
-/* build device Tree */
+/* build device Tree */
void usb_scan_devices(void)
{
int i;
struct usb_device *dev;
/* first make all devices unknown */
- for(i=0;i<USB_MAX_DEVICE;i++) {
- memset(&usb_dev[i],0,sizeof(struct usb_device));
- usb_dev[i].devnum=-1;
+ for(i = 0; i < USB_MAX_DEVICE; i++) {
+ memset(&usb_dev[i], 0, sizeof(struct usb_device));
+ usb_dev[i].devnum = -1;
}
- dev_index=0;
+ dev_index = 0;
/* device 0 is always present (root hub, so let it analyze) */
- dev=usb_alloc_new_device();
+ dev = usb_alloc_new_device();
usb_new_device(dev);
- printf("%d USB Device(s) found\n",dev_index);
+ printf("%d USB Device(s) found\n", dev_index);
/* insert "driver" if possible */
#ifdef CONFIG_USB_KEYBOARD
drv_usb_kbd_init();
@@ -871,7 +893,6 @@ void usb_scan_devices(void)
#endif
}
-
/****************************************************************************
* HUB "Driver"
* Probes device for being a hub and configurate it
@@ -885,11 +906,9 @@ void usb_scan_devices(void)
#define USB_HUB_PRINTF(fmt,args...)
#endif
-
static struct usb_hub_device hub_dev[USB_MAX_HUB];
static int usb_hub_index;
-
int usb_get_hub_descriptor(struct usb_device *dev, void *data, int size)
{
return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
@@ -940,22 +959,22 @@ static void usb_hub_power_on(struct usb_hub_device *hub)
USB_HUB_PRINTF("enabling power on all ports\n");
for (i = 0; i < dev->maxchild; i++) {
usb_set_port_feature(dev, i + 1, USB_PORT_FEAT_POWER);
- USB_HUB_PRINTF("port %d returns %lX\n",i+1,dev->status);
+ USB_HUB_PRINTF("port %d returns %lX\n", i + 1, dev->status);
wait_ms(hub->desc.bPwrOn2PwrGood * 2);
}
}
void usb_hub_reset(void)
{
- usb_hub_index=0;
+ usb_hub_index = 0;
}
struct usb_hub_device *usb_hub_allocate(void)
{
- if(usb_hub_index<USB_MAX_HUB) {
+ if(usb_hub_index < USB_MAX_HUB) {
return &hub_dev[usb_hub_index++];
}
- printf("ERROR: USB_MAX_HUB (%d) reached\n",USB_MAX_HUB);
+ printf("ERROR: USB_MAX_HUB (%d) reached\n", USB_MAX_HUB);
return NULL;
}
@@ -968,15 +987,14 @@ static int hub_port_reset(struct usb_device *dev, int port,
struct usb_port_status portsts;
unsigned short portstatus, portchange;
-
USB_HUB_PRINTF("hub_port_reset: resetting port %d...\n", port);
- for(tries=0;tries<MAX_TRIES;tries++) {
+ for(tries = 0; tries < MAX_TRIES; tries++) {
usb_set_port_feature(dev, port + 1, USB_PORT_FEAT_RESET);
wait_ms(200);
- if (usb_get_port_status(dev, port + 1, &portsts)<0) {
- USB_HUB_PRINTF("get_port_status failed status %lX\n",dev->status);
+ if (usb_get_port_status(dev, port + 1, &portsts) < 0) {
+ USB_HUB_PRINTF("get_port_status failed status %lX\n", dev->status);
return -1;
}
portstatus = swap_16(portsts.wPortStatus);
@@ -988,19 +1006,18 @@ static int hub_port_reset(struct usb_device *dev, int port,
(portstatus & USB_PORT_STAT_CONNECTION) ? 1 : 0,
(portstatus & USB_PORT_STAT_ENABLE) ? 1 : 0);
if ((portchange & USB_PORT_STAT_C_CONNECTION) ||
- !(portstatus & USB_PORT_STAT_CONNECTION))
+ !(portstatus & USB_PORT_STAT_CONNECTION))
return -1;
- if (portstatus & USB_PORT_STAT_ENABLE) {
-
+ if (portstatus & USB_PORT_STAT_ENABLE)
break;
- }
wait_ms(200);
}
- if (tries==MAX_TRIES) {
- USB_HUB_PRINTF("Cannot enable port %i after %i retries, disabling port.\n", port+1, MAX_TRIES);
+ if (tries == MAX_TRIES) {
+ USB_HUB_PRINTF("Cannot enable port %i after %i retries, disabling port.\n",
+ port + 1, MAX_TRIES);
USB_HUB_PRINTF("Maybe the USB cable is bad?\n");
return -1;
}
@@ -1019,7 +1036,7 @@ void usb_hub_port_connect_change(struct usb_device *dev, int port)
unsigned short portstatus, portchange;
/* Check status */
- if (usb_get_port_status(dev, port + 1, &portsts)<0) {
+ if (usb_get_port_status(dev, port + 1, &portsts) < 0) {
USB_HUB_PRINTF("get_port_status failed\n");
return;
}
@@ -1034,7 +1051,7 @@ void usb_hub_port_connect_change(struct usb_device *dev, int port)
/* Disconnect any existing devices under this port */
if (((!(portstatus & USB_PORT_STAT_CONNECTION)) &&
- (!(portstatus & USB_PORT_STAT_ENABLE)))|| (dev->children[port])) {
+ (!(portstatus & USB_PORT_STAT_ENABLE)))|| (dev->children[port])) {
USB_HUB_PRINTF("usb_disconnect(&hub->children[port]);\n");
/* Return now if nothing is connected */
if (!(portstatus & USB_PORT_STAT_CONNECTION))
@@ -1051,11 +1068,11 @@ void usb_hub_port_connect_change(struct usb_device *dev, int port)
wait_ms(200);
/* Allocate a new device struct for it */
- usb=usb_alloc_new_device();
+ usb = usb_alloc_new_device();
usb->slow = (portstatus & USB_PORT_STAT_LOW_SPEED) ? 1 : 0;
dev->children[port] = usb;
- usb->parent=dev;
+ usb->parent = dev;
/* Run it through the hoops (find a driver, etc) */
if (usb_new_device(usb)) {
/* Woops, disable the port */
@@ -1064,23 +1081,25 @@ void usb_hub_port_connect_change(struct usb_device *dev, int port)
}
}
-
int usb_hub_configure(struct usb_device *dev)
{
- unsigned char buffer[USB_BUFSIZ], *bitmap;
+ unsigned char buffer[USB_BUFSIZ];
+ unsigned char *bitmap;
struct usb_hub_descriptor *descriptor;
struct usb_hub_status *hubsts;
int i;
struct usb_hub_device *hub;
/* "allocate" Hub device */
- hub=usb_hub_allocate();
- if(hub==NULL)
+ hub = usb_hub_allocate();
+ if(hub == NULL)
return -1;
- hub->pusb_dev=dev;
+
+ hub->pusb_dev = dev;
/* Get the the hub descriptor */
if (usb_get_hub_descriptor(dev, buffer, 4) < 0) {
- USB_HUB_PRINTF("usb_hub_configure: failed to get hub descriptor, giving up %lX\n",dev->status);
+ USB_HUB_PRINTF("usb_hub_configure: failed to get hub descriptor, giving up %lX\n",
+ dev->status);
return -1;
}
descriptor = (struct usb_hub_descriptor *)buffer;
@@ -1088,29 +1107,30 @@ int usb_hub_configure(struct usb_device *dev)
/* silence compiler warning if USB_BUFSIZ is > 256 [= sizeof(char)] */
i = descriptor->bLength;
if (i > USB_BUFSIZ) {
- USB_HUB_PRINTF("usb_hub_configure: failed to get hub descriptor - too long: %d\N",
+ USB_HUB_PRINTF("usb_hub_configure: failed to get hub descriptor - too long: %d\n",
descriptor->bLength);
return -1;
}
if (usb_get_hub_descriptor(dev, buffer, descriptor->bLength) < 0) {
- USB_HUB_PRINTF("usb_hub_configure: failed to get hub descriptor 2nd giving up %lX\n",dev->status);
+ USB_HUB_PRINTF("usb_hub_configure: failed to get hub descriptor 2nd giving up %lX\n",
+ dev->status);
return -1;
}
- memcpy((unsigned char *)&hub->desc,buffer,descriptor->bLength);
+ memcpy((unsigned char *)&hub->desc, buffer, descriptor->bLength);
/* adjust 16bit values */
hub->desc.wHubCharacteristics=swap_16(descriptor->wHubCharacteristics);
/* set the bitmap */
bitmap=(unsigned char *)&hub->desc.DeviceRemovable[0];
- memset(bitmap,0xff,(USB_MAXCHILDREN+1+7)/8); /* devices not removable by default */
+ memset(bitmap, 0xff, (USB_MAXCHILDREN + 1 + 7) / 8); /* devices not removable by default */
bitmap=(unsigned char *)&hub->desc.PortPowerCtrlMask[0];
- memset(bitmap,0xff,(USB_MAXCHILDREN+1+7)/8); /* PowerMask = 1B */
- for(i=0;i<((hub->desc.bNbrPorts + 1 + 7)/8);i++) {
- hub->desc.DeviceRemovable[i]=descriptor->DeviceRemovable[i];
- }
- for(i=0;i<((hub->desc.bNbrPorts + 1 + 7)/8);i++) {
- hub->desc.DeviceRemovable[i]=descriptor->PortPowerCtrlMask[i];
- }
+ memset(bitmap, 0xff, (USB_MAXCHILDREN + 1 + 7) / 8); /* PowerMask = 1B */
+ for(i = 0; i < ((hub->desc.bNbrPorts + 1 + 7) / 8); i++)
+ hub->desc.DeviceRemovable[i] = descriptor->DeviceRemovable[i];
+
+ for(i = 0; i < ((hub->desc.bNbrPorts + 1 + 7) / 8); i++)
+ hub->desc.DeviceRemovable[i] = descriptor->PortPowerCtrlMask[i];
+
dev->maxchild = descriptor->bNbrPorts;
USB_HUB_PRINTF("%d ports detected\n", dev->maxchild);
@@ -1142,13 +1162,13 @@ int usb_hub_configure(struct usb_device *dev)
case 0x10:
case 0x18:
USB_HUB_PRINTF("no over-current protection\n");
- break;
+ break;
}
USB_HUB_PRINTF("power on to power good time: %dms\n", descriptor->bPwrOn2PwrGood * 2);
USB_HUB_PRINTF("hub controller current requirement: %dmA\n", descriptor->bHubContrCurrent);
for (i = 0; i < dev->maxchild; i++)
USB_HUB_PRINTF("port %d is%s removable\n", i + 1,
- hub->desc.DeviceRemovable[(i + 1)/8] & (1 << ((i + 1)%8)) ? " not" : "");
+ hub->desc.DeviceRemovable[(i + 1) / 8] & (1 << ((i + 1) % 8)) ? " not" : "");
if (sizeof(struct usb_hub_status) > USB_BUFSIZ) {
USB_HUB_PRINTF("usb_hub_configure: failed to get Status - too long: %d\n",
descriptor->bLength);
@@ -1161,7 +1181,7 @@ int usb_hub_configure(struct usb_device *dev)
}
hubsts = (struct usb_hub_status *)buffer;
USB_HUB_PRINTF("get_hub_status returned status %X, change %X\n",
- swap_16(hubsts->wHubStatus),swap_16(hubsts->wHubChange));
+ swap_16(hubsts->wHubStatus), swap_16(hubsts->wHubChange));
USB_HUB_PRINTF("local power source is %s\n",
(swap_16(hubsts->wHubStatus) & HUB_STATUS_LOCAL_POWER) ? "lost (inactive)" : "good");
USB_HUB_PRINTF("%sover-current condition exists\n",
@@ -1175,9 +1195,10 @@ int usb_hub_configure(struct usb_device *dev)
USB_HUB_PRINTF("get_port_status failed\n");
continue;
}
+
portstatus = swap_16(portsts.wPortStatus);
portchange = swap_16(portsts.wPortChange);
- USB_HUB_PRINTF("Port %d Status %X Change %X\n",i+1,portstatus,portchange);
+ USB_HUB_PRINTF("Port %d Status %X Change %X\n", i + 1, portstatus, portchange);
if (portchange & USB_PORT_STAT_C_CONNECTION) {
USB_HUB_PRINTF("port %d connection change\n", i + 1);
usb_hub_port_connect_change(dev, i);
@@ -1198,7 +1219,7 @@ int usb_hub_configure(struct usb_device *dev)
}
if (portstatus & USB_PORT_STAT_SUSPEND) {
USB_HUB_PRINTF("port %d suspend change\n", i + 1);
- usb_clear_port_feature(dev, i + 1, USB_PORT_FEAT_SUSPEND);
+ usb_clear_port_feature(dev, i + 1, USB_PORT_FEAT_SUSPEND);
}
if (portchange & USB_PORT_STAT_C_OVERCURRENT) {
@@ -1229,7 +1250,7 @@ int usb_hub_probe(struct usb_device *dev, int ifnum)
/* Some hubs have a subclass of 1, which AFAICT according to the */
/* specs is not defined, but it works */
if ((iface->bInterfaceSubClass != 0) &&
- (iface->bInterfaceSubClass != 1))
+ (iface->bInterfaceSubClass != 1))
return 0;
/* Multiple endpoints? What kind of mutant ninja-hub is this? */
if (iface->bNumEndpoints != 1)
@@ -1243,10 +1264,8 @@ int usb_hub_probe(struct usb_device *dev, int ifnum)
return 0;
/* We found a hub */
USB_HUB_PRINTF("USB hub found\n");
- ret=usb_hub_configure(dev);
+ ret = usb_hub_configure(dev);
return ret;
}
#endif
-
-/* EOF */
diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index 1703b23..e5cdb43 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
@@ -53,25 +53,25 @@ int overwrite_console (void)
#endif
-#define REPEAT_RATE 40/4 /* 40msec -> 25cps */
-#define REPEAT_DELAY 10 /* 10 x REAPEAT_RATE = 400msec */
+#define REPEAT_RATE 40/4 /* 40msec -> 25cps */
+#define REPEAT_DELAY 10 /* 10 x REAPEAT_RATE = 400msec */
#define NUM_LOCK 0x53
-#define CAPS_LOCK 0x39
-#define SCROLL_LOCK 0x47
+#define CAPS_LOCK 0x39
+#define SCROLL_LOCK 0x47
/* Modifier bits */
-#define LEFT_CNTR 0
+#define LEFT_CNTR 0
#define LEFT_SHIFT 1
-#define LEFT_ALT 2
-#define LEFT_GUI 3
+#define LEFT_ALT 2
+#define LEFT_GUI 3
#define RIGHT_CNTR 4
#define RIGHT_SHIFT 5
-#define RIGHT_ALT 6
-#define RIGHT_GUI 7
+#define RIGHT_ALT 6
+#define RIGHT_GUI 7
-#define USB_KBD_BUFFER_LEN 0x20 /* size of the keyboardbuffer */
+#define USB_KBD_BUFFER_LEN 0x20 /* size of the keyboardbuffer */
static volatile char usb_kbd_buffer[USB_KBD_BUFFER_LEN];
static volatile int usb_in_pointer = 0;
@@ -103,18 +103,17 @@ static unsigned char usb_kbd_numkey_shifted[] = {
/* puts character in the queue and sets up the in and out pointer */
static void usb_kbd_put_queue(char data)
{
- if((usb_in_pointer+1)==USB_KBD_BUFFER_LEN) {
- if(usb_out_pointer==0) {
+ if((usb_in_pointer + 1) == USB_KBD_BUFFER_LEN) {
+ if(usb_out_pointer == 0)
return; /* buffer full */
- } else{
- usb_in_pointer=0;
- }
+ else
+ usb_in_pointer = 0;
} else {
- if((usb_in_pointer+1)==usb_out_pointer)
+ if((usb_in_pointer + 1) == usb_out_pointer)
return; /* buffer full */
usb_in_pointer++;
}
- usb_kbd_buffer[usb_in_pointer]=data;
+ usb_kbd_buffer[usb_in_pointer] = data;
return;
}
@@ -124,7 +123,7 @@ static int usb_kbd_testc(void)
#ifdef CFG_USB_EVENT_POLL
usb_event_poll();
#endif
- if(usb_in_pointer==usb_out_pointer)
+ if(usb_in_pointer == usb_out_pointer)
return(0); /* no data */
else
return(1);
@@ -133,16 +132,17 @@ static int usb_kbd_testc(void)
static int usb_kbd_getc(void)
{
char c;
- while(usb_in_pointer==usb_out_pointer) {
+
+ while(usb_in_pointer == usb_out_pointer) {
#ifdef CFG_USB_EVENT_POLL
usb_event_poll();
#endif
}
- if((usb_out_pointer+1)==USB_KBD_BUFFER_LEN)
- usb_out_pointer=0;
+ if((usb_out_pointer + 1) == USB_KBD_BUFFER_LEN)
+ usb_out_pointer = 0;
else
usb_out_pointer++;
- c=usb_kbd_buffer[usb_out_pointer];
+ c = usb_kbd_buffer[usb_out_pointer];
return (int)c;
}
@@ -153,23 +153,23 @@ static int usb_kbd_probe(struct usb_device *dev, unsigned int ifnum);
/* search for keyboard and register it if found */
int drv_usb_kbd_init(void)
{
- int error,i,index;
- device_t usb_kbd_dev,*old_dev;
+ int error, i, index;
+ device_t usb_kbd_dev, *old_dev;
struct usb_device *dev;
- char *stdinname = getenv ("stdin");
+ char *stdinname = getenv ("stdin");
- usb_in_pointer=0;
- usb_out_pointer=0;
+ usb_in_pointer = 0;
+ usb_out_pointer = 0;
/* scan all USB Devices */
- for(i=0;i<USB_MAX_DEVICE;i++) {
- dev=usb_get_dev_index(i); /* get device */
- if(dev->devnum!=-1) {
- if(usb_kbd_probe(dev,0)==1) { /* Ok, we found a keyboard */
+ for(i = 0; i < USB_MAX_DEVICE; i++) {
+ dev = usb_get_dev_index(i); /* get device */
+ if(dev->devnum !=- 1) {
+ if(usb_kbd_probe(dev,0) == 1) { /* Ok, we found a keyboard */
/* check, if it is already registered */
USB_KBD_PRINTF("USB KBD found set up device.\n");
- for (index=1; index<=ListNumItems(devlist); index++) {
+ for (index = 1; index <= ListNumItems(devlist); index++) {
old_dev = ListGetPtrToItem(devlist, index);
- if(strcmp(old_dev->name,DEVNAME)==0) {
+ if(strcmp(old_dev->name, DEVNAME) == 0) {
/* ok, already registered, just return ok */
USB_KBD_PRINTF("USB KBD is already registered.\n");
return 1;
@@ -177,23 +177,23 @@ int drv_usb_kbd_init(void)
}
/* register the keyboard */
USB_KBD_PRINTF("USB KBD register.\n");
- memset (&usb_kbd_dev, 0, sizeof(device_t));
+ memset(&usb_kbd_dev, 0, sizeof(device_t));
strcpy(usb_kbd_dev.name, DEVNAME);
- usb_kbd_dev.flags = DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
+ usb_kbd_dev.flags = DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
usb_kbd_dev.putc = NULL;
usb_kbd_dev.puts = NULL;
usb_kbd_dev.getc = usb_kbd_getc;
usb_kbd_dev.tstc = usb_kbd_testc;
- error = device_register (&usb_kbd_dev);
- if(error==0) {
+ error = device_register(&usb_kbd_dev);
+ if(error == 0) {
/* check if this is the standard input device */
- if(strcmp(stdinname,DEVNAME)==0) {
+ if(strcmp(stdinname, DEVNAME) == 0) {
/* reassign the console */
- if(overwrite_console()) {
+ if(overwrite_console())
return 1;
- }
- error=console_assign(stdin,DEVNAME);
- if(error==0)
+
+ error = console_assign(stdin, DEVNAME);
+ if(error == 0)
return 1;
else
return error;
@@ -208,7 +208,6 @@ int drv_usb_kbd_init(void)
return -1;
}
-
/* deregistering the keyboard */
int usb_kbd_deregister(void)
{
@@ -226,78 +225,81 @@ int usb_kbd_deregister(void)
static void usb_kbd_setled(struct usb_device *dev)
{
struct usb_interface_descriptor *iface;
+
iface = &dev->config.if_desc[0];
- leds=0;
- if(scroll_lock!=0)
- leds|=1;
- leds<<=1;
- if(caps_lock!=0)
- leds|=1;
- leds<<=1;
- if(num_lock!=0)
- leds|=1;
+ leds = 0;
+ if(scroll_lock != 0)
+ leds |= 1;
+ leds <<= 1;
+ if(caps_lock != 0)
+ leds |= 1;
+ leds <<= 1;
+ if(num_lock != 0)
+ leds |= 1;
usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
USB_REQ_SET_REPORT, USB_TYPE_CLASS | USB_RECIP_INTERFACE,
- 0x200, iface->bInterfaceNumber,(void *)&leds, 1, 0);
+ 0x200, iface->bInterfaceNumber, (void *)&leds, 1, 0);
}
#define CAPITAL_MASK 0x20
/* Translate the scancode in ASCII */
-static int usb_kbd_translate(unsigned char scancode,unsigned char modifier,int pressed)
+static int usb_kbd_translate(unsigned char scancode, unsigned char modifier, int pressed)
{
unsigned char keycode;
- if(pressed==0) {
+ if(pressed == 0) {
/* key released */
- repeat_delay=0;
+ repeat_delay = 0;
return 0;
}
- if(pressed==2) {
+ if(pressed == 2) {
repeat_delay++;
- if(repeat_delay<REPEAT_DELAY)
+ if(repeat_delay < REPEAT_DELAY)
return 0;
- repeat_delay=REPEAT_DELAY;
+ repeat_delay = REPEAT_DELAY;
}
- keycode=0;
- if((scancode>3) && (scancode<=0x1d)) { /* alpha numeric values */
- keycode=scancode-4 + 0x61;
+ keycode = 0;
+ if((scancode > 3) && (scancode <= 0x1d)) { /* alpha numeric values */
+ keycode = scancode - 4 + 0x61;
if(caps_lock)
- keycode&=~CAPITAL_MASK; /* switch to capital Letters */
- if(((modifier&(1<<LEFT_SHIFT))!=0)||((modifier&(1<<RIGHT_SHIFT))!=0)) {
+ keycode &= ~CAPITAL_MASK; /* switch to capital Letters */
+ if(((modifier&(1 << LEFT_SHIFT)) != 0) ||
+ ((modifier&(1 << RIGHT_SHIFT)) != 0)) {
if(keycode & CAPITAL_MASK)
- keycode&=~CAPITAL_MASK; /* switch to capital Letters */
+ keycode& = ~CAPITAL_MASK; /* switch to capital Letters */
else
- keycode|=CAPITAL_MASK; /* switch to non capital Letters */
+ keycode |= CAPITAL_MASK; /* switch to non capital Letters */
}
}
- if((scancode>0x1d) && (scancode<0x3A)) {
- if(((modifier&(1<<LEFT_SHIFT))!=0)||((modifier&(1<<RIGHT_SHIFT))!=0)) /* shifted */
- keycode=usb_kbd_numkey_shifted[scancode-0x1e];
+ if((scancode > 0x1d) && (scancode < 0x3A)) {
+ if(((modifier&(1 << LEFT_SHIFT)) != 0) ||
+ ((modifier&(1 << RIGHT_SHIFT)) != 0)) /* shifted */
+ keycode = usb_kbd_numkey_shifted[scancode - 0x1e];
else /* non shifted */
- keycode=usb_kbd_numkey[scancode-0x1e];
+ keycode = usb_kbd_numkey[scancode - 0x1e];
}
if (ctrl)
keycode = scancode - 0x3;
- if(pressed==1) {
- if(scancode==NUM_LOCK) {
- num_lock=~num_lock;
+ if(pressed == 1) {
+ if(scancode == NUM_LOCK) {
+ num_lock = ~num_lock;
return 1;
}
- if(scancode==CAPS_LOCK) {
- caps_lock=~caps_lock;
+ if(scancode == CAPS_LOCK) {
+ caps_lock = ~caps_lock;
return 1;
}
- if(scancode==SCROLL_LOCK) {
- scroll_lock=~scroll_lock;
+ if(scancode == SCROLL_LOCK) {
+ scroll_lock = ~scroll_lock;
return 1;
}
}
- if(keycode!=0) {
- USB_KBD_PRINTF("%c",keycode);
+ if(keycode != 0) {
+ USB_KBD_PRINTF("%c", keycode);
usb_kbd_put_queue(keycode);
}
return 0;
@@ -306,14 +308,15 @@ static int usb_kbd_translate(unsigned char scancode,unsigned char modifier,int p
/* Interrupt service routine */
static int usb_kbd_irq(struct usb_device *dev)
{
- int i,res;
+ int i, res;
- if((dev->irq_status!=0)||(dev->irq_act_len!=8))
+ if((dev->irq_status != 0) || (dev->irq_act_len != 8))
{
- USB_KBD_PRINTF("usb_keyboard Error %lX, len %d\n",dev->irq_status,dev->irq_act_len);
+ USB_KBD_PRINTF("usb_keyboard Error %lX, len %d\n",
+ dev->irq_status, dev->irq_act_len);
return 1;
}
- res=0;
+ res = 0;
switch (new[0]) {
case 0x0: /* No combo key pressed */
@@ -326,18 +329,18 @@ static int usb_kbd_irq(struct usb_device *dev)
}
for (i = 2; i < 8; i++) {
- if (old[i] > 3 && memscan(&new[2], old[i], 6) == &new[8]) {
- res|=usb_kbd_translate(old[i],new[0],0);
- }
- if (new[i] > 3 && memscan(&old[2], new[i], 6) == &old[8]) {
- res|=usb_kbd_translate(new[i],new[0],1);
- }
+ if (old[i] > 3 && memscan(&new[2], old[i], 6) == &new[8])
+ res |= usb_kbd_translate(old[i], new[0], 0);
+
+ if (new[i] > 3 && memscan(&old[2], new[i], 6) == &old[8])
+ res |= usb_kbd_translate(new[i], new[0], 1);
+
}
- if((new[2]>3) && (old[2]==new[2])) /* still pressed */
- res|=usb_kbd_translate(new[2],new[0],2);
- if(res==1)
+ if((new[2] > 3) && (old[2] == new[2])) /* still pressed */
+ res |= usb_kbd_translate(new[2], new[0], 2);
+ if(res == 1)
usb_kbd_setled(dev);
- memcpy(&old[0],&new[0], 8);
+ memcpy(&old[0], &new[0], 8);
return 1; /* install IRQ Handler again */
}
@@ -346,20 +349,27 @@ static int usb_kbd_probe(struct usb_device *dev, unsigned int ifnum)
{
struct usb_interface_descriptor *iface;
struct usb_endpoint_descriptor *ep;
- int pipe,maxp;
+ int pipe, maxp;
- if (dev->descriptor.bNumConfigurations != 1) return 0;
+ if (dev->descriptor.bNumConfigurations != 1)
+ return 0;
iface = &dev->config.if_desc[ifnum];
- if (iface->bInterfaceClass != 3) return 0;
- if (iface->bInterfaceSubClass != 1) return 0;
- if (iface->bInterfaceProtocol != 1) return 0;
- if (iface->bNumEndpoints != 1) return 0;
+ if (iface->bInterfaceClass != 3)
+ return 0;
+ if (iface->bInterfaceSubClass != 1)
+ return 0;
+ if (iface->bInterfaceProtocol != 1)
+ return 0;
+ if (iface->bNumEndpoints != 1)
+ return 0;
ep = &iface->ep_desc[0];
- if (!(ep->bEndpointAddress & 0x80)) return 0;
- if ((ep->bmAttributes & 3) != 3) return 0;
+ if (!(ep->bEndpointAddress & 0x80))
+ return 0;
+ if ((ep->bmAttributes & 3) != 3)
+ return 0;
USB_KBD_PRINTF("USB KBD found set protocol...\n");
/* ok, we found a USB Keyboard, install it */
/* usb_kbd_get_hid_desc(dev); */
@@ -368,24 +378,23 @@ static int usb_kbd_probe(struct usb_device *dev, unsigned int ifnum)
usb_set_idle(dev, iface->bInterfaceNumber, REPEAT_RATE, 0);
memset(&new[0], 0, 8);
memset(&old[0], 0, 8);
- repeat_delay=0;
+ repeat_delay = 0;
pipe = usb_rcvintpipe(dev, ep->bEndpointAddress);
maxp = usb_maxpacket(dev, pipe);
- dev->irq_handle=usb_kbd_irq;
+ dev->irq_handle = usb_kbd_irq;
USB_KBD_PRINTF("USB KBD enable interrupt pipe...\n");
- usb_submit_int_msg(dev,pipe,&new[0], maxp > 8 ? 8 : maxp,ep->bInterval);
+ usb_submit_int_msg(dev, pipe, &new[0], maxp > 8 ? 8 : maxp, ep->bInterval);
return 1;
}
-
#if 0
struct usb_hid_descriptor {
- unsigned char bLength;
- unsigned char bDescriptorType; /* 0x21 for HID */
+ unsigned char bLength;
+ unsigned char bDescriptorType; /* 0x21 for HID */
unsigned short bcdHID; /* release number */
- unsigned char bCountryCode;
- unsigned char bNumDescriptors;
- unsigned char bReportDescriptorType;
+ unsigned char bCountryCode;
+ unsigned char bNumDescriptors;
+ unsigned char bReportDescriptorType;
unsigned short wDescriptorLength;
} __attribute__ ((packed));
@@ -401,13 +410,13 @@ struct hid_item {
unsigned char type;
unsigned char tag;
union {
- unsigned char u8;
- char s8;
- unsigned short u16;
- short s16;
- unsigned long u32;
- long s32;
- unsigned char *longdata;
+ unsigned char u8;
+ char s8;
+ unsigned short u16;
+ short s16;
+ unsigned long u32;
+ long s32;
+ unsigned char *longdata;
} data;
};
@@ -430,15 +439,14 @@ static struct usb_hid_descriptor usb_kbd_hid_desc;
void usb_kbd_display_hid(struct usb_hid_descriptor *hid)
{
printf("USB_HID_DESC:\n");
- printf(" bLenght 0x%x\n",hid->bLength);
- printf(" bcdHID 0x%x\n",hid->bcdHID);
- printf(" bCountryCode %d\n",hid->bCountryCode);
- printf(" bNumDescriptors 0x%x\n",hid->bNumDescriptors);
- printf(" bReportDescriptorType 0x%x\n",hid->bReportDescriptorType);
- printf(" wDescriptorLength 0x%x\n",hid->wDescriptorLength);
+ printf(" bLenght 0x%x\n", hid->bLength);
+ printf(" bcdHID 0x%x\n", hid->bcdHID);
+ printf(" bCountryCode %d\n", hid->bCountryCode);
+ printf(" bNumDescriptors 0x%x\n", hid->bNumDescriptors);
+ printf(" bReportDescriptorType 0x%x\n", hid->bReportDescriptorType);
+ printf(" wDescriptorLength 0x%x\n", hid->wDescriptorLength);
}
-
/*
* Fetch a report description item from the data stream. We support long
* items, though they are not used yet.
@@ -449,12 +457,12 @@ static int fetch_item(unsigned char *start,unsigned char *end, struct hid_item *
if((end - start) > 0) {
unsigned char b = *start++;
item->type = (b >> 2) & 3;
- item->tag = (b >> 4) & 15;
+ item->tag = (b >> 4) & 15;
if (item->tag == HID_ITEM_TAG_LONG) {
item->format = HID_ITEM_FORMAT_LONG;
if ((end - start) >= 2) {
item->size = *start++;
- item->tag = *start++;
+ item->tag = *start++;
if ((end - start) >= item->size) {
item->data.longdata = start;
start += item->size;
@@ -476,14 +484,14 @@ static int fetch_item(unsigned char *start,unsigned char *end, struct hid_item *
case 2:
if ((end - start) >= 2) {
item->data.u16 = swap_16((unsigned short *)start);
- start+=2;
+ start += 2;
return item->size;
}
case 3:
item->size++;
if ((end - start) >= 4) {
item->data.u32 = swap_32((unsigned long *)start);
- start+=4;
+ start += 4;
return item->size;
}
}
@@ -584,7 +592,7 @@ static void usb_kbd_show_item(struct hid_item *item)
printf("Main End Collection");
break;
default:
- printf("Main reserved %d",item->tag);
+ printf("Main reserved %d", item->tag);
break;
}
break;
@@ -692,36 +700,36 @@ static int usb_kbd_get_hid_desc(struct usb_device *dev)
unsigned char buffer[256];
struct usb_descriptor_header *head;
struct usb_config_descriptor *config;
- int index,len,i;
+ int index, len, i;
unsigned char *start, *end;
struct hid_item item;
- if(usb_get_configuration_no(dev,&buffer[0],0)==-1)
+ if(usb_get_configuration_no(dev, &buffer[0], 0) == -1)
return -1;
- head =(struct usb_descriptor_header *)&buffer[0];
- if(head->bDescriptorType!=USB_DT_CONFIG) {
- printf(" ERROR: NOT USB_CONFIG_DESC %x\n",head->bDescriptorType);
+ head = (struct usb_descriptor_header *)&buffer[0];
+ if(head->bDescriptorType != USB_DT_CONFIG) {
+ printf(" ERROR: NOT USB_CONFIG_DESC %x\n", head->bDescriptorType);
return -1;
}
- index=head->bLength;
- config=(struct usb_config_descriptor *)&buffer[0];
- len=swap_16(config->wTotalLength);
+ index = head->bLength;
+ config = (struct usb_config_descriptor *)&buffer[0];
+ len = swap_16(config->wTotalLength);
/* Ok the first entry must be a configuration entry, now process the others */
- head=(struct usb_descriptor_header *)&buffer[index];
- while(index+1 < len) {
- if(head->bDescriptorType==USB_DT_HID) {
+ head = (struct usb_descriptor_header *)&buffer[index];
+ while(index + 1 < len) {
+ if(head->bDescriptorType == USB_DT_HID) {
printf("HID desc found\n");
- memcpy(&usb_kbd_hid_desc,&buffer[index],buffer[index]);
- usb_kbd_hid_desc.bcdHID=swap_16(usb_kbd_hid_desc.bcdHID);
+ memcpy(&usb_kbd_hid_desc, &buffer[index], buffer[index]);
+ usb_kbd_hid_desc.bcdHID = swap_16(usb_kbd_hid_desc.bcdHID);
usb_kbd_hid_desc.wDescriptorLength=swap_16(usb_kbd_hid_desc.wDescriptorLength);
usb_kbd_display_hid(&usb_kbd_hid_desc);
- len=0;
+ len = 0;
break;
}
- index+=head->bLength;
- head=(struct usb_descriptor_header *)&buffer[index];
+ index += head->bLength;
+ head = (struct usb_descriptor_header *)&buffer[index];
}
- if(len>0)
+ if(len > 0)
return -1;
len=usb_kbd_hid_desc.wDescriptorLength;
if((index = usb_get_class_descriptor(dev, 0, USB_DT_REPORT, 0, &buffer[0], len)) < 0) {
@@ -729,23 +737,22 @@ static int usb_kbd_get_hid_desc(struct usb_device *dev)
return -1;
}
printf(" report descriptor (size %u, read %d)\n", len, index);
- start=&buffer[0];
- end=&buffer[len];
- i=0;
+ start = &buffer[0];
+ end = &buffer[len];
+ i = 0;
do {
- index=fetch_item(start,end,&item);
- i+=index;
+ index = fetch_item(start, end, &item);
+ i += index;
i++;
- if(index>=0)
+ if(index >= 0)
usb_kbd_show_item(&item);
- start+=index;
+ start += index;
start++;
- } while(index>=0);
+ } while(index >= 0);
}
-
#endif
#endif /* CONFIG_USB_KEYBOARD */
--
1.5.5.1
3
2
Hi,
I've written some new commands for the serial shell using the
recommendations enclosed in /docs. I've put all my stuff inside
/common because the changes are not board specific. Even though I've
changed /common/Makefile adding the new .o files that I want to have
built, the compilation process still ignores my modifications, not
compiling my new stuff. For the moment, I haven't put conditional
statement for preprocessing.
I'm wondering whether I've miss some steps.
Thanx
2
1