]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/meta-ti-glsdk.git/blob - recipes-kernel/linux/linux-ti33x-psp-3.2/beaglebone/0015-beaglebone-enable-PWM-for-lcd-backlight-backlight-is.patch
linux-ti33x-psp 3.2: rebase onto latest PSP
[glsdk/meta-ti-glsdk.git] / recipes-kernel / linux / linux-ti33x-psp-3.2 / beaglebone / 0015-beaglebone-enable-PWM-for-lcd-backlight-backlight-is.patch
1 From 46c7fc0ed1ad0e5da431d15a4333a4fb5bb0ff0e Mon Sep 17 00:00:00 2001
2 From: Koen Kooi <koen@dominion.thruhere.net>
3 Date: Tue, 31 Jan 2012 17:02:10 +0100
4 Subject: [PATCH 15/26] beaglebone: enable PWM for lcd backlight <- backlight
5  is inverted
7 Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
8 ---
9  arch/arm/mach-omap2/board-am335xevm.c |   51 +++++++++++++++++++++++++++------
10  1 file changed, 42 insertions(+), 9 deletions(-)
12 diff --git a/arch/arm/mach-omap2/board-am335xevm.c b/arch/arm/mach-omap2/board-am335xevm.c
13 index 3c67e94..23b59c2 100644
14 --- a/arch/arm/mach-omap2/board-am335xevm.c
15 +++ b/arch/arm/mach-omap2/board-am335xevm.c
16 @@ -179,6 +179,16 @@ static const struct display_panel bbtoys7_panel = {
17         COLOR_ACTIVE,
18  };
19  
20 +#define BBTOYS7LCD_PWM_DEVICE_ID   "ehrpwm.1:0"
21 +
22 +static struct platform_pwm_backlight_data bbtoys7lcd_backlight_data = {
23 +       .pwm_id         = BBTOYS7LCD_PWM_DEVICE_ID,
24 +       .ch             = -1,
25 +       .max_brightness = AM335X_BACKLIGHT_MAX_BRIGHTNESS,
26 +       .dft_brightness = AM335X_BACKLIGHT_DEFAULT_BRIGHTNESS,
27 +       .pwm_period_ns  = AM335X_PWM_PERIOD_NANO_SECONDS,
28 +};
29 +
30  static struct lcd_ctrl_config bbtoys7_cfg = {
31         &bbtoys7_panel,
32         .ac_bias                = 255,
33 @@ -599,9 +609,9 @@ static struct pinmux_config bbtoys7_pin_mux[] = {
34         {"lcd_vsync.lcd_vsync",         OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT},
35         {"lcd_hsync.lcd_hsync",         OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT},
36         {"lcd_pclk.lcd_pclk",           OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT},
37 -       {"lcd_ac_bias_en.lcd_ac_bias_en", OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT}, 
38 -       {"gpmc_a2.gpio1_18", OMAP_MUX_MODE7 | AM33XX_PIN_OUTPUT}, // Backlight
39 +       {"lcd_ac_bias_en.lcd_ac_bias_en", OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT},
40         {"ecap0_in_pwm0_out.gpio0_7", OMAP_MUX_MODE7 | AM33XX_PIN_OUTPUT}, // AVDD_EN
41 +       {"gpmc_a2.ehrpwm1A", OMAP_MUX_MODE6 | AM33XX_PIN_OUTPUT}, // Backlight
42         {NULL, 0},
43  };
44  
45 @@ -1134,6 +1144,7 @@ static struct pinmux_config ecap0_pin_mux[] = {
46         {NULL, 0},
47  };
48  
49 +static int ehrpwm_backlight_enable;
50  static int backlight_enable;
51  
52  #define AM335XEVM_WLAN_PMENA_GPIO      GPIO_TO_PIN(1, 30)
53 @@ -1216,6 +1227,30 @@ static int __init ecap0_init(void)
54  }
55  late_initcall(ecap0_init);
56  
57 +static void enable_ehrpwm1(int evm_id, int profile)
58 +{
59 +       ehrpwm_backlight_enable = true;
60 +}
61 +
62 +/* Setup pwm-backlight for bbtoys7lcd */
63 +static struct platform_device bbtoys7lcd_backlight = {
64 +       .name           = "pwm-backlight",
65 +       .id             = -1,
66 +       .dev            = {
67 +               .platform_data  = &bbtoys7lcd_backlight_data,
68 +       }
69 +};
70 +
71 +static int __init ehrpwm1_init(void)
72 +{
73 +       int status = 0;
74 +       if (ehrpwm_backlight_enable) {
75 +               platform_device_register(&bbtoys7lcd_backlight);
76 +       }
77 +       return status;
78 +}
79 +late_initcall(ehrpwm1_init);
80 +
81  static int __init conf_disp_pll(int rate)
82  {
83         struct clk *disp_pll;
84 @@ -1250,11 +1285,12 @@ static void lcdc_init(int evm_id, int profile)
85  }
86  
87  #define BEAGLEBONE_LCD_AVDD_EN GPIO_TO_PIN(0, 7)
88 -#define BEAGLEBONE_LCD_BL GPIO_TO_PIN(1, 18)
89  
90  static void bbtoys7lcd_init(int evm_id, int profile)
91  {
92         setup_pin_mux(bbtoys7_pin_mux);
93 +       gpio_request(BEAGLEBONE_LCD_AVDD_EN, "BONE_LCD_AVDD_EN");
94 +       gpio_direction_output(BEAGLEBONE_LCD_AVDD_EN, 1);
95  
96         // we are being stupid and setting pixclock from here instead of da8xx-fb.c
97         if (conf_disp_pll(300000000)) {
98 @@ -1265,12 +1301,7 @@ static void bbtoys7lcd_init(int evm_id, int profile)
99         
100         if (am33xx_register_lcdc(&bbtoys7_pdata))
101                 pr_info("Failed to register Beagleboardtoys 7\" LCD cape device\n");
102 -       
103 -       gpio_request(BEAGLEBONE_LCD_BL, "BONE_LCD_BL");
104 -       gpio_direction_output(BEAGLEBONE_LCD_BL, 1);
105 -       gpio_request(BEAGLEBONE_LCD_AVDD_EN, "BONE_LCD_AVDD_EN");
106 -       gpio_direction_output(BEAGLEBONE_LCD_AVDD_EN, 1);
108 +               
109         return;
110  }
111  
112 @@ -1831,6 +1862,8 @@ static void beaglebone_cape_setup(struct memory_accessor *mem_acc, void *context
113                 bbtoys7lcd_init(0,0);
114                 pr_info("BeagleBone cape: initializing LCD cape touchscreen\n");
115                 tsc_init(0,0);
116 +               pr_info("BeagleBone cape: Registering PWM backlight for LCD cape\n");
117 +               enable_ehrpwm1(0,0);
118                 beaglebone_tsadcpins_free = 0;
119         }
120         
121 -- 
122 1.7.9.5