Merge tag 'efi-2020-07-rc6' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi
[oweals/u-boot.git] / board / logicpd / zoom1 / zoom1.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2004-2008
4  * Texas Instruments, <www.ti.com>
5  *
6  * Author :
7  *      Nishanth Menon <nm@ti.com>
8  *
9  * Derived from Beagle Board and 3430 SDP code by
10  *      Sunil Kumar <sunilsaini05@gmail.com>
11  *      Shashi Ranjan <shashiranjanmca05@gmail.com>
12  *      Richard Woodruff <r-woodruff2@ti.com>
13  *      Syed Mohammed Khasim <khasim@ti.com>
14  *
15  */
16 #include <common.h>
17 #include <dm.h>
18 #include <env.h>
19 #include <init.h>
20 #include <net.h>
21 #include <ns16550.h>
22 #include <netdev.h>
23 #include <twl4030.h>
24 #include <linux/mtd/omap_gpmc.h>
25 #include <asm/io.h>
26 #include <asm/arch/mem.h>
27 #include <asm/arch/mmc_host_def.h>
28 #include <asm/arch/mux.h>
29 #include <asm/arch/sys_proto.h>
30 #include <asm/mach-types.h>
31 #include "zoom1.h"
32
33 DECLARE_GLOBAL_DATA_PTR;
34
35 /*
36  * gpmc_cfg is initialized by gpmc_init and we use it here.
37  * GPMC definitions for Ethenet Controller LAN9211
38  */
39 static const u32 gpmc_lab_enet[] = {
40         ZOOM1_ENET_GPMC_CONF1,
41         ZOOM1_ENET_GPMC_CONF2,
42         ZOOM1_ENET_GPMC_CONF3,
43         ZOOM1_ENET_GPMC_CONF4,
44         ZOOM1_ENET_GPMC_CONF5,
45         ZOOM1_ENET_GPMC_CONF6,
46         /*CONF7- computed as params */
47 };
48
49 static const struct ns16550_platdata zoom1_serial = {
50         .base = OMAP34XX_UART3,
51         .reg_shift = 2,
52         .clock = V_NS16550_CLK,
53         .fcr = UART_FCR_DEFVAL,
54 };
55
56 U_BOOT_DEVICE(zoom1_uart) = {
57         "ns16550_serial",
58         &zoom1_serial
59 };
60
61 /*
62  * Routine: board_init
63  * Description: Early hardware init.
64  */
65 int board_init(void)
66 {
67         gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
68         /* CS1 is Ethernet LAN9211 */
69         enable_gpmc_cs_config(gpmc_lab_enet, &gpmc_cfg->cs[1],
70                               DEBUG_BASE, GPMC_SIZE_16M);
71         /* board id for Linux */
72         gd->bd->bi_arch_number = MACH_TYPE_OMAP_LDP;
73         /* boot param addr */
74         gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
75
76         return 0;
77 }
78
79 /*
80  * Routine: misc_init_r
81  * Description: Configure zoom board specific configurations
82  */
83 int misc_init_r(void)
84 {
85         twl4030_power_init();
86         twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
87         omap_die_id_display();
88
89         /*
90          * Board Reset
91          * The board is reset by holding the red button on the
92          * top right front face for eight seconds.
93          */
94         twl4030_power_reset_init();
95
96         return 0;
97 }
98
99 /*
100  * Routine: set_muxconf_regs
101  * Description: Setting up the configuration Mux registers specific to the
102  *              hardware. Many pins need to be moved from protect to primary
103  *              mode.
104  */
105 void set_muxconf_regs(void)
106 {
107         /* platform specific muxes */
108         MUX_ZOOM1_MDK();
109 }
110
111 #ifdef CONFIG_MMC
112 int board_mmc_init(bd_t *bis)
113 {
114         return omap_mmc_init(0, 0, 0, -1, -1);
115 }
116
117 void board_mmc_power_init(void)
118 {
119         twl4030_power_mmc_init(0);
120 }
121 #endif
122
123 #ifdef CONFIG_CMD_NET
124 int board_eth_init(bd_t *bis)
125 {
126         int rc = 0;
127
128 #ifdef CONFIG_SMC911X
129 #define STR_ENV_ETHADDR "ethaddr"
130
131         struct eth_device *dev;
132         uchar eth_addr[6];
133
134         rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
135         if (!eth_env_get_enetaddr(STR_ENV_ETHADDR, eth_addr)) {
136                 dev = eth_get_dev_by_index(0);
137                 if (dev) {
138                         eth_env_set_enetaddr(STR_ENV_ETHADDR, dev->enetaddr);
139                 } else {
140                         printf("zoom1: Couldn't get eth device\n");
141                         rc = -1;
142                 }
143         }
144 #endif
145
146         return rc;
147 }
148 #endif