2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2015-07-20 13:17:11 +00:00
|
|
|
/*
|
2016-02-07 15:50:50 +00:00
|
|
|
* LG Optimus Black codename sniper board
|
2015-07-20 13:17:11 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2015 Paul Kocialkowski <contact@paulk.fr>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include <common.h>
|
|
|
|
#include <dm.h>
|
2019-08-01 15:46:51 +00:00
|
|
|
#include <env.h>
|
2020-07-28 20:35:32 +00:00
|
|
|
#include <fastboot.h>
|
2020-05-10 17:40:02 +00:00
|
|
|
#include <init.h>
|
2015-07-20 13:17:12 +00:00
|
|
|
#include <linux/ctype.h>
|
2015-07-20 13:17:15 +00:00
|
|
|
#include <linux/usb/musb.h>
|
|
|
|
#include <asm/omap_musb.h>
|
2015-07-20 13:17:11 +00:00
|
|
|
#include <asm/arch/mmc_host_def.h>
|
|
|
|
#include <asm/arch/sys_proto.h>
|
|
|
|
#include <asm/arch/mem.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <ns16550.h>
|
|
|
|
#include <twl4030.h>
|
|
|
|
#include "sniper.h"
|
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
|
|
|
const omap3_sysinfo sysinfo = {
|
|
|
|
.mtype = DDR_STACKED,
|
2016-02-26 12:18:47 +00:00
|
|
|
.board_string = "sniper",
|
2015-07-20 13:17:11 +00:00
|
|
|
.nand_string = "MMC"
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct ns16550_platdata serial_omap_platdata = {
|
|
|
|
.base = OMAP34XX_UART3,
|
|
|
|
.reg_shift = 2,
|
2017-01-18 07:05:49 +00:00
|
|
|
.clock = V_NS16550_CLK,
|
|
|
|
.fcr = UART_FCR_DEFVAL,
|
2015-07-20 13:17:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
U_BOOT_DEVICE(sniper_serial) = {
|
2015-11-19 13:48:12 +00:00
|
|
|
.name = "ns16550_serial",
|
2015-07-20 13:17:11 +00:00
|
|
|
.platdata = &serial_omap_platdata
|
|
|
|
};
|
|
|
|
|
2015-07-20 13:17:15 +00:00
|
|
|
static struct musb_hdrc_config musb_config = {
|
|
|
|
.multipoint = 1,
|
|
|
|
.dyn_fifo = 1,
|
|
|
|
.num_eps = 16,
|
|
|
|
.ram_bits = 12
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct omap_musb_board_data musb_board_data = {
|
|
|
|
.interface_type = MUSB_INTERFACE_ULPI,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct musb_hdrc_platform_data musb_platform_data = {
|
|
|
|
.mode = MUSB_PERIPHERAL,
|
|
|
|
.config = &musb_config,
|
|
|
|
.power = 100,
|
|
|
|
.platform_ops = &omap2430_ops,
|
|
|
|
.board_data = &musb_board_data,
|
|
|
|
};
|
|
|
|
|
2016-02-26 12:18:47 +00:00
|
|
|
void set_muxconf_regs(void)
|
|
|
|
{
|
|
|
|
MUX_SNIPER();
|
|
|
|
}
|
|
|
|
|
2015-07-20 13:17:11 +00:00
|
|
|
#ifdef CONFIG_SPL_BUILD
|
|
|
|
void get_board_mem_timings(struct board_sdrc_timings *timings)
|
|
|
|
{
|
|
|
|
timings->mcfg = HYNIX_V_MCFG_200(256 << 20);
|
|
|
|
timings->ctrla = HYNIX_V_ACTIMA_200;
|
|
|
|
timings->ctrlb = HYNIX_V_ACTIMB_200;
|
|
|
|
timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
|
|
|
|
timings->mr = MICRON_V_MR_165;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int board_init(void)
|
|
|
|
{
|
|
|
|
/* GPMC init */
|
|
|
|
gpmc_init();
|
|
|
|
|
|
|
|
/* MACH number */
|
|
|
|
gd->bd->bi_arch_number = 3000;
|
|
|
|
|
|
|
|
/* ATAGs location */
|
|
|
|
gd->bd->bi_boot_params = OMAP34XX_SDRC_CS0 + 0x100;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-07-20 13:17:12 +00:00
|
|
|
int misc_init_r(void)
|
|
|
|
{
|
2015-07-20 13:17:18 +00:00
|
|
|
unsigned char keypad_matrix[64] = { 0 };
|
2015-07-20 13:17:12 +00:00
|
|
|
char reboot_mode[2] = { 0 };
|
2015-07-20 13:17:18 +00:00
|
|
|
unsigned char keys[3];
|
2015-07-20 13:17:17 +00:00
|
|
|
unsigned char data = 0;
|
2016-03-29 12:16:25 +00:00
|
|
|
int rc;
|
2015-07-20 13:17:12 +00:00
|
|
|
|
2015-07-20 13:17:16 +00:00
|
|
|
/* Power button reset init */
|
|
|
|
|
|
|
|
twl4030_power_reset_init();
|
|
|
|
|
2015-07-20 13:17:18 +00:00
|
|
|
/* Keypad */
|
|
|
|
|
|
|
|
twl4030_keypad_scan((unsigned char *)&keypad_matrix);
|
|
|
|
|
|
|
|
keys[0] = twl4030_keypad_key((unsigned char *)&keypad_matrix, 0, 0);
|
|
|
|
keys[1] = twl4030_keypad_key((unsigned char *)&keypad_matrix, 0, 1);
|
|
|
|
keys[2] = twl4030_keypad_key((unsigned char *)&keypad_matrix, 0, 2);
|
|
|
|
|
2015-07-20 13:17:12 +00:00
|
|
|
/* Reboot mode */
|
|
|
|
|
2016-03-29 12:16:25 +00:00
|
|
|
rc = omap_reboot_mode(reboot_mode, sizeof(reboot_mode));
|
2015-07-20 13:17:18 +00:00
|
|
|
|
|
|
|
if (keys[0])
|
|
|
|
reboot_mode[0] = 'r';
|
|
|
|
else if (keys[1])
|
|
|
|
reboot_mode[0] = 'b';
|
|
|
|
|
2016-03-29 12:16:25 +00:00
|
|
|
if (rc < 0 || reboot_mode[0] == 'o') {
|
2015-07-20 13:17:17 +00:00
|
|
|
/*
|
|
|
|
* When not rebooting, valid power on reasons are either the
|
|
|
|
* power button, charger plug or USB plug.
|
|
|
|
*/
|
|
|
|
|
|
|
|
data |= twl4030_input_power_button();
|
|
|
|
data |= twl4030_input_charger();
|
|
|
|
data |= twl4030_input_usb();
|
|
|
|
|
|
|
|
if (!data)
|
|
|
|
twl4030_power_off();
|
2015-07-20 13:17:12 +00:00
|
|
|
}
|
|
|
|
|
2016-03-29 12:16:25 +00:00
|
|
|
if (reboot_mode[0] > 0 && isascii(reboot_mode[0])) {
|
2017-08-03 18:22:12 +00:00
|
|
|
if (!env_get("reboot-mode"))
|
2017-08-03 18:22:09 +00:00
|
|
|
env_set("reboot-mode", (char *)reboot_mode);
|
2016-03-29 12:16:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
omap_reboot_mode_clear();
|
|
|
|
|
2015-07-20 13:17:13 +00:00
|
|
|
/* Serial number */
|
|
|
|
|
2015-08-27 17:37:12 +00:00
|
|
|
omap_die_id_serial();
|
2015-07-20 13:17:13 +00:00
|
|
|
|
2015-07-20 13:17:15 +00:00
|
|
|
/* MUSB */
|
|
|
|
|
|
|
|
musb_register(&musb_platform_data, &musb_board_data, (void *)MUSB_BASE);
|
|
|
|
|
2015-07-20 13:17:12 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-02-26 12:18:47 +00:00
|
|
|
u32 get_board_rev(void)
|
|
|
|
{
|
|
|
|
/* Sold devices are expected to be at least revision F. */
|
|
|
|
return 6;
|
|
|
|
}
|
|
|
|
|
2015-07-20 13:17:14 +00:00
|
|
|
void get_board_serial(struct tag_serialnr *serialnr)
|
|
|
|
{
|
2015-08-27 17:37:14 +00:00
|
|
|
omap_die_id_get_board_serial(serialnr);
|
2015-07-20 13:17:14 +00:00
|
|
|
}
|
|
|
|
|
2016-03-29 12:16:25 +00:00
|
|
|
void reset_misc(void)
|
|
|
|
{
|
|
|
|
char reboot_mode[2] = { 0 };
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Valid resets must contain the reboot mode magic, but we must not
|
|
|
|
* override it when set previously (e.g. reboot to bootloader).
|
|
|
|
*/
|
|
|
|
|
|
|
|
omap_reboot_mode(reboot_mode, sizeof(reboot_mode));
|
|
|
|
omap_reboot_mode_store(reboot_mode);
|
|
|
|
}
|
|
|
|
|
2020-07-28 20:35:32 +00:00
|
|
|
int fastboot_set_reboot_flag(enum fastboot_reboot_reason reason)
|
2015-07-20 13:17:15 +00:00
|
|
|
{
|
2020-07-28 20:35:32 +00:00
|
|
|
if (reason != FASTBOOT_REBOOT_REASON_BOOTLOADER)
|
|
|
|
return -ENOTSUPP;
|
|
|
|
|
2016-02-27 18:26:41 +00:00
|
|
|
return omap_reboot_mode_store("b");
|
2015-07-20 13:17:15 +00:00
|
|
|
}
|
|
|
|
|
2020-06-26 06:13:33 +00:00
|
|
|
int board_mmc_init(struct bd_info *bis)
|
2015-07-20 13:17:11 +00:00
|
|
|
{
|
|
|
|
return omap_mmc_init(1, 0, 0, -1, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void board_mmc_power_init(void)
|
|
|
|
{
|
|
|
|
twl4030_power_mmc_init(1);
|
|
|
|
}
|