blob: 5d62e66495b5826bc2269d861fe09855fba3dd9c [file] [log] [blame]
Marek Vasut163551a2010-05-11 04:31:44 +02001/*
2 * Toradex Colibri PXA270 Support
3 *
4 * Copyright (C) 2010 Marek Vasut <marek.vasut@gmail.com>
Marcel Ziswilerd92dee52016-11-16 17:49:23 +01005 * Copyright (C) 2016 Marcel Ziswiler <marcel.ziswiler@toradex.com>
Marek Vasut163551a2010-05-11 04:31:44 +02006 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02007 * SPDX-License-Identifier: GPL-2.0+
Marek Vasut163551a2010-05-11 04:31:44 +02008 */
9
10#include <common.h>
Simon Glass11c89f32017-05-17 17:18:03 -060011#include <dm.h>
Marek Vasut163551a2010-05-11 04:31:44 +020012#include <asm/arch/hardware.h>
Marek Vasut71d058b2011-11-26 11:17:32 +010013#include <asm/arch/pxa.h>
Marcel Ziswiler15fc2722016-11-14 21:40:28 +010014#include <asm/arch/regs-mmc.h>
15#include <asm/arch/regs-uart.h>
Marek Vasut2db1e962010-09-09 09:50:39 +020016#include <asm/io.h>
Marcel Ziswiler15fc2722016-11-14 21:40:28 +010017#include <dm/platdata.h>
18#include <dm/platform_data/serial_pxa.h>
19#include <netdev.h>
Marek Vasute326a232011-11-26 07:15:36 +010020#include <serial.h>
Mateusz Zalegad862f892013-10-04 19:22:26 +020021#include <usb.h>
Stefan Agner98ffd0f2016-11-30 13:41:53 -080022#include "../common/tdx-common.h"
Marek Vasut163551a2010-05-11 04:31:44 +020023
24DECLARE_GLOBAL_DATA_PTR;
25
Marek Vasute326a232011-11-26 07:15:36 +010026int board_init(void)
Marek Vasut163551a2010-05-11 04:31:44 +020027{
Marek Vasut20212992010-10-20 20:15:11 +020028 /* We have RAM, disable cache */
29 dcache_disable();
30 icache_disable();
Marek Vasut163551a2010-05-11 04:31:44 +020031
Marcel Ziswilerb7063652015-03-01 00:53:08 +010032 /* arch number of Toradex Colibri PXA270 */
Marek Vasut163551a2010-05-11 04:31:44 +020033 gd->bd->bi_arch_number = MACH_TYPE_COLIBRI;
34
35 /* adress of boot parameters */
36 gd->bd->bi_boot_params = 0xa0000100;
37
38 return 0;
39}
40
Marcel Ziswilerd92dee52016-11-16 17:49:23 +010041int checkboard(void)
42{
43 puts("Model: Toradex Colibri PXA270\n");
44
45 return 0;
46}
47
Stefan Agner98ffd0f2016-11-30 13:41:53 -080048#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
49int ft_board_setup(void *blob, bd_t *bd)
50{
51 return ft_common_board_setup(blob, bd);
52}
53#endif
54
Marek Vasut20212992010-10-20 20:15:11 +020055int dram_init(void)
Marek Vasut163551a2010-05-11 04:31:44 +020056{
Marek Vasut08341be2011-11-26 11:18:57 +010057 pxa2xx_dram_init();
Marek Vasut20212992010-10-20 20:15:11 +020058 gd->ram_size = PHYS_SDRAM_1_SIZE;
59 return 0;
60}
Marek Vasut163551a2010-05-11 04:31:44 +020061
Marek Vasut163551a2010-05-11 04:31:44 +020062#ifdef CONFIG_CMD_USB
Troy Kiskyde8ae7b2013-10-10 15:27:55 -070063int board_usb_init(int index, enum usb_init_type init)
Marek Vasut163551a2010-05-11 04:31:44 +020064{
Marek Vasut2db1e962010-09-09 09:50:39 +020065 writel((readl(UHCHR) | UHCHR_PCPL | UHCHR_PSPL) &
66 ~(UHCHR_SSEP0 | UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSE),
67 UHCHR);
Marek Vasut163551a2010-05-11 04:31:44 +020068
Marek Vasut2db1e962010-09-09 09:50:39 +020069 writel(readl(UHCHR) | UHCHR_FSBIR, UHCHR);
Marek Vasut163551a2010-05-11 04:31:44 +020070
Marek Vasute326a232011-11-26 07:15:36 +010071 while (UHCHR & UHCHR_FSBIR)
72 ;
Marek Vasut163551a2010-05-11 04:31:44 +020073
Marek Vasut2db1e962010-09-09 09:50:39 +020074 writel(readl(UHCHR) & ~UHCHR_SSE, UHCHR);
75 writel((UHCHIE_UPRIE | UHCHIE_RWIE), UHCHIE);
Marek Vasut163551a2010-05-11 04:31:44 +020076
77 /* Clear any OTG Pin Hold */
Marek Vasut2db1e962010-09-09 09:50:39 +020078 if (readl(PSSR) & PSSR_OTGPH)
79 writel(readl(PSSR) | PSSR_OTGPH, PSSR);
Marek Vasut163551a2010-05-11 04:31:44 +020080
Marek Vasut2db1e962010-09-09 09:50:39 +020081 writel(readl(UHCRHDA) & ~(0x200), UHCRHDA);
82 writel(readl(UHCRHDA) | 0x100, UHCRHDA);
Marek Vasut163551a2010-05-11 04:31:44 +020083
84 /* Set port power control mask bits, only 3 ports. */
Marek Vasut2db1e962010-09-09 09:50:39 +020085 writel(readl(UHCRHDB) | (0x7<<17), UHCRHDB);
Marek Vasut163551a2010-05-11 04:31:44 +020086
87 /* enable port 2 */
Marek Vasut2db1e962010-09-09 09:50:39 +020088 writel(readl(UP2OCR) | UP2OCR_HXOE | UP2OCR_HXS |
89 UP2OCR_DMPDE | UP2OCR_DPPDE, UP2OCR);
Marek Vasut163551a2010-05-11 04:31:44 +020090
91 return 0;
92}
93
Troy Kiskyde8ae7b2013-10-10 15:27:55 -070094int board_usb_cleanup(int index, enum usb_init_type init)
Marek Vasut163551a2010-05-11 04:31:44 +020095{
Mateusz Zalegad862f892013-10-04 19:22:26 +020096 return 0;
Marek Vasut163551a2010-05-11 04:31:44 +020097}
98
99void usb_board_stop(void)
100{
Marek Vasut2db1e962010-09-09 09:50:39 +0200101 writel(readl(UHCHR) | UHCHR_FHR, UHCHR);
Marek Vasut163551a2010-05-11 04:31:44 +0200102 udelay(11);
Marek Vasut2db1e962010-09-09 09:50:39 +0200103 writel(readl(UHCHR) & ~UHCHR_FHR, UHCHR);
Marek Vasut163551a2010-05-11 04:31:44 +0200104
Marek Vasut2db1e962010-09-09 09:50:39 +0200105 writel(readl(UHCCOMS) | 1, UHCCOMS);
Marek Vasut163551a2010-05-11 04:31:44 +0200106 udelay(10);
107
Marek Vasut2db1e962010-09-09 09:50:39 +0200108 writel(readl(CKEN) & ~CKEN10_USBHOST, CKEN);
Marek Vasut163551a2010-05-11 04:31:44 +0200109
110 return;
111}
112#endif
113
114#ifdef CONFIG_DRIVER_DM9000
115int board_eth_init(bd_t *bis)
116{
117 return dm9000_initialize(bis);
118}
119#endif
Marek Vasute326a232011-11-26 07:15:36 +0100120
121#ifdef CONFIG_CMD_MMC
122int board_mmc_init(bd_t *bis)
123{
124 pxa_mmc_register(0);
125 return 0;
126}
127#endif
Marcel Ziswiler15fc2722016-11-14 21:40:28 +0100128
129static const struct pxa_serial_platdata serial_platdata = {
130 .base = (struct pxa_uart_regs *)FFUART_BASE,
131 .port = FFUART_INDEX,
132 .baudrate = CONFIG_BAUDRATE,
133};
134
135U_BOOT_DEVICE(pxa_serials) = {
136 .name = "serial_pxa",
137 .platdata = &serial_platdata,
138};