summaryrefslogtreecommitdiff
path: root/arch/arm/mach-mx3/mach-mx31_3ds.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-mx3/mach-mx31_3ds.c')
-rw-r--r--arch/arm/mach-mx3/mach-mx31_3ds.c270
1 files changed, 112 insertions, 158 deletions
diff --git a/arch/arm/mach-mx3/mach-mx31_3ds.c b/arch/arm/mach-mx3/mach-mx31_3ds.c
index 58e57291b79d..d72022b5e455 100644
--- a/arch/arm/mach-mx3/mach-mx31_3ds.c
+++ b/arch/arm/mach-mx3/mach-mx31_3ds.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2008 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright 2008-2010 Freescale Semiconductor, Inc. All Rights Reserved.
*
* 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
@@ -22,13 +22,15 @@
#include <linux/clk.h>
#include <linux/irq.h>
#include <linux/gpio.h>
-#include <linux/smsc911x.h>
#include <linux/platform_device.h>
#include <linux/mfd/mc13783.h>
#include <linux/spi/spi.h>
#include <linux/regulator/machine.h>
#include <linux/fsl_devices.h>
#include <linux/input/matrix_keypad.h>
+#include <linux/i2c.h>
+#include <linux/ata.h>
+#include <linux/fsl_devices.h>
#include <mach/hardware.h>
#include <asm/mach-types.h>
@@ -40,9 +42,12 @@
#include <mach/board-mx31_3ds.h>
#include <mach/imx-uart.h>
#include <mach/iomux-mx3.h>
+#include <mach/3ds_debugboard.h>
+#include <mach/mmc.h>
#include <mach/mxc_nand.h>
#include <mach/spi.h>
#include "devices.h"
+#include "crm_regs.h"
/*!
* @file mx31_3ds.c
@@ -68,6 +73,26 @@ static int mx31_3ds_pins[] = {
MX31_PIN_CSPI2_SS2__SS2, /*CS for MC13783 */
/* MC13783 IRQ */
IOMUX_MODE(MX31_PIN_GPIO1_3, IOMUX_CONFIG_GPIO),
+ /* SDHC1 */
+ MX31_PIN_SD1_DATA3__SD1_DATA3, MX31_PIN_SD1_DATA2__SD1_DATA2,
+ MX31_PIN_SD1_DATA1__SD1_DATA1, MX31_PIN_SD1_DATA0__SD1_DATA0,
+ MX31_PIN_SD1_CLK__SD1_CLK, MX31_PIN_SD1_CMD__SD1_CMD,
+ MX31_PIN_GPIO3_0__GPIO3_0, MX31_PIN_GPIO3_1__GPIO3_1,
+ /* SDHC2 */
+ MX31_PIN_PC_PWRON__SD2_DATA3, MX31_PIN_PC_VS1__SD2_DATA2,
+ MX31_PIN_PC_READY__SD2_DATA1, MX31_PIN_PC_WAIT_B__SD2_DATA0,
+ MX31_PIN_PC_CD2_B__SD2_CLK, MX31_PIN_PC_CD1_B__SD2_CMD,
+ MX31_PIN_GPIO1_2__GPIO1_2,
+ /* AUDMUX (4 & 5) */
+ MX31_PIN_SCK4__SCK4, MX31_PIN_SRXD4__SRXD4,
+ MX31_PIN_STXD4__STXD4, MX31_PIN_SFS4__SFS4,
+ MX31_PIN_STXD5__STXD5, MX31_PIN_SRXD5__SRXD5,
+ MX31_PIN_SCK5__SCK5, MX31_PIN_SFS5__SFS5,
+
+ MX31_PIN_LCS0__GPI03_23,
+ MX31_PIN_SRST0__GPIO3_2,
+ MX31_PIN_SIMPD0__GPIO2_3,
+ MX31_PIN_BATT_LINE__GPIO2_17,
/* USB OTG reset */
IOMUX_MODE(MX31_PIN_USB_PWR, IOMUX_CONFIG_GPIO),
/* USB OTG */
@@ -114,6 +139,10 @@ static struct matrix_keymap_data mx31_3ds_keymap_data = {
.keymap_size = ARRAY_SIZE(mx31_3ds_keymap),
};
+static struct mxc_audio_platform_data mxc_audio_data = {
+ .ssi_num = 1,
+};
+
/* Regulators */
static struct regulator_init_data pwgtx_init = {
.constraints = {
@@ -212,174 +241,56 @@ static struct imxuart_platform_data uart_pdata = {
.flags = IMXUART_HAVE_RTSCTS,
};
-/*
- * Support for the SMSC9217 on the Debug board.
- */
-
-static struct smsc911x_platform_config smsc911x_config = {
- .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
- .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
- .flags = SMSC911X_USE_16BIT | SMSC911X_FORCE_INTERNAL_PHY,
- .phy_interface = PHY_INTERFACE_MODE_MII,
-};
-
-static struct resource smsc911x_resources[] = {
- {
- .start = LAN9217_BASE_ADDR,
- .end = LAN9217_BASE_ADDR + 0xff,
- .flags = IORESOURCE_MEM,
- }, {
- .start = EXPIO_INT_ENET,
- .end = EXPIO_INT_ENET,
- .flags = IORESOURCE_IRQ,
- },
-};
-
-static struct platform_device smsc911x_device = {
- .name = "smsc911x",
- .id = -1,
- .num_resources = ARRAY_SIZE(smsc911x_resources),
- .resource = smsc911x_resources,
- .dev = {
- .platform_data = &smsc911x_config,
- },
-};
-
-/*
- * Routines for the CPLD on the debug board. It contains a CPLD handling
- * LEDs, switches, interrupts for Ethernet.
- */
+#define PLL_PCTL_REG(pd, mfd, mfi, mfn) \
+ ((((pd) - 1) << 26) + (((mfd) - 1) << 16) + ((mfi) << 10) + mfn)
-static void mx31_3ds_expio_irq_handler(uint32_t irq, struct irq_desc *desc)
-{
- uint32_t imr_val;
- uint32_t int_valid;
- uint32_t expio_irq;
-
- imr_val = __raw_readw(CPLD_INT_MASK_REG);
- int_valid = __raw_readw(CPLD_INT_STATUS_REG) & ~imr_val;
-
- expio_irq = MXC_EXP_IO_BASE;
- for (; int_valid != 0; int_valid >>= 1, expio_irq++) {
- if ((int_valid & 1) == 0)
- continue;
- generic_handle_irq(expio_irq);
- }
-}
+/* For 26MHz input clock */
+#define PLL_532MHZ PLL_PCTL_REG(1, 13, 10, 3)
+#define PLL_399MHZ PLL_PCTL_REG(1, 52, 7, 35)
+#define PLL_133MHZ PLL_PCTL_REG(2, 26, 5, 3)
-/*
- * Disable an expio pin's interrupt by setting the bit in the imr.
- * @param irq an expio virtual irq number
- */
-static void expio_mask_irq(uint32_t irq)
-{
- uint16_t reg;
- uint32_t expio = MXC_IRQ_TO_EXPIO(irq);
-
- /* mask the interrupt */
- reg = __raw_readw(CPLD_INT_MASK_REG);
- reg |= 1 << expio;
- __raw_writew(reg, CPLD_INT_MASK_REG);
-}
-
-/*
- * Acknowledge an expanded io pin's interrupt by clearing the bit in the isr.
- * @param irq an expanded io virtual irq number
- */
-static void expio_ack_irq(uint32_t irq)
-{
- uint32_t expio = MXC_IRQ_TO_EXPIO(irq);
+#define PDR0_REG(mcu, max, hsp, ipg, nfc) \
+ (MXC_CCM_PDR0_MCU_DIV_##mcu | MXC_CCM_PDR0_MAX_DIV_##max | \
+ MXC_CCM_PDR0_HSP_DIV_##hsp | MXC_CCM_PDR0_IPG_DIV_##ipg | \
+ MXC_CCM_PDR0_NFC_DIV_##nfc)
- /* clear the interrupt status */
- __raw_writew(1 << expio, CPLD_INT_RESET_REG);
- __raw_writew(0, CPLD_INT_RESET_REG);
- /* mask the interrupt */
- expio_mask_irq(irq);
-}
-
-/*
- * Enable a expio pin's interrupt by clearing the bit in the imr.
- * @param irq a expio virtual irq number
- */
-static void expio_unmask_irq(uint32_t irq)
-{
- uint16_t reg;
- uint32_t expio = MXC_IRQ_TO_EXPIO(irq);
-
- /* unmask the interrupt */
- reg = __raw_readw(CPLD_INT_MASK_REG);
- reg &= ~(1 << expio);
- __raw_writew(reg, CPLD_INT_MASK_REG);
-}
-
-static struct irq_chip expio_irq_chip = {
- .ack = expio_ack_irq,
- .mask = expio_mask_irq,
- .unmask = expio_unmask_irq,
+/* working point(wp): 0 - 133MHz; 1 - 266MHz; 2 - 399MHz; 3 - 532MHz */
+/* 26MHz input clock table */
+static struct cpu_wp cpu_wp_26[] = {
+ {
+ .pll_reg = PLL_532MHZ,
+ .pll_rate = 532000000,
+ .cpu_rate = 133000000,
+ .pdr0_reg = PDR0_REG(4, 4, 4, 2, 6),},
+ {
+ .pll_reg = PLL_532MHZ,
+ .pll_rate = 532000000,
+ .cpu_rate = 266000000,
+ .pdr0_reg = PDR0_REG(2, 4, 4, 2, 6),},
+ {
+ .pll_reg = PLL_399MHZ,
+ .pll_rate = 399000000,
+ .cpu_rate = 399000000,
+ .pdr0_reg = PDR0_REG(1, 3, 3, 2, 6),},
+ {
+ .pll_reg = PLL_532MHZ,
+ .pll_rate = 532000000,
+ .cpu_rate = 532000000,
+ .pdr0_reg = PDR0_REG(1, 4, 4, 2, 6),},
};
-static int __init mx31_3ds_init_expio(void)
+struct cpu_wp *get_cpu_wp(int *wp)
{
- int i;
- int ret;
-
- /* Check if there's a debug board connected */
- if ((__raw_readw(CPLD_MAGIC_NUMBER1_REG) != 0xAAAA) ||
- (__raw_readw(CPLD_MAGIC_NUMBER2_REG) != 0x5555) ||
- (__raw_readw(CPLD_MAGIC_NUMBER3_REG) != 0xCAFE)) {
- /* No Debug board found */
- return -ENODEV;
- }
-
- pr_info("i.MX31 3DS Debug board detected, rev = 0x%04X\n",
- __raw_readw(CPLD_CODE_VER_REG));
-
- /*
- * Configure INT line as GPIO input
- */
- ret = gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1), "sms9217-irq");
- if (ret)
- pr_warning("could not get LAN irq gpio\n");
- else
- gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1));
-
- /* Disable the interrupts and clear the status */
- __raw_writew(0, CPLD_INT_MASK_REG);
- __raw_writew(0xFFFF, CPLD_INT_RESET_REG);
- __raw_writew(0, CPLD_INT_RESET_REG);
- __raw_writew(0x1F, CPLD_INT_MASK_REG);
- for (i = MXC_EXP_IO_BASE;
- i < (MXC_EXP_IO_BASE + MXC_MAX_EXP_IO_LINES);
- i++) {
- set_irq_chip(i, &expio_irq_chip);
- set_irq_handler(i, handle_level_irq);
- set_irq_flags(i, IRQF_VALID);
- }
- set_irq_type(EXPIO_PARENT_INT, IRQ_TYPE_LEVEL_LOW);
- set_irq_chained_handler(EXPIO_PARENT_INT, mx31_3ds_expio_irq_handler);
-
- return 0;
+ *wp = 4;
+ return cpu_wp_26;
}
/*
- * This structure defines the MX31 memory map.
- */
-static struct map_desc mx31_3ds_io_desc[] __initdata = {
- {
- .virtual = MX31_CS5_BASE_ADDR_VIRT,
- .pfn = __phys_to_pfn(MX31_CS5_BASE_ADDR),
- .length = MX31_CS5_SIZE,
- .type = MT_DEVICE,
- },
-};
-
-/*
* Set up static virtual mappings.
*/
static void __init mx31_3ds_map_io(void)
{
mx31_map_io();
- iotable_init(mx31_3ds_io_desc, ARRAY_SIZE(mx31_3ds_io_desc));
}
/*!
@@ -387,6 +298,47 @@ static void __init mx31_3ds_map_io(void)
*/
static void __init mxc_board_init(void)
{
+ struct clk *pll_clk;
+ struct clk *ckih_clk;
+ struct clk *cko_clk;
+ void __iomem *iim_reg = MX31_IO_ADDRESS(MX31_IIM_BASE_ADDR);
+
+ /* request gpio for phone jack detect */
+ mxc_iomux_set_pad(MX31_PIN_BATT_LINE, PAD_CTL_PKE_NONE);
+ gpio_request(IOMUX_TO_GPIO(MX31_PIN_BATT_LINE), "batt_line");
+ gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_BATT_LINE));
+
+ pll_clk = clk_get(NULL, "usb_pll");
+ mxc_audio_data.ssi_clk[0] = clk_get(NULL, "ssi_clk.0");
+ if (IS_ERR(pll_clk) || IS_ERR(mxc_audio_data.ssi_clk[0])) {
+ pr_err("cannot get usb pll or ssi clks\n");
+ } else {
+ clk_set_parent(mxc_audio_data.ssi_clk[0], pll_clk);
+ clk_put(mxc_audio_data.ssi_clk[0]);
+ clk_put(pll_clk);
+ }
+
+ /* override fuse for Hantro HW clock */
+ if (__raw_readl(iim_reg + 0x808) == 0x4) {
+ if (!(__raw_readl(iim_reg + 0x800) & (1 << 5))) {
+ writel(__raw_readl(iim_reg + 0x808) & 0xfffffffb,
+ iim_reg + 0x808);
+ }
+ }
+
+ /* Enable 26 mhz clock on CKO1 for PMIC audio */
+ ckih_clk = clk_get(NULL, "ckih");
+ cko_clk = clk_get(NULL, "cko1_clk");
+ if (IS_ERR(ckih_clk) || IS_ERR(cko_clk)) {
+ printk(KERN_ERR "Unable to set CKO1 output to CKIH\n");
+ } else {
+ clk_set_parent(cko_clk, ckih_clk);
+ clk_set_rate(cko_clk, clk_get_rate(ckih_clk));
+ clk_enable(cko_clk);
+ }
+ clk_put(ckih_clk);
+ clk_put(cko_clk);
+
mxc_iomux_setup_multiple_pins(mx31_3ds_pins, ARRAY_SIZE(mx31_3ds_pins),
"mx31_3ds");
@@ -402,8 +354,10 @@ static void __init mxc_board_init(void)
mx31_3ds_usbotg_init();
mxc_register_device(&mxc_otg_udc_device, &usbotg_pdata);
- if (!mx31_3ds_init_expio())
- platform_device_register(&smsc911x_device);
+ if (mxc_expio_init(CS5_BASE_ADDR, EXPIO_PARENT_INT))
+ printk(KERN_WARNING "Init of the debugboard failed, all "
+ "devices on the board are unusable.\n");
+
}
static void __init mx31_3ds_timer_init(void)