[U-Boot] [PATCH 2/5] am33xx: support for booting via usbeth
This patch adds BOOT_DEVICE define for USB booting and fixes spl_board_init function to call arch_misc_init (this is the place there musb is initialized). Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- arch/arm/cpu/armv7/omap-common/boot-common.c | 3 +++ arch/arm/include/asm/arch-am33xx/spl.h | 1 + 2 files changed, 4 insertions(+) diff --git a/arch/arm/cpu/armv7/omap-common/boot-common.c b/arch/arm/cpu/armv7/omap-common/boot-common.c index 0f19141..99dc9d8 100644 --- a/arch/arm/cpu/armv7/omap-common/boot-common.c +++ b/arch/arm/cpu/armv7/omap-common/boot-common.c @@ -54,6 +54,9 @@ void spl_board_init(void) #ifdef CONFIG_SPL_NAND_SUPPORT gpmc_init(); #endif +#if defined(CONFIG_AM33XX) defined(CONFIG_SPL_MUSB_NEW_SUPPORT) + arch_misc_init(); +#endif } int board_mmc_init(bd_t *bis) diff --git a/arch/arm/include/asm/arch-am33xx/spl.h b/arch/arm/include/asm/arch-am33xx/spl.h index 644ff35..e961ce0 100644 --- a/arch/arm/include/asm/arch-am33xx/spl.h +++ b/arch/arm/include/asm/arch-am33xx/spl.h @@ -29,6 +29,7 @@ #define BOOT_DEVICE_MMC2 9 /* eMMC or daughter card */ #define BOOT_DEVICE_SPI11 #define BOOT_DEVICE_UART 65 +#define BOOT_DEVICE_USBETH 68 #define BOOT_DEVICE_CPGMAC 70 #define BOOT_DEVICE_MMC2_2 0xFF #endif -- 1.8.0.2 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 1/5] spl: support for booting via usbeth
In case of usbeth booting just call net_load_image(usb_ether). This patch also adds CONFIG_SPL_USBETH_SUPPORT and CONFIG_SPL_MUSB_NEW_SUPPORT config options to enable linking of SPL against USB gagdet support and new MUSB driver resp. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- common/spl/spl.c | 5 + spl/Makefile | 2 ++ 2 files changed, 7 insertions(+) diff --git a/common/spl/spl.c b/common/spl/spl.c index ff9ba7b..6a5a136 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -221,6 +221,11 @@ void board_init_r(gd_t *dummy1, ulong dummy2) #endif break; #endif +#ifdef CONFIG_SPL_USBETH_SUPPORT + case BOOT_DEVICE_USBETH: + spl_net_load_image(usb_ether); + break; +#endif default: debug(SPL: Un-supported Boot Device\n); hang(); diff --git a/spl/Makefile b/spl/Makefile index 6dbb105..cde 100644 --- a/spl/Makefile +++ b/spl/Makefile @@ -81,6 +81,8 @@ LIBS-$(CONFIG_SPL_POST_MEM_SUPPORT) += post/drivers/memory.o LIBS-$(CONFIG_SPL_NET_SUPPORT) += net/libnet.o LIBS-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/libnet.o LIBS-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/phy/libphy.o +LIBS-$(CONFIG_SPL_MUSB_NEW_SUPPORT) += drivers/usb/musb-new/libusb_musb-new.o +LIBS-$(CONFIG_SPL_USBETH_SUPPORT) += drivers/usb/gadget/libusb_gadget.o ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP34XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX),) LIBS-y += $(CPUDIR)/omap-common/libomap-common.o -- 1.8.0.2 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 4/5] spl: add possibility to force boot device
Sometimes (for debugging purposes mostly but also to overcome some hardware limitations) it's desirable to be able to force boot device to some fixed value. This patch adds this possibility via CONFIG_SPL_FORCE_BOOT_DEVICE option. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- common/spl/spl.c | 4 1 file changed, 4 insertions(+) diff --git a/common/spl/spl.c b/common/spl/spl.c index 6a5a136..37f4d38 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -177,7 +177,11 @@ void board_init_r(gd_t *dummy1, ulong dummy2) spl_board_init(); #endif +#ifdef CONFIG_SPL_FORCE_BOOT_DEVICE + boot_device = CONFIG_SPL_FORCE_BOOT_DEVICE; +#else boot_device = spl_boot_device(); +#endif debug(boot device - %d\n, boot_device); switch (boot_device) { #ifdef CONFIG_SPL_RAM_DEVICE -- 1.8.0.2 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 3/5] am335x_evm: enable support for booting via USB
This adds necessary config options to enable usb booting and fixes board_eth_init() function to take into account that we may have USB ether support in SPL now. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- board/ti/am335x/board.c | 3 ++- include/configs/am335x_evm.h | 8 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c index f0eca54..5728c9a 100644 --- a/board/ti/am335x/board.c +++ b/board/ti/am335x/board.c @@ -425,7 +425,8 @@ int board_eth_init(bd_t *bis) n += rv; #endif try_usbether: -#if defined(CONFIG_USB_ETHER) !defined(CONFIG_SPL_BUILD) +#if defined(CONFIG_USB_ETHER) \ + (!defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_USBETH_SUPPORT)) rv = usb_eth_initialize(bis); if (rv 0) printf(Error %d registering USB_ETHER\n, rv); diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h index ab9549b..2da863d 100644 --- a/include/configs/am335x_evm.h +++ b/include/configs/am335x_evm.h @@ -238,6 +238,8 @@ #define CONFIG_SPL_SPI_CS 0 #define CONFIG_SYS_SPI_U_BOOT_OFFS 0x2 #define CONFIG_SYS_SPI_U_BOOT_SIZE 0x4 +#define CONFIG_SPL_MUSB_NEW_SUPPORT +#define CONFIG_SPL_USBETH_SUPPORT #define CONFIG_SPL_LDSCRIPT$(CPUDIR)/omap-common/u-boot-spl.lds /* @@ -279,6 +281,8 @@ #ifdef CONFIG_MUSB_GADGET #define CONFIG_USB_ETHER #define CONFIG_USB_ETH_RNDIS +#define CONFIG_USBNET_HOST_ADDRde:ad:be:af:00:00 +#define CONFIG_USBNET_DEV_ADDR de:ad:be:af:00:01 #endif /* CONFIG_MUSB_GADGET */ /* Unsupported features */ @@ -301,4 +305,8 @@ #define CONFIG_PHYLIB #define CONFIG_PHY_SMSC +#ifdef CONFIG_SPL_BUILD +/* disable host part of MUSB in SPL */ +#undef CONFIG_MUSB_HOST +#endif #endif /* ! __CONFIG_AM335X_EVM_H */ -- 1.8.0.2 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 0/5] am335x_evm: support for booting via USB
These series add support for booting via USB on TI AM335X based boards. Tested on BeagleBone. Ilya Yanok (5): spl: support for booting via usbeth am33xx: support for booting via usbeth am335x_evm: enable support for booting via USB spl: add possibility to force boot device am335x_evm: add new config with forced USB booting arch/arm/cpu/armv7/omap-common/boot-common.c | 3 +++ arch/arm/include/asm/arch-am33xx/spl.h | 1 + board/ti/am335x/board.c | 3 ++- boards.cfg | 1 + common/spl/spl.c | 9 + include/configs/am335x_evm.h | 8 spl/Makefile | 2 ++ 7 files changed, 26 insertions(+), 1 deletion(-) -- 1.8.0.2 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 5/5] am335x_evm: add new config with forced USB booting
Currently AM335X hardware has bug in it's ROM code that prevents USB booting from working normally. So we have to load SPL via serial console instead. But it's feasible to use USB for loading the main U-Boot image. This patch adds additional am335x_evm configuration for this. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- boards.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/boards.cfg b/boards.cfg index 91504c0..e7c66a9 100644 --- a/boards.cfg +++ b/boards.cfg @@ -229,6 +229,7 @@ integratorap_cm946es arm arm946es integrator armltd integratorcp_cm946es arm arm946esintegrator armltd - integratorcp:CM946ES ca9x4_ct_vxp arm armv7 vexpressarmltd am335x_evm arm armv7 am335x ti am33xx am335x_evm:SERIAL1,CONS_INDEX=1 +am335x_evm_usbboot arm armv7 am335x ti am33xx am335x_evm:SERIAL1,CONS_INDEX=1,SPL_FORCE_BOOT_DEVICE=BOOT_DEVICE_USBETH am335x_evm_uart1 arm armv7 am335x ti am33xx am335x_evm:SERIAL2,CONS_INDEX=2 am335x_evm_uart2 arm armv7 am335x ti am33xx am335x_evm:SERIAL3,CONS_INDEX=3 am335x_evm_uart3 arm armv7 am335x ti am33xx am335x_evm:SERIAL4,CONS_INDEX=4 -- 1.8.0.2 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2 3/8] am33xx: NAND support
Hi Peter, On Thu, Nov 8, 2012 at 10:33 AM, Peter Korsgaard jac...@sunsite.dk wrote: Ilya +void enable_gpmc_cs_config(const u32 *gpmc_config, struct gpmc_cs *cs, u32 base, Ilya +u32 size) Ilya +{ Ilya +writel(0, cs-config7); Ilya +sdelay(1000); Ilya +/* Delay for settling */ That comment should go above the delay. Ok, will fix. Ilya +writel(gpmc_config[0], cs-config1); Ilya +writel(gpmc_config[1], cs-config2); Ilya +writel(gpmc_config[2], cs-config3); Ilya +writel(gpmc_config[3], cs-config4); Ilya +writel(gpmc_config[4], cs-config5); Ilya +writel(gpmc_config[5], cs-config6); Ilya +/* Enable the config */ Ilya +writelsize 0xF) 8) | ((base 24) 0x3F) | Ilya +(1 6)), cs-config7); Ilya +sdelay(2000); Any reason you now wait double as long? No idea ;) To tell the truth I've taken all this code from omap3 as is. Ilya +} Ilya + Ilya +/* Ilya + * gpmc_init(): init gpmc bus Ilya + * Init GPMC for x16, MuxMode (SDRAM in x32). Ilya + * This code can only be executed from SRAM or SDRAM. Ilya + */ Ilya +void gpmc_init(void) Ilya +{ Ilya +/* putting a blanket check on GPMC based on ZeBu for now */ Ilya +gpmc_cfg = (struct gpmc *)GPMC_BASE; Ilya + Ilya +#ifdef CONFIG_CMD_NAND Ilya +const u32 *gpmc_config = NULL; Ilya +u32 base = 0; Ilya +u32 size = 0; Ilya +#endif Ilya +/* global settings */ Ilya +writel(0x0008, gpmc_cfg-sysconfig); Ilya +writel(0x0100, gpmc_cfg-irqstatus); Ilya +writel(0x0200, gpmc_cfg-irqenable); Ilya +writel(0x0012, gpmc_cfg-config); Ilya +/* Ilya + * Disable the GPMC0 config set by ROM code Ilya + */ Ilya +writel(0, gpmc_cfg-cs[0].config7); Ilya +sdelay(1000); Why? You already do this in enable_gpmc_cs_config(). Hm... Again, I'm not the one who written this code, I just stole it ;) but probably the idea was to disable the config even in case of CONFIG_CMD_NAND undefined... Ilya + Ilya +#ifdef CONFIG_CMD_NAND Ilya +gpmc_config = gpmc_m_nand; Ilya + Ilya +base = PISMO1_NAND_BASE; Ilya +size = PISMO1_NAND_SIZE; Ilya +enable_gpmc_cs_config(gpmc_config, gpmc_cfg-cs[0], base, size); Ilya +#endif Ilya +} Ilya +#define M_NAND_GPMC_CONFIG1 0x0800 Ilya +#define M_NAND_GPMC_CONFIG2 0x001e1e00 Ilya +#define M_NAND_GPMC_CONFIG3 0x001e1e00 Ilya +#define M_NAND_GPMC_CONFIG4 0x16051807 Ilya +#define M_NAND_GPMC_CONFIG5 0x00151e1e Ilya +#define M_NAND_GPMC_CONFIG6 0x16000f80 Ilya +#define M_NAND_GPMC_CONFIG7 0x0008 For what Micron part is this exactly? How about using the actual part number in the define like we recently did for the DDR configuration? Ok, I'll try to figure that out from schematics. Do the non-BCH layouts make sense for am33xx? I've noticed that the TRM shows the BCH8 format as 13 bytes/256 tightly packed instead of 14, but that's wrong. I'll report it to the doc people. Hm. Non-BCH layouts was here because I initially planned to support nandecc command to switch between supported ECC schemas... But as Tom requested to remove it I guess we don't need these layouts any more... Well, my idea was to make separate patches (one to just support existing omap_gpmc driver on AM33xx and one to add BCH8 support) and this kinda needs non-BCH layouts too... but I guess I should just squash the patches into one. Thanks for the review. Regards, Ilya. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] SMSC LAN9514 on TI DM37x board
On Tue, Nov 6, 2012 at 9:24 AM, Felix Radensky fe...@embedded-sol.comwrote: Hi Marek, On 11/06/2012 12:57 AM, Marek Vasut wrote: Can you please avoid top-posting? Does U-Boot even support your USB device? Sorry about top-posting. My USB device is supported by smsc95xx.c driver in drivers/usb/eth. Judging by the portion of config you cited you don't have it enabled. But I don't think that's your current problem (you should see your device after usb start even if there is no driver for it). I'd verify PHY configuration if I were you. Regards, Ilya. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 0/8] NAND support for AM33XX
These series add support for NAND on AM33XX. AM33XX has the same GPMC controller as OMAP3 so the first part of the series just add required defines/initialization to enable the existing omap_gpmc driver to work on AM33XX. The rest of the series adds support for BCH8 error correction code. We use GPMC to generate codes/syndromes and ELM to find the errors. Changes in v2: -fix nand mux settings (profiles 23 don't have NAND) - rebased on current master - clean up mem.c (remove unused stuff that was copied from OMAP3) - nand headers: remove unneeded stuff - rebased onto master - minor config style fix (wrt nand) - fix wrong braces in Makefile Ilya Yanok (6): OMAP: include sys_proto.h from boot-common am335x_evm: add nand pinmux definition am33xx: NAND support am335x_evm: enable NAND support am33xx_spl_bch: simple SPL nand loader for AM33XX am335x_evm: enable SPL NAND support Mansoor Ahamed (2): am33xx: add ELM support omap_gpmc: BCH8 support (ELM based) arch/arm/cpu/armv7/am33xx/Makefile |2 + arch/arm/cpu/armv7/am33xx/board.c|1 + arch/arm/cpu/armv7/am33xx/clock.c| 10 + arch/arm/cpu/armv7/am33xx/elm.c | 212 ++ arch/arm/cpu/armv7/am33xx/mem.c | 101 +++ arch/arm/cpu/armv7/omap-common/boot-common.c |1 + arch/arm/include/asm/arch-am33xx/cpu.h | 53 arch/arm/include/asm/arch-am33xx/elm.h | 93 ++ arch/arm/include/asm/arch-am33xx/hardware.h |3 + arch/arm/include/asm/arch-am33xx/mem.h | 83 ++ arch/arm/include/asm/arch-am33xx/omap_gpmc.h | 120 arch/arm/include/asm/arch-am33xx/sys_proto.h |3 + board/ti/am335x/board.c |2 + board/ti/am335x/mux.c| 22 ++ drivers/mtd/nand/Makefile|1 + drivers/mtd/nand/am335x_spl_bch.c| 238 +++ drivers/mtd/nand/omap_gpmc.c | 403 +- include/configs/am335x_evm.h | 46 +++ 18 files changed, 1393 insertions(+), 1 deletion(-) create mode 100644 arch/arm/cpu/armv7/am33xx/elm.c create mode 100644 arch/arm/cpu/armv7/am33xx/mem.c create mode 100644 arch/arm/include/asm/arch-am33xx/elm.h create mode 100644 arch/arm/include/asm/arch-am33xx/mem.h create mode 100644 arch/arm/include/asm/arch-am33xx/omap_gpmc.h create mode 100644 drivers/mtd/nand/am335x_spl_bch.c -- 1.7.10.2 (Apple Git-33) ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 1/8] OMAP: include sys_proto.h from boot-common
Include asm/arch/sys_proto.h for gpmc_init prototype. Without this we get a warning while building for AM335x. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- arch/arm/cpu/armv7/omap-common/boot-common.c |1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/cpu/armv7/omap-common/boot-common.c b/arch/arm/cpu/armv7/omap-common/boot-common.c index 0f19141..2b584e0 100644 --- a/arch/arm/cpu/armv7/omap-common/boot-common.c +++ b/arch/arm/cpu/armv7/omap-common/boot-common.c @@ -21,6 +21,7 @@ #include asm/omap_common.h #include asm/arch/omap.h #include asm/arch/mmc_host_def.h +#include asm/arch/sys_proto.h /* * This is used to verify if the configuration header -- 1.7.10.2 (Apple Git-33) ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 2/8] am335x_evm: add nand pinmux definition
Add NAND pins mux settings for AM335X devices. Enable NAND pins for AM335X EVM board. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- Changes in v2: -fix nand mux settings (profiles 23 don't have NAND) board/ti/am335x/mux.c | 22 ++ 1 file changed, 22 insertions(+) diff --git a/board/ti/am335x/mux.c b/board/ti/am335x/mux.c index 8437ef5..0283708 100644 --- a/board/ti/am335x/mux.c +++ b/board/ti/am335x/mux.c @@ -171,6 +171,25 @@ static struct module_pin_mux mii1_pin_mux[] = { {-1}, }; +static struct module_pin_mux nand_pin_mux[] = { + {OFFSET(gpmc_ad0), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD0 */ + {OFFSET(gpmc_ad1), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD1 */ + {OFFSET(gpmc_ad2), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD2 */ + {OFFSET(gpmc_ad3), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD3 */ + {OFFSET(gpmc_ad4), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD4 */ + {OFFSET(gpmc_ad5), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD5 */ + {OFFSET(gpmc_ad6), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD6 */ + {OFFSET(gpmc_ad7), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD7 */ + {OFFSET(gpmc_wait0), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* NAND WAIT */ + {OFFSET(gpmc_wpn), (MODE(7) | PULLUP_EN | RXACTIVE)}, /* NAND_WPN */ + {OFFSET(gpmc_csn0), (MODE(0) | PULLUDEN)}, /* NAND_CS0 */ + {OFFSET(gpmc_advn_ale), (MODE(0) | PULLUDEN)}, /* NAND_ADV_ALE */ + {OFFSET(gpmc_oen_ren), (MODE(0) | PULLUDEN)}, /* NAND_OE */ + {OFFSET(gpmc_wen), (MODE(0) | PULLUDEN)}, /* NAND_WEN */ + {OFFSET(gpmc_be0n_cle), (MODE(0) | PULLUDEN)}, /* NAND_BE_CLE */ + {-1}, +}; + void enable_uart0_pin_mux(void) { configure_module_pin_mux(uart0_pin_mux); @@ -257,6 +276,9 @@ void enable_board_pin_mux(struct am335x_baseboard_id *header) /* In profile #2 i2c1 and spi0 conflict. */ if (profile ~PROFILE_2) configure_module_pin_mux(i2c1_pin_mux); + /* Profiles 2 3 don't have NAND */ + if (profile ~(PROFILE_2 | PROFILE_3)) + configure_module_pin_mux(nand_pin_mux); else if (profile == PROFILE_2) { configure_module_pin_mux(mmc1_pin_mux); configure_module_pin_mux(spi0_pin_mux); -- 1.7.10.2 (Apple Git-33) ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 3/8] am33xx: NAND support
TI AM33XX has the same GPMC controller as OMAP3 so we could just use the existing omap_gpmc driver. This patch adds adds required definitions/intialization. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- Changes in v2: - rebased on current master - clean up mem.c (remove unused stuff that was copied from OMAP3) - nand headers: remove unneeded stuff arch/arm/cpu/armv7/am33xx/Makefile |1 + arch/arm/cpu/armv7/am33xx/board.c|1 + arch/arm/cpu/armv7/am33xx/clock.c|5 ++ arch/arm/cpu/armv7/am33xx/mem.c | 101 ++ arch/arm/include/asm/arch-am33xx/cpu.h | 53 arch/arm/include/asm/arch-am33xx/hardware.h |3 + arch/arm/include/asm/arch-am33xx/mem.h | 83 ++ arch/arm/include/asm/arch-am33xx/omap_gpmc.h | 120 ++ arch/arm/include/asm/arch-am33xx/sys_proto.h |3 + 9 files changed, 370 insertions(+) create mode 100644 arch/arm/cpu/armv7/am33xx/mem.c create mode 100644 arch/arm/include/asm/arch-am33xx/mem.h create mode 100644 arch/arm/include/asm/arch-am33xx/omap_gpmc.h diff --git a/arch/arm/cpu/armv7/am33xx/Makefile b/arch/arm/cpu/armv7/am33xx/Makefile index 74875b3..f565357 100644 --- a/arch/arm/cpu/armv7/am33xx/Makefile +++ b/arch/arm/cpu/armv7/am33xx/Makefile @@ -18,6 +18,7 @@ LIB = $(obj)lib$(SOC).o COBJS += clock.o COBJS += sys_info.o +COBJS += mem.o COBJS += ddr.o COBJS += emif4.o COBJS += board.o diff --git a/arch/arm/cpu/armv7/am33xx/board.c b/arch/arm/cpu/armv7/am33xx/board.c index e4c123c..c756c09 100644 --- a/arch/arm/cpu/armv7/am33xx/board.c +++ b/arch/arm/cpu/armv7/am33xx/board.c @@ -25,6 +25,7 @@ #include asm/arch/ddr_defs.h #include asm/arch/clock.h #include asm/arch/gpio.h +#include asm/arch/mem.h #include asm/arch/mmc_host_def.h #include asm/arch/sys_proto.h #include asm/io.h diff --git a/arch/arm/cpu/armv7/am33xx/clock.c b/arch/arm/cpu/armv7/am33xx/clock.c index bc2abb6..6eb7d9f 100644 --- a/arch/arm/cpu/armv7/am33xx/clock.c +++ b/arch/arm/cpu/armv7/am33xx/clock.c @@ -150,6 +150,11 @@ static void enable_per_clocks(void) ; #endif /* CONFIG_SERIAL6 */ + /* GPMC */ + writel(PRCM_MOD_EN, cmper-gpmcclkctrl); + while (readl(cmper-gpmcclkctrl) != PRCM_MOD_EN) + ; + /* MMC0*/ writel(PRCM_MOD_EN, cmper-mmc0clkctrl); while (readl(cmper-mmc0clkctrl) != PRCM_MOD_EN) diff --git a/arch/arm/cpu/armv7/am33xx/mem.c b/arch/arm/cpu/armv7/am33xx/mem.c new file mode 100644 index 000..b8f54ab --- /dev/null +++ b/arch/arm/cpu/armv7/am33xx/mem.c @@ -0,0 +1,101 @@ +/* + * (C) Copyright 2010 + * Texas Instruments, www.ti.com + * + * Author : + * Mansoor Ahamed mansoor.aha...@ti.com + * + * Initial Code from: + * Manikandan Pillai mani.pil...@ti.com + * Richard Woodruff r-woodru...@ti.com + * Syed Mohammed Khasim kha...@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 + */ + +#include common.h +#include asm/io.h +#include asm/arch/cpu.h +#include asm/arch/mem.h +#include asm/arch/sys_proto.h +#include command.h + +struct gpmc *gpmc_cfg; + +#if defined(CONFIG_CMD_NAND) +static const u32 gpmc_m_nand[GPMC_MAX_REG] = { + M_NAND_GPMC_CONFIG1, + M_NAND_GPMC_CONFIG2, + M_NAND_GPMC_CONFIG3, + M_NAND_GPMC_CONFIG4, + M_NAND_GPMC_CONFIG5, + M_NAND_GPMC_CONFIG6, 0 +}; +#endif + + +void enable_gpmc_cs_config(const u32 *gpmc_config, struct gpmc_cs *cs, u32 base, + u32 size) +{ + writel(0, cs-config7); + sdelay(1000); + /* Delay for settling */ + writel(gpmc_config[0], cs-config1); + writel(gpmc_config[1], cs-config2); + writel(gpmc_config[2], cs-config3); + writel(gpmc_config[3], cs-config4); + writel(gpmc_config[4], cs-config5); + writel(gpmc_config[5], cs-config6); + /* Enable the config */ + writelsize 0xF) 8) | ((base 24) 0x3F) | + (1 6)), cs-config7); + sdelay(2000); +} + +/* + * gpmc_init(): init gpmc bus + * Init GPMC for x16, MuxMode (SDRAM in x32). + * This code can only be executed from SRAM or SDRAM
[U-Boot] [PATCH v2 4/8] am335x_evm: enable NAND support
Enable NAND support for AM335X boards. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- Changes in v2: - rebased onto master - minor config style fix (wrt nand) board/ti/am335x/board.c |2 ++ include/configs/am335x_evm.h | 12 2 files changed, 14 insertions(+) diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c index b56a801..6908378 100644 --- a/board/ti/am335x/board.c +++ b/board/ti/am335x/board.c @@ -318,6 +318,8 @@ int board_init(void) gd-bd-bi_boot_params = PHYS_DRAM_1 + 0x100; + gpmc_init(); + return 0; } diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h index b6e48f8..ded1cab 100644 --- a/include/configs/am335x_evm.h +++ b/include/configs/am335x_evm.h @@ -274,4 +274,16 @@ #define CONFIG_PHYLIB #define CONFIG_PHY_SMSC +#define CONFIG_NAND +/* NAND support */ +#ifdef CONFIG_NAND +#define CONFIG_CMD_NAND +#define CONFIG_NAND_OMAP_GPMC +#define GPMC_NAND_ECC_LP_x16_LAYOUT1 +#define CONFIG_SYS_NAND_BASE (0x0800)/* physical address */ + /* to access nand at */ + /* CS0 */ +#define CONFIG_SYS_MAX_NAND_DEVICE 1 /* Max number of NAND */ +#endif /* devices */ + #endif /* ! __CONFIG_AM335X_EVM_H */ -- 1.7.10.2 (Apple Git-33) ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 5/8] am33xx: add ELM support
From: Mansoor Ahamed mansoor.aha...@ti.com AM33XX has Error Location Module (ELM) that can be used in conjuction with GPMC controller to implement BCH codes fully in hardware. This code is mostly taken from arago tree. Signed-off-by: Mansoor Ahamed mansoor.aha...@ti.com Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- Changes in v2: - fix wrong braces in Makefile arch/arm/cpu/armv7/am33xx/Makefile |1 + arch/arm/cpu/armv7/am33xx/clock.c |5 + arch/arm/cpu/armv7/am33xx/elm.c| 212 arch/arm/include/asm/arch-am33xx/elm.h | 93 ++ 4 files changed, 311 insertions(+) create mode 100644 arch/arm/cpu/armv7/am33xx/elm.c create mode 100644 arch/arm/include/asm/arch-am33xx/elm.h diff --git a/arch/arm/cpu/armv7/am33xx/Makefile b/arch/arm/cpu/armv7/am33xx/Makefile index f565357..70c443e 100644 --- a/arch/arm/cpu/armv7/am33xx/Makefile +++ b/arch/arm/cpu/armv7/am33xx/Makefile @@ -23,6 +23,7 @@ COBJS += ddr.o COBJS += emif4.o COBJS += board.o COBJS += mux.o +COBJS-$(CONFIG_NAND_OMAP_GPMC) += elm.o SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS) $(COBJS-y) $(SOBJS)) diff --git a/arch/arm/cpu/armv7/am33xx/clock.c b/arch/arm/cpu/armv7/am33xx/clock.c index 6eb7d9f..2b7c910 100644 --- a/arch/arm/cpu/armv7/am33xx/clock.c +++ b/arch/arm/cpu/armv7/am33xx/clock.c @@ -155,6 +155,11 @@ static void enable_per_clocks(void) while (readl(cmper-gpmcclkctrl) != PRCM_MOD_EN) ; + /* ELM */ + writel(PRCM_MOD_EN, cmper-elmclkctrl); + while (readl(cmper-elmclkctrl) != PRCM_MOD_EN) + ; + /* MMC0*/ writel(PRCM_MOD_EN, cmper-mmc0clkctrl); while (readl(cmper-mmc0clkctrl) != PRCM_MOD_EN) diff --git a/arch/arm/cpu/armv7/am33xx/elm.c b/arch/arm/cpu/armv7/am33xx/elm.c new file mode 100644 index 000..9eed23d --- /dev/null +++ b/arch/arm/cpu/armv7/am33xx/elm.c @@ -0,0 +1,212 @@ +/* + * (C) Copyright 2010-2011 Texas Instruments, www.ti.com + * Mansoor Ahamed mansoor.aha...@ti.com + * + * BCH Error Location Module (ELM) support. + * + * NOTE: + * 1. Supports only continuous mode. Dont see need for page mode in uboot + * 2. Supports only syndrome polynomial 0. i.e. poly local variable is + *always set to ELM_DEFAULT_POLY. Dont see need for other polynomial + *sets in uboot + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include common.h +#include asm/io.h +#include asm/errno.h +#include asm/arch/cpu.h +#include asm/arch/omap_gpmc.h +#include asm/arch/elm.h + +#define ELM_DEFAULT_POLY (0) + +struct elm *elm_cfg; + +/** + * elm_load_syndromes - Load BCH syndromes based on nibble selection + * @syndrome: BCH syndrome + * @nibbles: + * @poly: Syndrome Polynomial set to use + * + * Load BCH syndromes based on nibble selection + */ +static void elm_load_syndromes(u8 *syndrome, u32 nibbles, u8 poly) +{ + u32 *ptr; + u32 val; + + /* reg 0 */ + ptr = elm_cfg-syndrome_fragments[poly].syndrome_fragment_x[0]; + val = syndrome[0] | (syndrome[1] 8) | (syndrome[2] 16) | + (syndrome[3] 24); + writel(val, ptr); + /* reg 1 */ + ptr = elm_cfg-syndrome_fragments[poly].syndrome_fragment_x[1]; + val = syndrome[4] | (syndrome[5] 8) | (syndrome[6] 16) | + (syndrome[7] 24); + writel(val, ptr); + + /* BCH 8-bit with 26 nibbles (4*8=32) */ + if (nibbles 13) { + /* reg 2 */ + ptr = elm_cfg-syndrome_fragments[poly].syndrome_fragment_x[2]; + val = syndrome[8] | (syndrome[9] 8) | (syndrome[10] 16) | + (syndrome[11] 24); + writel(val, ptr); + /* reg 3 */ + ptr = elm_cfg-syndrome_fragments[poly].syndrome_fragment_x[3]; + val = syndrome[12] | (syndrome[13] 8) | + (syndrome[14] 16) | (syndrome[15] 24); + writel(val, ptr); + } + + /* BCH 16-bit with 52 nibbles (7*8=56) */ + if (nibbles 26) { + /* reg 4 */ + ptr = elm_cfg-syndrome_fragments[poly
[U-Boot] [PATCH v2 6/8] omap_gpmc: BCH8 support (ELM based)
From: Mansoor Ahamed mansoor.aha...@ti.com This patch adds support for BCH8 error correction code to omap_gpmc driver. We use GPMC to generate codes/syndromes but we need ELM to find error locations from given syndrome. Signed-off-by: Mansoor Ahamed mansoor.aha...@ti.com [ilya: merge it with omap_gpmc driver, some fixes and cleanup] Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- drivers/mtd/nand/omap_gpmc.c | 403 +- 1 file changed, 402 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/nand/omap_gpmc.c b/drivers/mtd/nand/omap_gpmc.c index f1469d1..cee394e 100644 --- a/drivers/mtd/nand/omap_gpmc.c +++ b/drivers/mtd/nand/omap_gpmc.c @@ -29,6 +29,9 @@ #include linux/mtd/nand_ecc.h #include linux/compiler.h #include nand.h +#ifdef CONFIG_AM33XX +#include asm/arch/elm.h +#endif static uint8_t cs; static __maybe_unused struct nand_ecclayout hw_nand_oob = @@ -234,6 +237,370 @@ static void __maybe_unused omap_enable_hwecc(struct mtd_info *mtd, int32_t mode) } } +/* + * BCH8 support (needs ELM and thus AM33xx-only) + */ +#ifdef CONFIG_AM33XX +struct nand_bch_priv { + uint8_t mode; + uint8_t type; + uint8_t nibbles; +}; + +/* bch types */ +#define ECC_BCH4 0 +#define ECC_BCH8 1 +#define ECC_BCH16 2 + +/* BCH nibbles for diff bch levels */ +#define NAND_ECC_HW_BCH ((uint8_t)(NAND_ECC_HW_OOB_FIRST) + 1) +#define ECC_BCH4_NIBBLES 13 +#define ECC_BCH8_NIBBLES 26 +#define ECC_BCH16_NIBBLES 52 + +static struct nand_ecclayout hw_bch8_nand_oob = GPMC_NAND_HW_BCH8_ECC_LAYOUT; + +static struct nand_bch_priv bch_priv = { + .mode = NAND_ECC_HW_BCH, + .type = ECC_BCH8, + .nibbles = ECC_BCH8_NIBBLES +}; + +/* + * omap_read_bch8_result - Read BCH result for BCH8 level + * + * @mtd: MTD device structure + * @big_endian:When set read register 3 first + * @ecc_code: Read syndrome from BCH result registers + */ +static void omap_read_bch8_result(struct mtd_info *mtd, uint8_t big_endian, + uint8_t *ecc_code) +{ + uint32_t *ptr; + int8_t i = 0, j; + + if (big_endian) { + ptr = gpmc_cfg-bch_result_0_3[0].bch_result_x[3]; + ecc_code[i++] = readl(ptr) 0xFF; + ptr--; + for (j = 0; j 3; j++) { + ecc_code[i++] = (readl(ptr) 24) 0xFF; + ecc_code[i++] = (readl(ptr) 16) 0xFF; + ecc_code[i++] = (readl(ptr) 8) 0xFF; + ecc_code[i++] = readl(ptr) 0xFF; + ptr--; + } + } else { + ptr = gpmc_cfg-bch_result_0_3[0].bch_result_x[0]; + for (j = 0; j 3; j++) { + ecc_code[i++] = readl(ptr) 0xFF; + ecc_code[i++] = (readl(ptr) 8) 0xFF; + ecc_code[i++] = (readl(ptr) 16) 0xFF; + ecc_code[i++] = (readl(ptr) 24) 0xFF; + ptr++; + } + ecc_code[i++] = readl(ptr) 0xFF; + ecc_code[i++] = 0; /* 14th byte is always zero */ + } +} + +/* + * omap_ecc_disable - Disable H/W ECC calculation + * + * @mtd: MTD device structure + * + */ +static void omap_ecc_disable(struct mtd_info *mtd) +{ + writel((readl(gpmc_cfg-ecc_config) ~0x1), + gpmc_cfg-ecc_config); +} + +/* + * omap_rotate_ecc_bch - Rotate the syndrome bytes + * + * @mtd: MTD device structure + * @calc_ecc: ECC read from ECC registers + * @syndrome: Rotated syndrome will be retuned in this array + * + */ +static void omap_rotate_ecc_bch(struct mtd_info *mtd, uint8_t *calc_ecc, + uint8_t *syndrome) +{ + struct nand_chip *chip = mtd-priv; + struct nand_bch_priv *bch = chip-priv; + uint8_t n_bytes = 0; + int8_t i, j; + + switch (bch-type) { + case ECC_BCH4: + n_bytes = 8; + break; + + case ECC_BCH16: + n_bytes = 28; + break; + + case ECC_BCH8: + default: + n_bytes = 13; + break; + } + + for (i = 0, j = (n_bytes-1); i n_bytes; i++, j--) + syndrome[i] = calc_ecc[j]; +} + +/* + * omap_calculate_ecc_bch - Read BCH ECC result + * + * @mtd: MTD structure + * @dat: unused + * @ecc_code: ecc_code buffer + */ +static int omap_calculate_ecc_bch(struct mtd_info *mtd, const uint8_t *dat, + uint8_t *ecc_code) +{ + struct nand_chip *chip = mtd-priv; + struct nand_bch_priv *bch = chip-priv; + uint8_t big_endian = 1; + int8_t ret = 0; + + if (bch-type == ECC_BCH8) + omap_read_bch8_result(mtd, big_endian, ecc_code); + else /* BCH4 and BCH16 currently not supported */ + ret = -1; + + /* +* Stop reading
[U-Boot] [PATCH v2 8/8] am335x_evm: enable SPL NAND support
Enable booting from NAND support from AM335x boards as well as environment in NAND. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- include/configs/am335x_evm.h | 38 -- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h index ded1cab..6abe544 100644 --- a/include/configs/am335x_evm.h +++ b/include/configs/am335x_evm.h @@ -240,6 +240,35 @@ #define CONFIG_SYS_SPI_U_BOOT_SIZE 0x4 #define CONFIG_SPL_LDSCRIPT$(CPUDIR)/omap-common/u-boot-spl.lds +#define CONFIG_SPL_BOARD_INIT +#define CONFIG_SPL_NAND_AM33XX_BCH +#define CONFIG_SPL_NAND_SUPPORT +#define CONFIG_SYS_NAND_5_ADDR_CYCLE +#define CONFIG_SYS_NAND_PAGE_COUNT (CONFIG_SYS_NAND_BLOCK_SIZE / \ +CONFIG_SYS_NAND_PAGE_SIZE) +#define CONFIG_SYS_NAND_PAGE_SIZE 2048 +#define CONFIG_SYS_NAND_OOBSIZE64 +#define CONFIG_SYS_NAND_BLOCK_SIZE (128*1024) +#define CONFIG_SYS_NAND_BAD_BLOCK_POS NAND_LARGE_BADBLOCK_POS +#define CONFIG_SYS_NAND_ECCPOS { 2, 3, 4, 5, 6, 7, 8, 9, \ +10, 11, 12, 13, 14, 15, 16, 17, \ +18, 19, 20, 21, 22, 23, 24, 25, \ +26, 27, 28, 29, 30, 31, 32, 33, \ +34, 35, 36, 37, 38, 39, 40, 41, \ +42, 43, 44, 45, 46, 47, 48, 49, \ +50, 51, 52, 53, 54, 55, 56, 57, } + +#define CONFIG_SYS_NAND_ECCSIZE512 +#define CONFIG_SYS_NAND_ECCBYTES 14 + +#define CONFIG_SYS_NAND_ECCSTEPS 4 +#defineCONFIG_SYS_NAND_ECCTOTAL(CONFIG_SYS_NAND_ECCBYTES * \ + CONFIG_SYS_NAND_ECCSTEPS) + +#defineCONFIG_SYS_NAND_U_BOOT_STARTCONFIG_SYS_TEXT_BASE + +#define CONFIG_SYS_NAND_U_BOOT_OFFS0x8 + /* * 1MB into the SDRAM to allow for SPL's bss at the beginning of SDRAM * 64 bytes before this address should be set aside for u-boot.img's @@ -283,7 +312,12 @@ #define CONFIG_SYS_NAND_BASE (0x0800)/* physical address */ /* to access nand at */ /* CS0 */ -#define CONFIG_SYS_MAX_NAND_DEVICE 1 /* Max number of NAND */ -#endif /* devices */ +#define CONFIG_SYS_MAX_NAND_DEVICE 1 /* Max number of NAND + devices */ +#undef CONFIG_ENV_IS_NOWHERE +#define CONFIG_ENV_IS_IN_NAND +#define CONFIG_ENV_OFFSET 0x26 /* environment starts here */ +#define CONFIG_SYS_ENV_SECT_SIZE (128 10) /* 128 KiB */ +#endif #endif /* ! __CONFIG_AM335X_EVM_H */ -- 1.7.10.2 (Apple Git-33) ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 7/8] am33xx_spl_bch: simple SPL nand loader for AM33XX
AM33XX with BCH8 can't work with nand_spl_simple correctly because custom read_page implementation is required for proper syndrome generation. This simple driver mostly duplicates nand_spl_simple but has nand_read_page changed to suit our needs. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- drivers/mtd/nand/Makefile |1 + drivers/mtd/nand/am335x_spl_bch.c | 238 + 2 files changed, 239 insertions(+) create mode 100644 drivers/mtd/nand/am335x_spl_bch.c diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile index beb99ca..5322f3a 100644 --- a/drivers/mtd/nand/Makefile +++ b/drivers/mtd/nand/Makefile @@ -30,6 +30,7 @@ ifdef CONFIG_SPL_BUILD ifdef CONFIG_SPL_NAND_SIMPLE COBJS-y += nand_spl_simple.o endif +COBJS-$(CONFIG_SPL_NAND_AM33XX_BCH) += am335x_spl_bch.o ifdef CONFIG_SPL_NAND_LOAD COBJS-y+= nand_spl_load.o endif diff --git a/drivers/mtd/nand/am335x_spl_bch.c b/drivers/mtd/nand/am335x_spl_bch.c new file mode 100644 index 000..b84528b --- /dev/null +++ b/drivers/mtd/nand/am335x_spl_bch.c @@ -0,0 +1,238 @@ +/* + * (C) Copyright 2012 + * Konstantin Kozhevnikov, Cogent Embedded + * + * based on nand_spl_simple code + * + * (C) Copyright 2006-2008 + * Stefan Roese, DENX Software Engineering, s...@denx.de. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc. + */ + +#include common.h +#include nand.h +#include asm/io.h +#include linux/mtd/nand_ecc.h + +static int nand_ecc_pos[] = CONFIG_SYS_NAND_ECCPOS; +static nand_info_t mtd; +static struct nand_chip nand_chip; + +#define ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ + CONFIG_SYS_NAND_ECCSIZE) +#define ECCTOTAL (ECCSTEPS * CONFIG_SYS_NAND_ECCBYTES) + + +/* + * NAND command for large page NAND devices (2k) + */ +static int nand_command(int block, int page, uint32_t offs, + u8 cmd) +{ + struct nand_chip *this = mtd.priv; + int page_addr = page + block * CONFIG_SYS_NAND_PAGE_COUNT; + void (*hwctrl)(struct mtd_info *mtd, int cmd, + unsigned int ctrl) = this-cmd_ctrl; + + while (!this-dev_ready(mtd)) + ; + + /* Emulate NAND_CMD_READOOB */ + if (cmd == NAND_CMD_READOOB) { + offs += CONFIG_SYS_NAND_PAGE_SIZE; + cmd = NAND_CMD_READ0; + } + + /* Begin command latch cycle */ + hwctrl(mtd, cmd, NAND_CTRL_CLE | NAND_CTRL_CHANGE); + + if (cmd == NAND_CMD_RESET) { + hwctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); + while (!this-dev_ready(mtd)) + ; + return 0; + } + + /* Shift the offset from byte addressing to word addressing. */ + if (this-options NAND_BUSWIDTH_16) + offs = 1; + + /* Set ALE and clear CLE to start address cycle */ + /* Column address */ + hwctrl(mtd, offs 0xff, + NAND_CTRL_ALE | NAND_CTRL_CHANGE); /* A[7:0] */ + hwctrl(mtd, (offs 8) 0xff, NAND_CTRL_ALE); /* A[11:9] */ + /* Row address */ + hwctrl(mtd, (page_addr 0xff), NAND_CTRL_ALE); /* A[19:12] */ + hwctrl(mtd, ((page_addr 8) 0xff), + NAND_CTRL_ALE); /* A[27:20] */ +#ifdef CONFIG_SYS_NAND_5_ADDR_CYCLE + /* One more address cycle for devices 128MiB */ + hwctrl(mtd, (page_addr 16) 0x0f, + NAND_CTRL_ALE); /* A[31:28] */ +#endif + hwctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); + + if (cmd == NAND_CMD_READ0) { + /* Latch in address */ + hwctrl(mtd, NAND_CMD_READSTART, + NAND_CTRL_CLE | NAND_CTRL_CHANGE); + hwctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); + + /* +* Wait a while for the data to be ready +*/ + while (!this-dev_ready(mtd)) + ; + } else if (cmd == NAND_CMD_RNDOUT) { + hwctrl(mtd, NAND_CMD_RNDOUTSTART, NAND_CTRL_CLE | + NAND_CTRL_CHANGE); + hwctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); + } + + return 0; +} + +static int nand_is_bad_block(int block) +{ + struct nand_chip *this = mtd.priv; + + nand_command(block, 0
[U-Boot] [PATCH v5 0/13] Port of MUSB driver from Linux (changes from Linux)
Current MUSB driver in U-Boot uses old UDC API while new gagdet client drivers need new gadget API. Also current MUSB driver has some significant limitations (like inability to handle tx for endpoints other than ep0). So I think port of new Linux driver is desirable. This is initial port, performed mostly by putting DM and OTG code under #ifndef __UBOOT__ clauses. My intention was to be as close as possible to the original to ease of possible resyncs. Some warnings are suppressed via CFLAGS. There are some style problems but I'm not touching them for now for the above mentioned reason. There is obviously some room for optimisation, some structure fields are unused as well as (probably) some code. This is not a replacement for existing MUSB driver (at least for now), cause there are still consumers of USB serial gadget which uses old API and there is no support for serial with new API for now. OTG and DMA are not supported. Ported drivers include: musb_dsps (should work both with TI AM33xx and TI81xx, tested only on AM33xx), am35x (tested on AM3517 EVM) and omap2plus (should work on OMAP2/3/4, tested on omap3_beagle, omap4_panda doesn't work and needs more work). Others should be easy to port too. Virtual root hub is not implemented but this shouldn't be a big problem as the old code has virtual root hub support enabled only for Blackfin platform. Pathes are rather big because of the original code size (and I didn't delete unused code, just disabled it). So it's probably better to look at changes as compared to Linux code. I prepared such version also, you can find it at [1]. Hopefully it will be also useful if resync with the kernel will be needed in future. [1] https://github.com/yanok/u-boot/tree/musb-changes-from-linux-v4 Changes in v5: - rebase, compile fix (use usb_config_descriptor) - linux-compat: remove __releases and __aquires - rebase onto master (board_eth_init moved to board/) - rebase onto master (board_eth_init moved to board/) - don't init usb ether in SPL Changes in v4: - fix indent - minor style fixes Changes in v3: - fix old MUSB code compilation - bugfix: struct musb should be zeroed after alloc - fix musb gadget_chips entry - fix for new multi-interface usb API - use clrsetbits_le32 for USB PHY ops Changes in v2: - add missing linux-compat.h header - added host support - glue code moved from musb_gadget_uboot.c to musb_uboot.c and cleaned up slightly. - added check for malloc return value - define is_{host,peripheral}_capable conditionally to support compilation with only host or gadget enabled - added some more is_{host,peripheral}_capable guards to core code to support compilation with only host or gadget enabled - rename backend config option to CONFIG_USB_MUSB_DSPS - we are providing host support now so add yourself to usb.h Ilya Yanok (13): linux/usb/ch9.h: update with the version from Linux tree usb: use linux/usb/ch9.h instead of usbdescriptors.h musb-new: port of Linux musb driver musb-new: dsps backend driver am33xx: init OTG hardware and new musb gadget driver am335x_evm: enable both musb gadget and host musb-new: am35x backend driver OMAP3: am35x_def.h: add USB defines OMAP3: am35x: add musb functions am3517_evm: switch to musb-new musb-new: omap2plus backend driver omap3_beagle: add musb-new init omap3_beagle: use new MUSB intstead of the old one Makefile |1 + arch/arm/cpu/armv7/am33xx/board.c | 85 + arch/arm/cpu/armv7/am33xx/clock.c |8 + arch/arm/cpu/armv7/omap3/Makefile |1 + arch/arm/cpu/armv7/omap3/am35x_musb.c | 75 + arch/arm/include/asm/arch-am33xx/cpu.h| 11 +- arch/arm/include/asm/arch-am33xx/hardware.h |4 + arch/arm/include/asm/arch-omap3/am35x_def.h | 27 + arch/arm/include/asm/arch-omap3/musb.h| 28 + arch/arm/include/asm/omap_musb.h | 32 + arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c |2 +- arch/powerpc/cpu/mpc5xxx/usb_ohci.c |2 +- arch/powerpc/cpu/ppc4xx/usb_ohci.c|2 +- board/logicpd/am3517evm/am3517evm.c | 74 + board/ti/am335x/board.c | 23 +- board/ti/beagle/beagle.c | 43 + common/cmd_usb.c |2 +- common/usb.c |4 +- drivers/usb/gadget/config.c |1 - drivers/usb/gadget/epautoconf.c |1 - drivers/usb/gadget/ether.c|1 - drivers/usb/gadget/gadget_chips.h |4 +- drivers/usb/gadget/s3c_udc_otg.c |1 - drivers/usb/gadget/usbstring.c|1 - drivers/usb/host/ehci-hcd.c | 16 +- drivers/usb/host/isp116x-hcd.c|2 +- drivers/usb/host/ohci-hcd.c |2 +- drivers/usb/host/ohci-s3c24xx.c |2 +- drivers
[U-Boot] [PATCH v5 02/13] usb: use linux/usb/ch9.h instead of usbdescriptors.h
Linux usb/ch9.h seems to have all the same information (and more) as usbdescriptors.h so use the former instead of the later one. As a consequense of this change USB_SPEED_* values don't correspond directly to EHCI speed encoding anymore, I've added necessary recoding in EHCI driver. Also there is no point to put speed into pipe anymore so it's removed and a bunch of host drivers fixed to look at usb_device-speed instead. Old usbdescriptors.h included is not removed as it seems to be used by old USB device code. This makes usb.h and usbdevice.h incompatible. Fortunately the only place that tries to include both are the old MUSB code and it needs usb.h only for USB_DMA_MINALIGN used in aligned attribute on musb_regs structure but this attribute seems to be unneeded (old MUSB code doesn't support any DMA at all). Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- Changes in v5: - rebase, compile fix (use usb_config_descriptor) Changes in v4: - fix indent Changes in v3: - fix old MUSB code compilation arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c |2 +- arch/powerpc/cpu/mpc5xxx/usb_ohci.c |2 +- arch/powerpc/cpu/ppc4xx/usb_ohci.c|2 +- common/cmd_usb.c |2 +- common/usb.c |4 ++-- drivers/usb/host/ehci-hcd.c | 16 ++-- drivers/usb/host/isp116x-hcd.c|2 +- drivers/usb/host/ohci-hcd.c |2 +- drivers/usb/host/ohci-s3c24xx.c |2 +- drivers/usb/host/sl811-hcd.c |2 +- drivers/usb/musb/musb_core.h |3 +-- drivers/usb/musb/musb_hcd.c |5 +++-- include/usb.h | 15 +++ include/usb_defs.h|6 -- 14 files changed, 31 insertions(+), 34 deletions(-) diff --git a/arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c b/arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c index c747767..b9b0998 100644 --- a/arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c +++ b/arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c @@ -615,7 +615,7 @@ static ed_t * ep_add_ed (struct usb_device *usb_dev, unsigned long pipe) | usb_pipeendpoint (pipe) 7 | (usb_pipeisoc (pipe)? 0x8000: 0) | (usb_pipecontrol (pipe)? 0: (usb_pipeout (pipe)? 0x800: 0x1000)) - | usb_pipeslow (pipe) 13 + | (usb_dev-speed == USB_SPEED_LOW) 13 | usb_maxpacket (usb_dev, pipe) 16); return ed_ret; diff --git a/arch/powerpc/cpu/mpc5xxx/usb_ohci.c b/arch/powerpc/cpu/mpc5xxx/usb_ohci.c index 607034b..de07343 100644 --- a/arch/powerpc/cpu/mpc5xxx/usb_ohci.c +++ b/arch/powerpc/cpu/mpc5xxx/usb_ohci.c @@ -618,7 +618,7 @@ static ed_t * ep_add_ed (struct usb_device *usb_dev, unsigned long pipe) | usb_pipeendpoint (pipe) 7 | (usb_pipeisoc (pipe)? 0x8000: 0) | (usb_pipecontrol (pipe)? 0: (usb_pipeout (pipe)? 0x800: 0x1000)) - | usb_pipeslow (pipe) 13 + | (usb_dev-speed == USB_SPEED_LOW) 13 | usb_maxpacket (usb_dev, pipe) 16); return ed_ret; diff --git a/arch/powerpc/cpu/ppc4xx/usb_ohci.c b/arch/powerpc/cpu/ppc4xx/usb_ohci.c index 4ce2726..f820c37 100644 --- a/arch/powerpc/cpu/ppc4xx/usb_ohci.c +++ b/arch/powerpc/cpu/ppc4xx/usb_ohci.c @@ -621,7 +621,7 @@ static ed_t * ep_add_ed (struct usb_device *usb_dev, unsigned long pipe) | usb_pipeendpoint (pipe) 7 | (usb_pipeisoc (pipe)? 0x8000: 0) | (usb_pipecontrol (pipe)? 0: (usb_pipeout (pipe)? 0x800: 0x1000)) - | usb_pipeslow (pipe) 13 + | (usb_dev-speed == USB_SPEED_LOW) 13 | usb_maxpacket (usb_dev, pipe) 16); return ed_ret; diff --git a/common/cmd_usb.c b/common/cmd_usb.c index 8ad0b23..dacdc2d 100644 --- a/common/cmd_usb.c +++ b/common/cmd_usb.c @@ -192,7 +192,7 @@ static void usb_display_desc(struct usb_device *dev) } -static void usb_display_conf_desc(struct usb_configuration_descriptor *config, +static void usb_display_conf_desc(struct usb_config_descriptor *config, struct usb_device *dev) { printf( Configuration: %d\n, config-bConfigurationValue); diff --git a/common/usb.c b/common/usb.c index 50b8175..ac9b4ca 100644 --- a/common/usb.c +++ b/common/usb.c @@ -492,9 +492,9 @@ int usb_get_configuration_no(struct usb_device *dev, { int result; unsigned int tmp; - struct usb_configuration_descriptor *config; + struct usb_config_descriptor *config; - config = (struct usb_configuration_descriptor *)buffer[0]; + config = (struct usb_config_descriptor
[U-Boot] [PATCH v5 01/13] linux/usb/ch9.h: update with the version from Linux tree
Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- drivers/usb/gadget/config.c |1 - drivers/usb/gadget/epautoconf.c |1 - drivers/usb/gadget/ether.c |1 - drivers/usb/gadget/s3c_udc_otg.c |1 - drivers/usb/gadget/usbstring.c |1 - include/linux/usb/ch9.h | 514 -- include/usb/s3c_udc.h|1 - 7 files changed, 499 insertions(+), 21 deletions(-) diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c index f88d0c1..f9163a8 100644 --- a/drivers/usb/gadget/config.c +++ b/drivers/usb/gadget/config.c @@ -27,7 +27,6 @@ #include linux/string.h #include linux/usb/ch9.h -#include usbdescriptors.h #include linux/usb/gadget.h diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index b656c8b..5b8776e 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -23,7 +23,6 @@ #include common.h #include linux/usb/ch9.h -#include usbdescriptors.h #include asm/errno.h #include linux/usb/gadget.h #include asm/unaligned.h diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 8b24e00..de880ff 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -24,7 +24,6 @@ #include asm/errno.h #include linux/netdevice.h #include linux/usb/ch9.h -#include usbdescriptors.h #include linux/usb/cdc.h #include linux/usb/gadget.h #include net.h diff --git a/drivers/usb/gadget/s3c_udc_otg.c b/drivers/usb/gadget/s3c_udc_otg.c index 3fdfdf7..f9d24e3 100644 --- a/drivers/usb/gadget/s3c_udc_otg.c +++ b/drivers/usb/gadget/s3c_udc_otg.c @@ -37,7 +37,6 @@ #include malloc.h #include linux/usb/ch9.h -#include usbdescriptors.h #include linux/usb/gadget.h #include asm/byteorder.h diff --git a/drivers/usb/gadget/usbstring.c b/drivers/usb/gadget/usbstring.c index 4dbe060..9cf 100644 --- a/drivers/usb/gadget/usbstring.c +++ b/drivers/usb/gadget/usbstring.c @@ -13,7 +13,6 @@ #include common.h #include asm/errno.h #include linux/usb/ch9.h -#include usbdescriptors.h #include linux/usb/gadget.h #include asm/unaligned.h diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h index ce1d1e1..d1d732c 100644 --- a/include/linux/usb/ch9.h +++ b/include/linux/usb/ch9.h @@ -28,15 +28,13 @@ * [c] for consistency, removing all doubt even when it appears to * someone that the two other points are non-issues for that * particular descriptor type. - * - * Ported to U-boot by: Thomas Smits ts.sm...@gmail.com and - * Remy Bohmer li...@bohmer.net */ #ifndef __LINUX_USB_CH9_H #define __LINUX_USB_CH9_H #include linux/types.h /* __u8 etc */ +#include asm/byteorder.h /* le16_to_cpu */ /*-*/ @@ -70,7 +68,7 @@ #define USB_RECIP_OTHER0x03 /* From Wireless USB 1.0 */ #define USB_RECIP_PORT 0x04 -#define USB_RECIP_RPIPE0x05 +#define USB_RECIP_RPIPE0x05 /* * Standard requests, for the bRequest field of a SETUP packet. @@ -90,6 +88,8 @@ #define USB_REQ_GET_INTERFACE 0x0A #define USB_REQ_SET_INTERFACE 0x0B #define USB_REQ_SYNCH_FRAME0x0C +#define USB_REQ_SET_SEL0x30 +#define USB_REQ_SET_ISOCH_DELAY0x31 #define USB_REQ_SET_ENCRYPTION 0x0D/* Wireless USB */ #define USB_REQ_GET_ENCRYPTION 0x0E @@ -105,10 +105,16 @@ #define USB_REQ_LOOPBACK_DATA_READ 0x16 #define USB_REQ_SET_INTERFACE_DS 0x17 +/* The Link Power Management (LPM) ECN defines USB_REQ_TEST_AND_SET command, + * used by hubs to put ports into a new L1 suspend state, except that it + * forgot to define its number ... + */ + /* * USB feature flags are written using USB_REQ_{CLEAR,SET}_FEATURE, and * are read as a bit array returned by USB_REQ_GET_STATUS. (So there - * are at most sixteen features of each type.) + * are at most sixteen features of each type.) Hubs may also support a + * new USB_REQ_TEST_AND_SET_FEATURE to put ports into L1 suspend. */ #define USB_DEVICE_SELF_POWERED0 /* (read only) */ #define USB_DEVICE_REMOTE_WAKEUP 1 /* dev may initiate wakeup */ @@ -120,8 +126,38 @@ #define USB_DEVICE_A_ALT_HNP_SUPPORT 5 /* (otg) other RH port does */ #define USB_DEVICE_DEBUG_MODE 6 /* (special devices only) */ +/* + * Test Mode Selectors + * See USB 2.0 spec Table 9-7 + */ +#defineTEST_J 1 +#defineTEST_K 2 +#defineTEST_SE0_NAK3 +#defineTEST_PACKET 4 +#defineTEST_FORCE_EN 5 + +/* + * New Feature Selectors as added by USB 3.0 + * See USB 3.0 spec Table 9-6 + */ +#define USB_DEVICE_U1_ENABLE 48 /* dev may initiate U1 transition */ +#define USB_DEVICE_U2_ENABLE 49 /* dev may initiate U2 transition
[U-Boot] [PATCH v5 04/13] musb-new: dsps backend driver
Backend driver for MUSB OTG controllers found on TI AM33xx and TI81xx SoCs (tested with AM33xx only). Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- Changes in v2: - rename backend config option to CONFIG_USB_MUSB_DSPS - we are providing host support now so add yourself to usb.h arch/arm/include/asm/omap_musb.h | 25 ++ drivers/usb/musb-new/Makefile|1 + drivers/usb/musb-new/musb_dsps.c | 771 ++ include/usb.h|3 +- 4 files changed, 799 insertions(+), 1 deletion(-) create mode 100644 arch/arm/include/asm/omap_musb.h create mode 100644 drivers/usb/musb-new/musb_dsps.c diff --git a/arch/arm/include/asm/omap_musb.h b/arch/arm/include/asm/omap_musb.h new file mode 100644 index 000..0081a68 --- /dev/null +++ b/arch/arm/include/asm/omap_musb.h @@ -0,0 +1,25 @@ +/* + * Board data structure for musb gadget on OMAPs + * + * Copyright (C) 2012, Ilya Yanok ilya.ya...@gmail.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. + */ + +#ifndef __ASM_ARM_OMAP_MUSB_H +#define __ASM_ARM_OMAP_MUSB_H + +extern struct musb_platform_ops musb_dsps_ops; + +struct omap_musb_board_data { + void (*set_phy_power)(u8 on); +}; +#endif /* __ASM_ARM_OMAP_MUSB_H */ diff --git a/drivers/usb/musb-new/Makefile b/drivers/usb/musb-new/Makefile index f01fb16..a753423 100644 --- a/drivers/usb/musb-new/Makefile +++ b/drivers/usb/musb-new/Makefile @@ -9,6 +9,7 @@ LIB := $(obj)libusb_musb-new.o COBJS-$(CONFIG_MUSB_GADGET) += musb_gadget.o musb_gadget_ep0.o musb_core.o COBJS-$(CONFIG_MUSB_GADGET) += musb_uboot.o COBJS-$(CONFIG_MUSB_HOST) += musb_host.o musb_core.o musb_uboot.o +COBJS-$(CONFIG_USB_MUSB_DSPS) += musb_dsps.o CFLAGS_NO_WARN := $(call cc-option,-Wno-unused-variable) \ $(call cc-option,-Wno-unused-but-set-variable) \ diff --git a/drivers/usb/musb-new/musb_dsps.c b/drivers/usb/musb-new/musb_dsps.c new file mode 100644 index 000..9a03917 --- /dev/null +++ b/drivers/usb/musb-new/musb_dsps.c @@ -0,0 +1,771 @@ +/* + * Texas Instruments DSPS platforms glue layer + * + * Copyright (C) 2012, by Texas Instruments + * + * Based on the am35x glue layer code. + * + * This file is part of the Inventra Controller Driver for Linux. + * + * The Inventra Controller Driver for Linux is free software; you + * can redistribute it and/or modify it under the terms of the GNU + * General Public License version 2 as published by the Free Software + * Foundation. + * + * The Inventra Controller Driver for Linux 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 The Inventra Controller Driver for Linux ; if not, + * write to the Free Software Foundation, Inc., 59 Temple Place, + * Suite 330, Boston, MA 02111-1307 USA + * + * musb_dsps.c will be a common file for all the TI DSPS platforms + * such as dm64x, dm36x, dm35x, da8x, am35x and ti81x. + * For now only ti81x is using this and in future davinci.c, am35x.c + * da8xx.c would be merged to this file after testing. + */ + +#define __UBOOT__ +#ifndef __UBOOT__ +#include linux/init.h +#include linux/io.h +#include linux/err.h +#include linux/platform_device.h +#include linux/dma-mapping.h +#include linux/pm_runtime.h +#include linux/module.h + +#include linux/of.h +#include linux/of_device.h +#include linux/of_address.h + +#include plat/usb.h +#else +#include common.h +#include asm/omap_musb.h +#include linux-compat.h +#endif + +#include musb_core.h + +/** + * avoid using musb_readx()/musb_writex() as glue layer should not be + * dependent on musb core layer symbols. + */ +static inline u8 dsps_readb(const void __iomem *addr, unsigned offset) + { return __raw_readb(addr + offset); } + +static inline u32 dsps_readl(const void __iomem *addr, unsigned offset) + { return __raw_readl(addr + offset); } + +static inline void dsps_writeb(void __iomem *addr, unsigned offset, u8 data) + { __raw_writeb(data, addr + offset); } + +static inline void dsps_writel(void __iomem *addr, unsigned offset, u32 data) + { __raw_writel(data, addr + offset); } + +/** + * DSPS musb wrapper register offset. + * FIXME: This should be expanded to have all the wrapper registers from TI DSPS + * musb ips. + */ +struct dsps_musb_wrapper { + u16
[U-Boot] [PATCH v5 05/13] am33xx: init OTG hardware and new musb gadget driver
AM33xx has support for dual port MUSB OTG controller. This patch adds initialization for the controller using new MUSB gadget driver and ether gadget. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- Changes in v5: - rebase onto master (board_eth_init moved to board/) Changes in v3: - use clrsetbits_le32 for USB PHY ops arch/arm/cpu/armv7/am33xx/board.c | 85 +++ arch/arm/cpu/armv7/am33xx/clock.c |8 +++ arch/arm/include/asm/arch-am33xx/cpu.h | 11 +++- arch/arm/include/asm/arch-am33xx/hardware.h |4 ++ 4 files changed, 105 insertions(+), 3 deletions(-) diff --git a/arch/arm/cpu/armv7/am33xx/board.c b/arch/arm/cpu/armv7/am33xx/board.c index e4c123c..da5bc73 100644 --- a/arch/arm/cpu/armv7/am33xx/board.c +++ b/arch/arm/cpu/armv7/am33xx/board.c @@ -33,6 +33,11 @@ #include i2c.h #include miiphy.h #include cpsw.h +#include asm/errno.h +#include linux/usb/ch9.h +#include linux/usb/gadget.h +#include linux/usb/musb.h +#include asm/omap_musb.h DECLARE_GLOBAL_DATA_PTR; @@ -63,3 +68,83 @@ void setup_clocks_for_console(void) /* Not yet implemented */ return; } + +/* AM33XX has two MUSB controllers which can be host or gadget */ +#if (defined(CONFIG_MUSB_GADGET) || defined(CONFIG_MUSB_HOST)) \ + (defined(CONFIG_AM335X_USB0) || defined(CONFIG_AM335X_USB1)) +static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE; + +/* USB 2.0 PHY Control */ +#define CM_PHY_PWRDN (1 0) +#define CM_PHY_OTG_PWRDN (1 1) +#define OTGVDET_EN (1 19) +#define OTGSESSENDEN (1 20) + +static void am33xx_usb_set_phy_power(u8 on, u32 *reg_addr) +{ + if (on) { + clrsetbits_le32(reg_addr, CM_PHY_PWRDN | CM_PHY_OTG_PWRDN, + OTGVDET_EN | OTGSESSENDEN); + } else { + clrsetbits_le32(reg_addr, 0, CM_PHY_PWRDN | CM_PHY_OTG_PWRDN); + } +} + +static struct musb_hdrc_config musb_config = { + .multipoint = 1, + .dyn_fifo = 1, + .num_eps= 16, + .ram_bits = 12, +}; + +#ifdef CONFIG_AM335X_USB0 +static void am33xx_otg0_set_phy_power(u8 on) +{ + am33xx_usb_set_phy_power(on, cdev-usb_ctrl0); +} + +struct omap_musb_board_data otg0_board_data = { + .set_phy_power = am33xx_otg0_set_phy_power, +}; + +static struct musb_hdrc_platform_data otg0_plat = { + .mode = CONFIG_AM335X_USB0_MODE, + .config = musb_config, + .power = 50, + .platform_ops = musb_dsps_ops, + .board_data = otg0_board_data, +}; +#endif + +#ifdef CONFIG_AM335X_USB1 +static void am33xx_otg1_set_phy_power(u8 on) +{ + am33xx_usb_set_phy_power(on, cdev-usb_ctrl1); +} + +struct omap_musb_board_data otg1_board_data = { + .set_phy_power = am33xx_otg1_set_phy_power, +}; + +static struct musb_hdrc_platform_data otg1_plat = { + .mode = CONFIG_AM335X_USB1_MODE, + .config = musb_config, + .power = 50, + .platform_ops = musb_dsps_ops, + .board_data = otg1_board_data, +}; +#endif +#endif + +int arch_misc_init(void) +{ +#ifdef CONFIG_AM335X_USB0 + musb_register(otg0_plat, otg0_board_data, + (void *)AM335X_USB0_OTG_BASE); +#endif +#ifdef CONFIG_AM335X_USB1 + musb_register(otg1_plat, otg1_board_data, + (void *)AM335X_USB1_OTG_BASE); +#endif + return 0; +} diff --git a/arch/arm/cpu/armv7/am33xx/clock.c b/arch/arm/cpu/armv7/am33xx/clock.c index bc2abb6..0b4cb4e 100644 --- a/arch/arm/cpu/armv7/am33xx/clock.c +++ b/arch/arm/cpu/armv7/am33xx/clock.c @@ -40,6 +40,7 @@ #define CLK_MODE_MASK 0xfff8 #define CLK_DIV_SEL0xFFE0 #define CPGMAC0_IDLE 0x3 +#define DPLL_CLKDCOLDO_GATE_CTRL0x300 const struct cm_perpll *cmper = (struct cm_perpll *)CM_PER; const struct cm_wkuppll *cmwkup = (struct cm_wkuppll *)CM_WKUP; @@ -194,6 +195,11 @@ static void enable_per_clocks(void) writel(PRCM_MOD_EN, cmrtc-rtcclkctrl); while (readl(cmrtc-rtcclkctrl) != PRCM_MOD_EN) ; + + /* MUSB */ + writel(PRCM_MOD_EN, cmper-usb0clkctrl); + while (readl(cmper-usb0clkctrl) != PRCM_MOD_EN) + ; } static void mpu_pll_config(void) @@ -290,6 +296,8 @@ static void per_pll_config(void) while (readl(cmwkup-idlestdpllper) != ST_DPLL_CLK) ; + + writel(DPLL_CLKDCOLDO_GATE_CTRL, cmwkup-clkdcoldodpllper); } void ddr_pll_config(unsigned int ddrpll_m) diff --git a/arch/arm/include/asm/arch-am33xx/cpu.h b/arch/arm/include/asm/arch-am33xx/cpu.h index 819fd2f..d6c038e 100644 --- a/arch/arm/include/asm/arch-am33xx/cpu.h +++ b/arch/arm/include/asm/arch-am33xx/cpu.h @@ -82,7 +82,8 @@ struct cm_wkuppll { unsigned int clkseldpllcore;/* offset 0x68 */ unsigned int resv9[1]; unsigned int
[U-Boot] [PATCH v5 07/13] musb-new: am35x backend driver
Backend driver for MUSB OTG controllers found on TI AM35x. It seems that on AM35X interrupt status registers can be updated _before_ core registers. As we don't use true interrupts in U-Boot and poll interrupt status registers instead this can result in interrupt handler being called with non-updated core registers. This confuses the code and result in hanged transfers. Add a small delay in am35x_interrupt as a workaround. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- arch/arm/include/asm/omap_musb.h|3 + drivers/usb/musb-new/Makefile |1 + drivers/usb/musb-new/am35x.c| 709 +++ drivers/usb/musb-new/linux-compat.h |1 + include/usb.h |2 +- 5 files changed, 715 insertions(+), 1 deletion(-) create mode 100644 drivers/usb/musb-new/am35x.c diff --git a/arch/arm/include/asm/omap_musb.h b/arch/arm/include/asm/omap_musb.h index 0081a68..46c8578 100644 --- a/arch/arm/include/asm/omap_musb.h +++ b/arch/arm/include/asm/omap_musb.h @@ -18,8 +18,11 @@ #define __ASM_ARM_OMAP_MUSB_H extern struct musb_platform_ops musb_dsps_ops; +extern const struct musb_platform_ops am35x_ops; struct omap_musb_board_data { void (*set_phy_power)(u8 on); + void (*clear_irq)(void); + void (*reset)(void); }; #endif /* __ASM_ARM_OMAP_MUSB_H */ diff --git a/drivers/usb/musb-new/Makefile b/drivers/usb/musb-new/Makefile index a753423..23fc735 100644 --- a/drivers/usb/musb-new/Makefile +++ b/drivers/usb/musb-new/Makefile @@ -10,6 +10,7 @@ COBJS-$(CONFIG_MUSB_GADGET) += musb_gadget.o musb_gadget_ep0.o musb_core.o COBJS-$(CONFIG_MUSB_GADGET) += musb_uboot.o COBJS-$(CONFIG_MUSB_HOST) += musb_host.o musb_core.o musb_uboot.o COBJS-$(CONFIG_USB_MUSB_DSPS) += musb_dsps.o +COBJS-$(CONFIG_USB_MUSB_AM35X) += am35x.o CFLAGS_NO_WARN := $(call cc-option,-Wno-unused-variable) \ $(call cc-option,-Wno-unused-but-set-variable) \ diff --git a/drivers/usb/musb-new/am35x.c b/drivers/usb/musb-new/am35x.c new file mode 100644 index 000..57c9bd3 --- /dev/null +++ b/drivers/usb/musb-new/am35x.c @@ -0,0 +1,709 @@ +/* + * Texas Instruments AM35x glue layer + * + * Copyright (c) 2010, by Texas Instruments + * + * Based on the DA8xx glue layer code. + * Copyright (c) 2008-2009, MontaVista Software, Inc. sou...@mvista.com + * + * This file is part of the Inventra Controller Driver for Linux. + * + * The Inventra Controller Driver for Linux is free software; you + * can redistribute it and/or modify it under the terms of the GNU + * General Public License version 2 as published by the Free Software + * Foundation. + * + * The Inventra Controller Driver for Linux 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 The Inventra Controller Driver for Linux ; if not, + * write to the Free Software Foundation, Inc., 59 Temple Place, + * Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define __UBOOT__ +#ifndef __UBOOT__ +#include linux/init.h +#include linux/module.h +#include linux/clk.h +#include linux/err.h +#include linux/io.h +#include linux/platform_device.h +#include linux/dma-mapping.h + +#include plat/usb.h +#else +#include common.h +#include asm/omap_musb.h +#include linux-compat.h +#endif + +#include musb_core.h + +/* + * AM35x specific definitions + */ +/* USB 2.0 OTG module registers */ +#define USB_REVISION_REG 0x00 +#define USB_CTRL_REG 0x04 +#define USB_STAT_REG 0x08 +#define USB_EMULATION_REG 0x0c +/* 0x10 Reserved */ +#define USB_AUTOREQ_REG0x14 +#define USB_SRP_FIX_TIME_REG 0x18 +#define USB_TEARDOWN_REG 0x1c +#define EP_INTR_SRC_REG0x20 +#define EP_INTR_SRC_SET_REG0x24 +#define EP_INTR_SRC_CLEAR_REG 0x28 +#define EP_INTR_MASK_REG 0x2c +#define EP_INTR_MASK_SET_REG 0x30 +#define EP_INTR_MASK_CLEAR_REG 0x34 +#define EP_INTR_SRC_MASKED_REG 0x38 +#define CORE_INTR_SRC_REG 0x40 +#define CORE_INTR_SRC_SET_REG 0x44 +#define CORE_INTR_SRC_CLEAR_REG0x48 +#define CORE_INTR_MASK_REG 0x4c +#define CORE_INTR_MASK_SET_REG 0x50 +#define CORE_INTR_MASK_CLEAR_REG 0x54 +#define CORE_INTR_SRC_MASKED_REG 0x58 +/* 0x5c Reserved */ +#define USB_END_OF_INTR_REG0x60 + +/* Control register bits */ +#define AM35X_SOFT_RESET_MASK 1 + +/* USB interrupt register bits */ +#define AM35X_INTR_USB_SHIFT 16 +#define AM35X_INTR_USB_MASK(0x1ff AM35X_INTR_USB_SHIFT) +#define AM35X_INTR_DRVVBUS 0x100 +#define AM35X_INTR_RX_SHIFT16 +#define AM35X_INTR_TX_SHIFT0 +#define AM35X_TX_EP_MASK 0x /* EP0 + 15 Tx EPs */ +#define AM35X_RX_EP_MASK 0xfffe /* 15 Rx EPs */ +#define AM35X_TX_INTR_MASK
[U-Boot] [PATCH v5 06/13] am335x_evm: enable both musb gadget and host
Enable musb gadget in Ethernet mode on port 0 and musb host on port1. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- Changes in v5: - rebase onto master (board_eth_init moved to board/) - don't init usb ether in SPL board/ti/am335x/board.c | 23 +-- include/configs/am335x_evm.h | 27 +++ 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c index b56a801..f0eca54 100644 --- a/board/ti/am335x/board.c +++ b/board/ti/am335x/board.c @@ -379,9 +379,14 @@ static struct cpsw_platform_data cpsw_data = { .host_port_num = 0, .version= CPSW_CTRL_VERSION_2, }; +#endif +#if defined(CONFIG_DRIVER_TI_CPSW) || \ + (defined(CONFIG_USB_ETHER) defined(CONFIG_MUSB_GADGET)) int board_eth_init(bd_t *bis) { + int rv, n = 0; +#ifdef CONFIG_DRIVER_TI_CPSW uint8_t mac_addr[6]; uint32_t mac_hi, mac_lo; @@ -400,7 +405,7 @@ int board_eth_init(bd_t *bis) if (is_valid_ether_addr(mac_addr)) eth_setenv_enetaddr(ethaddr, mac_addr); else - return -1; + goto try_usbether; } if (board_is_bone() || board_is_bone_lt() || board_is_idk()) { @@ -413,6 +418,20 @@ int board_eth_init(bd_t *bis) PHY_INTERFACE_MODE_RGMII; } - return cpsw_register(cpsw_data); + rv = cpsw_register(cpsw_data); + if (rv 0) + printf(Error %d registering CPSW switch\n, rv); + else + n += rv; +#endif +try_usbether: +#if defined(CONFIG_USB_ETHER) !defined(CONFIG_SPL_BUILD) + rv = usb_eth_initialize(bis); + if (rv 0) + printf(Error %d registering USB_ETHER\n, rv); + else + n += rv; +#endif + return n; } #endif diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h index b6e48f8..ab9549b 100644 --- a/include/configs/am335x_evm.h +++ b/include/configs/am335x_evm.h @@ -257,6 +257,33 @@ #define CONFIG_SKIP_LOWLEVEL_INIT #endif +/* + * USB configuration + */ +#define CONFIG_USB_MUSB_DSPS +#define CONFIG_ARCH_MISC_INIT +#define CONFIG_MUSB_GADGET +#define CONFIG_MUSB_PIO_ONLY +#define CONFIG_USB_GADGET_DUALSPEED +#define CONFIG_MUSB_HOST +#define CONFIG_AM335X_USB0 +#define CONFIG_AM335X_USB0_MODEMUSB_PERIPHERAL +#define CONFIG_AM335X_USB1 +#define CONFIG_AM335X_USB1_MODE MUSB_HOST + +#ifdef CONFIG_MUSB_HOST +#define CONFIG_CMD_USB +#define CONFIG_USB_STORAGE +#endif + +#ifdef CONFIG_MUSB_GADGET +#define CONFIG_USB_ETHER +#define CONFIG_USB_ETH_RNDIS +#endif /* CONFIG_MUSB_GADGET */ + +/* Unsupported features */ +#undef CONFIG_USE_IRQ + #define CONFIG_CMD_NET #define CONFIG_CMD_DHCP #define CONFIG_CMD_PING -- 1.7.10.2 (Apple Git-33) ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v5 08/13] OMAP3: am35x_def.h: add USB defines
Add defines for MUSB IP block on AM35X SoCs. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- arch/arm/include/asm/arch-omap3/am35x_def.h | 27 +++ 1 file changed, 27 insertions(+) diff --git a/arch/arm/include/asm/arch-omap3/am35x_def.h b/arch/arm/include/asm/arch-omap3/am35x_def.h index bbaf1bc..67698bc 100644 --- a/arch/arm/include/asm/arch-omap3/am35x_def.h +++ b/arch/arm/include/asm/arch-omap3/am35x_def.h @@ -32,9 +32,34 @@ #ifndef __KERNEL_STRICT_NAMES #ifndef __ASSEMBLY__ +/* LVL_INTR_CLEAR bits */ +#define USBOTGSS_INT_CLR (1 4) + /* IP_SW_RESET bits */ +#define USBOTGSS_SW_RST(1 0)/* reset USBOTG */ #define CPGMACSS_SW_RST(1 1)/* reset CPGMAC */ +/* DEVCONF2 bits */ +#define CONF2_PHY_GPIOMODE (1 23) +#define CONF2_OTGMODE (3 14) +#define CONF2_NO_OVERRIDE (0 14) +#define CONF2_FORCE_HOST (1 14) +#define CONF2_FORCE_DEVICE (2 14) +#define CONF2_FORCE_HOST_VBUS_LOW (3 14) +#define CONF2_SESENDEN (1 13) +#define CONF2_VBDTCTEN (1 12) +#define CONF2_REFFREQ_24MHZ(2 8) +#define CONF2_REFFREQ_26MHZ(7 8) +#define CONF2_REFFREQ_13MHZ(6 8) +#define CONF2_REFFREQ (0xf 8) +#define CONF2_PHYCLKGD (1 7) +#define CONF2_VBUSSENSE(1 6) +#define CONF2_PHY_PLLON(1 5) +#define CONF2_RESET(1 4) +#define CONF2_PHYPWRDN (1 3) +#define CONF2_OTGPWRDN (1 2) +#define CONF2_DATPOL (1 1) + /* General register mappings of system control module */ #define AM35X_SCM_GEN_BASE 0x48002270 struct am35x_scm_general { @@ -49,6 +74,8 @@ struct am35x_scm_general { }; #define am35x_scm_general_regs ((struct am35x_scm_general *)AM35X_SCM_GEN_BASE) +#define AM35XX_IPSS_USBOTGSS_BASE 0x5C04 + #endif /*__ASSEMBLY__ */ #endif /* __KERNEL_STRICT_NAMES */ -- 1.7.10.2 (Apple Git-33) ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v5 10/13] am3517_evm: switch to musb-new
Use new musb framework instead of the old one on AM3517_EVM. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- board/logicpd/am3517evm/am3517evm.c | 74 +++ include/configs/am3517_evm.h| 37 -- 2 files changed, 90 insertions(+), 21 deletions(-) diff --git a/board/logicpd/am3517evm/am3517evm.c b/board/logicpd/am3517evm/am3517evm.c index d316f33..0b3721e 100644 --- a/board/logicpd/am3517evm/am3517evm.c +++ b/board/logicpd/am3517evm/am3517evm.c @@ -25,12 +25,20 @@ #include common.h #include asm/io.h +#include asm/omap_musb.h +#include asm/arch/am35x_def.h #include asm/arch/mem.h #include asm/arch/mux.h #include asm/arch/sys_proto.h #include asm/arch/mmc_host_def.h +#include asm/arch/musb.h #include asm/mach-types.h +#include asm/errno.h +#include linux/usb/ch9.h +#include linux/usb/gadget.h +#include linux/usb/musb.h #include i2c.h +#include netdev.h #include am3517evm.h DECLARE_GLOBAL_DATA_PTR; @@ -50,6 +58,52 @@ int board_init(void) return 0; } +#ifdef CONFIG_USB_MUSB_AM35X +static struct musb_hdrc_config musb_config = { + .multipoint = 1, + .dyn_fifo = 1, + .num_eps= 16, + .ram_bits = 12, +}; + +static struct omap_musb_board_data musb_board_data = { + .set_phy_power = am35x_musb_phy_power, + .clear_irq = am35x_musb_clear_irq, + .reset = am35x_musb_reset, +}; + +static struct musb_hdrc_platform_data musb_plat = { +#if defined(CONFIG_MUSB_HOST) + .mode = MUSB_HOST, +#elif defined(CONFIG_MUSB_GADGET) + .mode = MUSB_PERIPHERAL, +#else +#error Please define either CONFIG_MUSB_HOST or CONFIG_MUSB_GADGET +#endif + .config = musb_config, + .power = 250, + .platform_ops = am35x_ops, + .board_data = musb_board_data, +}; + +static void am3517_evm_musb_init(void) +{ + /* +* Set up USB clock/mode in the DEVCONF2 register. +* USB2.0 PHY reference clock is 13 MHz +*/ + clrsetbits_le32(am35x_scm_general_regs-devconf2, + CONF2_REFFREQ | CONF2_OTGMODE | CONF2_PHY_GPIOMODE, + CONF2_REFFREQ_13MHZ | CONF2_SESENDEN | + CONF2_VBDTCTEN | CONF2_DATPOL); + + musb_register(musb_plat, musb_board_data, + (void *)AM35XX_IPSS_USBOTGSS_BASE); +} +#else +#define am3517_evm_musb_init() do {} while (0) +#endif + /* * Routine: misc_init_r * Description: Init i2c, ethernet, etc... (done here so udelay works) @@ -62,6 +116,8 @@ int misc_init_r(void) dieid_num_r(); + am3517_evm_musb_init(); + return 0; } @@ -83,3 +139,21 @@ int board_mmc_init(bd_t *bis) return 0; } #endif + +#if defined(CONFIG_USB_ETHER) defined(CONFIG_MUSB_GADGET) +int board_eth_init(bd_t *bis) +{ + int rv, n = 0; + + rv = cpu_eth_init(bis); + if (rv 0) + n += rv; + + rv = usb_eth_initialize(bis); + if (rv 0) + n += rv; + + return n; +} +#endif + diff --git a/include/configs/am3517_evm.h b/include/configs/am3517_evm.h index ce71d13..9484e55 100644 --- a/include/configs/am3517_evm.h +++ b/include/configs/am3517_evm.h @@ -97,15 +97,16 @@ /* * USB configuration - * Enable CONFIG_MUSB_HCD for Host functionalities MSC, keyboard - * Enable CONFIG_MUSB_UDC for Device functionalities. + * Enable CONFIG_MUSB_HOST for Host functionalities MSC, keyboard + * Enable CONFIG_MUSB_GADGET for Device functionalities. */ -#define CONFIG_USB_AM35X 1 -#define CONFIG_MUSB_HCD1 +#define CONFIG_USB_MUSB_AM35X +#define CONFIG_MUSB_HOST +#define CONFIG_MUSB_PIO_ONLY -#ifdef CONFIG_USB_AM35X +#ifdef CONFIG_USB_MUSB_AM35X -#ifdef CONFIG_MUSB_HCD +#ifdef CONFIG_MUSB_HOST #define CONFIG_CMD_USB #define CONFIG_USB_STORAGE @@ -117,21 +118,15 @@ #define CONFIG_PREBOOT usb start #endif /* CONFIG_USB_KEYBOARD */ -#endif /* CONFIG_MUSB_HCD */ - -#ifdef CONFIG_MUSB_UDC -/* USB device configuration */ -#define CONFIG_USB_DEVICE 1 -#define CONFIG_USB_TTY 1 -#define CONFIG_SYS_CONSOLE_IS_IN_ENV 1 -/* Change these to suit your needs */ -#define CONFIG_USBD_VENDORID 0x0451 -#define CONFIG_USBD_PRODUCTID 0x5678 -#define CONFIG_USBD_MANUFACTURER Texas Instruments -#define CONFIG_USBD_PRODUCT_NAME AM3517EVM -#endif /* CONFIG_MUSB_UDC */ - -#endif /* CONFIG_USB_AM35X */ +#endif /* CONFIG_MUSB_HOST */ + +#ifdef CONFIG_MUSB_GADGET +#define CONFIG_USB_GADGET_DUALSPEED +#define CONFIG_USB_ETHER +#define CONFIG_USB_ETH_RNDIS +#endif /* CONFIG_MUSB_GADGET */ + +#endif /* CONFIG_USB_MUSB_AM35X */ /* commands to include */ #include config_cmd_default.h -- 1.7.10.2 (Apple Git-33) ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de
[U-Boot] [PATCH v5 11/13] musb-new: omap2plus backend driver
Backend driver for MUSB OTG controllers found on TI OMAP2/3/4 (tested only on OMAP3 Beagle). Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- arch/arm/include/asm/omap_musb.h|4 + drivers/usb/musb-new/Makefile |1 + drivers/usb/musb-new/linux-compat.h |9 + drivers/usb/musb-new/omap2430.c | 626 +++ drivers/usb/musb-new/omap2430.h | 56 include/usb.h |3 +- 6 files changed, 698 insertions(+), 1 deletion(-) create mode 100644 drivers/usb/musb-new/omap2430.c create mode 100644 drivers/usb/musb-new/omap2430.h diff --git a/arch/arm/include/asm/omap_musb.h b/arch/arm/include/asm/omap_musb.h index 46c8578..b04d865 100644 --- a/arch/arm/include/asm/omap_musb.h +++ b/arch/arm/include/asm/omap_musb.h @@ -19,10 +19,14 @@ extern struct musb_platform_ops musb_dsps_ops; extern const struct musb_platform_ops am35x_ops; +extern const struct musb_platform_ops omap2430_ops; struct omap_musb_board_data { + u8 interface_type; void (*set_phy_power)(u8 on); void (*clear_irq)(void); void (*reset)(void); }; + +enum musb_interface{MUSB_INTERFACE_ULPI, MUSB_INTERFACE_UTMI}; #endif /* __ASM_ARM_OMAP_MUSB_H */ diff --git a/drivers/usb/musb-new/Makefile b/drivers/usb/musb-new/Makefile index 23fc735..c23bef1 100644 --- a/drivers/usb/musb-new/Makefile +++ b/drivers/usb/musb-new/Makefile @@ -11,6 +11,7 @@ COBJS-$(CONFIG_MUSB_GADGET) += musb_uboot.o COBJS-$(CONFIG_MUSB_HOST) += musb_host.o musb_core.o musb_uboot.o COBJS-$(CONFIG_USB_MUSB_DSPS) += musb_dsps.o COBJS-$(CONFIG_USB_MUSB_AM35X) += am35x.o +COBJS-$(CONFIG_USB_MUSB_OMAP2PLUS) += omap2430.o CFLAGS_NO_WARN := $(call cc-option,-Wno-unused-variable) \ $(call cc-option,-Wno-unused-but-set-variable) \ diff --git a/drivers/usb/musb-new/linux-compat.h b/drivers/usb/musb-new/linux-compat.h index 6ecdb3e..5c126ef 100644 --- a/drivers/usb/musb-new/linux-compat.h +++ b/drivers/usb/musb-new/linux-compat.h @@ -34,6 +34,7 @@ typedef unsigned long dmaaddr_t; #define spin_unlock_irqrestore(lock, flags) do {} while (0) #define setup_timer(timer, func, data) do {} while (0) +#define del_timer_sync(timer) do {} while (0) #define schedule_work(work) do {} while (0) #define INIT_WORK(work, fun) do {} while (0) @@ -104,4 +105,12 @@ typedef unsigned long dmaaddr_t; #endif #define msleep(a) udelay(a * 1000) + +/* + * Map U-Boot config options to Linux ones + */ +#ifdef CONFIG_OMAP34XX +#define CONFIG_SOC_OMAP3430 +#endif + #endif /* __LINUX_COMPAT_H__ */ diff --git a/drivers/usb/musb-new/omap2430.c b/drivers/usb/musb-new/omap2430.c new file mode 100644 index 000..b1c4dc7 --- /dev/null +++ b/drivers/usb/musb-new/omap2430.c @@ -0,0 +1,626 @@ +/* + * Copyright (C) 2005-2007 by Texas Instruments + * Some code has been taken from tusb6010.c + * Copyrights for that are attributable to: + * Copyright (C) 2006 Nokia Corporation + * Tony Lindgren t...@atomide.com + * + * This file is part of the Inventra Controller Driver for Linux. + * + * The Inventra Controller Driver for Linux is free software; you + * can redistribute it and/or modify it under the terms of the GNU + * General Public License version 2 as published by the Free Software + * Foundation. + * + * The Inventra Controller Driver for Linux 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 The Inventra Controller Driver for Linux ; if not, + * write to the Free Software Foundation, Inc., 59 Temple Place, + * Suite 330, Boston, MA 02111-1307 USA + * + */ +#define __UBOOT__ +#ifndef __UBOOT__ +#include linux/module.h +#include linux/kernel.h +#include linux/sched.h +#include linux/init.h +#include linux/list.h +#include linux/io.h +#include linux/platform_device.h +#include linux/dma-mapping.h +#include linux/pm_runtime.h +#include linux/err.h +#include linux/usb/musb-omap.h +#else +#include common.h +#include asm/omap_musb.h +#include twl4030.h +#include linux-compat.h +#endif + +#include musb_core.h +#include omap2430.h + +#ifndef __UBOOT__ +struct omap2430_glue { + struct device *dev; + struct platform_device *musb; + enum omap_musb_vbus_id_status status; + struct work_struct omap_musb_mailbox_work; +}; +#define glue_to_musb(g)platform_get_drvdata(g-musb) + +struct omap2430_glue *_glue; + +static struct timer_list musb_idle_timer; + +static void musb_do_idle(unsigned long _musb) +{ + struct musb *musb = (void *)_musb; + unsigned long flags; + u8 power; + u8 devctl; + + spin_lock_irqsave(musb-lock, flags); + + switch (musb-xceiv-state) { + case
[U-Boot] [PATCH v5 12/13] omap3_beagle: add musb-new init
Add initialization for new MUSB framework. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- board/ti/beagle/beagle.c | 43 include/configs/omap3_beagle.h |2 ++ 2 files changed, 45 insertions(+) diff --git a/board/ti/beagle/beagle.c b/board/ti/beagle/beagle.c index 6175e1d..f20ebed 100644 --- a/board/ti/beagle/beagle.c +++ b/board/ti/beagle/beagle.c @@ -42,6 +42,11 @@ #include asm/arch/sys_proto.h #include asm/gpio.h #include asm/mach-types.h +#include asm/omap_musb.h +#include asm/errno.h +#include linux/usb/ch9.h +#include linux/usb/gadget.h +#include linux/usb/musb.h #include beagle.h #include command.h @@ -285,6 +290,33 @@ static void beagle_dvi_pup(void) } #endif +#ifdef CONFIG_USB_MUSB_OMAP2PLUS +static struct musb_hdrc_config musb_config = { + .multipoint = 1, + .dyn_fifo = 1, + .num_eps= 16, + .ram_bits = 12, +}; + +static struct omap_musb_board_data musb_board_data = { + .interface_type = MUSB_INTERFACE_ULPI, +}; + +static struct musb_hdrc_platform_data musb_plat = { +#if defined(CONFIG_MUSB_HOST) + .mode = MUSB_HOST, +#elif defined(CONFIG_MUSB_GADGET) + .mode = MUSB_PERIPHERAL, +#else +#error Please define either CONFIG_MUSB_HOST or CONFIG_MUSB_GADGET +#endif + .config = musb_config, + .power = 100, + .platform_ops = omap2430_ops, + .board_data = musb_board_data, +}; +#endif + /* * Routine: misc_init_r * Description: Configure board specific parts @@ -466,6 +498,10 @@ int misc_init_r(void) omap3_dss_enable(); #endif +#ifdef CONFIG_USB_MUSB_OMAP2PLUS + musb_register(musb_plat, musb_board_data, (void *)MUSB_BASE); +#endif + return 0; } @@ -513,3 +549,10 @@ int ehci_hcd_stop(int index) } #endif /* CONFIG_USB_EHCI */ + +#if defined(CONFIG_USB_ETHER) defined(CONFIG_MUSB_GADGET) +int board_eth_init(bd_t *bis) +{ + return usb_eth_initialize(bis); +} +#endif diff --git a/include/configs/omap3_beagle.h b/include/configs/omap3_beagle.h index 7a3cc16..b2d73f9 100644 --- a/include/configs/omap3_beagle.h +++ b/include/configs/omap3_beagle.h @@ -120,6 +120,8 @@ #define CONFIG_MUSB_UDC1 #define CONFIG_USB_OMAP3 1 #define CONFIG_TWL4030_USB 1 +#define CONFIG_USB_ETHER +#define CONFIG_USB_ETHER_RNDIS /* USB device configuration */ #define CONFIG_USB_DEVICE 1 -- 1.7.10.2 (Apple Git-33) ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v5 09/13] OMAP3: am35x: add musb functions
AM35XX specific functions for integrated USB PHY/MUSB IP. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- arch/arm/cpu/armv7/omap3/Makefile |1 + arch/arm/cpu/armv7/omap3/am35x_musb.c | 75 arch/arm/include/asm/arch-omap3/musb.h | 28 3 files changed, 104 insertions(+) create mode 100644 arch/arm/cpu/armv7/omap3/am35x_musb.c create mode 100644 arch/arm/include/asm/arch-omap3/musb.h diff --git a/arch/arm/cpu/armv7/omap3/Makefile b/arch/arm/cpu/armv7/omap3/Makefile index ac597be..de167ee 100644 --- a/arch/arm/cpu/armv7/omap3/Makefile +++ b/arch/arm/cpu/armv7/omap3/Makefile @@ -38,6 +38,7 @@ endif COBJS-$(CONFIG_DRIVER_TI_EMAC) += emac.o COBJS-$(CONFIG_EMIF4) += emif4.o COBJS-$(CONFIG_SDRC) += sdrc.o +COBJS-$(CONFIG_USB_MUSB_AM35X) += am35x_musb.o SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS) $(COBJS-y) $(SOBJS)) diff --git a/arch/arm/cpu/armv7/omap3/am35x_musb.c b/arch/arm/cpu/armv7/omap3/am35x_musb.c new file mode 100644 index 000..7183c4f --- /dev/null +++ b/arch/arm/cpu/armv7/omap3/am35x_musb.c @@ -0,0 +1,75 @@ +/* + * This file configures the internal USB PHY in AM35X. + * + * Copyright (C) 2012 Ilya Yanok ilya.ya...@gmail.com + * + * Based on omap_phy_internal.c code from Linux by + * Hema HK hem...@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. + * + */ + +#include common.h +#include asm/io.h +#include asm/arch/am35x_def.h + +void am35x_musb_reset(void) +{ + /* Reset the musb interface */ + clrsetbits_le32(am35x_scm_general_regs-ip_sw_reset, + 0, USBOTGSS_SW_RST); + clrsetbits_le32(am35x_scm_general_regs-ip_sw_reset, + USBOTGSS_SW_RST, 0); +} + +void am35x_musb_phy_power(u8 on) +{ + unsigned long start = get_timer(0); + + if (on) { + /* +* Start the on-chip PHY and its PLL. +*/ + clrsetbits_le32(am35x_scm_general_regs-devconf2, + CONF2_RESET | CONF2_PHYPWRDN | CONF2_OTGPWRDN, + CONF2_PHY_PLLON); + + debug(Waiting for PHY clock good...\n); + while (!(readl(am35x_scm_general_regs-devconf2) +CONF2_PHYCLKGD)) { + + if (get_timer(start) CONFIG_SYS_HZ / 10) { + printf(musb PHY clock good timed out\n); + break; + } + } + } else { + /* +* Power down the on-chip PHY. +*/ + clrsetbits_le32(am35x_scm_general_regs-devconf2, + CONF2_PHY_PLLON, + CONF2_PHYPWRDN | CONF2_OTGPWRDN); + } +} + +void am35x_musb_clear_irq(void) +{ + clrsetbits_le32(am35x_scm_general_regs-lvl_intr_clr, + 0, USBOTGSS_INT_CLR); + readl(am35x_scm_general_regs-lvl_intr_clr); +} + diff --git a/arch/arm/include/asm/arch-omap3/musb.h b/arch/arm/include/asm/arch-omap3/musb.h new file mode 100644 index 000..423ac50 --- /dev/null +++ b/arch/arm/include/asm/arch-omap3/musb.h @@ -0,0 +1,28 @@ +/* + * (C) Copyright 2012 + * Ilya Yanok, ilya.ya...@gmail.com + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc. + */ + +#ifndef __ASM_ARCH_OMAP3_MUSB_H +#define __ASM_ARCH_OMAP3_MUSB_H +extern void am35x_musb_reset(void); +extern void am35x_musb_phy_power(u8 on); +extern void am35x_musb_clear_irq(void); +#endif -- 1.7.10.2 (Apple Git-33) ___ U-Boot
[U-Boot] [PATCH v5 13/13] omap3_beagle: use new MUSB intstead of the old one
Enable using of new MUSB framework on Beagle. NOTE! This is not just a change of backend code: top-level behavior is also changed, we now use USB device port for USB Ethernet instead of serial. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- include/configs/omap3_beagle.h | 11 --- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/include/configs/omap3_beagle.h b/include/configs/omap3_beagle.h index b2d73f9..8b99967 100644 --- a/include/configs/omap3_beagle.h +++ b/include/configs/omap3_beagle.h @@ -117,17 +117,14 @@ #define CONFIG_SYS_I2C_NOPROBES{{0x0, 0x0}} /* USB */ -#define CONFIG_MUSB_UDC1 -#define CONFIG_USB_OMAP3 1 +#define CONFIG_MUSB_GADGET +#define CONFIG_USB_MUSB_OMAP2PLUS +#define CONFIG_MUSB_PIO_ONLY +#define CONFIG_USB_GADGET_DUALSPEED #define CONFIG_TWL4030_USB 1 #define CONFIG_USB_ETHER #define CONFIG_USB_ETHER_RNDIS -/* USB device configuration */ -#define CONFIG_USB_DEVICE 1 -#define CONFIG_USB_TTY 1 -#define CONFIG_SYS_CONSOLE_IS_IN_ENV 1 - /* USB EHCI */ #define CONFIG_CMD_USB #define CONFIG_USB_EHCI -- 1.7.10.2 (Apple Git-33) ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [RFC PATCH v3 0/13] Port of MUSB driver from Linux (changes from Linux)
Hi Tom, On Tue, Oct 23, 2012 at 1:45 AM, Tom Rini tr...@ti.com wrote: In general, things look OK but please run it through checkpatch.pl, use just one Signed-off-by line and fixup if (...) { ... one line ... } in the glue code you add that's not synced up from the kernel (I saw one in the am335x bits). Thanks! And lets move this out of RFC... Hm.. checkpatch produces tons of messages (mostly over 80 character lines) but I can't see anything about if ( ... ) { one-line } in the code I've added by hand... I've fixed some other minor style problems in the code that was not taken from the kernel directly. Regards, Ilya. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v4 0/13] Port of MUSB driver from Linux (changes from Linux)
Current MUSB driver in U-Boot uses old UDC API while new gagdet client drivers need new gadget API. Also current MUSB driver has some significant limitations (like inability to handle tx for endpoints other than ep0). So I think port of new Linux driver is desirable. This is initial port, performed mostly by putting DM and OTG code under #ifndef __UBOOT__ clauses. My intention was to be as close as possible to the original to ease of possible resyncs. Some warnings are suppressed via CFLAGS. There are some style problems but I'm not touching them for now for the above mentioned reason. There is obviously some room for optimisation, some structure fields are unused as well as (probably) some code. This is not a replacement for existing MUSB driver (at least for now), cause there are still consumers of USB serial gadget which uses old API and there is no support for serial with new API for now. OTG and DMA are not supported. Ported drivers include: musb_dsps (should work both with TI AM33xx and TI81xx, tested only on AM33xx), am35x (tested on AM3517 EVM) and omap2plus (should work on OMAP2/3/4, tested on omap3_beagle, omap4_panda doesn't work and needs more work). Others should be easy to port too. Virtual root hub is not implemented but this shouldn't be a big problem as the old code has virtual root hub support enabled only for Blackfin platform. Pathes are rather big because of the original code size (and I didn't delete unused code, just disabled it). So it's probably better to look at changes as compared to Linux code. I prepared such version also, you can find it at [1]. Hopefully it will be also useful if resync with the kernel will be needed in future. [1] https://github.com/yanok/u-boot/tree/musb-changes-from-linux-v4 Changes in v4: - fix indent - minor style fixes Changes in v3: - fix old MUSB code compilation - bugfix: struct musb should be zeroed after alloc - fix musb gadget_chips entry - fix for new multi-interface usb API - use clrsetbits_le32 for USB PHY ops Changes in v2: - add missing linux-compat.h header - added host support - glue code moved from musb_gadget_uboot.c to musb_uboot.c and cleaned up slightly. - added check for malloc return value - define is_{host,peripheral}_capable conditionally to support compilation with only host or gadget enabled - added some more is_{host,peripheral}_capable guards to core code to support compilation with only host or gadget enabled - rename backend config option to CONFIG_USB_MUSB_DSPS - we are providing host support now so add yourself to usb.h Ilya Yanok (13): linux/usb/ch9.h: update with the version from Linux tree usb: use linux/usb/ch9.h instead of usbdescriptors.h musb-new: port of Linux musb driver musb-new: dsps backend driver am33xx: init OTG hardware and new musb gadget driver am335x_evm: enable both musb gadget and host musb-new: am35x backend driver OMAP3: am35x_def.h: add USB defines OMAP3: am35x: add musb functions am3517_evm: switch to musb-new musb-new: omap2plus backend driver omap3_beagle: add musb-new init omap3_beagle: use new MUSB intstead of the old one Makefile |1 + arch/arm/cpu/arm920t/s3c24x0/usb_ohci.c |2 +- arch/arm/cpu/armv7/am33xx/board.c | 103 +- arch/arm/cpu/armv7/am33xx/clock.c |8 + arch/arm/cpu/armv7/omap3/Makefile |1 + arch/arm/cpu/armv7/omap3/am35x_musb.c | 75 + arch/arm/include/asm/arch-am33xx/cpu.h| 11 +- arch/arm/include/asm/arch-am33xx/hardware.h |4 + arch/arm/include/asm/arch-omap3/am35x_def.h | 27 + arch/arm/include/asm/arch-omap3/musb.h| 28 + arch/arm/include/asm/omap_musb.h | 32 + arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c |2 +- arch/powerpc/cpu/mpc5xxx/usb_ohci.c |2 +- arch/powerpc/cpu/ppc4xx/usb_ohci.c|2 +- board/logicpd/am3517evm/am3517evm.c | 74 + board/ti/beagle/beagle.c | 43 + common/cmd_usb.c |2 +- common/usb.c |4 +- drivers/usb/gadget/config.c |1 - drivers/usb/gadget/epautoconf.c |1 - drivers/usb/gadget/ether.c|1 - drivers/usb/gadget/gadget_chips.h |4 +- drivers/usb/gadget/s3c_udc_otg.c |1 - drivers/usb/gadget/usbstring.c|1 - drivers/usb/host/ehci-hcd.c | 16 +- drivers/usb/host/isp116x-hcd.c|2 +- drivers/usb/host/ohci-hcd.c |2 +- drivers/usb/host/sl811-hcd.c |2 +- drivers/usb/musb-new/Makefile | 39 + drivers/usb/musb-new/am35x.c | 709 +++ drivers/usb/musb-new/linux-compat.h | 119 ++ drivers/usb/musb-new/musb_core.c | 2497 + drivers/usb
[U-Boot] [PATCH v4 01/13] linux/usb/ch9.h: update with the version from Linux tree
Signed-off-by: Ilya Yanok ya...@cogentembedded.com Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- drivers/usb/gadget/config.c |1 - drivers/usb/gadget/epautoconf.c |1 - drivers/usb/gadget/ether.c |1 - drivers/usb/gadget/s3c_udc_otg.c |1 - drivers/usb/gadget/usbstring.c |1 - include/linux/usb/ch9.h | 514 -- include/usb/s3c_udc.h|1 - 7 files changed, 499 insertions(+), 21 deletions(-) diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c index f88d0c1..f9163a8 100644 --- a/drivers/usb/gadget/config.c +++ b/drivers/usb/gadget/config.c @@ -27,7 +27,6 @@ #include linux/string.h #include linux/usb/ch9.h -#include usbdescriptors.h #include linux/usb/gadget.h diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index b656c8b..5b8776e 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -23,7 +23,6 @@ #include common.h #include linux/usb/ch9.h -#include usbdescriptors.h #include asm/errno.h #include linux/usb/gadget.h #include asm/unaligned.h diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 1e187e5..c51e69c 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -24,7 +24,6 @@ #include asm/errno.h #include linux/netdevice.h #include linux/usb/ch9.h -#include usbdescriptors.h #include linux/usb/cdc.h #include linux/usb/gadget.h #include net.h diff --git a/drivers/usb/gadget/s3c_udc_otg.c b/drivers/usb/gadget/s3c_udc_otg.c index 3fdfdf7..f9d24e3 100644 --- a/drivers/usb/gadget/s3c_udc_otg.c +++ b/drivers/usb/gadget/s3c_udc_otg.c @@ -37,7 +37,6 @@ #include malloc.h #include linux/usb/ch9.h -#include usbdescriptors.h #include linux/usb/gadget.h #include asm/byteorder.h diff --git a/drivers/usb/gadget/usbstring.c b/drivers/usb/gadget/usbstring.c index 4dbe060..9cf 100644 --- a/drivers/usb/gadget/usbstring.c +++ b/drivers/usb/gadget/usbstring.c @@ -13,7 +13,6 @@ #include common.h #include asm/errno.h #include linux/usb/ch9.h -#include usbdescriptors.h #include linux/usb/gadget.h #include asm/unaligned.h diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h index ce1d1e1..d1d732c 100644 --- a/include/linux/usb/ch9.h +++ b/include/linux/usb/ch9.h @@ -28,15 +28,13 @@ * [c] for consistency, removing all doubt even when it appears to * someone that the two other points are non-issues for that * particular descriptor type. - * - * Ported to U-boot by: Thomas Smits ts.sm...@gmail.com and - * Remy Bohmer li...@bohmer.net */ #ifndef __LINUX_USB_CH9_H #define __LINUX_USB_CH9_H #include linux/types.h /* __u8 etc */ +#include asm/byteorder.h /* le16_to_cpu */ /*-*/ @@ -70,7 +68,7 @@ #define USB_RECIP_OTHER0x03 /* From Wireless USB 1.0 */ #define USB_RECIP_PORT 0x04 -#define USB_RECIP_RPIPE0x05 +#define USB_RECIP_RPIPE0x05 /* * Standard requests, for the bRequest field of a SETUP packet. @@ -90,6 +88,8 @@ #define USB_REQ_GET_INTERFACE 0x0A #define USB_REQ_SET_INTERFACE 0x0B #define USB_REQ_SYNCH_FRAME0x0C +#define USB_REQ_SET_SEL0x30 +#define USB_REQ_SET_ISOCH_DELAY0x31 #define USB_REQ_SET_ENCRYPTION 0x0D/* Wireless USB */ #define USB_REQ_GET_ENCRYPTION 0x0E @@ -105,10 +105,16 @@ #define USB_REQ_LOOPBACK_DATA_READ 0x16 #define USB_REQ_SET_INTERFACE_DS 0x17 +/* The Link Power Management (LPM) ECN defines USB_REQ_TEST_AND_SET command, + * used by hubs to put ports into a new L1 suspend state, except that it + * forgot to define its number ... + */ + /* * USB feature flags are written using USB_REQ_{CLEAR,SET}_FEATURE, and * are read as a bit array returned by USB_REQ_GET_STATUS. (So there - * are at most sixteen features of each type.) + * are at most sixteen features of each type.) Hubs may also support a + * new USB_REQ_TEST_AND_SET_FEATURE to put ports into L1 suspend. */ #define USB_DEVICE_SELF_POWERED0 /* (read only) */ #define USB_DEVICE_REMOTE_WAKEUP 1 /* dev may initiate wakeup */ @@ -120,8 +126,38 @@ #define USB_DEVICE_A_ALT_HNP_SUPPORT 5 /* (otg) other RH port does */ #define USB_DEVICE_DEBUG_MODE 6 /* (special devices only) */ +/* + * Test Mode Selectors + * See USB 2.0 spec Table 9-7 + */ +#defineTEST_J 1 +#defineTEST_K 2 +#defineTEST_SE0_NAK3 +#defineTEST_PACKET 4 +#defineTEST_FORCE_EN 5 + +/* + * New Feature Selectors as added by USB 3.0 + * See USB 3.0 spec Table 9-6 + */ +#define USB_DEVICE_U1_ENABLE 48 /* dev may initiate U1 transition */ +#define
[U-Boot] [PATCH v4 02/13] usb: use linux/usb/ch9.h instead of usbdescriptors.h
Linux usb/ch9.h seems to have all the same information (and more) as usbdescriptors.h so use the former instead of the later one. As a consequense of this change USB_SPEED_* values don't correspond directly to EHCI speed encoding anymore, I've added necessary recoding in EHCI driver. Also there is no point to put speed into pipe anymore so it's removed and a bunch of host drivers fixed to look at usb_device-speed instead. Old usbdescriptors.h included is not removed as it seems to be used by old USB device code. This makes usb.h and usbdevice.h incompatible. Fortunately the only place that tries to include both are the old MUSB code and it needs usb.h only for USB_DMA_MINALIGN used in aligned attribute on musb_regs structure but this attribute seems to be unneeded (old MUSB code doesn't support any DMA at all). Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- Changes in v4: - fix indent Changes in v3: - fix old MUSB code compilation arch/arm/cpu/arm920t/s3c24x0/usb_ohci.c |2 +- arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c |2 +- arch/powerpc/cpu/mpc5xxx/usb_ohci.c |2 +- arch/powerpc/cpu/ppc4xx/usb_ohci.c|2 +- common/cmd_usb.c |2 +- common/usb.c |4 ++-- drivers/usb/host/ehci-hcd.c | 16 ++-- drivers/usb/host/isp116x-hcd.c|2 +- drivers/usb/host/ohci-hcd.c |2 +- drivers/usb/host/sl811-hcd.c |2 +- drivers/usb/musb/musb_core.h |3 +-- drivers/usb/musb/musb_hcd.c |5 +++-- include/usb.h | 15 +++ include/usb_defs.h|6 -- 14 files changed, 31 insertions(+), 34 deletions(-) diff --git a/arch/arm/cpu/arm920t/s3c24x0/usb_ohci.c b/arch/arm/cpu/arm920t/s3c24x0/usb_ohci.c index 944bb32..3bca66a 100644 --- a/arch/arm/cpu/arm920t/s3c24x0/usb_ohci.c +++ b/arch/arm/cpu/arm920t/s3c24x0/usb_ohci.c @@ -620,7 +620,7 @@ static struct ed *ep_add_ed(struct usb_device *usb_dev, unsigned long pipe) | (usb_pipeisoc(pipe) ? 0x8000 : 0) | (usb_pipecontrol(pipe) ? 0 : (usb_pipeout(pipe) ? 0x800 : 0x1000)) - | usb_pipeslow(pipe) 13 | + | (usb_dev-speed == USB_SPEED_LOW) 13 | usb_maxpacket(usb_dev, pipe) 16); return ed_ret; diff --git a/arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c b/arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c index c747767..b9b0998 100644 --- a/arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c +++ b/arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c @@ -615,7 +615,7 @@ static ed_t * ep_add_ed (struct usb_device *usb_dev, unsigned long pipe) | usb_pipeendpoint (pipe) 7 | (usb_pipeisoc (pipe)? 0x8000: 0) | (usb_pipecontrol (pipe)? 0: (usb_pipeout (pipe)? 0x800: 0x1000)) - | usb_pipeslow (pipe) 13 + | (usb_dev-speed == USB_SPEED_LOW) 13 | usb_maxpacket (usb_dev, pipe) 16); return ed_ret; diff --git a/arch/powerpc/cpu/mpc5xxx/usb_ohci.c b/arch/powerpc/cpu/mpc5xxx/usb_ohci.c index 607034b..de07343 100644 --- a/arch/powerpc/cpu/mpc5xxx/usb_ohci.c +++ b/arch/powerpc/cpu/mpc5xxx/usb_ohci.c @@ -618,7 +618,7 @@ static ed_t * ep_add_ed (struct usb_device *usb_dev, unsigned long pipe) | usb_pipeendpoint (pipe) 7 | (usb_pipeisoc (pipe)? 0x8000: 0) | (usb_pipecontrol (pipe)? 0: (usb_pipeout (pipe)? 0x800: 0x1000)) - | usb_pipeslow (pipe) 13 + | (usb_dev-speed == USB_SPEED_LOW) 13 | usb_maxpacket (usb_dev, pipe) 16); return ed_ret; diff --git a/arch/powerpc/cpu/ppc4xx/usb_ohci.c b/arch/powerpc/cpu/ppc4xx/usb_ohci.c index 4ce2726..f820c37 100644 --- a/arch/powerpc/cpu/ppc4xx/usb_ohci.c +++ b/arch/powerpc/cpu/ppc4xx/usb_ohci.c @@ -621,7 +621,7 @@ static ed_t * ep_add_ed (struct usb_device *usb_dev, unsigned long pipe) | usb_pipeendpoint (pipe) 7 | (usb_pipeisoc (pipe)? 0x8000: 0) | (usb_pipecontrol (pipe)? 0: (usb_pipeout (pipe)? 0x800: 0x1000)) - | usb_pipeslow (pipe) 13 + | (usb_dev-speed == USB_SPEED_LOW) 13 | usb_maxpacket (usb_dev, pipe) 16); return ed_ret; diff --git a/common/cmd_usb.c b/common/cmd_usb.c index c128455..8be9952 100644 --- a/common/cmd_usb.c +++ b/common/cmd_usb.c @@ -192,7 +192,7 @@ void usb_display_desc(struct usb_device *dev) } -void usb_display_conf_desc(struct usb_configuration_descriptor *config
[U-Boot] [PATCH v4 04/13] musb-new: dsps backend driver
Backend driver for MUSB OTG controllers found on TI AM33xx and TI81xx SoCs (tested with AM33xx only). Signed-off-by: Ilya Yanok ya...@cogentembedded.com Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- Changes in v2: - rename backend config option to CONFIG_USB_MUSB_DSPS - we are providing host support now so add yourself to usb.h arch/arm/include/asm/omap_musb.h | 25 ++ drivers/usb/musb-new/Makefile|1 + drivers/usb/musb-new/musb_dsps.c | 771 ++ include/usb.h|3 +- 4 files changed, 799 insertions(+), 1 deletion(-) create mode 100644 arch/arm/include/asm/omap_musb.h create mode 100644 drivers/usb/musb-new/musb_dsps.c diff --git a/arch/arm/include/asm/omap_musb.h b/arch/arm/include/asm/omap_musb.h new file mode 100644 index 000..0081a68 --- /dev/null +++ b/arch/arm/include/asm/omap_musb.h @@ -0,0 +1,25 @@ +/* + * Board data structure for musb gadget on OMAPs + * + * Copyright (C) 2012, Ilya Yanok ilya.ya...@gmail.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. + */ + +#ifndef __ASM_ARM_OMAP_MUSB_H +#define __ASM_ARM_OMAP_MUSB_H + +extern struct musb_platform_ops musb_dsps_ops; + +struct omap_musb_board_data { + void (*set_phy_power)(u8 on); +}; +#endif /* __ASM_ARM_OMAP_MUSB_H */ diff --git a/drivers/usb/musb-new/Makefile b/drivers/usb/musb-new/Makefile index f01fb16..a753423 100644 --- a/drivers/usb/musb-new/Makefile +++ b/drivers/usb/musb-new/Makefile @@ -9,6 +9,7 @@ LIB := $(obj)libusb_musb-new.o COBJS-$(CONFIG_MUSB_GADGET) += musb_gadget.o musb_gadget_ep0.o musb_core.o COBJS-$(CONFIG_MUSB_GADGET) += musb_uboot.o COBJS-$(CONFIG_MUSB_HOST) += musb_host.o musb_core.o musb_uboot.o +COBJS-$(CONFIG_USB_MUSB_DSPS) += musb_dsps.o CFLAGS_NO_WARN := $(call cc-option,-Wno-unused-variable) \ $(call cc-option,-Wno-unused-but-set-variable) \ diff --git a/drivers/usb/musb-new/musb_dsps.c b/drivers/usb/musb-new/musb_dsps.c new file mode 100644 index 000..9a03917 --- /dev/null +++ b/drivers/usb/musb-new/musb_dsps.c @@ -0,0 +1,771 @@ +/* + * Texas Instruments DSPS platforms glue layer + * + * Copyright (C) 2012, by Texas Instruments + * + * Based on the am35x glue layer code. + * + * This file is part of the Inventra Controller Driver for Linux. + * + * The Inventra Controller Driver for Linux is free software; you + * can redistribute it and/or modify it under the terms of the GNU + * General Public License version 2 as published by the Free Software + * Foundation. + * + * The Inventra Controller Driver for Linux 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 The Inventra Controller Driver for Linux ; if not, + * write to the Free Software Foundation, Inc., 59 Temple Place, + * Suite 330, Boston, MA 02111-1307 USA + * + * musb_dsps.c will be a common file for all the TI DSPS platforms + * such as dm64x, dm36x, dm35x, da8x, am35x and ti81x. + * For now only ti81x is using this and in future davinci.c, am35x.c + * da8xx.c would be merged to this file after testing. + */ + +#define __UBOOT__ +#ifndef __UBOOT__ +#include linux/init.h +#include linux/io.h +#include linux/err.h +#include linux/platform_device.h +#include linux/dma-mapping.h +#include linux/pm_runtime.h +#include linux/module.h + +#include linux/of.h +#include linux/of_device.h +#include linux/of_address.h + +#include plat/usb.h +#else +#include common.h +#include asm/omap_musb.h +#include linux-compat.h +#endif + +#include musb_core.h + +/** + * avoid using musb_readx()/musb_writex() as glue layer should not be + * dependent on musb core layer symbols. + */ +static inline u8 dsps_readb(const void __iomem *addr, unsigned offset) + { return __raw_readb(addr + offset); } + +static inline u32 dsps_readl(const void __iomem *addr, unsigned offset) + { return __raw_readl(addr + offset); } + +static inline void dsps_writeb(void __iomem *addr, unsigned offset, u8 data) + { __raw_writeb(data, addr + offset); } + +static inline void dsps_writel(void __iomem *addr, unsigned offset, u32 data) + { __raw_writel(data, addr + offset); } + +/** + * DSPS musb wrapper register offset. + * FIXME: This should be expanded to have all the wrapper registers from TI DSPS + * musb
[U-Boot] [PATCH v4 02/13] usb: use linux/usb/ch9.h instead of usbdescriptors.h
Linux usb/ch9.h seems to have all the same information (and more) as usbdescriptors.h so use the former instead of the later one. As a consequense of this change USB_SPEED_* values don't correspond directly to EHCI speed encoding anymore, I've added necessary recoding in EHCI driver. Also there is no point to put speed into pipe anymore so it's removed and a bunch of host drivers fixed to look at usb_device-speed instead. Old usbdescriptors.h included is not removed as it seems to be used by old USB device code. This makes usb.h and usbdevice.h incompatible. Fortunately the only place that tries to include both are the old MUSB code and it needs usb.h only for USB_DMA_MINALIGN used in aligned attribute on musb_regs structure but this attribute seems to be unneeded (old MUSB code doesn't support any DMA at all). Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- Changes in v4: - fix indent Changes in v3: - fix old MUSB code compilation arch/arm/cpu/arm920t/s3c24x0/usb_ohci.c |2 +- arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c |2 +- arch/powerpc/cpu/mpc5xxx/usb_ohci.c |2 +- arch/powerpc/cpu/ppc4xx/usb_ohci.c|2 +- common/cmd_usb.c |2 +- common/usb.c |4 ++-- drivers/usb/host/ehci-hcd.c | 16 ++-- drivers/usb/host/isp116x-hcd.c|2 +- drivers/usb/host/ohci-hcd.c |2 +- drivers/usb/host/sl811-hcd.c |2 +- drivers/usb/musb/musb_core.h |3 +-- drivers/usb/musb/musb_hcd.c |5 +++-- include/usb.h | 15 +++ include/usb_defs.h|6 -- 14 files changed, 31 insertions(+), 34 deletions(-) diff --git a/arch/arm/cpu/arm920t/s3c24x0/usb_ohci.c b/arch/arm/cpu/arm920t/s3c24x0/usb_ohci.c index 944bb32..3bca66a 100644 --- a/arch/arm/cpu/arm920t/s3c24x0/usb_ohci.c +++ b/arch/arm/cpu/arm920t/s3c24x0/usb_ohci.c @@ -620,7 +620,7 @@ static struct ed *ep_add_ed(struct usb_device *usb_dev, unsigned long pipe) | (usb_pipeisoc(pipe) ? 0x8000 : 0) | (usb_pipecontrol(pipe) ? 0 : (usb_pipeout(pipe) ? 0x800 : 0x1000)) - | usb_pipeslow(pipe) 13 | + | (usb_dev-speed == USB_SPEED_LOW) 13 | usb_maxpacket(usb_dev, pipe) 16); return ed_ret; diff --git a/arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c b/arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c index c747767..b9b0998 100644 --- a/arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c +++ b/arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c @@ -615,7 +615,7 @@ static ed_t * ep_add_ed (struct usb_device *usb_dev, unsigned long pipe) | usb_pipeendpoint (pipe) 7 | (usb_pipeisoc (pipe)? 0x8000: 0) | (usb_pipecontrol (pipe)? 0: (usb_pipeout (pipe)? 0x800: 0x1000)) - | usb_pipeslow (pipe) 13 + | (usb_dev-speed == USB_SPEED_LOW) 13 | usb_maxpacket (usb_dev, pipe) 16); return ed_ret; diff --git a/arch/powerpc/cpu/mpc5xxx/usb_ohci.c b/arch/powerpc/cpu/mpc5xxx/usb_ohci.c index 607034b..de07343 100644 --- a/arch/powerpc/cpu/mpc5xxx/usb_ohci.c +++ b/arch/powerpc/cpu/mpc5xxx/usb_ohci.c @@ -618,7 +618,7 @@ static ed_t * ep_add_ed (struct usb_device *usb_dev, unsigned long pipe) | usb_pipeendpoint (pipe) 7 | (usb_pipeisoc (pipe)? 0x8000: 0) | (usb_pipecontrol (pipe)? 0: (usb_pipeout (pipe)? 0x800: 0x1000)) - | usb_pipeslow (pipe) 13 + | (usb_dev-speed == USB_SPEED_LOW) 13 | usb_maxpacket (usb_dev, pipe) 16); return ed_ret; diff --git a/arch/powerpc/cpu/ppc4xx/usb_ohci.c b/arch/powerpc/cpu/ppc4xx/usb_ohci.c index 4ce2726..f820c37 100644 --- a/arch/powerpc/cpu/ppc4xx/usb_ohci.c +++ b/arch/powerpc/cpu/ppc4xx/usb_ohci.c @@ -621,7 +621,7 @@ static ed_t * ep_add_ed (struct usb_device *usb_dev, unsigned long pipe) | usb_pipeendpoint (pipe) 7 | (usb_pipeisoc (pipe)? 0x8000: 0) | (usb_pipecontrol (pipe)? 0: (usb_pipeout (pipe)? 0x800: 0x1000)) - | usb_pipeslow (pipe) 13 + | (usb_dev-speed == USB_SPEED_LOW) 13 | usb_maxpacket (usb_dev, pipe) 16); return ed_ret; diff --git a/common/cmd_usb.c b/common/cmd_usb.c index c128455..8be9952 100644 --- a/common/cmd_usb.c +++ b/common/cmd_usb.c @@ -192,7 +192,7 @@ void usb_display_desc(struct usb_device *dev) } -void usb_display_conf_desc(struct usb_configuration_descriptor *config
[U-Boot] [PATCH v4 0/13] Port of MUSB driver from Linux (changes from Linux)
My apologies for double posting -- I was so stupid to forget to fix the Signed-off-by lines Current MUSB driver in U-Boot uses old UDC API while new gagdet client drivers need new gadget API. Also current MUSB driver has some significant limitations (like inability to handle tx for endpoints other than ep0). So I think port of new Linux driver is desirable. This is initial port, performed mostly by putting DM and OTG code under #ifndef __UBOOT__ clauses. My intention was to be as close as possible to the original to ease of possible resyncs. Some warnings are suppressed via CFLAGS. There are some style problems but I'm not touching them for now for the above mentioned reason. There is obviously some room for optimisation, some structure fields are unused as well as (probably) some code. This is not a replacement for existing MUSB driver (at least for now), cause there are still consumers of USB serial gadget which uses old API and there is no support for serial with new API for now. OTG and DMA are not supported. Ported drivers include: musb_dsps (should work both with TI AM33xx and TI81xx, tested only on AM33xx), am35x (tested on AM3517 EVM) and omap2plus (should work on OMAP2/3/4, tested on omap3_beagle, omap4_panda doesn't work and needs more work). Others should be easy to port too. Virtual root hub is not implemented but this shouldn't be a big problem as the old code has virtual root hub support enabled only for Blackfin platform. Pathes are rather big because of the original code size (and I didn't delete unused code, just disabled it). So it's probably better to look at changes as compared to Linux code. I prepared such version also, you can find it at [1]. Hopefully it will be also useful if resync with the kernel will be needed in future. [1] https://github.com/yanok/u-boot/tree/musb-changes-from-linux-v4 Changes in v4: - fix indent - minor style fixes Changes in v3: - fix old MUSB code compilation - bugfix: struct musb should be zeroed after alloc - fix musb gadget_chips entry - fix for new multi-interface usb API - use clrsetbits_le32 for USB PHY ops Changes in v2: - add missing linux-compat.h header - added host support - glue code moved from musb_gadget_uboot.c to musb_uboot.c and cleaned up slightly. - added check for malloc return value - define is_{host,peripheral}_capable conditionally to support compilation with only host or gadget enabled - added some more is_{host,peripheral}_capable guards to core code to support compilation with only host or gadget enabled - rename backend config option to CONFIG_USB_MUSB_DSPS - we are providing host support now so add yourself to usb.h Ilya Yanok (13): linux/usb/ch9.h: update with the version from Linux tree usb: use linux/usb/ch9.h instead of usbdescriptors.h musb-new: port of Linux musb driver musb-new: dsps backend driver am33xx: init OTG hardware and new musb gadget driver am335x_evm: enable both musb gadget and host musb-new: am35x backend driver OMAP3: am35x_def.h: add USB defines OMAP3: am35x: add musb functions am3517_evm: switch to musb-new musb-new: omap2plus backend driver omap3_beagle: add musb-new init omap3_beagle: use new MUSB intstead of the old one Makefile |1 + arch/arm/cpu/arm920t/s3c24x0/usb_ohci.c |2 +- arch/arm/cpu/armv7/am33xx/board.c | 103 +- arch/arm/cpu/armv7/am33xx/clock.c |8 + arch/arm/cpu/armv7/omap3/Makefile |1 + arch/arm/cpu/armv7/omap3/am35x_musb.c | 75 + arch/arm/include/asm/arch-am33xx/cpu.h| 11 +- arch/arm/include/asm/arch-am33xx/hardware.h |4 + arch/arm/include/asm/arch-omap3/am35x_def.h | 27 + arch/arm/include/asm/arch-omap3/musb.h| 28 + arch/arm/include/asm/omap_musb.h | 32 + arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c |2 +- arch/powerpc/cpu/mpc5xxx/usb_ohci.c |2 +- arch/powerpc/cpu/ppc4xx/usb_ohci.c|2 +- board/logicpd/am3517evm/am3517evm.c | 74 + board/ti/beagle/beagle.c | 43 + common/cmd_usb.c |2 +- common/usb.c |4 +- drivers/usb/gadget/config.c |1 - drivers/usb/gadget/epautoconf.c |1 - drivers/usb/gadget/ether.c|1 - drivers/usb/gadget/gadget_chips.h |4 +- drivers/usb/gadget/s3c_udc_otg.c |1 - drivers/usb/gadget/usbstring.c|1 - drivers/usb/host/ehci-hcd.c | 16 +- drivers/usb/host/isp116x-hcd.c|2 +- drivers/usb/host/ohci-hcd.c |2 +- drivers/usb/host/sl811-hcd.c |2 +- drivers/usb/musb-new/Makefile | 39 + drivers/usb/musb-new/am35x.c | 709 +++ drivers/usb/musb-new/linux-compat.h
[U-Boot] [PATCH v4 01/13] linux/usb/ch9.h: update with the version from Linux tree
Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- drivers/usb/gadget/config.c |1 - drivers/usb/gadget/epautoconf.c |1 - drivers/usb/gadget/ether.c |1 - drivers/usb/gadget/s3c_udc_otg.c |1 - drivers/usb/gadget/usbstring.c |1 - include/linux/usb/ch9.h | 514 -- include/usb/s3c_udc.h|1 - 7 files changed, 499 insertions(+), 21 deletions(-) diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c index f88d0c1..f9163a8 100644 --- a/drivers/usb/gadget/config.c +++ b/drivers/usb/gadget/config.c @@ -27,7 +27,6 @@ #include linux/string.h #include linux/usb/ch9.h -#include usbdescriptors.h #include linux/usb/gadget.h diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index b656c8b..5b8776e 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -23,7 +23,6 @@ #include common.h #include linux/usb/ch9.h -#include usbdescriptors.h #include asm/errno.h #include linux/usb/gadget.h #include asm/unaligned.h diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 1e187e5..c51e69c 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -24,7 +24,6 @@ #include asm/errno.h #include linux/netdevice.h #include linux/usb/ch9.h -#include usbdescriptors.h #include linux/usb/cdc.h #include linux/usb/gadget.h #include net.h diff --git a/drivers/usb/gadget/s3c_udc_otg.c b/drivers/usb/gadget/s3c_udc_otg.c index 3fdfdf7..f9d24e3 100644 --- a/drivers/usb/gadget/s3c_udc_otg.c +++ b/drivers/usb/gadget/s3c_udc_otg.c @@ -37,7 +37,6 @@ #include malloc.h #include linux/usb/ch9.h -#include usbdescriptors.h #include linux/usb/gadget.h #include asm/byteorder.h diff --git a/drivers/usb/gadget/usbstring.c b/drivers/usb/gadget/usbstring.c index 4dbe060..9cf 100644 --- a/drivers/usb/gadget/usbstring.c +++ b/drivers/usb/gadget/usbstring.c @@ -13,7 +13,6 @@ #include common.h #include asm/errno.h #include linux/usb/ch9.h -#include usbdescriptors.h #include linux/usb/gadget.h #include asm/unaligned.h diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h index ce1d1e1..d1d732c 100644 --- a/include/linux/usb/ch9.h +++ b/include/linux/usb/ch9.h @@ -28,15 +28,13 @@ * [c] for consistency, removing all doubt even when it appears to * someone that the two other points are non-issues for that * particular descriptor type. - * - * Ported to U-boot by: Thomas Smits ts.sm...@gmail.com and - * Remy Bohmer li...@bohmer.net */ #ifndef __LINUX_USB_CH9_H #define __LINUX_USB_CH9_H #include linux/types.h /* __u8 etc */ +#include asm/byteorder.h /* le16_to_cpu */ /*-*/ @@ -70,7 +68,7 @@ #define USB_RECIP_OTHER0x03 /* From Wireless USB 1.0 */ #define USB_RECIP_PORT 0x04 -#define USB_RECIP_RPIPE0x05 +#define USB_RECIP_RPIPE0x05 /* * Standard requests, for the bRequest field of a SETUP packet. @@ -90,6 +88,8 @@ #define USB_REQ_GET_INTERFACE 0x0A #define USB_REQ_SET_INTERFACE 0x0B #define USB_REQ_SYNCH_FRAME0x0C +#define USB_REQ_SET_SEL0x30 +#define USB_REQ_SET_ISOCH_DELAY0x31 #define USB_REQ_SET_ENCRYPTION 0x0D/* Wireless USB */ #define USB_REQ_GET_ENCRYPTION 0x0E @@ -105,10 +105,16 @@ #define USB_REQ_LOOPBACK_DATA_READ 0x16 #define USB_REQ_SET_INTERFACE_DS 0x17 +/* The Link Power Management (LPM) ECN defines USB_REQ_TEST_AND_SET command, + * used by hubs to put ports into a new L1 suspend state, except that it + * forgot to define its number ... + */ + /* * USB feature flags are written using USB_REQ_{CLEAR,SET}_FEATURE, and * are read as a bit array returned by USB_REQ_GET_STATUS. (So there - * are at most sixteen features of each type.) + * are at most sixteen features of each type.) Hubs may also support a + * new USB_REQ_TEST_AND_SET_FEATURE to put ports into L1 suspend. */ #define USB_DEVICE_SELF_POWERED0 /* (read only) */ #define USB_DEVICE_REMOTE_WAKEUP 1 /* dev may initiate wakeup */ @@ -120,8 +126,38 @@ #define USB_DEVICE_A_ALT_HNP_SUPPORT 5 /* (otg) other RH port does */ #define USB_DEVICE_DEBUG_MODE 6 /* (special devices only) */ +/* + * Test Mode Selectors + * See USB 2.0 spec Table 9-7 + */ +#defineTEST_J 1 +#defineTEST_K 2 +#defineTEST_SE0_NAK3 +#defineTEST_PACKET 4 +#defineTEST_FORCE_EN 5 + +/* + * New Feature Selectors as added by USB 3.0 + * See USB 3.0 spec Table 9-6 + */ +#define USB_DEVICE_U1_ENABLE 48 /* dev may initiate U1 transition */ +#define USB_DEVICE_U2_ENABLE 49 /* dev may initiate U2 transition
[U-Boot] [PATCH v4 04/13] musb-new: dsps backend driver
Backend driver for MUSB OTG controllers found on TI AM33xx and TI81xx SoCs (tested with AM33xx only). Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- Changes in v2: - rename backend config option to CONFIG_USB_MUSB_DSPS - we are providing host support now so add yourself to usb.h arch/arm/include/asm/omap_musb.h | 25 ++ drivers/usb/musb-new/Makefile|1 + drivers/usb/musb-new/musb_dsps.c | 771 ++ include/usb.h|3 +- 4 files changed, 799 insertions(+), 1 deletion(-) create mode 100644 arch/arm/include/asm/omap_musb.h create mode 100644 drivers/usb/musb-new/musb_dsps.c diff --git a/arch/arm/include/asm/omap_musb.h b/arch/arm/include/asm/omap_musb.h new file mode 100644 index 000..0081a68 --- /dev/null +++ b/arch/arm/include/asm/omap_musb.h @@ -0,0 +1,25 @@ +/* + * Board data structure for musb gadget on OMAPs + * + * Copyright (C) 2012, Ilya Yanok ilya.ya...@gmail.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. + */ + +#ifndef __ASM_ARM_OMAP_MUSB_H +#define __ASM_ARM_OMAP_MUSB_H + +extern struct musb_platform_ops musb_dsps_ops; + +struct omap_musb_board_data { + void (*set_phy_power)(u8 on); +}; +#endif /* __ASM_ARM_OMAP_MUSB_H */ diff --git a/drivers/usb/musb-new/Makefile b/drivers/usb/musb-new/Makefile index f01fb16..a753423 100644 --- a/drivers/usb/musb-new/Makefile +++ b/drivers/usb/musb-new/Makefile @@ -9,6 +9,7 @@ LIB := $(obj)libusb_musb-new.o COBJS-$(CONFIG_MUSB_GADGET) += musb_gadget.o musb_gadget_ep0.o musb_core.o COBJS-$(CONFIG_MUSB_GADGET) += musb_uboot.o COBJS-$(CONFIG_MUSB_HOST) += musb_host.o musb_core.o musb_uboot.o +COBJS-$(CONFIG_USB_MUSB_DSPS) += musb_dsps.o CFLAGS_NO_WARN := $(call cc-option,-Wno-unused-variable) \ $(call cc-option,-Wno-unused-but-set-variable) \ diff --git a/drivers/usb/musb-new/musb_dsps.c b/drivers/usb/musb-new/musb_dsps.c new file mode 100644 index 000..9a03917 --- /dev/null +++ b/drivers/usb/musb-new/musb_dsps.c @@ -0,0 +1,771 @@ +/* + * Texas Instruments DSPS platforms glue layer + * + * Copyright (C) 2012, by Texas Instruments + * + * Based on the am35x glue layer code. + * + * This file is part of the Inventra Controller Driver for Linux. + * + * The Inventra Controller Driver for Linux is free software; you + * can redistribute it and/or modify it under the terms of the GNU + * General Public License version 2 as published by the Free Software + * Foundation. + * + * The Inventra Controller Driver for Linux 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 The Inventra Controller Driver for Linux ; if not, + * write to the Free Software Foundation, Inc., 59 Temple Place, + * Suite 330, Boston, MA 02111-1307 USA + * + * musb_dsps.c will be a common file for all the TI DSPS platforms + * such as dm64x, dm36x, dm35x, da8x, am35x and ti81x. + * For now only ti81x is using this and in future davinci.c, am35x.c + * da8xx.c would be merged to this file after testing. + */ + +#define __UBOOT__ +#ifndef __UBOOT__ +#include linux/init.h +#include linux/io.h +#include linux/err.h +#include linux/platform_device.h +#include linux/dma-mapping.h +#include linux/pm_runtime.h +#include linux/module.h + +#include linux/of.h +#include linux/of_device.h +#include linux/of_address.h + +#include plat/usb.h +#else +#include common.h +#include asm/omap_musb.h +#include linux-compat.h +#endif + +#include musb_core.h + +/** + * avoid using musb_readx()/musb_writex() as glue layer should not be + * dependent on musb core layer symbols. + */ +static inline u8 dsps_readb(const void __iomem *addr, unsigned offset) + { return __raw_readb(addr + offset); } + +static inline u32 dsps_readl(const void __iomem *addr, unsigned offset) + { return __raw_readl(addr + offset); } + +static inline void dsps_writeb(void __iomem *addr, unsigned offset, u8 data) + { __raw_writeb(data, addr + offset); } + +static inline void dsps_writel(void __iomem *addr, unsigned offset, u32 data) + { __raw_writel(data, addr + offset); } + +/** + * DSPS musb wrapper register offset. + * FIXME: This should be expanded to have all the wrapper registers from TI DSPS + * musb ips. + */ +struct dsps_musb_wrapper { + u16
[U-Boot] [PATCH v4 06/13] am335x_evm: enable both musb gadget and host
Enable musb gadget in Ethernet mode on port 0 and musb host on port1. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- include/configs/am335x_evm.h | 27 +++ 1 file changed, 27 insertions(+) diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h index 339d4bd..77f7219 100644 --- a/include/configs/am335x_evm.h +++ b/include/configs/am335x_evm.h @@ -237,6 +237,33 @@ #define CONFIG_SKIP_LOWLEVEL_INIT #endif +/* + * USB configuration + */ +#define CONFIG_USB_MUSB_DSPS +#define CONFIG_ARCH_MISC_INIT +#define CONFIG_MUSB_GADGET +#define CONFIG_MUSB_PIO_ONLY +#define CONFIG_USB_GADGET_DUALSPEED +#define CONFIG_MUSB_HOST +#define CONFIG_AM335X_USB0 +#define CONFIG_AM335X_USB0_MODEMUSB_PERIPHERAL +#define CONFIG_AM335X_USB1 +#define CONFIG_AM335X_USB1_MODE MUSB_HOST + +#ifdef CONFIG_MUSB_HOST +#define CONFIG_CMD_USB +#define CONFIG_USB_STORAGE +#endif + +#ifdef CONFIG_MUSB_GADGET +#define CONFIG_USB_ETHER +#define CONFIG_USB_ETH_RNDIS +#endif /* CONFIG_MUSB_GADGET */ + +/* Unsupported features */ +#undef CONFIG_USE_IRQ + #define CONFIG_CMD_NET #define CONFIG_CMD_DHCP #define CONFIG_CMD_PING -- 1.7.10.2 (Apple Git-33) ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v4 05/13] am33xx: init OTG hardware and new musb gadget driver
AM33xx has support for dual port MUSB OTG controller. This patch adds initialization for the controller using new MUSB gadget driver and ether gadget. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- Changes in v3: - use clrsetbits_le32 for USB PHY ops arch/arm/cpu/armv7/am33xx/board.c | 103 ++- arch/arm/cpu/armv7/am33xx/clock.c |8 +++ arch/arm/include/asm/arch-am33xx/cpu.h | 11 ++- arch/arm/include/asm/arch-am33xx/hardware.h |4 ++ 4 files changed, 122 insertions(+), 4 deletions(-) diff --git a/arch/arm/cpu/armv7/am33xx/board.c b/arch/arm/cpu/armv7/am33xx/board.c index 978b184..1917c2a 100644 --- a/arch/arm/cpu/armv7/am33xx/board.c +++ b/arch/arm/cpu/armv7/am33xx/board.c @@ -33,6 +33,11 @@ #include i2c.h #include miiphy.h #include cpsw.h +#include asm/errno.h +#include linux/usb/ch9.h +#include linux/usb/gadget.h +#include linux/usb/musb.h +#include asm/omap_musb.h DECLARE_GLOBAL_DATA_PTR; @@ -209,6 +214,84 @@ void setup_clocks_for_console(void) return; } +/* AM33XX has two MUSB controllers which can be host or gadget */ +#if (defined(CONFIG_MUSB_GADGET) || defined(CONFIG_MUSB_HOST)) \ + (defined(CONFIG_AM335X_USB0) || defined(CONFIG_AM335X_USB1)) +/* USB 2.0 PHY Control */ +#define CM_PHY_PWRDN (1 0) +#define CM_PHY_OTG_PWRDN (1 1) +#define OTGVDET_EN (1 19) +#define OTGSESSENDEN (1 20) + +static void am33xx_usb_set_phy_power(u8 on, u32 *reg_addr) +{ + if (on) { + clrsetbits_le32(reg_addr, CM_PHY_PWRDN | CM_PHY_OTG_PWRDN, + OTGVDET_EN | OTGSESSENDEN); + } else { + clrsetbits_le32(reg_addr, 0, CM_PHY_PWRDN | CM_PHY_OTG_PWRDN); + } +} + +static struct musb_hdrc_config musb_config = { + .multipoint = 1, + .dyn_fifo = 1, + .num_eps= 16, + .ram_bits = 12, +}; + +#ifdef CONFIG_AM335X_USB0 +static void am33xx_otg0_set_phy_power(u8 on) +{ + am33xx_usb_set_phy_power(on, cdev-usb_ctrl0); +} + +struct omap_musb_board_data otg0_board_data = { + .set_phy_power = am33xx_otg0_set_phy_power, +}; + +static struct musb_hdrc_platform_data otg0_plat = { + .mode = CONFIG_AM335X_USB0_MODE, + .config = musb_config, + .power = 50, + .platform_ops = musb_dsps_ops, + .board_data = otg0_board_data, +}; +#endif + +#ifdef CONFIG_AM335X_USB1 +static void am33xx_otg1_set_phy_power(u8 on) +{ + am33xx_usb_set_phy_power(on, cdev-usb_ctrl1); +} + +struct omap_musb_board_data otg1_board_data = { + .set_phy_power = am33xx_otg1_set_phy_power, +}; + +static struct musb_hdrc_platform_data otg1_plat = { + .mode = CONFIG_AM335X_USB1_MODE, + .config = musb_config, + .power = 50, + .platform_ops = musb_dsps_ops, + .board_data = otg1_board_data, +}; +#endif +#endif + +int arch_misc_init(void) +{ +#ifdef CONFIG_AM335X_USB0 + musb_register(otg0_plat, otg0_board_data, + (void *)AM335X_USB0_OTG_BASE); +#endif +#ifdef CONFIG_AM335X_USB1 + musb_register(otg1_plat, otg1_board_data, + (void *)AM335X_USB1_OTG_BASE); +#endif + return 0; +} + /* * Basic board specific setup. Pinmux has been handled already. */ @@ -261,9 +344,14 @@ static struct cpsw_platform_data cpsw_data = { .host_port_num = 0, .version= CPSW_CTRL_VERSION_2, }; +#endif +#if defined(CONFIG_DRIVER_TI_CPSW) || \ + (defined(CONFIG_USB_ETHER) defined(CONFIG_MUSB_GADGET)) int board_eth_init(bd_t *bis) { + int rv, n = 0; +#ifdef CONFIG_DRIVER_TI_CPSW uint8_t mac_addr[6]; uint32_t mac_hi, mac_lo; @@ -295,6 +383,19 @@ int board_eth_init(bd_t *bis) PHY_INTERFACE_MODE_RGMII; } - return cpsw_register(cpsw_data); + rv = cpsw_register(cpsw_data); + if (rv 0) + printf(Error %d registering CPSW switch\n, rv); + else + n += rv; +#endif +#ifdef CONFIG_USB_ETHER + rv = usb_eth_initialize(bis); + if (rv 0) + printf(Error %d registering USB_ETHER\n, rv); + else + n += rv; +#endif + return n; } #endif diff --git a/arch/arm/cpu/armv7/am33xx/clock.c b/arch/arm/cpu/armv7/am33xx/clock.c index 2b19506..04841e4 100644 --- a/arch/arm/cpu/armv7/am33xx/clock.c +++ b/arch/arm/cpu/armv7/am33xx/clock.c @@ -40,6 +40,7 @@ #define CLK_MODE_MASK 0xfff8 #define CLK_DIV_SEL0xFFE0 #define CPGMAC0_IDLE 0x3 +#define DPLL_CLKDCOLDO_GATE_CTRL0x300 const struct cm_perpll *cmper = (struct cm_perpll *)CM_PER; const struct cm_wkuppll *cmwkup = (struct cm_wkuppll *)CM_WKUP; @@ -153,6 +154,11 @@ static void enable_per_clocks(void) writel(PRCM_MOD_EN
[U-Boot] [PATCH v4 07/13] musb-new: am35x backend driver
Backend driver for MUSB OTG controllers found on TI AM35x. It seems that on AM35X interrupt status registers can be updated _before_ core registers. As we don't use true interrupts in U-Boot and poll interrupt status registers instead this can result in interrupt handler being called with non-updated core registers. This confuses the code and result in hanged transfers. Add a small delay in am35x_interrupt as a workaround. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- arch/arm/include/asm/omap_musb.h|3 + drivers/usb/musb-new/Makefile |1 + drivers/usb/musb-new/am35x.c| 709 +++ drivers/usb/musb-new/linux-compat.h |1 + include/usb.h |2 +- 5 files changed, 715 insertions(+), 1 deletion(-) create mode 100644 drivers/usb/musb-new/am35x.c diff --git a/arch/arm/include/asm/omap_musb.h b/arch/arm/include/asm/omap_musb.h index 0081a68..46c8578 100644 --- a/arch/arm/include/asm/omap_musb.h +++ b/arch/arm/include/asm/omap_musb.h @@ -18,8 +18,11 @@ #define __ASM_ARM_OMAP_MUSB_H extern struct musb_platform_ops musb_dsps_ops; +extern const struct musb_platform_ops am35x_ops; struct omap_musb_board_data { void (*set_phy_power)(u8 on); + void (*clear_irq)(void); + void (*reset)(void); }; #endif /* __ASM_ARM_OMAP_MUSB_H */ diff --git a/drivers/usb/musb-new/Makefile b/drivers/usb/musb-new/Makefile index a753423..23fc735 100644 --- a/drivers/usb/musb-new/Makefile +++ b/drivers/usb/musb-new/Makefile @@ -10,6 +10,7 @@ COBJS-$(CONFIG_MUSB_GADGET) += musb_gadget.o musb_gadget_ep0.o musb_core.o COBJS-$(CONFIG_MUSB_GADGET) += musb_uboot.o COBJS-$(CONFIG_MUSB_HOST) += musb_host.o musb_core.o musb_uboot.o COBJS-$(CONFIG_USB_MUSB_DSPS) += musb_dsps.o +COBJS-$(CONFIG_USB_MUSB_AM35X) += am35x.o CFLAGS_NO_WARN := $(call cc-option,-Wno-unused-variable) \ $(call cc-option,-Wno-unused-but-set-variable) \ diff --git a/drivers/usb/musb-new/am35x.c b/drivers/usb/musb-new/am35x.c new file mode 100644 index 000..57c9bd3 --- /dev/null +++ b/drivers/usb/musb-new/am35x.c @@ -0,0 +1,709 @@ +/* + * Texas Instruments AM35x glue layer + * + * Copyright (c) 2010, by Texas Instruments + * + * Based on the DA8xx glue layer code. + * Copyright (c) 2008-2009, MontaVista Software, Inc. sou...@mvista.com + * + * This file is part of the Inventra Controller Driver for Linux. + * + * The Inventra Controller Driver for Linux is free software; you + * can redistribute it and/or modify it under the terms of the GNU + * General Public License version 2 as published by the Free Software + * Foundation. + * + * The Inventra Controller Driver for Linux 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 The Inventra Controller Driver for Linux ; if not, + * write to the Free Software Foundation, Inc., 59 Temple Place, + * Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define __UBOOT__ +#ifndef __UBOOT__ +#include linux/init.h +#include linux/module.h +#include linux/clk.h +#include linux/err.h +#include linux/io.h +#include linux/platform_device.h +#include linux/dma-mapping.h + +#include plat/usb.h +#else +#include common.h +#include asm/omap_musb.h +#include linux-compat.h +#endif + +#include musb_core.h + +/* + * AM35x specific definitions + */ +/* USB 2.0 OTG module registers */ +#define USB_REVISION_REG 0x00 +#define USB_CTRL_REG 0x04 +#define USB_STAT_REG 0x08 +#define USB_EMULATION_REG 0x0c +/* 0x10 Reserved */ +#define USB_AUTOREQ_REG0x14 +#define USB_SRP_FIX_TIME_REG 0x18 +#define USB_TEARDOWN_REG 0x1c +#define EP_INTR_SRC_REG0x20 +#define EP_INTR_SRC_SET_REG0x24 +#define EP_INTR_SRC_CLEAR_REG 0x28 +#define EP_INTR_MASK_REG 0x2c +#define EP_INTR_MASK_SET_REG 0x30 +#define EP_INTR_MASK_CLEAR_REG 0x34 +#define EP_INTR_SRC_MASKED_REG 0x38 +#define CORE_INTR_SRC_REG 0x40 +#define CORE_INTR_SRC_SET_REG 0x44 +#define CORE_INTR_SRC_CLEAR_REG0x48 +#define CORE_INTR_MASK_REG 0x4c +#define CORE_INTR_MASK_SET_REG 0x50 +#define CORE_INTR_MASK_CLEAR_REG 0x54 +#define CORE_INTR_SRC_MASKED_REG 0x58 +/* 0x5c Reserved */ +#define USB_END_OF_INTR_REG0x60 + +/* Control register bits */ +#define AM35X_SOFT_RESET_MASK 1 + +/* USB interrupt register bits */ +#define AM35X_INTR_USB_SHIFT 16 +#define AM35X_INTR_USB_MASK(0x1ff AM35X_INTR_USB_SHIFT) +#define AM35X_INTR_DRVVBUS 0x100 +#define AM35X_INTR_RX_SHIFT16 +#define AM35X_INTR_TX_SHIFT0 +#define AM35X_TX_EP_MASK 0x /* EP0 + 15 Tx EPs */ +#define AM35X_RX_EP_MASK 0xfffe /* 15 Rx EPs */ +#define AM35X_TX_INTR_MASK
[U-Boot] [PATCH v4 08/13] OMAP3: am35x_def.h: add USB defines
Add defines for MUSB IP block on AM35X SoCs. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- arch/arm/include/asm/arch-omap3/am35x_def.h | 27 +++ 1 file changed, 27 insertions(+) diff --git a/arch/arm/include/asm/arch-omap3/am35x_def.h b/arch/arm/include/asm/arch-omap3/am35x_def.h index bbaf1bc..67698bc 100644 --- a/arch/arm/include/asm/arch-omap3/am35x_def.h +++ b/arch/arm/include/asm/arch-omap3/am35x_def.h @@ -32,9 +32,34 @@ #ifndef __KERNEL_STRICT_NAMES #ifndef __ASSEMBLY__ +/* LVL_INTR_CLEAR bits */ +#define USBOTGSS_INT_CLR (1 4) + /* IP_SW_RESET bits */ +#define USBOTGSS_SW_RST(1 0)/* reset USBOTG */ #define CPGMACSS_SW_RST(1 1)/* reset CPGMAC */ +/* DEVCONF2 bits */ +#define CONF2_PHY_GPIOMODE (1 23) +#define CONF2_OTGMODE (3 14) +#define CONF2_NO_OVERRIDE (0 14) +#define CONF2_FORCE_HOST (1 14) +#define CONF2_FORCE_DEVICE (2 14) +#define CONF2_FORCE_HOST_VBUS_LOW (3 14) +#define CONF2_SESENDEN (1 13) +#define CONF2_VBDTCTEN (1 12) +#define CONF2_REFFREQ_24MHZ(2 8) +#define CONF2_REFFREQ_26MHZ(7 8) +#define CONF2_REFFREQ_13MHZ(6 8) +#define CONF2_REFFREQ (0xf 8) +#define CONF2_PHYCLKGD (1 7) +#define CONF2_VBUSSENSE(1 6) +#define CONF2_PHY_PLLON(1 5) +#define CONF2_RESET(1 4) +#define CONF2_PHYPWRDN (1 3) +#define CONF2_OTGPWRDN (1 2) +#define CONF2_DATPOL (1 1) + /* General register mappings of system control module */ #define AM35X_SCM_GEN_BASE 0x48002270 struct am35x_scm_general { @@ -49,6 +74,8 @@ struct am35x_scm_general { }; #define am35x_scm_general_regs ((struct am35x_scm_general *)AM35X_SCM_GEN_BASE) +#define AM35XX_IPSS_USBOTGSS_BASE 0x5C04 + #endif /*__ASSEMBLY__ */ #endif /* __KERNEL_STRICT_NAMES */ -- 1.7.10.2 (Apple Git-33) ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v4 10/13] am3517_evm: switch to musb-new
Use new musb framework instead of the old one on AM3517_EVM. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- board/logicpd/am3517evm/am3517evm.c | 74 +++ include/configs/am3517_evm.h| 37 -- 2 files changed, 90 insertions(+), 21 deletions(-) diff --git a/board/logicpd/am3517evm/am3517evm.c b/board/logicpd/am3517evm/am3517evm.c index d316f33..0b3721e 100644 --- a/board/logicpd/am3517evm/am3517evm.c +++ b/board/logicpd/am3517evm/am3517evm.c @@ -25,12 +25,20 @@ #include common.h #include asm/io.h +#include asm/omap_musb.h +#include asm/arch/am35x_def.h #include asm/arch/mem.h #include asm/arch/mux.h #include asm/arch/sys_proto.h #include asm/arch/mmc_host_def.h +#include asm/arch/musb.h #include asm/mach-types.h +#include asm/errno.h +#include linux/usb/ch9.h +#include linux/usb/gadget.h +#include linux/usb/musb.h #include i2c.h +#include netdev.h #include am3517evm.h DECLARE_GLOBAL_DATA_PTR; @@ -50,6 +58,52 @@ int board_init(void) return 0; } +#ifdef CONFIG_USB_MUSB_AM35X +static struct musb_hdrc_config musb_config = { + .multipoint = 1, + .dyn_fifo = 1, + .num_eps= 16, + .ram_bits = 12, +}; + +static struct omap_musb_board_data musb_board_data = { + .set_phy_power = am35x_musb_phy_power, + .clear_irq = am35x_musb_clear_irq, + .reset = am35x_musb_reset, +}; + +static struct musb_hdrc_platform_data musb_plat = { +#if defined(CONFIG_MUSB_HOST) + .mode = MUSB_HOST, +#elif defined(CONFIG_MUSB_GADGET) + .mode = MUSB_PERIPHERAL, +#else +#error Please define either CONFIG_MUSB_HOST or CONFIG_MUSB_GADGET +#endif + .config = musb_config, + .power = 250, + .platform_ops = am35x_ops, + .board_data = musb_board_data, +}; + +static void am3517_evm_musb_init(void) +{ + /* +* Set up USB clock/mode in the DEVCONF2 register. +* USB2.0 PHY reference clock is 13 MHz +*/ + clrsetbits_le32(am35x_scm_general_regs-devconf2, + CONF2_REFFREQ | CONF2_OTGMODE | CONF2_PHY_GPIOMODE, + CONF2_REFFREQ_13MHZ | CONF2_SESENDEN | + CONF2_VBDTCTEN | CONF2_DATPOL); + + musb_register(musb_plat, musb_board_data, + (void *)AM35XX_IPSS_USBOTGSS_BASE); +} +#else +#define am3517_evm_musb_init() do {} while (0) +#endif + /* * Routine: misc_init_r * Description: Init i2c, ethernet, etc... (done here so udelay works) @@ -62,6 +116,8 @@ int misc_init_r(void) dieid_num_r(); + am3517_evm_musb_init(); + return 0; } @@ -83,3 +139,21 @@ int board_mmc_init(bd_t *bis) return 0; } #endif + +#if defined(CONFIG_USB_ETHER) defined(CONFIG_MUSB_GADGET) +int board_eth_init(bd_t *bis) +{ + int rv, n = 0; + + rv = cpu_eth_init(bis); + if (rv 0) + n += rv; + + rv = usb_eth_initialize(bis); + if (rv 0) + n += rv; + + return n; +} +#endif + diff --git a/include/configs/am3517_evm.h b/include/configs/am3517_evm.h index 6980811..1f0199e 100644 --- a/include/configs/am3517_evm.h +++ b/include/configs/am3517_evm.h @@ -97,15 +97,16 @@ /* * USB configuration - * Enable CONFIG_MUSB_HCD for Host functionalities MSC, keyboard - * Enable CONFIG_MUSB_UDC for Device functionalities. + * Enable CONFIG_MUSB_HOST for Host functionalities MSC, keyboard + * Enable CONFIG_MUSB_GADGET for Device functionalities. */ -#define CONFIG_USB_AM35X 1 -#define CONFIG_MUSB_HCD1 +#define CONFIG_USB_MUSB_AM35X +#define CONFIG_MUSB_HOST +#define CONFIG_MUSB_PIO_ONLY -#ifdef CONFIG_USB_AM35X +#ifdef CONFIG_USB_MUSB_AM35X -#ifdef CONFIG_MUSB_HCD +#ifdef CONFIG_MUSB_HOST #define CONFIG_CMD_USB #define CONFIG_USB_STORAGE @@ -117,21 +118,15 @@ #define CONFIG_PREBOOT usb start #endif /* CONFIG_USB_KEYBOARD */ -#endif /* CONFIG_MUSB_HCD */ - -#ifdef CONFIG_MUSB_UDC -/* USB device configuration */ -#define CONFIG_USB_DEVICE 1 -#define CONFIG_USB_TTY 1 -#define CONFIG_SYS_CONSOLE_IS_IN_ENV 1 -/* Change these to suit your needs */ -#define CONFIG_USBD_VENDORID 0x0451 -#define CONFIG_USBD_PRODUCTID 0x5678 -#define CONFIG_USBD_MANUFACTURER Texas Instruments -#define CONFIG_USBD_PRODUCT_NAME AM3517EVM -#endif /* CONFIG_MUSB_UDC */ - -#endif /* CONFIG_USB_AM35X */ +#endif /* CONFIG_MUSB_HOST */ + +#ifdef CONFIG_MUSB_GADGET +#define CONFIG_USB_GADGET_DUALSPEED +#define CONFIG_USB_ETHER +#define CONFIG_USB_ETH_RNDIS +#endif /* CONFIG_MUSB_GADGET */ + +#endif /* CONFIG_USB_MUSB_AM35X */ /* commands to include */ #include config_cmd_default.h -- 1.7.10.2 (Apple Git-33) ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de
[U-Boot] [PATCH v4 09/13] OMAP3: am35x: add musb functions
AM35XX specific functions for integrated USB PHY/MUSB IP. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- arch/arm/cpu/armv7/omap3/Makefile |1 + arch/arm/cpu/armv7/omap3/am35x_musb.c | 75 arch/arm/include/asm/arch-omap3/musb.h | 28 3 files changed, 104 insertions(+) create mode 100644 arch/arm/cpu/armv7/omap3/am35x_musb.c create mode 100644 arch/arm/include/asm/arch-omap3/musb.h diff --git a/arch/arm/cpu/armv7/omap3/Makefile b/arch/arm/cpu/armv7/omap3/Makefile index ac597be..de167ee 100644 --- a/arch/arm/cpu/armv7/omap3/Makefile +++ b/arch/arm/cpu/armv7/omap3/Makefile @@ -38,6 +38,7 @@ endif COBJS-$(CONFIG_DRIVER_TI_EMAC) += emac.o COBJS-$(CONFIG_EMIF4) += emif4.o COBJS-$(CONFIG_SDRC) += sdrc.o +COBJS-$(CONFIG_USB_MUSB_AM35X) += am35x_musb.o SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS) $(COBJS-y) $(SOBJS)) diff --git a/arch/arm/cpu/armv7/omap3/am35x_musb.c b/arch/arm/cpu/armv7/omap3/am35x_musb.c new file mode 100644 index 000..7183c4f --- /dev/null +++ b/arch/arm/cpu/armv7/omap3/am35x_musb.c @@ -0,0 +1,75 @@ +/* + * This file configures the internal USB PHY in AM35X. + * + * Copyright (C) 2012 Ilya Yanok ilya.ya...@gmail.com + * + * Based on omap_phy_internal.c code from Linux by + * Hema HK hem...@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. + * + */ + +#include common.h +#include asm/io.h +#include asm/arch/am35x_def.h + +void am35x_musb_reset(void) +{ + /* Reset the musb interface */ + clrsetbits_le32(am35x_scm_general_regs-ip_sw_reset, + 0, USBOTGSS_SW_RST); + clrsetbits_le32(am35x_scm_general_regs-ip_sw_reset, + USBOTGSS_SW_RST, 0); +} + +void am35x_musb_phy_power(u8 on) +{ + unsigned long start = get_timer(0); + + if (on) { + /* +* Start the on-chip PHY and its PLL. +*/ + clrsetbits_le32(am35x_scm_general_regs-devconf2, + CONF2_RESET | CONF2_PHYPWRDN | CONF2_OTGPWRDN, + CONF2_PHY_PLLON); + + debug(Waiting for PHY clock good...\n); + while (!(readl(am35x_scm_general_regs-devconf2) +CONF2_PHYCLKGD)) { + + if (get_timer(start) CONFIG_SYS_HZ / 10) { + printf(musb PHY clock good timed out\n); + break; + } + } + } else { + /* +* Power down the on-chip PHY. +*/ + clrsetbits_le32(am35x_scm_general_regs-devconf2, + CONF2_PHY_PLLON, + CONF2_PHYPWRDN | CONF2_OTGPWRDN); + } +} + +void am35x_musb_clear_irq(void) +{ + clrsetbits_le32(am35x_scm_general_regs-lvl_intr_clr, + 0, USBOTGSS_INT_CLR); + readl(am35x_scm_general_regs-lvl_intr_clr); +} + diff --git a/arch/arm/include/asm/arch-omap3/musb.h b/arch/arm/include/asm/arch-omap3/musb.h new file mode 100644 index 000..423ac50 --- /dev/null +++ b/arch/arm/include/asm/arch-omap3/musb.h @@ -0,0 +1,28 @@ +/* + * (C) Copyright 2012 + * Ilya Yanok, ilya.ya...@gmail.com + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc. + */ + +#ifndef __ASM_ARCH_OMAP3_MUSB_H +#define __ASM_ARCH_OMAP3_MUSB_H +extern void am35x_musb_reset(void); +extern void am35x_musb_phy_power(u8 on); +extern void am35x_musb_clear_irq(void); +#endif -- 1.7.10.2 (Apple Git-33) ___ U-Boot
[U-Boot] [PATCH v4 12/13] omap3_beagle: add musb-new init
Add initialization for new MUSB framework. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- board/ti/beagle/beagle.c | 43 include/configs/omap3_beagle.h |2 ++ 2 files changed, 45 insertions(+) diff --git a/board/ti/beagle/beagle.c b/board/ti/beagle/beagle.c index 6175e1d..f20ebed 100644 --- a/board/ti/beagle/beagle.c +++ b/board/ti/beagle/beagle.c @@ -42,6 +42,11 @@ #include asm/arch/sys_proto.h #include asm/gpio.h #include asm/mach-types.h +#include asm/omap_musb.h +#include asm/errno.h +#include linux/usb/ch9.h +#include linux/usb/gadget.h +#include linux/usb/musb.h #include beagle.h #include command.h @@ -285,6 +290,33 @@ static void beagle_dvi_pup(void) } #endif +#ifdef CONFIG_USB_MUSB_OMAP2PLUS +static struct musb_hdrc_config musb_config = { + .multipoint = 1, + .dyn_fifo = 1, + .num_eps= 16, + .ram_bits = 12, +}; + +static struct omap_musb_board_data musb_board_data = { + .interface_type = MUSB_INTERFACE_ULPI, +}; + +static struct musb_hdrc_platform_data musb_plat = { +#if defined(CONFIG_MUSB_HOST) + .mode = MUSB_HOST, +#elif defined(CONFIG_MUSB_GADGET) + .mode = MUSB_PERIPHERAL, +#else +#error Please define either CONFIG_MUSB_HOST or CONFIG_MUSB_GADGET +#endif + .config = musb_config, + .power = 100, + .platform_ops = omap2430_ops, + .board_data = musb_board_data, +}; +#endif + /* * Routine: misc_init_r * Description: Configure board specific parts @@ -466,6 +498,10 @@ int misc_init_r(void) omap3_dss_enable(); #endif +#ifdef CONFIG_USB_MUSB_OMAP2PLUS + musb_register(musb_plat, musb_board_data, (void *)MUSB_BASE); +#endif + return 0; } @@ -513,3 +549,10 @@ int ehci_hcd_stop(int index) } #endif /* CONFIG_USB_EHCI */ + +#if defined(CONFIG_USB_ETHER) defined(CONFIG_MUSB_GADGET) +int board_eth_init(bd_t *bis) +{ + return usb_eth_initialize(bis); +} +#endif diff --git a/include/configs/omap3_beagle.h b/include/configs/omap3_beagle.h index f79f996..e3ed8ea 100644 --- a/include/configs/omap3_beagle.h +++ b/include/configs/omap3_beagle.h @@ -120,6 +120,8 @@ #define CONFIG_MUSB_UDC1 #define CONFIG_USB_OMAP3 1 #define CONFIG_TWL4030_USB 1 +#define CONFIG_USB_ETHER +#define CONFIG_USB_ETHER_RNDIS /* USB device configuration */ #define CONFIG_USB_DEVICE 1 -- 1.7.10.2 (Apple Git-33) ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v4 11/13] musb-new: omap2plus backend driver
Backend driver for MUSB OTG controllers found on TI OMAP2/3/4 (tested only on OMAP3 Beagle). Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- arch/arm/include/asm/omap_musb.h|4 + drivers/usb/musb-new/Makefile |1 + drivers/usb/musb-new/linux-compat.h |9 + drivers/usb/musb-new/omap2430.c | 626 +++ drivers/usb/musb-new/omap2430.h | 56 include/usb.h |3 +- 6 files changed, 698 insertions(+), 1 deletion(-) create mode 100644 drivers/usb/musb-new/omap2430.c create mode 100644 drivers/usb/musb-new/omap2430.h diff --git a/arch/arm/include/asm/omap_musb.h b/arch/arm/include/asm/omap_musb.h index 46c8578..b04d865 100644 --- a/arch/arm/include/asm/omap_musb.h +++ b/arch/arm/include/asm/omap_musb.h @@ -19,10 +19,14 @@ extern struct musb_platform_ops musb_dsps_ops; extern const struct musb_platform_ops am35x_ops; +extern const struct musb_platform_ops omap2430_ops; struct omap_musb_board_data { + u8 interface_type; void (*set_phy_power)(u8 on); void (*clear_irq)(void); void (*reset)(void); }; + +enum musb_interface{MUSB_INTERFACE_ULPI, MUSB_INTERFACE_UTMI}; #endif /* __ASM_ARM_OMAP_MUSB_H */ diff --git a/drivers/usb/musb-new/Makefile b/drivers/usb/musb-new/Makefile index 23fc735..c23bef1 100644 --- a/drivers/usb/musb-new/Makefile +++ b/drivers/usb/musb-new/Makefile @@ -11,6 +11,7 @@ COBJS-$(CONFIG_MUSB_GADGET) += musb_uboot.o COBJS-$(CONFIG_MUSB_HOST) += musb_host.o musb_core.o musb_uboot.o COBJS-$(CONFIG_USB_MUSB_DSPS) += musb_dsps.o COBJS-$(CONFIG_USB_MUSB_AM35X) += am35x.o +COBJS-$(CONFIG_USB_MUSB_OMAP2PLUS) += omap2430.o CFLAGS_NO_WARN := $(call cc-option,-Wno-unused-variable) \ $(call cc-option,-Wno-unused-but-set-variable) \ diff --git a/drivers/usb/musb-new/linux-compat.h b/drivers/usb/musb-new/linux-compat.h index 61f95f8..7cfcb1a 100644 --- a/drivers/usb/musb-new/linux-compat.h +++ b/drivers/usb/musb-new/linux-compat.h @@ -37,6 +37,7 @@ typedef unsigned long dmaaddr_t; #define spin_unlock_irqrestore(lock, flags) do {} while (0) #define setup_timer(timer, func, data) do {} while (0) +#define del_timer_sync(timer) do {} while (0) #define schedule_work(work) do {} while (0) #define INIT_WORK(work, fun) do {} while (0) @@ -107,4 +108,12 @@ typedef unsigned long dmaaddr_t; #endif #define msleep(a) udelay(a * 1000) + +/* + * Map U-Boot config options to Linux ones + */ +#ifdef CONFIG_OMAP34XX +#define CONFIG_SOC_OMAP3430 +#endif + #endif /* __LINUX_COMPAT_H__ */ diff --git a/drivers/usb/musb-new/omap2430.c b/drivers/usb/musb-new/omap2430.c new file mode 100644 index 000..b1c4dc7 --- /dev/null +++ b/drivers/usb/musb-new/omap2430.c @@ -0,0 +1,626 @@ +/* + * Copyright (C) 2005-2007 by Texas Instruments + * Some code has been taken from tusb6010.c + * Copyrights for that are attributable to: + * Copyright (C) 2006 Nokia Corporation + * Tony Lindgren t...@atomide.com + * + * This file is part of the Inventra Controller Driver for Linux. + * + * The Inventra Controller Driver for Linux is free software; you + * can redistribute it and/or modify it under the terms of the GNU + * General Public License version 2 as published by the Free Software + * Foundation. + * + * The Inventra Controller Driver for Linux 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 The Inventra Controller Driver for Linux ; if not, + * write to the Free Software Foundation, Inc., 59 Temple Place, + * Suite 330, Boston, MA 02111-1307 USA + * + */ +#define __UBOOT__ +#ifndef __UBOOT__ +#include linux/module.h +#include linux/kernel.h +#include linux/sched.h +#include linux/init.h +#include linux/list.h +#include linux/io.h +#include linux/platform_device.h +#include linux/dma-mapping.h +#include linux/pm_runtime.h +#include linux/err.h +#include linux/usb/musb-omap.h +#else +#include common.h +#include asm/omap_musb.h +#include twl4030.h +#include linux-compat.h +#endif + +#include musb_core.h +#include omap2430.h + +#ifndef __UBOOT__ +struct omap2430_glue { + struct device *dev; + struct platform_device *musb; + enum omap_musb_vbus_id_status status; + struct work_struct omap_musb_mailbox_work; +}; +#define glue_to_musb(g)platform_get_drvdata(g-musb) + +struct omap2430_glue *_glue; + +static struct timer_list musb_idle_timer; + +static void musb_do_idle(unsigned long _musb) +{ + struct musb *musb = (void *)_musb; + unsigned long flags; + u8 power; + u8 devctl; + + spin_lock_irqsave(musb-lock, flags); + + switch (musb-xceiv-state) { + case
[U-Boot] [PATCH v4 13/13] omap3_beagle: use new MUSB intstead of the old one
Enable using of new MUSB framework on Beagle. NOTE! This is not just a change of backend code: top-level behavior is also changed, we now use USB device port for USB Ethernet instead of serial. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- include/configs/omap3_beagle.h | 11 --- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/include/configs/omap3_beagle.h b/include/configs/omap3_beagle.h index e3ed8ea..fe67c84 100644 --- a/include/configs/omap3_beagle.h +++ b/include/configs/omap3_beagle.h @@ -117,17 +117,14 @@ #define CONFIG_SYS_I2C_NOPROBES{{0x0, 0x0}} /* USB */ -#define CONFIG_MUSB_UDC1 -#define CONFIG_USB_OMAP3 1 +#define CONFIG_MUSB_GADGET +#define CONFIG_USB_MUSB_OMAP2PLUS +#define CONFIG_MUSB_PIO_ONLY +#define CONFIG_USB_GADGET_DUALSPEED #define CONFIG_TWL4030_USB 1 #define CONFIG_USB_ETHER #define CONFIG_USB_ETHER_RNDIS -/* USB device configuration */ -#define CONFIG_USB_DEVICE 1 -#define CONFIG_USB_TTY 1 -#define CONFIG_SYS_CONSOLE_IS_IN_ENV 1 - /* USB EHCI */ #define CONFIG_CMD_USB #define CONFIG_USB_EHCI -- 1.7.10.2 (Apple Git-33) ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v1 7/8] am33xx_spl_bch: simple SPL nand loader for AM33XX
Hi Tom, On Wed, Oct 31, 2012 at 1:03 AM, Tom Rini tr...@ti.com wrote: + for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) { + this-ecc.hwctl(mtd, NAND_ECC_READ); + nand_command(block, page, data_pos, NAND_CMD_RNDOUT); + + this-read_buf(mtd, p, eccsize); + + nand_command(block, page, oob_pos, NAND_CMD_RNDOUT); + + this-read_buf(mtd, oob, eccbytes); + this-ecc.calculate(mtd, p, ecc_calc[i]); + + data_pos += eccsize; +oob_pos += eccbytes; + oob += eccbytes; + } This is where the function differs. If we can't merge things together, I'd like to see about putting just this function into nand_spl_simple.c under CONFIG_SYS_NAND_HW_BCH8 since if I follow what's going on, and I need to play with the code to confirm I do, it's a generic change related to how much more we're reading back out Not exactly. This change is rather GPMC-specific: we have to read data block then it's ecc code to get the syndrome. And even with GPMC in another configuration we will need another reading order... I'm not sure if we can do this in some generic way... Regards, Ilya. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v1 0/8] NAND support for AM33XX
These series add support for NAND on AM33XX. AM33XX has the same GPMC controller as OMAP3 so the first part of the series just add required defines/initialization to enable the existing omap_gpmc driver to work on AM33XX. The rest of the series adds support for BCH8 error correction code. We use GPMC to generate codes/syndromes and ELM to find the errors. Ilya Yanok (6): OMAP: include sys_proto.h from boot-common am335x_evm: add nand pinmux definition am33xx: NAND support am335x_evm: enable NAND support am33xx_spl_bch: simple SPL nand loader for AM33XX am335x_evm: enable SPL NAND support Mansoor Ahamed (2): am33xx: add ELM support omap_gpmc: BCH8 support (ELM based) arch/arm/cpu/armv7/am33xx/Makefile |2 + arch/arm/cpu/armv7/am33xx/board.c| 36 +++ arch/arm/cpu/armv7/am33xx/clock.c| 10 + arch/arm/cpu/armv7/am33xx/elm.c | 213 ++ arch/arm/cpu/armv7/am33xx/mem.c | 104 +++ arch/arm/cpu/armv7/omap-common/boot-common.c |1 + arch/arm/include/asm/arch-am33xx/cpu.h | 53 arch/arm/include/asm/arch-am33xx/elm.h | 93 ++ arch/arm/include/asm/arch-am33xx/hardware.h |3 + arch/arm/include/asm/arch-am33xx/mem.h | 174 +++ arch/arm/include/asm/arch-am33xx/omap_gpmc.h | 130 + arch/arm/include/asm/arch-am33xx/sys_proto.h |3 + board/ti/am335x/mux.c| 26 ++ drivers/mtd/nand/Makefile|1 + drivers/mtd/nand/am335x_spl_bch.c| 238 +++ drivers/mtd/nand/omap_gpmc.c | 403 +- include/configs/am335x_evm.h | 49 17 files changed, 1538 insertions(+), 1 deletion(-) create mode 100644 arch/arm/cpu/armv7/am33xx/elm.c create mode 100644 arch/arm/cpu/armv7/am33xx/mem.c create mode 100644 arch/arm/include/asm/arch-am33xx/elm.h create mode 100644 arch/arm/include/asm/arch-am33xx/mem.h create mode 100644 arch/arm/include/asm/arch-am33xx/omap_gpmc.h create mode 100644 drivers/mtd/nand/am335x_spl_bch.c -- 1.7.10.2 (Apple Git-33) ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v1 1/8] OMAP: include sys_proto.h from boot-common
Include asm/arch/sys_proto.h for gpmc_init prototype. Without this we get a warning while building for AM335x. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- arch/arm/cpu/armv7/omap-common/boot-common.c |1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/cpu/armv7/omap-common/boot-common.c b/arch/arm/cpu/armv7/omap-common/boot-common.c index 0f19141..2b584e0 100644 --- a/arch/arm/cpu/armv7/omap-common/boot-common.c +++ b/arch/arm/cpu/armv7/omap-common/boot-common.c @@ -21,6 +21,7 @@ #include asm/omap_common.h #include asm/arch/omap.h #include asm/arch/mmc_host_def.h +#include asm/arch/sys_proto.h /* * This is used to verify if the configuration header -- 1.7.10.2 (Apple Git-33) ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v1 2/8] am335x_evm: add nand pinmux definition
Add NAND pins mux settings for AM335X devices. Enable NAND pins for AM335X EVM board. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- board/ti/am335x/mux.c | 26 ++ 1 file changed, 26 insertions(+) diff --git a/board/ti/am335x/mux.c b/board/ti/am335x/mux.c index 80becd5..a46c680 100644 --- a/board/ti/am335x/mux.c +++ b/board/ti/am335x/mux.c @@ -362,6 +362,27 @@ static struct module_pin_mux mii1_pin_mux[] = { {-1}, }; +#ifdef CONFIG_NAND_OMAP_GPMC +static struct module_pin_mux nand_pin_mux[] = { + {OFFSET(gpmc_ad0), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD0 */ + {OFFSET(gpmc_ad1), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD1 */ + {OFFSET(gpmc_ad2), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD2 */ + {OFFSET(gpmc_ad3), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD3 */ + {OFFSET(gpmc_ad4), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD4 */ + {OFFSET(gpmc_ad5), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD5 */ + {OFFSET(gpmc_ad6), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD6 */ + {OFFSET(gpmc_ad7), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD7 */ + {OFFSET(gpmc_wait0), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* NAND WAIT */ + {OFFSET(gpmc_wpn), (MODE(7) | PULLUP_EN | RXACTIVE)}, /* NAND_WPN */ + {OFFSET(gpmc_csn0), (MODE(0) | PULLUDEN)}, /* NAND_CS0 */ + {OFFSET(gpmc_advn_ale), (MODE(0) | PULLUDEN)}, /* NAND_ADV_ALE */ + {OFFSET(gpmc_oen_ren), (MODE(0) | PULLUDEN)}, /* NAND_OE */ + {OFFSET(gpmc_wen), (MODE(0) | PULLUDEN)}, /* NAND_WEN */ + {OFFSET(gpmc_be0n_cle), (MODE(0) | PULLUDEN)}, /* NAND_BE_CLE */ + {-1}, +}; +#endif + /* * Configure the pin mux for the module */ @@ -435,11 +456,16 @@ void enable_board_pin_mux(struct am335x_baseboard_id *header) unsigned short profile = detect_daughter_board_profile(); configure_module_pin_mux(rgmii1_pin_mux); configure_module_pin_mux(mmc0_pin_mux); +#ifdef CONFIG_NAND_OMAP_GPMC + configure_module_pin_mux(nand_pin_mux); +#endif /* In profile #2 i2c1 and spi0 conflict. */ if (profile ~PROFILE_2) configure_module_pin_mux(i2c1_pin_mux); else if (profile == PROFILE_2) { +#ifndef CONFIG_NAND_OMAP_GPMC configure_module_pin_mux(mmc1_pin_mux); +#endif configure_module_pin_mux(spi0_pin_mux); } } else if (!strncmp(header-name, A335X_SK, HDR_NAME_LEN)) { -- 1.7.10.2 (Apple Git-33) ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v1 3/8] am33xx: NAND support
TI AM33XX has the same GPMC controller as OMAP3 so we could just use the existing omap_gpmc driver. This patch adds adds required definitions/intialization. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- arch/arm/cpu/armv7/am33xx/Makefile |1 + arch/arm/cpu/armv7/am33xx/board.c| 34 + arch/arm/cpu/armv7/am33xx/clock.c|5 + arch/arm/cpu/armv7/am33xx/mem.c | 104 +++ arch/arm/include/asm/arch-am33xx/cpu.h | 53 arch/arm/include/asm/arch-am33xx/hardware.h |3 + arch/arm/include/asm/arch-am33xx/mem.h | 174 ++ arch/arm/include/asm/arch-am33xx/omap_gpmc.h | 130 +++ arch/arm/include/asm/arch-am33xx/sys_proto.h |3 + 9 files changed, 507 insertions(+) create mode 100644 arch/arm/cpu/armv7/am33xx/mem.c create mode 100644 arch/arm/include/asm/arch-am33xx/mem.h create mode 100644 arch/arm/include/asm/arch-am33xx/omap_gpmc.h diff --git a/arch/arm/cpu/armv7/am33xx/Makefile b/arch/arm/cpu/armv7/am33xx/Makefile index 7768912..c93ac19 100644 --- a/arch/arm/cpu/armv7/am33xx/Makefile +++ b/arch/arm/cpu/armv7/am33xx/Makefile @@ -18,6 +18,7 @@ LIB = $(obj)lib$(SOC).o COBJS += clock.o COBJS += sys_info.o +COBJS += mem.o COBJS += ddr.o COBJS += emif4.o COBJS += board.o diff --git a/arch/arm/cpu/armv7/am33xx/board.c b/arch/arm/cpu/armv7/am33xx/board.c index 978b184..71f66ef 100644 --- a/arch/arm/cpu/armv7/am33xx/board.c +++ b/arch/arm/cpu/armv7/am33xx/board.c @@ -25,6 +25,7 @@ #include asm/arch/ddr_defs.h #include asm/arch/clock.h #include asm/arch/gpio.h +#include asm/arch/mem.h #include asm/arch/mmc_host_def.h #include asm/arch/sys_proto.h #include asm/io.h @@ -220,6 +221,8 @@ int board_init(void) gd-bd-bi_boot_params = PHYS_DRAM_1 + 0x100; + gpmc_init(); + return 0; } @@ -298,3 +301,34 @@ int board_eth_init(bd_t *bis) return cpsw_register(cpsw_data); } #endif + +#if defined(CONFIG_NAND_OMAP_GPMC) !defined(CONFIG_SPL_BUILD) +/** + * AM33xx specific command to switch between NAND HW and SW ecc + */ +static int +do_switch_ecc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + if (argc != 2) + goto usage; + if (strncmp(argv[1], hw, 2) == 0) + omap_nand_switch_ecc(1); + else if (strncmp(argv[1], sw, 2) == 0) + omap_nand_switch_ecc(0); + else + goto usage; + + return 0; + +usage: + printf(Usage: nandecc %s\n, cmdtp-usage); + return 1; +} + +U_BOOT_CMD( + nandecc, 2, 1, do_switch_ecc, + switch OMAP3 NAND ECC calculation algorithm, + [bch8/hw/sw] - Switch between NAND hardware (hw) or software (sw) ecc algorithm +); + +#endif /* CONFIG_NAND_OMAP_GPMC !CONFIG_SPL_BUILD */ diff --git a/arch/arm/cpu/armv7/am33xx/clock.c b/arch/arm/cpu/armv7/am33xx/clock.c index 2b19506..75ec860 100644 --- a/arch/arm/cpu/armv7/am33xx/clock.c +++ b/arch/arm/cpu/armv7/am33xx/clock.c @@ -114,6 +114,11 @@ static void enable_per_clocks(void) while (readl(cmwkup-wkup_uart0ctrl) != PRCM_MOD_EN) ; + /* GPMC */ + writel(PRCM_MOD_EN, cmper-gpmcclkctrl); + while (readl(cmper-gpmcclkctrl) != PRCM_MOD_EN) + ; + /* MMC0*/ writel(PRCM_MOD_EN, cmper-mmc0clkctrl); while (readl(cmper-mmc0clkctrl) != PRCM_MOD_EN) diff --git a/arch/arm/cpu/armv7/am33xx/mem.c b/arch/arm/cpu/armv7/am33xx/mem.c new file mode 100644 index 000..e7f1cf7 --- /dev/null +++ b/arch/arm/cpu/armv7/am33xx/mem.c @@ -0,0 +1,104 @@ +/* + * (C) Copyright 2010 + * Texas Instruments, www.ti.com + * + * Author : + * Mansoor Ahamed mansoor.aha...@ti.com + * + * Initial Code from: + * Manikandan Pillai mani.pil...@ti.com + * Richard Woodruff r-woodru...@ti.com + * Syed Mohammed Khasim kha...@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 + */ + +#include common.h +#include asm/io.h +#include asm/arch/cpu.h +#include asm/arch/mem.h +#include asm/arch/sys_proto.h +#include command.h + +struct gpmc *gpmc_cfg; + +#if defined
[U-Boot] [PATCH v1 4/8] am335x_evm: enable NAND support
Enable NAND support for AM335X boards. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- include/configs/am335x_evm.h | 15 +++ 1 file changed, 15 insertions(+) diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h index 339d4bd..a89cdcd 100644 --- a/include/configs/am335x_evm.h +++ b/include/configs/am335x_evm.h @@ -254,4 +254,19 @@ #define CONFIG_PHYLIB #define CONFIG_PHY_SMSC +#define CONFIG_NAND +/* NAND support */ +#ifdef CONFIG_NAND +#define CONFIG_CMD_NAND +#define CONFIG_NAND_OMAP_GPMC +#define GPMC_NAND_ECC_LP_x16_LAYOUT1 +#define NAND_BASE (0x0800) +#define CONFIG_SYS_NAND_ADDR NAND_BASE /* physical address */ + /* to access nand */ +#define CONFIG_SYS_NAND_BASE NAND_BASE /* physical address */ + /* to access nand at */ + /* CS0 */ +#define CONFIG_SYS_MAX_NAND_DEVICE 1 /* Max number of NAND */ +#endif /* devices */ + #endif /* ! __CONFIG_AM335X_EVM_H */ -- 1.7.10.2 (Apple Git-33) ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v1 5/8] am33xx: add ELM support
From: Mansoor Ahamed mansoor.aha...@ti.com AM33XX has Error Location Module (ELM) that can be used in conjuction with GPMC controller to implement BCH codes fully in hardware. This code is mostly taken from arago tree. Signed-off-by: Mansoor Ahamed mansoor.aha...@ti.com Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- arch/arm/cpu/armv7/am33xx/Makefile |1 + arch/arm/cpu/armv7/am33xx/clock.c |5 + arch/arm/cpu/armv7/am33xx/elm.c| 213 arch/arm/include/asm/arch-am33xx/elm.h | 93 ++ 4 files changed, 312 insertions(+) create mode 100644 arch/arm/cpu/armv7/am33xx/elm.c create mode 100644 arch/arm/include/asm/arch-am33xx/elm.h diff --git a/arch/arm/cpu/armv7/am33xx/Makefile b/arch/arm/cpu/armv7/am33xx/Makefile index c93ac19..96d7304 100644 --- a/arch/arm/cpu/armv7/am33xx/Makefile +++ b/arch/arm/cpu/armv7/am33xx/Makefile @@ -22,6 +22,7 @@ COBJS += mem.o COBJS += ddr.o COBJS += emif4.o COBJS += board.o +COBJS-${CONFIG_NAND_OMAP_GPMC} += elm.o SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS) $(COBJS-y) $(SOBJS)) diff --git a/arch/arm/cpu/armv7/am33xx/clock.c b/arch/arm/cpu/armv7/am33xx/clock.c index 75ec860..ec46f0b 100644 --- a/arch/arm/cpu/armv7/am33xx/clock.c +++ b/arch/arm/cpu/armv7/am33xx/clock.c @@ -119,6 +119,11 @@ static void enable_per_clocks(void) while (readl(cmper-gpmcclkctrl) != PRCM_MOD_EN) ; + /* ELM */ + writel(PRCM_MOD_EN, cmper-elmclkctrl); + while (readl(cmper-elmclkctrl) != PRCM_MOD_EN) + ; + /* MMC0*/ writel(PRCM_MOD_EN, cmper-mmc0clkctrl); while (readl(cmper-mmc0clkctrl) != PRCM_MOD_EN) diff --git a/arch/arm/cpu/armv7/am33xx/elm.c b/arch/arm/cpu/armv7/am33xx/elm.c new file mode 100644 index 000..9586553 --- /dev/null +++ b/arch/arm/cpu/armv7/am33xx/elm.c @@ -0,0 +1,213 @@ +/* + * (C) Copyright 2010-2011 Texas Instruments, www.ti.com + * Mansoor Ahamed mansoor.aha...@ti.com + * + * BCH Error Location Module (ELM) support. + * + * NOTE: + * 1. Supports only continuous mode. Dont see need for page mode in uboot + * 2. Supports only syndrome polynomial 0. i.e. poly local variable is + *always set to ELM_DEFAULT_POLY. Dont see need for other polynomial + *sets in uboot + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include common.h +#include asm/io.h +#include asm/errno.h +#include asm/arch/cpu.h +#include asm/arch/omap_gpmc.h +#include asm/arch/elm.h + +#define ELM_DEFAULT_POLY (0) + +struct elm *elm_cfg; + +/** + * elm_load_syndromes - Load BCH syndromes based on nibble selection + * @syndrome: BCH syndrome + * @nibbles: + * @poly: Syndrome Polynomial set to use + * + * Load BCH syndromes based on nibble selection + */ +static void elm_load_syndromes(u8 *syndrome, u32 nibbles, u8 poly) +{ + u32 *ptr; + u32 val; + + /* reg 0 */ + ptr = elm_cfg-syndrome_fragments[poly].syndrome_fragment_x[0]; + val = syndrome[0] | (syndrome[1] 8) | (syndrome[2] 16) | + (syndrome[3] 24); + writel(val, ptr); + /* reg 1 */ + ptr = elm_cfg-syndrome_fragments[poly].syndrome_fragment_x[1]; + val = syndrome[4] | (syndrome[5] 8) | (syndrome[6] 16) | + (syndrome[7] 24); + writel(val, ptr); + + /* BCH 8-bit with 26 nibbles (4*8=32) */ + if (nibbles 13) { + /* reg 2 */ + ptr = elm_cfg-syndrome_fragments[poly].syndrome_fragment_x[2]; + val = syndrome[8] | (syndrome[9] 8) | (syndrome[10] 16) | + (syndrome[11] 24); + writel(val, ptr); + /* reg 3 */ + ptr = elm_cfg-syndrome_fragments[poly].syndrome_fragment_x[3]; + val = syndrome[12] | (syndrome[13] 8) | + (syndrome[14] 16) | (syndrome[15] 24); + writel(val, ptr); + } + + /* BCH 16-bit with 52 nibbles (7*8=56) */ + if (nibbles 26) { + /* reg 4 */ + ptr = elm_cfg-syndrome_fragments[poly].syndrome_fragment_x[4]; + val = syndrome[16
[U-Boot] [PATCH v1 7/8] am33xx_spl_bch: simple SPL nand loader for AM33XX
AM33XX with BCH8 can't work with nand_spl_simple correctly because custom read_page implementation is required for proper syndrome generation. This simple driver mostly duplicates nand_spl_simple but has nand_read_page changed to suit our needs. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- drivers/mtd/nand/Makefile |1 + drivers/mtd/nand/am335x_spl_bch.c | 238 + 2 files changed, 239 insertions(+) create mode 100644 drivers/mtd/nand/am335x_spl_bch.c diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile index beb99ca..5322f3a 100644 --- a/drivers/mtd/nand/Makefile +++ b/drivers/mtd/nand/Makefile @@ -30,6 +30,7 @@ ifdef CONFIG_SPL_BUILD ifdef CONFIG_SPL_NAND_SIMPLE COBJS-y += nand_spl_simple.o endif +COBJS-$(CONFIG_SPL_NAND_AM33XX_BCH) += am335x_spl_bch.o ifdef CONFIG_SPL_NAND_LOAD COBJS-y+= nand_spl_load.o endif diff --git a/drivers/mtd/nand/am335x_spl_bch.c b/drivers/mtd/nand/am335x_spl_bch.c new file mode 100644 index 000..b84528b --- /dev/null +++ b/drivers/mtd/nand/am335x_spl_bch.c @@ -0,0 +1,238 @@ +/* + * (C) Copyright 2012 + * Konstantin Kozhevnikov, Cogent Embedded + * + * based on nand_spl_simple code + * + * (C) Copyright 2006-2008 + * Stefan Roese, DENX Software Engineering, s...@denx.de. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc. + */ + +#include common.h +#include nand.h +#include asm/io.h +#include linux/mtd/nand_ecc.h + +static int nand_ecc_pos[] = CONFIG_SYS_NAND_ECCPOS; +static nand_info_t mtd; +static struct nand_chip nand_chip; + +#define ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ + CONFIG_SYS_NAND_ECCSIZE) +#define ECCTOTAL (ECCSTEPS * CONFIG_SYS_NAND_ECCBYTES) + + +/* + * NAND command for large page NAND devices (2k) + */ +static int nand_command(int block, int page, uint32_t offs, + u8 cmd) +{ + struct nand_chip *this = mtd.priv; + int page_addr = page + block * CONFIG_SYS_NAND_PAGE_COUNT; + void (*hwctrl)(struct mtd_info *mtd, int cmd, + unsigned int ctrl) = this-cmd_ctrl; + + while (!this-dev_ready(mtd)) + ; + + /* Emulate NAND_CMD_READOOB */ + if (cmd == NAND_CMD_READOOB) { + offs += CONFIG_SYS_NAND_PAGE_SIZE; + cmd = NAND_CMD_READ0; + } + + /* Begin command latch cycle */ + hwctrl(mtd, cmd, NAND_CTRL_CLE | NAND_CTRL_CHANGE); + + if (cmd == NAND_CMD_RESET) { + hwctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); + while (!this-dev_ready(mtd)) + ; + return 0; + } + + /* Shift the offset from byte addressing to word addressing. */ + if (this-options NAND_BUSWIDTH_16) + offs = 1; + + /* Set ALE and clear CLE to start address cycle */ + /* Column address */ + hwctrl(mtd, offs 0xff, + NAND_CTRL_ALE | NAND_CTRL_CHANGE); /* A[7:0] */ + hwctrl(mtd, (offs 8) 0xff, NAND_CTRL_ALE); /* A[11:9] */ + /* Row address */ + hwctrl(mtd, (page_addr 0xff), NAND_CTRL_ALE); /* A[19:12] */ + hwctrl(mtd, ((page_addr 8) 0xff), + NAND_CTRL_ALE); /* A[27:20] */ +#ifdef CONFIG_SYS_NAND_5_ADDR_CYCLE + /* One more address cycle for devices 128MiB */ + hwctrl(mtd, (page_addr 16) 0x0f, + NAND_CTRL_ALE); /* A[31:28] */ +#endif + hwctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); + + if (cmd == NAND_CMD_READ0) { + /* Latch in address */ + hwctrl(mtd, NAND_CMD_READSTART, + NAND_CTRL_CLE | NAND_CTRL_CHANGE); + hwctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); + + /* +* Wait a while for the data to be ready +*/ + while (!this-dev_ready(mtd)) + ; + } else if (cmd == NAND_CMD_RNDOUT) { + hwctrl(mtd, NAND_CMD_RNDOUTSTART, NAND_CTRL_CLE | + NAND_CTRL_CHANGE); + hwctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); + } + + return 0; +} + +static int nand_is_bad_block(int block) +{ + struct nand_chip *this = mtd.priv; + + nand_command(block, 0
[U-Boot] [PATCH v1 8/8] am335x_evm: enable SPL NAND support
Enable booting from NAND support from AM335x boards as well as environment in NAND. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- include/configs/am335x_evm.h | 38 -- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h index a89cdcd..67e99aa 100644 --- a/include/configs/am335x_evm.h +++ b/include/configs/am335x_evm.h @@ -220,6 +220,35 @@ #define CONFIG_SPL_ETH_SUPPORT #define CONFIG_SPL_LDSCRIPT$(CPUDIR)/omap-common/u-boot-spl.lds +#define CONFIG_SPL_BOARD_INIT +#define CONFIG_SPL_NAND_AM33XX_BCH +#define CONFIG_SPL_NAND_SUPPORT +#define CONFIG_SYS_NAND_5_ADDR_CYCLE +#define CONFIG_SYS_NAND_PAGE_COUNT (CONFIG_SYS_NAND_BLOCK_SIZE / \ +CONFIG_SYS_NAND_PAGE_SIZE) +#define CONFIG_SYS_NAND_PAGE_SIZE 2048 +#define CONFIG_SYS_NAND_OOBSIZE64 +#define CONFIG_SYS_NAND_BLOCK_SIZE (128*1024) +#define CONFIG_SYS_NAND_BAD_BLOCK_POS NAND_LARGE_BADBLOCK_POS +#define CONFIG_SYS_NAND_ECCPOS { 2, 3, 4, 5, 6, 7, 8, 9, \ +10, 11, 12, 13, 14, 15, 16, 17, \ +18, 19, 20, 21, 22, 23, 24, 25, \ +26, 27, 28, 29, 30, 31, 32, 33, \ +34, 35, 36, 37, 38, 39, 40, 41, \ +42, 43, 44, 45, 46, 47, 48, 49, \ +50, 51, 52, 53, 54, 55, 56, 57, } + +#define CONFIG_SYS_NAND_ECCSIZE512 +#define CONFIG_SYS_NAND_ECCBYTES 14 + +#define CONFIG_SYS_NAND_ECCSTEPS 4 +#defineCONFIG_SYS_NAND_ECCTOTAL(CONFIG_SYS_NAND_ECCBYTES * \ + CONFIG_SYS_NAND_ECCSTEPS) + +#defineCONFIG_SYS_NAND_U_BOOT_STARTCONFIG_SYS_TEXT_BASE + +#define CONFIG_SYS_NAND_U_BOOT_OFFS0x8 + /* * 1MB into the SDRAM to allow for SPL's bss at the beginning of SDRAM * 64 bytes before this address should be set aside for u-boot.img's @@ -266,7 +295,12 @@ #define CONFIG_SYS_NAND_BASE NAND_BASE /* physical address */ /* to access nand at */ /* CS0 */ -#define CONFIG_SYS_MAX_NAND_DEVICE 1 /* Max number of NAND */ -#endif /* devices */ +#define CONFIG_SYS_MAX_NAND_DEVICE 1 /* Max number of NAND + devices */ +#undef CONFIG_ENV_IS_NOWHERE +#define CONFIG_ENV_IS_IN_NAND +#define CONFIG_ENV_OFFSET 0x26 /* environment starts here */ +#define CONFIG_SYS_ENV_SECT_SIZE (128 10) /* 128 KiB */ +#endif #endif /* ! __CONFIG_AM335X_EVM_H */ -- 1.7.10.2 (Apple Git-33) ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v1 6/8] omap_gpmc: BCH8 support (ELM based)
From: Mansoor Ahamed mansoor.aha...@ti.com This patch adds support for BCH8 error correction code to omap_gpmc driver. We use GPMC to generate codes/syndromes but we need ELM to find error locations from given syndrome. Signed-off-by: Mansoor Ahamed mansoor.aha...@ti.com [ilya: merge it with omap_gpmc driver, some fixes and cleanup] Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- arch/arm/cpu/armv7/am33xx/board.c |4 +- drivers/mtd/nand/omap_gpmc.c | 403 - 2 files changed, 405 insertions(+), 2 deletions(-) diff --git a/arch/arm/cpu/armv7/am33xx/board.c b/arch/arm/cpu/armv7/am33xx/board.c index 71f66ef..eed0c0a 100644 --- a/arch/arm/cpu/armv7/am33xx/board.c +++ b/arch/arm/cpu/armv7/am33xx/board.c @@ -311,7 +311,9 @@ do_switch_ecc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { if (argc != 2) goto usage; - if (strncmp(argv[1], hw, 2) == 0) + if (strncmp(argv[1], bch8, 4) == 0) + omap_nand_switch_ecc(2); + else if (strncmp(argv[1], hw, 2) == 0) omap_nand_switch_ecc(1); else if (strncmp(argv[1], sw, 2) == 0) omap_nand_switch_ecc(0); diff --git a/drivers/mtd/nand/omap_gpmc.c b/drivers/mtd/nand/omap_gpmc.c index f1469d1..cee394e 100644 --- a/drivers/mtd/nand/omap_gpmc.c +++ b/drivers/mtd/nand/omap_gpmc.c @@ -29,6 +29,9 @@ #include linux/mtd/nand_ecc.h #include linux/compiler.h #include nand.h +#ifdef CONFIG_AM33XX +#include asm/arch/elm.h +#endif static uint8_t cs; static __maybe_unused struct nand_ecclayout hw_nand_oob = @@ -234,6 +237,370 @@ static void __maybe_unused omap_enable_hwecc(struct mtd_info *mtd, int32_t mode) } } +/* + * BCH8 support (needs ELM and thus AM33xx-only) + */ +#ifdef CONFIG_AM33XX +struct nand_bch_priv { + uint8_t mode; + uint8_t type; + uint8_t nibbles; +}; + +/* bch types */ +#define ECC_BCH4 0 +#define ECC_BCH8 1 +#define ECC_BCH16 2 + +/* BCH nibbles for diff bch levels */ +#define NAND_ECC_HW_BCH ((uint8_t)(NAND_ECC_HW_OOB_FIRST) + 1) +#define ECC_BCH4_NIBBLES 13 +#define ECC_BCH8_NIBBLES 26 +#define ECC_BCH16_NIBBLES 52 + +static struct nand_ecclayout hw_bch8_nand_oob = GPMC_NAND_HW_BCH8_ECC_LAYOUT; + +static struct nand_bch_priv bch_priv = { + .mode = NAND_ECC_HW_BCH, + .type = ECC_BCH8, + .nibbles = ECC_BCH8_NIBBLES +}; + +/* + * omap_read_bch8_result - Read BCH result for BCH8 level + * + * @mtd: MTD device structure + * @big_endian:When set read register 3 first + * @ecc_code: Read syndrome from BCH result registers + */ +static void omap_read_bch8_result(struct mtd_info *mtd, uint8_t big_endian, + uint8_t *ecc_code) +{ + uint32_t *ptr; + int8_t i = 0, j; + + if (big_endian) { + ptr = gpmc_cfg-bch_result_0_3[0].bch_result_x[3]; + ecc_code[i++] = readl(ptr) 0xFF; + ptr--; + for (j = 0; j 3; j++) { + ecc_code[i++] = (readl(ptr) 24) 0xFF; + ecc_code[i++] = (readl(ptr) 16) 0xFF; + ecc_code[i++] = (readl(ptr) 8) 0xFF; + ecc_code[i++] = readl(ptr) 0xFF; + ptr--; + } + } else { + ptr = gpmc_cfg-bch_result_0_3[0].bch_result_x[0]; + for (j = 0; j 3; j++) { + ecc_code[i++] = readl(ptr) 0xFF; + ecc_code[i++] = (readl(ptr) 8) 0xFF; + ecc_code[i++] = (readl(ptr) 16) 0xFF; + ecc_code[i++] = (readl(ptr) 24) 0xFF; + ptr++; + } + ecc_code[i++] = readl(ptr) 0xFF; + ecc_code[i++] = 0; /* 14th byte is always zero */ + } +} + +/* + * omap_ecc_disable - Disable H/W ECC calculation + * + * @mtd: MTD device structure + * + */ +static void omap_ecc_disable(struct mtd_info *mtd) +{ + writel((readl(gpmc_cfg-ecc_config) ~0x1), + gpmc_cfg-ecc_config); +} + +/* + * omap_rotate_ecc_bch - Rotate the syndrome bytes + * + * @mtd: MTD device structure + * @calc_ecc: ECC read from ECC registers + * @syndrome: Rotated syndrome will be retuned in this array + * + */ +static void omap_rotate_ecc_bch(struct mtd_info *mtd, uint8_t *calc_ecc, + uint8_t *syndrome) +{ + struct nand_chip *chip = mtd-priv; + struct nand_bch_priv *bch = chip-priv; + uint8_t n_bytes = 0; + int8_t i, j; + + switch (bch-type) { + case ECC_BCH4: + n_bytes = 8; + break; + + case ECC_BCH16: + n_bytes = 28; + break; + + case ECC_BCH8: + default: + n_bytes = 13; + break; + } + + for (i = 0, j = (n_bytes-1); i n_bytes; i++, j
Re: [U-Boot] [RFC PATCH v3 13/13] omap3_beagle: use new MUSB intstead of the old one
Dear Marek, On Tue, Oct 23, 2012 at 11:20 AM, Marek Vasut ma...@denx.de wrote: Signed-off-by: Ilya Yanok ya...@cogentembedded.com Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com Double SoB line Yeah, it's a mess with SoBs, I'm sorry. I think it's not only this patch but others too... Regards, Ilya. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [RFC PATCH v3 0/13] Port of MUSB driver from Linux (changes from Linux)
Hi Tom, On Tue, Oct 23, 2012 at 1:45 AM, Tom Rini tr...@ti.com wrote: This is not a replacement for existing MUSB driver (at least for now), cause there are still consumers of USB serial gadget which uses old API and there is no support for serial with new API for now. I'm a little lost. In the kernel, you can't use CONFIG_USB_G_SERIAL with CONFIG_USB_MUSB_${hw glue} ? You can. But we don't have g_serial in U-Boot yet. In general, things look OK but please run it through checkpatch.pl, use just one Signed-off-by line and fixup if (...) { ... one line ... } in the glue code you add that's not synced up from the kernel (I saw one in the am335x bits). Thanks! And lets move this out of RFC... Ok. Regards, Ilya. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [RFC PATCH v3 0/13] Port of MUSB driver from Linux (changes from Linux)
Hi Tom, On Wed, Oct 24, 2012 at 4:24 PM, Tom Rini tr...@ti.com wrote: I'm a little lost. In the kernel, you can't use CONFIG_USB_G_SERIAL with CONFIG_USB_MUSB_${hw glue} ? You can. But we don't have g_serial in U-Boot yet. So we would need to port that, in order to remove the serial gadget we have, and drop the previous musb core? Yes, we need to port g_serial, but removing the old usbtty driver is probably too harsh: this will render a bunch of old udc driver (not only old MUSB code) not useful for anything. Regards, Ilya. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [RFC PATCH v3 0/13] Port of MUSB driver from Linux (changes from Linux)
Current MUSB driver in U-Boot uses old UDC API while new gagdet client drivers need new gadget API. Also current MUSB driver has some significant limitations (like inability to handle tx for endpoints other than ep0). So I think port of new Linux driver is desirable. This is initial port, performed mostly by putting DM and OTG code under #ifndef __UBOOT__ clauses. My intention was to be as close as possible to the original to ease of possible resyncs. Some warnings are suppressed via CFLAGS. There are some style problems but I'm not touching them for now for the above mentioned reason. There is obviously some room for optimisation, some structure fields are unused as well as (probably) some code. This is not a replacement for existing MUSB driver (at least for now), cause there are still consumers of USB serial gadget which uses old API and there is no support for serial with new API for now. OTG and DMA are not supported. Ported drivers include: musb_dsps (should work both with TI AM33xx and TI81xx, tested only on AM33xx), am35x (tested on AM3517 EVM) and omap2plus (should work on OMAP2/3/4, tested on omap3_beagle, omap4_panda doesn't work and needs more work). Others should be easy to port too. Virtual root hub is not implemented but this shouldn't be a big problem as the old code has virtual root hub support enabled only for Blackfin platform. Pathes are rather big because of the original code size (and I didn't delete unused code, just disabled it). So it's probably better to look at changes as compared to Linux code. I prepared such version also, you can find it at [1]. Hopefully it will be also useful if resync with the kernel will be needed in future. [1] https://github.com/yanok/u-boot/tree/musb-changes-from-linux-v3 Changes in v3: - fix old MUSB code compilation - bugfix: struct musb should be zeroed after alloc - fix musb gadget_chips entry - fix for new multi-interface usb API - use clrsetbits_le32 for USB PHY ops Changes in v2: - add missing linux-compat.h header - added host support - glue code moved from musb_gadget_uboot.c to musb_uboot.c and cleaned up slightly. - added check for malloc return value - define is_{host,peripheral}_capable conditionally to support compilation with only host or gadget enabled - added some more is_{host,peripheral}_capable guards to core code to support compilation with only host or gadget enabled - rename backend config option to CONFIG_USB_MUSB_DSPS - we are providing host support now so add yourself to usb.h Ilya Yanok (13): linux/usb/ch9.h: update with the version from Linux tree usb: use linux/usb/ch9.h instead of usbdescriptors.h musb-new: port of Linux musb driver musb-new: dsps backend driver am33xx: init OTG hardware and new musb gadget driver am335x_evm: enable both musb gadget and host musb-new: am35x backend driver OMAP3: am35x_def.h: add USB defines OMAP3: am35x: add musb functions am3517_evm: switch to musb-new musb-new: omap2plus backend driver omap3_beagle: add musb-new init omap3_beagle: use new MUSB intstead of the old one Makefile |1 + arch/arm/cpu/arm920t/s3c24x0/usb_ohci.c |2 +- arch/arm/cpu/armv7/am33xx/board.c | 103 +- arch/arm/cpu/armv7/am33xx/clock.c |8 + arch/arm/cpu/armv7/omap3/Makefile |1 + arch/arm/cpu/armv7/omap3/am35x_musb.c | 75 + arch/arm/include/asm/arch-am33xx/cpu.h| 11 +- arch/arm/include/asm/arch-am33xx/hardware.h |4 + arch/arm/include/asm/arch-omap3/am35x_def.h | 27 + arch/arm/include/asm/arch-omap3/musb.h| 28 + arch/arm/include/asm/omap_musb.h | 32 + arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c |2 +- arch/powerpc/cpu/mpc5xxx/usb_ohci.c |2 +- arch/powerpc/cpu/ppc4xx/usb_ohci.c|2 +- board/logicpd/am3517evm/am3517evm.c | 74 + board/ti/beagle/beagle.c | 43 + common/cmd_usb.c |2 +- common/usb.c |4 +- drivers/usb/gadget/config.c |1 - drivers/usb/gadget/epautoconf.c |1 - drivers/usb/gadget/ether.c|1 - drivers/usb/gadget/gadget_chips.h |4 +- drivers/usb/gadget/s3c_udc_otg.c |1 - drivers/usb/gadget/usbstring.c|1 - drivers/usb/host/ehci-hcd.c | 16 +- drivers/usb/host/isp116x-hcd.c|2 +- drivers/usb/host/ohci-hcd.c |2 +- drivers/usb/host/sl811-hcd.c |2 +- drivers/usb/musb-new/Makefile | 39 + drivers/usb/musb-new/am35x.c | 709 +++ drivers/usb/musb-new/linux-compat.h | 119 ++ drivers/usb/musb-new/musb_core.c | 2497 + drivers/usb/musb-new/musb_core.h | 623
[U-Boot] [RFC PATCH v3 02/13] usb: use linux/usb/ch9.h instead of usbdescriptors.h
Linux usb/ch9.h seems to have all the same information (and more) as usbdescriptors.h so use the former instead of the later one. As a consequense of this change USB_SPEED_* values don't correspond directly to EHCI speed encoding anymore, I've added necessary recoding in EHCI driver. Also there is no point to put speed into pipe anymore so it's removed and a bunch of host drivers fixed to look at usb_device-speed instead. Old usbdescriptors.h included is not removed as it seems to be used by old USB device code. This makes usb.h and usbdevice.h incompatible. Fortunately the only place that tries to include both are the old MUSB code and it needs usb.h only for USB_DMA_MINALIGN used in aligned attribute on musb_regs structure but this attribute seems to be unneeded (old MUSB code doesn't support any DMA at all). Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- Changes in v3: - fix old MUSB code compilation arch/arm/cpu/arm920t/s3c24x0/usb_ohci.c |2 +- arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c |2 +- arch/powerpc/cpu/mpc5xxx/usb_ohci.c |2 +- arch/powerpc/cpu/ppc4xx/usb_ohci.c|2 +- common/cmd_usb.c |2 +- common/usb.c |4 ++-- drivers/usb/host/ehci-hcd.c | 16 ++-- drivers/usb/host/isp116x-hcd.c|2 +- drivers/usb/host/ohci-hcd.c |2 +- drivers/usb/host/sl811-hcd.c |2 +- drivers/usb/musb/musb_core.h |3 +-- drivers/usb/musb/musb_hcd.c |5 +++-- include/usb.h | 15 +++ include/usb_defs.h|6 -- 14 files changed, 31 insertions(+), 34 deletions(-) diff --git a/arch/arm/cpu/arm920t/s3c24x0/usb_ohci.c b/arch/arm/cpu/arm920t/s3c24x0/usb_ohci.c index 944bb32..3bca66a 100644 --- a/arch/arm/cpu/arm920t/s3c24x0/usb_ohci.c +++ b/arch/arm/cpu/arm920t/s3c24x0/usb_ohci.c @@ -620,7 +620,7 @@ static struct ed *ep_add_ed(struct usb_device *usb_dev, unsigned long pipe) | (usb_pipeisoc(pipe) ? 0x8000 : 0) | (usb_pipecontrol(pipe) ? 0 : (usb_pipeout(pipe) ? 0x800 : 0x1000)) - | usb_pipeslow(pipe) 13 | + | (usb_dev-speed == USB_SPEED_LOW) 13 | usb_maxpacket(usb_dev, pipe) 16); return ed_ret; diff --git a/arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c b/arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c index c747767..ae611bb 100644 --- a/arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c +++ b/arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c @@ -615,7 +615,7 @@ static ed_t * ep_add_ed (struct usb_device *usb_dev, unsigned long pipe) | usb_pipeendpoint (pipe) 7 | (usb_pipeisoc (pipe)? 0x8000: 0) | (usb_pipecontrol (pipe)? 0: (usb_pipeout (pipe)? 0x800: 0x1000)) - | usb_pipeslow (pipe) 13 + | (usb_dev-speed == USB_SPEED_LOW) 13 | usb_maxpacket (usb_dev, pipe) 16); return ed_ret; diff --git a/arch/powerpc/cpu/mpc5xxx/usb_ohci.c b/arch/powerpc/cpu/mpc5xxx/usb_ohci.c index 607034b..de07343 100644 --- a/arch/powerpc/cpu/mpc5xxx/usb_ohci.c +++ b/arch/powerpc/cpu/mpc5xxx/usb_ohci.c @@ -618,7 +618,7 @@ static ed_t * ep_add_ed (struct usb_device *usb_dev, unsigned long pipe) | usb_pipeendpoint (pipe) 7 | (usb_pipeisoc (pipe)? 0x8000: 0) | (usb_pipecontrol (pipe)? 0: (usb_pipeout (pipe)? 0x800: 0x1000)) - | usb_pipeslow (pipe) 13 + | (usb_dev-speed == USB_SPEED_LOW) 13 | usb_maxpacket (usb_dev, pipe) 16); return ed_ret; diff --git a/arch/powerpc/cpu/ppc4xx/usb_ohci.c b/arch/powerpc/cpu/ppc4xx/usb_ohci.c index 4ce2726..f820c37 100644 --- a/arch/powerpc/cpu/ppc4xx/usb_ohci.c +++ b/arch/powerpc/cpu/ppc4xx/usb_ohci.c @@ -621,7 +621,7 @@ static ed_t * ep_add_ed (struct usb_device *usb_dev, unsigned long pipe) | usb_pipeendpoint (pipe) 7 | (usb_pipeisoc (pipe)? 0x8000: 0) | (usb_pipecontrol (pipe)? 0: (usb_pipeout (pipe)? 0x800: 0x1000)) - | usb_pipeslow (pipe) 13 + | (usb_dev-speed == USB_SPEED_LOW) 13 | usb_maxpacket (usb_dev, pipe) 16); return ed_ret; diff --git a/common/cmd_usb.c b/common/cmd_usb.c index c128455..8be9952 100644 --- a/common/cmd_usb.c +++ b/common/cmd_usb.c @@ -192,7 +192,7 @@ void usb_display_desc(struct usb_device *dev) } -void usb_display_conf_desc(struct usb_configuration_descriptor *config, +void usb_display_conf_desc(struct
[U-Boot] [RFC PATCH v3 01/13] linux/usb/ch9.h: update with the version from Linux tree
Signed-off-by: Ilya Yanok ya...@cogentembedded.com Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- drivers/usb/gadget/config.c |1 - drivers/usb/gadget/epautoconf.c |1 - drivers/usb/gadget/ether.c |1 - drivers/usb/gadget/s3c_udc_otg.c |1 - drivers/usb/gadget/usbstring.c |1 - include/linux/usb/ch9.h | 514 -- include/usb/s3c_udc.h|1 - 7 files changed, 499 insertions(+), 21 deletions(-) diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c index f88d0c1..f9163a8 100644 --- a/drivers/usb/gadget/config.c +++ b/drivers/usb/gadget/config.c @@ -27,7 +27,6 @@ #include linux/string.h #include linux/usb/ch9.h -#include usbdescriptors.h #include linux/usb/gadget.h diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index b656c8b..5b8776e 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -23,7 +23,6 @@ #include common.h #include linux/usb/ch9.h -#include usbdescriptors.h #include asm/errno.h #include linux/usb/gadget.h #include asm/unaligned.h diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 1e187e5..c51e69c 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -24,7 +24,6 @@ #include asm/errno.h #include linux/netdevice.h #include linux/usb/ch9.h -#include usbdescriptors.h #include linux/usb/cdc.h #include linux/usb/gadget.h #include net.h diff --git a/drivers/usb/gadget/s3c_udc_otg.c b/drivers/usb/gadget/s3c_udc_otg.c index 3fdfdf7..f9d24e3 100644 --- a/drivers/usb/gadget/s3c_udc_otg.c +++ b/drivers/usb/gadget/s3c_udc_otg.c @@ -37,7 +37,6 @@ #include malloc.h #include linux/usb/ch9.h -#include usbdescriptors.h #include linux/usb/gadget.h #include asm/byteorder.h diff --git a/drivers/usb/gadget/usbstring.c b/drivers/usb/gadget/usbstring.c index 4dbe060..9cf 100644 --- a/drivers/usb/gadget/usbstring.c +++ b/drivers/usb/gadget/usbstring.c @@ -13,7 +13,6 @@ #include common.h #include asm/errno.h #include linux/usb/ch9.h -#include usbdescriptors.h #include linux/usb/gadget.h #include asm/unaligned.h diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h index ce1d1e1..d1d732c 100644 --- a/include/linux/usb/ch9.h +++ b/include/linux/usb/ch9.h @@ -28,15 +28,13 @@ * [c] for consistency, removing all doubt even when it appears to * someone that the two other points are non-issues for that * particular descriptor type. - * - * Ported to U-boot by: Thomas Smits ts.sm...@gmail.com and - * Remy Bohmer li...@bohmer.net */ #ifndef __LINUX_USB_CH9_H #define __LINUX_USB_CH9_H #include linux/types.h /* __u8 etc */ +#include asm/byteorder.h /* le16_to_cpu */ /*-*/ @@ -70,7 +68,7 @@ #define USB_RECIP_OTHER0x03 /* From Wireless USB 1.0 */ #define USB_RECIP_PORT 0x04 -#define USB_RECIP_RPIPE0x05 +#define USB_RECIP_RPIPE0x05 /* * Standard requests, for the bRequest field of a SETUP packet. @@ -90,6 +88,8 @@ #define USB_REQ_GET_INTERFACE 0x0A #define USB_REQ_SET_INTERFACE 0x0B #define USB_REQ_SYNCH_FRAME0x0C +#define USB_REQ_SET_SEL0x30 +#define USB_REQ_SET_ISOCH_DELAY0x31 #define USB_REQ_SET_ENCRYPTION 0x0D/* Wireless USB */ #define USB_REQ_GET_ENCRYPTION 0x0E @@ -105,10 +105,16 @@ #define USB_REQ_LOOPBACK_DATA_READ 0x16 #define USB_REQ_SET_INTERFACE_DS 0x17 +/* The Link Power Management (LPM) ECN defines USB_REQ_TEST_AND_SET command, + * used by hubs to put ports into a new L1 suspend state, except that it + * forgot to define its number ... + */ + /* * USB feature flags are written using USB_REQ_{CLEAR,SET}_FEATURE, and * are read as a bit array returned by USB_REQ_GET_STATUS. (So there - * are at most sixteen features of each type.) + * are at most sixteen features of each type.) Hubs may also support a + * new USB_REQ_TEST_AND_SET_FEATURE to put ports into L1 suspend. */ #define USB_DEVICE_SELF_POWERED0 /* (read only) */ #define USB_DEVICE_REMOTE_WAKEUP 1 /* dev may initiate wakeup */ @@ -120,8 +126,38 @@ #define USB_DEVICE_A_ALT_HNP_SUPPORT 5 /* (otg) other RH port does */ #define USB_DEVICE_DEBUG_MODE 6 /* (special devices only) */ +/* + * Test Mode Selectors + * See USB 2.0 spec Table 9-7 + */ +#defineTEST_J 1 +#defineTEST_K 2 +#defineTEST_SE0_NAK3 +#defineTEST_PACKET 4 +#defineTEST_FORCE_EN 5 + +/* + * New Feature Selectors as added by USB 3.0 + * See USB 3.0 spec Table 9-6 + */ +#define USB_DEVICE_U1_ENABLE 48 /* dev may initiate U1 transition */ +#define
[U-Boot] [RFC PATCH v3 04/13] musb-new: dsps backend driver
Backend driver for MUSB OTG controllers found on TI AM33xx and TI81xx SoCs (tested with AM33xx only). Signed-off-by: Ilya Yanok ya...@cogentembedded.com Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- Changes in v2: - rename backend config option to CONFIG_USB_MUSB_DSPS - we are providing host support now so add yourself to usb.h arch/arm/include/asm/omap_musb.h | 25 ++ drivers/usb/musb-new/Makefile|1 + drivers/usb/musb-new/musb_dsps.c | 771 ++ include/usb.h|3 +- 4 files changed, 799 insertions(+), 1 deletion(-) create mode 100644 arch/arm/include/asm/omap_musb.h create mode 100644 drivers/usb/musb-new/musb_dsps.c diff --git a/arch/arm/include/asm/omap_musb.h b/arch/arm/include/asm/omap_musb.h new file mode 100644 index 000..0081a68 --- /dev/null +++ b/arch/arm/include/asm/omap_musb.h @@ -0,0 +1,25 @@ +/* + * Board data structure for musb gadget on OMAPs + * + * Copyright (C) 2012, Ilya Yanok ilya.ya...@gmail.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. + */ + +#ifndef __ASM_ARM_OMAP_MUSB_H +#define __ASM_ARM_OMAP_MUSB_H + +extern struct musb_platform_ops musb_dsps_ops; + +struct omap_musb_board_data { + void (*set_phy_power)(u8 on); +}; +#endif /* __ASM_ARM_OMAP_MUSB_H */ diff --git a/drivers/usb/musb-new/Makefile b/drivers/usb/musb-new/Makefile index f01fb16..a753423 100644 --- a/drivers/usb/musb-new/Makefile +++ b/drivers/usb/musb-new/Makefile @@ -9,6 +9,7 @@ LIB := $(obj)libusb_musb-new.o COBJS-$(CONFIG_MUSB_GADGET) += musb_gadget.o musb_gadget_ep0.o musb_core.o COBJS-$(CONFIG_MUSB_GADGET) += musb_uboot.o COBJS-$(CONFIG_MUSB_HOST) += musb_host.o musb_core.o musb_uboot.o +COBJS-$(CONFIG_USB_MUSB_DSPS) += musb_dsps.o CFLAGS_NO_WARN := $(call cc-option,-Wno-unused-variable) \ $(call cc-option,-Wno-unused-but-set-variable) \ diff --git a/drivers/usb/musb-new/musb_dsps.c b/drivers/usb/musb-new/musb_dsps.c new file mode 100644 index 000..9a03917 --- /dev/null +++ b/drivers/usb/musb-new/musb_dsps.c @@ -0,0 +1,771 @@ +/* + * Texas Instruments DSPS platforms glue layer + * + * Copyright (C) 2012, by Texas Instruments + * + * Based on the am35x glue layer code. + * + * This file is part of the Inventra Controller Driver for Linux. + * + * The Inventra Controller Driver for Linux is free software; you + * can redistribute it and/or modify it under the terms of the GNU + * General Public License version 2 as published by the Free Software + * Foundation. + * + * The Inventra Controller Driver for Linux 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 The Inventra Controller Driver for Linux ; if not, + * write to the Free Software Foundation, Inc., 59 Temple Place, + * Suite 330, Boston, MA 02111-1307 USA + * + * musb_dsps.c will be a common file for all the TI DSPS platforms + * such as dm64x, dm36x, dm35x, da8x, am35x and ti81x. + * For now only ti81x is using this and in future davinci.c, am35x.c + * da8xx.c would be merged to this file after testing. + */ + +#define __UBOOT__ +#ifndef __UBOOT__ +#include linux/init.h +#include linux/io.h +#include linux/err.h +#include linux/platform_device.h +#include linux/dma-mapping.h +#include linux/pm_runtime.h +#include linux/module.h + +#include linux/of.h +#include linux/of_device.h +#include linux/of_address.h + +#include plat/usb.h +#else +#include common.h +#include asm/omap_musb.h +#include linux-compat.h +#endif + +#include musb_core.h + +/** + * avoid using musb_readx()/musb_writex() as glue layer should not be + * dependent on musb core layer symbols. + */ +static inline u8 dsps_readb(const void __iomem *addr, unsigned offset) + { return __raw_readb(addr + offset); } + +static inline u32 dsps_readl(const void __iomem *addr, unsigned offset) + { return __raw_readl(addr + offset); } + +static inline void dsps_writeb(void __iomem *addr, unsigned offset, u8 data) + { __raw_writeb(data, addr + offset); } + +static inline void dsps_writel(void __iomem *addr, unsigned offset, u32 data) + { __raw_writel(data, addr + offset); } + +/** + * DSPS musb wrapper register offset. + * FIXME: This should be expanded to have all the wrapper registers from TI DSPS + * musb
[U-Boot] [RFC PATCH v3 05/13] am33xx: init OTG hardware and new musb gadget driver
AM33xx has support for dual port MUSB OTG controller. This patch adds initialization for the controller using new MUSB gadget driver and ether gadget. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- Changes in v3: - use clrsetbits_le32 for USB PHY ops arch/arm/cpu/armv7/am33xx/board.c | 103 ++- arch/arm/cpu/armv7/am33xx/clock.c |8 +++ arch/arm/include/asm/arch-am33xx/cpu.h | 11 ++- arch/arm/include/asm/arch-am33xx/hardware.h |4 ++ 4 files changed, 122 insertions(+), 4 deletions(-) diff --git a/arch/arm/cpu/armv7/am33xx/board.c b/arch/arm/cpu/armv7/am33xx/board.c index 978b184..1917c2a 100644 --- a/arch/arm/cpu/armv7/am33xx/board.c +++ b/arch/arm/cpu/armv7/am33xx/board.c @@ -33,6 +33,11 @@ #include i2c.h #include miiphy.h #include cpsw.h +#include asm/errno.h +#include linux/usb/ch9.h +#include linux/usb/gadget.h +#include linux/usb/musb.h +#include asm/omap_musb.h DECLARE_GLOBAL_DATA_PTR; @@ -209,6 +214,84 @@ void setup_clocks_for_console(void) return; } +/* AM33XX has two MUSB controllers which can be host or gadget */ +#if (defined(CONFIG_MUSB_GADGET) || defined(CONFIG_MUSB_HOST)) \ + (defined(CONFIG_AM335X_USB0) || defined(CONFIG_AM335X_USB1)) +/* USB 2.0 PHY Control */ +#define CM_PHY_PWRDN (1 0) +#define CM_PHY_OTG_PWRDN (1 1) +#define OTGVDET_EN (1 19) +#define OTGSESSENDEN (1 20) + +static void am33xx_usb_set_phy_power(u8 on, u32 *reg_addr) +{ + if (on) { + clrsetbits_le32(reg_addr, CM_PHY_PWRDN | CM_PHY_OTG_PWRDN, + OTGVDET_EN | OTGSESSENDEN); + } else { + clrsetbits_le32(reg_addr, 0, CM_PHY_PWRDN | CM_PHY_OTG_PWRDN); + } +} + +static struct musb_hdrc_config musb_config = { + .multipoint = 1, + .dyn_fifo = 1, + .num_eps= 16, + .ram_bits = 12, +}; + +#ifdef CONFIG_AM335X_USB0 +static void am33xx_otg0_set_phy_power(u8 on) +{ + am33xx_usb_set_phy_power(on, cdev-usb_ctrl0); +} + +struct omap_musb_board_data otg0_board_data = { + .set_phy_power = am33xx_otg0_set_phy_power, +}; + +static struct musb_hdrc_platform_data otg0_plat = { + .mode = CONFIG_AM335X_USB0_MODE, + .config = musb_config, + .power = 50, + .platform_ops = musb_dsps_ops, + .board_data = otg0_board_data, +}; +#endif + +#ifdef CONFIG_AM335X_USB1 +static void am33xx_otg1_set_phy_power(u8 on) +{ + am33xx_usb_set_phy_power(on, cdev-usb_ctrl1); +} + +struct omap_musb_board_data otg1_board_data = { + .set_phy_power = am33xx_otg1_set_phy_power, +}; + +static struct musb_hdrc_platform_data otg1_plat = { + .mode = CONFIG_AM335X_USB1_MODE, + .config = musb_config, + .power = 50, + .platform_ops = musb_dsps_ops, + .board_data = otg1_board_data, +}; +#endif +#endif + +int arch_misc_init(void) +{ +#ifdef CONFIG_AM335X_USB0 + musb_register(otg0_plat, otg0_board_data, + (void *)AM335X_USB0_OTG_BASE); +#endif +#ifdef CONFIG_AM335X_USB1 + musb_register(otg1_plat, otg1_board_data, + (void *)AM335X_USB1_OTG_BASE); +#endif + return 0; +} + /* * Basic board specific setup. Pinmux has been handled already. */ @@ -261,9 +344,14 @@ static struct cpsw_platform_data cpsw_data = { .host_port_num = 0, .version= CPSW_CTRL_VERSION_2, }; +#endif +#if defined(CONFIG_DRIVER_TI_CPSW) || \ + (defined(CONFIG_USB_ETHER) defined(CONFIG_MUSB_GADGET)) int board_eth_init(bd_t *bis) { + int rv, n = 0; +#ifdef CONFIG_DRIVER_TI_CPSW uint8_t mac_addr[6]; uint32_t mac_hi, mac_lo; @@ -295,6 +383,19 @@ int board_eth_init(bd_t *bis) PHY_INTERFACE_MODE_RGMII; } - return cpsw_register(cpsw_data); + rv = cpsw_register(cpsw_data); + if (rv 0) + printf(Error %d registering CPSW switch\n, rv); + else + n += rv; +#endif +#ifdef CONFIG_USB_ETHER + rv = usb_eth_initialize(bis); + if (rv 0) + printf(Error %d registering USB_ETHER\n, rv); + else + n += rv; +#endif + return n; } #endif diff --git a/arch/arm/cpu/armv7/am33xx/clock.c b/arch/arm/cpu/armv7/am33xx/clock.c index 2b19506..04841e4 100644 --- a/arch/arm/cpu/armv7/am33xx/clock.c +++ b/arch/arm/cpu/armv7/am33xx/clock.c @@ -40,6 +40,7 @@ #define CLK_MODE_MASK 0xfff8 #define CLK_DIV_SEL0xFFE0 #define CPGMAC0_IDLE 0x3 +#define DPLL_CLKDCOLDO_GATE_CTRL0x300 const struct cm_perpll *cmper = (struct cm_perpll *)CM_PER; const struct cm_wkuppll *cmwkup = (struct cm_wkuppll *)CM_WKUP; @@ -153,6 +154,11 @@ static void enable_per_clocks(void) writel(PRCM_MOD_EN
[U-Boot] [RFC PATCH v3 06/13] am335x_evm: enable both musb gadget and host
Enable musb gadget in Ethernet mode on port 0 and musb host on port1. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- include/configs/am335x_evm.h | 27 +++ 1 file changed, 27 insertions(+) diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h index 339d4bd..77f7219 100644 --- a/include/configs/am335x_evm.h +++ b/include/configs/am335x_evm.h @@ -237,6 +237,33 @@ #define CONFIG_SKIP_LOWLEVEL_INIT #endif +/* + * USB configuration + */ +#define CONFIG_USB_MUSB_DSPS +#define CONFIG_ARCH_MISC_INIT +#define CONFIG_MUSB_GADGET +#define CONFIG_MUSB_PIO_ONLY +#define CONFIG_USB_GADGET_DUALSPEED +#define CONFIG_MUSB_HOST +#define CONFIG_AM335X_USB0 +#define CONFIG_AM335X_USB0_MODEMUSB_PERIPHERAL +#define CONFIG_AM335X_USB1 +#define CONFIG_AM335X_USB1_MODE MUSB_HOST + +#ifdef CONFIG_MUSB_HOST +#define CONFIG_CMD_USB +#define CONFIG_USB_STORAGE +#endif + +#ifdef CONFIG_MUSB_GADGET +#define CONFIG_USB_ETHER +#define CONFIG_USB_ETH_RNDIS +#endif /* CONFIG_MUSB_GADGET */ + +/* Unsupported features */ +#undef CONFIG_USE_IRQ + #define CONFIG_CMD_NET #define CONFIG_CMD_DHCP #define CONFIG_CMD_PING -- 1.7.10.4 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [RFC PATCH v3 08/13] OMAP3: am35x_def.h: add USB defines
Add defines for MUSB IP block on AM35X SoCs. Signed-off-by: Ilya Yanok ya...@cogentembedded.com Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- arch/arm/include/asm/arch-omap3/am35x_def.h | 27 +++ 1 file changed, 27 insertions(+) diff --git a/arch/arm/include/asm/arch-omap3/am35x_def.h b/arch/arm/include/asm/arch-omap3/am35x_def.h index bbaf1bc..67698bc 100644 --- a/arch/arm/include/asm/arch-omap3/am35x_def.h +++ b/arch/arm/include/asm/arch-omap3/am35x_def.h @@ -32,9 +32,34 @@ #ifndef __KERNEL_STRICT_NAMES #ifndef __ASSEMBLY__ +/* LVL_INTR_CLEAR bits */ +#define USBOTGSS_INT_CLR (1 4) + /* IP_SW_RESET bits */ +#define USBOTGSS_SW_RST(1 0)/* reset USBOTG */ #define CPGMACSS_SW_RST(1 1)/* reset CPGMAC */ +/* DEVCONF2 bits */ +#define CONF2_PHY_GPIOMODE (1 23) +#define CONF2_OTGMODE (3 14) +#define CONF2_NO_OVERRIDE (0 14) +#define CONF2_FORCE_HOST (1 14) +#define CONF2_FORCE_DEVICE (2 14) +#define CONF2_FORCE_HOST_VBUS_LOW (3 14) +#define CONF2_SESENDEN (1 13) +#define CONF2_VBDTCTEN (1 12) +#define CONF2_REFFREQ_24MHZ(2 8) +#define CONF2_REFFREQ_26MHZ(7 8) +#define CONF2_REFFREQ_13MHZ(6 8) +#define CONF2_REFFREQ (0xf 8) +#define CONF2_PHYCLKGD (1 7) +#define CONF2_VBUSSENSE(1 6) +#define CONF2_PHY_PLLON(1 5) +#define CONF2_RESET(1 4) +#define CONF2_PHYPWRDN (1 3) +#define CONF2_OTGPWRDN (1 2) +#define CONF2_DATPOL (1 1) + /* General register mappings of system control module */ #define AM35X_SCM_GEN_BASE 0x48002270 struct am35x_scm_general { @@ -49,6 +74,8 @@ struct am35x_scm_general { }; #define am35x_scm_general_regs ((struct am35x_scm_general *)AM35X_SCM_GEN_BASE) +#define AM35XX_IPSS_USBOTGSS_BASE 0x5C04 + #endif /*__ASSEMBLY__ */ #endif /* __KERNEL_STRICT_NAMES */ -- 1.7.10.4 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [RFC PATCH v3 09/13] OMAP3: am35x: add musb functions
AM35XX specific functions for integrated USB PHY/MUSB IP. Signed-off-by: Ilya Yanok ya...@cogentembedded.com Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- arch/arm/cpu/armv7/omap3/Makefile |1 + arch/arm/cpu/armv7/omap3/am35x_musb.c | 75 arch/arm/include/asm/arch-omap3/musb.h | 28 3 files changed, 104 insertions(+) create mode 100644 arch/arm/cpu/armv7/omap3/am35x_musb.c create mode 100644 arch/arm/include/asm/arch-omap3/musb.h diff --git a/arch/arm/cpu/armv7/omap3/Makefile b/arch/arm/cpu/armv7/omap3/Makefile index ac597be..de167ee 100644 --- a/arch/arm/cpu/armv7/omap3/Makefile +++ b/arch/arm/cpu/armv7/omap3/Makefile @@ -38,6 +38,7 @@ endif COBJS-$(CONFIG_DRIVER_TI_EMAC) += emac.o COBJS-$(CONFIG_EMIF4) += emif4.o COBJS-$(CONFIG_SDRC) += sdrc.o +COBJS-$(CONFIG_USB_MUSB_AM35X) += am35x_musb.o SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS) $(COBJS-y) $(SOBJS)) diff --git a/arch/arm/cpu/armv7/omap3/am35x_musb.c b/arch/arm/cpu/armv7/omap3/am35x_musb.c new file mode 100644 index 000..7183c4f --- /dev/null +++ b/arch/arm/cpu/armv7/omap3/am35x_musb.c @@ -0,0 +1,75 @@ +/* + * This file configures the internal USB PHY in AM35X. + * + * Copyright (C) 2012 Ilya Yanok ilya.ya...@gmail.com + * + * Based on omap_phy_internal.c code from Linux by + * Hema HK hem...@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. + * + */ + +#include common.h +#include asm/io.h +#include asm/arch/am35x_def.h + +void am35x_musb_reset(void) +{ + /* Reset the musb interface */ + clrsetbits_le32(am35x_scm_general_regs-ip_sw_reset, + 0, USBOTGSS_SW_RST); + clrsetbits_le32(am35x_scm_general_regs-ip_sw_reset, + USBOTGSS_SW_RST, 0); +} + +void am35x_musb_phy_power(u8 on) +{ + unsigned long start = get_timer(0); + + if (on) { + /* +* Start the on-chip PHY and its PLL. +*/ + clrsetbits_le32(am35x_scm_general_regs-devconf2, + CONF2_RESET | CONF2_PHYPWRDN | CONF2_OTGPWRDN, + CONF2_PHY_PLLON); + + debug(Waiting for PHY clock good...\n); + while (!(readl(am35x_scm_general_regs-devconf2) +CONF2_PHYCLKGD)) { + + if (get_timer(start) CONFIG_SYS_HZ / 10) { + printf(musb PHY clock good timed out\n); + break; + } + } + } else { + /* +* Power down the on-chip PHY. +*/ + clrsetbits_le32(am35x_scm_general_regs-devconf2, + CONF2_PHY_PLLON, + CONF2_PHYPWRDN | CONF2_OTGPWRDN); + } +} + +void am35x_musb_clear_irq(void) +{ + clrsetbits_le32(am35x_scm_general_regs-lvl_intr_clr, + 0, USBOTGSS_INT_CLR); + readl(am35x_scm_general_regs-lvl_intr_clr); +} + diff --git a/arch/arm/include/asm/arch-omap3/musb.h b/arch/arm/include/asm/arch-omap3/musb.h new file mode 100644 index 000..423ac50 --- /dev/null +++ b/arch/arm/include/asm/arch-omap3/musb.h @@ -0,0 +1,28 @@ +/* + * (C) Copyright 2012 + * Ilya Yanok, ilya.ya...@gmail.com + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc. + */ + +#ifndef __ASM_ARCH_OMAP3_MUSB_H +#define __ASM_ARCH_OMAP3_MUSB_H +extern void am35x_musb_reset(void); +extern void am35x_musb_phy_power(u8 on); +extern void am35x_musb_clear_irq(void); +#endif -- 1.7.10.4
[U-Boot] [RFC PATCH v3 07/13] musb-new: am35x backend driver
Backend driver for MUSB OTG controllers found on TI AM35x. It seems that on AM35X interrupt status registers can be updated _before_ core registers. As we don't use true interrupts in U-Boot and poll interrupt status registers instead this can result in interrupt handler being called with non-updated core registers. This confuses the code and result in hanged transfers. Add a small delay in am35x_interrupt as a workaround. Signed-off-by: Ilya Yanok ya...@cogentembedded.com Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- arch/arm/include/asm/omap_musb.h|3 + drivers/usb/musb-new/Makefile |1 + drivers/usb/musb-new/am35x.c| 709 +++ drivers/usb/musb-new/linux-compat.h |1 + include/usb.h |2 +- 5 files changed, 715 insertions(+), 1 deletion(-) create mode 100644 drivers/usb/musb-new/am35x.c diff --git a/arch/arm/include/asm/omap_musb.h b/arch/arm/include/asm/omap_musb.h index 0081a68..46c8578 100644 --- a/arch/arm/include/asm/omap_musb.h +++ b/arch/arm/include/asm/omap_musb.h @@ -18,8 +18,11 @@ #define __ASM_ARM_OMAP_MUSB_H extern struct musb_platform_ops musb_dsps_ops; +extern const struct musb_platform_ops am35x_ops; struct omap_musb_board_data { void (*set_phy_power)(u8 on); + void (*clear_irq)(void); + void (*reset)(void); }; #endif /* __ASM_ARM_OMAP_MUSB_H */ diff --git a/drivers/usb/musb-new/Makefile b/drivers/usb/musb-new/Makefile index a753423..23fc735 100644 --- a/drivers/usb/musb-new/Makefile +++ b/drivers/usb/musb-new/Makefile @@ -10,6 +10,7 @@ COBJS-$(CONFIG_MUSB_GADGET) += musb_gadget.o musb_gadget_ep0.o musb_core.o COBJS-$(CONFIG_MUSB_GADGET) += musb_uboot.o COBJS-$(CONFIG_MUSB_HOST) += musb_host.o musb_core.o musb_uboot.o COBJS-$(CONFIG_USB_MUSB_DSPS) += musb_dsps.o +COBJS-$(CONFIG_USB_MUSB_AM35X) += am35x.o CFLAGS_NO_WARN := $(call cc-option,-Wno-unused-variable) \ $(call cc-option,-Wno-unused-but-set-variable) \ diff --git a/drivers/usb/musb-new/am35x.c b/drivers/usb/musb-new/am35x.c new file mode 100644 index 000..57c9bd3 --- /dev/null +++ b/drivers/usb/musb-new/am35x.c @@ -0,0 +1,709 @@ +/* + * Texas Instruments AM35x glue layer + * + * Copyright (c) 2010, by Texas Instruments + * + * Based on the DA8xx glue layer code. + * Copyright (c) 2008-2009, MontaVista Software, Inc. sou...@mvista.com + * + * This file is part of the Inventra Controller Driver for Linux. + * + * The Inventra Controller Driver for Linux is free software; you + * can redistribute it and/or modify it under the terms of the GNU + * General Public License version 2 as published by the Free Software + * Foundation. + * + * The Inventra Controller Driver for Linux 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 The Inventra Controller Driver for Linux ; if not, + * write to the Free Software Foundation, Inc., 59 Temple Place, + * Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define __UBOOT__ +#ifndef __UBOOT__ +#include linux/init.h +#include linux/module.h +#include linux/clk.h +#include linux/err.h +#include linux/io.h +#include linux/platform_device.h +#include linux/dma-mapping.h + +#include plat/usb.h +#else +#include common.h +#include asm/omap_musb.h +#include linux-compat.h +#endif + +#include musb_core.h + +/* + * AM35x specific definitions + */ +/* USB 2.0 OTG module registers */ +#define USB_REVISION_REG 0x00 +#define USB_CTRL_REG 0x04 +#define USB_STAT_REG 0x08 +#define USB_EMULATION_REG 0x0c +/* 0x10 Reserved */ +#define USB_AUTOREQ_REG0x14 +#define USB_SRP_FIX_TIME_REG 0x18 +#define USB_TEARDOWN_REG 0x1c +#define EP_INTR_SRC_REG0x20 +#define EP_INTR_SRC_SET_REG0x24 +#define EP_INTR_SRC_CLEAR_REG 0x28 +#define EP_INTR_MASK_REG 0x2c +#define EP_INTR_MASK_SET_REG 0x30 +#define EP_INTR_MASK_CLEAR_REG 0x34 +#define EP_INTR_SRC_MASKED_REG 0x38 +#define CORE_INTR_SRC_REG 0x40 +#define CORE_INTR_SRC_SET_REG 0x44 +#define CORE_INTR_SRC_CLEAR_REG0x48 +#define CORE_INTR_MASK_REG 0x4c +#define CORE_INTR_MASK_SET_REG 0x50 +#define CORE_INTR_MASK_CLEAR_REG 0x54 +#define CORE_INTR_SRC_MASKED_REG 0x58 +/* 0x5c Reserved */ +#define USB_END_OF_INTR_REG0x60 + +/* Control register bits */ +#define AM35X_SOFT_RESET_MASK 1 + +/* USB interrupt register bits */ +#define AM35X_INTR_USB_SHIFT 16 +#define AM35X_INTR_USB_MASK(0x1ff AM35X_INTR_USB_SHIFT) +#define AM35X_INTR_DRVVBUS 0x100 +#define AM35X_INTR_RX_SHIFT16 +#define AM35X_INTR_TX_SHIFT0 +#define AM35X_TX_EP_MASK 0x /* EP0 + 15 Tx EPs */ +#define AM35X_RX_EP_MASK 0xfffe
[U-Boot] [RFC PATCH v3 11/13] musb-new: omap2plus backend driver
Backend driver for MUSB OTG controllers found on TI OMAP2/3/4 (tested only on OMAP3 Beagle). Signed-off-by: Ilya Yanok ya...@cogentembedded.com Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- arch/arm/include/asm/omap_musb.h|4 + drivers/usb/musb-new/Makefile |1 + drivers/usb/musb-new/linux-compat.h |9 + drivers/usb/musb-new/omap2430.c | 626 +++ drivers/usb/musb-new/omap2430.h | 56 include/usb.h |3 +- 6 files changed, 698 insertions(+), 1 deletion(-) create mode 100644 drivers/usb/musb-new/omap2430.c create mode 100644 drivers/usb/musb-new/omap2430.h diff --git a/arch/arm/include/asm/omap_musb.h b/arch/arm/include/asm/omap_musb.h index 46c8578..b04d865 100644 --- a/arch/arm/include/asm/omap_musb.h +++ b/arch/arm/include/asm/omap_musb.h @@ -19,10 +19,14 @@ extern struct musb_platform_ops musb_dsps_ops; extern const struct musb_platform_ops am35x_ops; +extern const struct musb_platform_ops omap2430_ops; struct omap_musb_board_data { + u8 interface_type; void (*set_phy_power)(u8 on); void (*clear_irq)(void); void (*reset)(void); }; + +enum musb_interface{MUSB_INTERFACE_ULPI, MUSB_INTERFACE_UTMI}; #endif /* __ASM_ARM_OMAP_MUSB_H */ diff --git a/drivers/usb/musb-new/Makefile b/drivers/usb/musb-new/Makefile index 23fc735..c23bef1 100644 --- a/drivers/usb/musb-new/Makefile +++ b/drivers/usb/musb-new/Makefile @@ -11,6 +11,7 @@ COBJS-$(CONFIG_MUSB_GADGET) += musb_uboot.o COBJS-$(CONFIG_MUSB_HOST) += musb_host.o musb_core.o musb_uboot.o COBJS-$(CONFIG_USB_MUSB_DSPS) += musb_dsps.o COBJS-$(CONFIG_USB_MUSB_AM35X) += am35x.o +COBJS-$(CONFIG_USB_MUSB_OMAP2PLUS) += omap2430.o CFLAGS_NO_WARN := $(call cc-option,-Wno-unused-variable) \ $(call cc-option,-Wno-unused-but-set-variable) \ diff --git a/drivers/usb/musb-new/linux-compat.h b/drivers/usb/musb-new/linux-compat.h index 343ddd2..a23f9e0 100644 --- a/drivers/usb/musb-new/linux-compat.h +++ b/drivers/usb/musb-new/linux-compat.h @@ -37,6 +37,7 @@ typedef unsigned long dmaaddr_t; #define spin_unlock_irqrestore(lock, flags) do {} while (0) #define setup_timer(timer, func, data) do {} while (0) +#define del_timer_sync(timer) do {} while (0) #define schedule_work(work) do {} while (0) #define INIT_WORK(work, fun) do {} while (0) @@ -107,4 +108,12 @@ typedef unsigned long dmaaddr_t; #endif #define msleep(a) udelay(a * 1000) + +/* + * Map U-Boot config options to Linux ones + */ +#ifdef CONFIG_OMAP34XX +#define CONFIG_SOC_OMAP3430 +#endif + #endif /* __LINUX_COMPAT_H__ */ diff --git a/drivers/usb/musb-new/omap2430.c b/drivers/usb/musb-new/omap2430.c new file mode 100644 index 000..b1c4dc7 --- /dev/null +++ b/drivers/usb/musb-new/omap2430.c @@ -0,0 +1,626 @@ +/* + * Copyright (C) 2005-2007 by Texas Instruments + * Some code has been taken from tusb6010.c + * Copyrights for that are attributable to: + * Copyright (C) 2006 Nokia Corporation + * Tony Lindgren t...@atomide.com + * + * This file is part of the Inventra Controller Driver for Linux. + * + * The Inventra Controller Driver for Linux is free software; you + * can redistribute it and/or modify it under the terms of the GNU + * General Public License version 2 as published by the Free Software + * Foundation. + * + * The Inventra Controller Driver for Linux 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 The Inventra Controller Driver for Linux ; if not, + * write to the Free Software Foundation, Inc., 59 Temple Place, + * Suite 330, Boston, MA 02111-1307 USA + * + */ +#define __UBOOT__ +#ifndef __UBOOT__ +#include linux/module.h +#include linux/kernel.h +#include linux/sched.h +#include linux/init.h +#include linux/list.h +#include linux/io.h +#include linux/platform_device.h +#include linux/dma-mapping.h +#include linux/pm_runtime.h +#include linux/err.h +#include linux/usb/musb-omap.h +#else +#include common.h +#include asm/omap_musb.h +#include twl4030.h +#include linux-compat.h +#endif + +#include musb_core.h +#include omap2430.h + +#ifndef __UBOOT__ +struct omap2430_glue { + struct device *dev; + struct platform_device *musb; + enum omap_musb_vbus_id_status status; + struct work_struct omap_musb_mailbox_work; +}; +#define glue_to_musb(g)platform_get_drvdata(g-musb) + +struct omap2430_glue *_glue; + +static struct timer_list musb_idle_timer; + +static void musb_do_idle(unsigned long _musb) +{ + struct musb *musb = (void *)_musb; + unsigned long flags; + u8 power; + u8 devctl; + + spin_lock_irqsave(musb-lock, flags
[U-Boot] [RFC PATCH v3 12/13] omap3_beagle: add musb-new init
Add initialization for new MUSB framework. Signed-off-by: Ilya Yanok ya...@cogentembedded.com Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- board/ti/beagle/beagle.c | 43 include/configs/omap3_beagle.h |2 ++ 2 files changed, 45 insertions(+) diff --git a/board/ti/beagle/beagle.c b/board/ti/beagle/beagle.c index 6175e1d..f20ebed 100644 --- a/board/ti/beagle/beagle.c +++ b/board/ti/beagle/beagle.c @@ -42,6 +42,11 @@ #include asm/arch/sys_proto.h #include asm/gpio.h #include asm/mach-types.h +#include asm/omap_musb.h +#include asm/errno.h +#include linux/usb/ch9.h +#include linux/usb/gadget.h +#include linux/usb/musb.h #include beagle.h #include command.h @@ -285,6 +290,33 @@ static void beagle_dvi_pup(void) } #endif +#ifdef CONFIG_USB_MUSB_OMAP2PLUS +static struct musb_hdrc_config musb_config = { + .multipoint = 1, + .dyn_fifo = 1, + .num_eps= 16, + .ram_bits = 12, +}; + +static struct omap_musb_board_data musb_board_data = { + .interface_type = MUSB_INTERFACE_ULPI, +}; + +static struct musb_hdrc_platform_data musb_plat = { +#if defined(CONFIG_MUSB_HOST) + .mode = MUSB_HOST, +#elif defined(CONFIG_MUSB_GADGET) + .mode = MUSB_PERIPHERAL, +#else +#error Please define either CONFIG_MUSB_HOST or CONFIG_MUSB_GADGET +#endif + .config = musb_config, + .power = 100, + .platform_ops = omap2430_ops, + .board_data = musb_board_data, +}; +#endif + /* * Routine: misc_init_r * Description: Configure board specific parts @@ -466,6 +498,10 @@ int misc_init_r(void) omap3_dss_enable(); #endif +#ifdef CONFIG_USB_MUSB_OMAP2PLUS + musb_register(musb_plat, musb_board_data, (void *)MUSB_BASE); +#endif + return 0; } @@ -513,3 +549,10 @@ int ehci_hcd_stop(int index) } #endif /* CONFIG_USB_EHCI */ + +#if defined(CONFIG_USB_ETHER) defined(CONFIG_MUSB_GADGET) +int board_eth_init(bd_t *bis) +{ + return usb_eth_initialize(bis); +} +#endif diff --git a/include/configs/omap3_beagle.h b/include/configs/omap3_beagle.h index f79f996..e3ed8ea 100644 --- a/include/configs/omap3_beagle.h +++ b/include/configs/omap3_beagle.h @@ -120,6 +120,8 @@ #define CONFIG_MUSB_UDC1 #define CONFIG_USB_OMAP3 1 #define CONFIG_TWL4030_USB 1 +#define CONFIG_USB_ETHER +#define CONFIG_USB_ETHER_RNDIS /* USB device configuration */ #define CONFIG_USB_DEVICE 1 -- 1.7.10.4 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [RFC PATCH v3 10/13] am3517_evm: switch to musb-new
Use new musb framework instead of the old one on AM3517_EVM. Signed-off-by: Ilya Yanok ya...@cogentembedded.com Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- board/logicpd/am3517evm/am3517evm.c | 74 +++ include/configs/am3517_evm.h| 37 -- 2 files changed, 90 insertions(+), 21 deletions(-) diff --git a/board/logicpd/am3517evm/am3517evm.c b/board/logicpd/am3517evm/am3517evm.c index d316f33..0b3721e 100644 --- a/board/logicpd/am3517evm/am3517evm.c +++ b/board/logicpd/am3517evm/am3517evm.c @@ -25,12 +25,20 @@ #include common.h #include asm/io.h +#include asm/omap_musb.h +#include asm/arch/am35x_def.h #include asm/arch/mem.h #include asm/arch/mux.h #include asm/arch/sys_proto.h #include asm/arch/mmc_host_def.h +#include asm/arch/musb.h #include asm/mach-types.h +#include asm/errno.h +#include linux/usb/ch9.h +#include linux/usb/gadget.h +#include linux/usb/musb.h #include i2c.h +#include netdev.h #include am3517evm.h DECLARE_GLOBAL_DATA_PTR; @@ -50,6 +58,52 @@ int board_init(void) return 0; } +#ifdef CONFIG_USB_MUSB_AM35X +static struct musb_hdrc_config musb_config = { + .multipoint = 1, + .dyn_fifo = 1, + .num_eps= 16, + .ram_bits = 12, +}; + +static struct omap_musb_board_data musb_board_data = { + .set_phy_power = am35x_musb_phy_power, + .clear_irq = am35x_musb_clear_irq, + .reset = am35x_musb_reset, +}; + +static struct musb_hdrc_platform_data musb_plat = { +#if defined(CONFIG_MUSB_HOST) + .mode = MUSB_HOST, +#elif defined(CONFIG_MUSB_GADGET) + .mode = MUSB_PERIPHERAL, +#else +#error Please define either CONFIG_MUSB_HOST or CONFIG_MUSB_GADGET +#endif + .config = musb_config, + .power = 250, + .platform_ops = am35x_ops, + .board_data = musb_board_data, +}; + +static void am3517_evm_musb_init(void) +{ + /* +* Set up USB clock/mode in the DEVCONF2 register. +* USB2.0 PHY reference clock is 13 MHz +*/ + clrsetbits_le32(am35x_scm_general_regs-devconf2, + CONF2_REFFREQ | CONF2_OTGMODE | CONF2_PHY_GPIOMODE, + CONF2_REFFREQ_13MHZ | CONF2_SESENDEN | + CONF2_VBDTCTEN | CONF2_DATPOL); + + musb_register(musb_plat, musb_board_data, + (void *)AM35XX_IPSS_USBOTGSS_BASE); +} +#else +#define am3517_evm_musb_init() do {} while (0) +#endif + /* * Routine: misc_init_r * Description: Init i2c, ethernet, etc... (done here so udelay works) @@ -62,6 +116,8 @@ int misc_init_r(void) dieid_num_r(); + am3517_evm_musb_init(); + return 0; } @@ -83,3 +139,21 @@ int board_mmc_init(bd_t *bis) return 0; } #endif + +#if defined(CONFIG_USB_ETHER) defined(CONFIG_MUSB_GADGET) +int board_eth_init(bd_t *bis) +{ + int rv, n = 0; + + rv = cpu_eth_init(bis); + if (rv 0) + n += rv; + + rv = usb_eth_initialize(bis); + if (rv 0) + n += rv; + + return n; +} +#endif + diff --git a/include/configs/am3517_evm.h b/include/configs/am3517_evm.h index 6980811..1f0199e 100644 --- a/include/configs/am3517_evm.h +++ b/include/configs/am3517_evm.h @@ -97,15 +97,16 @@ /* * USB configuration - * Enable CONFIG_MUSB_HCD for Host functionalities MSC, keyboard - * Enable CONFIG_MUSB_UDC for Device functionalities. + * Enable CONFIG_MUSB_HOST for Host functionalities MSC, keyboard + * Enable CONFIG_MUSB_GADGET for Device functionalities. */ -#define CONFIG_USB_AM35X 1 -#define CONFIG_MUSB_HCD1 +#define CONFIG_USB_MUSB_AM35X +#define CONFIG_MUSB_HOST +#define CONFIG_MUSB_PIO_ONLY -#ifdef CONFIG_USB_AM35X +#ifdef CONFIG_USB_MUSB_AM35X -#ifdef CONFIG_MUSB_HCD +#ifdef CONFIG_MUSB_HOST #define CONFIG_CMD_USB #define CONFIG_USB_STORAGE @@ -117,21 +118,15 @@ #define CONFIG_PREBOOT usb start #endif /* CONFIG_USB_KEYBOARD */ -#endif /* CONFIG_MUSB_HCD */ - -#ifdef CONFIG_MUSB_UDC -/* USB device configuration */ -#define CONFIG_USB_DEVICE 1 -#define CONFIG_USB_TTY 1 -#define CONFIG_SYS_CONSOLE_IS_IN_ENV 1 -/* Change these to suit your needs */ -#define CONFIG_USBD_VENDORID 0x0451 -#define CONFIG_USBD_PRODUCTID 0x5678 -#define CONFIG_USBD_MANUFACTURER Texas Instruments -#define CONFIG_USBD_PRODUCT_NAME AM3517EVM -#endif /* CONFIG_MUSB_UDC */ - -#endif /* CONFIG_USB_AM35X */ +#endif /* CONFIG_MUSB_HOST */ + +#ifdef CONFIG_MUSB_GADGET +#define CONFIG_USB_GADGET_DUALSPEED +#define CONFIG_USB_ETHER +#define CONFIG_USB_ETH_RNDIS +#endif /* CONFIG_MUSB_GADGET */ + +#endif /* CONFIG_USB_MUSB_AM35X */ /* commands to include */ #include config_cmd_default.h -- 1.7.10.4 ___ U-Boot mailing list U-Boot
[U-Boot] [RFC PATCH v3 13/13] omap3_beagle: use new MUSB intstead of the old one
Enable using of new MUSB framework on Beagle. NOTE! This is not just a change of backend code: top-level behavior is also changed, we now use USB device port for USB Ethernet instead of serial. Signed-off-by: Ilya Yanok ya...@cogentembedded.com Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- include/configs/omap3_beagle.h | 11 --- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/include/configs/omap3_beagle.h b/include/configs/omap3_beagle.h index e3ed8ea..fe67c84 100644 --- a/include/configs/omap3_beagle.h +++ b/include/configs/omap3_beagle.h @@ -117,17 +117,14 @@ #define CONFIG_SYS_I2C_NOPROBES{{0x0, 0x0}} /* USB */ -#define CONFIG_MUSB_UDC1 -#define CONFIG_USB_OMAP3 1 +#define CONFIG_MUSB_GADGET +#define CONFIG_USB_MUSB_OMAP2PLUS +#define CONFIG_MUSB_PIO_ONLY +#define CONFIG_USB_GADGET_DUALSPEED #define CONFIG_TWL4030_USB 1 #define CONFIG_USB_ETHER #define CONFIG_USB_ETHER_RNDIS -/* USB device configuration */ -#define CONFIG_USB_DEVICE 1 -#define CONFIG_USB_TTY 1 -#define CONFIG_SYS_CONSOLE_IS_IN_ENV 1 - /* USB EHCI */ #define CONFIG_CMD_USB #define CONFIG_USB_EHCI -- 1.7.10.4 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [RFC PATCH v2 0/6] Port of MUSB driver from Linux
Dear Marek, On Sat, Sep 22, 2012 at 4:55 AM, Marek Vasut ma...@denx.de wrote: [...] I'm glad about this. But how can we make this work if we already have a driver for this in u-boot, now we will have another. Tom ? What's so wrong in letting the two coexist for some time so people could migrate smoothly? Of course we don't want any duplicate drivers... in the perfect world. But we are not in the perfect world (look, there is a bunch of OHCI drivers which are almost the same and they are in the tree for years) and the drivers are rather different. Of course, we should encourage people to switch to the new code, probably by marking the old one deprecated and scheduled for removal. BTW, anybody here use the current musb code? In my experience it never worked as expected... Probably we can drop it right away without much pain... Regards, Ilya. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [RFC PATCH v2 5/6] am33xx: init OTG hardware and new musb gadget driver
Dear Marek, On Sat, Sep 22, 2012 at 4:49 AM, Marek Vasut ma...@denx.de wrote: +{ + u32 usb_ctrl_reg; + + usb_ctrl_reg = readl(reg_addr); + if (on) { + usb_ctrl_reg = ~(CM_PHY_PWRDN | CM_PHY_OTG_PWRDN); + usb_ctrl_reg |= (OTGVDET_EN | OTGSESSENDEN); + } else { + usb_ctrl_reg |= (CM_PHY_PWRDN | CM_PHY_OTG_PWRDN); + } + writel(usb_ctrl_reg, reg_addr); +static void am33xx_usb_set_phy_power(u8 on, u32 *reg_addr) clrsetbits_le32() ? Will change. Regards, Ilya. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [RFC PATCH v2 4/6] musb-new: dsps backend driver
Dear Marek, On Sat, Sep 22, 2012 at 4:48 AM, Marek Vasut ma...@denx.de wrote: +COBJS-$(CONFIG_USB_MUSB_DSPS) += musb_dsps.o CONFIG_MUSB_... ? I'm following Linux here. We can change this, but should we? BTW, it looks to be in line with the current code where all USB lowlevel drivers have CONFIG_USB_* configuration options. Regards, Ilya. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v7 3/4] OMAP: networking support for SPL
This patch adds support for networking in SPL. Some devices are capable of loading SPL via network so it makes sense to load the main U-Boot binary via network too. This patch tries to use existing network code as much as possible. Unfortunately, it depends on environment which in turn depends on other code so SPL size is increased significantly. No effort was done to decouple network code and environment so far. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- Changes in v3: - use BOOTP in SPL regardless of CONFIG_CMD_DHCP - add support for setting different VCI in SPL Changes in v4: - fix compilation of SPL's libcommon with CONFIG_HUSH_PARSER and CONFIG_BOOTD defined - rename spl_eth.c to spl_net.c - set ethact variable if device name is passed Changes in v5: - set up guards in cmd_nvedit.c more carefully - now we don't need command.c and only need main.c for show_boot_progress() so defined it to be noop and remove both files from SPL sources - SPL guards in command.c and main.c are no longer needed - add some guards in env_common.c - qsort.c is no longer needed - add guard to hashtable.c to save some space - undefine unneeded CONFIG_CMD_* while building SPL to save space Changes in v6: - remove some unneeded changes introduced by earlier versions - switch clauses and use ifdef instead of ifndef - create new header config_uncmd_spl.h which undefines CONFIG_CMD_* options unneeded in SPL and include it last from config.h - remove explicit undefs from net/net.c and net/bootp.c Changes in v7: - remove explicit cmd undef from net/tftp.c also - add GPLv2 header to config_uncmd_spl.h - remove CONFIG_SPL_BUILD clause at hang() (not needed) arch/arm/cpu/armv7/omap-common/Makefile |3 ++ arch/arm/cpu/armv7/omap-common/spl.c |9 ++ arch/arm/cpu/armv7/omap-common/spl_net.c | 52 ++ arch/arm/include/asm/omap_common.h |4 +++ common/Makefile |4 +++ common/cmd_nvedit.c |8 + common/env_common.c |7 ++-- include/bootstage.h |6 +++- include/config_uncmd_spl.h | 44 + lib/Makefile |9 -- lib/hashtable.c |2 ++ mkconfig |1 + net/bootp.c |7 +++- spl/Makefile |3 ++ 14 files changed, 153 insertions(+), 6 deletions(-) create mode 100644 arch/arm/cpu/armv7/omap-common/spl_net.c create mode 100644 include/config_uncmd_spl.h diff --git a/arch/arm/cpu/armv7/omap-common/Makefile b/arch/arm/cpu/armv7/omap-common/Makefile index d37b22d..f042078 100644 --- a/arch/arm/cpu/armv7/omap-common/Makefile +++ b/arch/arm/cpu/armv7/omap-common/Makefile @@ -53,6 +53,9 @@ endif ifdef CONFIG_SPL_YMODEM_SUPPORT COBJS += spl_ymodem.o endif +ifdef CONFIG_SPL_NET_SUPPORT +COBJS += spl_net.o +endif endif ifndef CONFIG_SPL_BUILD diff --git a/arch/arm/cpu/armv7/omap-common/spl.c b/arch/arm/cpu/armv7/omap-common/spl.c index f0d766c..53b9261 100644 --- a/arch/arm/cpu/armv7/omap-common/spl.c +++ b/arch/arm/cpu/armv7/omap-common/spl.c @@ -178,6 +178,15 @@ void board_init_r(gd_t *id, ulong dummy) spl_ymodem_load_image(); break; #endif +#ifdef CONFIG_SPL_ETH_SUPPORT + case BOOT_DEVICE_CPGMAC: +#ifdef CONFIG_SPL_ETH_DEVICE + spl_net_load_image(CONFIG_SPL_ETH_DEVICE); +#else + spl_net_load_image(NULL); +#endif + break; +#endif default: printf(SPL: Un-supported Boot Device - %d!!!\n, boot_device); hang(); diff --git a/arch/arm/cpu/armv7/omap-common/spl_net.c b/arch/arm/cpu/armv7/omap-common/spl_net.c new file mode 100644 index 000..cbb3087 --- /dev/null +++ b/arch/arm/cpu/armv7/omap-common/spl_net.c @@ -0,0 +1,52 @@ +/* + * (C) Copyright 2000-2004 + * Wolfgang Denk, DENX Software Engineering, w...@denx.de. + * + * (C) Copyright 2012 + * Ilya Yanok ilya.ya...@gmail.com + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc. + */ +#include common.h +#include net.h +#include asm/omap_common.h + +DECLARE_GLOBAL_DATA_PTR
Re: [U-Boot] [PATCH v6 3/4] OMAP: networking support for SPL
Hi Tom, On Tue, Sep 18, 2012 at 4:17 AM, Tom Rini tr...@ti.com wrote: Please add a GPLv2+ header to the file, thanks. Done. diff --git a/lib/vsprintf.c b/lib/vsprintf.c index e38a4b7..6bb819c 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -784,7 +784,7 @@ void panic(const char *fmt, ...) vprintf(fmt, args); putc('\n'); va_end(args); -#if defined (CONFIG_PANIC_HANG) +#if defined (CONFIG_PANIC_HANG) || defined(CONFIG_SPL_BUILD) hang(); #else udelay (10);/* allow messages to go out */ Oh no, this change... Do we still really need this? Seems like it's not needed anymore. I've removed it. diff --git a/net/tftp.c b/net/tftp.c index 59a8ebb..baba8f3 100644 --- a/net/tftp.c +++ b/net/tftp.c @@ -7,6 +7,10 @@ */ #include common.h +#ifdef CONFIG_SPL_BUILD +#undef CONFIG_CMD_TFTPPUT +#undef CONFIG_CMD_TFTPSRV +#endif #include command.h #include net.h #include tftp.h Missed this. Yes, sorry. Also I saw a few manual inclusions of config_uncmd_spl.h, please fix those since mkconfig adds it always. Thanks. Hm, I can't see any. I reposted only this patch. Hope it's ok now. Regards, Ilya. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v5 4/5] OMAP: networking support for SPL
Hi Joe, On Thu, Aug 30, 2012 at 1:25 AM, Joe Hershberger joe.hershber...@gmail.comwrote: diff --git a/arch/arm/cpu/armv7/omap-common/Makefile b/arch/arm/cpu/armv7/omap-common/Makefile index d37b22d..f042078 100644 --- a/arch/arm/cpu/armv7/omap-common/Makefile +++ b/arch/arm/cpu/armv7/omap-common/Makefile @@ -53,6 +53,9 @@ endif ifdef CONFIG_SPL_YMODEM_SUPPORT COBJS += spl_ymodem.o endif +ifdef CONFIG_SPL_NET_SUPPORT +COBJS += spl_net.o +endif Why not use common pattern of... COBJS-$(CONFIG_SPL_NET_SUPPORT) += spl_net.o COBJS := $(sort $(COBJS-y)) In fact, I'm just following the existing style here... But I can change it as you requested. +#include common.h +#include net.h +#include asm/omap_common.h What in here needs this header? Looks like it's unneeded. Thanks, I'll remove it. diff --git a/common/command.c b/common/command.c index aa0fb0a..9827c70 100644 --- a/common/command.c +++ b/common/command.c @@ -526,7 +526,7 @@ enum command_ret_t cmd_process(int flag, int argc, char * const argv[], if (argc cmdtp-maxargs) rc = CMD_RET_USAGE; -#if defined(CONFIG_CMD_BOOTD) +#ifdef CONFIG_CMD_BOOTD Unrelated style change. Yep, it came from earlier version. Will fix. -#ifdef CONFIG_BOOTP_VCI_STRING +#if defined(CONFIG_BOOTP_VCI_STRING) || \ + (defined(CONFIG_SPL_BUILD) defined(CONFIG_SPL_NET_VCI_STRING)) +#ifndef CONFIG_SPL_BUILD Don't use negative logic for no reason. Ok, Will fix. put_vci(e, CONFIG_VCI_STRING); +#else + put_vci(e, CONFIG_SPL_NET_VCI_STRING); +#endif #endif #if defined(CONFIG_BOOTP_SUBNETMASK) diff --git a/net/net.c b/net/net.c index e8ff066..bbd1a6d 100644 --- a/net/net.c +++ b/net/net.c @@ -81,6 +81,19 @@ #include common.h +#ifdef CONFIG_SPL_BUILD +/* SPL needs only BOOTP + TFTP so undefine other stuff to save space */ +#undef CONFIG_CMD_DHCP +#undef CONFIG_CMD_CDP +#undef CONFIG_CMD_DNS +#undef CONFIG_CMD_LINK_LOCAL +#undef CONFIG_CMD_NFS +#undef CONFIG_CMD_PING +#undef CONFIG_CMD_RARP +#undef CONFIG_CMD_SNTP +#undef CONFIG_CMD_TFTPPUT +#undef CONFIG_CMD_TFTPSRV +#endif Is this the best place to do this? Seems it would be clearer to modify config_cmd_default.h or add a config_cmd_spl.h that will undefine them, and include that. I agree it's not the best place... config_cmd_spl.h sounds a little bit crazy as we don't have any commands at all in SPL... Regards, Ilya. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v5 4/5] OMAP: networking support for SPL
Hi Tom, On Mon, Sep 17, 2012 at 9:04 PM, Tom Rini tr...@ti.com wrote: I agree it's not the best place... config_cmd_spl.h sounds a little bit crazy as we don't have any commands at all in SPL... How about config_uncmd_spl.h then and a nice big comment up top Well, it will be at least less confusing... explaining what we're doing. Or can we take another stab at seeing why some stuff isn't being garbage collected? If garbage_collected_func_a calls never_seen_while_linking_func, we still succeed since we garbage collect the first func. There's just the gcc issue I've noted before about strings. That's not really about garbage collection in this case (net-spl). I want to disable some functionality of generic net code not some stuff used only by commands implementation. The confusion comes from the fact that this code is protected by CONFIG_CMD_* defines. Regards, Ilya. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v5 4/5] OMAP: networking support for SPL
On Mon, Sep 17, 2012 at 10:07 PM, Tom Rini tr...@ti.com wrote: That's not really about garbage collection in this case (net-spl). I want to disable some functionality of generic net code not some stuff used only by commands implementation. The confusion comes from the fact that this code is protected by CONFIG_CMD_* defines. So I guess the code construct is roughly: function_we_need(...) { #ifdef CONFIG_CMD_A ... stuff_spl_does_not_need(); #endif ... } ? Otherwise we would end up building files we don't use, but then all of the un-used code gets garbage collected. Exactly. Regards, Ilya. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v5 4/5] OMAP: networking support for SPL
BTW, I'm going to repost this serie soon. Shouldn't I rebase it on top of your SPL rework patches? Where can I find the tree? Regards, Ilya. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v5 4/5] OMAP: networking support for SPL
On Mon, Sep 17, 2012 at 1:55 PM, Ilya Yanok ilya.ya...@cogentembedded.comwrote: +#include common.h +#include net.h +#include asm/omap_common.h What in here needs this header? Looks like it's unneeded. Thanks, I'll remove it. Nope, it's needed for spl_parse_image_header. Regards, Ilya. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v6 2/4] OMAP: spl: call timer_init() from SPL
We need to initialize timer properly, otherwise all delays inside SPL will be wrong. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- Changes in v6: - fix typo in patch name arch/arm/cpu/armv7/omap-common/spl.c |2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/cpu/armv7/omap-common/spl.c b/arch/arm/cpu/armv7/omap-common/spl.c index 4d1ac85..f0d766c 100644 --- a/arch/arm/cpu/armv7/omap-common/spl.c +++ b/arch/arm/cpu/armv7/omap-common/spl.c @@ -152,6 +152,8 @@ void board_init_r(gd_t *id, ulong dummy) mem_malloc_init(CONFIG_SYS_SPL_MALLOC_START, CONFIG_SYS_SPL_MALLOC_SIZE); + timer_init(); + #ifdef CONFIG_SPL_BOARD_INIT spl_board_init(); #endif -- 1.7.9.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v6 0/4] OMAP: SPL networking support
These series provides support for networking in SPL. In this version some effort is done to minimize the resulting SPL size and now Net-only SPL is 50KB in size. So theoretically it can be used on boards with enough SRAM space like AM3517. But real testing was done only on AM335x. Changes in v3: - use BOOTP in SPL regardless of CONFIG_CMD_DHCP - add support for setting different VCI in SPL - set Vendor Class Identifier for SPL Changes in v4: - used strlen instead of sizeof - moved vci_strlen var inside macro - fix compilation of SPL's libcommon with CONFIG_HUSH_PARSER and CONFIG_BOOTD defined - rename spl_eth.c to spl_net.c - set ethact variable if device name is passed - SPL_BOARD_INIT is not needed anymore Changes in v5: - set up guards in cmd_nvedit.c more carefully - now we don't need command.c and only need main.c for show_boot_progress() so defined it to be noop and remove both files from SPL sources - SPL guards in command.c and main.c are no longer needed - add some guards in env_common.c - qsort.c is no longer needed - add guard to hashtable.c to save some space - undefine unneeded CONFIG_CMD_* while building SPL to save space Changes in v6: - fix typo in patch name - remove some unneeded changes introduced by earlier versions - switch clauses and use ifdef instead of ifndef - create new header config_uncmd_spl.h which undefines CONFIG_CMD_* options unneeded in SPL and include it last from config.h - remove explicit undefs from net/net.c and net/bootp.c Ilya Yanok (4): net/bootp: add VCI support for BOOTP also OMAP: spl: call timer_init() from SPL OMAP: networking support for SPL am335x_evm: enable networking in SPL arch/arm/cpu/armv7/omap-common/Makefile |3 ++ arch/arm/cpu/armv7/omap-common/spl.c | 11 +++ arch/arm/cpu/armv7/omap-common/spl_net.c | 52 ++ arch/arm/include/asm/omap_common.h |4 +++ common/Makefile |4 +++ common/cmd_nvedit.c |8 + common/env_common.c |7 ++-- include/bootstage.h |6 +++- include/config_uncmd_spl.h | 24 ++ include/configs/am335x_evm.h |5 ++- lib/Makefile |9 -- lib/hashtable.c |2 ++ lib/vsprintf.c |2 +- mkconfig |1 + net/bootp.c | 27 net/tftp.c |4 +++ spl/Makefile |3 ++ 17 files changed, 159 insertions(+), 13 deletions(-) create mode 100644 arch/arm/cpu/armv7/omap-common/spl_net.c create mode 100644 include/config_uncmd_spl.h -- 1.7.9.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v6 4/4] am335x_evm: enable networking in SPL
This patch adds support for networking in SPL on TI AM335x based boards. Vendor Class Identifier used by SPL during BOOTP is AM335x U-Boot SPL. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- Changes in v3: - set Vendor Class Identifier for SPL Changes in v4: - SPL_BOARD_INIT is not needed anymore include/configs/am335x_evm.h |5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h index a3752bc..1d69125 100644 --- a/include/configs/am335x_evm.h +++ b/include/configs/am335x_evm.h @@ -194,7 +194,7 @@ /* Defines for SPL */ #define CONFIG_SPL #define CONFIG_SPL_TEXT_BASE 0x402F0400 -#define CONFIG_SPL_MAX_SIZE(46 * 1024) +#define CONFIG_SPL_MAX_SIZE(101 * 1024) #define CONFIG_SPL_STACK CONFIG_SYS_INIT_SP_ADDR #define CONFIG_SPL_BSS_START_ADDR 0x8000 @@ -214,6 +214,9 @@ #define CONFIG_SPL_SERIAL_SUPPORT #define CONFIG_SPL_GPIO_SUPPORT #define CONFIG_SPL_YMODEM_SUPPORT +#define CONFIG_SPL_NET_SUPPORT +#define CONFIG_SPL_NET_VCI_STRING AM335x U-Boot SPL +#define CONFIG_SPL_ETH_SUPPORT #define CONFIG_SPL_LDSCRIPT$(CPUDIR)/omap-common/u-boot-spl.lds /* -- 1.7.9.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v6 3/4] OMAP: networking support for SPL
This patch adds support for networking in SPL. Some devices are capable of loading SPL via network so it makes sense to load the main U-Boot binary via network too. This patch tries to use existing network code as much as possible. Unfortunately, it depends on environment which in turn depends on other code so SPL size is increased significantly. No effort was done to decouple network code and environment so far. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- Changes in v3: - use BOOTP in SPL regardless of CONFIG_CMD_DHCP - add support for setting different VCI in SPL Changes in v4: - fix compilation of SPL's libcommon with CONFIG_HUSH_PARSER and CONFIG_BOOTD defined - rename spl_eth.c to spl_net.c - set ethact variable if device name is passed Changes in v5: - set up guards in cmd_nvedit.c more carefully - now we don't need command.c and only need main.c for show_boot_progress() so defined it to be noop and remove both files from SPL sources - SPL guards in command.c and main.c are no longer needed - add some guards in env_common.c - qsort.c is no longer needed - add guard to hashtable.c to save some space - undefine unneeded CONFIG_CMD_* while building SPL to save space Changes in v6: - remove some unneeded changes introduced by earlier versions - switch clauses and use ifdef instead of ifndef - create new header config_uncmd_spl.h which undefines CONFIG_CMD_* options unneeded in SPL and include it last from config.h - remove explicit undefs from net/net.c and net/bootp.c arch/arm/cpu/armv7/omap-common/Makefile |3 ++ arch/arm/cpu/armv7/omap-common/spl.c |9 ++ arch/arm/cpu/armv7/omap-common/spl_net.c | 52 ++ arch/arm/include/asm/omap_common.h |4 +++ common/Makefile |4 +++ common/cmd_nvedit.c |8 + common/env_common.c |7 ++-- include/bootstage.h |6 +++- include/config_uncmd_spl.h | 24 ++ lib/Makefile |9 -- lib/hashtable.c |2 ++ lib/vsprintf.c |2 +- mkconfig |1 + net/bootp.c |7 +++- net/tftp.c |4 +++ spl/Makefile |3 ++ 16 files changed, 138 insertions(+), 7 deletions(-) create mode 100644 arch/arm/cpu/armv7/omap-common/spl_net.c create mode 100644 include/config_uncmd_spl.h diff --git a/arch/arm/cpu/armv7/omap-common/Makefile b/arch/arm/cpu/armv7/omap-common/Makefile index d37b22d..f042078 100644 --- a/arch/arm/cpu/armv7/omap-common/Makefile +++ b/arch/arm/cpu/armv7/omap-common/Makefile @@ -53,6 +53,9 @@ endif ifdef CONFIG_SPL_YMODEM_SUPPORT COBJS += spl_ymodem.o endif +ifdef CONFIG_SPL_NET_SUPPORT +COBJS += spl_net.o +endif endif ifndef CONFIG_SPL_BUILD diff --git a/arch/arm/cpu/armv7/omap-common/spl.c b/arch/arm/cpu/armv7/omap-common/spl.c index f0d766c..53b9261 100644 --- a/arch/arm/cpu/armv7/omap-common/spl.c +++ b/arch/arm/cpu/armv7/omap-common/spl.c @@ -178,6 +178,15 @@ void board_init_r(gd_t *id, ulong dummy) spl_ymodem_load_image(); break; #endif +#ifdef CONFIG_SPL_ETH_SUPPORT + case BOOT_DEVICE_CPGMAC: +#ifdef CONFIG_SPL_ETH_DEVICE + spl_net_load_image(CONFIG_SPL_ETH_DEVICE); +#else + spl_net_load_image(NULL); +#endif + break; +#endif default: printf(SPL: Un-supported Boot Device - %d!!!\n, boot_device); hang(); diff --git a/arch/arm/cpu/armv7/omap-common/spl_net.c b/arch/arm/cpu/armv7/omap-common/spl_net.c new file mode 100644 index 000..cbb3087 --- /dev/null +++ b/arch/arm/cpu/armv7/omap-common/spl_net.c @@ -0,0 +1,52 @@ +/* + * (C) Copyright 2000-2004 + * Wolfgang Denk, DENX Software Engineering, w...@denx.de. + * + * (C) Copyright 2012 + * Ilya Yanok ilya.ya...@gmail.com + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc. + */ +#include common.h +#include net.h +#include asm/omap_common.h + +DECLARE_GLOBAL_DATA_PTR; + +void spl_net_load_image(const char *device) +{ + int rv
[U-Boot] [PATCH v6 1/4] net/bootp: add VCI support for BOOTP also
Vendor Class Identifier option is common to BOOTP and DHCP and can be useful without PXE. So send VCI in both BOOTP and DHCP requests if CONFIG_BOOTP_VCI_STRING is defined. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- Changes in v4: - used strlen instead of sizeof - moved vci_strlen var inside macro net/bootp.c | 22 -- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/net/bootp.c b/net/bootp.c index c9b8349..35b2e77 100644 --- a/net/bootp.c +++ b/net/bootp.c @@ -341,6 +341,15 @@ BootpTimeout(void) } } +#define put_vci(e, str)\ + do {\ + size_t vci_strlen = strlen(str);\ + *e++ = 60; /* Vendor Class Identifier */ \ + *e++ = vci_strlen; \ + memcpy(e, str, vci_strlen); \ + e += vci_strlen;\ + } while (0) + /* * Initialize BOOTP extension fields in the request. */ @@ -352,7 +361,6 @@ static int DhcpExtended(u8 *e, int message_type, IPaddr_t ServerID, u8 *cnt; #if defined(CONFIG_BOOTP_PXE) char *uuid; - size_t vci_strlen; u16 clientarch; #endif @@ -437,12 +445,10 @@ static int DhcpExtended(u8 *e, int message_type, IPaddr_t ServerID, printf(Invalid pxeuuid: %s\n, uuid); } } +#endif - *e++ = 60; /* Vendor Class Identifier */ - vci_strlen = strlen(CONFIG_BOOTP_VCI_STRING); - *e++ = vci_strlen; - memcpy(e, CONFIG_BOOTP_VCI_STRING, vci_strlen); - e += vci_strlen; +#ifdef CONFIG_BOOTP_VCI_STRING + put_vci(e, CONFIG_VCI_STRING); #endif #if defined(CONFIG_BOOTP_VENDOREX) @@ -529,6 +535,10 @@ static int BootpExtended(u8 *e) *e++ = (576 - 312 + OPT_FIELD_SIZE) 0xff; #endif +#ifdef CONFIG_BOOTP_VCI_STRING + put_vci(e, CONFIG_VCI_STRING); +#endif + #if defined(CONFIG_BOOTP_SUBNETMASK) *e++ = 1; /* Subnet mask request */ *e++ = 4; -- 1.7.9.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [RFC PATCH v2 1/6] linux/usb/ch9.h: update with the version from Linux tree
Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- drivers/usb/gadget/config.c |1 - drivers/usb/gadget/epautoconf.c |1 - drivers/usb/gadget/ether.c |1 - drivers/usb/gadget/s3c_udc_otg.c |1 - drivers/usb/gadget/usbstring.c |1 - include/linux/usb/ch9.h | 514 -- include/usb/s3c_udc.h|1 - 7 files changed, 499 insertions(+), 21 deletions(-) diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c index f88d0c1..f9163a8 100644 --- a/drivers/usb/gadget/config.c +++ b/drivers/usb/gadget/config.c @@ -27,7 +27,6 @@ #include linux/string.h #include linux/usb/ch9.h -#include usbdescriptors.h #include linux/usb/gadget.h diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index b656c8b..5b8776e 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -23,7 +23,6 @@ #include common.h #include linux/usb/ch9.h -#include usbdescriptors.h #include asm/errno.h #include linux/usb/gadget.h #include asm/unaligned.h diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index d975fb6..6f7e4cd 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -24,7 +24,6 @@ #include asm/errno.h #include linux/netdevice.h #include linux/usb/ch9.h -#include usbdescriptors.h #include linux/usb/cdc.h #include linux/usb/gadget.h #include net.h diff --git a/drivers/usb/gadget/s3c_udc_otg.c b/drivers/usb/gadget/s3c_udc_otg.c index 3fdfdf7..f9d24e3 100644 --- a/drivers/usb/gadget/s3c_udc_otg.c +++ b/drivers/usb/gadget/s3c_udc_otg.c @@ -37,7 +37,6 @@ #include malloc.h #include linux/usb/ch9.h -#include usbdescriptors.h #include linux/usb/gadget.h #include asm/byteorder.h diff --git a/drivers/usb/gadget/usbstring.c b/drivers/usb/gadget/usbstring.c index 4dbe060..9cf 100644 --- a/drivers/usb/gadget/usbstring.c +++ b/drivers/usb/gadget/usbstring.c @@ -13,7 +13,6 @@ #include common.h #include asm/errno.h #include linux/usb/ch9.h -#include usbdescriptors.h #include linux/usb/gadget.h #include asm/unaligned.h diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h index ce1d1e1..d1d732c 100644 --- a/include/linux/usb/ch9.h +++ b/include/linux/usb/ch9.h @@ -28,15 +28,13 @@ * [c] for consistency, removing all doubt even when it appears to * someone that the two other points are non-issues for that * particular descriptor type. - * - * Ported to U-boot by: Thomas Smits ts.sm...@gmail.com and - * Remy Bohmer li...@bohmer.net */ #ifndef __LINUX_USB_CH9_H #define __LINUX_USB_CH9_H #include linux/types.h /* __u8 etc */ +#include asm/byteorder.h /* le16_to_cpu */ /*-*/ @@ -70,7 +68,7 @@ #define USB_RECIP_OTHER0x03 /* From Wireless USB 1.0 */ #define USB_RECIP_PORT 0x04 -#define USB_RECIP_RPIPE0x05 +#define USB_RECIP_RPIPE0x05 /* * Standard requests, for the bRequest field of a SETUP packet. @@ -90,6 +88,8 @@ #define USB_REQ_GET_INTERFACE 0x0A #define USB_REQ_SET_INTERFACE 0x0B #define USB_REQ_SYNCH_FRAME0x0C +#define USB_REQ_SET_SEL0x30 +#define USB_REQ_SET_ISOCH_DELAY0x31 #define USB_REQ_SET_ENCRYPTION 0x0D/* Wireless USB */ #define USB_REQ_GET_ENCRYPTION 0x0E @@ -105,10 +105,16 @@ #define USB_REQ_LOOPBACK_DATA_READ 0x16 #define USB_REQ_SET_INTERFACE_DS 0x17 +/* The Link Power Management (LPM) ECN defines USB_REQ_TEST_AND_SET command, + * used by hubs to put ports into a new L1 suspend state, except that it + * forgot to define its number ... + */ + /* * USB feature flags are written using USB_REQ_{CLEAR,SET}_FEATURE, and * are read as a bit array returned by USB_REQ_GET_STATUS. (So there - * are at most sixteen features of each type.) + * are at most sixteen features of each type.) Hubs may also support a + * new USB_REQ_TEST_AND_SET_FEATURE to put ports into L1 suspend. */ #define USB_DEVICE_SELF_POWERED0 /* (read only) */ #define USB_DEVICE_REMOTE_WAKEUP 1 /* dev may initiate wakeup */ @@ -120,8 +126,38 @@ #define USB_DEVICE_A_ALT_HNP_SUPPORT 5 /* (otg) other RH port does */ #define USB_DEVICE_DEBUG_MODE 6 /* (special devices only) */ +/* + * Test Mode Selectors + * See USB 2.0 spec Table 9-7 + */ +#defineTEST_J 1 +#defineTEST_K 2 +#defineTEST_SE0_NAK3 +#defineTEST_PACKET 4 +#defineTEST_FORCE_EN 5 + +/* + * New Feature Selectors as added by USB 3.0 + * See USB 3.0 spec Table 9-6 + */ +#define USB_DEVICE_U1_ENABLE 48 /* dev may initiate U1 transition */ +#define USB_DEVICE_U2_ENABLE 49 /* dev may initiate U2 transition
[U-Boot] [RFC PATCH v2 0/6] Port of MUSB driver from Linux
Current MUSB driver in U-Boot uses old UDC API while new gagdet client drivers need new gadget API. Also current MUSB driver has some significant limitations (like inability to handle tx for endpoints other than ep0). So I think port of new Linux driver is desirable. This is initial port, performed mostly by putting DM and OTG code under #ifndef __UBOOT__ clauses. My intention was to be as close as possible to the original to ease of possible resyncs. Some warnings are suppressed via CFLAGS. There are some style problems but I'm not touching them for now for the above mentioned reason. There is obviously some room for optimisation, some structure fields are unused as well as (probably) some code. This is not a replacement for existing MUSB driver (at least for now), cause there are still consumers of the old interface and the only ported backend is for TI AM335X (while the old code has a bunch of other backends). OTG and DMA are not supported. The only ported driver is for TI AM33xx, but others should be easy to port too. Virtual root hub is not implemented but this shouldn't be a big problem as the old code has virtual root hub support enabled only for Blackfin platform. Tested it on AM335x EVM and BeagleBone with CDC Ethernet gadget and a bunch of storage devices. Pathes are rather big because of the original code size (and I didn't delete unused code, just disabled it). So it's probably better to look at changes as compared to Linux code. I prepared such version also, you can find it at [1]. Hopefully it will be also useful if resync with the kernel will be needed in future. [1] https://github.com/yanok/u-boot/tree/musb-changes-from-linux Changes in v2: - add missing linux-compat.h header - added host support - glue code moved from musb_gadget_uboot.c to musb_uboot.c and cleaned up slightly. - added check for malloc return value - define is_{host,peripheral}_capable conditionally to support compilation with only host or gadget enabled - added some more is_{host,peripheral}_capable guards to core code to support compilation with only host or gadget enabled - rename backend config option to CONFIG_USB_MUSB_DSPS - we are providing host support now so add yourself to usb.h - init both musb IPs (conditionally) from arch_init not from eth_initialize - host support enabled - define CONFIG_ARCH_INIT as now musb_register() is called from arch_init() - use new config options Ilya Yanok (6): linux/usb/ch9.h: update with the version from Linux tree usb: use linux/usb/ch9.h instead of usbdescriptors.h musb-new: port of Linux musb driver musb-new: dsps backend driver am33xx: init OTG hardware and new musb gadget driver am335x_evm: enable both musb gadget and host Makefile |1 + arch/arm/cpu/arm920t/s3c24x0/usb_ohci.c |2 +- arch/arm/cpu/armv7/am33xx/board.c | 107 +- arch/arm/cpu/armv7/am33xx/clock.c |8 + arch/arm/include/asm/arch-am33xx/cpu.h| 11 +- arch/arm/include/asm/arch-am33xx/hardware.h |4 + arch/arm/include/asm/omap_musb.h | 25 + arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c |2 +- arch/powerpc/cpu/mpc5xxx/usb_ohci.c |2 +- arch/powerpc/cpu/ppc4xx/usb_ohci.c|2 +- common/cmd_usb.c |2 +- common/usb.c |4 +- drivers/usb/gadget/config.c |1 - drivers/usb/gadget/epautoconf.c |1 - drivers/usb/gadget/ether.c|1 - drivers/usb/gadget/gadget_chips.h |2 + drivers/usb/gadget/s3c_udc_otg.c |1 - drivers/usb/gadget/usbstring.c|1 - drivers/usb/host/ehci-hcd.c | 16 +- drivers/usb/host/isp116x-hcd.c|2 +- drivers/usb/host/ohci-hcd.c |2 +- drivers/usb/host/sl811-hcd.c |2 +- drivers/usb/musb-new/Makefile | 37 + drivers/usb/musb-new/linux-compat.h | 109 ++ drivers/usb/musb-new/musb_core.c | 2497 + drivers/usb/musb-new/musb_core.h | 623 ++ drivers/usb/musb-new/musb_debug.h | 58 + drivers/usb/musb-new/musb_dma.h | 186 ++ drivers/usb/musb-new/musb_dsps.c | 771 drivers/usb/musb-new/musb_gadget.c| 2333 +++ drivers/usb/musb-new/musb_gadget.h| 130 ++ drivers/usb/musb-new/musb_gadget_ep0.c| 1089 +++ drivers/usb/musb-new/musb_host.c | 2400 drivers/usb/musb-new/musb_host.h | 114 ++ drivers/usb/musb-new/musb_io.h| 146 ++ drivers/usb/musb-new/musb_regs.h | 645 +++ drivers/usb/musb-new/musb_uboot.c | 237 +++ drivers/usb/musb-new/usb-compat.h | 88
[U-Boot] [RFC PATCH v2 4/6] musb-new: dsps backend driver
Backend driver for MUSB OTG controllers found on TI AM33xx and TI81xx SoCs (tested with AM33xx only). Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- Changes in v2: - rename backend config option to CONFIG_USB_MUSB_DSPS - we are providing host support now so add yourself to usb.h arch/arm/include/asm/omap_musb.h | 25 ++ drivers/usb/musb-new/Makefile|1 + drivers/usb/musb-new/musb_dsps.c | 771 ++ include/usb.h|3 +- 4 files changed, 799 insertions(+), 1 deletion(-) create mode 100644 arch/arm/include/asm/omap_musb.h create mode 100644 drivers/usb/musb-new/musb_dsps.c diff --git a/arch/arm/include/asm/omap_musb.h b/arch/arm/include/asm/omap_musb.h new file mode 100644 index 000..0081a68 --- /dev/null +++ b/arch/arm/include/asm/omap_musb.h @@ -0,0 +1,25 @@ +/* + * Board data structure for musb gadget on OMAPs + * + * Copyright (C) 2012, Ilya Yanok ilya.ya...@gmail.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. + */ + +#ifndef __ASM_ARM_OMAP_MUSB_H +#define __ASM_ARM_OMAP_MUSB_H + +extern struct musb_platform_ops musb_dsps_ops; + +struct omap_musb_board_data { + void (*set_phy_power)(u8 on); +}; +#endif /* __ASM_ARM_OMAP_MUSB_H */ diff --git a/drivers/usb/musb-new/Makefile b/drivers/usb/musb-new/Makefile index f01fb16..a753423 100644 --- a/drivers/usb/musb-new/Makefile +++ b/drivers/usb/musb-new/Makefile @@ -9,6 +9,7 @@ LIB := $(obj)libusb_musb-new.o COBJS-$(CONFIG_MUSB_GADGET) += musb_gadget.o musb_gadget_ep0.o musb_core.o COBJS-$(CONFIG_MUSB_GADGET) += musb_uboot.o COBJS-$(CONFIG_MUSB_HOST) += musb_host.o musb_core.o musb_uboot.o +COBJS-$(CONFIG_USB_MUSB_DSPS) += musb_dsps.o CFLAGS_NO_WARN := $(call cc-option,-Wno-unused-variable) \ $(call cc-option,-Wno-unused-but-set-variable) \ diff --git a/drivers/usb/musb-new/musb_dsps.c b/drivers/usb/musb-new/musb_dsps.c new file mode 100644 index 000..9a03917 --- /dev/null +++ b/drivers/usb/musb-new/musb_dsps.c @@ -0,0 +1,771 @@ +/* + * Texas Instruments DSPS platforms glue layer + * + * Copyright (C) 2012, by Texas Instruments + * + * Based on the am35x glue layer code. + * + * This file is part of the Inventra Controller Driver for Linux. + * + * The Inventra Controller Driver for Linux is free software; you + * can redistribute it and/or modify it under the terms of the GNU + * General Public License version 2 as published by the Free Software + * Foundation. + * + * The Inventra Controller Driver for Linux 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 The Inventra Controller Driver for Linux ; if not, + * write to the Free Software Foundation, Inc., 59 Temple Place, + * Suite 330, Boston, MA 02111-1307 USA + * + * musb_dsps.c will be a common file for all the TI DSPS platforms + * such as dm64x, dm36x, dm35x, da8x, am35x and ti81x. + * For now only ti81x is using this and in future davinci.c, am35x.c + * da8xx.c would be merged to this file after testing. + */ + +#define __UBOOT__ +#ifndef __UBOOT__ +#include linux/init.h +#include linux/io.h +#include linux/err.h +#include linux/platform_device.h +#include linux/dma-mapping.h +#include linux/pm_runtime.h +#include linux/module.h + +#include linux/of.h +#include linux/of_device.h +#include linux/of_address.h + +#include plat/usb.h +#else +#include common.h +#include asm/omap_musb.h +#include linux-compat.h +#endif + +#include musb_core.h + +/** + * avoid using musb_readx()/musb_writex() as glue layer should not be + * dependent on musb core layer symbols. + */ +static inline u8 dsps_readb(const void __iomem *addr, unsigned offset) + { return __raw_readb(addr + offset); } + +static inline u32 dsps_readl(const void __iomem *addr, unsigned offset) + { return __raw_readl(addr + offset); } + +static inline void dsps_writeb(void __iomem *addr, unsigned offset, u8 data) + { __raw_writeb(data, addr + offset); } + +static inline void dsps_writel(void __iomem *addr, unsigned offset, u32 data) + { __raw_writel(data, addr + offset); } + +/** + * DSPS musb wrapper register offset. + * FIXME: This should be expanded to have all the wrapper registers from TI DSPS + * musb ips. + */ +struct dsps_musb_wrapper { + u16
[U-Boot] [RFC PATCH v2 2/6] usb: use linux/usb/ch9.h instead of usbdescriptors.h
Linux usb/ch9.h seems to have all the same information (and more) as usbdescriptors.h so use the former instead of the later one. As a consequense of this change USB_SPEED_* values don't correspond directly to EHCI speed encoding anymore, I've added necessary recoding in EHCI driver. Also there is no point to put speed into pipe anymore so it's removed and a bunch of host drivers fixed to look at usb_device-speed instead. Old usbdescriptors.h included is not removed as it seems to be used by old USB device code. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- arch/arm/cpu/arm920t/s3c24x0/usb_ohci.c |2 +- arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c |2 +- arch/powerpc/cpu/mpc5xxx/usb_ohci.c |2 +- arch/powerpc/cpu/ppc4xx/usb_ohci.c|2 +- common/cmd_usb.c |2 +- common/usb.c |4 ++-- drivers/usb/host/ehci-hcd.c | 16 ++-- drivers/usb/host/isp116x-hcd.c|2 +- drivers/usb/host/ohci-hcd.c |2 +- drivers/usb/host/sl811-hcd.c |2 +- drivers/usb/musb/musb_hcd.c |4 ++-- include/usb.h | 15 +++ include/usb_defs.h|6 -- 13 files changed, 29 insertions(+), 32 deletions(-) diff --git a/arch/arm/cpu/arm920t/s3c24x0/usb_ohci.c b/arch/arm/cpu/arm920t/s3c24x0/usb_ohci.c index cf0335c..fad1d25 100644 --- a/arch/arm/cpu/arm920t/s3c24x0/usb_ohci.c +++ b/arch/arm/cpu/arm920t/s3c24x0/usb_ohci.c @@ -620,7 +620,7 @@ static struct ed *ep_add_ed(struct usb_device *usb_dev, unsigned long pipe) | (usb_pipeisoc(pipe) ? 0x8000 : 0) | (usb_pipecontrol(pipe) ? 0 : (usb_pipeout(pipe) ? 0x800 : 0x1000)) - | usb_pipeslow(pipe) 13 | + | (usb_dev-speed == USB_SPEED_LOW) 13 | usb_maxpacket(usb_dev, pipe) 16); return ed_ret; diff --git a/arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c b/arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c index 7647e11..07bbf6d 100644 --- a/arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c +++ b/arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c @@ -615,7 +615,7 @@ static ed_t * ep_add_ed (struct usb_device *usb_dev, unsigned long pipe) | usb_pipeendpoint (pipe) 7 | (usb_pipeisoc (pipe)? 0x8000: 0) | (usb_pipecontrol (pipe)? 0: (usb_pipeout (pipe)? 0x800: 0x1000)) - | usb_pipeslow (pipe) 13 + | (usb_dev-speed == USB_SPEED_LOW) 13 | usb_maxpacket (usb_dev, pipe) 16); return ed_ret; diff --git a/arch/powerpc/cpu/mpc5xxx/usb_ohci.c b/arch/powerpc/cpu/mpc5xxx/usb_ohci.c index 6d91525..19019b3 100644 --- a/arch/powerpc/cpu/mpc5xxx/usb_ohci.c +++ b/arch/powerpc/cpu/mpc5xxx/usb_ohci.c @@ -618,7 +618,7 @@ static ed_t * ep_add_ed (struct usb_device *usb_dev, unsigned long pipe) | usb_pipeendpoint (pipe) 7 | (usb_pipeisoc (pipe)? 0x8000: 0) | (usb_pipecontrol (pipe)? 0: (usb_pipeout (pipe)? 0x800: 0x1000)) - | usb_pipeslow (pipe) 13 + | (usb_dev-speed == USB_SPEED_LOW) 13 | usb_maxpacket (usb_dev, pipe) 16); return ed_ret; diff --git a/arch/powerpc/cpu/ppc4xx/usb_ohci.c b/arch/powerpc/cpu/ppc4xx/usb_ohci.c index 14c6a28..33a9d6b 100644 --- a/arch/powerpc/cpu/ppc4xx/usb_ohci.c +++ b/arch/powerpc/cpu/ppc4xx/usb_ohci.c @@ -621,7 +621,7 @@ static ed_t * ep_add_ed (struct usb_device *usb_dev, unsigned long pipe) | usb_pipeendpoint (pipe) 7 | (usb_pipeisoc (pipe)? 0x8000: 0) | (usb_pipecontrol (pipe)? 0: (usb_pipeout (pipe)? 0x800: 0x1000)) - | usb_pipeslow (pipe) 13 + | (usb_dev-speed == USB_SPEED_LOW) 13 | usb_maxpacket (usb_dev, pipe) 16); return ed_ret; diff --git a/common/cmd_usb.c b/common/cmd_usb.c index a8e3ae5..203c733 100644 --- a/common/cmd_usb.c +++ b/common/cmd_usb.c @@ -192,7 +192,7 @@ void usb_display_desc(struct usb_device *dev) } -void usb_display_conf_desc(struct usb_configuration_descriptor *config, +void usb_display_conf_desc(struct usb_config_descriptor *config, struct usb_device *dev) { printf( Configuration: %d\n, config-bConfigurationValue); diff --git a/common/usb.c b/common/usb.c index 1b40228..8764820 100644 --- a/common/usb.c +++ b/common/usb.c @@ -459,9 +459,9 @@ int usb_get_configuration_no(struct usb_device *dev, { int result; unsigned int tmp; - struct
[U-Boot] [RFC PATCH v2 5/6] am33xx: init OTG hardware and new musb gadget driver
AM33xx has support for dual port MUSB OTG controller. This patch adds initialization for the controller using new MUSB gadget driver and ether gadget. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- Changes in v2: - init both musb IPs (conditionally) from arch_init not from eth_initialize arch/arm/cpu/armv7/am33xx/board.c | 107 ++- arch/arm/cpu/armv7/am33xx/clock.c |8 ++ arch/arm/include/asm/arch-am33xx/cpu.h | 11 ++- arch/arm/include/asm/arch-am33xx/hardware.h |4 + 4 files changed, 126 insertions(+), 4 deletions(-) diff --git a/arch/arm/cpu/armv7/am33xx/board.c b/arch/arm/cpu/armv7/am33xx/board.c index b387ac2..9007356 100644 --- a/arch/arm/cpu/armv7/am33xx/board.c +++ b/arch/arm/cpu/armv7/am33xx/board.c @@ -33,6 +33,11 @@ #include i2c.h #include miiphy.h #include cpsw.h +#include asm/errno.h +#include linux/usb/ch9.h +#include linux/usb/gadget.h +#include linux/usb/musb.h +#include asm/omap_musb.h DECLARE_GLOBAL_DATA_PTR; @@ -227,6 +232,88 @@ void setup_clocks_for_console(void) return; } +/* AM33XX has two MUSB controllers which can be host or gadget */ +#if (defined(CONFIG_MUSB_GADGET) || defined(CONFIG_MUSB_HOST)) \ + (defined(CONFIG_AM335X_USB0) || defined(CONFIG_AM335X_USB1)) +/* USB 2.0 PHY Control */ +#define CM_PHY_PWRDN (1 0) +#define CM_PHY_OTG_PWRDN (1 1) +#define OTGVDET_EN (1 19) +#define OTGSESSENDEN (1 20) + +static void am33xx_usb_set_phy_power(u8 on, u32 *reg_addr) +{ + u32 usb_ctrl_reg; + + usb_ctrl_reg = readl(reg_addr); + if (on) { + usb_ctrl_reg = ~(CM_PHY_PWRDN | CM_PHY_OTG_PWRDN); + usb_ctrl_reg |= (OTGVDET_EN | OTGSESSENDEN); + } else { + usb_ctrl_reg |= (CM_PHY_PWRDN | CM_PHY_OTG_PWRDN); + } + writel(usb_ctrl_reg, reg_addr); +} + +static struct musb_hdrc_config musb_config = { + .multipoint = 1, + .dyn_fifo = 1, + .num_eps= 16, + .ram_bits = 12, +}; + +#ifdef CONFIG_AM335X_USB0 +static void am33xx_otg0_set_phy_power(u8 on) +{ + am33xx_usb_set_phy_power(on, cdev-usb_ctrl0); +} + +struct omap_musb_board_data otg0_board_data = { + .set_phy_power = am33xx_otg0_set_phy_power, +}; + +static struct musb_hdrc_platform_data otg0_plat = { + .mode = CONFIG_AM335X_USB0_MODE, + .config = musb_config, + .power = 50, + .platform_ops = musb_dsps_ops, + .board_data = otg0_board_data, +}; +#endif + +#ifdef CONFIG_AM335X_USB1 +static void am33xx_otg1_set_phy_power(u8 on) +{ + am33xx_usb_set_phy_power(on, cdev-usb_ctrl1); +} + +struct omap_musb_board_data otg1_board_data = { + .set_phy_power = am33xx_otg1_set_phy_power, +}; + +static struct musb_hdrc_platform_data otg1_plat = { + .mode = CONFIG_AM335X_USB1_MODE, + .config = musb_config, + .power = 50, + .platform_ops = musb_dsps_ops, + .board_data = otg1_board_data, +}; +#endif +#endif + +int arch_misc_init(void) +{ +#ifdef CONFIG_AM335X_USB0 + musb_register(otg0_plat, otg0_board_data, + (void *)AM335X_USB0_OTG_BASE); +#endif +#ifdef CONFIG_AM335X_USB1 + musb_register(otg1_plat, otg1_board_data, + (void *)AM335X_USB1_OTG_BASE); +#endif + return 0; +} + /* * Basic board specific setup. Pinmux has been handled already. */ @@ -279,9 +366,14 @@ static struct cpsw_platform_data cpsw_data = { .host_port_num = 0, .version= CPSW_CTRL_VERSION_2, }; +#endif +#if defined(CONFIG_DRIVER_TI_CPSW) || \ + (defined(CONFIG_USB_ETHER) defined(CONFIG_MUSB_GADGET)) int board_eth_init(bd_t *bis) { + int rv, n = 0; +#ifdef CONFIG_DRIVER_TI_CPSW uint8_t mac_addr[6]; uint32_t mac_hi, mac_lo; @@ -313,6 +405,19 @@ int board_eth_init(bd_t *bis) PHY_INTERFACE_MODE_RGMII; } - return cpsw_register(cpsw_data); + rv = cpsw_register(cpsw_data); + if (rv 0) + printf(Error %d registering CPSW switch\n, rv); + else + n += rv; +#endif +#ifdef CONFIG_USB_ETHER + rv = usb_eth_initialize(bis); + if (rv 0) + printf(Error %d registering USB_ETHER\n, rv); + else + n += rv; +#endif + return n; } #endif diff --git a/arch/arm/cpu/armv7/am33xx/clock.c b/arch/arm/cpu/armv7/am33xx/clock.c index 2b19506..04841e4 100644 --- a/arch/arm/cpu/armv7/am33xx/clock.c +++ b/arch/arm/cpu/armv7/am33xx/clock.c @@ -40,6 +40,7 @@ #define CLK_MODE_MASK 0xfff8 #define CLK_DIV_SEL0xFFE0 #define CPGMAC0_IDLE 0x3 +#define DPLL_CLKDCOLDO_GATE_CTRL0x300 const struct cm_perpll *cmper = (struct cm_perpll *)CM_PER; const struct cm_wkuppll
[U-Boot] [RFC PATCH v2 6/6] am335x_evm: enable both musb gadget and host
Enable musb gadget in Ethernet mode on port 0 and musb host on port1. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- Changes in v2: - host support enabled - define CONFIG_ARCH_INIT as now musb_register() is called from arch_init() - use new config options include/configs/am335x_evm.h | 27 +++ 1 file changed, 27 insertions(+) diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h index a3752bc..7a357f1 100644 --- a/include/configs/am335x_evm.h +++ b/include/configs/am335x_evm.h @@ -233,6 +233,33 @@ #define CONFIG_SKIP_LOWLEVEL_INIT #endif +/* + * USB configuration + */ +#define CONFIG_USB_MUSB_DSPS +#define CONFIG_ARCH_MISC_INIT +#define CONFIG_MUSB_GADGET +#define CONFIG_MUSB_PIO_ONLY +#define CONFIG_USB_GADGET_DUALSPEED +#define CONFIG_MUSB_HOST +#define CONFIG_AM335X_USB0 +#define CONFIG_AM335X_USB0_MODEMUSB_PERIPHERAL +#define CONFIG_AM335X_USB1 +#define CONFIG_AM335X_USB1_MODE MUSB_HOST + +#ifdef CONFIG_MUSB_HOST +#define CONFIG_CMD_USB +#define CONFIG_USB_STORAGE +#endif + +#ifdef CONFIG_MUSB_GADGET +#define CONFIG_USB_ETHER +#define CONFIG_USB_ETH_RNDIS +#endif /* CONFIG_MUSB_GADGET */ + +/* Unsupported features */ +#undef CONFIG_USE_IRQ + #define CONFIG_CMD_NET #define CONFIG_CMD_DHCP #define CONFIG_CMD_PING -- 1.7.9.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] patman doesn't send patches
Hi Stefan, Stefan Roese sr at denx.de writes: Or does patman not even try to send, once checkpatch warning/errors are detected? That's it. Normally you don't want to send patches that are not chackpatch-clean. If you are sure that problems are irrelevant use -i switch to ignore them. Regards, Ilya. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [RFC PATCH 0/5] Port of MUSB gadget driver from Linux
Dear Marek, Wolfgang, On Thu, Aug 9, 2012 at 11:23 PM, Wolfgang Denk w...@denx.de wrote: I hate to say it ... but given that this will cause duplication of code, I'm somehow inclined to push you to do a complete replacement of the old musb code, remove it and add this. Agreed, we should avoid such duplication. I agree with you generally. But I fear I won't have enough time now to port the host part too. Also please note that usbtty works only with the old API now. Regards, Ilya. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v4 1/5] net/bootp: add VCI support for BOOTP also
Hi Joe, On Mon, Aug 6, 2012 at 1:21 AM, Ilya Yanok ilya.ya...@cogentembedded.comwrote: Vendor Class Identifier option is common to BOOTP and DHCP and can be useful without PXE. So send VCI in both BOOTP and DHCP requests if CONFIG_BOOTP_VCI_STRING is defined. Signed-off-by: Ilya Yanok ilya.ya...@cogentembedded.com --- Changes in v4: - moved vci_strlen var inside macro - used strlen instead of sizeof Is it ok now? What about the rest of the series? Regards, Ilya. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v4 5/7] usb_storage: Adjust time-outs
Hi Benoit, On Fri, Aug 10, 2012 at 8:23 PM, Benoît Thébaudeau benoit.thebaud...@advansee.com wrote: Adjust time-out value for the new EHCI mechanism. Could you please be a bit more specific? ;) How this timeout is related to the new mechanism? Is it really EHCI specific? If it is, that's hardcoding of lower layer details again, I think that's undesirable... But generally this series looks really good. Thanks a lot! Regards, Ilya. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v4 4/7] usb_storage: Remove EHCI constraints
Hi Benoit, On Fri, Aug 10, 2012 at 8:23 PM, Benoît Thébaudeau benoit.thebaud...@advansee.com wrote: diff --git u-boot-usb-4f8254e.orig/common/usb_storage.c u-boot-usb-4f8254e/common/usb_storage.c index 0cd6399..822bd64 100644 --- u-boot-usb-4f8254e.orig/common/usb_storage.c +++ u-boot-usb-4f8254e/common/usb_storage.c @@ -157,12 +157,13 @@ struct us_data { #ifdef CONFIG_USB_EHCI /* - * The U-Boot EHCI driver cannot handle more than 5 page aligned buffers - * of 4096 bytes in a transfer without running itself out of qt_buffers + * The U-Boot EHCI driver can handle any transfer length as long as there is + * enough free heap space left, but the SCSI READ(10) and WRITE(10) commands are + * limited to 65535 bytes. bytes? */ -#define USB_MAX_XFER_BLK(start, blksz) (((4096 * 5) - (start % 4096)) / blksz) +#define USB_MAX_XFER_BLK 65535 But here you limit it to 65535 _blocks_, right? One of the two should be wrong ;) Regards, Ilya. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot