From 7a4fcf91c83ad76d30ee876615d5fd35ef907e32 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 13 Aug 2012 16:11:32 +0200 Subject: ARM: mach-shmobile: ag5evm: Add LCDC tx_dev field to platform data Reference the MIPI-DSI transceiver in the LCDC platform data and make sure it gets registered before the LCDC. Signed-off-by: Laurent Pinchart Acked-by: Simon Horman --- arch/arm/mach-shmobile/board-ag5evm.c | 157 +++++++++++++++++----------------- 1 file changed, 80 insertions(+), 77 deletions(-) (limited to 'arch/arm/mach-shmobile') diff --git a/arch/arm/mach-shmobile/board-ag5evm.c b/arch/arm/mach-shmobile/board-ag5evm.c index 25eb88a923e6..52b5e64eb6b9 100644 --- a/arch/arm/mach-shmobile/board-ag5evm.c +++ b/arch/arm/mach-shmobile/board-ag5evm.c @@ -213,6 +213,84 @@ static struct platform_device irda_device = { .num_resources = ARRAY_SIZE(irda_resources), }; +/* MIPI-DSI */ +static struct resource mipidsi0_resources[] = { + [0] = { + .name = "DSI0", + .start = 0xfeab0000, + .end = 0xfeab3fff, + .flags = IORESOURCE_MEM, + }, + [1] = { + .name = "DSI0", + .start = 0xfeab4000, + .end = 0xfeab7fff, + .flags = IORESOURCE_MEM, + }, +}; + +static int sh_mipi_set_dot_clock(struct platform_device *pdev, + void __iomem *base, + int enable) +{ + struct clk *pck, *phy; + int ret; + + pck = clk_get(&pdev->dev, "dsip_clk"); + if (IS_ERR(pck)) { + ret = PTR_ERR(pck); + goto sh_mipi_set_dot_clock_pck_err; + } + + phy = clk_get(&pdev->dev, "dsiphy_clk"); + if (IS_ERR(phy)) { + ret = PTR_ERR(phy); + goto sh_mipi_set_dot_clock_phy_err; + } + + if (enable) { + clk_set_rate(pck, clk_round_rate(pck, 24000000)); + clk_set_rate(phy, clk_round_rate(pck, 510000000)); + clk_enable(pck); + clk_enable(phy); + } else { + clk_disable(pck); + clk_disable(phy); + } + + ret = 0; + + clk_put(phy); +sh_mipi_set_dot_clock_phy_err: + clk_put(pck); +sh_mipi_set_dot_clock_pck_err: + return ret; +} + +static struct sh_mobile_lcdc_info lcdc0_info; + +static struct sh_mipi_dsi_info mipidsi0_info = { + .data_format = MIPI_RGB888, + .lcd_chan = &lcdc0_info.ch[0], + .lane = 2, + .vsynw_offset = 20, + .clksrc = 1, + .flags = SH_MIPI_DSI_HSABM | + SH_MIPI_DSI_SYNC_PULSES_MODE | + SH_MIPI_DSI_HSbyteCLK, + .set_dot_clock = sh_mipi_set_dot_clock, +}; + +static struct platform_device mipidsi0_device = { + .name = "sh-mipi-dsi", + .num_resources = ARRAY_SIZE(mipidsi0_resources), + .resource = mipidsi0_resources, + .id = 0, + .dev = { + .platform_data = &mipidsi0_info, + }, +}; + static unsigned char lcd_backlight_seq[3][2] = { { 0x04, 0x07 }, { 0x23, 0x80 }, @@ -275,6 +353,7 @@ static struct sh_mobile_lcdc_info lcdc0_info = { .display_on = lcd_backlight_on, .display_off = lcd_backlight_reset, }, + .tx_dev = &mipidsi0_device, } }; @@ -302,82 +381,6 @@ static struct platform_device lcdc0_device = { }, }; -/* MIPI-DSI */ -static struct resource mipidsi0_resources[] = { - [0] = { - .name = "DSI0", - .start = 0xfeab0000, - .end = 0xfeab3fff, - .flags = IORESOURCE_MEM, - }, - [1] = { - .name = "DSI0", - .start = 0xfeab4000, - .end = 0xfeab7fff, - .flags = IORESOURCE_MEM, - }, -}; - -static int sh_mipi_set_dot_clock(struct platform_device *pdev, - void __iomem *base, - int enable) -{ - struct clk *pck, *phy; - int ret; - - pck = clk_get(&pdev->dev, "dsip_clk"); - if (IS_ERR(pck)) { - ret = PTR_ERR(pck); - goto sh_mipi_set_dot_clock_pck_err; - } - - phy = clk_get(&pdev->dev, "dsiphy_clk"); - if (IS_ERR(phy)) { - ret = PTR_ERR(phy); - goto sh_mipi_set_dot_clock_phy_err; - } - - if (enable) { - clk_set_rate(pck, clk_round_rate(pck, 24000000)); - clk_set_rate(phy, clk_round_rate(pck, 510000000)); - clk_enable(pck); - clk_enable(phy); - } else { - clk_disable(pck); - clk_disable(phy); - } - - ret = 0; - - clk_put(phy); -sh_mipi_set_dot_clock_phy_err: - clk_put(pck); -sh_mipi_set_dot_clock_pck_err: - return ret; -} - -static struct sh_mipi_dsi_info mipidsi0_info = { - .data_format = MIPI_RGB888, - .lcd_chan = &lcdc0_info.ch[0], - .lane = 2, - .vsynw_offset = 20, - .clksrc = 1, - .flags = SH_MIPI_DSI_HSABM | - SH_MIPI_DSI_SYNC_PULSES_MODE | - SH_MIPI_DSI_HSbyteCLK, - .set_dot_clock = sh_mipi_set_dot_clock, -}; - -static struct platform_device mipidsi0_device = { - .name = "sh-mipi-dsi", - .num_resources = ARRAY_SIZE(mipidsi0_resources), - .resource = mipidsi0_resources, - .id = 0, - .dev = { - .platform_data = &mipidsi0_info, - }, -}; - /* Fixed 2.8V regulators to be used by SDHI0 */ static struct regulator_consumer_supply fixed2v8_power_consumers[] = { @@ -531,8 +534,8 @@ static struct platform_device *ag5evm_devices[] __initdata = { &fsi_device, &mmc_device, &irda_device, - &lcdc0_device, &mipidsi0_device, + &lcdc0_device, &sdhi0_device, &sdhi1_device, }; -- cgit v1.2.3 From 772f5d1b78f1427be0abe54dbde82c51678316b9 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 14 Aug 2012 12:21:17 +0200 Subject: ARM: mach-shmobile: Initiliaze the new sh_mipi_dsi_info channel field Signed-off-by: Laurent Pinchart Acked-by: Simon Horman --- arch/arm/mach-shmobile/board-ag5evm.c | 1 + arch/arm/mach-shmobile/board-ap4evb.c | 1 + 2 files changed, 2 insertions(+) (limited to 'arch/arm/mach-shmobile') diff --git a/arch/arm/mach-shmobile/board-ag5evm.c b/arch/arm/mach-shmobile/board-ag5evm.c index 52b5e64eb6b9..a38931f6b843 100644 --- a/arch/arm/mach-shmobile/board-ag5evm.c +++ b/arch/arm/mach-shmobile/board-ag5evm.c @@ -272,6 +272,7 @@ static struct sh_mobile_lcdc_info lcdc0_info; static struct sh_mipi_dsi_info mipidsi0_info = { .data_format = MIPI_RGB888, .lcd_chan = &lcdc0_info.ch[0], + .channel = LCDC_CHAN_MAINLCD, .lane = 2, .vsynw_offset = 20, .clksrc = 1, diff --git a/arch/arm/mach-shmobile/board-ap4evb.c b/arch/arm/mach-shmobile/board-ap4evb.c index 790dc68c4312..25a46b5ed9b2 100644 --- a/arch/arm/mach-shmobile/board-ap4evb.c +++ b/arch/arm/mach-shmobile/board-ap4evb.c @@ -557,6 +557,7 @@ static struct sh_mobile_lcdc_info lcdc_info; static struct sh_mipi_dsi_info mipidsi0_info = { .data_format = MIPI_RGB888, .lcd_chan = &lcdc_info.ch[0], + .channel = LCDC_CHAN_MAINLCD, .lane = 2, .vsynw_offset = 17, .phyctrl = 0x6 << 8, -- cgit v1.2.3 From 4b74fdeb24a5d1bcf35aad8b8e3bd068319a1125 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 14 Aug 2012 12:21:17 +0200 Subject: ARM: mach-shmobile: Remove the unused sh_mipi_dsi_info lcd_chan field Signed-off-by: Laurent Pinchart Acked-by: Simon Horman --- arch/arm/mach-shmobile/board-ag5evm.c | 3 --- arch/arm/mach-shmobile/board-ap4evb.c | 3 --- 2 files changed, 6 deletions(-) (limited to 'arch/arm/mach-shmobile') diff --git a/arch/arm/mach-shmobile/board-ag5evm.c b/arch/arm/mach-shmobile/board-ag5evm.c index a38931f6b843..d787979a5310 100644 --- a/arch/arm/mach-shmobile/board-ag5evm.c +++ b/arch/arm/mach-shmobile/board-ag5evm.c @@ -267,11 +267,8 @@ sh_mipi_set_dot_clock_pck_err: return ret; } -static struct sh_mobile_lcdc_info lcdc0_info; - static struct sh_mipi_dsi_info mipidsi0_info = { .data_format = MIPI_RGB888, - .lcd_chan = &lcdc0_info.ch[0], .channel = LCDC_CHAN_MAINLCD, .lane = 2, .vsynw_offset = 20, diff --git a/arch/arm/mach-shmobile/board-ap4evb.c b/arch/arm/mach-shmobile/board-ap4evb.c index 25a46b5ed9b2..728ed4d026c7 100644 --- a/arch/arm/mach-shmobile/board-ap4evb.c +++ b/arch/arm/mach-shmobile/board-ap4evb.c @@ -552,11 +552,8 @@ static struct resource mipidsi0_resources[] = { }, }; -static struct sh_mobile_lcdc_info lcdc_info; - static struct sh_mipi_dsi_info mipidsi0_info = { .data_format = MIPI_RGB888, - .lcd_chan = &lcdc_info.ch[0], .channel = LCDC_CHAN_MAINLCD, .lane = 2, .vsynw_offset = 17, -- cgit v1.2.3 From 4c108530dba393084766799422aea1631e0dec81 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 15 Aug 2012 18:11:26 +0200 Subject: ARM: mach-shmobile: mackerel: Removed unused get_brightness callback Signed-off-by: Laurent Pinchart Acked-by: Simon Horman --- arch/arm/mach-shmobile/board-mackerel.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'arch/arm/mach-shmobile') diff --git a/arch/arm/mach-shmobile/board-mackerel.c b/arch/arm/mach-shmobile/board-mackerel.c index 0c27c810cf99..bfd2dc83d995 100644 --- a/arch/arm/mach-shmobile/board-mackerel.c +++ b/arch/arm/mach-shmobile/board-mackerel.c @@ -370,11 +370,6 @@ static int mackerel_set_brightness(int brightness) return 0; } -static int mackerel_get_brightness(void) -{ - return gpio_get_value(GPIO_PORT31); -} - static const struct sh_mobile_meram_cfg lcd_meram_cfg = { .icb[0] = { .meram_size = 0x40, @@ -403,7 +398,6 @@ static struct sh_mobile_lcdc_info lcdc_info = { .name = "sh_mobile_lcdc_bl", .max_brightness = 1, .set_brightness = mackerel_set_brightness, - .get_brightness = mackerel_get_brightness, }, .meram_cfg = &lcd_meram_cfg, } -- cgit v1.2.3 From 37f4dd13505bab9f2bbd2f66a2c9375e959452eb Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 15 Aug 2012 18:25:27 +0200 Subject: ARM: mach-shmobile: ag5evm: Use the backlight API for brightness control Don't hook up brightness control in the display on/off operations, use the backlight API instead. Signed-off-by: Laurent Pinchart Acked-by: Simon Horman --- arch/arm/mach-shmobile/board-ag5evm.c | 45 ++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 16 deletions(-) (limited to 'arch/arm/mach-shmobile') diff --git a/arch/arm/mach-shmobile/board-ag5evm.c b/arch/arm/mach-shmobile/board-ag5evm.c index d787979a5310..032d10817e79 100644 --- a/arch/arm/mach-shmobile/board-ag5evm.c +++ b/arch/arm/mach-shmobile/board-ag5evm.c @@ -295,28 +295,38 @@ static unsigned char lcd_backlight_seq[3][2] = { { 0x03, 0x01 }, }; -static void lcd_backlight_on(void) +static int lcd_backlight_set_brightness(int brightness) { - struct i2c_adapter *a; + struct i2c_adapter *adap; struct i2c_msg msg; - int k; + unsigned int i; + int ret; + + if (brightness == 0) { + /* Reset the chip */ + gpio_set_value(GPIO_PORT235, 0); + mdelay(24); + gpio_set_value(GPIO_PORT235, 1); + return 0; + } + + adap = i2c_get_adapter(1); + if (adap == NULL) + return -ENODEV; - a = i2c_get_adapter(1); - for (k = 0; a && k < 3; k++) { + for (i = 0; i < ARRAY_SIZE(lcd_backlight_seq); i++) { msg.addr = 0x6d; - msg.buf = &lcd_backlight_seq[k][0]; + msg.buf = &lcd_backlight_seq[i][0]; msg.len = 2; msg.flags = 0; - if (i2c_transfer(a, &msg, 1) != 1) + + ret = i2c_transfer(adap, &msg, 1); + if (ret < 0) break; } -} -static void lcd_backlight_reset(void) -{ - gpio_set_value(GPIO_PORT235, 0); - mdelay(24); - gpio_set_value(GPIO_PORT235, 1); + i2c_put_adapter(adap); + return ret < 0 ? ret : 0; } /* LCDC0 */ @@ -348,8 +358,11 @@ static struct sh_mobile_lcdc_info lcdc0_info = { .panel_cfg = { .width = 44, .height = 79, - .display_on = lcd_backlight_on, - .display_off = lcd_backlight_reset, + }, + .bl_info = { + .name = "sh_mobile_lcdc_bl", + .max_brightness = 1, + .set_brightness = lcd_backlight_set_brightness, }, .tx_dev = &mipidsi0_device, } @@ -622,7 +635,7 @@ static void __init ag5evm_init(void) /* LCD backlight controller */ gpio_request(GPIO_PORT235, NULL); /* RESET */ gpio_direction_output(GPIO_PORT235, 0); - lcd_backlight_reset(); + lcd_backlight_set_brightness(0); /* enable SDHI0 on CN15 [SD I/F] */ gpio_request(GPIO_FN_SDHIWP0, NULL); -- cgit v1.2.3