Loading...
1/*
2 * Copyright (C) 2010 Texas Instruments Inc.
3 *
4 * Modified from mach-omap2/board-zoom-peripherals.c
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/platform_device.h>
14#include <linux/gpio.h>
15#include <linux/i2c/twl.h>
16#include <linux/spi/spi.h>
17#include <plat/mcspi.h>
18#include <video/omapdss.h>
19#include <mach/board-zoom.h>
20
21#define LCD_PANEL_RESET_GPIO_PROD 96
22#define LCD_PANEL_RESET_GPIO_PILOT 55
23#define LCD_PANEL_QVGA_GPIO 56
24
25static struct gpio zoom_lcd_gpios[] __initdata = {
26 { -EINVAL, GPIOF_OUT_INIT_HIGH, "lcd reset" },
27 { LCD_PANEL_QVGA_GPIO, GPIOF_OUT_INIT_HIGH, "lcd qvga" },
28};
29
30static void __init zoom_lcd_panel_init(void)
31{
32 zoom_lcd_gpios[0].gpio = (omap_rev() > OMAP3430_REV_ES3_0) ?
33 LCD_PANEL_RESET_GPIO_PROD :
34 LCD_PANEL_RESET_GPIO_PILOT;
35
36 if (gpio_request_array(zoom_lcd_gpios, ARRAY_SIZE(zoom_lcd_gpios)))
37 pr_err("%s: Failed to get LCD GPIOs.\n", __func__);
38}
39
40static int zoom_panel_enable_lcd(struct omap_dss_device *dssdev)
41{
42 return 0;
43}
44
45static void zoom_panel_disable_lcd(struct omap_dss_device *dssdev)
46{
47}
48
49/*
50 * PWMA/B register offsets (TWL4030_MODULE_PWMA)
51 */
52#define TWL_INTBR_PMBR1 0xD
53#define TWL_INTBR_GPBR1 0xC
54#define TWL_LED_PWMON 0x0
55#define TWL_LED_PWMOFF 0x1
56
57static int zoom_set_bl_intensity(struct omap_dss_device *dssdev, int level)
58{
59#ifdef CONFIG_TWL4030_CORE
60 unsigned char c;
61 u8 mux_pwm, enb_pwm;
62
63 if (level > 100)
64 return -1;
65
66 twl_i2c_read_u8(TWL4030_MODULE_INTBR, &mux_pwm, TWL_INTBR_PMBR1);
67 twl_i2c_read_u8(TWL4030_MODULE_INTBR, &enb_pwm, TWL_INTBR_GPBR1);
68
69 if (level == 0) {
70 /* disable pwm1 output and clock */
71 enb_pwm = enb_pwm & 0xF5;
72 /* change pwm1 pin to gpio pin */
73 mux_pwm = mux_pwm & 0xCF;
74 twl_i2c_write_u8(TWL4030_MODULE_INTBR,
75 enb_pwm, TWL_INTBR_GPBR1);
76 twl_i2c_write_u8(TWL4030_MODULE_INTBR,
77 mux_pwm, TWL_INTBR_PMBR1);
78 return 0;
79 }
80
81 if (!((enb_pwm & 0xA) && (mux_pwm & 0x30))) {
82 /* change gpio pin to pwm1 pin */
83 mux_pwm = mux_pwm | 0x30;
84 /* enable pwm1 output and clock*/
85 enb_pwm = enb_pwm | 0x0A;
86 twl_i2c_write_u8(TWL4030_MODULE_INTBR,
87 mux_pwm, TWL_INTBR_PMBR1);
88 twl_i2c_write_u8(TWL4030_MODULE_INTBR,
89 enb_pwm, TWL_INTBR_GPBR1);
90 }
91
92 c = ((50 * (100 - level)) / 100) + 1;
93 twl_i2c_write_u8(TWL4030_MODULE_PWM1, 0x7F, TWL_LED_PWMOFF);
94 twl_i2c_write_u8(TWL4030_MODULE_PWM1, c, TWL_LED_PWMON);
95#else
96 pr_warn("Backlight not enabled\n");
97#endif
98
99 return 0;
100}
101
102static struct omap_dss_device zoom_lcd_device = {
103 .name = "lcd",
104 .driver_name = "NEC_8048_panel",
105 .type = OMAP_DISPLAY_TYPE_DPI,
106 .phy.dpi.data_lines = 24,
107 .platform_enable = zoom_panel_enable_lcd,
108 .platform_disable = zoom_panel_disable_lcd,
109 .max_backlight_level = 100,
110 .set_backlight = zoom_set_bl_intensity,
111};
112
113static struct omap_dss_device *zoom_dss_devices[] = {
114 &zoom_lcd_device,
115};
116
117static struct omap_dss_board_info zoom_dss_data = {
118 .num_devices = ARRAY_SIZE(zoom_dss_devices),
119 .devices = zoom_dss_devices,
120 .default_device = &zoom_lcd_device,
121};
122
123static struct omap2_mcspi_device_config dss_lcd_mcspi_config = {
124 .turbo_mode = 1,
125};
126
127static struct spi_board_info nec_8048_spi_board_info[] __initdata = {
128 [0] = {
129 .modalias = "nec_8048_spi",
130 .bus_num = 1,
131 .chip_select = 2,
132 .max_speed_hz = 375000,
133 .controller_data = &dss_lcd_mcspi_config,
134 },
135};
136
137void __init zoom_display_init(void)
138{
139 omap_display_init(&zoom_dss_data);
140 spi_register_board_info(nec_8048_spi_board_info,
141 ARRAY_SIZE(nec_8048_spi_board_info));
142 zoom_lcd_panel_init();
143}
144
1/*
2 * Copyright (C) 2010 Texas Instruments Inc.
3 *
4 * Modified from mach-omap2/board-zoom-peripherals.c
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/platform_device.h>
14#include <linux/gpio.h>
15#include <linux/i2c/twl.h>
16#include <linux/spi/spi.h>
17#include <plat/mcspi.h>
18#include <video/omapdss.h>
19
20#define LCD_PANEL_RESET_GPIO_PROD 96
21#define LCD_PANEL_RESET_GPIO_PILOT 55
22#define LCD_PANEL_QVGA_GPIO 56
23
24static struct gpio zoom_lcd_gpios[] __initdata = {
25 { -EINVAL, GPIOF_OUT_INIT_HIGH, "lcd reset" },
26 { LCD_PANEL_QVGA_GPIO, GPIOF_OUT_INIT_HIGH, "lcd qvga" },
27};
28
29static void __init zoom_lcd_panel_init(void)
30{
31 zoom_lcd_gpios[0].gpio = (omap_rev() > OMAP3430_REV_ES3_0) ?
32 LCD_PANEL_RESET_GPIO_PROD :
33 LCD_PANEL_RESET_GPIO_PILOT;
34
35 if (gpio_request_array(zoom_lcd_gpios, ARRAY_SIZE(zoom_lcd_gpios)))
36 pr_err("%s: Failed to get LCD GPIOs.\n", __func__);
37}
38
39static int zoom_panel_enable_lcd(struct omap_dss_device *dssdev)
40{
41 return 0;
42}
43
44static void zoom_panel_disable_lcd(struct omap_dss_device *dssdev)
45{
46}
47
48/*
49 * PWMA/B register offsets (TWL4030_MODULE_PWMA)
50 */
51#define TWL_INTBR_PMBR1 0xD
52#define TWL_INTBR_GPBR1 0xC
53#define TWL_LED_PWMON 0x0
54#define TWL_LED_PWMOFF 0x1
55
56static int zoom_set_bl_intensity(struct omap_dss_device *dssdev, int level)
57{
58 unsigned char c;
59 u8 mux_pwm, enb_pwm;
60
61 if (level > 100)
62 return -1;
63
64 twl_i2c_read_u8(TWL4030_MODULE_INTBR, &mux_pwm, TWL_INTBR_PMBR1);
65 twl_i2c_read_u8(TWL4030_MODULE_INTBR, &enb_pwm, TWL_INTBR_GPBR1);
66
67 if (level == 0) {
68 /* disable pwm1 output and clock */
69 enb_pwm = enb_pwm & 0xF5;
70 /* change pwm1 pin to gpio pin */
71 mux_pwm = mux_pwm & 0xCF;
72 twl_i2c_write_u8(TWL4030_MODULE_INTBR,
73 enb_pwm, TWL_INTBR_GPBR1);
74 twl_i2c_write_u8(TWL4030_MODULE_INTBR,
75 mux_pwm, TWL_INTBR_PMBR1);
76 return 0;
77 }
78
79 if (!((enb_pwm & 0xA) && (mux_pwm & 0x30))) {
80 /* change gpio pin to pwm1 pin */
81 mux_pwm = mux_pwm | 0x30;
82 /* enable pwm1 output and clock*/
83 enb_pwm = enb_pwm | 0x0A;
84 twl_i2c_write_u8(TWL4030_MODULE_INTBR,
85 mux_pwm, TWL_INTBR_PMBR1);
86 twl_i2c_write_u8(TWL4030_MODULE_INTBR,
87 enb_pwm, TWL_INTBR_GPBR1);
88 }
89
90 c = ((50 * (100 - level)) / 100) + 1;
91 twl_i2c_write_u8(TWL4030_MODULE_PWM1, 0x7F, TWL_LED_PWMOFF);
92 twl_i2c_write_u8(TWL4030_MODULE_PWM1, c, TWL_LED_PWMON);
93
94 return 0;
95}
96
97static struct omap_dss_device zoom_lcd_device = {
98 .name = "lcd",
99 .driver_name = "NEC_8048_panel",
100 .type = OMAP_DISPLAY_TYPE_DPI,
101 .phy.dpi.data_lines = 24,
102 .platform_enable = zoom_panel_enable_lcd,
103 .platform_disable = zoom_panel_disable_lcd,
104 .max_backlight_level = 100,
105 .set_backlight = zoom_set_bl_intensity,
106};
107
108static struct omap_dss_device *zoom_dss_devices[] = {
109 &zoom_lcd_device,
110};
111
112static struct omap_dss_board_info zoom_dss_data = {
113 .num_devices = ARRAY_SIZE(zoom_dss_devices),
114 .devices = zoom_dss_devices,
115 .default_device = &zoom_lcd_device,
116};
117
118static struct omap2_mcspi_device_config dss_lcd_mcspi_config = {
119 .turbo_mode = 1,
120 .single_channel = 1, /* 0: slave, 1: master */
121};
122
123static struct spi_board_info nec_8048_spi_board_info[] __initdata = {
124 [0] = {
125 .modalias = "nec_8048_spi",
126 .bus_num = 1,
127 .chip_select = 2,
128 .max_speed_hz = 375000,
129 .controller_data = &dss_lcd_mcspi_config,
130 },
131};
132
133void __init zoom_display_init(void)
134{
135 omap_display_init(&zoom_dss_data);
136 spi_register_board_info(nec_8048_spi_board_info,
137 ARRAY_SIZE(nec_8048_spi_board_info));
138 zoom_lcd_panel_init();
139}
140