Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp1361326rdh; Fri, 27 Oct 2023 11:48:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHSNr9R3txJUBatnRDzjz6qbB4TOAaVoZi2U+ciqTgCNZ4acnjNg4NSLGUaVVrvoD0K2DOD X-Received: by 2002:a81:c445:0:b0:5a7:bc79:9618 with SMTP id s5-20020a81c445000000b005a7bc799618mr3506378ywj.12.1698432513941; Fri, 27 Oct 2023 11:48:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698432513; cv=none; d=google.com; s=arc-20160816; b=Vm3aBK0ScXofi1OItl5aj2pDy+X5KQgiitjHPkSvq30HfN6utO/SnQ/mMo1COrepni icf5Ikwis5CfW4oYR6yZCvJ/Y6p9Bcc+7fZXgvtXmUWsEU0tybKIAhm/Te1ZhVhUujLa g7xAaMjWEMlws3CNuxpGniCS6/viFujpXI7XH1Fd7NIlkTVg14OnlVzYXVG+AUS3mdbW Od7UgWTLZKb7CYuJ28mAp0Q/8wT0NnI0K1Hky243o27wGY5jms1/dlaJNPux0ODuLTFa /pDZBiU3vSWEmH4H4+qwlvYNqAHfaSCgNNAjr6mSzOmZBIERLWqCQcws2x1xGNHNjwrx pUcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KM+51/Ab8q9Ob1ygxdet2j1y8TyHO4eFE3VACdVz/qw=; fh=2nC6Eum3KPrNBmIby8V3XGk+pStcLbxmYHi8gkGLd5Q=; b=hc9Ybut9ZuQGL8WsKYCuBZ92THg3Tqvlgy3aIL6boK4FsUNLwSYRvE7JebYKmJQeFd wAMV6QFj36vPXk/6oecsIxXMrsd3FrQgiNnImjsuQ+nFoQQUdt1eO/afNx2+kZPXqmYD tCPeJ9gKvWbG1WQmpVu/7a6yjGTPXqNIr61WqkU+iJ6fxVP5btRUz/GswmE7KDwk7Q37 sQXGaI9HQdWX/VjNwlRr0yF+ZFyYSKoL61IWDG1Ht9r7Mqj4jNVxb3PcRJfzV+puxyeD UwD1VWwbR4/cJBy7mxjqUXw9tFUSEunGPspFJIiHHtNwYBmjpFOF6/Fhj03yiXPHsw/l P/DA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@9elements.com header.s=google header.b="hCuE/Xxw"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=9elements.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id z66-20020a0dd745000000b005afa434c002si3291978ywd.48.2023.10.27.11.48.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 11:48:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@9elements.com header.s=google header.b="hCuE/Xxw"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=9elements.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 07DED8332E9D; Fri, 27 Oct 2023 11:48:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346566AbjJ0SsF (ORCPT + 99 others); Fri, 27 Oct 2023 14:48:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235230AbjJ0Srq (ORCPT ); Fri, 27 Oct 2023 14:47:46 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4567C1BC9 for ; Fri, 27 Oct 2023 11:47:22 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-32d849cc152so1626751f8f.1 for ; Fri, 27 Oct 2023 11:47:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; t=1698432441; x=1699037241; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KM+51/Ab8q9Ob1ygxdet2j1y8TyHO4eFE3VACdVz/qw=; b=hCuE/XxwPWtTF5iPZCADkjYwkp3/0mZ6nKDv0DQRwhpG7VqVl6uaOMi8jODvzcPCKU 3/rLFVByVldZignqZ8Pu2hoQy4huW4sidrnJtIq5OTI2qgCCK0gVBKjFTehBnURx5ahP WvrgmMdLu4wXIcCC0V8qAthInYguwJmi8PpYCzjN4o0MwLIknYh1PJE4XFwPQzn2XLwA aLBvZ9o+lFjAoxBo4YvRM0nCXn4NNX3ESvwvNZr104NUKwV/bbrXwIm0TtoC4kehqXOw GHddrQwKZCwpvXbPG6uBw3vD6PWijNYwMec8oAGWfi/4kEfrot7lkuvV4AbGpXqcS85U aAtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698432441; x=1699037241; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KM+51/Ab8q9Ob1ygxdet2j1y8TyHO4eFE3VACdVz/qw=; b=Mb7gbSBnniLgse20wiVnJRQ+I8iUPHHYqFqPtOt0Qo4XBEtb6zzlleDpOmXAu8ll+x PKY9gGGfFFUYsDRGEEKgGY2B7geLnH6CQcgzdwjUbaVOs5fYpnqd3vj0xOM0OE3QJDYB mM+zvGknK0u/Sr7DD4SLqL/tTWxcuZFy2H4r0bixJSzCIL4P4XQylo9n8q4DYeenwhPa 7+l2dSdAHJxXy58UeuTplPhAJRL3dkjQOqpvnySK5HD3fvaGg5eR+OhDr2wtHnfZkdNf MvD/uhNN9MmQ8a8rgRAWSiaIC7q2eEZX57X6X2v4YdAqF8EgLaO+8R24j+dMcD7Ed4SN 03Qw== X-Gm-Message-State: AOJu0YzmYoY7rMPWFifmM9rNUD+ncyOBUp35jTKfZdIhBp0jxp0nKapH fRkqADzJkF8BJgLVo+JWzKFgzA== X-Received: by 2002:a5d:5b0e:0:b0:32d:ad4a:bcef with SMTP id bx14-20020a5d5b0e000000b0032dad4abcefmr3447970wrb.2.1698432440652; Fri, 27 Oct 2023 11:47:20 -0700 (PDT) Received: from stroh80.sec.9e.network (ip-078-094-000-051.um19.pools.vodafone-ip.de. [78.94.0.51]) by smtp.gmail.com with ESMTPSA id j12-20020adfe50c000000b0032d893d8dc8sm2298527wrm.2.2023.10.27.11.47.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 11:47:20 -0700 (PDT) From: Naresh Solanki To: Peter Rosin Cc: andi.shyti@kernel.org, robh@kernel.org, Patrick Rudolph , Naresh Solanki , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 2/2] i2c: muxes: pca954x: Enable features on MAX7357 Date: Fri, 27 Oct 2023 18:47:08 +0000 Message-ID: <20231027184709.1541375-2-naresh.solanki@9elements.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231027184709.1541375-1-naresh.solanki@9elements.com> References: <20231027184709.1541375-1-naresh.solanki@9elements.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 27 Oct 2023 11:48:29 -0700 (PDT) From: Patrick Rudolph Enable additional features based on DT settings and unconditionally release the shared interrupt pin after 1.6 seconds and allow to use it as reset. These features aren't enabled by default and it's up to board designer to validate for proper functioning and detection of devices in secondary bus as sometimes it can cause secondary bus being disabled. Signed-off-by: Patrick Rudolph Signed-off-by: Naresh Solanki --- Changes in V5: - Fix typos - Update comment - Add newline in dev_warn Changes in V4: - Drop max7358 - Update #define - Move conf variable - Print warning when I2C_FUNC_SMBUS_WRITE_BYTE_DATA isn't supported Changes in V3: - Delete unused #define - Update pca954x_init - Update commit message Changes in V2: - Update comments - Update check for DT properties --- drivers/i2c/muxes/i2c-mux-pca954x.c | 43 ++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c index 2219062104fb..f5dfc33b97c0 100644 --- a/drivers/i2c/muxes/i2c-mux-pca954x.c +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c @@ -57,6 +57,20 @@ #define PCA954X_IRQ_OFFSET 4 +/* + * MAX7357's configuration register is writeable after POR, but + * can be locked by setting the basic mode bit. MAX7358 configuration + * register is locked by default and needs to be unlocked first. + * The configuration register holds the following settings: + */ +#define MAX7357_CONF_INT_ENABLE BIT(0) +#define MAX7357_CONF_FLUSH_OUT BIT(1) +#define MAX7357_CONF_RELEASE_INT BIT(2) +#define MAX7357_CONF_DISCON_SINGLE_CHAN BIT(4) +#define MAX7357_CONF_PRECONNECT_TEST BIT(7) + +#define MAX7357_POR_DEFAULT_CONF MAX7357_CONF_INT_ENABLE + enum pca_type { max_7356, max_7357, @@ -470,7 +484,34 @@ static int pca954x_init(struct i2c_client *client, struct pca954x *data) else data->last_chan = 0; /* Disconnect multiplexer */ - ret = i2c_smbus_write_byte(client, data->last_chan); + if (device_is_compatible(&client->dev, "maxim,max7357")) { + if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { + u8 conf = MAX7357_POR_DEFAULT_CONF; + /* + * The interrupt signal is shared with the reset pin. Release the + * interrupt after 1.6 seconds to allow using the pin as reset. + */ + conf |= MAX7357_CONF_RELEASE_INT; + + if (device_property_read_bool(&client->dev, "maxim,isolate-stuck-channel")) + conf |= MAX7357_CONF_DISCON_SINGLE_CHAN; + if (device_property_read_bool(&client->dev, + "maxim,send-flush-out-sequence")) + conf |= MAX7357_CONF_FLUSH_OUT; + if (device_property_read_bool(&client->dev, + "maxim,preconnection-wiggle-test-enable")) + conf |= MAX7357_CONF_PRECONNECT_TEST; + + ret = i2c_smbus_write_byte_data(client, data->last_chan, conf); + } else { + dev_warn(&client->dev, "Write byte data not supported." + "Cannot enable enhanced mode features\n"); + ret = i2c_smbus_write_byte(client, data->last_chan); + } + } else { + ret = i2c_smbus_write_byte(client, data->last_chan); + } + if (ret < 0) data->last_chan = 0; -- 2.41.0