Commit c175f306b3f8885965f63ff6c71df5c0f899b4c9

Authored by Tom Rini

Merge git://git.denx.de/u-boot-arc

Showing 6 changed files Inline Diff

arch/arc/cpu/u-boot.lds
1 /* 1 /*
2 * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved. 2 * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
3 * 3 *
4 * SPDX-License-Identifier: GPL-2.0+ 4 * SPDX-License-Identifier: GPL-2.0+
5 */ 5 */
6 6
7 OUTPUT_FORMAT("elf32-littlearc", "elf32-littlearc", "elf32-littlearc") 7 OUTPUT_FORMAT("elf32-littlearc", "elf32-littlearc", "elf32-littlearc")
8 OUTPUT_ARCH(arc) 8 OUTPUT_ARCH(arc)
9 ENTRY(_start) 9 ENTRY(_start)
10 SECTIONS 10 SECTIONS
11 { 11 {
12 . = ALIGN(4); 12 . = ALIGN(4);
13 .text : { 13 .text : {
14 *(.__text_start) 14 *(.__text_start)
15 *(.__image_copy_start) 15 *(.__image_copy_start)
16 arch/arc/lib/start.o (.text*)
16 *(.text*) 17 *(.text*)
17 } 18 }
18 19
19 . = ALIGN(4); 20 . = ALIGN(4);
20 .text_end : 21 .text_end :
21 { 22 {
22 *(.__text_end) 23 *(.__text_end)
23 } 24 }
24 25
25 . = ALIGN(1024); 26 . = ALIGN(1024);
26 .ivt_start : { 27 .ivt_start : {
27 *(.__ivt_start) 28 *(.__ivt_start)
28 } 29 }
29 30
30 .ivt : 31 .ivt :
31 { 32 {
32 *(.ivt) 33 *(.ivt)
33 } 34 }
34 35
35 .ivt_end : { 36 .ivt_end : {
36 *(.__ivt_end) 37 *(.__ivt_end)
37 } 38 }
38 39
39 . = ALIGN(4); 40 . = ALIGN(4);
40 .rodata : { 41 .rodata : {
41 *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) 42 *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
42 } 43 }
43 44
44 . = ALIGN(4); 45 . = ALIGN(4);
45 .data : { 46 .data : {
46 *(.data*) 47 *(.data*)
47 } 48 }
48 49
49 . = ALIGN(4); 50 . = ALIGN(4);
50 .u_boot_list : { 51 .u_boot_list : {
51 KEEP(*(SORT(.u_boot_list*))); 52 KEEP(*(SORT(.u_boot_list*)));
52 } 53 }
53 54
54 . = ALIGN(4); 55 . = ALIGN(4);
55 .rel_dyn_start : { 56 .rel_dyn_start : {
56 *(.__rel_dyn_start) 57 *(.__rel_dyn_start)
57 } 58 }
58 59
59 .rela.dyn : { 60 .rela.dyn : {
60 *(.rela.dyn) 61 *(.rela.dyn)
61 } 62 }
62 63
63 .rel_dyn_end : { 64 .rel_dyn_end : {
64 *(.__rel_dyn_end) 65 *(.__rel_dyn_end)
65 } 66 }
66 67
67 . = ALIGN(4); 68 . = ALIGN(4);
68 .bss_start : { 69 .bss_start : {
69 *(.__bss_start); 70 *(.__bss_start);
70 } 71 }
71 72
72 .bss : { 73 .bss : {
73 *(.bss*) 74 *(.bss*)
74 } 75 }
75 76
76 .bss_end : { 77 .bss_end : {
77 *(.__bss_end); 78 *(.__bss_end);
78 } 79 }
79 80
80 . = ALIGN(4); 81 . = ALIGN(4);
81 .image_copy_end : { 82 .image_copy_end : {
82 *(.__image_copy_end) 83 *(.__image_copy_end)
83 *(.__init_end) 84 *(.__init_end)
84 } 85 }
85 } 86 }
86 87
arch/arc/lib/Makefile
1 # 1 #
2 # Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved. 2 # Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
3 # 3 #
4 # SPDX-License-Identifier: GPL-2.0+ 4 # SPDX-License-Identifier: GPL-2.0+
5 # 5 #
6 6
7 extra-y = start.o
8 head-y := start.o
7 obj-y += cache.o 9 obj-y += cache.o
8 obj-y += cpu.o 10 obj-y += cpu.o
9 obj-y += interrupts.o 11 obj-y += interrupts.o
10 obj-y += sections.o 12 obj-y += sections.o
11 obj-y += relocate.o 13 obj-y += relocate.o
12 obj-y += strchr-700.o 14 obj-y += strchr-700.o
13 obj-y += strcmp.o 15 obj-y += strcmp.o
14 obj-y += strcpy-700.o 16 obj-y += strcpy-700.o
15 obj-y += strlen.o 17 obj-y += strlen.o
16 obj-y += memcmp.o 18 obj-y += memcmp.o
17 obj-y += memcpy-700.o 19 obj-y += memcpy-700.o
18 obj-y += memset.o 20 obj-y += memset.o
19 obj-y += reset.o 21 obj-y += reset.o
20 obj-y += timer.o 22 obj-y += timer.o
21 obj-y += start.o
22 obj-y += ints_low.o 23 obj-y += ints_low.o
23 obj-y += init_helpers.o 24 obj-y += init_helpers.o
24 25
25 obj-$(CONFIG_CMD_BOOTM) += bootm.o 26 obj-$(CONFIG_CMD_BOOTM) += bootm.o
26 27
27 lib-$(CONFIG_USE_PRIVATE_LIBGCC) += _millicodethunk.o libgcc2.o 28 lib-$(CONFIG_USE_PRIVATE_LIBGCC) += _millicodethunk.o libgcc2.o
board/synopsys/axs101/axs101.c
1 /* 1 /*
2 * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved. 2 * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
3 * 3 *
4 * SPDX-License-Identifier: GPL-2.0+ 4 * SPDX-License-Identifier: GPL-2.0+
5 */ 5 */
6 6
7 #include <common.h> 7 #include <common.h>
8 #include <dwmmc.h> 8 #include <dwmmc.h>
9 #include <malloc.h> 9 #include <malloc.h>
10 #include <netdev.h> 10 #include <netdev.h>
11 #include <phy.h> 11 #include <phy.h>
12 #include "axs10x.h"
12 13
13 DECLARE_GLOBAL_DATA_PTR; 14 DECLARE_GLOBAL_DATA_PTR;
14 15
15 int board_mmc_init(bd_t *bis) 16 int board_mmc_init(bd_t *bis)
16 { 17 {
17 struct dwmci_host *host = NULL; 18 struct dwmci_host *host = NULL;
18 19
19 host = malloc(sizeof(struct dwmci_host)); 20 host = malloc(sizeof(struct dwmci_host));
20 if (!host) { 21 if (!host) {
21 printf("dwmci_host malloc fail!\n"); 22 printf("dwmci_host malloc fail!\n");
22 return 1; 23 return 1;
23 } 24 }
24 25
25 memset(host, 0, sizeof(struct dwmci_host)); 26 memset(host, 0, sizeof(struct dwmci_host));
26 host->name = "Synopsys Mobile storage"; 27 host->name = "Synopsys Mobile storage";
27 host->ioaddr = (void *)ARC_DWMMC_BASE; 28 host->ioaddr = (void *)ARC_DWMMC_BASE;
28 host->buswidth = 4; 29 host->buswidth = 4;
29 host->dev_index = 0; 30 host->dev_index = 0;
30 host->bus_hz = 50000000; 31 host->bus_hz = 50000000;
31 32
32 add_dwmci(host, host->bus_hz, 400000); 33 add_dwmci(host, host->bus_hz, 400000);
33 34
34 return 0; 35 return 0;
35 } 36 }
36 37
37 int board_eth_init(bd_t *bis) 38 int board_eth_init(bd_t *bis)
38 { 39 {
39 if (designware_initialize(ARC_DWGMAC_BASE, 40 if (designware_initialize(ARC_DWGMAC_BASE,
40 PHY_INTERFACE_MODE_RGMII) >= 0) 41 PHY_INTERFACE_MODE_RGMII) >= 0)
41 return 1; 42 return 1;
43
44 return 0;
45 }
46
47
48 #define AXS_MB_CREG 0xE0011000
49
50 int board_early_init_f(void)
51 {
52 if (readl((void __iomem *)AXS_MB_CREG + 0x234) & (1 << 28))
53 gd->board_type = AXS_MB_V3;
54 else
55 gd->board_type = AXS_MB_V2;
42 56
43 return 0; 57 return 0;
44 } 58 }
45 59
board/synopsys/axs101/axs10x.h
File was created 1 /*
2 * Copyright (C) 2015 Synopsys, Inc. All rights reserved.
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7 #ifndef _BOARD_SYNOPSYS_AXS10X_H
8 #define _BOARD_SYNOPSYS_AXS10X_H
9
10 enum {
11 AXS_MB_V2,
12 AXS_MB_V3
13 };
14
15 #endif /* _BOARD_SYNOPSYS_AXS10X_H */
16
17
board/synopsys/axs101/nand.c
1 /* 1 /*
2 * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved. 2 * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
3 * 3 *
4 * SPDX-License-Identifier: GPL-2.0+ 4 * SPDX-License-Identifier: GPL-2.0+
5 */ 5 */
6 6
7 #include <bouncebuf.h> 7 #include <bouncebuf.h>
8 #include <common.h> 8 #include <common.h>
9 #include <malloc.h> 9 #include <malloc.h>
10 #include <nand.h> 10 #include <nand.h>
11 #include <asm/io.h> 11 #include <asm/io.h>
12 #include "axs10x.h"
12 13
14 DECLARE_GLOBAL_DATA_PTR;
15
13 #define BUS_WIDTH 8 /* AXI data bus width in bytes */ 16 #define BUS_WIDTH 8 /* AXI data bus width in bytes */
14 17
15 /* DMA buffer descriptor bits & masks */ 18 /* DMA buffer descriptor bits & masks */
16 #define BD_STAT_OWN (1 << 31) 19 #define BD_STAT_OWN (1 << 31)
17 #define BD_STAT_BD_FIRST (1 << 3) 20 #define BD_STAT_BD_FIRST (1 << 3)
18 #define BD_STAT_BD_LAST (1 << 2) 21 #define BD_STAT_BD_LAST (1 << 2)
19 #define BD_SIZES_BUFFER1_MASK 0xfff 22 #define BD_SIZES_BUFFER1_MASK 0xfff
20 23
21 #define BD_STAT_BD_COMPLETE (BD_STAT_BD_FIRST | BD_STAT_BD_LAST) 24 #define BD_STAT_BD_COMPLETE (BD_STAT_BD_FIRST | BD_STAT_BD_LAST)
22 25
23 /* Controller command flags */ 26 /* Controller command flags */
24 #define B_WFR (1 << 19) /* 1b - Wait for ready */ 27 #define B_WFR (1 << 19) /* 1b - Wait for ready */
25 #define B_LC (1 << 18) /* 1b - Last cycle */ 28 #define B_LC (1 << 18) /* 1b - Last cycle */
26 #define B_IWC (1 << 13) /* 1b - Interrupt when complete */ 29 #define B_IWC (1 << 13) /* 1b - Interrupt when complete */
27 30
28 /* NAND cycle types */ 31 /* NAND cycle types */
29 #define B_CT_ADDRESS (0x0 << 16) /* Address operation */ 32 #define B_CT_ADDRESS (0x0 << 16) /* Address operation */
30 #define B_CT_COMMAND (0x1 << 16) /* Command operation */ 33 #define B_CT_COMMAND (0x1 << 16) /* Command operation */
31 #define B_CT_WRITE (0x2 << 16) /* Write operation */ 34 #define B_CT_WRITE (0x2 << 16) /* Write operation */
32 #define B_CT_READ (0x3 << 16) /* Write operation */ 35 #define B_CT_READ (0x3 << 16) /* Write operation */
33 36
34 enum nand_isr_t { 37 enum nand_isr_t {
35 NAND_ISR_DATAREQUIRED = 0, 38 NAND_ISR_DATAREQUIRED = 0,
36 NAND_ISR_TXUNDERFLOW, 39 NAND_ISR_TXUNDERFLOW,
37 NAND_ISR_TXOVERFLOW, 40 NAND_ISR_TXOVERFLOW,
38 NAND_ISR_DATAAVAILABLE, 41 NAND_ISR_DATAAVAILABLE,
39 NAND_ISR_RXUNDERFLOW, 42 NAND_ISR_RXUNDERFLOW,
40 NAND_ISR_RXOVERFLOW, 43 NAND_ISR_RXOVERFLOW,
41 NAND_ISR_TXDMACOMPLETE, 44 NAND_ISR_TXDMACOMPLETE,
42 NAND_ISR_RXDMACOMPLETE, 45 NAND_ISR_RXDMACOMPLETE,
43 NAND_ISR_DESCRIPTORUNAVAILABLE, 46 NAND_ISR_DESCRIPTORUNAVAILABLE,
44 NAND_ISR_CMDDONE, 47 NAND_ISR_CMDDONE,
45 NAND_ISR_CMDAVAILABLE, 48 NAND_ISR_CMDAVAILABLE,
46 NAND_ISR_CMDERROR, 49 NAND_ISR_CMDERROR,
47 NAND_ISR_DATATRANSFEROVER, 50 NAND_ISR_DATATRANSFEROVER,
48 NAND_ISR_NONE 51 NAND_ISR_NONE
49 }; 52 };
50 53
51 enum nand_regs_t { 54 enum nand_regs_t {
52 AC_FIFO = 0, /* address and command fifo */ 55 AC_FIFO = 0, /* address and command fifo */
53 IDMAC_BDADDR = 0x18, /* idmac descriptor list base address */ 56 IDMAC_BDADDR = 0x18, /* idmac descriptor list base address */
54 INT_STATUS = 0x118, /* interrupt status register */ 57 INT_STATUS = 0x118, /* interrupt status register */
55 INT_CLR_STATUS = 0x120, /* interrupt clear status register */ 58 INT_CLR_STATUS = 0x120, /* interrupt clear status register */
56 }; 59 };
57 60
58 struct nand_bd { 61 struct nand_bd {
59 uint32_t status; /* DES0 */ 62 uint32_t status; /* DES0 */
60 uint32_t sizes; /* DES1 */ 63 uint32_t sizes; /* DES1 */
61 uint32_t buffer_ptr0; /* DES2 */ 64 uint32_t buffer_ptr0; /* DES2 */
62 uint32_t buffer_ptr1; /* DES3 */ 65 uint32_t buffer_ptr1; /* DES3 */
63 }; 66 };
64 67
65 #define NAND_REG_WRITE(r, v) \ 68 #define NAND_REG_WRITE(r, v) \
66 writel(v, (volatile void __iomem *)(CONFIG_SYS_NAND_BASE + r)) 69 writel(v, (volatile void __iomem *)(CONFIG_SYS_NAND_BASE + r))
67 #define NAND_REG_READ(r) \ 70 #define NAND_REG_READ(r) \
68 readl((const volatile void __iomem *)(CONFIG_SYS_NAND_BASE + r)) 71 readl((const volatile void __iomem *)(CONFIG_SYS_NAND_BASE + r))
69 72
70 static struct nand_bd *bd; /* DMA buffer descriptors */ 73 static struct nand_bd *bd; /* DMA buffer descriptors */
71 74
72 /** 75 /**
73 * axs101_nand_write_buf - write buffer to chip 76 * axs101_nand_write_buf - write buffer to chip
74 * @mtd: MTD device structure 77 * @mtd: MTD device structure
75 * @buf: data buffer 78 * @buf: data buffer
76 * @len: number of bytes to write 79 * @len: number of bytes to write
77 */ 80 */
78 static uint32_t nand_flag_is_set(uint32_t flag) 81 static uint32_t nand_flag_is_set(uint32_t flag)
79 { 82 {
80 uint32_t reg = NAND_REG_READ(INT_STATUS); 83 uint32_t reg = NAND_REG_READ(INT_STATUS);
81 84
82 if (reg & (1 << NAND_ISR_CMDERROR)) 85 if (reg & (1 << NAND_ISR_CMDERROR))
83 return 0; 86 return 0;
84 87
85 if (reg & (1 << flag)) { 88 if (reg & (1 << flag)) {
86 NAND_REG_WRITE(INT_CLR_STATUS, 1 << flag); 89 NAND_REG_WRITE(INT_CLR_STATUS, 1 << flag);
87 return 1; 90 return 1;
88 } 91 }
89 92
90 return 0; 93 return 0;
91 } 94 }
92 95
93 /** 96 /**
94 * axs101_nand_write_buf - write buffer to chip 97 * axs101_nand_write_buf - write buffer to chip
95 * @mtd: MTD device structure 98 * @mtd: MTD device structure
96 * @buf: data buffer 99 * @buf: data buffer
97 * @len: number of bytes to write 100 * @len: number of bytes to write
98 */ 101 */
99 static void axs101_nand_write_buf(struct mtd_info *mtd, const u_char *buf, 102 static void axs101_nand_write_buf(struct mtd_info *mtd, const u_char *buf,
100 int len) 103 int len)
101 { 104 {
102 struct bounce_buffer bbstate; 105 struct bounce_buffer bbstate;
103 106
104 bounce_buffer_start(&bbstate, (void *)buf, len, GEN_BB_READ); 107 bounce_buffer_start(&bbstate, (void *)buf, len, GEN_BB_READ);
105 108
106 /* Setup buffer descriptor */ 109 /* Setup buffer descriptor */
107 writel(BD_STAT_OWN | BD_STAT_BD_COMPLETE, &bd->status); 110 writel(BD_STAT_OWN | BD_STAT_BD_COMPLETE, &bd->status);
108 writel(ALIGN(len, BUS_WIDTH) & BD_SIZES_BUFFER1_MASK, &bd->sizes); 111 writel(ALIGN(len, BUS_WIDTH) & BD_SIZES_BUFFER1_MASK, &bd->sizes);
109 writel(bbstate.bounce_buffer, &bd->buffer_ptr0); 112 writel(bbstate.bounce_buffer, &bd->buffer_ptr0);
110 writel(0, &bd->buffer_ptr1); 113 writel(0, &bd->buffer_ptr1);
111 114
112 /* Flush modified buffer descriptor */ 115 /* Flush modified buffer descriptor */
113 flush_dcache_range((unsigned long)bd, 116 flush_dcache_range((unsigned long)bd,
114 (unsigned long)bd + sizeof(struct nand_bd)); 117 (unsigned long)bd + sizeof(struct nand_bd));
115 118
116 /* Issue "write" command */ 119 /* Issue "write" command */
117 NAND_REG_WRITE(AC_FIFO, B_CT_WRITE | B_WFR | B_IWC | B_LC | (len-1)); 120 NAND_REG_WRITE(AC_FIFO, B_CT_WRITE | B_WFR | B_IWC | B_LC | (len-1));
118 121
119 /* Wait for NAND command and DMA to complete */ 122 /* Wait for NAND command and DMA to complete */
120 while (!nand_flag_is_set(NAND_ISR_CMDDONE)) 123 while (!nand_flag_is_set(NAND_ISR_CMDDONE))
121 ; 124 ;
122 while (!nand_flag_is_set(NAND_ISR_TXDMACOMPLETE)) 125 while (!nand_flag_is_set(NAND_ISR_TXDMACOMPLETE))
123 ; 126 ;
124 127
125 bounce_buffer_stop(&bbstate); 128 bounce_buffer_stop(&bbstate);
126 } 129 }
127 130
128 /** 131 /**
129 * axs101_nand_read_buf - read chip data into buffer 132 * axs101_nand_read_buf - read chip data into buffer
130 * @mtd: MTD device structure 133 * @mtd: MTD device structure
131 * @buf: buffer to store data 134 * @buf: buffer to store data
132 * @len: number of bytes to read 135 * @len: number of bytes to read
133 */ 136 */
134 static void axs101_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len) 137 static void axs101_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
135 { 138 {
136 struct bounce_buffer bbstate; 139 struct bounce_buffer bbstate;
137 140
138 bounce_buffer_start(&bbstate, buf, len, GEN_BB_WRITE); 141 bounce_buffer_start(&bbstate, buf, len, GEN_BB_WRITE);
139 142
140 /* Setup buffer descriptor */ 143 /* Setup buffer descriptor */
141 writel(BD_STAT_OWN | BD_STAT_BD_COMPLETE, &bd->status); 144 writel(BD_STAT_OWN | BD_STAT_BD_COMPLETE, &bd->status);
142 writel(ALIGN(len, BUS_WIDTH) & BD_SIZES_BUFFER1_MASK, &bd->sizes); 145 writel(ALIGN(len, BUS_WIDTH) & BD_SIZES_BUFFER1_MASK, &bd->sizes);
143 writel(bbstate.bounce_buffer, &bd->buffer_ptr0); 146 writel(bbstate.bounce_buffer, &bd->buffer_ptr0);
144 writel(0, &bd->buffer_ptr1); 147 writel(0, &bd->buffer_ptr1);
145 148
146 /* Flush modified buffer descriptor */ 149 /* Flush modified buffer descriptor */
147 flush_dcache_range((unsigned long)bd, 150 flush_dcache_range((unsigned long)bd,
148 (unsigned long)bd + sizeof(struct nand_bd)); 151 (unsigned long)bd + sizeof(struct nand_bd));
149 152
150 /* Issue "read" command */ 153 /* Issue "read" command */
151 NAND_REG_WRITE(AC_FIFO, B_CT_READ | B_WFR | B_IWC | B_LC | (len - 1)); 154 NAND_REG_WRITE(AC_FIFO, B_CT_READ | B_WFR | B_IWC | B_LC | (len - 1));
152 155
153 /* Wait for NAND command and DMA to complete */ 156 /* Wait for NAND command and DMA to complete */
154 while (!nand_flag_is_set(NAND_ISR_CMDDONE)) 157 while (!nand_flag_is_set(NAND_ISR_CMDDONE))
155 ; 158 ;
156 while (!nand_flag_is_set(NAND_ISR_RXDMACOMPLETE)) 159 while (!nand_flag_is_set(NAND_ISR_RXDMACOMPLETE))
157 ; 160 ;
158 161
159 bounce_buffer_stop(&bbstate); 162 bounce_buffer_stop(&bbstate);
160 } 163 }
161 164
162 /** 165 /**
163 * axs101_nand_read_byte - read one byte from the chip 166 * axs101_nand_read_byte - read one byte from the chip
164 * @mtd: MTD device structure 167 * @mtd: MTD device structure
165 */ 168 */
166 static u_char axs101_nand_read_byte(struct mtd_info *mtd) 169 static u_char axs101_nand_read_byte(struct mtd_info *mtd)
167 { 170 {
168 u8 byte; 171 u8 byte;
169 172
170 axs101_nand_read_buf(mtd, (uchar *)&byte, sizeof(byte)); 173 axs101_nand_read_buf(mtd, (uchar *)&byte, sizeof(byte));
171 return byte; 174 return byte;
172 } 175 }
173 176
174 /** 177 /**
175 * axs101_nand_read_word - read one word from the chip 178 * axs101_nand_read_word - read one word from the chip
176 * @mtd: MTD device structure 179 * @mtd: MTD device structure
177 */ 180 */
178 static u16 axs101_nand_read_word(struct mtd_info *mtd) 181 static u16 axs101_nand_read_word(struct mtd_info *mtd)
179 { 182 {
180 u16 word; 183 u16 word;
181 184
182 axs101_nand_read_buf(mtd, (uchar *)&word, sizeof(word)); 185 axs101_nand_read_buf(mtd, (uchar *)&word, sizeof(word));
183 return word; 186 return word;
184 } 187 }
185 188
186 /** 189 /**
187 * axs101_nand_hwcontrol - NAND control functions wrapper. 190 * axs101_nand_hwcontrol - NAND control functions wrapper.
188 * @mtd: MTD device structure 191 * @mtd: MTD device structure
189 * @cmd: Command 192 * @cmd: Command
190 */ 193 */
191 static void axs101_nand_hwcontrol(struct mtd_info *mtdinfo, int cmd, 194 static void axs101_nand_hwcontrol(struct mtd_info *mtdinfo, int cmd,
192 unsigned int ctrl) 195 unsigned int ctrl)
193 { 196 {
194 if (cmd == NAND_CMD_NONE) 197 if (cmd == NAND_CMD_NONE)
195 return; 198 return;
196 199
197 cmd = cmd & 0xff; 200 cmd = cmd & 0xff;
198 201
199 switch (ctrl & (NAND_ALE | NAND_CLE)) { 202 switch (ctrl & (NAND_ALE | NAND_CLE)) {
200 /* Address */ 203 /* Address */
201 case NAND_ALE: 204 case NAND_ALE:
202 cmd |= B_CT_ADDRESS; 205 cmd |= B_CT_ADDRESS;
203 break; 206 break;
204 207
205 /* Command */ 208 /* Command */
206 case NAND_CLE: 209 case NAND_CLE:
207 cmd |= B_CT_COMMAND | B_WFR; 210 cmd |= B_CT_COMMAND | B_WFR;
208 211
209 break; 212 break;
210 213
211 default: 214 default:
212 debug("%s: unknown ctrl %#x\n", __func__, ctrl); 215 debug("%s: unknown ctrl %#x\n", __func__, ctrl);
213 } 216 }
214 217
215 NAND_REG_WRITE(AC_FIFO, cmd | B_LC); 218 NAND_REG_WRITE(AC_FIFO, cmd | B_LC);
216 while (!nand_flag_is_set(NAND_ISR_CMDDONE)) 219 while (!nand_flag_is_set(NAND_ISR_CMDDONE))
217 ; 220 ;
218 } 221 }
219 222
220 int board_nand_init(struct nand_chip *nand) 223 int board_nand_init(struct nand_chip *nand)
221 { 224 {
222 bd = (struct nand_bd *)memalign(ARCH_DMA_MINALIGN, 225 bd = (struct nand_bd *)memalign(ARCH_DMA_MINALIGN,
223 sizeof(struct nand_bd)); 226 sizeof(struct nand_bd));
224 227
225 /* Set buffer descriptor address in IDMAC */ 228 /* Set buffer descriptor address in IDMAC */
226 NAND_REG_WRITE(IDMAC_BDADDR, bd); 229 NAND_REG_WRITE(IDMAC_BDADDR, bd);
227 230
228 nand->ecc.mode = NAND_ECC_SOFT; 231 nand->ecc.mode = NAND_ECC_SOFT;
229 nand->cmd_ctrl = axs101_nand_hwcontrol; 232 nand->cmd_ctrl = axs101_nand_hwcontrol;
230 nand->read_byte = axs101_nand_read_byte; 233 nand->read_byte = axs101_nand_read_byte;
231 nand->read_word = axs101_nand_read_word; 234 nand->read_word = axs101_nand_read_word;
232 nand->write_buf = axs101_nand_write_buf; 235 nand->write_buf = axs101_nand_write_buf;
233 nand->read_buf = axs101_nand_read_buf; 236 nand->read_buf = axs101_nand_read_buf;
237
238 /* MBv3 has NAND IC with 16-bit data bus */
239 if (gd->board_type == AXS_MB_V3)
240 nand->options |= NAND_BUSWIDTH_16;
234 241
235 return 0; 242 return 0;
236 } 243 }
237 244
include/configs/axs101.h
1 /* 1 /*
2 * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved. 2 * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
3 * 3 *
4 * SPDX-License-Identifier: GPL-2.0+ 4 * SPDX-License-Identifier: GPL-2.0+
5 */ 5 */
6 6
7 #ifndef _CONFIG_AXS101_H_ 7 #ifndef _CONFIG_AXS101_H_
8 #define _CONFIG_AXS101_H_ 8 #define _CONFIG_AXS101_H_
9 9
10 /* 10 /*
11 * CPU configuration 11 * CPU configuration
12 */ 12 */
13 #define CONFIG_SYS_TIMER_RATE CONFIG_SYS_CLK_FREQ 13 #define CONFIG_SYS_TIMER_RATE CONFIG_SYS_CLK_FREQ
14 14
15 #define ARC_FPGA_PERIPHERAL_BASE 0xE0000000 15 #define ARC_FPGA_PERIPHERAL_BASE 0xE0000000
16 #define ARC_APB_PERIPHERAL_BASE 0xF0000000 16 #define ARC_APB_PERIPHERAL_BASE 0xF0000000
17 #define ARC_DWMMC_BASE (ARC_FPGA_PERIPHERAL_BASE + 0x15000) 17 #define ARC_DWMMC_BASE (ARC_FPGA_PERIPHERAL_BASE + 0x15000)
18 #define ARC_DWGMAC_BASE (ARC_FPGA_PERIPHERAL_BASE + 0x18000) 18 #define ARC_DWGMAC_BASE (ARC_FPGA_PERIPHERAL_BASE + 0x18000)
19 19
20 /* 20 /*
21 * Memory configuration 21 * Memory configuration
22 */ 22 */
23 #define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_TEXT_BASE 23 #define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_TEXT_BASE
24 24
25 #define CONFIG_SYS_DDR_SDRAM_BASE 0x80000000 25 #define CONFIG_SYS_DDR_SDRAM_BASE 0x80000000
26 #define CONFIG_SYS_SDRAM_BASE CONFIG_SYS_DDR_SDRAM_BASE 26 #define CONFIG_SYS_SDRAM_BASE CONFIG_SYS_DDR_SDRAM_BASE
27 #define CONFIG_SYS_SDRAM_SIZE 0x20000000 /* 512 Mb */ 27 #define CONFIG_SYS_SDRAM_SIZE 0x20000000 /* 512 Mb */
28 28
29 #define CONFIG_SYS_INIT_SP_ADDR \ 29 #define CONFIG_SYS_INIT_SP_ADDR \
30 (CONFIG_SYS_SDRAM_BASE + 0x1000 - GENERATED_GBL_DATA_SIZE) 30 (CONFIG_SYS_SDRAM_BASE + 0x1000 - GENERATED_GBL_DATA_SIZE)
31 31
32 #define CONFIG_SYS_MALLOC_LEN 0x200000 /* 2 MB */ 32 #define CONFIG_SYS_MALLOC_LEN 0x200000 /* 2 MB */
33 #define CONFIG_SYS_BOOTM_LEN 0x2000000 /* 32 MB */ 33 #define CONFIG_SYS_BOOTM_LEN 0x2000000 /* 32 MB */
34 #define CONFIG_SYS_LOAD_ADDR 0x82000000 34 #define CONFIG_SYS_LOAD_ADDR 0x82000000
35 35
36 /* 36 /*
37 * This board might be of different versions so handle it
38 */
39 #define CONFIG_BOARD_TYPES
40 #define CONFIG_BOARD_EARLY_INIT_F
41
42 /*
37 * NAND Flash configuration 43 * NAND Flash configuration
38 */ 44 */
39 #define CONFIG_SYS_NO_FLASH 45 #define CONFIG_SYS_NO_FLASH
40 #define CONFIG_SYS_NAND_BASE (ARC_FPGA_PERIPHERAL_BASE + 0x16000) 46 #define CONFIG_SYS_NAND_BASE (ARC_FPGA_PERIPHERAL_BASE + 0x16000)
41 #define CONFIG_SYS_MAX_NAND_DEVICE 1 47 #define CONFIG_SYS_MAX_NAND_DEVICE 1
42 48
43 /* 49 /*
44 * UART configuration 50 * UART configuration
45 * 51 *
46 * CONFIG_CONS_INDEX = 1 - Debug UART 52 * CONFIG_CONS_INDEX = 1 - Debug UART
47 * CONFIG_CONS_INDEX = 4 - FPGA UART connected to FTDI/USB 53 * CONFIG_CONS_INDEX = 4 - FPGA UART connected to FTDI/USB
48 */ 54 */
49 #define CONFIG_CONS_INDEX 4 55 #define CONFIG_CONS_INDEX 4
50 #define CONFIG_SYS_NS16550 56 #define CONFIG_SYS_NS16550
51 #define CONFIG_SYS_NS16550_SERIAL 57 #define CONFIG_SYS_NS16550_SERIAL
52 #define CONFIG_SYS_NS16550_REG_SIZE -4 58 #define CONFIG_SYS_NS16550_REG_SIZE -4
53 #if (CONFIG_CONS_INDEX == 1) 59 #if (CONFIG_CONS_INDEX == 1)
54 /* Debug UART */ 60 /* Debug UART */
55 # define CONFIG_SYS_NS16550_CLK 33333000 61 # define CONFIG_SYS_NS16550_CLK 33333000
56 #else 62 #else
57 /* FPGA UARTs use different clock */ 63 /* FPGA UARTs use different clock */
58 # define CONFIG_SYS_NS16550_CLK 33333333 64 # define CONFIG_SYS_NS16550_CLK 33333333
59 #endif 65 #endif
60 #define CONFIG_SYS_NS16550_COM1 (ARC_APB_PERIPHERAL_BASE + 0x5000) 66 #define CONFIG_SYS_NS16550_COM1 (ARC_APB_PERIPHERAL_BASE + 0x5000)
61 #define CONFIG_SYS_NS16550_COM2 (ARC_FPGA_PERIPHERAL_BASE + 0x20000) 67 #define CONFIG_SYS_NS16550_COM2 (ARC_FPGA_PERIPHERAL_BASE + 0x20000)
62 #define CONFIG_SYS_NS16550_COM3 (ARC_FPGA_PERIPHERAL_BASE + 0x21000) 68 #define CONFIG_SYS_NS16550_COM3 (ARC_FPGA_PERIPHERAL_BASE + 0x21000)
63 #define CONFIG_SYS_NS16550_COM4 (ARC_FPGA_PERIPHERAL_BASE + 0x22000) 69 #define CONFIG_SYS_NS16550_COM4 (ARC_FPGA_PERIPHERAL_BASE + 0x22000)
64 #define CONFIG_SYS_NS16550_MEM32 70 #define CONFIG_SYS_NS16550_MEM32
65 71
66 #define CONFIG_BAUDRATE 115200 72 #define CONFIG_BAUDRATE 115200
67 /* 73 /*
68 * I2C configuration 74 * I2C configuration
69 */ 75 */
70 #define CONFIG_SYS_I2C 76 #define CONFIG_SYS_I2C
71 #define CONFIG_SYS_I2C_DW 77 #define CONFIG_SYS_I2C_DW
72 #define CONFIG_I2C_ENV_EEPROM_BUS 2 78 #define CONFIG_I2C_ENV_EEPROM_BUS 2
73 #define CONFIG_SYS_I2C_SPEED 100000 79 #define CONFIG_SYS_I2C_SPEED 100000
74 #define CONFIG_SYS_I2C_SPEED1 100000 80 #define CONFIG_SYS_I2C_SPEED1 100000
75 #define CONFIG_SYS_I2C_SPEED2 100000 81 #define CONFIG_SYS_I2C_SPEED2 100000
76 #define CONFIG_SYS_I2C_SLAVE 0 82 #define CONFIG_SYS_I2C_SLAVE 0
77 #define CONFIG_SYS_I2C_SLAVE1 0 83 #define CONFIG_SYS_I2C_SLAVE1 0
78 #define CONFIG_SYS_I2C_SLAVE2 0 84 #define CONFIG_SYS_I2C_SLAVE2 0
79 #define CONFIG_SYS_I2C_BASE 0xE001D000 85 #define CONFIG_SYS_I2C_BASE 0xE001D000
80 #define CONFIG_SYS_I2C_BASE1 0xE001E000 86 #define CONFIG_SYS_I2C_BASE1 0xE001E000
81 #define CONFIG_SYS_I2C_BASE2 0xE001F000 87 #define CONFIG_SYS_I2C_BASE2 0xE001F000
82 #define CONFIG_SYS_I2C_BUS_MAX 3 88 #define CONFIG_SYS_I2C_BUS_MAX 3
83 #define IC_CLK 50 89 #define IC_CLK 50
84 90
85 /* 91 /*
86 * EEPROM configuration 92 * EEPROM configuration
87 */ 93 */
88 #define CONFIG_SYS_I2C_MULTI_EEPROMS 94 #define CONFIG_SYS_I2C_MULTI_EEPROMS
89 #define CONFIG_SYS_I2C_EEPROM_ADDR (0xA8 >> 1) 95 #define CONFIG_SYS_I2C_EEPROM_ADDR (0xA8 >> 1)
90 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1 96 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
91 #define CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW 1 97 #define CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW 1
92 #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3 98 #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
93 #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 64 99 #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 64
94 100
95 /* 101 /*
96 * SD/MMC configuration 102 * SD/MMC configuration
97 */ 103 */
98 #define CONFIG_MMC 104 #define CONFIG_MMC
99 #define CONFIG_GENERIC_MMC 105 #define CONFIG_GENERIC_MMC
100 #define CONFIG_DWMMC 106 #define CONFIG_DWMMC
101 #define CONFIG_DOS_PARTITION 107 #define CONFIG_DOS_PARTITION
102 108
103 /* 109 /*
104 * Ethernet PHY configuration 110 * Ethernet PHY configuration
105 */ 111 */
106 #define CONFIG_PHYLIB 112 #define CONFIG_PHYLIB
107 #define CONFIG_MII 113 #define CONFIG_MII
108 #define CONFIG_PHY_GIGE 114 #define CONFIG_PHY_GIGE
109 115
110 /* 116 /*
111 * Ethernet configuration 117 * Ethernet configuration
112 */ 118 */
113 #define CONFIG_DESIGNWARE_ETH 119 #define CONFIG_DESIGNWARE_ETH
114 #define CONFIG_DW_AUTONEG 120 #define CONFIG_DW_AUTONEG
115 #define CONFIG_NET_MULTI 121 #define CONFIG_NET_MULTI
116 122
117 /* 123 /*
118 * Command line configuration 124 * Command line configuration
119 */ 125 */
120 #include <config_cmd_default.h> 126 #include <config_cmd_default.h>
121 127
122 #define CONFIG_CMD_DHCP 128 #define CONFIG_CMD_DHCP
123 #define CONFIG_CMD_EEPROM 129 #define CONFIG_CMD_EEPROM
124 #define CONFIG_CMD_ELF 130 #define CONFIG_CMD_ELF
125 #define CONFIG_CMD_FAT 131 #define CONFIG_CMD_FAT
126 #define CONFIG_CMD_I2C 132 #define CONFIG_CMD_I2C
127 #define CONFIG_CMD_MMC 133 #define CONFIG_CMD_MMC
128 #define CONFIG_CMD_NAND 134 #define CONFIG_CMD_NAND
129 #define CONFIG_CMD_PING 135 #define CONFIG_CMD_PING
130 #define CONFIG_CMD_RARP 136 #define CONFIG_CMD_RARP
131 137
132 #define CONFIG_OF_LIBFDT 138 #define CONFIG_OF_LIBFDT
133 139
134 #define CONFIG_AUTO_COMPLETE 140 #define CONFIG_AUTO_COMPLETE
135 #define CONFIG_SYS_MAXARGS 16 141 #define CONFIG_SYS_MAXARGS 16
136 142
137 /* 143 /*
138 * Environment settings 144 * Environment settings
139 */ 145 */
140 #define CONFIG_ENV_IS_IN_EEPROM 146 #define CONFIG_ENV_IS_IN_EEPROM
141 #define CONFIG_ENV_SIZE 0x00200 /* 512 bytes */ 147 #define CONFIG_ENV_SIZE 0x00200 /* 512 bytes */
142 #define CONFIG_ENV_OFFSET 0 148 #define CONFIG_ENV_OFFSET 0
143 149
144 /* 150 /*
145 * Environment configuration 151 * Environment configuration
146 */ 152 */
147 #define CONFIG_BOOTDELAY 3 153 #define CONFIG_BOOTDELAY 3
148 #define CONFIG_BOOTFILE "uImage" 154 #define CONFIG_BOOTFILE "uImage"
149 #define CONFIG_BOOTARGS "console=ttyS3,115200n8" 155 #define CONFIG_BOOTARGS "console=ttyS3,115200n8"
150 #define CONFIG_LOADADDR CONFIG_SYS_LOAD_ADDR 156 #define CONFIG_LOADADDR CONFIG_SYS_LOAD_ADDR
151 157
152 /* 158 /*
153 * Console configuration 159 * Console configuration
154 */ 160 */
155 #define CONFIG_SYS_LONGHELP 161 #define CONFIG_SYS_LONGHELP
156 #define CONFIG_SYS_PROMPT "AXS# " 162 #define CONFIG_SYS_PROMPT "AXS# "
157 #define CONFIG_SYS_CBSIZE 256 163 #define CONFIG_SYS_CBSIZE 256
158 #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE 164 #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE
159 #define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + \ 165 #define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + \
160 sizeof(CONFIG_SYS_PROMPT) + 16) 166 sizeof(CONFIG_SYS_PROMPT) + 16)
161 167
162 /* 168 /*
163 * Misc utility configuration 169 * Misc utility configuration
164 */ 170 */
165 #define CONFIG_BOUNCE_BUFFER 171 #define CONFIG_BOUNCE_BUFFER
166 172
167 #endif /* _CONFIG_AXS101_H_ */ 173 #endif /* _CONFIG_AXS101_H_ */
168 174