Lines Matching +full:0 +full:- +full:inch

1 // SPDX-License-Identifier: GPL-2.0
23 #define REG_ID 0x80
24 #define REG_PORTA 0x81
25 #define REG_PORTB 0x82
26 #define REG_PORTC 0x83
27 #define REG_POWERON 0x85
28 #define REG_PWM 0x86
29 #define REG_ADDR_L 0x8c
30 #define REG_ADDR_H 0x8d
31 #define REG_WRITE_DATA_H 0x90
32 #define REG_WRITE_DATA_L 0x91
34 #define PA_LCD_DITHB BIT(0)
39 #define PB_BRIDGE_PWRDNX_N BIT(0)
43 #define PC_LED_EN BIT(0)
84 state->port_states[reg - REG_PORTA] = val; in attiny_set_port_state()
85 return regmap_write(state->regmap, reg, val); in attiny_set_port_state()
90 return state->port_states[reg - REG_PORTA]; in attiny_get_port_state()
97 mutex_lock(&state->lock); in attiny_lcd_power_enable()
100 attiny_set_port_state(state, REG_PORTC, 0); in attiny_lcd_power_enable()
118 mutex_unlock(&state->lock); in attiny_lcd_power_enable()
120 return 0; in attiny_lcd_power_enable()
127 mutex_lock(&state->lock); in attiny_lcd_power_disable()
129 regmap_write(rdev->regmap, REG_PWM, 0); in attiny_lcd_power_disable()
132 attiny_set_port_state(state, REG_PORTA, 0); in attiny_lcd_power_disable()
136 attiny_set_port_state(state, REG_PORTC, 0); in attiny_lcd_power_disable()
139 mutex_unlock(&state->lock); in attiny_lcd_power_disable()
141 return 0; in attiny_lcd_power_disable()
150 mutex_lock(&state->lock); in attiny_lcd_power_is_enabled()
152 for (i = 0; i < 10; i++) { in attiny_lcd_power_is_enabled()
153 ret = regmap_read(rdev->regmap, REG_PORTC, &data); in attiny_lcd_power_is_enabled()
159 mutex_unlock(&state->lock); in attiny_lcd_power_is_enabled()
161 if (ret < 0) in attiny_lcd_power_is_enabled()
180 .name = "tc358762-power",
189 struct regmap *regmap = state->regmap; in attiny_update_status()
193 mutex_lock(&state->lock); in attiny_update_status()
195 for (i = 0; i < 10; i++) { in attiny_update_status()
201 mutex_unlock(&state->lock); in attiny_update_status()
223 mutex_lock(&state->lock); in attiny_gpio_set()
235 regmap_write(state->regmap, REG_ADDR_H, 0x04); in attiny_gpio_set()
237 regmap_write(state->regmap, REG_ADDR_L, 0x7c); in attiny_gpio_set()
239 regmap_write(state->regmap, REG_WRITE_DATA_H, 0x00); in attiny_gpio_set()
241 regmap_write(state->regmap, REG_WRITE_DATA_L, 0x00); in attiny_gpio_set()
246 mutex_unlock(&state->lock); in attiny_gpio_set()
253 u8 data_buf[1] = { 0, }; in attiny_i2c_read()
257 msgs[0].addr = client->addr; in attiny_i2c_read()
258 msgs[0].flags = 0; in attiny_i2c_read()
259 msgs[0].len = ARRAY_SIZE(addr_buf); in attiny_i2c_read()
260 msgs[0].buf = addr_buf; in attiny_i2c_read()
262 ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); in attiny_i2c_read()
264 return -EIO; in attiny_i2c_read()
269 msgs[0].addr = client->addr; in attiny_i2c_read()
270 msgs[0].flags = I2C_M_RD; in attiny_i2c_read()
271 msgs[0].len = 1; in attiny_i2c_read()
272 msgs[0].buf = data_buf; in attiny_i2c_read()
274 ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); in attiny_i2c_read()
276 return -EIO; in attiny_i2c_read()
278 *buf = data_buf[0]; in attiny_i2c_read()
279 return 0; in attiny_i2c_read()
297 state = devm_kzalloc(&i2c->dev, sizeof(*state), GFP_KERNEL); in attiny_i2c_probe()
299 return -ENOMEM; in attiny_i2c_probe()
301 mutex_init(&state->lock); in attiny_i2c_probe()
307 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", in attiny_i2c_probe()
313 if (ret < 0) { in attiny_i2c_probe()
314 dev_err(&i2c->dev, "Failed to read REG_ID reg: %d\n", ret); in attiny_i2c_probe()
319 case 0xde: /* ver 1 */ in attiny_i2c_probe()
320 case 0xc3: /* ver 2 */ in attiny_i2c_probe()
323 dev_err(&i2c->dev, "Unknown Atmel firmware revision: 0x%02x\n", data); in attiny_i2c_probe()
324 ret = -ENODEV; in attiny_i2c_probe()
328 regmap_write(regmap, REG_POWERON, 0); in attiny_i2c_probe()
330 regmap_write(regmap, REG_PWM, 0); in attiny_i2c_probe()
332 config.dev = &i2c->dev; in attiny_i2c_probe()
334 config.of_node = i2c->dev.of_node; in attiny_i2c_probe()
338 rdev = devm_regulator_register(&i2c->dev, &attiny_regulator, &config); in attiny_i2c_probe()
340 dev_err(&i2c->dev, "Failed to register ATTINY regulator\n"); in attiny_i2c_probe()
346 props.max_brightness = 0xff; in attiny_i2c_probe()
348 state->regmap = regmap; in attiny_i2c_probe()
350 bl = devm_backlight_device_register(&i2c->dev, dev_name(&i2c->dev), in attiny_i2c_probe()
351 &i2c->dev, state, &attiny_bl, in attiny_i2c_probe()
358 bl->props.brightness = 0xff; in attiny_i2c_probe()
360 state->gc.parent = &i2c->dev; in attiny_i2c_probe()
361 state->gc.label = i2c->name; in attiny_i2c_probe()
362 state->gc.owner = THIS_MODULE; in attiny_i2c_probe()
363 state->gc.base = -1; in attiny_i2c_probe()
364 state->gc.ngpio = NUM_GPIO; in attiny_i2c_probe()
366 state->gc.set = attiny_gpio_set; in attiny_i2c_probe()
367 state->gc.get_direction = attiny_gpio_get_direction; in attiny_i2c_probe()
368 state->gc.can_sleep = true; in attiny_i2c_probe()
370 ret = devm_gpiochip_add_data(&i2c->dev, &state->gc, state); in attiny_i2c_probe()
372 dev_err(&i2c->dev, "Failed to create gpiochip: %d\n", ret); in attiny_i2c_probe()
376 return 0; in attiny_i2c_probe()
379 mutex_destroy(&state->lock); in attiny_i2c_probe()
388 mutex_destroy(&state->lock); in attiny_i2c_remove()
392 { .compatible = "raspberrypi,7inch-touchscreen-panel-regulator" },
409 MODULE_DESCRIPTION("Regulator device driver for Raspberry Pi 7-inch touchscreen");