mxs: Reset the EMI block on mx23
Subsystems (6)
PATCH 1/13 mxs: Reset the EMI block on mx23
The real reason for memory instability was the fact that the EMI block was gated and not reset throughout the boards' operation. This patch resets the EMI block properly while also reverts the memory voltage bump. The memory stability issues were caused by the EMI not being reset properly and thus there is no longer need to run the memory at higher voltage than it ought to run at.
This partly reverts 8303ed128a55519f19c5f11087032d4bc4e0537a .
--- arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c +10 -2
@@ -27,6 +27,7 @@#include <config.h> #include <asm/io.h> #include <asm/arch/imx-regs.h> +#include <asm/arch/sys_proto.h> #include <linux/compiler.h> #include "mxs_init.h"
@@ -229,7 +230,7 @@ static void mx23_mem_setup_vddmem(void)struct mxs_power_regs *power_regs = (struct mxs_power_regs *)MXS_POWER_BASE ; - writel((0x12 << POWER_VDDMEMCTRL_TRG_OFFSET) | + writel((0x10 << POWER_VDDMEMCTRL_TRG_OFFSET) | POWER_VDDMEMCTRL_ENABLE_ILIMIT | POWER_VDDMEMCTRL_ENABLE_LINREG | POWER_VDDMEMCTRL_PULLDOWN_ACTIVE,
@@ -237,13 +238,20 @@ static void mx23_mem_setup_vddmem(void)early_delay (10000 ); -writel ((0x12 <<POWER_VDDMEMCTRL_TRG_OFFSET ) | +writel ((0x10 <<POWER_VDDMEMCTRL_TRG_OFFSET ) |POWER_VDDMEMCTRL_ENABLE_LINREG , &power_regs->hw_power_vddmemctrl); }static void mx23_mem_init (void ) { +/* +* Reset/ungate the EMI block. This is essential, otherwise the system +* suffers from memory instability. This thing is mx23 specific and is +* no longer present on mx28. +*/ +mxs_reset_block ((struct mxs_register_32 *)MXS_EMI_BASE ); +mx23_mem_setup_vddmem ();/*
Signature · 1 line
1.7.10.4
PATCH 2/13 mxs: mmc: spi: dma: Better wrap the MXS differences
This patch streamlines the differences between the MX23 and MX28 by implementing a few helper functions to handle different DMA channel mapping, different clock domain for SSP block and fixes a few minor bugs.
First of all, the DMA channel mapping is now fixed in dma.h by defining the actual channel map for both MX23 and MX28. Thus, MX23 now does no longer use MX28 channel map which was wrong. Also, there is a fix for MX28 DMA channel map, where the last four channels were incorrect.
Next, because correct DMA channel map is in place, the mxs_dma_init_channel() call now bases the channel ID starting from SSP port #0. This removes the need for DMA channel offset being added and cleans up the code. For the same reason, the SSP0 offset can now be used in mxs_dma_desc_append(), thus no need to adjust dma channel number in the driver either.
Lastly, the SSP clock ID is now retrieved by calling mxs_ssp_clock_by_bus() which handles the fact that MX23 has shared SSP clock for both ports, while MX28 has per-port SSP clock.
Finally, the mxs_ssp_bus_id_valid() pulls out two implementations of the same functionality from MMC and SPI driver into common code.
--- arch/arm/cpu/arm926ejs/mxs/clock.c | 3 ++- arch/arm/include/asm/arch-mxs/dma.h | 19 ++++++++++++++++++- arch/arm/include/asm/arch-mxs/regs-ssp.h | 26 ++++++++++++++++++++++++++ drivers/mmc/mxsmmc.c | 20 ++++---------------- drivers/spi/mxs_spi.c | 4 ++-- 5 files changed, 52 insertions(+), 20 deletions(-)
arch/arm/cpu/arm926ejs/mxs/clock.c +2 -1
@@ -289,7 +289,8 @@ static uint32_t mxs_get_sspclk(enum mxs_sspclock ssp)void mxs_set_ssp_busclock (unsigned int bus,uint32_t freq) {struct mxs_ssp_regs *ssp_regs; -const uint32_t sspclk =mxs_get_sspclk (bus); +const enum mxs_sspclock clk =mxs_ssp_clock_by_bus (bus); +const uint32_t sspclk =mxs_get_sspclk (clk);uint32_t reg;uint32_t divide, rate, tgtclk;
arch/arm/include/asm/arch-mxs/dma.h +18 -1
@@ -40,6 +40,19 @@/* * MXS DMA channels */ +#if defined(CONFIG_MX23 ) +enum { +MXS_DMA_CHANNEL_AHB_APBH_LCDIF =0 , +MXS_DMA_CHANNEL_AHB_APBH_SSP0 , +MXS_DMA_CHANNEL_AHB_APBH_SSP1 , +MXS_DMA_CHANNEL_AHB_APBH_RESERVED0 , +MXS_DMA_CHANNEL_AHB_APBH_GPMI0 , +MXS_DMA_CHANNEL_AHB_APBH_GPMI1 , +MXS_DMA_CHANNEL_AHB_APBH_GPMI2 , +MXS_DMA_CHANNEL_AHB_APBH_GPMI3 , +MXS_MAX_DMA_CHANNELS , +}; +#elif defined(CONFIG_MX28 )enum {MXS_DMA_CHANNEL_AHB_APBH_SSP0 =0 , MXS_DMA_CHANNEL_AHB_APBH_SSP1,
@@ -53,9 +66,13 @@ enum {MXS_DMA_CHANNEL_AHB_APBH_GPMI5 ,MXS_DMA_CHANNEL_AHB_APBH_GPMI6 ,MXS_DMA_CHANNEL_AHB_APBH_GPMI7 , -MXS_DMA_CHANNEL_AHB_APBH_SSP , +MXS_DMA_CHANNEL_AHB_APBH_HSADC , +MXS_DMA_CHANNEL_AHB_APBH_LCDIF , +MXS_DMA_CHANNEL_AHB_APBH_RESERVED0 , +MXS_DMA_CHANNEL_AHB_APBH_RESERVED1 , MXS_MAX_DMA_CHANNELS, }; +#endif /* * MXS DMA hardware command.
arch/arm/include/asm/arch-mxs/regs-ssp.h +26 -0
@@ -74,6 +74,32 @@ struct mxs_ssp_regs { };#endif +static inline int mxs_ssp_bus_id_valid (int bus) +{ +#if defined(CONFIG_MX23 ) +const unsigned int mxs_ssp_chan_count =2 ; +#elif defined(CONFIG_MX28 ) +const unsigned int mxs_ssp_chan_count =4 ; +#endif + +if (bus >= mxs_ssp_chan_count) +return 0 ; + +if (bus <0 ) +return 0 ; + +return 1 ; +} + +static inline int mxs_ssp_clock_by_bus (unsigned int clock) +{ +#if defined(CONFIG_MX23 ) +return 0 ; +#elif defined(CONFIG_MX28 ) +return clock; +#endif +} +static inline struct mxs_ssp_regs *mxs_ssp_regs_by_bus (unsigned int port) {switch (port) {
drivers/mmc/mxsmmc.c +4 -16
@@ -53,12 +53,6 @@ struct mxsmmc_priv {struct mxs_dma_desc *desc; }; -#if defined(CONFIG_MX23 ) -static const unsigned int mxsmmc_id_offset =1 ; -#elif defined(CONFIG_MX28 ) -static const unsigned int mxsmmc_id_offset =0 ; -#endif -#define MXSMMC_MAX_TIMEOUT 10000#define MXSMMC_SMALL_TRANSFER 512
@@ -137,7 +131,7 @@ static int mxsmmc_send_cmd_dma(struct mxsmmc_priv *priv, struct mmc_data *data) priv->desc->cmd.data |=MXS_DMA_DESC_IRQ |MXS_DMA_DESC_DEC_SEM | (data_count <<MXS_DMA_DESC_BYTES_OFFSET ); - dmach =MXS_DMA_CHANNEL_AHB_APBH_SSP0 + priv->id + mxsmmc_id_offset; + dmach =MXS_DMA_CHANNEL_AHB_APBH_SSP0 + priv->id;mxs_dma_desc_append (dmach, priv->desc);if (mxs_dma_go (dmach)) {bounce_buffer_stop (&bbstate);
@@ -390,15 +384,9 @@ int mxsmmc_initialize(bd_t *bis, int id, int (*wp)(int), int (*cd)(int))struct mmc *mmc =NULL ;struct mxsmmc_priv *priv =NULL ;int ret; -#if defined(CONFIG_MX23 ) -const unsigned int mxsmmc_max_id =2 ; -const unsigned int mxsmmc_clk_id =0 ; -#elif defined(CONFIG_MX28 ) -const unsigned int mxsmmc_max_id =4 ; -const unsigned int mxsmmc_clk_id = id; -#endif +const unsigned int mxsmmc_clk_id =mxs_ssp_clock_by_bus (id); -if (id >= mxsmmc_max_id) +if (!mxs_ssp_bus_id_valid (id))return -ENODEV ; mmc =malloc (sizeof (struct mmc ));
@@ -418,7 +406,7 @@ int mxsmmc_initialize(bd_t *bis, int id, int (*wp)(int), int (*cd)(int))return -ENOMEM ; } - ret =mxs_dma_init_channel (id + mxsmmc_id_offset); + ret =mxs_dma_init_channel (MXS_DMA_CHANNEL_AHB_APBH_SSP0 + id);if (ret)return ret;
drivers/spi/mxs_spi.c +2 -2
@@ -70,7 +70,7 @@ void spi_init(void)int spi_cs_is_valid (unsigned int bus,unsigned int cs) {/* MXS SPI: 4 ports and 3 chip selects maximum */ -if (bus >3 || cs >2 ) +if (!mxs_ssp_bus_id_valid (bus) || cs >2 )return 0 ;else return 1 ;
@@ -92,7 +92,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,if (!mxs_slave)return NULL ; -if (mxs_dma_init_channel (bus)) +if (mxs_dma_init_channel (MXS_DMA_CHANNEL_AHB_APBH_SSP0 + bus)) goto err_init; mxs_slave->slave.bus = bus;
Signature · 1 line
1.7.10.4
PATCH 3/13 mxs: spi: Fix the MXS SPI for mx23
In reply to Marek VasutThe MX23 has slightly different register layout. Adjust the SPI driver to match the layout, both the PIO and DMA part.
--- drivers/spi/mxs_spi.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
drivers/spi/mxs_spi.c +17 -2
@@ -168,7 +168,12 @@ static int mxs_spi_xfer_pio(struct mxs_spi_slave *slave,while (length--) {/* We transfer 1 byte */ +#if defined(CONFIG_MX23 ) +writel (SSP_CTRL0_XFER_COUNT_MASK , &ssp_regs->hw_ssp_ctrl0_clr); +writel (1 , &ssp_regs->hw_ssp_ctrl0_set); +#elif defined(CONFIG_MX28 )writel (1 , &ssp_regs->hw_ssp_xfer_size); +#endif if ((flags &SPI_XFER_END ) && !length)mxs_spi_end_xfer (ssp_regs);
@@ -226,6 +231,12 @@ static int mxs_spi_xfer_dma(struct mxs_spi_slave *slave,int tl;int ret =0 ; +#if defined(CONFIG_MX23 ) +const int mxs_spi_pio_words =1 ; +#elif defined(CONFIG_MX28 ) +const int mxs_spi_pio_words =4 ; +#endif + ALLOC_CACHE_ALIGN_BUFFER(struct mxs_dma_desc, desc, desc_count);memset (desc,0 ,sizeof (struct mxs_dma_desc ) * desc_count);
@@ -281,7 +292,7 @@ static int mxs_spi_xfer_dma(struct mxs_spi_slave *slave, dp->cmd.data |= ((tl &0xffff ) <<MXS_DMA_DESC_BYTES_OFFSET ) | - (4 <<MXS_DMA_DESC_PIO_WORDS_OFFSET ) | + (mxs_spi_pio_words <<MXS_DMA_DESC_PIO_WORDS_OFFSET ) |MXS_DMA_DESC_HALT_ON_TERMINATE |MXS_DMA_DESC_TERMINATE_FLUSH ;
@@ -298,15 +309,19 @@ static int mxs_spi_xfer_dma(struct mxs_spi_slave *slave, }/* -* Write CTRL0, CMD0, CMD1, XFER_SIZE registers. It is +* Write CTRL0, CMD0, CMD1 and XFER_SIZE registers in +* case of MX28, write only CTRL0 in case of MX23 due +* to the difference in register layout. It is utterly * essential that the XFER_SIZE register is written on * a per-descriptor basis with the same size as is the * descriptor! */ dp->cmd.pio_words[0 ] = ctrl0; +#ifdef CONFIG_MX28 dp->cmd.pio_words[1 ] =0 ; dp->cmd.pio_words[2 ] =0 ; dp->cmd.pio_words[3 ] = tl; +#endif mxs_dma_desc_append (dmach, dp);
Signature · 1 line
1.7.10.4
PATCH 3/13 mxs: spi: Fix the MXS SPI for mx23
Quoted 4 lines · Marek Vasut
The MX23 has slightly different register layout. Adjust the SPI driver to match the layout, both the PIO and DMA part.
Signed-off-by Marek Vasut <[email protected]>
What the changes from v1?
Signature · 3 lines
Otavio Salvador O.S. Systems E-mail: otavio at ossystems.com.br http://www.ossystems.com.br Mobile: +55 53 9981-7854 http://projetos.ossystems.com.br
PATCH 3/13 mxs: spi: Fix the MXS SPI for mx23
Dear Otavio Salvador,
Quoted 7 lines · Marek Vasut
Quoted 4 lines
The MX23 has slightly different register layout. Adjust the SPI driver to match the layout, both the PIO and DMA part.
Signed-off-by Marek Vasut <[email protected]>What the changes from v1?
Same applies to 01/13, this is V1.
Best regards,
Marek Vasut
PATCH 4/13 mxs: spi: Remove CONFIG_MXS_SPI_DMA_ENABLE
In reply to Marek VasutThe CONFIG_MXS_SPI_DMA_ENABLE is no longer relevant as the SPI DMA has proven to work correctly. Remove this configuration option.
--- drivers/spi/mxs_spi.c | 16 ---------------- include/configs/m28evk.h | 1 - include/configs/mx28evk.h | 1 - 3 files changed, 18 deletions(-)
drivers/spi/mxs_spi.c +0 -16
@@ -40,17 +40,6 @@#define MXSSSP_SMALL_TRANSFER 512 -/* -* CONFIG_MXS_SPI_DMA_ENABLE: Experimental mixed PIO/DMA support for MXS SPI -* host. Use with utmost caution! -* -* Enabling this is not yet recommended since this -* still doesn't support transfers to/from unaligned -* addresses. Therefore this driver will not work -* for example with saving environment. This is -* caused by DMA alignment constraints on MXS. -*/ -struct mxs_spi_slave {struct spi_slave slave;uint32_t max_khz;
@@ -347,12 +336,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen,char dummy;int write =0 ;char *data =NULL ; - -#ifdef CONFIG_MXS_SPI_DMA_ENABLE int dma =1 ; -#else -int dma =0 ; -#endif if (bitlen ==0 ) {if (flags &SPI_XFER_END ) {
include/configs/m28evk.h +0 -1
@@ -244,7 +244,6 @@#ifdef CONFIG_CMD_SPI #define CONFIG_HARD_SPI #define CONFIG_MXS_SPI -#define CONFIG_MXS_SPI_DMA_ENABLE #define CONFIG_SPI_HALF_DUPLEX #define CONFIG_DEFAULT_SPI_BUS 2#define CONFIG_DEFAULT_SPI_CS 0
include/configs/mx28evk.h +0 -1
@@ -202,7 +202,6 @@#ifdef CONFIG_CMD_SPI #define CONFIG_HARD_SPI #define CONFIG_MXS_SPI -#define CONFIG_MXS_SPI_DMA_ENABLE #define CONFIG_SPI_HALF_DUPLEX #define CONFIG_DEFAULT_SPI_BUS 2#define CONFIG_DEFAULT_SPI_MODE SPI_MODE_0
Signature · 1 line
1.7.10.4
Fabio Estevam
reviewerPATCH 4/13 mxs: spi: Remove CONFIG_MXS_SPI_DMA_ENABLE
Hi Marek,
drivers/spi/mxs_spi.c int spi_xfer(struct spi_slave *slave, unsigned int bitlen, · line 339
Quoted 3 lines · Marek Vasut
drivers/spi/mxs_spi.c +0
-2- -#ifdef CONFIG_MXS_SPI_DMA_ENABLE int dma =1 ;
Can't we get rid of the 'dma' variable now?
PATCH 4/13 mxs: spi: Remove CONFIG_MXS_SPI_DMA_ENABLE
Dear Fabio Estevam,
Quoted 9 lines
Hi Marek,
drivers/spi/mxs_spi.c int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
Quoted 4 lines · Marek Vasut
drivers/spi/mxs_spi.c +0
-2- -#ifdef CONFIG_MXS_SPI_DMA_ENABLE int dma =1 ;Can't we get rid of the 'dma' variable now?
No, we still use it for DMA switching. DMA is enabled only for aligned transfers.
Best regards,
Marek Vasut
PATCH 5/13 mxs: Squash the header file usage in ehci-mxs
In reply to Marek VasutThe ehci-mxs driver included the register definitions directly. Use imx-regs.h instead since it contains proper handling of the differences between mx23 and mx28.
--- arch/arm/include/asm/arch-mxs/imx-regs.h | 2 ++ drivers/usb/host/ehci-mxs.c | 6 +----- 2 files changed, 3 insertions(+), 5 deletions(-)
arch/arm/include/asm/arch-mxs/imx-regs.h +2 -0
@@ -36,6 +36,8 @@#include <asm/arch/regs-rtc.h> #include <asm/arch/regs-ssp.h> #include <asm/arch/regs-timrot.h> +#include <asm/arch/regs-usb.h> +#include <asm/arch/regs-usbphy.h> #ifdef CONFIG_MX23 #include <asm/arch/regs-clkctrl-mx23.h>
drivers/usb/host/ehci-mxs.c +1 -5
@@ -21,11 +21,7 @@#include <common.h> #include <asm/io.h> -#include <asm/arch/regs-common.h> -#include <asm/arch/regs-base.h> -#include <asm/arch/regs-clkctrl-mx28.h> -#include <asm/arch/regs-usb.h> -#include <asm/arch/regs-usbphy.h> +#include <asm/arch/imx-regs.h> #include "ehci.h"
Signature · 1 line
1.7.10.4
PATCH 5/13 mxs: Squash the header file usage in ehci-mxs
Quoted 5 lines · Marek Vasut
The ehci-mxs driver included the register definitions directly. Use
imx-regs.hinstead since it contains proper handling of the differences between mx23 and mx28.Signed-off-by Marek Vasut <[email protected]>
Signature · 3 lines
Otavio Salvador O.S. Systems E-mail: otavio at ossystems.com.br http://www.ossystems.com.br Mobile: +55 53 9981-7854 http://projetos.ossystems.com.br
PATCH 6/13 mxs: Make ehci-mxs multiport capable
In reply to Marek VasutRework ehci-mxs so it supports both ports on MX28. It was necessary to wrap the per-port configuration into struct ehci_mxs_port and pull out the clock configuration function.
--- drivers/usb/host/ehci-mxs.c | 149 +++++++++++++++++++++++------------------- include/configs/apx4devkit.h | 3 +- include/configs/m28evk.h | 4 +- include/configs/mx28evk.h | 3 +- include/configs/sc_sps_1.h | 3 +- 5 files changed, 90 insertions(+), 72 deletions(-)
NOTE: For MX23, just use this setup:
#define CONFIG_EHCI_MXS_PORT0
#define CONFIG_USB_MAX_CONTROLLER_COUNT 1
drivers/usb/host/ehci-mxs.c +81 -68
@@ -22,86 +22,106 @@#include <common.h> #include <asm/io.h> #include <asm/arch/imx-regs.h> +#include <errno.h> #include "ehci.h" -#if (CONFIG_EHCI_MXS_PORT !=0 ) && (CONFIG_EHCI_MXS_PORT !=1 ) -#error "MXS EHCI: Invalid port selected!" -#endif - -#ifndef CONFIG_EHCI_MXS_PORT -#error "MXS EHCI: Please define correct port using CONFIG_EHCI_MXS_PORT!" -#endif +/* This DIGCTL register ungates clock to USB */ +#define HW_DIGCTL_CTRL 0x8001c000 +#define HW_DIGCTL_CTRL_USB0_CLKGATE (1 << 2) +#define HW_DIGCTL_CTRL_USB1_CLKGATE (1 << 16) -static struct ehci_mxs { -struct mxs_usb_regs *usb_regs; +struct ehci_mxs_port { +uint32_t usb_regs;struct mxs_usbphy_regs *phy_regs; -} ehci_mxs; -int mxs_ehci_get_port (struct ehci_mxs *mxs_usb,int port) +struct mxs_register_32 *pll; +uint32_t pll_en_bits; +uint32_t pll_dis_bits; +uint32_t gate_bits; +}; + +static const struct ehci_mxs_port mxs_port[] = { +#ifdef CONFIG_EHCI_MXS_PORT0 + { +MXS_USBCTRL0_BASE , + (struct mxs_usbphy_regs *)MXS_USBPHY0_BASE , + (struct mxs_register_32 *)(MXS_CLKCTRL_BASE + + offsetof(struct mxs_clkctrl_regs , + hw_clkctrl_pll0ctrl0_reg)), +CLKCTRL_PLL0CTRL0_EN_USB_CLKS |CLKCTRL_PLL0CTRL0_POWER , +CLKCTRL_PLL0CTRL0_EN_USB_CLKS , +HW_DIGCTL_CTRL_USB0_CLKGATE , + }, +#endif +#ifdef CONFIG_EHCI_MXS_PORT1 + { +MXS_USBCTRL1_BASE , + (struct mxs_usbphy_regs *)MXS_USBPHY1_BASE , + (struct mxs_register_32 *)(MXS_CLKCTRL_BASE + + offsetof(struct mxs_clkctrl_regs , + hw_clkctrl_pll1ctrl0_reg)), +CLKCTRL_PLL1CTRL0_EN_USB_CLKS |CLKCTRL_PLL1CTRL0_POWER , +CLKCTRL_PLL1CTRL0_EN_USB_CLKS , +HW_DIGCTL_CTRL_USB1_CLKGATE , + }, +#endif +}; + +static int ehci_mxs_toggle_clock (const struct ehci_mxs_port *port,int enable) { -uint32_t usb_base, phy_base; -switch (port) { -case 0 : - usb_base =MXS_USBCTRL0_BASE ; - phy_base =MXS_USBPHY0_BASE ; -break ; -case 1 : - usb_base =MXS_USBCTRL1_BASE ; - phy_base =MXS_USBPHY1_BASE ; -break ; -default : -printf ("CONFIG_EHCI_MXS_PORT (port = %d)\n" , port); -return -1 ; +struct mxs_register_32 *digctl_ctrl = + (struct mxs_register_32 *)HW_DIGCTL_CTRL ; +int pll_offset, dig_offset; + +if (enable) { + pll_offset = offsetof(struct mxs_register_32 , reg_set); + dig_offset = offsetof(struct mxs_register_32 , reg_clr); +writel (port->gate_bits, (u32 )&digctl_ctrl->reg + dig_offset); +writel (port->pll_en_bits, (u32 )port->pll + pll_offset); + }else { + pll_offset = offsetof(struct mxs_register_32 , reg_clr); + dig_offset = offsetof(struct mxs_register_32 , reg_set); +writel (port->pll_dis_bits, (u32 )port->pll + pll_offset); +writel (port->gate_bits, (u32 )&digctl_ctrl->reg + dig_offset); } - mxs_usb->usb_regs = (struct mxs_usb_regs *)usb_base; - mxs_usb->phy_regs = (struct mxs_usbphy_regs *)phy_base;return 0 ; } -/* This DIGCTL register ungates clock to USB */ -#define HW_DIGCTL_CTRL 0x8001c000 -#define HW_DIGCTL_CTRL_USB0_CLKGATE (1 << 2) -#define HW_DIGCTL_CTRL_USB1_CLKGATE (1 << 16) -int ehci_hcd_init (int index,struct ehci_hccr **hccr,struct ehci_hcor **hcor) {int ret;uint32_t usb_base, cap_base; -struct mxs_register_32 *digctl_ctrl = - (struct mxs_register_32 *)HW_DIGCTL_CTRL ; -struct mxs_clkctrl_regs *clkctrl_regs = - (struct mxs_clkctrl_regs *)MXS_CLKCTRL_BASE ; +const struct ehci_mxs_port *port; - ret =mxs_ehci_get_port (&ehci_mxs,CONFIG_EHCI_MXS_PORT ); -if (ret) -return ret; +if ((index <0 ) || (index >=ARRAY_SIZE (mxs_port))) { +printf ("Invalid port index (index = %d)!\n" , index); +return -EINVAL ; + } + + port = &mxs_port[index];/* Reset the PHY block */ -writel (USBPHY_CTRL_SFTRST , &ehci_mxs.phy_regs->hw_usbphy_ctrl_set); +writel (USBPHY_CTRL_SFTRST , &port->phy_regs->hw_usbphy_ctrl_set);udelay (10 );writel (USBPHY_CTRL_SFTRST |USBPHY_CTRL_CLKGATE , - &ehci_mxs.phy_regs->hw_usbphy_ctrl_clr); + &port->phy_regs->hw_usbphy_ctrl_clr);/* Enable USB clock */ -writel (CLKCTRL_PLL0CTRL0_EN_USB_CLKS |CLKCTRL_PLL0CTRL0_POWER , - &clkctrl_regs->hw_clkctrl_pll0ctrl0_set); -writel (CLKCTRL_PLL1CTRL0_EN_USB_CLKS |CLKCTRL_PLL1CTRL0_POWER , - &clkctrl_regs->hw_clkctrl_pll1ctrl0_set); - -writel (HW_DIGCTL_CTRL_USB0_CLKGATE |HW_DIGCTL_CTRL_USB1_CLKGATE , - &digctl_ctrl->reg_clr); + ret =ehci_mxs_toggle_clock (port,1 ); +if (ret) +return ret;/* Start USB PHY */ -writel (0 , &ehci_mxs.phy_regs->hw_usbphy_pwd); +writel (0 , &port->phy_regs->hw_usbphy_pwd);/* Enable UTMI+ Level 2 and Level 3 compatibility */ writel (USBPHY_CTRL_ENUTMILEVEL3 |USBPHY_CTRL_ENUTMILEVEL2 |1 , - &ehci_mxs.phy_regs->hw_usbphy_ctrl_set); + &port->phy_regs->hw_usbphy_ctrl_set); - usb_base = ((uint32_t )ehci_mxs.usb_regs) +0x100 ; + usb_base = port->usb_regs +0x100 ; *hccr = (struct ehci_hccr *)usb_base; cap_base =ehci_readl (&(*hccr)->cr_capbase);
@@ -114,19 +134,19 @@ int ehci_hcd_stop(int index) {int ret;uint32_t usb_base, cap_base, tmp; -struct mxs_register_32 *digctl_ctrl = - (struct mxs_register_32 *)HW_DIGCTL_CTRL ; -struct mxs_clkctrl_regs *clkctrl_regs = - (struct mxs_clkctrl_regs *)MXS_CLKCTRL_BASE ;struct ehci_hccr *hccr;struct ehci_hcor *hcor; +const struct ehci_mxs_port *port; - ret =mxs_ehci_get_port (&ehci_mxs,CONFIG_EHCI_MXS_PORT ); -if (ret) -return ret; +if ((index <0 ) || (index >=ARRAY_SIZE (mxs_port))) { +printf ("Invalid port index (index = %d)!\n" , index); +return -EINVAL ; + } + + port = &mxs_port[index];/* Stop the USB port */ - usb_base = ((uint32_t )ehci_mxs.usb_regs) +0x100 ; + usb_base = port->usb_regs +0x100 ; hccr = (struct ehci_hccr *)usb_base; cap_base =ehci_readl (&hccr->cr_capbase); hcor = (struct ehci_hcor *)(usb_base +HC_LENGTH (cap_base));
@@ -140,17 +160,10 @@ int ehci_hcd_stop(int index)USBPHY_PWD_RXPWD1PT1 |USBPHY_PWD_RXPWDENV |USBPHY_PWD_TXPWDV2I |USBPHY_PWD_TXPWDIBIAS |USBPHY_PWD_TXPWDFS ; -writel (tmp, &ehci_mxs.phy_regs->hw_usbphy_pwd); +writel (tmp, &port->phy_regs->hw_usbphy_pwd);/* Disable USB clock */ -writel (CLKCTRL_PLL0CTRL0_EN_USB_CLKS , - &clkctrl_regs->hw_clkctrl_pll0ctrl0_clr); -writel (CLKCTRL_PLL1CTRL0_EN_USB_CLKS , - &clkctrl_regs->hw_clkctrl_pll1ctrl0_clr); + ret =ehci_mxs_toggle_clock (port,0 ); -/* Gate off the USB clock */ -writel (HW_DIGCTL_CTRL_USB0_CLKGATE |HW_DIGCTL_CTRL_USB1_CLKGATE , - &digctl_ctrl->reg_set); - -return 0 ; +return ret; }
include/configs/apx4devkit.h +2 -1
@@ -183,7 +183,8 @@#ifdef CONFIG_CMD_USB #define CONFIG_USB_EHCI #define CONFIG_USB_EHCI_MXS -#define CONFIG_EHCI_MXS_PORT 1 +#define CONFIG_EHCI_MXS_PORT1 +#define CONFIG_USB_MAX_CONTROLLER_COUNT 1#define CONFIG_EHCI_IS_TDI #define CONFIG_USB_STORAGE #endif
include/configs/m28evk.h +3 -1
@@ -233,7 +233,9 @@#ifdef CONFIG_CMD_USB #define CONFIG_USB_EHCI #define CONFIG_USB_EHCI_MXS -#define CONFIG_EHCI_MXS_PORT 1 +#define CONFIG_EHCI_MXS_PORT0 +#define CONFIG_EHCI_MXS_PORT1 +#define CONFIG_USB_MAX_CONTROLLER_COUNT 2#define CONFIG_EHCI_IS_TDI #define CONFIG_USB_STORAGE #endif
include/configs/mx28evk.h +2 -1
@@ -181,7 +181,8 @@#ifdef CONFIG_CMD_USB #define CONFIG_USB_EHCI #define CONFIG_USB_EHCI_MXS -#define CONFIG_EHCI_MXS_PORT 1 +#define CONFIG_EHCI_MXS_PORT1 +#define CONFIG_USB_MAX_CONTROLLER_COUNT 1#define CONFIG_EHCI_IS_TDI #define CONFIG_USB_STORAGE #define CONFIG_USB_HOST_ETHER
include/configs/sc_sps_1.h +2 -1
@@ -171,7 +171,8 @@#ifdef CONFIG_CMD_USB #define CONFIG_USB_EHCI #define CONFIG_USB_EHCI_MXS -#define CONFIG_EHCI_MXS_PORT 0 +#define CONFIG_EHCI_MXS_PORT0 +#define CONFIG_USB_MAX_CONTROLLER_COUNT 1#define CONFIG_EHCI_IS_TDI #define CONFIG_USB_STORAGE #endif
Signature · 1 line
1.7.10.4
PATCH 6/13 mxs: Make ehci-mxs multiport capable
Quoted 5 lines · Marek Vasut
Rework ehci-mxs so it supports both ports on MX28. It was necessary to wrap the per-port configuration into struct
ehci_mxs_portand pull out the clock configuration function.Signed-off-by Marek Vasut <[email protected]>
I couldn't test it yet but it is much nicer than my version :-)
Will give it a try ...
Signature · 3 lines
Otavio Salvador O.S. Systems E-mail: otavio at ossystems.com.br http://www.ossystems.com.br Mobile: +55 53 9981-7854 http://projetos.ossystems.com.br
PATCH 7/13 mxs: m28: Enable power to USB port 0
In reply to Marek VasutThe USB port 0 can now be used alongside the USB port 1, thus enable power to it.
--- board/denx/m28evk/m28evk.c | 4 ++++ 1 file changed, 4 insertions(+)
board/denx/m28evk/m28evk.c +4 -0
@@ -57,6 +57,10 @@ int board_early_init_f(void)mxs_iomux_setup_pad (MX28_PAD_AUART3_TX__GPIO_3_13 |MXS_PAD_12MA |MXS_PAD_3V3 |MXS_PAD_PULLUP );gpio_direction_output (MX28_PAD_AUART3_TX__GPIO_3_13 ,0 ); + +mxs_iomux_setup_pad (MX28_PAD_AUART3_RX__GPIO_3_12 | +MXS_PAD_12MA |MXS_PAD_3V3 |MXS_PAD_PULLUP ); +gpio_direction_output (MX28_PAD_AUART3_RX__GPIO_3_12 ,0 );#endif return 0 ;
Signature · 1 line
1.7.10.4
PATCH 8/13 mxs: Rename CONFIG_SPL_MX28_PSWITCH_WAIT to CONFIG_SPL_MXS_PSWITCH_WAIT
In reply to Marek VasutFrom: Otavio Salvador <[email protected]>
The power switch option is compatible with i.MX23 and i.MX28 so the configration option needs to reflect it. We choose 'CONFIG_SPL_MXS_PSWITCH_WAIT' for the option name.
--- arch/arm/cpu/arm926ejs/mxs/mxs_init.h | 2 +- arch/arm/cpu/arm926ejs/mxs/spl_power_init.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/cpu/arm926ejs/mxs/mxs_init.h +1 -1
@@ -30,7 +30,7 @@ void early_delay(int delay);void mxs_power_init (void ); -#ifdef CONFIG_SPL_MX28_PSWITCH_WAIT +#ifdef CONFIG_SPL_MXS_PSWITCH_WAIT void mxs_power_wait_pswitch (void );#else static inline void mxs_power_wait_pswitch (void ) { }
arch/arm/cpu/arm926ejs/mxs/spl_power_init.c +1 -1
@@ -921,7 +921,7 @@ void mxs_power_init(void)early_delay (1000 ); } -#ifdef CONFIG_SPL_MX28_PSWITCH_WAIT +#ifdef CONFIG_SPL_MXS_PSWITCH_WAIT void mxs_power_wait_pswitch (void ) { struct mxs_power_regs *power_regs =
Signature · 1 line
1.7.10.4
PATCH 9/13 mx23: Document the tRAS lockout setting in memory initialization
In reply to Marek VasutFrom: Otavio Salvador <[email protected]>
Add a comment about the tRAS lockout setting of HW_DRAM_CTL08 to enable the 'Fast Auto Pre-Charge' found in the memory chip. The setting is applied after memory initialization and it is worth document it.
--- arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c +4 -0
@@ -120,6 +120,10 @@ static void initialize_dram_values(void)writel (dram_vals[i],MXS_DRAM_BASE + (4 * i));#ifdef CONFIG_MX23 +/* +* Enable tRAS lockout in HW_DRAM_CTL08 ; it must be the last +* element to be set +*/ writel ((1 <<24 ),MXS_DRAM_BASE + (4 *8 ));#endif }
Signature · 1 line
1.7.10.4
PATCH 10/13 mx23evk: Adjust DRAM control register to use full 128MB of RAM
In reply to Marek VasutFrom: Otavio Salvador <[email protected]>
Adjust HW_DRAM_CTL14 to enable the chip selects to allow usage of full 128MB of RAM.
--- board/freescale/mx23evk/spl_boot.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
board/freescale/mx23evk/spl_boot.c +10 -0
@@ -98,6 +98,16 @@ const iomux_cfg_t iomux_setup[] = { (MXS_PAD_4MA | MXS_PAD_3V3 | MXS_PAD_NOPULL), }; +#define HW_DRAM_CTL14 (0x38 >> 2) +#define CS_MAP 0x3 +#define INTAREF 0x2 +#define HW_DRAM_CTL14_CONFIG (INTAREF << 8 | CS_MAP) + +void mxs_adjust_memory_params (uint32_t *dram_vals) +{ + dram_vals[HW_DRAM_CTL14 ] =HW_DRAM_CTL14_CONFIG ; +} +void board_init_ll (void ) {mxs_common_spl_init (iomux_setup,ARRAY_SIZE (iomux_setup));
Signature · 1 line
1.7.10.4
PATCH 11/13 led: Use STATUS_LED_ON and STATUS_LED_OFF when calling __led_set
In reply to Marek VasutFrom: Otavio Salvador <[email protected]>
This fixes the gpio_led driver which needs to compare againt a STATUS_LED_ON to enable a led.
--- common/cmd_led.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
common/cmd_led.c +4 -2
@@ -110,13 +110,15 @@ int do_led (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])if (led_commands[i].on) led_commands[i].on ();else -__led_set (led_commands[i].mask,1 ); +__led_set (led_commands[i].mask, +STATUS_LED_ON );break ;case LED_OFF :if (led_commands[i].off) led_commands[i].off ();else -__led_set (led_commands[i].mask,0 ); +__led_set (led_commands[i].mask, +STATUS_LED_OFF );break ;case LED_TOGGLE :if (led_commands[i].toggle)
Signature · 1 line
1.7.10.4
PATCH 12/13 mxs: Fix iomux.h to not break build during assembly stage
In reply to Marek VasutFrom: Otavio Salvador <[email protected]>
This fixes the build failure when included in mx23_olinuxino.h board config; the addition of "asm/types.h" is due "u32" being otherwise undefined.
--- arch/arm/include/asm/arch-mxs/iomux.h | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm/include/asm/arch-mxs/iomux.h +5 -0
@@ -21,6 +21,10 @@#ifndef __MACH_MXS_IOMUX_H__#define __MACH_MXS_IOMUX_H__ +#ifndef __ASSEMBLY__ + +#include <asm/types.h> +/* * IOMUX/PAD Bit field definitions *
@@ -165,4 +169,5 @@ int mxs_iomux_setup_pad(iomux_cfg_t pad);*/ int mxs_iomux_setup_multiple_pads (const iomux_cfg_t *pad_list,unsigned count); +#endif /* __ASSEMBLY__ */ #endif /* __MACH_MXS_IOMUX_H__*/
Signature · 1 line
1.7.10.4
PATCH 13/13 mx23_olinuxino: Add support for status LED
In reply to Marek VasutFrom: Otavio Salvador <[email protected]>
This allow user to know if the bootloader is running, even without a serial console.
--- board/olimex/mx23_olinuxino/mx23_olinuxino.c | 7 +++++++ board/olimex/mx23_olinuxino/spl_boot.c | 4 ++++ include/configs/mx23_olinuxino.h | 14 ++++++++++++++ 3 files changed, 25 insertions(+)
board/olimex/mx23_olinuxino/mx23_olinuxino.c +7 -0
@@ -28,6 +28,9 @@#include <asm/arch/imx-regs.h> #include <asm/arch/clock.h> #include <asm/arch/sys_proto.h> +#ifdef CONFIG_STATUS_LED +#include <status_led.h> +#endif DECLARE_GLOBAL_DATA_PTR ;
@@ -67,5 +70,9 @@ int board_init(void)/* Adress of boot parameters */ gd->bd->bi_boot_params =PHYS_SDRAM_1 +0x100 ; +#if defined(CONFIG_STATUS_LED ) && defined(STATUS_LED_BOOT ) +status_led_set (STATUS_LED_BOOT ,STATUS_LED_STATE ); +#endif +return 0 ; }
board/olimex/mx23_olinuxino/spl_boot.c +4 -0
@@ -84,6 +84,10 @@ const iomux_cfg_t iomux_setup[] = {MX23_PAD_EMI_RASN__EMI_RASN |MUX_CONFIG_EMI ,MX23_PAD_EMI_WEN__EMI_WEN |MUX_CONFIG_EMI , +/* Green LED */ +MX23_PAD_SSP1_DETECT__GPIO_2_1 | + (MXS_PAD_3V3 |MXS_PAD_4MA |MXS_PAD_NOPULL ), +/* MMC 0 */ MX23_PAD_SSP1_CMD__SSP1_CMD |MUX_CONFIG_SSP , MX23_PAD_SSP1_DATA0__SSP1_DATA0 | MUX_CONFIG_SSP,
include/configs/mx23_olinuxino.h +14 -0
@@ -19,6 +19,8 @@#ifndef __MX23_OLINUXINO_CONFIG_H__#define __MX23_OLINUXINO_CONFIG_H__ +#include <asm/arch/iomux-mx23.h> +/* * SoC configurations */
@@ -56,6 +58,7 @@#define CONFIG_CMD_EXT2 #define CONFIG_CMD_FAT #define CONFIG_CMD_GPIO +#define CONFIG_CMD_LED #define CONFIG_CMD_MMC /*
@@ -112,6 +115,17 @@#define CONFIG_BAUDRATE 115200/* Default baud rate */ /* +* Status LED +*/ +#define CONFIG_STATUS_LED +#define CONFIG_GPIO_LED +#define CONFIG_BOARD_SPECIFIC_LED +#define STATUS_LED_BOOT 0 +#define STATUS_LED_BIT MX23_PAD_SSP1_DETECT__GPIO_2_1 +#define STATUS_LED_STATE STATUS_LED_ON +#define STATUS_LED_PERIOD (CONFIG_SYS_HZ / 2) + +/* * MMC Driver */ #ifdef CONFIG_CMD_MMC
Signature · 1 line
1.7.10.4
PATCH 1/13 mxs: Reset the EMI block on mx23
In reply to Marek VasutQuoted 10 lines · Marek Vasut
The real reason for memory instability was the fact that the EMI block was gated and not reset throughout the boards' operation. This patch resets the EMI block properly while also reverts the memory voltage bump. The memory stability issues were caused by the EMI not being reset properly and thus there is no longer need to run the memory at higher voltage than it ought to run at.
This partly reverts
8303ed128a55519f19c5f11087032d4bc4e0537a.Signed-off-by Marek Vasut <[email protected]>
What the changes from v1? Last time I tested it, it broke mx23evk as it made it fail in mtest.
Signature · 3 lines
Otavio Salvador O.S. Systems E-mail: otavio at ossystems.com.br http://www.ossystems.com.br Mobile: +55 53 9981-7854 http://projetos.ossystems.com.br
PATCH 1/13 mxs: Reset the EMI block on mx23
Dear Otavio Salvador,
Quoted 8 lines · Marek Vasut
Quoted 7 lines
The real reason for memory instability was the fact that the EMI block was gated and not reset throughout the boards' operation. This patch resets the EMI block properly while also reverts the memory voltage bump. The memory stability issues were caused by the EMI not being reset properly and thus there is no longer need to run the memory at higher voltage than it ought to run at.
Quoted 6 lines
Quoted 3 lines
This partly reverts
8303ed128a55519f19c5f11087032d4bc4e0537a.Signed-off-by Marek Vasut <[email protected]>What the changes from v1? Last time I tested it, it broke mx23evk as it made it fail in mtest.
The MX23EVK reboots unconditionally when I attempt mtest with or without this patch.
And there's no previous version, this patch is V1. The stuff sent before shall be ignored.
Best regards,
Marek Vasut
PATCH 1/13 mxs: Reset the EMI block on mx23
Quoted 12 lines · Marek Vasut
Dear Otavio Salvador,
Quoted 10 lines · Marek Vasut
Quoted 9 lines
The real reason for memory instability was the fact that the EMI block was gated and not reset throughout the boards' operation. This patch resets the EMI block properly while also reverts the memory voltage bump. The memory stability issues were caused by the EMI not being reset properly and thus there is no longer need to run the memory at higher voltage than it ought to run at.
This partly reverts
8303ed128a55519f19c5f11087032d4bc4e0537a.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Marek Vasut <[email protected]>What the changes from v1? Last time I tested it, it broke mx23evk as it made it fail in mtest.
The MX23EVK reboots unconditionally when I attempt mtest with or without this patch.
Here it works fine.
Quoted 2 lines
And there's no previous version, this patch is V1. The stuff sent before shall be ignored.
So does it change something from initial post?
Signature · 3 lines
Otavio Salvador O.S. Systems E-mail: otavio at ossystems.com.br http://www.ossystems.com.br Mobile: +55 53 9981-7854 http://projetos.ossystems.com.br
PATCH 1/13 mxs: Reset the EMI block on mx23
Dear Otavio Salvador,
Quoted 21 lines · Marek Vasut
Quoted 12 lines
Dear Otavio Salvador,
Quoted 10 lines · Marek Vasut
Quoted 9 lines
The real reason for memory instability was the fact that the EMI block was gated and not reset throughout the boards' operation. This patch resets the EMI block properly while also reverts the memory voltage bump. The memory stability issues were caused by the EMI not being reset properly and thus there is no longer need to run the memory at higher voltage than it ought to run at.
This partly reverts
8303ed128a55519f19c5f11087032d4bc4e0537a.Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Marek Vasut <[email protected]>What the changes from v1? Last time I tested it, it broke mx23evk as it made it fail in mtest.
The MX23EVK reboots unconditionally when I attempt mtest with or without this patch.
Quoted 6 lines
Here it works fine.
Quoted 2 lines
And there's no previous version, this patch is V1. The stuff sent before shall be ignored.
So does it change something from initial post?
I do not know, that's why this is V1.
Best regards,
Marek Vasut
PATCH 1/13 mxs: Reset the EMI block on mx23
In reply to Otavio SalvadorDear Otavio Salvador,
Quoted 8 lines · Marek Vasut
Quoted 7 lines
The real reason for memory instability was the fact that the EMI block was gated and not reset throughout the boards' operation. This patch resets the EMI block properly while also reverts the memory voltage bump. The memory stability issues were caused by the EMI not being reset properly and thus there is no longer need to run the memory at higher voltage than it ought to run at.
Quoted 6 lines
Quoted 3 lines
This partly reverts
8303ed128a55519f19c5f11087032d4bc4e0537a.Signed-off-by Marek Vasut <[email protected]>What the changes from v1? Last time I tested it, it broke mx23evk as it made it fail in mtest.
I just tested this on MX23EVK, I detect no problem.
Best regards,
Marek Vasut
PATCH 1/13 mxs: Reset the EMI block on mx23
In reply to Marek VasutQuoted 7 lines · Marek Vasut
The real reason for memory instability was the fact that the EMI block was gated and not reset throughout the boards' operation. This patch resets the EMI block properly while also reverts the memory voltage bump. The memory stability issues were caused by the EMI not being reset properly and thus there is no longer need to run the memory at higher voltage than it ought to run at.
Quoted 7 lines
This partly reverts
8303ed128a55519f19c5f11087032d4bc4e0537a.Signed-off-by Marek Vasut <[email protected]>Cc Fabio Estevam <[email protected]>Cc Otavio Salvador <[email protected]>Cc Stefano Babic <[email protected]>---
Applied (whole series) to u-boot-imx, thanks.
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================