blob: 8e948545e3b92708359b18d53a15ee1b2cc94a0d [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>
11#include <asm/arch/hardware.h>
Marek Vasut71d058b2011-11-26 11:17:32 +010012#include <asm/arch/pxa.h>
Marcel Ziswiler15fc2722016-11-14 21:40:28 +010013#include <asm/arch/regs-mmc.h>
14#include <asm/arch/regs-uart.h>
Marek Vasut2db1e962010-09-09 09:50:39 +020015#include <asm/io.h>
Marcel Ziswiler15fc2722016-11-14 21:40:28 +010016#include <dm/platdata.h>
17#include <dm/platform_data/serial_pxa.h>
18#include <netdev.h>
Marek Vasute326a232011-11-26 07:15:36 +010019#include <serial.h>
Mateusz Zalegad862f892013-10-04 19:22:26 +020020#include <usb.h>
Stefan Agner98ffd0f2016-11-30 13:41:53 -080021#include "../common/tdx-common.h"
Marek Vasut163551a2010-05-11 04:31:44 +020022
23DECLARE_GLOBAL_DATA_PTR;
24
Marek Vasute326a232011-11-26 07:15:36 +010025int board_init(void)
Marek Vasut163551a2010-05-11 04:31:44 +020026{
Marek Vasut20212992010-10-20 20:15:11 +020027 /* We have RAM, disable cache */
28 dcache_disable();
29 icache_disable();
Marek Vasut163551a2010-05-11 04:31:44 +020030
Marcel Ziswilerb7063652015-03-01 00:53:08 +010031 /* arch number of Toradex Colibri PXA270 */
Marek Vasut163551a2010-05-11 04:31:44 +020032 gd->bd->bi_arch_number = MACH_TYPE_COLIBRI;
33
34 /* adress of boot parameters */
35 gd->bd->bi_boot_params = 0xa0000100;
36
37 return 0;
38}
39
Marcel Ziswilerd92dee52016-11-16 17:49:23 +010040int checkboard(void)
41{
42 puts("Model: Toradex Colibri PXA270\n");
43
44 return 0;
45}
46
Stefan Agner98ffd0f2016-11-30 13:41:53 -080047#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
48int ft_board_setup(void *blob, bd_t *bd)
49{
50 return ft_common_board_setup(blob, bd);
51}
52#endif
53
Marek Vasut20212992010-10-20 20:15:11 +020054int dram_init(void)
Marek Vasut163551a2010-05-11 04:31:44 +020055{
Marek Vasut08341be2011-11-26 11:18:57 +010056 pxa2xx_dram_init();
Marek Vasut20212992010-10-20 20:15:11 +020057 gd->ram_size = PHYS_SDRAM_1_SIZE;
58 return 0;
59}
Marek Vasut163551a2010-05-11 04:31:44 +020060
Marek Vasut163551a2010-05-11 04:31:44 +020061#ifdef CONFIG_CMD_USB
Troy Kiskyde8ae7b2013-10-10 15:27:55 -070062int board_usb_init(int index, enum usb_init_type init)
Marek Vasut163551a2010-05-11 04:31:44 +020063{
Marek Vasut2db1e962010-09-09 09:50:39 +020064 writel((readl(UHCHR) | UHCHR_PCPL | UHCHR_PSPL) &
65 ~(UHCHR_SSEP0 | UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSE),
66 UHCHR);
Marek Vasut163551a2010-05-11 04:31:44 +020067
Marek Vasut2db1e962010-09-09 09:50:39 +020068 writel(readl(UHCHR) | UHCHR_FSBIR, UHCHR);
Marek Vasut163551a2010-05-11 04:31:44 +020069
Marek Vasute326a232011-11-26 07:15:36 +010070 while (UHCHR & UHCHR_FSBIR)
71 ;
Marek Vasut163551a2010-05-11 04:31:44 +020072
Marek Vasut2db1e962010-09-09 09:50:39 +020073 writel(readl(UHCHR) & ~UHCHR_SSE, UHCHR);
74 writel((UHCHIE_UPRIE | UHCHIE_RWIE), UHCHIE);
Marek Vasut163551a2010-05-11 04:31:44 +020075
76 /* Clear any OTG Pin Hold */
Marek Vasut2db1e962010-09-09 09:50:39 +020077 if (readl(PSSR) & PSSR_OTGPH)
78 writel(readl(PSSR) | PSSR_OTGPH, PSSR);
Marek Vasut163551a2010-05-11 04:31:44 +020079
Marek Vasut2db1e962010-09-09 09:50:39 +020080 writel(readl(UHCRHDA) & ~(0x200), UHCRHDA);
81 writel(readl(UHCRHDA) | 0x100, UHCRHDA);
Marek Vasut163551a2010-05-11 04:31:44 +020082
83 /* Set port power control mask bits, only 3 ports. */
Marek Vasut2db1e962010-09-09 09:50:39 +020084 writel(readl(UHCRHDB) | (0x7<<17), UHCRHDB);
Marek Vasut163551a2010-05-11 04:31:44 +020085
86 /* enable port 2 */
Marek Vasut2db1e962010-09-09 09:50:39 +020087 writel(readl(UP2OCR) | UP2OCR_HXOE | UP2OCR_HXS |
88 UP2OCR_DMPDE | UP2OCR_DPPDE, UP2OCR);
Marek Vasut163551a2010-05-11 04:31:44 +020089
90 return 0;
91}
92
Troy Kiskyde8ae7b2013-10-10 15:27:55 -070093int board_usb_cleanup(int index, enum usb_init_type init)
Marek Vasut163551a2010-05-11 04:31:44 +020094{
Mateusz Zalegad862f892013-10-04 19:22:26 +020095 return 0;
Marek Vasut163551a2010-05-11 04:31:44 +020096}
97
98void usb_board_stop(void)
99{
Marek Vasut2db1e962010-09-09 09:50:39 +0200100 writel(readl(UHCHR) | UHCHR_FHR, UHCHR);
Marek Vasut163551a2010-05-11 04:31:44 +0200101 udelay(11);
Marek Vasut2db1e962010-09-09 09:50:39 +0200102 writel(readl(UHCHR) & ~UHCHR_FHR, UHCHR);
Marek Vasut163551a2010-05-11 04:31:44 +0200103
Marek Vasut2db1e962010-09-09 09:50:39 +0200104 writel(readl(UHCCOMS) | 1, UHCCOMS);
Marek Vasut163551a2010-05-11 04:31:44 +0200105 udelay(10);
106
Marek Vasut2db1e962010-09-09 09:50:39 +0200107 writel(readl(CKEN) & ~CKEN10_USBHOST, CKEN);
Marek Vasut163551a2010-05-11 04:31:44 +0200108
109 return;
110}
111#endif
112
113#ifdef CONFIG_DRIVER_DM9000
114int board_eth_init(bd_t *bis)
115{
116 return dm9000_initialize(bis);
117}
118#endif
Marek Vasute326a232011-11-26 07:15:36 +0100119
120#ifdef CONFIG_CMD_MMC
121int board_mmc_init(bd_t *bis)
122{
123 pxa_mmc_register(0);
124 return 0;
125}
126#endif
Marcel Ziswiler15fc2722016-11-14 21:40:28 +0100127
128static const struct pxa_serial_platdata serial_platdata = {
129 .base = (struct pxa_uart_regs *)FFUART_BASE,
130 .port = FFUART_INDEX,
131 .baudrate = CONFIG_BAUDRATE,
132};
133
134U_BOOT_DEVICE(pxa_serials) = {
135 .name = "serial_pxa",
136 .platdata = &serial_platdata,
137};