blob: 4c21731eed865a40239a1b3b345cf1e0300bff4f [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Marek Vasut163551a2010-05-11 04:31:44 +02002/*
3 * Toradex Colibri PXA270 Support
4 *
5 * Copyright (C) 2010 Marek Vasut <marek.vasut@gmail.com>
Marcel Ziswiler6ad69a42019-05-20 02:45:01 +02006 * Copyright (C) 2016-2019 Marcel Ziswiler <marcel.ziswiler@toradex.com>
Marek Vasut163551a2010-05-11 04:31:44 +02007 */
8
9#include <common.h>
Simon Glass1d91ba72019-11-14 12:57:37 -070010#include <cpu_func.h>
Simon Glass11c89f32017-05-17 17:18:03 -060011#include <dm.h>
Simon Glass97589732020-05-10 11:40:02 -060012#include <init.h>
Simon Glass274e0b02020-05-10 11:39:56 -060013#include <net.h>
Marek Vasut163551a2010-05-11 04:31:44 +020014#include <asm/arch/hardware.h>
Marek Vasut71d058b2011-11-26 11:17:32 +010015#include <asm/arch/pxa.h>
Marcel Ziswiler15fc2722016-11-14 21:40:28 +010016#include <asm/arch/regs-mmc.h>
17#include <asm/arch/regs-uart.h>
Marek Vasut2db1e962010-09-09 09:50:39 +020018#include <asm/io.h>
Marcel Ziswiler15fc2722016-11-14 21:40:28 +010019#include <dm/platdata.h>
Marcel Ziswiler6ad69a42019-05-20 02:45:01 +020020#include <dm/platform_data/pxa_mmc_gen.h>
Marcel Ziswiler15fc2722016-11-14 21:40:28 +010021#include <dm/platform_data/serial_pxa.h>
22#include <netdev.h>
Marek Vasute326a232011-11-26 07:15:36 +010023#include <serial.h>
Mateusz Zalegad862f892013-10-04 19:22:26 +020024#include <usb.h>
Simon Glass0ffb9d62017-05-31 19:47:48 -060025#include <asm/mach-types.h>
Simon Glassdbd79542020-05-10 11:40:11 -060026#include <linux/delay.h>
Stefan Agner98ffd0f2016-11-30 13:41:53 -080027#include "../common/tdx-common.h"
Marek Vasut163551a2010-05-11 04:31:44 +020028
29DECLARE_GLOBAL_DATA_PTR;
30
Marek Vasute326a232011-11-26 07:15:36 +010031int board_init(void)
Marek Vasut163551a2010-05-11 04:31:44 +020032{
Marek Vasut20212992010-10-20 20:15:11 +020033 /* We have RAM, disable cache */
34 dcache_disable();
35 icache_disable();
Marek Vasut163551a2010-05-11 04:31:44 +020036
Marcel Ziswilerb7063652015-03-01 00:53:08 +010037 /* arch number of Toradex Colibri PXA270 */
Marek Vasut163551a2010-05-11 04:31:44 +020038 gd->bd->bi_arch_number = MACH_TYPE_COLIBRI;
39
Marcel Ziswiler6ad69a42019-05-20 02:45:01 +020040 /* address of boot parameters */
Marek Vasut163551a2010-05-11 04:31:44 +020041 gd->bd->bi_boot_params = 0xa0000100;
42
43 return 0;
44}
45
Marcel Ziswilerd92dee52016-11-16 17:49:23 +010046int checkboard(void)
47{
48 puts("Model: Toradex Colibri PXA270\n");
49
50 return 0;
51}
52
Stefan Agner98ffd0f2016-11-30 13:41:53 -080053#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
54int ft_board_setup(void *blob, bd_t *bd)
55{
56 return ft_common_board_setup(blob, bd);
57}
58#endif
59
Marek Vasut20212992010-10-20 20:15:11 +020060int dram_init(void)
Marek Vasut163551a2010-05-11 04:31:44 +020061{
Marek Vasut08341be2011-11-26 11:18:57 +010062 pxa2xx_dram_init();
Marek Vasut20212992010-10-20 20:15:11 +020063 gd->ram_size = PHYS_SDRAM_1_SIZE;
64 return 0;
65}
Marek Vasut163551a2010-05-11 04:31:44 +020066
Marek Vasut163551a2010-05-11 04:31:44 +020067#ifdef CONFIG_CMD_USB
Troy Kiskyde8ae7b2013-10-10 15:27:55 -070068int board_usb_init(int index, enum usb_init_type init)
Marek Vasut163551a2010-05-11 04:31:44 +020069{
Marek Vasut2db1e962010-09-09 09:50:39 +020070 writel((readl(UHCHR) | UHCHR_PCPL | UHCHR_PSPL) &
71 ~(UHCHR_SSEP0 | UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSE),
72 UHCHR);
Marek Vasut163551a2010-05-11 04:31:44 +020073
Marek Vasut2db1e962010-09-09 09:50:39 +020074 writel(readl(UHCHR) | UHCHR_FSBIR, UHCHR);
Marek Vasut163551a2010-05-11 04:31:44 +020075
Marek Vasute326a232011-11-26 07:15:36 +010076 while (UHCHR & UHCHR_FSBIR)
77 ;
Marek Vasut163551a2010-05-11 04:31:44 +020078
Marek Vasut2db1e962010-09-09 09:50:39 +020079 writel(readl(UHCHR) & ~UHCHR_SSE, UHCHR);
80 writel((UHCHIE_UPRIE | UHCHIE_RWIE), UHCHIE);
Marek Vasut163551a2010-05-11 04:31:44 +020081
82 /* Clear any OTG Pin Hold */
Marek Vasut2db1e962010-09-09 09:50:39 +020083 if (readl(PSSR) & PSSR_OTGPH)
84 writel(readl(PSSR) | PSSR_OTGPH, PSSR);
Marek Vasut163551a2010-05-11 04:31:44 +020085
Marek Vasut2db1e962010-09-09 09:50:39 +020086 writel(readl(UHCRHDA) & ~(0x200), UHCRHDA);
87 writel(readl(UHCRHDA) | 0x100, UHCRHDA);
Marek Vasut163551a2010-05-11 04:31:44 +020088
89 /* Set port power control mask bits, only 3 ports. */
Marcel Ziswiler6ad69a42019-05-20 02:45:01 +020090 writel(readl(UHCRHDB) | (0x7 << 17), UHCRHDB);
Marek Vasut163551a2010-05-11 04:31:44 +020091
92 /* enable port 2 */
Marek Vasut2db1e962010-09-09 09:50:39 +020093 writel(readl(UP2OCR) | UP2OCR_HXOE | UP2OCR_HXS |
94 UP2OCR_DMPDE | UP2OCR_DPPDE, UP2OCR);
Marek Vasut163551a2010-05-11 04:31:44 +020095
96 return 0;
97}
98
Troy Kiskyde8ae7b2013-10-10 15:27:55 -070099int board_usb_cleanup(int index, enum usb_init_type init)
Marek Vasut163551a2010-05-11 04:31:44 +0200100{
Mateusz Zalegad862f892013-10-04 19:22:26 +0200101 return 0;
Marek Vasut163551a2010-05-11 04:31:44 +0200102}
103
104void usb_board_stop(void)
105{
Marek Vasut2db1e962010-09-09 09:50:39 +0200106 writel(readl(UHCHR) | UHCHR_FHR, UHCHR);
Marek Vasut163551a2010-05-11 04:31:44 +0200107 udelay(11);
Marek Vasut2db1e962010-09-09 09:50:39 +0200108 writel(readl(UHCHR) & ~UHCHR_FHR, UHCHR);
Marek Vasut163551a2010-05-11 04:31:44 +0200109
Marek Vasut2db1e962010-09-09 09:50:39 +0200110 writel(readl(UHCCOMS) | 1, UHCCOMS);
Marek Vasut163551a2010-05-11 04:31:44 +0200111 udelay(10);
112
Marek Vasut2db1e962010-09-09 09:50:39 +0200113 writel(readl(CKEN) & ~CKEN10_USBHOST, CKEN);
Marek Vasut163551a2010-05-11 04:31:44 +0200114}
115#endif
116
117#ifdef CONFIG_DRIVER_DM9000
118int board_eth_init(bd_t *bis)
119{
120 return dm9000_initialize(bis);
121}
122#endif
Marek Vasute326a232011-11-26 07:15:36 +0100123
124#ifdef CONFIG_CMD_MMC
Marcel Ziswiler6ad69a42019-05-20 02:45:01 +0200125#if !CONFIG_IS_ENABLED(DM_MMC)
Marek Vasute326a232011-11-26 07:15:36 +0100126int board_mmc_init(bd_t *bis)
127{
128 pxa_mmc_register(0);
129 return 0;
130}
Marcel Ziswiler6ad69a42019-05-20 02:45:01 +0200131#else /* !CONFIG_IS_ENABLED(DM_MMC) */
132static const struct pxa_mmc_plat mmc_platdata = {
133 .base = (struct pxa_mmc_regs *)MMC0_BASE,
134};
135
136U_BOOT_DEVICE(pxa_mmcs) = {
137 .name = "pxa_mmc",
138 .platdata = &mmc_platdata,
139};
140#endif /* !CONFIG_IS_ENABLED(DM_MMC) */
Marek Vasute326a232011-11-26 07:15:36 +0100141#endif
Marcel Ziswiler15fc2722016-11-14 21:40:28 +0100142
143static const struct pxa_serial_platdata serial_platdata = {
144 .base = (struct pxa_uart_regs *)FFUART_BASE,
145 .port = FFUART_INDEX,
146 .baudrate = CONFIG_BAUDRATE,
147};
148
149U_BOOT_DEVICE(pxa_serials) = {
150 .name = "serial_pxa",
151 .platdata = &serial_platdata,
152};