Path: blob/master/arch/arm/mach-imx/mach-mx31ads.c
10817 views
/*1* Copyright (C) 2000 Deep Blue Solutions Ltd2* Copyright (C) 2002 Shane Nay ([email protected])3* Copyright 2005-2007 Freescale Semiconductor, Inc. All Rights Reserved.4*5* This program is free software; you can redistribute it and/or modify6* it under the terms of the GNU General Public License as published by7* the Free Software Foundation; either version 2 of the License, or8* (at your option) any later version.9*10* This program is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13* GNU General Public License for more details.14*/1516#include <linux/types.h>17#include <linux/init.h>18#include <linux/clk.h>19#include <linux/serial_8250.h>20#include <linux/gpio.h>21#include <linux/i2c.h>22#include <linux/irq.h>2324#include <asm/mach-types.h>25#include <asm/mach/arch.h>26#include <asm/mach/time.h>27#include <asm/memory.h>28#include <asm/mach/map.h>29#include <mach/common.h>30#include <mach/board-mx31ads.h>31#include <mach/iomux-mx3.h>3233#ifdef CONFIG_MACH_MX31ADS_WM1133_EV134#include <linux/mfd/wm8350/audio.h>35#include <linux/mfd/wm8350/core.h>36#include <linux/mfd/wm8350/pmic.h>37#endif3839#include "devices-imx31.h"4041/* PBC Board interrupt status register */42#define PBC_INTSTATUS 0x0000164344/* PBC Board interrupt current status register */45#define PBC_INTCURR_STATUS 0x0000184647/* PBC Interrupt mask register set address */48#define PBC_INTMASK_SET 0x00001A4950/* PBC Interrupt mask register clear address */51#define PBC_INTMASK_CLEAR 0x00001C5253/* External UART A */54#define PBC_SC16C652_UARTA 0x0100005556/* External UART B */57#define PBC_SC16C652_UARTB 0x0100105859#define PBC_INTSTATUS_REG (PBC_INTSTATUS + PBC_BASE_ADDRESS)60#define PBC_INTMASK_SET_REG (PBC_INTMASK_SET + PBC_BASE_ADDRESS)61#define PBC_INTMASK_CLEAR_REG (PBC_INTMASK_CLEAR + PBC_BASE_ADDRESS)62#define EXPIO_PARENT_INT IOMUX_TO_IRQ(MX31_PIN_GPIO1_4)6364#define MXC_IRQ_TO_EXPIO(irq) ((irq) - MXC_EXP_IO_BASE)6566#define EXPIO_INT_XUART_INTA (MXC_EXP_IO_BASE + 10)67#define EXPIO_INT_XUART_INTB (MXC_EXP_IO_BASE + 11)6869#define MXC_MAX_EXP_IO_LINES 167071/*72* The serial port definition structure.73*/74static struct plat_serial8250_port serial_platform_data[] = {75{76.membase = (void *)(PBC_BASE_ADDRESS + PBC_SC16C652_UARTA),77.mapbase = (unsigned long)(MX31_CS4_BASE_ADDR + PBC_SC16C652_UARTA),78.irq = EXPIO_INT_XUART_INTA,79.uartclk = 14745600,80.regshift = 0,81.iotype = UPIO_MEM,82.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_AUTO_IRQ,83}, {84.membase = (void *)(PBC_BASE_ADDRESS + PBC_SC16C652_UARTB),85.mapbase = (unsigned long)(MX31_CS4_BASE_ADDR + PBC_SC16C652_UARTB),86.irq = EXPIO_INT_XUART_INTB,87.uartclk = 14745600,88.regshift = 0,89.iotype = UPIO_MEM,90.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_AUTO_IRQ,91},92{},93};9495static struct platform_device serial_device = {96.name = "serial8250",97.id = 0,98.dev = {99.platform_data = serial_platform_data,100},101};102103static int __init mxc_init_extuart(void)104{105return platform_device_register(&serial_device);106}107108static const struct imxuart_platform_data uart_pdata __initconst = {109.flags = IMXUART_HAVE_RTSCTS,110};111112static unsigned int uart_pins[] = {113MX31_PIN_CTS1__CTS1,114MX31_PIN_RTS1__RTS1,115MX31_PIN_TXD1__TXD1,116MX31_PIN_RXD1__RXD1117};118119static inline void mxc_init_imx_uart(void)120{121mxc_iomux_setup_multiple_pins(uart_pins, ARRAY_SIZE(uart_pins), "uart-0");122imx31_add_imx_uart0(&uart_pdata);123}124125static void mx31ads_expio_irq_handler(u32 irq, struct irq_desc *desc)126{127u32 imr_val;128u32 int_valid;129u32 expio_irq;130131imr_val = __raw_readw(PBC_INTMASK_SET_REG);132int_valid = __raw_readw(PBC_INTSTATUS_REG) & imr_val;133134expio_irq = MXC_EXP_IO_BASE;135for (; int_valid != 0; int_valid >>= 1, expio_irq++) {136if ((int_valid & 1) == 0)137continue;138139generic_handle_irq(expio_irq);140}141}142143/*144* Disable an expio pin's interrupt by setting the bit in the imr.145* @param d an expio virtual irq description146*/147static void expio_mask_irq(struct irq_data *d)148{149u32 expio = MXC_IRQ_TO_EXPIO(d->irq);150/* mask the interrupt */151__raw_writew(1 << expio, PBC_INTMASK_CLEAR_REG);152__raw_readw(PBC_INTMASK_CLEAR_REG);153}154155/*156* Acknowledge an expanded io pin's interrupt by clearing the bit in the isr.157* @param d an expio virtual irq description158*/159static void expio_ack_irq(struct irq_data *d)160{161u32 expio = MXC_IRQ_TO_EXPIO(d->irq);162/* clear the interrupt status */163__raw_writew(1 << expio, PBC_INTSTATUS_REG);164}165166/*167* Enable a expio pin's interrupt by clearing the bit in the imr.168* @param d an expio virtual irq description169*/170static void expio_unmask_irq(struct irq_data *d)171{172u32 expio = MXC_IRQ_TO_EXPIO(d->irq);173/* unmask the interrupt */174__raw_writew(1 << expio, PBC_INTMASK_SET_REG);175}176177static struct irq_chip expio_irq_chip = {178.name = "EXPIO(CPLD)",179.irq_ack = expio_ack_irq,180.irq_mask = expio_mask_irq,181.irq_unmask = expio_unmask_irq,182};183184static void __init mx31ads_init_expio(void)185{186int i;187188printk(KERN_INFO "MX31ADS EXPIO(CPLD) hardware\n");189190/*191* Configure INT line as GPIO input192*/193mxc_iomux_alloc_pin(IOMUX_MODE(MX31_PIN_GPIO1_4, IOMUX_CONFIG_GPIO), "expio");194195/* disable the interrupt and clear the status */196__raw_writew(0xFFFF, PBC_INTMASK_CLEAR_REG);197__raw_writew(0xFFFF, PBC_INTSTATUS_REG);198for (i = MXC_EXP_IO_BASE; i < (MXC_EXP_IO_BASE + MXC_MAX_EXP_IO_LINES);199i++) {200irq_set_chip_and_handler(i, &expio_irq_chip, handle_level_irq);201set_irq_flags(i, IRQF_VALID);202}203irq_set_irq_type(EXPIO_PARENT_INT, IRQ_TYPE_LEVEL_HIGH);204irq_set_chained_handler(EXPIO_PARENT_INT, mx31ads_expio_irq_handler);205}206207#ifdef CONFIG_MACH_MX31ADS_WM1133_EV1208/* This section defines setup for the Wolfson Microelectronics209* 1133-EV1 PMU/audio board. When other PMU boards are supported the210* regulator definitions may be shared with them, but for now they can211* only be used with this board so would generate warnings about212* unused statics and some of the configuration is specific to this213* module.214*/215216/* CPU */217static struct regulator_consumer_supply sw1a_consumers[] = {218{219.supply = "cpu_vcc",220}221};222223static struct regulator_init_data sw1a_data = {224.constraints = {225.name = "SW1A",226.min_uV = 1275000,227.max_uV = 1600000,228.valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |229REGULATOR_CHANGE_MODE,230.valid_modes_mask = REGULATOR_MODE_NORMAL |231REGULATOR_MODE_FAST,232.state_mem = {233.uV = 1400000,234.mode = REGULATOR_MODE_NORMAL,235.enabled = 1,236},237.initial_state = PM_SUSPEND_MEM,238.always_on = 1,239.boot_on = 1,240},241.num_consumer_supplies = ARRAY_SIZE(sw1a_consumers),242.consumer_supplies = sw1a_consumers,243};244245/* System IO - High */246static struct regulator_init_data viohi_data = {247.constraints = {248.name = "VIOHO",249.min_uV = 2800000,250.max_uV = 2800000,251.state_mem = {252.uV = 2800000,253.mode = REGULATOR_MODE_NORMAL,254.enabled = 1,255},256.initial_state = PM_SUSPEND_MEM,257.always_on = 1,258.boot_on = 1,259},260};261262/* System IO - Low */263static struct regulator_init_data violo_data = {264.constraints = {265.name = "VIOLO",266.min_uV = 1800000,267.max_uV = 1800000,268.state_mem = {269.uV = 1800000,270.mode = REGULATOR_MODE_NORMAL,271.enabled = 1,272},273.initial_state = PM_SUSPEND_MEM,274.always_on = 1,275.boot_on = 1,276},277};278279/* DDR RAM */280static struct regulator_init_data sw2a_data = {281.constraints = {282.name = "SW2A",283.min_uV = 1800000,284.max_uV = 1800000,285.valid_modes_mask = REGULATOR_MODE_NORMAL,286.state_mem = {287.uV = 1800000,288.mode = REGULATOR_MODE_NORMAL,289.enabled = 1,290},291.state_disk = {292.mode = REGULATOR_MODE_NORMAL,293.enabled = 0,294},295.always_on = 1,296.boot_on = 1,297.initial_state = PM_SUSPEND_MEM,298},299};300301static struct regulator_init_data ldo1_data = {302.constraints = {303.name = "VCAM/VMMC1/VMMC2",304.min_uV = 2800000,305.max_uV = 2800000,306.valid_modes_mask = REGULATOR_MODE_NORMAL,307.valid_ops_mask = REGULATOR_CHANGE_STATUS,308.apply_uV = 1,309},310};311312static struct regulator_consumer_supply ldo2_consumers[] = {313{ .supply = "AVDD", .dev_name = "1-001a" },314{ .supply = "HPVDD", .dev_name = "1-001a" },315};316317/* CODEC and SIM */318static struct regulator_init_data ldo2_data = {319.constraints = {320.name = "VESIM/VSIM/AVDD",321.min_uV = 3300000,322.max_uV = 3300000,323.valid_modes_mask = REGULATOR_MODE_NORMAL,324.valid_ops_mask = REGULATOR_CHANGE_STATUS,325.apply_uV = 1,326},327.num_consumer_supplies = ARRAY_SIZE(ldo2_consumers),328.consumer_supplies = ldo2_consumers,329};330331/* General */332static struct regulator_init_data vdig_data = {333.constraints = {334.name = "VDIG",335.min_uV = 1500000,336.max_uV = 1500000,337.valid_modes_mask = REGULATOR_MODE_NORMAL,338.apply_uV = 1,339.always_on = 1,340.boot_on = 1,341},342};343344/* Tranceivers */345static struct regulator_init_data ldo4_data = {346.constraints = {347.name = "VRF1/CVDD_2.775",348.min_uV = 2500000,349.max_uV = 2500000,350.valid_modes_mask = REGULATOR_MODE_NORMAL,351.apply_uV = 1,352.always_on = 1,353.boot_on = 1,354},355};356357static struct wm8350_led_platform_data wm8350_led_data = {358.name = "wm8350:white",359.default_trigger = "heartbeat",360.max_uA = 27899,361};362363static struct wm8350_audio_platform_data imx32ads_wm8350_setup = {364.vmid_discharge_msecs = 1000,365.drain_msecs = 30,366.cap_discharge_msecs = 700,367.vmid_charge_msecs = 700,368.vmid_s_curve = WM8350_S_CURVE_SLOW,369.dis_out4 = WM8350_DISCHARGE_SLOW,370.dis_out3 = WM8350_DISCHARGE_SLOW,371.dis_out2 = WM8350_DISCHARGE_SLOW,372.dis_out1 = WM8350_DISCHARGE_SLOW,373.vroi_out4 = WM8350_TIE_OFF_500R,374.vroi_out3 = WM8350_TIE_OFF_500R,375.vroi_out2 = WM8350_TIE_OFF_500R,376.vroi_out1 = WM8350_TIE_OFF_500R,377.vroi_enable = 0,378.codec_current_on = WM8350_CODEC_ISEL_1_0,379.codec_current_standby = WM8350_CODEC_ISEL_0_5,380.codec_current_charge = WM8350_CODEC_ISEL_1_5,381};382383static int mx31_wm8350_init(struct wm8350 *wm8350)384{385wm8350_gpio_config(wm8350, 0, WM8350_GPIO_DIR_IN,386WM8350_GPIO0_PWR_ON_IN, WM8350_GPIO_ACTIVE_LOW,387WM8350_GPIO_PULL_UP, WM8350_GPIO_INVERT_OFF,388WM8350_GPIO_DEBOUNCE_ON);389390wm8350_gpio_config(wm8350, 3, WM8350_GPIO_DIR_IN,391WM8350_GPIO3_PWR_OFF_IN, WM8350_GPIO_ACTIVE_HIGH,392WM8350_GPIO_PULL_DOWN, WM8350_GPIO_INVERT_OFF,393WM8350_GPIO_DEBOUNCE_ON);394395wm8350_gpio_config(wm8350, 4, WM8350_GPIO_DIR_IN,396WM8350_GPIO4_MR_IN, WM8350_GPIO_ACTIVE_HIGH,397WM8350_GPIO_PULL_DOWN, WM8350_GPIO_INVERT_OFF,398WM8350_GPIO_DEBOUNCE_OFF);399400wm8350_gpio_config(wm8350, 7, WM8350_GPIO_DIR_IN,401WM8350_GPIO7_HIBERNATE_IN, WM8350_GPIO_ACTIVE_HIGH,402WM8350_GPIO_PULL_DOWN, WM8350_GPIO_INVERT_OFF,403WM8350_GPIO_DEBOUNCE_OFF);404405wm8350_gpio_config(wm8350, 6, WM8350_GPIO_DIR_OUT,406WM8350_GPIO6_SDOUT_OUT, WM8350_GPIO_ACTIVE_HIGH,407WM8350_GPIO_PULL_NONE, WM8350_GPIO_INVERT_OFF,408WM8350_GPIO_DEBOUNCE_OFF);409410wm8350_gpio_config(wm8350, 8, WM8350_GPIO_DIR_OUT,411WM8350_GPIO8_VCC_FAULT_OUT, WM8350_GPIO_ACTIVE_LOW,412WM8350_GPIO_PULL_NONE, WM8350_GPIO_INVERT_OFF,413WM8350_GPIO_DEBOUNCE_OFF);414415wm8350_gpio_config(wm8350, 9, WM8350_GPIO_DIR_OUT,416WM8350_GPIO9_BATT_FAULT_OUT, WM8350_GPIO_ACTIVE_LOW,417WM8350_GPIO_PULL_NONE, WM8350_GPIO_INVERT_OFF,418WM8350_GPIO_DEBOUNCE_OFF);419420wm8350_register_regulator(wm8350, WM8350_DCDC_1, &sw1a_data);421wm8350_register_regulator(wm8350, WM8350_DCDC_3, &viohi_data);422wm8350_register_regulator(wm8350, WM8350_DCDC_4, &violo_data);423wm8350_register_regulator(wm8350, WM8350_DCDC_6, &sw2a_data);424wm8350_register_regulator(wm8350, WM8350_LDO_1, &ldo1_data);425wm8350_register_regulator(wm8350, WM8350_LDO_2, &ldo2_data);426wm8350_register_regulator(wm8350, WM8350_LDO_3, &vdig_data);427wm8350_register_regulator(wm8350, WM8350_LDO_4, &ldo4_data);428429/* LEDs */430wm8350_dcdc_set_slot(wm8350, WM8350_DCDC_5, 1, 1,431WM8350_DC5_ERRACT_SHUTDOWN_CONV);432wm8350_isink_set_flash(wm8350, WM8350_ISINK_A,433WM8350_ISINK_FLASH_DISABLE,434WM8350_ISINK_FLASH_TRIG_BIT,435WM8350_ISINK_FLASH_DUR_32MS,436WM8350_ISINK_FLASH_ON_INSTANT,437WM8350_ISINK_FLASH_OFF_INSTANT,438WM8350_ISINK_FLASH_MODE_EN);439wm8350_dcdc25_set_mode(wm8350, WM8350_DCDC_5,440WM8350_ISINK_MODE_BOOST,441WM8350_ISINK_ILIM_NORMAL,442WM8350_DC5_RMP_20V,443WM8350_DC5_FBSRC_ISINKA);444wm8350_register_led(wm8350, 0, WM8350_DCDC_5, WM8350_ISINK_A,445&wm8350_led_data);446447wm8350->codec.platform_data = &imx32ads_wm8350_setup;448449regulator_has_full_constraints();450451return 0;452}453454static struct wm8350_platform_data __initdata mx31_wm8350_pdata = {455.init = mx31_wm8350_init,456.irq_base = MXC_BOARD_IRQ_START + MXC_MAX_EXP_IO_LINES,457};458#endif459460static struct i2c_board_info __initdata mx31ads_i2c1_devices[] = {461#ifdef CONFIG_MACH_MX31ADS_WM1133_EV1462{463I2C_BOARD_INFO("wm8350", 0x1a),464.platform_data = &mx31_wm8350_pdata,465.irq = IOMUX_TO_IRQ(MX31_PIN_GPIO1_3),466},467#endif468};469470static void mxc_init_i2c(void)471{472i2c_register_board_info(1, mx31ads_i2c1_devices,473ARRAY_SIZE(mx31ads_i2c1_devices));474475mxc_iomux_mode(IOMUX_MODE(MX31_PIN_CSPI2_MOSI, IOMUX_CONFIG_ALT1));476mxc_iomux_mode(IOMUX_MODE(MX31_PIN_CSPI2_MISO, IOMUX_CONFIG_ALT1));477478imx31_add_imx_i2c1(NULL);479}480481static unsigned int ssi_pins[] = {482MX31_PIN_SFS5__SFS5,483MX31_PIN_SCK5__SCK5,484MX31_PIN_SRXD5__SRXD5,485MX31_PIN_STXD5__STXD5,486};487488static void mxc_init_audio(void)489{490imx31_add_imx_ssi(0, NULL);491mxc_iomux_setup_multiple_pins(ssi_pins, ARRAY_SIZE(ssi_pins), "ssi");492}493494/* static mappings */495static struct map_desc mx31ads_io_desc[] __initdata = {496{497.virtual = MX31_CS4_BASE_ADDR_VIRT,498.pfn = __phys_to_pfn(MX31_CS4_BASE_ADDR),499.length = MX31_CS4_SIZE / 2,500.type = MT_DEVICE501},502};503504static void __init mx31ads_map_io(void)505{506mx31_map_io();507iotable_init(mx31ads_io_desc, ARRAY_SIZE(mx31ads_io_desc));508}509510static void __init mx31ads_init_irq(void)511{512mx31_init_irq();513mx31ads_init_expio();514}515516static void __init mx31ads_init(void)517{518mxc_init_extuart();519mxc_init_imx_uart();520mxc_init_i2c();521mxc_init_audio();522}523524static void __init mx31ads_timer_init(void)525{526mx31_clocks_init(26000000);527}528529static struct sys_timer mx31ads_timer = {530.init = mx31ads_timer_init,531};532533MACHINE_START(MX31ADS, "Freescale MX31ADS")534/* Maintainer: Freescale Semiconductor, Inc. */535.boot_params = MX3x_PHYS_OFFSET + 0x100,536.map_io = mx31ads_map_io,537.init_early = imx31_init_early,538.init_irq = mx31ads_init_irq,539.timer = &mx31ads_timer,540.init_machine = mx31ads_init,541MACHINE_END542543544