Lines Matching refs:tca

261 static void set_select(struct tca6507_chip *tca, int led, int val)
267 int n = tca->reg_file[bit] & ~mask;
270 if (tca->reg_file[bit] != n) {
271 tca->reg_file[bit] = n;
272 tca->reg_set |= (1 << bit);
281 static void set_code(struct tca6507_chip *tca, int reg, int bank, int new)
289 n = tca->reg_file[reg] & ~mask;
291 if (tca->reg_file[reg] != n) {
292 tca->reg_file[reg] = n;
293 tca->reg_set |= 1 << reg;
298 static void set_level(struct tca6507_chip *tca, int bank, int level)
303 set_code(tca, TCA6507_MAX_INTENSITY, bank, level);
306 set_code(tca, TCA6507_MASTER_INTENSITY, 0, level);
309 tca->bank[bank].level = level;
313 static void set_times(struct tca6507_chip *tca, int bank)
318 result = choose_times(tca->bank[bank].ontime, &c1, &c2);
321 dev_dbg(&tca->client->dev,
324 c2, time_codes[c2], tca->bank[bank].ontime);
325 set_code(tca, TCA6507_FADE_ON, bank, c2);
326 set_code(tca, TCA6507_FULL_ON, bank, c1);
327 tca->bank[bank].ontime = result;
329 result = choose_times(tca->bank[bank].offtime, &c1, &c2);
330 dev_dbg(&tca->client->dev,
333 c2, time_codes[c2], tca->bank[bank].offtime);
334 set_code(tca, TCA6507_FADE_OFF, bank, c2);
335 set_code(tca, TCA6507_FIRST_OFF, bank, c1);
336 set_code(tca, TCA6507_SECOND_OFF, bank, c1);
337 tca->bank[bank].offtime = result;
339 set_code(tca, TCA6507_INITIALIZE, bank, INIT_CODE);
346 struct tca6507_chip *tca = container_of(work, struct tca6507_chip,
348 struct i2c_client *cl = tca->client;
353 spin_lock_irq(&tca->lock);
354 set = tca->reg_set;
355 memcpy(file, tca->reg_file, TCA6507_REG_CNT);
356 tca->reg_set = 0;
357 spin_unlock_irq(&tca->lock);
367 struct tca6507_chip *tca = led->chip;
369 struct bank *b = tca->bank + led->bank;
383 struct tca6507_chip *tca = led->chip;
391 set_select(tca, led->num, TCA6507_LS_LED_OFF);
406 set_select(tca, led->num, TCA6507_LS_LED_ON);
412 if (tca->bank[i].level == level ||
413 tca->bank[i].level_use == 0) {
417 d = abs(level - tca->bank[i].level);
425 set_select(tca, led->num, TCA6507_LS_LED_ON);
430 if (!tca->bank[best].level_use)
431 set_level(tca, best, level);
433 tca->bank[best].level_use++;
435 set_select(tca, led->num, bank_source[best]);
436 led->led_cdev.brightness = TO_BRIGHT(tca->bank[best].level);
451 if (tca->bank[i].level_use == 0)
454 if (tca->bank[i].level != level)
461 if (tca->bank[i].time_use == 0)
465 if (!(tca->bank[i].on_dflt ||
467 tca->bank[i].ontime == led->ontime))
471 if (!(tca->bank[i].off_dflt ||
473 tca->bank[i].offtime == led->offtime))
485 b = &tca->bank[i];
487 set_level(tca, i, level);
508 set_times(tca, i);
516 set_select(tca, led->num, blink_source[i]);
522 struct tca6507_chip *tca = led->chip;
526 spin_lock_irqsave(&tca->lock, flags);
538 spin_unlock_irqrestore(&tca->lock, flags);
540 if (tca->reg_set)
541 schedule_work(&tca->work);
597 struct tca6507_chip *tca = gpiochip_get_data(gc);
600 spin_lock_irqsave(&tca->lock, flags);
605 set_select(tca, tca->gpio_map[offset],
607 spin_unlock_irqrestore(&tca->lock, flags);
608 if (tca->reg_set)
609 schedule_work(&tca->work);
620 struct tca6507_chip *tca,
630 tca->gpio_map[gpios] = i;
637 tca->gpio.label = "gpio-tca6507";
638 tca->gpio.ngpio = gpios;
639 tca->gpio.base = pdata->gpio_base;
640 tca->gpio.owner = THIS_MODULE;
641 tca->gpio.direction_output = tca6507_gpio_direction_output;
642 tca->gpio.set = tca6507_gpio_set_value;
643 tca->gpio.parent = dev;
644 err = gpiochip_add_data(&tca->gpio, tca);
646 tca->gpio.ngpio = 0;
652 static void tca6507_remove_gpio(struct tca6507_chip *tca)
654 if (tca->gpio.ngpio)
655 gpiochip_remove(&tca->gpio);
659 struct tca6507_chip *tca,
664 static void tca6507_remove_gpio(struct tca6507_chip *tca)
735 struct tca6507_chip *tca;
750 tca = devm_kzalloc(dev, sizeof(*tca), GFP_KERNEL);
751 if (!tca)
754 tca->client = client;
755 INIT_WORK(&tca->work, tca6507_work);
756 spin_lock_init(&tca->lock);
757 i2c_set_clientdata(client, tca);
760 struct tca6507_led *l = tca->leds + i;
762 l->chip = tca;
776 err = tca6507_probe_gpios(dev, tca, pdata);
780 tca->reg_set = 0x7f;
781 schedule_work(&tca->work);
786 if (tca->leds[i].led_cdev.name)
787 led_classdev_unregister(&tca->leds[i].led_cdev);
795 struct tca6507_chip *tca = i2c_get_clientdata(client);
796 struct tca6507_led *tca_leds = tca->leds;
802 tca6507_remove_gpio(tca);
803 cancel_work_sync(&tca->work);