common: Drop linux/delay.h from common header
[oweals/u-boot.git] / board / toradex / colibri_pxa270 / colibri_pxa270.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Toradex Colibri PXA270 Support
4  *
5  * Copyright (C) 2010 Marek Vasut <marek.vasut@gmail.com>
6  * Copyright (C) 2016 Marcel Ziswiler <marcel.ziswiler@toradex.com>
7  */
8
9 #include <common.h>
10 #include <cpu_func.h>
11 #include <dm.h>
12 #include <init.h>
13 #include <net.h>
14 #include <asm/arch/hardware.h>
15 #include <asm/arch/pxa.h>
16 #include <asm/arch/regs-mmc.h>
17 #include <asm/arch/regs-uart.h>
18 #include <asm/io.h>
19 #include <dm/platdata.h>
20 #include <dm/platform_data/serial_pxa.h>
21 #include <netdev.h>
22 #include <serial.h>
23 #include <usb.h>
24 #include <asm/mach-types.h>
25 #include <linux/delay.h>
26 #include "../common/tdx-common.h"
27
28 DECLARE_GLOBAL_DATA_PTR;
29
30 int board_init(void)
31 {
32         /* We have RAM, disable cache */
33         dcache_disable();
34         icache_disable();
35
36         /* arch number of Toradex Colibri PXA270 */
37         gd->bd->bi_arch_number = MACH_TYPE_COLIBRI;
38
39         /* adress of boot parameters */
40         gd->bd->bi_boot_params = 0xa0000100;
41
42         return 0;
43 }
44
45 int checkboard(void)
46 {
47         puts("Model: Toradex Colibri PXA270\n");
48
49         return 0;
50 }
51
52 #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
53 int ft_board_setup(void *blob, bd_t *bd)
54 {
55         return ft_common_board_setup(blob, bd);
56 }
57 #endif
58
59 int dram_init(void)
60 {
61         pxa2xx_dram_init();
62         gd->ram_size = PHYS_SDRAM_1_SIZE;
63         return 0;
64 }
65
66 #ifdef  CONFIG_CMD_USB
67 int board_usb_init(int index, enum usb_init_type init)
68 {
69         writel((readl(UHCHR) | UHCHR_PCPL | UHCHR_PSPL) &
70                 ~(UHCHR_SSEP0 | UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSE),
71                 UHCHR);
72
73         writel(readl(UHCHR) | UHCHR_FSBIR, UHCHR);
74
75         while (UHCHR & UHCHR_FSBIR)
76                 ;
77
78         writel(readl(UHCHR) & ~UHCHR_SSE, UHCHR);
79         writel((UHCHIE_UPRIE | UHCHIE_RWIE), UHCHIE);
80
81         /* Clear any OTG Pin Hold */
82         if (readl(PSSR) & PSSR_OTGPH)
83                 writel(readl(PSSR) | PSSR_OTGPH, PSSR);
84
85         writel(readl(UHCRHDA) & ~(0x200), UHCRHDA);
86         writel(readl(UHCRHDA) | 0x100, UHCRHDA);
87
88         /* Set port power control mask bits, only 3 ports. */
89         writel(readl(UHCRHDB) | (0x7<<17), UHCRHDB);
90
91         /* enable port 2 */
92         writel(readl(UP2OCR) | UP2OCR_HXOE | UP2OCR_HXS |
93                 UP2OCR_DMPDE | UP2OCR_DPPDE, UP2OCR);
94
95         return 0;
96 }
97
98 int board_usb_cleanup(int index, enum usb_init_type init)
99 {
100         return 0;
101 }
102
103 void usb_board_stop(void)
104 {
105         writel(readl(UHCHR) | UHCHR_FHR, UHCHR);
106         udelay(11);
107         writel(readl(UHCHR) & ~UHCHR_FHR, UHCHR);
108
109         writel(readl(UHCCOMS) | 1, UHCCOMS);
110         udelay(10);
111
112         writel(readl(CKEN) & ~CKEN10_USBHOST, CKEN);
113
114         return;
115 }
116 #endif
117
118 #ifdef CONFIG_DRIVER_DM9000
119 int board_eth_init(bd_t *bis)
120 {
121         return dm9000_initialize(bis);
122 }
123 #endif
124
125 #ifdef  CONFIG_CMD_MMC
126 int board_mmc_init(bd_t *bis)
127 {
128         pxa_mmc_register(0);
129         return 0;
130 }
131 #endif
132
133 static const struct pxa_serial_platdata serial_platdata = {
134         .base = (struct pxa_uart_regs *)FFUART_BASE,
135         .port = FFUART_INDEX,
136         .baudrate = CONFIG_BAUDRATE,
137 };
138
139 U_BOOT_DEVICE(pxa_serials) = {
140         .name = "serial_pxa",
141         .platdata = &serial_platdata,
142 };