2012-03-31 20:26:57 +07:00
|
|
|
/*
|
|
|
|
* Copyright 2012 Freescale Semiconductor, Inc.
|
|
|
|
* Copyright 2012 Linaro Ltd.
|
|
|
|
*
|
|
|
|
* The code contained herein is licensed under the GNU General Public
|
|
|
|
* License. You may obtain a copy of the GNU General Public License
|
|
|
|
* Version 2 or later at the following locations:
|
|
|
|
*
|
|
|
|
* http://www.opensource.org/licenses/gpl-license.html
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/clk.h>
|
2013-03-29 12:36:05 +07:00
|
|
|
#include <linux/clk/mxs.h>
|
2012-03-31 20:26:57 +07:00
|
|
|
#include <linux/clkdev.h>
|
2013-03-25 13:53:08 +07:00
|
|
|
#include <linux/clocksource.h>
|
2013-07-31 21:07:59 +07:00
|
|
|
#include <linux/clk-provider.h>
|
2012-07-13 13:15:34 +07:00
|
|
|
#include <linux/delay.h>
|
2012-03-31 20:26:57 +07:00
|
|
|
#include <linux/err.h>
|
2012-07-13 13:15:34 +07:00
|
|
|
#include <linux/gpio.h>
|
2012-03-31 20:26:57 +07:00
|
|
|
#include <linux/init.h>
|
2013-03-25 20:34:51 +07:00
|
|
|
#include <linux/irqchip/mxs.h>
|
2013-07-09 06:01:40 +07:00
|
|
|
#include <linux/reboot.h>
|
2012-07-07 22:12:03 +07:00
|
|
|
#include <linux/micrel_phy.h>
|
2013-03-29 08:45:31 +07:00
|
|
|
#include <linux/of_address.h>
|
2012-03-31 20:26:57 +07:00
|
|
|
#include <linux/of_platform.h>
|
2012-07-07 22:12:03 +07:00
|
|
|
#include <linux/phy.h>
|
2012-07-13 13:15:34 +07:00
|
|
|
#include <linux/pinctrl/consumer.h>
|
2013-06-04 20:18:45 +07:00
|
|
|
#include <linux/sys_soc.h>
|
2012-03-31 20:26:57 +07:00
|
|
|
#include <asm/mach/arch.h>
|
2013-03-29 12:07:34 +07:00
|
|
|
#include <asm/mach/map.h>
|
2012-03-31 20:26:57 +07:00
|
|
|
#include <asm/mach/time.h>
|
2013-03-29 08:45:31 +07:00
|
|
|
#include <asm/system_misc.h>
|
2013-03-29 12:53:11 +07:00
|
|
|
|
2013-03-29 13:41:27 +07:00
|
|
|
#include "pm.h"
|
|
|
|
|
2013-03-29 12:53:11 +07:00
|
|
|
/* MXS DIGCTL SAIF CLKMUX */
|
|
|
|
#define MXS_DIGCTL_SAIF_CLKMUX_DIRECT 0x0
|
|
|
|
#define MXS_DIGCTL_SAIF_CLKMUX_CROSSINPUT 0x1
|
|
|
|
#define MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR0 0x2
|
|
|
|
#define MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR1 0x3
|
|
|
|
|
2013-06-04 20:18:45 +07:00
|
|
|
#define HW_DIGCTL_CHIPID 0x310
|
|
|
|
#define HW_DIGCTL_CHIPID_MASK (0xffff << 16)
|
|
|
|
#define HW_DIGCTL_REV_MASK 0xff
|
|
|
|
#define HW_DIGCTL_CHIPID_MX23 (0x3780 << 16)
|
|
|
|
#define HW_DIGCTL_CHIPID_MX28 (0x2800 << 16)
|
|
|
|
|
|
|
|
#define MXS_CHIP_REVISION_1_0 0x10
|
|
|
|
#define MXS_CHIP_REVISION_1_1 0x11
|
|
|
|
#define MXS_CHIP_REVISION_1_2 0x12
|
|
|
|
#define MXS_CHIP_REVISION_1_3 0x13
|
|
|
|
#define MXS_CHIP_REVISION_1_4 0x14
|
|
|
|
#define MXS_CHIP_REV_UNKNOWN 0xff
|
|
|
|
|
2013-03-29 12:53:11 +07:00
|
|
|
#define MXS_GPIO_NR(bank, nr) ((bank) * 32 + (nr))
|
|
|
|
|
|
|
|
#define MXS_SET_ADDR 0x4
|
|
|
|
#define MXS_CLR_ADDR 0x8
|
|
|
|
#define MXS_TOG_ADDR 0xc
|
|
|
|
|
2013-06-04 20:18:45 +07:00
|
|
|
static u32 chipid;
|
|
|
|
static u32 socid;
|
|
|
|
|
2013-08-05 15:51:14 +07:00
|
|
|
static void __iomem *reset_addr;
|
|
|
|
|
2013-03-29 12:53:11 +07:00
|
|
|
static inline void __mxs_setl(u32 mask, void __iomem *reg)
|
|
|
|
{
|
|
|
|
__raw_writel(mask, reg + MXS_SET_ADDR);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void __mxs_clrl(u32 mask, void __iomem *reg)
|
|
|
|
{
|
|
|
|
__raw_writel(mask, reg + MXS_CLR_ADDR);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void __mxs_togl(u32 mask, void __iomem *reg)
|
|
|
|
{
|
|
|
|
__raw_writel(mask, reg + MXS_TOG_ADDR);
|
|
|
|
}
|
2012-03-31 20:26:57 +07:00
|
|
|
|
2013-03-29 12:27:55 +07:00
|
|
|
#define OCOTP_WORD_OFFSET 0x20
|
|
|
|
#define OCOTP_WORD_COUNT 0x20
|
|
|
|
|
|
|
|
#define BM_OCOTP_CTRL_BUSY (1 << 8)
|
|
|
|
#define BM_OCOTP_CTRL_ERROR (1 << 9)
|
|
|
|
#define BM_OCOTP_CTRL_RD_BANK_OPEN (1 << 12)
|
|
|
|
|
|
|
|
static DEFINE_MUTEX(ocotp_mutex);
|
|
|
|
static u32 ocotp_words[OCOTP_WORD_COUNT];
|
|
|
|
|
|
|
|
static const u32 *mxs_get_ocotp(void)
|
|
|
|
{
|
|
|
|
struct device_node *np;
|
|
|
|
void __iomem *ocotp_base;
|
|
|
|
int timeout = 0x400;
|
|
|
|
size_t i;
|
|
|
|
static int once;
|
|
|
|
|
|
|
|
if (once)
|
|
|
|
return ocotp_words;
|
|
|
|
|
|
|
|
np = of_find_compatible_node(NULL, NULL, "fsl,ocotp");
|
|
|
|
ocotp_base = of_iomap(np, 0);
|
|
|
|
WARN_ON(!ocotp_base);
|
|
|
|
|
|
|
|
mutex_lock(&ocotp_mutex);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* clk_enable(hbus_clk) for ocotp can be skipped
|
|
|
|
* as it must be on when system is running.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* try to clear ERROR bit */
|
|
|
|
__mxs_clrl(BM_OCOTP_CTRL_ERROR, ocotp_base);
|
|
|
|
|
|
|
|
/* check both BUSY and ERROR cleared */
|
|
|
|
while ((__raw_readl(ocotp_base) &
|
|
|
|
(BM_OCOTP_CTRL_BUSY | BM_OCOTP_CTRL_ERROR)) && --timeout)
|
|
|
|
cpu_relax();
|
|
|
|
|
|
|
|
if (unlikely(!timeout))
|
|
|
|
goto error_unlock;
|
|
|
|
|
|
|
|
/* open OCOTP banks for read */
|
|
|
|
__mxs_setl(BM_OCOTP_CTRL_RD_BANK_OPEN, ocotp_base);
|
|
|
|
|
|
|
|
/* approximately wait 32 hclk cycles */
|
|
|
|
udelay(1);
|
|
|
|
|
|
|
|
/* poll BUSY bit becoming cleared */
|
|
|
|
timeout = 0x400;
|
|
|
|
while ((__raw_readl(ocotp_base) & BM_OCOTP_CTRL_BUSY) && --timeout)
|
|
|
|
cpu_relax();
|
|
|
|
|
|
|
|
if (unlikely(!timeout))
|
|
|
|
goto error_unlock;
|
|
|
|
|
|
|
|
for (i = 0; i < OCOTP_WORD_COUNT; i++)
|
|
|
|
ocotp_words[i] = __raw_readl(ocotp_base + OCOTP_WORD_OFFSET +
|
|
|
|
i * 0x10);
|
|
|
|
|
|
|
|
/* close banks for power saving */
|
|
|
|
__mxs_clrl(BM_OCOTP_CTRL_RD_BANK_OPEN, ocotp_base);
|
|
|
|
|
|
|
|
once = 1;
|
|
|
|
|
|
|
|
mutex_unlock(&ocotp_mutex);
|
|
|
|
|
|
|
|
return ocotp_words;
|
|
|
|
|
|
|
|
error_unlock:
|
|
|
|
mutex_unlock(&ocotp_mutex);
|
|
|
|
pr_err("%s: timeout in reading OCOTP\n", __func__);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-06-19 21:38:14 +07:00
|
|
|
enum mac_oui {
|
|
|
|
OUI_FSL,
|
|
|
|
OUI_DENX,
|
2012-10-07 09:36:28 +07:00
|
|
|
OUI_CRYSTALFONTZ,
|
2012-06-19 21:38:14 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
static void __init update_fec_mac_prop(enum mac_oui oui)
|
|
|
|
{
|
|
|
|
struct device_node *np, *from = NULL;
|
2012-07-13 13:13:55 +07:00
|
|
|
struct property *newmac;
|
2012-06-19 21:38:14 +07:00
|
|
|
const u32 *ocotp = mxs_get_ocotp();
|
|
|
|
u8 *macaddr;
|
|
|
|
u32 val;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
np = of_find_compatible_node(from, NULL, "fsl,imx28-fec");
|
|
|
|
if (!np)
|
|
|
|
return;
|
2012-09-25 18:32:18 +07:00
|
|
|
|
2012-06-19 21:38:14 +07:00
|
|
|
from = np;
|
|
|
|
|
2012-09-25 18:32:18 +07:00
|
|
|
if (of_get_property(np, "local-mac-address", NULL))
|
|
|
|
continue;
|
|
|
|
|
2012-06-19 21:38:14 +07:00
|
|
|
newmac = kzalloc(sizeof(*newmac) + 6, GFP_KERNEL);
|
|
|
|
if (!newmac)
|
|
|
|
return;
|
|
|
|
newmac->value = newmac + 1;
|
|
|
|
newmac->length = 6;
|
|
|
|
|
|
|
|
newmac->name = kstrdup("local-mac-address", GFP_KERNEL);
|
|
|
|
if (!newmac->name) {
|
|
|
|
kfree(newmac);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* OCOTP only stores the last 4 octets for each mac address,
|
|
|
|
* so hard-code OUI here.
|
|
|
|
*/
|
|
|
|
macaddr = newmac->value;
|
|
|
|
switch (oui) {
|
|
|
|
case OUI_FSL:
|
|
|
|
macaddr[0] = 0x00;
|
|
|
|
macaddr[1] = 0x04;
|
|
|
|
macaddr[2] = 0x9f;
|
|
|
|
break;
|
|
|
|
case OUI_DENX:
|
|
|
|
macaddr[0] = 0xc0;
|
|
|
|
macaddr[1] = 0xe5;
|
|
|
|
macaddr[2] = 0x4e;
|
|
|
|
break;
|
2012-10-07 09:36:28 +07:00
|
|
|
case OUI_CRYSTALFONTZ:
|
|
|
|
macaddr[0] = 0x58;
|
|
|
|
macaddr[1] = 0xb9;
|
|
|
|
macaddr[2] = 0xe1;
|
|
|
|
break;
|
2012-06-19 21:38:14 +07:00
|
|
|
}
|
|
|
|
val = ocotp[i];
|
|
|
|
macaddr[3] = (val >> 16) & 0xff;
|
|
|
|
macaddr[4] = (val >> 8) & 0xff;
|
|
|
|
macaddr[5] = (val >> 0) & 0xff;
|
|
|
|
|
2012-10-02 23:58:46 +07:00
|
|
|
of_update_property(np, newmac);
|
2012-06-19 21:38:14 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-07 20:21:38 +07:00
|
|
|
static inline void enable_clk_enet_out(void)
|
2012-03-31 20:26:57 +07:00
|
|
|
{
|
2012-07-07 20:21:38 +07:00
|
|
|
struct clk *clk = clk_get_sys("enet_out", NULL);
|
2012-03-31 20:26:57 +07:00
|
|
|
|
|
|
|
if (!IS_ERR(clk))
|
|
|
|
clk_prepare_enable(clk);
|
2012-07-07 20:21:38 +07:00
|
|
|
}
|
2012-06-19 21:38:14 +07:00
|
|
|
|
2012-07-07 20:21:38 +07:00
|
|
|
static void __init imx28_evk_init(void)
|
|
|
|
{
|
2012-06-19 21:38:14 +07:00
|
|
|
update_fec_mac_prop(OUI_FSL);
|
2012-06-25 20:21:46 +07:00
|
|
|
|
2012-08-01 10:20:16 +07:00
|
|
|
mxs_saif_clkmux_select(MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR0);
|
2012-03-31 20:26:57 +07:00
|
|
|
}
|
|
|
|
|
2012-07-07 22:12:03 +07:00
|
|
|
static int apx4devkit_phy_fixup(struct phy_device *phy)
|
|
|
|
{
|
|
|
|
phy->dev_flags |= MICREL_PHY_50MHZ_CLK;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __init apx4devkit_init(void)
|
|
|
|
{
|
|
|
|
enable_clk_enet_out();
|
|
|
|
|
|
|
|
if (IS_BUILTIN(CONFIG_PHYLIB))
|
2012-09-23 23:58:50 +07:00
|
|
|
phy_register_fixup_for_uid(PHY_ID_KSZ8051, MICREL_PHY_ID_MASK,
|
2012-07-07 22:12:03 +07:00
|
|
|
apx4devkit_phy_fixup);
|
|
|
|
}
|
|
|
|
|
2012-07-13 13:15:34 +07:00
|
|
|
#define ENET0_MDC__GPIO_4_0 MXS_GPIO_NR(4, 0)
|
|
|
|
#define ENET0_MDIO__GPIO_4_1 MXS_GPIO_NR(4, 1)
|
|
|
|
#define ENET0_RX_EN__GPIO_4_2 MXS_GPIO_NR(4, 2)
|
|
|
|
#define ENET0_RXD0__GPIO_4_3 MXS_GPIO_NR(4, 3)
|
|
|
|
#define ENET0_RXD1__GPIO_4_4 MXS_GPIO_NR(4, 4)
|
|
|
|
#define ENET0_TX_EN__GPIO_4_6 MXS_GPIO_NR(4, 6)
|
|
|
|
#define ENET0_TXD0__GPIO_4_7 MXS_GPIO_NR(4, 7)
|
|
|
|
#define ENET0_TXD1__GPIO_4_8 MXS_GPIO_NR(4, 8)
|
|
|
|
#define ENET_CLK__GPIO_4_16 MXS_GPIO_NR(4, 16)
|
|
|
|
|
|
|
|
#define TX28_FEC_PHY_POWER MXS_GPIO_NR(3, 29)
|
|
|
|
#define TX28_FEC_PHY_RESET MXS_GPIO_NR(4, 13)
|
|
|
|
#define TX28_FEC_nINT MXS_GPIO_NR(4, 5)
|
|
|
|
|
|
|
|
static const struct gpio tx28_gpios[] __initconst = {
|
|
|
|
{ ENET0_MDC__GPIO_4_0, GPIOF_OUT_INIT_LOW, "GPIO_4_0" },
|
|
|
|
{ ENET0_MDIO__GPIO_4_1, GPIOF_OUT_INIT_LOW, "GPIO_4_1" },
|
|
|
|
{ ENET0_RX_EN__GPIO_4_2, GPIOF_OUT_INIT_LOW, "GPIO_4_2" },
|
|
|
|
{ ENET0_RXD0__GPIO_4_3, GPIOF_OUT_INIT_LOW, "GPIO_4_3" },
|
|
|
|
{ ENET0_RXD1__GPIO_4_4, GPIOF_OUT_INIT_LOW, "GPIO_4_4" },
|
|
|
|
{ ENET0_TX_EN__GPIO_4_6, GPIOF_OUT_INIT_LOW, "GPIO_4_6" },
|
|
|
|
{ ENET0_TXD0__GPIO_4_7, GPIOF_OUT_INIT_LOW, "GPIO_4_7" },
|
|
|
|
{ ENET0_TXD1__GPIO_4_8, GPIOF_OUT_INIT_LOW, "GPIO_4_8" },
|
|
|
|
{ ENET_CLK__GPIO_4_16, GPIOF_OUT_INIT_LOW, "GPIO_4_16" },
|
|
|
|
{ TX28_FEC_PHY_POWER, GPIOF_OUT_INIT_LOW, "fec-phy-power" },
|
|
|
|
{ TX28_FEC_PHY_RESET, GPIOF_OUT_INIT_LOW, "fec-phy-reset" },
|
|
|
|
{ TX28_FEC_nINT, GPIOF_DIR_IN, "fec-int" },
|
|
|
|
};
|
|
|
|
|
|
|
|
static void __init tx28_post_init(void)
|
|
|
|
{
|
|
|
|
struct device_node *np;
|
|
|
|
struct platform_device *pdev;
|
|
|
|
struct pinctrl *pctl;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
enable_clk_enet_out();
|
|
|
|
|
|
|
|
np = of_find_compatible_node(NULL, NULL, "fsl,imx28-fec");
|
|
|
|
pdev = of_find_device_by_node(np);
|
|
|
|
if (!pdev) {
|
|
|
|
pr_err("%s: failed to find fec device\n", __func__);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pctl = pinctrl_get_select(&pdev->dev, "gpio_mode");
|
|
|
|
if (IS_ERR(pctl)) {
|
|
|
|
pr_err("%s: failed to get pinctrl state\n", __func__);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = gpio_request_array(tx28_gpios, ARRAY_SIZE(tx28_gpios));
|
|
|
|
if (ret) {
|
|
|
|
pr_err("%s: failed to request gpios: %d\n", __func__, ret);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Power up fec phy */
|
|
|
|
gpio_set_value(TX28_FEC_PHY_POWER, 1);
|
|
|
|
msleep(26); /* 25ms according to data sheet */
|
|
|
|
|
|
|
|
/* Mode strap pins */
|
|
|
|
gpio_set_value(ENET0_RX_EN__GPIO_4_2, 1);
|
|
|
|
gpio_set_value(ENET0_RXD0__GPIO_4_3, 1);
|
|
|
|
gpio_set_value(ENET0_RXD1__GPIO_4_4, 1);
|
|
|
|
|
|
|
|
udelay(100); /* minimum assertion time for nRST */
|
|
|
|
|
|
|
|
/* Deasserting FEC PHY RESET */
|
|
|
|
gpio_set_value(TX28_FEC_PHY_RESET, 1);
|
|
|
|
|
|
|
|
pinctrl_put(pctl);
|
|
|
|
}
|
|
|
|
|
2013-06-13 20:43:44 +07:00
|
|
|
static void __init crystalfontz_init(void)
|
2012-10-07 09:36:28 +07:00
|
|
|
{
|
|
|
|
update_fec_mac_prop(OUI_CRYSTALFONTZ);
|
|
|
|
}
|
|
|
|
|
2013-06-04 20:18:45 +07:00
|
|
|
static const char __init *mxs_get_soc_id(void)
|
2013-01-26 12:40:37 +07:00
|
|
|
{
|
2013-06-04 20:18:45 +07:00
|
|
|
struct device_node *np;
|
|
|
|
void __iomem *digctl_base;
|
|
|
|
|
|
|
|
np = of_find_compatible_node(NULL, NULL, "fsl,imx23-digctl");
|
|
|
|
digctl_base = of_iomap(np, 0);
|
|
|
|
WARN_ON(!digctl_base);
|
|
|
|
|
|
|
|
chipid = readl(digctl_base + HW_DIGCTL_CHIPID);
|
|
|
|
socid = chipid & HW_DIGCTL_CHIPID_MASK;
|
|
|
|
|
|
|
|
iounmap(digctl_base);
|
|
|
|
of_node_put(np);
|
|
|
|
|
|
|
|
switch (socid) {
|
|
|
|
case HW_DIGCTL_CHIPID_MX23:
|
|
|
|
return "i.MX23";
|
|
|
|
case HW_DIGCTL_CHIPID_MX28:
|
|
|
|
return "i.MX28";
|
|
|
|
default:
|
|
|
|
return "Unknown";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static u32 __init mxs_get_cpu_rev(void)
|
|
|
|
{
|
|
|
|
u32 rev = chipid & HW_DIGCTL_REV_MASK;
|
|
|
|
|
|
|
|
switch (socid) {
|
|
|
|
case HW_DIGCTL_CHIPID_MX23:
|
|
|
|
switch (rev) {
|
|
|
|
case 0x0:
|
|
|
|
return MXS_CHIP_REVISION_1_0;
|
|
|
|
case 0x1:
|
|
|
|
return MXS_CHIP_REVISION_1_1;
|
|
|
|
case 0x2:
|
|
|
|
return MXS_CHIP_REVISION_1_2;
|
|
|
|
case 0x3:
|
|
|
|
return MXS_CHIP_REVISION_1_3;
|
|
|
|
case 0x4:
|
|
|
|
return MXS_CHIP_REVISION_1_4;
|
|
|
|
default:
|
|
|
|
return MXS_CHIP_REV_UNKNOWN;
|
|
|
|
}
|
|
|
|
case HW_DIGCTL_CHIPID_MX28:
|
|
|
|
switch (rev) {
|
|
|
|
case 0x0:
|
|
|
|
return MXS_CHIP_REVISION_1_1;
|
|
|
|
case 0x1:
|
|
|
|
return MXS_CHIP_REVISION_1_2;
|
|
|
|
default:
|
|
|
|
return MXS_CHIP_REV_UNKNOWN;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return MXS_CHIP_REV_UNKNOWN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char __init *mxs_get_revision(void)
|
|
|
|
{
|
|
|
|
u32 rev = mxs_get_cpu_rev();
|
|
|
|
|
|
|
|
if (rev != MXS_CHIP_REV_UNKNOWN)
|
2013-08-13 20:28:02 +07:00
|
|
|
return kasprintf(GFP_KERNEL, "%d.%d", (rev >> 4) & 0xf,
|
2013-06-04 20:18:45 +07:00
|
|
|
rev & 0xf);
|
|
|
|
else
|
|
|
|
return kasprintf(GFP_KERNEL, "%s", "Unknown");
|
2013-01-26 12:40:37 +07:00
|
|
|
}
|
|
|
|
|
2013-08-05 15:51:14 +07:00
|
|
|
#define MX23_CLKCTRL_RESET_OFFSET 0x120
|
|
|
|
#define MX28_CLKCTRL_RESET_OFFSET 0x1e0
|
|
|
|
|
|
|
|
static int __init mxs_restart_init(void)
|
|
|
|
{
|
|
|
|
struct device_node *np;
|
|
|
|
|
|
|
|
np = of_find_compatible_node(NULL, NULL, "fsl,clkctrl");
|
|
|
|
reset_addr = of_iomap(np, 0);
|
|
|
|
if (!reset_addr)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
if (of_device_is_compatible(np, "fsl,imx23-clkctrl"))
|
|
|
|
reset_addr += MX23_CLKCTRL_RESET_OFFSET;
|
|
|
|
else
|
|
|
|
reset_addr += MX28_CLKCTRL_RESET_OFFSET;
|
|
|
|
of_node_put(np);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-03-31 20:26:57 +07:00
|
|
|
static void __init mxs_machine_init(void)
|
|
|
|
{
|
2013-06-04 20:18:45 +07:00
|
|
|
struct device_node *root;
|
|
|
|
struct device *parent;
|
|
|
|
struct soc_device *soc_dev;
|
|
|
|
struct soc_device_attribute *soc_dev_attr;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
|
|
|
|
if (!soc_dev_attr)
|
|
|
|
return;
|
|
|
|
|
|
|
|
root = of_find_node_by_path("/");
|
|
|
|
ret = of_property_read_string(root, "model", &soc_dev_attr->machine);
|
|
|
|
if (ret)
|
|
|
|
return;
|
|
|
|
|
|
|
|
soc_dev_attr->family = "Freescale MXS Family";
|
|
|
|
soc_dev_attr->soc_id = mxs_get_soc_id();
|
|
|
|
soc_dev_attr->revision = mxs_get_revision();
|
|
|
|
|
|
|
|
soc_dev = soc_device_register(soc_dev_attr);
|
|
|
|
if (IS_ERR(soc_dev)) {
|
|
|
|
kfree(soc_dev_attr->revision);
|
|
|
|
kfree(soc_dev_attr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
parent = soc_device_to_device(soc_dev);
|
|
|
|
|
2012-03-31 20:26:57 +07:00
|
|
|
if (of_machine_is_compatible("fsl,imx28-evk"))
|
|
|
|
imx28_evk_init();
|
2012-07-07 22:12:03 +07:00
|
|
|
else if (of_machine_is_compatible("bluegiga,apx4devkit"))
|
|
|
|
apx4devkit_init();
|
2013-06-13 20:43:44 +07:00
|
|
|
else if (of_machine_is_compatible("crystalfontz,cfa10037") ||
|
|
|
|
of_machine_is_compatible("crystalfontz,cfa10049") ||
|
2013-06-13 20:43:45 +07:00
|
|
|
of_machine_is_compatible("crystalfontz,cfa10055") ||
|
|
|
|
of_machine_is_compatible("crystalfontz,cfa10057"))
|
2013-06-13 20:43:44 +07:00
|
|
|
crystalfontz_init();
|
2012-03-31 20:26:57 +07:00
|
|
|
|
|
|
|
of_platform_populate(NULL, of_default_bus_match_table,
|
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
Pull networking updates from David Miller:
"This is a re-do of the net-next pull request for the current merge
window. The only difference from the one I made the other day is that
this has Eliezer's interface renames and the timeout handling changes
made based upon your feedback, as well as a few bug fixes that have
trickeled in.
Highlights:
1) Low latency device polling, eliminating the cost of interrupt
handling and context switches. Allows direct polling of a network
device from socket operations, such as recvmsg() and poll().
Currently ixgbe, mlx4, and bnx2x support this feature.
Full high level description, performance numbers, and design in
commit 0a4db187a999 ("Merge branch 'll_poll'")
From Eliezer Tamir.
2) With the routing cache removed, ip_check_mc_rcu() gets exercised
more than ever before in the case where we have lots of multicast
addresses. Use a hash table instead of a simple linked list, from
Eric Dumazet.
3) Add driver for Atheros CQA98xx 802.11ac wireless devices, from
Bartosz Markowski, Janusz Dziedzic, Kalle Valo, Marek Kwaczynski,
Marek Puzyniak, Michal Kazior, and Sujith Manoharan.
4) Support reporting the TUN device persist flag to userspace, from
Pavel Emelyanov.
5) Allow controlling network device VF link state using netlink, from
Rony Efraim.
6) Support GRE tunneling in openvswitch, from Pravin B Shelar.
7) Adjust SOCK_MIN_RCVBUF and SOCK_MIN_SNDBUF for modern times, from
Daniel Borkmann and Eric Dumazet.
8) Allow controlling of TCP quickack behavior on a per-route basis,
from Cong Wang.
9) Several bug fixes and improvements to vxlan from Stephen
Hemminger, Pravin B Shelar, and Mike Rapoport. In particular,
support receiving on multiple UDP ports.
10) Major cleanups, particular in the area of debugging and cookie
lifetime handline, to the SCTP protocol code. From Daniel
Borkmann.
11) Allow packets to cross network namespaces when traversing tunnel
devices. From Nicolas Dichtel.
12) Allow monitoring netlink traffic via AF_PACKET sockets, in a
manner akin to how we monitor real network traffic via ptype_all.
From Daniel Borkmann.
13) Several bug fixes and improvements for the new alx device driver,
from Johannes Berg.
14) Fix scalability issues in the netem packet scheduler's time queue,
by using an rbtree. From Eric Dumazet.
15) Several bug fixes in TCP loss recovery handling, from Yuchung
Cheng.
16) Add support for GSO segmentation of MPLS packets, from Simon
Horman.
17) Make network notifiers have a real data type for the opaque
pointer that's passed into them. Use this to properly handle
network device flag changes in arp_netdev_event(). From Jiri
Pirko and Timo Teräs.
18) Convert several drivers over to module_pci_driver(), from Peter
Huewe.
19) tcp_fixup_rcvbuf() can loop 500 times over loopback, just use a
O(1) calculation instead. From Eric Dumazet.
20) Support setting of explicit tunnel peer addresses in ipv6, just
like ipv4. From Nicolas Dichtel.
21) Protect x86 BPF JIT against spraying attacks, from Eric Dumazet.
22) Prevent a single high rate flow from overruning an individual cpu
during RX packet processing via selective flow shedding. From
Willem de Bruijn.
23) Don't use spinlocks in TCP md5 signing fast paths, from Eric
Dumazet.
24) Don't just drop GSO packets which are above the TBF scheduler's
burst limit, chop them up so they are in-bounds instead. Also
from Eric Dumazet.
25) VLAN offloads are missed when configured on top of a bridge, fix
from Vlad Yasevich.
26) Support IPV6 in ping sockets. From Lorenzo Colitti.
27) Receive flow steering targets should be updated at poll() time
too, from David Majnemer.
28) Fix several corner case regressions in PMTU/redirect handling due
to the routing cache removal, from Timo Teräs.
29) We have to be mindful of ipv4 mapped ipv6 sockets in
upd_v6_push_pending_frames(). From Hannes Frederic Sowa.
30) Fix L2TP sequence number handling bugs, from James Chapman."
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1214 commits)
drivers/net: caif: fix wrong rtnl_is_locked() usage
drivers/net: enic: release rtnl_lock on error-path
vhost-net: fix use-after-free in vhost_net_flush
net: mv643xx_eth: do not use port number as platform device id
net: sctp: confirm route during forward progress
virtio_net: fix race in RX VQ processing
virtio: support unlocked queue poll
net/cadence/macb: fix bug/typo in extracting gem_irq_read_clear bit
Documentation: Fix references to defunct linux-net@vger.kernel.org
net/fs: change busy poll time accounting
net: rename low latency sockets functions to busy poll
bridge: fix some kernel warning in multicast timer
sfc: Fix memory leak when discarding scattered packets
sit: fix tunnel update via netlink
dt:net:stmmac: Add dt specific phy reset callback support.
dt:net:stmmac: Add support to dwmac version 3.610 and 3.710
dt:net:stmmac: Allocate platform data only if its NULL.
net:stmmac: fix memleak in the open method
ipv6: rt6_check_neigh should successfully verify neigh if no NUD information are available
net: ipv6: fix wrong ping_v6_sendmsg return value
...
2013-07-10 08:24:39 +07:00
|
|
|
NULL, parent);
|
2012-07-13 13:15:34 +07:00
|
|
|
|
2013-08-05 15:51:14 +07:00
|
|
|
mxs_restart_init();
|
|
|
|
|
2012-07-13 13:15:34 +07:00
|
|
|
if (of_machine_is_compatible("karo,tx28"))
|
|
|
|
tx28_post_init();
|
2012-03-31 20:26:57 +07:00
|
|
|
}
|
|
|
|
|
2013-03-29 08:45:31 +07:00
|
|
|
#define MXS_CLKCTRL_RESET_CHIP (1 << 1)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset the system. It is called by machine_restart().
|
|
|
|
*/
|
2013-07-09 06:01:40 +07:00
|
|
|
static void mxs_restart(enum reboot_mode mode, const char *cmd)
|
2013-03-29 08:45:31 +07:00
|
|
|
{
|
2013-08-05 15:51:14 +07:00
|
|
|
if (reset_addr) {
|
|
|
|
/* reset the chip */
|
|
|
|
__mxs_setl(MXS_CLKCTRL_RESET_CHIP, reset_addr);
|
2013-03-29 08:45:31 +07:00
|
|
|
|
2013-08-05 15:51:14 +07:00
|
|
|
pr_err("Failed to assert the chip reset\n");
|
2013-03-29 08:45:31 +07:00
|
|
|
|
2013-08-05 15:51:14 +07:00
|
|
|
/* Delay to allow the serial port to show the message */
|
|
|
|
mdelay(50);
|
|
|
|
}
|
2013-03-29 08:45:31 +07:00
|
|
|
|
|
|
|
/* We'll take a jump through zero as a poor second */
|
|
|
|
soft_restart(0);
|
|
|
|
}
|
|
|
|
|
2013-03-29 13:04:07 +07:00
|
|
|
static void __init mxs_timer_init(void)
|
|
|
|
{
|
|
|
|
if (of_machine_is_compatible("fsl,imx23"))
|
|
|
|
mx23_clocks_init();
|
|
|
|
else
|
|
|
|
mx28_clocks_init();
|
2013-07-31 21:07:59 +07:00
|
|
|
of_clk_init(NULL);
|
2013-03-29 13:04:07 +07:00
|
|
|
clocksource_of_init();
|
|
|
|
}
|
2012-05-04 20:33:42 +07:00
|
|
|
|
2013-03-29 13:04:07 +07:00
|
|
|
static const char *mxs_dt_compat[] __initdata = {
|
2012-03-31 20:26:57 +07:00
|
|
|
"fsl,imx28",
|
2013-03-29 13:04:07 +07:00
|
|
|
"fsl,imx23",
|
2012-03-31 20:26:57 +07:00
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
2013-03-29 13:04:07 +07:00
|
|
|
DT_MACHINE_START(MXS, "Freescale MXS (Device Tree)")
|
2012-08-20 09:14:56 +07:00
|
|
|
.handle_irq = icoll_handle_irq,
|
2013-03-29 13:04:07 +07:00
|
|
|
.init_time = mxs_timer_init,
|
2012-03-31 20:26:57 +07:00
|
|
|
.init_machine = mxs_machine_init,
|
2013-03-29 13:41:27 +07:00
|
|
|
.init_late = mxs_pm_init,
|
2013-03-29 13:04:07 +07:00
|
|
|
.dt_compat = mxs_dt_compat,
|
2012-03-31 20:26:57 +07:00
|
|
|
.restart = mxs_restart,
|
|
|
|
MACHINE_END
|