From patchwork Sat Jun 9 14:02:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10455945 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C038B6053F for ; Sat, 9 Jun 2018 14:04:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AEE78223A6 for ; Sat, 9 Jun 2018 14:04:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A2F42223B2; Sat, 9 Jun 2018 14:04:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1DDD0223A7 for ; Sat, 9 Jun 2018 14:04:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=JKtaqZd5T7ef9jJxXtzbNQGXBgsPnrqi0gXmHOTEp+A=; b=L3dxUIMJ/V6Wlao0TosSv3YIaX F5Vih6RkfhtUoZlhcItZFmNVORVOL/UTrUuBUJOU+IX4DOH3ur6pYpyO5epR3Cjd0Cx6uoLGqc1b+ CvR+WN9/0GjusMVP/MZSeWBHN9XeNkaI5o8He6uT8SDMRaWEUGsY5PcQQb4Vvudi0SCrTzj9Dk30k a/0ov6uf3H9B6Htk0pcAT85wJsuVXRr9GuGMhP0hSEsyobogFnSlYHZ2DPgmc9kEPrBdmvoNwflsv /6ufDqXhuq6kJcOH6vvaHILw2jphd9Fo7TwmxDXVQHxE6kyViQO3UnrLF39zefLoXrWYHZOhJfatD DJ/BADnQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fReTq-0008NC-4i; Sat, 09 Jun 2018 14:04:34 +0000 Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fReSQ-0007J2-QL for linux-arm-kernel@lists.infradead.org; Sat, 09 Jun 2018 14:03:21 +0000 Received: by mail-lf0-x243.google.com with SMTP id o9-v6so24194763lfk.1 for ; Sat, 09 Jun 2018 07:02:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vK4z529eQgjlfX/v4pgs6FSNrghjntEr72J0iDzPGms=; b=FhnWWQnGoqq/Cf4wJR+SslOmv4vfdb/Y6LgwUHIEzrH+YaObjcON2IgAHikCO6ChTQ lAWh1G+TcYjw2Xh0h7KX6pBesQVLcrBB1Z/80uOaX1d8YNuA4HKLClZt10enlVBvZbQU DatZtdJ7KaZr434BQOn8CWt3Y3XpYIHxOSATCmHx3WmpSNhgAgEG8QjZB/jPdLaMx1Nu WfgIaKRK5f5QjCngt39l+sea5FxA/F32gSKZUdtlgKPTx1SL/F71t6KjwQQUMYZF1Iu9 +r4ycodTfRPVlpxDZsPej8MRZBpyjJx63a5qIW8uUl9lbLdBBK5PsEL4zy/U9Uxm6rL/ RdoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vK4z529eQgjlfX/v4pgs6FSNrghjntEr72J0iDzPGms=; b=nyI4WN7TCk3V7Pudw7pVEpjYhvPH7eBgkF2pFhUQZ61iceg0YqOcxDyUdkMRe2zWp/ +7rPlAhpfTQpuY1jN93pkJpTcIuROFdql01ie4MfD5Xou8rWKBrGcz1pi7U+PGml85AM hgDywi/BWRFHq2z3ZHxPYYFLIK8J/z8CKvqh5M/LSMwq8zbSRHi+6pS6dMo2hGHmcDo/ oLoM9x2u1ueAP7UOK2DuHKjKpvqPJ7IMjnfJuQsMCsKxqY1mIP8lxT8r15k60A9qjwgJ 9caUrzvO+QXE4Kp53FxpCFlW8Op6Bkbf2akhMIpB/ya1dPC0b7VXRljXroEti2KBI7ad g6Zw== X-Gm-Message-State: APt69E30ylUfH6dOvjoAxZ2WEUV+bLVGbWSdZbgQ3ngn+/KlW1PblRtf aYTRkGBnk8Jdvhun3Q0JgtA= X-Google-Smtp-Source: ADUXVKLqyvyfQ3kXRdQP3O3KmnifeFYN87VRiPmKwyRLdOQ3FDj+Pqxb7NLwFTNZdP0byATnaiF6hA== X-Received: by 2002:a2e:29cf:: with SMTP id p76-v6mr7624565ljp.12.1528552974782; Sat, 09 Jun 2018 07:02:54 -0700 (PDT) Received: from localhost.localdomain (apn-31-0-40-98.dynamic.gprs.plus.pl. [31.0.40.98]) by smtp.gmail.com with ESMTPSA id n84-v6sm4477727lfi.19.2018.06.09.07.02.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 09 Jun 2018 07:02:54 -0700 (PDT) From: Janusz Krzysztofik To: Dmitry Torokhov , Tony Lindgren , Aaro Koskinen Subject: [PATCH 04/10] Input: ams_delta_serio: Replace power GPIO with regulator Date: Sat, 9 Jun 2018 16:02:18 +0200 Message-Id: <20180609140224.32606-4-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180609140224.32606-1-jmkrzyszt@gmail.com> References: <20180609140224.32606-1-jmkrzyszt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180609_070306_870408_88308907 X-CRM114-Status: GOOD ( 20.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kroah-Hartman , Linus Walleij , Randy Dunlap , Janusz Krzysztofik , Liam Girdwood , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Mark Brown , linux-input@vger.kernel.org, Mauro Carvalho Chehab , Andrew Morton , linux-omap@vger.kernel.org, "David S . Miller" , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Modify the driver so it no longer requests and manipulates the "keybrd_pwr" GPIO pin but a "vcc" regulator supply instead. For this to work with Amstrad Delta, define a regulator over the "keybrd_pwr" GPIO pin with the "vcc" supply for ams-delta-serio device and register it from the board file. Both assign an absulute GPIO number to the soon depreciated .gpio member of the regulator config structure, and also build and register a GPIO lookup table so it is ready for use by the regulator driver as soon as its upcoming update is applied. Signed-off-by: Janusz Krzysztofik --- arch/arm/mach-omap1/board-ams-delta.c | 63 +++++++++++++++++++++++++++++++++-- drivers/input/serio/ams_delta_serio.c | 27 ++++++++++----- 2 files changed, 79 insertions(+), 11 deletions(-) diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c index 2119d2d3ba84..706eb2f9301d 100644 --- a/arch/arm/mach-omap1/board-ams-delta.c +++ b/arch/arm/mach-omap1/board-ams-delta.c @@ -509,6 +509,46 @@ static struct platform_device ams_delta_serio_device = { .id = PLATFORM_DEVID_NONE, }; +static struct regulator_consumer_supply keybrd_pwr_consumers[] = { + /* + * Initialize supply .dev_name with NULL. It will be replaced + * with serio dev_name() as soon as the serio device is registered. + */ + REGULATOR_SUPPLY("vcc", NULL), +}; + +static struct regulator_init_data keybrd_pwr_initdata = { + .constraints = { + .valid_ops_mask = REGULATOR_CHANGE_STATUS, + }, + .num_consumer_supplies = ARRAY_SIZE(keybrd_pwr_consumers), + .consumer_supplies = keybrd_pwr_consumers, +}; + +static struct fixed_voltage_config keybrd_pwr_config = { + .supply_name = "keybrd_pwr", + .microvolts = 5000000, + .gpio = AMS_DELTA_GPIO_PIN_KEYBRD_PWR, + .enable_high = 1, + .init_data = &keybrd_pwr_initdata, +}; + +static struct platform_device keybrd_pwr_device = { + .name = "reg-fixed-voltage", + .id = PLATFORM_DEVID_AUTO, + .dev = { + .platform_data = &keybrd_pwr_config, + }, +}; + +static struct gpiod_lookup_table keybrd_pwr_gpio_table = { + .table = { + GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_KEYBRD_PWR, NULL, + GPIO_ACTIVE_HIGH), + { }, + }, +}; + static struct platform_device *ams_delta_devices[] __initdata = { &latch1_gpio_device, &latch2_gpio_device, @@ -526,6 +566,7 @@ static struct platform_device *late_devices[] __initdata = { static struct gpiod_lookup_table *ams_delta_gpio_tables[] __initdata = { &ams_delta_audio_gpio_table, + &keybrd_pwr_gpio_table, }; static struct gpiod_lookup_table *late_gpio_tables[] __initdata = { @@ -566,12 +607,30 @@ static void __init ams_delta_init(void) platform_add_devices(ams_delta_devices, ARRAY_SIZE(ams_delta_devices)); /* - * As soon as devices have been registered, assign their dev_names - * to respective GPIO lookup tables before they are added. + * As soon as regulator consumers have been registered, assign their + * dev_names to consumer supply entries of respective regulators. + */ + keybrd_pwr_consumers[0].dev_name = + dev_name(&ams_delta_serio_device.dev); + + /* + * Once consumer supply entries are populated with dev_names, + * register regulator devices. At this stage only the keyboard + * power regulator has its consumer supply table fully populated. + */ + platform_device_register(&keybrd_pwr_device); + + /* + * As soon as GPIO consumers have been registered, assign + * their dev_names to respective GPIO lookup tables. */ ams_delta_audio_gpio_table.dev_id = dev_name(&ams_delta_audio_device.dev); + keybrd_pwr_gpio_table.dev_id = dev_name(&keybrd_pwr_device.dev); + /* + * Once GPIO lookup tables are populated with dev_names, register them. + */ gpiod_add_lookup_tables(ams_delta_gpio_tables, ARRAY_SIZE(ams_delta_gpio_tables)); diff --git a/drivers/input/serio/ams_delta_serio.c b/drivers/input/serio/ams_delta_serio.c index 551a4fa73fe4..d48beab1d00d 100644 --- a/drivers/input/serio/ams_delta_serio.c +++ b/drivers/input/serio/ams_delta_serio.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -39,6 +40,7 @@ MODULE_LICENSE("GPL"); struct ams_delta_serio { struct serio *serio; + struct regulator *vcc; }; static int check_data(struct serio *serio, int data) @@ -94,16 +96,18 @@ static irqreturn_t ams_delta_serio_interrupt(int irq, void *dev_id) static int ams_delta_serio_open(struct serio *serio) { - /* enable keyboard */ - gpio_set_value(AMS_DELTA_GPIO_PIN_KEYBRD_PWR, 1); + struct ams_delta_serio *priv = serio->port_data; - return 0; + /* enable keyboard */ + return regulator_enable(priv->vcc); } static void ams_delta_serio_close(struct serio *serio) { + struct ams_delta_serio *priv = serio->port_data; + /* disable keyboard */ - gpio_set_value(AMS_DELTA_GPIO_PIN_KEYBRD_PWR, 0); + regulator_disable(priv->vcc); } static const struct gpio ams_delta_gpios[] __initconst_or_module = { @@ -117,11 +121,6 @@ static const struct gpio ams_delta_gpios[] __initconst_or_module = { .flags = GPIOF_DIR_IN, .label = "serio-clock", }, - { - .gpio = AMS_DELTA_GPIO_PIN_KEYBRD_PWR, - .flags = GPIOF_OUT_INIT_LOW, - .label = "serio-power", - }, { .gpio = AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT, .flags = GPIOF_OUT_INIT_LOW, @@ -146,6 +145,16 @@ static int ams_delta_serio_init(struct platform_device *pdev) goto serio; } + priv->vcc = devm_regulator_get(&pdev->dev, "vcc"); + if (IS_ERR(priv->vcc)) { + err = PTR_ERR(priv->vcc); + dev_err(&pdev->dev, "regulator request failed (%d)\n", err); + /* Fail softly if the regulator is not available yet */ + if (err == -ENODEV) + err = -EPROBE_DEFER; + goto gpio; + } + err = request_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), ams_delta_serio_interrupt, IRQ_TYPE_EDGE_RISING, DRIVER_NAME, priv);