Lines Matching +full:twl6030 +full:- +full:charger
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * twl_core.c - driver for TWL4030/TWL5030/TWL60X0/TPS659x0 PM
6 * Copyright (C) 2005-2006 Texas Instruments, Inc.
39 #include <linux/mfd/twl4030-audio.h>
41 #include "twl-core.h"
44 * The TWL4030 "Triton 2" is one of a family of a multi-function "Power
62 /* subchip/slave 0 - USB ID */
65 /* subchip/slave 1 - AUD ID */
72 /* subchip/slave 2 - AUX ID */
85 /* subchip/slave 3 - POWER ID */
100 /* subchip/slave 0 0x48 - POWER */
108 /* subchip/slave 1 0x49 - FEATURE */
119 /* subchip/slave 2 0x4A - DFT */
122 /* subchip/slave 3 0x4B - AUDIO */
142 /*----------------------------------------------------------------------*/
144 /* Structure for each TWL4030/TWL6030 Slave */
268 /* 0x40 - 0x42 Unused */
357 /* TWL6030 specific IPs */
364 /* TWL6032 specific charger registers */
389 /*----------------------------------------------------------------------*/
396 return 3; /* TWL6030 class have three slave address */ in twl_get_num_slaves()
411 return twl_priv ? twl_priv->twl_id : 0; in twl_rev()
416 * twl_get_regmap - Get the regmap associated with the given module
426 if (unlikely(!twl_priv || !twl_priv->ready)) { in twl_get_regmap()
435 sid = twl_priv->twl_map[mod_no].sid; in twl_get_regmap()
436 twl = &twl_priv->twl_modules[sid]; in twl_get_regmap()
438 return twl->regmap; in twl_get_regmap()
442 * twl_i2c_write - Writes a n bit register in TWL4030/TWL5030/TWL60X0
456 return -EPERM; in twl_i2c_write()
458 ret = regmap_bulk_write(regmap, twl_priv->twl_map[mod_no].base + reg, in twl_i2c_write()
470 * twl_i2c_read - Reads a n bit register in TWL4030/TWL5030/TWL60X0
484 return -EPERM; in twl_i2c_read()
486 ret = regmap_bulk_read(regmap, twl_priv->twl_map[mod_no].base + reg, in twl_i2c_read()
498 * twl_set_regcache_bypass - Configure the regcache bypass for the regmap associated
510 return -EPERM; in twl_set_regcache_bypass()
518 /*----------------------------------------------------------------------*/
521 * twl_read_idcode_register - API to read the IDCODE register.
532 pr_err("TWL4030 Unable to unlock IDCODE registers -%d\n", err); in twl_read_idcode_register()
536 err = twl_i2c_read(TWL4030_MODULE_INTBR, (u8 *)(&twl_priv->twl_idcode), in twl_read_idcode_register()
539 pr_err("TWL4030: unable to read IDCODE -%d\n", err); in twl_read_idcode_register()
545 pr_err("TWL4030 Unable to relock IDCODE registers -%d\n", err); in twl_read_idcode_register()
551 * twl_get_type - API to get TWL Si type.
557 return TWL_SIL_TYPE(twl_priv->twl_idcode); in twl_get_type()
562 * twl_get_version - API to get TWL Si version.
568 return TWL_SIL_REV(twl_priv->twl_idcode); in twl_get_version()
573 * twl_get_hfclk_rate - API to get TWL external HFCLK clock rate.
596 rate = -EINVAL; in twl_get_hfclk_rate()
604 /*----------------------------------------------------------------------*/
607 * These three functions initialize the on-chip clock framework,
664 /* effect->MADC+USB ck en */ in clocks_init()
672 /*----------------------------------------------------------------------*/
686 struct twl_client *twl = &twl_priv->twl_modules[i]; in twl_remove()
688 if (twl->client && twl->client != client) in twl_remove()
689 i2c_unregister_device(twl->client); in twl_remove()
690 twl->client = NULL; in twl_remove()
692 twl_priv->ready = false; in twl_remove()
710 OF_DEV_AUXDATA("ti,twl4030-gpio", 0, "twl4030-gpio", NULL),
715 { .name = "twl6030-clk" },
719 { .name = "twl6032-clk" },
727 struct device_node *node = client->dev.of_node; in twl_probe()
735 dev_err(&client->dev, "no platform data\n"); in twl_probe()
736 return -EINVAL; in twl_probe()
740 dev_dbg(&client->dev, "only one instance of %s allowed\n", in twl_probe()
742 return -EBUSY; in twl_probe()
745 pdev = platform_device_alloc(DRIVER_NAME, -1); in twl_probe()
747 dev_err(&client->dev, "can't alloc pdev\n"); in twl_probe()
748 return -ENOMEM; in twl_probe()
757 if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C) == 0) { in twl_probe()
758 dev_dbg(&client->dev, "can't talk I2C?\n"); in twl_probe()
759 status = -EIO; in twl_probe()
763 twl_priv = devm_kzalloc(&client->dev, sizeof(struct twl_private), in twl_probe()
766 status = -ENOMEM; in twl_probe()
770 if ((id->driver_data) & TWL6030_CLASS) { in twl_probe()
771 twl_priv->twl_id = TWL6030_CLASS_ID; in twl_probe()
772 twl_priv->twl_map = &twl6030_map[0]; in twl_probe()
775 twl_priv->twl_id = TWL4030_CLASS_ID; in twl_probe()
776 twl_priv->twl_map = &twl4030_map[0]; in twl_probe()
781 twl_priv->twl_modules = devm_kcalloc(&client->dev, in twl_probe()
785 if (!twl_priv->twl_modules) { in twl_probe()
786 status = -ENOMEM; in twl_probe()
791 struct twl_client *twl = &twl_priv->twl_modules[i]; in twl_probe()
794 twl->client = client; in twl_probe()
796 twl->client = i2c_new_dummy_device(client->adapter, in twl_probe()
797 client->addr + i); in twl_probe()
798 if (IS_ERR(twl->client)) { in twl_probe()
799 dev_err(&client->dev, in twl_probe()
801 status = PTR_ERR(twl->client); in twl_probe()
806 twl->regmap = devm_regmap_init_i2c(twl->client, in twl_probe()
808 if (IS_ERR(twl->regmap)) { in twl_probe()
809 status = PTR_ERR(twl->regmap); in twl_probe()
810 dev_err(&client->dev, in twl_probe()
817 twl_priv->ready = true; in twl_probe()
820 clocks_init(&client->dev); in twl_probe()
829 if (client->irq) { in twl_probe()
831 twl4030_init_chip_irq(id->name); in twl_probe()
832 irq_base = twl4030_init_irq(&client->dev, client->irq); in twl_probe()
834 irq_base = twl6030_init_irq(&client->dev, client->irq); in twl_probe()
844 * Disable TWL4030/TWL5030 I2C Pull-up on I2C1 and I2C4(SR) interface. in twl_probe()
872 if (id->driver_data & TWL6032_SUBCLASS) { in twl_probe()
880 status = devm_mfd_add_devices(&client->dev, PLATFORM_DEVID_NONE, in twl_probe()
889 dev_warn(&client->dev, "Poweroff callback already assigned\n"); in twl_probe()
894 &client->dev); in twl_probe()
910 if (client->irq) in twl_suspend()
911 disable_irq(client->irq); in twl_suspend()
920 if (client->irq) in twl_resume()
921 enable_irq(client->irq); in twl_resume()
933 { "tps65930", TPS_SUBSET }, /* fewer LDOs and DACs; no charger */
934 { "tps65920", TPS_SUBSET }, /* fewer LDOs; no codec or charger */
936 and vibrator. Charger in USB module*/
937 { "twl6030", TWL6030_CLASS }, /* "Phoenix power chip" */