Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright (c) Intel Corp. 2007.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * develop this driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * This file is part of the Carillo Ranch video subsystem driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * Authors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *   Thomas Hellstrom <thomas-at-tungstengraphics-dot-com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *   Alan Hourihane <alanh-at-tungstengraphics-dot-com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <linux/fb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include <linux/backlight.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include <linux/lcd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #include <linux/pci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) /* The LVDS- and panel power controls sits on the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  * GPIO port of the ISA bridge.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #define CRVML_DEVICE_LPC    0x27B8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #define CRVML_REG_GPIOBAR   0x48
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #define CRVML_REG_GPIOEN    0x4C
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #define CRVML_GPIOEN_BIT    (1 << 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #define CRVML_PANEL_PORT    0x38
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #define CRVML_LVDS_ON       0x00000001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #define CRVML_PANEL_ON      0x00000002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #define CRVML_BACKLIGHT_OFF 0x00000004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) /* The PLL Clock register sits on Host bridge */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #define CRVML_DEVICE_MCH   0x5001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #define CRVML_REG_MCHBAR   0x44
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #define CRVML_REG_MCHEN    0x54
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #define CRVML_MCHEN_BIT    (1 << 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) #define CRVML_MCHMAP_SIZE  4096
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #define CRVML_REG_CLOCK    0xc3c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) #define CRVML_CLOCK_SHIFT  8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #define CRVML_CLOCK_MASK   0x00000f00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) static struct pci_dev *lpc_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) static u32 gpio_bar;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) struct cr_panel {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	struct backlight_device *cr_backlight_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	struct lcd_device *cr_lcd_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) static int cr_backlight_set_intensity(struct backlight_device *bd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	u32 addr = gpio_bar + CRVML_PANEL_PORT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	u32 cur = inl(addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	if (backlight_get_brightness(bd) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 		/* OFF */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		cur |= CRVML_BACKLIGHT_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		outl(cur, addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 		/* FULL ON */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		cur &= ~CRVML_BACKLIGHT_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		outl(cur, addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) static int cr_backlight_get_intensity(struct backlight_device *bd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	u32 addr = gpio_bar + CRVML_PANEL_PORT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	u32 cur = inl(addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	u8 intensity;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	if (cur & CRVML_BACKLIGHT_OFF)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 		intensity = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		intensity = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	return intensity;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) static const struct backlight_ops cr_backlight_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	.get_brightness = cr_backlight_get_intensity,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	.update_status = cr_backlight_set_intensity,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) static void cr_panel_on(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	u32 addr = gpio_bar + CRVML_PANEL_PORT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	u32 cur = inl(addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	if (!(cur & CRVML_PANEL_ON)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		/* Make sure LVDS controller is down. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		if (cur & 0x00000001) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 			cur &= ~CRVML_LVDS_ON;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 			outl(cur, addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 		/* Power up Panel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		schedule_timeout(HZ / 10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		cur |= CRVML_PANEL_ON;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		outl(cur, addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	/* Power up LVDS controller */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	if (!(cur & CRVML_LVDS_ON)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		schedule_timeout(HZ / 10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		outl(cur | CRVML_LVDS_ON, addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) static void cr_panel_off(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	u32 addr = gpio_bar + CRVML_PANEL_PORT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	u32 cur = inl(addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	/* Power down LVDS controller first to avoid high currents */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	if (cur & CRVML_LVDS_ON) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		cur &= ~CRVML_LVDS_ON;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		outl(cur, addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	if (cur & CRVML_PANEL_ON) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		schedule_timeout(HZ / 10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		outl(cur & ~CRVML_PANEL_ON, addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) static int cr_lcd_set_power(struct lcd_device *ld, int power)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	if (power == FB_BLANK_UNBLANK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		cr_panel_on();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	if (power == FB_BLANK_POWERDOWN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		cr_panel_off();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) static struct lcd_ops cr_lcd_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	.set_power = cr_lcd_set_power,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) static int cr_backlight_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	struct backlight_properties props;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	struct backlight_device *bdp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	struct lcd_device *ldp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	struct cr_panel *crp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	u8 dev_en;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	lpc_dev = pci_get_device(PCI_VENDOR_ID_INTEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 					CRVML_DEVICE_LPC, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	if (!lpc_dev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 		pr_err("INTEL CARILLO RANCH LPC not found.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	pci_read_config_byte(lpc_dev, CRVML_REG_GPIOEN, &dev_en);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	if (!(dev_en & CRVML_GPIOEN_BIT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 		pr_err("Carillo Ranch GPIO device was not enabled.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		pci_dev_put(lpc_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	memset(&props, 0, sizeof(struct backlight_properties));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	props.type = BACKLIGHT_RAW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	bdp = devm_backlight_device_register(&pdev->dev, "cr-backlight",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 					&pdev->dev, NULL, &cr_backlight_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 					&props);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	if (IS_ERR(bdp)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		pci_dev_put(lpc_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 		return PTR_ERR(bdp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	ldp = devm_lcd_device_register(&pdev->dev, "cr-lcd", &pdev->dev, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 					&cr_lcd_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	if (IS_ERR(ldp)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		pci_dev_put(lpc_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		return PTR_ERR(ldp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	pci_read_config_dword(lpc_dev, CRVML_REG_GPIOBAR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 			      &gpio_bar);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	gpio_bar &= ~0x3F;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	crp = devm_kzalloc(&pdev->dev, sizeof(*crp), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	if (!crp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		pci_dev_put(lpc_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	crp->cr_backlight_device = bdp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	crp->cr_lcd_device = ldp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	crp->cr_backlight_device->props.power = FB_BLANK_UNBLANK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	crp->cr_backlight_device->props.brightness = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	cr_backlight_set_intensity(crp->cr_backlight_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	cr_lcd_set_power(crp->cr_lcd_device, FB_BLANK_UNBLANK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	platform_set_drvdata(pdev, crp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) static int cr_backlight_remove(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	struct cr_panel *crp = platform_get_drvdata(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	crp->cr_backlight_device->props.power = FB_BLANK_POWERDOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	crp->cr_backlight_device->props.brightness = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	crp->cr_backlight_device->props.max_brightness = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	cr_backlight_set_intensity(crp->cr_backlight_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	cr_lcd_set_power(crp->cr_lcd_device, FB_BLANK_POWERDOWN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	pci_dev_put(lpc_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) static struct platform_driver cr_backlight_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	.probe = cr_backlight_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	.remove = cr_backlight_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	.driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		   .name = "cr_backlight",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 		   },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) static struct platform_device *crp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) static int __init cr_backlight_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	int ret = platform_driver_register(&cr_backlight_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	crp = platform_device_register_simple("cr_backlight", -1, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	if (IS_ERR(crp)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 		platform_driver_unregister(&cr_backlight_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 		return PTR_ERR(crp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	pr_info("Carillo Ranch Backlight Driver Initialized.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) static void __exit cr_backlight_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	platform_device_unregister(crp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	platform_driver_unregister(&cr_backlight_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) module_init(cr_backlight_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) module_exit(cr_backlight_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) MODULE_AUTHOR("Tungsten Graphics Inc.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) MODULE_DESCRIPTION("Carillo Ranch Backlight Driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) MODULE_LICENSE("GPL");