Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

video: amba-clcd: Decomission Versatile and Nomadik

These board families are now handled in the DRM subsystem
where we can have reusable panel drivers and some other
stuff. The PL111 there is now the driver used in the
defconfig for Versatile and Nomadik so no need to keep
this code around.

There are a few minor machines in arch/arm/ such as
mach-netx still using the old driver, so we need to keep
the core fbdev driver around for some time.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Cc: Russell King <linux@armlinux.org.uk>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>

authored by

Linus Walleij and committed by
Bartlomiej Zolnierkiewicz
a6fdbd55 9dc20113

+2 -996
-8
drivers/video/fbdev/Kconfig
··· 293 293 here and read <file:Documentation/kbuild/modules.txt>. The module 294 294 will be called amba-clcd. 295 295 296 - # Helper logic selected only by the ARM Versatile platform family. 297 - config PLAT_VERSATILE_CLCD 298 - def_bool ARCH_VERSATILE || ARCH_REALVIEW || ARCH_VEXPRESS || ARCH_INTEGRATOR 299 - depends on ARM 300 - depends on FB_ARMCLCD && FB=y 301 - select REGMAP 302 - select MFD_SYSCON 303 - 304 296 config FB_ACORN 305 297 bool "Acorn VIDC support" 306 298 depends on (FB = y) && ARM && ARCH_ACORN
-2
drivers/video/fbdev/Makefile
··· 76 76 obj-$(CONFIG_FB_PVR2) += pvr2fb.o 77 77 obj-$(CONFIG_FB_VOODOO1) += sstfb.o 78 78 obj-$(CONFIG_FB_ARMCLCD) += amba-clcd.o 79 - obj-$(CONFIG_ARCH_NOMADIK) += amba-clcd-nomadik.o 80 - obj-$(CONFIG_PLAT_VERSATILE_CLCD) += amba-clcd-versatile.o 81 79 obj-$(CONFIG_FB_GOLDFISH) += goldfishfb.o 82 80 obj-$(CONFIG_FB_68328) += 68328fb.o 83 81 obj-$(CONFIG_FB_GBE) += gbefb.o
-251
drivers/video/fbdev/amba-clcd-nomadik.c
··· 1 - #include <linux/amba/bus.h> 2 - #include <linux/amba/clcd.h> 3 - #include <linux/gpio/consumer.h> 4 - #include <linux/of.h> 5 - #include <linux/of_graph.h> 6 - #include <linux/delay.h> 7 - #include <linux/bitops.h> 8 - #include <linux/mfd/syscon.h> 9 - #include <linux/regmap.h> 10 - 11 - #include "amba-clcd-nomadik.h" 12 - 13 - static struct gpio_desc *grestb; 14 - static struct gpio_desc *scen; 15 - static struct gpio_desc *scl; 16 - static struct gpio_desc *sda; 17 - 18 - static u8 tpg110_readwrite_reg(bool write, u8 address, u8 outval) 19 - { 20 - int i; 21 - u8 inval = 0; 22 - 23 - /* Assert SCEN */ 24 - gpiod_set_value_cansleep(scen, 1); 25 - ndelay(150); 26 - /* Hammer out the address */ 27 - for (i = 5; i >= 0; i--) { 28 - if (address & BIT(i)) 29 - gpiod_set_value_cansleep(sda, 1); 30 - else 31 - gpiod_set_value_cansleep(sda, 0); 32 - ndelay(150); 33 - /* Send an SCL pulse */ 34 - gpiod_set_value_cansleep(scl, 1); 35 - ndelay(160); 36 - gpiod_set_value_cansleep(scl, 0); 37 - ndelay(160); 38 - } 39 - 40 - if (write) { 41 - /* WRITE */ 42 - gpiod_set_value_cansleep(sda, 0); 43 - } else { 44 - /* READ */ 45 - gpiod_set_value_cansleep(sda, 1); 46 - } 47 - ndelay(150); 48 - /* Send an SCL pulse */ 49 - gpiod_set_value_cansleep(scl, 1); 50 - ndelay(160); 51 - gpiod_set_value_cansleep(scl, 0); 52 - ndelay(160); 53 - 54 - if (!write) 55 - /* HiZ turn-around cycle */ 56 - gpiod_direction_input(sda); 57 - ndelay(150); 58 - /* Send an SCL pulse */ 59 - gpiod_set_value_cansleep(scl, 1); 60 - ndelay(160); 61 - gpiod_set_value_cansleep(scl, 0); 62 - ndelay(160); 63 - 64 - /* Hammer in/out the data */ 65 - for (i = 7; i >= 0; i--) { 66 - int value; 67 - 68 - if (write) { 69 - value = !!(outval & BIT(i)); 70 - gpiod_set_value_cansleep(sda, value); 71 - } else { 72 - value = gpiod_get_value(sda); 73 - if (value) 74 - inval |= BIT(i); 75 - } 76 - ndelay(150); 77 - /* Send an SCL pulse */ 78 - gpiod_set_value_cansleep(scl, 1); 79 - ndelay(160); 80 - gpiod_set_value_cansleep(scl, 0); 81 - ndelay(160); 82 - } 83 - 84 - gpiod_direction_output(sda, 0); 85 - /* Deassert SCEN */ 86 - gpiod_set_value_cansleep(scen, 0); 87 - /* Satisfies SCEN pulse width */ 88 - udelay(1); 89 - 90 - return inval; 91 - } 92 - 93 - static u8 tpg110_read_reg(u8 address) 94 - { 95 - return tpg110_readwrite_reg(false, address, 0); 96 - } 97 - 98 - static void tpg110_write_reg(u8 address, u8 outval) 99 - { 100 - tpg110_readwrite_reg(true, address, outval); 101 - } 102 - 103 - static void tpg110_startup(struct device *dev) 104 - { 105 - u8 val; 106 - 107 - dev_info(dev, "TPG110 display enable\n"); 108 - /* De-assert the reset signal */ 109 - gpiod_set_value_cansleep(grestb, 0); 110 - mdelay(1); 111 - dev_info(dev, "de-asserted GRESTB\n"); 112 - 113 - /* Test display communication */ 114 - tpg110_write_reg(0x00, 0x55); 115 - val = tpg110_read_reg(0x00); 116 - if (val == 0x55) 117 - dev_info(dev, "passed communication test\n"); 118 - val = tpg110_read_reg(0x01); 119 - dev_info(dev, "TPG110 chip ID: %d version: %d\n", 120 - val>>4, val&0x0f); 121 - 122 - /* Show display resolution */ 123 - val = tpg110_read_reg(0x02); 124 - val &= 7; 125 - switch (val) { 126 - case 0x0: 127 - dev_info(dev, "IN 400x240 RGB -> OUT 800x480 RGB (dual scan)"); 128 - break; 129 - case 0x1: 130 - dev_info(dev, "IN 480x272 RGB -> OUT 800x480 RGB (dual scan)"); 131 - break; 132 - case 0x4: 133 - dev_info(dev, "480x640 RGB"); 134 - break; 135 - case 0x5: 136 - dev_info(dev, "480x272 RGB"); 137 - break; 138 - case 0x6: 139 - dev_info(dev, "640x480 RGB"); 140 - break; 141 - case 0x7: 142 - dev_info(dev, "800x480 RGB"); 143 - break; 144 - default: 145 - dev_info(dev, "ILLEGAL RESOLUTION"); 146 - break; 147 - } 148 - 149 - val = tpg110_read_reg(0x03); 150 - dev_info(dev, "resolution is controlled by %s\n", 151 - (val & BIT(7)) ? "software" : "hardware"); 152 - } 153 - 154 - static void tpg110_enable(struct clcd_fb *fb) 155 - { 156 - struct device *dev = &fb->dev->dev; 157 - static bool startup; 158 - u8 val; 159 - 160 - if (!startup) { 161 - tpg110_startup(dev); 162 - startup = true; 163 - } 164 - 165 - /* Take chip out of standby */ 166 - val = tpg110_read_reg(0x03); 167 - val |= BIT(0); 168 - tpg110_write_reg(0x03, val); 169 - } 170 - 171 - static void tpg110_disable(struct clcd_fb *fb) 172 - { 173 - u8 val; 174 - 175 - dev_info(&fb->dev->dev, "TPG110 display disable\n"); 176 - val = tpg110_read_reg(0x03); 177 - /* Put into standby */ 178 - val &= ~BIT(0); 179 - tpg110_write_reg(0x03, val); 180 - } 181 - 182 - static void tpg110_init(struct device *dev, struct device_node *np, 183 - struct clcd_board *board) 184 - { 185 - dev_info(dev, "TPG110 display init\n"); 186 - 187 - /* This asserts the GRESTB signal, putting the display into reset */ 188 - grestb = devm_fwnode_get_gpiod_from_child(dev, "grestb", &np->fwnode, 189 - GPIOD_OUT_HIGH, "grestb"); 190 - if (IS_ERR(grestb)) { 191 - dev_err(dev, "no GRESTB GPIO\n"); 192 - return; 193 - } 194 - scen = devm_fwnode_get_gpiod_from_child(dev, "scen", &np->fwnode, 195 - GPIOD_OUT_LOW, "scen"); 196 - if (IS_ERR(scen)) { 197 - dev_err(dev, "no SCEN GPIO\n"); 198 - return; 199 - } 200 - scl = devm_fwnode_get_gpiod_from_child(dev, "scl", &np->fwnode, 201 - GPIOD_OUT_LOW, "scl"); 202 - if (IS_ERR(scl)) { 203 - dev_err(dev, "no SCL GPIO\n"); 204 - return; 205 - } 206 - sda = devm_fwnode_get_gpiod_from_child(dev, "sda", &np->fwnode, 207 - GPIOD_OUT_LOW, "sda"); 208 - if (IS_ERR(sda)) { 209 - dev_err(dev, "no SDA GPIO\n"); 210 - return; 211 - } 212 - board->enable = tpg110_enable; 213 - board->disable = tpg110_disable; 214 - } 215 - 216 - int nomadik_clcd_init_panel(struct clcd_fb *fb, struct device_node *panel) 217 - { 218 - if (of_device_is_compatible(panel, "tpo,tpg110")) 219 - tpg110_init(&fb->dev->dev, panel, fb->board); 220 - else 221 - dev_info(&fb->dev->dev, "unknown panel\n"); 222 - 223 - /* Unknown panel, fall through */ 224 - return 0; 225 - } 226 - EXPORT_SYMBOL_GPL(nomadik_clcd_init_panel); 227 - 228 - #define PMU_CTRL_OFFSET 0x0000 229 - #define PMU_CTRL_LCDNDIF BIT(26) 230 - 231 - int nomadik_clcd_init_board(struct amba_device *adev, 232 - struct clcd_board *board) 233 - { 234 - struct regmap *pmu_regmap; 235 - 236 - dev_info(&adev->dev, "Nomadik CLCD board init\n"); 237 - pmu_regmap = 238 - syscon_regmap_lookup_by_compatible("stericsson,nomadik-pmu"); 239 - if (IS_ERR(pmu_regmap)) { 240 - dev_err(&adev->dev, "could not find PMU syscon regmap\n"); 241 - return PTR_ERR(pmu_regmap); 242 - } 243 - regmap_update_bits(pmu_regmap, 244 - PMU_CTRL_OFFSET, 245 - PMU_CTRL_LCDNDIF, 246 - 0); 247 - dev_info(&adev->dev, "set PMU mux to CLCD mode\n"); 248 - 249 - return 0; 250 - } 251 - EXPORT_SYMBOL_GPL(nomadik_clcd_init_board);
-24
drivers/video/fbdev/amba-clcd-nomadik.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef _AMBA_CLCD_NOMADIK_H 3 - #define _AMBA_CLCD_NOMADIK_H 4 - 5 - #include <linux/amba/bus.h> 6 - 7 - #ifdef CONFIG_ARCH_NOMADIK 8 - int nomadik_clcd_init_board(struct amba_device *adev, 9 - struct clcd_board *board); 10 - int nomadik_clcd_init_panel(struct clcd_fb *fb, struct device_node *panel); 11 - #else 12 - static inline int nomadik_clcd_init_board(struct amba_device *adev, 13 - struct clcd_board *board) 14 - { 15 - return 0; 16 - } 17 - static inline int nomadik_clcd_init_panel(struct clcd_fb *fb, 18 - struct device_node *panel) 19 - { 20 - return 0; 21 - } 22 - #endif 23 - 24 - #endif /* inclusion guard */
-567
drivers/video/fbdev/amba-clcd-versatile.c
··· 1 - #include <linux/device.h> 2 - #include <linux/dma-mapping.h> 3 - #include <linux/amba/bus.h> 4 - #include <linux/amba/clcd.h> 5 - #include <linux/platform_data/video-clcd-versatile.h> 6 - #include <linux/of.h> 7 - #include <linux/of_graph.h> 8 - #include <linux/regmap.h> 9 - #include <linux/mfd/syscon.h> 10 - #include <linux/bitops.h> 11 - #include "amba-clcd-versatile.h" 12 - 13 - static struct clcd_panel vga = { 14 - .mode = { 15 - .name = "VGA", 16 - .refresh = 60, 17 - .xres = 640, 18 - .yres = 480, 19 - .pixclock = 39721, 20 - .left_margin = 40, 21 - .right_margin = 24, 22 - .upper_margin = 32, 23 - .lower_margin = 11, 24 - .hsync_len = 96, 25 - .vsync_len = 2, 26 - .sync = 0, 27 - .vmode = FB_VMODE_NONINTERLACED, 28 - }, 29 - .width = -1, 30 - .height = -1, 31 - .tim2 = TIM2_BCD | TIM2_IPC, 32 - .cntl = CNTL_LCDTFT | CNTL_BGR | CNTL_LCDVCOMP(1), 33 - .caps = CLCD_CAP_5551 | CLCD_CAP_565 | CLCD_CAP_888, 34 - .bpp = 16, 35 - }; 36 - 37 - static struct clcd_panel xvga = { 38 - .mode = { 39 - .name = "XVGA", 40 - .refresh = 60, 41 - .xres = 1024, 42 - .yres = 768, 43 - .pixclock = 15748, 44 - .left_margin = 152, 45 - .right_margin = 48, 46 - .upper_margin = 23, 47 - .lower_margin = 3, 48 - .hsync_len = 104, 49 - .vsync_len = 4, 50 - .sync = 0, 51 - .vmode = FB_VMODE_NONINTERLACED, 52 - }, 53 - .width = -1, 54 - .height = -1, 55 - .tim2 = TIM2_BCD | TIM2_IPC, 56 - .cntl = CNTL_LCDTFT | CNTL_BGR | CNTL_LCDVCOMP(1), 57 - .caps = CLCD_CAP_5551 | CLCD_CAP_565 | CLCD_CAP_888, 58 - .bpp = 16, 59 - }; 60 - 61 - /* Sanyo TM38QV67A02A - 3.8 inch QVGA (320x240) Color TFT */ 62 - static struct clcd_panel sanyo_tm38qv67a02a = { 63 - .mode = { 64 - .name = "Sanyo TM38QV67A02A", 65 - .refresh = 116, 66 - .xres = 320, 67 - .yres = 240, 68 - .pixclock = 100000, 69 - .left_margin = 6, 70 - .right_margin = 6, 71 - .upper_margin = 5, 72 - .lower_margin = 5, 73 - .hsync_len = 6, 74 - .vsync_len = 6, 75 - .sync = 0, 76 - .vmode = FB_VMODE_NONINTERLACED, 77 - }, 78 - .width = -1, 79 - .height = -1, 80 - .tim2 = TIM2_BCD, 81 - .cntl = CNTL_LCDTFT | CNTL_BGR | CNTL_LCDVCOMP(1), 82 - .caps = CLCD_CAP_5551, 83 - .bpp = 16, 84 - }; 85 - 86 - static struct clcd_panel sanyo_2_5_in = { 87 - .mode = { 88 - .name = "Sanyo QVGA Portrait", 89 - .refresh = 116, 90 - .xres = 240, 91 - .yres = 320, 92 - .pixclock = 100000, 93 - .left_margin = 20, 94 - .right_margin = 10, 95 - .upper_margin = 2, 96 - .lower_margin = 2, 97 - .hsync_len = 10, 98 - .vsync_len = 2, 99 - .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 100 - .vmode = FB_VMODE_NONINTERLACED, 101 - }, 102 - .width = -1, 103 - .height = -1, 104 - .tim2 = TIM2_IVS | TIM2_IHS | TIM2_IPC, 105 - .cntl = CNTL_LCDTFT | CNTL_BGR | CNTL_LCDVCOMP(1), 106 - .caps = CLCD_CAP_5551, 107 - .bpp = 16, 108 - }; 109 - 110 - /* Epson L2F50113T00 - 2.2 inch 176x220 Color TFT */ 111 - static struct clcd_panel epson_l2f50113t00 = { 112 - .mode = { 113 - .name = "Epson L2F50113T00", 114 - .refresh = 390, 115 - .xres = 176, 116 - .yres = 220, 117 - .pixclock = 62500, 118 - .left_margin = 3, 119 - .right_margin = 2, 120 - .upper_margin = 1, 121 - .lower_margin = 0, 122 - .hsync_len = 3, 123 - .vsync_len = 2, 124 - .sync = 0, 125 - .vmode = FB_VMODE_NONINTERLACED, 126 - }, 127 - .width = -1, 128 - .height = -1, 129 - .tim2 = TIM2_BCD | TIM2_IPC, 130 - .cntl = CNTL_LCDTFT | CNTL_BGR | CNTL_LCDVCOMP(1), 131 - .caps = CLCD_CAP_5551, 132 - .bpp = 16, 133 - }; 134 - 135 - static struct clcd_panel *panels[] = { 136 - &vga, 137 - &xvga, 138 - &sanyo_tm38qv67a02a, 139 - &sanyo_2_5_in, 140 - &epson_l2f50113t00, 141 - }; 142 - 143 - struct clcd_panel *versatile_clcd_get_panel(const char *name) 144 - { 145 - int i; 146 - 147 - for (i = 0; i < ARRAY_SIZE(panels); i++) 148 - if (strcmp(panels[i]->mode.name, name) == 0) 149 - break; 150 - 151 - if (i < ARRAY_SIZE(panels)) 152 - return panels[i]; 153 - 154 - pr_err("CLCD: couldn't get parameters for panel %s\n", name); 155 - 156 - return NULL; 157 - } 158 - 159 - int versatile_clcd_setup_dma(struct clcd_fb *fb, unsigned long framesize) 160 - { 161 - dma_addr_t dma; 162 - 163 - fb->fb.screen_base = dma_alloc_wc(&fb->dev->dev, framesize, &dma, 164 - GFP_KERNEL); 165 - if (!fb->fb.screen_base) { 166 - pr_err("CLCD: unable to map framebuffer\n"); 167 - return -ENOMEM; 168 - } 169 - 170 - fb->fb.fix.smem_start = dma; 171 - fb->fb.fix.smem_len = framesize; 172 - 173 - return 0; 174 - } 175 - 176 - int versatile_clcd_mmap_dma(struct clcd_fb *fb, struct vm_area_struct *vma) 177 - { 178 - return dma_mmap_wc(&fb->dev->dev, vma, fb->fb.screen_base, 179 - fb->fb.fix.smem_start, fb->fb.fix.smem_len); 180 - } 181 - 182 - void versatile_clcd_remove_dma(struct clcd_fb *fb) 183 - { 184 - dma_free_wc(&fb->dev->dev, fb->fb.fix.smem_len, fb->fb.screen_base, 185 - fb->fb.fix.smem_start); 186 - } 187 - 188 - #ifdef CONFIG_OF 189 - 190 - static struct regmap *versatile_syscon_map; 191 - static struct regmap *versatile_ib2_map; 192 - 193 - /* 194 - * We detect the different syscon types from the compatible strings. 195 - */ 196 - enum versatile_clcd { 197 - INTEGRATOR_CLCD_CM, 198 - VERSATILE_CLCD, 199 - REALVIEW_CLCD_EB, 200 - REALVIEW_CLCD_PB1176, 201 - REALVIEW_CLCD_PB11MP, 202 - REALVIEW_CLCD_PBA8, 203 - REALVIEW_CLCD_PBX, 204 - }; 205 - 206 - static const struct of_device_id versatile_clcd_of_match[] = { 207 - { 208 - .compatible = "arm,core-module-integrator", 209 - .data = (void *)INTEGRATOR_CLCD_CM, 210 - }, 211 - { 212 - .compatible = "arm,versatile-sysreg", 213 - .data = (void *)VERSATILE_CLCD, 214 - }, 215 - { 216 - .compatible = "arm,realview-eb-syscon", 217 - .data = (void *)REALVIEW_CLCD_EB, 218 - }, 219 - { 220 - .compatible = "arm,realview-pb1176-syscon", 221 - .data = (void *)REALVIEW_CLCD_PB1176, 222 - }, 223 - { 224 - .compatible = "arm,realview-pb11mp-syscon", 225 - .data = (void *)REALVIEW_CLCD_PB11MP, 226 - }, 227 - { 228 - .compatible = "arm,realview-pba8-syscon", 229 - .data = (void *)REALVIEW_CLCD_PBA8, 230 - }, 231 - { 232 - .compatible = "arm,realview-pbx-syscon", 233 - .data = (void *)REALVIEW_CLCD_PBX, 234 - }, 235 - {}, 236 - }; 237 - 238 - /* 239 - * Core module CLCD control on the Integrator/CP, bits 240 - * 8 thru 19 of the CM_CONTROL register controls a bunch 241 - * of CLCD settings. 242 - */ 243 - #define INTEGRATOR_HDR_CTRL_OFFSET 0x0C 244 - #define INTEGRATOR_CLCD_LCDBIASEN BIT(8) 245 - #define INTEGRATOR_CLCD_LCDBIASUP BIT(9) 246 - #define INTEGRATOR_CLCD_LCDBIASDN BIT(10) 247 - /* Bits 11,12,13 controls the LCD type */ 248 - #define INTEGRATOR_CLCD_LCDMUX_MASK (BIT(11)|BIT(12)|BIT(13)) 249 - #define INTEGRATOR_CLCD_LCDMUX_LCD24 BIT(11) 250 - #define INTEGRATOR_CLCD_LCDMUX_VGA565 BIT(12) 251 - #define INTEGRATOR_CLCD_LCDMUX_SHARP (BIT(11)|BIT(12)) 252 - #define INTEGRATOR_CLCD_LCDMUX_VGA555 BIT(13) 253 - #define INTEGRATOR_CLCD_LCDMUX_VGA24 (BIT(11)|BIT(12)|BIT(13)) 254 - #define INTEGRATOR_CLCD_LCD0_EN BIT(14) 255 - #define INTEGRATOR_CLCD_LCD1_EN BIT(15) 256 - /* R/L flip on Sharp */ 257 - #define INTEGRATOR_CLCD_LCD_STATIC1 BIT(16) 258 - /* U/D flip on Sharp */ 259 - #define INTEGRATOR_CLCD_LCD_STATIC2 BIT(17) 260 - /* No connection on Sharp */ 261 - #define INTEGRATOR_CLCD_LCD_STATIC BIT(18) 262 - /* 0 = 24bit VGA, 1 = 18bit VGA */ 263 - #define INTEGRATOR_CLCD_LCD_N24BITEN BIT(19) 264 - 265 - #define INTEGRATOR_CLCD_MASK (INTEGRATOR_CLCD_LCDBIASEN | \ 266 - INTEGRATOR_CLCD_LCDBIASUP | \ 267 - INTEGRATOR_CLCD_LCDBIASDN | \ 268 - INTEGRATOR_CLCD_LCDMUX_MASK | \ 269 - INTEGRATOR_CLCD_LCD0_EN | \ 270 - INTEGRATOR_CLCD_LCD1_EN | \ 271 - INTEGRATOR_CLCD_LCD_STATIC1 | \ 272 - INTEGRATOR_CLCD_LCD_STATIC2 | \ 273 - INTEGRATOR_CLCD_LCD_STATIC | \ 274 - INTEGRATOR_CLCD_LCD_N24BITEN) 275 - 276 - static void integrator_clcd_enable(struct clcd_fb *fb) 277 - { 278 - struct fb_var_screeninfo *var = &fb->fb.var; 279 - u32 val; 280 - 281 - dev_info(&fb->dev->dev, "enable Integrator CLCD connectors\n"); 282 - 283 - /* FIXME: really needed? */ 284 - val = INTEGRATOR_CLCD_LCD_STATIC1 | INTEGRATOR_CLCD_LCD_STATIC2 | 285 - INTEGRATOR_CLCD_LCD0_EN | INTEGRATOR_CLCD_LCD1_EN; 286 - if (var->bits_per_pixel <= 8 || 287 - (var->bits_per_pixel == 16 && var->green.length == 5)) 288 - /* Pseudocolor, RGB555, BGR555 */ 289 - val |= INTEGRATOR_CLCD_LCDMUX_VGA555; 290 - else if (fb->fb.var.bits_per_pixel <= 16) 291 - /* truecolor RGB565 */ 292 - val |= INTEGRATOR_CLCD_LCDMUX_VGA565; 293 - else 294 - val = 0; /* no idea for this, don't trust the docs */ 295 - 296 - regmap_update_bits(versatile_syscon_map, 297 - INTEGRATOR_HDR_CTRL_OFFSET, 298 - INTEGRATOR_CLCD_MASK, 299 - val); 300 - } 301 - 302 - /* 303 - * This configuration register in the Versatile and RealView 304 - * family is uniformly present but appears more and more 305 - * unutilized starting with the RealView series. 306 - */ 307 - #define SYS_CLCD 0x50 308 - #define SYS_CLCD_MODE_MASK (BIT(0)|BIT(1)) 309 - #define SYS_CLCD_MODE_888 0 310 - #define SYS_CLCD_MODE_5551 BIT(0) 311 - #define SYS_CLCD_MODE_565_R_LSB BIT(1) 312 - #define SYS_CLCD_MODE_565_B_LSB (BIT(0)|BIT(1)) 313 - #define SYS_CLCD_CONNECTOR_MASK (BIT(2)|BIT(3)|BIT(4)|BIT(5)) 314 - #define SYS_CLCD_NLCDIOON BIT(2) 315 - #define SYS_CLCD_VDDPOSSWITCH BIT(3) 316 - #define SYS_CLCD_PWR3V5SWITCH BIT(4) 317 - #define SYS_CLCD_VDDNEGSWITCH BIT(5) 318 - #define SYS_CLCD_TSNSS BIT(6) /* touchscreen enable */ 319 - #define SYS_CLCD_SSPEXP BIT(7) /* SSP expansion enable */ 320 - 321 - /* The Versatile can detect the connected panel type */ 322 - #define SYS_CLCD_CLCDID_MASK (BIT(8)|BIT(9)|BIT(10)|BIT(11)|BIT(12)) 323 - #define SYS_CLCD_ID_SANYO_3_8 (0x00 << 8) 324 - #define SYS_CLCD_ID_SHARP_8_4 (0x01 << 8) 325 - #define SYS_CLCD_ID_EPSON_2_2 (0x02 << 8) 326 - #define SYS_CLCD_ID_SANYO_2_5 (0x07 << 8) 327 - #define SYS_CLCD_ID_VGA (0x1f << 8) 328 - 329 - #define SYS_CLCD_TSNDAV BIT(13) /* data ready from TS */ 330 - 331 - /* IB2 control register for the Versatile daughterboard */ 332 - #define IB2_CTRL 0x00 333 - #define IB2_CTRL_LCD_SD BIT(1) /* 1 = shut down LCD */ 334 - #define IB2_CTRL_LCD_BL_ON BIT(0) 335 - #define IB2_CTRL_LCD_MASK (BIT(0)|BIT(1)) 336 - 337 - static void versatile_clcd_disable(struct clcd_fb *fb) 338 - { 339 - dev_info(&fb->dev->dev, "disable Versatile CLCD connectors\n"); 340 - regmap_update_bits(versatile_syscon_map, 341 - SYS_CLCD, 342 - SYS_CLCD_CONNECTOR_MASK, 343 - 0); 344 - 345 - /* If we're on an IB2 daughterboard, turn off display */ 346 - if (versatile_ib2_map) { 347 - dev_info(&fb->dev->dev, "disable IB2 display\n"); 348 - regmap_update_bits(versatile_ib2_map, 349 - IB2_CTRL, 350 - IB2_CTRL_LCD_MASK, 351 - IB2_CTRL_LCD_SD); 352 - } 353 - } 354 - 355 - static void versatile_clcd_enable(struct clcd_fb *fb) 356 - { 357 - struct fb_var_screeninfo *var = &fb->fb.var; 358 - u32 val = 0; 359 - 360 - dev_info(&fb->dev->dev, "enable Versatile CLCD connectors\n"); 361 - switch (var->green.length) { 362 - case 5: 363 - val |= SYS_CLCD_MODE_5551; 364 - break; 365 - case 6: 366 - if (var->red.offset == 0) 367 - val |= SYS_CLCD_MODE_565_R_LSB; 368 - else 369 - val |= SYS_CLCD_MODE_565_B_LSB; 370 - break; 371 - case 8: 372 - val |= SYS_CLCD_MODE_888; 373 - break; 374 - } 375 - 376 - /* Set up the MUX */ 377 - regmap_update_bits(versatile_syscon_map, 378 - SYS_CLCD, 379 - SYS_CLCD_MODE_MASK, 380 - val); 381 - 382 - /* Then enable the display */ 383 - regmap_update_bits(versatile_syscon_map, 384 - SYS_CLCD, 385 - SYS_CLCD_CONNECTOR_MASK, 386 - SYS_CLCD_NLCDIOON | SYS_CLCD_PWR3V5SWITCH); 387 - 388 - /* If we're on an IB2 daughterboard, turn on display */ 389 - if (versatile_ib2_map) { 390 - dev_info(&fb->dev->dev, "enable IB2 display\n"); 391 - regmap_update_bits(versatile_ib2_map, 392 - IB2_CTRL, 393 - IB2_CTRL_LCD_MASK, 394 - IB2_CTRL_LCD_BL_ON); 395 - } 396 - } 397 - 398 - static void versatile_clcd_decode(struct clcd_fb *fb, struct clcd_regs *regs) 399 - { 400 - clcdfb_decode(fb, regs); 401 - 402 - /* Always clear BGR for RGB565: we do the routing externally */ 403 - if (fb->fb.var.green.length == 6) 404 - regs->cntl &= ~CNTL_BGR; 405 - } 406 - 407 - static void realview_clcd_disable(struct clcd_fb *fb) 408 - { 409 - dev_info(&fb->dev->dev, "disable RealView CLCD connectors\n"); 410 - regmap_update_bits(versatile_syscon_map, 411 - SYS_CLCD, 412 - SYS_CLCD_CONNECTOR_MASK, 413 - 0); 414 - } 415 - 416 - static void realview_clcd_enable(struct clcd_fb *fb) 417 - { 418 - dev_info(&fb->dev->dev, "enable RealView CLCD connectors\n"); 419 - regmap_update_bits(versatile_syscon_map, 420 - SYS_CLCD, 421 - SYS_CLCD_CONNECTOR_MASK, 422 - SYS_CLCD_NLCDIOON | SYS_CLCD_PWR3V5SWITCH); 423 - } 424 - 425 - struct versatile_panel { 426 - u32 id; 427 - char *compatible; 428 - bool ib2; 429 - }; 430 - 431 - static const struct versatile_panel versatile_panels[] = { 432 - { 433 - .id = SYS_CLCD_ID_VGA, 434 - .compatible = "VGA", 435 - }, 436 - { 437 - .id = SYS_CLCD_ID_SANYO_3_8, 438 - .compatible = "sanyo,tm38qv67a02a", 439 - }, 440 - { 441 - .id = SYS_CLCD_ID_SHARP_8_4, 442 - .compatible = "sharp,lq084v1dg21", 443 - }, 444 - { 445 - .id = SYS_CLCD_ID_EPSON_2_2, 446 - .compatible = "epson,l2f50113t00", 447 - }, 448 - { 449 - .id = SYS_CLCD_ID_SANYO_2_5, 450 - .compatible = "sanyo,alr252rgt", 451 - .ib2 = true, 452 - }, 453 - }; 454 - 455 - static void versatile_panel_probe(struct device *dev, struct device_node *panel) 456 - { 457 - struct versatile_panel const *vpanel = NULL; 458 - u32 val; 459 - int ret; 460 - int i; 461 - 462 - /* 463 - * The Versatile CLCD has a panel auto-detection mechanism. 464 - * We use this and look for the compatible panel in the 465 - * device tree. 466 - */ 467 - ret = regmap_read(versatile_syscon_map, SYS_CLCD, &val); 468 - if (ret) { 469 - dev_err(dev, "cannot read CLCD syscon register\n"); 470 - return; 471 - } 472 - val &= SYS_CLCD_CLCDID_MASK; 473 - 474 - /* First find corresponding panel information */ 475 - for (i = 0; i < ARRAY_SIZE(versatile_panels); i++) { 476 - vpanel = &versatile_panels[i]; 477 - 478 - if (val == vpanel->id) { 479 - dev_err(dev, "autodetected panel \"%s\"\n", 480 - vpanel->compatible); 481 - break; 482 - } 483 - } 484 - if (i == ARRAY_SIZE(versatile_panels)) { 485 - dev_err(dev, "could not auto-detect panel\n"); 486 - return; 487 - } 488 - 489 - if (!of_device_is_compatible(panel, vpanel->compatible)) 490 - dev_err(dev, "panel in DT is not compatible with the " 491 - "auto-detected panel, continuing anyway\n"); 492 - 493 - /* 494 - * If we have a Sanyo 2.5" port 495 - * that we're running on an IB2 and proceed to look for the 496 - * IB2 syscon regmap. 497 - */ 498 - if (!vpanel->ib2) 499 - return; 500 - 501 - versatile_ib2_map = syscon_regmap_lookup_by_compatible( 502 - "arm,versatile-ib2-syscon"); 503 - if (IS_ERR(versatile_ib2_map)) { 504 - dev_err(dev, "could not locate IB2 control register\n"); 505 - versatile_ib2_map = NULL; 506 - return; 507 - } 508 - } 509 - 510 - int versatile_clcd_init_panel(struct clcd_fb *fb, struct device_node *panel) 511 - { 512 - const struct of_device_id *clcd_id; 513 - enum versatile_clcd versatile_clcd_type; 514 - struct device_node *np; 515 - struct regmap *map; 516 - struct device *dev = &fb->dev->dev; 517 - 518 - np = of_find_matching_node_and_match(NULL, versatile_clcd_of_match, 519 - &clcd_id); 520 - if (!np) { 521 - /* Vexpress does not have this */ 522 - return 0; 523 - } 524 - versatile_clcd_type = (enum versatile_clcd)clcd_id->data; 525 - 526 - map = syscon_node_to_regmap(np); 527 - if (IS_ERR(map)) { 528 - dev_err(dev, "no Versatile syscon regmap\n"); 529 - return PTR_ERR(map); 530 - } 531 - 532 - switch (versatile_clcd_type) { 533 - case INTEGRATOR_CLCD_CM: 534 - versatile_syscon_map = map; 535 - fb->board->enable = integrator_clcd_enable; 536 - /* Override the caps, we have only these */ 537 - fb->board->caps = CLCD_CAP_5551 | CLCD_CAP_RGB565 | 538 - CLCD_CAP_888; 539 - dev_info(dev, "set up callbacks for Integrator PL110\n"); 540 - break; 541 - case VERSATILE_CLCD: 542 - versatile_syscon_map = map; 543 - fb->board->enable = versatile_clcd_enable; 544 - fb->board->disable = versatile_clcd_disable; 545 - fb->board->decode = versatile_clcd_decode; 546 - versatile_panel_probe(dev, panel); 547 - dev_info(dev, "set up callbacks for Versatile\n"); 548 - break; 549 - case REALVIEW_CLCD_EB: 550 - case REALVIEW_CLCD_PB1176: 551 - case REALVIEW_CLCD_PB11MP: 552 - case REALVIEW_CLCD_PBA8: 553 - case REALVIEW_CLCD_PBX: 554 - versatile_syscon_map = map; 555 - fb->board->enable = realview_clcd_enable; 556 - fb->board->disable = realview_clcd_disable; 557 - dev_info(dev, "set up callbacks for RealView PL111\n"); 558 - break; 559 - default: 560 - dev_info(dev, "unknown Versatile system controller\n"); 561 - break; 562 - } 563 - 564 - return 0; 565 - } 566 - EXPORT_SYMBOL_GPL(versatile_clcd_init_panel); 567 - #endif
-17
drivers/video/fbdev/amba-clcd-versatile.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - /* 3 - * Special local versatile callbacks 4 - */ 5 - #include <linux/of.h> 6 - #include <linux/amba/bus.h> 7 - #include <linux/platform_data/video-clcd-versatile.h> 8 - 9 - #if defined(CONFIG_PLAT_VERSATILE_CLCD) && defined(CONFIG_OF) 10 - int versatile_clcd_init_panel(struct clcd_fb *fb, struct device_node *panel); 11 - #else 12 - static inline int versatile_clcd_init_panel(struct clcd_fb *fb, 13 - struct device_node *panel) 14 - { 15 - return 0; 16 - } 17 - #endif
+2 -96
drivers/video/fbdev/amba-clcd.c
··· 30 30 #include <video/of_display_timing.h> 31 31 #include <video/videomode.h> 32 32 33 - #include "amba-clcd-nomadik.h" 34 - #include "amba-clcd-versatile.h" 35 - 36 33 #define to_clcd(info) container_of(info, struct clcd_fb, fb) 37 34 38 35 /* This is limited to 16 characters when displayed by X startup */ ··· 220 223 var->blue.length = 4; 221 224 } 222 225 break; 223 - case 24: 224 - if (fb->vendor->packed_24_bit_pixels) { 225 - var->red.length = 8; 226 - var->green.length = 8; 227 - var->blue.length = 8; 228 - } else { 229 - ret = -EINVAL; 230 - } 231 - break; 232 226 case 32: 233 227 /* If we can't do 888, reject */ 234 228 caps &= CLCD_CAP_888; ··· 305 317 fb->board->decode(fb, &regs); 306 318 307 319 clcdfb_disable(fb); 308 - 309 - /* Some variants must be clocked here */ 310 - if (fb->vendor->clock_timregs && !fb->clk_enabled) { 311 - fb->clk_enabled = true; 312 - clk_enable(fb->clk); 313 - } 314 320 315 321 writel(regs.tim0, fb->regs + CLCD_TIM0); 316 322 writel(regs.tim1, fb->regs + CLCD_TIM1); ··· 447 465 fb->off_ienb = CLCD_PL111_IENB; 448 466 fb->off_cntl = CLCD_PL111_CNTL; 449 467 } else { 450 - if (of_machine_is_compatible("arm,versatile-ab") || 451 - of_machine_is_compatible("arm,versatile-pb")) { 452 - fb->off_ienb = CLCD_PL111_IENB; 453 - fb->off_cntl = CLCD_PL111_CNTL; 454 - } else { 455 - fb->off_ienb = CLCD_PL110_IENB; 456 - fb->off_cntl = CLCD_PL110_CNTL; 457 - } 468 + fb->off_ienb = CLCD_PL110_IENB; 469 + fb->off_cntl = CLCD_PL110_CNTL; 458 470 } 459 471 460 472 fb->clk = clk_get(&fb->dev->dev, NULL); ··· 689 713 if (r0 != 0 && b0 == 0) 690 714 fb->panel->bgr_connection = true; 691 715 692 - if (fb->panel->caps && fb->vendor->st_bitmux_control) { 693 - /* 694 - * Set up the special bits for the Nomadik control register 695 - * (other platforms tend to do this through an external 696 - * register). 697 - */ 698 - 699 - /* Offset of the highest used color */ 700 - int maxoff = max3(r0, g0, b0); 701 - /* Most significant bit out, highest used bit */ 702 - int msb = 0; 703 - 704 - if (fb->panel->caps & CLCD_CAP_888) { 705 - msb = maxoff + 8 - 1; 706 - } else if (fb->panel->caps & CLCD_CAP_565) { 707 - msb = maxoff + 5 - 1; 708 - fb->panel->cntl |= CNTL_ST_1XBPP_565; 709 - } else if (fb->panel->caps & CLCD_CAP_5551) { 710 - msb = maxoff + 5 - 1; 711 - fb->panel->cntl |= CNTL_ST_1XBPP_5551; 712 - } else if (fb->panel->caps & CLCD_CAP_444) { 713 - msb = maxoff + 4 - 1; 714 - fb->panel->cntl |= CNTL_ST_1XBPP_444; 715 - } 716 - 717 - /* Send out as many bits as we need */ 718 - if (msb > 17) 719 - fb->panel->cntl |= CNTL_ST_CDWID_24; 720 - else if (msb > 15) 721 - fb->panel->cntl |= CNTL_ST_CDWID_18; 722 - else if (msb > 11) 723 - fb->panel->cntl |= CNTL_ST_CDWID_16; 724 - else 725 - fb->panel->cntl |= CNTL_ST_CDWID_12; 726 - } 727 - 728 716 return fb->panel->caps ? 0 : -EINVAL; 729 717 } 730 718 ··· 714 774 panel = of_graph_get_remote_port_parent(endpoint); 715 775 if (!panel) 716 776 return -ENODEV; 717 - 718 - if (fb->vendor->init_panel) { 719 - err = fb->vendor->init_panel(fb, panel); 720 - if (err) 721 - return err; 722 - } 723 777 724 778 err = clcdfb_of_get_backlight(panel, fb->panel); 725 779 if (err) ··· 875 941 static int clcdfb_probe(struct amba_device *dev, const struct amba_id *id) 876 942 { 877 943 struct clcd_board *board = dev_get_platdata(&dev->dev); 878 - struct clcd_vendor_data *vendor = id->data; 879 944 struct clcd_fb *fb; 880 945 int ret; 881 946 ··· 883 950 884 951 if (!board) 885 952 return -EINVAL; 886 - 887 - if (vendor->init_board) { 888 - ret = vendor->init_board(dev, board); 889 - if (ret) 890 - return ret; 891 - } 892 953 893 954 ret = dma_set_mask_and_coherent(&dev->dev, DMA_BIT_MASK(32)); 894 955 if (ret) ··· 901 974 } 902 975 903 976 fb->dev = dev; 904 - fb->vendor = vendor; 905 977 fb->board = board; 906 978 907 979 dev_info(&fb->dev->dev, "PL%03x designer %02x rev%u at 0x%08llx\n", ··· 947 1021 return 0; 948 1022 } 949 1023 950 - static struct clcd_vendor_data vendor_arm = { 951 - /* Sets up the versatile board displays */ 952 - .init_panel = versatile_clcd_init_panel, 953 - }; 954 - 955 - static struct clcd_vendor_data vendor_nomadik = { 956 - .clock_timregs = true, 957 - .packed_24_bit_pixels = true, 958 - .st_bitmux_control = true, 959 - .init_board = nomadik_clcd_init_board, 960 - .init_panel = nomadik_clcd_init_panel, 961 - }; 962 - 963 1024 static const struct amba_id clcdfb_id_table[] = { 964 1025 { 965 1026 .id = 0x00041110, 966 1027 .mask = 0x000ffffe, 967 - .data = &vendor_arm, 968 - }, 969 - /* ST Electronics Nomadik variant */ 970 - { 971 - .id = 0x00180110, 972 - .mask = 0x00fffffe, 973 - .data = &vendor_nomadik, 974 1028 }, 975 1029 { 0, 0 }, 976 1030 };
-31
include/linux/amba/clcd.h
··· 124 124 struct amba_device; 125 125 struct clk; 126 126 127 - /** 128 - * struct clcd_vendor_data - holds hardware (IP-block) vendor-specific 129 - * variant information 130 - * 131 - * @clock_timregs: the CLCD needs to be clocked when accessing the 132 - * timer registers, or the hardware will hang. 133 - * @packed_24_bit_pixels: this variant supports 24bit packed pixel data, 134 - * so that RGB accesses 3 bytes at a time, not just on even 32bit 135 - * boundaries, packing the pixel data in memory. ST Microelectronics 136 - * have this. 137 - * @st_bitmux_control: ST Microelectronics have implemented output 138 - * bit line multiplexing into the CLCD control register. This indicates 139 - * that we need to use this. 140 - * @init_board: custom board init function for this variant 141 - * @init_panel: custom panel init function for this variant 142 - */ 143 - struct clcd_vendor_data { 144 - bool clock_timregs; 145 - bool packed_24_bit_pixels; 146 - bool st_bitmux_control; 147 - int (*init_board)(struct amba_device *adev, 148 - struct clcd_board *board); 149 - int (*init_panel)(struct clcd_fb *fb, 150 - struct device_node *panel); 151 - }; 152 - 153 127 /* this data structure describes each frame buffer device we find */ 154 128 struct clcd_fb { 155 129 struct fb_info fb; 156 130 struct amba_device *dev; 157 131 struct clk *clk; 158 - struct clcd_vendor_data *vendor; 159 132 struct clcd_panel *panel; 160 133 struct clcd_board *board; 161 134 void *board_data; ··· 229 256 val |= CNTL_LCDBPP16_565; 230 257 else 231 258 val |= CNTL_LCDBPP16_444; 232 - break; 233 - case 24: 234 - /* Modified variant supporting 24 bit packed pixels */ 235 - val |= CNTL_ST_LCDBPP24_PACKED; 236 259 break; 237 260 case 32: 238 261 val |= CNTL_LCDBPP24;