common: Drop init.h from common header
[pandora-u-boot.git] / arch / arm / cpu / arm926ejs / spear / cpu.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2010
4  * Vipin Kumar, ST Micoelectronics, vipin.kumar@st.com.
5  */
6
7 #include <common.h>
8 #include <init.h>
9 #include <asm/io.h>
10 #include <asm/arch/hardware.h>
11 #include <asm/arch/spr_misc.h>
12
13 int arch_cpu_init(void)
14 {
15         struct misc_regs *const misc_p =
16             (struct misc_regs *)CONFIG_SPEAR_MISCBASE;
17         u32 periph1_clken, periph_clk_cfg;
18
19         periph1_clken = readl(&misc_p->periph1_clken);
20
21 #if defined(CONFIG_SPEAR3XX)
22         periph1_clken |= MISC_GPT2ENB;
23 #elif defined(CONFIG_SPEAR600)
24         periph1_clken |= MISC_GPT3ENB;
25 #endif
26
27 #if defined(CONFIG_PL011_SERIAL)
28         periph1_clken |= MISC_UART0ENB;
29
30         periph_clk_cfg = readl(&misc_p->periph_clk_cfg);
31         periph_clk_cfg &= ~CONFIG_SPEAR_UARTCLKMSK;
32         periph_clk_cfg |= CONFIG_SPEAR_UART48M;
33         writel(periph_clk_cfg, &misc_p->periph_clk_cfg);
34 #endif
35 #if defined(CONFIG_ETH_DESIGNWARE)
36         periph1_clken |= MISC_ETHENB;
37 #endif
38 #if defined(CONFIG_DW_UDC)
39         periph1_clken |= MISC_USBDENB;
40 #endif
41 #if defined(CONFIG_SYS_I2C_DW)
42         periph1_clken |= MISC_I2CENB;
43 #endif
44 #if defined(CONFIG_ST_SMI)
45         periph1_clken |= MISC_SMIENB;
46 #endif
47 #if defined(CONFIG_NAND_FSMC)
48         periph1_clken |= MISC_FSMCENB;
49 #endif
50 #if defined(CONFIG_USB_EHCI_SPEAR)
51         periph1_clken |= PERIPH_USBH1 | PERIPH_USBH2;
52 #endif
53 #if defined(CONFIG_SPEAR_GPIO)
54         periph1_clken |= MISC_GPIO3ENB | MISC_GPIO4ENB;
55 #endif
56 #if defined(CONFIG_PL022_SPI)
57         periph1_clken |= MISC_SSP1ENB | MISC_SSP2ENB | MISC_SSP3ENB;
58 #endif
59
60         writel(periph1_clken, &misc_p->periph1_clken);
61
62         return 0;
63 }
64
65 #ifdef CONFIG_DISPLAY_CPUINFO
66 int print_cpuinfo(void)
67 {
68 #ifdef CONFIG_SPEAR300
69         printf("CPU:   SPEAr300\n");
70 #elif defined(CONFIG_SPEAR310)
71         printf("CPU:   SPEAr310\n");
72 #elif defined(CONFIG_SPEAR320)
73         printf("CPU:   SPEAr320\n");
74 #elif defined(CONFIG_SPEAR600)
75         printf("CPU:   SPEAr600\n");
76 #else
77 #error CPU not supported in spear platform
78 #endif
79         return 0;
80 }
81 #endif
82
83 #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_NAND_ECC_BCH) && defined(CONFIG_NAND_FSMC)
84 static int do_switch_ecc(cmd_tbl_t *cmdtp, int flag, int argc,
85                          char *const argv[])
86 {
87         if (argc != 2)
88                 goto usage;
89
90         if (strncmp(argv[1], "hw", 2) == 0) {
91                 /* 1-bit HW ECC */
92                 printf("Switching to 1-bit HW ECC\n");
93                 fsmc_nand_switch_ecc(1);
94         } else if (strncmp(argv[1], "bch4", 2) == 0) {
95                 /* 4-bit SW ECC BCH4 */
96                 printf("Switching to 4-bit SW ECC (BCH4)\n");
97                 fsmc_nand_switch_ecc(4);
98         } else {
99                 goto usage;
100         }
101
102         return 0;
103
104 usage:
105         printf("Usage: nandecc %s\n", cmdtp->usage);
106         return 1;
107 }
108
109 U_BOOT_CMD(
110         nandecc, 2, 0,  do_switch_ecc,
111         "switch NAND ECC calculation algorithm",
112         "hw|bch4 - Switch between NAND hardware 1-bit HW and"
113         " 4-bit SW BCH\n"
114 );
115 #endif