diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2013-07-09 13:01:00 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-07-23 16:25:13 +0200 |
commit | ca13a84ac2580d8507f292b469751a919af60411 (patch) | |
tree | 8cc52c2a7520bdd0d1f0b8c8175e4862503abc77 /arch/arm | |
parent | 66891566ccf72c19c3c25182f98eda4dc2a8ad3e (diff) | |
download | barebox-ca13a84ac2580d8507f292b469751a919af60411.tar.gz barebox-ca13a84ac2580d8507f292b469751a919af60411.tar.xz |
ARM: MXS: introduce stmp device support
MXS specific devices have some common infrastructure in the kernel
known as STMP devices. We have the same in barebox, but with a
mxs_ prefix instead of a stmp_ prefix. As some STMP devices are
also found on i.MX6 move the common infrastructure out of MXS
specific files and use the stmp_ prefix.
This is done in preparation for i.MX6 NAND support.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/mach-mxs/Kconfig | 2 | ||||
-rw-r--r-- | arch/arm/mach-mxs/Makefile | 2 | ||||
-rw-r--r-- | arch/arm/mach-mxs/common.c | 64 | ||||
-rw-r--r-- | arch/arm/mach-mxs/imx.c | 3 | ||||
-rw-r--r-- | arch/arm/mach-mxs/include/mach/imx-regs.h | 5 | ||||
-rw-r--r-- | arch/arm/mach-mxs/include/mach/mxs.h | 6 | ||||
-rw-r--r-- | arch/arm/mach-mxs/iomux-imx.c | 27 | ||||
-rw-r--r-- | arch/arm/mach-mxs/ocotp.c | 9 | ||||
-rw-r--r-- | arch/arm/mach-mxs/power.c | 5 |
9 files changed, 29 insertions, 94 deletions
diff --git a/arch/arm/mach-mxs/Kconfig b/arch/arm/mach-mxs/Kconfig index d1bf8fcbe6..128bf84e49 100644 --- a/arch/arm/mach-mxs/Kconfig +++ b/arch/arm/mach-mxs/Kconfig @@ -24,11 +24,13 @@ choice config ARCH_IMX23 bool "i.MX23" + select STMP_DEVICE select CPU_ARM926T config ARCH_IMX28 bool "i.MX28" select CPU_ARM926T + select STMP_DEVICE select ARCH_HAS_FEC_IMX endchoice diff --git a/arch/arm/mach-mxs/Makefile b/arch/arm/mach-mxs/Makefile index a183987285..bd6892ed22 100644 --- a/arch/arm/mach-mxs/Makefile +++ b/arch/arm/mach-mxs/Makefile @@ -1,4 +1,4 @@ -obj-y += imx.o iomux-imx.o power.o common.o +obj-y += imx.o iomux-imx.o power.o obj-$(CONFIG_ARCH_IMX23) += clocksource-imx23.o usb-imx23.o soc-imx23.o obj-$(CONFIG_ARCH_IMX28) += clocksource-imx28.o usb-imx28.o soc-imx28.o obj-$(CONFIG_MXS_OCOTP) += ocotp.o diff --git a/arch/arm/mach-mxs/common.c b/arch/arm/mach-mxs/common.c deleted file mode 100644 index 122d88362b..0000000000 --- a/arch/arm/mach-mxs/common.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Freescale i.MXS common code - * - * Copyright (C) 2012 Wolfram Sang <w.sang@pengutronix.de> - * - * Based on code from LTIB: - * Copyright (C) 2010 Freescale Semiconductor, Inc. - * - * 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. - */ - -#include <common.h> -#include <io.h> -#include <errno.h> -#include <clock.h> -#include <mach/mxs.h> -#include <mach/imx-regs.h> - -#define MXS_IP_RESET_TIMEOUT (10 * MSECOND) - -#define MXS_BLOCK_SFTRST (1 << 31) -#define MXS_BLOCK_CLKGATE (1 << 30) - -int mxs_reset_block(void __iomem *reg, int just_enable) -{ - /* Clear SFTRST */ - writel(MXS_BLOCK_SFTRST, reg + BIT_CLR); - - if (wait_on_timeout(MXS_IP_RESET_TIMEOUT, !(readl(reg) & MXS_BLOCK_SFTRST))) - goto timeout; - - /* Clear CLKGATE */ - writel(MXS_BLOCK_CLKGATE, reg + BIT_CLR); - - if (!just_enable) { - /* Set SFTRST */ - writel(MXS_BLOCK_SFTRST, reg + BIT_SET); - - /* Wait for CLKGATE being set */ - if (wait_on_timeout(MXS_IP_RESET_TIMEOUT, readl(reg) & MXS_BLOCK_CLKGATE)) - goto timeout; - } - - /* Clear SFTRST */ - writel(MXS_BLOCK_SFTRST, reg + BIT_CLR); - - if (wait_on_timeout(MXS_IP_RESET_TIMEOUT, !(readl(reg) & MXS_BLOCK_SFTRST))) - goto timeout; - - /* Clear CLKGATE */ - writel(MXS_BLOCK_CLKGATE, reg + BIT_CLR); - - if (wait_on_timeout(MXS_IP_RESET_TIMEOUT, !(readl(reg) & MXS_BLOCK_CLKGATE))) - goto timeout; - - return 0; - -timeout: - printf("MXS: Timeout resetting block via register 0x%p\n", reg); - return -ETIMEDOUT; -} diff --git a/arch/arm/mach-mxs/imx.c b/arch/arm/mach-mxs/imx.c index 9f195e4dd3..b7247b9b72 100644 --- a/arch/arm/mach-mxs/imx.c +++ b/arch/arm/mach-mxs/imx.c @@ -19,6 +19,7 @@ #include <complete.h> #include <init.h> #include <io.h> +#include <stmp-device.h> #include <mach/generic.h> #include <mach/imx-regs.h> @@ -39,7 +40,7 @@ static int imx_reset_usb_bootstrap(void) * To prevent this (and boot from the configured bootsource instead) * clear this bit here. */ - writel(0x2, IMX_WDT_BASE + HW_RTC_PERSISTENT1 + BIT_CLR); + writel(0x2, IMX_WDT_BASE + HW_RTC_PERSISTENT1 + STMP_OFFSET_REG_CLR); return 0; } diff --git a/arch/arm/mach-mxs/include/mach/imx-regs.h b/arch/arm/mach-mxs/include/mach/imx-regs.h index 39c97b7705..f5abd8bf79 100644 --- a/arch/arm/mach-mxs/include/mach/imx-regs.h +++ b/arch/arm/mach-mxs/include/mach/imx-regs.h @@ -16,11 +16,6 @@ #ifndef _IMX_REGS_H # define _IMX_REGS_H -/* Note: Some registers do not support this bit change feature! */ -#define BIT_SET 0x04 -#define BIT_CLR 0x08 -#define BIT_TGL 0x0C - #if defined CONFIG_ARCH_IMX23 # include <mach/imx23-regs.h> #endif diff --git a/arch/arm/mach-mxs/include/mach/mxs.h b/arch/arm/mach-mxs/include/mach/mxs.h deleted file mode 100644 index 182ed8a998..0000000000 --- a/arch/arm/mach-mxs/include/mach/mxs.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __MACH_MXS_H -#define __MACH_MXS_H - -int mxs_reset_block(void __iomem *reg, int just_enable); - -#endif /* __MACH_MXS_H */ diff --git a/arch/arm/mach-mxs/iomux-imx.c b/arch/arm/mach-mxs/iomux-imx.c index 66ba74309d..3d26302d4c 100644 --- a/arch/arm/mach-mxs/iomux-imx.c +++ b/arch/arm/mach-mxs/iomux-imx.c @@ -18,6 +18,7 @@ #include <gpio.h> #include <errno.h> #include <io.h> +#include <stmp-device.h> #include <mach/imx-regs.h> #define HW_PINCTRL_CTRL 0x000 @@ -112,22 +113,24 @@ void imx_gpio_mode(uint32_t m) reg_offset = calc_strength_reg(gpio_pin); if (GET_VOLTAGE(m) == 1) writel(0x1 << (((gpio_pin % 8) << 2) + 2), - IMX_IOMUXC_BASE + reg_offset + BIT_SET); + IMX_IOMUXC_BASE + reg_offset + STMP_OFFSET_REG_SET); else writel(0x1 << (((gpio_pin % 8) << 2) + 2), - IMX_IOMUXC_BASE + reg_offset + BIT_CLR); + IMX_IOMUXC_BASE + reg_offset + STMP_OFFSET_REG_CLR); } if (PE_PRESENT(m)) { reg_offset = calc_pullup_reg(gpio_pin); writel(0x1 << (gpio_pin % 32), IMX_IOMUXC_BASE + reg_offset + - (GET_PULLUP(m) == 1 ? BIT_SET : BIT_CLR)); + (GET_PULLUP(m) == 1 ? + STMP_OFFSET_REG_SET : STMP_OFFSET_REG_CLR)); } if (BK_PRESENT(m)) { reg_offset = calc_pullup_reg(gpio_pin); writel(0x1 << (gpio_pin % 32), IMX_IOMUXC_BASE + reg_offset + - (GET_BITKEEPER(m) == 1 ? BIT_CLR : BIT_SET)); + (GET_BITKEEPER(m) == 1 ? + STMP_OFFSET_REG_CLR : STMP_OFFSET_REG_SET)); } if (GET_FUNC(m) == IS_GPIO) { @@ -135,16 +138,17 @@ void imx_gpio_mode(uint32_t m) /* first set the output value */ reg_offset = calc_output_reg(gpio_pin); writel(0x1 << (gpio_pin % 32), IMX_IOMUXC_BASE + - reg_offset + (GET_GPIOVAL(m) == 1 ? BIT_SET : BIT_CLR)); + reg_offset + (GET_GPIOVAL(m) == 1 ? + STMP_OFFSET_REG_SET : STMP_OFFSET_REG_CLR)); /* then the direction */ reg_offset = calc_output_enable_reg(gpio_pin); writel(0x1 << (gpio_pin % 32), - IMX_IOMUXC_BASE + reg_offset + BIT_SET); + IMX_IOMUXC_BASE + reg_offset + STMP_OFFSET_REG_SET); } else { /* then the direction */ reg_offset = calc_output_enable_reg(gpio_pin); writel(0x1 << (gpio_pin % 32), - IMX_IOMUXC_BASE + reg_offset + BIT_CLR); + IMX_IOMUXC_BASE + reg_offset + STMP_OFFSET_REG_CLR); } } } @@ -157,7 +161,7 @@ int gpio_direction_input(unsigned gpio) return -EINVAL; reg_offset = calc_output_enable_reg(gpio); - writel(0x1 << (gpio % 32), IMX_IOMUXC_BASE + reg_offset + BIT_CLR); + writel(0x1 << (gpio % 32), IMX_IOMUXC_BASE + reg_offset + STMP_OFFSET_REG_CLR); return 0; } @@ -172,10 +176,10 @@ int gpio_direction_output(unsigned gpio, int val) /* first set the output value... */ reg_offset = calc_output_reg(gpio); writel(0x1 << (gpio % 32), IMX_IOMUXC_BASE + - reg_offset + (val != 0 ? BIT_SET : BIT_CLR)); + reg_offset + (val != 0 ? STMP_OFFSET_REG_SET : STMP_OFFSET_REG_CLR)); /* ...then the direction */ reg_offset = calc_output_enable_reg(gpio); - writel(0x1 << (gpio % 32), IMX_IOMUXC_BASE + reg_offset + BIT_SET); + writel(0x1 << (gpio % 32), IMX_IOMUXC_BASE + reg_offset + STMP_OFFSET_REG_SET); return 0; } @@ -186,7 +190,8 @@ void gpio_set_value(unsigned gpio, int val) reg_offset = calc_output_reg(gpio); writel(0x1 << (gpio % 32), IMX_IOMUXC_BASE + - reg_offset + (val != 0 ? BIT_SET : BIT_CLR)); + reg_offset + (val != 0 ? + STMP_OFFSET_REG_SET : STMP_OFFSET_REG_CLR)); } int gpio_get_value(unsigned gpio) diff --git a/arch/arm/mach-mxs/ocotp.c b/arch/arm/mach-mxs/ocotp.c index 6bfa3e2d96..59c3b8a095 100644 --- a/arch/arm/mach-mxs/ocotp.c +++ b/arch/arm/mach-mxs/ocotp.c @@ -20,6 +20,7 @@ #include <fcntl.h> #include <malloc.h> #include <io.h> +#include <stmp-device.h> #include <clock.h> #include <linux/clk.h> #include <linux/err.h> @@ -75,13 +76,13 @@ static ssize_t mxs_ocotp_cdev_read(struct cdev *cdev, void *buf, size_t count, */ /* try to clear ERROR bit */ - writel(OCOTP_CTRL_ERROR, base + OCOTP_CTRL + BIT_CLR); + writel(OCOTP_CTRL_ERROR, base + OCOTP_CTRL + STMP_OFFSET_REG_CLR); if (mxs_ocotp_wait_busy(priv)) return -ETIMEDOUT; /* open OCOTP banks for read */ - writel(OCOTP_CTRL_RD_BANK_OPEN, base + OCOTP_CTRL + BIT_SET); + writel(OCOTP_CTRL_RD_BANK_OPEN, base + OCOTP_CTRL + STMP_OFFSET_REG_SET); /* approximately wait 32 hclk cycles */ udelay(1); @@ -96,7 +97,7 @@ static ssize_t mxs_ocotp_cdev_read(struct cdev *cdev, void *buf, size_t count, (((i + offset) & 0xfc) << 2) + ((i + offset) & 3)); /* close banks for power saving */ - writel(OCOTP_CTRL_RD_BANK_OPEN, base + OCOTP_CTRL + BIT_CLR); + writel(OCOTP_CTRL_RD_BANK_OPEN, base + OCOTP_CTRL + STMP_OFFSET_REG_CLR); return size; } @@ -139,7 +140,7 @@ static ssize_t mxs_ocotp_cdev_write(struct cdev *cdev, const void *buf, size_t c clk_set_rate(priv->clk, 24000000); imx_set_vddio(2800000); - writel(OCOTP_CTRL_RD_BANK_OPEN, base + OCOTP_CTRL + BIT_CLR); + writel(OCOTP_CTRL_RD_BANK_OPEN, base + OCOTP_CTRL + STMP_OFFSET_REG_CLR); if (mxs_ocotp_wait_busy(priv)) { ret = -ETIMEDOUT; diff --git a/arch/arm/mach-mxs/power.c b/arch/arm/mach-mxs/power.c index f4d0b9e3e6..74c5479f3e 100644 --- a/arch/arm/mach-mxs/power.c +++ b/arch/arm/mach-mxs/power.c @@ -11,6 +11,7 @@ */ #include <common.h> #include <io.h> +#include <stmp-device.h> #include <errno.h> #include <mach/imx-regs.h> @@ -72,11 +73,11 @@ void imx_power_prepare_usbphy(void) * Set these bits so that we can force the OTG bits high * so the ARC core operates properly */ - writel(POWER_CTRL_CLKGATE, POWER_CTRL + BIT_CLR); + writel(POWER_CTRL_CLKGATE, POWER_CTRL + STMP_OFFSET_REG_CLR); writel(POWER_DEBUG_VBUSVALIDPIOLOCK | POWER_DEBUG_AVALIDPIOLOCK | - POWER_DEBUG_BVALIDPIOLOCK, POWER_DEBUG + BIT_SET); + POWER_DEBUG_BVALIDPIOLOCK, POWER_DEBUG + STMP_OFFSET_REG_SET); reg = readl(POWER_STS); reg |= POWER_STS_BVALID | POWER_STS_AVALID | POWER_STS_VBUSVALID; |