From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BEC8C48BD1 for ; Fri, 11 Jun 2021 02:38:20 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C3DF261364 for ; Fri, 11 Jun 2021 02:38:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C3DF261364 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C69F482F3D; Fri, 11 Jun 2021 04:37:37 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com 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=gmail.com header.i=@gmail.com header.b="FoVMVI4p"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CF4A282ECD; Fri, 11 Jun 2021 04:37:30 +0200 (CEST) Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) (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 3DF1B82F27 for ; Fri, 11 Jun 2021 04:37:26 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=twoerner@gmail.com Received: by mail-qt1-x836.google.com with SMTP id e3so1584919qte.0 for ; Thu, 10 Jun 2021 19:37:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=aCFyRQHQ1bwM5k1dbot81y+QdhbRUOSHGKW4VZ8Y6x4=; b=FoVMVI4ppfuK/YElDDsA4/MJAaR1KUx4JSEPonBpOD9/47neASOEIm1h+HE/99a3eh YT7abpplKEHfrnNgxaOqwemLrnpWZ821uhap9Zfv2KVLf/8/l7BGaTqvOGXvkJ1nHNiP J6IV1rQvv/nx64RWxrHv96x/IDZTNLvAEhvdbPTDpLbgJonY2PQ/2IIyKjxJew/PfPs5 bekkF1wuxPOVSvGAXNCA9Ha+KiliM/IlP9VRJ1HV0IyF/tswozBg025KKzmVK37/Sg73 ywR6YFSMxMZzZXP7MnAZY8Ti3n/g6rEPZQOBBuSPzkJIkvxZXFvGvsRrYYd2TOWjf/WB 7DDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aCFyRQHQ1bwM5k1dbot81y+QdhbRUOSHGKW4VZ8Y6x4=; b=eGMXh+iXiWZu5bOM5QJQsmhaQWepafSobDFRbIWCyiHQumt3DUFK7Dli4gYN0/C65K vlV9xr9/69Sj4ehrguLPCoXuKdLSAT8ROPPpR6vLjieVV9eGpKC1+PVWNeH3oYm7uT21 czAQKXfYHTfoqiBErmCe7763uE+Zrd5FstdHcsXSCMQ5/Z1b1AvVeIkxHOQKOOoTLh6i 7aR2FwjBF9FoY/5cXA6HIhVym34M9j1q/+YrupQmEzm71p4+cN4wC/CGuskadR4oKMq2 ry+APG3QuFX8Zw+2prCWWI2x1lfV5Lx0BwirwSau7os2OPYX67LG1/cmIbBS6trxDg/1 lqAw== X-Gm-Message-State: AOAM533HDbOeXgU/hZV1Yr/z8ulAIgdl8uOi3YkE5PzpF28Pn06lIbaU 1MTl2TQj0rMs5KJEZWDUktyrBDhx+7Xd7w== X-Google-Smtp-Source: ABdhPJyT3eGRmlL8hfbvnnAgNAgsMf1I8WN9mZkJii88q50GgKYprqv+Vh7ELc6sr1SAbged2O/KtQ== X-Received: by 2002:ac8:45c2:: with SMTP id e2mr1878975qto.331.1623379044839; Thu, 10 Jun 2021 19:37:24 -0700 (PDT) Received: from localhost.localdomain (pppoe-209-91-167-254.vianet.ca. [209.91.167.254]) by smtp.gmail.com with ESMTPSA id m189sm3602444qkd.107.2021.06.10.19.37.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Jun 2021 19:37:24 -0700 (PDT) From: Trevor Woerner To: U-Boot Mailing List Subject: [PATCH v2 8/8] lpc32xx: ea-lpc3250devkitv2: enable i2c (DM) Date: Thu, 10 Jun 2021 22:37:09 -0400 Message-Id: <20210611023710.35203-8-twoerner@gmail.com> X-Mailer: git-send-email 2.30.0.rc0 In-Reply-To: <20210611023710.35203-1-twoerner@gmail.com> References: <20210611023710.35203-1-twoerner@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.4 at phobos.denx.de X-Virus-Status: Clean Enable a DMed i2c driver for the ea-lpc3250devkitv2 board. Include some sample commands/output for testing. Signed-off-by: Trevor Woerner --- Changes in v2: - added board/ea/ea-lpc3250devkitv2/README.rst | 54 +++++++++++++++++++ .../ea-lpc3250devkitv2/ea-lpc3250devkitv2.c | 4 ++ configs/ea-lpc3250devkitv2_defconfig | 3 ++ 3 files changed, 61 insertions(+) diff --git a/board/ea/ea-lpc3250devkitv2/README.rst b/board/ea/ea-lpc3250devkitv2/README.rst index 56b5d0dbb1..1b78000331 100644 --- a/board/ea/ea-lpc3250devkitv2/README.rst +++ b/board/ea/ea-lpc3250devkitv2/README.rst @@ -4,6 +4,7 @@ ToC: - Introduction - Booting - Debugging +- i2c Introduction @@ -130,3 +131,56 @@ dongle from Olimex successfully as follows: # openocd \ -f interface/ftdi/olimex-arm-usb-ocd-h.cfg \ -f board/phytec_lpc3250.cfg + + +i2c +=== +Some of the LEDs on the board are connected via an I/O Expander (PCA9532) that +is attached to the i2c1 bus. Here is a sample session of toggling some of +these LEDs via i2c in U-Boot: + +show the existing i2c busses: + EA-LPC3250v2=> i2c bus + Bus 0: i2c@300 + Bus 1: i2c@400a0000 + Bus 2: i2c@400a8000 + +set i2c1 as the current bus: + EA-LPC3250v2=> i2c dev 1 + Setting bus to 1 + +see what potential devices are found with rudimentary probing on i2c1: + EA-LPC3250v2=> i2c probe + Valid chip addresses: 1A 1D 48 50 57 60 66 6E + +According to the schematics the i2c slave address of the PCA9532 is 0x60. + +dump all of the 10 registers from the I/O Expander; NOTE that the 0x10 in the +command specifies the self-incrementing mode of the PCA9532; also NOTE that +the values repeat themseves to fill out a full 16 bytes: + EA-LPC3250v2=> i2c md 0x60 0x10 10 + 0010: 00 ff 00 80 00 80 00 00 00 00 4f ff 00 80 00 80 ..........O..... + +turn on LEDs 23, 25, 27, and 29 (green): + EA-LPC3250v2=> i2c mw 0x60 9 0x55 + +turn on LEDs 22, 24, 26, and 28 (red): + EA-LPC3250v2=> i2c mw 0x60 8 0x55 + +dim the green LEDs (23, 25, 27, 29): + EA-LPC3250v2=> i2c mw 0x60 3 0x20 + EA-LPC3250v2=> i2c mw 0x60 9 0xaa + +turn off all LEDs (23-29): + EA-LPC3250v2=> i2c mw 0x60 8 0 + EA-LPC3250v2=> i2c mw 0x60 9 0 + +read value of switches (input): + EA-LPC3250v2=> i2c md 0x60 0 1 + 0000: 4f O +[none are pressed] + +press and hold SW2 while running the following: + EA-LPC3250v2=> i2c md 0x60 0 1 + 0000: 4e N +[SW2 is pressed] diff --git a/board/ea/ea-lpc3250devkitv2/ea-lpc3250devkitv2.c b/board/ea/ea-lpc3250devkitv2/ea-lpc3250devkitv2.c index 7a19400041..72cf46c749 100644 --- a/board/ea/ea-lpc3250devkitv2/ea-lpc3250devkitv2.c +++ b/board/ea/ea-lpc3250devkitv2/ea-lpc3250devkitv2.c @@ -19,6 +19,10 @@ int board_early_init_f(void) { lpc32xx_uart_init(CONFIG_CONS_INDEX); + if (IS_ENABLED(CONFIG_SYS_I2C_LPC32XX)) { + lpc32xx_i2c_init(1); + lpc32xx_i2c_init(2); + } return 0; } diff --git a/configs/ea-lpc3250devkitv2_defconfig b/configs/ea-lpc3250devkitv2_defconfig index dc90e16475..e8d60b573e 100644 --- a/configs/ea-lpc3250devkitv2_defconfig +++ b/configs/ea-lpc3250devkitv2_defconfig @@ -14,9 +14,12 @@ CONFIG_DISTRO_DEFAULTS=y CONFIG_BOARD_EARLY_INIT_F=y CONFIG_SYS_PROMPT="EA-LPC3250v2=> " CONFIG_CMD_GPIO=y +CONFIG_CMD_I2C=y CONFIG_OF_CONTROL=y # CONFIG_NET is not set CONFIG_LPC32XX_GPIO=y +CONFIG_DM_I2C=y +CONFIG_SYS_I2C_LPC32XX=y CONFIG_SPECIFY_CONSOLE_INDEX=y CONFIG_CONS_INDEX=5 CONFIG_SYS_NS16550=y -- 2.30.0.rc0