Lines Matching +full:2 +full:x32 +full:- +full:bit
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 */
92 #define SMARTREFLEX_ENABLE BIT(3)
100 /* subchip/slave 0 0x48 - POWER */
108 /* subchip/slave 1 0x49 - FEATURE */
119 /* subchip/slave 2 0x4A - DFT */
122 /* subchip/slave 3 0x4B - AUDIO */
128 #define TWL6030_APP_DEVOFF BIT(0)
129 #define TWL6030_CON_DEVOFF BIT(1)
130 #define TWL6030_MOD_DEVOFF BIT(2)
137 #define HFCLK_FREQ_26_MHZ (2 << 0)
142 /*----------------------------------------------------------------------*/
177 { 2, TWL4030_BASEADD_MAIN_CHARGE },
182 { 2, TWL4030_BASEADD_PWM },
183 { 2, TWL4030_BASEADD_LED },
191 { 2, TWL4030_BASEADD_KEYPAD },
193 { 2, TWL4030_BASEADD_MADC },
194 { 2, TWL4030_BASEADD_INTERRUPTS },
195 { 2, TWL4030_BASEADD_PRECHARGE },
199 { 2, TWL5031_BASEADD_ACCESSORY },
200 { 2, TWL5031_BASEADD_INTERRUPTS },
229 { 0x19, 0x32}, /* ARXL1_APGA_CTL*/
230 { 0x1a, 0x32}, /* ARXR1_APGA_CTL*/
231 { 0x1b, 0x32}, /* ARXL2_APGA_CTL*/
232 { 0x1c, 0x32}, /* ARXR2_APGA_CTL*/
254 { 0x32, 0x00}, /* DTMF_TONEXT1L */
268 /* 0x40 - 0x42 Unused */
270 { 0x44, 0x32}, /* VDL_APGA_CTL */
360 { 2, TWL6030_BASEADD_ZERO },
389 /*----------------------------------------------------------------------*/
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.
523 * Unlocks the IDCODE register and read the 32 bit value.
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 = "twl6032-clk" },
723 struct device_node *node = client->dev.of_node; in twl_probe()
731 dev_err(&client->dev, "no platform data\n"); in twl_probe()
732 return -EINVAL; in twl_probe()
736 dev_dbg(&client->dev, "only one instance of %s allowed\n", in twl_probe()
738 return -EBUSY; in twl_probe()
741 pdev = platform_device_alloc(DRIVER_NAME, -1); in twl_probe()
743 dev_err(&client->dev, "can't alloc pdev\n"); in twl_probe()
744 return -ENOMEM; in twl_probe()
753 if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C) == 0) { in twl_probe()
754 dev_dbg(&client->dev, "can't talk I2C?\n"); in twl_probe()
755 status = -EIO; in twl_probe()
759 twl_priv = devm_kzalloc(&client->dev, sizeof(struct twl_private), in twl_probe()
762 status = -ENOMEM; in twl_probe()
766 if ((id->driver_data) & TWL6030_CLASS) { in twl_probe()
767 twl_priv->twl_id = TWL6030_CLASS_ID; in twl_probe()
768 twl_priv->twl_map = &twl6030_map[0]; in twl_probe()
771 twl_priv->twl_id = TWL4030_CLASS_ID; in twl_probe()
772 twl_priv->twl_map = &twl4030_map[0]; in twl_probe()
777 twl_priv->twl_modules = devm_kcalloc(&client->dev, in twl_probe()
781 if (!twl_priv->twl_modules) { in twl_probe()
782 status = -ENOMEM; in twl_probe()
787 struct twl_client *twl = &twl_priv->twl_modules[i]; in twl_probe()
790 twl->client = client; in twl_probe()
792 twl->client = i2c_new_dummy_device(client->adapter, in twl_probe()
793 client->addr + i); in twl_probe()
794 if (IS_ERR(twl->client)) { in twl_probe()
795 dev_err(&client->dev, in twl_probe()
797 status = PTR_ERR(twl->client); in twl_probe()
802 twl->regmap = devm_regmap_init_i2c(twl->client, in twl_probe()
804 if (IS_ERR(twl->regmap)) { in twl_probe()
805 status = PTR_ERR(twl->regmap); in twl_probe()
806 dev_err(&client->dev, in twl_probe()
813 twl_priv->ready = true; in twl_probe()
816 clocks_init(&client->dev); in twl_probe()
825 if (client->irq) { in twl_probe()
827 twl4030_init_chip_irq(id->name); in twl_probe()
828 irq_base = twl4030_init_irq(&client->dev, client->irq); in twl_probe()
830 irq_base = twl6030_init_irq(&client->dev, client->irq); in twl_probe()
840 * Disable TWL4030/TWL5030 I2C Pull-up on I2C1 and I2C4(SR) interface. in twl_probe()
841 * Program I2C_SCL_CTRL_PU(bit 0)=0, I2C_SDA_CTRL_PU (bit 2)=0, in twl_probe()
842 * SR_I2C_SCL_CTRL_PU(bit 4)=0 and SR_I2C_SDA_CTRL_PU(bit 6)=0. in twl_probe()
844 * Also, always enable SmartReflex bit as that's needed for omaps to in twl_probe()
846 * is disabled. Without the SmartReflex bit omap sys_clkreq idle in twl_probe()
864 if (id->driver_data == (TWL6030_CLASS | TWL6032_SUBCLASS)) { in twl_probe()
865 status = devm_mfd_add_devices(&client->dev, in twl_probe()
879 dev_warn(&client->dev, "Poweroff callback already assigned\n"); in twl_probe()
884 &client->dev); in twl_probe()
900 if (client->irq) in twl_suspend()
901 disable_irq(client->irq); in twl_suspend()
910 if (client->irq) in twl_resume()
911 enable_irq(client->irq); in twl_resume()
919 { "twl4030", TWL4030_VAUX2 }, /* "Triton 2" */