From patchwork Sun Feb 16 17:21:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Noralf_Tr=C3=B8nnes?= X-Patchwork-Id: 11384497 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1E44518E8 for ; Sun, 16 Feb 2020 17:27:17 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 06EC320857 for ; Sun, 16 Feb 2020 17:27:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 06EC320857 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=tronnes.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 596CA6E456; Sun, 16 Feb 2020 17:27:04 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from asav22.altibox.net (asav22.altibox.net [109.247.116.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id BC9E26E452 for ; Sun, 16 Feb 2020 17:27:02 +0000 (UTC) Received: from localhost.localdomain (unknown [81.166.168.211]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: noralf.tronnes@ebnett.no) by asav22.altibox.net (Postfix) with ESMTPSA id 43359200E1; Sun, 16 Feb 2020 18:21:38 +0100 (CET) From: =?utf-8?q?Noralf_Tr=C3=B8nnes?= To: broonie@kernel.org, balbi@kernel.org, lee.jones@linaro.org Subject: [RFC 0/9] Regmap over USB for Multifunction USB Device (gpio, display, ...) Date: Sun, 16 Feb 2020 18:21:08 +0100 Message-Id: <20200216172117.49832-1-noralf@tronnes.org> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 X-CMAE-Score: 0 X-CMAE-Analysis: v=2.3 cv=ZvHD1ezG c=1 sm=1 tr=0 a=OYZzhG0JTxDrWp/F2OJbnw==:117 a=OYZzhG0JTxDrWp/F2OJbnw==:17 a=IkcTkHD0fZMA:10 a=M51BFTxLslgA:10 a=0GFqvFEQP_9VLyYywQIA:9 a=QEXdDO2ut3YA:10 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-usb@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Hi, A while back I had the idea to turn a Raspberry Pi Zero into a $5 USB to HDMI/SDTV/DSI/DPI display adapter. Thinking about how to represent the display to the driver I realised that hardware use registers as API. And Linux does have a generic register abstraction: regmap. Furthermore this means that if I can do a regmap over USB implementation, it will be easy to do other functions like gpio, adc and others. After a few iterations trying to understand the USB subsystem and satisfying driver requirements, I now have something that looks promising. I'm sending out an early version hoping to get feedback especially on the core parts that handles regmap and interrupts. Overview: USB Host : USB Device : -------------- : ------------------ ---------- | mfd: mud | : | f_mud | ---------- | Driver | -------------- : | | | Driver | ---------- | regmap-usb | : | (mud_regmap) | ---------- -------------- : ------------------ I've attached 2 drivers: - gpio/pinctrl: is more or less finished - display: needs a lot more work USB3 device I've only tested this with usb2 devices (Pi, BBB) so I should get myself a usb3 gadget capable board. My searching didn't turn up much, so this seems to be quite rare. ROCK960 has USB 3.0 type C OTG but the price is $139 which is a bit expensive for this hobby project. Does anyone know of a cheap board? Noralf. Noralf Trønnes (9): regmap: Add USB support mfd: Add driver for Multifunction USB Device usb: gadget: function: Add Multifunction USB Device support pinctrl: Add Multifunction USB Device pinctrl driver usb: gadget: function: mud: Add gpio support regmap: Speed up _regmap_raw_write_impl() for large buffers drm: Add Multifunction USB Device display driver drm/client: Add drm_client_init_from_id() and drm_client_modeset_set() usb: gadget: function: mud: Add display support drivers/base/regmap/Kconfig | 8 +- drivers/base/regmap/Makefile | 1 + drivers/base/regmap/regmap-usb.c | 1026 ++++++++++++++++++ drivers/base/regmap/regmap.c | 10 +- drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/drm_client.c | 37 + drivers/gpu/drm/drm_client_modeset.c | 52 + drivers/gpu/drm/mud/Kconfig | 18 + drivers/gpu/drm/mud/Makefile | 4 + drivers/gpu/drm/mud/mud_drm.c | 1198 ++++++++++++++++++++++ drivers/gpu/drm/mud/mud_drm.h | 137 +++ drivers/gpu/drm/mud/mud_drm_gadget.c | 889 ++++++++++++++++ drivers/mfd/Kconfig | 8 + drivers/mfd/Makefile | 1 + drivers/mfd/mud.c | 580 +++++++++++ drivers/pinctrl/Kconfig | 9 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-mud.c | 657 ++++++++++++ drivers/pinctrl/pinctrl-mud.h | 89 ++ drivers/usb/gadget/Kconfig | 36 + drivers/usb/gadget/function/Makefile | 6 + drivers/usb/gadget/function/f_mud.c | 913 +++++++++++++++++ drivers/usb/gadget/function/f_mud.h | 210 ++++ drivers/usb/gadget/function/f_mud_drm.c | 181 ++++ drivers/usb/gadget/function/f_mud_pins.c | 962 +++++++++++++++++ drivers/usb/gadget/function/mud_regmap.c | 936 +++++++++++++++++ include/drm/drm_client.h | 4 + include/linux/mfd/mud.h | 16 + include/linux/regmap.h | 23 + include/linux/regmap_usb.h | 97 ++ 31 files changed, 8107 insertions(+), 5 deletions(-) create mode 100644 drivers/base/regmap/regmap-usb.c create mode 100644 drivers/gpu/drm/mud/Kconfig create mode 100644 drivers/gpu/drm/mud/Makefile create mode 100644 drivers/gpu/drm/mud/mud_drm.c create mode 100644 drivers/gpu/drm/mud/mud_drm.h create mode 100644 drivers/gpu/drm/mud/mud_drm_gadget.c create mode 100644 drivers/mfd/mud.c create mode 100644 drivers/pinctrl/pinctrl-mud.c create mode 100644 drivers/pinctrl/pinctrl-mud.h create mode 100644 drivers/usb/gadget/function/f_mud.c create mode 100644 drivers/usb/gadget/function/f_mud.h create mode 100644 drivers/usb/gadget/function/f_mud_drm.c create mode 100644 drivers/usb/gadget/function/f_mud_pins.c create mode 100644 drivers/usb/gadget/function/mud_regmap.c create mode 100644 include/linux/mfd/mud.h create mode 100644 include/linux/regmap_usb.h