Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Copyright (C) 2009 Jan Weitzel, Phytec Messtechnik GmbH
- * based on pcm043.c
- * Copyright (C) 2009 Sascha Hauer, Pengutronix
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
- #include <linux/types.h>
- #include <linux/init.h>
- #include <linux/platform_device.h>
- #include <linux/mtd/physmap.h>
- #include <linux/mtd/plat-ram.h>
- #include <linux/memory.h>
- #include <linux/gpio.h>
- #include <linux/smc911x.h>
- #include <linux/interrupt.h>
- #include <linux/i2c.h>
- #include <linux/i2c/at24.h>
- #include <linux/fsl_devices.h>
- #include <linux/delay.h>
- #ifdef CONFIG_SPI
- #include <linux/spi/spi.h>
- #endif
- #ifdef CONFIG_GPIO_MAX7301
- #include <linux/spi/max7301.h>
- #endif
- #include <asm/mach-types.h>
- #include <asm/mach/arch.h>
- #include <asm/mach/time.h>
- #include <asm/mach/map.h>
- #include <mach/hardware.h>
- #include <mach/common.h>
- #include <mach/imx-uart.h>
- #if defined CONFIG_I2C_IMX || defined CONFIG_I2C_IMX_MODULE
- #include <mach/i2c.h>
- #endif
- #ifdef CONFIG_SPI
- #include <mach/spi.h>
- #endif
- #include <mach/iomux-mx35.h>
- #include <mach/ipu.h>
- #include <mach/mx3fb.h>
- #include <mach/mxc_ehci.h>
- #include <mach/audmux.h>
- #include <mach/ssi.h>
- #include <mach/mxc_nand.h>
- #include "devices.h"
- static const struct fb_videomode fb_modedb[] = {
- {
- .name = "Primeview-PD050VL1",
- .refresh = 60,
- .xres = 640,
- .yres = 480,
- .pixclock = 45045, /* in ps (22,2 MHz) */
- .hsync_len = 32,
- .left_margin = 112,
- .right_margin = 36,
- .vsync_len = 2,
- .upper_margin = 33,
- .lower_margin = 33,
- .sync = FB_SYNC_OE_ACT_HIGH,
- .vmode = FB_VMODE_NONINTERLACED,
- .flag = 0,
- },
- };
- static struct ipu_platform_data mx3_ipu_data = {
- .irq_base = MXC_IPU_IRQ_START,
- };
- static struct mx3fb_platform_data mx3fb_pdata = {
- .dma_dev = &mx3_ipu.dev,
- .name = "Primeview-PD050VL1",
- .mode = fb_modedb,
- .num_modes = ARRAY_SIZE(fb_modedb),
- };
- static struct imxuart_platform_data uart_pdata = {
- .flags = IMXUART_HAVE_RTSCTS,
- };
- #if defined CONFIG_I2C_IMX || defined CONFIG_I2C_IMX_MODULE
- static struct imxi2c_platform_data pca101_i2c_1_data = {
- .bitrate = 50000,
- };
- static struct at24_platform_data board_eeprom = {
- .byte_len = 4096,
- .page_size = 32,
- .flags = AT24_FLAG_ADDR16,
- };
- static struct i2c_board_info pca101_i2c_devices_modul[] = {
- {
- I2C_BOARD_INFO("at24", 0x52), /* E0=0, E1=1, E2=0 */
- .platform_data = &board_eeprom,
- }
- };
- static struct imxi2c_platform_data pca101_i2c_3_data = {
- .bitrate = 50000,
- };
- static struct i2c_board_info pca101_i2c_devices_board[] = {
- {
- I2C_BOARD_INFO("pcf8563", 0x51),
- }
- };
- #endif
- static struct platform_device *devices[] __initdata = {
- &mxc_fec_device,
- &mxc_w1_master_device,
- };
- static struct pad_desc pca101_pads[] = {
- /* UART1 */
- MX35_PAD_CTS1__UART1_CTS,
- MX35_PAD_RTS1__UART1_RTS,
- MX35_PAD_TXD1__UART1_TXD_MUX,
- MX35_PAD_RXD1__UART1_RXD_MUX,
- /* FEC */
- MX35_PAD_FEC_TX_CLK__FEC_TX_CLK,
- MX35_PAD_FEC_RX_CLK__FEC_RX_CLK,
- MX35_PAD_FEC_RX_DV__FEC_RX_DV,
- MX35_PAD_FEC_COL__FEC_COL,
- MX35_PAD_FEC_RDATA0__FEC_RDATA_0,
- MX35_PAD_FEC_TDATA0__FEC_TDATA_0,
- MX35_PAD_FEC_TX_EN__FEC_TX_EN,
- MX35_PAD_FEC_MDC__FEC_MDC,
- MX35_PAD_FEC_MDIO__FEC_MDIO,
- MX35_PAD_FEC_TX_ERR__FEC_TX_ERR,
- MX35_PAD_FEC_RX_ERR__FEC_RX_ERR,
- MX35_PAD_FEC_CRS__FEC_CRS,
- MX35_PAD_FEC_RDATA1__FEC_RDATA_1,
- MX35_PAD_FEC_TDATA1__FEC_TDATA_1,
- MX35_PAD_FEC_RDATA2__FEC_RDATA_2,
- MX35_PAD_FEC_TDATA2__FEC_TDATA_2,
- MX35_PAD_FEC_RDATA3__FEC_RDATA_3,
- MX35_PAD_FEC_TDATA3__FEC_TDATA_3,
- /* I2C1 Module*/
- MX35_PAD_I2C1_CLK__I2C1_SCL,
- MX35_PAD_I2C1_DAT__I2C1_SDA,
- /* I2C3 Board */
- MX35_PAD_ATA_DATA12__I2C3_SCL,
- MX35_PAD_ATA_DATA13__I2C3_SDA,
- /* Display */
- MX35_PAD_LD0__IPU_DISPB_DAT_0,
- MX35_PAD_LD1__IPU_DISPB_DAT_1,
- MX35_PAD_LD2__IPU_DISPB_DAT_2,
- MX35_PAD_LD3__IPU_DISPB_DAT_3,
- MX35_PAD_LD4__IPU_DISPB_DAT_4,
- MX35_PAD_LD5__IPU_DISPB_DAT_5,
- MX35_PAD_LD6__IPU_DISPB_DAT_6,
- MX35_PAD_LD7__IPU_DISPB_DAT_7,
- MX35_PAD_LD8__IPU_DISPB_DAT_8,
- MX35_PAD_LD9__IPU_DISPB_DAT_9,
- MX35_PAD_LD10__IPU_DISPB_DAT_10,
- MX35_PAD_LD11__IPU_DISPB_DAT_11,
- MX35_PAD_LD12__IPU_DISPB_DAT_12,
- MX35_PAD_LD13__IPU_DISPB_DAT_13,
- MX35_PAD_LD14__IPU_DISPB_DAT_14,
- MX35_PAD_LD15__IPU_DISPB_DAT_15,
- MX35_PAD_LD16__IPU_DISPB_DAT_16,
- MX35_PAD_LD17__IPU_DISPB_DAT_17,
- MX35_PAD_LD18__IPU_DISPB_DAT_18,
- MX35_PAD_LD19__IPU_DISPB_DAT_19,
- MX35_PAD_LD20__IPU_DISPB_DAT_20,
- MX35_PAD_LD21__IPU_DISPB_DAT_21,
- MX35_PAD_LD22__IPU_DISPB_DAT_22,
- MX35_PAD_LD23__IPU_DISPB_DAT_23,
- MX35_PAD_D3_HSYNC__IPU_DISPB_D3_HSYNC,
- MX35_PAD_D3_FPSHIFT__IPU_DISPB_D3_CLK,
- MX35_PAD_D3_DRDY__IPU_DISPB_D3_DRDY,
- MX35_PAD_D3_VSYNC__IPU_DISPB_D3_VSYNC,
- /* USB host */
- MX35_PAD_I2C2_CLK__USB_TOP_USBH2_PWR,
- MX35_PAD_I2C2_DAT__USB_TOP_USBH2_OC,
- /* SPI */
- MX35_PAD_CSPI1_SS0__CSPI1_SS0,
- MX35_PAD_CSPI1_SS1__CSPI1_SS1,
- MX35_PAD_CSPI1_MISO__CSPI1_MISO,
- MX35_PAD_CSPI1_MOSI__CSPI1_MOSI,
- MX35_PAD_CSPI1_SCLK__CSPI1_SCLK,
- MX35_PAD_CSPI1_SPI_RDY__CSPI1_RDY,
- /* SSI */
- MX35_PAD_STXFS4__AUDMUX_AUD4_TXFS,
- MX35_PAD_STXD4__AUDMUX_AUD4_TXD,
- MX35_PAD_SRXD4__AUDMUX_AUD4_RXD,
- MX35_PAD_SCK4__AUDMUX_AUD4_TXC,
- /* 1-Wire*/
- MX35_PAD_GPIO1_0__OWIRE_LINE,
- /* GPIO */
- ///* VB
- MX35_PAD_ATA_CS0__GPIO2_6,
- MX35_PAD_ATA_CS1__GPIO2_7,
- MX35_PAD_ATA_DATA10__GPIO2_23, // ADD VB
- //MX35_PAD_SRXD5__GPIO1_1, // ADD VB
- MX35_PAD_CSPI1_SS0__GPIO1_18, // ADD VB
- MX35_PAD_CSPI1_SS1__GPIO1_19, // ADD VB
- //VB */
- };
- static int pca101_usbh1_init(struct platform_device *pdev)
- {
- unsigned int tmp;
- tmp = readl(IO_ADDRESS(MX35_OTG_BASE_ADDR) + 0x600);
- tmp &= ~((3 << 21) | (1 << 2) | (1 << 16));
- tmp |= (1 << 4) | (2 << 21) | (1 << 19) | (1 << 12) | (1 << 6) | (1 << 5);
- writel(tmp, IO_ADDRESS(MX35_OTG_BASE_ADDR) + 0x600);
- tmp = readl(IO_ADDRESS(MX35_OTG_BASE_ADDR) + 0x584);
- tmp |= (3 << 30);
- writel(tmp, IO_ADDRESS(MX35_OTG_BASE_ADDR) + 0x584);
- return 0;
- }
- static struct mxc_usbh_platform_data usbh1_pdata = {
- .init = pca101_usbh1_init,
- };
- static int pca101_otg_init(struct platform_device *pdev)
- {
- unsigned int tmp;
- tmp = readl(IO_ADDRESS(MX35_OTG_BASE_ADDR) + 0x600);
- tmp &= ~(3 << 29);
- tmp |= (2 << 29);
- writel(tmp, IO_ADDRESS(MX35_OTG_BASE_ADDR) + 0x600);
- tmp = readl(IO_ADDRESS(MX35_OTG_BASE_ADDR) + 0x184);
- tmp &= ~(3 << 30);
- writel(tmp, IO_ADDRESS(MX35_OTG_BASE_ADDR) + 0x184);
- return 0;
- }
- static struct mxc_usbh_platform_data otg_pdata = {
- .init = pca101_otg_init,
- };
- static struct fsl_usb2_platform_data usb_data = {
- .operating_mode = FSL_USB2_DR_DEVICE,
- .phy_mode = FSL_USB2_PHY_UTMI,
- };
- #ifdef CONFIG_SPI
- static unsigned int pca101_spi_cs [] = {MXC_SPI_CS(0), };
- static struct spi_imx_master pca101_spi_0_data = {
- .chipselect = pca101_spi_cs,
- .num_chipselect = ARRAY_SIZE (pca101_spi_cs),
- };
- #endif /* CONFIG_SPI */
- #ifdef CONFIG_GPIO_MAX7301
- static struct max7301_platform_data max7301_info = {
- .base = -1,
- };
- // bus_num must match id in imx_spi_device struct
- static struct spi_board_info spi_board_info [] __initdata = {
- {
- .modalias = "max7301",
- .platform_data = &max7301_info,
- .max_speed_hz = 13000000,
- .bus_num = 1,
- .chip_select = 0,
- .mode = SPI_MODE_0,
- },
- };
- #endif /* CONFIG_GPIO_MAX7301 */
- /* VB */
- static struct spi_board_info spi_board_info [] __initdata = {
- {
- .modalias = "spidev",
- .max_speed_hz = 10000000,
- .bus_num = 1,
- .chip_select = 0,
- .mode = SPI_MODE_0,
- },
- };
- /* VB */
- static int otg_mode_host;
- static int __init pca101_otg_mode(char *options)
- {
- if (!strcmp(options, "host"))
- otg_mode_host = 1;
- else if (!strcmp(options, "device"))
- otg_mode_host = 0;
- else
- pr_info("pca101_otg_mode neither \"host\" nor \"device\". "
- "Defaulting to device\n");
- return 0;
- }
- __setup("pca101_otg_mode=", pca101_otg_mode);
- #define AC97_GPIO_TXFS (1 * 32 + 31)
- #define AC97_GPIO_TXD (1 * 32 + 28)
- #define AC97_GPIO_RESET (2 * 32 + 2)
- static void pca101_ac97_warm_reset(struct snd_ac97 *ac97)
- {
- struct pad_desc txfs_gpio = MX35_PAD_STXFS4__GPIO2_31;
- struct pad_desc txfs = MX35_PAD_STXFS4__AUDMUX_AUD4_TXFS;
- int ret;
- ret = gpio_request(AC97_GPIO_TXFS, "SSI");
- if (ret) {
- printk("failed to get GPIO_TXFS: %d\n", ret);
- return;
- }
- mxc_iomux_v3_setup_pad(&txfs_gpio);
- /* warm reset */
- gpio_direction_output(AC97_GPIO_TXFS, 1);
- udelay(2);
- gpio_set_value(AC97_GPIO_TXFS, 0);
- gpio_free(AC97_GPIO_TXFS);
- mxc_iomux_v3_setup_pad(&txfs);
- }
- static void pca101_ac97_cold_reset(struct snd_ac97 *ac97)
- {
- struct pad_desc txfs_gpio = MX35_PAD_STXFS4__GPIO2_31;
- struct pad_desc txfs = MX35_PAD_STXFS4__AUDMUX_AUD4_TXFS;
- struct pad_desc txd_gpio = MX35_PAD_STXD4__GPIO2_28;
- struct pad_desc txd = MX35_PAD_STXD4__AUDMUX_AUD4_TXD;
- struct pad_desc reset_gpio = MX35_PAD_ATA_DA2__GPIO3_2;
- int ret;
- ret = gpio_request(AC97_GPIO_TXFS, "SSI");
- if (ret)
- goto err1;
- ret = gpio_request(AC97_GPIO_TXD, "SSI");
- if (ret)
- goto err2;
- ret = gpio_request(AC97_GPIO_RESET, "SSI");
- if (ret)
- goto err3;
- mxc_iomux_v3_setup_pad(&txfs_gpio);
- mxc_iomux_v3_setup_pad(&txd_gpio);
- mxc_iomux_v3_setup_pad(&reset_gpio);
- gpio_direction_output(AC97_GPIO_TXFS, 0);
- gpio_direction_output(AC97_GPIO_TXD, 0);
- /* cold reset */
- gpio_direction_output(AC97_GPIO_RESET, 0);
- udelay(10);
- gpio_direction_output(AC97_GPIO_RESET, 1);
- mxc_iomux_v3_setup_pad(&txd);
- mxc_iomux_v3_setup_pad(&txfs);
- gpio_free(AC97_GPIO_RESET);
- err3:
- gpio_free(AC97_GPIO_TXD);
- err2:
- gpio_free(AC97_GPIO_TXFS);
- err1:
- if (ret)
- printk("%s failed with %d\n", __func__, ret);
- mdelay(1);
- }
- static struct imx_ssi_platform_data pca101_ssi_pdata = {
- .ac97_reset = pca101_ac97_cold_reset,
- .ac97_warm_reset = pca101_ac97_warm_reset,
- .flags = IMX_SSI_USE_AC97,
- };
- static struct mxc_nand_platform_data pca101_nand_board_info = {
- .width = 1,
- .hw_ecc = 1,
- };
- /*
- * Board specific initialization.
- */
- static void __init mxc_board_init(void)
- {
- unsigned int tmp;
- mxc_iomux_v3_setup_multiple_pads(pca101_pads, ARRAY_SIZE(pca101_pads));
- mxc_audmux_v2_configure_port(3,
- MXC_AUDMUX_V2_PTCR_SYN | /* 4wire mode */
- MXC_AUDMUX_V2_PTCR_TFSEL(0) |
- MXC_AUDMUX_V2_PTCR_TFSDIR,
- MXC_AUDMUX_V2_PDCR_RXDSEL(0));
- mxc_audmux_v2_configure_port(0,
- MXC_AUDMUX_V2_PTCR_SYN | /* 4wire mode */
- MXC_AUDMUX_V2_PTCR_TCSEL(3) |
- MXC_AUDMUX_V2_PTCR_TCLKDIR, /* clock is output */
- MXC_AUDMUX_V2_PDCR_RXDSEL(3));
- platform_add_devices(devices, ARRAY_SIZE(devices));
- mxc_register_device(&mxc_uart_device0, &uart_pdata);
- mxc_register_device(&imx_ssi_device0, &pca101_ssi_pdata);
- #if defined CONFIG_I2C_IMX || defined CONFIG_I2C_IMX_MODULE
- i2c_register_board_info(0, pca101_i2c_devices_modul,
- ARRAY_SIZE(pca101_i2c_devices_modul));
- mxc_register_device(&mxc_i2c_device0, &pca101_i2c_1_data);
- i2c_register_board_info(2, pca101_i2c_devices_board,
- ARRAY_SIZE(pca101_i2c_devices_board));
- mxc_register_device(&mxc_i2c_device2, &pca101_i2c_3_data);
- #endif
- mxc_register_device(&mxc_nand_device, &pca101_nand_board_info);
- mxc_register_device(&mx3_ipu, &mx3_ipu_data);
- mxc_register_device(&mx3_fb, &mx3fb_pdata);
- tmp = readl(IO_ADDRESS(MX35_OTG_BASE_ADDR) + 0x600);
- tmp &= ~(3 << 29);
- tmp |= (2 << 29);
- writel(tmp, IO_ADDRESS(MX35_OTG_BASE_ADDR) + 0x600);
- mxc_register_device(&mxc_usbh1, &usbh1_pdata);
- if (otg_mode_host)
- mxc_register_device(&mxc_otg_host, &otg_pdata);
- else
- mxc_register_device(&mxc_otg_udc_device, &usb_data);
- #ifdef CONFIG_SPI
- mxc_register_device (&mxc_spi_device0, &pca101_spi_0_data);
- #endif
- #ifdef CONFIG_GPIO_MAX7301
- spi_register_board_info (spi_board_info,
- ARRAY_SIZE (spi_board_info));
- #endif
- /* VB */
- printk("** VB spi_register_board_info...\n");
- tmp=spi_register_board_info (spi_board_info,
- ARRAY_SIZE (spi_board_info));
- printk("** VB tmp=%d\n", tmp);
- /* VB */
- }
- static void __init pca101_timer_init(void)
- {
- printk("mx35_clocks_init()\n");
- mx35_clocks_init();
- }
- struct sys_timer pca101_timer = {
- .init = pca101_timer_init,
- };
- MACHINE_START(PCA101, "Phytec PhyCARD-M pca101 VB")
- /* Maintainer: Phytec */
- .phys_io = AIPS1_BASE_ADDR,
- .io_pg_offst = ((AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,
- .boot_params = PHYS_OFFSET + 0x100,
- .map_io = mx35_map_io,
- .init_irq = mx35_init_irq,
- .init_machine = mxc_board_init,
- .timer = &pca101_timer,
- MACHINE_END
- #define BACKLIGHT_GPIO (1 * 32 + 7)
- static int __init pca101_baseboard_init_late(void)
- {
- int ret;
- /*Switch Backligth on*/
- ret = gpio_request(BACKLIGHT_GPIO, "BACKLIGHT");
- if (!ret) {
- gpio_direction_output(BACKLIGHT_GPIO, 0);
- gpio_free(BACKLIGHT_GPIO);
- }
- return ret;
- }
- late_initcall(pca101_baseboard_init_late);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement