Lines Matching +full:slave +full:- +full:addr
1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright 2011-2012 Texas Instruments Inc.
328 struct palmas_pmic_driver_data *pmic_ddata = palmas->pmic_ddata; in palmas_ext_control_req_config()
350 bit_pos = pmic_ddata->sleep_req_info[id].bit_pos; in palmas_ext_control_req_config()
351 reg_add += pmic_ddata->sleep_req_info[id].reg_offset; in palmas_ext_control_req_config()
359 dev_err(palmas->dev, "Resource reg 0x%02x update failed %d\n", in palmas_ext_control_req_config()
368 dev_err(palmas->dev, "POWER_CTRL register update failed %d\n", in palmas_ext_control_req_config()
379 struct irq_data *irq_data = irq_get_irq_data(i2c->irq); in palmas_set_pdata_irq_flag()
381 dev_err(&i2c->dev, "Invalid IRQ: %d\n", i2c->irq); in palmas_set_pdata_irq_flag()
382 return -EINVAL; in palmas_set_pdata_irq_flag()
385 pdata->irq_flags = irqd_get_trigger_type(irq_data); in palmas_set_pdata_irq_flag()
386 dev_info(&i2c->dev, "Irq flag is 0x%08x\n", pdata->irq_flags); in palmas_set_pdata_irq_flag()
393 struct device_node *node = i2c->dev.of_node; in palmas_dt_to_pdata()
397 ret = of_property_read_u32(node, "ti,mux-pad1", &prop); in palmas_dt_to_pdata()
399 pdata->mux_from_pdata = 1; in palmas_dt_to_pdata()
400 pdata->pad1 = prop; in palmas_dt_to_pdata()
403 ret = of_property_read_u32(node, "ti,mux-pad2", &prop); in palmas_dt_to_pdata()
405 pdata->mux_from_pdata = 1; in palmas_dt_to_pdata()
406 pdata->pad2 = prop; in palmas_dt_to_pdata()
410 ret = of_property_read_u32(node, "ti,power-ctrl", &prop); in palmas_dt_to_pdata()
412 pdata->power_ctrl = prop; in palmas_dt_to_pdata()
414 pdata->power_ctrl = PALMAS_POWER_CTRL_NSLEEP_MASK | in palmas_dt_to_pdata()
417 if (i2c->irq) in palmas_dt_to_pdata()
420 pdata->pm_off = of_property_read_bool(node, in palmas_dt_to_pdata()
421 "ti,system-power-controller"); in palmas_dt_to_pdata()
427 unsigned int addr; in palmas_power_off() local
428 int ret, slave; in palmas_power_off() local
430 struct device_node *np = palmas_dev->dev->of_node; in palmas_power_off()
432 if (of_property_read_bool(np, "ti,palmas-override-powerhold")) { in palmas_power_off()
433 addr = PALMAS_BASE_TO_REG(PALMAS_PU_PD_OD_BASE, in palmas_power_off()
435 slave = PALMAS_BASE_TO_SLAVE(PALMAS_PU_PD_OD_BASE); in palmas_power_off()
444 ret = regmap_update_bits(palmas_dev->regmap[slave], addr, in palmas_power_off()
447 dev_err(palmas_dev->dev, in palmas_power_off()
452 slave = PALMAS_BASE_TO_SLAVE(PALMAS_PMU_CONTROL_BASE); in palmas_power_off()
453 addr = PALMAS_BASE_TO_REG(PALMAS_PMU_CONTROL_BASE, PALMAS_DEV_CTRL); in palmas_power_off()
456 palmas_dev->regmap[slave], in palmas_power_off()
457 addr, in palmas_power_off()
489 struct device_node *node = i2c->dev.of_node; in palmas_i2c_probe()
491 unsigned int reg, addr; in palmas_i2c_probe() local
492 int slave; in palmas_i2c_probe() local
494 pdata = dev_get_platdata(&i2c->dev); in palmas_i2c_probe()
497 pdata = devm_kzalloc(&i2c->dev, sizeof(*pdata), GFP_KERNEL); in palmas_i2c_probe()
500 return -ENOMEM; in palmas_i2c_probe()
506 return -EINVAL; in palmas_i2c_probe()
508 palmas = devm_kzalloc(&i2c->dev, sizeof(struct palmas), GFP_KERNEL); in palmas_i2c_probe()
510 return -ENOMEM; in palmas_i2c_probe()
513 palmas->dev = &i2c->dev; in palmas_i2c_probe()
514 palmas->irq = i2c->irq; in palmas_i2c_probe()
517 palmas->features = driver_data->features; in palmas_i2c_probe()
521 palmas->i2c_clients[i] = i2c; in palmas_i2c_probe()
523 palmas->i2c_clients[i] = in palmas_i2c_probe()
524 i2c_new_dummy_device(i2c->adapter, in palmas_i2c_probe()
525 i2c->addr + i); in palmas_i2c_probe()
526 if (IS_ERR(palmas->i2c_clients[i])) { in palmas_i2c_probe()
527 dev_err(palmas->dev, in palmas_i2c_probe()
529 ret = PTR_ERR(palmas->i2c_clients[i]); in palmas_i2c_probe()
532 palmas->i2c_clients[i]->dev.of_node = of_node_get(node); in palmas_i2c_probe()
534 palmas->regmap[i] = devm_regmap_init_i2c(palmas->i2c_clients[i], in palmas_i2c_probe()
536 if (IS_ERR(palmas->regmap[i])) { in palmas_i2c_probe()
537 ret = PTR_ERR(palmas->regmap[i]); in palmas_i2c_probe()
538 dev_err(palmas->dev, in palmas_i2c_probe()
545 if (!palmas->irq) { in palmas_i2c_probe()
546 dev_warn(palmas->dev, "IRQ missing: skipping irq request\n"); in palmas_i2c_probe()
551 if (pdata->irq_flags & IRQ_TYPE_LEVEL_HIGH) in palmas_i2c_probe()
559 dev_err(palmas->dev, "POLARITY_CTRL update failed: %d\n", ret); in palmas_i2c_probe()
564 slave = PALMAS_BASE_TO_SLAVE(PALMAS_INTERRUPT_BASE); in palmas_i2c_probe()
565 addr = PALMAS_BASE_TO_REG(PALMAS_INTERRUPT_BASE, PALMAS_INT_CTRL); in palmas_i2c_probe()
568 regmap_write(palmas->regmap[slave], addr, reg); in palmas_i2c_probe()
570 ret = regmap_add_irq_chip(palmas->regmap[slave], palmas->irq, in palmas_i2c_probe()
571 IRQF_ONESHOT | pdata->irq_flags, 0, in palmas_i2c_probe()
572 driver_data->irq_chip, &palmas->irq_data); in palmas_i2c_probe()
577 slave = PALMAS_BASE_TO_SLAVE(PALMAS_PU_PD_OD_BASE); in palmas_i2c_probe()
578 addr = PALMAS_BASE_TO_REG(PALMAS_PU_PD_OD_BASE, in palmas_i2c_probe()
581 if (pdata->mux_from_pdata) { in palmas_i2c_probe()
582 reg = pdata->pad1; in palmas_i2c_probe()
583 ret = regmap_write(palmas->regmap[slave], addr, reg); in palmas_i2c_probe()
587 ret = regmap_read(palmas->regmap[slave], addr, ®); in palmas_i2c_probe()
593 palmas->gpio_muxed |= PALMAS_GPIO_0_MUXED; in palmas_i2c_probe()
595 palmas->gpio_muxed |= PALMAS_GPIO_1_MUXED; in palmas_i2c_probe()
598 palmas->led_muxed |= PALMAS_LED1_MUXED; in palmas_i2c_probe()
601 palmas->pwm_muxed |= PALMAS_PWM1_MUXED; in palmas_i2c_probe()
603 palmas->gpio_muxed |= PALMAS_GPIO_2_MUXED; in palmas_i2c_probe()
606 palmas->led_muxed |= PALMAS_LED2_MUXED; in palmas_i2c_probe()
609 palmas->pwm_muxed |= PALMAS_PWM2_MUXED; in palmas_i2c_probe()
611 palmas->gpio_muxed |= PALMAS_GPIO_3_MUXED; in palmas_i2c_probe()
613 addr = PALMAS_BASE_TO_REG(PALMAS_PU_PD_OD_BASE, in palmas_i2c_probe()
616 if (pdata->mux_from_pdata) { in palmas_i2c_probe()
617 reg = pdata->pad2; in palmas_i2c_probe()
618 ret = regmap_write(palmas->regmap[slave], addr, reg); in palmas_i2c_probe()
622 ret = regmap_read(palmas->regmap[slave], addr, ®); in palmas_i2c_probe()
628 palmas->gpio_muxed |= PALMAS_GPIO_4_MUXED; in palmas_i2c_probe()
630 palmas->gpio_muxed |= PALMAS_GPIO_5_MUXED; in palmas_i2c_probe()
632 palmas->gpio_muxed |= PALMAS_GPIO_6_MUXED; in palmas_i2c_probe()
634 palmas->gpio_muxed |= PALMAS_GPIO_7_MUXED; in palmas_i2c_probe()
636 dev_info(palmas->dev, "Muxing GPIO %x, PWM %x, LED %x\n", in palmas_i2c_probe()
637 palmas->gpio_muxed, palmas->pwm_muxed, in palmas_i2c_probe()
638 palmas->led_muxed); in palmas_i2c_probe()
640 reg = pdata->power_ctrl; in palmas_i2c_probe()
642 slave = PALMAS_BASE_TO_SLAVE(PALMAS_PMU_CONTROL_BASE); in palmas_i2c_probe()
643 addr = PALMAS_BASE_TO_REG(PALMAS_PMU_CONTROL_BASE, PALMAS_POWER_CTRL); in palmas_i2c_probe()
645 ret = regmap_write(palmas->regmap[slave], addr, reg); in palmas_i2c_probe()
654 ret = devm_of_platform_populate(&i2c->dev); in palmas_i2c_probe()
657 } else if (pdata->pm_off && !pm_power_off) { in palmas_i2c_probe()
666 regmap_del_irq_chip(palmas->irq, palmas->irq_data); in palmas_i2c_probe()
669 if (palmas->i2c_clients[i]) in palmas_i2c_probe()
670 i2c_unregister_device(palmas->i2c_clients[i]); in palmas_i2c_probe()
680 regmap_del_irq_chip(palmas->irq, palmas->irq_data); in palmas_i2c_remove()
683 if (palmas->i2c_clients[i]) in palmas_i2c_remove()
684 i2c_unregister_device(palmas->i2c_clients[i]); in palmas_i2c_remove()
734 MODULE_DESCRIPTION("Palmas chip family multi-function driver");