Lines Matching +full:twl4030 +full:- +full:madc

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.
37 #include <linux/mfd/twl4030-audio.h>
39 #include "twl-core.h"
42 * The TWL4030 "Triton 2" is one of a family of a multi-function "Power
60 /* subchip/slave 0 - USB ID */
63 /* subchip/slave 1 - AUD ID */
70 /* subchip/slave 2 - AUX ID */
80 #define TWL5031_BASEADD_INTERRUPTS 0x00B9 /* Different than TWL4030's
83 /* subchip/slave 3 - POWER ID */
98 /* subchip/slave 0 0x48 - POWER */
106 /* subchip/slave 1 0x49 - FEATURE */
117 /* subchip/slave 2 0x4A - DFT */
120 /* subchip/slave 3 0x4B - AUDIO */
135 /*----------------------------------------------------------------------*/
137 /* Structure for each TWL4030/TWL6030 Slave */
179 /* TWL4030 specific IPs */
261 /* 0x40 - 0x42 Unused */
382 /*----------------------------------------------------------------------*/
387 return 4; /* TWL4030 class have four slave address */ in twl_get_num_slaves()
404 return twl_priv ? twl_priv->twl_id : 0; in twl_rev()
409 * twl_get_regmap - Get the regmap associated with the given module
419 if (unlikely(!twl_priv || !twl_priv->ready)) { in twl_get_regmap()
428 sid = twl_priv->twl_map[mod_no].sid; in twl_get_regmap()
429 twl = &twl_priv->twl_modules[sid]; in twl_get_regmap()
431 return twl->regmap; in twl_get_regmap()
435 * twl_i2c_write - Writes a n bit register in TWL4030/TWL5030/TWL60X0
449 return -EPERM; in twl_i2c_write()
451 ret = regmap_bulk_write(regmap, twl_priv->twl_map[mod_no].base + reg, in twl_i2c_write()
463 * twl_i2c_read - Reads a n bit register in TWL4030/TWL5030/TWL60X0
477 return -EPERM; in twl_i2c_read()
479 ret = regmap_bulk_read(regmap, twl_priv->twl_map[mod_no].base + reg, in twl_i2c_read()
491 * twl_set_regcache_bypass - Configure the regcache bypass for the regmap associated
503 return -EPERM; in twl_set_regcache_bypass()
511 /*----------------------------------------------------------------------*/
514 * twl_read_idcode_register - API to read the IDCODE register.
525 pr_err("TWL4030 Unable to unlock IDCODE registers -%d\n", err); in twl_read_idcode_register()
529 err = twl_i2c_read(TWL4030_MODULE_INTBR, (u8 *)(&twl_priv->twl_idcode), in twl_read_idcode_register()
532 pr_err("TWL4030: unable to read IDCODE -%d\n", err); in twl_read_idcode_register()
538 pr_err("TWL4030 Unable to relock IDCODE registers -%d\n", err); in twl_read_idcode_register()
544 * twl_get_type - API to get TWL Si type.
550 return TWL_SIL_TYPE(twl_priv->twl_idcode); in twl_get_type()
555 * twl_get_version - API to get TWL Si version.
561 return TWL_SIL_REV(twl_priv->twl_idcode); in twl_get_version()
566 * twl_get_hfclk_rate - API to get TWL external HFCLK clock rate.
588 pr_err("TWL4030: HFCLK is not configured\n"); in twl_get_hfclk_rate()
589 rate = -EINVAL; in twl_get_hfclk_rate()
597 /*----------------------------------------------------------------------*/
600 * These three functions initialize the on-chip clock framework,
601 * letting it generate the right frequencies for USB, MADC, and
657 /* effect->MADC+USB ck en */ in clocks_init()
665 /*----------------------------------------------------------------------*/
679 struct twl_client *twl = &twl_priv->twl_modules[i]; in twl_remove()
681 if (twl->client && twl->client != client) in twl_remove()
682 i2c_unregister_device(twl->client); in twl_remove()
683 twl->client = NULL; in twl_remove()
685 twl_priv->ready = false; in twl_remove()
689 OF_DEV_AUXDATA("ti,twl4030-gpio", 0, "twl4030-gpio", NULL),
693 /* NOTE: This driver only handles a single twl4030/tps659x0 chip */
698 struct device_node *node = client->dev.of_node; in twl_probe()
706 dev_err(&client->dev, "no platform data\n"); in twl_probe()
707 return -EINVAL; in twl_probe()
711 dev_dbg(&client->dev, "only one instance of %s allowed\n", in twl_probe()
713 return -EBUSY; in twl_probe()
716 pdev = platform_device_alloc(DRIVER_NAME, -1); in twl_probe()
718 dev_err(&client->dev, "can't alloc pdev\n"); in twl_probe()
719 return -ENOMEM; in twl_probe()
728 if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C) == 0) { in twl_probe()
729 dev_dbg(&client->dev, "can't talk I2C?\n"); in twl_probe()
730 status = -EIO; in twl_probe()
734 twl_priv = devm_kzalloc(&client->dev, sizeof(struct twl_private), in twl_probe()
737 status = -ENOMEM; in twl_probe()
741 if ((id->driver_data) & TWL6030_CLASS) { in twl_probe()
742 twl_priv->twl_id = TWL6030_CLASS_ID; in twl_probe()
743 twl_priv->twl_map = &twl6030_map[0]; in twl_probe()
746 twl_priv->twl_id = TWL4030_CLASS_ID; in twl_probe()
747 twl_priv->twl_map = &twl4030_map[0]; in twl_probe()
752 twl_priv->twl_modules = devm_kcalloc(&client->dev, in twl_probe()
756 if (!twl_priv->twl_modules) { in twl_probe()
757 status = -ENOMEM; in twl_probe()
762 struct twl_client *twl = &twl_priv->twl_modules[i]; in twl_probe()
765 twl->client = client; in twl_probe()
767 twl->client = i2c_new_dummy_device(client->adapter, in twl_probe()
768 client->addr + i); in twl_probe()
769 if (IS_ERR(twl->client)) { in twl_probe()
770 dev_err(&client->dev, in twl_probe()
772 status = PTR_ERR(twl->client); in twl_probe()
777 twl->regmap = devm_regmap_init_i2c(twl->client, in twl_probe()
779 if (IS_ERR(twl->regmap)) { in twl_probe()
780 status = PTR_ERR(twl->regmap); in twl_probe()
781 dev_err(&client->dev, in twl_probe()
788 twl_priv->ready = true; in twl_probe()
791 clocks_init(&client->dev); in twl_probe()
800 if (client->irq) { in twl_probe()
802 twl4030_init_chip_irq(id->name); in twl_probe()
803 irq_base = twl4030_init_irq(&client->dev, client->irq); in twl_probe()
805 irq_base = twl6030_init_irq(&client->dev, client->irq); in twl_probe()
815 * Disable TWL4030/TWL5030 I2C Pull-up on I2C1 and I2C4(SR) interface. in twl_probe()
840 &client->dev); in twl_probe()
856 if (client->irq) in twl_suspend()
857 disable_irq(client->irq); in twl_suspend()
866 if (client->irq) in twl_resume()
867 enable_irq(client->irq); in twl_resume()
875 { "twl4030", TWL4030_VAUX2 }, /* "Triton 2" */