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=-6.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no 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 BE2AEC433B4 for ; Wed, 21 Apr 2021 14:52:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 928BD613B6 for ; Wed, 21 Apr 2021 14:52:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243688AbhDUOwr (ORCPT ); Wed, 21 Apr 2021 10:52:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:37882 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240369AbhDUOwm (ORCPT ); Wed, 21 Apr 2021 10:52:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8881D613B6; Wed, 21 Apr 2021 14:52:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619016729; bh=KV+Ho0UxpPWM/DJ7vXp8Ca8eQ9iHjx1m52Pvj4SRTTk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nHvRdsmx9g3QMyv663N5BwhMOXbVYkurwTlbFgvVKKB9UT2X4//bbT0RhohT21j74 MVHo3ZXyl+CkWhY7Mv+iQEljzUJmYGD3WHYiksDdPXswTJQ9F1ZlGYOeSU+StZ7Fk4 1SyyrulMrr9revyUAR0g/A/P6S6x2Wrjdaj0qoPkIQ2rbHATxsboa6aNNutMXKq3Cu i592eaH5knlXyk+uRET3/amSRoUpLlO2sd2gBKxNRDeDxCTUTQs1f5yvQglmffePo8 wgHlMWhRPTwAhMtBQxoL1uINWC/9jI5FF1izA2NnudpoL4pbkRIMbaXgVOHw18wnrc d32ps7+hnPNtQ== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1lZED6-00036M-UM; Wed, 21 Apr 2021 16:52:13 +0200 Date: Wed, 21 Apr 2021 16:52:12 +0200 From: Johan Hovold To: Pho Tran Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Hung.Nguyen@silabs.com, Tung.Pham@silabs.com, Pho Tran Subject: Re: [PATCH v9] USB: serial: cp210x: Add support for GPIOs on CP2108 Message-ID: References: <20210408103607.2077-1-photranvan0712@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210408103607.2077-1-photranvan0712@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org On Thu, Apr 08, 2021 at 05:36:07PM +0700, Pho Tran wrote: > From: Pho Tran > > Similar to other CP210x devices, GPIO interfaces (gpiochip) should be > supported for CP2108. > +/* > + * Quad Port Config definitions > + * Refer to https://www.silabs.com/documents/public/application-notes/an978-cp210x-usb-to-uart-api-specification.pdf > + * for more information. > + * CP210X_VENDOR_SPECIFIC, CP210X_GET_PORTCONFIG call reads these 0x49 bytes > + * on a CP2108 chip. > + * CP2108 Quad Port State structure(used in Quad Port Config structure) > + */ > +struct cp210x_quad_port_state { > + __le16 gpio_mode_PB0; > + __le16 gpio_mode_PB1; > + __le16 gpio_mode_PB2; > + __le16 gpio_mode_PB3; > + __le16 gpio_mode_PB4; > + > + > + __le16 gpio_lowpower_PB0; > + __le16 gpio_lowpower_PB1; > + __le16 gpio_lowpower_PB2; > + __le16 gpio_lowpower_PB3; > + __le16 gpio_lowpower_PB4; > + > + __le16 gpio_latch_PB0; > + __le16 gpio_latch_PB1; > + __le16 gpio_latch_PB2; > + __le16 gpio_latch_PB3; > + __le16 gpio_latch_PB4; > +}; > + > +// Cp2108 Quad Port Config structure > +struct cp210x_quad_port_config { > + struct cp210x_quad_port_state reset_state; > + struct cp210x_quad_port_state suspend_state; > + u8 ipdelay_IFC[4]; > + u8 enhancedfxn_IFC[4]; > + u8 enhancedfxn_device; > + u8 extclkfreq[4]; > +} __packed; One more thing; I noticed that the layout of the other port-config structures do not match the ones used by your library API, which is what the above pdf documents (e.g. they have additional padding). Did you verify that the above layout is actually correct? And did you try changing the pin functions in EEPROM and make sure that your code handles it as expected? Is there any corresponding document for the actual device protocol? Johan