Lines Matching refs:mcu

34 struct mcu {  struct
41 static struct mcu *glob_mcu; argument
47 struct mcu *mcu = glob_mcu; in shutdown_thread_fn() local
50 ret = i2c_smbus_read_byte_data(mcu->client, MCU_REG_CTRL); in shutdown_thread_fn()
53 mcu->reg_ctrl = ret; in shutdown_thread_fn()
56 if (mcu->reg_ctrl & MCU_CTRL_BTN) { in shutdown_thread_fn()
57 i2c_smbus_write_byte_data(mcu->client, MCU_REG_CTRL, in shutdown_thread_fn()
58 mcu->reg_ctrl & ~MCU_CTRL_BTN); in shutdown_thread_fn()
74 struct mcu *mcu = glob_mcu; in show_status() local
76 ret = i2c_smbus_read_byte_data(mcu->client, MCU_REG_CTRL); in show_status()
79 mcu->reg_ctrl = ret; in show_status()
87 struct mcu *mcu = glob_mcu; in mcu_power_off() local
90 mutex_lock(&mcu->lock); in mcu_power_off()
91 i2c_smbus_write_byte_data(mcu->client, MCU_REG_CTRL, in mcu_power_off()
92 mcu->reg_ctrl | MCU_CTRL_POFF); in mcu_power_off()
93 mutex_unlock(&mcu->lock); in mcu_power_off()
98 struct mcu *mcu = gpiochip_get_data(gc); in mcu_gpio_set() local
101 mutex_lock(&mcu->lock); in mcu_gpio_set()
103 mcu->reg_ctrl &= ~bit; in mcu_gpio_set()
105 mcu->reg_ctrl |= bit; in mcu_gpio_set()
107 i2c_smbus_write_byte_data(mcu->client, MCU_REG_CTRL, mcu->reg_ctrl); in mcu_gpio_set()
108 mutex_unlock(&mcu->lock); in mcu_gpio_set()
117 static int mcu_gpiochip_add(struct mcu *mcu) in mcu_gpiochip_add() argument
120 struct gpio_chip *gc = &mcu->gc; in mcu_gpiochip_add()
135 return gpiochip_add_data(gc, mcu); in mcu_gpiochip_add()
138 static int mcu_gpiochip_remove(struct mcu *mcu) in mcu_gpiochip_remove() argument
140 kfree(mcu->gc.label); in mcu_gpiochip_remove()
141 gpiochip_remove(&mcu->gc); in mcu_gpiochip_remove()
147 struct mcu *mcu; in mcu_probe() local
150 mcu = kzalloc(sizeof(*mcu), GFP_KERNEL); in mcu_probe()
151 if (!mcu) in mcu_probe()
154 mutex_init(&mcu->lock); in mcu_probe()
155 mcu->client = client; in mcu_probe()
156 i2c_set_clientdata(client, mcu); in mcu_probe()
158 ret = i2c_smbus_read_byte_data(mcu->client, MCU_REG_CTRL); in mcu_probe()
161 mcu->reg_ctrl = ret; in mcu_probe()
163 ret = mcu_gpiochip_add(mcu); in mcu_probe()
169 glob_mcu = mcu; in mcu_probe()
183 kfree(mcu); in mcu_probe()
189 struct mcu *mcu = i2c_get_clientdata(client); in mcu_remove() local
196 if (glob_mcu == mcu) { in mcu_remove()
201 ret = mcu_gpiochip_remove(mcu); in mcu_remove()
204 kfree(mcu); in mcu_remove()