arm: ep9315: Return back Cirrus Logic EDB9315A board support
Subsystems (5)
PATCH 1/1 arm: ep9315: Return back Cirrus Logic EDB9315A board support
This patch return back support of old EDB9315A board based on Cirrus Logic EP9315 processor.
Signed-off-by Sergey Kostanbaev <[email protected]>
Cc albert.u.boot at aribaud.net
--- arch/arm/cpu/arm920t/ep93xx/lowlevel_init.S | 568 +++++++++++++++++++++++++-- arch/arm/include/asm/arch-ep93xx/ep93xx.h | 62 +++ board/cirrus/edb93xx/Makefile | 37 ++ board/cirrus/edb93xx/edb93xx.c | 340 ++++++++++++++++ board/cirrus/edb93xx/u-boot.lds | 106 +++++ boards.cfg | 1 + drivers/spi/Makefile | 1 + drivers/spi/ep93xx_spi.c | 274 +++++++++++++ drivers/usb/host/Makefile | 1 + drivers/usb/host/ohci-ep93xx.c | 38 ++ include/configs/edb93xx.h | 291 ++++++++++++++ 11 files changed, 1690 insertions(+), 29 deletions(-) create mode 100644 board/cirrus/edb93xx/Makefile create mode 100644 board/cirrus/edb93xx/edb93xx.c create mode 100644 board/cirrus/edb93xx/u-boot.lds create mode 100644 drivers/spi/ep93xx_spi.c create mode 100644 drivers/usb/host/ohci-ep93xx.c create mode 100644 include/configs/edb93xx.h
arch/arm/cpu/arm920t/ep93xx/lowlevel_init.S +539 -29
@@ -1,49 +1,559 @@ /* * Low-level initialization for EP93xx * - * Copyright (C) 2009 Matthias Kaehlcke <[email protected]> + * Copyright (C) 2013 + * Sergey Kostanabev <sergey.kostanbaev <at> fairwaves.ru> * - * Copyright (C) 2006 Dominic Rath <[email protected]> + * Copyright (C) 2006 Cirrus Logic Inc. + * + * See file CREDITS for list of people who contributed to this + * project. * * SPDX-License-Identifier: GPL-2.0+ */ -#include <version.h> -#include <asm/arch/ep93xx.h> +#include <config.h> +#include <asm/arch-ep93xx/ep93xx.h> + +/* +/* Configure the SDRAM based on the supplied settings. + */ +ep93xx_sdram_config: + /* Program the SDRAM device configuration register. */ + ldr r3, =EP93XX_SDRAMCTRL +#ifdef CONFIG_EDB93XX_SDCS0 + str r0, [r3, #0x0010] +#endif +#ifdef CONFIG_EDB93XX_SDCS1 + str r0, [r3, #0x0014] +#endif +#ifdef CONFIG_EDB93XX_SDCS2 + str r0, [r3, #0x0018] +#endif +#ifdef CONFIG_EDB93XX_SDCS3 + str r0, [r3, #0x001c] +#endif + + /* Set the Initialize and MRS bits (issue continuous NOP commands + * (INIT & MRS set)) + */ + ldr r4, =(EP93XX_SDRAMCTRL_GLOBALCFG_INIT | \ + EP93XX_SDRAMCTRL_GLOBALCFG_MRS | \ + EP93XX_SDRAMCTRL_GLOBALCFG_CKE) + str r4, [r3, #0x0004] + + /* Delay for 200us. */ + mov r4, #0x3000 +delay1: + subs r4, r4, #1 + bne delay1 + + /* Clear the MRS bit to issue a precharge all. */ + ldr r4, =(EP93XX_SDRAMCTRL_GLOBALCFG_INIT | \ + EP93XX_SDRAMCTRL_GLOBALCFG_CKE) + str r4, [r3, #0x0004] + + /* Temporarily set the refresh timer to 0x10. Make it really low so + * that refresh cycles are generated. + */ + ldr r4, =0x10 + str r4, [r3, #0x0008] + + /* Delay for at least 80 SDRAM clock cycles. */ + mov r4, #80 +delay2: + subs r4, r4, #1 + bne delay2 + + /* Set the refresh timer to the fastest required for any device + * that might be used. + */ + ldr r4, =0x01e0 + str r4, [r3, #0x0008] + + /* Select mode register update mode. */ + ldr r4, =(EP93XX_SDRAMCTRL_GLOBALCFG_CKE | \ + EP93XX_SDRAMCTRL_GLOBALCFG_MRS) + str r4, [r3, #0x0004] + + /* Program the mode register on the SDRAM. */ + ldr r4, [r2] + + /* Select normal operating mode. */ + ldr r4, =EP93XX_SDRAMCTRL_GLOBALCFG_CKE + str r4, [r3, #0x0004] + + /* Return to the caller. */ + mov pc, lr + +/* + * Test to see if the SDRAM has been configured in a usable mode. + */ +ep93xx_sdram_test: + /* Load the test patterns to be written to SDRAM. */ + ldr r1, =0xf00dface + ldr r2, =0xdeadbeef + ldr r3, =0x08675309 + ldr r4, =0xdeafc0ed + + /* Store the test patterns to SDRAM. */ + stmia r0, {r1-r4} + + /* Load the test patterns from SDRAM one at a time and compare them + * to the actual pattern. + */ + ldr r5, [r0] + cmp r5, r1 + ldreq r5, [r0, #0x0004] + cmpeq r5, r2 + ldreq r5, [r0, #0x0008] + cmpeq r5, r3 + ldreq r5, [r0, #0x000c] + cmpeq r5, r4 + + /* Return -1 if a mismatch was encountered, 0 otherwise. */ + mvnne r0, #0xffffffff + moveq r0, #0x00000000 + + /* Return to the caller. */ + mov pc, lr + +/* + * Determine the size of the SDRAM. Use data=address for the scan. + * + * Input: r0 - Start SDRAM address + * + * Return: r0 - Single block size + * r1 - Valid block mask + * r2 - Total block count + */ +ep93xx_sdram_size: + /* Store zero at offset zero. */ + str r0, [r0] + + /* Start checking for an alias at 1MB into SDRAM. */ + ldr r1, =0x00100000 + + /* Store the offset at the current offset. */ +check_block_size: + str r1, [r0, r1] + + /* Read back from zero. */ + ldr r2, [r0] + + /* Stop searching of an alias was found. */ + cmp r1, r2 + beq found_block_size + + /* Advance to the next power of two boundary. */ + mov r1, r1, lsl #1 + + /* Loop back if the size has not reached 256MB. */ + cmp r1, #0x10000000 + bne check_block_size + + /* A full 256MB of memory was found, so return it now. */ + ldr r0, =0x10000000 + ldr r1, =0x00000000 + ldr r2, =0x00000001 + mov pc, lr + + /* An alias was found. See if the first block is 128MB in size. */ +found_block_size: + cmp r1, #0x08000000 + + /* The first block is 128MB, so there is no further memory. Return it + * now. + */ + ldreq r0, =0x08000000 + ldreq r1, =0x00000000 + ldreq r2, =0x00000001 + moveq pc, lr + + /* Save the block size, set the block address bits to zero, and + * initialize the block count to one. + */ + mov r3, r1 + ldr r4, =0x00000000 + ldr r5, =0x00000001 + + /* Look for additional blocks of memory by searching for non-aliases. */ +find_blocks: + /* Store zero back to address zero. It may be overwritten. */ + str r0, [r0] + + /* Advance to the next power of two boundary. */ + mov r1, r1, lsl #1 + + /* Store the offset at the current offset. */ + str r1, [r0, r1] + + /* Read back from zero. */ + ldr r2, [r0] + + /* See if a non-alias was found. */ + cmp r1, r2 + + /* If a non-alias was found, then or in the block address bit and + * multiply the block count by two (since there are two unique + * blocks, one with this bit zero and one with it one). + */ + orrne r4, r4, r1 + movne r5, r5, lsl #1 + + /* Continue searching if there are more address bits to check. */ + cmp r1, #0x08000000 + bne find_blocks + + /* Return the block size, address mask, and count. */ + mov r0, r3 + mov r1, r4 + mov r2, r5 + + /* Return to the caller. */ + mov pc, lr + +/* + * Compute the starting address of the SDRAM memory blocks. + */ +ep93xx_sdram_find_bank: + /* Get a pointer to the SDRAM address map. */ + orr r0, r11, #0x00002100 + + /* If there is only one bank, then there is no need to look for it. */ + cmp r10, #1 + moveq r1, #0x00000000 + streq r1, [r0] + moveq pc, lr + + /* Create a table mapping the individual address bits used to access the + * various banks. + */ + add r1, r0, #0x00000080 + mov r2, r10, lsr #1 + mov r3, #0x00100000 +find_bit: + tst r9, r3 + moveq r3, r3, lsl #1 + beq find_bit + str r3, [r1], #4 + mov r3, r3, lsl #1 + movs r2, r2, lsr #1 + bne find_bit + + /* Using the individual address bits, compute the address of each + * bank of SDRAM. + */ + add r1, r0, #0x00000080 + mov r2, r10 + mov r3, #0x00000000 +find_bank: + mov r4, #0x00000000 + tst r3, #0x00000001 + ldrne r5, [r1] + orrne r4, r4, r5 + tst r3, #0x00000002 + ldrne r5, [r1, #4] + orrne r4, r4, r5 + tst r3, #0x00000004 + ldrne r5, [r1, #8] + orrne r4, r4, r5 + tst r3, #0x00000008 + ldrne r5, [r1, #12] + orrne r4, r4, r5 + tst r3, #0x00000010 + ldrne r5, [r1, #16] + orrne r4, r4, r5 + tst r3, #0x00000020 + ldrne r5, [r1, #20] + orrne r4, r4, r5 + tst r3, #0x00000040 + ldrne r5, [r1, #24] + orrne r4, r4, r5 + tst r3, #0x00000080 + ldrne r5, [r1, #28] + orrne r4, r4, r5 + str r4, [r0], #4 + add r3, r3, #1 + subs r2, r2, #1 + bne find_bank + + /* Return to the caller. */ + mov pc, lr .globl lowlevel_init lowlevel_init: - /* backup return address */ - ldr r1, =SYSCON_SCRATCH0 - str lr, [r1] - /* Turn on both LEDs */ - bl red_led_on - bl green_led_on + mov r6, lr + + /* Make sure caches are off and invalidated. */ + ldr r0, =0x00000000 + mcr p15, 0, r0, c1, c0, 0 + nop + nop + nop + nop + nop + +#ifdef CONFIG_LOWLEVEL_DEBUG + bl SetBaud + mov r0, #0x42 /* 'B' */ + bl SendChar +#endif + + /* Turn off the green LED and turn on the red LED. If the red LED + * is left on for too long, the external reset circuit described + * by application note AN258 will cause the system to reset. + */ + ldr r1, =EP93XX_LED_DATA + ldr r0, [r1] + bic r0, r0, #EP93XX_LED_GREEN_ON + orr r0, r0, #EP93XX_LED_RED_ON + str r0, [r1] + + /* Undo the silly static memory controller programming performed + * by the boot rom. + */ + ldr r0, =0x80080000 + ldr r1, =0x0000fbe0 + ldr r2, [r0] + orr r2, r2, r1 + str r2, [r0] + ldr r2, [r0, #0x04] + orr r2, r2, r1 + str r2, [r0, #0x04] + ldr r2, [r0, #0x08] + orr r2, r2, r1 + str r2, [r0, #0x08] + ldr r2, [r0, #0x0c] + orr r2, r2, r1 + str r2, [r0, #0x0c] + ldr r2, [r0, #0x18] + orr r2, r2, r1 + str r2, [r0, #0x18] + ldr r2, [r0, #0x1c] + orr r2, r2, r1 + str r2, [r0, #0x1c] + + /* Set the PLL1 and processor clock. */ + ldr r0, =SYSCON_BASE +#ifdef CONFIG_EDB9301 + /* 332MHz, giving a 166MHz processor clock. */ + ldr r1, = 0x02b49907 +#else + + /* 400MHz, giving a 200MHz processor clock. */ + ldr r1, =0x02a4e39e + + + /* If you are using an Industrial Rated EP93XX then you need to + * comment the above ldr line and uncomment this one below here + * to enable correct CLKSET1 values of 192Mhz Core and 96Mhz SDRAM + */ + + /* ldr r1, =0x02a4bb38 This is for Industrial rated Chips */ + + +#endif + str r1, [r0, #0x0020] + + nop + nop + nop + nop + nop + +#ifdef CONFIG_LOWLEVEL_DEBUG + mov r0, #0x43 /* 'C' */ + bl SendChar +#endif + + + /* Need to make sure that SDRAM is configured correctly before + * coping the code into it. + */ + +#ifdef CONFIG_EDB93XX_SDCS0 + mov r11, #0xc0000000 +#endif +#ifdef CONFIG_EDB93XX_SDCS1 + mov r11, #0xd0000000 +#endif +#ifdef CONFIG_EDB93XX_SDCS2 + mov r11, #0xe0000000 +#endif +#ifdef CONFIG_EDB93XX_SDCS3 + ldr r0, =EP93XX_SYSCON + ldr r0, [r0, #0x009c] + ands r0, r0, #0x00000020 + moveq r11, #0xf0000000 + movne r11, #0x00000000 +#endif + /* Try a 32-bit wide configuration of SDRAM. */ + ldr r0, =(EP93XX_SDRAMCTRL_DEVCFG_BANKCOUNT | \ + EP93XX_SDRAMCTRL_DEVCFG_SROMLL | \ + EP93XX_SDRAMCTRL_DEVCFG_CASLAT_2 | \ + EP93XX_SDRAMCTRL_DEVCFG_RASTOCAS_2) + + ldr r1, =0x00400000 + orr r2, r11, #0x00008800 + bl ep93xx_sdram_config + + /* Test the SDRAM. */ + mov r0, r11 + bl ep93xx_sdram_test + cmp r0, #0x00000000 + beq ep93xx_sdram_done + + /* Try a 16-bit wide configuration of SDRAM. */ + ldr r0, =(EP93XX_SDRAMCTRL_DEVCFG_BANKCOUNT | \ + EP93XX_SDRAMCTRL_DEVCFG_SROMLL | \ + EP93XX_SDRAMCTRL_DEVCFG_CASLAT_2 | \ + EP93XX_SDRAMCTRL_DEVCFG_RASTOCAS_2 | \ + EP93XX_SDRAMCTRL_DEVCFG_EXTBUSWIDTH) + ldr r1, =0x00200000 + orr r2, r11, #0x00004600 + bl ep93xx_sdram_config + + /* Test the SDRAM. */ + mov r0, r11 + bl ep93xx_sdram_test + cmp r0, #0x00000000 + beq ep93xx_sdram_done + + /* Turn off the red LED. */ + ldr r0, =EP93XX_LED_DATA + ldr r1, [r0] + bic r1, r1, #EP93XX_LED_RED_ON + str r1, [r0] + + /* There is no SDRAM so flash the green LED. */ +flash_green: + orr r1, r1, #EP93XX_LED_GREEN_ON + str r1, [r0] + ldr r2, =0x00010000 +flash_green_delay_1: + subs r2, r2, #1 + bne flash_green_delay_1 + bic r1, r1, #EP93XX_LED_GREEN_ON + str r1, [r0] + ldr r2, =0x00010000 +flash_green_delay_2: + subs r2, r2, #1 + bne flash_green_delay_2 + orr r1, r1, #EP93XX_LED_GREEN_ON + str r1, [r0] + ldr r2, =0x00010000 +flash_green_delay_3: + subs r2, r2, #1 + bne flash_green_delay_3 + bic r1, r1, #EP93XX_LED_GREEN_ON + str r1, [r0] + ldr r2, =0x00050000 +flash_green_delay_4: + subs r2, r2, #1 + bne flash_green_delay_4 + b flash_green + + +ep93xx_sdram_done: + + ldr r1, =EP93XX_LED_DATA + ldr r0, [r1] + bic r0, r0, #EP93XX_LED_RED_ON + str r0, [r1] + + /* Determine the size of the SDRAM. */ + mov r0, r11 + bl ep93xx_sdram_size + + /* Save the SDRAM characteristics. */ + mov r8, r0 + mov r9, r1 + mov r10, r2 + ldr r3, =EP93XX_SDRAMCTRL + mul r1, r8, r10 +#ifdef CONFIG_EDB93XX_SDCS0 + ldr r2, [r0, #0x0010] +#endif +#ifdef CONFIG_EDB93XX_SDCS1 + ldr r2, [r0, #0x0014] +#endif +#ifdef CONFIG_EDB93XX_SDCS2 + ldr r2, [r0, #0x0018] +#endif +#ifdef CONFIG_EDB93XX_SDCS3 + ldr r2, [r0, #0x001c] +#endif + tst r2, #EP93XX_SDRAMCTRL_DEVCFG_EXTBUSWIDTH + moveq r1, r1, lsr #1 + cmp r1, #0x02000000 +#if defined(CONFIG_EDB9301) + movlt r1, #0x03f0 + movge r1, #0x01e0 +#else + movlt r1, #0x0600 + movge r1, #0x2f0 +#endif + str r1, [r0, #0x0008] + + /* Find the location of each block of SDRAM. */ + bl ep93xx_sdram_find_bank + + /* Save the memory configuration information. */ + orr r0, r11, #0x00002000 + stmia r0, {r8-r11} + +#ifdef CONFIG_LOWLEVEL_DEBUG + mov r0, #0x44 /* 'D' */ + bl SendChar +#endif + mov lr, r6 + mov pc,lr + +#ifdef CONFIG_LOWLEVEL_DEBUG +SetBaud: + /* DEVICECFG */ + ldr r1, =0x80930080 + ldr r0, [r1] + orr r0, r0, #0x040000 + str r0, [r1] + + ldr r3, =0x808c0000 + + /* Clear the status */ + mov r1, #0 + str r1, [r3, #0x4] + + /* Set 115200 Baud. */ + mov r1, #0x03 + str r1, [r3, #0x10] + + /* Clear the upper baud divisor register */ + mov r1, #0 + str r1, [r3, #0xc] - /* Configure flash wait states before we switch to the PLL */ - bl flash_cfg + /* Set the mode to N-8-1 */ + mov r1, #0x70 + str r1, [r3, #0x8] - /* Set up PLL */ - bl pll_cfg + /* Enable uart 1 */ + mov r1, #1 + str r1, [r3, #0x14] - /* Turn off the Green LED and leave the Red LED on */ - bl green_led_off + /* Return to the caller. */ + mov pc, lr - /* Setup SDRAM */ - bl sdram_cfg - /* Turn on Green LED, Turn off the Red LED */ - bl green_led_on - bl red_led_off +.globl SendChar +SendChar: + /* Load the base address to the UART 1 registers. 0x808c0000 */ + ldr r1, =0x808c0000 - /* FIXME: we use async mode for now */ - mrc p15, 0, r0, c1, c0, 0 - orr r0, r0, #0xc0000000 - mcr p15, 0, r0, c1, c0, 0 + /* Write the character to UART1. */ + str r0, [r1] - /* restore return address */ - ldr r1, =SYSCON_SCRATCH0 - ldr lr, [r1] + /* Return to the caller. */ + mov pc, lr - mov pc, lr +#endif
arch/arm/include/asm/arch-ep93xx/ep93xx.h +62 -0
92 lines not on this page · raw message
board/cirrus/edb93xx/Makefile new file +37 -0
@@ -0,0 +1,37 @@ +# +# (C) Copyright 2013 +# Sergey Kostanbaev <sergey.kostanbaev <at> fairwaves.ru> +# +# (C) Copyright 2003-2006 +# Wolfgang Denk, DENX Software Engineering, wd <at> denx.de. +# +# * SPDX-License-Identifier: GPL-2.0+ +# + +include $(TOPDIR)/config.mk + +LIB = $(obj)lib$(BOARD).o + +COBJS-y := edb93xx.o + +SRCS := $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c) +OBJS := $(addprefix $(obj),$(COBJS-y)) +SOBJS := $(addprefix $(obj),$(SOBJS-y)) + +$(LIB): $(obj).depend $(OBJS) $(SOBJS) + $(call cmd_link_o_target, $(OBJS) $(SOBJS)) + +clean: + rm -f $(SOBJS) $(OBJS) + +distclean: clean + rm -f $(LIB) core *.bak .depend + +######################################################################### + +# defines $(obj).depend target +include $(SRCTREE)/rules.mk + +sinclude $(obj).depend + +#########################################################################
board/cirrus/edb93xx/edb93xx.c new file +340 -0
340 lines not on this page · raw message
board/cirrus/edb93xx/u-boot.lds new file +106 -0
106 lines not on this page · raw message
boards.cfg +1 -0
@@ -72,6 +72,7 @@ Active arm arm920t ks8695 - - Active arm arm920t s3c24x0 friendlyarm mini2440 mini2440 - Gabriel Huau <[email protected]> Active arm arm920t s3c24x0 mpl vcma9 VCMA9 - David M?ller <[email protected]> Active arm arm920t s3c24x0 samsung - smdk2410 - David M?ller <[email protected]> +Active arm arm920t ep93xx cirrus edb93xx edb9315a edb93xx:MK_edb9315a Sergey Kostanbaev <[email protected]> Active arm arm926ejs - armltd integrator integratorap_cm926ejs integratorap:CM926EJ_S Linus Walleij <[email protected]> Active arm arm926ejs - armltd integrator integratorcp_cm926ejs integratorcp:CM924EJ_S Linus Walleij <[email protected]> Active arm arm926ejs armada100 Marvell - aspenite - Prafulla Wadaskar <[email protected]>
drivers/spi/Makefile +1 -0
@@ -12,6 +12,7 @@ LIB := $(obj)libspi.o # There are many options which enable SPI, so make this library available COBJS-y += spi.o +COBJS-$(CONFIG_EP93XX_SPI) += ep93xx_spi.o COBJS-$(CONFIG_ALTERA_SPI) += altera_spi.o COBJS-$(CONFIG_ANDES_SPI) += andes_spi.o COBJS-$(CONFIG_ARMADA100_SPI) += armada100_spi.o
drivers/spi/ep93xx_spi.c new file +274 -0
274 lines not on this page · raw message
drivers/usb/host/Makefile +1 -0
@@ -12,6 +12,7 @@ LIB := $(obj)libusb_host.o # ohci COBJS-$(CONFIG_USB_OHCI_NEW) += ohci-hcd.o COBJS-$(CONFIG_USB_ATMEL) += ohci-at91.o +COBJS-$(CONFIG_USB_OHCI_EP93XX) += ohci-ep93xx.o COBJS-$(CONFIG_USB_OHCI_DA8XX) += ohci-da8xx.o COBJS-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o COBJS-$(CONFIG_USB_R8A66597_HCD) += r8a66597-hcd.o
drivers/usb/host/ohci-ep93xx.c new file +38 -0
@@ -0,0 +1,38 @@ +/* +* (C) Copyright 2013 +* Sergey Kostanbaev < sergey.kostanbaev <at> fairwaves.ru > +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <config.h> +#include <common.h> + +#if defined(CONFIG_USB_OHCI_NEW ) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT ) +#include <asm/io.h> +#include <asm/arch/ep93xx.h> + +int usb_cpu_init (void ) +{ +struct syscon_regs *syscon = (struct syscon_regs *)SYSCON_BASE ; +unsigned long pwr =readl (&syscon->pwrcnt); +writel (pwr |SYSCON_PWRCNT_USH_EN , &syscon->pwrcnt); + +return 0 ; +} + +int usb_cpu_stop (void ) +{ +struct syscon_regs *syscon = (struct syscon_regs *)SYSCON_BASE ; +unsigned long pwr =readl (&syscon->pwrcnt); +writel (pwr & ~SYSCON_PWRCNT_USH_EN , &syscon->pwrcnt); + +return 0 ; +} + +int usb_cpu_init_fail (void ) +{ +return usb_cpu_stop (); +} + +#endif /* defined(CONFIG_USB_OHCI) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT) */
include/configs/edb93xx.h new file +291 -0
291 lines not on this page · raw message
Signature · 1 line
1.7.3.4