Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3250093ybt; Mon, 22 Jun 2020 19:55:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJysfUnB+D9DmcOMGvftb0INCuatbuHyGY1qg6jMGRSNKJ6umjM5InLwxAYbK+djVd7yEPYv X-Received: by 2002:a05:6402:c83:: with SMTP id cm3mr264814edb.307.1592880944529; Mon, 22 Jun 2020 19:55:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592880944; cv=none; d=google.com; s=arc-20160816; b=CyEliPb95nWOvxbCK6AezWKw0rsmzS+i5y92X1ghHQ/zbs8y0UVisDzfkiHLFIZAdK iFRqRV2h4kfsfPZ5RFbz+TWcZGfyxQIfBkrmCj7oik8+IME0ZNK7B+N1JZ4z7qzzafzK l5pL1Agu5fCg3zjvv1hDkRnxqRThHZxX9Llu3xE59Tow06GtR1cwfFRMNu7djRapeCt1 cFjtq51IcFkWnT6FRPWnyS3+Mg1l8LymKfkA6GfGdc3F+K21DLmfu70XaGQfZxKqNC/B jE7+Xgeov8nxV1m30ZLAJfspHmPs/KRRGKcscAuRtfM7p3uyIyn4SAhcH2RDO9Qlb2Gm dbzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=BhR4sHXkSgOjtpuGGjpCZQc3KmPPFrg8Jceqqj13eEo=; b=q01gxQcicqpw0EAPapPXQ3dSgfCnEjIHkmtyOJs8FRPWlq6cxXEglCIL+X9lQCQ2JI Haanx/nJm6nWDCAMtuFKk0ebGy2R3QruMnqJ+7NZZnIsYmWCc/YEJEuOuYjPsFA9aZFe gel1F0pmWger3pY/taAWk1p6VQorvCq02kY4O9eTy2chs7zehS+EAYZ8cOuGKjPQpDkD zE5qGFpX7t0VTHz6nADWvYeo3dDZVoAmx7JLRCQJ33MBuNkL+nFoTzYT5Plo70+7+K7C 5f83kbThrVf3QhiRcrBd2m1JdQrYzjIQf3SfPnFGoWbRIPYHbkTpWAQgU+Ab+bxHJpOP aS9w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h2si9613337ejq.305.2020.06.22.19.55.22; Mon, 22 Jun 2020 19:55:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732307AbgFWCwt (ORCPT + 99 others); Mon, 22 Jun 2020 22:52:49 -0400 Received: from mx2.suse.de ([195.135.220.15]:33226 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731974AbgFWCvn (ORCPT ); Mon, 22 Jun 2020 22:51:43 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id C812DB1A5; Tue, 23 Jun 2020 02:51:41 +0000 (UTC) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: linux-realtek-soc@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, =?UTF-8?q?James=20Tai=20=5B=E6=88=B4=E5=BF=97=E5=B3=B0=5D?= , =?UTF-8?q?Stanley=20Chang=20=5B=E6=98=8C=E8=82=B2=E5=BE=B7=5D?= , Edgar Lee , =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [PATCH v2 26/29] soc: realtek: chip: Detect RTD1294 Date: Tue, 23 Jun 2020 04:51:03 +0200 Message-Id: <20200623025106.31273-27-afaerber@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200623025106.31273-1-afaerber@suse.de> References: <20200623025106.31273-1-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Detection logic from downstream include/soc/realtek/rtd129x_cpu.h. Signed-off-by: Andreas Färber --- Note: We don't have any RTD1294 .dtsi/.dts yet. v1 -> v2: * Instead of direct eFuse register access use nvmem cell API * Warn on errors other than deferred probing drivers/soc/realtek/chip.c | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/soc/realtek/chip.c b/drivers/soc/realtek/chip.c index 9cee760bac35..bed028ce1b16 100644 --- a/drivers/soc/realtek/chip.c +++ b/drivers/soc/realtek/chip.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -26,6 +27,8 @@ #define REG_ISO_CHIP_INFO1 0x028 +#define REG_EFUSE_PACKAGE_ID 0x1d8 + struct dhc_soc_revision { const char *name; u16 chip_rev; @@ -76,6 +79,33 @@ struct dhc_soc { const char *codename; }; +static int dhc_efuse_read_u8(struct device *dev, const char *cell_id, u8 *val) +{ + struct nvmem_cell *cell; + void *buf; + size_t len; + + cell = nvmem_cell_get(dev, cell_id); + if (IS_ERR(cell)) + return PTR_ERR(cell); + + buf = nvmem_cell_read(cell, &len); + if (IS_ERR(buf)) { + nvmem_cell_put(cell); + return PTR_ERR(buf); + } + if (len != sizeof(*val)) { + kfree(buf); + nvmem_cell_put(cell); + return -EINVAL; + } + memcpy(val, buf, 1); + kfree(buf); + nvmem_cell_put(cell); + + return 0; +} + static const char *default_name(struct device *dev, const struct dhc_soc *s) { return s->family; @@ -86,6 +116,15 @@ static const char *rtd1295_name(struct device *dev, const struct dhc_soc *s) struct regmap *regmap; unsigned int val; int ret; + u8 b; + + ret = dhc_efuse_read_u8(dev, "efuse_package_id", &b); + if (ret == -EPROBE_DEFER) + return ERR_PTR(ret); + else if (ret) + dev_warn(dev, "Could not read efuse package_id (%d)\n", ret); + else if (b == 0x1) + return "RTD1294"; regmap = syscon_regmap_lookup_by_phandle(dev->of_node, "iso-syscon"); if (IS_ERR(regmap)) { -- 2.26.2