From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tony Lindgren Subject: Re: [PATCH] pinctrl: single: support GPIO for bits pinctrl Date: Mon, 6 Jul 2015 03:40:00 -0700 Message-ID: <20150706103959.GD10644@atomide.com> References: <1434506172-4401-1-git-send-email-jun.nie@linaro.org> <20150617071740.GL2712@atomide.com> <20150623101415.GV20628@atomide.com> <20150706090321.GC10644@atomide.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from muru.com ([72.249.23.125]:33223 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753784AbbGFKkE (ORCPT ); Mon, 6 Jul 2015 06:40:04 -0400 Content-Disposition: inline In-Reply-To: Sender: linux-gpio-owner@vger.kernel.org List-Id: linux-gpio@vger.kernel.org To: Jun Nie Cc: Haojian Zhuang , Linus Walleij , linux-gpio@vger.kernel.org, Shawn Guo , "wan.zhijun" , Jason Liu * Jun Nie [150706 02:21]: > 2015-07-06 17:03 GMT+08:00 Tony Lindgren : > > * Jun Nie [150706 01:43]: > >> 2015-06-23 18:18 GMT+08:00 Jun Nie : > >> > 2015-06-23 18:14 GMT+08:00 Tony Lindgren : > >> >> * Jun Nie [150623 02:56]: > >> >>> 2015-06-17 15:17 GMT+08:00 Tony Lindgren : > >> >>> > * Jun Nie [150616 18:58]: > >> >>> >> + if (pcs->bits_per_mux) { > >> >>> >> + int pin_pos, byte_num, num_pins_in_register; > >> >>> >> + > >> >>> >> + num_pins_in_register = pcs->width / pcs->bits_per_pin; > >> >>> >> + byte_num = (pcs->bits_per_pin * pin) / BITS_PER_BYTE; > >> >>> >> + offset = (byte_num / mux_bytes) * mux_bytes; > >> >>> >> + pin_pos = pin % num_pins_in_register; > >> >>> >> + pin_pos *= pcs->bits_per_pin; > >> >>> >> + data = pcs->read(pcs->base + offset) & > >> >>> >> + ~(pcs->fmask << pin_pos); > >> >>> > > >> >>> > Should you check the pcs->fmask here too in case some bits are reserved? > >> >>> > > >> >>> Did not catch your idea? Those bits set in fmask are dedicated for one > >> >>> pin mux control and should be clear before set as desired value per my > >> >>> understanding. Do you mean some bits may be reserved and not for any > >> >>> function? > >> >> > >> >> Right, can you please check that we don't try to write to reserved > >> >> bits in the hardawre if the mask is set? > >> > >> > Then I have question that how can I know what bits is for function > >> > mask, what bits are for reserved? Do we have any other value to > >> > indicate it? I did not find it in one register for one pin mux case. > >> > >> Could you help elaborate this? Thanks! > > > > We can only write to the bits specified in pinctrl-single,function-mask. > > > I see, you want below mask to make sure gpiofunc value does not exceed > expected bits though it should be safe if dts data is correct. Right? > + data = pcs->read(pcs->base + offset) & > + ~(pcs->fmask << pin_pos); > + data |= (pcs->fmask & frange->gpiofunc) << pin_pos; Yes please :) Tony