stefano babic | 6708a60 | 2007-08-30 23:01:49 +0200 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2007 |
| 3 | * Stefano Babic, DENX Gmbh, sbabic@denx.de |
| 4 | * |
| 5 | * (C) Copyright 2004 |
| 6 | * Robert Whaley, Applied Data Systems, Inc. rwhaley@applieddata.net |
| 7 | * |
| 8 | * (C) Copyright 2002 |
| 9 | * Kyle Harris, Nexus Technologies, Inc. kharris@nexus-tech.net |
| 10 | * |
| 11 | * (C) Copyright 2002 |
| 12 | * Sysgo Real-Time Solutions, GmbH <www.elinos.com> |
| 13 | * Marius Groeger <mgroeger@sysgo.de> |
| 14 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 15 | * SPDX-License-Identifier: GPL-2.0+ |
stefano babic | 6708a60 | 2007-08-30 23:01:49 +0200 | [diff] [blame] | 16 | */ |
| 17 | |
| 18 | #include <common.h> |
| 19 | #include <asm/arch/pxa-regs.h> |
Marek Vasut | 71d058b | 2011-11-26 11:17:32 +0100 | [diff] [blame] | 20 | #include <asm/arch/pxa.h> |
Marek Vasut | d2f3bbd | 2012-09-30 10:09:49 +0000 | [diff] [blame] | 21 | #include <asm/arch/regs-mmc.h> |
Remy Bohmer | 7eefd92 | 2009-05-02 21:49:18 +0200 | [diff] [blame] | 22 | #include <netdev.h> |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 23 | #include <asm/io.h> |
Mateusz Zalega | d862f89 | 2013-10-04 19:22:26 +0200 | [diff] [blame] | 24 | #include <usb.h> |
stefano babic | 6708a60 | 2007-08-30 23:01:49 +0200 | [diff] [blame] | 25 | |
| 26 | DECLARE_GLOBAL_DATA_PTR; |
| 27 | |
| 28 | #define RH_A_PSM (1 << 8) /* power switching mode */ |
| 29 | #define RH_A_NPS (1 << 9) /* no power switching */ |
| 30 | |
| 31 | extern struct serial_device serial_ffuart_device; |
| 32 | extern struct serial_device serial_btuart_device; |
| 33 | extern struct serial_device serial_stuart_device; |
| 34 | |
Marek Vasut | 4ccaaef | 2010-10-04 00:21:51 +0200 | [diff] [blame] | 35 | #if CONFIG_MK_POLARIS |
Stefano Babic | e33f804 | 2009-07-01 20:40:41 +0200 | [diff] [blame] | 36 | #define BOOT_CONSOLE "serial_stuart" |
| 37 | #else |
| 38 | #define BOOT_CONSOLE "serial_ffuart" |
| 39 | #endif |
stefano babic | 6708a60 | 2007-08-30 23:01:49 +0200 | [diff] [blame] | 40 | /* ------------------------------------------------------------------------- */ |
| 41 | |
| 42 | /* |
| 43 | * Miscelaneous platform dependent initialisations |
| 44 | */ |
| 45 | |
Troy Kisky | de8ae7b | 2013-10-10 15:27:55 -0700 | [diff] [blame] | 46 | int board_usb_init(int index, enum usb_init_type init) |
stefano babic | 6708a60 | 2007-08-30 23:01:49 +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); |
stefano babic | 6708a60 | 2007-08-30 23:01:49 +0200 | [diff] [blame] | 51 | |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 52 | writel(readl(UHCHR) | UHCHR_FSBIR, UHCHR); |
stefano babic | 6708a60 | 2007-08-30 23:01:49 +0200 | [diff] [blame] | 53 | |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 54 | while (readl(UHCHR) & UHCHR_FSBIR) |
| 55 | ; |
stefano babic | 6708a60 | 2007-08-30 23:01:49 +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); |
stefano babic | 6708a60 | 2007-08-30 23:01:49 +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); |
stefano babic | 6708a60 | 2007-08-30 23:01:49 +0200 | [diff] [blame] | 63 | |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 64 | writel(readl(UHCRHDA) & ~(RH_A_NPS), UHCRHDA); |
| 65 | writel(readl(UHCRHDA) | RH_A_PSM, UHCRHDA); |
stefano babic | 6708a60 | 2007-08-30 23:01:49 +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); |
Stefano Babic | 57eb46b | 2009-07-01 04:33:56 +0200 | [diff] [blame] | 69 | |
| 70 | return 0; |
stefano babic | 6708a60 | 2007-08-30 23:01:49 +0200 | [diff] [blame] | 71 | } |
| 72 | |
Troy Kisky | de8ae7b | 2013-10-10 15:27:55 -0700 | [diff] [blame] | 73 | int board_usb_cleanup(int index, enum usb_init_type init) |
stefano babic | 6708a60 | 2007-08-30 23:01:49 +0200 | [diff] [blame] | 74 | { |
Mateusz Zalega | d862f89 | 2013-10-04 19:22:26 +0200 | [diff] [blame] | 75 | return 0; |
stefano babic | 6708a60 | 2007-08-30 23:01:49 +0200 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | void usb_board_stop(void) |
| 79 | { |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 80 | writel(readl(UHCHR) | UHCHR_FHR, UHCHR); |
stefano babic | 6708a60 | 2007-08-30 23:01:49 +0200 | [diff] [blame] | 81 | udelay(11); |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 82 | writel(readl(UHCHR) & ~UHCHR_FHR, UHCHR); |
stefano babic | 6708a60 | 2007-08-30 23:01:49 +0200 | [diff] [blame] | 83 | |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 84 | writel(readl(UHCCOMS) | 1, UHCCOMS); |
stefano babic | 6708a60 | 2007-08-30 23:01:49 +0200 | [diff] [blame] | 85 | udelay(10); |
| 86 | |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 87 | writel(readl(CKEN) & ~CKEN10_USBHOST, CKEN); |
stefano babic | 6708a60 | 2007-08-30 23:01:49 +0200 | [diff] [blame] | 88 | |
stefano babic | 6708a60 | 2007-08-30 23:01:49 +0200 | [diff] [blame] | 89 | return; |
| 90 | } |
| 91 | |
| 92 | int board_init (void) |
| 93 | { |
Marek Vasut | a11b85d | 2010-10-20 21:28:14 +0200 | [diff] [blame] | 94 | /* We have RAM, disable cache */ |
| 95 | dcache_disable(); |
| 96 | icache_disable(); |
stefano babic | 6708a60 | 2007-08-30 23:01:49 +0200 | [diff] [blame] | 97 | |
| 98 | /* arch number of ConXS Board */ |
| 99 | gd->bd->bi_arch_number = 776; |
| 100 | |
| 101 | /* adress of boot parameters */ |
| 102 | gd->bd->bi_boot_params = 0xa000003c; |
| 103 | |
| 104 | return 0; |
| 105 | } |
| 106 | |
| 107 | int board_late_init(void) |
| 108 | { |
stefano babic | 6708a60 | 2007-08-30 23:01:49 +0200 | [diff] [blame] | 109 | char *console=getenv("boot_console"); |
| 110 | |
Stefano Babic | e33f804 | 2009-07-01 20:40:41 +0200 | [diff] [blame] | 111 | if ((console == NULL) || (strcmp(console,"serial_btuart") && |
| 112 | strcmp(console,"serial_stuart") && |
| 113 | strcmp(console,"serial_ffuart"))) { |
| 114 | console = BOOT_CONSOLE; |
stefano babic | 6708a60 | 2007-08-30 23:01:49 +0200 | [diff] [blame] | 115 | } |
Stefano Babic | e33f804 | 2009-07-01 20:40:41 +0200 | [diff] [blame] | 116 | setenv("stdout",console); |
| 117 | setenv("stdin", console); |
| 118 | setenv("stderr",console); |
stefano babic | 6708a60 | 2007-08-30 23:01:49 +0200 | [diff] [blame] | 119 | return 0; |
| 120 | } |
| 121 | |
Marek Vasut | a11b85d | 2010-10-20 21:28:14 +0200 | [diff] [blame] | 122 | int dram_init(void) |
| 123 | { |
Marek Vasut | 08341be | 2011-11-26 11:18:57 +0100 | [diff] [blame] | 124 | pxa2xx_dram_init(); |
Marek Vasut | a11b85d | 2010-10-20 21:28:14 +0200 | [diff] [blame] | 125 | gd->ram_size = PHYS_SDRAM_1_SIZE; |
| 126 | return 0; |
| 127 | } |
| 128 | |
| 129 | void dram_init_banksize(void) |
stefano babic | 6708a60 | 2007-08-30 23:01:49 +0200 | [diff] [blame] | 130 | { |
| 131 | gd->bd->bi_dram[0].start = PHYS_SDRAM_1; |
| 132 | gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE; |
stefano babic | 6708a60 | 2007-08-30 23:01:49 +0200 | [diff] [blame] | 133 | } |
Remy Bohmer | 7eefd92 | 2009-05-02 21:49:18 +0200 | [diff] [blame] | 134 | |
| 135 | #ifdef CONFIG_DRIVER_DM9000 |
| 136 | int board_eth_init(bd_t *bis) |
| 137 | { |
| 138 | return dm9000_initialize(bis); |
| 139 | } |
| 140 | #endif |
Marek Vasut | d2f3bbd | 2012-09-30 10:09:49 +0000 | [diff] [blame] | 141 | |
| 142 | #ifdef CONFIG_CMD_MMC |
| 143 | int board_mmc_init(bd_t *bis) |
| 144 | { |
| 145 | pxa_mmc_register(0); |
| 146 | return 0; |
| 147 | } |
| 148 | #endif |