| .. | .. |
|---|
| 172 | 172 | int num_modes; |
|---|
| 173 | 173 | |
|---|
| 174 | 174 | struct regulator *lcd_pwr; |
|---|
| 175 | + int lcd_pwr_enabled; |
|---|
| 175 | 176 | }; |
|---|
| 176 | 177 | |
|---|
| 177 | 178 | static const struct platform_device_id imxfb_devtype[] = { |
|---|
| .. | .. |
|---|
| 566 | 567 | return 0; |
|---|
| 567 | 568 | } |
|---|
| 568 | 569 | |
|---|
| 569 | | -static struct fb_ops imxfb_ops = { |
|---|
| 570 | +static const struct fb_ops imxfb_ops = { |
|---|
| 570 | 571 | .owner = THIS_MODULE, |
|---|
| 571 | 572 | .fb_check_var = imxfb_check_var, |
|---|
| 572 | 573 | .fb_set_par = imxfb_set_par, |
|---|
| .. | .. |
|---|
| 801 | 802 | return FB_BLANK_UNBLANK; |
|---|
| 802 | 803 | } |
|---|
| 803 | 804 | |
|---|
| 805 | +static int imxfb_regulator_set(struct imxfb_info *fbi, int enable) |
|---|
| 806 | +{ |
|---|
| 807 | + int ret; |
|---|
| 808 | + |
|---|
| 809 | + if (enable == fbi->lcd_pwr_enabled) |
|---|
| 810 | + return 0; |
|---|
| 811 | + |
|---|
| 812 | + if (enable) |
|---|
| 813 | + ret = regulator_enable(fbi->lcd_pwr); |
|---|
| 814 | + else |
|---|
| 815 | + ret = regulator_disable(fbi->lcd_pwr); |
|---|
| 816 | + |
|---|
| 817 | + if (ret == 0) |
|---|
| 818 | + fbi->lcd_pwr_enabled = enable; |
|---|
| 819 | + |
|---|
| 820 | + return ret; |
|---|
| 821 | +} |
|---|
| 822 | + |
|---|
| 804 | 823 | static int imxfb_lcd_set_power(struct lcd_device *lcddev, int power) |
|---|
| 805 | 824 | { |
|---|
| 806 | 825 | struct imxfb_info *fbi = dev_get_drvdata(&lcddev->dev); |
|---|
| 807 | 826 | |
|---|
| 808 | | - if (!IS_ERR(fbi->lcd_pwr)) { |
|---|
| 809 | | - if (power == FB_BLANK_UNBLANK) |
|---|
| 810 | | - return regulator_enable(fbi->lcd_pwr); |
|---|
| 811 | | - else |
|---|
| 812 | | - return regulator_disable(fbi->lcd_pwr); |
|---|
| 813 | | - } |
|---|
| 827 | + if (!IS_ERR(fbi->lcd_pwr)) |
|---|
| 828 | + return imxfb_regulator_set(fbi, power == FB_BLANK_UNBLANK); |
|---|
| 814 | 829 | |
|---|
| 815 | 830 | return 0; |
|---|
| 816 | 831 | } |
|---|
| .. | .. |
|---|
| 974 | 989 | } |
|---|
| 975 | 990 | |
|---|
| 976 | 991 | fbi->map_size = PAGE_ALIGN(info->fix.smem_len); |
|---|
| 977 | | - info->screen_base = dma_alloc_wc(&pdev->dev, fbi->map_size, |
|---|
| 978 | | - &fbi->map_dma, GFP_KERNEL); |
|---|
| 979 | | - |
|---|
| 980 | | - if (!info->screen_base) { |
|---|
| 981 | | - dev_err(&pdev->dev, "Failed to allocate video RAM: %d\n", ret); |
|---|
| 992 | + info->screen_buffer = dma_alloc_wc(&pdev->dev, fbi->map_size, |
|---|
| 993 | + &fbi->map_dma, GFP_KERNEL); |
|---|
| 994 | + if (!info->screen_buffer) { |
|---|
| 995 | + dev_err(&pdev->dev, "Failed to allocate video RAM\n"); |
|---|
| 982 | 996 | ret = -ENOMEM; |
|---|
| 983 | 997 | goto failed_map; |
|---|
| 984 | 998 | } |
|---|
| .. | .. |
|---|
| 1018 | 1032 | } |
|---|
| 1019 | 1033 | |
|---|
| 1020 | 1034 | fbi->lcd_pwr = devm_regulator_get(&pdev->dev, "lcd"); |
|---|
| 1021 | | - if (IS_ERR(fbi->lcd_pwr) && (PTR_ERR(fbi->lcd_pwr) == -EPROBE_DEFER)) { |
|---|
| 1035 | + if (PTR_ERR(fbi->lcd_pwr) == -EPROBE_DEFER) { |
|---|
| 1022 | 1036 | ret = -EPROBE_DEFER; |
|---|
| 1023 | 1037 | goto failed_lcd; |
|---|
| 1024 | 1038 | } |
|---|
| .. | .. |
|---|
| 1046 | 1060 | if (pdata && pdata->exit) |
|---|
| 1047 | 1061 | pdata->exit(fbi->pdev); |
|---|
| 1048 | 1062 | failed_platform_init: |
|---|
| 1049 | | - dma_free_wc(&pdev->dev, fbi->map_size, info->screen_base, |
|---|
| 1063 | + dma_free_wc(&pdev->dev, fbi->map_size, info->screen_buffer, |
|---|
| 1050 | 1064 | fbi->map_dma); |
|---|
| 1051 | 1065 | failed_map: |
|---|
| 1052 | 1066 | iounmap(fbi->regs); |
|---|
| .. | .. |
|---|
| 1077 | 1091 | pdata = dev_get_platdata(&pdev->dev); |
|---|
| 1078 | 1092 | if (pdata && pdata->exit) |
|---|
| 1079 | 1093 | pdata->exit(fbi->pdev); |
|---|
| 1080 | | - dma_free_wc(&pdev->dev, fbi->map_size, info->screen_base, |
|---|
| 1094 | + dma_free_wc(&pdev->dev, fbi->map_size, info->screen_buffer, |
|---|
| 1081 | 1095 | fbi->map_dma); |
|---|
| 1082 | 1096 | iounmap(fbi->regs); |
|---|
| 1083 | 1097 | release_mem_region(res->start, resource_size(res)); |
|---|