2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2014-10-24 21:39:07 +00:00
|
|
|
/*
|
|
|
|
* Novena board support
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 Marek Vasut <marex@denx.de>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2019-05-17 18:32:17 +00:00
|
|
|
#include <dm.h>
|
2019-11-14 19:57:50 +00:00
|
|
|
#include <eeprom.h>
|
2019-11-14 19:57:46 +00:00
|
|
|
#include <init.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2019-05-17 18:32:17 +00:00
|
|
|
#include <dm/device-internal.h>
|
|
|
|
#include <ahci.h>
|
2019-08-01 15:46:51 +00:00
|
|
|
#include <env.h>
|
2016-09-21 02:28:55 +00:00
|
|
|
#include <linux/errno.h>
|
2014-10-24 21:39:07 +00:00
|
|
|
#include <asm/gpio.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/arch/clock.h>
|
|
|
|
#include <asm/arch/crm_regs.h>
|
|
|
|
#include <asm/arch/imx-regs.h>
|
|
|
|
#include <asm/arch/iomux.h>
|
|
|
|
#include <asm/arch/mxc_hdmi.h>
|
|
|
|
#include <asm/arch/sys_proto.h>
|
2017-06-29 08:16:06 +00:00
|
|
|
#include <asm/mach-imx/boot_mode.h>
|
|
|
|
#include <asm/mach-imx/iomux-v3.h>
|
|
|
|
#include <asm/mach-imx/mxc_i2c.h>
|
|
|
|
#include <asm/mach-imx/sata.h>
|
|
|
|
#include <asm/mach-imx/video.h>
|
2019-05-17 18:32:17 +00:00
|
|
|
#include <dwc_ahsata.h>
|
2019-06-21 03:42:28 +00:00
|
|
|
#include <fsl_esdhc_imx.h>
|
2014-10-24 21:39:07 +00:00
|
|
|
#include <i2c.h>
|
|
|
|
#include <input.h>
|
|
|
|
#include <ipu_pixfmt.h>
|
|
|
|
#include <linux/fb.h>
|
|
|
|
#include <linux/input.h>
|
|
|
|
#include <malloc.h>
|
|
|
|
#include <mmc.h>
|
|
|
|
#include <netdev.h>
|
|
|
|
#include <power/pmic.h>
|
|
|
|
#include <power/pfuze100_pmic.h>
|
|
|
|
#include <stdio_dev.h>
|
2019-05-17 18:32:20 +00:00
|
|
|
#include <video_console.h>
|
2014-10-24 21:39:07 +00:00
|
|
|
|
2014-12-16 13:09:21 +00:00
|
|
|
#include "novena.h"
|
2014-10-24 21:39:07 +00:00
|
|
|
|
2014-12-16 13:09:21 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
2014-10-24 21:39:07 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* GPIO button
|
|
|
|
*/
|
|
|
|
#ifdef CONFIG_KEYBOARD
|
|
|
|
static struct input_config button_input;
|
|
|
|
|
|
|
|
static int novena_gpio_button_read_keys(struct input_config *input)
|
|
|
|
{
|
|
|
|
int key = KEY_ENTER;
|
|
|
|
if (gpio_get_value(NOVENA_BUTTON_GPIO))
|
|
|
|
return 0;
|
|
|
|
input_send_keycodes(&button_input, &key, 1);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int novena_gpio_button_getc(struct stdio_dev *dev)
|
|
|
|
{
|
|
|
|
return input_getc(&button_input);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int novena_gpio_button_tstc(struct stdio_dev *dev)
|
|
|
|
{
|
|
|
|
return input_tstc(&button_input);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int novena_gpio_button_init(struct stdio_dev *dev)
|
|
|
|
{
|
|
|
|
gpio_direction_input(NOVENA_BUTTON_GPIO);
|
|
|
|
input_set_delays(&button_input, 250, 250);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int drv_keyboard_init(void)
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
struct stdio_dev dev = {
|
|
|
|
.name = "button",
|
2015-11-04 07:23:37 +00:00
|
|
|
.flags = DEV_FLAGS_INPUT,
|
2014-10-24 21:39:07 +00:00
|
|
|
.start = novena_gpio_button_init,
|
|
|
|
.getc = novena_gpio_button_getc,
|
|
|
|
.tstc = novena_gpio_button_tstc,
|
|
|
|
};
|
|
|
|
|
2019-05-17 18:32:16 +00:00
|
|
|
gpio_request(NOVENA_BUTTON_GPIO, "button");
|
|
|
|
|
2014-10-24 21:39:07 +00:00
|
|
|
error = input_init(&button_input, 0);
|
|
|
|
if (error) {
|
|
|
|
debug("%s: Cannot set up input\n", __func__);
|
|
|
|
return -1;
|
|
|
|
}
|
2015-11-11 17:05:37 +00:00
|
|
|
input_add_tables(&button_input, false);
|
2014-10-24 21:39:07 +00:00
|
|
|
button_input.read_keys = novena_gpio_button_read_keys;
|
|
|
|
|
|
|
|
error = input_stdio_register(&dev);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int board_early_init_f(void)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_VIDEO_IPUV3)
|
2014-12-16 13:09:22 +00:00
|
|
|
setup_display_clock();
|
2014-10-24 21:39:07 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int board_init(void)
|
|
|
|
{
|
|
|
|
/* address of boot parameters */
|
|
|
|
gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-12-16 13:09:23 +00:00
|
|
|
int board_late_init(void)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_VIDEO_IPUV3)
|
2019-05-17 18:32:20 +00:00
|
|
|
struct udevice *con;
|
|
|
|
char buf[DISPLAY_OPTIONS_BANNER_LENGTH];
|
|
|
|
int ret;
|
|
|
|
|
2014-12-16 13:09:23 +00:00
|
|
|
setup_display_lvds();
|
2019-05-17 18:32:20 +00:00
|
|
|
|
|
|
|
ret = uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
display_options_get_banner(false, buf, sizeof(buf));
|
|
|
|
vidconsole_position_cursor(con, 0, 0);
|
|
|
|
vidconsole_put_string(con, buf);
|
2014-12-16 13:09:23 +00:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-10-24 21:39:07 +00:00
|
|
|
int checkboard(void)
|
|
|
|
{
|
|
|
|
puts("Board: Novena 4x\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int dram_init(void)
|
|
|
|
{
|
|
|
|
gd->ram_size = imx_ddr_size();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* setup board specific PMIC */
|
|
|
|
int power_init_board(void)
|
|
|
|
{
|
|
|
|
struct pmic *p;
|
|
|
|
u32 reg;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
power_pfuze100_init(1);
|
|
|
|
p = pmic_get("PFUZE100");
|
|
|
|
if (!p)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
ret = pmic_probe(p);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
pmic_reg_read(p, PFUZE100_DEVICEID, ®);
|
|
|
|
printf("PMIC: PFUZE100 ID=0x%02x\n", reg);
|
|
|
|
|
|
|
|
/* Set SWBST to 5.0V and enable (for USB) */
|
|
|
|
pmic_reg_read(p, PFUZE100_SWBSTCON1, ®);
|
|
|
|
reg &= ~(SWBST_MODE_MASK | SWBST_VOL_MASK);
|
2015-11-26 13:08:50 +00:00
|
|
|
reg |= (SWBST_5_00V | (SWBST_MODE_AUTO << SWBST_MODE_SHIFT));
|
2014-10-24 21:39:07 +00:00
|
|
|
pmic_reg_write(p, PFUZE100_SWBSTCON1, reg);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* EEPROM configuration data */
|
|
|
|
struct novena_eeprom_data {
|
|
|
|
uint8_t signature[6];
|
|
|
|
uint8_t version;
|
|
|
|
uint8_t reserved;
|
|
|
|
uint32_t serial;
|
|
|
|
uint8_t mac[6];
|
|
|
|
uint16_t features;
|
|
|
|
};
|
|
|
|
|
|
|
|
int misc_init_r(void)
|
|
|
|
{
|
|
|
|
struct novena_eeprom_data data;
|
|
|
|
uchar *datap = (uchar *)&data;
|
|
|
|
const char *signature = "Novena";
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* If 'ethaddr' is already set, do nothing. */
|
2017-08-03 18:22:12 +00:00
|
|
|
if (env_get("ethaddr"))
|
2014-10-24 21:39:07 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* EEPROM is at bus 2. */
|
|
|
|
ret = i2c_set_bus_num(2);
|
|
|
|
if (ret) {
|
|
|
|
puts("Cannot select EEPROM I2C bus.\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* EEPROM is at address 0x56. */
|
|
|
|
ret = eeprom_read(0x56, 0, datap, sizeof(data));
|
|
|
|
if (ret) {
|
|
|
|
puts("Cannot read I2C EEPROM.\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check EEPROM signature. */
|
|
|
|
if (memcmp(data.signature, signature, 6)) {
|
|
|
|
puts("Invalid I2C EEPROM signature.\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set ethernet address from EEPROM. */
|
2017-08-03 18:22:11 +00:00
|
|
|
eth_env_set_enetaddr("ethaddr", data.mac);
|
2014-10-24 21:39:07 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|