From patchwork Fri Jan 20 07:17:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 644605 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp637686pvb; Thu, 19 Jan 2023 23:17:59 -0800 (PST) X-Google-Smtp-Source: AMrXdXuLuweGn6PzlbB68WgJflJk8ZcZtdGesMHkyzNkdbx+HigwYd5/Z1j3Ig8JpcL6ZKMQyq98 X-Received: by 2002:a05:6808:308e:b0:363:a565:e392 with SMTP id bl14-20020a056808308e00b00363a565e392mr8290423oib.4.1674199079564; Thu, 19 Jan 2023 23:17:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674199079; cv=none; d=google.com; s=arc-20160816; b=GKLMImil+cbV7pBkliBKD4eLAz5KxL8mABctzCK2n7iPKXqu5pCtzC95CfpAcG5v1X /Ky/DqeLB14ykakls7YMIaOK6zUUr0AEObEdY5W6TPVuPyTxJ8BVsvGtVJuDL7TsmggO +5FsQMdPJEsfw6v0ith+EfFJeXb0nquKVSlphXWphezt6cbzWnK3qFRRwW47msd/dGmx pzzAbiod0WVoo31o8vkBUc20zXe1C9OySzWCDTt4o87whLWxxBqLoPsVnJomONQ5DQ3P OX87E/9byzxptVW9KrFOjLDr11CG7T3DPdp7a6uDBvHVRdNU6rwNRf4VCq9m7ZdsILuC jT6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=c6KJR1dXWQfbUVvWqz3TDKFjYpVTl3dj4ftXimlQA7Q=; b=qOwFnGPMAOVo4F4TND0+ubjc1O8f2UDqO8GkPpnDqd+aTBQgX9tg55ddeAuF+YcP4t QYin/Bri2PleCBBgUlCxaFiOiCaP6sGji+MHPAtuPE8r+aN1Kv/pp6H0Y5mFv/vUeVGU WZX4O8XEstyYgNjO310Drti+rcQFSyfUKucjRPjlxbYQne6wlzYKITgtqtJQa+LuzdbJ /G85Uas2fOqqvVokyTr+zIxTv8VF1Oig8m6SHS1J0xoISPujCW4F+qhz+ilI1kivGBpc j2YL7djf2ac3gE+wkU7oQLIp3mT4VfcIk8UBcOH8s/CeeaNrkeGUtGfa5NsmwpDU5DNI ufpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eKNUQ56V; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id cg10-20020a056830630a00b00666a50cccd0si41462664otb.238.2023.01.19.23.17.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 23:17:59 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eKNUQ56V; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7DFF885694; Fri, 20 Jan 2023 08:17:46 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="eKNUQ56V"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8BF0785695; Fri, 20 Jan 2023 08:17:44 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 56DB185694 for ; Fri, 20 Jan 2023 08:17:41 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sumit.garg@linaro.org Received: by mail-pg1-x535.google.com with SMTP id b6so3446475pgi.7 for ; Thu, 19 Jan 2023 23:17:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=c6KJR1dXWQfbUVvWqz3TDKFjYpVTl3dj4ftXimlQA7Q=; b=eKNUQ56VgwJws/sYZKZfFSMLdwVpB0kiJc7a4CIZ+M+Lk09buQOYhHSwexJgN1wgOZ bTPWxYLrs87kcEnpZS9esHB0AM9OvDQR4DF9QBzN0LRDERNHvOC6evX7NENr9Z8z7pCA KvoAoDRlfWsvk9baSMmqnLYb9so7Mg46k6437tTNCZg06N0FI4Bo4noXMSa/F2rrEm8t VWbGcS+3VU7161mGs0mLzi68B2q5hSEBHHzu+RDRVfFm/C0iuVNg6ICMe/lKznuXtd1J vtCYik+yEUKlv+EVkFhIcFfgHqWesUdEXa6Cm01EuYo4lGqJRq37lzRZysB04meiDKnj 4xog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=c6KJR1dXWQfbUVvWqz3TDKFjYpVTl3dj4ftXimlQA7Q=; b=GoN7rP+Ik8IwcKApQVZpABOLGJOT+phWQDRFER2+Dzt3WDCBOKETxRgH4+51ET11yZ zvYd0tFcTvxuZuEAoxPdrPMqoZeAKiIE36q1frKEI4q8dyL+EKSPKcTs//egv4yPShxp ObhaIuR/KHIsHVuyvB5ugha0ubHasoWPWSkJYiM/9eLBK1NHkQml09Fm84Xp4ImJVZfn ZyVOkAv04M2NJ93sobezaCA+R+vGYj+B95cDo0Z1WTMFLgVGK5Ytbm4sDVPS45drNZXJ WVh2kJAj1S+vY2IzapbDSf65ThMnAxs803oOV58L2JKbMBwQf13jK2Y/i+NjDtF/nTDb 0I9Q== X-Gm-Message-State: AFqh2krChMzQCTRHv2azps5YVYoI0IkNVC+gLgammc07JaNrumKsClUl shP5cmAeBpVL0jLFj5WHDBUHQza2yh4/oliW X-Received: by 2002:a05:6a00:3495:b0:58d:d7b6:cf58 with SMTP id cp21-20020a056a00349500b0058dd7b6cf58mr13699202pfb.7.1674199059329; Thu, 19 Jan 2023 23:17:39 -0800 (PST) Received: from sumit-X1.. ([223.178.212.120]) by smtp.gmail.com with ESMTPSA id x15-20020aa7956f000000b0058bacd6c4e8sm9797586pfq.207.2023.01.19.23.17.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 23:17:38 -0800 (PST) From: Sumit Garg To: u-boot@lists.denx.de Cc: rfried.dev@gmail.com, hs@denx.de, joe.hershberger@ni.com, stephan@gerhold.net, mworsfold@impinj.com, lgillham@impinj.com, jbrennan@impinj.com, nicolas.dechesne@linaro.org, vinod.koul@linaro.org, daniel.thompson@linaro.org, Sumit Garg Subject: [PATCH 01/14] qcs404: sysmap: Don't map reserved memory ranges Date: Fri, 20 Jan 2023 12:47:06 +0530 Message-Id: <20230120071719.623661-2-sumit.garg@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230120071719.623661-1-sumit.garg@linaro.org> References: <20230120071719.623661-1-sumit.garg@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Currently u-boot maps whole of 1G RAM but there reserved memory ranges on QCS404 which are reserved for TrustZone, various firmware components etc. Any access to these reserved memory ranges causes a bus hang issue. So disable mapping for reserved memory ranges in u-boot. Signed-off-by: Sumit Garg --- arch/arm/mach-snapdragon/sysmap-qcs404.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-snapdragon/sysmap-qcs404.c b/arch/arm/mach-snapdragon/sysmap-qcs404.c index b7409031a0..64ca4adf1b 100644 --- a/arch/arm/mach-snapdragon/sysmap-qcs404.c +++ b/arch/arm/mach-snapdragon/sysmap-qcs404.c @@ -19,7 +19,19 @@ static struct mm_region qcs404_mem_map[] = { }, { .virt = 0x80000000UL, /* DDR */ .phys = 0x80000000UL, /* DDR */ - .size = 0x40000000UL, + .size = 0x05900000UL, + .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | + PTE_BLOCK_INNER_SHARE + }, { + .virt = 0x89600000UL, /* DDR */ + .phys = 0x89600000UL, /* DDR */ + .size = 0x162000000UL, + .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | + PTE_BLOCK_INNER_SHARE + }, { + .virt = 0xa0000000UL, /* DDR */ + .phys = 0xa0000000UL, /* DDR */ + .size = 0x20000000UL, .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | PTE_BLOCK_INNER_SHARE }, { From patchwork Fri Jan 20 07:17:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 644606 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp637746pvb; Thu, 19 Jan 2023 23:18:12 -0800 (PST) X-Google-Smtp-Source: AMrXdXteDezWh/tqKg5gdxme+Bm28AjkCWkp/AJ9wOR8VKe/II/yUFYCgawwu2sZE4nD7WRh9QVt X-Received: by 2002:a05:6830:1e5b:b0:684:d7f8:dc46 with SMTP id e27-20020a0568301e5b00b00684d7f8dc46mr6973012otj.20.1674199092454; Thu, 19 Jan 2023 23:18:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674199092; cv=none; d=google.com; s=arc-20160816; b=ZbKj/FuFSGO2hp2klxICgcQvRd13CthTdeD/mkMQVa9GVOgGOElq2275Wgxe7D15+d WI+r6lRPKCejwgHE5iMNyXi9XCGpN+HBmoHYLpSudOqHgjrjqqR499Nj6WoaIsFuCHm2 7N3TyfM/+JSELoPKakOpuYHQMmH0KZdGFxdUOtXZ6JGfHkAVdpruq1Cp5Z74CCdQgJMT JBqKOZQZjrerh3Kntn80joug9UlJN4qEtPKyQK4xbtateShYCZBxLRdaF3Gy3BCDFBEj O/ignTP2FCr4gEA9ov0D1sf833bJO7DvquOf/XFNSna40DSaq2tWN97apnbRyaVziaAy 63Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DnPqZxZKlu/mwL/JZ5NDglUAkFtE4vKdj9ILH6v2XIw=; b=0EJcvTpijHoyVYFwzq+KkrU9ImIDLUIHXiZh7G9lhreaZO2EJ/JUaJjiBZeSVxeNQJ WaPUtqB1zONmv6rHgfN6Wp+em5GlwqDtOiQLpbqZlr2n6wwiAxlE/KfBMB5Qv3UANdOv 9l/W0tkMgWWFaOqbWVMvSjwoGD5YEmLcO0j2LWEJ+v013Bjp88zs5L18cpI1mHlwAu13 TD9Q6/S6H7jLE/R5sU7hkd4umK6TiL39hTWbvmXoGr0TI7/KYP8lL2DTo47CNF60ujVZ 2t+zzs/xg7RBpBaiS9BuBzNKgElX3xS13Ty+8ZTydD+6BNjbBw14Ha0+bCGXXNgaL31R FN4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pyhpIkGR; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id bu1-20020a0568300d0100b0066eb995f923si42876122otb.70.2023.01.19.23.18.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 23:18:12 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pyhpIkGR; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6265A85698; Fri, 20 Jan 2023 08:17:57 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="pyhpIkGR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 417FE8568B; Fri, 20 Jan 2023 08:17:49 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id BE5B984FB4 for ; Fri, 20 Jan 2023 08:17:45 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sumit.garg@linaro.org Received: by mail-pf1-x42a.google.com with SMTP id a184so3311241pfa.9 for ; Thu, 19 Jan 2023 23:17:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=DnPqZxZKlu/mwL/JZ5NDglUAkFtE4vKdj9ILH6v2XIw=; b=pyhpIkGRYU4cFZjeQrH9+MErHueqm5tLj7Judn48U6nzlYJJByZDYwcwHjA/+VoZTT L3iWrpmxCqcqzdFsc7ZyXYt0FJXxxst1sGp3acJKsPRGS8zfSL0t5g7FHoKTIc0IzSXF y6b3OYnG6BDg1/1XyM+D7wH+ydErhgkncroRJ/GAhAF6kSDqSW3eEWttJg3gi3iVTrQM JCTKuN+UKkxvXdk1wkTOWo5eIS/bwaRZS2ncOS7ZuCOxtCM6a+o/eWc7cM9n9pPU7eI+ tIdl6iNe+/yYjjdGXlVm/GGxkrMY25xYK6FvUEh1fm9bZUieRwyIpgdyaxfb8gDZy5Vv hGsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=DnPqZxZKlu/mwL/JZ5NDglUAkFtE4vKdj9ILH6v2XIw=; b=30Op7piRSg0gmRYF69+CoRsZqhlwiEOVJBAkp1QnahzUdrvkGv0OEQ+x94W8KlYRbM MCSBY2Sc7Oe08Syrl145EXeBBT6Hi/WwRH32HRLMmG03OBMHbEaE0zLlz6g8YyHTzSY7 NovmBd8jVFXaW5hSVckpk5S8O9VKVPj6y7n1O2zOHdsE2zYJakSQdu3aZbEMRKKzFw1T rBLr50mrS+YZaclYOix94bS8LGQ57nBGHq8BlwXgagSeKewnSAKYHQLaTUOCUBeWKpTP nWQ64arz3jBH9hNL0+BY3axsFIUMxz38RbxuJR8j3PDaFSW/rk1S+3cl3LNsOCtOOjmC j0QQ== X-Gm-Message-State: AFqh2kobeT1RvfGxvSl013K2Aqour+hQaducxwTfAWSHfZty+7DRLFe5 hL8NRDB9AYMFwGq5+KAKcxFdxt5EfjlYofj+ X-Received: by 2002:aa7:91c1:0:b0:58a:fddd:9b1d with SMTP id z1-20020aa791c1000000b0058afddd9b1dmr13652573pfa.10.1674199063703; Thu, 19 Jan 2023 23:17:43 -0800 (PST) Received: from sumit-X1.. ([223.178.212.120]) by smtp.gmail.com with ESMTPSA id x15-20020aa7956f000000b0058bacd6c4e8sm9797586pfq.207.2023.01.19.23.17.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 23:17:43 -0800 (PST) From: Sumit Garg To: u-boot@lists.denx.de Cc: rfried.dev@gmail.com, hs@denx.de, joe.hershberger@ni.com, stephan@gerhold.net, mworsfold@impinj.com, lgillham@impinj.com, jbrennan@impinj.com, nicolas.dechesne@linaro.org, vinod.koul@linaro.org, daniel.thompson@linaro.org, Sumit Garg Subject: [PATCH 02/14] qcs404-evb: Enable msm_gpio driver support Date: Fri, 20 Jan 2023 12:47:07 +0530 Message-Id: <20230120071719.623661-3-sumit.garg@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230120071719.623661-1-sumit.garg@linaro.org> References: <20230120071719.623661-1-sumit.garg@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Signed-off-by: Sumit Garg --- arch/arm/dts/qcs404-evb.dts | 4 ++++ configs/qcs404evb_defconfig | 1 + 2 files changed, 5 insertions(+) diff --git a/arch/arm/dts/qcs404-evb.dts b/arch/arm/dts/qcs404-evb.dts index 0639af8fe3..c8bcf9f71d 100644 --- a/arch/arm/dts/qcs404-evb.dts +++ b/arch/arm/dts/qcs404-evb.dts @@ -40,6 +40,10 @@ pinctrl_north@1300000 { compatible = "qcom,qcs404-pinctrl"; reg = <0x1300000 0x200000>; + gpio-controller; + gpio-count = <120>; + gpio-bank-name="soc"; + #gpio-cells = <2>; blsp1_uart2: uart { pins = "GPIO_17", "GPIO_18"; diff --git a/configs/qcs404evb_defconfig b/configs/qcs404evb_defconfig index dae1551411..d64cd74269 100644 --- a/configs/qcs404evb_defconfig +++ b/configs/qcs404evb_defconfig @@ -44,6 +44,7 @@ CONFIG_DM_PMIC=y CONFIG_PMIC_QCOM=y CONFIG_DM_RESET=y CONFIG_MSM_SERIAL=y +CONFIG_MSM_GPIO=y CONFIG_SPMI_MSM=y CONFIG_USB=y CONFIG_USB_XHCI_HCD=y From patchwork Fri Jan 20 07:17:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 644607 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp637813pvb; Thu, 19 Jan 2023 23:18:26 -0800 (PST) X-Google-Smtp-Source: AMrXdXu+oD/GANQHyFyk5S8eu3LxiyLhsljrTqGOa56urPhlMUls1+TbO4R6eN/+EnCID9d+gV4I X-Received: by 2002:a05:6808:1053:b0:35e:acd7:99d6 with SMTP id c19-20020a056808105300b0035eacd799d6mr5873311oih.9.1674199106677; Thu, 19 Jan 2023 23:18:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674199106; cv=none; d=google.com; s=arc-20160816; b=KdIr++vjC8gzuAXUC5F9YI8TJzvUriauP/TnDo8jSvXe4O2hHmFBxL1QrNdqpG3gSn 3oYxebVOK6y7Q2byuGjuBMttAf+AXneqw8BJCz128/W31T/v9/QplSLTJ85VPlXy6iT5 1J/THJhgIzOx+ZOY2ymIW2bXyHnXBGQ6XK02zP/ctCCQ5eLfIO/AaEnkn39eJC5zF2o1 cwNCx48+tUm2BDniyj7koVm0LAqAdLoV3dc/6M0iNPC/8MMDdUXhBHEeSRA+3DzK7HaS gS47pElyNCmWjynIelzNYGpn9SOP4tAieIyqgk5dsojbZ2qu3zPz/u1FPjyZ2ATDElCV Lecw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wh9FITta3C+uiujkN9yOlTx3uqHPS8M4Fiy7NsSWCpk=; b=BHob66F0CTfLxrzqBYW1VvIjW4R3KFQyqjBt3QndA/oeKnm+0SyFaXC/Ap8YjyJtgO JI1z8ASlB2VT6APXfbLw7bMERU7AfU1VYnAHSdfqBeRaZ3/6FTxGK/ag8JYgiCfZ5jW1 hKgv2qNx+rjmZhGE/jSL3/o9znedrnLZMwDin3IcgzGkjhO1z99Jm8l3qr/No9qfaDrQ GeEPmQ2FS/CfW5lbqgPzcz/oDLi+OXbQzojfhAS3J/652yfzyImPiuJiOEWA+95LR6eK 8g1I+ePrTZspnNxcw2tmcqXSaOmsG+1gVJ0+tX4udxUudSIzSAR6TCJGRpR3BH7P8x9y 33Fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nfj31rns; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id w21-20020a056808141500b00368bd4ce7a8si11785680oiv.161.2023.01.19.23.18.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 23:18:26 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nfj31rns; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E6347856A9; Fri, 20 Jan 2023 08:17:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="nfj31rns"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CEC92856A0; Fri, 20 Jan 2023 08:17:53 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id CE5BE84FB4 for ; Fri, 20 Jan 2023 08:17:49 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sumit.garg@linaro.org Received: by mail-pg1-x52b.google.com with SMTP id 36so3442198pgp.10 for ; Thu, 19 Jan 2023 23:17:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=wh9FITta3C+uiujkN9yOlTx3uqHPS8M4Fiy7NsSWCpk=; b=nfj31rns5rPiflYgoopeawK8ql9JVCSF0NDPerJpUJd90QfxWT2xp8uCDIZ1JLwraD DIvYwAz0pC6t4Nk45XmoELimYRXkHeURStY8V/Gsn6LIaBn1txAnfxK821vv/oPtMnGA Xcd49qPxipZ4o1U+ceKiRfd8MqrFGQtxTkwrUcZz/KxtSH6cAEDsyhFen78iOlwjp/nF g5rKyIzW250h+OSkk5390e6eTk9/lq4GeFEOjT4dpaEzY6mJDD2RwzaiuQ/4NE4hPNTG WtWjQye9AjILI/IqIOZvDj6eVQWtZyvuybocq8AmCipnTblCcq0JDHiXapoK9QTVZJJg OZvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=wh9FITta3C+uiujkN9yOlTx3uqHPS8M4Fiy7NsSWCpk=; b=8Q2lpzWhuce7pihMeln9IQ0jyW24OvowEvfDwx9252zQK1H/WsslNVQgY+mrUCf0Uv LLKhZeqhFM4Kh4v2vtC7uc9vmuh8xNbHvHyG4Rfyelp3rPiFgOoX9FjoIohugJncDTya uncsLT+1PuZP+jBXUNP7I18eiWYmehynEoGQ8Lr+joHe5Lu5kjozfy9lRxzn8ax4+diw ZAsESoGFI3eC34h4h8TqeSPzByFfG7h7h00PEvXBuC11Xxiw6avPgGXAPKtaX0Y2v3oc ZJgjjLYbybwDcNS7WcrQFCBcT2NXErfyBr//B0JnM//3urnGBSTRn27+2fgLhWdRCulf nXgA== X-Gm-Message-State: AFqh2kqPko5bGUi+KkHland1HZ2m03Au5QDnHCX1MENW0jyXMXQ66reM jYsUxCgXkCxasTBir861Mvwgr4GXdK9c0wK2 X-Received: by 2002:a05:6a00:2913:b0:58e:1b58:56ec with SMTP id cg19-20020a056a00291300b0058e1b5856ecmr207535pfb.16.1674199067974; Thu, 19 Jan 2023 23:17:47 -0800 (PST) Received: from sumit-X1.. ([223.178.212.120]) by smtp.gmail.com with ESMTPSA id x15-20020aa7956f000000b0058bacd6c4e8sm9797586pfq.207.2023.01.19.23.17.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 23:17:47 -0800 (PST) From: Sumit Garg To: u-boot@lists.denx.de Cc: rfried.dev@gmail.com, hs@denx.de, joe.hershberger@ni.com, stephan@gerhold.net, mworsfold@impinj.com, lgillham@impinj.com, jbrennan@impinj.com, nicolas.dechesne@linaro.org, vinod.koul@linaro.org, daniel.thompson@linaro.org, Sumit Garg Subject: [PATCH 03/14] clocks: qcs404: Add support for ethernet clocks Date: Fri, 20 Jan 2023 12:47:08 +0530 Message-Id: <20230120071719.623661-4-sumit.garg@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230120071719.623661-1-sumit.garg@linaro.org> References: <20230120071719.623661-1-sumit.garg@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Signed-off-by: Sumit Garg --- arch/arm/mach-snapdragon/clock-qcs404.c | 60 +++++++++++++++++++ .../include/mach/sysmap-qcs404.h | 14 +++++ 2 files changed, 74 insertions(+) diff --git a/arch/arm/mach-snapdragon/clock-qcs404.c b/arch/arm/mach-snapdragon/clock-qcs404.c index 6fe92afe8d..b8f5691aae 100644 --- a/arch/arm/mach-snapdragon/clock-qcs404.c +++ b/arch/arm/mach-snapdragon/clock-qcs404.c @@ -18,6 +18,9 @@ /* GPLL0 clock control registers */ #define GPLL0_STATUS_ACTIVE BIT(31) +#define CFG_CLK_SRC_GPLL1 BIT(8) +#define GPLL1_STATUS_ACTIVE BIT(31) + static struct vote_clk gcc_blsp1_ahb_clk = { .cbcr_reg = BLSP1_AHB_CBCR, .ena_vote = APCS_CLOCK_BRANCH_ENA_VOTE, @@ -47,6 +50,13 @@ static struct pll_vote_clk gpll0_vote_clk = { .vote_bit = BIT(0), }; +static struct pll_vote_clk gpll1_vote_clk = { + .status = GPLL1_STATUS, + .status_bit = GPLL1_STATUS_ACTIVE, + .ena_vote = APCS_GPLL_ENA_VOTE, + .vote_bit = BIT(1), +}; + static const struct bcr_regs usb30_master_regs = { .cfg_rcgr = USB30_MASTER_CFG_RCGR, .cmd_rcgr = USB30_MASTER_CMD_RCGR, @@ -55,6 +65,22 @@ static const struct bcr_regs usb30_master_regs = { .D = USB30_MASTER_D, }; +static const struct bcr_regs emac_regs = { + .cfg_rcgr = EMAC_CFG_RCGR, + .cmd_rcgr = EMAC_CMD_RCGR, + .M = EMAC_M, + .N = EMAC_N, + .D = EMAC_D, +}; + +static const struct bcr_regs emac_ptp_regs = { + .cfg_rcgr = EMAC_PTP_CFG_RCGR, + .cmd_rcgr = EMAC_PTP_CMD_RCGR, + .M = EMAC_M, + .N = EMAC_N, + .D = EMAC_D, +}; + ulong msm_set_rate(struct clk *clk, ulong rate) { struct msm_clk_priv *priv = dev_get_priv(clk->dev); @@ -79,6 +105,20 @@ ulong msm_set_rate(struct clk *clk, ulong rate) case GCC_SDCC1_AHB_CLK: clk_enable_cbc(priv->base + SDCC_AHB_CBCR(1)); break; + case GCC_ETH_RGMII_CLK: + if (rate == 250000000) + clk_rcg_set_rate_mnd(priv->base, &emac_regs, 2, 0, 0, + CFG_CLK_SRC_GPLL1); + else if (rate == 125000000) + clk_rcg_set_rate_mnd(priv->base, &emac_regs, 4, 0, 0, + CFG_CLK_SRC_GPLL1); + else if (rate == 50000000) + clk_rcg_set_rate_mnd(priv->base, &emac_regs, 10, 0, 0, + CFG_CLK_SRC_GPLL1); + else if (rate == 5000000) + clk_rcg_set_rate_mnd(priv->base, &emac_regs, 2, 1, 50, + CFG_CLK_SRC_GPLL1); + break; default: return 0; } @@ -111,6 +151,26 @@ int msm_enable(struct clk *clk) case GCC_USB2A_PHY_SLEEP_CLK: clk_enable_cbc(priv->base + USB_HS_PHY_CFG_AHB_CBCR); break; + case GCC_ETH_PTP_CLK: + /* SPEED_1000: freq -> 250MHz */ + clk_enable_cbc(priv->base + ETH_PTP_CBCR); + clk_enable_gpll0(priv->base, &gpll1_vote_clk); + clk_rcg_set_rate_mnd(priv->base, &emac_ptp_regs, 2, 0, 0, + CFG_CLK_SRC_GPLL1); + break; + case GCC_ETH_RGMII_CLK: + /* SPEED_1000: freq -> 250MHz */ + clk_enable_cbc(priv->base + ETH_RGMII_CBCR); + clk_enable_gpll0(priv->base, &gpll1_vote_clk); + clk_rcg_set_rate_mnd(priv->base, &emac_regs, 2, 0, 0, + CFG_CLK_SRC_GPLL1); + break; + case GCC_ETH_SLAVE_AHB_CLK: + clk_enable_cbc(priv->base + ETH_SLAVE_AHB_CBCR); + break; + case GCC_ETH_AXI_CLK: + clk_enable_cbc(priv->base + ETH_AXI_CBCR); + break; default: return 0; } diff --git a/arch/arm/mach-snapdragon/include/mach/sysmap-qcs404.h b/arch/arm/mach-snapdragon/include/mach/sysmap-qcs404.h index e448faad2d..8920c4ee8f 100644 --- a/arch/arm/mach-snapdragon/include/mach/sysmap-qcs404.h +++ b/arch/arm/mach-snapdragon/include/mach/sysmap-qcs404.h @@ -12,6 +12,7 @@ /* Clocks: (from CLK_CTL_BASE) */ #define GPLL0_STATUS (0x21000) +#define GPLL1_STATUS (0x20000) #define APCS_GPLL_ENA_VOTE (0x45000) #define APCS_CLOCK_BRANCH_ENA_VOTE (0x45004) @@ -54,4 +55,17 @@ #define USB2A_PHY_SLEEP_CBCR (0x4102C) #define USB_HS_PHY_CFG_AHB_CBCR (0x41030) +/* ETH controller clock control registers */ +#define ETH_PTP_CBCR (0x4e004) +#define ETH_RGMII_CBCR (0x4e008) +#define ETH_SLAVE_AHB_CBCR (0x4e00c) +#define ETH_AXI_CBCR (0x4e010) +#define EMAC_PTP_CMD_RCGR (0x4e014) +#define EMAC_PTP_CFG_RCGR (0x4e018) +#define EMAC_CMD_RCGR (0x4e01c) +#define EMAC_CFG_RCGR (0x4e020) +#define EMAC_M (0x4e024) +#define EMAC_N (0x4e028) +#define EMAC_D (0x4e02c) + #endif From patchwork Fri Jan 20 07:17:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 644608 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp637905pvb; Thu, 19 Jan 2023 23:18:42 -0800 (PST) X-Google-Smtp-Source: AMrXdXu8hAlN7OmNb0F9n3XWKl0Pq6V542dw9jcIrXjrymO7aSDhopU3x6DNHh89cqI53fFn2dD0 X-Received: by 2002:a05:6830:3361:b0:684:42a:b3f3 with SMTP id l33-20020a056830336100b00684042ab3f3mr6880073ott.2.1674199122189; Thu, 19 Jan 2023 23:18:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674199122; cv=none; d=google.com; s=arc-20160816; b=NNzLyyo1vnC6CFR3ZAuUOgj6mRJ6UuFNJsD+NZL2Z/S13DQu3K7FDIR/fltFlTfcKF 62zDbdGvc5Xk7nR6kltWQFnzyCxYFJZBGpzVzlvCkocVk8h663zVaqXMGZhcIXKyUaGL UJHUGaCKDRfox6xQBvFLiLIhXhZ4tPkZwqGyo2kXWxGqT74WbWiI0KzyZ/ryywDbpdtf RAok6Q3dOf9mkla04FAFjxCXWofEnZ55bC1r2aMtMK9I1KyEwaLxFFwmzq0Xn37lgBJ0 hQNJAvfKbBsY8NlsWOLGV6sTlcLqd+HhSoT91lz/PTvW4SD8kMkmgYBKYqfHx4k++a8A 5XgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Uf0JUp0WOyuAxl1CUsKprRoREAUbOiStWI2VOsSFB6c=; b=gMLGM59WhJVzCYHikELDrl4cy7MzWpwj1+RJpnMzy0eqE21Gi2OCDm8kMAwlua0+Km sh6ZRcSHAf6aYFjaFiu7KlsIN9n4zmzJ09RH0+k55fqYnVL1bpvB/VX9JPKRETr6ICVs xn11Flnfm+Vys9BdrSej+AMIIljWqAZT79eFrCis63E+stoB8iDDIXQtVUdRM4PvsPxU TF6b/WBQALP5LgKZLBjkykVEe+jKV3kQM6BBMyb9WPg6DHTx3Tj1NXI3Fkmwm/IclJME jszsdddeXSBn2GhBKD66GVqZ6JrF5tO2G8Cge8zCr4B/GncC2L46sUiIOZH9GvaldfGt S+9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oQLMl0gP; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id v11-20020a9d4e8b000000b00684bfe10b34si22007192otk.303.2023.01.19.23.18.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 23:18:42 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oQLMl0gP; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7723A856B9; Fri, 20 Jan 2023 08:18:10 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="oQLMl0gP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7ED42856A0; Fri, 20 Jan 2023 08:17:57 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0ED24856AE for ; Fri, 20 Jan 2023 08:17:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sumit.garg@linaro.org Received: by mail-pg1-x535.google.com with SMTP id v3so3464684pgh.4 for ; Thu, 19 Jan 2023 23:17:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=Uf0JUp0WOyuAxl1CUsKprRoREAUbOiStWI2VOsSFB6c=; b=oQLMl0gPlojdKUSjsHfKRvdQ/NnHZV1NzHq0bfFfbn0MP5mA8ImyLiVTwigjG4IJQw QMAT1xZDPGhPY4ATRlvIjy+30THjUvTim1TAJbCa42jaPshXjZj8g0LQbovFx2wQPi2j mOWsXgiAJw6II2xlEX8D+TyIacsePkG4HvAT1eJ30G5kUt8/0+YR+6ML8UC5jW/dymq6 QmT4RJKdP9izf7I1EjamxEBA+kIX1WdfIX0dDaZNRc6SRl6JJMN0bMxgtnbV4N9Ifidi j3T+1WanPQyLUfv7VPYSf289IHwvLIlA25T+oEEmEJw/lf0yt2ONRXaWU8VcpOSU9s4q DXyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=Uf0JUp0WOyuAxl1CUsKprRoREAUbOiStWI2VOsSFB6c=; b=ayDE25VSGzGrQKvBhAMrmGUTcsjc6hqjrPRx1UDQcj+OrApcYsmofghu/H06b3syoL KQ3Mfh6nOI2XnPWGbZyVj733c33JKQiuk9JdODWAIOTRmWMIP9oB3BNvT9l8h5epdeTa cTUbqRTTyOCQ/eTbO9F28t9SZ9nYsMRiZDHLLpHT0TiGaBRv4Bar1QuqasZsX9NxmCnK oC3YxuL4rUlwQ41yct51gDqzUVQz6WkfJhlkf9huEgAOQs9suuLVGW1C5pbheEp22vSb P1qPHwGQqaLUSbzXOhfsKh4hSB6+jcBmoqrQHnlWViB++cNQ80vHzitj6nhnzDnrLMfN cqzg== X-Gm-Message-State: AFqh2kp3o192H9dGM50pYAEZY/zdfHrav510nICH+tJsJud5Iu/e3aDu pFp2+SpdpO9mYEyNrsNu/ItCm7s0afPA1l8k X-Received: by 2002:a62:1c45:0:b0:58d:9850:d556 with SMTP id c66-20020a621c45000000b0058d9850d556mr13934274pfc.18.1674199072285; Thu, 19 Jan 2023 23:17:52 -0800 (PST) Received: from sumit-X1.. ([223.178.212.120]) by smtp.gmail.com with ESMTPSA id x15-20020aa7956f000000b0058bacd6c4e8sm9797586pfq.207.2023.01.19.23.17.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 23:17:52 -0800 (PST) From: Sumit Garg To: u-boot@lists.denx.de Cc: rfried.dev@gmail.com, hs@denx.de, joe.hershberger@ni.com, stephan@gerhold.net, mworsfold@impinj.com, lgillham@impinj.com, jbrennan@impinj.com, nicolas.dechesne@linaro.org, vinod.koul@linaro.org, daniel.thompson@linaro.org, Sumit Garg Subject: [PATCH 04/14] pinctrl: qcs404: Enable ethernet pinmux options Date: Fri, 20 Jan 2023 12:47:09 +0530 Message-Id: <20230120071719.623661-5-sumit.garg@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230120071719.623661-1-sumit.garg@linaro.org> References: <20230120071719.623661-1-sumit.garg@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Signed-off-by: Sumit Garg --- arch/arm/mach-snapdragon/pinctrl-qcs404.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm/mach-snapdragon/pinctrl-qcs404.c b/arch/arm/mach-snapdragon/pinctrl-qcs404.c index 889ead0f57..5a7fbfd441 100644 --- a/arch/arm/mach-snapdragon/pinctrl-qcs404.c +++ b/arch/arm/mach-snapdragon/pinctrl-qcs404.c @@ -22,6 +22,13 @@ static const char * const msm_pinctrl_pins[] = { static const struct pinctrl_function msm_pinctrl_functions[] = { {"blsp_uart2", 1}, + {"rgmii_int", 1}, + {"rgmii_ck", 1}, + {"rgmii_tx", 1}, + {"rgmii_ctl", 1}, + {"rgmii_rx", 1}, + {"rgmii_mdio", 1}, + {"rgmii_mdc", 1}, }; static const char *qcs404_get_function_name(struct udevice *dev, From patchwork Fri Jan 20 07:17:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 644609 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp637971pvb; Thu, 19 Jan 2023 23:18:56 -0800 (PST) X-Google-Smtp-Source: AMrXdXtKqNiNpn8a2KByvYpfrOqZSuUsOXFFZHgdfHMleDKd0iL/4xkJHxIw0Td89fl6/u2RyQ+9 X-Received: by 2002:a05:6808:15a6:b0:363:1449:1614 with SMTP id t38-20020a05680815a600b0036314491614mr7989050oiw.2.1674199136762; Thu, 19 Jan 2023 23:18:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674199136; cv=none; d=google.com; s=arc-20160816; b=ZyAszt+FUGyuc/sZfHttOYuwJ89RQNs35Swxvnx87PdZpG91vTJhpgHdoE4152fcsU Cr7uRLkAVvYDIQUkGW4TVhKWfxa/nsWjpuEVtyEnErjEC8g7jcbiQAGzt7coNBWKqjaU OCBTVbXp/VEJmQRd5aZrRfaDrMdbXL+22mFjkcMGf45xWF3s44XtHo6Y2ozWEM1Q1Fu/ RINO/BarLZKJkLtFeJJfisQsrWBf9U9558m463c7b82PoKeK1TBVaPaiqi/H9NMdM6yW PJB2jBKgBMshqD7SB8D9qlt+kRTIobhiaL1TEPvDNVDm2CV3HuzCQXeWdOjfmocU0+Ft mAng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=p4QXbhIBEYEVJTr0EjAPuGhsfyb+2nd1b+W+Go2gHcc=; b=Hc5I7N5vstXwoI18ovMfYvPE3bq2ZOXUvAUO6CUcojEJJGxcIvTLB7hNqIMAsywYhv 4dPuv5HdoSIXFxWCJrYYl/UMf0XHqkTugqOSK3wg9lEuB2RnubO8OemGgUDJ8uaos3gI TjUFQxR3F9D9315JhunFfw063XwTeJBIwd4+frNMaP0l4U/TujW+hCEbfS3UltPl6IKF /5YtSK3Kctgho1YugfCu9ifChmFSI2ZAP7E3HK/b9PyvE3psnCpV5k19yCSP79tcZPhq j7mzwwF8joWuO2f1ghM84VKyqsz2pKoBilRjFm+xEDWJdwhOSSl/XGVyNx0KiDRpH1bG A4aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wBq6DgEW; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id q24-20020a056808201800b0035b1e2b292asi40187292oiw.51.2023.01.19.23.18.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 23:18:56 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wBq6DgEW; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3F28A856B8; Fri, 20 Jan 2023 08:18:13 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="wBq6DgEW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 09EB085657; Fri, 20 Jan 2023 08:18:03 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 70686856A0 for ; Fri, 20 Jan 2023 08:17:58 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sumit.garg@linaro.org Received: by mail-pg1-x52d.google.com with SMTP id s67so3460538pgs.3 for ; Thu, 19 Jan 2023 23:17:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=p4QXbhIBEYEVJTr0EjAPuGhsfyb+2nd1b+W+Go2gHcc=; b=wBq6DgEW8M7bnf7E9uL1L5nt4qsOBHTZ2s4Zup5sCjh2jA4X6YXliONTtdY9R4C29u KyTcVltOt8ZnIPBSuJhTGhmU9CKFglRK7v5KhPyXIk/ZJ/auKSLaJ6UoiMGooJwgjDWa O0qIC03/WroP6xu8xObeY0gbzkVmFHn3yEvr3VqUXZPdG1p3xKF3Gt4OXV3vicUSmPtt jsLd4xE59Y3bB5R+6VJQx0MggtKTkkiWltGcoKqOTWIYiVlLBtL6l7RdThqGFTiYcdCb V64FzpL3jUhdt7MNBYByzfoAMPheHnolLAC6DDxyUmjThwbgXFTsAvyDWb4c9NrVy+v9 iaDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=p4QXbhIBEYEVJTr0EjAPuGhsfyb+2nd1b+W+Go2gHcc=; b=K+6bSzyjckZ+DIu1C46wf+BhPxWKeVvoIIh6Xxbb6yN1Cgil6XwVjPhXORs6Lr2F/f XH/NcwHDMTa6bz8b23bPj3EA8WodNHxVj2TWhQxjN3UvgF1OnrcVc0EmszhK17tzGbO/ 5RuuXLLtPdsl4AuEZMmMvdFQCPjubLVNC6pUrs20UvbXRrV5oUji32vd9O2hQT4YBikQ iaXN4d1lwWf2bsqEQnaSNFwN1PxKpgnSe8AOuFzObvHAoy3WAMEnzzSwwNaRgz4b43y1 rfUra/jFMDqK6tz7qDJAamJqeKzn6DBg3JTiup6U/B29dueKmXGide9zytW6muBjQO2t 34Gg== X-Gm-Message-State: AFqh2koh7nBNqVdMdt0dU/sfqTnVsQx+jAYpDxvQUy3QMVmPnLku3zpB vT+UJVhYi2u0Sgju/EERcoSaty+lPX9hcasx X-Received: by 2002:a05:6a00:26ef:b0:58d:f20b:5f2e with SMTP id p47-20020a056a0026ef00b0058df20b5f2emr7065365pfw.1.1674199076561; Thu, 19 Jan 2023 23:17:56 -0800 (PST) Received: from sumit-X1.. ([223.178.212.120]) by smtp.gmail.com with ESMTPSA id x15-20020aa7956f000000b0058bacd6c4e8sm9797586pfq.207.2023.01.19.23.17.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 23:17:56 -0800 (PST) From: Sumit Garg To: u-boot@lists.denx.de Cc: rfried.dev@gmail.com, hs@denx.de, joe.hershberger@ni.com, stephan@gerhold.net, mworsfold@impinj.com, lgillham@impinj.com, jbrennan@impinj.com, nicolas.dechesne@linaro.org, vinod.koul@linaro.org, daniel.thompson@linaro.org, Sumit Garg Subject: [PATCH 05/14] pinctrl-snapdragon: Get rid of custom drive-strength values Date: Fri, 20 Jan 2023 12:47:10 +0530 Message-Id: <20230120071719.623661-6-sumit.garg@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230120071719.623661-1-sumit.garg@linaro.org> References: <20230120071719.623661-1-sumit.garg@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Use standard pinconf drive-strength values from Linux DT bindings rather than ones based on custom u-boot header. These changes are in direction to make u-boot DTs for Qcom SoCs to be compatible with standard Linux DT bindings. Also, add support for pinconf bias-pull-up. Signed-off-by: Sumit Garg --- arch/arm/dts/dragonboard410c.dts | 3 +-- arch/arm/dts/dragonboard820c.dts | 3 +-- arch/arm/dts/qcom-ipq4019.dtsi | 1 - arch/arm/dts/qcs404-evb.dts | 1 - arch/arm/mach-snapdragon/pinctrl-snapdragon.c | 8 ++++++- .../dt-bindings/pinctrl/pinctrl-snapdragon.h | 22 ------------------- 6 files changed, 9 insertions(+), 29 deletions(-) delete mode 100644 include/dt-bindings/pinctrl/pinctrl-snapdragon.h diff --git a/arch/arm/dts/dragonboard410c.dts b/arch/arm/dts/dragonboard410c.dts index 59cf45eb17..9230dd3fd9 100644 --- a/arch/arm/dts/dragonboard410c.dts +++ b/arch/arm/dts/dragonboard410c.dts @@ -9,7 +9,6 @@ #include "skeleton64.dtsi" #include -#include / { model = "Qualcomm Technologies, Inc. Dragonboard 410c"; @@ -71,7 +70,7 @@ blsp1_uart: uart { function = "blsp1_uart"; pins = "GPIO_4", "GPIO_5"; - drive-strength = ; + drive-strength = <8>; bias-disable; }; }; diff --git a/arch/arm/dts/dragonboard820c.dts b/arch/arm/dts/dragonboard820c.dts index aaca681d2e..ad201d4874 100644 --- a/arch/arm/dts/dragonboard820c.dts +++ b/arch/arm/dts/dragonboard820c.dts @@ -8,7 +8,6 @@ /dts-v1/; #include "skeleton64.dtsi" -#include / { model = "Qualcomm Technologies, Inc. DB820c"; @@ -71,7 +70,7 @@ blsp8_uart: uart { function = "blsp_uart8"; pins = "GPIO_4", "GPIO_5"; - drive-strength = ; + drive-strength = <8>; bias-disable; }; }; diff --git a/arch/arm/dts/qcom-ipq4019.dtsi b/arch/arm/dts/qcom-ipq4019.dtsi index 181732d262..6edc69da67 100644 --- a/arch/arm/dts/qcom-ipq4019.dtsi +++ b/arch/arm/dts/qcom-ipq4019.dtsi @@ -9,7 +9,6 @@ #include "skeleton.dtsi" #include -#include #include #include diff --git a/arch/arm/dts/qcs404-evb.dts b/arch/arm/dts/qcs404-evb.dts index c8bcf9f71d..cc70afa4c8 100644 --- a/arch/arm/dts/qcs404-evb.dts +++ b/arch/arm/dts/qcs404-evb.dts @@ -9,7 +9,6 @@ #include "skeleton64.dtsi" #include -#include #include / { diff --git a/arch/arm/mach-snapdragon/pinctrl-snapdragon.c b/arch/arm/mach-snapdragon/pinctrl-snapdragon.c index ab884ab6bf..826dc51486 100644 --- a/arch/arm/mach-snapdragon/pinctrl-snapdragon.c +++ b/arch/arm/mach-snapdragon/pinctrl-snapdragon.c @@ -28,8 +28,9 @@ struct msm_pinctrl_priv { #define TLMM_GPIO_DISABLE BIT(9) static const struct pinconf_param msm_conf_params[] = { - { "drive-strength", PIN_CONFIG_DRIVE_STRENGTH, 3 }, + { "drive-strength", PIN_CONFIG_DRIVE_STRENGTH, 2 }, { "bias-disable", PIN_CONFIG_BIAS_DISABLE, 0 }, + { "bias-pull-up", PIN_CONFIG_BIAS_PULL_UP, 3 }, }; static int msm_get_functions_count(struct udevice *dev) @@ -89,6 +90,7 @@ static int msm_pinconf_set(struct udevice *dev, unsigned int pin_selector, switch (param) { case PIN_CONFIG_DRIVE_STRENGTH: + argument = (argument / 2) - 1; clrsetbits_le32(priv->base + GPIO_CONFIG_OFFSET(pin_selector), TLMM_DRV_STRENGTH_MASK, argument << 6); break; @@ -96,6 +98,10 @@ static int msm_pinconf_set(struct udevice *dev, unsigned int pin_selector, clrbits_le32(priv->base + GPIO_CONFIG_OFFSET(pin_selector), TLMM_GPIO_PULL_MASK); break; + case PIN_CONFIG_BIAS_PULL_UP: + clrsetbits_le32(priv->base + GPIO_CONFIG_OFFSET(pin_selector), + TLMM_GPIO_PULL_MASK, argument); + break; default: return 0; } diff --git a/include/dt-bindings/pinctrl/pinctrl-snapdragon.h b/include/dt-bindings/pinctrl/pinctrl-snapdragon.h deleted file mode 100644 index 615affb6f2..0000000000 --- a/include/dt-bindings/pinctrl/pinctrl-snapdragon.h +++ /dev/null @@ -1,22 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* - * This header provides constants for Qualcomm Snapdragon pinctrl bindings. - * - * (C) Copyright 2018 Ramon Fried - * - */ - -#ifndef _DT_BINDINGS_PINCTRL_SNAPDRAGON_H -#define _DT_BINDINGS_PINCTRL_SNAPDRAGON_H - -/* GPIO Drive Strength */ -#define DRIVE_STRENGTH_2MA 0 -#define DRIVE_STRENGTH_4MA 1 -#define DRIVE_STRENGTH_6MA 2 -#define DRIVE_STRENGTH_8MA 3 -#define DRIVE_STRENGTH_10MA 4 -#define DRIVE_STRENGTH_12MA 5 -#define DRIVE_STRENGTH_14MA 6 -#define DRIVE_STRENGTH_16MA 7 - -#endif From patchwork Fri Jan 20 07:17:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 644610 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp638030pvb; Thu, 19 Jan 2023 23:19:10 -0800 (PST) X-Google-Smtp-Source: AMrXdXt1hiVKlf/peC8XCpSMSSfuYgC//BT0ksh/wW7lc+7C+kuQYDVn9ZyHWUtVvwtvL8gbPgxa X-Received: by 2002:a05:6830:3192:b0:686:55fc:924 with SMTP id p18-20020a056830319200b0068655fc0924mr4889819ots.10.1674199150609; Thu, 19 Jan 2023 23:19:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674199150; cv=none; d=google.com; s=arc-20160816; b=EoyMlKVznEeCbY6fIawPql+Y/DNK1n9oG+0yneUB5KpJglo9wqKMv2SrSJZqyGQljg dHoUpVnDzIWOs1jVSk62vLzn11dnRgbsciSU6CpAje0i4mdx0Xkj0fX39PbGm0Czd3hb qG9x2cAomHaLFAQ40p3crlOv29Udy8KCg3f4rF2LToE5GXmDPwgJJjkU7xM1fhnf1Ipb Ng4zBTXmC+h+NamNZjFlVXa8qks71sSJGG2qcCA1cbdNvdreru/szTl13+QHegCEeZgo FI82f9KsY4/HBqgFKMjrZHth39TBhVSW61BcNQZ0W4wmHn3M/NGE9wx1nCLU/6WxDC+b u7jA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nQ4N2iEXD19K17SmVs7Q6jYkWQq8B8obtRDPStpvTrA=; b=ZIcEHcnmWCth5nGJuCCwhNLKCLVNVKKIPNzOpadDj08YLS7nM+D08mAVC1WBuSPywr 7deS71ql52BbI0x39gEyylMQYBTLnvM0spyJFhqET00WLjQulgplU4vW7E88BbBwYQqD FG+RGB7kmC94SddS++kfnZfgd1N/f6BAbdDXCZ+KQIU71ei6YmQ/c8//Mkcq9jJOqmu2 cipl2uiAUlmcfqZaA0l+EApjsMnVKzqaz6CHN7EYnmNhOuJE9AlDhoeEuVPw4U6YuxQz 7dsBExwQpNeF0FT8nrUt62fILGZTTLLLEpCTyNKjIJlpGFJzbryOEgMIZSDqyYa5CBia DvuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Yqjv+1Zw; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id f18-20020a056830205200b00684a2a98118si20550269otp.38.2023.01.19.23.19.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 23:19:10 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Yqjv+1Zw; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 834AD856C0; Fri, 20 Jan 2023 08:18:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Yqjv+1Zw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9E7BC856B9; Fri, 20 Jan 2023 08:18:07 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5EB63856A7 for ; Fri, 20 Jan 2023 08:18:04 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sumit.garg@linaro.org Received: by mail-pj1-x102d.google.com with SMTP id d8so4767434pjc.3 for ; Thu, 19 Jan 2023 23:18:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=nQ4N2iEXD19K17SmVs7Q6jYkWQq8B8obtRDPStpvTrA=; b=Yqjv+1ZwVEIivYmCuaEe8GGTtAjmRGf+E1lMpf+Ig1p2SfrFjLivGSD1p/tynPDiQZ Br/g2HRPnd99w3s0pEj4sgr77RWmCVAtzH4UwkO6LYdRvbZS2gHqqHQXyzAjldAd+N+Q qqY+9xCPPL8LgZezfAPYq4ifqwGHjp/fTcO1xyfYHwGBA/JujFx7jqoK8gFpWlk3WUTk WuCfAa8qQR2Mxsnfg6S5BqpseybxCR18/HR8kGOfHch7iMuV0zTMnbIHbvntFuWbx0et mU1KYDMF8xTar+LH2hoZEf1geUtpH5Cw7VaLxjiTrj7VxorolfRmwQp9r19i+PVLFnNy 5dSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=nQ4N2iEXD19K17SmVs7Q6jYkWQq8B8obtRDPStpvTrA=; b=rSNe43hf6qdeUEoO8ZhUdglFChSHn163mIM7nCzFwi8YrQYmk44/qvsu8vNYETG0hG pFjPRqBEI0Fw7oRxf1ZmhD/P2DKRgk3aLrcfS0JRtRRF726KSECYG7D1QOHOKtpftN4E aNYXGkakCmLmiQDvee5YWA5AoT/FdPjjzHix/zJaG5fYuv9VTGxWTNV50CdtCi7ltXwW G91GroA+iBmW9AjWaURkuiEgshV+B1lxAjDg8hESGmQBzhvV8DC2mCwBUGvwVY60L2Lw j6fR7WXlRqcuNI0vOV54dQ/pYDx1V3tAlEe78zG38NZGJlI1bRzMjRFYb318V1AnTDfI aGTA== X-Gm-Message-State: AFqh2koXPy7TFGjN4F4tGQmALUdA3Dv7OGC+aGKas1Qfi4t+9VKzG64b OWoVD/vUsxodsZAGv7Bm5hfbyuLzYjDYkuQu X-Received: by 2002:a05:6a20:ce43:b0:9d:efbe:2066 with SMTP id id3-20020a056a20ce4300b0009defbe2066mr14481379pzb.28.1674199080883; Thu, 19 Jan 2023 23:18:00 -0800 (PST) Received: from sumit-X1.. ([223.178.212.120]) by smtp.gmail.com with ESMTPSA id x15-20020aa7956f000000b0058bacd6c4e8sm9797586pfq.207.2023.01.19.23.17.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 23:18:00 -0800 (PST) From: Sumit Garg To: u-boot@lists.denx.de Cc: rfried.dev@gmail.com, hs@denx.de, joe.hershberger@ni.com, stephan@gerhold.net, mworsfold@impinj.com, lgillham@impinj.com, jbrennan@impinj.com, nicolas.dechesne@linaro.org, vinod.koul@linaro.org, daniel.thompson@linaro.org, Sumit Garg Subject: [PATCH 06/14] net: dwc_eth_qos: Make eqos_get_tick_clk_rate callback optional Date: Fri, 20 Jan 2023 12:47:11 +0530 Message-Id: <20230120071719.623661-7-sumit.garg@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230120071719.623661-1-sumit.garg@linaro.org> References: <20230120071719.623661-1-sumit.garg@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Signed-off-by: Sumit Garg Reviewed-by: Ramon Fried --- drivers/net/dwc_eth_qos.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c index afc47b56ff..753a912607 100644 --- a/drivers/net/dwc_eth_qos.c +++ b/drivers/net/dwc_eth_qos.c @@ -774,10 +774,13 @@ static int eqos_start(struct udevice *dev) pr_err("eqos_calibrate_pads() failed: %d", ret); goto err_stop_resets; } - rate = eqos->config->ops->eqos_get_tick_clk_rate(dev); - val = (rate / 1000000) - 1; - writel(val, &eqos->mac_regs->us_tic_counter); + if (eqos->config->ops->eqos_get_tick_clk_rate) { + rate = eqos->config->ops->eqos_get_tick_clk_rate(dev); + + val = (rate / 1000000) - 1; + writel(val, &eqos->mac_regs->us_tic_counter); + } /* * if PHY was already connected and configured, From patchwork Fri Jan 20 07:17:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 644611 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp638102pvb; Thu, 19 Jan 2023 23:19:23 -0800 (PST) X-Google-Smtp-Source: AMrXdXvEcCff+w1m+IUtyIcASg8nmug06RBYScvC4xQzJwKvLjS76dDumKZsfAKgcvYP0FqykBFJ X-Received: by 2002:a9d:6f05:0:b0:684:a657:3a44 with SMTP id n5-20020a9d6f05000000b00684a6573a44mr7235985otq.16.1674199163601; Thu, 19 Jan 2023 23:19:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674199163; cv=none; d=google.com; s=arc-20160816; b=D3F9+qhtRfTFKI6roBnwU5eGnSwfD5/DuKg12u9+NnoCOTMIdCEmtxkmZhLf8sqB6a wxUOuli8YKdO5J3H8te8i973qQcfh1okRg22wfAzMln6WyWF8+Sk12PwE+Mug8ARmG7c k0mFfveIR/8AwZMJdx3od055BwE+IIMb018oSUtFHpG+w6MT9Cb1y64CPmBYD8tkbWjs mQe/l9xnBxqmPFAjty7qBf08QXI0TpTojz10CJ0zjQcVjuonVDvSkW9t3lUmGcS1bJVW VWtrC6dMBAKfbKGzrL9XsJdOK2IzFn/Llf0FD0YG4o0AZzZeZ+Bldqhsib6tDzZqohTJ DCqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=EykesWwKz9OUTCa4KBwIKHRquT8YbapR9SO1jwz0yT0=; b=qlZgy+LwUOjkQKQ/Mh1jXVkALv1cuQOQrlqeM8cU85BGatFpF0GXSWgypZgqBnTQ3G NM4NGCX6ufMtnnJB8FL/ZUCrWSflGh/d9QTQ6LXAgpITp+eRBj2SnU7m6WCeX4B9FLPx Ls6nl9vsx0hCab1/SAViI9Uu2EfwrhAuELCOh8sTH3+4qpCcNU0Vs2zK+L+Vwsvi3UJa jCxVbtEGk0GEGLR4+IZ4Lj1ClW0OSRtocv8+Qd0MgHl3v5KbUzv+EQOyx8W96JGQVaGO rjdZ92piq0y2a5jTrZMVeCikx9hFtTkr7WlPfcYbfBazcK/15pL8E7w8wLifHR/f3U+H mrAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QQ44tiow; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id d13-20020a056830004d00b00684c22c83cdsi22556196otp.170.2023.01.19.23.19.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 23:19:23 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QQ44tiow; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7F3CC856B2; Fri, 20 Jan 2023 08:18:26 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="QQ44tiow"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6376A856B2; Fri, 20 Jan 2023 08:18:14 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 12770856B5 for ; Fri, 20 Jan 2023 08:18:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sumit.garg@linaro.org Received: by mail-pg1-x536.google.com with SMTP id 7so3466930pga.1 for ; Thu, 19 Jan 2023 23:18:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=EykesWwKz9OUTCa4KBwIKHRquT8YbapR9SO1jwz0yT0=; b=QQ44tiow8Lql46RYjfjFFlvESPDODVwXSHXxh7H+IropRegBy/YXQ2TnRGagIM4jQC d8NGRFnUApdTQtbmDkoyDCnyEsZwsk6C4zrNDX7+hQuy7pBdYiXAl9R9m+7Uv8hhaG4/ WQiSMTtforWajpQDPKQdAdAw8RYG8sslQEYfQle7j4pdh5aoN5AN9iFkb/uQNUsx13vO k1YHpjh96Uq8Hqk28tQlL7sZAVHDFqeD+oeOqyeb4+7HRxZ46whEdyZ4Y9TRAJ4MJiAk O/T1n0fauLPFrIz15sDLLEHERT+sNSRVRniYrQ7dBkDRaiyGYcKJ0QGf2I7VFGTDjjAK 0nIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=EykesWwKz9OUTCa4KBwIKHRquT8YbapR9SO1jwz0yT0=; b=JH766g848qafDYlnRJNVxPbsodrPBfA8qv2Who9427SH7kf25PoXvh2N0MLHZX8O+F fPASGldEddM3iObTT09kDf7DBMsKAThiK2b/i8Q5cZh9O+Acpn93GR4aQzeGp1lKW8v9 AgXC31QC61fsz1NbfAcJLwxIKoo7s+yoqsZLcmp4tHQmnW94G0j7qaPFi73y5wXL38cl MvhmeUJb6UN/53XVXSiTCD+TjMxigsWAEX7ayLdn+/UC7eoBocsj3Pmn0PbXl7oOqZjv z1vQVw3+hGmJ42lNB0b6oZpgbo+oDYDWdOUHMULrVlQlhkjiRYzCbgeI7F+xoeStc8IT n93g== X-Gm-Message-State: AFqh2kpUDe6sCe8I5QHzMXLLSbDgq98Ts9MRO+NvuLlPZWprr6BKnkcj IpcUEHLpXblxO0qoo2iDlqhaMMXryxVRwFdF X-Received: by 2002:a62:1910:0:b0:58d:c1ca:9360 with SMTP id 16-20020a621910000000b0058dc1ca9360mr14742778pfz.17.1674199085185; Thu, 19 Jan 2023 23:18:05 -0800 (PST) Received: from sumit-X1.. ([223.178.212.120]) by smtp.gmail.com with ESMTPSA id x15-20020aa7956f000000b0058bacd6c4e8sm9797586pfq.207.2023.01.19.23.18.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 23:18:04 -0800 (PST) From: Sumit Garg To: u-boot@lists.denx.de Cc: rfried.dev@gmail.com, hs@denx.de, joe.hershberger@ni.com, stephan@gerhold.net, mworsfold@impinj.com, lgillham@impinj.com, jbrennan@impinj.com, nicolas.dechesne@linaro.org, vinod.koul@linaro.org, daniel.thompson@linaro.org, Sumit Garg Subject: [PATCH 07/14] net: dwc_eth_qos: Allow platform to override tx/rx_fifo_sz Date: Fri, 20 Jan 2023 12:47:12 +0530 Message-Id: <20230120071719.623661-8-sumit.garg@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230120071719.623661-1-sumit.garg@linaro.org> References: <20230120071719.623661-1-sumit.garg@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean The GMAC controller on QCS404 SoC (support added by upcoming patch) fails to work with maximum tx/rx_fifo_sz supported by the hardware (16K). So allow platforms to override FIFO size using corresponding DT node properties. Signed-off-by: Sumit Garg Reviewed-by: Ramon Fried --- drivers/net/dwc_eth_qos.c | 19 +++++++++++++------ drivers/net/dwc_eth_qos.h | 1 + 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c index 753a912607..65b8556be2 100644 --- a/drivers/net/dwc_eth_qos.c +++ b/drivers/net/dwc_eth_qos.c @@ -852,12 +852,19 @@ static int eqos_start(struct udevice *dev) rx_fifo_sz = (val >> EQOS_MAC_HW_FEATURE1_RXFIFOSIZE_SHIFT) & EQOS_MAC_HW_FEATURE1_RXFIFOSIZE_MASK; - /* - * r/tx_fifo_sz is encoded as log2(n / 128). Undo that by shifting. - * r/tqs is encoded as (n / 256) - 1. - */ - tqs = (128 << tx_fifo_sz) / 256 - 1; - rqs = (128 << rx_fifo_sz) / 256 - 1; + /* r/tx_fifo_sz is encoded as log2(n / 128). Undo that by shifting */ + tx_fifo_sz = 128 << tx_fifo_sz; + rx_fifo_sz = 128 << rx_fifo_sz; + + /* Allow platform to override TX/RX fifo size */ + if (eqos->tx_fifo_sz) + tx_fifo_sz = eqos->tx_fifo_sz; + if (eqos->rx_fifo_sz) + rx_fifo_sz = eqos->rx_fifo_sz; + + /* r/tqs is encoded as (n / 256) - 1 */ + tqs = tx_fifo_sz / 256 - 1; + rqs = rx_fifo_sz / 256 - 1; clrsetbits_le32(&eqos->mtl_regs->txq0_operation_mode, EQOS_MTL_TXQ0_OPERATION_MODE_TQS_MASK << diff --git a/drivers/net/dwc_eth_qos.h b/drivers/net/dwc_eth_qos.h index 8fccd6f057..466a792de7 100644 --- a/drivers/net/dwc_eth_qos.h +++ b/drivers/net/dwc_eth_qos.h @@ -276,6 +276,7 @@ struct eqos_priv { bool started; bool reg_access_ok; bool clk_ck_enabled; + unsigned int tx_fifo_sz, rx_fifo_sz; }; void eqos_inval_desc_generic(void *desc); From patchwork Fri Jan 20 07:17:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 644612 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp638179pvb; Thu, 19 Jan 2023 23:19:36 -0800 (PST) X-Google-Smtp-Source: AMrXdXvt7Ny8CiiLcP1qyTrJyd/QsW8hJIv+77k+7UqsjozWERT3KeeVloIhrj8GUOayFqcgpNPV X-Received: by 2002:a4a:a509:0:b0:4f2:2208:46a2 with SMTP id v9-20020a4aa509000000b004f2220846a2mr6758625ook.8.1674199176333; Thu, 19 Jan 2023 23:19:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674199176; cv=none; d=google.com; s=arc-20160816; b=LwkQHCRTo3syh+Bw7GffnFy4XWkYWaFpxm0z1OqnCyehsTEOMKQ+MykGkv6IPiprug OkLi60O/jHhhsbglBhdHNre7YjgAIKN4qD3fCyHUnQRjhvprlvGZ+Lxc7X3S54nAMr+m jOqghySNVbeV88f6/4szHzL52T9rGeGvLVpqc8f3qF673PTJ2kfV4iUwrJr6pqlK96PO sddXIR13nnuW2VRMa2ce5xiOojcbnNFwuBhLRYwvvvZcfBb9/n34+qRheT8zhkBft4lQ vXY9ytqgYZIhWOxtTY3yN7j4gFTPoWtMt8Cf7wH7wuoZ0hFFOoXir8vLEv4rRp51+KDO ulgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=802uP/qYFsXNpFPpKtLgraFSP3GdBPd001BAT0HwI10=; b=x1CD3yseNZkd8OGRQ+qzAhea7SQ0LqACXDcZblTs/xio9x3uXiUBtC0PeYk8RELxVi QzV/qmjrHFySuuPsiZebGIOxVXjXb5RXgHXY8JcPedNAQJqc/WZM2m6XEXG6wafPGL5n EcMz7Ty7CNB60Lyq7zJdjI9N0keKIa1Va3glKKqSZfTvgDCiOuWZgo7i02A3pATmf1hr A6+8uktt3YDLk5fZN+qZDTIB4X3GYaUoMiri66nn2vChMXJNcLbwNfO5J/EKwwfEsUmw hlSDs0D15R99832wanFmhDsyhN3oBBPeO0kR4UM0U0aFHhFMNJZtQL3PFWUBli7oVYgw nGvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LKSPcGs6; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id k185-20020a4a4ac2000000b004f299ed0495si22506380oob.66.2023.01.19.23.19.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 23:19:36 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LKSPcGs6; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BD85D856BD; Fri, 20 Jan 2023 08:18:28 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="LKSPcGs6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DCC17856C7; Fri, 20 Jan 2023 08:18:19 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 984BE856AE for ; Fri, 20 Jan 2023 08:18:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sumit.garg@linaro.org Received: by mail-pl1-x632.google.com with SMTP id jm10so4563301plb.13 for ; Thu, 19 Jan 2023 23:18:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=802uP/qYFsXNpFPpKtLgraFSP3GdBPd001BAT0HwI10=; b=LKSPcGs6/H+0mLEOD1wYUiTPNmeDFtV8bK20SsTQBtGMS3Y02FfeoflwazgFhWNmAa CJsvVUh28FRCHDezRJcfcNT2ImtVnJFXZn1liwR0q9gGa2IJoVLfLEJ+x19qe1c5TZN+ +dDhzeDcGOTI1KqMtP41nnOHLyRm3Bi8teFsqJlTPtXKfeCJ8XpbgLjErU7k335ezvz9 iK/DSkZl9AyfHx2KTC6AWtv6zCqbHllzui3oZOScgb6CRHWx7D8QloHxyhprt+nI9/Ok NDBFHrT0HSzG6wKnhrs6g5EC7TlPCihpcwphlzwbufQurbRqTwrgJwMKATwtbOZ7uZqx dnAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=802uP/qYFsXNpFPpKtLgraFSP3GdBPd001BAT0HwI10=; b=cD0nxzHUELodX7sZYkHMgGORH4R02qsU6+HD/1t1QoglLTzb1mHuDhCbFbSifSwfs9 UraHgg8OmPL0wzdW4v65XtYP+1xBYIuPNmzT6XO57HKs0PPRogFLUnuXYMwDfHgFYHDc +cjOc7X426wfemwJ/ABfM7eiS3M/eiF5uSoFIJBSjeGLf5vYbWiTZ9/fJ4lNx9f7rLOJ nTBu7hR1o4HN9FOBzXv6UpJflQZ14AC2RAzj5mN8SeF5Qpfz6wJk2ysBRgDwzPYycgks SAC/lU3joJGMB0CKwyWc/r2rikwL17cU9IP28UoE2epedCAPalZgQfy+luRpk6dMAhFo uL0w== X-Gm-Message-State: AFqh2kpIKW254+QH9xs0yitA1W4rjw7h7Z5baDdVQvLtoTTQvZiZXCz0 oMeHZhtXvN5qpaYpq5EXshbE0jj0NjzhWRTN X-Received: by 2002:a05:6a20:1a9d:b0:b0:b870:54e1 with SMTP id ci29-20020a056a201a9d00b000b0b87054e1mr12870663pzb.12.1674199089496; Thu, 19 Jan 2023 23:18:09 -0800 (PST) Received: from sumit-X1.. ([223.178.212.120]) by smtp.gmail.com with ESMTPSA id x15-20020aa7956f000000b0058bacd6c4e8sm9797586pfq.207.2023.01.19.23.18.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 23:18:09 -0800 (PST) From: Sumit Garg To: u-boot@lists.denx.de Cc: rfried.dev@gmail.com, hs@denx.de, joe.hershberger@ni.com, stephan@gerhold.net, mworsfold@impinj.com, lgillham@impinj.com, jbrennan@impinj.com, nicolas.dechesne@linaro.org, vinod.koul@linaro.org, daniel.thompson@linaro.org, Sumit Garg Subject: [PATCH 08/14] net: dwc_eth_qos: Add Qcom ethernet driver glue layer Date: Fri, 20 Jan 2023 12:47:13 +0530 Message-Id: <20230120071719.623661-9-sumit.garg@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230120071719.623661-1-sumit.garg@linaro.org> References: <20230120071719.623661-1-sumit.garg@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean The Qualcom ETHQOS hardware supports an RGMII macro which needs to be configured according to following link speeds: - SPEED_1000 - SPEED_100 - SPEED_10 So add a corresponding glue driver to configure RGMII macro. Signed-off-by: Sumit Garg Reviewed-by: Ramon Fried --- drivers/net/Kconfig | 7 + drivers/net/Makefile | 1 + drivers/net/dwc_eth_qos.c | 7 + drivers/net/dwc_eth_qos.h | 3 + drivers/net/dwc_eth_qos_qcom.c | 612 +++++++++++++++++++++++++++++++++ 5 files changed, 630 insertions(+) create mode 100644 drivers/net/dwc_eth_qos_qcom.c diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 7873538cc2..815e1f9248 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -242,6 +242,13 @@ config DWC_ETH_QOS_TEGRA186 The Synopsys Designware Ethernet QOS IP block with specific configuration used in NVIDIA's Tegra186 chip. +config DWC_ETH_QOS_QCOM + bool "Synopsys DWC Ethernet QOS device support for Qcom SoCs" + depends on DWC_ETH_QOS + help + The Synopsys Designware Ethernet QOS IP block with specific + configuration used in Qcom QCS404 SoC. + config E1000 bool "Intel PRO/1000 Gigabit Ethernet support" depends on PCI diff --git a/drivers/net/Makefile b/drivers/net/Makefile index 5b4e60eea3..b009b10aca 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile @@ -20,6 +20,7 @@ obj-$(CONFIG_DRIVER_DM9000) += dm9000x.o obj-$(CONFIG_DSA_SANDBOX) += dsa_sandbox.o obj-$(CONFIG_DWC_ETH_QOS) += dwc_eth_qos.o obj-$(CONFIG_DWC_ETH_QOS_IMX) += dwc_eth_qos_imx.o +obj-$(CONFIG_DWC_ETH_QOS_QCOM) += dwc_eth_qos_qcom.o obj-$(CONFIG_E1000) += e1000.o obj-$(CONFIG_E1000_SPI) += e1000_spi.o obj-$(CONFIG_EEPRO100) += eepro100.o diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c index 65b8556be2..112deb546d 100644 --- a/drivers/net/dwc_eth_qos.c +++ b/drivers/net/dwc_eth_qos.c @@ -1712,6 +1712,13 @@ static const struct udevice_id eqos_ids[] = { }, #endif +#if IS_ENABLED(CONFIG_DWC_ETH_QOS_QCOM) + { + .compatible = "qcom,qcs404-ethqos", + .data = (ulong)&eqos_qcom_config + }, +#endif + { } }; diff --git a/drivers/net/dwc_eth_qos.h b/drivers/net/dwc_eth_qos.h index 466a792de7..fddbe9336c 100644 --- a/drivers/net/dwc_eth_qos.h +++ b/drivers/net/dwc_eth_qos.h @@ -253,6 +253,7 @@ struct eqos_priv { struct eqos_mtl_regs *mtl_regs; struct eqos_dma_regs *dma_regs; struct eqos_tegra186_regs *tegra186_regs; + void *eqos_qcom_rgmii_regs; struct reset_ctl reset_ctl; struct gpio_desc phy_reset_gpio; struct clk clk_master_bus; @@ -277,6 +278,7 @@ struct eqos_priv { bool reg_access_ok; bool clk_ck_enabled; unsigned int tx_fifo_sz, rx_fifo_sz; + u32 reset_delays[3]; }; void eqos_inval_desc_generic(void *desc); @@ -286,3 +288,4 @@ void eqos_flush_buffer_generic(void *buf, size_t size); int eqos_null_ops(struct udevice *dev); extern struct eqos_config eqos_imx_config; +extern struct eqos_config eqos_qcom_config; diff --git a/drivers/net/dwc_eth_qos_qcom.c b/drivers/net/dwc_eth_qos_qcom.c new file mode 100644 index 0000000000..df83f1c5f9 --- /dev/null +++ b/drivers/net/dwc_eth_qos_qcom.c @@ -0,0 +1,612 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2022-2023 Sumit Garg + * + * Qcom DWMAC specific glue layer + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "dwc_eth_qos.h" + +/* RGMII_IO_MACRO_CONFIG fields */ +#define RGMII_CONFIG_FUNC_CLK_EN BIT(30) +#define RGMII_CONFIG_POS_NEG_DATA_SEL BIT(23) +#define RGMII_CONFIG_GPIO_CFG_RX_INT GENMASK(21, 20) +#define RGMII_CONFIG_GPIO_CFG_TX_INT GENMASK(19, 17) +#define RGMII_CONFIG_MAX_SPD_PRG_9 GENMASK(16, 8) +#define RGMII_CONFIG_MAX_SPD_PRG_2 GENMASK(7, 6) +#define RGMII_CONFIG_INTF_SEL GENMASK(5, 4) +#define RGMII_CONFIG_BYPASS_TX_ID_EN BIT(3) +#define RGMII_CONFIG_LOOPBACK_EN BIT(2) +#define RGMII_CONFIG_PROG_SWAP BIT(1) +#define RGMII_CONFIG_DDR_MODE BIT(0) + +/* SDCC_HC_REG_DLL_CONFIG fields */ +#define SDCC_DLL_CONFIG_DLL_RST BIT(30) +#define SDCC_DLL_CONFIG_PDN BIT(29) +#define SDCC_DLL_CONFIG_MCLK_FREQ GENMASK(26, 24) +#define SDCC_DLL_CONFIG_CDR_SELEXT GENMASK(23, 20) +#define SDCC_DLL_CONFIG_CDR_EXT_EN BIT(19) +#define SDCC_DLL_CONFIG_CK_OUT_EN BIT(18) +#define SDCC_DLL_CONFIG_CDR_EN BIT(17) +#define SDCC_DLL_CONFIG_DLL_EN BIT(16) +#define SDCC_DLL_MCLK_GATING_EN BIT(5) +#define SDCC_DLL_CDR_FINE_PHASE GENMASK(3, 2) + +/* SDCC_HC_REG_DDR_CONFIG fields */ +#define SDCC_DDR_CONFIG_PRG_DLY_EN BIT(31) +#define SDCC_DDR_CONFIG_EXT_PRG_RCLK_DLY GENMASK(26, 21) +#define SDCC_DDR_CONFIG_EXT_PRG_RCLK_DLY_CODE GENMASK(29, 27) +#define SDCC_DDR_CONFIG_EXT_PRG_RCLK_DLY_EN BIT(30) +#define SDCC_DDR_CONFIG_PRG_RCLK_DLY GENMASK(8, 0) + +/* SDCC_HC_REG_DLL_CONFIG2 fields */ +#define SDCC_DLL_CONFIG2_DLL_CLOCK_DIS BIT(21) +#define SDCC_DLL_CONFIG2_MCLK_FREQ_CALC GENMASK(17, 10) +#define SDCC_DLL_CONFIG2_DDR_TRAFFIC_INIT_SEL GENMASK(3, 2) +#define SDCC_DLL_CONFIG2_DDR_TRAFFIC_INIT_SW BIT(1) +#define SDCC_DLL_CONFIG2_DDR_CAL_EN BIT(0) + +/* SDC4_STATUS bits */ +#define SDC4_STATUS_DLL_LOCK BIT(7) + +/* RGMII_IO_MACRO_CONFIG2 fields */ +#define RGMII_CONFIG2_RSVD_CONFIG15 GENMASK(31, 17) +#define RGMII_CONFIG2_RGMII_CLK_SEL_CFG BIT(16) +#define RGMII_CONFIG2_TX_TO_RX_LOOPBACK_EN BIT(13) +#define RGMII_CONFIG2_CLK_DIVIDE_SEL BIT(12) +#define RGMII_CONFIG2_RX_PROG_SWAP BIT(7) +#define RGMII_CONFIG2_DATA_DIVIDE_CLK_SEL BIT(6) +#define RGMII_CONFIG2_TX_CLK_PHASE_SHIFT_EN BIT(5) + +struct dwmac_rgmii_regs { + u32 io_macro_config; /* 0x00 */ + u32 sdcc_hc_dll_config; /* 0x04 */ + u32 reserved_1; /* 0x08 */ + u32 sdcc_hc_ddr_config; /* 0x0c */ + u32 sdcc_hc_dll_config2; /* 0x10 */ + u32 sdc4_status; /* 0x14 */ + u32 sdcc_usr_ctl; /* 0x18 */ + u32 io_macro_config2; /* 0x1c */ + u32 io_macro_debug1; /* 0x20 */ + u32 reserved_2; /* 0x24 */ + u32 emac_sys_low_power_dbg; /* 0x28 */ + u32 reserved_3[53]; /* upto 0x100 */ +}; + +static struct dwmac_rgmii_regs emac_v2_3_0_por = { + .io_macro_config = 0x00C01343, + .sdcc_hc_dll_config = 0x2004642C, + .sdcc_hc_ddr_config = 0x00000000, + .sdcc_hc_dll_config2 = 0x00200000, + .sdcc_usr_ctl = 0x00010800, + .io_macro_config2 = 0x00002060 +}; + +static void ethqos_set_func_clk_en(struct dwmac_rgmii_regs *regs) +{ + setbits_le32(®s->io_macro_config, RGMII_CONFIG_FUNC_CLK_EN); +} + +static int ethqos_dll_configure(struct udevice *dev, + struct dwmac_rgmii_regs *regs) +{ + unsigned int val; + int retry = 1000; + + /* Set CDR_EN */ + setbits_le32(®s->sdcc_hc_dll_config, SDCC_DLL_CONFIG_CDR_EN); + + /* Set CDR_EXT_EN */ + setbits_le32(®s->sdcc_hc_dll_config, SDCC_DLL_CONFIG_CDR_EXT_EN); + + /* Clear CK_OUT_EN */ + clrbits_le32(®s->sdcc_hc_dll_config, SDCC_DLL_CONFIG_CK_OUT_EN); + + /* Set DLL_EN */ + setbits_le32(®s->sdcc_hc_dll_config, SDCC_DLL_CONFIG_DLL_EN); + + clrbits_le32(®s->sdcc_hc_dll_config, SDCC_DLL_MCLK_GATING_EN); + + clrbits_le32(®s->sdcc_hc_dll_config, SDCC_DLL_CDR_FINE_PHASE); + + /* Wait for CK_OUT_EN clear */ + do { + val = readl(®s->sdcc_hc_dll_config); + val &= SDCC_DLL_CONFIG_CK_OUT_EN; + if (!val) + break; + mdelay(1); + retry--; + } while (retry > 0); + if (!retry) + dev_err(dev, "Clear CK_OUT_EN timedout\n"); + + /* Set CK_OUT_EN */ + setbits_le32(®s->sdcc_hc_dll_config, SDCC_DLL_CONFIG_CK_OUT_EN); + + /* Wait for CK_OUT_EN set */ + retry = 1000; + do { + val = readl(®s->sdcc_hc_dll_config); + val &= SDCC_DLL_CONFIG_CK_OUT_EN; + if (val) + break; + mdelay(1); + retry--; + } while (retry > 0); + if (!retry) + dev_err(dev, "Set CK_OUT_EN timedout\n"); + + /* Set DDR_CAL_EN */ + setbits_le32(®s->sdcc_hc_dll_config2, SDCC_DLL_CONFIG2_DDR_CAL_EN); + + clrbits_le32(®s->sdcc_hc_dll_config2, + SDCC_DLL_CONFIG2_DLL_CLOCK_DIS); + + clrsetbits_le32(®s->sdcc_hc_dll_config2, + SDCC_DLL_CONFIG2_MCLK_FREQ_CALC, 0x1A << 10); + + clrsetbits_le32(®s->sdcc_hc_dll_config2, + SDCC_DLL_CONFIG2_DDR_TRAFFIC_INIT_SEL, BIT(2)); + + setbits_le32(®s->sdcc_hc_dll_config2, + SDCC_DLL_CONFIG2_DDR_TRAFFIC_INIT_SW); + + return 0; +} + +static int ethqos_rgmii_macro_init(struct udevice *dev, + struct dwmac_rgmii_regs *regs, + unsigned long speed) +{ + /* Disable loopback mode */ + clrbits_le32(®s->io_macro_config2, + RGMII_CONFIG2_TX_TO_RX_LOOPBACK_EN); + + /* Select RGMII, write 0 to interface select */ + clrbits_le32(®s->io_macro_config, RGMII_CONFIG_INTF_SEL); + + switch (speed) { + case SPEED_1000: + setbits_le32(®s->io_macro_config, RGMII_CONFIG_DDR_MODE); + clrbits_le32(®s->io_macro_config, + RGMII_CONFIG_BYPASS_TX_ID_EN); + setbits_le32(®s->io_macro_config, + RGMII_CONFIG_POS_NEG_DATA_SEL); + setbits_le32(®s->io_macro_config, RGMII_CONFIG_PROG_SWAP); + + clrbits_le32(®s->io_macro_config2, + RGMII_CONFIG2_DATA_DIVIDE_CLK_SEL); + setbits_le32(®s->io_macro_config2, + RGMII_CONFIG2_TX_CLK_PHASE_SHIFT_EN); + clrbits_le32(®s->io_macro_config2, + RGMII_CONFIG2_RSVD_CONFIG15); + setbits_le32(®s->io_macro_config2, + RGMII_CONFIG2_RX_PROG_SWAP); + + /* Set PRG_RCLK_DLY to 57 for 1.8 ns delay */ + clrsetbits_le32(®s->sdcc_hc_ddr_config, + SDCC_DDR_CONFIG_PRG_RCLK_DLY, 57); + setbits_le32(®s->sdcc_hc_ddr_config, SDCC_DDR_CONFIG_PRG_DLY_EN); + + setbits_le32(®s->io_macro_config, RGMII_CONFIG_LOOPBACK_EN); + break; + + case SPEED_100: + setbits_le32(®s->io_macro_config, RGMII_CONFIG_DDR_MODE); + setbits_le32(®s->io_macro_config, + RGMII_CONFIG_BYPASS_TX_ID_EN); + clrbits_le32(®s->io_macro_config, + RGMII_CONFIG_POS_NEG_DATA_SEL); + clrbits_le32(®s->io_macro_config, RGMII_CONFIG_PROG_SWAP); + clrsetbits_le32(®s->io_macro_config, + RGMII_CONFIG_MAX_SPD_PRG_2, BIT(6)); + + clrbits_le32(®s->io_macro_config2, + RGMII_CONFIG2_DATA_DIVIDE_CLK_SEL); + setbits_le32(®s->io_macro_config2, + RGMII_CONFIG2_TX_CLK_PHASE_SHIFT_EN); + clrbits_le32(®s->io_macro_config2, + RGMII_CONFIG2_RSVD_CONFIG15); + clrbits_le32(®s->io_macro_config2, + RGMII_CONFIG2_RX_PROG_SWAP); + + /* Write 0x5 to PRG_RCLK_DLY_CODE */ + clrsetbits_le32(®s->sdcc_hc_ddr_config, + SDCC_DDR_CONFIG_EXT_PRG_RCLK_DLY_CODE, + (BIT(29) | BIT(27))); + setbits_le32(®s->sdcc_hc_ddr_config, + SDCC_DDR_CONFIG_EXT_PRG_RCLK_DLY); + setbits_le32(®s->sdcc_hc_ddr_config, + SDCC_DDR_CONFIG_EXT_PRG_RCLK_DLY_EN); + + setbits_le32(®s->io_macro_config, RGMII_CONFIG_LOOPBACK_EN); + break; + + case SPEED_10: + setbits_le32(®s->io_macro_config, RGMII_CONFIG_DDR_MODE); + setbits_le32(®s->io_macro_config, + RGMII_CONFIG_BYPASS_TX_ID_EN); + clrbits_le32(®s->io_macro_config, + RGMII_CONFIG_POS_NEG_DATA_SEL); + clrbits_le32(®s->io_macro_config, RGMII_CONFIG_PROG_SWAP); + clrsetbits_le32(®s->io_macro_config, + RGMII_CONFIG_MAX_SPD_PRG_9, + BIT(12) | GENMASK(9, 8)); + + clrbits_le32(®s->io_macro_config2, + RGMII_CONFIG2_DATA_DIVIDE_CLK_SEL); + clrbits_le32(®s->io_macro_config2, + RGMII_CONFIG2_TX_CLK_PHASE_SHIFT_EN); + clrbits_le32(®s->io_macro_config2, + RGMII_CONFIG2_RSVD_CONFIG15); + clrbits_le32(®s->io_macro_config2, + RGMII_CONFIG2_RX_PROG_SWAP); + + /* Write 0x5 to PRG_RCLK_DLY_CODE */ + clrsetbits_le32(®s->sdcc_hc_ddr_config, + SDCC_DDR_CONFIG_EXT_PRG_RCLK_DLY_CODE, + (BIT(29) | BIT(27))); + setbits_le32(®s->sdcc_hc_ddr_config, + SDCC_DDR_CONFIG_EXT_PRG_RCLK_DLY); + setbits_le32(®s->sdcc_hc_ddr_config, + SDCC_DDR_CONFIG_EXT_PRG_RCLK_DLY_EN); + + setbits_le32(®s->io_macro_config, RGMII_CONFIG_LOOPBACK_EN); + break; + + default: + dev_err(dev, "Invalid speed %ld\n", speed); + return -EINVAL; + } + + return 0; +} + +static int ethqos_configure(struct udevice *dev, + struct dwmac_rgmii_regs *regs, + unsigned long speed) +{ + unsigned int retry = 1000; + + /* Reset to POR values and enable clk */ + writel(emac_v2_3_0_por.io_macro_config, ®s->io_macro_config); + writel(emac_v2_3_0_por.sdcc_hc_dll_config, ®s->sdcc_hc_dll_config); + writel(emac_v2_3_0_por.sdcc_hc_ddr_config, ®s->sdcc_hc_ddr_config); + writel(emac_v2_3_0_por.sdcc_hc_dll_config2, ®s->sdcc_hc_dll_config2); + writel(emac_v2_3_0_por.sdcc_usr_ctl, ®s->sdcc_usr_ctl); + writel(emac_v2_3_0_por.io_macro_config2, ®s->io_macro_config2); + + ethqos_set_func_clk_en(regs); + + /* Initialize the DLL first */ + + /* Set DLL_RST */ + setbits_le32(®s->sdcc_hc_dll_config, SDCC_DLL_CONFIG_DLL_RST); + + /* Set PDN */ + setbits_le32(®s->sdcc_hc_dll_config, SDCC_DLL_CONFIG_PDN); + + /* Clear DLL_RST */ + clrbits_le32(®s->sdcc_hc_dll_config, SDCC_DLL_CONFIG_DLL_RST); + + /* Clear PDN */ + clrbits_le32(®s->sdcc_hc_dll_config, SDCC_DLL_CONFIG_PDN); + + if (speed == SPEED_1000) { + /* Set DLL_EN */ + setbits_le32(®s->sdcc_hc_dll_config, SDCC_DLL_CONFIG_DLL_EN); + + /* Set CK_OUT_EN */ + setbits_le32(®s->sdcc_hc_dll_config, + SDCC_DLL_CONFIG_CK_OUT_EN); + + /* Set USR_CTL bit 26 with mask of 3 bits */ + clrsetbits_le32(®s->sdcc_usr_ctl, GENMASK(26, 24), BIT(26)); + + /* wait for DLL LOCK */ + do { + mdelay(1); + if (readl(®s->sdc4_status) & SDC4_STATUS_DLL_LOCK) + break; + retry--; + } while (retry > 0); + if (!retry) + dev_err(dev, "Timeout while waiting for DLL lock\n"); + + ethqos_dll_configure(dev, regs); + } + + ethqos_rgmii_macro_init(dev, regs, speed); + + return 0; +} + +static void ethqos_rgmii_dump(struct udevice *dev, + struct dwmac_rgmii_regs *regs) +{ + dev_dbg(dev, "Rgmii register dump\n"); + dev_dbg(dev, "RGMII_IO_MACRO_CONFIG: %08x\n", + readl(®s->io_macro_config)); + dev_dbg(dev, "SDCC_HC_REG_DLL_CONFIG: %08x\n", + readl(®s->sdcc_hc_dll_config)); + dev_dbg(dev, "SDCC_HC_REG_DDR_CONFIG: %08x\n", + readl(®s->sdcc_hc_ddr_config)); + dev_dbg(dev, "SDCC_HC_REG_DLL_CONFIG2: %08x\n", + readl(®s->sdcc_hc_dll_config2)); + dev_dbg(dev, "SDC4_STATUS: %08x\n", + readl(®s->sdc4_status)); + dev_dbg(dev, "SDCC_USR_CTL: %08x\n", + readl(®s->sdcc_usr_ctl)); + dev_dbg(dev, "RGMII_IO_MACRO_CONFIG2: %08x\n", + readl(®s->io_macro_config2)); + dev_dbg(dev, "RGMII_IO_MACRO_DEBUG1: %08x\n", + readl(®s->io_macro_debug1)); + dev_dbg(dev, "EMAC_SYSTEM_LOW_POWER_DEBUG: %08x\n", + readl(®s->emac_sys_low_power_dbg)); +} + +static int qcom_eqos_rgmii_set_speed(struct udevice *dev, + void *rgmii_regs, + unsigned long speed) +{ + int ret; + + ethqos_rgmii_dump(dev, rgmii_regs); + + ret = ethqos_configure(dev, rgmii_regs, speed); + if (ret) + return ret; + + ethqos_rgmii_dump(dev, rgmii_regs); + + return 0; +} + +static int qcom_eqos_rgmii_reset(struct udevice *dev, void *rgmii_regs) +{ + ethqos_set_func_clk_en(rgmii_regs); + + return 0; +} + +static int eqos_start_clks_qcom(struct udevice *dev) +{ + if (IS_ENABLED(CONFIG_CLK)) { + struct clk_bulk clocks; + int ret; + + ret = clk_get_bulk(dev, &clocks); + if (ret) + return ret; + + ret = clk_enable_bulk(&clocks); + if (ret) + return ret; + } + + debug("%s: OK\n", __func__); + return 0; +} + +static int eqos_stop_clks_qcom(struct udevice *dev) +{ + if (IS_ENABLED(CONFIG_CLK)) { + struct clk_bulk clocks; + int ret; + + ret = clk_get_bulk(dev, &clocks); + if (ret) + return ret; + + ret = clk_disable_bulk(&clocks); + if (ret) + return ret; + } + + debug("%s: OK\n", __func__); + return 0; +} + +static int eqos_start_resets_qcom(struct udevice *dev) +{ + struct eqos_priv *eqos = dev_get_priv(dev); + int ret; + + debug("%s(dev=%p):\n", __func__, dev); + + if (!eqos->phy) { + ret = dm_gpio_set_value(&eqos->phy_reset_gpio, 0); + if (ret < 0) { + pr_err("dm_gpio_set_value(phy_reset, assert) failed: %d", ret); + return ret; + } + + udelay(eqos->reset_delays[0]); + + ret = dm_gpio_set_value(&eqos->phy_reset_gpio, 1); + if (ret < 0) { + pr_err("dm_gpio_set_value(phy_reset, deassert) failed: %d", ret); + return ret; + } + + udelay(eqos->reset_delays[1]); + + ret = dm_gpio_set_value(&eqos->phy_reset_gpio, 0); + if (ret < 0) { + pr_err("dm_gpio_set_value(phy_reset, deassert) failed: %d", ret); + return ret; + } + + udelay(eqos->reset_delays[2]); + } + + ret = reset_deassert(&eqos->reset_ctl); + if (ret < 0) { + pr_err("reset_deassert() failed: %d", ret); + return ret; + } + + ret = qcom_eqos_rgmii_reset(dev, eqos->eqos_qcom_rgmii_regs); + if (ret < 0) { + pr_err("qcom rgmii_reset failed: %d", ret); + return ret; + } + + debug("%s: OK\n", __func__); + return 0; +} + +/* Clock rates */ +#define RGMII_1000_NOM_CLK_FREQ (250 * 1000 * 1000UL) +#define RGMII_ID_MODE_100_LOW_SVS_CLK_FREQ (50 * 1000 * 1000UL) +#define RGMII_ID_MODE_10_LOW_SVS_CLK_FREQ (5 * 1000 * 1000UL) + +static int eqos_set_tx_clk_speed_qcom(struct udevice *dev) +{ + struct eqos_priv *eqos = dev_get_priv(dev); + ulong rate; + int ret; + + debug("%s(dev=%p):\n", __func__, dev); + + switch (eqos->phy->speed) { + case SPEED_1000: + rate = RGMII_1000_NOM_CLK_FREQ; + break; + case SPEED_100: + rate = RGMII_ID_MODE_100_LOW_SVS_CLK_FREQ; + break; + case SPEED_10: + rate = RGMII_ID_MODE_10_LOW_SVS_CLK_FREQ; + break; + default: + pr_err("invalid speed %d", eqos->phy->speed); + return -EINVAL; + } + + ret = clk_set_rate(&eqos->clk_tx, rate); + if (ret < 0) { + pr_err("clk_set_rate(tx_clk, %lu) failed: %d", rate, ret); + return ret; + } + + ret = qcom_eqos_rgmii_set_speed(dev, eqos->eqos_qcom_rgmii_regs, + eqos->phy->speed); + if (ret < 0) { + pr_err("qcom set_speed: %d, failed: %d", eqos->phy->speed, ret); + return ret; + } + + return 0; +} + +static int eqos_probe_resources_qcom(struct udevice *dev) +{ + struct eqos_priv *eqos = dev_get_priv(dev); + phy_interface_t interface; + int reset_flags = GPIOD_IS_OUT; + int ret; + + debug("%s(dev=%p):\n", __func__, dev); + + interface = eqos->config->interface(dev); + + if (interface == PHY_INTERFACE_MODE_NA) { + pr_err("Invalid PHY interface\n"); + return -EINVAL; + } + + eqos->max_speed = dev_read_u32_default(dev, "max-speed", 0); + + eqos->tx_fifo_sz = dev_read_u32_default(dev, "tx-fifo-depth", 0); + eqos->rx_fifo_sz = dev_read_u32_default(dev, "rx-fifo-depth", 0); + + ret = reset_get_by_name(dev, "emac", &eqos->reset_ctl); + if (ret) { + pr_err("reset_get_by_name(rst) failed: %d", ret); + return ret; + } + + if (dev_read_bool(dev, "snps,reset-active-low")) + reset_flags |= GPIOD_ACTIVE_LOW; + + ret = gpio_request_by_name(dev, "snps,reset-gpio", 0, + &eqos->phy_reset_gpio, reset_flags); + if (ret == 0) { + ret = dev_read_u32_array(dev, "snps,reset-delays-us", + eqos->reset_delays, 3); + } else if (ret == -ENOENT) { + ret = 0; + } + + eqos->eqos_qcom_rgmii_regs = (void *)dev_read_addr_name(dev, "rgmii"); + if ((fdt_addr_t)eqos->eqos_qcom_rgmii_regs == FDT_ADDR_T_NONE) { + pr_err("Invalid RGMII address\n"); + return -EINVAL; + } + + ret = clk_get_by_name(dev, "rgmii", &eqos->clk_tx); + if (ret) { + pr_err("clk_get_by_name(tx) failed: %d", ret); + return -EINVAL; + } + + debug("%s: OK\n", __func__); + return 0; +} + +static int eqos_remove_resources_qcom(struct udevice *dev) +{ + struct eqos_priv *eqos = dev_get_priv(dev); + + debug("%s(dev=%p):\n", __func__, dev); + + clk_free(&eqos->clk_tx); + dm_gpio_free(dev, &eqos->phy_reset_gpio); + reset_free(&eqos->reset_ctl); + + debug("%s: OK\n", __func__); + return 0; +} + +static struct eqos_ops eqos_qcom_ops = { + .eqos_inval_desc = eqos_inval_desc_generic, + .eqos_flush_desc = eqos_flush_desc_generic, + .eqos_inval_buffer = eqos_inval_buffer_generic, + .eqos_flush_buffer = eqos_flush_buffer_generic, + .eqos_probe_resources = eqos_probe_resources_qcom, + .eqos_remove_resources = eqos_remove_resources_qcom, + .eqos_stop_resets = eqos_null_ops, + .eqos_start_resets = eqos_start_resets_qcom, + .eqos_stop_clks = eqos_stop_clks_qcom, + .eqos_start_clks = eqos_start_clks_qcom, + .eqos_calibrate_pads = eqos_null_ops, + .eqos_disable_calibration = eqos_null_ops, + .eqos_set_tx_clk_speed = eqos_set_tx_clk_speed_qcom, + .eqos_get_enetaddr = eqos_null_ops, +}; + +struct eqos_config __maybe_unused eqos_qcom_config = { + .reg_access_always_ok = false, + .mdio_wait = 10, + .swr_wait = 50, + .config_mac = EQOS_MAC_RXQ_CTRL0_RXQ0EN_ENABLED_DCB, + .config_mac_mdio = EQOS_MAC_MDIO_ADDRESS_CR_250_300, + .axi_bus_width = EQOS_AXI_WIDTH_64, + .interface = dev_read_phy_mode, + .ops = &eqos_qcom_ops +}; From patchwork Fri Jan 20 07:17:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 644613 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp638226pvb; Thu, 19 Jan 2023 23:19:49 -0800 (PST) X-Google-Smtp-Source: AMrXdXsXwsoRvjarNtID5qYFBqkFTmAgEattPjgNuM8vo6FD5LbGu8oiVz6jdJltfqhgDnr06RLP X-Received: by 2002:a05:6870:c20b:b0:15f:2172:19b1 with SMTP id z11-20020a056870c20b00b0015f217219b1mr8104917oae.31.1674199188921; Thu, 19 Jan 2023 23:19:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674199188; cv=none; d=google.com; s=arc-20160816; b=fWEwzQZymCHHeX2/ffXMre2ovEDZZGpvmy5Y+fJuJhYCTdTdyGpUiFczz9Aqh8vZVC iu5ZWtqeOKwK/earo8XdmCc1qS9Y3Q9mZ+opfaZ2C+lo44oLWPlyixBokFwQsZnUaqnZ zAxgin6Ba/76fx/9kgYo1M2ZROXSvuXYUAKm16oPkewTfUkXBT+dWeV02kEpa35fYMfX HVZ3cUwx9FfYDhNsS7y1JIi3LZ+gkbYCfPno0Jcnn/pf1DOcHP7wjOhmC09io7tyeBwM cq4Z4zfB9MtKdIncdZKMYuVZ+sfFFER5EXtwBaZ9VdUWceUdVG7HHfG7NMaZ2LfUZZCF ml0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yfvp1gUUP//SmMVEed5zgIAdTdTyK6Ynwsoz/X58s40=; b=hbLsmUs5eRBP4XdiHZ+Z1ddRDMkbdpsD9IxGP+nTJ+L6+kisMZJy5UHwiMrC5epTW7 1a7n4zCQu6/uhYOwItEdiQ3ThxDRgXvyiFGRJN23Yg4oiPZzMYb5l08ToxvzTSeOI4rm DsVJOHlPGWDhuck7z7T/SlAPDbs0PViHkUgGqcsK+t6IhSUtMeiMZVsNY3Tb8NwZ7ORb S6+StxwSF6fmBiG4h4KtBUDvYcppBWSfQlHrnlXYu92jGBYdaSwRi6l6lii+W4Kx9Mfa jGx26I38WP6mfDnCC2oGppG2bd2AeVLmNoA2Mx+1B+7lB2M9Go05GhNJS7HfxBUCF6vI zc4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="DIXfo/4r"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id s5-20020a056808008500b0036eaf82ae8asi2862782oic.246.2023.01.19.23.19.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 23:19:48 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="DIXfo/4r"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 29EDA856CA; Fri, 20 Jan 2023 08:18:31 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="DIXfo/4r"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3F780856B4; Fri, 20 Jan 2023 08:18:21 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9DF5C856BD for ; Fri, 20 Jan 2023 08:18:15 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sumit.garg@linaro.org Received: by mail-pf1-x42f.google.com with SMTP id c26so3312649pfp.10 for ; Thu, 19 Jan 2023 23:18:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=yfvp1gUUP//SmMVEed5zgIAdTdTyK6Ynwsoz/X58s40=; b=DIXfo/4rB11kWGsyvpXJtAhsiN/W3nHwUbXW86tLLG2Cx/pCnDELFxPCt2JwpKRW6u P9oHsLMAA/w41xfVZnMUuf/lPDRqOEM7SHrxmL4PqsRCaD02dI7q+k2FUkd4qg0mtXic xDpZBVcBqrkemhq3KXPRjIMyyGmjcHjgNle3JxeG07ZKbRsc1E9T2Ma92eQrGJbNwD0s 74J4gPjmaStkcQQvVT0Od8RPCu5wTpz4wneqVGRZY/5kP8XnT85Vr8bBC+WAWBarxigj DeYeq6d0QkBHuhMsC+PK/vkR1FNG5tKzhKqbLSnA/zMjFzngI77GOEe5CBVCItcLCTUU FnEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=yfvp1gUUP//SmMVEed5zgIAdTdTyK6Ynwsoz/X58s40=; b=pw+jfFPQcX2qGCR87OVTbL8EVLaXmyiPIYABzrjxDH11JIfNyB/R18I6QPsQ8dKNja waO1AXfG8frh3VltbkP/iFQZ4hRofu4wHBTPGAWniEpyl8Kqw6dIa94lNZO7SacE3a40 +oDgY/Uaa10YuizC3HU0snDM819hfyhhujAeFI8Jt5iszsT3KtXf//6tyayQvjufCh0q 7YHbF+H8gTKQQ6lUsDyUkNaq2Jka4ghwjaFbzbbfkRWNKWX3vILWeCMwZYMU/DuDRVmk BdeAPGSvdu3zZUmjVUKNrLiRteo8tpozpCYQStICU5DFzriqvGyI4nQw2oNuZs03GYDs 90tg== X-Gm-Message-State: AFqh2kq+NG9848/VFUwIDtraOqUzahpyhtNENdIXJKwI/aME0Vc1lhzs 2SeujtQs1rpP3D1N/6JbHc5ojIct0OEnEUio X-Received: by 2002:a05:6a00:278d:b0:56b:f51d:820a with SMTP id bd13-20020a056a00278d00b0056bf51d820amr14054973pfb.7.1674199093798; Thu, 19 Jan 2023 23:18:13 -0800 (PST) Received: from sumit-X1.. ([223.178.212.120]) by smtp.gmail.com with ESMTPSA id x15-20020aa7956f000000b0058bacd6c4e8sm9797586pfq.207.2023.01.19.23.18.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 23:18:13 -0800 (PST) From: Sumit Garg To: u-boot@lists.denx.de Cc: rfried.dev@gmail.com, hs@denx.de, joe.hershberger@ni.com, stephan@gerhold.net, mworsfold@impinj.com, lgillham@impinj.com, jbrennan@impinj.com, nicolas.dechesne@linaro.org, vinod.koul@linaro.org, daniel.thompson@linaro.org, Sumit Garg Subject: [PATCH 09/14] dts: qcs404-evb: Add ethernet controller node Date: Fri, 20 Jan 2023 12:47:14 +0530 Message-Id: <20230120071719.623661-10-sumit.garg@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230120071719.623661-1-sumit.garg@linaro.org> References: <20230120071719.623661-1-sumit.garg@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Signed-off-by: Sumit Garg --- arch/arm/dts/qcs404-evb.dts | 98 ++++++++++++++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 1 deletion(-) diff --git a/arch/arm/dts/qcs404-evb.dts b/arch/arm/dts/qcs404-evb.dts index cc70afa4c8..2de0e7537b 100644 --- a/arch/arm/dts/qcs404-evb.dts +++ b/arch/arm/dts/qcs404-evb.dts @@ -36,7 +36,7 @@ ranges = <0x0 0x0 0x0 0xffffffff>; compatible = "simple-bus"; - pinctrl_north@1300000 { + soc_gpios: pinctrl_north@1300000 { compatible = "qcom,qcs404-pinctrl"; reg = <0x1300000 0x200000>; gpio-controller; @@ -48,6 +48,61 @@ pins = "GPIO_17", "GPIO_18"; function = "blsp_uart2"; }; + + ethernet_defaults: ethernet-defaults { + int { + pins = "GPIO_61"; + function = "rgmii_int"; + bias-disable; + drive-strength = <2>; + }; + mdc { + pins = "GPIO_76"; + function = "rgmii_mdc"; + bias-pull-up; + }; + mdio { + pins = "GPIO_75"; + function = "rgmii_mdio"; + bias-pull-up; + }; + tx { + pins = "GPIO_67", "GPIO_66", "GPIO_65", "GPIO_64"; + function = "rgmii_tx"; + bias-pull-up; + drive-strength = <16>; + }; + rx { + pins = "GPIO_73", "GPIO_72", "GPIO_71", "GPIO_70"; + function = "rgmii_rx"; + bias-disable; + drive-strength = <2>; + }; + tx-ctl { + pins = "GPIO_68"; + function = "rgmii_ctl"; + bias-pull-up; + drive-strength = <16>; + }; + rx-ctl { + pins = "GPIO_74"; + function = "rgmii_ctl"; + bias-disable; + drive-strength = <2>; + }; + tx-ck { + pins = "GPIO_63"; + function = "rgmii_ck"; + bias-pull-up; + drive-strength = <16>; + }; + rx-ck { + pins = "GPIO_69"; + function = "rgmii_ck"; + bias-disable; + drive-strength = <2>; + }; + }; }; gcc: clock-controller@1800000 { @@ -172,6 +227,47 @@ }; }; + ethernet: ethernet@7a80000 { + compatible = "qcom,qcs404-ethqos"; + reg = <0x07a80000 0x10000>, + <0x07a96000 0x100>; + reg-names = "stmmaceth", "rgmii"; + clock-names = "stmmaceth", "pclk", "ptp_ref", "rgmii"; + clocks = <&gcc GCC_ETH_AXI_CLK>, + <&gcc GCC_ETH_SLAVE_AHB_CLK>, + <&gcc GCC_ETH_PTP_CLK>, + <&gcc GCC_ETH_RGMII_CLK>; + + resets = <&reset GCC_EMAC_BCR>; + reset-names = "emac"; + + snps,tso; + rx-fifo-depth = <4096>; + tx-fifo-depth = <4096>; + + snps,reset-gpio = <&soc_gpios 60 GPIO_ACTIVE_LOW>; + snps,reset-active-low; + snps,reset-delays-us = <0 10000 10000>; + + pinctrl-names = "default"; + pinctrl-0 = <ðernet_defaults>; + + phy-handle = <&phy1>; + phy-mode = "rgmii"; + max-speed = <1000>; + + mdio { + #address-cells = <0x1>; + #size-cells = <0x0>; + compatible = "snps,dwmac-mdio"; + phy1: phy@3 { + compatible = "ethernet-phy-ieee802.3-c22"; + device_type = "ethernet-phy"; + reg = <0x3>; + }; + }; + }; + spmi@200f000 { compatible = "qcom,spmi-pmic-arb"; reg = <0x200f000 0x1000 From patchwork Fri Jan 20 07:17:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 644614 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp638293pvb; Thu, 19 Jan 2023 23:20:01 -0800 (PST) X-Google-Smtp-Source: AMrXdXv7H9RIp3F69oqiJhhRuzwMNY8lb8Oo7LIxvosKsRqbN7BUw+re0H7DuZhodgYDI70nUlEv X-Received: by 2002:a05:6830:3747:b0:686:5e82:14b2 with SMTP id bm7-20020a056830374700b006865e8214b2mr4391994otb.10.1674199201416; Thu, 19 Jan 2023 23:20:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674199201; cv=none; d=google.com; s=arc-20160816; b=oFZ+4rS/r4JYarSUHhEB9MG4mjEcoGeWdCMwhSHGNJLcA6Qv9PeCty/YFfJK631LEo LjJMMUywO57N7l50i/Kjj1+Rf93gX02ocFidJGA+agu4fi3iurOzCeVkNkYMat3D/xOz FkpP37zetbXQY8Cfst0fNlSKJXQu8P86wATejXDbwZ3WFGAffzKfH9Gmvhr1RfAv5QNT npmHkID3FzpmfY/xY6X0pWTEoWiM0JOTDTohGOD2cbeQvVyQAZa6ZU2QU7h34MzWMF2t ShR1BzWI0p67wo7JbwbhtOiuXyaOpfDSMemwCoA0S016mrfp3/WQc25dXTVPM716V7KG Tx1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=H7l5e1Mk6NBap2n4RtHZEWgpKHTeaD3uETXTC3h5PBs=; b=Fyk4F7EbTDDBRWPZ2l8XtbdXIrpr/lSfwHtajewUWoizdww2QzUTyUz9jFmsjJInSi qVWHTAJY0ewsQluAE1V/4Um0pyRtTbF9pAIN9zDonYmnhChhh/s4HgM0Ii5hhdqyOgAx y48ECVMam4o9uefesQC7PUnF3nAg/ydYfF6OoqHAQ/4lH3aOGtINsQUGZ+FpZSunHikQ xPKOuluoxnrpUIh/H54bSomrwM0QFPfWxVytIzA+lMysE130hn5I6Gsr/CBUryaH49O9 6ON2A3cZSXKmXX8IrrWQcRKjkvq8HnmJOWtMwhDyWAA/HuMoAMPLNdmAdORUamVhqP9R I0vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c87J+4Fc; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id u18-20020a056808115200b0036ec8da8319si73079oiu.279.2023.01.19.23.20.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 23:20:01 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c87J+4Fc; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DA4A9856DD; Fri, 20 Jan 2023 08:18:34 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="c87J+4Fc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3FE88856A2; Fri, 20 Jan 2023 08:18:24 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3B2B8856A1 for ; Fri, 20 Jan 2023 08:18:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sumit.garg@linaro.org Received: by mail-pj1-x1033.google.com with SMTP id u1-20020a17090a450100b0022936a63a21so8211434pjg.4 for ; Thu, 19 Jan 2023 23:18:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=H7l5e1Mk6NBap2n4RtHZEWgpKHTeaD3uETXTC3h5PBs=; b=c87J+4Fc1tWd1MC5zRL2ze+j6gWHq5v2vMuNactVJUX8taLdTu/ByJyo8G64xIHj4B IJ2215ymKgjoHsukgLmiB2a3rWg+2MmycrSvfs//OdJvc58cNQ0hePDgNnPzc6UD4+sb KN2Hb+wrGtJ93J10RKTMO56uV/lPOAUW/186xk27WcRSDTn+1o1n5cpFrn4Vv++6+YsU pBYgOvO6T9/3LsexSFLpWoQ/gtB+QZpLmeAPCftdItk+jJz1jdAbol8CfH/G7XpolGsI VrcpVHlcJUI6dUncCvxWC2/ujwQA/wf00IWXMRoC1LuPJkeNz/gKM07LS31qhKYsGzi7 //lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=H7l5e1Mk6NBap2n4RtHZEWgpKHTeaD3uETXTC3h5PBs=; b=L0WWtm8dBDKawM9PFVjHyuxmFyZ8DBxYt9NknedmmOo1pPgn5GlBJrHRikby6MGrYN aowoyfS4/yDieG+Wm0Jr1FzcMqFZXS6meYRd1lElaHM7Au+eCZQO+ij2K6u15zpvF6aL hOP4xvdYEzJygKGAx2T0qetqBNcphVTe7vlHObye2OesM4fG4MjNSvcrnwrc1409wtMx 7pTxiVWpvY/dEM+BUfpHfyQyw1iDAL5/bprpn3CY2VhjGYjtxQO8Rc4E4yl79ZK7B0Tt DbLP8Zdp8AYj+joTSKF81zjkLWzahT1a3PXDQbhmxTEiZSi6tMPeao+YUy3Gj45eFTyK L35A== X-Gm-Message-State: AFqh2kp08ZzXflcG1BcKR9jB8ss6lX1suyUweT26LPWV/G/bGESNS2og PFQ9YmDlC/nk3gjf459a6qAY4bURh3rTT47d X-Received: by 2002:a05:6a20:6d02:b0:b6:9f9f:4b90 with SMTP id fv2-20020a056a206d0200b000b69f9f4b90mr29829923pzb.24.1674199098125; Thu, 19 Jan 2023 23:18:18 -0800 (PST) Received: from sumit-X1.. ([223.178.212.120]) by smtp.gmail.com with ESMTPSA id x15-20020aa7956f000000b0058bacd6c4e8sm9797586pfq.207.2023.01.19.23.18.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 23:18:17 -0800 (PST) From: Sumit Garg To: u-boot@lists.denx.de Cc: rfried.dev@gmail.com, hs@denx.de, joe.hershberger@ni.com, stephan@gerhold.net, mworsfold@impinj.com, lgillham@impinj.com, jbrennan@impinj.com, nicolas.dechesne@linaro.org, vinod.koul@linaro.org, daniel.thompson@linaro.org, Sumit Garg Subject: [PATCH 10/14] clock-snapdragon: Add clk_rcg_set_rate() with mnd_width=0 Date: Fri, 20 Jan 2023 12:47:15 +0530 Message-Id: <20230120071719.623661-11-sumit.garg@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230120071719.623661-1-sumit.garg@linaro.org> References: <20230120071719.623661-1-sumit.garg@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Add clk_rcg_set_rate() which allows to configure clocks without programming MND values. This is required for configuring I2C clocks on QCS404. Co-developed-by: Mike Worsfold Signed-off-by: Mike Worsfold Signed-off-by: Sumit Garg --- arch/arm/mach-snapdragon/clock-snapdragon.c | 24 +++++++++++++++++++++ arch/arm/mach-snapdragon/clock-snapdragon.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/arch/arm/mach-snapdragon/clock-snapdragon.c b/arch/arm/mach-snapdragon/clock-snapdragon.c index fda7098274..0ac45dce9a 100644 --- a/arch/arm/mach-snapdragon/clock-snapdragon.c +++ b/arch/arm/mach-snapdragon/clock-snapdragon.c @@ -111,6 +111,30 @@ void clk_rcg_set_rate_mnd(phys_addr_t base, const struct bcr_regs *regs, clk_bcr_update(base + regs->cmd_rcgr); } +/* root set rate for clocks with half integer and mnd_width=0 */ +void clk_rcg_set_rate(phys_addr_t base, const struct bcr_regs *regs, int div, + int source) +{ + u32 cfg; + + /* setup src select and divider */ + cfg = readl(base + regs->cfg_rcgr); + cfg &= ~CFG_MASK; + cfg |= source & CFG_CLK_SRC_MASK; /* Select clock source */ + + /* + * Set the divider; HW permits fraction dividers (+0.5), but + * for simplicity, we will support integers only + */ + if (div) + cfg |= (2 * div - 1) & CFG_DIVIDER_MASK; + + writel(cfg, base + regs->cfg_rcgr); /* Write new clock configuration */ + + /* Inform h/w to start using the new config. */ + clk_bcr_update(base + regs->cmd_rcgr); +} + static int msm_clk_probe(struct udevice *dev) { struct msm_clk_priv *priv = dev_get_priv(dev); diff --git a/arch/arm/mach-snapdragon/clock-snapdragon.h b/arch/arm/mach-snapdragon/clock-snapdragon.h index 2ac53b538d..c90bbefa58 100644 --- a/arch/arm/mach-snapdragon/clock-snapdragon.h +++ b/arch/arm/mach-snapdragon/clock-snapdragon.h @@ -42,5 +42,7 @@ void clk_enable_cbc(phys_addr_t cbcr); void clk_enable_vote_clk(phys_addr_t base, const struct vote_clk *vclk); void clk_rcg_set_rate_mnd(phys_addr_t base, const struct bcr_regs *regs, int div, int m, int n, int source); +void clk_rcg_set_rate(phys_addr_t base, const struct bcr_regs *regs, int div, + int source); #endif From patchwork Fri Jan 20 07:17:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 644615 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp638372pvb; Thu, 19 Jan 2023 23:20:15 -0800 (PST) X-Google-Smtp-Source: AMrXdXsmDiTJceiikbdC4b67IFEygYJ9S+9fYIDuFWOTVWdouQWOjLm4TPpUM5Ys+RfILW5taKrd X-Received: by 2002:a05:6830:26d9:b0:684:cd04:6684 with SMTP id m25-20020a05683026d900b00684cd046684mr6234327otu.14.1674199215455; Thu, 19 Jan 2023 23:20:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674199215; cv=none; d=google.com; s=arc-20160816; b=PhIyIPNU36wrIrSa4rBxv9BAWh8cwnuNhvbHh2AI9WTGjoGZDcok2Yp8lrYQj6vo2z STwh4mICu0u2zSkeRf3OMiDvFHauZNlSKamqyhBKgbyESVLYytUwu1TGFyK/cYxhsVfx mD6RdF2H8J3/i9logKlA0ZsIgpgMdP6kp8RD6YvfgbXPT0dy3msL5/B6GwOzehCTfjMN rmXeKv3ib+dPE2kthEX375Nzm7YYLL8n5iGwgCWG0KV5eYnVpvh5bqdidXXlGHxm6g5D mzYiBACwDgyqrNMK574emAtyb02gNjeeqrHquOhVOG6JpkX4V9kbZhwUsJgFIeG7OMpd 3Big== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PfPCoj3SXxX8BeKajevQ8cFnAmbQjLo3kGosLmqaGTo=; b=s6055+pKh6rUFEWMupyUgk+EXowe9Km8yHMqEa8CmSChmuNQMnL6h4Usu0pp/9YUJ4 Ws4xE1ZAiF4GVFkJ5lkFwItZZo60U9rz3LbyjXqf6p7P21PS0WVKf1saTiTka6RsiqSW 7B9MHTRzIDY5ie0RM2AC9phpMjMWbymacLMwcFhHOEx8FYL3XYdxYFDh+p/V+OkeHb0J ih/uHb1B/KXM5aLIvmyh0WigXf+61ZdrJwpDvaK4Z2qpiVycUWK3+63cZBUsUih0sl0A MhytLuYDMWuNu9HIVgreZ+ZFptHLx4AEajCRhHYzs9861ROGfXRkcWVem/wPA33Bulx3 GVbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lmNOaBey; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id s31-20020a0568302a9f00b00686506878ebsi9126674otu.218.2023.01.19.23.20.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 23:20:15 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lmNOaBey; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 467E3856CD; Fri, 20 Jan 2023 08:18:48 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="lmNOaBey"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6B43685657; Fri, 20 Jan 2023 08:18:27 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 398E4856A0 for ; Fri, 20 Jan 2023 08:18:24 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sumit.garg@linaro.org Received: by mail-pf1-x42e.google.com with SMTP id i65so3362759pfc.0 for ; Thu, 19 Jan 2023 23:18:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=PfPCoj3SXxX8BeKajevQ8cFnAmbQjLo3kGosLmqaGTo=; b=lmNOaBeyW9pZ9nUHPUri/tegRJzzROqeeGEz6LtfEQRGH8+dmppgijSRboz96YQQjA v+4VjW7nnF6vQWBUhaMepXa1OJ586b9YRddbWL+urEeyvG+KJ/EFsb0z1BRBUEwaD8B6 IPSLw+VMohlHjJOwB4nU7PQFzIUmt2XPYlGWw7BBOYpCd0D0/VGQxtWmDwkneTiqJTtp FDUKhXZId9lAiAQx3cEyfPZ4e5uF0s9GNiqIMklI65/tm2lMS99RQpQ1M10m/dMqrjzK mYXIHIsh2ZCKtrn3+2CFbpinEmoy8YKgg2vzx/SpzHSyeTkzIW+uV3xmVVc+oMevPBB0 jY4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=PfPCoj3SXxX8BeKajevQ8cFnAmbQjLo3kGosLmqaGTo=; b=asd5JDgd8T4g7UOS0F3JVRr3BJJ0MmwnPBPRELZT2S1CZmvUt+AF2/ZbsrJV+rA0da lMmszlEU3XG2eZ43jRMlh2SZuRVbnb4hxamBTctFijBWwzuw2Fo52OJ86DDIbL3gWy6o d096AyYkH5/3u3PjPdwUSPNe0QDcnlRJiszTHgLIa9wNAZO82x8tINnfppT8tN2UiKX0 6EZJu22QdZvnmQCy1AMDg4baU81NyAqqnAuLCT/5GORMJm5JNLRiHFKfMzX/fWEDEbVl toVTVRfON2ZYPWASUE2YZo9ZrC+ZA84Ouyouk0pwwcM+dc3ijXh6eYfSyDKLlhqsCJ6u qPlQ== X-Gm-Message-State: AFqh2koxVcvH0uU7OsfRNDGppWZu0JRPNGtFrO1kT7ncGyUPX8rUs/KP iiQNpOLbXCiE1tQsuo5IPhipRb9+/O8DrJ/u X-Received: by 2002:aa7:8a45:0:b0:58d:924e:e5de with SMTP id n5-20020aa78a45000000b0058d924ee5demr14266445pfa.11.1674199102434; Thu, 19 Jan 2023 23:18:22 -0800 (PST) Received: from sumit-X1.. ([223.178.212.120]) by smtp.gmail.com with ESMTPSA id x15-20020aa7956f000000b0058bacd6c4e8sm9797586pfq.207.2023.01.19.23.18.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 23:18:22 -0800 (PST) From: Sumit Garg To: u-boot@lists.denx.de Cc: rfried.dev@gmail.com, hs@denx.de, joe.hershberger@ni.com, stephan@gerhold.net, mworsfold@impinj.com, lgillham@impinj.com, jbrennan@impinj.com, nicolas.dechesne@linaro.org, vinod.koul@linaro.org, daniel.thompson@linaro.org, Sumit Garg Subject: [PATCH 11/14] clocks: qcs404: Add support for I2C clocks Date: Fri, 20 Jan 2023 12:47:16 +0530 Message-Id: <20230120071719.623661-12-sumit.garg@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230120071719.623661-1-sumit.garg@linaro.org> References: <20230120071719.623661-1-sumit.garg@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Co-developed-by: Mike Worsfold Signed-off-by: Mike Worsfold Signed-off-by: Sumit Garg --- arch/arm/mach-snapdragon/clock-qcs404.c | 58 +++++++++++++++++++ .../include/mach/sysmap-qcs404.h | 17 ++++++ 2 files changed, 75 insertions(+) diff --git a/arch/arm/mach-snapdragon/clock-qcs404.c b/arch/arm/mach-snapdragon/clock-qcs404.c index b8f5691aae..3357b54c30 100644 --- a/arch/arm/mach-snapdragon/clock-qcs404.c +++ b/arch/arm/mach-snapdragon/clock-qcs404.c @@ -81,6 +81,36 @@ static const struct bcr_regs emac_ptp_regs = { .D = EMAC_D, }; +static const struct bcr_regs blsp1_qup0_i2c_apps_regs = { + .cmd_rcgr = BLSP1_QUP0_I2C_APPS_CMD_RCGR, + .cfg_rcgr = BLSP1_QUP0_I2C_APPS_CFG_RCGR, + /* mnd_width = 0 */ +}; + +static const struct bcr_regs blsp1_qup1_i2c_apps_regs = { + .cmd_rcgr = BLSP1_QUP1_I2C_APPS_CMD_RCGR, + .cfg_rcgr = BLSP1_QUP1_I2C_APPS_CFG_RCGR, + /* mnd_width = 0 */ +}; + +static const struct bcr_regs blsp1_qup2_i2c_apps_regs = { + .cmd_rcgr = BLSP1_QUP2_I2C_APPS_CMD_RCGR, + .cfg_rcgr = BLSP1_QUP2_I2C_APPS_CFG_RCGR, + /* mnd_width = 0 */ +}; + +static const struct bcr_regs blsp1_qup3_i2c_apps_regs = { + .cmd_rcgr = BLSP1_QUP3_I2C_APPS_CMD_RCGR, + .cfg_rcgr = BLSP1_QUP3_I2C_APPS_CFG_RCGR, + /* mnd_width = 0 */ +}; + +static const struct bcr_regs blsp1_qup4_i2c_apps_regs = { + .cmd_rcgr = BLSP1_QUP4_I2C_APPS_CMD_RCGR, + .cfg_rcgr = BLSP1_QUP4_I2C_APPS_CFG_RCGR, + /* mnd_width = 0 */ +}; + ulong msm_set_rate(struct clk *clk, ulong rate) { struct msm_clk_priv *priv = dev_get_priv(clk->dev); @@ -171,6 +201,34 @@ int msm_enable(struct clk *clk) case GCC_ETH_AXI_CLK: clk_enable_cbc(priv->base + ETH_AXI_CBCR); break; + case GCC_BLSP1_AHB_CLK: + clk_enable_vote_clk(priv->base, &gcc_blsp1_ahb_clk); + break; + case GCC_BLSP1_QUP0_I2C_APPS_CLK: + clk_enable_cbc(priv->base + BLSP1_QUP0_I2C_APPS_CBCR); + clk_rcg_set_rate(priv->base, &blsp1_qup0_i2c_apps_regs, 0, + CFG_CLK_SRC_CXO); + break; + case GCC_BLSP1_QUP1_I2C_APPS_CLK: + clk_enable_cbc(priv->base + BLSP1_QUP1_I2C_APPS_CBCR); + clk_rcg_set_rate(priv->base, &blsp1_qup1_i2c_apps_regs, 0, + CFG_CLK_SRC_CXO); + break; + case GCC_BLSP1_QUP2_I2C_APPS_CLK: + clk_enable_cbc(priv->base + BLSP1_QUP2_I2C_APPS_CBCR); + clk_rcg_set_rate(priv->base, &blsp1_qup2_i2c_apps_regs, 0, + CFG_CLK_SRC_CXO); + break; + case GCC_BLSP1_QUP3_I2C_APPS_CLK: + clk_enable_cbc(priv->base + BLSP1_QUP3_I2C_APPS_CBCR); + clk_rcg_set_rate(priv->base, &blsp1_qup3_i2c_apps_regs, 0, + CFG_CLK_SRC_CXO); + break; + case GCC_BLSP1_QUP4_I2C_APPS_CLK: + clk_enable_cbc(priv->base + BLSP1_QUP4_I2C_APPS_CBCR); + clk_rcg_set_rate(priv->base, &blsp1_qup4_i2c_apps_regs, 0, + CFG_CLK_SRC_CXO); + break; default: return 0; } diff --git a/arch/arm/mach-snapdragon/include/mach/sysmap-qcs404.h b/arch/arm/mach-snapdragon/include/mach/sysmap-qcs404.h index 8920c4ee8f..5768fb1377 100644 --- a/arch/arm/mach-snapdragon/include/mach/sysmap-qcs404.h +++ b/arch/arm/mach-snapdragon/include/mach/sysmap-qcs404.h @@ -28,6 +28,23 @@ #define BLSP1_UART2_APPS_N (0x3040) #define BLSP1_UART2_APPS_D (0x3044) +/* I2C controller clock control registerss */ +#define BLSP1_QUP0_I2C_APPS_CBCR (0x6028) +#define BLSP1_QUP0_I2C_APPS_CMD_RCGR (0x602C) +#define BLSP1_QUP0_I2C_APPS_CFG_RCGR (0x6030) +#define BLSP1_QUP1_I2C_APPS_CBCR (0x2008) +#define BLSP1_QUP1_I2C_APPS_CMD_RCGR (0x200C) +#define BLSP1_QUP1_I2C_APPS_CFG_RCGR (0x2010) +#define BLSP1_QUP2_I2C_APPS_CBCR (0x3010) +#define BLSP1_QUP2_I2C_APPS_CMD_RCGR (0x3000) +#define BLSP1_QUP2_I2C_APPS_CFG_RCGR (0x3004) +#define BLSP1_QUP3_I2C_APPS_CBCR (0x4020) +#define BLSP1_QUP3_I2C_APPS_CMD_RCGR (0x4000) +#define BLSP1_QUP3_I2C_APPS_CFG_RCGR (0x4004) +#define BLSP1_QUP4_I2C_APPS_CBCR (0x5020) +#define BLSP1_QUP4_I2C_APPS_CMD_RCGR (0x5000) +#define BLSP1_QUP4_I2C_APPS_CFG_RCGR (0x5004) + /* SD controller clock control registers */ #define SDCC_BCR(n) (((n) * 0x1000) + 0x41000) #define SDCC_CMD_RCGR(n) (((n) * 0x1000) + 0x41004) From patchwork Fri Jan 20 07:17:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 644616 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp638425pvb; Thu, 19 Jan 2023 23:20:28 -0800 (PST) X-Google-Smtp-Source: AMrXdXvUpXE8Bb1mkjZs2g6zmp5jJvKmZwKtlC75/I7QvYFpHJyRMt/oDfwn1k0fV2V2fcwRJRSR X-Received: by 2002:a05:6808:434d:b0:363:ea5c:25b4 with SMTP id dx13-20020a056808434d00b00363ea5c25b4mr6321789oib.6.1674199228021; Thu, 19 Jan 2023 23:20:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674199228; cv=none; d=google.com; s=arc-20160816; b=l9QU61XJ4v20N/AiBWMfAt6jrgEf236Y1njpmNP+/TU5Ef3rmkbUvCLJqT4J5GmJWR 4hwK06OY59zF/Z3x3gSVgjbWC/JNbqTDBok4ARPuwDkFDFXVa7/P4PwjpVg5cVDrAkMh 65M87As1mPkGWjfOCnQdblHAwP+/1LEcNKyxAy/cgxzxb7fRbpS6xEzGyrHp+Q+PdNRy Z7ZOIrxDUI4vsmSGMBtWpe8rZ1z5/0bQ/ol1sV2miuXn6fX4KKfxsk8lej/l0zDST+J0 9HCBFYxKBIIUeqMfFYZQ/3w7/YfT5PZ06Iue1J2to3GQP9Uf9e6SrA+lOLKQBsEqnclz +onw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Xdf8I24my+RES1hqOGFcOF5sho33tW39rnt5z28aa9A=; b=PtZevO0nwSnER+hzp9YXfXDy5e6XyxFW8QWFATJvHyy9+R9jRO2loY5LNr755k84sY 6Lik0ywj71Q+Qjcas9PPWJxVnKQhQy4XaUjbgRvpSUmWUBj0vcxebAJxaAlR4OKJmD29 E+bvyGJMrMSqYutIZsl/3dqTvNO5OEcTeioQhckhFnvmfSTRSRswJchMHObK2IRkF/a4 xBv9gKb6p0yafPQUBqslD4UJ++clJedXuY++EtIK9C3ayiGXh/HTiZIHUsPK9IKM2EwU PqpcJ2bvV1d36Lb4eWFHTybV/ZnW49V8iGsjjf/2VaLlwXnNOy46ABrRHhhYNYi22Q08 xF7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Wpj3RzP0; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id bd40-20020a056808222800b0033aa1ea1525si2211682oib.285.2023.01.19.23.20.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 23:20:27 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Wpj3RzP0; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5B60D856C7; Fri, 20 Jan 2023 08:18:51 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Wpj3RzP0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 69E5F856B4; Fri, 20 Jan 2023 08:18:35 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 6FFF7856A1 for ; Fri, 20 Jan 2023 08:18:28 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sumit.garg@linaro.org Received: by mail-pg1-x531.google.com with SMTP id q9so3456752pgq.5 for ; Thu, 19 Jan 2023 23:18:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=Xdf8I24my+RES1hqOGFcOF5sho33tW39rnt5z28aa9A=; b=Wpj3RzP0Ow9an4jAOVzETR1B+nQu0KNL3SzJrXU8vmkKxEoj/jTJuNjxMwpMGGMspd uTZvwDNCJP6OMoQBdEutVytFjAJ2ftSbzhqhfAC/KWg8Un654iJxX5WiMCcDxyj4U5GJ sA6kVb4aqk/NeSUuKwycH4DxfP8u9YJQDKkSvA1KnP/abLyg9PpSUq4YsCtVZjUul1FP rr0lYn+fLP9eFYRNNC/oQtrDifReoDSyIV2iFlJCTjnvhPJDy4efCuu+CY2j69/mHxMT LTk+1sRhBrqE283grivbEW5wzWKG3GqTivc8xBQn5RR9P6f/NuYcdXxypssAStz4472s 4/7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=Xdf8I24my+RES1hqOGFcOF5sho33tW39rnt5z28aa9A=; b=kYJCg3Zhl23HiBkZm1fxarJI6DfHfh/6CBCA5E29mL5IQzdMa8YzWEjzNS/oCxEmRN q+73cMvoPa4lwe9rWs+uF6GKmhQ6saniYfEUbwNgXDR8JXi720cWPFLHpPB47c2DP2ZZ FiwknrLASkCW3c9KZZQRY4V10Obtt3SiizCKrg2EAdsnAvChtkLIWPs92dpvOGPLapvj y45iXuJ0P0htOBn1snMbIiiABNotaBj9ljgGNEqZD73ScESJLIbSlsdu08u26HNyslrM mP5vdOABiCpKWPiqdihL6zbHOqLZDpmbuMPd4FnHLxGkwwynaQR6ruAUJ+runeAOu5lA W0jw== X-Gm-Message-State: AFqh2kpDRk4MnQ7FaILY0aUnkEqGXVyJb9umjXerGi/3BRVql8Az/3jI 7locOCUm9e9LyRwDg8463LarBZs0dpAUYGVw X-Received: by 2002:a62:7b43:0:b0:57b:30b6:9e85 with SMTP id w64-20020a627b43000000b0057b30b69e85mr13115888pfc.22.1674199106689; Thu, 19 Jan 2023 23:18:26 -0800 (PST) Received: from sumit-X1.. ([223.178.212.120]) by smtp.gmail.com with ESMTPSA id x15-20020aa7956f000000b0058bacd6c4e8sm9797586pfq.207.2023.01.19.23.18.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 23:18:26 -0800 (PST) From: Sumit Garg To: u-boot@lists.denx.de Cc: rfried.dev@gmail.com, hs@denx.de, joe.hershberger@ni.com, stephan@gerhold.net, mworsfold@impinj.com, lgillham@impinj.com, jbrennan@impinj.com, nicolas.dechesne@linaro.org, vinod.koul@linaro.org, daniel.thompson@linaro.org, Sumit Garg Subject: [PATCH 12/14] pinctrl: qcs404: Enable I2C pinmux options Date: Fri, 20 Jan 2023 12:47:17 +0530 Message-Id: <20230120071719.623661-13-sumit.garg@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230120071719.623661-1-sumit.garg@linaro.org> References: <20230120071719.623661-1-sumit.garg@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Co-developed-by: Mike Worsfold Signed-off-by: Mike Worsfold Signed-off-by: Sumit Garg --- arch/arm/mach-snapdragon/pinctrl-qcs404.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/arm/mach-snapdragon/pinctrl-qcs404.c b/arch/arm/mach-snapdragon/pinctrl-qcs404.c index 5a7fbfd441..a6e53c4412 100644 --- a/arch/arm/mach-snapdragon/pinctrl-qcs404.c +++ b/arch/arm/mach-snapdragon/pinctrl-qcs404.c @@ -29,6 +29,12 @@ static const struct pinctrl_function msm_pinctrl_functions[] = { {"rgmii_rx", 1}, {"rgmii_mdio", 1}, {"rgmii_mdc", 1}, + {"blsp_i2c0", 3}, + {"blsp_i2c1", 2}, + {"blsp_i2c_sda_a2", 3}, + {"blsp_i2c_scl_a2", 3}, + {"blsp_i2c3", 2}, + {"blsp_i2c4", 1}, }; static const char *qcs404_get_function_name(struct udevice *dev, From patchwork Fri Jan 20 07:17:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 644617 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp638502pvb; Thu, 19 Jan 2023 23:20:40 -0800 (PST) X-Google-Smtp-Source: AMrXdXvovAZdAdzrAKKwhF8nMtcLWsUDtf+M4ZOYo+bY/5YmmseMI56XdKZeFjsVKnrmLWeFTfyq X-Received: by 2002:a05:6830:168b:b0:686:64a8:515 with SMTP id k11-20020a056830168b00b0068664a80515mr3004159otr.2.1674199240683; Thu, 19 Jan 2023 23:20:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674199240; cv=none; d=google.com; s=arc-20160816; b=KMeWaAlag5fbpD+Ru+6bLEoDM1NKJcniPsXyv79KtPQ9BL+xFQGakjIaJGmlYvYMgW jBY1lpYFyBb6n5niLwGmkFFPPj2GqYyMqwMgUuTY3oxSZg4kp2Xe2itgXF5SEqCLpMK8 Hlt1Aqzfb2rTcFpeDgB+P5NkBgLUPkXEjyKMd3VvzOAPqVQn57iBq3buwTtXsDovjaYG E92gaBFhn2z8I0+fopn6eIJenjlbTJKmcA7sTXn19L/bPPB2UIT7OelBP990lQ6tleUN ZRZcErH6ua6RZ/zS1wijAahIqFN/04EpxA7sf8vRgQoP3HqfuKNjYtb/s1s9Z/aoiuuX hHtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=52p6hdj2wo+1GmH7rXLBPTuhOCrQtwAwxzUYNPgkty0=; b=fRbr82Xauu8F+cy4ybuZGVh4Qlcv0HbBwuhWcqJFANNFUDsUKiu+ROnD3hGHgCU7a6 bwH+lnA7h78Eg9ND1DXfz6bRGp+CKN9THtywA+P/B9BDDKIamEB8hBIFYfrHy0T9h/UU lX0d+UfTuQhCyhEJqRt26dfAMNW3kDoR9IW9r3qDqdaWyAbyoy+TF3fHcr7cZ2mw4X57 uHMnG+rY/x+47zfNTx7exbRY5lOFLIOdTTgNH63u6d3ggpM6p4tTDjfspN3x6zJ2x+Fo OJmFSUHhmaJoSrm+G4I3POAN4aB+Xy2mT7E98qFnQM/Qz7baiYVBe3V6niGjx23rDJBs dUsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MAV5xQKp; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id q7-20020a056830440700b0067075185728si37892551otv.204.2023.01.19.23.20.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 23:20:40 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MAV5xQKp; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CC489856BB; Fri, 20 Jan 2023 08:18:53 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="MAV5xQKp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2A531856A7; Fri, 20 Jan 2023 08:18:45 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 20A30856D8 for ; Fri, 20 Jan 2023 08:18:33 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sumit.garg@linaro.org Received: by mail-pj1-x1035.google.com with SMTP id b10so4799043pjo.1 for ; Thu, 19 Jan 2023 23:18:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=52p6hdj2wo+1GmH7rXLBPTuhOCrQtwAwxzUYNPgkty0=; b=MAV5xQKpNYKcEGCV8X3h8R+uYjtEDaJAX+cwskoLZ7muqFX6i27zK5svIwh44hbnF0 lv/rW5TVBU+5p/hAuFj5frC/1RlnJE6hzxwRsSOQ9aMChfYEPfNFvJWMl0aax/uRJ+RQ GAIzfV69IWcHE3CucbFTQtdbf2unB03pzqpm9mTT7xpwEbswHtTRNwHmj8fp9GbJPhcr vWkBtBxPSSIQeQhAZPTWHH2N1uGWLZ8qNr2nmMNH9VHcy9p6XBO8qw2Ac0RXtpZ+prGx SdwBog0NPO4bWa6ih8QQ/DZFAdmIjJbyK5rEuuYRTMkXsHCs9pHuY49LgvtGiNDyl/t4 /FrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=52p6hdj2wo+1GmH7rXLBPTuhOCrQtwAwxzUYNPgkty0=; b=PsoX3Eva1Blf5zrR0Kp9aE0KAyPfIfoJeC7bRt8h5bgSgKsTD1hJThe35XcqFt/VLh gQIbixRWvld3dlhsAyHACTucbr72VcNw8VbZ3sWsKQMKUbSQ2FPQj2fApMdcUvwm6+bm wSGRb5X1X0ZMgtCgAzq3N6gawShXHgK8usdx0PQG7BM7RaUueGUkdOD11rP69RTV36WN ajN/eEytAHl5jN1Xu43b7ioVC0OP8HrFvI+5AGc554q8Ie9Pv/Koad1HAicjOL+ZnphJ TqqxqAuBi55SX87WFtUjQ/D8TygOmMnsS60tlmRR1AbHgs34mrr1KkfxqwWyVQ5MAwYW Hbbg== X-Gm-Message-State: AFqh2kqs8u3POY37xlSv7SvpSQXzQuCAEf/Fmk0EiG81EfPTdqZQIB7o JbpQ/BRjGwySoJVpslTbL1iYery28HyK++Y6 X-Received: by 2002:a05:6a20:3d09:b0:b8:6fe8:5ed7 with SMTP id y9-20020a056a203d0900b000b86fe85ed7mr19374205pzi.44.1674199111023; Thu, 19 Jan 2023 23:18:31 -0800 (PST) Received: from sumit-X1.. ([223.178.212.120]) by smtp.gmail.com with ESMTPSA id x15-20020aa7956f000000b0058bacd6c4e8sm9797586pfq.207.2023.01.19.23.18.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 23:18:30 -0800 (PST) From: Sumit Garg To: u-boot@lists.denx.de Cc: rfried.dev@gmail.com, hs@denx.de, joe.hershberger@ni.com, stephan@gerhold.net, mworsfold@impinj.com, lgillham@impinj.com, jbrennan@impinj.com, nicolas.dechesne@linaro.org, vinod.koul@linaro.org, daniel.thompson@linaro.org, Sumit Garg Subject: [PATCH 13/14] i2c: Add support for Qualcomm I2C driver Date: Fri, 20 Jan 2023 12:47:18 +0530 Message-Id: <20230120071719.623661-14-sumit.garg@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230120071719.623661-1-sumit.garg@linaro.org> References: <20230120071719.623661-1-sumit.garg@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Add support for Qualcomm I2C QUP driver which is inspired from corresponding driver in Linux: drivers/i2c/busses/i2c-qup.c. Currently this driver only support FIFO polling mode which is sufficient to support devices like eeprom, rtc etc. Co-developed-by: Mike Worsfold Signed-off-by: Mike Worsfold Signed-off-by: Sumit Garg --- drivers/i2c/Kconfig | 6 + drivers/i2c/Makefile | 1 + drivers/i2c/qup_i2c.c | 592 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 599 insertions(+) create mode 100644 drivers/i2c/qup_i2c.c diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig index 76e19918aa..2a1d36f91a 100644 --- a/drivers/i2c/Kconfig +++ b/drivers/i2c/Kconfig @@ -635,6 +635,12 @@ config SYS_I2C_TEGRA help Support for NVIDIA I2C controller available in Tegra SoCs. +config SYS_I2C_QUP + bool "Qualcomm I2C controller" + depends on ARCH_SNAPDRAGON + help + Support for Qualcomm I2C controller. + config SYS_I2C_UNIPHIER bool "UniPhier I2C driver" depends on ARCH_UNIPHIER && DM_I2C diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile index 920aafb91c..f6aa39dd7a 100644 --- a/drivers/i2c/Makefile +++ b/drivers/i2c/Makefile @@ -50,6 +50,7 @@ obj-$(CONFIG_SYS_I2C_SUN6I_P2WI) += sun6i_p2wi.o obj-$(CONFIG_SYS_I2C_SUN8I_RSB) += sun8i_rsb.o obj-$(CONFIG_SYS_I2C_SYNQUACER) += synquacer_i2c.o obj-$(CONFIG_SYS_I2C_TEGRA) += tegra_i2c.o +obj-$(CONFIG_SYS_I2C_QUP) += qup_i2c.o obj-$(CONFIG_SYS_I2C_UNIPHIER) += i2c-uniphier.o obj-$(CONFIG_SYS_I2C_UNIPHIER_F) += i2c-uniphier-f.o obj-$(CONFIG_SYS_I2C_VERSATILE) += i2c-versatile.o diff --git a/drivers/i2c/qup_i2c.c b/drivers/i2c/qup_i2c.c new file mode 100644 index 0000000000..6787fc75fc --- /dev/null +++ b/drivers/i2c/qup_i2c.c @@ -0,0 +1,592 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2009-2013, 2016-2018, The Linux Foundation. All rights reserved. + * Copyright (c) 2014, Sony Mobile Communications AB. + * Copyright (c) 2022-2023, Sumit Garg + * + * Inspired by corresponding driver in Linux: drivers/i2c/busses/i2c-qup.c + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* QUP Registers */ +#define QUP_CONFIG 0x000 +#define QUP_STATE 0x004 +#define QUP_IO_MODE 0x008 +#define QUP_SW_RESET 0x00c +#define QUP_OPERATIONAL 0x018 +#define QUP_ERROR_FLAGS 0x01c +#define QUP_ERROR_FLAGS_EN 0x020 +#define QUP_TEST_CTRL 0x024 /* NOT USED */ +#define QUP_OPERATIONAL_MASK 0x028 +#define QUP_HW_VERSION 0x030 +#define QUP_MX_OUTPUT_CNT 0x100 +#define QUP_OUT_DEBUG 0x108 /* NOT USED */ +#define QUP_OUT_FIFO_CNT 0x10C /* NOT USED */ +#define QUP_OUT_FIFO_BASE 0x110 +#define QUP_MX_WRITE_CNT 0x150 +#define QUP_MX_INPUT_CNT 0x200 +#define QUP_MX_READ_CNT 0x208 +#define QUP_IN_READ_CUR 0x20C /* NOT USED */ +#define QUP_IN_DEBUG 0x210 /* NOT USED */ +#define QUP_IN_FIFO_CNT 0x214 /* NOT USED */ +#define QUP_IN_FIFO_BASE 0x218 +#define QUP_I2C_CLK_CTL 0x400 +#define QUP_I2C_STATUS 0x404 +#define QUP_I2C_MASTER_GEN 0x408 +#define QUP_I2C_MASTER_BUS_CLR 0x40C /* NOT USED */ + +/* QUP States and reset values */ +#define QUP_RESET_STATE 0 +#define QUP_RUN_STATE 1 +#define QUP_PAUSE_STATE 3 +#define QUP_STATE_MASK 3 + +#define QUP_STATE_VALID BIT(2) +#define QUP_I2C_MAST_GEN BIT(4) +#define QUP_I2C_FLUSH BIT(6) + +#define QUP_OPERATIONAL_RESET 0x000ff0 +#define QUP_I2C_STATUS_RESET 0xfffffc + +/* QUP OPERATIONAL FLAGS */ +#define QUP_I2C_NACK_FLAG BIT(3) +#define QUP_OUT_NOT_EMPTY BIT(4) +#define QUP_IN_NOT_EMPTY BIT(5) +#define QUP_OUT_FULL BIT(6) +#define QUP_OUT_SVC_FLAG BIT(8) +#define QUP_IN_SVC_FLAG BIT(9) +#define QUP_MX_OUTPUT_DONE BIT(10) +#define QUP_MX_INPUT_DONE BIT(11) +#define OUT_BLOCK_WRITE_REQ BIT(12) +#define IN_BLOCK_READ_REQ BIT(13) + +/* I2C mini core related values */ +#define QUP_NO_OUTPUT BIT(6) +#define QUP_NO_INPUT BIT(7) +#define QUP_CLOCK_AUTO_GATE BIT(13) +#define I2C_MINI_CORE (2 << 8) +#define I2C_N_VAL 15 +#define I2C_N_VAL_V2 7 + +/* Most significant word offset in FIFO port */ +#define QUP_MSW_SHIFT (I2C_N_VAL + 1) + +/* Packing/Unpacking words in FIFOs, and IO modes */ +#define QUP_OUTPUT_BLK_MODE BIT(10) +#define QUP_OUTPUT_BAM_MODE (BIT(10) | BIT(11)) +#define QUP_INPUT_BLK_MODE BIT(12) +#define QUP_INPUT_BAM_MODE (BIT(12) | BIT(13)) +#define QUP_BAM_MODE (QUP_OUTPUT_BAM_MODE | QUP_INPUT_BAM_MODE) +#define QUP_BLK_MODE (QUP_OUTPUT_BLK_MODE | QUP_INPUT_BLK_MODE) +#define QUP_UNPACK_EN BIT(14) +#define QUP_PACK_EN BIT(15) + +#define QUP_REPACK_EN (QUP_UNPACK_EN | QUP_PACK_EN) +#define QUP_V2_TAGS_EN 1 + +#define QUP_OUTPUT_BLOCK_SIZE(x) (((x) >> 0) & 0x03) +#define QUP_OUTPUT_FIFO_SIZE(x) (((x) >> 2) & 0x07) +#define QUP_INPUT_BLOCK_SIZE(x) (((x) >> 5) & 0x03) +#define QUP_INPUT_FIFO_SIZE(x) (((x) >> 7) & 0x07) + +/* QUP v2 tags */ +#define QUP_TAG_V2_START 0x81 +#define QUP_TAG_V2_DATAWR 0x82 +#define QUP_TAG_V2_DATAWR_STOP 0x83 +#define QUP_TAG_V2_DATARD 0x85 +#define QUP_TAG_V2_DATARD_NACK 0x86 +#define QUP_TAG_V2_DATARD_STOP 0x87 + +/* Status, Error flags */ +#define I2C_STATUS_WR_BUFFER_FULL BIT(0) +#define I2C_STATUS_BUS_ERROR BIT(2) +#define I2C_STATUS_PACKET_NACKED BIT(3) +#define I2C_STATUS_ARB_LOST BIT(4) +#define I2C_STATUS_INVALID_WRITE BIT(5) +#define I2C_STATUS_FAILED BIT(6) +#define I2C_STATUS_BUS_ACTIVE BIT(8) +#define I2C_STATUS_BUS_MASTER BIT(9) +#define I2C_STATUS_INVALID_TAG BIT(23) +#define I2C_STATUS_INVALID_READ_ADDR BIT(24) +#define I2C_STATUS_INVALID_READ_SEQ BIT(25) +#define I2C_STATUS_I2C_SDA BIT(26) +#define I2C_STATUS_I2C_SCL BIT(27) +#define I2C_STATUS_ERROR_MASK 0x38000fc +#define QUP_STATUS_ERROR_FLAGS 0x7c + +#define QUP_I2C_MX_CONFIG_DURING_RUN BIT(31) + +/* Minimum transfer timeout for i2c transfers in micro seconds */ +#define TOUT_CNT 2 * 1000 * 1000 + +/* Default values. Use these if FW query fails */ +#define DEFAULT_CLK_FREQ I2C_SPEED_STANDARD_RATE +#define DEFAULT_SRC_CLK 19200000 + +/* + * Max tags length (start, stop and maximum 2 bytes address) for each QUP + * data transfer + */ +#define QUP_MAX_TAGS_LEN 4 +/* Max data length for each DATARD tags */ +#define RECV_MAX_DATA_LEN 254 +/* TAG length for DATA READ in RX FIFO */ +#define READ_RX_TAGS_LEN 2 + +struct qup_i2c_priv { + phys_addr_t base; + struct clk core; + struct clk iface; + u32 in_fifo_sz; + u32 out_fifo_sz; + u32 clk_ctl; + u32 config_run; +}; + +static inline u8 i2c_8bit_addr_from_msg(const struct i2c_msg *msg) +{ + return (msg->addr << 1) | (msg->flags & I2C_M_RD ? 1 : 0); +} + +static int qup_i2c_poll_state_mask(struct qup_i2c_priv *qup, + u32 req_state, u32 req_mask) +{ + int retries = 1; + u32 state; + + /* + * State transition takes 3 AHB clocks cycles + 3 I2C master clock + * cycles. So retry once after a 1uS delay. + */ + do { + state = readl(qup->base + QUP_STATE); + + if (state & QUP_STATE_VALID && + (state & req_mask) == req_state) + return 0; + + udelay(1); + } while (retries--); + + return -ETIMEDOUT; +} + +static int qup_i2c_poll_state(struct qup_i2c_priv *qup, u32 req_state) +{ + return qup_i2c_poll_state_mask(qup, req_state, QUP_STATE_MASK); +} + +static int qup_i2c_poll_state_valid(struct qup_i2c_priv *qup) +{ + return qup_i2c_poll_state_mask(qup, 0, 0); +} + +static int qup_i2c_poll_state_i2c_master(struct qup_i2c_priv *qup) +{ + return qup_i2c_poll_state_mask(qup, QUP_I2C_MAST_GEN, QUP_I2C_MAST_GEN); +} + +static int qup_i2c_change_state(struct qup_i2c_priv *qup, u32 state) +{ + if (qup_i2c_poll_state_valid(qup) != 0) + return -EIO; + + writel(state, qup->base + QUP_STATE); + + if (qup_i2c_poll_state(qup, state) != 0) + return -EIO; + return 0; +} + +/* + * Function to check wheather Input or Output FIFO + * has data to be serviced + */ +static int qup_i2c_check_fifo_status(struct qup_i2c_priv *qup, u32 reg_addr, + u32 flags) +{ + unsigned long count = TOUT_CNT; + u32 val, status_flag; + int ret = 0; + + do { + val = readl(qup->base + reg_addr); + status_flag = val & flags; + + if (!count) { + printf("%s, timeout\n", __func__); + ret = -ETIMEDOUT; + break; + } + + count--; + udelay(1); + } while (!status_flag); + + return ret; +} + +/* + * Function to configure Input and Output enable/disable + */ +static void qup_i2c_enable_io_config(struct qup_i2c_priv *qup, u32 write_cnt, + u32 read_cnt) +{ + u32 qup_config = I2C_MINI_CORE | I2C_N_VAL_V2; + + writel(qup->config_run | write_cnt, qup->base + QUP_MX_WRITE_CNT); + + if (read_cnt) + writel(qup->config_run | read_cnt, qup->base + QUP_MX_READ_CNT); + else + qup_config |= QUP_NO_INPUT; + + writel(qup_config, qup->base + QUP_CONFIG); +} + +static unsigned int qup_i2c_read_word(struct qup_i2c_priv *qup) +{ + return readl(qup->base + QUP_IN_FIFO_BASE); +} + +static void qup_i2c_write_word(struct qup_i2c_priv *qup, u32 word) +{ + writel(word, qup->base + QUP_OUT_FIFO_BASE); +} + +static int qup_i2c_blsp_read(struct qup_i2c_priv *qup, unsigned int addr, + bool last, u8 *buffer, unsigned int bytes) +{ + unsigned int i, j, word; + int ret = 0; + + /* FIFO mode size limitation, for larger size implement block mode */ + if (bytes > (qup->in_fifo_sz - READ_RX_TAGS_LEN)) + return -EINVAL; + + qup_i2c_enable_io_config(qup, QUP_MAX_TAGS_LEN, + bytes + READ_RX_TAGS_LEN); + + if (last) + qup_i2c_write_word(qup, QUP_TAG_V2_START | addr << 8 | + QUP_TAG_V2_DATARD_STOP << 16 | + bytes << 24); + else + qup_i2c_write_word(qup, QUP_TAG_V2_START | addr << 8 | + QUP_TAG_V2_DATARD << 16 | bytes << 24); + + ret = qup_i2c_change_state(qup, QUP_RUN_STATE); + if (ret) + return ret; + + ret = qup_i2c_check_fifo_status(qup, QUP_OPERATIONAL, QUP_OUT_SVC_FLAG); + if (ret) + return ret; + writel(QUP_OUT_SVC_FLAG, qup->base + QUP_OPERATIONAL); + + ret = qup_i2c_check_fifo_status(qup, QUP_OPERATIONAL, QUP_IN_SVC_FLAG); + if (ret) + return ret; + writel(QUP_IN_SVC_FLAG, qup->base + QUP_OPERATIONAL); + + word = qup_i2c_read_word(qup); + *(buffer++) = (word >> (8 * READ_RX_TAGS_LEN)) & 0xff; + if (bytes > 1) + *(buffer++) = (word >> (8 * (READ_RX_TAGS_LEN + 1))) & 0xff; + + for (i = 2; i < bytes; i += 4) { + word = qup_i2c_read_word(qup); + + for (j = 0; j < 4; j++) { + if ((i + j) == bytes) + break; + *buffer = (word >> (j * 8)) & 0xff; + buffer++; + } + } + + ret = qup_i2c_change_state(qup, QUP_PAUSE_STATE); + return ret; +} + +static int qup_i2c_blsp_write(struct qup_i2c_priv *qup, unsigned int addr, + bool first, bool last, const u8 *buffer, + unsigned int bytes) +{ + unsigned int i; + u32 word = 0; + int ret = 0; + + /* FIFO mode size limitation, for larger size implement block mode */ + if (bytes > (qup->out_fifo_sz - QUP_MAX_TAGS_LEN)) + return -EINVAL; + + qup_i2c_enable_io_config(qup, bytes + QUP_MAX_TAGS_LEN, 0); + + if (first) { + ret = qup_i2c_change_state(qup, QUP_RUN_STATE); + if (ret) + return ret; + + writel(qup->clk_ctl, qup->base + QUP_I2C_CLK_CTL); + + ret = qup_i2c_change_state(qup, QUP_PAUSE_STATE); + if (ret) + return ret; + } + + if (last) + qup_i2c_write_word(qup, QUP_TAG_V2_START | addr << 8 | + QUP_TAG_V2_DATAWR_STOP << 16 | + bytes << 24); + else + qup_i2c_write_word(qup, QUP_TAG_V2_START | addr << 8 | + QUP_TAG_V2_DATAWR << 16 | bytes << 24); + + for (i = 0; i < bytes; i++) { + /* Write the byte of data */ + word |= *buffer << ((i % 4) * 8); + if ((i % 4) == 3) { + qup_i2c_write_word(qup, word); + word = 0; + } + buffer++; + } + + if ((i % 4) != 0) + qup_i2c_write_word(qup, word); + + ret = qup_i2c_change_state(qup, QUP_RUN_STATE); + if (ret) + return ret; + + ret = qup_i2c_check_fifo_status(qup, QUP_OPERATIONAL, QUP_OUT_SVC_FLAG); + if (ret) + return ret; + writel(QUP_OUT_SVC_FLAG, qup->base + QUP_OPERATIONAL); + + ret = qup_i2c_change_state(qup, QUP_PAUSE_STATE); + return ret; +} + +static void qup_i2c_conf_mode_v2(struct qup_i2c_priv *qup) +{ + u32 io_mode = QUP_REPACK_EN; + + writel(0, qup->base + QUP_MX_OUTPUT_CNT); + writel(0, qup->base + QUP_MX_INPUT_CNT); + + writel(io_mode, qup->base + QUP_IO_MODE); +} + +static int qup_i2c_xfer_v2(struct udevice *bus, struct i2c_msg msgs[], int num) +{ + struct qup_i2c_priv *qup = dev_get_priv(bus); + int ret, idx = 0; + u32 i2c_addr; + + writel(1, qup->base + QUP_SW_RESET); + ret = qup_i2c_poll_state(qup, QUP_RESET_STATE); + if (ret) + goto out; + + /* Configure QUP as I2C mini core */ + writel(I2C_MINI_CORE | I2C_N_VAL_V2 | QUP_NO_INPUT, + qup->base + QUP_CONFIG); + writel(QUP_V2_TAGS_EN, qup->base + QUP_I2C_MASTER_GEN); + + if (qup_i2c_poll_state_i2c_master(qup)) { + ret = -EIO; + goto out; + } + + qup_i2c_conf_mode_v2(qup); + + for (idx = 0; idx < num; idx++) { + struct i2c_msg *m = &msgs[idx]; + + qup->config_run = !idx ? 0 : QUP_I2C_MX_CONFIG_DURING_RUN; + i2c_addr = i2c_8bit_addr_from_msg(m); + + if (m->flags & I2C_M_RD) + ret = qup_i2c_blsp_read(qup, i2c_addr, idx == (num - 1), + m->buf, m->len); + else + ret = qup_i2c_blsp_write(qup, i2c_addr, idx == 0, + idx == (num - 1), m->buf, + m->len); + if (ret) + break; + } +out: + qup_i2c_change_state(qup, QUP_RESET_STATE); + return ret; +} + +static int qup_i2c_enable_clocks(struct udevice *dev, struct qup_i2c_priv *qup) +{ + int ret; + + ret = clk_enable(&qup->core); + if (ret) { + dev_err(dev, "clk_enable failed %d\n", ret); + return ret; + } + + ret = clk_enable(&qup->iface); + if (ret) { + dev_err(dev, "clk_enable failed %d\n", ret); + return ret; + } + + return 0; +} + +static int qup_i2c_probe(struct udevice *dev) +{ + static const int blk_sizes[] = {4, 16, 32}; + struct qup_i2c_priv *qup = dev_get_priv(dev); + u32 io_mode, hw_ver, size, size_idx; + int ret; + + qup->base = (phys_addr_t)dev_read_addr_ptr(dev); + if (!qup->base) + return -EINVAL; + + ret = clk_get_by_name(dev, "core", &qup->core); + if (ret) { + pr_err("clk_get_by_name(core) failed: %d\n", ret); + return ret; + } + ret = clk_get_by_name(dev, "iface", &qup->iface); + if (ret) { + pr_err("clk_get_by_name(iface) failed: %d\n", ret); + return ret; + } + qup_i2c_enable_clocks(dev, qup); + + writel(1, qup->base + QUP_SW_RESET); + ret = qup_i2c_poll_state_valid(qup); + if (ret) + return ret; + + hw_ver = readl(qup->base + QUP_HW_VERSION); + dev_dbg(dev, "Revision %x\n", hw_ver); + + io_mode = readl(qup->base + QUP_IO_MODE); + + /* + * The block/fifo size w.r.t. 'actual data' is 1/2 due to 'tag' + * associated with each byte written/received + */ + size_idx = QUP_OUTPUT_BLOCK_SIZE(io_mode); + if (size_idx >= ARRAY_SIZE(blk_sizes)) { + ret = -EIO; + return ret; + } + size = QUP_OUTPUT_FIFO_SIZE(io_mode); + qup->out_fifo_sz = blk_sizes[size_idx] * (2 << size); + + size_idx = QUP_INPUT_BLOCK_SIZE(io_mode); + if (size_idx >= ARRAY_SIZE(blk_sizes)) { + ret = -EIO; + return ret; + } + size = QUP_INPUT_FIFO_SIZE(io_mode); + qup->in_fifo_sz = blk_sizes[size_idx] * (2 << size); + + dev_dbg(dev, "IN:fifo:%d, OUT:fifo:%d\n", qup->in_fifo_sz, + qup->out_fifo_sz); + + return 0; +} + +static int qup_i2c_set_bus_speed(struct udevice *dev, unsigned int clk_freq) +{ + struct qup_i2c_priv *qup = dev_get_priv(dev); + unsigned int src_clk_freq; + int fs_div, hs_div; + + /* We support frequencies up to FAST Mode Plus (1MHz) */ + if (!clk_freq || clk_freq > I2C_SPEED_FAST_PLUS_RATE) { + dev_err(dev, "clock frequency not supported %d\n", clk_freq); + return -EINVAL; + } + + src_clk_freq = clk_get_rate(&qup->iface); + if ((int)src_clk_freq < 0) { + src_clk_freq = DEFAULT_SRC_CLK; + dev_dbg(dev, "using default core freq %d\n", src_clk_freq); + } + + dev_dbg(dev, "src_clk_freq %u\n", src_clk_freq); + dev_dbg(dev, "clk_freq %u\n", clk_freq); + + hs_div = 3; + if (clk_freq <= I2C_SPEED_STANDARD_RATE) { + fs_div = ((src_clk_freq / clk_freq) / 2) - 3; + qup->clk_ctl = (hs_div << 8) | (fs_div & 0xff); + } else { + /* 33%/66% duty cycle */ + fs_div = ((src_clk_freq / clk_freq) - 6) * 2 / 3; + qup->clk_ctl = ((fs_div / 2) << 16) | (hs_div << 8) | (fs_div & 0xff); + } + + dev_dbg(dev, "clk_ctl %u\n", qup->clk_ctl); + + return 0; +} + +/* Probe to see if a chip is present. */ +static int qup_i2c_probe_chip(struct udevice *dev, uint chip_addr, + uint chip_flags) +{ + struct qup_i2c_priv *qup = dev_get_priv(dev); + u32 hw_ver = readl(qup->base + QUP_HW_VERSION); + + return hw_ver ? 0 : -1; +} + +static const struct dm_i2c_ops qup_i2c_ops = { + .xfer = qup_i2c_xfer_v2, + .probe_chip = qup_i2c_probe_chip, + .set_bus_speed = qup_i2c_set_bus_speed, +}; + +static const struct udevice_id qup_i2c_ids[] = { + { .compatible = "qcom,i2c-qup-v2.1.1" }, + { .compatible = "qcom,i2c-qup-v2.2.1" }, + { .compatible = "qcom,i2c-qup" }, + {} +}; + +U_BOOT_DRIVER(i2c_qup) = { + .name = "i2c_qup", + .id = UCLASS_I2C, + .of_match = qup_i2c_ids, + .probe = qup_i2c_probe, + .priv_auto = sizeof(struct qup_i2c_priv), + .ops = &qup_i2c_ops, +}; From patchwork Fri Jan 20 07:17:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 644618 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp638569pvb; Thu, 19 Jan 2023 23:20:53 -0800 (PST) X-Google-Smtp-Source: AMrXdXuVEbIb8+Fy5j0FrUGl6SnyHFlpxVNhZEsf7wY4SAolmTmdLDz7YBpzaZrcS+X5TjXKOzgg X-Received: by 2002:a4a:ea2f:0:b0:49b:e8d9:6c6 with SMTP id y15-20020a4aea2f000000b0049be8d906c6mr7070797ood.0.1674199253676; Thu, 19 Jan 2023 23:20:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674199253; cv=none; d=google.com; s=arc-20160816; b=FD3sUotrDPjY7TAC2bhfdg1Y5UdpcQEoztcWmO2ofbTda2AQvZT/ISuguraYgmSm0c slgPQeiqS26CZNBBWChhf9uejDP3s17mjHJpl6yIKYcGL4mkD+roxc+mHLbPwQ3wL7UH 4u5D75HSXd+v6MTzsNBTP+wPGI48L8O3K9Cw/U3fRsNq/tkqXWk8YajmrIKgU1Fz6TpU IDBomZcgnbFWTGLeP6zkbRs7l95FBppDp9f3hC29FeJHpYNqNS3iTCH8at8i9s1fpPLm s720ovNH8UnCZNDcNY2Il9aCrk+6e7KFICs5sngaHji+sUcIAXXxmS6PntHDVPuQgzRq M0wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6kr/g6m/4ZltE8jqlhDtEwO8Fv1oew34oK40awNbuVI=; b=c9SC+Dq146c5yrnJgUnkf5Boy4FFCfYJ7n5UIwDI5gQplrJWgw8KRqeIS6wEhql142 phcO9eEn258Rk/jIhv2grYs9p4hjQxrNE1iUXMRSAg0Rqg7eKHbzi+vFqMmZAUZUnnZ1 qMGlG9yV9tIebtxlNxt6Vc45bubIo9YCCpzFZKqbwhNogyqCJ81yzr56DLUvtMSbvrp/ 7PAxTRavDV8rOTxGj7krpeELyqXexSyZJAfzzePc5hSm8qQq3LShrixTo/tMcwXg4GN9 oL6Cd2/cLAytQPsp/SUKAGoMNT9y7f2u5vW7tjHU74Hmhs6hOrbd7KDSRtaREM0kE8xk CajA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wng20l2R; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id y36-20020a4a9827000000b004b195b8a0c0si33311966ooi.75.2023.01.19.23.20.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 23:20:53 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wng20l2R; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 427D8856DE; Fri, 20 Jan 2023 08:18:56 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="wng20l2R"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D6AF285694; Fri, 20 Jan 2023 08:18:45 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 23AE8856E3 for ; Fri, 20 Jan 2023 08:18:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sumit.garg@linaro.org Received: by mail-pj1-x1033.google.com with SMTP id o13so4795803pjg.2 for ; Thu, 19 Jan 2023 23:18:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=6kr/g6m/4ZltE8jqlhDtEwO8Fv1oew34oK40awNbuVI=; b=wng20l2RTnLS/b2uP13Lq0MLpP4QbuS2hAqBy7zMYdfcsRd0r8uoC+jIb3OqGgc3Ih hUX79XWxQSsenLkFka8Qx3DgJ9elXP8zyEfMxtOnODTINIC9VOVPEJcapnwNOefm8zcn abKr5GZ+/1vs5cDgVyEYvTmAxP4bNaoI75eRNDq25aUSGFOP3DvNyYWEIoys/tLpVNQt q9MN7mxOtEMMtTaUg1SBw4FKLk+xY/HGWGTatPN7KzMSOJwB45dm40lNT6qBaghTwOhP VoqCCSKDEbkcg9A/Ipk18ZUicmD4mz5+2BPdgOt3KcYpryEhY1IT3goNeuCvrZoZngkQ q5dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=6kr/g6m/4ZltE8jqlhDtEwO8Fv1oew34oK40awNbuVI=; b=Grt5AcBwaMw7ZZJParjOUXZzfC3n31U/0uL5dxQkJpCR/7bKvZn0WrVjdwu3FkRk0T w0p6S5te87ACt3MguapmGHzuV1h+zUl2Xmx3l0hJsIzSs8Roy5H+DE8i9AUVJ4l+lBEu jUMRBWVhQdo2b/lIHSx9gkXgpwu5njDEsd2tvSM2b/llY4G2DrkXGbR7JQbqTnYbRBQP Qvkixm6Xryhn8pZ7TutHM5/nDrH2jRLOxIxJQQ6+1ZWME4dGRFjPmg144FKbuktbfZ0o U1bCrHo/3rkYstMZZTkmsGR31Um6wGTMN2fFnYaYopJBpwLgLyy+p22GwehCwN039jTn GplA== X-Gm-Message-State: AFqh2kq1S60/Mkv7UqAO7xEaLzM8TAxk/j/arnwGh0e1v/UfwT2MpF+P Op1PqxnwL+I5qShe/pOT8rwO0uB2cXBZSWl5 X-Received: by 2002:a05:6a20:7f8f:b0:b9:5fc6:9e4b with SMTP id d15-20020a056a207f8f00b000b95fc69e4bmr2978318pzj.62.1674199115326; Thu, 19 Jan 2023 23:18:35 -0800 (PST) Received: from sumit-X1.. ([223.178.212.120]) by smtp.gmail.com with ESMTPSA id x15-20020aa7956f000000b0058bacd6c4e8sm9797586pfq.207.2023.01.19.23.18.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 23:18:35 -0800 (PST) From: Sumit Garg To: u-boot@lists.denx.de Cc: rfried.dev@gmail.com, hs@denx.de, joe.hershberger@ni.com, stephan@gerhold.net, mworsfold@impinj.com, lgillham@impinj.com, jbrennan@impinj.com, nicolas.dechesne@linaro.org, vinod.koul@linaro.org, daniel.thompson@linaro.org, Sumit Garg Subject: [PATCH 14/14] dts: qcs404-evb: Add I2C controller nodes Date: Fri, 20 Jan 2023 12:47:19 +0530 Message-Id: <20230120071719.623661-15-sumit.garg@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230120071719.623661-1-sumit.garg@linaro.org> References: <20230120071719.623661-1-sumit.garg@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Signed-off-by: Sumit Garg --- arch/arm/dts/qcs404-evb.dts | 97 +++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/arch/arm/dts/qcs404-evb.dts b/arch/arm/dts/qcs404-evb.dts index 2de0e7537b..8d7893c116 100644 --- a/arch/arm/dts/qcs404-evb.dts +++ b/arch/arm/dts/qcs404-evb.dts @@ -23,6 +23,11 @@ aliases { serial0 = &debug_uart; + i2c0 = &blsp1_i2c0; + i2c1 = &blsp1_i2c1; + i2c2 = &blsp1_i2c2; + i2c3 = &blsp1_i2c3; + i2c4 = &blsp1_i2c4; }; memory { @@ -49,6 +54,38 @@ function = "blsp_uart2"; }; + blsp1_i2c0_default: blsp1-i2c0-default { + pins = "GPIO_32", "GPIO_33"; + function = "blsp_i2c0"; + }; + + blsp1_i2c1_default: blsp1-i2c1-default { + pins = "GPIO_24", "GPIO_25"; + function = "blsp_i2c1"; + }; + + blsp1_i2c2_default: blsp1-i2c2-default { + sda { + pins = "GPIO_19"; + function = "blsp_i2c_sda_a2"; + }; + + scl { + pins = "GPIO_20"; + function = "blsp_i2c_scl_a2"; + }; + }; + + blsp1_i2c3_default: blsp1-i2c3-default { + pins = "GPIO_84", "GPIO_85"; + function = "blsp_i2c3"; + }; + + blsp1_i2c4_default: blsp1-i2c4-default { + pins = "GPIO_117", "GPIO_118"; + function = "blsp_i2c4"; + }; + ethernet_defaults: ethernet-defaults { int { pins = "GPIO_61"; @@ -105,6 +142,66 @@ }; }; + blsp1_i2c0: i2c@78b5000 { + compatible = "qcom,i2c-qup-v2.2.1"; + reg = <0x078b5000 0x600>; + clocks = <&gcc GCC_BLSP1_AHB_CLK>, + <&gcc GCC_BLSP1_QUP0_I2C_APPS_CLK>; + clock-names = "iface", "core"; + pinctrl-names = "default"; + pinctrl-0 = <&blsp1_i2c0_default>; + #address-cells = <1>; + #size-cells = <0>; + }; + + blsp1_i2c1: i2c@78b6000 { + compatible = "qcom,i2c-qup-v2.2.1"; + reg = <0x078b6000 0x600>; + clocks = <&gcc GCC_BLSP1_AHB_CLK>, + <&gcc GCC_BLSP1_QUP1_I2C_APPS_CLK>; + clock-names = "iface", "core"; + pinctrl-names = "default"; + pinctrl-0 = <&blsp1_i2c1_default>; + #address-cells = <1>; + #size-cells = <0>; + }; + + blsp1_i2c2: i2c@78b7000 { + compatible = "qcom,i2c-qup-v2.2.1"; + reg = <0x078b7000 0x600>; + clocks = <&gcc GCC_BLSP1_AHB_CLK>, + <&gcc GCC_BLSP1_QUP2_I2C_APPS_CLK>; + clock-names = "iface", "core"; + pinctrl-names = "default"; + pinctrl-0 = <&blsp1_i2c2_default>; + #address-cells = <1>; + #size-cells = <0>; + }; + + blsp1_i2c3: i2c@78b8000 { + compatible = "qcom,i2c-qup-v2.2.1"; + reg = <0x078b8000 0x600>; + clocks = <&gcc GCC_BLSP1_AHB_CLK>, + <&gcc GCC_BLSP1_QUP3_I2C_APPS_CLK>; + clock-names = "iface", "core"; + pinctrl-names = "default"; + pinctrl-0 = <&blsp1_i2c3_default>; + #address-cells = <1>; + #size-cells = <0>; + }; + + blsp1_i2c4: i2c@78b9000 { + compatible = "qcom,i2c-qup-v2.2.1"; + reg = <0x078b9000 0x600>; + clocks = <&gcc GCC_BLSP1_AHB_CLK>, + <&gcc GCC_BLSP1_QUP4_I2C_APPS_CLK>; + clock-names = "iface", "core"; + pinctrl-names = "default"; + pinctrl-0 = <&blsp1_i2c4_default>; + #address-cells = <1>; + #size-cells = <0>; + }; + gcc: clock-controller@1800000 { compatible = "qcom,gcc-qcs404"; reg = <0x1800000 0x80000>;