Commit b1277b2a authored by Alexander Potashev's avatar Alexander Potashev

RT74765. twr-k60n512: the very basic port

Stubs for twr-k60n512 port.

The `.kinetis_flash_conf` section is necessary to keep the MCU flash
unprotected and allow future flash programming.

This port does not work, because the Watchdog Timer is not unlocked and
the MCU is reset by WDT shortly after start-up.
parent 869efa44
......@@ -3214,6 +3214,9 @@ stm3220g-eval_config : unconfig
ea-lpc1788_config : unconfig
@$(MKCONFIG) $(@:_config=) arm arm_cortexm3 ea-lpc1788 nxp lpc178x
twr-k60n512_config : unconfig
@$(MKCONFIG) $(@:_config=) arm arm_cortexm3 twr-k60n512 freescale kinetis
#########################################################################
## XScale Systems
#########################################################################
......
#
# (C) Copyright 2011
#
# Alexander Potashev, Emcraft Systems, aspotashev@emcraft.com
#
# See file CREDITS for list of people who contributed to this
# project.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
include $(TOPDIR)/config.mk
LIB = $(obj)lib$(BOARD).a
COBJS := board.o
SRCS := $(COBJS:.o=.c)
OBJS := $(addprefix $(obj),$(COBJS))
$(LIB): $(obj).depend $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
clean:
rm -f $(OBJS)
distclean: clean
rm -f $(LIB) core *.bak $(obj).depend
#########################################################################
# defines $(obj).depend target
include $(SRCTREE)/rules.mk
sinclude $(obj).depend
/*
* (C) Copyright 2011
*
* Alexander Potashev, Emcraft Systems, aspotashev@emcraft.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
/*
* Board specific code for the Freescale TWR-K60N512 board
*/
#include <common.h>
DECLARE_GLOBAL_DATA_PTR;
/*
* Early hardware init.
*/
int board_init(void)
{
/* TBD */
return 0;
}
/*
* Dump pertinent info to the console.
*/
int checkboard(void)
{
printf("Board: Freescale TWR-K60N512 rev %s\n",
CONFIG_SYS_BOARD_REV_STR);
return 0;
}
/*
* Configure board specific parts.
*/
int misc_init_r(void)
{
/* TBD */
return 0;
}
/*
* Setup external RAM.
*/
int dram_init(void)
{
/* TBD */
return 0;
}
......@@ -60,6 +60,8 @@ int arch_cpu_init(void)
gd->bd->bi_arch_number = MACH_TYPE_STM32;
#elif defined(CONFIG_SYS_LPC178X)
gd->bd->bi_arch_number = MACH_TYPE_LPC178X;
#elif defined(CONFIG_SYS_KINETIS)
gd->bd->bi_arch_number = MACH_TYPE_KINETIS;
#else
# error "Unsupported Cortex-M3 SOC."
#endif
......
#
# (C) Copyright 2000-2003
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
#
# (C) Copyright 2011
# Port to Freescale Kinetis
# Alexander Potashev, Emcraft Systems, aspotashev@emcraft.com.
#
# See file CREDITS for list of people who contributed to this
# project.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
include $(TOPDIR)/config.mk
LIB = $(obj)lib$(SOC).a
COBJS := clock.o cpu.o envm.o wdt.o
SOBJS :=
SRCS := $(COBJS:.o=.c)
OBJS := $(addprefix $(obj),$(COBJS))
SOBJS := $(addprefix $(obj),$(SOBJS))
$(LIB): $(obj).depend $(OBJS) $(SOBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
clean:
rm -f $(SOBJS) $(OBJS)
distclean:
rm -f $(LIB) core *.bak $(obj).depend
#########################################################################
# defines $(obj).depend target
include $(SRCTREE)/rules.mk
sinclude $(obj).depend
#########################################################################
/*
* (C) Copyright 2011
*
* Alexander Potashev, Emcraft Systems, aspotashev@emcraft.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#include <common.h>
#include "clock.h"
/*
* Clock values
*/
static u32 clock_val[CLOCK_END];
/*
* Initialize the reference clocks.
*/
void clock_init(void)
{
/*
* TBD
*/
return;
}
/*
* Return a clock value for the specified clock.
*
* @param clck id of the clock
* @returns frequency of the clock
*/
unsigned long clock_get(enum clock clck)
{
return clock_val[clck];
}
/*
* (C) Copyright 2011
*
* Alexander Potashev, Emcraft Systems, aspotashev@emcraft.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#include <common.h>
#include <asm/arch/kinetis.h>
#include "clock.h"
/*
* Print the CPU specific information
*/
int print_cpuinfo(void)
{
printf("CPU : %s\n", "Freescale Kinetis series (Cortex-M4)");
return 0;
}
/*
* (C) Copyright 2011
*
* Alexander Potashev, Emcraft Systems, aspotashev@emcraft.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#include <common.h>
#include "envm.h"
/*
* The Flash Configuration Field must be present in the image and
* occupy addresses 0x00000400 to 0x0000040f.
*/
struct kinetis_flash_conf {
u8 backdoor_key[8]; /* Backdoor Comparison Key */
u8 fprot[4]; /* Program flash protection bytes */
u8 fsec; /* Flash security byte */
u8 fopt; /* Flash nonvolatile option byte */
u8 feprot; /* FlexNVM: EEPROM protection byte */
u8 fdprot; /* FlexNVM: Data flash protection byte */
};
/*
* Program Flash Protection Registers
*/
#define KINETIS_FLASH_CONF_FPROT_UNPROTECTED 0xFF
/*
* Data Flash Protection Register
*/
#define KINETIS_FLASH_CONF_FDPROT_UNPROTECTED 0xFF
/*
* EEPROM Protection Register
*/
#define KINETIS_FLASH_CONF_FEPROT_UNPROTECTED 0xFF
/*
* Flash Option Register
*/
#define KINETIS_FLASH_CONF_FOPT_EZPORT_BIT 1
#define KINETIS_FLASH_CONF_FOPT_EZPORT_EN \
(1 << KINETIS_FLASH_CONF_FOPT_EZPORT_BIT)
#define KINETIS_FLASH_CONF_FOPT_LPBOOT_BIT 0
#define KINETIS_FLASH_CONF_FOPT_LPBOOT_NORMAL \
(1 << KINETIS_FLASH_CONF_FOPT_LPBOOT_BIT)
/*
* EEPROM Protection Register
*/
#define KINETIS_FLASH_CONF_FEPROT_UNPROTECTED 0xFF
/*
* Flash Security Register
*/
/* Backdoor Key Security Enable */
#define KINETIS_FLASH_CONF_FSEC_KEYEN_BITS 6
#define KINETIS_FLASH_CONF_FSEC_KEYEN_DISABLE \
(3 << KINETIS_FLASH_CONF_FSEC_KEYEN_BITS)
/* Mass Erase Enable */
#define KINETIS_FLASH_CONF_FSEC_MEEN_BITS 4
#define KINETIS_FLASH_CONF_FSEC_MEEN_ENABLE \
(3 << KINETIS_FLASH_CONF_FSEC_MEEN_BITS)
/* Freescale Failure Analysis Access */
#define KINETIS_FLASH_CONF_FSEC_FSLACC_BITS 2
#define KINETIS_FLASH_CONF_FSEC_FSLACC_GRANTED \
(3 << KINETIS_FLASH_CONF_FSEC_FSLACC_BITS)
/* Flash Security */
#define KINETIS_FLASH_CONF_FSEC_SEC_BITS 0
#define KINETIS_FLASH_CONF_FSEC_SEC_UNSECURE \
(2 << KINETIS_FLASH_CONF_FSEC_SEC_BITS)
/*
* This is an invalid backdoor key. But we will not secure the MCU and
* therefore will not have to use the backdoor key to unsecure it.
*/
#define KINETIS_FLASH_CONF_BACKDOOR_KEY {0xFF, 0xFF, 0xFF, 0xFF, \
0xFF, 0xFF, 0xFF, 0xFF}
/*
* All 32 flash regions are unprotected
*/
#define KINETIS_FLASH_CONF_FPROT \
{KINETIS_FLASH_CONF_FPROT_UNPROTECTED, \
KINETIS_FLASH_CONF_FPROT_UNPROTECTED, \
KINETIS_FLASH_CONF_FPROT_UNPROTECTED, \
KINETIS_FLASH_CONF_FPROT_UNPROTECTED}
/*
* Disable chip lockout
*/
#define KINETIS_FLASH_CONF_FSEC \
(KINETIS_FLASH_CONF_FSEC_KEYEN_DISABLE | \
KINETIS_FLASH_CONF_FSEC_MEEN_ENABLE | \
KINETIS_FLASH_CONF_FSEC_FSLACC_GRANTED | \
KINETIS_FLASH_CONF_FSEC_SEC_UNSECURE) \
/*
* Enable EzPort.
* Disable low-power boot.
*/
#define KINETIS_FLASH_CONF_FOPT \
(KINETIS_FLASH_CONF_FOPT_EZPORT_EN | \
KINETIS_FLASH_CONF_FOPT_LPBOOT_NORMAL)
/*
* FlexRAM is unprotected
*/
#define KINETIS_FLASH_CONF_FEPROT KINETIS_FLASH_CONF_FEPROT_UNPROTECTED
/*
* Data Flash is unprotected
*/
#define KINETIS_FLASH_CONF_FDPROT KINETIS_FLASH_CONF_FDPROT_UNPROTECTED
const struct kinetis_flash_conf kinetis_flash_conf
__attribute__((section(".kinetis_flash_conf"), used)) = {
.backdoor_key = KINETIS_FLASH_CONF_BACKDOOR_KEY,
.fprot = KINETIS_FLASH_CONF_FPROT,
.fsec = KINETIS_FLASH_CONF_FSEC,
.fopt = KINETIS_FLASH_CONF_FOPT,
.feprot = KINETIS_FLASH_CONF_FEPROT,
.fdprot = KINETIS_FLASH_CONF_FDPROT
};
/*
* Initialize internal Flash interface
*/
void envm_init(void)
{
/*
* TBD
*/
return;
}
/*
* Write a data buffer to internal Flash.
* Note that we need for this function to reside in RAM since it
* will be used to self-upgrade U-boot in internal Flash.
*/
unsigned int __attribute__((section(".ramcode")))
__attribute__ ((long_call))
envm_write(unsigned int offset, void * buf, unsigned int size)
{
/*
* TBD
*/
return 0;
}
/*
* (C) Copyright 2011
*
* Alexander Potashev, Emcraft Systems, aspotashev@emcraft.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#include <common.h>
#include "wdt.h"
/*
* Strobe the WDT.
*/
void wdt_strobe(void)
{
/*
* TBD
*/
return;
}
/*
* Disable the WDT.
*/
void wdt_disable(void)
{
/*
* TBD
*/
return;
}
/*
* Enable the WDT.
*/
void wdt_enable(void)
{
/*
* TBD
*/
return;
}
......@@ -44,6 +44,15 @@ SECTIONS
*(.vectors)
} >NVM
/*
* This section is only necessary for Freescale Kinetis. For other MCUs,
* this section will be empty and the linker will drop it.
*/
.kinetis_flash_conf 0x00000400 :
{
KEEP(*(.kinetis_flash_conf))
} >NVM
.text :
{
*(.text)
......
......@@ -53,6 +53,7 @@ COBJS-$(CONFIG_S3C44B0_SERIAL) += serial_s3c44b0.o
COBJS-$(CONFIG_XILINX_UARTLITE) += serial_xuartlite.o
COBJS-$(CONFIG_SCIF_CONSOLE) += serial_sh.o
COBJS-$(CONFIG_STM32_USART_CONSOLE) += stm32_usart.o
COBJS-$(CONFIG_KINETIS_UART_CONSOLE) += kinetis_uart.o
COBJS-$(CONFIG_USB_TTY) += usbtty.o
COBJS := $(sort $(COBJS-y))
......
/*
* (C) Copyright 2011
*
* Alexander Potashev, Emcraft Systems, aspotashev@emcraft.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
/*
* Freescale Kinetis UART driver
*/
#include <common.h>
/*
* Initialize the serial port.
*/
int serial_init(void)
{
/*
* TBD
*/
return 0;
}
/*
* Set new baudrate.
*/
void serial_setbrg(void)
{
/*
* TBD
*/
return;
}
/*
* Read a single character from the serial port.
*/
int serial_getc(void)
{
/*
* TBD
*/
return 0;
}
/*
* Put a single character to the serial port.
*/
void serial_putc(const char c)
{
/*
* TBD
*/
return;
}
/*
* Put a string ('\0'-terminated) to the serial port.
*/
void serial_puts(const char *s)
{
while (*s)
serial_putc(*s++);
}
/*
* Test whether a character in in the RX buffer.
*/
int serial_tstc(void)
{
/*
* TBD
*/
return 0;
}