Lines Matching refs:mcu

33 struct mcu {  struct
40 static struct mcu *glob_mcu; argument
46 struct mcu *mcu = glob_mcu; in shutdown_thread_fn() local
49 ret = i2c_smbus_read_byte_data(mcu->client, MCU_REG_CTRL); in shutdown_thread_fn()
52 mcu->reg_ctrl = ret; in shutdown_thread_fn()
55 if (mcu->reg_ctrl & MCU_CTRL_BTN) { in shutdown_thread_fn()
56 i2c_smbus_write_byte_data(mcu->client, MCU_REG_CTRL, in shutdown_thread_fn()
57 mcu->reg_ctrl & ~MCU_CTRL_BTN); in shutdown_thread_fn()
73 struct mcu *mcu = glob_mcu; in show_status() local
75 ret = i2c_smbus_read_byte_data(mcu->client, MCU_REG_CTRL); in show_status()
78 mcu->reg_ctrl = ret; in show_status()
86 struct mcu *mcu = glob_mcu; in mcu_power_off() local
89 mutex_lock(&mcu->lock); in mcu_power_off()
90 i2c_smbus_write_byte_data(mcu->client, MCU_REG_CTRL, in mcu_power_off()
91 mcu->reg_ctrl | MCU_CTRL_POFF); in mcu_power_off()
92 mutex_unlock(&mcu->lock); in mcu_power_off()
97 struct mcu *mcu = gpiochip_get_data(gc); in mcu_gpio_set() local
100 mutex_lock(&mcu->lock); in mcu_gpio_set()
102 mcu->reg_ctrl &= ~bit; in mcu_gpio_set()
104 mcu->reg_ctrl |= bit; in mcu_gpio_set()
106 i2c_smbus_write_byte_data(mcu->client, MCU_REG_CTRL, mcu->reg_ctrl); in mcu_gpio_set()
107 mutex_unlock(&mcu->lock); in mcu_gpio_set()
116 static int mcu_gpiochip_add(struct mcu *mcu) in mcu_gpiochip_add() argument
118 struct device *dev = &mcu->client->dev; in mcu_gpiochip_add()
119 struct gpio_chip *gc = &mcu->gc; in mcu_gpiochip_add()
130 return gpiochip_add_data(gc, mcu); in mcu_gpiochip_add()
133 static void mcu_gpiochip_remove(struct mcu *mcu) in mcu_gpiochip_remove() argument
135 kfree(mcu->gc.label); in mcu_gpiochip_remove()
136 gpiochip_remove(&mcu->gc); in mcu_gpiochip_remove()
141 struct mcu *mcu; in mcu_probe() local
144 mcu = kzalloc(sizeof(*mcu), GFP_KERNEL); in mcu_probe()
145 if (!mcu) in mcu_probe()
148 mutex_init(&mcu->lock); in mcu_probe()
149 mcu->client = client; in mcu_probe()
150 i2c_set_clientdata(client, mcu); in mcu_probe()
152 ret = i2c_smbus_read_byte_data(mcu->client, MCU_REG_CTRL); in mcu_probe()
155 mcu->reg_ctrl = ret; in mcu_probe()
157 ret = mcu_gpiochip_add(mcu); in mcu_probe()
163 glob_mcu = mcu; in mcu_probe()
177 kfree(mcu); in mcu_probe()
183 struct mcu *mcu = i2c_get_clientdata(client); in mcu_remove() local
189 if (glob_mcu == mcu) { in mcu_remove()
194 mcu_gpiochip_remove(mcu); in mcu_remove()
195 kfree(mcu); in mcu_remove()