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 */
132 #define HFCLK_FREQ_26_MHZ (2 << 0)
137 /*----------------------------------------------------------------------*/
172 { 2, TWL4030_BASEADD_MAIN_CHARGE },
177 { 2, TWL4030_BASEADD_PWM },
178 { 2, TWL4030_BASEADD_LED },
186 { 2, TWL4030_BASEADD_KEYPAD },
188 { 2, TWL4030_BASEADD_MADC },
189 { 2, TWL4030_BASEADD_INTERRUPTS },
190 { 2, TWL4030_BASEADD_PRECHARGE },
194 { 2, TWL5031_BASEADD_ACCESSORY },
195 { 2, TWL5031_BASEADD_INTERRUPTS },
224 { 0x19, 0x32}, /* ARXL1_APGA_CTL*/
225 { 0x1a, 0x32}, /* ARXR1_APGA_CTL*/
226 { 0x1b, 0x32}, /* ARXL2_APGA_CTL*/
227 { 0x1c, 0x32}, /* ARXR2_APGA_CTL*/
249 { 0x32, 0x00}, /* DTMF_TONEXT1L */
263 /* 0x40 - 0x42 Unused */
265 { 0x44, 0x32}, /* VDL_APGA_CTL */
355 { 2, TWL6030_BASEADD_ZERO },
384 /*----------------------------------------------------------------------*/
406 return twl_priv ? twl_priv->twl_id : 0; in twl_rev()
411 * twl_get_regmap - Get the regmap associated with the given module
421 if (unlikely(!twl_priv || !twl_priv->ready)) { in twl_get_regmap()
430 sid = twl_priv->twl_map[mod_no].sid; in twl_get_regmap()
431 twl = &twl_priv->twl_modules[sid]; in twl_get_regmap()
433 return twl->regmap; in twl_get_regmap()
437 * twl_i2c_write - Writes a n bit register in TWL4030/TWL5030/TWL60X0
451 return -EPERM; in twl_i2c_write()
453 ret = regmap_bulk_write(regmap, twl_priv->twl_map[mod_no].base + reg, in twl_i2c_write()
465 * twl_i2c_read - Reads a n bit register in TWL4030/TWL5030/TWL60X0
479 return -EPERM; in twl_i2c_read()
481 ret = regmap_bulk_read(regmap, twl_priv->twl_map[mod_no].base + reg, in twl_i2c_read()
493 * twl_set_regcache_bypass - Configure the regcache bypass for the regmap associated
505 return -EPERM; in twl_set_regcache_bypass()
513 /*----------------------------------------------------------------------*/
516 * twl_read_idcode_register - API to read the IDCODE register.
518 * Unlocks the IDCODE register and read the 32 bit value.
527 pr_err("TWL4030 Unable to unlock IDCODE registers -%d\n", err); in twl_read_idcode_register()
531 err = twl_i2c_read(TWL4030_MODULE_INTBR, (u8 *)(&twl_priv->twl_idcode), in twl_read_idcode_register()
534 pr_err("TWL4030: unable to read IDCODE -%d\n", err); in twl_read_idcode_register()
540 pr_err("TWL4030 Unable to relock IDCODE registers -%d\n", err); in twl_read_idcode_register()
546 * twl_get_type - API to get TWL Si type.
552 return TWL_SIL_TYPE(twl_priv->twl_idcode); in twl_get_type()
557 * twl_get_version - API to get TWL Si version.
563 return TWL_SIL_REV(twl_priv->twl_idcode); in twl_get_version()
568 * twl_get_hfclk_rate - API to get TWL external HFCLK clock rate.
591 rate = -EINVAL; in twl_get_hfclk_rate()
599 /*----------------------------------------------------------------------*/
602 * These three functions initialize the on-chip clock framework,
659 /* effect->MADC+USB ck en */ in clocks_init()
667 /*----------------------------------------------------------------------*/
681 struct twl_client *twl = &twl_priv->twl_modules[i]; in twl_remove()
683 if (twl->client && twl->client != client) in twl_remove()
684 i2c_unregister_device(twl->client); in twl_remove()
685 twl->client = NULL; in twl_remove()
687 twl_priv->ready = false; in twl_remove()
691 OF_DEV_AUXDATA("ti,twl4030-gpio", 0, "twl4030-gpio", NULL),
696 { .name = "twl6032-clk" },
704 struct device_node *node = client->dev.of_node; in twl_probe()
712 dev_err(&client->dev, "no platform data\n"); in twl_probe()
713 return -EINVAL; in twl_probe()
717 dev_dbg(&client->dev, "only one instance of %s allowed\n", in twl_probe()
719 return -EBUSY; in twl_probe()
722 pdev = platform_device_alloc(DRIVER_NAME, -1); in twl_probe()
724 dev_err(&client->dev, "can't alloc pdev\n"); in twl_probe()
725 return -ENOMEM; in twl_probe()
734 if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C) == 0) { in twl_probe()
735 dev_dbg(&client->dev, "can't talk I2C?\n"); in twl_probe()
736 status = -EIO; in twl_probe()
740 twl_priv = devm_kzalloc(&client->dev, sizeof(struct twl_private), in twl_probe()
743 status = -ENOMEM; in twl_probe()
747 if ((id->driver_data) & TWL6030_CLASS) { in twl_probe()
748 twl_priv->twl_id = TWL6030_CLASS_ID; in twl_probe()
749 twl_priv->twl_map = &twl6030_map[0]; in twl_probe()
752 twl_priv->twl_id = TWL4030_CLASS_ID; in twl_probe()
753 twl_priv->twl_map = &twl4030_map[0]; in twl_probe()
758 twl_priv->twl_modules = devm_kcalloc(&client->dev, in twl_probe()
762 if (!twl_priv->twl_modules) { in twl_probe()
763 status = -ENOMEM; in twl_probe()
768 struct twl_client *twl = &twl_priv->twl_modules[i]; in twl_probe()
771 twl->client = client; in twl_probe()
773 twl->client = i2c_new_dummy_device(client->adapter, in twl_probe()
774 client->addr + i); in twl_probe()
775 if (IS_ERR(twl->client)) { in twl_probe()
776 dev_err(&client->dev, in twl_probe()
778 status = PTR_ERR(twl->client); in twl_probe()
783 twl->regmap = devm_regmap_init_i2c(twl->client, in twl_probe()
785 if (IS_ERR(twl->regmap)) { in twl_probe()
786 status = PTR_ERR(twl->regmap); in twl_probe()
787 dev_err(&client->dev, in twl_probe()
794 twl_priv->ready = true; in twl_probe()
797 clocks_init(&client->dev); in twl_probe()
806 if (client->irq) { in twl_probe()
808 twl4030_init_chip_irq(id->name); in twl_probe()
809 irq_base = twl4030_init_irq(&client->dev, client->irq); in twl_probe()
811 irq_base = twl6030_init_irq(&client->dev, client->irq); in twl_probe()
821 * Disable TWL4030/TWL5030 I2C Pull-up on I2C1 and I2C4(SR) interface. in twl_probe()
822 * Program I2C_SCL_CTRL_PU(bit 0)=0, I2C_SDA_CTRL_PU (bit 2)=0, in twl_probe()
823 * SR_I2C_SCL_CTRL_PU(bit 4)=0 and SR_I2C_SDA_CTRL_PU(bit 6)=0. in twl_probe()
825 * Also, always enable SmartReflex bit as that's needed for omaps to in twl_probe()
827 * is disabled. Without the SmartReflex bit omap sys_clkreq idle in twl_probe()
845 if (id->driver_data == (TWL6030_CLASS | TWL6032_SUBCLASS)) { in twl_probe()
846 status = devm_mfd_add_devices(&client->dev, in twl_probe()
856 &client->dev); in twl_probe()
872 if (client->irq) in twl_suspend()
873 disable_irq(client->irq); in twl_suspend()
882 if (client->irq) in twl_resume()
883 enable_irq(client->irq); in twl_resume()
891 { "twl4030", TWL4030_VAUX2 }, /* "Triton 2" */