2009-04-14 15:08:03 +00:00
|
|
|
/*
|
2007-10-07 22:13:19 +00:00
|
|
|
* Copyright (C) 2007 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.
|
|
|
|
*/
|
2014-06-05 17:24:47 +00:00
|
|
|
|
2013-01-26 12:10:57 +00:00
|
|
|
#define pr_fmt(fmt) "pcm038: " fmt
|
2007-10-07 22:13:19 +00:00
|
|
|
|
2013-04-03 08:12:11 +00:00
|
|
|
#include <bootsource.h>
|
2014-06-05 17:24:47 +00:00
|
|
|
#include <common.h>
|
2013-08-16 10:26:17 +00:00
|
|
|
#include <gpio.h>
|
2014-06-05 17:24:47 +00:00
|
|
|
#include <init.h>
|
2011-09-22 17:02:57 +00:00
|
|
|
#include <io.h>
|
2014-06-05 17:24:47 +00:00
|
|
|
#include <notifier.h>
|
|
|
|
#include <sizes.h>
|
2014-06-12 06:25:19 +00:00
|
|
|
#include <envfs.h>
|
2014-06-05 17:24:47 +00:00
|
|
|
#include <mach/devices-imx27.h>
|
2009-10-22 12:21:25 +00:00
|
|
|
#include <mach/imx-pll.h>
|
2014-06-05 17:24:47 +00:00
|
|
|
#include <mach/imx27-regs.h>
|
2009-10-22 12:21:25 +00:00
|
|
|
#include <mach/imxfb.h>
|
2010-06-16 12:30:07 +00:00
|
|
|
#include <mach/iomux-mx27.h>
|
2012-04-10 19:44:16 +00:00
|
|
|
#include <mfd/mc13xxx.h>
|
2007-10-07 22:13:19 +00:00
|
|
|
|
2010-10-08 09:02:43 +00:00
|
|
|
#include "pll.h"
|
|
|
|
|
2013-05-06 13:35:39 +00:00
|
|
|
#define PCM038_GPIO_OTG_STP (GPIO_PORTE + 1)
|
2013-05-03 13:11:48 +00:00
|
|
|
|
2009-07-31 13:09:59 +00:00
|
|
|
static struct imx_fb_videomode imxfb_mode = {
|
|
|
|
.mode = {
|
|
|
|
.name = "Sharp-LQ035Q7",
|
|
|
|
.refresh = 60,
|
|
|
|
.xres = 240,
|
|
|
|
.yres = 320,
|
|
|
|
.pixclock = 188679, /* in ps (5.3MHz) */
|
|
|
|
.hsync_len = 7,
|
|
|
|
.left_margin = 5,
|
|
|
|
.right_margin = 16,
|
|
|
|
.vsync_len = 1,
|
|
|
|
.upper_margin = 7,
|
|
|
|
.lower_margin = 9,
|
|
|
|
},
|
|
|
|
/*
|
|
|
|
* - HSYNC active high
|
|
|
|
* - VSYNC active high
|
|
|
|
* - clk notenabled while idle
|
|
|
|
* - clock not inverted
|
|
|
|
* - data not inverted
|
|
|
|
* - data enable low active
|
|
|
|
* - enable sharp mode
|
|
|
|
*/
|
2014-06-05 17:24:47 +00:00
|
|
|
.pcr = 0xf00080c0,
|
2009-07-31 13:09:59 +00:00
|
|
|
.bpp = 16,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct imx_fb_platform_data pcm038_fb_data = {
|
|
|
|
.mode = &imxfb_mode,
|
2012-01-04 14:20:16 +00:00
|
|
|
.num_modes = 1,
|
2014-06-05 17:24:47 +00:00
|
|
|
.pwmr = 0x00a903ff,
|
2009-07-31 13:09:59 +00:00
|
|
|
.lscr1 = 0x00120300,
|
|
|
|
.dmacr = 0x00020010,
|
|
|
|
};
|
|
|
|
|
2014-06-05 17:24:47 +00:00
|
|
|
static const unsigned int pcm038_pins[] = {
|
|
|
|
/* Display */
|
|
|
|
PA5_PF_LSCLK,
|
|
|
|
PA6_PF_LD0,
|
|
|
|
PA7_PF_LD1,
|
|
|
|
PA8_PF_LD2,
|
|
|
|
PA9_PF_LD3,
|
|
|
|
PA10_PF_LD4,
|
|
|
|
PA11_PF_LD5,
|
|
|
|
PA12_PF_LD6,
|
|
|
|
PA13_PF_LD7,
|
|
|
|
PA14_PF_LD8,
|
|
|
|
PA15_PF_LD9,
|
|
|
|
PA16_PF_LD10,
|
|
|
|
PA17_PF_LD11,
|
|
|
|
PA18_PF_LD12,
|
|
|
|
PA19_PF_LD13,
|
|
|
|
PA20_PF_LD14,
|
|
|
|
PA21_PF_LD15,
|
|
|
|
PA22_PF_LD16,
|
|
|
|
PA23_PF_LD17,
|
|
|
|
PA24_PF_REV,
|
|
|
|
PA25_PF_CLS,
|
|
|
|
PA26_PF_PS,
|
|
|
|
PA27_PF_SPL_SPR,
|
|
|
|
PA28_PF_HSYNC,
|
|
|
|
PA29_PF_VSYNC,
|
|
|
|
PA30_PF_CONTRAST,
|
|
|
|
PA31_PF_OE_ACD,
|
|
|
|
/* USB */
|
|
|
|
PE1_PF_USBOTG_STP,
|
2014-02-27 20:39:09 +00:00
|
|
|
};
|
|
|
|
|
2014-06-05 17:24:47 +00:00
|
|
|
static int pcm038_init(void)
|
2007-10-07 22:13:19 +00:00
|
|
|
{
|
2014-06-05 17:24:47 +00:00
|
|
|
struct mc13xxx *mc13xxx = mc13xxx_get();
|
2009-06-10 16:17:32 +00:00
|
|
|
char *envdev;
|
2014-06-05 17:24:47 +00:00
|
|
|
uint32_t i;
|
2011-08-12 09:21:56 +00:00
|
|
|
|
2014-06-05 17:24:47 +00:00
|
|
|
if (!of_machine_is_compatible("phytec,imx27-pcm038"))
|
|
|
|
return 0;
|
2009-05-18 07:06:58 +00:00
|
|
|
|
2013-05-06 13:35:39 +00:00
|
|
|
/* Apply delay for STP line to stop ULPI */
|
2014-06-05 17:24:47 +00:00
|
|
|
imx_gpio_mode(PCM038_GPIO_OTG_STP | GPIO_GPIO);
|
2013-05-06 13:35:39 +00:00
|
|
|
gpio_direction_output(PCM038_GPIO_OTG_STP, 1);
|
|
|
|
mdelay(1);
|
|
|
|
|
2014-06-05 17:24:47 +00:00
|
|
|
for (i = 0; i < ARRAY_SIZE(pcm038_pins); i++)
|
|
|
|
imx_gpio_mode(pcm038_pins[i]);
|
|
|
|
|
|
|
|
imx27_add_fb(&pcm038_fb_data);
|
2013-05-06 13:35:39 +00:00
|
|
|
|
2013-04-03 08:12:11 +00:00
|
|
|
switch (bootsource_get()) {
|
2013-03-14 17:38:40 +00:00
|
|
|
case BOOTSOURCE_NAND:
|
2014-06-05 17:24:47 +00:00
|
|
|
of_device_enable_path("/chosen/environment-nand");
|
2009-05-18 07:06:58 +00:00
|
|
|
envdev = "NAND";
|
|
|
|
break;
|
|
|
|
default:
|
2014-06-05 17:24:47 +00:00
|
|
|
of_device_enable_path("/chosen/environment-nor");
|
2009-05-18 07:06:58 +00:00
|
|
|
envdev = "NOR";
|
2014-06-05 17:24:47 +00:00
|
|
|
break;
|
2009-05-18 07:06:58 +00:00
|
|
|
}
|
|
|
|
|
2013-01-26 12:10:57 +00:00
|
|
|
pr_notice("Using environment in %s Flash\n", envdev);
|
2009-05-18 07:06:58 +00:00
|
|
|
|
2014-06-05 17:24:47 +00:00
|
|
|
if (!mc13xxx) {
|
|
|
|
pr_err("Failed to initialize PMIC. Will continue with low CPU speed\n");
|
|
|
|
return 0;
|
|
|
|
}
|
2009-05-18 07:06:58 +00:00
|
|
|
|
2014-06-05 17:24:47 +00:00
|
|
|
mc13xxx_reg_write(mc13xxx, MC13783_REG_SWITCHERS(0),
|
|
|
|
MC13783_SWX_VOLTAGE(MC13783_SWX_VOLTAGE_1_450) |
|
|
|
|
MC13783_SWX_VOLTAGE_DVS(MC13783_SWX_VOLTAGE_1_450) |
|
|
|
|
MC13783_SWX_VOLTAGE_STANDBY(MC13783_SWX_VOLTAGE_1_450));
|
2007-10-07 22:13:19 +00:00
|
|
|
|
2014-06-05 17:24:47 +00:00
|
|
|
mc13xxx_reg_write(mc13xxx, MC13783_REG_SWITCHERS(4),
|
|
|
|
MC13783_SW1A_MODE(MC13783_SWX_MODE_NO_PULSE_SKIP) |
|
|
|
|
MC13783_SW1A_MODE_STANDBY(MC13783_SWX_MODE_NO_PULSE_SKIP) |
|
|
|
|
MC13783_SW1A_SOFTSTART |
|
|
|
|
MC13783_SW1B_MODE(MC13783_SWX_MODE_NO_PULSE_SKIP) |
|
|
|
|
MC13783_SW1B_MODE_STANDBY(MC13783_SWX_MODE_NO_PULSE_SKIP) |
|
|
|
|
MC13783_SW1B_SOFTSTART |
|
|
|
|
MC13783_SW_PLL_FACTOR(32));
|
2007-10-07 22:13:19 +00:00
|
|
|
|
2014-06-05 17:24:47 +00:00
|
|
|
if (IS_ENABLED(CONFIG_MCI_IMX)) {
|
|
|
|
/* VMMC1 = 3.00 V */
|
|
|
|
mc13xxx_set_bits(mc13xxx, MC13783_REG_REG_SETTING(1),
|
|
|
|
7 << 6, 6 << 6);
|
|
|
|
/* Enable VMMC */
|
|
|
|
mc13xxx_set_bits(mc13xxx, MC13783_REG_REG_MODE(1),
|
|
|
|
1 << 18, 1 << 18);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Wait for required power level to run the CPU at 400 MHz */
|
|
|
|
mdelay(100);
|
|
|
|
|
|
|
|
console_flush();
|
|
|
|
writel(CSCR_VAL_FINAL, MX27_CCM_BASE_ADDR + MX27_CSCR);
|
|
|
|
writel(0x130410c3, MX27_CCM_BASE_ADDR + MX27_PCDR0);
|
|
|
|
writel(0x09030911, MX27_CCM_BASE_ADDR + MX27_PCDR1);
|
2013-08-15 07:02:17 +00:00
|
|
|
|
2014-06-05 17:24:47 +00:00
|
|
|
/* Clocks have changed. Notify clients */
|
|
|
|
clock_notifier_call_chain();
|
|
|
|
|
|
|
|
/* Clock gating enable */
|
|
|
|
writel(0x00050f08, MX27_SYSCTRL_BASE_ADDR + MX27_GPCR);
|
2009-05-18 07:06:58 +00:00
|
|
|
|
2014-06-12 06:25:19 +00:00
|
|
|
defaultenv_append_directory(defaultenv_pcm038);
|
|
|
|
|
2009-05-18 07:06:58 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2014-06-05 17:24:47 +00:00
|
|
|
device_initcall(pcm038_init);
|