Lines Matching refs:mcu
38 struct mcu { struct
45 static struct mcu *glob_mcu; argument
51 struct mcu *mcu = glob_mcu; in shutdown_thread_fn() local
54 ret = i2c_smbus_read_byte_data(mcu->client, MCU_REG_CTRL); in shutdown_thread_fn()
57 mcu->reg_ctrl = ret; in shutdown_thread_fn()
60 if (mcu->reg_ctrl & MCU_CTRL_BTN) { in shutdown_thread_fn()
61 i2c_smbus_write_byte_data(mcu->client, MCU_REG_CTRL, in shutdown_thread_fn()
62 mcu->reg_ctrl & ~MCU_CTRL_BTN); in shutdown_thread_fn()
78 struct mcu *mcu = glob_mcu; in show_status() local
80 ret = i2c_smbus_read_byte_data(mcu->client, MCU_REG_CTRL); in show_status()
83 mcu->reg_ctrl = ret; in show_status()
91 struct mcu *mcu = glob_mcu; in mcu_power_off() local
94 mutex_lock(&mcu->lock); in mcu_power_off()
95 i2c_smbus_write_byte_data(mcu->client, MCU_REG_CTRL, in mcu_power_off()
96 mcu->reg_ctrl | MCU_CTRL_POFF); in mcu_power_off()
97 mutex_unlock(&mcu->lock); in mcu_power_off()
102 struct mcu *mcu = container_of(gc, struct mcu, gc); in mcu_gpio_set() local
105 mutex_lock(&mcu->lock); in mcu_gpio_set()
107 mcu->reg_ctrl &= ~bit; in mcu_gpio_set()
109 mcu->reg_ctrl |= bit; in mcu_gpio_set()
111 i2c_smbus_write_byte_data(mcu->client, MCU_REG_CTRL, mcu->reg_ctrl); in mcu_gpio_set()
112 mutex_unlock(&mcu->lock); in mcu_gpio_set()
121 static int mcu_gpiochip_add(struct mcu *mcu) in mcu_gpiochip_add() argument
124 struct gpio_chip *gc = &mcu->gc; in mcu_gpiochip_add()
142 static int mcu_gpiochip_remove(struct mcu *mcu) in mcu_gpiochip_remove() argument
144 gpiochip_remove(&mcu->gc); in mcu_gpiochip_remove()
150 struct mcu *mcu; in mcu_probe() local
153 mcu = kzalloc(sizeof(*mcu), GFP_KERNEL); in mcu_probe()
154 if (!mcu) in mcu_probe()
157 mutex_init(&mcu->lock); in mcu_probe()
158 mcu->client = client; in mcu_probe()
159 i2c_set_clientdata(client, mcu); in mcu_probe()
161 ret = i2c_smbus_read_byte_data(mcu->client, MCU_REG_CTRL); in mcu_probe()
164 mcu->reg_ctrl = ret; in mcu_probe()
166 ret = mcu_gpiochip_add(mcu); in mcu_probe()
172 glob_mcu = mcu; in mcu_probe()
186 kfree(mcu); in mcu_probe()
192 struct mcu *mcu = i2c_get_clientdata(client); in mcu_remove() local
199 if (glob_mcu == mcu) { in mcu_remove()
204 ret = mcu_gpiochip_remove(mcu); in mcu_remove()
207 kfree(mcu); in mcu_remove()