Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Toradex Colibri PXA270 Support |
| 3 | * |
| 4 | * Copyright (C) 2010 Marek Vasut <marek.vasut@gmail.com> |
| 5 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 6 | * SPDX-License-Identifier: GPL-2.0+ |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <common.h> |
| 10 | #include <asm/arch/hardware.h> |
Marek Vasut | 71d058b | 2011-11-26 11:17:32 +0100 | [diff] [blame] | 11 | #include <asm/arch/pxa.h> |
Marcel Ziswiler | 15fc272 | 2016-11-14 21:40:28 +0100 | [diff] [blame^] | 12 | #include <asm/arch/regs-mmc.h> |
| 13 | #include <asm/arch/regs-uart.h> |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 14 | #include <asm/io.h> |
Marcel Ziswiler | 15fc272 | 2016-11-14 21:40:28 +0100 | [diff] [blame^] | 15 | #include <dm/platdata.h> |
| 16 | #include <dm/platform_data/serial_pxa.h> |
| 17 | #include <netdev.h> |
Marek Vasut | e326a23 | 2011-11-26 07:15:36 +0100 | [diff] [blame] | 18 | #include <serial.h> |
Mateusz Zalega | d862f89 | 2013-10-04 19:22:26 +0200 | [diff] [blame] | 19 | #include <usb.h> |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 20 | |
| 21 | DECLARE_GLOBAL_DATA_PTR; |
| 22 | |
Marek Vasut | e326a23 | 2011-11-26 07:15:36 +0100 | [diff] [blame] | 23 | int board_init(void) |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 24 | { |
Marek Vasut | 2021299 | 2010-10-20 20:15:11 +0200 | [diff] [blame] | 25 | /* We have RAM, disable cache */ |
| 26 | dcache_disable(); |
| 27 | icache_disable(); |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 28 | |
Marcel Ziswiler | b706365 | 2015-03-01 00:53:08 +0100 | [diff] [blame] | 29 | /* arch number of Toradex Colibri PXA270 */ |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 30 | gd->bd->bi_arch_number = MACH_TYPE_COLIBRI; |
| 31 | |
| 32 | /* adress of boot parameters */ |
| 33 | gd->bd->bi_boot_params = 0xa0000100; |
| 34 | |
| 35 | return 0; |
| 36 | } |
| 37 | |
Marek Vasut | 2021299 | 2010-10-20 20:15:11 +0200 | [diff] [blame] | 38 | int dram_init(void) |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 39 | { |
Marek Vasut | 08341be | 2011-11-26 11:18:57 +0100 | [diff] [blame] | 40 | pxa2xx_dram_init(); |
Marek Vasut | 2021299 | 2010-10-20 20:15:11 +0200 | [diff] [blame] | 41 | gd->ram_size = PHYS_SDRAM_1_SIZE; |
| 42 | return 0; |
| 43 | } |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 44 | |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 45 | #ifdef CONFIG_CMD_USB |
Troy Kisky | de8ae7b | 2013-10-10 15:27:55 -0700 | [diff] [blame] | 46 | int board_usb_init(int index, enum usb_init_type init) |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 47 | { |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 48 | writel((readl(UHCHR) | UHCHR_PCPL | UHCHR_PSPL) & |
| 49 | ~(UHCHR_SSEP0 | UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSE), |
| 50 | UHCHR); |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 51 | |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 52 | writel(readl(UHCHR) | UHCHR_FSBIR, UHCHR); |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 53 | |
Marek Vasut | e326a23 | 2011-11-26 07:15:36 +0100 | [diff] [blame] | 54 | while (UHCHR & UHCHR_FSBIR) |
| 55 | ; |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 56 | |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 57 | writel(readl(UHCHR) & ~UHCHR_SSE, UHCHR); |
| 58 | writel((UHCHIE_UPRIE | UHCHIE_RWIE), UHCHIE); |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 59 | |
| 60 | /* Clear any OTG Pin Hold */ |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 61 | if (readl(PSSR) & PSSR_OTGPH) |
| 62 | writel(readl(PSSR) | PSSR_OTGPH, PSSR); |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 63 | |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 64 | writel(readl(UHCRHDA) & ~(0x200), UHCRHDA); |
| 65 | writel(readl(UHCRHDA) | 0x100, UHCRHDA); |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 66 | |
| 67 | /* Set port power control mask bits, only 3 ports. */ |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 68 | writel(readl(UHCRHDB) | (0x7<<17), UHCRHDB); |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 69 | |
| 70 | /* enable port 2 */ |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 71 | writel(readl(UP2OCR) | UP2OCR_HXOE | UP2OCR_HXS | |
| 72 | UP2OCR_DMPDE | UP2OCR_DPPDE, UP2OCR); |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 73 | |
| 74 | return 0; |
| 75 | } |
| 76 | |
Troy Kisky | de8ae7b | 2013-10-10 15:27:55 -0700 | [diff] [blame] | 77 | int board_usb_cleanup(int index, enum usb_init_type init) |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 78 | { |
Mateusz Zalega | d862f89 | 2013-10-04 19:22:26 +0200 | [diff] [blame] | 79 | return 0; |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | void usb_board_stop(void) |
| 83 | { |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 84 | writel(readl(UHCHR) | UHCHR_FHR, UHCHR); |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 85 | udelay(11); |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 86 | writel(readl(UHCHR) & ~UHCHR_FHR, UHCHR); |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 87 | |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 88 | writel(readl(UHCCOMS) | 1, UHCCOMS); |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 89 | udelay(10); |
| 90 | |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 91 | writel(readl(CKEN) & ~CKEN10_USBHOST, CKEN); |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 92 | |
| 93 | return; |
| 94 | } |
| 95 | #endif |
| 96 | |
| 97 | #ifdef CONFIG_DRIVER_DM9000 |
| 98 | int board_eth_init(bd_t *bis) |
| 99 | { |
| 100 | return dm9000_initialize(bis); |
| 101 | } |
| 102 | #endif |
Marek Vasut | e326a23 | 2011-11-26 07:15:36 +0100 | [diff] [blame] | 103 | |
| 104 | #ifdef CONFIG_CMD_MMC |
| 105 | int board_mmc_init(bd_t *bis) |
| 106 | { |
| 107 | pxa_mmc_register(0); |
| 108 | return 0; |
| 109 | } |
| 110 | #endif |
Marcel Ziswiler | 15fc272 | 2016-11-14 21:40:28 +0100 | [diff] [blame^] | 111 | |
| 112 | static const struct pxa_serial_platdata serial_platdata = { |
| 113 | .base = (struct pxa_uart_regs *)FFUART_BASE, |
| 114 | .port = FFUART_INDEX, |
| 115 | .baudrate = CONFIG_BAUDRATE, |
| 116 | }; |
| 117 | |
| 118 | U_BOOT_DEVICE(pxa_serials) = { |
| 119 | .name = "serial_pxa", |
| 120 | .platdata = &serial_platdata, |
| 121 | }; |