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
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright (C) 2020 Marek Vasut <marex@denx.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Based on rpi_touchscreen.c by Eric Anholt <eric@anholt.net>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/backlight.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/err.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/gpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/regmap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/regulator/driver.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/regulator/machine.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/regulator/of_regulator.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) /* I2C registers of the Atmel microcontroller. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #define REG_ID		0x80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #define REG_PORTA	0x81
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #define REG_PORTA_HF	BIT(2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #define REG_PORTA_VF	BIT(3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #define REG_PORTB	0x82
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #define REG_POWERON	0x85
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #define REG_PWM		0x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) static const struct regmap_config attiny_regmap_config = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	.reg_bits = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	.val_bits = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	.max_register = REG_PWM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	.cache_type = REGCACHE_NONE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) static int attiny_lcd_power_enable(struct regulator_dev *rdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	unsigned int data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	int ret, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	regmap_write(rdev->regmap, REG_POWERON, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	msleep(80);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	/* Wait for nPWRDWN to go low to indicate poweron is done. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	for (i = 0; i < 20; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 		ret = regmap_read(rdev->regmap, REG_PORTB, &data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 		if (!ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 			if (data & BIT(0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 		usleep_range(10000, 12000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	usleep_range(10000, 12000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 		pr_err("%s: regmap_read_poll_timeout failed %d\n", __func__, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	/* Default to the same orientation as the closed source
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	 * firmware used for the panel.  Runtime rotation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	 * configuration will be supported using VC4's plane
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	 * orientation bits.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	regmap_write(rdev->regmap, REG_PORTA, BIT(2));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) static int attiny_lcd_power_disable(struct regulator_dev *rdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	regmap_write(rdev->regmap, REG_PWM, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	regmap_write(rdev->regmap, REG_POWERON, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	msleep(30);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) static int attiny_lcd_power_is_enabled(struct regulator_dev *rdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	unsigned int data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	int ret, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	for (i = 0; i < 10; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		ret = regmap_read(rdev->regmap, REG_POWERON, &data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		if (!ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		usleep_range(10000, 12000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	if (!(data & BIT(0)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	for (i = 0; i < 10; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		ret = regmap_read(rdev->regmap, REG_PORTB, &data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		if (!ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		usleep_range(10000, 12000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	return data & BIT(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) static const struct regulator_init_data attiny_regulator_default = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	.constraints = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		.valid_ops_mask = REGULATOR_CHANGE_STATUS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) static const struct regulator_ops attiny_regulator_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	.enable = attiny_lcd_power_enable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	.disable = attiny_lcd_power_disable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	.is_enabled = attiny_lcd_power_is_enabled,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) static const struct regulator_desc attiny_regulator = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	.name	= "tc358762-power",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	.ops	= &attiny_regulator_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	.type	= REGULATOR_VOLTAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	.owner	= THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) static int attiny_update_status(struct backlight_device *bl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	struct regmap *regmap = bl_get_data(bl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	int brightness = bl->props.brightness;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	int ret, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	if (bl->props.power != FB_BLANK_UNBLANK ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	    bl->props.fb_blank != FB_BLANK_UNBLANK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		brightness = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	for (i = 0; i < 10; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		ret = regmap_write(regmap, REG_PWM, brightness);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		if (!ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) static int attiny_get_brightness(struct backlight_device *bl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	struct regmap *regmap = bl_get_data(bl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	int ret, brightness, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	for (i = 0; i < 10; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 		ret = regmap_read(regmap, REG_PWM, &brightness);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 		if (!ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	return brightness;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) static const struct backlight_ops attiny_bl = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	.update_status	= attiny_update_status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	.get_brightness	= attiny_get_brightness,
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)  * I2C driver interface functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) static int attiny_i2c_probe(struct i2c_client *i2c,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		const struct i2c_device_id *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	struct backlight_properties props = { };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	struct regulator_config config = { };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	struct backlight_device *bl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	struct regulator_dev *rdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	struct regmap *regmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	unsigned int data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	regmap = devm_regmap_init_i2c(i2c, &attiny_regmap_config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	if (IS_ERR(regmap)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 		ret = PTR_ERR(regmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 		dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 			ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	ret = regmap_read(regmap, REG_ID, &data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		dev_err(&i2c->dev, "Failed to read REG_ID reg: %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	switch (data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	case 0xde: /* ver 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	case 0xc3: /* ver 2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		dev_err(&i2c->dev, "Unknown Atmel firmware revision: 0x%02x\n", data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	regmap_write(regmap, REG_POWERON, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	msleep(30);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	config.dev = &i2c->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	config.regmap = regmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	config.of_node = i2c->dev.of_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	config.init_data = &attiny_regulator_default;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	rdev = devm_regulator_register(&i2c->dev, &attiny_regulator, &config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	if (IS_ERR(rdev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		dev_err(&i2c->dev, "Failed to register ATTINY regulator\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 		return PTR_ERR(rdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	props.type = BACKLIGHT_RAW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	props.max_brightness = 0xff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	bl = devm_backlight_device_register(&i2c->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 					    "7inch-touchscreen-panel-bl",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 					    &i2c->dev, regmap, &attiny_bl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 					    &props);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	if (IS_ERR(bl))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		return PTR_ERR(bl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	bl->props.brightness = 0xff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) static const struct of_device_id attiny_dt_ids[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	{ .compatible = "raspberrypi,7inch-touchscreen-panel-regulator" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	{},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) MODULE_DEVICE_TABLE(of, attiny_dt_ids);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) static struct i2c_driver attiny_regulator_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	.driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 		.name = "rpi_touchscreen_attiny",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 		.of_match_table = of_match_ptr(attiny_dt_ids),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	.probe = attiny_i2c_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) module_i2c_driver(attiny_regulator_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) MODULE_AUTHOR("Marek Vasut <marex@denx.de>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) MODULE_DESCRIPTION("Regulator device driver for Raspberry Pi 7-inch touchscreen");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) MODULE_LICENSE("GPL v2");