diff options
Diffstat (limited to 'drivers')
45 files changed, 444 insertions, 1330 deletions
diff --git a/drivers/bootcount/Kconfig b/drivers/bootcount/Kconfig index 73972b7f9c..d335ed14b9 100644 --- a/drivers/bootcount/Kconfig +++ b/drivers/bootcount/Kconfig @@ -34,6 +34,7 @@ config BOOTCOUNT_EXT config BOOTCOUNT_AM33XX bool "Boot counter in AM33XX RTC IP block" depends on AM33XX || SOC_DA8XX + select SPL_AM33XX_ENABLE_RTC32K_OSC if AM33XX help A bootcount driver for the RTC IP block found on many TI platforms. This requires the RTC clocks, etc, to be enabled prior to use and diff --git a/drivers/clk/clk_stm32mp1.c b/drivers/clk/clk_stm32mp1.c index 55b0f7977b..c67aa44473 100644 --- a/drivers/clk/clk_stm32mp1.c +++ b/drivers/clk/clk_stm32mp1.c @@ -27,6 +27,15 @@ #define TIMEOUT_200MS 200000 #define TIMEOUT_1S 1000000 +/* STGEN registers */ +#define STGENC_CNTCR 0x00 +#define STGENC_CNTSR 0x04 +#define STGENC_CNTCVL 0x08 +#define STGENC_CNTCVU 0x0C +#define STGENC_CNTFID0 0x20 + +#define STGENC_CNTCR_EN BIT(0) + /* RCC registers */ #define RCC_OCENSETR 0x0C #define RCC_OCENCLRR 0x10 @@ -1377,6 +1386,36 @@ static int set_clksrc(struct stm32mp1_clk_priv *priv, unsigned int clksrc) return ret; } +static void stgen_config(struct stm32mp1_clk_priv *priv) +{ + int p; + u32 stgenc, cntfid0; + ulong rate; + + stgenc = (u32)syscon_get_first_range(STM32MP_SYSCON_STGEN); + + cntfid0 = readl(stgenc + STGENC_CNTFID0); + p = stm32mp1_clk_get_parent(priv, STGEN_K); + rate = stm32mp1_clk_get(priv, p); + + if (cntfid0 != rate) { + pr_debug("System Generic Counter (STGEN) update\n"); + clrbits_le32(stgenc + STGENC_CNTCR, STGENC_CNTCR_EN); + writel(0x0, stgenc + STGENC_CNTCVL); + writel(0x0, stgenc + STGENC_CNTCVU); + writel(rate, stgenc + STGENC_CNTFID0); + setbits_le32(stgenc + STGENC_CNTCR, STGENC_CNTCR_EN); + + __asm__ volatile("mcr p15, 0, %0, c14, c0, 0" : : "r" (rate)); + + /* need to update gd->arch.timer_rate_hz with new frequency */ + timer_init(); + pr_debug("gd->arch.timer_rate_hz = %x\n", + (u32)gd->arch.timer_rate_hz); + pr_debug("Tick = %x\n", (u32)(get_ticks())); + } +} + static int set_clkdiv(unsigned int clkdiv, u32 address) { u32 val; @@ -1544,8 +1583,10 @@ static int stm32mp1_clktree(struct udevice *dev) /* configure HSIDIV */ debug("configure HSIDIV\n"); - if (priv->osc[_HSI]) + if (priv->osc[_HSI]) { stm32mp1_hsidiv(rcc, priv->osc[_HSI]); + stgen_config(priv); + } /* select DIV */ debug("select DIV\n"); @@ -1634,6 +1675,9 @@ static int stm32mp1_clktree(struct udevice *dev) pkcs_config(priv, CLK_CKPER_DISABLED); } + /* STGEN clock source can change with CLK_STGEN_XXX */ + stgen_config(priv); + debug("oscillator off\n"); /* switch OFF HSI if not found in device-tree */ if (!priv->osc[_HSI]) diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c index 9faf3357af..1fbfdef477 100644 --- a/drivers/gpio/gpio-uclass.c +++ b/drivers/gpio/gpio-uclass.c @@ -655,7 +655,7 @@ static int gpio_request_tail(int ret, ofnode node, ret = uclass_get_device_by_ofnode(UCLASS_GPIO, args->node, &desc->dev); if (ret) { - debug("%s: uclass_get_device_by_of_offset failed\n", __func__); + debug("%s: uclass_get_device_by_ofnode failed\n", __func__); goto err; } ret = gpio_find_and_xlate(desc, args); diff --git a/drivers/gpio/sunxi_gpio.c b/drivers/gpio/sunxi_gpio.c index 3cf01b6e36..ea6f3593b9 100644 --- a/drivers/gpio/sunxi_gpio.c +++ b/drivers/gpio/sunxi_gpio.c @@ -354,12 +354,15 @@ static const struct udevice_id sunxi_gpio_ids[] = { ID("allwinner,sun8i-a83t-pinctrl", a_all), ID("allwinner,sun8i-h3-pinctrl", a_all), ID("allwinner,sun8i-r40-pinctrl", a_all), + ID("allwinner,sun8i-v3s-pinctrl", a_all), ID("allwinner,sun9i-a80-pinctrl", a_all), + ID("allwinner,sun50i-a64-pinctrl", a_all), ID("allwinner,sun6i-a31-r-pinctrl", l_2), ID("allwinner,sun8i-a23-r-pinctrl", l_1), ID("allwinner,sun8i-a83t-r-pinctrl", l_1), ID("allwinner,sun8i-h3-r-pinctrl", l_1), ID("allwinner,sun9i-a80-r-pinctrl", l_3), + ID("allwinner,sun50i-a64-r-pinctrl", l_1), { } }; diff --git a/drivers/i2c/soft_i2c.c b/drivers/i2c/soft_i2c.c index 4fd5551a22..cc9c5ef356 100644 --- a/drivers/i2c/soft_i2c.c +++ b/drivers/i2c/soft_i2c.c @@ -25,9 +25,6 @@ #include <asm/arch/gpio.h> #endif #endif -#if defined(CONFIG_8xx) -#include <asm/io.h> -#endif #include <i2c.h> #if defined(CONFIG_SOFT_I2C_GPIO_SCL) diff --git a/drivers/input/Makefile b/drivers/input/Makefile index 9109ac6dba..ee7bfc4d2c 100644 --- a/drivers/input/Makefile +++ b/drivers/input/Makefile @@ -12,9 +12,5 @@ obj-$(CONFIG_TEGRA_KEYBOARD) += tegra-kbc.o obj-$(CONFIG_TWL4030_INPUT) += twl4030.o obj-$(CONFIG_TWL6030_INPUT) += twl6030.o obj-$(CONFIG_CROS_EC_KEYB) += cros_ec_keyb.o -ifdef CONFIG_PS2KBD -obj-y += keyboard.o pc_keyb.o -obj-$(CONFIG_PS2MULT) += ps2mult.o ps2ser.o -endif obj-y += input.o obj-$(CONFIG_$(SPL_)OF_CONTROL) += key_matrix.o diff --git a/drivers/input/keyboard.c b/drivers/input/keyboard.c deleted file mode 100644 index 84ee015cb3..0000000000 --- a/drivers/input/keyboard.c +++ /dev/null @@ -1,87 +0,0 @@ -/*********************************************************************** - * - * (C) Copyright 2004 - * DENX Software Engineering - * Wolfgang Denk, wd@denx.de - * - * Keyboard driver - * - ***********************************************************************/ - -#include <common.h> -#include <console.h> -#include <input.h> - -#include <stdio_dev.h> -#include <keyboard.h> -#include <stdio_dev.h> - -static struct input_config config; - -static int kbd_read_keys(struct input_config *config) -{ -#if defined(CONFIG_ARCH_MPC8540) || \ - defined(CONFIG_ARCH_MPC8541) || defined(CONFIG_ARCH_MPC8555) - /* no ISR is used, so received chars must be polled */ - ps2ser_check(); -#endif - - return 1; -} - -static int check_leds(int ret) -{ - int leds; - - leds = input_leds_changed(&config); - if (leds >= 0) - pckbd_leds(leds); - - return ret; -} - -/* test if a character is in the queue */ -static int kbd_testc(struct stdio_dev *dev) -{ - return check_leds(input_tstc(&config)); -} - -/* gets the character from the queue */ -static int kbd_getc(struct stdio_dev *dev) -{ - return check_leds(input_getc(&config)); -} - -void handle_scancode(unsigned char scan_code) -{ - bool release = false; - - /* Compare with i8042_kbd_check() in i8042.c if some logic is missing */ - if (scan_code & 0x80) { - scan_code &= 0x7f; - release = true; - } - - input_add_keycode(&config, scan_code, release); -} - -/* TODO: convert to driver model */ -int kbd_init (void) -{ - struct stdio_dev kbddev; - struct input_config *input = &config; - - if(kbd_init_hw()==-1) - return -1; - memset (&kbddev, 0, sizeof(kbddev)); - strcpy(kbddev.name, "kbd"); - kbddev.flags = DEV_FLAGS_INPUT; - kbddev.getc = kbd_getc; - kbddev.tstc = kbd_testc; - - input_init(input, 0); - input->read_keys = kbd_read_keys; - input_add_tables(input, true); - - return input_stdio_register(&kbddev); -} diff --git a/drivers/input/pc_keyb.c b/drivers/input/pc_keyb.c deleted file mode 100644 index 1606ab33ff..0000000000 --- a/drivers/input/pc_keyb.c +++ /dev/null @@ -1,251 +0,0 @@ -/*********************************************************************** - * - * (C) Copyright 2004 - * DENX Software Engineering - * Wolfgang Denk, wd@denx.de - * - * PS/2 keyboard driver - * - * Originally from linux source (drivers/char/pc_keyb.c) - * - ***********************************************************************/ - -#include <common.h> - -#include <keyboard.h> -#include <pc_keyb.h> - -#undef KBG_DEBUG - -#ifdef KBG_DEBUG -#define PRINTF(fmt,args...) printf (fmt ,##args) -#else -#define PRINTF(fmt,args...) -#endif - - -/* - * This reads the keyboard status port, and does the - * appropriate action. - * - */ -static unsigned char handle_kbd_event(void) -{ - unsigned char status = kbd_read_status(); - unsigned int work = 10000; - - while ((--work > 0) && (status & KBD_STAT_OBF)) { - unsigned char scancode; - - scancode = kbd_read_input(); - - /* Error bytes must be ignored to make the - Synaptics touchpads compaq use work */ - /* Ignore error bytes */ - if (!(status & (KBD_STAT_GTO | KBD_STAT_PERR))) { - if (status & KBD_STAT_MOUSE_OBF) - ; /* not supported: handle_mouse_event(scancode); */ - else - handle_scancode(scancode); - } - status = kbd_read_status(); - } - if (!work) - PRINTF("pc_keyb: controller jammed (0x%02X).\n", status); - return status; -} - - -static int kbd_read_data(void) -{ - int val; - unsigned char status; - - val = -1; - status = kbd_read_status(); - if (status & KBD_STAT_OBF) { - val = kbd_read_input(); - if (status & (KBD_STAT_GTO | KBD_STAT_PERR)) - val = -2; - } - return val; -} - -static int kbd_wait_for_input(void) -{ - unsigned long timeout; - int val; - - timeout = KBD_TIMEOUT; - val=kbd_read_data(); - while(val < 0) { - if(timeout--==0) - return -1; - udelay(1000); - val=kbd_read_data(); - } - return val; -} - - -static int kb_wait(void) -{ - unsigned long timeout = KBC_TIMEOUT * 10; - - do { - unsigned char status = handle_kbd_event(); - if (!(status & KBD_STAT_IBF)) - return 0; /* ok */ - udelay(1000); - timeout--; - } while (timeout); - return 1; -} - -static void kbd_write_command_w(int data) -{ - if(kb_wait()) - PRINTF("timeout in kbd_write_command_w\n"); - kbd_write_command(data); -} - -static void kbd_write_output_w(int data) -{ - if(kb_wait()) - PRINTF("timeout in kbd_write_output_w\n"); - kbd_write_output(data); -} - -static void kbd_send_data(unsigned char data) -{ - kbd_write_output_w(data); - kbd_wait_for_input(); -} - - -static char * kbd_initialize(void) -{ - int status; - - /* - * Test the keyboard interface. - * This seems to be the only way to get it going. - * If the test is successful a x55 is placed in the input buffer. - */ - kbd_write_command_w(KBD_CCMD_SELF_TEST); - if (kbd_wait_for_input() != 0x55) - return "Kbd: failed self test"; - /* - * Perform a keyboard interface test. This causes the controller - * to test the keyboard clock and data lines. The results of the - * test are placed in the input buffer. - */ - kbd_write_command_w(KBD_CCMD_KBD_TEST); - if (kbd_wait_for_input() != 0x00) - return "Kbd: interface failed self test"; - /* - * Enable the keyboard by allowing the keyboard clock to run. - */ - kbd_write_command_w(KBD_CCMD_KBD_ENABLE); - - /* - * Reset keyboard. If the read times out - * then the assumption is that no keyboard is - * plugged into the machine. - * This defaults the keyboard to scan-code set 2. - * - * Set up to try again if the keyboard asks for RESEND. - */ - do { - kbd_write_output_w(KBD_CMD_RESET); - status = kbd_wait_for_input(); - if (status == KBD_REPLY_ACK) - break; - if (status != KBD_REPLY_RESEND) { - PRINTF("status: %X\n",status); - return "Kbd: reset failed, no ACK"; - } - } while (1); - if (kbd_wait_for_input() != KBD_REPLY_POR) - return "Kbd: reset failed, no POR"; - - /* - * Set keyboard controller mode. During this, the keyboard should be - * in the disabled state. - * - * Set up to try again if the keyboard asks for RESEND. - */ - do { - kbd_write_output_w(KBD_CMD_DISABLE); - status = kbd_wait_for_input(); - if (status == KBD_REPLY_ACK) - break; - if (status != KBD_REPLY_RESEND) - return "Kbd: disable keyboard: no ACK"; - } while (1); - - kbd_write_command_w(KBD_CCMD_WRITE_MODE); - kbd_write_output_w(KBD_MODE_KBD_INT - | KBD_MODE_SYS - | KBD_MODE_DISABLE_MOUSE - | KBD_MODE_KCC); - - /* AMCC powerpc portables need this to use scan-code set 1 -- Cort */ - kbd_write_command_w(KBD_CCMD_READ_MODE); - if (!(kbd_wait_for_input() & KBD_MODE_KCC)) { - /* - * If the controller does not support conversion, - * Set the keyboard to scan-code set 1. - */ - kbd_write_output_w(0xF0); - kbd_wait_for_input(); - kbd_write_output_w(0x01); - kbd_wait_for_input(); - } - kbd_write_output_w(KBD_CMD_ENABLE); - if (kbd_wait_for_input() != KBD_REPLY_ACK) - return "Kbd: enable keyboard: no ACK"; - - /* - * Finally, set the typematic rate to maximum. - */ - kbd_write_output_w(KBD_CMD_SET_RATE); - if (kbd_wait_for_input() != KBD_REPLY_ACK) - return "Kbd: Set rate: no ACK"; - kbd_write_output_w(0x00); - if (kbd_wait_for_input() != KBD_REPLY_ACK) - return "Kbd: Set rate: no ACK"; - return NULL; -} - -static void kbd_interrupt(void *dev_id) -{ - handle_kbd_event(); -} - -/****************************************************************** - * Init - ******************************************************************/ - -int kbd_init_hw(void) -{ - char* result; - - kbd_request_region(); - - result=kbd_initialize(); - if (result==NULL) { - PRINTF("AT Keyboard initialized\n"); - kbd_request_irq(kbd_interrupt); - return (1); - } else { - printf("%s\n",result); - return (-1); - } -} - -void pckbd_leds(unsigned char leds) -{ - kbd_send_data(KBD_CMD_SET_LEDS); - kbd_send_data(leds); -} diff --git a/drivers/input/ps2mult.c b/drivers/input/ps2mult.c deleted file mode 100644 index ab749336bf..0000000000 --- a/drivers/input/ps2mult.c +++ /dev/null @@ -1,461 +0,0 @@ -/*********************************************************************** - * - * (C) Copyright 2004 - * DENX Software Engineering - * Wolfgang Denk, wd@denx.de - * - * PS/2 multiplexer driver - * - * Originally from linux source (drivers/char/ps2mult.c) - * - * Uses simple serial driver (ps2ser.c) to access the multiplexer - * Used by PS/2 keyboard driver (pc_keyb.c) - * - ***********************************************************************/ - -#include <common.h> - -#include <pc_keyb.h> -#include <asm/atomic.h> -#include <ps2mult.h> - -/* #define DEBUG_MULT */ -/* #define DEBUG_KEYB */ - -#define KBD_STAT_DEFAULT (KBD_STAT_SELFTEST | KBD_STAT_UNLOCKED) - -#define PRINTF(format, args...) printf("ps2mult.c: " format, ## args) - -#ifdef DEBUG_MULT -#define PRINTF_MULT(format, args...) printf("PS2MULT: " format, ## args) -#else -#define PRINTF_MULT(format, args...) -#endif - -#ifdef DEBUG_KEYB -#define PRINTF_KEYB(format, args...) printf("KEYB: " format, ## args) -#else -#define PRINTF_KEYB(format, args...) -#endif - - -static ulong start_time; -static int init_done = 0; - -static int received_escape = 0; -static int received_bsync = 0; -static int received_selector = 0; - -static int kbd_command_active = 0; -static int mouse_command_active = 0; -static int ctl_command_active = 0; - -static u_char command_byte = 0; - -static void (*keyb_handler)(void *dev_id); - -static u_char ps2mult_buf [PS2BUF_SIZE]; -static atomic_t ps2mult_buf_cnt; -static int ps2mult_buf_in_idx; -static int ps2mult_buf_out_idx; - -static u_char ps2mult_buf_status [PS2BUF_SIZE]; - -#ifndef CONFIG_BOARD_EARLY_INIT_R -#error #define CONFIG_BOARD_EARLY_INIT_R and call ps2mult_early_init() in board_early_init_r() -#endif -void ps2mult_early_init (void) -{ - start_time = get_timer(0); -} - -static void ps2mult_send_byte(u_char byte, u_char sel) -{ - ps2ser_putc(sel); - - if (sel == PS2MULT_KB_SELECTOR) { - PRINTF_MULT("0x%02x send KEYBOARD\n", byte); - kbd_command_active = 1; - } else { - PRINTF_MULT("0x%02x send MOUSE\n", byte); - mouse_command_active = 1; - } - - switch (byte) { - case PS2MULT_ESCAPE: - case PS2MULT_BSYNC: - case PS2MULT_KB_SELECTOR: - case PS2MULT_MS_SELECTOR: - case PS2MULT_SESSION_START: - case PS2MULT_SESSION_END: - ps2ser_putc(PS2MULT_ESCAPE); - break; - default: - break; - } - - ps2ser_putc(byte); -} - -static void ps2mult_receive_byte(u_char byte, u_char sel) -{ - u_char status = KBD_STAT_DEFAULT; - -#if 1 /* Ignore mouse in U-Boot */ - if (sel == PS2MULT_MS_SELECTOR) return; -#endif - - if (sel == PS2MULT_KB_SELECTOR) { - if (kbd_command_active) { - if (!received_bsync) { - PRINTF_MULT("0x%02x lost KEYBOARD !!!\n", byte); - return; - } else { - kbd_command_active = 0; - received_bsync = 0; - } - } - PRINTF_MULT("0x%02x receive KEYBOARD\n", byte); - status |= KBD_STAT_IBF | KBD_STAT_OBF; - } else { - if (mouse_command_active) { - if (!received_bsync) { - PRINTF_MULT("0x%02x lost MOUSE !!!\n", byte); - return; - } else { - mouse_command_active = 0; - received_bsync = 0; - } - } - PRINTF_MULT("0x%02x receive MOUSE\n", byte); - status |= KBD_STAT_IBF | KBD_STAT_OBF | KBD_STAT_MOUSE_OBF; - } - - if (atomic_read(&ps2mult_buf_cnt) < PS2BUF_SIZE) { - ps2mult_buf_status[ps2mult_buf_in_idx] = status; - ps2mult_buf[ps2mult_buf_in_idx++] = byte; - ps2mult_buf_in_idx &= (PS2BUF_SIZE - 1); - atomic_inc(&ps2mult_buf_cnt); - } else { - PRINTF("buffer overflow\n"); - } - - if (received_bsync) { - PRINTF("unexpected BSYNC\n"); - received_bsync = 0; - } -} - -void ps2mult_callback (int in_cnt) -{ - int i; - u_char byte; - static int keyb_handler_active = 0; - - if (!init_done) { - return; - } - - for (i = 0; i < in_cnt; i ++) { - byte = ps2ser_getc(); - - if (received_escape) { - ps2mult_receive_byte(byte, received_selector); - received_escape = 0; - } else switch (byte) { - case PS2MULT_ESCAPE: - PRINTF_MULT("ESCAPE receive\n"); - received_escape = 1; - break; - - case PS2MULT_BSYNC: - PRINTF_MULT("BSYNC receive\n"); - received_bsync = 1; - break; - - case PS2MULT_KB_SELECTOR: - case PS2MULT_MS_SELECTOR: - PRINTF_MULT("%s receive\n", - byte == PS2MULT_KB_SELECTOR ? "KB_SEL" : "MS_SEL"); - received_selector = byte; - break; - - case PS2MULT_SESSION_START: - case PS2MULT_SESSION_END: - PRINTF_MULT("%s receive\n", - byte == PS2MULT_SESSION_START ? - "SESSION_START" : "SESSION_END"); - break; - - default: - ps2mult_receive_byte(byte, received_selector); - } - } - - if (keyb_handler && !keyb_handler_active && - atomic_read(&ps2mult_buf_cnt)) { - keyb_handler_active = 1; - keyb_handler(NULL); - keyb_handler_active = 0; - } -} - -u_char ps2mult_read_status(void) -{ - u_char byte; - - if (atomic_read(&ps2mult_buf_cnt) == 0) { - ps2ser_check(); - } - - if (atomic_read(&ps2mult_buf_cnt)) { - byte = ps2mult_buf_status[ps2mult_buf_out_idx]; - } else { - byte = KBD_STAT_DEFAULT; - } - PRINTF_KEYB("read_status()=0x%02x\n", byte); - return byte; -} - -u_char ps2mult_read_input(void) -{ - u_char byte = 0; - - if (atomic_read(&ps2mult_buf_cnt) == 0) { - ps2ser_check(); - } - - if (atomic_read(&ps2mult_buf_cnt)) { - byte = ps2mult_buf[ps2mult_buf_out_idx++]; - ps2mult_buf_out_idx &= (PS2BUF_SIZE - 1); - atomic_dec(&ps2mult_buf_cnt); - } - PRINTF_KEYB("read_input()=0x%02x\n", byte); - return byte; -} - -void ps2mult_write_output(u_char val) -{ - int i; - - PRINTF_KEYB("write_output(0x%02x)\n", val); - - for (i = 0; i < KBD_TIMEOUT; i++) { - if (!kbd_command_active && !mouse_command_active) { - break; - } - udelay(1000); - ps2ser_check(); - } - - if (kbd_command_active) { - PRINTF("keyboard command not acknoledged\n"); - kbd_command_active = 0; - } - - if (mouse_command_active) { - PRINTF("mouse command not acknoledged\n"); - mouse_command_active = 0; - } - - if (ctl_command_active) { - switch (ctl_command_active) { - case KBD_CCMD_WRITE_MODE: - /* Scan code conversion not supported */ - command_byte = val & ~KBD_MODE_KCC; - break; - - case KBD_CCMD_WRITE_AUX_OBUF: - ps2mult_receive_byte(val, PS2MULT_MS_SELECTOR); - break; - - case KBD_CCMD_WRITE_MOUSE: - ps2mult_send_byte(val, PS2MULT_MS_SELECTOR); - break; - - default: - PRINTF("invalid controller command\n"); - break; - } - - ctl_command_active = 0; - return; - } - - ps2mult_send_byte(val, PS2MULT_KB_SELECTOR); -} - -void ps2mult_write_command(u_char val) -{ - ctl_command_active = 0; - - PRINTF_KEYB("write_command(0x%02x)\n", val); - - switch (val) { - case KBD_CCMD_READ_MODE: - ps2mult_receive_byte(command_byte, PS2MULT_KB_SELECTOR); - break; - - case KBD_CCMD_WRITE_MODE: - ctl_command_active = val; - break; - - case KBD_CCMD_MOUSE_DISABLE: - break; - - case KBD_CCMD_MOUSE_ENABLE: - break; - - case KBD_CCMD_SELF_TEST: - ps2mult_receive_byte(0x55, PS2MULT_KB_SELECTOR); - break; - - case KBD_CCMD_KBD_TEST: - ps2mult_receive_byte(0x00, PS2MULT_KB_SELECTOR); - break; - - case KBD_CCMD_KBD_DISABLE: - break; - - case KBD_CCMD_KBD_ENABLE: - break; - - case KBD_CCMD_WRITE_AUX_OBUF: - ctl_command_active = val; - break; - - case KBD_CCMD_WRITE_MOUSE: - ctl_command_active = val; - break; - - default: - PRINTF("invalid controller command\n"); - break; - } -} - -static int ps2mult_getc_w (void) -{ - int res = -1; - int i; - - for (i = 0; i < KBD_TIMEOUT; i++) { - if (ps2ser_check()) { - res = ps2ser_getc(); - break; - } - udelay(1000); - } - - switch (res) { - case PS2MULT_KB_SELECTOR: - case PS2MULT_MS_SELECTOR: - received_selector = res; - break; - default: - break; - } - - return res; -} - -int ps2mult_init (void) -{ - int byte; - int kbd_found = 0; - int mouse_found = 0; - - while (get_timer(start_time) < CONFIG_PS2MULT_DELAY); - - ps2ser_init(); - - ps2ser_putc(PS2MULT_SESSION_START); - - ps2ser_putc(PS2MULT_KB_SELECTOR); - ps2ser_putc(KBD_CMD_RESET); - - do { - byte = ps2mult_getc_w(); - } while (byte >= 0 && byte != KBD_REPLY_ACK); - - if (byte == KBD_REPLY_ACK) { - byte = ps2mult_getc_w(); - if (byte == 0xaa) { - kbd_found = 1; - puts("keyboard"); - } - } - - if (!kbd_found) { - while (byte >= 0) { - byte = ps2mult_getc_w(); - } - } - -#if 1 /* detect mouse */ - ps2ser_putc(PS2MULT_MS_SELECTOR); - ps2ser_putc(AUX_RESET); - - do { - byte = ps2mult_getc_w(); - } while (byte >= 0 && byte != AUX_ACK); - - if (byte == AUX_ACK) { - byte = ps2mult_getc_w(); - if (byte == 0xaa) { - byte = ps2mult_getc_w(); - if (byte == 0x00) { - mouse_found = 1; - puts(", mouse"); - } - } - } - - if (!mouse_found) { - while (byte >= 0) { - byte = ps2mult_getc_w(); - } - } -#endif - - if (mouse_found || kbd_found) { - if (!received_selector) { - if (mouse_found) { - received_selector = PS2MULT_MS_SELECTOR; - } else { - received_selector = PS2MULT_KB_SELECTOR; - } - } - - init_done = 1; - } else { - puts("No device found"); - } - - puts("\n"); - -#if 0 /* for testing */ - { - int i; - u_char key[] = { - 0x1f, 0x12, 0x14, 0x12, 0x31, 0x2f, 0x39, /* setenv */ - 0x1f, 0x14, 0x20, 0x17, 0x31, 0x39, /* stdin */ - 0x1f, 0x12, 0x13, 0x17, 0x1e, 0x26, 0x1c, /* serial */ - }; - - for (i = 0; i < sizeof (key); i++) { - ps2mult_receive_byte (key[i], PS2MULT_KB_SELECTOR); - ps2mult_receive_byte (key[i] | 0x80, PS2MULT_KB_SELECTOR); - } - } -#endif - - return init_done ? 0 : -1; -} - -int ps2mult_request_irq(void (*handler)(void *)) -{ - keyb_handler = handler; - - return 0; -} diff --git a/drivers/input/ps2ser.c b/drivers/input/ps2ser.c deleted file mode 100644 index 0b5ce06853..0000000000 --- a/drivers/input/ps2ser.c +++ /dev/null @@ -1,147 +0,0 @@ -/*********************************************************************** - * - * (C) Copyright 2004-2009 - * DENX Software Engineering - * Wolfgang Denk, wd@denx.de - * - * Simple 16550A serial driver - * - * Originally from linux source (drivers/char/ps2ser.c) - * - * Used by the PS/2 multiplexer driver (ps2mult.c) - * - ***********************************************************************/ - -#include <common.h> - -#include <asm/io.h> -#include <asm/atomic.h> -#include <ps2mult.h> -/* This is needed for ns16550.h */ -#ifndef CONFIG_SYS_NS16550_REG_SIZE -#define CONFIG_SYS_NS16550_REG_SIZE 1 -#endif -#include <ns16550.h> - -DECLARE_GLOBAL_DATA_PTR; - -/* #define DEBUG */ - -#define PS2SER_BAUD 57600 - -#if CONFIG_PS2SERIAL == 1 -#define COM_BASE (CONFIG_SYS_CCSRBAR+0x4500) -#elif CONFIG_PS2SERIAL == 2 -#define COM_BASE (CONFIG_SYS_CCSRBAR+0x4600) -#else -#error CONFIG_PS2SERIAL must be in 1 ... 2 -#endif - -static int ps2ser_getc_hw(void); -static void ps2ser_interrupt(void *dev_id); - -extern struct serial_state rs_table[]; /* in serial.c */ - -static u_char ps2buf[PS2BUF_SIZE]; -static atomic_t ps2buf_cnt; -static int ps2buf_in_idx; -static int ps2buf_out_idx; - -int ps2ser_init(void) -{ - NS16550_t com_port = (NS16550_t)COM_BASE; - - com_port->ier = 0x00; - com_port->lcr = UART_LCR_BKSE | UART_LCR_8N1; - com_port->dll = (CONFIG_SYS_NS16550_CLK / 16 / PS2SER_BAUD) & 0xff; - com_port->dlm = ((CONFIG_SYS_NS16550_CLK / 16 / PS2SER_BAUD) >> 8) & 0xff; - com_port->lcr = UART_LCR_8N1; - com_port->mcr = (UART_MCR_DTR | UART_MCR_RTS); - com_port->fcr = (UART_FCR_FIFO_EN | UART_FCR_RXSR | UART_FCR_TXSR); - - return (0); -} - -void ps2ser_putc(int chr) -{ - NS16550_t com_port = (NS16550_t)COM_BASE; - debug(">>>> 0x%02x\n", chr); - - while ((com_port->lsr & UART_LSR_THRE) == 0); - com_port->thr = chr; -} - -static int ps2ser_getc_hw(void) -{ - NS16550_t com_port = (NS16550_t)COM_BASE; - int res = -1; - - if (com_port->lsr & UART_LSR_DR) { - res = com_port->rbr; - } - - return res; -} - -int ps2ser_getc(void) -{ - volatile int chr; - int flags; - - debug("<< "); - - flags = disable_interrupts(); - - do { - if (atomic_read(&ps2buf_cnt) != 0) { - chr = ps2buf[ps2buf_out_idx++]; - ps2buf_out_idx &= (PS2BUF_SIZE - 1); - atomic_dec(&ps2buf_cnt); - } else { - chr = ps2ser_getc_hw(); - } - } - while (chr < 0); - - if (flags) - enable_interrupts(); - - debug("0x%02x\n", chr); - - return chr; -} - -int ps2ser_check(void) -{ - int flags; - - flags = disable_interrupts(); - ps2ser_interrupt(NULL); - if (flags) enable_interrupts(); - - return atomic_read(&ps2buf_cnt); -} - -static void ps2ser_interrupt(void *dev_id) -{ - NS16550_t com_port = (NS16550_t)COM_BASE; - int chr; - int status; - - do { - chr = ps2ser_getc_hw(); - status = com_port->lsr; - if (chr < 0) continue; - - if (atomic_read(&ps2buf_cnt) < PS2BUF_SIZE) { - ps2buf[ps2buf_in_idx++] = chr; - ps2buf_in_idx &= (PS2BUF_SIZE - 1); - atomic_inc(&ps2buf_cnt); - } else { - printf ("ps2ser.c: buffer overflow\n"); - } - } while (status & UART_LSR_DR); - if (atomic_read(&ps2buf_cnt)) { - ps2mult_callback(atomic_read(&ps2buf_cnt)); - } -} diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig index 3a79cbf165..ff4a8f5b97 100644 --- a/drivers/mmc/Kconfig +++ b/drivers/mmc/Kconfig @@ -548,6 +548,12 @@ config TEGRA124_MMC_DISABLE_EXT_LOOPBACK TODO(marcel.ziswiler@toradex.com): Move to device tree controlled approach once proper kernel integration made it mainline. +config FSL_ESDHC + bool "Freescale/NXP eSDHC controller support" + help + This selects support for the eSDHC (enhanced secure digital host + controller) found on numerous Freescale/NXP SoCs. + endmenu config SYS_FSL_ERRATUM_ESDHC111 diff --git a/drivers/mmc/bcm2835_sdhci.c b/drivers/mmc/bcm2835_sdhci.c index 3157354d2a..08bddd410e 100644 --- a/drivers/mmc/bcm2835_sdhci.c +++ b/drivers/mmc/bcm2835_sdhci.c @@ -183,7 +183,7 @@ static int bcm2835_sdhci_probe(struct udevice *dev) if (base == FDT_ADDR_T_NONE) return -EINVAL; - ret = bcm2835_get_mmc_clock(); + ret = bcm2835_get_mmc_clock(BCM2835_MBOX_CLOCK_ID_EMMC); if (ret < 0) { debug("%s: Failed to set MMC clock (err=%d)\n", __func__, ret); return ret; diff --git a/drivers/mmc/bcm2835_sdhost.c b/drivers/mmc/bcm2835_sdhost.c index 1bf52a3019..bccd182e50 100644 --- a/drivers/mmc/bcm2835_sdhost.c +++ b/drivers/mmc/bcm2835_sdhost.c @@ -35,6 +35,7 @@ #include <dm.h> #include <mmc.h> #include <asm/arch/msg.h> +#include <asm/arch/mbox.h> #include <asm/unaligned.h> #include <linux/compat.h> #include <linux/io.h> @@ -941,7 +942,7 @@ static int bcm2835_probe(struct udevice *dev) if (!host->ioaddr) return -ENOMEM; - host->max_clk = bcm2835_get_mmc_clock(); + host->max_clk = bcm2835_get_mmc_clock(BCM2835_MBOX_CLOCK_ID_CORE); bcm2835_add_host(host); diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig index a820af61ce..94fbf89e4b 100644 --- a/drivers/mtd/nand/Kconfig +++ b/drivers/mtd/nand/Kconfig @@ -95,9 +95,11 @@ config NAND_PXA3XX config NAND_SUNXI bool "Support for NAND on Allwinner SoCs" - depends on MACH_SUN4I || MACH_SUN5I || MACH_SUN7I + default ARCH_SUNXI + depends on MACH_SUN4I || MACH_SUN5I || MACH_SUN7I || MACH_SUN8I select SYS_NAND_SELF_INIT select SYS_NAND_U_BOOT_LOCATIONS + select SPL_NAND_SUPPORT imply CMD_NAND ---help--- Enable support for NAND. This option enables the standard and @@ -166,6 +168,28 @@ config NAND_ZYNQ_USE_BOOTLOADER1_TIMINGS comment "Generic NAND options" +config SYS_NAND_BLOCK_SIZE + hex "NAND chip eraseblock size" + depends on ARCH_SUNXI + help + Number of data bytes in one eraseblock for the NAND chip on the + board. This is the multiple of NAND_PAGE_SIZE and the number of + pages. + +config SYS_NAND_PAGE_SIZE + hex "NAND chip page size" + depends on ARCH_SUNXI + help + Number of data bytes in one page for the NAND chip on the + board, not including the OOB area. + +config SYS_NAND_OOBSIZE + hex "NAND chip OOB size" + depends on ARCH_SUNXI + help + Number of bytes in the Out-Of-Band area for the NAND chip on + the board. + # Enhance depends when converting drivers to Kconfig which use this config # option (mxc_nand, ndfc, omap_gpmc). config SYS_NAND_BUSWIDTH_16BIT diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c index 532e03cd84..37160aaec2 100644 --- a/drivers/mtd/nand/sunxi_nand.c +++ b/drivers/mtd/nand/sunxi_nand.c @@ -1407,8 +1407,14 @@ static int sunxi_nand_hw_common_ecc_ctrl_init(struct mtd_info *mtd, /* Add ECC info retrieval from DT */ for (i = 0; i < ARRAY_SIZE(strengths); i++) { - if (ecc->strength <= strengths[i]) + if (ecc->strength <= strengths[i]) { + /* + * Update ecc->strength value with the actual strength + * that will be used by the ECC engine. + */ + ecc->strength = strengths[i]; break; + } } if (i >= ARRAY_SIZE(strengths)) { diff --git a/drivers/mtd/nand/sunxi_nand_spl.c b/drivers/mtd/nand/sunxi_nand_spl.c index eed4472bdc..7241e9a374 100644 --- a/drivers/mtd/nand/sunxi_nand_spl.c +++ b/drivers/mtd/nand/sunxi_nand_spl.c @@ -10,6 +10,7 @@ #include <common.h> #include <config.h> #include <nand.h> +#include <linux/ctype.h> /* registers */ #define NFC_CTL 0x00000000 @@ -55,7 +56,7 @@ #define NFC_ADDR_NUM_OFFSET 16 -#define NFC_SEND_ADR (1 << 19) +#define NFC_SEND_ADDR (1 << 19) #define NFC_ACCESS_DIR (1 << 20) #define NFC_DATA_TRANS (1 << 21) #define NFC_SEND_CMD1 (1 << 22) @@ -67,10 +68,12 @@ #define NFC_SEND_CMD3 (1 << 28) #define NFC_SEND_CMD4 (1 << 29) #define NFC_RAW_CMD (0 << 30) +#define NFC_ECC_CMD (1 << 30) #define NFC_PAGE_CMD (2 << 30) #define NFC_ST_CMD_INT_FLAG (1 << 1) #define NFC_ST_DMA_INT_FLAG (1 << 2) +#define NFC_ST_CMD_FIFO_STAT (1 << 3) #define NFC_READ_CMD_OFFSET 0 #define NFC_RANDOM_READ_CMD0_OFFSET 8 @@ -80,22 +83,6 @@ #define NFC_CMD_RNDOUT 0x05 #define NFC_CMD_READSTART 0x30 -#define SUNXI_DMA_CFG_REG0 0x300 -#define SUNXI_DMA_SRC_START_ADDR_REG0 0x304 -#define SUNXI_DMA_DEST_START_ADDRR_REG0 0x308 -#define SUNXI_DMA_DDMA_BC_REG0 0x30C -#define SUNXI_DMA_DDMA_PARA_REG0 0x318 - -#define SUNXI_DMA_DDMA_CFG_REG_LOADING (1 << 31) -#define SUNXI_DMA_DDMA_CFG_REG_DMA_DEST_DATA_WIDTH_32 (2 << 25) -#define SUNXI_DMA_DDMA_CFG_REG_DDMA_DST_DRQ_TYPE_DRAM (1 << 16) -#define SUNXI_DMA_DDMA_CFG_REG_DMA_SRC_DATA_WIDTH_32 (2 << 9) -#define SUNXI_DMA_DDMA_CFG_REG_DMA_SRC_ADDR_MODE_IO (1 << 5) -#define SUNXI_DMA_DDMA_CFG_REG_DDMA_SRC_DRQ_TYPE_NFC (3 << 0) - -#define SUNXI_DMA_DDMA_PARA_REG_SRC_WAIT_CYC (0x0F << 0) -#define SUNXI_DMA_DDMA_PARA_REG_SRC_BLK_SIZE (0x7F << 8) - struct nfc_config { int page_size; int ecc_strength; @@ -155,6 +142,42 @@ static inline int check_value_negated(int offset, int unexpected_bits, return check_value_inner(offset, unexpected_bits, timeout_us, 1); } +static int nand_wait_cmd_fifo_empty(void) +{ + if (!check_value_negated(SUNXI_NFC_BASE + NFC_ST, NFC_ST_CMD_FIFO_STAT, + DEFAULT_TIMEOUT_US)) { + printf("nand: timeout waiting for empty cmd FIFO\n"); + return -ETIMEDOUT; + } + + return 0; +} + +static int nand_wait_int(void) +{ + if (!check_value(SUNXI_NFC_BASE + NFC_ST, NFC_ST_CMD_INT_FLAG, + DEFAULT_TIMEOUT_US)) { + printf("nand: timeout waiting for interruption\n"); + return -ETIMEDOUT; + } + + return 0; +} + +static int nand_exec_cmd(u32 cmd) +{ + int ret; + + ret = nand_wait_cmd_fifo_empty(); + if (ret) + return ret; + + writel(NFC_ST_CMD_INT_FLAG, SUNXI_NFC_BASE + NFC_ST); + writel(cmd, SUNXI_NFC_BASE + NFC_CMD); + + return nand_wait_int(); +} + void nand_init(void) { uint32_t val; @@ -172,22 +195,15 @@ void nand_init(void) } /* reset NAND */ - writel(NFC_ST_CMD_INT_FLAG, SUNXI_NFC_BASE + NFC_ST); - writel(NFC_SEND_CMD1 | NFC_WAIT_FLAG | NAND_CMD_RESET, - SUNXI_NFC_BASE + NFC_CMD); - - if (!check_value(SUNXI_NFC_BASE + NFC_ST, NFC_ST_CMD_INT_FLAG, - DEFAULT_TIMEOUT_US)) { - printf("Error timeout waiting for nand reset\n"); - return; - } - writel(NFC_ST_CMD_INT_FLAG, SUNXI_NFC_BASE + NFC_ST); + nand_exec_cmd(NFC_SEND_CMD1 | NFC_WAIT_FLAG | NAND_CMD_RESET); } static void nand_apply_config(const struct nfc_config *conf) { u32 val; + nand_wait_cmd_fifo_empty(); + val = readl(SUNXI_NFC_BASE + NFC_CTL); val &= ~NFC_CTL_PAGE_SIZE_MASK; writel(val | NFC_CTL_RAM_METHOD | NFC_CTL_PAGE_SIZE(conf->page_size), @@ -206,128 +222,111 @@ static int nand_load_page(const struct nfc_config *conf, u32 offs) SUNXI_NFC_BASE + NFC_RCMD_SET); writel(((page & 0xFFFF) << 16), SUNXI_NFC_BASE + NFC_ADDR_LOW); writel((page >> 16) & 0xFF, SUNXI_NFC_BASE + NFC_ADDR_HIGH); - writel(NFC_ST_CMD_INT_FLAG, SUNXI_NFC_BASE + NFC_ST); - writel(NFC_SEND_CMD1 | NFC_SEND_CMD2 | NFC_RAW_CMD | NFC_WAIT_FLAG | - ((conf->addr_cycles - 1) << NFC_ADDR_NUM_OFFSET) | NFC_SEND_ADR, - SUNXI_NFC_BASE + NFC_CMD); - - if (!check_value(SUNXI_NFC_BASE + NFC_ST, NFC_ST_CMD_INT_FLAG, - DEFAULT_TIMEOUT_US)) { - printf("Error while initializing dma interrupt\n"); - return -EIO; - } - return 0; + return nand_exec_cmd(NFC_SEND_CMD1 | NFC_SEND_CMD2 | NFC_RAW_CMD | + NFC_SEND_ADDR | NFC_WAIT_FLAG | + ((conf->addr_cycles - 1) << NFC_ADDR_NUM_OFFSET)); } -static int nand_reset_column(void) +static int nand_change_column(u16 column) { + int ret; + writel((NFC_CMD_RNDOUTSTART << NFC_RANDOM_READ_CMD1_OFFSET) | (NFC_CMD_RNDOUT << NFC_RANDOM_READ_CMD0_OFFSET) | (NFC_CMD_RNDOUTSTART << NFC_READ_CMD_OFFSET), SUNXI_NFC_BASE + NFC_RCMD_SET); - writel(0, SUNXI_NFC_BASE + NFC_ADDR_LOW); - writel(NFC_SEND_CMD1 | NFC_SEND_CMD2 | NFC_RAW_CMD | - (1 << NFC_ADDR_NUM_OFFSET) | NFC_SEND_ADR | NFC_CMD_RNDOUT, - SUNXI_NFC_BASE + NFC_CMD); + writel(column, SUNXI_NFC_BASE + NFC_ADDR_LOW); - if (!check_value(SUNXI_NFC_BASE + NFC_ST, NFC_ST_CMD_INT_FLAG, - DEFAULT_TIMEOUT_US)) { - printf("Error while initializing dma interrupt\n"); - return -1; - } + ret = nand_exec_cmd(NFC_SEND_CMD1 | NFC_SEND_CMD2 | NFC_RAW_CMD | + (1 << NFC_ADDR_NUM_OFFSET) | NFC_SEND_ADDR | + NFC_CMD_RNDOUT); + if (ret) + return ret; + + /* Ensure tCCS has passed before reading data */ + udelay(1); return 0; } +static const int ecc_bytes[] = {32, 46, 54, 60, 74, 88, 102, 110, 116}; + static int nand_read_page(const struct nfc_config *conf, u32 offs, void *dest, int len) { - dma_addr_t dst = (dma_addr_t)dest; int nsectors = len / conf->ecc_size; u16 rand_seed = 0; - u32 val; - int page; - - page = offs / conf->page_size; + int oob_chunk_sz = ecc_bytes[conf->ecc_strength]; + int page = offs / conf->page_size; + u32 ecc_st; + int i; if (offs % conf->page_size || len % conf->ecc_size || len > conf->page_size || len < 0) return -EINVAL; - /* clear ecc status */ - writel(0, SUNXI_NFC_BASE + NFC_ECC_ST); - /* Choose correct seed if randomized */ if (conf->randomize) rand_seed = random_seed[page % conf->nseeds]; - writel((rand_seed << 16) | (conf->ecc_strength << 12) | - (conf->randomize ? NFC_ECC_RANDOM_EN : 0) | - (conf->ecc_size == 512 ? NFC_ECC_BLOCK_SIZE : 0) | - NFC_ECC_EN | NFC_ECC_PIPELINE | NFC_ECC_EXCEPTION, - SUNXI_NFC_BASE + NFC_ECC_CTL); - - flush_dcache_range(dst, ALIGN(dst + conf->ecc_size, ARCH_DMA_MINALIGN)); - - /* SUNXI_DMA */ - writel(0x0, SUNXI_DMA_BASE + SUNXI_DMA_CFG_REG0); /* clr dma cmd */ - /* read from REG_IO_DATA */ - writel(SUNXI_NFC_BASE + NFC_IO_DATA, - SUNXI_DMA_BASE + SUNXI_DMA_SRC_START_ADDR_REG0); - /* read to RAM */ - writel(dst, SUNXI_DMA_BASE + SUNXI_DMA_DEST_START_ADDRR_REG0); - writel(SUNXI_DMA_DDMA_PARA_REG_SRC_WAIT_CYC | - SUNXI_DMA_DDMA_PARA_REG_SRC_BLK_SIZE, - SUNXI_DMA_BASE + SUNXI_DMA_DDMA_PARA_REG0); - writel(len, SUNXI_DMA_BASE + SUNXI_DMA_DDMA_BC_REG0); - writel(SUNXI_DMA_DDMA_CFG_REG_LOADING | - SUNXI_DMA_DDMA_CFG_REG_DMA_DEST_DATA_WIDTH_32 | - SUNXI_DMA_DDMA_CFG_REG_DDMA_DST_DRQ_TYPE_DRAM | - SUNXI_DMA_DDMA_CFG_REG_DMA_SRC_DATA_WIDTH_32 | - SUNXI_DMA_DDMA_CFG_REG_DMA_SRC_ADDR_MODE_IO | - SUNXI_DMA_DDMA_CFG_REG_DDMA_SRC_DRQ_TYPE_NFC, - SUNXI_DMA_BASE + SUNXI_DMA_CFG_REG0); - - writel(nsectors, SUNXI_NFC_BASE + NFC_SECTOR_NUM); - writel(NFC_ST_DMA_INT_FLAG, SUNXI_NFC_BASE + NFC_ST); - writel(NFC_DATA_TRANS | NFC_PAGE_CMD | NFC_DATA_SWAP_METHOD, - SUNXI_NFC_BASE + NFC_CMD); - - if (!check_value(SUNXI_NFC_BASE + NFC_ST, NFC_ST_DMA_INT_FLAG, - DEFAULT_TIMEOUT_US)) { - printf("Error while initializing dma interrupt\n"); - return -EIO; - } - writel(NFC_ST_DMA_INT_FLAG, SUNXI_NFC_BASE + NFC_ST); + /* Retrieve data from SRAM (PIO) */ + for (i = 0; i < nsectors; i++) { + int data_off = i * conf->ecc_size; + int oob_off = conf->page_size + (i * oob_chunk_sz); + u8 *data = dest + data_off; + + /* Clear ECC status and restart ECC engine */ + writel(0, SUNXI_NFC_BASE + NFC_ECC_ST); + writel((rand_seed << 16) | (conf->ecc_strength << 12) | + (conf->randomize ? NFC_ECC_RANDOM_EN : 0) | + (conf->ecc_size == 512 ? NFC_ECC_BLOCK_SIZE : 0) | + NFC_ECC_EN | NFC_ECC_EXCEPTION, + SUNXI_NFC_BASE + NFC_ECC_CTL); + + /* Move the data in SRAM */ + nand_change_column(data_off); + writel(conf->ecc_size, SUNXI_NFC_BASE + NFC_CNT); + nand_exec_cmd(NFC_DATA_TRANS); - if (!check_value_negated(SUNXI_DMA_BASE + SUNXI_DMA_CFG_REG0, - SUNXI_DMA_DDMA_CFG_REG_LOADING, - DEFAULT_TIMEOUT_US)) { - printf("Error while waiting for dma transfer to finish\n"); - return -EIO; - } + /* + * Let the ECC engine consume the ECC bytes and possibly correct + * the data. + */ + nand_change_column(oob_off); + nand_exec_cmd(NFC_DATA_TRANS | NFC_ECC_CMD); + + /* Get the ECC status */ + ecc_st = readl(SUNXI_NFC_BASE + NFC_ECC_ST); + + /* ECC error detected. */ + if (ecc_st & 0xffff) + return -EIO; + + /* + * Return 1 if the first chunk is empty (needed for + * configuration detection). + */ + if (!i && (ecc_st & 0x10000)) + return 1; - invalidate_dcache_range(dst, - ALIGN(dst + conf->ecc_size, ARCH_DMA_MINALIGN)); + /* Retrieve the data from SRAM */ + memcpy_fromio(data, SUNXI_NFC_BASE + NFC_RAM0_BASE, + conf->ecc_size); - val = readl(SUNXI_NFC_BASE + NFC_ECC_ST); + /* Stop the ECC engine */ + writel(readl(SUNXI_NFC_BASE + NFC_ECC_CTL) & ~NFC_ECC_EN, + SUNXI_NFC_BASE + NFC_ECC_CTL); - /* ECC error detected. */ - if (val & 0xffff) - return -EIO; + if (data_off + conf->ecc_size >= len) + break; + } - /* - * Return 1 if the page is empty. - * We consider the page as empty if the first ECC block is marked - * empty. - */ - return (val & 0x10000) ? 1 : 0; + return 0; } static int nand_max_ecc_strength(struct nfc_config *conf) { - static const int ecc_bytes[] = { 32, 46, 54, 60, 74, 88, 102, 110, 116 }; int max_oobsize, max_ecc_bytes; int nsectors = conf->page_size / conf->ecc_size; int i; @@ -393,7 +392,7 @@ static int nand_detect_ecc_config(struct nfc_config *conf, u32 offs, conf->ecc_strength >= 0; conf->ecc_strength--) { conf->randomize = false; - if (nand_reset_column()) + if (nand_change_column(0)) return -EIO; /* @@ -413,7 +412,7 @@ static int nand_detect_ecc_config(struct nfc_config *conf, u32 offs, conf->randomize = true; conf->nseeds = ARRAY_SIZE(random_seed); do { - if (nand_reset_column()) + if (nand_change_column(0)) return -EIO; if (!nand_read_page(conf, offs, dest, @@ -475,11 +474,12 @@ static int nand_detect_config(struct nfc_config *conf, u32 offs, void *dest) static int nand_read_buffer(struct nfc_config *conf, uint32_t offs, unsigned int size, void *dest) { - int first_seed, page, ret; + int first_seed = 0, page, ret; size = ALIGN(size, conf->page_size); page = offs / conf->page_size; - first_seed = page % conf->nseeds; + if (conf->randomize) + first_seed = page % conf->nseeds; for (; size; size -= conf->page_size) { if (nand_load_page(conf, offs)) @@ -504,7 +504,7 @@ static int nand_read_buffer(struct nfc_config *conf, uint32_t offs, /* Try to adjust ->nseeds and read the page again... */ conf->nseeds = cur_seed; - if (nand_reset_column()) + if (nand_change_column(0)) return -EIO; /* ... it still fails => it's a real corruption. */ diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index f589978b43..98573cb22a 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -11,6 +11,13 @@ config DM_ETH This is currently implemented in net/eth.c Look in include/net.h for details. +config DRIVER_TI_CPSW + bool "TI Common Platform Ethernet Switch" + select PHYLIB + help + This driver supports the TI three port switch gigabit ethernet + subsystem found in the TI SoCs. + menuconfig NETDEVICES bool "Network device support" depends on NET @@ -331,7 +338,7 @@ config RENESAS_RAVB config MPC8XX_FEC bool "Fast Ethernet Controller on MPC8XX" - depends on 8xx + depends on MPC8xx select MII help This driver implements support for the Fast Ethernet Controller @@ -411,4 +418,11 @@ config SYS_DPAA_QBMAN help QBman fixups to allow deep sleep in DPAA 1 SOCs +config TSEC_ENET + select PHYLIB + bool "Enable Three-Speed Ethernet Controller" + help + This driver implements support for the (Enhanced) Three-Speed + Ethernet Controller found on Freescale SoCs. + endif # NETDEVICES diff --git a/drivers/net/cpsw-common.c b/drivers/net/cpsw-common.c index 0dc83ab820..7bd312a6c0 100644 --- a/drivers/net/cpsw-common.c +++ b/drivers/net/cpsw-common.c @@ -8,6 +8,7 @@ #include <common.h> #include <dm.h> +#include <environment.h> #include <fdt_support.h> #include <asm/io.h> #include <cpsw.h> diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c index ff7ad91116..29af85ce0a 100644 --- a/drivers/net/fec_mxc.c +++ b/drivers/net/fec_mxc.c @@ -10,6 +10,7 @@ #include <common.h> #include <dm.h> +#include <environment.h> #include <malloc.h> #include <memalign.h> #include <miiphy.h> diff --git a/drivers/net/fsl_mcdmafec.c b/drivers/net/fsl_mcdmafec.c index 2d89cea4a3..00d905c299 100644 --- a/drivers/net/fsl_mcdmafec.c +++ b/drivers/net/fsl_mcdmafec.c @@ -9,6 +9,7 @@ */ #include <common.h> +#include <environment.h> #include <malloc.h> #include <command.h> #include <config.h> diff --git a/drivers/net/mcffec.c b/drivers/net/mcffec.c index ebcbed941a..505a2d1bee 100644 --- a/drivers/net/mcffec.c +++ b/drivers/net/mcffec.c @@ -9,6 +9,7 @@ */ #include <common.h> +#include <environment.h> #include <malloc.h> #include <command.h> diff --git a/drivers/net/mpc8xx_fec.c b/drivers/net/mpc8xx_fec.c index 71fe984a5d..1dd41df18b 100644 --- a/drivers/net/mpc8xx_fec.c +++ b/drivers/net/mpc8xx_fec.c @@ -7,10 +7,10 @@ #include <common.h> #include <command.h> -#include <commproc.h> #include <malloc.h> #include <net.h> #include <netdev.h> +#include <asm/cpm_8xx.h> #include <asm/io.h> #include <phy.h> diff --git a/drivers/net/ne2000_base.c b/drivers/net/ne2000_base.c index fb088e06a4..421aa20ea6 100644 --- a/drivers/net/ne2000_base.c +++ b/drivers/net/ne2000_base.c @@ -74,6 +74,7 @@ Add SNMP #include <common.h> #include <command.h> +#include <environment.h> #include <net.h> #include <malloc.h> #include <linux/compiler.h> diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c index 6f48e93ab5..e3416f3391 100644 --- a/drivers/net/sh_eth.c +++ b/drivers/net/sh_eth.c @@ -11,6 +11,7 @@ #include <config.h> #include <common.h> +#include <environment.h> #include <malloc.h> #include <net.h> #include <netdev.h> diff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c index be43472b1a..b6e5dafe83 100644 --- a/drivers/net/sun8i_emac.c +++ b/drivers/net/sun8i_emac.c @@ -21,6 +21,7 @@ #include <malloc.h> #include <miiphy.h> #include <net.h> +#include <dt-bindings/pinctrl/sun4i-a10.h> #ifdef CONFIG_DM_GPIO #include <asm-generic/gpio.h> #endif @@ -278,7 +279,7 @@ static int sun8i_emac_set_syscon(struct emac_eth_dev *priv) int ret; u32 reg; - reg = readl(priv->sysctl_reg); + reg = readl(priv->sysctl_reg + 0x30); if (priv->variant == H3_EMAC) { ret = sun8i_emac_set_syscon_ephy(priv, ®); @@ -309,7 +310,7 @@ static int sun8i_emac_set_syscon(struct emac_eth_dev *priv) return -EINVAL; } - writel(reg, priv->sysctl_reg); + writel(reg, priv->sysctl_reg + 0x30); return 0; } @@ -455,7 +456,7 @@ static int parse_phy_pins(struct udevice *dev) { int offset; const char *pin_name; - int drive, pull, i; + int drive, pull = SUN4I_PINCTRL_NO_PULL, i; offset = fdtdec_lookup_phandle(gd->fdt_blob, dev_of_offset(dev), "pinctrl-0"); @@ -465,30 +466,44 @@ static int parse_phy_pins(struct udevice *dev) } drive = fdt_getprop_u32_default_node(gd->fdt_blob, offset, 0, - "allwinner,drive", 4); - pull = fdt_getprop_u32_default_node(gd->fdt_blob, offset, 0, - "allwinner,pull", 0); + "drive-strength", ~0); + if (drive != ~0) { + if (drive <= 10) + drive = SUN4I_PINCTRL_10_MA; + else if (drive <= 20) + drive = SUN4I_PINCTRL_20_MA; + else if (drive <= 30) + drive = SUN4I_PINCTRL_30_MA; + else + drive = SUN4I_PINCTRL_40_MA; + } + + if (fdt_get_property(gd->fdt_blob, offset, "bias-pull-up", NULL)) + pull = SUN4I_PINCTRL_PULL_UP; + else if (fdt_get_property(gd->fdt_blob, offset, "bias-pull-down", NULL)) + pull = SUN4I_PINCTRL_PULL_DOWN; + for (i = 0; ; i++) { int pin; pin_name = fdt_stringlist_get(gd->fdt_blob, offset, - "allwinner,pins", i, NULL); + "pins", i, NULL); if (!pin_name) break; - if (pin_name[0] != 'P') - continue; - pin = (pin_name[1] - 'A') << 5; - if (pin >= 26 << 5) + + pin = sunxi_name_to_gpio(pin_name); + if (pin < 0) continue; - pin += simple_strtol(&pin_name[2], NULL, 10); sunxi_gpio_set_cfgpin(pin, SUN8I_GPD8_GMAC); - sunxi_gpio_set_drv(pin, drive); - sunxi_gpio_set_pull(pin, pull); + if (drive != ~0) + sunxi_gpio_set_drv(pin, drive); + if (pull != ~0) + sunxi_gpio_set_pull(pin, pull); } if (!i) { - printf("WARNING: emac: cannot find allwinner,pins property\n"); + printf("WARNING: emac: cannot find pins property\n"); return -2; } @@ -772,6 +787,7 @@ static int sun8i_emac_eth_ofdata_to_platdata(struct udevice *dev) struct eth_pdata *pdata = &sun8i_pdata->eth_pdata; struct emac_eth_dev *priv = dev_get_priv(dev); const char *phy_mode; + const fdt32_t *reg; int node = dev_of_offset(dev); int offset = 0; #ifdef CONFIG_DM_GPIO @@ -779,18 +795,40 @@ static int sun8i_emac_eth_ofdata_to_platdata(struct udevice *dev) int ret = 0; #endif - pdata->iobase = devfdt_get_addr_name(dev, "emac"); - priv->sysctl_reg = devfdt_get_addr_name(dev, "syscon"); + pdata->iobase = devfdt_get_addr(dev); + if (pdata->iobase == FDT_ADDR_T_NONE) { + debug("%s: Cannot find MAC base address\n", __func__); + return -EINVAL; + } + + offset = fdtdec_lookup_phandle(gd->fdt_blob, node, "syscon"); + if (offset < 0) { + debug("%s: cannot find syscon node\n", __func__); + return -EINVAL; + } + reg = fdt_getprop(gd->fdt_blob, offset, "reg", NULL); + if (!reg) { + debug("%s: cannot find reg property in syscon node\n", + __func__); + return -EINVAL; + } + priv->sysctl_reg = fdt_translate_address((void *)gd->fdt_blob, + offset, reg); + if (priv->sysctl_reg == FDT_ADDR_T_NONE) { + debug("%s: Cannot find syscon base address\n", __func__); + return -EINVAL; + } pdata->phy_interface = -1; priv->phyaddr = -1; priv->use_internal_phy = false; - offset = fdtdec_lookup_phandle(gd->fdt_blob, node, - "phy"); - if (offset > 0) - priv->phyaddr = fdtdec_get_int(gd->fdt_blob, offset, "reg", - -1); + offset = fdtdec_lookup_phandle(gd->fdt_blob, node, "phy-handle"); + if (offset < 0) { + debug("%s: Cannot find PHY address\n", __func__); + return -EINVAL; + } + priv->phyaddr = fdtdec_get_int(gd->fdt_blob, offset, "reg", -1); phy_mode = fdt_getprop(gd->fdt_blob, node, "phy-mode", NULL); @@ -812,8 +850,11 @@ static int sun8i_emac_eth_ofdata_to_platdata(struct udevice *dev) } if (priv->variant == H3_EMAC) { - if (fdt_getprop(gd->fdt_blob, node, - "allwinner,use-internal-phy", NULL)) + int parent = fdt_parent_offset(gd->fdt_blob, offset); + + if (parent >= 0 && + !fdt_node_check_compatible(gd->fdt_blob, parent, + "allwinner,sun8i-h3-mdio-internal")) priv->use_internal_phy = true; } diff --git a/drivers/power/regulator/pbias_regulator.c b/drivers/power/regulator/pbias_regulator.c index 116b7f480a..adf589b224 100644 --- a/drivers/power/regulator/pbias_regulator.c +++ b/drivers/power/regulator/pbias_regulator.c @@ -225,9 +225,6 @@ static int pbias_regulator_set_value(struct udevice *dev, int uV) int rc; u32 reg; - debug("Setting %s voltage to %s\n", p->name, - (reg & p->vmode) ? "3.0v" : "1.8v"); - rc = pmic_read(dev->parent, 0, (uint8_t *)®, sizeof(reg)); if (rc) return rc; @@ -239,6 +236,9 @@ static int pbias_regulator_set_value(struct udevice *dev, int uV) else return -EINVAL; + debug("Setting %s voltage to %s\n", p->name, + (reg & p->vmode) ? "3.0v" : "1.8v"); + return pmic_write(dev->parent, 0, (uint8_t *)®, sizeof(reg)); } diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 95ac031243..277dc3de73 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig @@ -30,6 +30,18 @@ config RTC_DS1307 Support for Dallas Semiconductor (now Maxim) DS1307 and DS1338/9 and compatible Real Time Clock devices. +config RTC_ISL1208 + bool "Enable ISL1208 driver" + depends on DM_RTC + help + The Renesas (formerly Intersil) ISL1208 is a I2C Real Time Clock (RTC) and + calendar with automatic leap year correction, 2-byte battery backed SRAM, + automatic power switch-over, alarm function and 15 selectable frequency + outputs. + + This driver supports reading and writing the RTC/calendar and detects + total power failures. + config RTC_RX8010SJ bool "Enable RX8010SJ driver" depends on DM_RTC diff --git a/drivers/rtc/ds1307.c b/drivers/rtc/ds1307.c index 5df15c7fd6..5e74b93b72 100644 --- a/drivers/rtc/ds1307.c +++ b/drivers/rtc/ds1307.c @@ -184,25 +184,8 @@ int rtc_set (struct rtc_time *tmp) */ void rtc_reset (void) { - struct rtc_time tmp; - rtc_write (RTC_SEC_REG_ADDR, 0x00); /* clearing Clock Halt */ rtc_write (RTC_CTL_REG_ADDR, RTC_CTL_BIT_SQWE | RTC_CTL_BIT_RS1 | RTC_CTL_BIT_RS0); - - tmp.tm_year = 1970; - tmp.tm_mon = 1; - tmp.tm_mday= 1; - tmp.tm_hour = 0; - tmp.tm_min = 0; - tmp.tm_sec = 0; - - rtc_set(&tmp); - - printf ( "RTC: %4d-%02d-%02d %2d:%02d:%02d UTC\n", - tmp.tm_year, tmp.tm_mon, tmp.tm_mday, - tmp.tm_hour, tmp.tm_min, tmp.tm_sec); - - return; } @@ -321,14 +304,6 @@ read_rtc: static int ds1307_rtc_reset(struct udevice *dev) { int ret; - struct rtc_time tmp = { - .tm_year = 1970, - .tm_mon = 1, - .tm_mday = 1, - .tm_hour = 0, - .tm_min = 0, - .tm_sec = 0, - }; /* clear Clock Halt */ ret = dm_i2c_reg_write(dev, RTC_SEC_REG_ADDR, 0x00); @@ -340,14 +315,6 @@ static int ds1307_rtc_reset(struct udevice *dev) if (ret < 0) return ret; - ret = ds1307_rtc_set(dev, &tmp); - if (ret < 0) - return ret; - - debug("RTC: %4d-%02d-%02d %2d:%02d:%02d UTC\n", - tmp.tm_year, tmp.tm_mon, tmp.tm_mday, - tmp.tm_hour, tmp.tm_min, tmp.tm_sec); - return 0; } diff --git a/drivers/rtc/ds1374.c b/drivers/rtc/ds1374.c index 78473570b9..9e440d8457 100644 --- a/drivers/rtc/ds1374.c +++ b/drivers/rtc/ds1374.c @@ -172,8 +172,6 @@ int rtc_set (struct rtc_time *tmp){ */ void rtc_reset (void){ - struct rtc_time tmp; - /* clear status flags */ rtc_write(RTC_SR_ADDR, (RTC_SR_BIT_AF|RTC_SR_BIT_OSF), false); /* clearing OSF and AF */ @@ -189,19 +187,6 @@ void rtc_reset (void){ |RTC_CTL_BIT_BBSQW), true);/* disable WD/ALM, WDSTR set to INT-pin, set BBSQW and SQW to 32k - set to 1 */ - tmp.tm_year = 1970; - tmp.tm_mon = 1; - tmp.tm_mday= 1; - tmp.tm_hour = 0; - tmp.tm_min = 0; - tmp.tm_sec = 0; - - rtc_set(&tmp); - - printf("RTC: %4d-%02d-%02d %2d:%02d:%02d UTC\n", - tmp.tm_year, tmp.tm_mon, tmp.tm_mday, - tmp.tm_hour, tmp.tm_min, tmp.tm_sec); - rtc_write(RTC_WD_ALM_CNT_BYTE2_ADDR, 0xAC, true); rtc_write(RTC_WD_ALM_CNT_BYTE1_ADDR, 0xDE, true); rtc_write(RTC_WD_ALM_CNT_BYTE2_ADDR, 0xAD, true); diff --git a/drivers/rtc/isl1208.c b/drivers/rtc/isl1208.c index 807e2e404e..fa1178a36e 100644 --- a/drivers/rtc/isl1208.c +++ b/drivers/rtc/isl1208.c @@ -14,6 +14,7 @@ #include <common.h> #include <command.h> +#include <dm.h> #include <rtc.h> #include <i2c.h> @@ -51,45 +52,38 @@ #define RTC_STAT_BIT_BAT 0x02 /* BATTERY BIT */ #define RTC_STAT_BIT_RTCF 0x01 /* REAL TIME CLOCK FAIL BIT */ -static uchar rtc_read (uchar reg); -static void rtc_write (uchar reg, uchar val); - /* * Get the current time from the RTC */ -int rtc_get (struct rtc_time *tmp) +static int isl1208_rtc_get(struct udevice *dev, struct rtc_time *tmp) { - int rel = 0; - uchar sec, min, hour, mday, wday, mon, year, status; - - status = rtc_read (RTC_STAT_REG_ADDR); - sec = rtc_read (RTC_SEC_REG_ADDR); - min = rtc_read (RTC_MIN_REG_ADDR); - hour = rtc_read (RTC_HR_REG_ADDR); - wday = rtc_read (RTC_DAY_REG_ADDR); - mday = rtc_read (RTC_DATE_REG_ADDR); - mon = rtc_read (RTC_MON_REG_ADDR); - year = rtc_read (RTC_YR_REG_ADDR); - - DEBUGR ("Get RTC year: %02x mon: %02x mday: %02x wday: %02x " - "hr: %02x min: %02x sec: %02x status: %02x\n", - year, mon, mday, wday, hour, min, sec, status); - - if (status & RTC_STAT_BIT_RTCF) { + int ret; + uchar buf[8], val; + + ret = dm_i2c_read(dev, 0, buf, sizeof(buf)); + if (ret < 0) + return ret; + + if (buf[RTC_STAT_REG_ADDR] & RTC_STAT_BIT_RTCF) { printf ("### Warning: RTC oscillator has stopped\n"); - rtc_write(RTC_STAT_REG_ADDR, - rtc_read(RTC_STAT_REG_ADDR) &~ (RTC_STAT_BIT_BAT|RTC_STAT_BIT_RTCF)); - rel = -1; + ret = dm_i2c_read(dev, RTC_STAT_REG_ADDR, &val, sizeof(val)); + if (ret < 0) + return ret; + + val = val & ~(RTC_STAT_BIT_BAT | RTC_STAT_BIT_RTCF); + ret = dm_i2c_write(dev, RTC_STAT_REG_ADDR, &val, sizeof(val)); + if (ret < 0) + return ret; } - tmp->tm_sec = bcd2bin (sec & 0x7F); - tmp->tm_min = bcd2bin (min & 0x7F); - tmp->tm_hour = bcd2bin (hour & 0x3F); - tmp->tm_mday = bcd2bin (mday & 0x3F); - tmp->tm_mon = bcd2bin (mon & 0x1F); - tmp->tm_year = bcd2bin (year)+2000; - tmp->tm_wday = bcd2bin (wday & 0x07); + tmp->tm_sec = bcd2bin(buf[RTC_SEC_REG_ADDR] & 0x7F); + tmp->tm_min = bcd2bin(buf[RTC_MIN_REG_ADDR] & 0x7F); + tmp->tm_hour = bcd2bin(buf[RTC_HR_REG_ADDR] & 0x3F); + tmp->tm_mday = bcd2bin(buf[RTC_DATE_REG_ADDR] & 0x3F); + tmp->tm_mon = bcd2bin(buf[RTC_MON_REG_ADDR] & 0x1F); + tmp->tm_year = bcd2bin(buf[RTC_YR_REG_ADDR]) + 2000; + tmp->tm_wday = bcd2bin(buf[RTC_DAY_REG_ADDR] & 0x07); tmp->tm_yday = 0; tmp->tm_isdst= 0; @@ -97,51 +91,88 @@ int rtc_get (struct rtc_time *tmp) tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday, tmp->tm_hour, tmp->tm_min, tmp->tm_sec); - return rel; + return 0; } /* * Set the RTC */ -int rtc_set (struct rtc_time *tmp) +static int isl1208_rtc_set(struct udevice *dev, const struct rtc_time *tmp) { + int ret; + uchar val, buf[7]; + DEBUGR ("Set DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n", tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday, tmp->tm_hour, tmp->tm_min, tmp->tm_sec); + if (tmp->tm_year < 2000 || tmp->tm_year > 2099) + printf("WARNING: year should be between 2000 and 2099!\n"); + /* enable write */ - rtc_write(RTC_STAT_REG_ADDR, - rtc_read(RTC_STAT_REG_ADDR) | RTC_STAT_BIT_WRTC); + ret = dm_i2c_read(dev, RTC_STAT_REG_ADDR, &val, sizeof(val)); + if (ret < 0) + return ret; + + val = val | RTC_STAT_BIT_WRTC; + + ret = dm_i2c_write(dev, RTC_STAT_REG_ADDR, &val, sizeof(val)); + if (ret < 0) + return ret; + + buf[RTC_YR_REG_ADDR] = bin2bcd(tmp->tm_year % 100); + buf[RTC_MON_REG_ADDR] = bin2bcd(tmp->tm_mon); + buf[RTC_DAY_REG_ADDR] = bin2bcd(tmp->tm_wday); + buf[RTC_DATE_REG_ADDR] = bin2bcd(tmp->tm_mday); + buf[RTC_HR_REG_ADDR] = bin2bcd(tmp->tm_hour) | 0x80; /* 24h clock */ + buf[RTC_MIN_REG_ADDR] = bin2bcd(tmp->tm_min); + buf[RTC_SEC_REG_ADDR] = bin2bcd(tmp->tm_sec); - rtc_write (RTC_YR_REG_ADDR, bin2bcd (tmp->tm_year % 100)); - rtc_write (RTC_MON_REG_ADDR, bin2bcd (tmp->tm_mon)); - rtc_write (RTC_DAY_REG_ADDR, bin2bcd (tmp->tm_wday)); - rtc_write (RTC_DATE_REG_ADDR, bin2bcd (tmp->tm_mday)); - rtc_write (RTC_HR_REG_ADDR, bin2bcd (tmp->tm_hour) | 0x80 ); /* 24h clock */ - rtc_write (RTC_MIN_REG_ADDR, bin2bcd (tmp->tm_min)); - rtc_write (RTC_SEC_REG_ADDR, bin2bcd (tmp->tm_sec)); + ret = dm_i2c_write(dev, 0, buf, sizeof(buf)); + if (ret < 0) + return ret; /* disable write */ - rtc_write(RTC_STAT_REG_ADDR, - rtc_read(RTC_STAT_REG_ADDR) & ~RTC_STAT_BIT_WRTC); + ret = dm_i2c_read(dev, RTC_STAT_REG_ADDR, &val, sizeof(val)); + if (ret < 0) + return ret; + + val = val & ~RTC_STAT_BIT_WRTC; + ret = dm_i2c_write(dev, RTC_STAT_REG_ADDR, &val, sizeof(val)); + if (ret < 0) + return ret; return 0; } -void rtc_reset (void) +static int isl1208_rtc_reset(struct udevice *dev) { + return 0; } -/* - * Helper functions - */ - -static uchar rtc_read (uchar reg) +static int isl1208_probe(struct udevice *dev) { - return (i2c_reg_read (CONFIG_SYS_I2C_RTC_ADDR, reg)); -} + i2c_set_chip_flags(dev, DM_I2C_CHIP_RD_ADDRESS | + DM_I2C_CHIP_WR_ADDRESS); -static void rtc_write (uchar reg, uchar val) -{ - i2c_reg_write (CONFIG_SYS_I2C_RTC_ADDR, reg, val); + return 0; } + +static const struct rtc_ops isl1208_rtc_ops = { + .get = isl1208_rtc_get, + .set = isl1208_rtc_set, + .reset = isl1208_rtc_reset, +}; + +static const struct udevice_id isl1208_rtc_ids[] = { + { .compatible = "isil,isl1208" }, + { } +}; + +U_BOOT_DRIVER(rtc_isl1208) = { + .name = "rtc-isl1208", + .id = UCLASS_RTC, + .probe = isl1208_probe, + .of_match = isl1208_rtc_ids, + .ops = &isl1208_rtc_ops, +}; diff --git a/drivers/rtc/mx27rtc.c b/drivers/rtc/mx27rtc.c index 29ccdf1730..b42770e05b 100644 --- a/drivers/rtc/mx27rtc.c +++ b/drivers/rtc/mx27rtc.c @@ -61,9 +61,5 @@ int rtc_set(struct rtc_time *time) void rtc_reset(void) { - struct rtc_regs *rtc_regs = (struct rtc_regs *)IMX_RTC_BASE; - - writel(0, &rtc_regs->dayr); - writel(0, &rtc_regs->hourmin); - writel(0, &rtc_regs->seconds); + /* nothing to do */ } diff --git a/drivers/rtc/rs5c372.c b/drivers/rtc/rs5c372.c index 65f45ea5e3..c815c915d5 100644 --- a/drivers/rtc/rs5c372.c +++ b/drivers/rtc/rs5c372.c @@ -247,35 +247,13 @@ int rtc_set (struct rtc_time *tmp) } /* - * Reset the RTC. We set the date back to 1970-01-01. + * Reset the RTC. */ void rtc_reset (void) { - struct rtc_time tmp; - if (!setup_done) rs5c372_enable(); - - if (!setup_done) - return; - - tmp.tm_year = 1970; - tmp.tm_mon = 1; - /* Jan. 1, 1970 was a Thursday */ - tmp.tm_wday= 4; - tmp.tm_mday= 1; - tmp.tm_hour = 0; - tmp.tm_min = 0; - tmp.tm_sec = 0; - - rtc_set(&tmp); - - printf ("RTC: %4d-%02d-%02d %2d:%02d:%02d UTC\n", - tmp.tm_year, tmp.tm_mon, tmp.tm_mday, - tmp.tm_hour, tmp.tm_min, tmp.tm_sec); - - return; } #endif diff --git a/drivers/rtc/rx8025.c b/drivers/rtc/rx8025.c index b4a149b738..c43966a50d 100644 --- a/drivers/rtc/rx8025.c +++ b/drivers/rtc/rx8025.c @@ -163,11 +163,10 @@ int rtc_set (struct rtc_time *tmp) } /* - * Reset the RTC. We setting the date back to 1970-01-01. + * Reset the RTC */ void rtc_reset (void) { - struct rtc_time tmp; uchar buf[16]; uchar ctl2; @@ -178,21 +177,6 @@ void rtc_reset (void) ctl2 &= ~(RTC_CTL2_BIT_PON | RTC_CTL2_BIT_VDET); ctl2 |= RTC_CTL2_BIT_XST | RTC_CTL2_BIT_VDSL; rtc_write (RTC_CTL2_REG_ADDR, ctl2); - - tmp.tm_year = 1970; - tmp.tm_mon = 1; - tmp.tm_mday= 1; - tmp.tm_hour = 0; - tmp.tm_min = 0; - tmp.tm_sec = 0; - - rtc_set(&tmp); - - printf ( "RTC: %4d-%02d-%02d %2d:%02d:%02d UTC\n", - tmp.tm_year, tmp.tm_mon, tmp.tm_mday, - tmp.tm_hour, tmp.tm_min, tmp.tm_sec); - - return; } /* diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index eb718a650f..3d5b2bf15f 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -624,7 +624,7 @@ config ZYNQ_SERIAL config MPC8XX_CONS bool "Console driver for MPC8XX" - depends on 8xx + depends on MPC8xx default y choice diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c index cc4bdcb834..397c6f5203 100644 --- a/drivers/serial/serial.c +++ b/drivers/serial/serial.c @@ -109,48 +109,16 @@ U_BOOT_ENV_CALLBACK(baudrate, on_baudrate); void name(void) \ __attribute__((weak, alias("serial_null"))); -serial_initfunc(amirix_serial_initialize); -serial_initfunc(arc_serial_initialize); -serial_initfunc(arm_dcc_initialize); -serial_initfunc(asc_serial_initialize); serial_initfunc(atmel_serial_initialize); serial_initfunc(au1x00_serial_initialize); -serial_initfunc(bfin_jtag_initialize); -serial_initfunc(bfin_serial_initialize); -serial_initfunc(bmw_serial_initialize); -serial_initfunc(clps7111_serial_initialize); -serial_initfunc(cogent_serial_initialize); -serial_initfunc(cpci750_serial_initialize); -serial_initfunc(evb64260_serial_initialize); -serial_initfunc(imx_serial_initialize); -serial_initfunc(iop480_serial_initialize); -serial_initfunc(jz_serial_initialize); -serial_initfunc(leon2_serial_initialize); -serial_initfunc(leon3_serial_initialize); -serial_initfunc(lh7a40x_serial_initialize); -serial_initfunc(lpc32xx_serial_initialize); -serial_initfunc(marvell_serial_initialize); -serial_initfunc(max3100_serial_initialize); serial_initfunc(mcf_serial_initialize); -serial_initfunc(ml2_serial_initialize); serial_initfunc(mpc85xx_serial_initialize); serial_initfunc(mpc8xx_serial_initialize); serial_initfunc(mxc_serial_initialize); -serial_initfunc(mxs_auart_initialize); serial_initfunc(ns16550_serial_initialize); -serial_initfunc(oc_serial_initialize); -serial_initfunc(p3mx_serial_initialize); serial_initfunc(pl01x_serial_initialize); serial_initfunc(pxa_serial_initialize); -serial_initfunc(s3c24xx_serial_initialize); -serial_initfunc(s5p_serial_initialize); -serial_initfunc(sa1100_serial_initialize); -serial_initfunc(sandbox_serial_initialize); -serial_initfunc(sconsole_serial_initialize); serial_initfunc(sh_serial_initialize); -serial_initfunc(stm32_serial_initialize); -serial_initfunc(uartlite_serial_initialize); -serial_initfunc(zynq_serial_initialize); /** * serial_register() - Register serial driver with serial driver core @@ -196,48 +164,16 @@ void serial_register(struct serial_device *dev) */ void serial_initialize(void) { - amirix_serial_initialize(); - arc_serial_initialize(); - arm_dcc_initialize(); - asc_serial_initialize(); atmel_serial_initialize(); au1x00_serial_initialize(); - bfin_jtag_initialize(); - bfin_serial_initialize(); - bmw_serial_initialize(); - clps7111_serial_initialize(); - cogent_serial_initialize(); - cpci750_serial_initialize(); - evb64260_serial_initialize(); - imx_serial_initialize(); - iop480_serial_initialize(); - jz_serial_initialize(); - leon2_serial_initialize(); - leon3_serial_initialize(); - lh7a40x_serial_initialize(); - lpc32xx_serial_initialize(); - marvell_serial_initialize(); - max3100_serial_initialize(); mcf_serial_initialize(); - ml2_serial_initialize(); mpc85xx_serial_initialize(); mpc8xx_serial_initialize(); mxc_serial_initialize(); - mxs_auart_initialize(); ns16550_serial_initialize(); - oc_serial_initialize(); - p3mx_serial_initialize(); pl01x_serial_initialize(); pxa_serial_initialize(); - s3c24xx_serial_initialize(); - s5p_serial_initialize(); - sa1100_serial_initialize(); - sandbox_serial_initialize(); - sconsole_serial_initialize(); sh_serial_initialize(); - stm32_serial_initialize(); - uartlite_serial_initialize(); - zynq_serial_initialize(); serial_assign(default_serial_console()->name); } diff --git a/drivers/serial/serial_mpc8xx.c b/drivers/serial/serial_mpc8xx.c index 26a8085a69..7a5908f464 100644 --- a/drivers/serial/serial_mpc8xx.c +++ b/drivers/serial/serial_mpc8xx.c @@ -6,10 +6,10 @@ */ #include <common.h> -#include <commproc.h> #include <command.h> #include <serial.h> #include <watchdog.h> +#include <asm/cpm_8xx.h> #include <linux/compiler.h> DECLARE_GLOBAL_DATA_PTR; diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index a3b4a0b2f0..d3e407ec11 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig @@ -41,7 +41,7 @@ config ATH79_SPI config ATMEL_SPI bool "Atmel SPI driver" - depends on ARCH_AT91 + default y if ARCH_AT91 help This enables driver for the Atmel SPI Controller, present on many AT91 (ARM) chips. This driver can be used to access @@ -276,7 +276,7 @@ config LPC32XX_SSP config MPC8XX_SPI bool "MPC8XX SPI Driver" - depends on 8xx + depends on MPC8xx help Enable support for SPI on MPC8XX diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c index 8010ab434c..3cdfd366ab 100644 --- a/drivers/spi/atmel_spi.c +++ b/drivers/spi/atmel_spi.c @@ -236,7 +236,9 @@ struct atmel_spi_priv { unsigned int freq; /* Default frequency */ unsigned int mode; ulong bus_clk_rate; +#ifdef CONFIG_DM_GPIO struct gpio_desc cs_gpios[MAX_CS_COUNT]; +#endif }; static int atmel_spi_claim_bus(struct udevice *dev) @@ -291,6 +293,7 @@ static int atmel_spi_release_bus(struct udevice *dev) static void atmel_spi_cs_activate(struct udevice *dev) { +#ifdef CONFIG_DM_GPIO struct udevice *bus = dev_get_parent(dev); struct atmel_spi_priv *priv = dev_get_priv(bus); struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev); @@ -300,10 +303,12 @@ static void atmel_spi_cs_activate(struct udevice *dev) return; dm_gpio_set_value(&priv->cs_gpios[cs], 0); +#endif } static void atmel_spi_cs_deactivate(struct udevice *dev) { +#ifdef CONFIG_DM_GPIO struct udevice *bus = dev_get_parent(dev); struct atmel_spi_priv *priv = dev_get_priv(bus); struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev); @@ -313,6 +318,7 @@ static void atmel_spi_cs_deactivate(struct udevice *dev) return; dm_gpio_set_value(&priv->cs_gpios[cs], 1); +#endif } static int atmel_spi_xfer(struct udevice *dev, unsigned int bitlen, @@ -462,8 +468,7 @@ static int atmel_spi_enable_clk(struct udevice *bus) static int atmel_spi_probe(struct udevice *bus) { struct atmel_spi_platdata *bus_plat = dev_get_platdata(bus); - struct atmel_spi_priv *priv = dev_get_priv(bus); - int i, ret; + int ret; ret = atmel_spi_enable_clk(bus); if (ret) @@ -471,6 +476,10 @@ static int atmel_spi_probe(struct udevice *bus) bus_plat->regs = (struct at91_spi *)devfdt_get_addr(bus); +#ifdef CONFIG_DM_GPIO + struct atmel_spi_priv *priv = dev_get_priv(bus); + int i; + ret = gpio_request_list_by_name(bus, "cs-gpios", priv->cs_gpios, ARRAY_SIZE(priv->cs_gpios), 0); if (ret < 0) { @@ -485,6 +494,7 @@ static int atmel_spi_probe(struct udevice *bus) dm_gpio_set_dir_flags(&priv->cs_gpios[i], GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE); } +#endif writel(ATMEL_SPI_CR_SWRST, &bus_plat->regs->cr); diff --git a/drivers/spi/mpc8xx_spi.c b/drivers/spi/mpc8xx_spi.c index b5bd558526..eb035e9510 100644 --- a/drivers/spi/mpc8xx_spi.c +++ b/drivers/spi/mpc8xx_spi.c @@ -19,7 +19,7 @@ #include <common.h> #include <mpc8xx.h> -#include <commproc.h> +#include <asm/cpm_8xx.h> #include <linux/ctype.h> #include <malloc.h> #include <post.h> diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 6825e6b543..26b4d12a09 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -158,6 +158,7 @@ endif # USB_GADGET_DOWNLOAD config USB_ETHER bool "USB Ethernet Gadget" + depends on NET default y if ARCH_SUNXI && USB_MUSB_GADGET help Creates an Ethernet network device through a USB peripheral diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index a80486e91f..386505d42d 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -10,6 +10,7 @@ #include <common.h> #include <console.h> +#include <environment.h> #include <linux/errno.h> #include <linux/netdevice.h> #include <linux/usb/ch9.h> diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 2fc0defcd0..45a105db06 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -38,7 +38,6 @@ config BACKLIGHT_GPIO config VIDEO_BPP8 bool "Support 8-bit-per-pixel displays" depends on DM_VIDEO - default n if ARCH_SUNXI default y if DM_VIDEO help Support drawing text and bitmaps onto a 8-bit-per-pixel display. @@ -49,7 +48,6 @@ config VIDEO_BPP8 config VIDEO_BPP16 bool "Support 16-bit-per-pixel displays" depends on DM_VIDEO - default n if ARCH_SUNXI default y if DM_VIDEO help Support drawing text and bitmaps onto a 16-bit-per-pixel display. diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index 8a66e479ab..dca2c901ac 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -56,9 +56,9 @@ config WDT_SANDBOX bool "Enable Watchdog Timer support for Sandbox" depends on SANDBOX && WDT help - Enable Watchdog Timer support in Sandbox. This is a dummy device that - can be probed and supports all of the methods of WDT, but does not - really do anything. + Enable Watchdog Timer support in Sandbox. This is a dummy device that + can be probed and supports all of the methods of WDT, but does not + really do anything. config WDT_ASPEED bool "Aspeed ast2400/ast2500 watchdog timer support" diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index 4b97df3ab6..4fee6dbd1f 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -23,3 +23,4 @@ obj-$(CONFIG_WDT_BCM6345) += bcm6345_wdt.o obj-$(CONFIG_BCM2835_WDT) += bcm2835_wdt.o obj-$(CONFIG_WDT_ORION) += orion_wdt.o obj-$(CONFIG_WDT_CDNS) += cdns_wdt.o +obj-$(CONFIG_MPC8xx_WATCHDOG) += mpc8xx_wdt.o diff --git a/drivers/watchdog/mpc8xx_wdt.c b/drivers/watchdog/mpc8xx_wdt.c new file mode 100644 index 0000000000..ded80c4d6a --- /dev/null +++ b/drivers/watchdog/mpc8xx_wdt.c @@ -0,0 +1,21 @@ +/* + * Copyright 2017 CS Systemes d'Information + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <common.h> +#include <mpc8xx.h> +#include <asm/cpm_8xx.h> +#include <asm/io.h> + +DECLARE_GLOBAL_DATA_PTR; + +void hw_watchdog_reset(void) +{ + immap_t __iomem *immap = (immap_t __iomem *)CONFIG_SYS_IMMR; + + out_be16(&immap->im_siu_conf.sc_swsr, 0x556c); /* write magic1 */ + out_be16(&immap->im_siu_conf.sc_swsr, 0xaa39); /* write magic2 */ +} + |