From 661edaafd44c6a7001a95d3a93a7dc03acc18a39 Mon Sep 17 00:00:00 2001 From: Andreas Wass Date: Wed, 14 Aug 2013 23:45:03 +0200 Subject: ARM: mxs: Added application UART driver The driver makes it possible to use an application UART as the U-Boot output console for Freescale i.MX23/i.MX28 devices. Signed-off-by: Andreas Wass Cc: Fabio Estevam Cc: Marek Vasut Acked-by: Marek Vasut --- drivers/serial/Makefile | 1 + drivers/serial/mxs_auart.c | 151 +++++++++++++++++++++++++++++++++++++++++++++ drivers/serial/serial.c | 2 + 3 files changed, 154 insertions(+) create mode 100644 drivers/serial/mxs_auart.c (limited to 'drivers') diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile index 697f2bb4e8d..4c45bfa363f 100644 --- a/drivers/serial/Makefile +++ b/drivers/serial/Makefile @@ -38,6 +38,7 @@ COBJS-$(CONFIG_SCIF_CONSOLE) += serial_sh.o COBJS-$(CONFIG_ZYNQ_SERIAL) += serial_zynq.o COBJS-$(CONFIG_BFIN_SERIAL) += serial_bfin.o COBJS-$(CONFIG_FSL_LPUART) += serial_lpuart.o +COBJS-$(CONFIG_MXS_AUART) += mxs_auart.o ifndef CONFIG_SPL_BUILD COBJS-$(CONFIG_USB_TTY) += usbtty.o diff --git a/drivers/serial/mxs_auart.c b/drivers/serial/mxs_auart.c new file mode 100644 index 00000000000..7cfe5bccf73 --- /dev/null +++ b/drivers/serial/mxs_auart.c @@ -0,0 +1,151 @@ +/* + * Freescale i.MX23/i.MX28 AUART driver + * + * Copyright (C) 2013 Andreas Wass + * + * Based on the MXC serial driver: + * + * (c) 2007 Sascha Hauer + * + * Further based on the Linux mxs-auart.c driver: + * + * Freescale STMP37XX/STMP38X Application UART drkiver + * Copyright 2008-2010 Freescale Semiconductor, Inc. + * + * SPDX-License-Identifier: GPL-2.0+ + */ +#include +#include +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +#ifndef CONFIG_MXS_AUART_BASE +#error "CONFIG_MXS_AUART_BASE must be set to the base UART to use" +#endif + +/* AUART clock always supplied by XTAL and always 24MHz */ +#define MXS_AUART_CLK 24000000 + +static struct mxs_uartapp_regs *get_uartapp_registers(void) +{ + return (struct mxs_uartapp_regs *)CONFIG_MXS_AUART_BASE; +} + +/** + * Sets the baud rate and settings. + * The settings are: 8 data bits, no parit and 1 stop bit. + */ +void mxs_auart_setbrg(void) +{ + u32 div; + u32 linectrl = 0; + struct mxs_uartapp_regs *regs = get_uartapp_registers(); + + if (!gd->baudrate) + gd->baudrate = CONFIG_BAUDRATE; + + /* + * From i.MX28 datasheet: + * div is calculated by calculating UARTCLK*32/baudrate, rounded to int + * div must be between 0xEC and 0x003FFFC0 inclusive + * Lowest 6 bits of div goes in BAUD_DIVFRAC part of LINECTRL register + * Next 16 bits goes in BAUD_DIVINT part of LINECTRL register + */ + div = (MXS_AUART_CLK * 32) / gd->baudrate; + if (div < 0xEC || div > 0x003FFFC0) + return; + + linectrl |= ((div & UARTAPP_LINECTRL_EXTRACT_BAUD_DIVFRAC_MASK) << + UARTAPP_LINECTRL_BAUD_DIVFRAC_OFFSET) & + UARTAPP_LINECTRL_BAUD_DIVFRAC_MASK; + linectrl |= ((div >> UARTAPP_LINECTRL_EXTRACT_BAUD_DIVINT_OFFSET) << + UARTAPP_LINECTRL_BAUD_DIVINT_OFFSET) & + UARTAPP_LINECTRL_BAUD_DIVINT_MASK; + + /* Word length: 8 bits */ + linectrl |= UARTAPP_LINECTRL_WLEN_8BITS; + + /* Enable FIFOs. */ + linectrl |= UARTAPP_LINECTRL_FEN_MASK; + + /* Write above settings, no parity, 1 stop bit */ + writel(linectrl, ®s->hw_uartapp_linectrl); +} + +int mxs_auart_init(void) +{ + struct mxs_uartapp_regs *regs = get_uartapp_registers(); + /* Reset everything */ + mxs_reset_block(®s->hw_uartapp_ctrl0_reg); + /* Disable interrupts */ + writel(0, ®s->hw_uartapp_intr); + /* Set baud rate and settings */ + serial_setbrg(); + /* Disable RTS and CTS, ignore LINECTRL2 register */ + writel(UARTAPP_CTRL2_RTSEN_MASK | + UARTAPP_CTRL2_CTSEN_MASK | + UARTAPP_CTRL2_USE_LCR2_MASK, + ®s->hw_uartapp_ctrl2_clr); + /* Enable receiver, transmitter and UART */ + writel(UARTAPP_CTRL2_RXE_MASK | + UARTAPP_CTRL2_TXE_MASK | + UARTAPP_CTRL2_UARTEN_MASK, + ®s->hw_uartapp_ctrl2_set); + return 0; +} + +void mxs_auart_putc(const char c) +{ + struct mxs_uartapp_regs *regs = get_uartapp_registers(); + /* Wait in loop while the transmit FIFO is full */ + while (readl(®s->hw_uartapp_stat) & UARTAPP_STAT_TXFF_MASK) + ; + + writel(c, ®s->hw_uartapp_data); + + if (c == '\n') + mxs_auart_putc('\r'); +} + +int mxs_auart_tstc(void) +{ + struct mxs_uartapp_regs *regs = get_uartapp_registers(); + /* Checks if receive FIFO is empty */ + return !(readl(®s->hw_uartapp_stat) & UARTAPP_STAT_RXFE_MASK); +} + +int mxs_auart_getc(void) +{ + struct mxs_uartapp_regs *regs = get_uartapp_registers(); + /* Wait until a character is available to read */ + while (!mxs_auart_tstc()) + ; + /* Read the character from the data register */ + return readl(®s->hw_uartapp_data) & 0xFF; +} + +static struct serial_device mxs_auart_drv = { + .name = "mxs_auart_serial", + .start = mxs_auart_init, + .stop = NULL, + .setbrg = mxs_auart_setbrg, + .putc = mxs_auart_putc, + .puts = default_serial_puts, + .getc = mxs_auart_getc, + .tstc = mxs_auart_tstc, +}; + +void mxs_auart_initialize(void) +{ + serial_register(&mxs_auart_drv); +} + +__weak struct serial_device *default_serial_console(void) +{ + return &mxs_auart_drv; +} diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c index 67301355d7d..336ff357211 100644 --- a/drivers/serial/serial.c +++ b/drivers/serial/serial.c @@ -159,6 +159,7 @@ serial_initfunc(pl01x_serial_initialize); serial_initfunc(s3c44b0_serial_initialize); serial_initfunc(sa1100_serial_initialize); serial_initfunc(sh_serial_initialize); +serial_initfunc(mxs_auart_initialize); /** * serial_register() - Register serial driver with serial driver core @@ -251,6 +252,7 @@ void serial_initialize(void) s3c44b0_serial_initialize(); sa1100_serial_initialize(); sh_serial_initialize(); + mxs_auart_initialize(); serial_assign(default_serial_console()->name); } -- cgit v1.2.3 From ddb636bd66f527e6680faed5a6adced69836517d Mon Sep 17 00:00:00 2001 From: Eric Nelson Date: Fri, 2 Aug 2013 10:37:00 -0700 Subject: fec_mxc: set ethaddr if fuses burned and not previously set Without this change, the following message is generated: Warning: FEC using MAC address from net device See doc/README.enetaddr for details. Signed-off-by: Eric Nelson --- drivers/net/fec_mxc.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c index e14a3598ca3..690e5724b4e 100644 --- a/drivers/net/fec_mxc.c +++ b/drivers/net/fec_mxc.c @@ -980,6 +980,8 @@ static int fec_probe(bd_t *bd, int dev_id, uint32_t base_addr, if (fec_get_hwaddr(edev, dev_id, ethaddr) == 0) { debug("got MAC%d address from fuse: %pM\n", dev_id, ethaddr); memcpy(edev->enetaddr, ethaddr, 6); + if (!getenv("ethaddr")) + eth_setenv_enetaddr("ethaddr", ethaddr); } return ret; err3: -- cgit v1.2.3 From 49b0415a80474eeb7876dede868c65764d6e973a Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Thu, 1 Aug 2013 16:21:00 +0200 Subject: mmc: mxsmmc: Enable MMC HC support Enable support for high-capacity eMMC and MMC cards. The MXS MMC driver has no problem with those. Signed-off-by: Marek Vasut Signed-off-by: Amaury Pouly Cc: Andy Fleming Cc: Fabio Estevam Cc: Stefano Babic Cc: Otavio Salvador Reviewed-by: Otavio Salvador --- drivers/mmc/mxsmmc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/mmc/mxsmmc.c b/drivers/mmc/mxsmmc.c index e5a5d7532c9..245f9d0c672 100644 --- a/drivers/mmc/mxsmmc.c +++ b/drivers/mmc/mxsmmc.c @@ -410,7 +410,8 @@ int mxsmmc_initialize(bd_t *bis, int id, int (*wp)(int), int (*cd)(int)) mmc->voltages = MMC_VDD_32_33 | MMC_VDD_33_34; mmc->host_caps = MMC_MODE_4BIT | MMC_MODE_8BIT | - MMC_MODE_HS_52MHz | MMC_MODE_HS; + MMC_MODE_HS_52MHz | MMC_MODE_HS | + MMC_MODE_HC; /* * SSPCLK = 480 * 18 / 29 / 1 = 297.731 MHz -- cgit v1.2.3