···100100 select IMX_HAVE_PLATFORM_FSL_USB2_UDC101101 select IMX_HAVE_PLATFORM_IMX2_WDT102102 select IMX_HAVE_PLATFORM_IMXDI_RTC103103+ select IMX_HAVE_PLATFORM_IMX_I2C103104 select IMX_HAVE_PLATFORM_IMX_FB104105 select IMX_HAVE_PLATFORM_IMX_KEYPAD105106 select IMX_HAVE_PLATFORM_IMX_UART···239238 select SOC_IMX27240239 select IMX_HAVE_PLATFORM_FSL_USB2_UDC241240 select IMX_HAVE_PLATFORM_IMX2_WDT241241+ select IMX_HAVE_PLATFORM_IMX_I2C242242 select IMX_HAVE_PLATFORM_IMX_KEYPAD243243 select IMX_HAVE_PLATFORM_IMX_UART244244 select IMX_HAVE_PLATFORM_MXC_EHCI···267265 bool "LogicPD MX27 LITEKIT platform"268266 select SOC_IMX27269267 select IMX_HAVE_PLATFORM_IMX_UART268268+ select IMX_HAVE_PLATFORM_IMX_SSI270269 help271270 Include support for MX27 LITEKIT platform. This includes specific272271 configurations for the board and its peripherals.···302299 help303300 Include support for i-MXT (aka td60) platform. This304301 includes specific configurations for the module and its peripherals.302302+303303+config MACH_IMX27IPCAM304304+ bool "IMX27 IPCAM platform"305305+ select SOC_IMX27306306+ select IMX_HAVE_PLATFORM_IMX2_WDT307307+ select IMX_HAVE_PLATFORM_IMX_UART308308+ help309309+ Include support for IMX27 IPCAM platform. This includes specific310310+ configurations for the board and its peripherals.305311306312endif
···11+/*22+ * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>33+ * Copyright (C) 2010 Freescale Semiconductor, Inc.44+ *55+ * This program is free software; you can redistribute it and/or modify it66+ * under the terms of the GNU General Public License as published by the77+ * Free Software Foundation; either version 2 of the License, or (at your88+ * option) any later version.99+ *1010+ * This program is distributed in the hope that it will be useful, but1111+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY1212+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License1313+ * for more details.1414+ */1515+1616+#include <linux/platform_device.h>1717+#include <linux/io.h>1818+1919+#include <mach/hardware.h>2020+#include <mach/mxc_ehci.h>2121+2222+#define USBCTRL_OTGBASE_OFFSET 0x6002323+2424+#define MX25_OTG_SIC_SHIFT 292525+#define MX25_OTG_SIC_MASK (0x3 << MX25_OTG_SIC_SHIFT)2626+#define MX25_OTG_PM_BIT (1 << 24)2727+2828+#define MX25_H1_SIC_SHIFT 212929+#define MX25_H1_SIC_MASK (0x3 << MX25_H1_SIC_SHIFT)3030+#define MX25_H1_PM_BIT (1 << 8)3131+#define MX25_H1_IPPUE_UP_BIT (1 << 7)3232+#define MX25_H1_IPPUE_DOWN_BIT (1 << 6)3333+#define MX25_H1_TLL_BIT (1 << 5)3434+#define MX25_H1_USBTE_BIT (1 << 4)3535+3636+int mx25_initialize_usb_hw(int port, unsigned int flags)3737+{3838+ unsigned int v;3939+4040+ v = readl(MX25_IO_ADDRESS(MX25_USB_BASE_ADDR + USBCTRL_OTGBASE_OFFSET));4141+4242+ switch (port) {4343+ case 0: /* OTG port */4444+ v &= ~(MX25_OTG_SIC_MASK | MX25_OTG_PM_BIT);4545+ v |= (flags & MXC_EHCI_INTERFACE_MASK) << MX25_OTG_SIC_SHIFT;4646+4747+ if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))4848+ v |= MX25_OTG_PM_BIT;4949+5050+ break;5151+ case 1: /* H1 port */5252+ v &= ~(MX25_H1_SIC_MASK | MX25_H1_PM_BIT | MX25_H1_TLL_BIT |5353+ MX25_H1_USBTE_BIT | MX25_H1_IPPUE_DOWN_BIT | MX25_H1_IPPUE_UP_BIT);5454+ v |= (flags & MXC_EHCI_INTERFACE_MASK) << MX25_H1_SIC_SHIFT;5555+5656+ if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))5757+ v |= MX25_H1_PM_BIT;5858+5959+ if (!(flags & MXC_EHCI_TTL_ENABLED))6060+ v |= MX25_H1_TLL_BIT;6161+6262+ if (flags & MXC_EHCI_INTERNAL_PHY)6363+ v |= MX25_H1_USBTE_BIT;6464+6565+ if (flags & MXC_EHCI_IPPUE_DOWN)6666+ v |= MX25_H1_IPPUE_DOWN_BIT;6767+6868+ if (flags & MXC_EHCI_IPPUE_UP)6969+ v |= MX25_H1_IPPUE_UP_BIT;7070+7171+ break;7272+ default:7373+ return -EINVAL;7474+ }7575+7676+ writel(v, MX25_IO_ADDRESS(MX25_USB_BASE_ADDR + USBCTRL_OTGBASE_OFFSET));7777+7878+ return 0;7979+}8080+
+82
arch/arm/mach-imx/ehci-imx27.c
···11+/*22+ * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>33+ * Copyright (C) 2010 Freescale Semiconductor, Inc.44+ *55+ * This program is free software; you can redistribute it and/or modify it66+ * under the terms of the GNU General Public License as published by the77+ * Free Software Foundation; either version 2 of the License, or (at your88+ * option) any later version.99+ *1010+ * This program is distributed in the hope that it will be useful, but1111+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY1212+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License1313+ * for more details.1414+ */1515+1616+#include <linux/platform_device.h>1717+#include <linux/io.h>1818+1919+#include <mach/hardware.h>2020+#include <mach/mxc_ehci.h>2121+2222+#define USBCTRL_OTGBASE_OFFSET 0x6002323+2424+#define MX27_OTG_SIC_SHIFT 292525+#define MX27_OTG_SIC_MASK (0x3 << MX27_OTG_SIC_SHIFT)2626+#define MX27_OTG_PM_BIT (1 << 24)2727+2828+#define MX27_H2_SIC_SHIFT 212929+#define MX27_H2_SIC_MASK (0x3 << MX27_H2_SIC_SHIFT)3030+#define MX27_H2_PM_BIT (1 << 16)3131+#define MX27_H2_DT_BIT (1 << 5)3232+3333+#define MX27_H1_SIC_SHIFT 133434+#define MX27_H1_SIC_MASK (0x3 << MX27_H1_SIC_SHIFT)3535+#define MX27_H1_PM_BIT (1 << 8)3636+#define MX27_H1_DT_BIT (1 << 4)3737+3838+int mx27_initialize_usb_hw(int port, unsigned int flags)3939+{4040+ unsigned int v;4141+4242+ v = readl(MX27_IO_ADDRESS(MX27_USB_BASE_ADDR + USBCTRL_OTGBASE_OFFSET));4343+4444+ switch (port) {4545+ case 0: /* OTG port */4646+ v &= ~(MX27_OTG_SIC_MASK | MX27_OTG_PM_BIT);4747+ v |= (flags & MXC_EHCI_INTERFACE_MASK) << MX27_OTG_SIC_SHIFT;4848+4949+ if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))5050+ v |= MX27_OTG_PM_BIT;5151+ break;5252+ case 1: /* H1 port */5353+ v &= ~(MX27_H1_SIC_MASK | MX27_H1_PM_BIT | MX27_H1_DT_BIT);5454+ v |= (flags & MXC_EHCI_INTERFACE_MASK) << MX27_H1_SIC_SHIFT;5555+5656+ if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))5757+ v |= MX27_H1_PM_BIT;5858+5959+ if (!(flags & MXC_EHCI_TTL_ENABLED))6060+ v |= MX27_H1_DT_BIT;6161+6262+ break;6363+ case 2: /* H2 port */6464+ v &= ~(MX27_H2_SIC_MASK | MX27_H2_PM_BIT | MX27_H2_DT_BIT);6565+ v |= (flags & MXC_EHCI_INTERFACE_MASK) << MX27_H2_SIC_SHIFT;6666+6767+ if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))6868+ v |= MX27_H2_PM_BIT;6969+7070+ if (!(flags & MXC_EHCI_TTL_ENABLED))7171+ v |= MX27_H2_DT_BIT;7272+7373+ break;7474+ default:7575+ return -EINVAL;7676+ }7777+7878+ writel(v, MX27_IO_ADDRESS(MX27_USB_BASE_ADDR + USBCTRL_OTGBASE_OFFSET));7979+8080+ return 0;8181+}8282+
···11+/*22+ * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved.33+ *44+ * Author: Fabio Estevam <fabio.estevam@freescale.com>55+ *66+ * This program is free software; you can redistribute it and/or modify77+ * it under the terms of the GNU General Public License as published by88+ * the Free Software Foundation; either version 2 of the License, or99+ * (at your option) any later version.1010+ *1111+ * This program is distributed in the hope that it will be useful,1212+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1313+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1414+ * GNU General Public License for more details.1515+ */1616+1717+#include <asm/mach-types.h>1818+#include <asm/mach/arch.h>1919+#include <asm/mach/time.h>2020+#include <mach/hardware.h>2121+#include <mach/common.h>2222+#include <mach/iomux-mx27.h>2323+2424+#include "devices-imx27.h"2525+2626+static const int mx27ipcam_pins[] __initconst = {2727+ /* UART1 */2828+ PE12_PF_UART1_TXD,2929+ PE13_PF_UART1_RXD,3030+ /* FEC */3131+ PD0_AIN_FEC_TXD0,3232+ PD1_AIN_FEC_TXD1,3333+ PD2_AIN_FEC_TXD2,3434+ PD3_AIN_FEC_TXD3,3535+ PD4_AOUT_FEC_RX_ER,3636+ PD5_AOUT_FEC_RXD1,3737+ PD6_AOUT_FEC_RXD2,3838+ PD7_AOUT_FEC_RXD3,3939+ PD8_AF_FEC_MDIO,4040+ PD9_AIN_FEC_MDC,4141+ PD10_AOUT_FEC_CRS,4242+ PD11_AOUT_FEC_TX_CLK,4343+ PD12_AOUT_FEC_RXD0,4444+ PD13_AOUT_FEC_RX_DV,4545+ PD14_AOUT_FEC_RX_CLK,4646+ PD15_AOUT_FEC_COL,4747+ PD16_AIN_FEC_TX_ER,4848+ PF23_AIN_FEC_TX_EN,4949+};5050+5151+static void __init mx27ipcam_init(void)5252+{5353+ mxc_gpio_setup_multiple_pins(mx27ipcam_pins, ARRAY_SIZE(mx27ipcam_pins),5454+ "mx27ipcam");5555+5656+ imx27_add_imx_uart0(NULL);5757+ imx27_add_fec(NULL);5858+ imx27_add_imx2_wdt(NULL);5959+}6060+6161+static void __init mx27ipcam_timer_init(void)6262+{6363+ mx27_clocks_init(25000000);6464+}6565+6666+static struct sys_timer mx27ipcam_timer = {6767+ .init = mx27ipcam_timer_init,6868+};6969+7070+MACHINE_START(IMX27IPCAM, "Freescale IMX27IPCAM")7171+ /* maintainer: Freescale Semiconductor, Inc. */7272+ .boot_params = MX27_PHYS_OFFSET + 0x100,7373+ .map_io = mx27_map_io,7474+ .init_early = imx27_init_early,7575+ .init_irq = mx27_init_irq,7676+ .timer = &mx27ipcam_timer,7777+ .init_machine = mx27ipcam_init,7878+MACHINE_END
···9494 select MXC_DEBUG_BOARD9595 select IMX_HAVE_PLATFORM_FSL_USB2_UDC9696 select IMX_HAVE_PLATFORM_IMX2_WDT9797+ select IMX_HAVE_PLATFORM_IMX_I2C9798 select IMX_HAVE_PLATFORM_IMX_KEYPAD9899 select IMX_HAVE_PLATFORM_IMX_UART99100 select IMX_HAVE_PLATFORM_MXC_EHCI···184183 select MXC_DEBUG_BOARD185184 select IMX_HAVE_PLATFORM_FSL_USB2_UDC186185 select IMX_HAVE_PLATFORM_IMX2_WDT186186+ select IMX_HAVE_PLATFORM_IMX_I2C187187 select IMX_HAVE_PLATFORM_IMX_UART188188 select IMX_HAVE_PLATFORM_MXC_EHCI189189 select IMX_HAVE_PLATFORM_MXC_NAND···199197 select IMX_HAVE_PLATFORM_IMX_UART200198 help201199 Include support for KZM-ARM11-01. This includes specific200200+ configurations for the board and its peripherals.201201+202202+config MACH_BUG203203+ bool "Support Buglabs BUGBase platform"204204+ select SOC_IMX31205205+ select IMX_HAVE_PLATFORM_IMX_UART206206+ default y207207+ help208208+ Include support for BUGBase 1.3 platform. This includes specific202209 configurations for the board and its peripherals.203210204211config MACH_EUKREA_CPUIMX35···239228 MBIMXSD evaluation board.240229241230endchoice231231+232232+config MACH_VPR200233233+ bool "Support VPR200 platform"234234+ select SOC_IMX35235235+ select IMX_HAVE_PLATFORM_FSL_USB2_UDC236236+ select IMX_HAVE_PLATFORM_IMX2_WDT237237+ select IMX_HAVE_PLATFORM_IMX_UART238238+ select IMX_HAVE_PLATFORM_IMX_I2C239239+ select IMX_HAVE_PLATFORM_MXC_EHCI240240+ select IMX_HAVE_PLATFORM_MXC_NAND241241+ select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX242242+ help243243+ Include support for VPR200 platform. This includes specific244244+ configurations for the board and its peripherals.242245243246endif
···11+/*22+ * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>33+ * Copyright (C) 2010 Freescale Semiconductor, Inc.44+ *55+ * This program is free software; you can redistribute it and/or modify it66+ * under the terms of the GNU General Public License as published by the77+ * Free Software Foundation; either version 2 of the License, or (at your88+ * option) any later version.99+ *1010+ * This program is distributed in the hope that it will be useful, but1111+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY1212+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License1313+ * for more details.1414+ */1515+1616+#include <linux/platform_device.h>1717+#include <linux/io.h>1818+1919+#include <mach/hardware.h>2020+#include <mach/mxc_ehci.h>2121+2222+#define USBCTRL_OTGBASE_OFFSET 0x6002323+2424+#define MX31_OTG_SIC_SHIFT 292525+#define MX31_OTG_SIC_MASK (0x3 << MX31_OTG_SIC_SHIFT)2626+#define MX31_OTG_PM_BIT (1 << 24)2727+2828+#define MX31_H2_SIC_SHIFT 212929+#define MX31_H2_SIC_MASK (0x3 << MX31_H2_SIC_SHIFT)3030+#define MX31_H2_PM_BIT (1 << 16)3131+#define MX31_H2_DT_BIT (1 << 5)3232+3333+#define MX31_H1_SIC_SHIFT 133434+#define MX31_H1_SIC_MASK (0x3 << MX31_H1_SIC_SHIFT)3535+#define MX31_H1_PM_BIT (1 << 8)3636+#define MX31_H1_DT_BIT (1 << 4)3737+3838+int mx31_initialize_usb_hw(int port, unsigned int flags)3939+{4040+ unsigned int v;4141+4242+ v = readl(MX31_IO_ADDRESS(MX31_USB_BASE_ADDR + USBCTRL_OTGBASE_OFFSET));4343+4444+ switch (port) {4545+ case 0: /* OTG port */4646+ v &= ~(MX31_OTG_SIC_MASK | MX31_OTG_PM_BIT);4747+ v |= (flags & MXC_EHCI_INTERFACE_MASK) << MX31_OTG_SIC_SHIFT;4848+4949+ if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))5050+ v |= MX31_OTG_PM_BIT;5151+5252+ break;5353+ case 1: /* H1 port */5454+ v &= ~(MX31_H1_SIC_MASK | MX31_H1_PM_BIT | MX31_H1_DT_BIT);5555+ v |= (flags & MXC_EHCI_INTERFACE_MASK) << MX31_H1_SIC_SHIFT;5656+5757+ if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))5858+ v |= MX31_H1_PM_BIT;5959+6060+ if (!(flags & MXC_EHCI_TTL_ENABLED))6161+ v |= MX31_H1_DT_BIT;6262+6363+ break;6464+ case 2: /* H2 port */6565+ v &= ~(MX31_H2_SIC_MASK | MX31_H2_PM_BIT | MX31_H2_DT_BIT);6666+ v |= (flags & MXC_EHCI_INTERFACE_MASK) << MX31_H2_SIC_SHIFT;6767+6868+ if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))6969+ v |= MX31_H2_PM_BIT;7070+7171+ if (!(flags & MXC_EHCI_TTL_ENABLED))7272+ v |= MX31_H2_DT_BIT;7373+7474+ break;7575+ default:7676+ return -EINVAL;7777+ }7878+7979+ writel(v, MX31_IO_ADDRESS(MX31_USB_BASE_ADDR + USBCTRL_OTGBASE_OFFSET));8080+8181+ return 0;8282+}8383+
+80
arch/arm/mach-mx3/ehci-imx35.c
···11+/*22+ * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>33+ * Copyright (C) 2010 Freescale Semiconductor, Inc.44+ *55+ * This program is free software; you can redistribute it and/or modify it66+ * under the terms of the GNU General Public License as published by the77+ * Free Software Foundation; either version 2 of the License, or (at your88+ * option) any later version.99+ *1010+ * This program is distributed in the hope that it will be useful, but1111+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY1212+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License1313+ * for more details.1414+ */1515+1616+#include <linux/platform_device.h>1717+#include <linux/io.h>1818+1919+#include <mach/hardware.h>2020+#include <mach/mxc_ehci.h>2121+2222+#define USBCTRL_OTGBASE_OFFSET 0x6002323+2424+#define MX35_OTG_SIC_SHIFT 292525+#define MX35_OTG_SIC_MASK (0x3 << MX35_OTG_SIC_SHIFT)2626+#define MX35_OTG_PM_BIT (1 << 24)2727+2828+#define MX35_H1_SIC_SHIFT 212929+#define MX35_H1_SIC_MASK (0x3 << MX35_H1_SIC_SHIFT)3030+#define MX35_H1_PM_BIT (1 << 8)3131+#define MX35_H1_IPPUE_UP_BIT (1 << 7)3232+#define MX35_H1_IPPUE_DOWN_BIT (1 << 6)3333+#define MX35_H1_TLL_BIT (1 << 5)3434+#define MX35_H1_USBTE_BIT (1 << 4)3535+3636+int mx35_initialize_usb_hw(int port, unsigned int flags)3737+{3838+ unsigned int v;3939+4040+ v = readl(MX35_IO_ADDRESS(MX35_USB_BASE_ADDR + USBCTRL_OTGBASE_OFFSET));4141+4242+ switch (port) {4343+ case 0: /* OTG port */4444+ v &= ~(MX35_OTG_SIC_MASK | MX35_OTG_PM_BIT);4545+ v |= (flags & MXC_EHCI_INTERFACE_MASK) << MX35_OTG_SIC_SHIFT;4646+4747+ if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))4848+ v |= MX35_OTG_PM_BIT;4949+5050+ break;5151+ case 1: /* H1 port */5252+ v &= ~(MX35_H1_SIC_MASK | MX35_H1_PM_BIT | MX35_H1_TLL_BIT |5353+ MX35_H1_USBTE_BIT | MX35_H1_IPPUE_DOWN_BIT | MX35_H1_IPPUE_UP_BIT);5454+ v |= (flags & MXC_EHCI_INTERFACE_MASK) << MX35_H1_SIC_SHIFT;5555+5656+ if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))5757+ v |= MX35_H1_PM_BIT;5858+5959+ if (!(flags & MXC_EHCI_TTL_ENABLED))6060+ v |= MX35_H1_TLL_BIT;6161+6262+ if (flags & MXC_EHCI_INTERNAL_PHY)6363+ v |= MX35_H1_USBTE_BIT;6464+6565+ if (flags & MXC_EHCI_IPPUE_DOWN)6666+ v |= MX35_H1_IPPUE_DOWN_BIT;6767+6868+ if (flags & MXC_EHCI_IPPUE_UP)6969+ v |= MX35_H1_IPPUE_UP_BIT;7070+7171+ break;7272+ default:7373+ return -EINVAL;7474+ }7575+7676+ writel(v, MX35_IO_ADDRESS(MX35_USB_BASE_ADDR + USBCTRL_OTGBASE_OFFSET));7777+7878+ return 0;7979+}8080+
···9797 * - reserves the pin so that it is not claimed by another driver9898 * - setups the iomux according to the configuration9999 */100100-int mxc_iomux_alloc_pin(const unsigned int pin, const char *label)100100+int mxc_iomux_alloc_pin(unsigned int pin, const char *label)101101{102102 unsigned pad = pin & IOMUX_PADNUM_MASK;103103···118118}119119EXPORT_SYMBOL(mxc_iomux_alloc_pin);120120121121-int mxc_iomux_setup_multiple_pins(unsigned int *pin_list, unsigned count,121121+int mxc_iomux_setup_multiple_pins(const unsigned int *pin_list, unsigned count,122122 const char *label)123123{124124- unsigned int *p = pin_list;124124+ const unsigned int *p = pin_list;125125 int i;126126 int ret = -EINVAL;127127···139139}140140EXPORT_SYMBOL(mxc_iomux_setup_multiple_pins);141141142142-void mxc_iomux_release_pin(const unsigned int pin)142142+void mxc_iomux_release_pin(unsigned int pin)143143{144144 unsigned pad = pin & IOMUX_PADNUM_MASK;145145···148148}149149EXPORT_SYMBOL(mxc_iomux_release_pin);150150151151-void mxc_iomux_release_multiple_pins(unsigned int *pin_list, int count)151151+void mxc_iomux_release_multiple_pins(const unsigned int *pin_list, int count)152152{153153- unsigned int *p = pin_list;153153+ const unsigned int *p = pin_list;154154 int i;155155156156 for (i = 0; i < count; i++) {
···11+/*22+ * Copyright (C) 2000 Deep Blue Solutions Ltd33+ * Copyright (C) 2002 Shane Nay (shane@minirl.com)44+ * Copyright 2005-2007 Freescale Semiconductor, Inc. All Rights Reserved.55+ * Copyright 2011 Denis 'GNUtoo' Carikli <GNUtoo@no-log.org>66+ *77+ * This program is free software; you can redistribute it and/or modify88+ * it under the terms of the GNU General Public License as published by99+ * the Free Software Foundation; either version 2 of the License, or1010+ * (at your option) any later version.1111+ *1212+ * This program is distributed in the hope that it will be useful,1313+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1414+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1515+ * GNU General Public License for more details.1616+ */1717+1818+#include <linux/kernel.h>1919+#include <linux/init.h>2020+#include <linux/platform_device.h>2121+2222+#include <mach/iomux-mx3.h>2323+#include <mach/imx-uart.h>2424+#include <mach/hardware.h>2525+#include <mach/common.h>2626+2727+#include <asm/mach/time.h>2828+#include <asm/mach/arch.h>2929+#include <asm/mach-types.h>3030+3131+#include "devices-imx31.h"3232+3333+static const struct imxuart_platform_data uart_pdata __initconst = {3434+ .flags = IMXUART_HAVE_RTSCTS,3535+};3636+3737+static const unsigned int bug_pins[] __initconst = {3838+ MX31_PIN_PC_RST__CTS5,3939+ MX31_PIN_PC_VS2__RTS5,4040+ MX31_PIN_PC_BVD2__TXD5,4141+ MX31_PIN_PC_BVD1__RXD5,4242+};4343+4444+static void __init bug_board_init(void)4545+{4646+ mxc_iomux_setup_multiple_pins(bug_pins,4747+ ARRAY_SIZE(bug_pins), "uart-4");4848+ imx31_add_imx_uart4(&uart_pdata);4949+}5050+5151+static void __init bug_timer_init(void)5252+{5353+ mx31_clocks_init(26000000);5454+}5555+5656+static struct sys_timer bug_timer = {5757+ .init = bug_timer_init,5858+};5959+6060+MACHINE_START(BUG, "BugLabs BUGBase")6161+ .map_io = mx31_map_io,6262+ .init_early = imx31_init_early,6363+ .init_irq = mx31_init_irq,6464+ .timer = &bug_timer,6565+ .init_machine = bug_board_init,6666+MACHINE_END
···11if ARCH_MX522-# ARCH_MX51 and ARCH_MX50 are left for compatibility22+# ARCH_MX50/51/53 are left to mark places where prevent multi-soc in single33+# image. So for most time, SOC_IMX50/51/53 should be used.3445config ARCH_MX5056 bool···5150config MACH_MX51_3DS5251 bool "Support MX51PDK (3DS)"5352 select SOC_IMX515353+ select IMX_HAVE_PLATFORM_IMX2_WDT5454 select IMX_HAVE_PLATFORM_IMX_KEYPAD5555 select IMX_HAVE_PLATFORM_IMX_UART5656 select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX···114112115113endchoice116114117117-config MACH_MX51_EFIKAMX118118- bool "Support MX51 Genesi Efika MX nettop"115115+config MX51_EFIKA_COMMON116116+ bool119117 select SOC_IMX51120118 select IMX_HAVE_PLATFORM_IMX_UART121119 select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX122120 select IMX_HAVE_PLATFORM_SPI_IMX121121+ select MXC_ULPI if USB_ULPI122122+123123+config MACH_MX51_EFIKAMX124124+ bool "Support MX51 Genesi Efika MX nettop"125125+ select MX51_EFIKA_COMMON123126 help124127 Include support for Genesi Efika MX nettop. This includes specific128128+ configurations for the board and its peripherals.129129+130130+config MACH_MX51_EFIKASB131131+ bool "Support MX51 Genesi Efika Smartbook"132132+ select MX51_EFIKA_COMMON133133+ help134134+ Include support for Genesi Efika Smartbook. This includes specific125135 configurations for the board and its peripherals.126136127137config MACH_MX53_EVK128138 bool "Support MX53 EVK platforms"129139 select SOC_IMX53140140+ select IMX_HAVE_PLATFORM_IMX2_WDT130141 select IMX_HAVE_PLATFORM_IMX_UART131142 select IMX_HAVE_PLATFORM_IMX_I2C132143 select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX···151136config MACH_MX53_SMD152137 bool "Support MX53 SMD platforms"153138 select SOC_IMX53139139+ select IMX_HAVE_PLATFORM_IMX2_WDT140140+ select IMX_HAVE_PLATFORM_IMX_I2C154141 select IMX_HAVE_PLATFORM_IMX_UART155142 help156143 Include support for MX53 SMD platform. This includes specific···161144config MACH_MX53_LOCO162145 bool "Support MX53 LOCO platforms"163146 select SOC_IMX53147147+ select IMX_HAVE_PLATFORM_IMX2_WDT148148+ select IMX_HAVE_PLATFORM_IMX_I2C164149 select IMX_HAVE_PLATFORM_IMX_UART150150+ select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX165151 help166152 Include support for MX53 LOCO platform. This includes specific167153 configurations for the board and its peripherals.···177157 select IMX_HAVE_PLATFORM_IMX_UART178158 select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX179159 select IMX_HAVE_PLATFORM_SPI_IMX160160+ select IMX_HAVE_PLATFORM_FEC180161 help181162 Include support for MX50 reference design platform (RDP) board. This182163 includes specific configurations for the board and its peripherals.
···5050/*5151 * set the mode for a IOMUX pin.5252 */5353-int mxc_iomux_mode(const unsigned int pin_mode)5353+int mxc_iomux_mode(unsigned int pin_mode)5454{5555 u32 side, field, l, mode, ret = 0;5656 void __iomem *reg;···114114 * - reserves the pin so that it is not claimed by another driver115115 * - setups the iomux according to the configuration116116 */117117-int mxc_iomux_alloc_pin(const unsigned int pin_mode, const char *label)117117+int mxc_iomux_alloc_pin(unsigned int pin_mode, const char *label)118118{119119 unsigned pad = PIN_GLOBAL_NUM(pin_mode);120120 if (pad >= (PIN_MAX + 1)) {···134134}135135EXPORT_SYMBOL(mxc_iomux_alloc_pin);136136137137-int mxc_iomux_setup_multiple_pins(unsigned int *pin_list, unsigned count,137137+int mxc_iomux_setup_multiple_pins(const unsigned int *pin_list, unsigned count,138138 const char *label)139139{140140- unsigned int *p = pin_list;140140+ const unsigned int *p = pin_list;141141 int i;142142 int ret = -EINVAL;143143···155155}156156EXPORT_SYMBOL(mxc_iomux_setup_multiple_pins);157157158158-void mxc_iomux_release_pin(const unsigned int pin_mode)158158+void mxc_iomux_release_pin(unsigned int pin_mode)159159{160160 unsigned pad = PIN_GLOBAL_NUM(pin_mode);161161···164164}165165EXPORT_SYMBOL(mxc_iomux_release_pin);166166167167-void mxc_iomux_release_multiple_pins(unsigned int *pin_list, int count)167167+void mxc_iomux_release_multiple_pins(const unsigned int *pin_list, int count)168168{169169- unsigned int *p = pin_list;169169+ const unsigned int *p = pin_list;170170 int i;171171172172 for (i = 0; i < count; i++) {
···6666 ret = platform_device_add(pdev);6767 if (ret) {6868err:6969+ if (dmamask)7070+ kfree(pdev->dev.dma_mask);6971 platform_device_put(pdev);7072 return ERR_PTR(ret);7173 }
···11+/*22+ * Copyright (C) 2010 Pengutronix33+ * Sascha Hauer <s.hauer@pengutronix.de>44+ *55+ * This program is free software; you can redistribute it and/or modify it under66+ * the terms of the GNU General Public License version 2 as published by the77+ * Free Software Foundation.88+ */99+#include <asm/sizes.h>1010+#include <mach/mx23.h>1111+#include <mach/mx28.h>1212+#include <mach/devices-common.h>1313+1414+#define mxs_auart_data_entry_single(soc, _id, hwid) \1515+ { \1616+ .id = _id, \1717+ .iobase = soc ## _AUART ## hwid ## _BASE_ADDR, \1818+ .irq = soc ## _INT_AUART ## hwid, \1919+ }2020+2121+#define mxs_auart_data_entry(soc, _id, hwid) \2222+ [_id] = mxs_auart_data_entry_single(soc, _id, hwid)2323+2424+#ifdef CONFIG_SOC_IMX232525+const struct mxs_auart_data mx23_auart_data[] __initconst = {2626+#define mx23_auart_data_entry(_id, hwid) \2727+ mxs_auart_data_entry(MX23, _id, hwid)2828+ mx23_auart_data_entry(0, 1),2929+ mx23_auart_data_entry(1, 2),3030+};3131+#endif3232+3333+#ifdef CONFIG_SOC_IMX283434+const struct mxs_auart_data mx28_auart_data[] __initconst = {3535+#define mx28_auart_data_entry(_id) \3636+ mxs_auart_data_entry(MX28, _id, _id)3737+ mx28_auart_data_entry(0),3838+ mx28_auart_data_entry(1),3939+ mx28_auart_data_entry(2),4040+ mx28_auart_data_entry(3),4141+ mx28_auart_data_entry(4),4242+};4343+#endif4444+4545+struct platform_device *__init mxs_add_auart(4646+ const struct mxs_auart_data *data)4747+{4848+ struct resource res[] = {4949+ {5050+ .start = data->iobase,5151+ .end = data->iobase + SZ_8K - 1,5252+ .flags = IORESOURCE_MEM,5353+ }, {5454+ .start = data->irq,5555+ .end = data->irq,5656+ .flags = IORESOURCE_IRQ,5757+ },5858+ };5959+6060+ return mxs_add_platform_device_dmamask("mxs-auart", data->id,6161+ res, ARRAY_SIZE(res), NULL, 0,6262+ DMA_BIT_MASK(32));6363+}6464+
+49
arch/arm/mach-mxs/devices/platform-dma.c
···11+/*22+ * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved.33+ *44+ * This program is free software; you can redistribute it and/or modify it under55+ * the terms of the GNU General Public License version 2 as published by the66+ * Free Software Foundation.77+ */88+#include <linux/compiler.h>99+#include <linux/err.h>1010+#include <linux/init.h>1111+1212+#include <mach/mx23.h>1313+#include <mach/mx28.h>1414+#include <mach/devices-common.h>1515+1616+static struct platform_device *__init mxs_add_dma(const char *devid,1717+ resource_size_t base)1818+{1919+ struct resource res[] = {2020+ {2121+ .start = base,2222+ .end = base + SZ_8K - 1,2323+ .flags = IORESOURCE_MEM,2424+ }2525+ };2626+2727+ return mxs_add_platform_device_dmamask(devid, -1,2828+ res, ARRAY_SIZE(res), NULL, 0,2929+ DMA_BIT_MASK(32));3030+}3131+3232+static int __init mxs_add_mxs_dma(void)3333+{3434+ char *apbh = "mxs-dma-apbh";3535+ char *apbx = "mxs-dma-apbx";3636+3737+ if (cpu_is_mx23()) {3838+ mxs_add_dma(apbh, MX23_APBH_DMA_BASE_ADDR);3939+ mxs_add_dma(apbx, MX23_APBX_DMA_BASE_ADDR);4040+ }4141+4242+ if (cpu_is_mx28()) {4343+ mxs_add_dma(apbh, MX28_APBH_DMA_BASE_ADDR);4444+ mxs_add_dma(apbx, MX28_APBX_DMA_BASE_ADDR);4545+ }4646+4747+ return 0;4848+}4949+arch_initcall(mxs_add_mxs_dma);
···11+/*22+ * Copyright (C) 2010, 2011 Pengutronix,33+ * Marc Kleine-Budde <kernel@pengutronix.de>44+ *55+ * This program is free software; you can redistribute it and/or modify it under66+ * the terms of the GNU General Public License version 2 as published by the77+ * Free Software Foundation.88+ */99+#include <asm/sizes.h>1010+#include <mach/mx28.h>1111+#include <mach/devices-common.h>1212+1313+#define mxs_flexcan_data_entry_single(soc, _id, _hwid, _size) \1414+ { \1515+ .id = _id, \1616+ .iobase = soc ## _CAN ## _hwid ## _BASE_ADDR, \1717+ .iosize = _size, \1818+ .irq = soc ## _INT_CAN ## _hwid, \1919+ }2020+2121+#define mxs_flexcan_data_entry(soc, _id, _hwid, _size) \2222+ [_id] = mxs_flexcan_data_entry_single(soc, _id, _hwid, _size)2323+2424+#ifdef CONFIG_SOC_IMX282525+const struct mxs_flexcan_data mx28_flexcan_data[] __initconst = {2626+#define mx28_flexcan_data_entry(_id, _hwid) \2727+ mxs_flexcan_data_entry_single(MX28, _id, _hwid, SZ_8K)2828+ mx28_flexcan_data_entry(0, 0),2929+ mx28_flexcan_data_entry(1, 1),3030+};3131+#endif /* ifdef CONFIG_SOC_IMX28 */3232+3333+struct platform_device *__init mxs_add_flexcan(3434+ const struct mxs_flexcan_data *data,3535+ const struct flexcan_platform_data *pdata)3636+{3737+ struct resource res[] = {3838+ {3939+ .start = data->iobase,4040+ .end = data->iobase + data->iosize - 1,4141+ .flags = IORESOURCE_MEM,4242+ }, {4343+ .start = data->irq,4444+ .end = data->irq,4545+ .flags = IORESOURCE_IRQ,4646+ },4747+ };4848+4949+ return mxs_add_platform_device("flexcan", data->id,5050+ res, ARRAY_SIZE(res), pdata, sizeof(*pdata));5151+}
+51
arch/arm/mach-mxs/devices/platform-mxs-i2c.c
···11+/*22+ * Copyright (C) 2011 Pengutronix33+ * Wolfram Sang <w.sang@pengutronix.de>44+ *55+ * This program is free software; you can redistribute it and/or modify it under66+ * the terms of the GNU General Public License version 2 as published by the77+ * Free Software Foundation.88+ */99+#include <asm/sizes.h>1010+#include <mach/mx28.h>1111+#include <mach/devices-common.h>1212+1313+#define mxs_i2c_data_entry_single(soc, _id) \1414+ { \1515+ .id = _id, \1616+ .iobase = soc ## _I2C ## _id ## _BASE_ADDR, \1717+ .errirq = soc ## _INT_I2C ## _id ## _ERROR, \1818+ .dmairq = soc ## _INT_I2C ## _id ## _DMA, \1919+ }2020+2121+#define mxs_i2c_data_entry(soc, _id) \2222+ [_id] = mxs_i2c_data_entry_single(soc, _id)2323+2424+#ifdef CONFIG_SOC_IMX282525+const struct mxs_i2c_data mx28_mxs_i2c_data[] __initconst = {2626+ mxs_i2c_data_entry(MX28, 0),2727+ mxs_i2c_data_entry(MX28, 1),2828+};2929+#endif3030+3131+struct platform_device *__init mxs_add_mxs_i2c(const struct mxs_i2c_data *data)3232+{3333+ struct resource res[] = {3434+ {3535+ .start = data->iobase,3636+ .end = data->iobase + SZ_8K - 1,3737+ .flags = IORESOURCE_MEM,3838+ }, {3939+ .start = data->errirq,4040+ .end = data->errirq,4141+ .flags = IORESOURCE_IRQ,4242+ }, {4343+ .start = data->dmairq,4444+ .end = data->dmairq,4545+ .flags = IORESOURCE_IRQ,4646+ },4747+ };4848+4949+ return mxs_add_platform_device("mxs-i2c", data->id, res,5050+ ARRAY_SIZE(res), NULL, 0);5151+}
+22
arch/arm/mach-mxs/devices/platform-mxs-pwm.c
···11+/*22+ * Copyright (C) 2010 Pengutronix33+ * Sascha Hauer <s.hauer@pengutronix.de>44+ *55+ * This program is free software; you can redistribute it and/or modify it under66+ * the terms of the GNU General Public License version 2 as published by the77+ * Free Software Foundation.88+ */99+#include <asm/sizes.h>1010+#include <mach/devices-common.h>1111+1212+struct platform_device *__init mxs_add_mxs_pwm(resource_size_t iobase, int id)1313+{1414+ struct resource res = {1515+ .flags = IORESOURCE_MEM,1616+ };1717+1818+ res.start = iobase + 0x10 + 0x20 * id;1919+ res.end = res.start + 0x1f;2020+2121+ return mxs_add_platform_device("mxs-pwm", id, &res, 1, NULL, 0);2222+}
+46
arch/arm/mach-mxs/devices/platform-mxsfb.c
···11+/*22+ * Copyright (C) 2011 Pengutronix, Sascha Hauer <s.hauer@pengutronix.de>33+ *44+ * This program is free software; you can redistribute it and/or modify it under55+ * the terms of the GNU General Public License version 2 as published by the66+ * Free Software Foundation.77+ */88+#include <asm/sizes.h>99+#include <mach/mx23.h>1010+#include <mach/mx28.h>1111+#include <mach/devices-common.h>1212+#include <mach/mxsfb.h>1313+1414+#ifdef CONFIG_SOC_IMX231515+struct platform_device *__init mx23_add_mxsfb(1616+ const struct mxsfb_platform_data *pdata)1717+{1818+ struct resource res[] = {1919+ {2020+ .start = MX23_LCDIF_BASE_ADDR,2121+ .end = MX23_LCDIF_BASE_ADDR + SZ_8K - 1,2222+ .flags = IORESOURCE_MEM,2323+ },2424+ };2525+2626+ return mxs_add_platform_device_dmamask("imx23-fb", -1,2727+ res, ARRAY_SIZE(res), pdata, sizeof(*pdata), DMA_BIT_MASK(32));2828+}2929+#endif /* ifdef CONFIG_SOC_IMX23 */3030+3131+#ifdef CONFIG_SOC_IMX283232+struct platform_device *__init mx28_add_mxsfb(3333+ const struct mxsfb_platform_data *pdata)3434+{3535+ struct resource res[] = {3636+ {3737+ .start = MX28_LCDIF_BASE_ADDR,3838+ .end = MX28_LCDIF_BASE_ADDR + SZ_8K - 1,3939+ .flags = IORESOURCE_MEM,4040+ },4141+ };4242+4343+ return mxs_add_platform_device_dmamask("imx28-fb", -1,4444+ res, ARRAY_SIZE(res), pdata, sizeof(*pdata), DMA_BIT_MASK(32));4545+}4646+#endif /* ifdef CONFIG_SOC_IMX28 */
···11+/*22+ * This program is free software; you can redistribute it and/or33+ * modify it under the terms of the GNU General Public License44+ * as published by the Free Software Foundation; either version 255+ * of the License, or (at your option) any later version.66+ * This program is distributed in the hope that it will be useful,77+ * but WITHOUT ANY WARRANTY; without even the implied warranty of88+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the99+ * GNU General Public License for more details.1010+ *1111+ * You should have received a copy of the GNU General Public License1212+ * along with this program; if not, write to the Free Software1313+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,1414+ * MA 02110-1301, USA.1515+ */1616+1717+#ifndef __MACH_FB_H1818+#define __MACH_FB_H1919+2020+#include <linux/fb.h>2121+2222+#define STMLCDIF_8BIT 1 /** pixel data bus to the display is of 8 bit width */2323+#define STMLCDIF_16BIT 0 /** pixel data bus to the display is of 16 bit width */2424+#define STMLCDIF_18BIT 2 /** pixel data bus to the display is of 18 bit width */2525+#define STMLCDIF_24BIT 3 /** pixel data bus to the display is of 24 bit width */2626+2727+#define FB_SYNC_DATA_ENABLE_HIGH_ACT (1 << 6)2828+#define FB_SYNC_DOTCLK_FAILING_ACT (1 << 7) /* failing/negtive edge sampling */2929+3030+struct mxsfb_platform_data {3131+ struct fb_videomode *mode_list;3232+ unsigned mode_count;3333+3434+ unsigned default_bpp;3535+3636+ unsigned dotclk_delay; /* refer manual HW_LCDIF_VDCTRL4 register */3737+ unsigned ld_intf_width; /* refer STMLCDIF_* macros */3838+3939+ unsigned fb_size; /* Size of the video memory. If zero a4040+ * default will be used4141+ */4242+ unsigned long fb_phys; /* physical address for the video memory. If4343+ * zero the framebuffer memory will be dynamically4444+ * allocated. If specified,fb_size must also be specified.4545+ * fb_phys must be unused by Linux.4646+ */4747+};4848+4949+#endif /* __MACH_FB_H */
+1
arch/arm/mach-mxs/include/mach/uncompress.h
···6363 mxs_duart_base = MX23_DUART_BASE_ADDR;6464 break;6565 case MACH_TYPE_MX28EVK:6666+ case MACH_TYPE_TX28:6667 mxs_duart_base = MX28_DUART_BASE_ADDR;6768 break;6869 default:
···11+/*22+ * Copyright (C) 2010 <LW@KARO-electronics.de>33+ *44+ * This program is free software; you can redistribute it and/or modify it under55+ * the terms of the GNU General Public License version 2 as published by the66+ * Free Software Foundation.77+ */88+99+#include <linux/delay.h>1010+#include <linux/fec.h>1111+#include <linux/gpio.h>1212+1313+#include <mach/iomux-mx28.h>1414+#include "../devices-mx28.h"1515+1616+#include "module-tx28.h"1717+1818+#define TX28_FEC_PHY_POWER MXS_GPIO_NR(3, 29)1919+#define TX28_FEC_PHY_RESET MXS_GPIO_NR(4, 13)2020+2121+static const iomux_cfg_t tx28_fec_gpio_pads[] __initconst = {2222+ /* PHY POWER */2323+ MX28_PAD_PWM4__GPIO_3_29 |2424+ MXS_PAD_4MA | MXS_PAD_NOPULL | MXS_PAD_3V3,2525+ /* PHY RESET */2626+ MX28_PAD_ENET0_RX_CLK__GPIO_4_13 |2727+ MXS_PAD_4MA | MXS_PAD_NOPULL | MXS_PAD_3V3,2828+ /* Mode strap pins 0-2 */2929+ MX28_PAD_ENET0_RXD0__GPIO_4_3 |3030+ MXS_PAD_8MA | MXS_PAD_PULLUP | MXS_PAD_3V3,3131+ MX28_PAD_ENET0_RXD1__GPIO_4_4 |3232+ MXS_PAD_8MA | MXS_PAD_PULLUP | MXS_PAD_3V3,3333+ MX28_PAD_ENET0_RX_EN__GPIO_4_2 |3434+ MXS_PAD_8MA | MXS_PAD_PULLUP | MXS_PAD_3V3,3535+ /* nINT */3636+ MX28_PAD_ENET0_TX_CLK__GPIO_4_5 |3737+ MXS_PAD_4MA | MXS_PAD_NOPULL | MXS_PAD_3V3,3838+3939+ MX28_PAD_ENET0_MDC__GPIO_4_0,4040+ MX28_PAD_ENET0_MDIO__GPIO_4_1,4141+ MX28_PAD_ENET0_TX_EN__GPIO_4_6,4242+ MX28_PAD_ENET0_TXD0__GPIO_4_7,4343+ MX28_PAD_ENET0_TXD1__GPIO_4_8,4444+ MX28_PAD_ENET_CLK__GPIO_4_16,4545+};4646+4747+#define FEC_MODE (MXS_PAD_8MA | MXS_PAD_PULLUP | MXS_PAD_3V3)4848+static const iomux_cfg_t tx28_fec_pads[] __initconst = {4949+ MX28_PAD_ENET0_MDC__ENET0_MDC | FEC_MODE,5050+ MX28_PAD_ENET0_MDIO__ENET0_MDIO | FEC_MODE,5151+ MX28_PAD_ENET0_RX_EN__ENET0_RX_EN | FEC_MODE,5252+ MX28_PAD_ENET0_RXD0__ENET0_RXD0 | FEC_MODE,5353+ MX28_PAD_ENET0_RXD1__ENET0_RXD1 | FEC_MODE,5454+ MX28_PAD_ENET0_TX_EN__ENET0_TX_EN | FEC_MODE,5555+ MX28_PAD_ENET0_TXD0__ENET0_TXD0 | FEC_MODE,5656+ MX28_PAD_ENET0_TXD1__ENET0_TXD1 | FEC_MODE,5757+ MX28_PAD_ENET_CLK__CLKCTRL_ENET | FEC_MODE,5858+};5959+6060+static const struct fec_platform_data tx28_fec_data __initconst = {6161+ .phy = PHY_INTERFACE_MODE_RMII,6262+};6363+6464+int __init tx28_add_fec0(void)6565+{6666+ int i, ret;6767+6868+ pr_debug("%s: Switching FEC PHY power off\n", __func__);6969+ ret = mxs_iomux_setup_multiple_pads(tx28_fec_gpio_pads,7070+ ARRAY_SIZE(tx28_fec_gpio_pads));7171+ for (i = 0; i < ARRAY_SIZE(tx28_fec_gpio_pads); i++) {7272+ unsigned int gpio = MXS_GPIO_NR(PAD_BANK(tx28_fec_gpio_pads[i]),7373+ PAD_PIN(tx28_fec_gpio_pads[i]));7474+7575+ ret = gpio_request(gpio, "FEC");7676+ if (ret) {7777+ pr_err("Failed to request GPIO_%d_%d: %d\n",7878+ PAD_BANK(tx28_fec_gpio_pads[i]),7979+ PAD_PIN(tx28_fec_gpio_pads[i]), ret);8080+ goto free_gpios;8181+ }8282+ ret = gpio_direction_output(gpio, 0);8383+ if (ret) {8484+ pr_err("Failed to set direction of GPIO_%d_%d to output: %d\n",8585+ gpio / 32 + 1, gpio % 32, ret);8686+ goto free_gpios;8787+ }8888+ }8989+9090+ /* Power up fec phy */9191+ pr_debug("%s: Switching FEC PHY power on\n", __func__);9292+ ret = gpio_direction_output(TX28_FEC_PHY_POWER, 1);9393+ if (ret) {9494+ pr_err("Failed to power on PHY: %d\n", ret);9595+ goto free_gpios;9696+ }9797+ mdelay(26); /* 25ms according to data sheet */9898+9999+ /* nINT */100100+ gpio_direction_input(MXS_GPIO_NR(4, 5));101101+ /* Mode strap pins */102102+ gpio_direction_output(MXS_GPIO_NR(4, 2), 1);103103+ gpio_direction_output(MXS_GPIO_NR(4, 3), 1);104104+ gpio_direction_output(MXS_GPIO_NR(4, 4), 1);105105+106106+ udelay(100); /* minimum assertion time for nRST */107107+108108+ pr_debug("%s: Deasserting FEC PHY RESET\n", __func__);109109+ gpio_set_value(TX28_FEC_PHY_RESET, 1);110110+111111+ ret = mxs_iomux_setup_multiple_pads(tx28_fec_pads,112112+ ARRAY_SIZE(tx28_fec_pads));113113+ if (ret) {114114+ pr_debug("%s: mxs_iomux_setup_multiple_pads() failed with rc: %d\n",115115+ __func__, ret);116116+ goto free_gpios;117117+ }118118+ pr_debug("%s: Registering FEC device\n", __func__);119119+ mx28_add_fec(0, &tx28_fec_data);120120+ return 0;121121+122122+free_gpios:123123+ while (--i >= 0) {124124+ unsigned int gpio = MXS_GPIO_NR(PAD_BANK(tx28_fec_gpio_pads[i]),125125+ PAD_PIN(tx28_fec_gpio_pads[i]));126126+127127+ gpio_free(gpio);128128+ }129129+130130+ return ret;131131+}
+9
arch/arm/mach-mxs/module-tx28.h
···11+/*22+ * Copyright (C) 2010 Pengutronix33+ * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>44+ *55+ * This program is free software; you can redistribute it and/or modify it under66+ * the terms of the GNU General Public License version 2 as published by the77+ * Free Software Foundation.88+ */99+int __init tx28_add_fec0(void);
+90
arch/arm/mach-mxs/ocotp.c
···11+/*22+ * Copyright 2010 Freescale Semiconductor, Inc. All Rights Reserved.33+ *44+ * This program is free software; you can redistribute it and/or modify55+ * it under the terms of the GNU General Public License as published by66+ * the Free Software Foundation; either version 2 of the License, or77+ * (at your option) any later version.88+ *99+ * This program is distributed in the hope that it will be useful,1010+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1111+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1212+ * GNU General Public License for more details.1313+ */1414+1515+#include <linux/delay.h>1616+#include <linux/err.h>1717+#include <linux/mutex.h>1818+1919+#include <mach/mxs.h>2020+2121+#define OCOTP_WORD_OFFSET 0x202222+#define OCOTP_WORD_COUNT 0x202323+2424+#define BM_OCOTP_CTRL_BUSY (1 << 8)2525+#define BM_OCOTP_CTRL_ERROR (1 << 9)2626+#define BM_OCOTP_CTRL_RD_BANK_OPEN (1 << 12)2727+2828+static DEFINE_MUTEX(ocotp_mutex);2929+static u32 ocotp_words[OCOTP_WORD_COUNT];3030+3131+const u32 *mxs_get_ocotp(void)3232+{3333+ void __iomem *ocotp_base = MXS_IO_ADDRESS(MXS_OCOTP_BASE_ADDR);3434+ int timeout = 0x400;3535+ size_t i;3636+ static int once = 0;3737+3838+ if (once)3939+ return ocotp_words;4040+4141+ mutex_lock(&ocotp_mutex);4242+4343+ /*4444+ * clk_enable(hbus_clk) for ocotp can be skipped4545+ * as it must be on when system is running.4646+ */4747+4848+ /* try to clear ERROR bit */4949+ __mxs_clrl(BM_OCOTP_CTRL_ERROR, ocotp_base);5050+5151+ /* check both BUSY and ERROR cleared */5252+ while ((__raw_readl(ocotp_base) &5353+ (BM_OCOTP_CTRL_BUSY | BM_OCOTP_CTRL_ERROR)) && --timeout)5454+ cpu_relax();5555+5656+ if (unlikely(!timeout))5757+ goto error_unlock;5858+5959+ /* open OCOTP banks for read */6060+ __mxs_setl(BM_OCOTP_CTRL_RD_BANK_OPEN, ocotp_base);6161+6262+ /* approximately wait 32 hclk cycles */6363+ udelay(1);6464+6565+ /* poll BUSY bit becoming cleared */6666+ timeout = 0x400;6767+ while ((__raw_readl(ocotp_base) & BM_OCOTP_CTRL_BUSY) && --timeout)6868+ cpu_relax();6969+7070+ if (unlikely(!timeout))7171+ goto error_unlock;7272+7373+ for (i = 0; i < OCOTP_WORD_COUNT; i++)7474+ ocotp_words[i] = __raw_readl(ocotp_base + OCOTP_WORD_OFFSET +7575+ i * 0x10);7676+7777+ /* close banks for power saving */7878+ __mxs_clrl(BM_OCOTP_CTRL_RD_BANK_OPEN, ocotp_base);7979+8080+ once = 1;8181+8282+ mutex_unlock(&ocotp_mutex);8383+8484+ return ocotp_words;8585+8686+error_unlock:8787+ mutex_unlock(&ocotp_mutex);8888+ pr_err("%s: timeout in reading OCOTP\n", __func__);8989+ return NULL;9090+}
+43
arch/arm/mach-mxs/pm.c
···11+/*22+ * Copyright (C) 2010 Freescale Semiconductor, Inc.33+ *44+ * This program is free software; you can redistribute it and/or modify55+ * it under the terms of the GNU General Public License as published by66+ * the Free Software Foundation; either version 2 of the License, or77+ * (at your option) any later version.88+ *99+ * This program is distributed in the hope that it will be useful,1010+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1111+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1212+ * GNU General Public License for more details.1313+ */1414+1515+#include <linux/kernel.h>1616+#include <linux/suspend.h>1717+#include <linux/io.h>1818+#include <mach/system.h>1919+2020+static int mxs_suspend_enter(suspend_state_t state)2121+{2222+ switch (state) {2323+ case PM_SUSPEND_MEM:2424+ arch_idle();2525+ break;2626+2727+ default:2828+ return -EINVAL;2929+ }3030+ return 0;3131+}3232+3333+static struct platform_suspend_ops mxs_suspend_ops = {3434+ .enter = mxs_suspend_enter,3535+ .valid = suspend_valid_only_mem,3636+};3737+3838+static int __init mxs_pm_init(void)3939+{4040+ suspend_set_ops(&mxs_suspend_ops);4141+ return 0;4242+}4343+device_initcall(mxs_pm_init);
···3333config ARCH_MXC912313434 bool "MXC91231-based"3535 select CPU_V63636+ select MXC_AVIC3637 help3738 This enables support for systems based on the Freescale MXC91231 family3839
···8181 ret = platform_device_add(pdev);8282 if (ret) {8383err:8484+ if (dmamask)8585+ kfree(pdev->dev.dma_mask);8486 platform_device_put(pdev);8587 return ERR_PTR(ret);8688 }
···112112 * - setups the iomux according to the configuration113113 * - if the pin is configured as a GPIO, we claim it through kernel gpiolib114114 */115115-int mxc_iomux_alloc_pin(const unsigned int pin, const char *label);115115+int mxc_iomux_alloc_pin(unsigned int pin, const char *label);116116/*117117 * setups mutliple pins118118 * convenient way to call the above function with tables119119 */120120-int mxc_iomux_setup_multiple_pins(unsigned int *pin_list, unsigned count,120120+int mxc_iomux_setup_multiple_pins(const unsigned int *pin_list, unsigned count,121121 const char *label);122122123123/*···126126 * - frees the GPIO if the pin was configured as GPIO127127 * - DOES NOT reconfigure the IOMUX in its reset state128128 */129129-void mxc_iomux_release_pin(const unsigned int pin);129129+void mxc_iomux_release_pin(unsigned int pin);130130/*131131 * releases multiple pins132132 * convenvient way to call the above function with tables133133 */134134-void mxc_iomux_release_multiple_pins(unsigned int *pin_list, int count);134134+void mxc_iomux_release_multiple_pins(const unsigned int *pin_list, int count);135135136136/*137137 * This function enables/disables the general purpose function for a particular
···4646 * - setups the iomux according to the configuration4747 * - if the pin is configured as a GPIO, we claim it through kernel gpiolib4848 */4949-int mxc_iomux_alloc_pin(const unsigned int pin_mode, const char *label);4949+int mxc_iomux_alloc_pin(unsigned int pin_mode, const char *label);5050/*5151 * setups mutliple pins5252 * convenient way to call the above function with tables5353 */5454-int mxc_iomux_setup_multiple_pins(unsigned int *pin_list, unsigned count,5454+int mxc_iomux_setup_multiple_pins(const unsigned int *pin_list, unsigned count,5555 const char *label);56565757/*···6060 * - frees the GPIO if the pin was configured as GPIO6161 * - DOES NOT reconfigure the IOMUX in its reset state6262 */6363-void mxc_iomux_release_pin(const unsigned int pin_mode);6363+void mxc_iomux_release_pin(unsigned int pin_mode);6464/*6565 * releases multiple pins6666 * convenvient way to call the above function with tables6767 */6868-void mxc_iomux_release_multiple_pins(unsigned int *pin_list, int count);6868+void mxc_iomux_release_multiple_pins(const unsigned int *pin_list, int count);69697070#define MUX_SIDE_AP (0)7171#define MUX_SIDE_SP (1)
+2
arch/arm/plat-mxc/include/mach/iomux-v1.h
···100100 const char *label);101101extern void mxc_gpio_release_multiple_pins(const int *pin_list, int count);102102103103+extern int __init imx_iomuxv1_init(void __iomem *base, int numports);104104+103105#endif /* __MACH_IOMUX_V1_H__ */
+3-3
arch/arm/plat-mxc/include/mach/irqs.h
···2323#define MXC_GPIO_IRQ_START MXC_INTERNAL_IRQS24242525/* these are ordered by size to support multi-SoC kernels */2626-#if defined CONFIG_ARCH_MX532626+#if defined CONFIG_SOC_IMX532727#define MXC_GPIO_IRQS (32 * 7)2828#elif defined CONFIG_ARCH_MX22929#define MXC_GPIO_IRQS (32 * 6)3030-#elif defined CONFIG_ARCH_MX503030+#elif defined CONFIG_SOC_IMX503131#define MXC_GPIO_IRQS (32 * 6)3232#elif defined CONFIG_ARCH_MX13333#define MXC_GPIO_IRQS (32 * 4)3434#elif defined CONFIG_ARCH_MX253535#define MXC_GPIO_IRQS (32 * 4)3636-#elif defined CONFIG_ARCH_MX513636+#elif defined CONFIG_SOC_IMX513737#define MXC_GPIO_IRQS (32 * 4)3838#elif defined CONFIG_ARCH_MXC912313939#define MXC_GPIO_IRQS (32 * 4)
···6262#define MX2X_UART1_BASE_ADDR 0x1000a0006363#define MX3X_UART1_BASE_ADDR 0x43F900006464#define MX3X_UART2_BASE_ADDR 0x43F940006565+#define MX3X_UART5_BASE_ADDR 0x43FB40006566#define MX51_UART1_BASE_ADDR 0x73fbc0006667#define MX50_UART1_BASE_ADDR 0x53fbc0006768#define MX53_UART1_BASE_ADDR 0x53fbc000···8483 case MACH_TYPE_MX21ADS:8584 case MACH_TYPE_PCA100:8685 case MACH_TYPE_MXT_TD60:8686+ case MACH_TYPE_IMX27IPCAM:8787 uart_base = MX2X_UART1_BASE_ADDR;8888 break;8989 case MACH_TYPE_MX31LITE:···103101 case MACH_TYPE_MAGX_ZN5:104102 uart_base = MX3X_UART2_BASE_ADDR;105103 break;104104+ case MACH_TYPE_BUG:105105+ uart_base = MX3X_UART5_BASE_ADDR;106106+ break;106107 case MACH_TYPE_MX51_BABBAGE:107108 case MACH_TYPE_EUKREA_CPUIMX51SD:108109 case MACH_TYPE_MX51_3DS:···115110 uart_base = MX50_UART1_BASE_ADDR;116111 break;117112 case MACH_TYPE_MX53_EVK:113113+ case MACH_TYPE_MX53_LOCO:114114+ case MACH_TYPE_MX53_SMD:118115 uart_base = MX53_UART1_BASE_ADDR;119116 break;120117 default:
···476476477477config MTD_NAND_MXC478478 tristate "MXC NAND support"479479- depends on ARCH_MX2 || ARCH_MX25 || ARCH_MX3 || ARCH_MX51479479+ depends on IMX_HAVE_PLATFORM_MXC_NAND480480 help481481 This enables the driver for the NAND flash controller on the482482 MXC processors.
+1-1
drivers/net/Kconfig
···19441944config FEC19451945 bool "FEC ethernet controller (of ColdFire and some i.MX CPUs)"19461946 depends on M523x || M527x || M5272 || M528x || M520x || M532x || \19471947- MACH_MX27 || ARCH_MX35 || ARCH_MX25 || ARCH_MX5 || SOC_IMX2819471947+ IMX_HAVE_PLATFORM_FEC || SOC_IMX2819481948 select PHYLIB19491949 help19501950 Say Y here if you want to use the built-in 10/100 Fast ethernet
+3-3
drivers/spi/Kconfig
···161161 def_bool y if SOC_IMX21 || SOC_IMX27162162163163config SPI_IMX_VER_0_4164164- def_bool y if ARCH_MX31164164+ def_bool y if SOC_IMX31165165166166config SPI_IMX_VER_0_7167167- def_bool y if ARCH_MX25 || ARCH_MX35 || ARCH_MX51 || ARCH_MX53167167+ def_bool y if ARCH_MX25 || SOC_IMX35 || SOC_IMX51 || SOC_IMX53168168169169config SPI_IMX_VER_2_3170170- def_bool y if ARCH_MX51 || ARCH_MX53170170+ def_bool y if SOC_IMX51 || SOC_IMX53171171172172config SPI_IMX173173 tristate "Freescale i.MX SPI controllers"
+15
drivers/tty/serial/Kconfig
···15961596 This driver is for PCH(Platform controller Hub) UART of Intel EG20T15971597 which is an IOH(Input/Output Hub) for x86 embedded processor.15981598 Enabling PCH_DMA, this PCH UART works as DMA mode.15991599+16001600+config SERIAL_MXS_AUART16011601+ depends on ARCH_MXS16021602+ tristate "MXS AUART support"16031603+ select SERIAL_CORE16041604+ help16051605+ This driver supports the MXS Application UART (AUART) port.16061606+16071607+config SERIAL_MXS_AUART_CONSOLE16081608+ bool "MXS AUART console support"16091609+ depends on SERIAL_MXS_AUART=y16101610+ select SERIAL_CORE_CONSOLE16111611+ help16121612+ Enable a MXS AUART port to be the system console.16131613+15991614endmenu
···11+/*22+ * Freescale STMP37XX/STMP378X Application UART driver33+ *44+ * Author: dmitry pervushin <dimka@embeddedalley.com>55+ *66+ * Copyright 2008-2010 Freescale Semiconductor, Inc.77+ * Copyright 2008 Embedded Alley Solutions, Inc All Rights Reserved.88+ *99+ * The code contained herein is licensed under the GNU General Public1010+ * License. You may obtain a copy of the GNU General Public License1111+ * Version 2 or later at the following locations:1212+ *1313+ * http://www.opensource.org/licenses/gpl-license.html1414+ * http://www.gnu.org/copyleft/gpl.html1515+ */1616+1717+#include <linux/kernel.h>1818+#include <linux/errno.h>1919+#include <linux/init.h>2020+#include <linux/console.h>2121+#include <linux/interrupt.h>2222+#include <linux/module.h>2323+#include <linux/slab.h>2424+#include <linux/wait.h>2525+#include <linux/tty.h>2626+#include <linux/tty_driver.h>2727+#include <linux/tty_flip.h>2828+#include <linux/serial.h>2929+#include <linux/serial_core.h>3030+#include <linux/platform_device.h>3131+#include <linux/device.h>3232+#include <linux/clk.h>3333+#include <linux/delay.h>3434+#include <linux/io.h>3535+3636+#include <asm/cacheflush.h>3737+3838+#define MXS_AUART_PORTS 53939+4040+#define AUART_CTRL0 0x000000004141+#define AUART_CTRL0_SET 0x000000044242+#define AUART_CTRL0_CLR 0x000000084343+#define AUART_CTRL0_TOG 0x0000000c4444+#define AUART_CTRL1 0x000000104545+#define AUART_CTRL1_SET 0x000000144646+#define AUART_CTRL1_CLR 0x000000184747+#define AUART_CTRL1_TOG 0x0000001c4848+#define AUART_CTRL2 0x000000204949+#define AUART_CTRL2_SET 0x000000245050+#define AUART_CTRL2_CLR 0x000000285151+#define AUART_CTRL2_TOG 0x0000002c5252+#define AUART_LINECTRL 0x000000305353+#define AUART_LINECTRL_SET 0x000000345454+#define AUART_LINECTRL_CLR 0x000000385555+#define AUART_LINECTRL_TOG 0x0000003c5656+#define AUART_LINECTRL2 0x000000405757+#define AUART_LINECTRL2_SET 0x000000445858+#define AUART_LINECTRL2_CLR 0x000000485959+#define AUART_LINECTRL2_TOG 0x0000004c6060+#define AUART_INTR 0x000000506161+#define AUART_INTR_SET 0x000000546262+#define AUART_INTR_CLR 0x000000586363+#define AUART_INTR_TOG 0x0000005c6464+#define AUART_DATA 0x000000606565+#define AUART_STAT 0x000000706666+#define AUART_DEBUG 0x000000806767+#define AUART_VERSION 0x000000906868+#define AUART_AUTOBAUD 0x000000a06969+7070+#define AUART_CTRL0_SFTRST (1 << 31)7171+#define AUART_CTRL0_CLKGATE (1 << 30)7272+7373+#define AUART_CTRL2_CTSEN (1 << 15)7474+#define AUART_CTRL2_RTS (1 << 11)7575+#define AUART_CTRL2_RXE (1 << 9)7676+#define AUART_CTRL2_TXE (1 << 8)7777+#define AUART_CTRL2_UARTEN (1 << 0)7878+7979+#define AUART_LINECTRL_BAUD_DIVINT_SHIFT 168080+#define AUART_LINECTRL_BAUD_DIVINT_MASK 0xffff00008181+#define AUART_LINECTRL_BAUD_DIVINT(v) (((v) & 0xffff) << 16)8282+#define AUART_LINECTRL_BAUD_DIVFRAC_SHIFT 88383+#define AUART_LINECTRL_BAUD_DIVFRAC_MASK 0x00003f008484+#define AUART_LINECTRL_BAUD_DIVFRAC(v) (((v) & 0x3f) << 8)8585+#define AUART_LINECTRL_WLEN_MASK 0x000000608686+#define AUART_LINECTRL_WLEN(v) (((v) & 0x3) << 5)8787+#define AUART_LINECTRL_FEN (1 << 4)8888+#define AUART_LINECTRL_STP2 (1 << 3)8989+#define AUART_LINECTRL_EPS (1 << 2)9090+#define AUART_LINECTRL_PEN (1 << 1)9191+#define AUART_LINECTRL_BRK (1 << 0)9292+9393+#define AUART_INTR_RTIEN (1 << 22)9494+#define AUART_INTR_TXIEN (1 << 21)9595+#define AUART_INTR_RXIEN (1 << 20)9696+#define AUART_INTR_CTSMIEN (1 << 17)9797+#define AUART_INTR_RTIS (1 << 6)9898+#define AUART_INTR_TXIS (1 << 5)9999+#define AUART_INTR_RXIS (1 << 4)100100+#define AUART_INTR_CTSMIS (1 << 1)101101+102102+#define AUART_STAT_BUSY (1 << 29)103103+#define AUART_STAT_CTS (1 << 28)104104+#define AUART_STAT_TXFE (1 << 27)105105+#define AUART_STAT_TXFF (1 << 25)106106+#define AUART_STAT_RXFE (1 << 24)107107+#define AUART_STAT_OERR (1 << 19)108108+#define AUART_STAT_BERR (1 << 18)109109+#define AUART_STAT_PERR (1 << 17)110110+#define AUART_STAT_FERR (1 << 16)111111+112112+static struct uart_driver auart_driver;113113+114114+struct mxs_auart_port {115115+ struct uart_port port;116116+117117+ unsigned int flags;118118+ unsigned int ctrl;119119+120120+ unsigned int irq;121121+122122+ struct clk *clk;123123+ struct device *dev;124124+};125125+126126+static void mxs_auart_stop_tx(struct uart_port *u);127127+128128+#define to_auart_port(u) container_of(u, struct mxs_auart_port, port)129129+130130+static inline void mxs_auart_tx_chars(struct mxs_auart_port *s)131131+{132132+ struct circ_buf *xmit = &s->port.state->xmit;133133+134134+ while (!(readl(s->port.membase + AUART_STAT) &135135+ AUART_STAT_TXFF)) {136136+ if (s->port.x_char) {137137+ s->port.icount.tx++;138138+ writel(s->port.x_char,139139+ s->port.membase + AUART_DATA);140140+ s->port.x_char = 0;141141+ continue;142142+ }143143+ if (!uart_circ_empty(xmit) && !uart_tx_stopped(&s->port)) {144144+ s->port.icount.tx++;145145+ writel(xmit->buf[xmit->tail],146146+ s->port.membase + AUART_DATA);147147+ xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);148148+ if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)149149+ uart_write_wakeup(&s->port);150150+ } else151151+ break;152152+ }153153+ if (uart_circ_empty(&(s->port.state->xmit)))154154+ writel(AUART_INTR_TXIEN,155155+ s->port.membase + AUART_INTR_CLR);156156+ else157157+ writel(AUART_INTR_TXIEN,158158+ s->port.membase + AUART_INTR_SET);159159+160160+ if (uart_tx_stopped(&s->port))161161+ mxs_auart_stop_tx(&s->port);162162+}163163+164164+static void mxs_auart_rx_char(struct mxs_auart_port *s)165165+{166166+ int flag;167167+ u32 stat;168168+ u8 c;169169+170170+ c = readl(s->port.membase + AUART_DATA);171171+ stat = readl(s->port.membase + AUART_STAT);172172+173173+ flag = TTY_NORMAL;174174+ s->port.icount.rx++;175175+176176+ if (stat & AUART_STAT_BERR) {177177+ s->port.icount.brk++;178178+ if (uart_handle_break(&s->port))179179+ goto out;180180+ } else if (stat & AUART_STAT_PERR) {181181+ s->port.icount.parity++;182182+ } else if (stat & AUART_STAT_FERR) {183183+ s->port.icount.frame++;184184+ }185185+186186+ /*187187+ * Mask off conditions which should be ingored.188188+ */189189+ stat &= s->port.read_status_mask;190190+191191+ if (stat & AUART_STAT_BERR) {192192+ flag = TTY_BREAK;193193+ } else if (stat & AUART_STAT_PERR)194194+ flag = TTY_PARITY;195195+ else if (stat & AUART_STAT_FERR)196196+ flag = TTY_FRAME;197197+198198+ if (stat & AUART_STAT_OERR)199199+ s->port.icount.overrun++;200200+201201+ if (uart_handle_sysrq_char(&s->port, c))202202+ goto out;203203+204204+ uart_insert_char(&s->port, stat, AUART_STAT_OERR, c, flag);205205+out:206206+ writel(stat, s->port.membase + AUART_STAT);207207+}208208+209209+static void mxs_auart_rx_chars(struct mxs_auart_port *s)210210+{211211+ struct tty_struct *tty = s->port.state->port.tty;212212+ u32 stat = 0;213213+214214+ for (;;) {215215+ stat = readl(s->port.membase + AUART_STAT);216216+ if (stat & AUART_STAT_RXFE)217217+ break;218218+ mxs_auart_rx_char(s);219219+ }220220+221221+ writel(stat, s->port.membase + AUART_STAT);222222+ tty_flip_buffer_push(tty);223223+}224224+225225+static int mxs_auart_request_port(struct uart_port *u)226226+{227227+ return 0;228228+}229229+230230+static int mxs_auart_verify_port(struct uart_port *u,231231+ struct serial_struct *ser)232232+{233233+ if (u->type != PORT_UNKNOWN && u->type != PORT_IMX)234234+ return -EINVAL;235235+ return 0;236236+}237237+238238+static void mxs_auart_config_port(struct uart_port *u, int flags)239239+{240240+}241241+242242+static const char *mxs_auart_type(struct uart_port *u)243243+{244244+ struct mxs_auart_port *s = to_auart_port(u);245245+246246+ return dev_name(s->dev);247247+}248248+249249+static void mxs_auart_release_port(struct uart_port *u)250250+{251251+}252252+253253+static void mxs_auart_set_mctrl(struct uart_port *u, unsigned mctrl)254254+{255255+ struct mxs_auart_port *s = to_auart_port(u);256256+257257+ u32 ctrl = readl(u->membase + AUART_CTRL2);258258+259259+ ctrl &= ~AUART_CTRL2_RTS;260260+ if (mctrl & TIOCM_RTS)261261+ ctrl |= AUART_CTRL2_RTS;262262+ s->ctrl = mctrl;263263+ writel(ctrl, u->membase + AUART_CTRL2);264264+}265265+266266+static u32 mxs_auart_get_mctrl(struct uart_port *u)267267+{268268+ struct mxs_auart_port *s = to_auart_port(u);269269+ u32 stat = readl(u->membase + AUART_STAT);270270+ int ctrl2 = readl(u->membase + AUART_CTRL2);271271+ u32 mctrl = s->ctrl;272272+273273+ mctrl &= ~TIOCM_CTS;274274+ if (stat & AUART_STAT_CTS)275275+ mctrl |= TIOCM_CTS;276276+277277+ if (ctrl2 & AUART_CTRL2_RTS)278278+ mctrl |= TIOCM_RTS;279279+280280+ return mctrl;281281+}282282+283283+static void mxs_auart_settermios(struct uart_port *u,284284+ struct ktermios *termios,285285+ struct ktermios *old)286286+{287287+ u32 bm, ctrl, ctrl2, div;288288+ unsigned int cflag, baud;289289+290290+ cflag = termios->c_cflag;291291+292292+ ctrl = AUART_LINECTRL_FEN;293293+ ctrl2 = readl(u->membase + AUART_CTRL2);294294+295295+ /* byte size */296296+ switch (cflag & CSIZE) {297297+ case CS5:298298+ bm = 0;299299+ break;300300+ case CS6:301301+ bm = 1;302302+ break;303303+ case CS7:304304+ bm = 2;305305+ break;306306+ case CS8:307307+ bm = 3;308308+ break;309309+ default:310310+ return;311311+ }312312+313313+ ctrl |= AUART_LINECTRL_WLEN(bm);314314+315315+ /* parity */316316+ if (cflag & PARENB) {317317+ ctrl |= AUART_LINECTRL_PEN;318318+ if ((cflag & PARODD) == 0)319319+ ctrl |= AUART_LINECTRL_EPS;320320+ }321321+322322+ u->read_status_mask = 0;323323+324324+ if (termios->c_iflag & INPCK)325325+ u->read_status_mask |= AUART_STAT_PERR;326326+ if (termios->c_iflag & (BRKINT | PARMRK))327327+ u->read_status_mask |= AUART_STAT_BERR;328328+329329+ /*330330+ * Characters to ignore331331+ */332332+ u->ignore_status_mask = 0;333333+ if (termios->c_iflag & IGNPAR)334334+ u->ignore_status_mask |= AUART_STAT_PERR;335335+ if (termios->c_iflag & IGNBRK) {336336+ u->ignore_status_mask |= AUART_STAT_BERR;337337+ /*338338+ * If we're ignoring parity and break indicators,339339+ * ignore overruns too (for real raw support).340340+ */341341+ if (termios->c_iflag & IGNPAR)342342+ u->ignore_status_mask |= AUART_STAT_OERR;343343+ }344344+345345+ /*346346+ * ignore all characters if CREAD is not set347347+ */348348+ if (cflag & CREAD)349349+ ctrl2 |= AUART_CTRL2_RXE;350350+ else351351+ ctrl2 &= ~AUART_CTRL2_RXE;352352+353353+ /* figure out the stop bits requested */354354+ if (cflag & CSTOPB)355355+ ctrl |= AUART_LINECTRL_STP2;356356+357357+ /* figure out the hardware flow control settings */358358+ if (cflag & CRTSCTS)359359+ ctrl2 |= AUART_CTRL2_CTSEN;360360+ else361361+ ctrl2 &= ~AUART_CTRL2_CTSEN;362362+363363+ /* set baud rate */364364+ baud = uart_get_baud_rate(u, termios, old, 0, u->uartclk);365365+ div = u->uartclk * 32 / baud;366366+ ctrl |= AUART_LINECTRL_BAUD_DIVFRAC(div & 0x3F);367367+ ctrl |= AUART_LINECTRL_BAUD_DIVINT(div >> 6);368368+369369+ writel(ctrl, u->membase + AUART_LINECTRL);370370+ writel(ctrl2, u->membase + AUART_CTRL2);371371+}372372+373373+static irqreturn_t mxs_auart_irq_handle(int irq, void *context)374374+{375375+ u32 istatus, istat;376376+ struct mxs_auart_port *s = context;377377+ u32 stat = readl(s->port.membase + AUART_STAT);378378+379379+ istatus = istat = readl(s->port.membase + AUART_INTR);380380+381381+ if (istat & AUART_INTR_CTSMIS) {382382+ uart_handle_cts_change(&s->port, stat & AUART_STAT_CTS);383383+ writel(AUART_INTR_CTSMIS,384384+ s->port.membase + AUART_INTR_CLR);385385+ istat &= ~AUART_INTR_CTSMIS;386386+ }387387+388388+ if (istat & (AUART_INTR_RTIS | AUART_INTR_RXIS)) {389389+ mxs_auart_rx_chars(s);390390+ istat &= ~(AUART_INTR_RTIS | AUART_INTR_RXIS);391391+ }392392+393393+ if (istat & AUART_INTR_TXIS) {394394+ mxs_auart_tx_chars(s);395395+ istat &= ~AUART_INTR_TXIS;396396+ }397397+398398+ writel(istatus & (AUART_INTR_RTIS399399+ | AUART_INTR_TXIS400400+ | AUART_INTR_RXIS401401+ | AUART_INTR_CTSMIS),402402+ s->port.membase + AUART_INTR_CLR);403403+404404+ return IRQ_HANDLED;405405+}406406+407407+static void mxs_auart_reset(struct uart_port *u)408408+{409409+ int i;410410+ unsigned int reg;411411+412412+ writel(AUART_CTRL0_SFTRST, u->membase + AUART_CTRL0_CLR);413413+414414+ for (i = 0; i < 10000; i++) {415415+ reg = readl(u->membase + AUART_CTRL0);416416+ if (!(reg & AUART_CTRL0_SFTRST))417417+ break;418418+ udelay(3);419419+ }420420+ writel(AUART_CTRL0_CLKGATE, u->membase + AUART_CTRL0_CLR);421421+}422422+423423+static int mxs_auart_startup(struct uart_port *u)424424+{425425+ struct mxs_auart_port *s = to_auart_port(u);426426+427427+ clk_enable(s->clk);428428+429429+ writel(AUART_CTRL0_CLKGATE, u->membase + AUART_CTRL0_CLR);430430+431431+ writel(AUART_CTRL2_UARTEN, u->membase + AUART_CTRL2_SET);432432+433433+ writel(AUART_INTR_RXIEN | AUART_INTR_RTIEN | AUART_INTR_CTSMIEN,434434+ u->membase + AUART_INTR);435435+436436+ /*437437+ * Enable fifo so all four bytes of a DMA word are written to438438+ * output (otherwise, only the LSB is written, ie. 1 in 4 bytes)439439+ */440440+ writel(AUART_LINECTRL_FEN, u->membase + AUART_LINECTRL_SET);441441+442442+ return 0;443443+}444444+445445+static void mxs_auart_shutdown(struct uart_port *u)446446+{447447+ struct mxs_auart_port *s = to_auart_port(u);448448+449449+ writel(AUART_CTRL2_UARTEN, u->membase + AUART_CTRL2_CLR);450450+451451+ writel(AUART_CTRL0_CLKGATE, u->membase + AUART_CTRL0_SET);452452+453453+ writel(AUART_INTR_RXIEN | AUART_INTR_RTIEN | AUART_INTR_CTSMIEN,454454+ u->membase + AUART_INTR_CLR);455455+456456+ clk_disable(s->clk);457457+}458458+459459+static unsigned int mxs_auart_tx_empty(struct uart_port *u)460460+{461461+ if (readl(u->membase + AUART_STAT) & AUART_STAT_TXFE)462462+ return TIOCSER_TEMT;463463+ else464464+ return 0;465465+}466466+467467+static void mxs_auart_start_tx(struct uart_port *u)468468+{469469+ struct mxs_auart_port *s = to_auart_port(u);470470+471471+ /* enable transmitter */472472+ writel(AUART_CTRL2_TXE, u->membase + AUART_CTRL2_SET);473473+474474+ mxs_auart_tx_chars(s);475475+}476476+477477+static void mxs_auart_stop_tx(struct uart_port *u)478478+{479479+ writel(AUART_CTRL2_TXE, u->membase + AUART_CTRL2_CLR);480480+}481481+482482+static void mxs_auart_stop_rx(struct uart_port *u)483483+{484484+ writel(AUART_CTRL2_RXE, u->membase + AUART_CTRL2_CLR);485485+}486486+487487+static void mxs_auart_break_ctl(struct uart_port *u, int ctl)488488+{489489+ if (ctl)490490+ writel(AUART_LINECTRL_BRK,491491+ u->membase + AUART_LINECTRL_SET);492492+ else493493+ writel(AUART_LINECTRL_BRK,494494+ u->membase + AUART_LINECTRL_CLR);495495+}496496+497497+static void mxs_auart_enable_ms(struct uart_port *port)498498+{499499+ /* just empty */500500+}501501+502502+static struct uart_ops mxs_auart_ops = {503503+ .tx_empty = mxs_auart_tx_empty,504504+ .start_tx = mxs_auart_start_tx,505505+ .stop_tx = mxs_auart_stop_tx,506506+ .stop_rx = mxs_auart_stop_rx,507507+ .enable_ms = mxs_auart_enable_ms,508508+ .break_ctl = mxs_auart_break_ctl,509509+ .set_mctrl = mxs_auart_set_mctrl,510510+ .get_mctrl = mxs_auart_get_mctrl,511511+ .startup = mxs_auart_startup,512512+ .shutdown = mxs_auart_shutdown,513513+ .set_termios = mxs_auart_settermios,514514+ .type = mxs_auart_type,515515+ .release_port = mxs_auart_release_port,516516+ .request_port = mxs_auart_request_port,517517+ .config_port = mxs_auart_config_port,518518+ .verify_port = mxs_auart_verify_port,519519+};520520+521521+static struct mxs_auart_port *auart_port[MXS_AUART_PORTS];522522+523523+#ifdef CONFIG_SERIAL_MXS_AUART_CONSOLE524524+static void mxs_auart_console_putchar(struct uart_port *port, int ch)525525+{526526+ unsigned int to = 1000;527527+528528+ while (readl(port->membase + AUART_STAT) & AUART_STAT_TXFF) {529529+ if (!to--)530530+ break;531531+ udelay(1);532532+ }533533+534534+ writel(ch, port->membase + AUART_DATA);535535+}536536+537537+static void538538+auart_console_write(struct console *co, const char *str, unsigned int count)539539+{540540+ struct mxs_auart_port *s;541541+ struct uart_port *port;542542+ unsigned int old_ctrl0, old_ctrl2;543543+ unsigned int to = 1000;544544+545545+ if (co->index > MXS_AUART_PORTS || co->index < 0)546546+ return;547547+548548+ s = auart_port[co->index];549549+ port = &s->port;550550+551551+ clk_enable(s->clk);552552+553553+ /* First save the CR then disable the interrupts */554554+ old_ctrl2 = readl(port->membase + AUART_CTRL2);555555+ old_ctrl0 = readl(port->membase + AUART_CTRL0);556556+557557+ writel(AUART_CTRL0_CLKGATE,558558+ port->membase + AUART_CTRL0_CLR);559559+ writel(AUART_CTRL2_UARTEN | AUART_CTRL2_TXE,560560+ port->membase + AUART_CTRL2_SET);561561+562562+ uart_console_write(port, str, count, mxs_auart_console_putchar);563563+564564+ /*565565+ * Finally, wait for transmitter to become empty566566+ * and restore the TCR567567+ */568568+ while (readl(port->membase + AUART_STAT) & AUART_STAT_BUSY) {569569+ if (!to--)570570+ break;571571+ udelay(1);572572+ }573573+574574+ writel(old_ctrl0, port->membase + AUART_CTRL0);575575+ writel(old_ctrl2, port->membase + AUART_CTRL2);576576+577577+ clk_disable(s->clk);578578+}579579+580580+static void __init581581+auart_console_get_options(struct uart_port *port, int *baud,582582+ int *parity, int *bits)583583+{584584+ unsigned int lcr_h, quot;585585+586586+ if (!(readl(port->membase + AUART_CTRL2) & AUART_CTRL2_UARTEN))587587+ return;588588+589589+ lcr_h = readl(port->membase + AUART_LINECTRL);590590+591591+ *parity = 'n';592592+ if (lcr_h & AUART_LINECTRL_PEN) {593593+ if (lcr_h & AUART_LINECTRL_EPS)594594+ *parity = 'e';595595+ else596596+ *parity = 'o';597597+ }598598+599599+ if ((lcr_h & AUART_LINECTRL_WLEN_MASK) == AUART_LINECTRL_WLEN(2))600600+ *bits = 7;601601+ else602602+ *bits = 8;603603+604604+ quot = ((readl(port->membase + AUART_LINECTRL)605605+ & AUART_LINECTRL_BAUD_DIVINT_MASK))606606+ >> (AUART_LINECTRL_BAUD_DIVINT_SHIFT - 6);607607+ quot |= ((readl(port->membase + AUART_LINECTRL)608608+ & AUART_LINECTRL_BAUD_DIVFRAC_MASK))609609+ >> AUART_LINECTRL_BAUD_DIVFRAC_SHIFT;610610+ if (quot == 0)611611+ quot = 1;612612+613613+ *baud = (port->uartclk << 2) / quot;614614+}615615+616616+static int __init617617+auart_console_setup(struct console *co, char *options)618618+{619619+ struct mxs_auart_port *s;620620+ int baud = 9600;621621+ int bits = 8;622622+ int parity = 'n';623623+ int flow = 'n';624624+ int ret;625625+626626+ /*627627+ * Check whether an invalid uart number has been specified, and628628+ * if so, search for the first available port that does have629629+ * console support.630630+ */631631+ if (co->index == -1 || co->index >= ARRAY_SIZE(auart_port))632632+ co->index = 0;633633+ s = auart_port[co->index];634634+ if (!s)635635+ return -ENODEV;636636+637637+ clk_enable(s->clk);638638+639639+ if (options)640640+ uart_parse_options(options, &baud, &parity, &bits, &flow);641641+ else642642+ auart_console_get_options(&s->port, &baud, &parity, &bits);643643+644644+ ret = uart_set_options(&s->port, co, baud, parity, bits, flow);645645+646646+ clk_disable(s->clk);647647+648648+ return ret;649649+}650650+651651+static struct console auart_console = {652652+ .name = "ttyAPP",653653+ .write = auart_console_write,654654+ .device = uart_console_device,655655+ .setup = auart_console_setup,656656+ .flags = CON_PRINTBUFFER,657657+ .index = -1,658658+ .data = &auart_driver,659659+};660660+#endif661661+662662+static struct uart_driver auart_driver = {663663+ .owner = THIS_MODULE,664664+ .driver_name = "ttyAPP",665665+ .dev_name = "ttyAPP",666666+ .major = 0,667667+ .minor = 0,668668+ .nr = MXS_AUART_PORTS,669669+#ifdef CONFIG_SERIAL_MXS_AUART_CONSOLE670670+ .cons = &auart_console,671671+#endif672672+};673673+674674+static int __devinit mxs_auart_probe(struct platform_device *pdev)675675+{676676+ struct mxs_auart_port *s;677677+ u32 version;678678+ int ret = 0;679679+ struct resource *r;680680+681681+ s = kzalloc(sizeof(struct mxs_auart_port), GFP_KERNEL);682682+ if (!s) {683683+ ret = -ENOMEM;684684+ goto out;685685+ }686686+687687+ s->clk = clk_get(&pdev->dev, NULL);688688+ if (IS_ERR(s->clk)) {689689+ ret = PTR_ERR(s->clk);690690+ goto out_free;691691+ }692692+693693+ r = platform_get_resource(pdev, IORESOURCE_MEM, 0);694694+ if (!r) {695695+ ret = -ENXIO;696696+ goto out_free_clk;697697+ }698698+699699+ s->port.mapbase = r->start;700700+ s->port.membase = ioremap(r->start, resource_size(r));701701+ s->port.ops = &mxs_auart_ops;702702+ s->port.iotype = UPIO_MEM;703703+ s->port.line = pdev->id < 0 ? 0 : pdev->id;704704+ s->port.fifosize = 16;705705+ s->port.uartclk = clk_get_rate(s->clk);706706+ s->port.type = PORT_IMX;707707+ s->port.dev = s->dev = get_device(&pdev->dev);708708+709709+ s->flags = 0;710710+ s->ctrl = 0;711711+712712+ s->irq = platform_get_irq(pdev, 0);713713+ s->port.irq = s->irq;714714+ ret = request_irq(s->irq, mxs_auart_irq_handle, 0, dev_name(&pdev->dev), s);715715+ if (ret)716716+ goto out_free_clk;717717+718718+ platform_set_drvdata(pdev, s);719719+720720+ auart_port[pdev->id] = s;721721+722722+ mxs_auart_reset(&s->port);723723+724724+ ret = uart_add_one_port(&auart_driver, &s->port);725725+ if (ret)726726+ goto out_free_irq;727727+728728+ version = readl(s->port.membase + AUART_VERSION);729729+ dev_info(&pdev->dev, "Found APPUART %d.%d.%d\n",730730+ (version >> 24) & 0xff,731731+ (version >> 16) & 0xff, version & 0xffff);732732+733733+ return 0;734734+735735+out_free_irq:736736+ auart_port[pdev->id] = NULL;737737+ free_irq(s->irq, s);738738+out_free_clk:739739+ clk_put(s->clk);740740+out_free:741741+ kfree(s);742742+out:743743+ return ret;744744+}745745+746746+static int __devexit mxs_auart_remove(struct platform_device *pdev)747747+{748748+ struct mxs_auart_port *s = platform_get_drvdata(pdev);749749+750750+ uart_remove_one_port(&auart_driver, &s->port);751751+752752+ auart_port[pdev->id] = NULL;753753+754754+ clk_put(s->clk);755755+ free_irq(s->irq, s);756756+ kfree(s);757757+758758+ return 0;759759+}760760+761761+static struct platform_driver mxs_auart_driver = {762762+ .probe = mxs_auart_probe,763763+ .remove = __devexit_p(mxs_auart_remove),764764+ .driver = {765765+ .name = "mxs-auart",766766+ .owner = THIS_MODULE,767767+ },768768+};769769+770770+static int __init mxs_auart_init(void)771771+{772772+ int r;773773+774774+ r = uart_register_driver(&auart_driver);775775+ if (r)776776+ goto out;777777+778778+ r = platform_driver_register(&mxs_auart_driver);779779+ if (r)780780+ goto out_err;781781+782782+ return 0;783783+out_err:784784+ uart_unregister_driver(&auart_driver);785785+out:786786+ return r;787787+}788788+789789+static void __exit mxs_auart_exit(void)790790+{791791+ platform_driver_unregister(&mxs_auart_driver);792792+ uart_unregister_driver(&auart_driver);793793+}794794+795795+module_init(mxs_auart_init);796796+module_exit(mxs_auart_exit);797797+MODULE_LICENSE("GPL");798798+MODULE_DESCRIPTION("Freescale MXS application uart driver");
+1-1
drivers/usb/gadget/fsl_mxc_udc.c
···8888void fsl_udc_clk_finalize(struct platform_device *pdev)8989{9090 struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data;9191-#if defined(CONFIG_ARCH_MX35)9191+#if defined(CONFIG_SOC_IMX35)9292 unsigned int v;93939494 /* workaround ENGcm09152 for i.MX35 */
-5
drivers/usb/host/ehci-mxc.c
···203203 mdelay(10);204204 }205205206206- /* setup specific usb hw */207207- ret = mxc_initialize_usb_hw(pdev->id, pdata->flags);208208- if (ret < 0)209209- goto err_init;210210-211206 ehci = hcd_to_ehci(hcd);212207213208 /* EHCI registers start at offset 0x100 */
+9
drivers/video/Kconfig
···23652365 help23662366 Framebuffer support for the JZ4740 SoC.2367236723682368+config FB_MXS23692369+ tristate "MXS LCD framebuffer support"23702370+ depends on FB && ARCH_MXS23712371+ select FB_CFB_FILLRECT23722372+ select FB_CFB_COPYAREA23732373+ select FB_CFB_IMAGEBLIT23742374+ help23752375+ Framebuffer support for the MXS SoC.23762376+23682377source "drivers/video/omap/Kconfig"23692378source "drivers/video/omap2/Kconfig"23702379
+1
drivers/video/Makefile
···153153obj-$(CONFIG_FB_BFIN_7393) += bfin_adv7393fb.o154154obj-$(CONFIG_FB_MX3) += mx3fb.o155155obj-$(CONFIG_FB_DA8XX) += da8xx-fb.o156156+obj-$(CONFIG_FB_MXS) += mxsfb.o156157157158# the test framebuffer is last158159obj-$(CONFIG_FB_VIRTUAL) += vfb.o
+919
drivers/video/mxsfb.c
···11+/*22+ * Copyright (C) 2010 Juergen Beisert, Pengutronix33+ *44+ * This code is based on:55+ * Author: Vitaly Wool <vital@embeddedalley.com>66+ *77+ * Copyright 2008-2009 Freescale Semiconductor, Inc. All Rights Reserved.88+ * Copyright 2008 Embedded Alley Solutions, Inc All Rights Reserved.99+ *1010+ * This program is free software; you can redistribute it and/or1111+ * modify it under the terms of the GNU General Public License1212+ * as published by the Free Software Foundation; either version 21313+ * of the License, or (at your option) any later version.1414+ * This program is distributed in the hope that it will be useful,1515+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1616+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1717+ * GNU General Public License for more details.1818+ */1919+2020+#define DRIVER_NAME "mxsfb"2121+2222+/**2323+ * @file2424+ * @brief LCDIF driver for i.MX23 and i.MX282525+ *2626+ * The LCDIF support four modes of operation2727+ * - MPU interface (to drive smart displays) -> not supported yet2828+ * - VSYNC interface (like MPU interface plus Vsync) -> not supported yet2929+ * - Dotclock interface (to drive LC displays with RGB data and sync signals)3030+ * - DVI (to drive ITU-R BT656) -> not supported yet3131+ *3232+ * This driver depends on a correct setup of the pins used for this purpose3333+ * (platform specific).3434+ *3535+ * For the developer: Don't forget to set the data bus width to the display3636+ * in the imx_fb_videomode structure. You will else end up with ugly colours.3737+ * If you fight against jitter you can vary the clock delay. This is a feature3838+ * of the i.MX28 and you can vary it between 2 ns ... 8 ns in 2 ns steps. Give3939+ * the required value in the imx_fb_videomode structure.4040+ */4141+4242+#include <linux/kernel.h>4343+#include <linux/platform_device.h>4444+#include <linux/clk.h>4545+#include <linux/dma-mapping.h>4646+#include <linux/io.h>4747+#include <mach/mxsfb.h>4848+4949+#define REG_SET 45050+#define REG_CLR 85151+5252+#define LCDC_CTRL 0x005353+#define LCDC_CTRL1 0x105454+#define LCDC_V4_CTRL2 0x205555+#define LCDC_V3_TRANSFER_COUNT 0x205656+#define LCDC_V4_TRANSFER_COUNT 0x305757+#define LCDC_V4_CUR_BUF 0x405858+#define LCDC_V4_NEXT_BUF 0x505959+#define LCDC_V3_CUR_BUF 0x306060+#define LCDC_V3_NEXT_BUF 0x406161+#define LCDC_TIMING 0x606262+#define LCDC_VDCTRL0 0x706363+#define LCDC_VDCTRL1 0x806464+#define LCDC_VDCTRL2 0x906565+#define LCDC_VDCTRL3 0xa06666+#define LCDC_VDCTRL4 0xb06767+#define LCDC_DVICTRL0 0xc06868+#define LCDC_DVICTRL1 0xd06969+#define LCDC_DVICTRL2 0xe07070+#define LCDC_DVICTRL3 0xf07171+#define LCDC_DVICTRL4 0x1007272+#define LCDC_V4_DATA 0x1807373+#define LCDC_V3_DATA 0x1b07474+#define LCDC_V4_DEBUG0 0x1d07575+#define LCDC_V3_DEBUG0 0x1f07676+7777+#define CTRL_SFTRST (1 << 31)7878+#define CTRL_CLKGATE (1 << 30)7979+#define CTRL_BYPASS_COUNT (1 << 19)8080+#define CTRL_VSYNC_MODE (1 << 18)8181+#define CTRL_DOTCLK_MODE (1 << 17)8282+#define CTRL_DATA_SELECT (1 << 16)8383+#define CTRL_SET_BUS_WIDTH(x) (((x) & 0x3) << 10)8484+#define CTRL_GET_BUS_WIDTH(x) (((x) >> 10) & 0x3)8585+#define CTRL_SET_WORD_LENGTH(x) (((x) & 0x3) << 8)8686+#define CTRL_GET_WORD_LENGTH(x) (((x) >> 8) & 0x3)8787+#define CTRL_MASTER (1 << 5)8888+#define CTRL_DF16 (1 << 3)8989+#define CTRL_DF18 (1 << 2)9090+#define CTRL_DF24 (1 << 1)9191+#define CTRL_RUN (1 << 0)9292+9393+#define CTRL1_FIFO_CLEAR (1 << 21)9494+#define CTRL1_SET_BYTE_PACKAGING(x) (((x) & 0xf) << 16)9595+#define CTRL1_GET_BYTE_PACKAGING(x) (((x) >> 16) & 0xf)9696+9797+#define TRANSFER_COUNT_SET_VCOUNT(x) (((x) & 0xffff) << 16)9898+#define TRANSFER_COUNT_GET_VCOUNT(x) (((x) >> 16) & 0xffff)9999+#define TRANSFER_COUNT_SET_HCOUNT(x) ((x) & 0xffff)100100+#define TRANSFER_COUNT_GET_HCOUNT(x) ((x) & 0xffff)101101+102102+103103+#define VDCTRL0_ENABLE_PRESENT (1 << 28)104104+#define VDCTRL0_VSYNC_ACT_HIGH (1 << 27)105105+#define VDCTRL0_HSYNC_ACT_HIGH (1 << 26)106106+#define VDCTRL0_DOTCLK_ACT_FAILING (1 << 25)107107+#define VDCTRL0_ENABLE_ACT_HIGH (1 << 24)108108+#define VDCTRL0_VSYNC_PERIOD_UNIT (1 << 21)109109+#define VDCTRL0_VSYNC_PULSE_WIDTH_UNIT (1 << 20)110110+#define VDCTRL0_HALF_LINE (1 << 19)111111+#define VDCTRL0_HALF_LINE_MODE (1 << 18)112112+#define VDCTRL0_SET_VSYNC_PULSE_WIDTH(x) ((x) & 0x3ffff)113113+#define VDCTRL0_GET_VSYNC_PULSE_WIDTH(x) ((x) & 0x3ffff)114114+115115+#define VDCTRL2_SET_HSYNC_PERIOD(x) ((x) & 0x3ffff)116116+#define VDCTRL2_GET_HSYNC_PERIOD(x) ((x) & 0x3ffff)117117+118118+#define VDCTRL3_MUX_SYNC_SIGNALS (1 << 29)119119+#define VDCTRL3_VSYNC_ONLY (1 << 28)120120+#define SET_HOR_WAIT_CNT(x) (((x) & 0xfff) << 16)121121+#define GET_HOR_WAIT_CNT(x) (((x) >> 16) & 0xfff)122122+#define SET_VERT_WAIT_CNT(x) ((x) & 0xffff)123123+#define GET_VERT_WAIT_CNT(x) ((x) & 0xffff)124124+125125+#define VDCTRL4_SET_DOTCLK_DLY(x) (((x) & 0x7) << 29) /* v4 only */126126+#define VDCTRL4_GET_DOTCLK_DLY(x) (((x) >> 29) & 0x7) /* v4 only */127127+#define VDCTRL4_SYNC_SIGNALS_ON (1 << 18)128128+#define SET_DOTCLK_H_VALID_DATA_CNT(x) ((x) & 0x3ffff)129129+130130+#define DEBUG0_HSYNC (1 < 26)131131+#define DEBUG0_VSYNC (1 < 25)132132+133133+#define MIN_XRES 120134134+#define MIN_YRES 120135135+136136+#define RED 0137137+#define GREEN 1138138+#define BLUE 2139139+#define TRANSP 3140140+141141+enum mxsfb_devtype {142142+ MXSFB_V3,143143+ MXSFB_V4,144144+};145145+146146+/* CPU dependent register offsets */147147+struct mxsfb_devdata {148148+ unsigned transfer_count;149149+ unsigned cur_buf;150150+ unsigned next_buf;151151+ unsigned debug0;152152+ unsigned hs_wdth_mask;153153+ unsigned hs_wdth_shift;154154+ unsigned ipversion;155155+};156156+157157+struct mxsfb_info {158158+ struct fb_info fb_info;159159+ struct platform_device *pdev;160160+ struct clk *clk;161161+ void __iomem *base; /* registers */162162+ unsigned allocated_size;163163+ int enabled;164164+ unsigned ld_intf_width;165165+ unsigned dotclk_delay;166166+ const struct mxsfb_devdata *devdata;167167+ int mapped;168168+};169169+170170+#define mxsfb_is_v3(host) (host->devdata->ipversion == 3)171171+#define mxsfb_is_v4(host) (host->devdata->ipversion == 4)172172+173173+static const struct mxsfb_devdata mxsfb_devdata[] = {174174+ [MXSFB_V3] = {175175+ .transfer_count = LCDC_V3_TRANSFER_COUNT,176176+ .cur_buf = LCDC_V3_CUR_BUF,177177+ .next_buf = LCDC_V3_NEXT_BUF,178178+ .debug0 = LCDC_V3_DEBUG0,179179+ .hs_wdth_mask = 0xff,180180+ .hs_wdth_shift = 24,181181+ .ipversion = 3,182182+ },183183+ [MXSFB_V4] = {184184+ .transfer_count = LCDC_V4_TRANSFER_COUNT,185185+ .cur_buf = LCDC_V4_CUR_BUF,186186+ .next_buf = LCDC_V4_NEXT_BUF,187187+ .debug0 = LCDC_V4_DEBUG0,188188+ .hs_wdth_mask = 0x3fff,189189+ .hs_wdth_shift = 18,190190+ .ipversion = 4,191191+ },192192+};193193+194194+#define to_imxfb_host(x) (container_of(x, struct mxsfb_info, fb_info))195195+196196+/* mask and shift depends on architecture */197197+static inline u32 set_hsync_pulse_width(struct mxsfb_info *host, unsigned val)198198+{199199+ return (val & host->devdata->hs_wdth_mask) <<200200+ host->devdata->hs_wdth_shift;201201+}202202+203203+static inline u32 get_hsync_pulse_width(struct mxsfb_info *host, unsigned val)204204+{205205+ return (val >> host->devdata->hs_wdth_shift) &206206+ host->devdata->hs_wdth_mask;207207+}208208+209209+static const struct fb_bitfield def_rgb565[] = {210210+ [RED] = {211211+ .offset = 11,212212+ .length = 5,213213+ },214214+ [GREEN] = {215215+ .offset = 5,216216+ .length = 6,217217+ },218218+ [BLUE] = {219219+ .offset = 0,220220+ .length = 5,221221+ },222222+ [TRANSP] = { /* no support for transparency */223223+ .length = 0,224224+ }225225+};226226+227227+static const struct fb_bitfield def_rgb666[] = {228228+ [RED] = {229229+ .offset = 16,230230+ .length = 6,231231+ },232232+ [GREEN] = {233233+ .offset = 8,234234+ .length = 6,235235+ },236236+ [BLUE] = {237237+ .offset = 0,238238+ .length = 6,239239+ },240240+ [TRANSP] = { /* no support for transparency */241241+ .length = 0,242242+ }243243+};244244+245245+static const struct fb_bitfield def_rgb888[] = {246246+ [RED] = {247247+ .offset = 16,248248+ .length = 8,249249+ },250250+ [GREEN] = {251251+ .offset = 8,252252+ .length = 8,253253+ },254254+ [BLUE] = {255255+ .offset = 0,256256+ .length = 8,257257+ },258258+ [TRANSP] = { /* no support for transparency */259259+ .length = 0,260260+ }261261+};262262+263263+static inline unsigned chan_to_field(unsigned chan, struct fb_bitfield *bf)264264+{265265+ chan &= 0xffff;266266+ chan >>= 16 - bf->length;267267+ return chan << bf->offset;268268+}269269+270270+static int mxsfb_check_var(struct fb_var_screeninfo *var,271271+ struct fb_info *fb_info)272272+{273273+ struct mxsfb_info *host = to_imxfb_host(fb_info);274274+ const struct fb_bitfield *rgb = NULL;275275+276276+ if (var->xres < MIN_XRES)277277+ var->xres = MIN_XRES;278278+ if (var->yres < MIN_YRES)279279+ var->yres = MIN_YRES;280280+281281+ var->xres_virtual = var->xres;282282+283283+ var->yres_virtual = var->yres;284284+285285+ switch (var->bits_per_pixel) {286286+ case 16:287287+ /* always expect RGB 565 */288288+ rgb = def_rgb565;289289+ break;290290+ case 32:291291+ switch (host->ld_intf_width) {292292+ case STMLCDIF_8BIT:293293+ pr_debug("Unsupported LCD bus width mapping\n");294294+ break;295295+ case STMLCDIF_16BIT:296296+ case STMLCDIF_18BIT:297297+ /* 24 bit to 18 bit mapping */298298+ rgb = def_rgb666;299299+ break;300300+ case STMLCDIF_24BIT:301301+ /* real 24 bit */302302+ rgb = def_rgb888;303303+ break;304304+ }305305+ break;306306+ default:307307+ pr_debug("Unsupported colour depth: %u\n", var->bits_per_pixel);308308+ return -EINVAL;309309+ }310310+311311+ /*312312+ * Copy the RGB parameters for this display313313+ * from the machine specific parameters.314314+ */315315+ var->red = rgb[RED];316316+ var->green = rgb[GREEN];317317+ var->blue = rgb[BLUE];318318+ var->transp = rgb[TRANSP];319319+320320+ return 0;321321+}322322+323323+static void mxsfb_enable_controller(struct fb_info *fb_info)324324+{325325+ struct mxsfb_info *host = to_imxfb_host(fb_info);326326+ u32 reg;327327+328328+ dev_dbg(&host->pdev->dev, "%s\n", __func__);329329+330330+ clk_enable(host->clk);331331+ clk_set_rate(host->clk, PICOS2KHZ(fb_info->var.pixclock) * 1000U);332332+333333+ /* if it was disabled, re-enable the mode again */334334+ writel(CTRL_DOTCLK_MODE, host->base + LCDC_CTRL + REG_SET);335335+336336+ /* enable the SYNC signals first, then the DMA engine */337337+ reg = readl(host->base + LCDC_VDCTRL4);338338+ reg |= VDCTRL4_SYNC_SIGNALS_ON;339339+ writel(reg, host->base + LCDC_VDCTRL4);340340+341341+ writel(CTRL_RUN, host->base + LCDC_CTRL + REG_SET);342342+343343+ host->enabled = 1;344344+}345345+346346+static void mxsfb_disable_controller(struct fb_info *fb_info)347347+{348348+ struct mxsfb_info *host = to_imxfb_host(fb_info);349349+ unsigned loop;350350+ u32 reg;351351+352352+ dev_dbg(&host->pdev->dev, "%s\n", __func__);353353+354354+ /*355355+ * Even if we disable the controller here, it will still continue356356+ * until its FIFOs are running out of data357357+ */358358+ writel(CTRL_DOTCLK_MODE, host->base + LCDC_CTRL + REG_CLR);359359+360360+ loop = 1000;361361+ while (loop) {362362+ reg = readl(host->base + LCDC_CTRL);363363+ if (!(reg & CTRL_RUN))364364+ break;365365+ loop--;366366+ }367367+368368+ writel(VDCTRL4_SYNC_SIGNALS_ON, host->base + LCDC_VDCTRL4 + REG_CLR);369369+370370+ clk_disable(host->clk);371371+372372+ host->enabled = 0;373373+}374374+375375+static int mxsfb_set_par(struct fb_info *fb_info)376376+{377377+ struct mxsfb_info *host = to_imxfb_host(fb_info);378378+ u32 ctrl, vdctrl0, vdctrl4;379379+ int line_size, fb_size;380380+ int reenable = 0;381381+382382+ line_size = fb_info->var.xres * (fb_info->var.bits_per_pixel >> 3);383383+ fb_size = fb_info->var.yres_virtual * line_size;384384+385385+ if (fb_size > fb_info->fix.smem_len)386386+ return -ENOMEM;387387+388388+ fb_info->fix.line_length = line_size;389389+390390+ /*391391+ * It seems, you can't re-program the controller if it is still running.392392+ * This may lead into shifted pictures (FIFO issue?).393393+ * So, first stop the controller and drain its FIFOs394394+ */395395+ if (host->enabled) {396396+ reenable = 1;397397+ mxsfb_disable_controller(fb_info);398398+ }399399+400400+ /* clear the FIFOs */401401+ writel(CTRL1_FIFO_CLEAR, host->base + LCDC_CTRL1 + REG_SET);402402+403403+ ctrl = CTRL_BYPASS_COUNT | CTRL_MASTER |404404+ CTRL_SET_BUS_WIDTH(host->ld_intf_width);;405405+406406+ switch (fb_info->var.bits_per_pixel) {407407+ case 16:408408+ dev_dbg(&host->pdev->dev, "Setting up RGB565 mode\n");409409+ ctrl |= CTRL_SET_WORD_LENGTH(0);410410+ writel(CTRL1_SET_BYTE_PACKAGING(0xf), host->base + LCDC_CTRL1);411411+ break;412412+ case 32:413413+ dev_dbg(&host->pdev->dev, "Setting up RGB888/666 mode\n");414414+ ctrl |= CTRL_SET_WORD_LENGTH(3);415415+ switch (host->ld_intf_width) {416416+ case STMLCDIF_8BIT:417417+ dev_dbg(&host->pdev->dev,418418+ "Unsupported LCD bus width mapping\n");419419+ return -EINVAL;420420+ case STMLCDIF_16BIT:421421+ case STMLCDIF_18BIT:422422+ /* 24 bit to 18 bit mapping */423423+ ctrl |= CTRL_DF24; /* ignore the upper 2 bits in424424+ * each colour component425425+ */426426+ break;427427+ case STMLCDIF_24BIT:428428+ /* real 24 bit */429429+ break;430430+ }431431+ /* do not use packed pixels = one pixel per word instead */432432+ writel(CTRL1_SET_BYTE_PACKAGING(0x7), host->base + LCDC_CTRL1);433433+ break;434434+ default:435435+ dev_dbg(&host->pdev->dev, "Unhandled color depth of %u\n",436436+ fb_info->var.bits_per_pixel);437437+ return -EINVAL;438438+ }439439+440440+ writel(ctrl, host->base + LCDC_CTRL);441441+442442+ writel(TRANSFER_COUNT_SET_VCOUNT(fb_info->var.yres) |443443+ TRANSFER_COUNT_SET_HCOUNT(fb_info->var.xres),444444+ host->base + host->devdata->transfer_count);445445+446446+ vdctrl0 = VDCTRL0_ENABLE_PRESENT | /* always in DOTCLOCK mode */447447+ VDCTRL0_VSYNC_PERIOD_UNIT |448448+ VDCTRL0_VSYNC_PULSE_WIDTH_UNIT |449449+ VDCTRL0_SET_VSYNC_PULSE_WIDTH(fb_info->var.vsync_len);450450+ if (fb_info->var.sync & FB_SYNC_HOR_HIGH_ACT)451451+ vdctrl0 |= VDCTRL0_HSYNC_ACT_HIGH;452452+ if (fb_info->var.sync & FB_SYNC_VERT_HIGH_ACT)453453+ vdctrl0 |= VDCTRL0_VSYNC_ACT_HIGH;454454+ if (fb_info->var.sync & FB_SYNC_DATA_ENABLE_HIGH_ACT)455455+ vdctrl0 |= VDCTRL0_ENABLE_ACT_HIGH;456456+ if (fb_info->var.sync & FB_SYNC_DOTCLK_FAILING_ACT)457457+ vdctrl0 |= VDCTRL0_DOTCLK_ACT_FAILING;458458+459459+ writel(vdctrl0, host->base + LCDC_VDCTRL0);460460+461461+ /* frame length in lines */462462+ writel(fb_info->var.upper_margin + fb_info->var.vsync_len +463463+ fb_info->var.lower_margin + fb_info->var.yres,464464+ host->base + LCDC_VDCTRL1);465465+466466+ /* line length in units of clocks or pixels */467467+ writel(set_hsync_pulse_width(host, fb_info->var.hsync_len) |468468+ VDCTRL2_SET_HSYNC_PERIOD(fb_info->var.left_margin +469469+ fb_info->var.hsync_len + fb_info->var.right_margin +470470+ fb_info->var.xres),471471+ host->base + LCDC_VDCTRL2);472472+473473+ writel(SET_HOR_WAIT_CNT(fb_info->var.left_margin +474474+ fb_info->var.hsync_len) |475475+ SET_VERT_WAIT_CNT(fb_info->var.upper_margin +476476+ fb_info->var.vsync_len),477477+ host->base + LCDC_VDCTRL3);478478+479479+ vdctrl4 = SET_DOTCLK_H_VALID_DATA_CNT(fb_info->var.xres);480480+ if (mxsfb_is_v4(host))481481+ vdctrl4 |= VDCTRL4_SET_DOTCLK_DLY(host->dotclk_delay);482482+ writel(vdctrl4, host->base + LCDC_VDCTRL4);483483+484484+ writel(fb_info->fix.smem_start +485485+ fb_info->fix.line_length * fb_info->var.yoffset,486486+ host->base + host->devdata->next_buf);487487+488488+ if (reenable)489489+ mxsfb_enable_controller(fb_info);490490+491491+ return 0;492492+}493493+494494+static int mxsfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,495495+ u_int transp, struct fb_info *fb_info)496496+{497497+ unsigned int val;498498+ int ret = -EINVAL;499499+500500+ /*501501+ * If greyscale is true, then we convert the RGB value502502+ * to greyscale no matter what visual we are using.503503+ */504504+ if (fb_info->var.grayscale)505505+ red = green = blue = (19595 * red + 38470 * green +506506+ 7471 * blue) >> 16;507507+508508+ switch (fb_info->fix.visual) {509509+ case FB_VISUAL_TRUECOLOR:510510+ /*511511+ * 12 or 16-bit True Colour. We encode the RGB value512512+ * according to the RGB bitfield information.513513+ */514514+ if (regno < 16) {515515+ u32 *pal = fb_info->pseudo_palette;516516+517517+ val = chan_to_field(red, &fb_info->var.red);518518+ val |= chan_to_field(green, &fb_info->var.green);519519+ val |= chan_to_field(blue, &fb_info->var.blue);520520+521521+ pal[regno] = val;522522+ ret = 0;523523+ }524524+ break;525525+526526+ case FB_VISUAL_STATIC_PSEUDOCOLOR:527527+ case FB_VISUAL_PSEUDOCOLOR:528528+ break;529529+ }530530+531531+ return ret;532532+}533533+534534+static int mxsfb_blank(int blank, struct fb_info *fb_info)535535+{536536+ struct mxsfb_info *host = to_imxfb_host(fb_info);537537+538538+ switch (blank) {539539+ case FB_BLANK_POWERDOWN:540540+ case FB_BLANK_VSYNC_SUSPEND:541541+ case FB_BLANK_HSYNC_SUSPEND:542542+ case FB_BLANK_NORMAL:543543+ if (host->enabled)544544+ mxsfb_disable_controller(fb_info);545545+ break;546546+547547+ case FB_BLANK_UNBLANK:548548+ if (!host->enabled)549549+ mxsfb_enable_controller(fb_info);550550+ break;551551+ }552552+ return 0;553553+}554554+555555+static int mxsfb_pan_display(struct fb_var_screeninfo *var,556556+ struct fb_info *fb_info)557557+{558558+ struct mxsfb_info *host = to_imxfb_host(fb_info);559559+ unsigned offset;560560+561561+ if (var->xoffset != 0)562562+ return -EINVAL;563563+564564+ offset = fb_info->fix.line_length * var->yoffset;565565+566566+ /* update on next VSYNC */567567+ writel(fb_info->fix.smem_start + offset,568568+ host->base + host->devdata->next_buf);569569+570570+ return 0;571571+}572572+573573+static struct fb_ops mxsfb_ops = {574574+ .owner = THIS_MODULE,575575+ .fb_check_var = mxsfb_check_var,576576+ .fb_set_par = mxsfb_set_par,577577+ .fb_setcolreg = mxsfb_setcolreg,578578+ .fb_blank = mxsfb_blank,579579+ .fb_pan_display = mxsfb_pan_display,580580+ .fb_fillrect = cfb_fillrect,581581+ .fb_copyarea = cfb_copyarea,582582+ .fb_imageblit = cfb_imageblit,583583+};584584+585585+static int __devinit mxsfb_restore_mode(struct mxsfb_info *host)586586+{587587+ struct fb_info *fb_info = &host->fb_info;588588+ unsigned line_count;589589+ unsigned period;590590+ unsigned long pa, fbsize;591591+ int bits_per_pixel, ofs;592592+ u32 transfer_count, vdctrl0, vdctrl2, vdctrl3, vdctrl4, ctrl;593593+ struct fb_videomode vmode;594594+595595+ /* Only restore the mode when the controller is running */596596+ ctrl = readl(host->base + LCDC_CTRL);597597+ if (!(ctrl & CTRL_RUN))598598+ return -EINVAL;599599+600600+ vdctrl0 = readl(host->base + LCDC_VDCTRL0);601601+ vdctrl2 = readl(host->base + LCDC_VDCTRL2);602602+ vdctrl3 = readl(host->base + LCDC_VDCTRL3);603603+ vdctrl4 = readl(host->base + LCDC_VDCTRL4);604604+605605+ transfer_count = readl(host->base + host->devdata->transfer_count);606606+607607+ vmode.xres = TRANSFER_COUNT_GET_HCOUNT(transfer_count);608608+ vmode.yres = TRANSFER_COUNT_GET_VCOUNT(transfer_count);609609+610610+ switch (CTRL_GET_WORD_LENGTH(ctrl)) {611611+ case 0:612612+ bits_per_pixel = 16;613613+ break;614614+ case 3:615615+ bits_per_pixel = 32;616616+ case 1:617617+ default:618618+ return -EINVAL;619619+ }620620+621621+ fb_info->var.bits_per_pixel = bits_per_pixel;622622+623623+ vmode.pixclock = KHZ2PICOS(clk_get_rate(host->clk) / 1000U);624624+ vmode.hsync_len = get_hsync_pulse_width(host, vdctrl2);625625+ vmode.left_margin = GET_HOR_WAIT_CNT(vdctrl3) - vmode.hsync_len;626626+ vmode.right_margin = VDCTRL2_GET_HSYNC_PERIOD(vdctrl2) - vmode.hsync_len -627627+ vmode.left_margin - vmode.xres;628628+ vmode.vsync_len = VDCTRL0_GET_VSYNC_PULSE_WIDTH(vdctrl0);629629+ period = readl(host->base + LCDC_VDCTRL1);630630+ vmode.upper_margin = GET_VERT_WAIT_CNT(vdctrl3) - vmode.vsync_len;631631+ vmode.lower_margin = period - vmode.vsync_len - vmode.upper_margin - vmode.yres;632632+633633+ vmode.vmode = FB_VMODE_NONINTERLACED;634634+635635+ vmode.sync = 0;636636+ if (vdctrl0 & VDCTRL0_HSYNC_ACT_HIGH)637637+ vmode.sync |= FB_SYNC_HOR_HIGH_ACT;638638+ if (vdctrl0 & VDCTRL0_VSYNC_ACT_HIGH)639639+ vmode.sync |= FB_SYNC_VERT_HIGH_ACT;640640+641641+ pr_debug("Reconstructed video mode:\n");642642+ pr_debug("%dx%d, hsync: %u left: %u, right: %u, vsync: %u, upper: %u, lower: %u\n",643643+ vmode.xres, vmode.yres,644644+ vmode.hsync_len, vmode.left_margin, vmode.right_margin,645645+ vmode.vsync_len, vmode.upper_margin, vmode.lower_margin);646646+ pr_debug("pixclk: %ldkHz\n", PICOS2KHZ(vmode.pixclock));647647+648648+ fb_add_videomode(&vmode, &fb_info->modelist);649649+650650+ host->ld_intf_width = CTRL_GET_BUS_WIDTH(ctrl);651651+ host->dotclk_delay = VDCTRL4_GET_DOTCLK_DLY(vdctrl4);652652+653653+ fb_info->fix.line_length = vmode.xres * (bits_per_pixel >> 3);654654+655655+ pa = readl(host->base + host->devdata->cur_buf);656656+ fbsize = fb_info->fix.line_length * vmode.yres;657657+ if (pa < fb_info->fix.smem_start)658658+ return -EINVAL;659659+ if (pa + fbsize > fb_info->fix.smem_start + fb_info->fix.smem_len)660660+ return -EINVAL;661661+ ofs = pa - fb_info->fix.smem_start;662662+ if (ofs) {663663+ memmove(fb_info->screen_base, fb_info->screen_base + ofs, fbsize);664664+ writel(fb_info->fix.smem_start, host->base + host->devdata->next_buf);665665+ }666666+667667+ line_count = fb_info->fix.smem_len / fb_info->fix.line_length;668668+ fb_info->fix.ypanstep = 1;669669+670670+ clk_enable(host->clk);671671+ host->enabled = 1;672672+673673+ return 0;674674+}675675+676676+static int __devinit mxsfb_init_fbinfo(struct mxsfb_info *host)677677+{678678+ struct fb_info *fb_info = &host->fb_info;679679+ struct fb_var_screeninfo *var = &fb_info->var;680680+ struct mxsfb_platform_data *pdata = host->pdev->dev.platform_data;681681+ dma_addr_t fb_phys;682682+ void *fb_virt;683683+ unsigned fb_size = pdata->fb_size;684684+685685+ fb_info->fbops = &mxsfb_ops;686686+ fb_info->flags = FBINFO_FLAG_DEFAULT | FBINFO_READS_FAST;687687+ strlcpy(fb_info->fix.id, "mxs", sizeof(fb_info->fix.id));688688+ fb_info->fix.type = FB_TYPE_PACKED_PIXELS;689689+ fb_info->fix.ypanstep = 1;690690+ fb_info->fix.visual = FB_VISUAL_TRUECOLOR,691691+ fb_info->fix.accel = FB_ACCEL_NONE;692692+693693+ var->bits_per_pixel = pdata->default_bpp ? pdata->default_bpp : 16;694694+ var->nonstd = 0;695695+ var->activate = FB_ACTIVATE_NOW;696696+ var->accel_flags = 0;697697+ var->vmode = FB_VMODE_NONINTERLACED;698698+699699+ host->dotclk_delay = pdata->dotclk_delay;700700+ host->ld_intf_width = pdata->ld_intf_width;701701+702702+ /* Memory allocation for framebuffer */703703+ if (pdata->fb_phys) {704704+ if (!fb_size)705705+ return -EINVAL;706706+707707+ fb_phys = pdata->fb_phys;708708+709709+ if (!request_mem_region(fb_phys, fb_size, host->pdev->name))710710+ return -ENOMEM;711711+712712+ fb_virt = ioremap(fb_phys, fb_size);713713+ if (!fb_virt) {714714+ release_mem_region(fb_phys, fb_size);715715+ return -ENOMEM;716716+ }717717+ host->mapped = 1;718718+ } else {719719+ if (!fb_size)720720+ fb_size = SZ_2M; /* default */721721+ fb_virt = alloc_pages_exact(fb_size, GFP_DMA);722722+ if (!fb_virt)723723+ return -ENOMEM;724724+725725+ fb_phys = virt_to_phys(fb_virt);726726+ }727727+728728+ fb_info->fix.smem_start = fb_phys;729729+ fb_info->screen_base = fb_virt;730730+ fb_info->screen_size = fb_info->fix.smem_len = fb_size;731731+732732+ if (mxsfb_restore_mode(host))733733+ memset(fb_virt, 0, fb_size);734734+735735+ return 0;736736+}737737+738738+static void __devexit mxsfb_free_videomem(struct mxsfb_info *host)739739+{740740+ struct fb_info *fb_info = &host->fb_info;741741+742742+ if (host->mapped) {743743+ iounmap(fb_info->screen_base);744744+ release_mem_region(fb_info->fix.smem_start,745745+ fb_info->screen_size);746746+ } else {747747+ free_pages_exact(fb_info->screen_base, fb_info->fix.smem_len);748748+ }749749+}750750+751751+static int __devinit mxsfb_probe(struct platform_device *pdev)752752+{753753+ struct mxsfb_platform_data *pdata = pdev->dev.platform_data;754754+ struct resource *res;755755+ struct mxsfb_info *host;756756+ struct fb_info *fb_info;757757+ struct fb_modelist *modelist;758758+ int i, ret;759759+760760+ if (!pdata) {761761+ dev_err(&pdev->dev, "No platformdata. Giving up\n");762762+ return -ENODEV;763763+ }764764+765765+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);766766+ if (!res) {767767+ dev_err(&pdev->dev, "Cannot get memory IO resource\n");768768+ return -ENODEV;769769+ }770770+771771+ if (!request_mem_region(res->start, resource_size(res), pdev->name))772772+ return -EBUSY;773773+774774+ fb_info = framebuffer_alloc(sizeof(struct mxsfb_info), &pdev->dev);775775+ if (!fb_info) {776776+ dev_err(&pdev->dev, "Failed to allocate fbdev\n");777777+ ret = -ENOMEM;778778+ goto error_alloc_info;779779+ }780780+781781+ host = to_imxfb_host(fb_info);782782+783783+ host->base = ioremap(res->start, resource_size(res));784784+ if (!host->base) {785785+ dev_err(&pdev->dev, "ioremap failed\n");786786+ ret = -ENOMEM;787787+ goto error_ioremap;788788+ }789789+790790+ host->pdev = pdev;791791+ platform_set_drvdata(pdev, host);792792+793793+ host->devdata = &mxsfb_devdata[pdev->id_entry->driver_data];794794+795795+ host->clk = clk_get(&host->pdev->dev, NULL);796796+ if (IS_ERR(host->clk)) {797797+ ret = PTR_ERR(host->clk);798798+ goto error_getclock;799799+ }800800+801801+ fb_info->pseudo_palette = kmalloc(sizeof(u32) * 16, GFP_KERNEL);802802+ if (!fb_info->pseudo_palette) {803803+ ret = -ENOMEM;804804+ goto error_pseudo_pallette;805805+ }806806+807807+ INIT_LIST_HEAD(&fb_info->modelist);808808+809809+ ret = mxsfb_init_fbinfo(host);810810+ if (ret != 0)811811+ goto error_init_fb;812812+813813+ for (i = 0; i < pdata->mode_count; i++)814814+ fb_add_videomode(&pdata->mode_list[i], &fb_info->modelist);815815+816816+ modelist = list_first_entry(&fb_info->modelist,817817+ struct fb_modelist, list);818818+ fb_videomode_to_var(&fb_info->var, &modelist->mode);819819+820820+ /* init the color fields */821821+ mxsfb_check_var(&fb_info->var, fb_info);822822+823823+ platform_set_drvdata(pdev, fb_info);824824+825825+ ret = register_framebuffer(fb_info);826826+ if (ret != 0) {827827+ dev_err(&pdev->dev,"Failed to register framebuffer\n");828828+ goto error_register;829829+ }830830+831831+ if (!host->enabled) {832832+ writel(0, host->base + LCDC_CTRL);833833+ mxsfb_set_par(fb_info);834834+ mxsfb_enable_controller(fb_info);835835+ }836836+837837+ dev_info(&pdev->dev, "initialized\n");838838+839839+ return 0;840840+841841+error_register:842842+ if (host->enabled)843843+ clk_disable(host->clk);844844+ fb_destroy_modelist(&fb_info->modelist);845845+error_init_fb:846846+ kfree(fb_info->pseudo_palette);847847+error_pseudo_pallette:848848+ clk_put(host->clk);849849+error_getclock:850850+ iounmap(host->base);851851+error_ioremap:852852+ framebuffer_release(fb_info);853853+error_alloc_info:854854+ release_mem_region(res->start, resource_size(res));855855+856856+ return ret;857857+}858858+859859+static int __devexit mxsfb_remove(struct platform_device *pdev)860860+{861861+ struct fb_info *fb_info = platform_get_drvdata(pdev);862862+ struct mxsfb_info *host = to_imxfb_host(fb_info);863863+ struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);864864+865865+ if (host->enabled)866866+ mxsfb_disable_controller(fb_info);867867+868868+ unregister_framebuffer(fb_info);869869+ kfree(fb_info->pseudo_palette);870870+ mxsfb_free_videomem(host);871871+ iounmap(host->base);872872+ clk_put(host->clk);873873+874874+ framebuffer_release(fb_info);875875+ release_mem_region(res->start, resource_size(res));876876+877877+ platform_set_drvdata(pdev, NULL);878878+879879+ return 0;880880+}881881+882882+static struct platform_device_id mxsfb_devtype[] = {883883+ {884884+ .name = "imx23-fb",885885+ .driver_data = MXSFB_V3,886886+ }, {887887+ .name = "imx28-fb",888888+ .driver_data = MXSFB_V4,889889+ }, {890890+ /* sentinel */891891+ }892892+};893893+MODULE_DEVICE_TABLE(platform, mxsfb_devtype);894894+895895+static struct platform_driver mxsfb_driver = {896896+ .probe = mxsfb_probe,897897+ .remove = __devexit_p(mxsfb_remove),898898+ .id_table = mxsfb_devtype,899899+ .driver = {900900+ .name = DRIVER_NAME,901901+ },902902+};903903+904904+static int __init mxsfb_init(void)905905+{906906+ return platform_driver_register(&mxsfb_driver);907907+}908908+909909+static void __exit mxsfb_exit(void)910910+{911911+ platform_driver_unregister(&mxsfb_driver);912912+}913913+914914+module_init(mxsfb_init);915915+module_exit(mxsfb_exit);916916+917917+MODULE_DESCRIPTION("Freescale mxs framebuffer driver");918918+MODULE_AUTHOR("Sascha Hauer, Pengutronix");919919+MODULE_LICENSE("GPL");
···9898 int ret;9999100100 if (!machine_is_eukrea_cpuimx27() && !machine_is_eukrea_cpuimx25sd()101101- && !machine_is_eukrea_cpuimx35sd())101101+ && !machine_is_eukrea_cpuimx35sd()102102+ && !machine_is_eukrea_cpuimx51sd())102103 /* return happy. We might run on a totally different machine */103104 return 0;104105