uboot/board/samsung/goni/goni.c
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-2.0+
   2/*
   3 *  Copyright (C) 2008-2009 Samsung Electronics
   4 *  Minkyu Kang <mk7.kang@samsung.com>
   5 *  Kyungmin Park <kyungmin.park@samsung.com>
   6 */
   7
   8#include <common.h>
   9#include <init.h>
  10#include <log.h>
  11#include <asm/global_data.h>
  12#include <asm/gpio.h>
  13#include <asm/arch/mmc.h>
  14#include <dm.h>
  15#include <linux/delay.h>
  16#include <power/pmic.h>
  17#include <usb/dwc2_udc.h>
  18#include <asm/arch/cpu.h>
  19#include <power/max8998_pmic.h>
  20#include <samsung/misc.h>
  21#include <usb.h>
  22#include <usb_mass_storage.h>
  23#include <asm/mach-types.h>
  24
  25DECLARE_GLOBAL_DATA_PTR;
  26
  27int board_init(void)
  28{
  29        /* Set Initial global variables */
  30        gd->bd->bi_arch_number = MACH_TYPE_GONI;
  31        gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
  32
  33        return 0;
  34}
  35
  36#ifdef CONFIG_SYS_I2C_INIT_BOARD
  37void i2c_init_board(void)
  38{
  39        gpio_request(S5PC110_GPIO_J43, "i2c_clk");
  40        gpio_request(S5PC110_GPIO_J40, "i2c_data");
  41        gpio_direction_output(S5PC110_GPIO_J43, 1);
  42        gpio_direction_output(S5PC110_GPIO_J40, 1);
  43}
  44#endif
  45
  46int dram_init(void)
  47{
  48        gd->ram_size = PHYS_SDRAM_1_SIZE + PHYS_SDRAM_2_SIZE +
  49                        PHYS_SDRAM_3_SIZE;
  50
  51        return 0;
  52}
  53
  54int dram_init_banksize(void)
  55{
  56        gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
  57        gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
  58        gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
  59        gd->bd->bi_dram[1].size = PHYS_SDRAM_2_SIZE;
  60        gd->bd->bi_dram[2].start = PHYS_SDRAM_3;
  61        gd->bd->bi_dram[2].size = PHYS_SDRAM_3_SIZE;
  62
  63        return 0;
  64}
  65
  66#ifdef CONFIG_DISPLAY_BOARDINFO
  67int checkboard(void)
  68{
  69        puts("Board:\tGoni\n");
  70        return 0;
  71}
  72#endif
  73
  74#ifdef CONFIG_MMC
  75int board_mmc_init(struct bd_info *bis)
  76{
  77        int i, ret, ret_sd = 0;
  78
  79        /* MASSMEMORY_EN: XMSMDATA7: GPJ2[7] output high */
  80        gpio_request(S5PC110_GPIO_J27, "massmemory_en");
  81        gpio_direction_output(S5PC110_GPIO_J27, 1);
  82
  83        /*
  84         * MMC0 GPIO
  85         * GPG0[0]      SD_0_CLK
  86         * GPG0[1]      SD_0_CMD
  87         * GPG0[2]      SD_0_CDn        -> Not used
  88         * GPG0[3:6]    SD_0_DATA[0:3]
  89         */
  90        for (i = S5PC110_GPIO_G00; i < S5PC110_GPIO_G07; i++) {
  91                if (i == S5PC110_GPIO_G02)
  92                        continue;
  93                /* GPG0[0:6] special function 2 */
  94                gpio_cfg_pin(i, 0x2);
  95                /* GPG0[0:6] pull disable */
  96                gpio_set_pull(i, S5P_GPIO_PULL_NONE);
  97                /* GPG0[0:6] drv 4x */
  98                gpio_set_drv(i, S5P_GPIO_DRV_4X);
  99        }
 100
 101        ret = s5p_mmc_init(0, 4);
 102        if (ret)
 103                pr_err("MMC: Failed to init MMC:0.\n");
 104
 105        /*
 106         * SD card (T_FLASH) detect and init
 107         * T_FLASH_DETECT: EINT28: GPH3[4] input mode
 108         */
 109        gpio_request(S5PC110_GPIO_H34, "t_flash_detect");
 110        gpio_cfg_pin(S5PC110_GPIO_H34, S5P_GPIO_INPUT);
 111        gpio_set_pull(S5PC110_GPIO_H34, S5P_GPIO_PULL_UP);
 112
 113        if (!gpio_get_value(S5PC110_GPIO_H34)) {
 114                for (i = S5PC110_GPIO_G20; i < S5PC110_GPIO_G27; i++) {
 115                        if (i == S5PC110_GPIO_G22)
 116                                continue;
 117
 118                        /* GPG2[0:6] special function 2 */
 119                        gpio_cfg_pin(i, 0x2);
 120                        /* GPG2[0:6] pull disable */
 121                        gpio_set_pull(i, S5P_GPIO_PULL_NONE);
 122                        /* GPG2[0:6] drv 4x */
 123                        gpio_set_drv(i, S5P_GPIO_DRV_4X);
 124                }
 125
 126                ret_sd = s5p_mmc_init(2, 4);
 127                if (ret_sd)
 128                        pr_err("MMC: Failed to init SD card (MMC:2).\n");
 129        }
 130
 131        return ret & ret_sd;
 132}
 133#endif
 134
 135#ifdef CONFIG_USB_GADGET
 136static int s5pc1xx_phy_control(int on)
 137{
 138        struct udevice *dev;
 139        static int status;
 140        int reg, ret;
 141
 142        ret = pmic_get("max8998-pmic", &dev);
 143        if (ret)
 144                return ret;
 145
 146        if (on && !status) {
 147                reg = pmic_reg_read(dev, MAX8998_REG_ONOFF1);
 148                reg |= MAX8998_LDO3;
 149                ret = pmic_reg_write(dev, MAX8998_REG_ONOFF1, reg);
 150                if (ret) {
 151                        puts("MAX8998 LDO setting error!\n");
 152                        return -EINVAL;
 153                }
 154
 155                reg = pmic_reg_read(dev, MAX8998_REG_ONOFF2);
 156                reg |= MAX8998_LDO8;
 157                ret = pmic_reg_write(dev, MAX8998_REG_ONOFF2, reg);
 158                if (ret) {
 159                        puts("MAX8998 LDO setting error!\n");
 160                        return -EINVAL;
 161                }
 162                status = 1;
 163        } else if (!on && status) {
 164                reg = pmic_reg_read(dev, MAX8998_REG_ONOFF1);
 165                reg &= ~MAX8998_LDO3;
 166                ret = pmic_reg_write(dev, MAX8998_REG_ONOFF1, reg);
 167                if (ret) {
 168                        puts("MAX8998 LDO setting error!\n");
 169                        return -EINVAL;
 170                }
 171
 172                reg = pmic_reg_read(dev, MAX8998_REG_ONOFF2);
 173                reg &= ~MAX8998_LDO8;
 174                ret = pmic_reg_write(dev, MAX8998_REG_ONOFF2, reg);
 175                if (ret) {
 176                        puts("MAX8998 LDO setting error!\n");
 177                        return -EINVAL;
 178                }
 179                status = 0;
 180        }
 181        udelay(10000);
 182        return 0;
 183}
 184
 185struct dwc2_plat_otg_data s5pc110_otg_data = {
 186        .phy_control = s5pc1xx_phy_control,
 187        .regs_phy = S5PC110_PHY_BASE,
 188        .regs_otg = S5PC110_OTG_BASE,
 189        .usb_phy_ctrl = S5PC110_USB_PHY_CONTROL,
 190};
 191
 192int board_usb_init(int index, enum usb_init_type init)
 193{
 194        debug("USB_udc_probe\n");
 195        return dwc2_udc_probe(&s5pc110_otg_data);
 196}
 197#endif
 198
 199#ifdef CONFIG_MISC_INIT_R
 200int misc_init_r(void)
 201{
 202#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
 203        set_board_info();
 204#endif
 205        return 0;
 206}
 207#endif
 208
 209int board_usb_cleanup(int index, enum usb_init_type init)
 210{
 211        return 0;
 212}
 213