Skip to contentSkip to conversation

ARM: mach-shmobile: ap4evb: Add SCIFA0 support

PATCH Applied Kuninori Morimoto 3 participants 23 messages Feb 18, 2010 – Nov 16, 2010

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: mach-shmobile: ap4evb: Add SCIFA0 support

---
 arch/arm/mach-shmobile/board-ap4evb.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
arch/arm/mach-shmobile/board-ap4evb.c +4 -0
index bcd4456..41bc248 100644
@@ -189,6 +189,10 @@ static void __init ap4evb_init(void)
 {
 	sh7372_pinmux_init();
 
+	/* enable SCIFA0 */
+	gpio_request(GPIO_FN_SCIFA0_TXD, NULL);
+	gpio_request(GPIO_FN_SCIFA0_RXD, NULL);
+
 	/* enable SMSC911X */
 	gpio_request(GPIO_FN_CS5A,	NULL);
 	gpio_request(GPIO_FN_IRQ6_39,	NULL);
Signature · 1 line
1.6.3.3
#1 lore raw

PATCH 1/1 ARM: mach-shmobile: ap4evb: Add tiny document

---
 arch/arm/mach-shmobile/board-ap4evb.c |   42 +++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)
arch/arm/mach-shmobile/board-ap4evb.c +42 -0
index 70277e0..bcd4456 100644
@@ -35,6 +35,48 @@
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
 
+/*
+ * Address	Interface		BusWidth	note
+ * ------------------------------------------------------------------
+ * 0x0000_0000	NOR Flash ROM (MCP)	16bit		SW7 : bit1 = ON
+ * 0x0800_0000	user area		-
+ * 0x1000_0000	NOR Flash ROM (MCP)	16bit		SW7 : bit1 = OFF
+ * 0x1400_0000	Ether (LAN9220)		16bit
+ * 0x1600_0000	user area		-		cannot use with NAND
+ * 0x1800_0000	user area		-
+ * 0x1A00_0000	-
+ * 0x4000_0000	LPDDR2-SDRAM (POP)	32bit
+ */
+
+/*
+ * NOR Flash ROM
+ *
+ *  SW1  |     SW2    | SW7  | NOR Flash ROM
+ *  bit1 | bit1  bit2 | bit1 | Memory allocation
+ * ------+------------+------+------------------
+ *  OFF  | ON     OFF | ON   |    Area 0
+ *  OFF  | ON     OFF | OFF  |    Area 4
+ */
+
+/*
+ * NAND Flash ROM
+ *
+ *  SW1  |     SW2    | SW7  | NAND Flash ROM
+ *  bit1 | bit1  bit2 | bit2 | Memory allocation
+ * ------+------------+------+------------------
+ *  OFF  | ON     OFF | ON   |    FCE 0
+ *  OFF  | ON     OFF | OFF  |    FCE 1
+ */
+
+/*
+ * SMSC 9220
+ *
+ *  SW1		SMSC 9220
+ * -----------------------
+ *  ON		access disable
+ *  OFF		access enable
+ */
+
 /* MTD */
 static struct mtd_partition nor_flash_partitions[] = {
 	{
Signature · 1 line
1.6.3.3
#3 lore raw

PATCH 1/1 ARM: mach-shmobile: ap4evb: Add KEYSC support

In reply to Kuninori Morimoto

Because AP4 board has capacitor for KEYSC,
we need much time for waiting.

---
 arch/arm/mach-shmobile/board-ap4evb.c |   61 +++++++++++++++++++++++++++++++++
 1 files changed, 61 insertions(+), 0 deletions(-)
arch/arm/mach-shmobile/board-ap4evb.c +61 -0
index 41bc248..39cfd59 100644
@@ -29,6 +29,8 @@
 #include <linux/io.h>
 #include <linux/smsc911x.h>
 #include <linux/gpio.h>
+#include <linux/input.h>
+#include <linux/input/sh_keysc.h>
 #include <mach/common.h>
 #include <mach/sh7372.h>
 #include <asm/mach-types.h>
@@ -77,6 +79,15 @@
  *  OFF		access enable
  */
 
+/*
+ * KEYSC
+ *
+ * SW43		KEYSC
+ * -------------------------
+ * ON		enable
+ * OFF		disable
+ */
+
 /* MTD */
 static struct mtd_partition nor_flash_partitions[] = {
 	{
@@ -158,9 +169,47 @@ static struct platform_device smc911x_device = {
 	},
 };
 
+/* KEYSC (Needs SW43 set to ON) */
+static struct sh_keysc_info keysc_info = {
+	.mode		= SH_KEYSC_MODE_1,
+	.scan_timing	= 3,
+	.delay		= 2500,
+	.keycodes = {
+		KEY_0, KEY_1, KEY_2, KEY_3, KEY_4,
+		KEY_5, KEY_6, KEY_7, KEY_8, KEY_9,
+		KEY_A, KEY_B, KEY_C, KEY_D, KEY_E,
+		KEY_F, KEY_G, KEY_H, KEY_I, KEY_J,
+		KEY_K, KEY_L, KEY_M, KEY_N, KEY_O,
+	},
+};
+
+static struct resource keysc_resources[] = {
+	[0] = {
+		.name	= "KEYSC",
+		.start  = 0xe61b0000,
+		.end    = 0xe61b0063,
+		.flags  = IORESOURCE_MEM,
+	},
+	[1] = {
+		.start  = 79,
+		.flags  = IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device keysc_device = {
+	.name           = "sh_keysc",
+	.id             = 0, /* "keysc0" clock */
+	.num_resources  = ARRAY_SIZE(keysc_resources),
+	.resource       = keysc_resources,
+	.dev	= {
+		.platform_data	= &keysc_info,
+	},
+};
+
 static struct platform_device *ap4evb_devices[] __initdata = {
 	&nor_flash_device,
 	&smc911x_device,
+	&keysc_device,
 };
 
 static struct map_desc ap4evb_io_desc[] __initdata = {
@@ -197,6 +246,18 @@ static void __init ap4evb_init(void)
 	gpio_request(GPIO_FN_CS5A,	NULL);
 	gpio_request(GPIO_FN_IRQ6_39,	NULL);
 
+	/* enable KEYSC */
+	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, NULL);
+	gpio_request(GPIO_FN_KEYIN0_136, NULL);
+	gpio_request(GPIO_FN_KEYIN1_135, NULL);
+	gpio_request(GPIO_FN_KEYIN2_134, NULL);
+	gpio_request(GPIO_FN_KEYIN3_133, NULL);
+	gpio_request(GPIO_FN_KEYIN4,     NULL);
+
 	sh7372_add_standard_devices();
 
 	platform_add_devices(ap4evb_devices, ARRAY_SIZE(ap4evb_devices));
Signature · 1 line
1.6.3.3
Applied
#5 lore raw

Re: [PATCH] ARM: mach-shmobile: ap4evb: Add KEYSC support

In reply to Kuninori Morimoto
Quoted 2 lines · Kuninori Morimoto

Because AP4 board has capacitor for KEYSC,
we need much time for waiting.

Applied, thanks.

#6 lore raw

PATCH 1/1 ARM: mach-shmobile: ap4evb: Add SW43, SW3 tiny document

In reply to Kuninori Morimoto

---
depend on
[PATCH 2/3] ARM: mach-shmobile: ap4evb: Add TouchScreen support

 arch/arm/mach-shmobile/board-ap4evb.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)
arch/arm/mach-shmobile/board-ap4evb.c +10 -6
index b134902..28a9cde 100644
@@ -82,12 +82,16 @@
  */
 
 /*
- * KEYSC
+ * LCD / IRQ / KEYSC / IrDA
  *
- * SW43		KEYSC
- * -------------------------
- * ON		enable
- * OFF		disable
+ * IRQ = IRQ26 (TS), IRQ27 (VIO), IRQ28 (TouchScreen)
+ * LCD = 2nd LCDC
+ *
+ * 		|		SW43			|
+ * SW3		|	ON		|	OFF	|
+ * -------------+-----------------------+---------------+
+ * ON		| KEY / IrDA		| LCD		|
+ * OFF		| KEY / IrDA / IRQ	| IRQ		|
  */
 
 /* MTD */
@@ -236,7 +240,7 @@ static struct platform_device *ap4evb_devices[] __initdata = {
 	&sdhi0_device,
 };
 
-/* TouchScreen */
+/* TouchScreen (Needs SW3 set to OFF) */
 #define IRQ28	396
 struct tsc2007_platform_data tsc2007_info = {
 	.model			= 2007,
Signature · 1 line
1.6.3.3
#7 lore raw

PATCH 1/1 ARM: mach-shmobile: ap4evb: Add FSI2 support

In reply to Kuninori Morimoto

---
This patch needs Magnus's clock patch series

 arch/arm/mach-shmobile/board-ap4evb.c |  129 ++++++++++++++++++++++++++++++++-
 1 files changed, 126 insertions(+), 3 deletions(-)
arch/arm/mach-shmobile/board-ap4evb.c +126 -3
index d3b8ca5..a553c16 100644
@@ -30,15 +30,18 @@
 #include <linux/i2c/tsc2007.h>
 #include <linux/io.h>
 #include <linux/smsc911x.h>
+#include <linux/sh_intc.h>
 #include <linux/gpio.h>
 #include <linux/input.h>
 #include <linux/input/sh_keysc.h>
 #include <linux/usb/r8a66597.h>
+#include <sound/sh_fsi.h>
 #include <mach/common.h>
 #include <mach/sh7372.h>
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
+#include <asm/clock.h>
 
 /*
  * Address	Interface		BusWidth	note
@@ -284,12 +287,69 @@ static struct platform_device usb1_host_device = {
 	.resource	= usb1_host_resources,
 };
 
+/* FSI */
+#define IRQ_FSI		178
+#define FSIACKCR	0xE6150018
+static void fsiackcr_init(struct clk *clk)
+{
+	u32 status = __raw_readl(clk->enable_reg);
+
+	/* use external clock */
+	status &= ~0x000000ff;
+	status |= 0x00000080;
+	__raw_writel(status, clk->enable_reg);
+}
+
+static struct clk_ops fsiackcr_clk_ops = {
+	.init = fsiackcr_init,
+};
+
+static struct clk fsiackcr_clk = {
+	.name		= "fsiackcr_clk",
+	.id		= -1,
+	.ops		= &fsiackcr_clk_ops,
+	.enable_reg	= (void __iomem *)FSIACKCR,
+	.rate		= 0, /* unknown */
+};
+
+struct sh_fsi_platform_info fsi_info = {
+	.porta_flags = SH_FSI_BRS_INV |
+		       SH_FSI_OUT_SLAVE_MODE |
+		       SH_FSI_IN_SLAVE_MODE |
+		       SH_FSI_OFMT(PCM) |
+		       SH_FSI_IFMT(PCM),
+};
+
+static struct resource fsi_resources[] = {
+	[0] = {
+		.name	= "FSI",
+		.start	= 0xFE3C0000,
+		.end	= 0xFE3C0400 - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {
+		.start  = IRQ_FSI,
+		.flags  = IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device fsi_device = {
+	.name		= "sh_fsi2",
+	.id		= 0,
+	.num_resources	= ARRAY_SIZE(fsi_resources),
+	.resource	= fsi_resources,
+	.dev	= {
+		.platform_data	= &fsi_info,
+	},
+};
+
 static struct platform_device *ap4evb_devices[] __initdata = {
 	&nor_flash_device,
 	&smc911x_device,
 	&keysc_device,
 	&sdhi0_device,
 	&usb1_host_device,
+	&fsi_device,
 };
 
 /* TouchScreen (Needs SW3 set to OFF) */
@@ -300,6 +360,12 @@ struct tsc2007_platform_data tsc2007_info = {
 };
 
 /* I2C */
+static struct i2c_board_info i2c0_devices[] = {
+	{
+		I2C_BOARD_INFO("ak4643", 0x13),
+	},
+};
+
 static struct i2c_board_info i2c1_devices[] = {
 	{
 		I2C_BOARD_INFO("r2025sd", 0x32),
@@ -334,8 +400,27 @@ static void __init ap4evb_map_io(void)
 	shmobile_setup_console();
 }
 
+/*
+ * FIXME !!
+ *
+ * gpio_no_direction is quick_hack.
+ *
+ * current gpio frame work doesn't have
+ * the method to control only pull up/down/free.
+ * this function should be replaced by correct gpio function
+ */
+static void __init gpio_no_direction(u32 addr)
+{
+	__raw_writeb(0x00, addr);
+}
+
+#define GPIO_PORT9CR	0xE6051009
+#define GPIO_PORT10CR	0xE605100A
+
 static void __init ap4evb_init(void)
 {
+	struct clk *clk;
+
 	sh7372_pinmux_init();
 
 	/* enable SCIFA0 */
@@ -400,9 +485,6 @@ static void __init ap4evb_init(void)
 	gpio_request(GPIO_FN_IRQ28_123, NULL);
 	set_irq_type(IRQ28, IRQ_TYPE_LEVEL_LOW);
 
-	i2c_register_board_info(1, i2c1_devices,
-				ARRAY_SIZE(i2c1_devices));
-
 	/* USB enable */
 	gpio_request(GPIO_FN_VBUS0_1,    NULL);
 	gpio_request(GPIO_FN_IDIN_1_18,  NULL);
@@ -414,6 +496,47 @@ static void __init ap4evb_init(void)
 	/* setup USB phy */
 	__raw_writew(0x8a0a, 0xE6058130);	/* USBCR2 */
 
+	/* enable FSI2 */
+	gpio_request(GPIO_FN_FSIAIBT,	NULL);
+	gpio_request(GPIO_FN_FSIAILR,	NULL);
+	gpio_request(GPIO_FN_FSIAISLD,	NULL);
+	gpio_request(GPIO_FN_FSIAOSLD,	NULL);
+	gpio_request(GPIO_PORT161,	NULL);
+	gpio_direction_output(GPIO_PORT161, 0); /* slave */
+
+	gpio_request(GPIO_PORT9, NULL);
+	gpio_request(GPIO_PORT10, NULL);
+	gpio_no_direction(GPIO_PORT9CR);  /* FSIAOBT needs no direction */
+	gpio_no_direction(GPIO_PORT10CR); /* FSIAOLR needs no direction */
+
+	/* set SPU2 clock to 119.6 MHz */
+	clk = clk_get(NULL, "spu_clk");
+	if (clk) {
+		clk_set_rate(clk, clk_round_rate(clk, 119600000));
+		clk_put(clk);
+	}
+
+	/* change parent of FSI A */
+	clk = clk_get(NULL, "fsia_clk");
+	if (clk) {
+		clk_register(&fsiackcr_clk);
+		clk_set_parent(clk, &fsiackcr_clk);
+		clk_put(clk);
+	}
+
+	/*
+	 * set irq priority, to avoid sound chopping
+	 * when NFS rootfs is used
+	 *  FSI(3) > SMSC911X(2)
+	 */
+	intc_set_priority(IRQ_FSI, 3);
+
+	i2c_register_board_info(0, i2c0_devices,
+				ARRAY_SIZE(i2c0_devices));
+
+	i2c_register_board_info(1, i2c1_devices,
+				ARRAY_SIZE(i2c1_devices));
+
 	sh7372_add_standard_devices();
 
 	platform_add_devices(ap4evb_devices, ARRAY_SIZE(ap4evb_devices));
Signature · 1 line
1.7.0.4
#8 lore raw

PATCH 1/1 ARM: mach-shmobile: ap4evb: Add MMC support

In reply to Kuninori Morimoto

---
This patch is depend on Goda-san's
"Add support MMCIF for SuperH" patch

 arch/arm/mach-shmobile/board-ap4evb.c |   67 +++++++++++++++++++++++++++++++++
 1 files changed, 67 insertions(+), 0 deletions(-)
arch/arm/mach-shmobile/board-ap4evb.c +67 -0
index a553c16..0e74161 100644
@@ -26,6 +26,8 @@
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
 #include <linux/mtd/physmap.h>
+#include <linux/mmc/host.h>
+#include <linux/mmc/sh_mmcif.h>
 #include <linux/i2c.h>
 #include <linux/i2c/tsc2007.h>
 #include <linux/io.h>
@@ -107,6 +109,18 @@
  * S39: bit2: off
  */
 
+/*
+ * MMC (CN7)
+ *
+ * J22 : 1-2: 1.8v for MMC
+ *       2-3: 3.3v for MMC
+ * SW1 : OFF
+ * SW33: bit1: OFF
+ *       bit2: ON
+ *       bit3: ON
+ *       bit4: X
+ */
+
 /* MTD */
 static struct mtd_partition nor_flash_partitions[] = {
 	{
@@ -225,6 +239,46 @@ static struct platform_device keysc_device = {
 	},
 };
 
+/* SH_MMCIF */
+static struct resource sh_mmcif_resources[] = {
+	[0] = {
+		.name	= "SH_MMCIF",
+		.start	= 0xE6BD0000,
+		.end	= 0xE6BD00FF,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {
+		/* MMC ERR */
+		.start	= 198,
+		.flags	= IORESOURCE_IRQ,
+	},
+	[2] = {
+		/* MMC NOR */
+		.start	= 199,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+struct sh_mmcif_plat_data sh_mmcif_plat = {
+	.sup_pclk	= 0,
+	.ocr		= MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
+	.caps		= MMC_CAP_4_BIT_DATA |
+			  MMC_CAP_8_BIT_DATA |
+			  MMC_CAP_NEEDS_POLL,
+};
+
+static struct platform_device sh_mmcif_device = {
+	.name		= "sh_mmcif",
+	.id		= 0,
+	.dev		= {
+		.dma_mask		= NULL,
+		.coherent_dma_mask	= 0xffffffff,
+		.platform_data		= &sh_mmcif_plat,
+	},
+	.num_resources	= ARRAY_SIZE(sh_mmcif_resources),
+	.resource	= sh_mmcif_resources,
+};
+
 /* SDHI0 */
 static struct resource sdhi0_resources[] = {
 	[0] = {
@@ -350,6 +404,7 @@ static struct platform_device *ap4evb_devices[] __initdata = {
 	&sdhi0_device,
 	&usb1_host_device,
 	&fsi_device,
+	&sh_mmcif_device
 };
 
 /* TouchScreen (Needs SW3 set to OFF) */
@@ -485,6 +540,18 @@ static void __init ap4evb_init(void)
 	gpio_request(GPIO_FN_IRQ28_123, NULL);
 	set_irq_type(IRQ28, IRQ_TYPE_LEVEL_LOW);
 
+	/* MMCIF */
+	gpio_request(GPIO_FN_MMCD0_0, NULL);
+	gpio_request(GPIO_FN_MMCD0_1, NULL);
+	gpio_request(GPIO_FN_MMCD0_2, NULL);
+	gpio_request(GPIO_FN_MMCD0_3, NULL);
+	gpio_request(GPIO_FN_MMCD0_4, NULL);
+	gpio_request(GPIO_FN_MMCD0_5, NULL);
+	gpio_request(GPIO_FN_MMCD0_6, NULL);
+	gpio_request(GPIO_FN_MMCD0_7, NULL);
+	gpio_request(GPIO_FN_MMCCMD0, NULL);
+	gpio_request(GPIO_FN_MMCCLK0, NULL);
+
 	/* USB enable */
 	gpio_request(GPIO_FN_VBUS0_1,    NULL);
 	gpio_request(GPIO_FN_IDIN_1_18,  NULL);
Signature · 1 line
1.7.0.4
#9 lore raw

Re: [PATCH] ARM: mach-shmobile: ap4evb: Add FSI2 support

In reply to Kuninori Morimoto
Quoted 4 lines · Kuninori Morimoto

---
This patch needs Magnus's clock patch series

Which version precisely? With the shared clock framework there is no asm/clock.h header. Please update this patch for the current clock support and I'll apply it then.

Applied
#10 lore raw

Re: [PATCH] ARM: mach-shmobile: ap4evb: Add MMC support

In reply to Kuninori Morimoto
Quoted 8 lines · Kuninori Morimoto

---
This patch is depend on Goda-san's
"Add support MMCIF for SuperH" patch

 arch/arm/mach-shmobile/board-ap4evb.c |   67 +++++++++++++++++++++++++++++++++
 1 files changed, 67 insertions(+), 0 deletions(-)

Applied, thanks.

#11 lore raw

PATCH 1/1 ARM: mach-shmobile: ap4evb: Add LCD panel selection

In reply to Kuninori Morimoto

On AP4EVB board, it is possible to select LCD panel type which are parallel or MIPI by SW3, SW43 dip-switch. This patch add parallel LCD settings and
select menu to Kconfig.

---
 arch/arm/mach-shmobile/Kconfig        |   13 ++
 arch/arm/mach-shmobile/board-ap4evb.c |  346 ++++++++++++++++++++-------------
 2 files changed, 227 insertions(+), 132 deletions(-)
arch/arm/mach-shmobile/Kconfig +13 -0
index 1de8d17..bd6cc6d 100644
@@ -44,6 +44,19 @@ config MACH_AP4EVB
 	select ARCH_REQUIRE_GPIOLIB
 	select SH_LCD_MIPI_DSI
 
+choice
+	prompt "AP4EVB LCD panel selection"
+	default AP4EVB_QHD
+	depends on MACH_AP4EVB
+
+config AP4EVB_QHD
+	bool "MIPI-DSI QHD (960x540)"
+
+config AP4EVB_WVGA
+	bool "Parallel WVGA (800x480)"
+
+endchoice
+
 comment "SH-Mobile System Configuration"
 
 menu "Memory configuration"
arch/arm/mach-shmobile/board-ap4evb.c +214 -132

445 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#13 lore raw

PATCH 1/1 ARM: mach-shmobile: ap4evb: Add ts_get_pendown_state for

In reply to Kuninori Morimoto

This function is necessary to ensure the detection of pen-down. This patch support both QHD / WVGA pannel.

---
This patch is depend on
[PATCH] ARM: mach-shmobile: ap4evb: Add LCD panel selection

# above patch got "Applied, thanks" from Paul
# But I can not find it on latest Paul's git...
 arch/arm/mach-shmobile/board-ap4evb.c |   78 ++++++++++++++++++++++++++-------
 1 files changed, 62 insertions(+), 16 deletions(-)
arch/arm/mach-shmobile/board-ap4evb.c +62 -16
index e8a9d79..9686012 100644
@@ -576,12 +576,74 @@ static struct platform_device *ap4evb_devices[] __initdata = {
 	&sh_mmcif_device
 };
 
+/*
+ * FIXME !!
+ *
+ * gpio_no_direction
+ * gpio_pull_up
+ * are quick_hack.
+ *
+ * current gpio frame work doesn't have
+ * the method to control only pull up/down/free.
+ * this function should be replaced by correct gpio function
+ */
+static void __init gpio_no_direction(u32 addr)
+{
+	__raw_writeb(0x00, addr);
+}
+
+static void __init gpio_pull_up(u32 addr)
+{
+	u8 data = __raw_readb(addr);
+
+	data &= 0x0F;
+	data |= 0xC0;
+	__raw_writeb(data, addr);
+}
+
 /* TouchScreen */
 #define IRQ28	evt2irq(0x3380) /* IRQ28A */
 #define IRQ7	evt2irq(0x02e0) /* IRQ7A */
+static int ts_get_pendown_state(void)
+{
+	int val1, val2;
+
+	gpio_free(GPIO_FN_IRQ28_123);
+	gpio_free(GPIO_FN_IRQ7_40);
+
+	gpio_request(GPIO_PORT123, NULL);
+	gpio_request(GPIO_PORT40, NULL);
+
+	gpio_direction_input(GPIO_PORT123);
+	gpio_direction_input(GPIO_PORT40);
+
+	val1 = gpio_get_value(GPIO_PORT123);
+	val2 = gpio_get_value(GPIO_PORT40);
+
+	gpio_request(GPIO_FN_IRQ28_123, NULL);	/* for QHD */
+	gpio_request(GPIO_FN_IRQ7_40, NULL);	/* for WVGA */
+
+	return val1 ^ val2;
+}
+
+#define PORT40CR	0xE6051028
+#define PORT123CR	0xE605007B
+static int ts_init(void)
+{
+	gpio_request(GPIO_FN_IRQ28_123, NULL);	/* for QHD */
+	gpio_request(GPIO_FN_IRQ7_40, NULL);	/* for WVGA */
+
+	gpio_pull_up(PORT40CR);
+	gpio_pull_up(PORT123CR);
+
+	return 0;
+}
+
 static struct tsc2007_platform_data tsc2007_info = {
 	.model			= 2007,
 	.x_plate_ohms		= 180,
+	.get_pendown_state	= ts_get_pendown_state,
+	.init_platform_hw	= ts_init,
 };
 
 static struct i2c_board_info tsc_device = {
@@ -625,20 +687,6 @@ static void __init ap4evb_map_io(void)
 	shmobile_setup_console();
 }
 
-/*
- * FIXME !!
- *
- * gpio_no_direction is quick_hack.
- *
- * current gpio frame work doesn't have
- * the method to control only pull up/down/free.
- * this function should be replaced by correct gpio function
- */
-static void __init gpio_no_direction(u32 addr)
-{
-	__raw_writeb(0x00, addr);
-}
-
 #define GPIO_PORT9CR	0xE6051009
 #define GPIO_PORT10CR	0xE605100A
 
@@ -784,7 +832,6 @@ static void __init ap4evb_init(void)
 	gpio_request(GPIO_FN_KEYIN4,     NULL);
 
 	/* enable TouchScreen */
-	gpio_request(GPIO_FN_IRQ28_123, NULL);
 	set_irq_type(IRQ28, IRQ_TYPE_LEVEL_LOW);
 
 	tsc_device.irq = IRQ28;
@@ -860,7 +907,6 @@ static void __init ap4evb_init(void)
 	lcdc_info.ch[0].lcd_size_cfg.height	= 91;
 
 	/* enable TouchScreen */
-	gpio_request(GPIO_FN_IRQ7_40, NULL);
 	set_irq_type(IRQ7, IRQ_TYPE_LEVEL_LOW);
 
 	tsc_device.irq = IRQ7;
Signature · 1 line
1.7.0.4
#14 lore raw

PATCH 1/1 ARM: mach-shmobile: ap4evb: Add ts_get_pendown_state for

In reply to Kuninori Morimoto

This function is necessary to ensure the detection of pen-down. This patch support both QHD / WVGA pannel.

---
This patch is depend on
[PATCH] ARM: mach-shmobile: ap4evb: Add LCD panel selection

# above patch got "Applied, thanks" from Paul
# But I can not find it on latest Paul's git...
 arch/arm/mach-shmobile/board-ap4evb.c |   78 ++++++++++++++++++++++++++-------
 1 files changed, 62 insertions(+), 16 deletions(-)
arch/arm/mach-shmobile/board-ap4evb.c +62 -16
index e8a9d79..9686012 100644
@@ -576,12 +576,74 @@ static struct platform_device *ap4evb_devices[] __initdata = {
 	&sh_mmcif_device
 };
 
+/*
+ * FIXME !!
+ *
+ * gpio_no_direction
+ * gpio_pull_up
+ * are quick_hack.
+ *
+ * current gpio frame work doesn't have
+ * the method to control only pull up/down/free.
+ * this function should be replaced by correct gpio function
+ */
+static void __init gpio_no_direction(u32 addr)
+{
+	__raw_writeb(0x00, addr);
+}
+
+static void __init gpio_pull_up(u32 addr)
+{
+	u8 data = __raw_readb(addr);
+
+	data &= 0x0F;
+	data |= 0xC0;
+	__raw_writeb(data, addr);
+}
+
 /* TouchScreen */
 #define IRQ28	evt2irq(0x3380) /* IRQ28A */
 #define IRQ7	evt2irq(0x02e0) /* IRQ7A */
+static int ts_get_pendown_state(void)
+{
+	int val1, val2;
+
+	gpio_free(GPIO_FN_IRQ28_123);
+	gpio_free(GPIO_FN_IRQ7_40);
+
+	gpio_request(GPIO_PORT123, NULL);
+	gpio_request(GPIO_PORT40, NULL);
+
+	gpio_direction_input(GPIO_PORT123);
+	gpio_direction_input(GPIO_PORT40);
+
+	val1 = gpio_get_value(GPIO_PORT123);
+	val2 = gpio_get_value(GPIO_PORT40);
+
+	gpio_request(GPIO_FN_IRQ28_123, NULL);	/* for QHD */
+	gpio_request(GPIO_FN_IRQ7_40, NULL);	/* for WVGA */
+
+	return val1 ^ val2;
+}
+
+#define PORT40CR	0xE6051028
+#define PORT123CR	0xE605007B
+static int ts_init(void)
+{
+	gpio_request(GPIO_FN_IRQ28_123, NULL);	/* for QHD */
+	gpio_request(GPIO_FN_IRQ7_40, NULL);	/* for WVGA */
+
+	gpio_pull_up(PORT40CR);
+	gpio_pull_up(PORT123CR);
+
+	return 0;
+}
+
 static struct tsc2007_platform_data tsc2007_info = {
 	.model			= 2007,
 	.x_plate_ohms		= 180,
+	.get_pendown_state	= ts_get_pendown_state,
+	.init_platform_hw	= ts_init,
 };
 
 static struct i2c_board_info tsc_device = {
@@ -625,20 +687,6 @@ static void __init ap4evb_map_io(void)
 	shmobile_setup_console();
 }
 
-/*
- * FIXME !!
- *
- * gpio_no_direction is quick_hack.
- *
- * current gpio frame work doesn't have
- * the method to control only pull up/down/free.
- * this function should be replaced by correct gpio function
- */
-static void __init gpio_no_direction(u32 addr)
-{
-	__raw_writeb(0x00, addr);
-}
-
 #define GPIO_PORT9CR	0xE6051009
 #define GPIO_PORT10CR	0xE605100A
 
@@ -784,7 +832,6 @@ static void __init ap4evb_init(void)
 	gpio_request(GPIO_FN_KEYIN4,     NULL);
 
 	/* enable TouchScreen */
-	gpio_request(GPIO_FN_IRQ28_123, NULL);
 	set_irq_type(IRQ28, IRQ_TYPE_LEVEL_LOW);
 
 	tsc_device.irq = IRQ28;
@@ -860,7 +907,6 @@ static void __init ap4evb_init(void)
 	lcdc_info.ch[0].lcd_size_cfg.height	= 91;
 
 	/* enable TouchScreen */
-	gpio_request(GPIO_FN_IRQ7_40, NULL);
 	set_irq_type(IRQ7, IRQ_TYPE_LEVEL_LOW);
 
 	tsc_device.irq = IRQ7;
Signature · 1 line
1.7.0.4
#15 lore raw

PATCH 1/1 ARM: mach-shmobile: ap4evb: Add HDMI sound support

In reply to Kuninori Morimoto

---
This patch is depend on my FSIDIV support patch and ALSA tree

 arch/arm/mach-shmobile/board-ap4evb.c |   46 ++++++++++++++++++++++++++++++++-
 1 files changed, 45 insertions(+), 1 deletions(-)
arch/arm/mach-shmobile/board-ap4evb.c +45 -1
index efbdbdf..9ba8f8a 100644
@@ -517,12 +517,50 @@ static struct platform_device *qhd_devices[] __initdata = {
 
 /* FSI */
 #define IRQ_FSI		evt2irq(0x1840)
+
+static int fsi_set_rate(int is_porta, int rate)
+{
+	struct clk *fsib_clk;
+	struct clk *fdiv_clk = &sh7372_fsidivb_clk;
+	int ret;
+
+	/* set_rate is not needed if port A */
+	if (is_porta)
+		return 0;
+
+	fsib_clk = clk_get(NULL, "fsib_clk");
+	if (IS_ERR(fsib_clk))
+		return -EINVAL;
+
+	switch (rate) {
+	case 48000:
+		clk_set_rate(fsib_clk, clk_round_rate(fsib_clk, 85428000));
+		clk_set_rate(fdiv_clk, clk_round_rate(fdiv_clk, 12204000));
+		ret = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64;
+		break;
+	default:
+		pr_err("unsupported rate in FSI2 port B\n");
+		ret = -EINVAL;
+		break;
+	}
+
+	clk_put(fsib_clk);
+
+	return ret;
+}
+
 static struct sh_fsi_platform_info fsi_info = {
 	.porta_flags = SH_FSI_BRS_INV |
 		       SH_FSI_OUT_SLAVE_MODE |
 		       SH_FSI_IN_SLAVE_MODE |
 		       SH_FSI_OFMT(PCM) |
 		       SH_FSI_IFMT(PCM),
+
+	.portb_flags = SH_FSI_BRS_INV |
+		       SH_FSI_BRM_INV |
+		       SH_FSI_LRS_INV |
+		       SH_FSI_OFMT(SPDIF),
+	.set_rate = fsi_set_rate,
 };
 
 static struct resource fsi_resources[] = {
@@ -606,6 +644,7 @@ static struct platform_device lcdc1_device = {
 static struct sh_mobile_hdmi_info hdmi_info = {
 	.lcd_chan = &sh_mobile_lcdc1_info.ch[0],
 	.lcd_dev = &lcdc1_device.dev,
+	.flags = HDMI_SND_SRC_SPDIF,
 };
 
 static struct resource hdmi_resources[] = {
@@ -838,6 +877,7 @@ static void __init ap4evb_map_io(void)
 
 #define GPIO_PORT9CR	0xE6051009
 #define GPIO_PORT10CR	0xE605100A
+#define USCCR1		0xE6058144
 static void __init ap4evb_init(void)
 {
 	u32 srcr4;
@@ -908,7 +948,7 @@ static void __init ap4evb_init(void)
 	/* setup USB phy */
 	__raw_writew(0x8a0a, 0xE6058130);	/* USBCR2 */
 
-	/* enable FSI2 */
+	/* enable FSI2 port A (ak4643) */
 	gpio_request(GPIO_FN_FSIAIBT,	NULL);
 	gpio_request(GPIO_FN_FSIAILR,	NULL);
 	gpio_request(GPIO_FN_FSIAISLD,	NULL);
@@ -921,6 +961,10 @@ static void __init ap4evb_init(void)
 	gpio_no_direction(GPIO_PORT9CR);  /* FSIAOBT needs no direction */
 	gpio_no_direction(GPIO_PORT10CR); /* FSIAOLR needs no direction */
 
+	/* setup FSI2 port B (HDMI) */
+	gpio_request(GPIO_FN_FSIBCK, NULL);
+	__raw_writew(__raw_readw(USCCR1) & ~(1 << 6), USCCR1); /* use SPDIF */
+
 	/* set SPU2 clock to 119.6 MHz */
 	clk = clk_get(NULL, "spu_clk");
 	if (!IS_ERR(clk)) {
Signature · 1 line
1.7.0.4
#16 lore raw

Re: [PATCH] ARM: mach-shmobile: ap4evb: Add HDMI sound support

In reply to Kuninori Morimoto
Quoted 7 lines · Kuninori Morimoto

---
This patch is depend on my FSIDIV support patch and ALSA tree

 arch/arm/mach-shmobile/board-ap4evb.c |   46 ++++++++++++++++++++++++++++++++-
 1 files changed, 45 insertions(+), 1 deletions(-)

Ok, I've now applied this and the FSIDIV patch. It all builds ok, but you may wish to doublecheck to make sure nothing got overlooked.

#17 lore raw

PATCH 1/1 ARM: mach-shmobile: ap4evb: add fsib 44100Hz rate

In reply to Kuninori Morimoto
---
 arch/arm/mach-shmobile/board-ap4evb.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
arch/arm/mach-shmobile/board-ap4evb.c +7 -0
index 63c2fca..5c14c73 100644
@@ -582,7 +582,14 @@ static int fsi_set_rate(int is_porta, int rate)
 	if (IS_ERR(fsib_clk))
 		return -EINVAL;
 
+	while (fdiv_clk->usecount)
+		clk_disable(fdiv_clk);
+
 	switch (rate) {
+	case 44100:
+		clk_set_rate(fsib_clk, clk_round_rate(fsib_clk, 11283000));
+		ret = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64;
+		break;
 	case 48000:
 		clk_set_rate(fsib_clk, clk_round_rate(fsib_clk, 85428000));
 		clk_set_rate(fdiv_clk, clk_round_rate(fdiv_clk, 12204000));
Signature · 1 line
1.7.0.4
#18 lore raw

Re: [PATCH] ARM: mach-shmobile: ap4evb: add fsib 44100Hz rate

In reply to Kuninori Morimoto
Quoted 12 lines · Kuninori Morimoto
---
 arch/arm/mach-shmobile/board-ap4evb.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
arch/arm/mach-shmobile/board-ap4evb.c +0 -0
index 63c2fca..5c14c73 100644

arch/arm/mach-shmobile/board-ap4evb.c static int fsi_set_rate(int is_porta, int rate) · line 587

Quoted 6 lines
arch/arm/mach-shmobile/board-ap4evb.c +3 -0
@@ -582,7 +582,14 @@ static int fsi_set_rate(int is_porta, int rate)
 	if (IS_ERR(fsib_clk))
 		return -EINVAL;
 
+	while (fdiv_clk->usecount)
+		clk_disable(fdiv_clk);
+

Uhm, no. Whatever this thinks its doing, is horribly, horribly wrong.

The refcount exists for a reason. If your driver wants to change the rate, then it can drop the usecount itself and give it a go. If that fails, then that means that some other driver also has a handle on the same clock, and simply changing the rate underneath it is precisely the sort of thing that the refcounting exists to prevent!

arch/arm/mach-shmobile/board-ap4evb.c static int fsi_set_rate(int is_porta, int rate) · line 592

Quoted 5 lines
arch/arm/mach-shmobile/board-ap4evb.c +4 -0
 	switch (rate) {
+	case 44100:
+		clk_set_rate(fsib_clk, clk_round_rate(fsib_clk, 11283000));
+		ret = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64;
+		break;

This part looks fine, and I'll apply it, while pretending like I never saw the first part.

When you fix your driver to get the refcounting right, feel free to submit a follow-up patch for that.

#19 lore raw

PATCH 1/1 ARM: mach-shmobile: ap4evb: add fsib 44100Hz rate fixup

In reply to Kuninori Morimoto

This patch disable fdiv_clk when 44.1kHz

---
 arch/arm/mach-shmobile/board-ap4evb.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
arch/arm/mach-shmobile/board-ap4evb.c +1 -0
index d326054..355e3cf 100644
@@ -585,6 +585,7 @@ static int fsi_set_rate(int is_porta, int rate)
 	switch (rate) {
 	case 44100:
 		clk_set_rate(fsib_clk, clk_round_rate(fsib_clk, 11283000));
+		clk_set_rate(fdiv_clk, clk_round_rate(fsib_clk, 11283000));
 		ret = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64;
 		break;
 	case 48000:
Signature · 1 line
1.7.0.4
#20 lore raw

Re: [PATCH] ARM: mach-shmobile: ap4evb: add fsib 44100Hz rate fixup

In reply to Kuninori Morimoto
Quoted 12 lines · Kuninori Morimoto

This patch disable fdiv_clk when 44.1kHz

---
 arch/arm/mach-shmobile/board-ap4evb.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
arch/arm/mach-shmobile/board-ap4evb.c +0 -0
index d326054..355e3cf 100644

arch/arm/mach-shmobile/board-ap4evb.c static int fsi_set_rate(int is_porta, int rate) · line 588

Quoted 4 lines
arch/arm/mach-shmobile/board-ap4evb.c +1 -0
@@ -585,6 +585,7 @@ static int fsi_set_rate(int is_porta, int rate)
 	switch (rate) {
 	case 44100:
 		clk_set_rate(fsib_clk, clk_round_rate(fsib_clk, 11283000));
+		clk_set_rate(fdiv_clk, clk_round_rate(fsib_clk, 11283000));

Shouldn't this be

	clk_set_rate(fdiv_clk, clk_round_rate(fdiv_clk, 11283000));

?

#21 lore raw

Re: [PATCH] ARM: mach-shmobile: ap4evb: add fsib 44100Hz rate fixup

In reply to Kuninori Morimoto

Dear Paul

Quoted 8 lines

Review

Quoted 3 lines
(quoted diff) +1 -0
 	case 44100:
 		clk_set_rate(fsib_clk, clk_round_rate(fsib_clk, 11283000));
+		clk_set_rate(fdiv_clk, clk_round_rate(fsib_clk, 11283000));

Shouldn't this be

	clk_set_rate(fdiv_clk, clk_round_rate(fdiv_clk, 11283000));

clk_round_rate(fsib_clk, 11283000) is correct.
this mean fdiv_clk no divide.

should I modify like this ?

case 44100:

		rate = clk_round_rate(fsib_clk, 11283000);
         	clk_set_rate(fsib_clk, rate);
		clk_set_rate(fdiv_clk, rate);

Best regards
--
Kuninori Morimoto

#22 lore raw

Re: [PATCH] ARM: mach-shmobile: ap4evb: add fsib 44100Hz rate fixup

In reply to Kuninori Morimoto
Quoted 15 lines · Kuninori Morimoto

Dear Paul

Quoted 8 lines

Review

Quoted 3 lines
(quoted diff) +1 -0
 	case 44100:
 		clk_set_rate(fsib_clk, clk_round_rate(fsib_clk, 11283000));
+		clk_set_rate(fdiv_clk, clk_round_rate(fsib_clk, 11283000));

Shouldn't this be

	clk_set_rate(fdiv_clk, clk_round_rate(fdiv_clk, 11283000));

clk_round_rate(fsib_clk, 11283000) is correct.
this mean fdiv_clk no divide.

Quoted 7 lines

should I modify like this ?

case 44100:

		rate = clk_round_rate(fsib_clk, 11283000);
         	clk_set_rate(fsib_clk, rate);
		clk_set_rate(fdiv_clk, rate);

Yes, that would be cleaner. It would also be nice if you provided some changeset comments so it's more apparent what you're trying to do.