Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp329201pxu; Wed, 14 Oct 2020 02:24:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwu+KMbbMOOFX5UZhtdK3u2Qx/geGR+ZXKoIj/Dc8NKn48mTwETCBrkG1qjbrYlUnJxehjg X-Received: by 2002:a05:6402:602:: with SMTP id n2mr4151707edv.327.1602667479427; Wed, 14 Oct 2020 02:24:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602667479; cv=none; d=google.com; s=arc-20160816; b=m4z+G9wsZbPABGou7YLKeAIYKWFJmCyezTidquu/BPrGTVU0wlMoFn2zNXfhUpjeI1 SMR4PDEYMp/H9TikXoHxcTYWvKm6i59+ZpfYYfQQyEfXrLHksHsla+bXJI97ZG/D2gDy wkCctEFF/3iJd7vxf1v+7CkAC08glahpfpb3K3YMwG6tNOPbcsYUahQYULLhhH9AMEKc Qdg1WMMQ6azOdoUJissGnlbVAv/KXQScgSdc8mwmChNsUbJdUed2V0wtCUv+2yYsSSs6 Gh1cEsWF+tePqgVEd7U8+Lr2/O2ojB65mPmw3+iMhqEF5aDHgbHb2Omm5UW6vekYzI2Z i9Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:user-agent:date:message-id:cc:subject:from:to :dkim-signature; bh=w10ZuoPIwCwbhv8a3DX0b8jne0U2O/g6VGYCUIOnuOY=; b=nUFWF6WHWUYyVq/a9Zr/NnSZhIwwsP/CPUVn/qrrOYzm7ihkAh4re7Ho1zbeybWWXL urHoKivILhmQYJr/wGxxMmdxTrZJ2LYNNECHf/3kCJEH44JcOqoInoVjm4NxlvwnNf9U SROQ7EVYMN8cimH3at7exAQ00iPIgak+x+AzLQtys5Kj2Tl6wNwAa6YBrbOVFSHG3iNJ OFv/SqFOd3Xc4QTNy4xbjlQB6ofZJQ/KPGCoMpCf48HbM5Z6+lq1t/v7PTLjn177XZQO S2zRKbw+d6xYoVkEfWFGxE5gD9zqB3QY8JDFi8ooNOd9N5duRscDqWPbUp/sRLP5ooYG xjsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=TSlPJwqp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p17si1825315edx.292.2020.10.14.02.24.16; Wed, 14 Oct 2020 02:24:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=TSlPJwqp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731004AbgJNJVg (ORCPT + 99 others); Wed, 14 Oct 2020 05:21:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730999AbgJNJUk (ORCPT ); Wed, 14 Oct 2020 05:20:40 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAB2AC061787 for ; Tue, 13 Oct 2020 14:34:35 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id u21so1888538eja.2 for ; Tue, 13 Oct 2020 14:34:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=to:from:subject:cc:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=w10ZuoPIwCwbhv8a3DX0b8jne0U2O/g6VGYCUIOnuOY=; b=TSlPJwqpWYteMMobIirFJw6tjLSWYd+9weNNzZoSps+6TK28+53PrZDS/37/C3HeTC /t9Jf6XK3lZoDAtqNjbqY0sXTk69I1ndPvW7l/Aftvk6YeD758tOGMWA1yJQZODferrt AF7FndMJvuhYdqoZWn7iCIMqHAmeZ23i57jkU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:cc:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=w10ZuoPIwCwbhv8a3DX0b8jne0U2O/g6VGYCUIOnuOY=; b=MceVOQq1E6jYGq7pVN04KpVzFQBI+2xPnLevThf6PejN1OBHjPDp0VG+whgqUknJdY ZPJrgDYdgjdaU69nbxS242kTXJ9gCA1KysOEIdokBR1TaHa00qgA09UsxGBuG49fS7qR mC72/nk9Ko2oDIBPvqLVruINhoX3+t2yVOwMZYqJ/otBGi00/x+iQ2Xd2/Z9A95Z6vEZ EdqDHngzdFIryjvGwnU21C0ClromznZ199XpzWpPorHVROVNJ+qlF85T02q0tE0wug8o eHRhoHZVh0S0Ewy1S4rKhKjxERpxkCQEFFTJ70+TbNZ6PuVh1qhwJmS9QfaQajaYrMoS 38qg== X-Gm-Message-State: AOAM530WVZEIT3frTCrE+Qwlc/awE0pDm/acnHNS5WPTkDUcc2XZ9fOb XFJIaxGeOwH0dfMqh1pY1VYOsZ5grtWDCNdt5wM= X-Received: by 2002:a17:906:b04e:: with SMTP id bj14mr1996325ejb.254.1602624874233; Tue, 13 Oct 2020 14:34:34 -0700 (PDT) Received: from [192.168.1.149] (5.186.115.188.cgn.fibianet.dk. [5.186.115.188]) by smtp.gmail.com with ESMTPSA id ss7sm565707ejb.28.2020.10.13.14.34.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Oct 2020 14:34:33 -0700 (PDT) To: Peter Rosin From: Rasmus Villemoes Subject: using one gpio for multiple dht22 sensors Cc: LKML Message-ID: <91c25030-d5d1-e3e7-2d26-ac631dddc756@rasmusvillemoes.dk> Date: Tue, 13 Oct 2020 23:34:31 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Peter Since you're the author of io-channel-mux.txt, gpio-mux.txt and mux-controller.txt, I hope you don't mind me asking some perhaps silly questions. I'm going to hook up a bunch of dht22 humidity (and temperature) sensors [1] (drivers/iio/humidity/dht11.c), but partly due to limited number of available gpios, I'm also going to use a 74hc4051 multiplexer [2], so that all the dht22's actually sit on the same gpio. It's pretty obvious how the multiplexer is to be described in device-tree (I'm probably going to send a patch to add support for an optional "enable-gpio", as on the 74hc4051, so that MUX_IDLE_DISCONNECT gets supported). It also seems like io-channel-mux should somehow magically apply to all kinds of iio devices, but it can't be that simple. And if it is, I can't figure out how to write the DT. So: - do I need to teach the dht11.c driver to be mux-aware? - currently, a dht11/dht22 shows up in sysfs with just two files, in_humidityrelative_input and in_temp_input. Now, should I end up with one device and, say, 2*8 files (so that it seems like one sensor with eight input channels), or should it show up as eight different devices? If the latter, I guess the device tree would end up with the same "gpios = " spec for all eight - is that even allowed? If you can show how the DT is supposed to describe this situation, I'll try to fill out the missing pieces on the driver side. [I could also just not describe the multiplexer at all and control everything about it by toggling gpios from userspace, and just have a single dht22 in DT, but I prefer doing this "the right way" if it's feasible.] Thanks, Rasmus Just FTR: [1] https://www.electroschematics.com/wp-content/uploads/2015/02/DHT22-datasheet.pdf [2] https://assets.nexperia.com/documents/data-sheet/74HC_HCT4051.pdf