Lines Matching refs:chip

41 static void lp55xx_reset_device(struct lp55xx_chip *chip)  in lp55xx_reset_device()  argument
43 struct lp55xx_device_config *cfg = chip->cfg; in lp55xx_reset_device()
48 lp55xx_write(chip, addr, val); in lp55xx_reset_device()
51 static int lp55xx_detect_device(struct lp55xx_chip *chip) in lp55xx_detect_device() argument
53 struct lp55xx_device_config *cfg = chip->cfg; in lp55xx_detect_device()
58 ret = lp55xx_write(chip, addr, val); in lp55xx_detect_device()
64 ret = lp55xx_read(chip, addr, &val); in lp55xx_detect_device()
74 static int lp55xx_post_init_device(struct lp55xx_chip *chip) in lp55xx_post_init_device() argument
76 struct lp55xx_device_config *cfg = chip->cfg; in lp55xx_post_init_device()
81 return cfg->post_init_device(chip); in lp55xx_post_init_device()
98 struct lp55xx_chip *chip = led->chip; in lp55xx_store_current() local
107 if (!chip->cfg->set_led_current) in lp55xx_store_current()
110 mutex_lock(&chip->lock); in lp55xx_store_current()
111 chip->cfg->set_led_current(led, (u8)curr); in lp55xx_store_current()
112 mutex_unlock(&chip->lock); in lp55xx_store_current()
147 struct lp55xx_chip *chip, int chan) in lp55xx_init_led() argument
149 struct lp55xx_platform_data *pdata = chip->pdata; in lp55xx_init_led()
150 struct lp55xx_device_config *cfg = chip->cfg; in lp55xx_init_led()
151 struct device *dev = &chip->cl->dev; in lp55xx_init_led()
182 pdata->label ? : chip->cl->name, chan); in lp55xx_init_led()
197 struct lp55xx_chip *chip = context; in lp55xx_firmware_loaded() local
198 struct device *dev = &chip->cl->dev; in lp55xx_firmware_loaded()
199 enum lp55xx_engine_index idx = chip->engine_idx; in lp55xx_firmware_loaded()
207 mutex_lock(&chip->lock); in lp55xx_firmware_loaded()
209 chip->engines[idx - 1].mode = LP55XX_ENGINE_LOAD; in lp55xx_firmware_loaded()
210 chip->fw = fw; in lp55xx_firmware_loaded()
211 if (chip->cfg->firmware_cb) in lp55xx_firmware_loaded()
212 chip->cfg->firmware_cb(chip); in lp55xx_firmware_loaded()
214 mutex_unlock(&chip->lock); in lp55xx_firmware_loaded()
218 release_firmware(chip->fw); in lp55xx_firmware_loaded()
221 static int lp55xx_request_firmware(struct lp55xx_chip *chip) in lp55xx_request_firmware() argument
223 const char *name = chip->cl->name; in lp55xx_request_firmware()
224 struct device *dev = &chip->cl->dev; in lp55xx_request_firmware()
227 GFP_KERNEL, chip, lp55xx_firmware_loaded); in lp55xx_request_firmware()
235 struct lp55xx_chip *chip = led->chip; in lp55xx_show_engine_select() local
237 return sprintf(buf, "%d\n", chip->engine_idx); in lp55xx_show_engine_select()
245 struct lp55xx_chip *chip = led->chip; in lp55xx_store_engine_select() local
258 mutex_lock(&chip->lock); in lp55xx_store_engine_select()
259 chip->engine_idx = val; in lp55xx_store_engine_select()
260 ret = lp55xx_request_firmware(chip); in lp55xx_store_engine_select()
261 mutex_unlock(&chip->lock); in lp55xx_store_engine_select()
276 static inline void lp55xx_run_engine(struct lp55xx_chip *chip, bool start) in lp55xx_run_engine() argument
278 if (chip->cfg->run_engine) in lp55xx_run_engine()
279 chip->cfg->run_engine(chip, start); in lp55xx_run_engine()
287 struct lp55xx_chip *chip = led->chip; in lp55xx_store_engine_run() local
296 lp55xx_run_engine(chip, false); in lp55xx_store_engine_run()
300 mutex_lock(&chip->lock); in lp55xx_store_engine_run()
301 lp55xx_run_engine(chip, true); in lp55xx_store_engine_run()
302 mutex_unlock(&chip->lock); in lp55xx_store_engine_run()
321 int lp55xx_write(struct lp55xx_chip *chip, u8 reg, u8 val) in lp55xx_write() argument
323 return i2c_smbus_write_byte_data(chip->cl, reg, val); in lp55xx_write()
327 int lp55xx_read(struct lp55xx_chip *chip, u8 reg, u8 *val) in lp55xx_read() argument
331 ret = i2c_smbus_read_byte_data(chip->cl, reg); in lp55xx_read()
340 int lp55xx_update_bits(struct lp55xx_chip *chip, u8 reg, u8 mask, u8 val) in lp55xx_update_bits() argument
345 ret = lp55xx_read(chip, reg, &tmp); in lp55xx_update_bits()
352 return lp55xx_write(chip, reg, tmp); in lp55xx_update_bits()
356 bool lp55xx_is_extclk_used(struct lp55xx_chip *chip) in lp55xx_is_extclk_used() argument
361 clk = devm_clk_get(&chip->cl->dev, "32k_clk"); in lp55xx_is_extclk_used()
374 dev_info(&chip->cl->dev, "%dHz external clock used\n", LP55XX_CLK_32K); in lp55xx_is_extclk_used()
376 chip->clk = clk; in lp55xx_is_extclk_used()
380 dev_info(&chip->cl->dev, "internal clock used\n"); in lp55xx_is_extclk_used()
385 int lp55xx_init_device(struct lp55xx_chip *chip) in lp55xx_init_device() argument
389 struct device *dev = &chip->cl->dev; in lp55xx_init_device()
392 WARN_ON(!chip); in lp55xx_init_device()
394 pdata = chip->pdata; in lp55xx_init_device()
395 cfg = chip->cfg; in lp55xx_init_device()
415 lp55xx_reset_device(chip); in lp55xx_init_device()
423 ret = lp55xx_detect_device(chip); in lp55xx_init_device()
430 ret = lp55xx_post_init_device(chip); in lp55xx_init_device()
439 lp55xx_deinit_device(chip); in lp55xx_init_device()
445 void lp55xx_deinit_device(struct lp55xx_chip *chip) in lp55xx_deinit_device() argument
447 struct lp55xx_platform_data *pdata = chip->pdata; in lp55xx_deinit_device()
449 if (chip->clk) in lp55xx_deinit_device()
450 clk_disable_unprepare(chip->clk); in lp55xx_deinit_device()
457 int lp55xx_register_leds(struct lp55xx_led *led, struct lp55xx_chip *chip) in lp55xx_register_leds() argument
459 struct lp55xx_platform_data *pdata = chip->pdata; in lp55xx_register_leds()
460 struct lp55xx_device_config *cfg = chip->cfg; in lp55xx_register_leds()
468 dev_err(&chip->cl->dev, "empty brightness configuration\n"); in lp55xx_register_leds()
480 ret = lp55xx_init_led(each, chip, i); in lp55xx_register_leds()
486 chip->num_leds++; in lp55xx_register_leds()
487 each->chip = chip; in lp55xx_register_leds()
497 lp55xx_unregister_leds(led, chip); in lp55xx_register_leds()
502 void lp55xx_unregister_leds(struct lp55xx_led *led, struct lp55xx_chip *chip) in lp55xx_unregister_leds() argument
507 for (i = 0; i < chip->num_leds; i++) { in lp55xx_unregister_leds()
515 int lp55xx_register_sysfs(struct lp55xx_chip *chip) in lp55xx_register_sysfs() argument
517 struct device *dev = &chip->cl->dev; in lp55xx_register_sysfs()
518 struct lp55xx_device_config *cfg = chip->cfg; in lp55xx_register_sysfs()
534 void lp55xx_unregister_sysfs(struct lp55xx_chip *chip) in lp55xx_unregister_sysfs() argument
536 struct device *dev = &chip->cl->dev; in lp55xx_unregister_sysfs()
537 struct lp55xx_device_config *cfg = chip->cfg; in lp55xx_unregister_sysfs()