2009-07-22 16:20:54 +00:00
|
|
|
/*
|
|
|
|
* KFR2R09 board support code
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Magnus Damm
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/interrupt.h>
|
2010-12-28 22:22:34 +00:00
|
|
|
#include <linux/mmc/host.h>
|
2011-03-09 10:29:48 +00:00
|
|
|
#include <linux/mmc/sh_mobile_sdhi.h>
|
2010-05-19 18:36:13 +00:00
|
|
|
#include <linux/mfd/tmio.h>
|
2009-07-22 16:22:28 +00:00
|
|
|
#include <linux/mtd/physmap.h>
|
2009-08-06 14:58:43 +00:00
|
|
|
#include <linux/mtd/onenand.h>
|
2009-07-22 16:20:54 +00:00
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/clk.h>
|
|
|
|
#include <linux/gpio.h>
|
2009-07-22 16:23:45 +00:00
|
|
|
#include <linux/input.h>
|
2009-11-27 07:32:24 +00:00
|
|
|
#include <linux/input/sh_keysc.h>
|
2009-08-19 14:39:15 +00:00
|
|
|
#include <linux/i2c.h>
|
2013-07-04 19:13:29 +00:00
|
|
|
#include <linux/platform_data/lv5207lp.h>
|
2012-06-26 22:50:05 +00:00
|
|
|
#include <linux/regulator/fixed.h>
|
|
|
|
#include <linux/regulator/machine.h>
|
2009-08-19 14:39:15 +00:00
|
|
|
#include <linux/usb/r8a66597.h>
|
2012-01-25 21:07:05 +00:00
|
|
|
#include <linux/videodev2.h>
|
2012-05-18 06:53:29 +00:00
|
|
|
#include <linux/sh_intc.h>
|
2009-12-11 14:53:45 +00:00
|
|
|
#include <media/rj54n1cb0c.h>
|
2009-10-03 11:21:30 +00:00
|
|
|
#include <media/soc_camera.h>
|
|
|
|
#include <media/sh_mobile_ceu.h>
|
2009-08-06 14:51:30 +00:00
|
|
|
#include <video/sh_mobile_lcdc.h>
|
2009-10-29 10:52:15 +00:00
|
|
|
#include <asm/suspend.h>
|
2009-07-22 16:20:54 +00:00
|
|
|
#include <asm/clock.h>
|
|
|
|
#include <asm/machvec.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <cpu/sh7724.h>
|
2009-08-06 14:51:30 +00:00
|
|
|
#include <mach/kfr2r09.h>
|
2009-07-22 16:20:54 +00:00
|
|
|
|
2009-07-22 16:22:28 +00:00
|
|
|
static struct mtd_partition kfr2r09_nor_flash_partitions[] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
.name = "boot",
|
|
|
|
.offset = 0,
|
|
|
|
.size = (4 * 1024 * 1024),
|
|
|
|
.mask_flags = MTD_WRITEABLE, /* Read-only */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "other",
|
|
|
|
.offset = MTDPART_OFS_APPEND,
|
|
|
|
.size = MTDPART_SIZ_FULL,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct physmap_flash_data kfr2r09_nor_flash_data = {
|
|
|
|
.width = 2,
|
|
|
|
.parts = kfr2r09_nor_flash_partitions,
|
|
|
|
.nr_parts = ARRAY_SIZE(kfr2r09_nor_flash_partitions),
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct resource kfr2r09_nor_flash_resources[] = {
|
|
|
|
[0] = {
|
|
|
|
.name = "NOR Flash",
|
|
|
|
.start = 0x00000000,
|
|
|
|
.end = 0x03ffffff,
|
|
|
|
.flags = IORESOURCE_MEM,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct platform_device kfr2r09_nor_flash_device = {
|
|
|
|
.name = "physmap-flash",
|
|
|
|
.resource = kfr2r09_nor_flash_resources,
|
|
|
|
.num_resources = ARRAY_SIZE(kfr2r09_nor_flash_resources),
|
|
|
|
.dev = {
|
|
|
|
.platform_data = &kfr2r09_nor_flash_data,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2009-08-06 14:58:43 +00:00
|
|
|
static struct resource kfr2r09_nand_flash_resources[] = {
|
|
|
|
[0] = {
|
|
|
|
.name = "NAND Flash",
|
|
|
|
.start = 0x10000000,
|
|
|
|
.end = 0x1001ffff,
|
|
|
|
.flags = IORESOURCE_MEM,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct platform_device kfr2r09_nand_flash_device = {
|
|
|
|
.name = "onenand-flash",
|
|
|
|
.resource = kfr2r09_nand_flash_resources,
|
|
|
|
.num_resources = ARRAY_SIZE(kfr2r09_nand_flash_resources),
|
|
|
|
};
|
|
|
|
|
2009-07-22 16:23:45 +00:00
|
|
|
static struct sh_keysc_info kfr2r09_sh_keysc_info = {
|
|
|
|
.mode = SH_KEYSC_MODE_1, /* KEYOUT0->4, KEYIN0->4 */
|
|
|
|
.scan_timing = 3,
|
|
|
|
.delay = 10,
|
|
|
|
.keycodes = {
|
|
|
|
KEY_PHONE, KEY_CLEAR, KEY_MAIL, KEY_WWW, KEY_ENTER,
|
|
|
|
KEY_1, KEY_2, KEY_3, 0, KEY_UP,
|
|
|
|
KEY_4, KEY_5, KEY_6, 0, KEY_LEFT,
|
|
|
|
KEY_7, KEY_8, KEY_9, KEY_PROG1, KEY_RIGHT,
|
|
|
|
KEY_S, KEY_0, KEY_P, KEY_PROG2, KEY_DOWN,
|
|
|
|
0, 0, 0, 0, 0
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct resource kfr2r09_sh_keysc_resources[] = {
|
|
|
|
[0] = {
|
|
|
|
.name = "KEYSC",
|
|
|
|
.start = 0x044b0000,
|
|
|
|
.end = 0x044b000f,
|
|
|
|
.flags = IORESOURCE_MEM,
|
|
|
|
},
|
|
|
|
[1] = {
|
2012-05-18 06:53:29 +00:00
|
|
|
.start = evt2irq(0xbe0),
|
2009-07-22 16:23:45 +00:00
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct platform_device kfr2r09_sh_keysc_device = {
|
|
|
|
.name = "sh_keysc",
|
|
|
|
.id = 0, /* "keysc0" clock */
|
|
|
|
.num_resources = ARRAY_SIZE(kfr2r09_sh_keysc_resources),
|
|
|
|
.resource = kfr2r09_sh_keysc_resources,
|
|
|
|
.dev = {
|
|
|
|
.platform_data = &kfr2r09_sh_keysc_info,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2011-07-09 21:16:22 +00:00
|
|
|
static const struct fb_videomode kfr2r09_lcdc_modes[] = {
|
2010-09-03 07:20:04 +00:00
|
|
|
{
|
|
|
|
.name = "TX07D34VM0AAA",
|
|
|
|
.xres = 240,
|
|
|
|
.yres = 400,
|
|
|
|
.left_margin = 0,
|
|
|
|
.right_margin = 16,
|
|
|
|
.hsync_len = 8,
|
|
|
|
.upper_margin = 0,
|
|
|
|
.lower_margin = 1,
|
|
|
|
.vsync_len = 1,
|
|
|
|
.sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2009-08-06 14:51:30 +00:00
|
|
|
static struct sh_mobile_lcdc_info kfr2r09_sh_lcdc_info = {
|
|
|
|
.clock_source = LCDC_CLK_BUS,
|
|
|
|
.ch[0] = {
|
|
|
|
.chan = LCDC_CHAN_MAINLCD,
|
2011-12-13 13:02:28 +00:00
|
|
|
.fourcc = V4L2_PIX_FMT_RGB565,
|
2009-08-06 14:51:30 +00:00
|
|
|
.interface_type = SYS18,
|
|
|
|
.clock_divider = 6,
|
|
|
|
.flags = LCDC_FLAGS_DWPOL,
|
2011-11-29 13:33:41 +00:00
|
|
|
.lcd_modes = kfr2r09_lcdc_modes,
|
|
|
|
.num_modes = ARRAY_SIZE(kfr2r09_lcdc_modes),
|
2011-09-11 20:59:04 +00:00
|
|
|
.panel_cfg = {
|
2009-08-06 14:51:30 +00:00
|
|
|
.width = 35,
|
|
|
|
.height = 58,
|
|
|
|
.setup_sys = kfr2r09_lcd_setup,
|
2009-12-07 14:26:05 +00:00
|
|
|
.start_transfer = kfr2r09_lcd_start,
|
2012-08-15 16:48:36 +00:00
|
|
|
},
|
2009-08-06 14:51:30 +00:00
|
|
|
.sys_bus_cfg = {
|
|
|
|
.ldmt2r = 0x07010904,
|
|
|
|
.ldmt3r = 0x14012914,
|
|
|
|
/* set 1s delay to encourage fsync() */
|
|
|
|
.deferred_io_msec = 1000,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct resource kfr2r09_sh_lcdc_resources[] = {
|
|
|
|
[0] = {
|
|
|
|
.name = "LCDC",
|
|
|
|
.start = 0xfe940000, /* P4-only space */
|
2009-09-15 12:00:30 +00:00
|
|
|
.end = 0xfe942fff,
|
2009-08-06 14:51:30 +00:00
|
|
|
.flags = IORESOURCE_MEM,
|
|
|
|
},
|
|
|
|
[1] = {
|
2012-05-18 06:53:29 +00:00
|
|
|
.start = evt2irq(0xf40),
|
2009-08-06 14:51:30 +00:00
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct platform_device kfr2r09_sh_lcdc_device = {
|
|
|
|
.name = "sh_mobile_lcdc_fb",
|
|
|
|
.num_resources = ARRAY_SIZE(kfr2r09_sh_lcdc_resources),
|
|
|
|
.resource = kfr2r09_sh_lcdc_resources,
|
|
|
|
.dev = {
|
|
|
|
.platform_data = &kfr2r09_sh_lcdc_info,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2013-07-04 19:13:29 +00:00
|
|
|
static struct lv5207lp_platform_data kfr2r09_backlight_data = {
|
|
|
|
.fbdev = &kfr2r09_sh_lcdc_device.dev,
|
|
|
|
.def_value = 13,
|
|
|
|
.max_value = 13,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct i2c_board_info kfr2r09_backlight_board_info = {
|
|
|
|
I2C_BOARD_INFO("lv5207lp", 0x75),
|
|
|
|
.platform_data = &kfr2r09_backlight_data,
|
|
|
|
};
|
|
|
|
|
2009-08-19 14:39:15 +00:00
|
|
|
static struct r8a66597_platdata kfr2r09_usb0_gadget_data = {
|
|
|
|
.on_chip = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct resource kfr2r09_usb0_gadget_resources[] = {
|
|
|
|
[0] = {
|
|
|
|
.start = 0x04d80000,
|
|
|
|
.end = 0x04d80123,
|
|
|
|
.flags = IORESOURCE_MEM,
|
|
|
|
},
|
|
|
|
[1] = {
|
2012-06-27 09:26:34 +00:00
|
|
|
.start = evt2irq(0xa20),
|
|
|
|
.end = evt2irq(0xa20),
|
2009-08-19 14:39:15 +00:00
|
|
|
.flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct platform_device kfr2r09_usb0_gadget_device = {
|
|
|
|
.name = "r8a66597_udc",
|
|
|
|
.id = 0,
|
|
|
|
.dev = {
|
|
|
|
.dma_mask = NULL, /* not use dma */
|
|
|
|
.coherent_dma_mask = 0xffffffff,
|
|
|
|
.platform_data = &kfr2r09_usb0_gadget_data,
|
|
|
|
},
|
|
|
|
.num_resources = ARRAY_SIZE(kfr2r09_usb0_gadget_resources),
|
|
|
|
.resource = kfr2r09_usb0_gadget_resources,
|
|
|
|
};
|
|
|
|
|
2009-10-03 11:21:30 +00:00
|
|
|
static struct sh_mobile_ceu_info sh_mobile_ceu_info = {
|
|
|
|
.flags = SH_CEU_FLAG_USE_8BIT_BUS,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct resource kfr2r09_ceu_resources[] = {
|
|
|
|
[0] = {
|
|
|
|
.name = "CEU",
|
|
|
|
.start = 0xfe910000,
|
|
|
|
.end = 0xfe91009f,
|
|
|
|
.flags = IORESOURCE_MEM,
|
|
|
|
},
|
|
|
|
[1] = {
|
2012-05-18 06:53:29 +00:00
|
|
|
.start = evt2irq(0x880),
|
|
|
|
.end = evt2irq(0x880),
|
2009-10-03 11:21:30 +00:00
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
[2] = {
|
|
|
|
/* place holder for contiguous memory */
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct platform_device kfr2r09_ceu_device = {
|
|
|
|
.name = "sh_mobile_ceu",
|
|
|
|
.id = 0, /* "ceu0" clock */
|
|
|
|
.num_resources = ARRAY_SIZE(kfr2r09_ceu_resources),
|
|
|
|
.resource = kfr2r09_ceu_resources,
|
|
|
|
.dev = {
|
|
|
|
.platform_data = &sh_mobile_ceu_info,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct i2c_board_info kfr2r09_i2c_camera = {
|
|
|
|
I2C_BOARD_INFO("rj54n1cb0c", 0x50),
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct clk *camera_clk;
|
|
|
|
|
2009-12-11 14:53:45 +00:00
|
|
|
/* set VIO_CKO clock to 25MHz */
|
|
|
|
#define CEU_MCLK_FREQ 25000000
|
|
|
|
|
2009-10-03 11:21:30 +00:00
|
|
|
#define DRVCRB 0xA405018C
|
|
|
|
static int camera_power(struct device *dev, int mode)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (mode) {
|
|
|
|
long rate;
|
|
|
|
|
|
|
|
camera_clk = clk_get(NULL, "video_clk");
|
|
|
|
if (IS_ERR(camera_clk))
|
|
|
|
return PTR_ERR(camera_clk);
|
|
|
|
|
2009-12-11 14:53:45 +00:00
|
|
|
rate = clk_round_rate(camera_clk, CEU_MCLK_FREQ);
|
2009-10-03 11:21:30 +00:00
|
|
|
ret = clk_set_rate(camera_clk, rate);
|
|
|
|
if (ret < 0)
|
|
|
|
goto eclkrate;
|
|
|
|
|
|
|
|
/* set DRVCRB
|
|
|
|
*
|
|
|
|
* use 1.8 V for VccQ_VIO
|
|
|
|
* use 2.85V for VccQ_SR
|
|
|
|
*/
|
2010-01-26 03:58:40 +00:00
|
|
|
__raw_writew((__raw_readw(DRVCRB) & ~0x0003) | 0x0001, DRVCRB);
|
2009-10-03 11:21:30 +00:00
|
|
|
|
|
|
|
/* reset clear */
|
|
|
|
ret = gpio_request(GPIO_PTB4, NULL);
|
|
|
|
if (ret < 0)
|
|
|
|
goto eptb4;
|
|
|
|
ret = gpio_request(GPIO_PTB7, NULL);
|
|
|
|
if (ret < 0)
|
|
|
|
goto eptb7;
|
|
|
|
|
|
|
|
ret = gpio_direction_output(GPIO_PTB4, 1);
|
|
|
|
if (!ret)
|
|
|
|
ret = gpio_direction_output(GPIO_PTB7, 1);
|
|
|
|
if (ret < 0)
|
|
|
|
goto egpioout;
|
|
|
|
msleep(1);
|
|
|
|
|
|
|
|
ret = clk_enable(camera_clk); /* start VIO_CKO */
|
|
|
|
if (ret < 0)
|
|
|
|
goto eclkon;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
clk_disable(camera_clk);
|
|
|
|
eclkon:
|
|
|
|
gpio_set_value(GPIO_PTB7, 0);
|
|
|
|
egpioout:
|
|
|
|
gpio_set_value(GPIO_PTB4, 0);
|
|
|
|
gpio_free(GPIO_PTB7);
|
|
|
|
eptb7:
|
|
|
|
gpio_free(GPIO_PTB4);
|
|
|
|
eptb4:
|
|
|
|
eclkrate:
|
|
|
|
clk_put(camera_clk);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-12-11 14:53:45 +00:00
|
|
|
static struct rj54n1_pdata rj54n1_priv = {
|
|
|
|
.mclk_freq = CEU_MCLK_FREQ,
|
|
|
|
.ioctl_high = false,
|
|
|
|
};
|
|
|
|
|
2009-10-03 11:21:30 +00:00
|
|
|
static struct soc_camera_link rj54n1_link = {
|
|
|
|
.power = camera_power,
|
|
|
|
.board_info = &kfr2r09_i2c_camera,
|
|
|
|
.i2c_adapter_id = 1,
|
2009-12-11 14:53:45 +00:00
|
|
|
.priv = &rj54n1_priv,
|
2009-10-03 11:21:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct platform_device kfr2r09_camera = {
|
|
|
|
.name = "soc-camera-pdrv",
|
|
|
|
.id = 0,
|
|
|
|
.dev = {
|
|
|
|
.platform_data = &rj54n1_link,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2012-06-26 22:50:05 +00:00
|
|
|
/* Fixed 3.3V regulator to be used by SDHI0 */
|
|
|
|
static struct regulator_consumer_supply fixed3v3_power_consumers[] =
|
|
|
|
{
|
|
|
|
REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
|
|
|
|
REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
|
|
|
|
};
|
|
|
|
|
2009-10-02 02:23:19 +00:00
|
|
|
static struct resource kfr2r09_sh_sdhi0_resources[] = {
|
|
|
|
[0] = {
|
|
|
|
.name = "SDHI0",
|
|
|
|
.start = 0x04ce0000,
|
2011-03-09 12:42:42 +00:00
|
|
|
.end = 0x04ce00ff,
|
2009-10-02 02:23:19 +00:00
|
|
|
.flags = IORESOURCE_MEM,
|
|
|
|
},
|
|
|
|
[1] = {
|
2012-05-18 06:53:29 +00:00
|
|
|
.start = evt2irq(0xe80),
|
2009-10-02 02:23:19 +00:00
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2010-05-19 18:34:36 +00:00
|
|
|
static struct sh_mobile_sdhi_info sh7724_sdhi0_data = {
|
2010-05-19 18:36:13 +00:00
|
|
|
.dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
|
|
|
|
.dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
|
|
|
|
.tmio_flags = TMIO_MMC_WRPROTECT_DISABLE,
|
2010-12-28 22:22:34 +00:00
|
|
|
.tmio_caps = MMC_CAP_SDIO_IRQ,
|
2010-05-19 18:34:36 +00:00
|
|
|
};
|
|
|
|
|
2009-10-02 02:23:19 +00:00
|
|
|
static struct platform_device kfr2r09_sh_sdhi0_device = {
|
|
|
|
.name = "sh_mobile_sdhi",
|
|
|
|
.num_resources = ARRAY_SIZE(kfr2r09_sh_sdhi0_resources),
|
|
|
|
.resource = kfr2r09_sh_sdhi0_resources,
|
2010-05-19 18:34:36 +00:00
|
|
|
.dev = {
|
|
|
|
.platform_data = &sh7724_sdhi0_data,
|
|
|
|
},
|
2009-10-02 02:23:19 +00:00
|
|
|
};
|
|
|
|
|
2009-07-22 16:22:28 +00:00
|
|
|
static struct platform_device *kfr2r09_devices[] __initdata = {
|
|
|
|
&kfr2r09_nor_flash_device,
|
2009-08-06 14:58:43 +00:00
|
|
|
&kfr2r09_nand_flash_device,
|
2009-07-22 16:23:45 +00:00
|
|
|
&kfr2r09_sh_keysc_device,
|
2009-08-06 14:51:30 +00:00
|
|
|
&kfr2r09_sh_lcdc_device,
|
2009-10-03 11:21:30 +00:00
|
|
|
&kfr2r09_ceu_device,
|
|
|
|
&kfr2r09_camera,
|
2009-10-02 02:23:19 +00:00
|
|
|
&kfr2r09_sh_sdhi0_device,
|
2009-07-22 16:22:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define BSC_CS0BCR 0xfec10004
|
|
|
|
#define BSC_CS0WCR 0xfec10024
|
2009-08-06 14:58:43 +00:00
|
|
|
#define BSC_CS4BCR 0xfec10010
|
|
|
|
#define BSC_CS4WCR 0xfec10030
|
2009-08-19 14:39:15 +00:00
|
|
|
#define PORT_MSELCRB 0xa4050182
|
|
|
|
|
2009-08-20 13:57:36 +00:00
|
|
|
#ifdef CONFIG_I2C
|
2009-08-19 14:39:15 +00:00
|
|
|
static int kfr2r09_usb0_gadget_i2c_setup(void)
|
|
|
|
{
|
|
|
|
struct i2c_adapter *a;
|
|
|
|
struct i2c_msg msg;
|
|
|
|
unsigned char buf[2];
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
a = i2c_get_adapter(0);
|
|
|
|
if (!a)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
/* set bit 1 (the second bit) of chip at 0x09, register 0x13 */
|
|
|
|
buf[0] = 0x13;
|
|
|
|
msg.addr = 0x09;
|
|
|
|
msg.buf = buf;
|
|
|
|
msg.len = 1;
|
|
|
|
msg.flags = 0;
|
|
|
|
ret = i2c_transfer(a, &msg, 1);
|
|
|
|
if (ret != 1)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
buf[0] = 0;
|
|
|
|
msg.addr = 0x09;
|
|
|
|
msg.buf = buf;
|
|
|
|
msg.len = 1;
|
|
|
|
msg.flags = I2C_M_RD;
|
|
|
|
ret = i2c_transfer(a, &msg, 1);
|
|
|
|
if (ret != 1)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
buf[1] = buf[0] | (1 << 1);
|
|
|
|
buf[0] = 0x13;
|
|
|
|
msg.addr = 0x09;
|
|
|
|
msg.buf = buf;
|
|
|
|
msg.len = 2;
|
|
|
|
msg.flags = 0;
|
|
|
|
ret = i2c_transfer(a, &msg, 1);
|
|
|
|
if (ret != 1)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2009-11-27 09:28:03 +00:00
|
|
|
|
|
|
|
static int kfr2r09_serial_i2c_setup(void)
|
|
|
|
{
|
|
|
|
struct i2c_adapter *a;
|
|
|
|
struct i2c_msg msg;
|
|
|
|
unsigned char buf[2];
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
a = i2c_get_adapter(0);
|
|
|
|
if (!a)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
/* set bit 6 (the 7th bit) of chip at 0x09, register 0x13 */
|
|
|
|
buf[0] = 0x13;
|
|
|
|
msg.addr = 0x09;
|
|
|
|
msg.buf = buf;
|
|
|
|
msg.len = 1;
|
|
|
|
msg.flags = 0;
|
|
|
|
ret = i2c_transfer(a, &msg, 1);
|
|
|
|
if (ret != 1)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
buf[0] = 0;
|
|
|
|
msg.addr = 0x09;
|
|
|
|
msg.buf = buf;
|
|
|
|
msg.len = 1;
|
|
|
|
msg.flags = I2C_M_RD;
|
|
|
|
ret = i2c_transfer(a, &msg, 1);
|
|
|
|
if (ret != 1)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
buf[1] = buf[0] | (1 << 6);
|
|
|
|
buf[0] = 0x13;
|
|
|
|
msg.addr = 0x09;
|
|
|
|
msg.buf = buf;
|
|
|
|
msg.len = 2;
|
|
|
|
msg.flags = 0;
|
|
|
|
ret = i2c_transfer(a, &msg, 1);
|
|
|
|
if (ret != 1)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2009-08-20 13:57:36 +00:00
|
|
|
#else
|
|
|
|
static int kfr2r09_usb0_gadget_i2c_setup(void)
|
|
|
|
{
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
2009-11-27 09:28:03 +00:00
|
|
|
|
|
|
|
static int kfr2r09_serial_i2c_setup(void)
|
|
|
|
{
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
2009-08-20 13:57:36 +00:00
|
|
|
#endif
|
2009-08-19 14:39:15 +00:00
|
|
|
|
|
|
|
static int kfr2r09_usb0_gadget_setup(void)
|
|
|
|
{
|
|
|
|
int plugged_in;
|
|
|
|
|
|
|
|
gpio_request(GPIO_PTN4, NULL); /* USB_DET */
|
|
|
|
gpio_direction_input(GPIO_PTN4);
|
|
|
|
plugged_in = gpio_get_value(GPIO_PTN4);
|
|
|
|
if (!plugged_in)
|
|
|
|
return -ENODEV; /* no cable plugged in */
|
|
|
|
|
|
|
|
if (kfr2r09_usb0_gadget_i2c_setup() != 0)
|
|
|
|
return -ENODEV; /* unable to configure using i2c */
|
|
|
|
|
2010-01-26 03:58:40 +00:00
|
|
|
__raw_writew((__raw_readw(PORT_MSELCRB) & ~0xc000) | 0x8000, PORT_MSELCRB);
|
2009-08-19 14:39:15 +00:00
|
|
|
gpio_request(GPIO_FN_PDSTATUS, NULL); /* R-standby disables USB clock */
|
|
|
|
gpio_request(GPIO_PTV6, NULL); /* USBCLK_ON */
|
|
|
|
gpio_direction_output(GPIO_PTV6, 1); /* USBCLK_ON = H */
|
|
|
|
msleep(20); /* wait 20ms to let the clock settle */
|
|
|
|
clk_enable(clk_get(NULL, "usb0"));
|
2010-01-26 03:58:40 +00:00
|
|
|
__raw_writew(0x0600, 0xa40501d4);
|
2009-08-19 14:39:15 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2009-07-22 16:22:28 +00:00
|
|
|
|
2009-10-29 10:52:15 +00:00
|
|
|
extern char kfr2r09_sdram_enter_start;
|
|
|
|
extern char kfr2r09_sdram_enter_end;
|
|
|
|
extern char kfr2r09_sdram_leave_start;
|
|
|
|
extern char kfr2r09_sdram_leave_end;
|
|
|
|
|
2009-07-22 16:20:54 +00:00
|
|
|
static int __init kfr2r09_devices_setup(void)
|
|
|
|
{
|
2009-10-29 10:52:15 +00:00
|
|
|
/* register board specific self-refresh code */
|
2009-10-30 04:24:48 +00:00
|
|
|
sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF |
|
|
|
|
SUSP_SH_RSTANDBY,
|
2009-10-29 10:52:15 +00:00
|
|
|
&kfr2r09_sdram_enter_start,
|
|
|
|
&kfr2r09_sdram_enter_end,
|
|
|
|
&kfr2r09_sdram_leave_start,
|
|
|
|
&kfr2r09_sdram_leave_end);
|
|
|
|
|
2012-06-26 22:50:05 +00:00
|
|
|
regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
|
|
|
|
ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
|
|
|
|
|
2009-07-22 16:20:54 +00:00
|
|
|
/* enable SCIF1 serial port for YC401 console support */
|
|
|
|
gpio_request(GPIO_FN_SCIF1_RXD, NULL);
|
|
|
|
gpio_request(GPIO_FN_SCIF1_TXD, NULL);
|
2009-11-27 09:28:03 +00:00
|
|
|
kfr2r09_serial_i2c_setup(); /* ECONTMSK(bit6=L10ONEN) set 1 */
|
|
|
|
gpio_request(GPIO_PTG3, NULL); /* HPON_ON */
|
|
|
|
gpio_direction_output(GPIO_PTG3, 1); /* HPON_ON = H */
|
2009-07-22 16:20:54 +00:00
|
|
|
|
2009-07-22 16:22:28 +00:00
|
|
|
/* setup NOR flash at CS0 */
|
2010-01-26 03:58:40 +00:00
|
|
|
__raw_writel(0x36db0400, BSC_CS0BCR);
|
|
|
|
__raw_writel(0x00000500, BSC_CS0WCR);
|
2009-07-22 16:22:28 +00:00
|
|
|
|
2009-08-06 14:58:43 +00:00
|
|
|
/* setup NAND flash at CS4 */
|
2010-01-26 03:58:40 +00:00
|
|
|
__raw_writel(0x36db0400, BSC_CS4BCR);
|
|
|
|
__raw_writel(0x00000500, BSC_CS4WCR);
|
2009-08-06 14:58:43 +00:00
|
|
|
|
2009-07-22 16:23:45 +00:00
|
|
|
/* setup KEYSC pins */
|
|
|
|
gpio_request(GPIO_FN_KEYOUT0, NULL);
|
|
|
|
gpio_request(GPIO_FN_KEYOUT1, NULL);
|
|
|
|
gpio_request(GPIO_FN_KEYOUT2, NULL);
|
|
|
|
gpio_request(GPIO_FN_KEYOUT3, NULL);
|
|
|
|
gpio_request(GPIO_FN_KEYOUT4_IN6, NULL);
|
|
|
|
gpio_request(GPIO_FN_KEYIN0, NULL);
|
|
|
|
gpio_request(GPIO_FN_KEYIN1, NULL);
|
|
|
|
gpio_request(GPIO_FN_KEYIN2, NULL);
|
|
|
|
gpio_request(GPIO_FN_KEYIN3, NULL);
|
|
|
|
gpio_request(GPIO_FN_KEYIN4, NULL);
|
|
|
|
gpio_request(GPIO_FN_KEYOUT5_IN5, NULL);
|
|
|
|
|
2009-08-06 14:51:30 +00:00
|
|
|
/* setup LCDC pins for SYS panel */
|
|
|
|
gpio_request(GPIO_FN_LCDD17, NULL);
|
|
|
|
gpio_request(GPIO_FN_LCDD16, NULL);
|
|
|
|
gpio_request(GPIO_FN_LCDD15, NULL);
|
|
|
|
gpio_request(GPIO_FN_LCDD14, NULL);
|
|
|
|
gpio_request(GPIO_FN_LCDD13, NULL);
|
|
|
|
gpio_request(GPIO_FN_LCDD12, NULL);
|
|
|
|
gpio_request(GPIO_FN_LCDD11, NULL);
|
|
|
|
gpio_request(GPIO_FN_LCDD10, NULL);
|
|
|
|
gpio_request(GPIO_FN_LCDD9, NULL);
|
|
|
|
gpio_request(GPIO_FN_LCDD8, NULL);
|
|
|
|
gpio_request(GPIO_FN_LCDD7, NULL);
|
|
|
|
gpio_request(GPIO_FN_LCDD6, NULL);
|
|
|
|
gpio_request(GPIO_FN_LCDD5, NULL);
|
|
|
|
gpio_request(GPIO_FN_LCDD4, NULL);
|
|
|
|
gpio_request(GPIO_FN_LCDD3, NULL);
|
|
|
|
gpio_request(GPIO_FN_LCDD2, NULL);
|
|
|
|
gpio_request(GPIO_FN_LCDD1, NULL);
|
|
|
|
gpio_request(GPIO_FN_LCDD0, NULL);
|
|
|
|
gpio_request(GPIO_FN_LCDRS, NULL); /* LCD_RS */
|
|
|
|
gpio_request(GPIO_FN_LCDCS, NULL); /* LCD_CS/ */
|
|
|
|
gpio_request(GPIO_FN_LCDRD, NULL); /* LCD_RD/ */
|
|
|
|
gpio_request(GPIO_FN_LCDWR, NULL); /* LCD_WR/ */
|
|
|
|
gpio_request(GPIO_FN_LCDVSYN, NULL); /* LCD_VSYNC */
|
|
|
|
gpio_request(GPIO_PTE4, NULL); /* LCD_RST/ */
|
|
|
|
gpio_direction_output(GPIO_PTE4, 1);
|
|
|
|
gpio_request(GPIO_PTF4, NULL); /* PROTECT/ */
|
|
|
|
gpio_direction_output(GPIO_PTF4, 1);
|
|
|
|
gpio_request(GPIO_PTU0, NULL); /* LEDSTDBY/ */
|
|
|
|
gpio_direction_output(GPIO_PTU0, 1);
|
|
|
|
|
2009-08-19 14:39:15 +00:00
|
|
|
/* setup USB function */
|
|
|
|
if (kfr2r09_usb0_gadget_setup() == 0)
|
|
|
|
platform_device_register(&kfr2r09_usb0_gadget_device);
|
|
|
|
|
2009-10-03 11:21:30 +00:00
|
|
|
/* CEU */
|
|
|
|
gpio_request(GPIO_FN_VIO_CKO, NULL);
|
|
|
|
gpio_request(GPIO_FN_VIO0_CLK, NULL);
|
|
|
|
gpio_request(GPIO_FN_VIO0_VD, NULL);
|
|
|
|
gpio_request(GPIO_FN_VIO0_HD, NULL);
|
|
|
|
gpio_request(GPIO_FN_VIO0_FLD, NULL);
|
|
|
|
gpio_request(GPIO_FN_VIO0_D7, NULL);
|
|
|
|
gpio_request(GPIO_FN_VIO0_D6, NULL);
|
|
|
|
gpio_request(GPIO_FN_VIO0_D5, NULL);
|
|
|
|
gpio_request(GPIO_FN_VIO0_D4, NULL);
|
|
|
|
gpio_request(GPIO_FN_VIO0_D3, NULL);
|
|
|
|
gpio_request(GPIO_FN_VIO0_D2, NULL);
|
|
|
|
gpio_request(GPIO_FN_VIO0_D1, NULL);
|
|
|
|
gpio_request(GPIO_FN_VIO0_D0, NULL);
|
|
|
|
|
|
|
|
platform_resource_setup_memory(&kfr2r09_ceu_device, "ceu", 4 << 20);
|
|
|
|
|
2009-10-02 02:23:19 +00:00
|
|
|
/* SDHI0 connected to yc304 */
|
|
|
|
gpio_request(GPIO_FN_SDHI0CD, NULL);
|
|
|
|
gpio_request(GPIO_FN_SDHI0D3, NULL);
|
|
|
|
gpio_request(GPIO_FN_SDHI0D2, NULL);
|
|
|
|
gpio_request(GPIO_FN_SDHI0D1, NULL);
|
|
|
|
gpio_request(GPIO_FN_SDHI0D0, NULL);
|
|
|
|
gpio_request(GPIO_FN_SDHI0CMD, NULL);
|
|
|
|
gpio_request(GPIO_FN_SDHI0CLK, NULL);
|
|
|
|
|
2013-07-04 19:13:29 +00:00
|
|
|
i2c_register_board_info(0, &kfr2r09_backlight_board_info, 1);
|
|
|
|
|
2009-07-22 16:22:28 +00:00
|
|
|
return platform_add_devices(kfr2r09_devices,
|
|
|
|
ARRAY_SIZE(kfr2r09_devices));
|
2009-07-22 16:20:54 +00:00
|
|
|
}
|
|
|
|
device_initcall(kfr2r09_devices_setup);
|
|
|
|
|
|
|
|
/* Return the board specific boot mode pin configuration */
|
|
|
|
static int kfr2r09_mode_pins(void)
|
|
|
|
{
|
|
|
|
/* MD0=1, MD1=1, MD2=0: Clock Mode 3
|
|
|
|
* MD3=0: 16-bit Area0 Bus Width
|
|
|
|
* MD5=1: Little Endian
|
|
|
|
* MD8=1: Test Mode Disabled
|
|
|
|
*/
|
|
|
|
return MODE_PIN0 | MODE_PIN1 | MODE_PIN5 | MODE_PIN8;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The Machine Vector
|
|
|
|
*/
|
|
|
|
static struct sh_machine_vector mv_kfr2r09 __initmv = {
|
|
|
|
.mv_name = "kfr2r09",
|
|
|
|
.mv_mode_pins = kfr2r09_mode_pins,
|
|
|
|
};
|