blob: 25fbf4120955f6c578e15ad6e6ff0c9d4b4d1dca [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>
Simon Glass3ba929a2020-10-30 21:38:53 -060018#include <asm/global_data.h>
Marek Vasut2db1e962010-09-09 09:50:39 +020019#include <asm/io.h>
Marcel Ziswiler15fc2722016-11-14 21:40:28 +010020#include <dm/platdata.h>
Marcel Ziswiler6ad69a42019-05-20 02:45:01 +020021#include <dm/platform_data/pxa_mmc_gen.h>
Marcel Ziswiler15fc2722016-11-14 21:40:28 +010022#include <dm/platform_data/serial_pxa.h>
23#include <netdev.h>
Marek Vasute326a232011-11-26 07:15:36 +010024#include <serial.h>
Mateusz Zalegad862f892013-10-04 19:22:26 +020025#include <usb.h>
Simon Glass0ffb9d62017-05-31 19:47:48 -060026#include <asm/mach-types.h>
Simon Glassdbd79542020-05-10 11:40:11 -060027#include <linux/delay.h>
Stefan Agner98ffd0f2016-11-30 13:41:53 -080028#include "../common/tdx-common.h"
Marek Vasut163551a2010-05-11 04:31:44 +020029
30DECLARE_GLOBAL_DATA_PTR;
31
Marek Vasute326a232011-11-26 07:15:36 +010032int board_init(void)
Marek Vasut163551a2010-05-11 04:31:44 +020033{
Marek Vasut20212992010-10-20 20:15:11 +020034 /* We have RAM, disable cache */
35 dcache_disable();
36 icache_disable();
Marek Vasut163551a2010-05-11 04:31:44 +020037
Marcel Ziswilerb7063652015-03-01 00:53:08 +010038 /* arch number of Toradex Colibri PXA270 */
Marek Vasut163551a2010-05-11 04:31:44 +020039 gd->bd->bi_arch_number = MACH_TYPE_COLIBRI;
40
Marcel Ziswiler6ad69a42019-05-20 02:45:01 +020041 /* address of boot parameters */
Marek Vasut163551a2010-05-11 04:31:44 +020042 gd->bd->bi_boot_params = 0xa0000100;
43
44 return 0;
45}
46
Marcel Ziswilerd92dee52016-11-16 17:49:23 +010047int checkboard(void)
48{
49 puts("Model: Toradex Colibri PXA270\n");
50
51 return 0;
52}
53
Stefan Agner98ffd0f2016-11-30 13:41:53 -080054#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +090055int ft_board_setup(void *blob, struct bd_info *bd)
Stefan Agner98ffd0f2016-11-30 13:41:53 -080056{
57 return ft_common_board_setup(blob, bd);
58}
59#endif
60
Marek Vasut20212992010-10-20 20:15:11 +020061int dram_init(void)
Marek Vasut163551a2010-05-11 04:31:44 +020062{
Marek Vasut08341be2011-11-26 11:18:57 +010063 pxa2xx_dram_init();
Marek Vasut20212992010-10-20 20:15:11 +020064 gd->ram_size = PHYS_SDRAM_1_SIZE;
65 return 0;
66}
Marek Vasut163551a2010-05-11 04:31:44 +020067
Marek Vasut163551a2010-05-11 04:31:44 +020068#ifdef CONFIG_CMD_USB
Troy Kiskyde8ae7b2013-10-10 15:27:55 -070069int board_usb_init(int index, enum usb_init_type init)
Marek Vasut163551a2010-05-11 04:31:44 +020070{
Marek Vasut2db1e962010-09-09 09:50:39 +020071 writel((readl(UHCHR) | UHCHR_PCPL | UHCHR_PSPL) &
72 ~(UHCHR_SSEP0 | UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSE),
73 UHCHR);
Marek Vasut163551a2010-05-11 04:31:44 +020074
Marek Vasut2db1e962010-09-09 09:50:39 +020075 writel(readl(UHCHR) | UHCHR_FSBIR, UHCHR);
Marek Vasut163551a2010-05-11 04:31:44 +020076
Marek Vasute326a232011-11-26 07:15:36 +010077 while (UHCHR & UHCHR_FSBIR)
78 ;
Marek Vasut163551a2010-05-11 04:31:44 +020079
Marek Vasut2db1e962010-09-09 09:50:39 +020080 writel(readl(UHCHR) & ~UHCHR_SSE, UHCHR);
81 writel((UHCHIE_UPRIE | UHCHIE_RWIE), UHCHIE);
Marek Vasut163551a2010-05-11 04:31:44 +020082
83 /* Clear any OTG Pin Hold */
Marek Vasut2db1e962010-09-09 09:50:39 +020084 if (readl(PSSR) & PSSR_OTGPH)
85 writel(readl(PSSR) | PSSR_OTGPH, PSSR);
Marek Vasut163551a2010-05-11 04:31:44 +020086
Marek Vasut2db1e962010-09-09 09:50:39 +020087 writel(readl(UHCRHDA) & ~(0x200), UHCRHDA);
88 writel(readl(UHCRHDA) | 0x100, UHCRHDA);
Marek Vasut163551a2010-05-11 04:31:44 +020089
90 /* Set port power control mask bits, only 3 ports. */
Marcel Ziswiler6ad69a42019-05-20 02:45:01 +020091 writel(readl(UHCRHDB) | (0x7 << 17), UHCRHDB);
Marek Vasut163551a2010-05-11 04:31:44 +020092
93 /* enable port 2 */
Marek Vasut2db1e962010-09-09 09:50:39 +020094 writel(readl(UP2OCR) | UP2OCR_HXOE | UP2OCR_HXS |
95 UP2OCR_DMPDE | UP2OCR_DPPDE, UP2OCR);
Marek Vasut163551a2010-05-11 04:31:44 +020096
97 return 0;
98}
99
Troy Kiskyde8ae7b2013-10-10 15:27:55 -0700100int board_usb_cleanup(int index, enum usb_init_type init)
Marek Vasut163551a2010-05-11 04:31:44 +0200101{
Mateusz Zalegad862f892013-10-04 19:22:26 +0200102 return 0;
Marek Vasut163551a2010-05-11 04:31:44 +0200103}
104
105void usb_board_stop(void)
106{
Marek Vasut2db1e962010-09-09 09:50:39 +0200107 writel(readl(UHCHR) | UHCHR_FHR, UHCHR);
Marek Vasut163551a2010-05-11 04:31:44 +0200108 udelay(11);
Marek Vasut2db1e962010-09-09 09:50:39 +0200109 writel(readl(UHCHR) & ~UHCHR_FHR, UHCHR);
Marek Vasut163551a2010-05-11 04:31:44 +0200110
Marek Vasut2db1e962010-09-09 09:50:39 +0200111 writel(readl(UHCCOMS) | 1, UHCCOMS);
Marek Vasut163551a2010-05-11 04:31:44 +0200112 udelay(10);
113
Marek Vasut2db1e962010-09-09 09:50:39 +0200114 writel(readl(CKEN) & ~CKEN10_USBHOST, CKEN);
Marek Vasut163551a2010-05-11 04:31:44 +0200115}
116#endif
117
118#ifdef CONFIG_DRIVER_DM9000
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +0900119int board_eth_init(struct bd_info *bis)
Marek Vasut163551a2010-05-11 04:31:44 +0200120{
121 return dm9000_initialize(bis);
122}
123#endif
Marek Vasute326a232011-11-26 07:15:36 +0100124
125#ifdef CONFIG_CMD_MMC
Marcel Ziswiler6ad69a42019-05-20 02:45:01 +0200126#if !CONFIG_IS_ENABLED(DM_MMC)
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +0900127int board_mmc_init(struct bd_info *bis)
Marek Vasute326a232011-11-26 07:15:36 +0100128{
129 pxa_mmc_register(0);
130 return 0;
131}
Marcel Ziswiler6ad69a42019-05-20 02:45:01 +0200132#else /* !CONFIG_IS_ENABLED(DM_MMC) */
Simon Glassb75b15b2020-12-03 16:55:23 -0700133static const struct pxa_mmc_plat mmc_plat = {
Marcel Ziswiler6ad69a42019-05-20 02:45:01 +0200134 .base = (struct pxa_mmc_regs *)MMC0_BASE,
135};
136
Simon Glass1d8364a2020-12-28 20:34:54 -0700137U_BOOT_DRVINFO(pxa_mmcs) = {
Marcel Ziswiler6ad69a42019-05-20 02:45:01 +0200138 .name = "pxa_mmc",
Simon Glassb75b15b2020-12-03 16:55:23 -0700139 .plat = &mmc_plat,
Marcel Ziswiler6ad69a42019-05-20 02:45:01 +0200140};
141#endif /* !CONFIG_IS_ENABLED(DM_MMC) */
Marek Vasute326a232011-11-26 07:15:36 +0100142#endif
Marcel Ziswiler15fc2722016-11-14 21:40:28 +0100143
Simon Glassb75b15b2020-12-03 16:55:23 -0700144static const struct pxa_serial_plat serial_plat = {
Marcel Ziswiler15fc2722016-11-14 21:40:28 +0100145 .base = (struct pxa_uart_regs *)FFUART_BASE,
146 .port = FFUART_INDEX,
147 .baudrate = CONFIG_BAUDRATE,
148};
149
Simon Glass1d8364a2020-12-28 20:34:54 -0700150U_BOOT_DRVINFO(pxa_serials) = {
Marcel Ziswiler15fc2722016-11-14 21:40:28 +0100151 .name = "serial_pxa",
Simon Glassb75b15b2020-12-03 16:55:23 -0700152 .plat = &serial_plat,
Marcel Ziswiler15fc2722016-11-14 21:40:28 +0100153};